Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3466421pxp; Tue, 8 Mar 2022 15:12:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPvT44qT8h07uFjHSWy1DIrvY5P1X8hycvzfo//U0V1kI6MxtWPLREfIZumkjpVbVHbKFc X-Received: by 2002:a05:6a00:2485:b0:4f6:b5c5:ee8e with SMTP id c5-20020a056a00248500b004f6b5c5ee8emr20988317pfv.21.1646781136760; Tue, 08 Mar 2022 15:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646781136; cv=none; d=google.com; s=arc-20160816; b=dDTdOTDzrJMB2Nu+EoNil8TnDaLouFgqr4mm9g3FIhJSAjjvQP2BwAcfDRbLRomdhB GMWgp/7bwtSoEZKjfEl26Vhj2dHNlkfr8ag3OxHaI2izCVsSTuqyzFodqZMzdcPME+CK KNNcHrTUzg7T30iW0yWeklshyeFD4iZAzawqsPB8Qk76WYtiaNl8vBane6a3tYM4YAHt G9PQ5GB4Xbdsamle1h3IqttGXhhAKa7iTNF+8Y4wBemYlHQ6AZepn96XTWxHerelqcBr Z1SNawTORsc1WZOKhJ7COCeJQ5kEHfvVXJiyWgsDu4WXzBVmg16Di+Huzv1/5sJQ+hYL XtlQ== 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=JL+fHw3WhsV9O/Wd+KEgcebsSyVdADFzpedK1sT+6pk=; b=Ci/T0bb/V8p/tYwvwX9v5GcKvl5f7ZywmqHbLURuvoXNcEA+xqyVtVhXztAbcV6T+g QzjT7c8ooDEYddZTws8kda659O4nonF/PALXHVSuicdhyGDvo4hIqKQjiO2qodBdhfIX LdEs4TG3cDGNNsBl9SSgG422QmT3ObsXOfrahY44cjsMJhjJSFkLgX0iEOK85I0g/Xij dwaJl/xS1rmqgIq6M9kI6mArlgzmmc8v7QFIL5O5VehtwOMwBboly38dBzNW+4YapbBj fMUHb9mEVAFR60H2oFNVQzmtcW2EX5HbVuipQPhh0J5YtXmEWwE0gzgUKjzuzUndawCr 9N6w== 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=hisilicon.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x1-20020a654141000000b00380472238f0si194109pgp.395.2022.03.08.15.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 15:12:16 -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=hisilicon.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D8C526B08C; Tue, 8 Mar 2022 15:08:40 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345161AbiCHIvm (ORCPT + 99 others); Tue, 8 Mar 2022 03:51:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238210AbiCHIvi (ORCPT ); Tue, 8 Mar 2022 03:51:38 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A886E3FDBB; Tue, 8 Mar 2022 00:50:41 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KCTWd0Hz5zBrjL; Tue, 8 Mar 2022 16:48:45 +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.2308.21; Tue, 8 Mar 2022 16:50:39 +0800 From: Yicong Yang To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , Subject: [PATCH v5 1/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Date: Tue, 8 Mar 2022 16:49:23 +0800 Message-ID: <20220308084930.5142-2-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220308084930.5142-1-yangyicong@hisilicon.com> References: <20220308084930.5142-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: dggems706-chm.china.huawei.com (10.3.19.183) 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 of HiSilicon PTT device can only work with identical mapping. So add a quirk for the device to force the domain passthrough. 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) + +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, }; -- 2.24.0