Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp362062imw; Thu, 14 Jul 2022 02:47:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vGXNY39Gi+02xbLeB8HsLfIRC9s/+sdj79dD2MeI4YfWUBt1A6JEAWwSjHNgXcwR9oKUjN X-Received: by 2002:a17:90b:4aca:b0:1f0:3395:6432 with SMTP id mh10-20020a17090b4aca00b001f033956432mr14822820pjb.19.1657792020986; Thu, 14 Jul 2022 02:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657792020; cv=none; d=google.com; s=arc-20160816; b=vj6vQCCZp/xf9QgM4aSmIqZRa5EMIvtfedf2oSHkftiJk43y9711hR4TqhrCQ1FfDQ qozwxKcuYKM5dytd4RLUuWftZPq3J69qevAImBhSCqHRD7CADwNEbcGROKqEbi0GVQ2E Cwrjvkc2XHGli+8IxgQWvJSjJHMe3G0I7HANVhCynFvM1vnnVhU8jlsJ4AfH93Xq9uGw cyA+UNkTUO4t6XVDotNg+PlimKv99yS/rM27fEa6YLOLE4g925ucpofqzuxuAaYftlgV /UDlQqWO4sc8cPUIQ1sEGMnhFBPnbirRgfl1vci1JmMz8Z/9wLTqQJTiQgB+qUVlmYfT uVnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/xiEI70fDxgBUz2x7X5y5kBDo8SCO4bdRNAR2NwxQDI=; b=Aej2c9BA+OZQvyFtbeJ7w939ofnbPg+JX/9STad3le5+75bqWU2u+RR+21a+rX/s6f 3dx1R9o8dtXqbWjvnqAGh+YxQkOHoYKDrZdLwgE7c4uRCKRklDJkA+Mxvppseuqeqj8s jP90w1sV553TZGOPN6+/Y2K0CJ/AurWgSgEdHdEeZb72ywUPFlpj8Zq5J2N/LxC5pirN jrQIhp6AMoBIikkIBG4SaNAeLbl02WEK7PYl9EIGfkLvNy+HekP6EPwWQI8j8jjRRheK zIknDa1nw8THumDdir0Nw15W5wAFrOHiT13HwY6dRH6fCebRdE8uim+YBrtO5Be5OB5l YUrw== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a17090a4a9500b001ece9122d4esi1584323pjh.86.2022.07.14.02.46.48; Thu, 14 Jul 2022 02:47:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238291AbiGNJ3G (ORCPT + 99 others); Thu, 14 Jul 2022 05:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238003AbiGNJ2s (ORCPT ); Thu, 14 Jul 2022 05:28:48 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 570EA383; Thu, 14 Jul 2022 02:28:45 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lk8Hg4XNkz1L8wP; Thu, 14 Jul 2022 17:26:07 +0800 (CST) Received: from localhost.localdomain (10.67.164.66) 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.2375.24; Thu, 14 Jul 2022 17:28:43 +0800 From: Yicong Yang To: , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v10 1/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Date: Thu, 14 Jul 2022 17:27:03 +0800 Message-ID: <20220714092710.53486-2-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220714092710.53486-1-yangyicong@hisilicon.com> References: <20220714092710.53486-1-yangyicong@hisilicon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.164.66] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 The DMA operations of HiSilicon PTT device can only work properly with identical mappings. So add a quirk for the device to force the domain as passthrough. Acked-by: Will Deacon Signed-off-by: Yicong Yang Reviewed-by: John Garry --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 21 +++++++++++++++++++++ 1 file changed, 21 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 88817a3376ef..e119ff8396c9 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2839,6 +2839,26 @@ static int arm_smmu_dev_disable_feature(struct device *dev, } } +/* + * HiSilicon PCIe tune and trace device can be used to trace TLP headers on the + * PCIe link and save the data to memory by DMA. The hardware is restricted to + * use identity mapping only. + */ +#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, @@ -2856,6 +2876,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, .default_domain_ops = &(const struct iommu_domain_ops) { -- 2.24.0