From patchwork Fri Jun 9 19:56:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13274395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43698C8300C for ; Fri, 9 Jun 2023 19:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Tcclnm1TH75AB1zCVqH35bpSep5j/dMLcLYxMRacbhU=; b=Yd4/6WGlMxIhmI EdX4P8tSDWnS7wwgosrECnx2/mI4Y2HjWX2SnhJmD/WhXZc1gCIMaKSN5W40jLBCD/lGG5tnGqB2c VdfaX5lylvxvzcgc6s9N32xFMgpfLilIQ98ANZEyPpN0dSen4rfiTyHHo+lU0Rh7Z076zaxYzpnRD +sze/2JUoyV55VQq47eauaclM4urdGCkjHnx0AGbXxEMITPfQ9keB4XZMnHgKDOMmLmLbR0UZ74RJ d6D99Qb1xjCx7YkULs5EtrPBNphLxs9nYGtdvw7D51PZyl6i9MH5vQWeicrtyH4IUl+Ek8JKPzU6T EsjCt2pR/VmAGBWr25Uw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7iDs-00E4Z4-1Z; Fri, 09 Jun 2023 19:56:36 +0000 Received: from mail-bn8nam12on20627.outbound.protection.outlook.com ([2a01:111:f400:fe5b::627] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7iDl-00E4RR-0G; Fri, 09 Jun 2023 19:56:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MVC7ejHHhx/BkjZmQgXw8RUNINkA3uxf9xn5D2fADJps7mh9g8I7aehwKFEA+ngRm/EV27j+xSRhdq0CfrZsfa7KFk4quwm9uCAgvzg2pJ1+A6Col1a1G0suuAo+r2dh4S3SJyZ3umhKg1EGOh6NNwuekaXxO2i4K3DhDyxDT76LbocXqo4FcDzATxs1jlt+ODXf9Rgjx/wkkcKroHYk4xiUjhTLd2x4rkdWjorwuKQEoRORUHyV9dOSSFFNZERFNPenaNkPJQlgfBt9HPr7/4keXnwaBTBDFvFFfq8Dgss4BRvmPvt5DAQLIRUF4veUtLKxXp8+bSbYSKkp0o8kVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fUUt/fAI8ph2DHNlhM4gNIsfEv7BScpXS9Tps+iWPLY=; b=T98twroviB78Q3Qw505KL1Rdajkj3B+z45uZkQ48pPNiFN9I64z8GxccFCJeeaS1fNpTfvWrCvHysycKQbhO0UTZdSWh7TIkjTAhhFfKoBI5xZXCOTdLz2IFyFA2UkwyPNcnA215a8w5e5gRegwQx9ZxgjlaELC1N4SmeNmx3zdzMTozk1KfPCptCSSUS2TE/vPsO2/4B0B9Cum0EwYbgbkNhF8Wf77DegHiQBZnksmErSNHeowH008fWsceGPyY3cxmpHa7DULjLhlOmiHbQPuX0Ws/wK2KkzWD7nXZ6aFKVEJpSXXznUASbxXYKEd5yAm1vxx1WENqYTmu7RvDlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fUUt/fAI8ph2DHNlhM4gNIsfEv7BScpXS9Tps+iWPLY=; b=IE4ChkQC1J9SOmEB+7GZs51dViivCwcQtcA+wZB+6O6nvHdxPqEs2nQqI1FkbZ724JkfIU0SG3Fuq3FtfUVLPmChK0QnSdJkvMEFmu6a0LBEfg/w42qRI+qo0GCMyBbanIHoFDTNrCSzvH3JTARk1OG4IFV4+A2IXxO6KHoJYmRx/UGrS6/YsE77tl6mqFiplhth8zoAH4E6SIzUttSGIPFUFIR315syf0h24fFbBoVEHoPsxB0UORVIAfSWeDW0vsdMNZGqj/nFNhhAkpG/m5DN8MyJrLJtJaBgjus+hB0RUfijQcCszF2JC6C9d5NjyTndjo0700VBSXTq4T8ewA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by CY8PR12MB7489.namprd12.prod.outlook.com (2603:10b6:930:90::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 19:56:16 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 19:56:16 +0000 From: Jason Gunthorpe To: Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Christophe Leroy , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Kevin Tian , Konrad Dybcio , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Russell King , linuxppc-dev@lists.ozlabs.org, Matthias Brugger , Matthew Rosato , Michael Ellerman , Nicholas Piggin , Orson Zhai , Rob Clark , Robin Murphy , Samuel Holland , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Dmitry Osipenko , Marek Szyprowski , Nicolin Chen , Niklas Schnelle , Steven Price , Thierry Reding Subject: [PATCH v3 12/25] iommu/tegra-smmu: Support DMA domains in tegra Date: Fri, 9 Jun 2023 16:56:00 -0300 Message-Id: <12-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: BY3PR05CA0039.namprd05.prod.outlook.com (2603:10b6:a03:39b::14) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|CY8PR12MB7489:EE_ X-MS-Office365-Filtering-Correlation-Id: df09db72-fb6f-47d4-8d2a-08db692395f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /H6Ugj0j7KGou1ti2pxM8uJDRb2eI9R+3EAJgy/RO0cf6I9+eTOM5w6Yy2PD/tHrdtC5JF2149R4qYstNzd3dcrkwnzB6Lx8kbZ1qmitsEilf/FmGCpo5us201rb7BR85gdZ/4TL/xAJwZ53dePJsXbM90hzPg1nf5BdaLufzi/CFankz/qNGx6PIBYjCt2/qODnn0YSRu7yEzMsLTvtOFciVEGgFISAzqqPJqzaichdFrzVXVfDyYQ2t1i7ULor+kwwNjBJgZJhuDUvhJ9JeYSxGw7EidWMvwIvIPl6GcnN/GhdqdU+Mz+AcDK3iEND7ij5+qoNSgloaiSLf/6N69VwlOobmG93rpSlgzd915Hj7+iAcRc7CieETDfKt5sCG7inhEbdskKjyDfPXtrKI+ydz/RArJCGhXSB2DdP3VgUw94MjEAoePcA5jxXL8XSPMIjxCbDDjUNws12yCS14q8ve0/K/Jr1jtDIWCGxAPLyrO6+3ZUBpP6rD6g109RIP/d7bmtzzMwJJT8Lx/nd0XS8bDoBJUKVZbN1EC/gc+q1Hlb4NOU1K5kRo9coMjW+7mfke7EEYHpfFTtrwlYMtWXCrPBNpdH8uGlkxJpMmEg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(366004)(39860400002)(396003)(136003)(451199021)(478600001)(2906002)(83380400001)(2616005)(6506007)(107886003)(186003)(6512007)(26005)(921005)(86362001)(38100700002)(6486002)(36756003)(6666004)(5660300002)(8676002)(8936002)(41300700001)(66476007)(4326008)(66556008)(66946007)(316002)(54906003)(7406005)(7416002)(110136005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5aXlUtpqqGUf3/ZoiOcQ38Z503MHnNxzJ8qVACsJPc7OuuzZ+wx6HvIAqOaPtyejfftJNF29dOrBUHq6Z4ywzM+/rJsSacM/kWOEeqlSyzxIjkmLS6Ld4tDcSIwwFobGHRcjhWcRp4Yya1V4JUfNnmFIufkeetY69JPHH+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693NwoXDnN1NifMvqQjl55bt0oMIAyK5jhPaJxr+/8jc/9AXgx3UuiOMKoC6tJ25bBySNyfizmywbqR19JRd9wJnVAAO7mxCE5hyDFnc0JzcDrWZ0Klp0iOmIIkdSYNxGMsDwSqiweacv5aDGWousMfSW2scgaQCcpVXV8OX+ix4AclpcLC2AfIRQGm8qOxIpt1Lfkepv1bU447HV6nBukxO80Iu/vR++W9b51Q0/BBZW6zevnP5jCccBDBolm9v1nBu9lFlhcSc56e0TTDqiNLZ/Qt0LitbpC5AHXG+Pl8h+qSmvtar7L0UOnoTD8E3BgEtpGh0ZZ+opENW+w++aJb X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: df09db72-fb6f-47d4-8d2a-08db692395f2 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 19:56:16.5049 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +fPlJMs4apbZIY/zn1RTjoaeFciIVgyWvk5DRpHrvRVnmd3mKC+f5ygdTql3RL+q X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7489 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_125629_122372_5E125DC0 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All ARM64 iommu drivers should support IOMMU_DOMAIN_DMA to enable dma-iommu.c. tegra is blocking dma-iommu usage, and also default_domain's, because it wants an identity translation. This is needed for some device quirk. The correct way to do this is to support IDENTITY domains and use ops->def_domain_type() to return IOMMU_DOMAIN_IDENTITY for only the quirky devices. Add support for IOMMU_DOMAIN_DMA and force IOMMU_DOMAIN_IDENTITY mode for everything so no behavior changes. Signed-off-by: Jason Gunthorpe --- drivers/iommu/tegra-smmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index f63f1d4f0bd10f..6cba034905edbf 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c @@ -276,7 +276,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc(unsigned type) { struct tegra_smmu_as *as; - if (type != IOMMU_DOMAIN_UNMANAGED) + if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA) return NULL; as = kzalloc(sizeof(*as), GFP_KERNEL); @@ -989,6 +989,12 @@ static int tegra_smmu_def_domain_type(struct device *dev) } static const struct iommu_ops tegra_smmu_ops = { + /* + * FIXME: For now we want to run all translation in IDENTITY mode, + * better would be to have a def_domain_type op do this for just the + * quirky device. + */ + .default_domain = &tegra_smmu_identity_domain, .identity_domain = &tegra_smmu_identity_domain, .def_domain_type = &tegra_smmu_def_domain_type, .domain_alloc = tegra_smmu_domain_alloc,