Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp942089pxp; Wed, 16 Mar 2022 22:05:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB4n9U5loPV/0C2y0dec1pM8lc2SvgqL6sCwND6mtztFI1HLbRglDDZRAWmCzJVJjO2ymm X-Received: by 2002:a65:5381:0:b0:381:6968:ba39 with SMTP id x1-20020a655381000000b003816968ba39mr2284643pgq.230.1647493543654; Wed, 16 Mar 2022 22:05:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647493543; cv=none; d=google.com; s=arc-20160816; b=t5NBbU1J1/90pZ23gqS3gOcip3nvEcDmPnQut8TpZP5NUHt8J2vxFMP5HzxxgRZDzr XV95blRsqIZaNN/kLI0jl5TtYJPnR39cj09bIaJKLkHM5YIdVK/RLpZdIrbxytFP0lpo jsGNN5s6ohB03tcrlBER7yYAkENIjw/LGT+nKROdch+2bD3Z9EQvonspasKrvucV75OB KOfAu7qCPvjiallwH6Oo1I3cEEBWdcfT0kzEzzs91O0a5WJNg+foMqGy3+NZLZ0lTLRg C7QZYHlJ7JgKL/8CebDkwsq4gotihcsuga9zKafrhO7UVd3MsgeFYBnrHENx/4aJvZn4 oX4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject :cc; bh=lUVeCssILJC1RLLyjEYwtSiqhv3YOsFI121SF4eNYho=; b=BJvGKfeSL5q4R9P4XMg+Nk+ZHMAp9PgRm8EhqcL7WBMziJ4eRccYw5ACkd5KV8pO2v dUNif2WNEvh5pXtzfUZgIBZwzqYg6J3ryybLZ6hEMtTQd02Ta6YWDpTWJ6hN+zenJOhj FFmWvLBEGydbgQu+OJwyZn6YuyAA4GkPVOarfKSAi/xQpyliGSqaZMSCQVnEBwrwgnXi ioPz2Kjy/idZxD6LEtUWHYiAAQOkESajER7GBbLj3stBfU0koEuSZhlOk0R6DM+aH7aE FH9RY2v+ZO0YTaxxNWlwaN2XJLnPs+HRiLnaIpyPkFsjIfmLqQ+zIj4tXyXSViWvGeIH M5xQ== 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=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e11-20020a63ee0b000000b003816043f0casi995291pgi.703.2022.03.16.22.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:05:43 -0700 (PDT) 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=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1596E104A6B; Wed, 16 Mar 2022 21:17:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353841AbiCPGRN (ORCPT + 99 others); Wed, 16 Mar 2022 02:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237256AbiCPGRL (ORCPT ); Wed, 16 Mar 2022 02:17:11 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB073701C; Tue, 15 Mar 2022 23:15:57 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KJKds0rrTzcb5F; Wed, 16 Mar 2022 14:10:57 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) 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; Wed, 16 Mar 2022 14:15:48 +0800 CC: , , , , Subject: Re: [PATCH v5 1/8] iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity To: John Garry , Yicong Yang , , , , , , , , , , , , , , , , , , , , , , , , References: <20220308084930.5142-1-yangyicong@hisilicon.com> <20220308084930.5142-2-yangyicong@hisilicon.com> <162a116a-4b0f-c58b-6760-86d10ecf543f@huawei.com> From: Yicong Yang Message-ID: Date: Wed, 16 Mar 2022 14:15:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <162a116a-4b0f-c58b-6760-86d10ecf543f@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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,NICE_REPLY_A, 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 On 2022/3/12 1:27, John Garry wrote: > On 08/03/2022 08:49, Yicong Yang wrote: >> The DMA of HiSilicon PTT device can only work with identical mapping. > > nit: I'd have "DMA operations of the HiSilicon PTT device can only work properly with identity mappings". > >> So add a quirk for the device to force the domain passthrough. > > ".. domain as passthrough." > thanks for the comments. will refine the commit as suggested. >> >> 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, >>   }; > > .