Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp494059pxy; Wed, 5 May 2021 07:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSsmUnsmphUOy0hN7zasH1QxlULI5HVysK0rmBexLKW+yUugAYhoA8s0MEacCeFcbTzR5U X-Received: by 2002:a05:6402:1a2f:: with SMTP id be15mr32493809edb.207.1620223930386; Wed, 05 May 2021 07:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620223930; cv=none; d=google.com; s=arc-20160816; b=ogYe5MTJOkLrn8gHHaTZ4BHSz0H45IXiCRNMTgPxQbQliiIwiRyxXrKE1hrEgomdvw QVcaOOUexRw3b8kpZFOHXoaBG7ZuJ0noZVIC+m3k7cQ4yE3azVkDYMo/ZdpA38weP32G euQuqWIXEvcYXlE4RRgmNoSxJ2sZ94eMg0czMIitkLsTENY2reuhZaCyNk73DvN85TbT tQdXw2GV8NUnHXl/07NhCdUFrD9jR7dhoqR0jJxITa8Jgoy30aPfeY0zAws1aUQQpxYt Ke5TV7CfPmPAZUEhMjNDG4FJ5FcXXeOlhmlJoykk4oz+AmiMIoMb8eDHbb7tvDmcHbnK +ztw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gtPtWuHMmQnLGooVMurVtBrNaFfvzrhwVrkFCBzygEM=; b=CQ3Fj913yzL0Oal2yHrXLjY+KtkceVc5pAkm05rZNHsqEOrDZ5m5Ut7pITA89bOwkX wcaPnwQUNz0ECTBelc3uqXj1QNbPysEL8t/2ZA98xRO/FTEUMkCkBr8hVG7Nn1TtIvye 67ZrD8H6mFxXBefwNHqxeMmuAiC5GkZVEFrQHk1wohdO9eDRlrgd+UThU+pvEOLH2KUA jWPxPGrl7wgIdGifQ+5pDwE6k7H0x3QyR/id/Vj++PMITinyKXKrbEKX8xCvDQC2YIPV sNxKexljK/fNJhAXsS1Cda9a6YNviFGaRjOlXzkjuE4YeCFPZXVuKH9h9KC+akr4yVEI bXrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UmBbQzff; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 27si13241509edv.475.2021.05.05.07.11.44; Wed, 05 May 2021 07:12:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UmBbQzff; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233378AbhEEMMh (ORCPT + 99 others); Wed, 5 May 2021 08:12:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:50458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233428AbhEEMJ4 (ORCPT ); Wed, 5 May 2021 08:09:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CF33613BC; Wed, 5 May 2021 12:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620216531; bh=/IQ/5OEyL3PjjzovRqk0SJYBgEim+SVXg8628Sjss3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UmBbQzff91HAfBV3IOFdeB6jxqVw4gAvGMxEsXGnR+yIYwwc5MzF0VQeEzjMmZe/x UKRlrW7ezoJg+UzUPjFz4ItWAeys7dI87cwJPXhiuymP65bPCYQm2kpm/BWV6BzE9f 3cxLw+oJCKSvUqFqOdBrL/3A6W8dC/cbR8vYXmYU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Jianxiong Gao , Konrad Rzeszutek Wilk Subject: [PATCH 5.11 17/31] swiotlb: clean up swiotlb_tbl_unmap_single Date: Wed, 5 May 2021 14:06:06 +0200 Message-Id: <20210505112327.231041841@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210505112326.672439569@linuxfoundation.org> References: <20210505112326.672439569@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jianxiong Gao commit: ca10d0f8e530600ec63c603dbace2c30927d70b7 swiotlb: clean up swiotlb_tbl_unmap_single 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 Signed-off-by: Jianxiong Gao Signed-off-by: Greg Kroah-Hartman --- kernel/dma/swiotlb.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -626,28 +626,29 @@ void swiotlb_tbl_unmap_single(struct dev * 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); }