From patchwork Wed Oct 13 06:50:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 1540243 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=gO4uwmqY; 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 4HTjpY6Ssyz9sR4 for ; Wed, 13 Oct 2021 17:50:29 +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 1maY5k-00066c-Pk; Wed, 13 Oct 2021 06:50:20 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1maY5i-000654-Db for kernel-team@lists.ubuntu.com; Wed, 13 Oct 2021 06:50:18 +0000 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (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-0.canonical.com (Postfix) with ESMTPS id 2D9EA40011 for ; Wed, 13 Oct 2021 06:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634107818; bh=hulVMMiQzyJvVQe/LCyknh1xzlkLDVjuWWk+Xn9piHw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=gO4uwmqY6ctJ65y4ljFBVICcYZhBmO8oOGf/Z5Nj0c9ZTXbG7KFsloEYlRaDgJBnu hkVmVMiXtyXte36wl/td4u+B9kIHk+g3MzIkt22S+zSUAua7JHFv/cV28sj+AGUPTf crlq4iqWxeZxY0/zY3jzJkk3OHvLOoPT8TvJzL7DSdS6VVcFXsshSPGKiXeUW0FoPQ vikumj2J3bprcYmrbautyphtLeDDVirVlEkpqtzqIrQn1VlXBizb+Ts4SYK7OVyiTS 5EwzfrYSAlk5xLJA8pZ7bAYxoIKOnblx7z15ScEM79pNmgW/6Nr4ZJydpEGUJ8DsHm TlNaUNuanJxWA== Received: by mail-qv1-f70.google.com with SMTP id ey7-20020a0562140b6700b00382cf3eb480so1703651qvb.22 for ; Tue, 12 Oct 2021 23:50:18 -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=hulVMMiQzyJvVQe/LCyknh1xzlkLDVjuWWk+Xn9piHw=; b=P52+HBFHQDVmUG1F8Wl5jW465w9/tYJ9Tb2kt5cnN1VePOcQkqcFaxo//6DNrzat+5 Yay3NkK6FGWwz3Bq15/Jllm4V2uyQ7qizZ15zxagnYBWa8v3qu1XlVA5Cq20a8FKybgT BuA4NlLSvp6WzV4FROMpNhYuwAvVwdAQiTjArDQjZdhyaiYqlL7Mfw9HUyZDwdPb6KAI 3eeBYPrUYYif3tr++wQWi1Obi4qsKnteco17Q2+kl/2Y9NJ9zAn01jZ+8qQr2ml1nX4p 7i0q5c7C5lGocy/7NcBHI8m/8Bb2lc1DjyHa2LRXoaSVWbA8r8lmugz8jgiqTjCi5fma 64oA== X-Gm-Message-State: AOAM530ar/wFyo5XluxB+0nwyesxVLHXmRb+Ezh5OW23g4caLrjJHiM2 dShC3xmwQs6cZR4IKx9PnvXlqOIi/xjo5mnrFCcjAJrVe58aASzlBz3lTGn/t+ZS5UWRBi0oDK8 uMDjdIyVORE6NAbxxXg0jVUyufyZQHHwFcY3eq+H60w== X-Received: by 2002:ac8:7044:: with SMTP id y4mr27014915qtm.64.1634107817311; Tue, 12 Oct 2021 23:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHbddyKU8mzMWQuQfxT+mza7LSe7dS/RFS9PU8fndepDatt/tN9TPbnRehLFmqWWRt2M69HA== X-Received: by 2002:ac8:7044:: with SMTP id y4mr27014902qtm.64.1634107817032; Tue, 12 Oct 2021 23:50:17 -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 t19sm5727298qtn.26.2021.10.12.23.50.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 23:50:16 -0700 (PDT) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [PATCH 06/13] swiotlb: clean up swiotlb_tbl_unmap_single Date: Wed, 13 Oct 2021 02:50:00 -0400 Message-Id: <20211013065007.1302-7-khalid.elmously@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211013065007.1302-1-khalid.elmously@canonical.com> References: <20211013065007.1302-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 c85540673cd39..64e87bc8011fd 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -611,28 +611,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); }