Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2473609pxb; Mon, 18 Jan 2021 20:24:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3eFhRtYmNr6qr6wXm7JBMZtN6PcV5QiDROUcyQ0j5S2BmPlDDhYIr2RoZhVaO4gXG9H+A X-Received: by 2002:a17:906:36d4:: with SMTP id b20mr1761300ejc.144.1611030272810; Mon, 18 Jan 2021 20:24:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611030272; cv=none; d=google.com; s=arc-20160816; b=WCx8vdkUQ8eJlG7Laf0vfGJRf/PfFaF6ZkREcNpJX0bFa+uCzU+LtrkPXnYKNFh2Km h4TMW08s3eTbQh3xvM6gqYHC848TRY5hdkxnnWd+DCant/GgBb0Dxv6kL7MAaS3Cfcrv WDkpH1S2WlHcb2pWqBIYKaYXAlrAceuT2Sxc7XGu9NJznUG9Zn5CEKlMhUUuKnIJXwhn 0UBASUuo2xialANpmuvNdRKc1C43DFqoc0Qwjca7GF7/Fi6fXHXiRdWGm2O6XIAwzLvc T2UWCDHIaprZDqjVP8vf0ZFFjcQ0snogPbYQHJtxL1g3DO7HqqGOBks4TUzhG+QnqcFE 0GVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=RTFbyEE0B0+dGwmCnueIqh0uyURSZByyZqG2MEINrvU=; b=ZUAzoFZGq+QdvOyxbwD/yqKh8uOSwh+6VGaGoa9usXEu9vYtfuuEthXziUGqxPnQmE zvzUgJ9ANm47vDNk8gyi9ZpengiQqSqljhMSkRiRMqmtjdQUApbzUD0Q40CVm0ejnse+ ifW3AfzH6yFTBQntnH6WBswbk6VUjEP9+xonNOxD8a9hwcGhUciGrMIB+WtVUAz3Un/m Yc538aSQSaPVMqtgQ/jFvimyMmePvQslmEf8k31b3bS04skjE0IGAOpFXspH3FXyaxoO erqnTm7ap0f6CQQI5MJPwwTFoElds4sn/5nFEoKDDHH/xnKAx232araPuW/xrnyr4mwh Pa0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si777385ejn.465.2021.01.18.20.24.10; Mon, 18 Jan 2021 20:24:32 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392446AbhARNtG (ORCPT + 99 others); Mon, 18 Jan 2021 08:49:06 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:11557 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392151AbhARNsw (ORCPT ); Mon, 18 Jan 2021 08:48:52 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DKCkZ544QzMLhC; Mon, 18 Jan 2021 21:46:46 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Mon, 18 Jan 2021 21:48:03 +0800 Subject: Re: [PATCH 6/6] vfio/iommu_type1: Drop parameter "pgsize" of update_user_bitmap To: Alex Williamson References: <20210107044401.19828-1-zhukeqian1@huawei.com> <20210107044401.19828-7-zhukeqian1@huawei.com> <20210115164409.3e7ddb28@omen.home.shazbot.org> CC: , , , , , Cornelia Huck , "Will Deacon" , Marc Zyngier , Catalin Marinas , Mark Rutland , James Morse , Robin Murphy , Joerg Roedel , Daniel Lezcano , "Thomas Gleixner" , Suzuki K Poulose , Julien Thierry , Andrew Morton , Alexios Zavras , , From: Keqian Zhu Message-ID: <279c11d9-e79b-2057-3e0c-ac12ab6d917e@huawei.com> Date: Mon, 18 Jan 2021 21:48:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20210115164409.3e7ddb28@omen.home.shazbot.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/1/16 7:44, Alex Williamson wrote: > On Thu, 7 Jan 2021 12:44:01 +0800 > Keqian Zhu wrote: > >> We always use the smallest supported page size of vfio_iommu as >> pgsize. Drop parameter "pgsize" of update_user_bitmap. >> >> Signed-off-by: Keqian Zhu >> --- >> drivers/vfio/vfio_iommu_type1.c | 9 ++++----- >> 1 file changed, 4 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c >> index 82649a040148..bceda5e8baaa 100644 >> --- a/drivers/vfio/vfio_iommu_type1.c >> +++ b/drivers/vfio/vfio_iommu_type1.c >> @@ -978,10 +978,9 @@ static void vfio_update_pgsize_bitmap(struct vfio_iommu *iommu) >> } >> >> static int update_user_bitmap(u64 __user *bitmap, struct vfio_iommu *iommu, >> - struct vfio_dma *dma, dma_addr_t base_iova, >> - size_t pgsize) >> + struct vfio_dma *dma, dma_addr_t base_iova) >> { >> - unsigned long pgshift = __ffs(pgsize); >> + unsigned long pgshift = __ffs(iommu->pgsize_bitmap); >> unsigned long nbits = dma->size >> pgshift; >> unsigned long bit_offset = (dma->iova - base_iova) >> pgshift; >> unsigned long copy_offset = bit_offset / BITS_PER_LONG; >> @@ -1046,7 +1045,7 @@ static int vfio_iova_dirty_bitmap(u64 __user *bitmap, struct vfio_iommu *iommu, >> if (dma->iova > iova + size - 1) >> break; >> >> - ret = update_user_bitmap(bitmap, iommu, dma, iova, pgsize); >> + ret = update_user_bitmap(bitmap, iommu, dma, iova); >> if (ret) >> return ret; >> >> @@ -1192,7 +1191,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu, >> >> if (unmap->flags & VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP) { >> ret = update_user_bitmap(bitmap->data, iommu, dma, >> - unmap->iova, pgsize); >> + unmap->iova); >> if (ret) >> break; >> } > > Same as the previous, both call sites already have both pgsize and > pgshift, pass both rather than recalculate. Thanks, > My idea is that the "pgsize" parameter goes here and there, disturbs our sight when read code. To be frankly, the recalculate is negligible. Or we can add new fields in vfio_iommu, which are updated in vfio_update_pgsize_bitmap(). Thanks, Keqian > Alex > > . >