Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3131206iob; Mon, 16 May 2022 13:55:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBt0c/LEk0MdsNw6Gjf6kwRnZg1LBMfq5mZkMO6jTLvH2FC/RQnLrc3MNJ8gYUcS5HYDq+ X-Received: by 2002:a63:87c1:0:b0:3c6:a988:61de with SMTP id i184-20020a6387c1000000b003c6a98861demr16662409pge.412.1652734536043; Mon, 16 May 2022 13:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652734536; cv=none; d=google.com; s=arc-20160816; b=IxP59lzc3mdaP2nutZ0EkqkDKOaDd1dGoqcgkXI2Oc9AI2Bnr3bpAnk9r3GQWovMcA 4sYq1hlVKp9VTHympTSec8Zzek6qVdGsqOBvazkk+qJ7jTAnR6ul3BdVANgxj3XDys0c P5hizCsSJxrSpJDdYOliwQCLmaZfSkDse+pO9krIJhl5l8cfz04puCbdMyyX6xDpO8nQ 0Kp2m4YG4+05XHEc1TWCbxe8aH+Xugch7ZW2HVLEAoX1Jk80uGzq8FCOwFlSjY1iQPsY YzkCJZIPUVFihu4hn4TtHaQBHYIls/RRUTv+P9AOQ3AiBeLq4c7b142sQKOdO8ivYN4d s58A== 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=phLfLRQZzKjic4cTB16qwX2LAWPV/E6jP1ApLxaMIvQ=; b=M3FiM3dfB1RQ37vzHUWBuxVr5xtGwd5yp3/oY2CRLdubGb3vF39p1zKSZJn5wfvoLQ 9Y4osOTAk2FWWfjjSwqE6tc3yyXyI8avNwLHFYQaikHKApIFJalCYdK6Bh5JEUy6gSgE +4qsROZbeQ8bgbazj7vrrLCAEfc+UknrUafdgIuzpS8jb2RI8ccdEVLbTHwUw04NtG0U UCxQaS3Efp6vXNEsgAvxwJdiP+fMVCsHxj8bTpYUftb/nGBTx9OAfsva0GmI/97n31kY 0lPHM93HYS8zJCu9LCQx9JLwhRmX5onOVKBtuwL62UQ+qYfivoiBZzWWhAxomx92cYaz +Z7g== 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 137-20020a63038f000000b003c63fbcf466si14278096pgd.785.2022.05.16.13.55.24; Mon, 16 May 2022 13:55:35 -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 S243105AbiEPMxU (ORCPT + 99 others); Mon, 16 May 2022 08:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242524AbiEPMxS (ORCPT ); Mon, 16 May 2022 08:53:18 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2004393F0; Mon, 16 May 2022 05:53:15 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4L1zfL19bqz1JC8X; Mon, 16 May 2022 20:51:54 +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; Mon, 16 May 2022 20:53:12 +0800 From: Yicong Yang To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v8 1/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Date: Mon, 16 May 2022 20:52:16 +0800 Message-ID: <20220516125223.32012-2-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220516125223.32012-1-yangyicong@hisilicon.com> References: <20220516125223.32012-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 627a3ed5ee8f..7f51823ab63b 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