From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88CE6C433F5 for ; Tue, 15 Feb 2022 13:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3nJI7/6nhRc5dzj0APVBowL4blcwwIgf9Lbp6yVyo54=; b=uc1a515Yp65nHq GMULiyhdY0YOjprN5Q8pLGdkWdfEpCHisMj/lUjuY2Fcr3N9w4Uk4j9uYzRR1rUVNlQYm8WxwWMhK WdsTqiI6RHzE1bmlV0OKae6r67IR+8DcOl1LqwsF1EOveiTwKK1oAinZQhC4RZMURtRLOorw9AKiA 7U5rK28Ok9m/aDxH3DNPy51gFVOqeMO7IhuA4mqzSkqpnH+3TlTc/UNT4ouQyJEfPE5QAwMuQg5st NMC4jpi9bEHxLscDTvkqlcAX6iAGEw9E2eQU1WGdW3dmzEjZ2n+qNakvqr4tGpwSf9T+1nJ5WH1wc DhStr7DfBpCNl6siqp0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJxRz-002kKi-Es; Tue, 15 Feb 2022 13:00:59 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nJxRv-002kJn-OI for linux-arm-kernel@lists.infradead.org; Tue, 15 Feb 2022 13:00:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D5FE6616D6; Tue, 15 Feb 2022 13:00:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4D88C340EB; Tue, 15 Feb 2022 13:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644930054; bh=rBQWeVT+EjzsgM3r1Lc4uCaVLYnzGjhTjj/msDXK3JQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Krj7P+C91g6qOvjxvKB81mvkRoyrAHTF2oSPNlKRcBJo6UzBrK7m9Qlspp+bE8L60 XCQxx4QeOVrwnNgvEJ86FjQZg7CL9v5KzzXIYET+suGKDkot+JLR+jgRJgrDF8PHXb y8zl/wECo6oZ0t040D0GT8hit88BtxAcseq6Nt54m60DPgh6P+Wc7CDmPmCCQirWT6 /bhPJTdJme5BWgevr8q2KdY9PycccGncoMNM4ZarxRXa6gIzXof5emg7hWNjzMo6+z 8OapdOtjag5MQHSESLH0Mvw9rq7Q9xmSOPi/qCAVtsiX7TXBH/kk03l0SaDjMWwS86 AStehWQJl8CIg== Date: Tue, 15 Feb 2022 13:00:44 +0000 From: Will Deacon To: Yicong Yang Cc: Yicong Yang , gregkh@linuxfoundation.org, helgaas@kernel.org, alexander.shishkin@linux.intel.com, lorenzo.pieralisi@arm.com, mark.rutland@arm.com, mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, jonathan.cameron@huawei.com, daniel.thompson@linaro.org, joro@8bytes.org, john.garry@huawei.com, shameerali.kolothum.thodi@huawei.com, robin.murphy@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, linux-pci@vger.kernel.org, linux-perf-users@vger.kernel.org, iommu@lists.linux-foundation.org, prime.zeng@huawei.com, liuqi115@huawei.com, zhangshaokun@hisilicon.com, linuxarm@huawei.com, song.bao.hua@hisilicon.com Subject: Re: [PATCH v3 8/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Message-ID: <20220215130044.GA7154@willie-the-truck> References: <20220124131118.17887-1-yangyicong@hisilicon.com> <20220124131118.17887-9-yangyicong@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220215_050055_914465_41A5155D X-CRM114-Status: GOOD ( 26.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Feb 14, 2022 at 08:55:20PM +0800, Yicong Yang wrote: > On 2022/1/24 21:11, Yicong Yang wrote: > > The DMA of HiSilicon PTT device can only work with identical > > mapping. So add a quirk for the device to force the domain > > passthrough. > > > > Signed-off-by: Yicong Yang > > --- > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > index 6dc6d8b6b368..6f67a2b1dd27 100644 > > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > > @@ -2838,6 +2838,21 @@ static int arm_smmu_dev_disable_feature(struct device *dev, > > } > > } > > > > +#define IS_HISI_PTT_DEVICE(pdev) ((pdev)->vendor == PCI_VENDOR_ID_HUAWEI && \ > > + (pdev)->device == 0xa12e) > > + > > +static int arm_smmu_def_domain_type(struct device *dev) > > +{ > > + if (dev_is_pci(dev)) { > > + struct pci_dev *pdev = to_pci_dev(dev); > > + > > + if (IS_HISI_PTT_DEVICE(pdev)) > > + return IOMMU_DOMAIN_IDENTITY; > > + } > > + > > + return 0; > > +} > > + > > static struct iommu_ops arm_smmu_ops = { > > .capable = arm_smmu_capable, > > .domain_alloc = arm_smmu_domain_alloc, > > @@ -2863,6 +2878,7 @@ static struct iommu_ops arm_smmu_ops = { > > .sva_unbind = arm_smmu_sva_unbind, > > .sva_get_pasid = arm_smmu_sva_get_pasid, > > .page_response = arm_smmu_page_response, > > + .def_domain_type = arm_smmu_def_domain_type, > > .pgsize_bitmap = -1UL, /* Restricted during device attach */ > > .owner = THIS_MODULE, > > }; > > > > Is this quirk ok with the SMMU v3 driver? Just want to confirm that I'm on the > right way to dealing with the issue of our device. I don't think the quirk should be in the SMMUv3 driver. Assumedly, you would have the exact same problem if you stuck the PTT device behind a different type of IOMMU, and so the quirk should be handled by a higher level of the stack. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel