Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1536527pxb; Tue, 8 Feb 2022 21:29:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0S7poNy6pwRTN9d4pCl525InFDz0gNhb9XxO5DQBV0k/BJXcURldnjd31K56X2K63thHo X-Received: by 2002:a17:903:1c2:: with SMTP id e2mr843135plh.154.1644384581781; Tue, 08 Feb 2022 21:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644384581; cv=none; d=google.com; s=arc-20160816; b=iTlG/YfNE/OF+ZCzSVsmIH8qV9p4BQrWSWkhPSNukLmWGaRgBiiCgp8e7VyK+GNMo7 z6Qa8uFDBar/NKdrtO9lQtE6cadDbLZyCvy8nQnjx0e+w93Voc3I8xH7XrzabydgDChW 3BR5JGaYOTZN/m8+XkD7uqqpAZZZppqQbe0orsBWP23FYXYGliPRrNDiuTAw0+DaDVDl MsrxERCPX8iayIPDqsS4sKbpqnSJA6xtXWUmO0ZRL3It4J/GpYYywPpFA2gfRgkRSpTu hGedh1UN92XnM4Lfpnu0jVgtsUEfeGvK5QXDLxda4jcXSRZ66glbQ+iESyfIL9LMzejl 74rQ== 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:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=Blhm288Wr2L8zK3KktAptisPUl5JFf91/2GOwCflIok=; b=G7h6OZssXtskpVPPrFA6i4JG1XmdPnKXLONh+d1/oi5M/tFgxQxZ8T7tR2NB979rSh qj8jNKKSqg8NHiKWGVeTIaGsFS4yY/HyXSmeA9ZOJjvpQrNDbA4csgmznHCUaIBi5z+J DIIqVekWDf3D+QDao4q/yjL9pYYb1Wi9w+rwI4bl4OjUzvfLyOHqhkcqYO00MKaBWkIW NiBy4AvOlJjh5bTiC+XJTvv7xuCagOwCun7x+k9hzYeG1QB2P+InbnGtiOw3ez9Afm33 OuxHC6MVo9RIeFfco96gEy9cFi5PE4uUfsFdqG5X+rt7sveG6san51W6+I0ShAHQmIE+ t+mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n7si1918956pfj.214.2022.02.08.21.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 21:29:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 054B5C03401A; Tue, 8 Feb 2022 21:29:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348759AbiBHIFy (ORCPT + 99 others); Tue, 8 Feb 2022 03:05:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236001AbiBHIFw (ORCPT ); Tue, 8 Feb 2022 03:05:52 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6509C0401EF; Tue, 8 Feb 2022 00:05:51 -0800 (PST) Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4JtFnG68VGz6F92x; Tue, 8 Feb 2022 16:00:50 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Tue, 8 Feb 2022 09:05:49 +0100 Received: from [10.47.24.125] (10.47.24.125) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 8 Feb 2022 08:05:35 +0000 Message-ID: <4f6f6e0f-4398-3018-cc35-6aa7ea1305fe@huawei.com> Date: Tue, 8 Feb 2022 08:05:29 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v3 8/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity To: Yicong Yang , "gregkh@linuxfoundation.org" , "helgaas@kernel.org" , "alexander.shishkin@linux.intel.com" , "lorenzo.pieralisi@arm.com" , "will@kernel.org" , "mark.rutland@arm.com" , "mathieu.poirier@linaro.org" , "suzuki.poulose@arm.com" , "mike.leach@linaro.org" , "leo.yan@linaro.org" , "Jonathan Cameron" , "daniel.thompson@linaro.org" , "joro@8bytes.org" , "Shameerali Kolothum Thodi" , "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" CC: "Zengtao (B)" , "liuqi (BA)" , Zhangshaokun , Linuxarm , yangyicong , "Song Bao Hua (Barry Song)" References: <20220124131118.17887-1-yangyicong@hisilicon.com> <20220124131118.17887-9-yangyicong@hisilicon.com> From: John Garry In-Reply-To: <20220124131118.17887-9-yangyicong@hisilicon.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.24.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/01/2022 13: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. This patch should be earlier in the series, before the PTT driver, and the comment on hisi_ptt_check_iommu_mapping() should mention what is going on here. > > 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) I assume that not all revisions will require this check, right? > + > +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, > };