Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1570640pxb; Tue, 8 Feb 2022 22:38:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3gbKV1IebNljfdR2EuQiNhqrZTSifYYLX5g5QfW10L+iaEm1sg0rtSiyRoWzqIO0OqAZ7 X-Received: by 2002:a05:6402:908:: with SMTP id g8mr926043edz.4.1644388730579; Tue, 08 Feb 2022 22:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644388730; cv=none; d=google.com; s=arc-20160816; b=MGcohx3tEiZ+3UQHCZYhiMTN+iHzO85N4PnHMHJqGw3BbshavEGHUrydwHNFkmvSmQ 14qYn8z5l3TMJee5hzX+6qbrSnAWT8cvTVk15RxYGQjs4ukKRAMUXKc9Z4B5opprOiNN OqSAZuU8zOi5nJD6VWbNc50QPBMUxe0lI1XFp+eqwNx3zuHx17b7SAij7FkypM1n8bdc OwCV/idvdor4gmSyuil2hBrUriDd9WJNtD2OWtCwd5KbBuQ3u4X70ICUNG62Purpr6HA 2tGSqM9us19AKQ/w1EbrL+H23sQhidIsVorlT2sgBcAqSFp1isMZnk318agSs9eyHG7Q DEAQ== 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:references:to:subject :cc; bh=JmXaANj8J+fD69BbDiw9DBX1+kPZJp/3MsXdqWdYYe4=; b=wuBYZLAjtgoP8YSszj5kVYTm48RpvNTUPO0qSVnmPt52xGzrPilJFa6ARGU0u462VF a/SkNIKZZflyCw+b36gT04OhNwoLLT+aHwQmEzQCyKXT1eOt2bLg9bH+0Y2G0kYv5N3J 9y0bQzorraA/Z57wN6QqoUZ+gSnhazRd4ERUSRUeyqEn7kwrdnIerqia3wOczDeZt4+m bHUiBI2ng8BGYbjMuvjB/RrX6LtaG1cHyGvFnykd4oQga7beYrOrVphmf2OyehtZf4Eo XtFFjro+fUUzC2Ds26JVPHiMdg8zSSvWsRqyFPSfOJeGgMUBbaQAejhC9PTyAYNOh84Y 0GzA== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt37si518400ejc.97.2022.02.08.22.38.26; Tue, 08 Feb 2022 22:38:50 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358196AbiBHLgQ (ORCPT + 99 others); Tue, 8 Feb 2022 06:36:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244901AbiBHLVM (ORCPT ); Tue, 8 Feb 2022 06:21:12 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 967B9C03FEC0; Tue, 8 Feb 2022 03:21:10 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4JtL7X0Ry6z1FD30; Tue, 8 Feb 2022 19:16:56 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) 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 19:21:05 +0800 CC: "Zengtao (B)" , "liuqi (BA)" , Zhangshaokun , Linuxarm , "Song Bao Hua (Barry Song)" Subject: Re: [PATCH v3 8/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity To: John Garry , 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" References: <20220124131118.17887-1-yangyicong@hisilicon.com> <20220124131118.17887-9-yangyicong@hisilicon.com> <4f6f6e0f-4398-3018-cc35-6aa7ea1305fe@huawei.com> From: Yicong Yang Message-ID: Date: Tue, 8 Feb 2022 19:21:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <4f6f6e0f-4398-3018-cc35-6aa7ea1305fe@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 2022/2/8 16:05, John Garry wrote: > 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. > ok I'll reorder the serives and modify the comments of hisi_ptt_check_iommu_mapping() like: /* * The DMA of PTT trace can only use direct mapping, due to some * hardware restriction. Check whether there is an iommu or the * policy of the iommu domain is passthrough, otherwise the trace * cannot work. * * The PTT device is supposed to behind the arm smmu v3, which * should have passthrough the device by a quirk. Otherwise user * should manually set the iommu domain type to identity through * sysfs. */ >> >> 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? > For current revisions it's necessary. >> + >> +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, >>   }; > > .