Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp515642pxu; Wed, 25 Nov 2020 08:44:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJziHLWtA3wPmdjTIWx7f7Pf2MdjjIViLlza8uMyyJItazjDZV0XKNDhpo50YDp8c7wvtX5s X-Received: by 2002:a17:906:5587:: with SMTP id y7mr3987724ejp.138.1606322650500; Wed, 25 Nov 2020 08:44:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606322650; cv=none; d=google.com; s=arc-20160816; b=FR4OsrQRxHqT57nqdRFgKXgfgdRpN4ud9dpaJbHNyQs9zY2ybEeBs1czqnNWMgHuAR wqzZDaCfU+PoQBaJgQlNpNUll4F1psOyft01Rw9qM0faiHRB4DplWJ1/4j3pWQsp87o+ KWZXpvBLxbYcyzKie9u5NgvkM4Erk58tFV/WvUZuWdLd9OjVsThhIfArG4f49F/hOTPJ lKCqS1dVhNONkJFAe7BcYKR8mGz9eVGRH4KiCUSXKFP/aUxmfnlx5JMwMtwsjfHUyu9k 6h+ZDWBBRFcTjbocKdyOFeMPa0fAgcwei+IGjvboDtrACQVw5qIsxPSNvvuhi2S3uw02 aiHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=EPCzpJD2i33nk1GnwdzUF8xP1n82QciIK2MZ5dXrFcQ=; b=wED7+bnvfuIw8eqMwmfjt46c3EH7+msTwYa3/1P5+R4gfSGAi3o0VVfR3oZyouqzAC ALBzyOuv0Q+RNn2I3Bj6w8UpcIYrirfJ2F2Zh63h4baUE/nqqOlyjgn65uXwzsmrZW9C TRIrlYcDIqPacmYmmIZhDOSHj0p2vyV1MggryMV5C242YYT9gt8tUmSrXdexrBQpeF0X IIhxwuKvhELWY4tPCt2lFI898A8mK8lKiG+euERD0SSojLRUvpMIWUgbOyy8RI3wX+wW xjN4x93nuI5/W+ceyat1TvrkPt1pVan6CRZK1hRQvDsws8+yDn612FaBPG+WgHWtMeYi 78Ew== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g26si1567691edy.14.2020.11.25.08.43.47; Wed, 25 Nov 2020 08:44:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731982AbgKYQij (ORCPT + 99 others); Wed, 25 Nov 2020 11:38:39 -0500 Received: from foss.arm.com ([217.140.110.172]:58526 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730249AbgKYQij (ORCPT ); Wed, 25 Nov 2020 11:38:39 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AF38131B; Wed, 25 Nov 2020 08:38:38 -0800 (PST) Received: from [10.57.59.159] (unknown [10.57.59.159]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4EE6E3F7BB; Wed, 25 Nov 2020 08:38:36 -0800 (PST) Subject: Re: [PATCH v2 4/6] iommu: Add granule_ignore when tlb gather To: Yong Wu , Joerg Roedel , Will Deacon Cc: Matthias Brugger , Krzysztof Kozlowski , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, youlin.pei@mediatek.com, Nicolas Boichat , anan.sun@mediatek.com, chao.hao@mediatek.com, jun.wen@mediatek.com References: <20201119061836.15238-1-yong.wu@mediatek.com> <20201119061836.15238-5-yong.wu@mediatek.com> From: Robin Murphy Message-ID: <49bae447-d662-e6cf-7500-ab78e3b75dc4@arm.com> Date: Wed, 25 Nov 2020 16:38:35 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201119061836.15238-5-yong.wu@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-19 06:18, Yong Wu wrote: > Add a granule_ignore option when tlb gather for some HW which don't care > about granule when it flush tlb. > > Signed-off-by: Yong Wu > --- > include/linux/iommu.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index 794d4085edd3..1aad32238510 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -171,6 +171,7 @@ enum iommu_dev_features { > * @start: IOVA representing the start of the range to be flushed > * @end: IOVA representing the end of the range to be flushed (exclusive) > * @pgsize: The interval at which to perform the flush > + * @granule_ignore: For tlb flushing that could be regardless of granule. > * > * This structure is intended to be updated by multiple calls to the > * ->unmap() function in struct iommu_ops before eventually being passed > @@ -180,6 +181,7 @@ struct iommu_iotlb_gather { > unsigned long start; > unsigned long end; > size_t pgsize; > + bool granule_ignore; I can't see that this would ever need to vary on a per-unmap-operation basis, so this doesn't seem like the right level of abstraction. AFAICS it should simply be hard-coded in the driver logic. > }; > > /** > @@ -544,7 +546,7 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain, > * a different granularity, then sync the TLB so that the gather > * structure can be rewritten. > */ > - if (gather->pgsize != size || > + if ((!gather->granule_ignore && gather->pgsize != size) || I also think this is a slippery slope in the wrong direction anyway - there is likely to be a fair bit of hardware-dependent variation around how low-level TLB maintenance works (also consider drivers that may want to convert a sufficiently large range to an "invalidate all" operation), so if a generic helper function doesn't do the right thing for a given driver, that driver should simply not use the helper, and directly implement the logic it does need. Robin. > end < gather->start || start > gather->end) { > if (gather->pgsize) > iommu_iotlb_sync(domain, gather); >