From patchwork Thu Oct 7 18:06:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 1537883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=D5Y8eyLM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HQK6C4fbnz9sR4 for ; Fri, 8 Oct 2021 05:07:15 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mYXnN-0004TW-Oe; Thu, 07 Oct 2021 18:07:05 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mYXnE-0004L4-Rb for kernel-team@lists.ubuntu.com; Thu, 07 Oct 2021 18:06:56 +0000 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9E68C3FFD9 for ; Thu, 7 Oct 2021 18:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1633630016; bh=m0MupuKP8vmWuVlBIdhoUAVrcI8g9/k7fq3zwmegdyY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=D5Y8eyLMQIRPSo8VE9ThI+50FSa9WSSDmEvuy3csNSEXHZmBNacp/2z5XRrIdXc9O g8C8zcM9xX50+eZvrOvXo7l7iFyqPp493eCoZQRbcOJA8PbvaP+Qifye0MeXb+k2LE XLeL1CcFw6qRCwmA3blWl0QLO+AVNYwpv4Jwgl7VNevEK7yx7hf7tO7E3UkpG3CuIA 5wo5QO5yenMru3SenxNFF1fypheIzn9MleUtRF/XwBhF1NxpnCEQc6wny4N0nzgP9W h+iGuFZWrvPHrrjJ+sdg4zly4dTltgmuzhho+OP/EfOoiy5R2xDmHWqgIR1/lfwkHQ aGFIacktLjkow== Received: by mail-qv1-f69.google.com with SMTP id x16-20020a0cfe10000000b003834102a98cso113267qvr.9 for ; Thu, 07 Oct 2021 11:06:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m0MupuKP8vmWuVlBIdhoUAVrcI8g9/k7fq3zwmegdyY=; b=nmtQdU9w78A2iElhgtErDy+CW2aMtI+Em/H7mosAw1HS4p064k+9dKr3iz7croeEB/ 6zxWOtesdLBizyr9ThxUr+FvCUP+I49bb+Bz0cUYpASGHWCsXlp83i+QmqIdtjz+fm4z MwhBdQ08UCdDn4IifyicDtPQD+rC47biHYVCsc9h+WFILbZD44vovRdAO92l0Lvh+Lm8 juy7fceBBmMidDSVjAXORLBNaZ4+1bXH6+IQMAm7BcFTqoxribK3q2GxskJMsULVaGmz /Mvw603ghpRKXM2fVBtQ/dI4Yhf8uvshe4nfKvCg6+A6DcdN9J6Yt/lqb1HAeoLHoqGp UbKg== X-Gm-Message-State: AOAM531eiHWM+5p6BM3IzxctCb2BWstV83LXRBqR7o63ZH7+3UGnu0wX z9I26jDJMoKnolCecvPxl3hQwDeSuH1pfug7Ggt8DOgciUE9/uB37NCvwX6e8pbNrf05urP/Duq 9pFxEOhTIp6hGs+k5NlOGLVC7Vu8Hyh7Herhthp8Mfg== X-Received: by 2002:a37:9b58:: with SMTP id d85mr2511378qke.239.1633630015649; Thu, 07 Oct 2021 11:06:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx330pih1kxDRpjorvBgJeNwtlbnR39a4mjk5CQpP3J+9aeomGxfCEmAKrrLOGRNPpsrapjXQ== X-Received: by 2002:a37:9b58:: with SMTP id d85mr2511361qke.239.1633630015403; Thu, 07 Oct 2021 11:06:55 -0700 (PDT) Received: from kbuntu2.fuzzbuzz.org (dhcp-24-53-240-12.cable.user.start.ca. [24.53.240.12]) by smtp.gmail.com with ESMTPSA id o22sm72382qkk.132.2021.10.07.11.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:06:55 -0700 (PDT) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [SRU][PATCH 05/13] swiotlb: clean up swiotlb_tbl_unmap_single Date: Thu, 7 Oct 2021 14:06:36 -0400 Message-Id: <20211007180644.9187-6-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211007180644.9187-1-khalid.elmously@canonical.com> References: <20211007180644.9187-1-khalid.elmously@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Christoph Hellwig BugLink: https://bugs.launchpad.net/bugs/1943902 Remove a layer of pointless indentation, replace a hard to follow ternary expression with a plain if/else. Signed-off-by: Christoph Hellwig Acked-by: Jianxiong Gao Tested-by: Jianxiong Gao Signed-off-by: Konrad Rzeszutek Wilk (cherry picked from commit ca10d0f8e530600ec63c603dbace2c30927d70b7) Signed-off-by: Khalid Elmously --- kernel/dma/swiotlb.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index b57e0741ce2f8..af22c3c5e488c 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -614,28 +614,29 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr, * with slots below and above the pool being returned. */ spin_lock_irqsave(&io_tlb_lock, flags); - { - count = ((index + nslots) < ALIGN(index + 1, IO_TLB_SEGSIZE) ? - io_tlb_list[index + nslots] : 0); - /* - * Step 1: return the slots to the free list, merging the - * slots with superceeding slots - */ - for (i = index + nslots - 1; i >= index; i--) { - io_tlb_list[i] = ++count; - io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; - } - /* - * Step 2: merge the returned slots with the preceding slots, - * if available (non zero) - */ - for (i = index - 1; - io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && - io_tlb_list[i]; i--) - io_tlb_list[i] = ++count; + if (index + nslots < ALIGN(index + 1, IO_TLB_SEGSIZE)) + count = io_tlb_list[index + nslots]; + else + count = 0; - io_tlb_used -= nslots; + /* + * Step 1: return the slots to the free list, merging the slots with + * superceeding slots + */ + for (i = index + nslots - 1; i >= index; i--) { + io_tlb_list[i] = ++count; + io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; } + + /* + * Step 2: merge the returned slots with the preceding slots, if + * available (non zero) + */ + for (i = index - 1; + io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && io_tlb_list[i]; + i--) + io_tlb_list[i] = ++count; + io_tlb_used -= nslots; spin_unlock_irqrestore(&io_tlb_lock, flags); }