From patchwork Fri Jun 9 19:56:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13274423 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFF17C87FE2 for ; Fri, 9 Jun 2023 19:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbjFIT4Y (ORCPT ); Fri, 9 Jun 2023 15:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbjFIT4W (ORCPT ); Fri, 9 Jun 2023 15:56:22 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071.outbound.protection.outlook.com [40.107.244.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B30A270F; Fri, 9 Jun 2023 12:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lVXKa/tLUjmM/u6+/GI0QuDntk/lOD4z3NTe63LkUEu6gDsVcx/0wfa26qrg5fgMN3PLtGa5UjLddGQKG8Wbsy1abbeMnstZT0HnEzchYwxPJGtsApj22NZX1TwvNhbxi/B49jp5mdk1hx4Eszm2jiFm2CKIEb4BuBgFWv4DG2J1uFFIbNHZy7rXxkn6gFOaRPM0kalsG3BgGxlYX8aQ0eGLqNKhz0sxsPx9aMRBJSULzYs/hopwnQHH/CiB36Ac5UGZNIjmc16ecCiwJNWc8tNe3Z0PneyErXDCAOrxlxkbA0LdtNMX8U/ocqsolg7ZYmV7VIIiR4OW15PS9Q4INA== 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=rTyavZJIyqr4bzkZ78lJsHJ+7Og9ytKqwQ0syxXa+K4=; b=mZHsn/PButXG/R5leB1YmwhpSMnS3J/p3dMzD02zuTHevfJYypx7PEDqVt43PE1AdMR55XjMtOUizjKsouKMpFziymFsxl5lN8lDKTpLeU/e46TEQTon54sMNDlDAFCNhGOjmK+eRl+uwvEScM8F2xLY7s4xioZK8urpgSjrCTnhDpMWcremg7nIpzJaBv4faNzkVgyu8nWg4u9v5lX6IG/fY1p+rOFRGbRXXBzAdwrvwyhTTQdouedEU+lK1mVE1u4ySDoxHo9nLhIlJaGzxINhG7PASKiEkYuZauoDXE24KChze7kjjJjQNfBD+iApF18U6uM+l4CAivgjtevkbw== 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=rTyavZJIyqr4bzkZ78lJsHJ+7Og9ytKqwQ0syxXa+K4=; b=TedxXsgOFAl1Tah6XOnZHkAsHgkjRmBhaFWMQ8z2sFfFG8Kop+oZ8E5IlWv4vRgdHri4tE6p6QiHGNpZxFwyh3sPRT34VT0OJeEV/P5aL4Jin5avgnUQ9S12o06BlYlw1djM0qvSJhmtz/NYbNYhouDmuBiVuAvjdpW1nMwtfX3dGUQb8XxZxogomk7OecDrxf56H0FNDXjg3u2kU8KTNHx+I8svgEK54UmQB2D+8T/Q82F9pqjfz7JSQmf1hO7/fRpdAvxroAhV3pIJE51uvzsaFtCbG4rMWOx/NN4rKLhCLLFQIDkfhYcIRTKNnC26qZmZWissatSL8myujKMs4Q== 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 DM4PR12MB5264.namprd12.prod.outlook.com (2603:10b6:5:39c::17) 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:19 +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:18 +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 13/25] iommu/omap: Implement an IDENTITY domain Date: Fri, 9 Jun 2023 16:56:01 -0300 Message-Id: <13-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: SJ0PR05CA0136.namprd05.prod.outlook.com (2603:10b6:a03:33d::21) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5264:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d97404f-e116-4255-fcae-08db69239626 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i9+eHV35JJL+sQJUy11x6k+f2pBWsLZiSpsLKNq9Eq+JXGd6nARj9+ZLIDsSuYpXDd3JIHQsMQG6/osfC5AqOmBRZsQ2VCKVzLYJ58M4iUQzQ52OWsOz0CisOZdPo6y3AHd0glCCym+CY8Pmflnmjic+IGUBo8O8PytZstJE1EmaPgDilvl2VK+iIMhY9eM0efns1mnqU3goa4JNDsjHRCItF9O+JFy7XxQbYIASU7qocM357ZuIR89KnPEIGt7YfFIsNGUu/K+0OMK5KE3YjZ/smS8f42cEmNzeNWvUB9xRiM7Qrr3Y8YlzFGChLNqNkUqVbTpORcg++qoEh0wUMNSd60rM1YulAEVA/xtjwr+pRRusAxDUhh7boCX/8tg0t9sIyAb0tayucxArCQ9fcKYLPPVCdexQF53sQtVGYu/GwvYZiK8jWfoobl8jV0wQ5gb/5D5GOBTdZUczutR2WVP+lzGS9U+e+VoRv1V9r24aiMzsh7lNH8q7AvJyzaduvWhESBIe0K3KZa+/CtC0RE4/XAEZmeQ5rayzfGso7TGU7OgxiOTm1WwmVYjJ3f2Tm3fHfmXv081jo9OpWhZnqed+RZvu6ix3UJwCf6aR3SY= 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)(346002)(39860400002)(366004)(136003)(376002)(396003)(451199021)(2906002)(83380400001)(36756003)(26005)(6512007)(6506007)(478600001)(54906003)(110136005)(107886003)(6486002)(6666004)(8936002)(7416002)(7406005)(5660300002)(2616005)(41300700001)(66946007)(66556008)(4326008)(66476007)(8676002)(186003)(316002)(38100700002)(921005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pnS2x/jW2hl5ekb4rLHYAEha9CBDQlyBWqx0V2WtlGr/nDVqS/juNcahf7qm3ImLO9MKRNzzByN3MVbY9Y7RdeNVjJ6i9kGP+7XZhg8iP7mND+6pQiVoU7pj0kQKXwcfLm4YjjgrQM8bs81Q+xGG7W2ZaOXPFV2pkwXmm035StmYJunaT6J5QMUzsqbaMhPIpzoBexJVG53xaXXEeef90LrKk7IRQthMgKczw1dHEwo2Zp+Hn/e8+XovnPRHnHF+nDvvEXiIJ+9CKaFkRyVGwAzsN2z9bSEqPcP0wjnjbbwHxc8fnUaB2ToU3SZquL3u+fOjgYxk86Mm7iAbRL705PosSCcH9fhSKDWqjWB5W9FsLbfaZD0sZuI/0RDNG4AFWyr1rrDDTe3e7IMjoqP3/mM3F59WTpUtTm+xjG5khVXZO7Xoby/29ySIN92+whziudke+4avue+o2cAnKBxRwkUycEeH18N5zp4JNt7Ih75JMTKnW6Osd7nCeEsdSnbxTdKUCV0aH7IerplL7mLFKLckqfO03DYyNM0z0A6313MRXSwBQ95nhgwyK0rxpIe5COLw01Hrxi3Z/gyCxFeYiz7O6+X3762HqNnlj9odsKLCHkKEkQx1o/2reF2aTSUsCo6qQ5/G69T7h4M02cc9mWhW0s7PDMtyVed9UF1PPqgEq0wit3z3fn3zTAaAT6/w6XEO2xLL1cMcULIYDs67dYRQtOXoBZaNsdmpp29jFz+vKLJvxLWnwkgO08Sqfx94QVn3QTXg0Pa4rN0Q3McFeokCBSWikVtAK213yfvfV4xZN2vx7Q3GfIQ53io1T7J8IU9zjfQUO8F45JEDjNC/oAnTXD2/HiZEo8OwQ58UVIOstUPziD6/mW5I4JBgSViZ2kNnuop/8AjEvBZxCGJhIyTY3B0dwwsM09+PcegZ03B1+CQJflAOHpankaLXsvdGvTSOPHhlThfcjh//1gTXW3afyiwsXSW1UIL5C5KpQVArKdMW2BvODRrg9BM0QtNb/3Q/iFjtga9rak6xzRHBXkaqPCXRy1ucjosnEEsUDu0yQuxANGyd+ip3X//bceB78uKN8coreTvaB4S0wKmxqN+11Z8pKZc838pMKzEdyqHjy/hhJCV+jG/1pG4jo3vnlMFaVFtdAJZDkIuRrWHJbC1H9AOQmwpGCUWTy6Mm2GuEDi+y+S6R8bd/SmYsQ4UV5Il8JFl5XWkRMOkln9xPPZyE2Bp8xNMGQjKS+6o98QkLNsKkzd2CzvOwXFCYt+WV7izn48Bvlbki+iqdQMFAFcwa6GwyYimBEVFvP0rLPqcq/CZejAj/u4laJItmDaPK4piCP6ecCufIYi3J+yMw8AMKf5Wl6anFT778q96vDlDUk7mC0LWyVhf4ALQxDEoHTHDXa3n/wvKhB0uquzu5gyo0/wY478wPGLKk8cUzGNOENm2wHmdPox/OnGsT8XZ6fxnKzogcV8DK07LsAyYoE80Bu6Iclnz7XEo4+tNiI7jpTUp+JN9LHqe9gDxFj8aX4Lwq81ca//hebb8SEvoTjJ7TlGHgYYB4BVyNR2uX4PK/5uxaddc/6/ydBCbxl7Ac X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d97404f-e116-4255-fcae-08db69239626 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:17.0515 (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: 0uESICC2lODOvu3vukrqYvrdYTOmOuTPPCeOUIx6ojdfXdb8mu1ykAtJHAP/cq00 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5264 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org What omap does during omap_iommu_set_platform_dma() is actually putting the iommu into identity mode. Move to the new core support for ARM_DMA_USE_IOMMU by defining ops->identity_domain. This driver does not support IOMMU_DOMAIN_DMA, however it cannot be compiled on ARM64 either. Most likely it is fine to support dma-iommu.c Signed-off-by: Jason Gunthorpe --- drivers/iommu/omap-iommu.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 537e402f9bba97..34340ef15241bc 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1555,16 +1555,31 @@ static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain, omap_domain->dev = NULL; } -static void omap_iommu_set_platform_dma(struct device *dev) +static int omap_iommu_identity_attach(struct iommu_domain *identity_domain, + struct device *dev) { struct iommu_domain *domain = iommu_get_domain_for_dev(dev); - struct omap_iommu_domain *omap_domain = to_omap_domain(domain); + struct omap_iommu_domain *omap_domain; + if (domain == identity_domain || !domain) + return 0; + + omap_domain = to_omap_domain(domain); spin_lock(&omap_domain->lock); _omap_iommu_detach_dev(omap_domain, dev); spin_unlock(&omap_domain->lock); + return 0; } +static struct iommu_domain_ops omap_iommu_identity_ops = { + .attach_dev = omap_iommu_identity_attach, +}; + +static struct iommu_domain omap_iommu_identity_domain = { + .type = IOMMU_DOMAIN_IDENTITY, + .ops = &omap_iommu_identity_ops, +}; + static struct iommu_domain *omap_iommu_domain_alloc(unsigned type) { struct omap_iommu_domain *omap_domain; @@ -1732,11 +1747,11 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev) } static const struct iommu_ops omap_iommu_ops = { + .identity_domain = &omap_iommu_identity_domain, .domain_alloc = omap_iommu_domain_alloc, .probe_device = omap_iommu_probe_device, .release_device = omap_iommu_release_device, .device_group = omap_iommu_device_group, - .set_platform_dma_ops = omap_iommu_set_platform_dma, .pgsize_bitmap = OMAP_IOMMU_PGSIZES, .default_domain_ops = &(const struct iommu_domain_ops) { .attach_dev = omap_iommu_attach_dev,