Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1044298pxb; Wed, 6 Apr 2022 07:24:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoFws626eqXIDEPK2KiadnIRrKN8kPPBs9HjO4vRHT0noaIOUWv7gPabiyEc5XdxnrZIFP X-Received: by 2002:a62:84d3:0:b0:4fa:72e2:1c64 with SMTP id k202-20020a6284d3000000b004fa72e21c64mr9232414pfd.29.1649255074287; Wed, 06 Apr 2022 07:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255074; cv=none; d=google.com; s=arc-20160816; b=Wixf7vh2Wu0oXY6N2ekpLJM6O84qk/OQr2t/duck7qqlIKbc9ejvi+SIRn6rA3uDRG 5kim1AYH7WKwSacu6n4+xNLsj3ooWYfNB3LPEGlEuCFQ+CBqQbhBxzk/UHwXoxLOr2v0 YmjHH5ivHkuVm5jRFxGytIBnxb91AMJVL+HXfJa5awGDJhZV/8fC3iToh3xPpmiuOqGh Ch9r2eB/1YQZXQ/hfZAM7YrcmbGsoUohkESizTPxe5DypwklegU4MpwsS4LfgDBGxIFV Bwu2Tet19y0+HEkS5EYZeZ9Yc5W4fcRO0yq4Fy0R8ojQ2pAAroKvX3jIr2uug2j1m2Ro 76Wg== 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=UOjYpAKxM06XIING8Td0jzmj8wp/DOI0sCMQ9w4vSx8=; b=LmIYxMpTHmVZeBUqIRiiQc+8WhJONTYHDwj+w4Lg8JwxZ1eLaYLS/ZyBVdkSwmoM9Y u4Wduq93GpPrMWnyWK2/vSRWvIGD9doHF1fB2QHLjNELp1ygXZKKRFqkAIoUuaUhBWlR fn1sMwvvzIy/L8KSIzRMK9Szt28uPo7zzcJqjml5nh2KqWdcA5KEf60oZSGqCoLuEjHC QvMSAirt6pc4dGygmugnaB7rVvrDcFlTpCJTe1dtnZvmuicAt8InjvMuxxV2DpC8zflU TuyOxrIl1ij3ewC2N1n8uhXONkFd6CtERTHNoxLkwF67LkJfPgRM/xkNgIKSrGV1Dyq8 CyuA== 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 u1-20020a17090341c100b00153b2d165b0si17156965ple.440.2022.04.06.07.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:24:34 -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 155B34F78F6; Wed, 6 Apr 2022 05:08:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231694AbiDFL4d (ORCPT + 99 others); Wed, 6 Apr 2022 07:56:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbiDFLzH (ORCPT ); Wed, 6 Apr 2022 07:55:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F0FC35C043; Wed, 6 Apr 2022 00:19:03 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KYG8B5vHfzdZZl; Wed, 6 Apr 2022 15:18:34 +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; Wed, 6 Apr 2022 15:19:01 +0800 From: Yicong Yang To: , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v6 1/7] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity Date: Wed, 6 Apr 2022 15:17:24 +0800 Message-ID: <20220406071730.41031-2-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220406071730.41031-1-yangyicong@hisilicon.com> References: <20220406071730.41031-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 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. 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 627a3ed5ee8f..5ec15ae2a9b1 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,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, @@ -2856,6 +2871,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