Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp360729iof; Mon, 6 Jun 2022 05:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCikPf8L1W8DOoJp49G2uI+UD+qEczwUnzmbbVCNl8iVq6v6TcvRzLHXHfWE0HZ5izKWjk X-Received: by 2002:a63:131b:0:b0:3fc:c051:5a04 with SMTP id i27-20020a63131b000000b003fcc0515a04mr20891314pgl.568.1654517003849; Mon, 06 Jun 2022 05:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654517003; cv=none; d=google.com; s=arc-20160816; b=yO8+LhQdKGjCG7rbt+VW/jQW7R7Jw8T90gUd3M9gI/AJaUK2mfmLHMCm6af33mZ9pO Qv7H+N0oo87Qj8qbiLwt0GbbedNu3Pt3k+po0Ls1gfiF7J1ax86JN2CQUAPS5x2M3lOc Rsrf7dOvayZleQ/F//MB8Cla1DoF5BOIwqamNuK+TxL5jAov/fSIG16rBKE6JYykDSFJ 3ZlQ4nXhAYvhI0U+u9m+KjJDa2QCtmiRAg0eSiib2brFmK6TH72EEas0PlplG3vCJ/NH faVmWJmwQPf358SKE4YKKH+UZNswsNmlfpo4bDgu/6w+MKEHE1MOfWERP+BtzFnLn51E mt8A== 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=x5LtTkfN9sY4LwGirPT/pi7FSg52bapmXbXMi0Nrwd0TX4yntWoqkcEGqcbr748+hb ZzlDfezkqwd05MkO/Kc9KJ8Fe6Jhvd4sNg6cBg5HWukrAfsOn6iRC1tZHrFfsf1IHfLA pM/bXO1S6JzIhS5iwnCz9TQ9dnwRI9lh6T3i7bw506FR8ETmKJMR5c4zeSZ/HRPr4OV/ zt5D8BbDZg4SiRhF8/1MeY6wdFMbR+3f9FLL1VQguSbgIFyMKSvjTeMP57fcYd+hvFv7 AEZARV3wC2vCkmvu9Ir0dIry+0fAFbiY5Am/JGgVbvE8A0FaiYmYzpcuH2bzB+4PhJfl GQyw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z5-20020aa791c5000000b00518820f0cbfsi18215152pfa.335.2022.06.06.05.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 05:03:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D154BC5; Mon, 6 Jun 2022 04:58:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235955AbiFFL50 (ORCPT + 99 others); Mon, 6 Jun 2022 07:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235953AbiFFL5V (ORCPT ); Mon, 6 Jun 2022 07:57:21 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B6DC5; Mon, 6 Jun 2022 04:57:08 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LGsMf4hRtzRhh3; Mon, 6 Jun 2022 19:53:50 +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, 6 Jun 2022 19:57:01 +0800 From: Yicong Yang To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 1/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Date: Mon, 6 Jun 2022 19:55:48 +0800 Message-ID: <20220606115555.41103-2-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220606115555.41103-1-yangyicong@hisilicon.com> References: <20220606115555.41103-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=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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