From patchwork Fri Jun 16 19:02:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13283199 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 500EAEB64DA for ; Fri, 16 Jun 2023 19:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjFPTDz (ORCPT ); Fri, 16 Jun 2023 15:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345872AbjFPTDq (ORCPT ); Fri, 16 Jun 2023 15:03:46 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2058.outbound.protection.outlook.com [40.107.237.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69CA02130; Fri, 16 Jun 2023 12:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wb7Yn+8+apISWwRD/1GcDAEYLLUSIN1ynPp0VFBKJzgeSzBJ6VqROYPGc/q2tvlPcZNPfY4ZmbYIS6msYVvEUmt9R1k/QbbQEtCBC4fvEmF/NynrdTJ8WEvo0AdD4/k6oRisSbL+z5JfDJk2WdsgNrnKkMLVyEq3R2s/sMnYuiGlhXcv6XpDDVcadMVyPJC2cZdK5k3oZKkZRRcq2soONWZi7OVuBHbeFVUyU6OaVMfWCORENP1csRDjlywgqG29nRqM5gYzro8KJeov3M1mBeqkPHUklIysKDLV/Kf7TJ8jz5IaM/WI2yNhlWp9ZCirrRtZqp+1VlPDzoY0uTWVyQ== 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=iQpTVigddQ3W1bvpxs9sZ1ZsGLS41PkyGIqEgROO10uFYEA0ZGMWUx+SNilfdqJd4s863rDQp4GphYMP32Uk7RQkCarPc1QOWFpkKkLJYtfq099aB9vkAqvSRzRlI9pmRsjCO54aoMNr/ICNQkdEbzin/iGwDOXJXY4w0j5SIDYPlszTKx77gMjWlWCgKHjWu6WVomSGDRMLuvsVGGDyxL0/C52AmiJzS4EBmJ8tKseQbzoIfZspEa5hWOO6fP+DgSqA5ScowcVE2CHVYClO9AgwMcvLcPGPBvfZefAntWkC8xD2yaClXsyTdEcgARFZzUCo94C6vVycQNYqRRtutQ== 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=V0n/5+R+0FViFScxxs8W05wMBwG7YYInHsPO/52mVT5bE44trSaLk/hWejunwAIHN2Xx0rgXIVdgRLCX40NI+7a1K0o4J65P+gM9vgUjJ2zf1Ccqntf4rI+aVTKtPOTxFHFkJEE2JMOUMpJyVSztSiuhyH/X+USbMjKQBSI83I08ddKISafFw3z4gGeiZKvvQzvo0Ug4FuI3x1Uvf6/9iwecpdLoy+Aj9p5RCXIGVqbFM9C0ZkKrBUKK+R1BJMOrhvCNIk1DrVrR/wMck10uiebIEnR6PJmRQ76B36K+RLFdvJBD25JSDnYEEjZXq1nct0AvRXJ0d0Dcj1cDpFS2kQ== 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 DS7PR12MB5912.namprd12.prod.outlook.com (2603:10b6:8:7d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.29; Fri, 16 Jun 2023 19:03:09 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%7]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 19:03:09 +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 v4 13/25] iommu/omap: Implement an IDENTITY domain Date: Fri, 16 Jun 2023 16:02:42 -0300 Message-Id: <13-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR20CA0044.namprd20.prod.outlook.com (2603:10b6:208:235::13) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DS7PR12MB5912:EE_ X-MS-Office365-Filtering-Correlation-Id: e15153d6-da58-4770-3404-08db6e9c4c38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uu4S2mUnHhscO0uGBY+MQu1YJu5VIIZZa3GiO7Zviq+PBMazSfLDVWbCD68f/DINXMPuDMuXZY/Ge5o0rlYKu8a3ZuiEK2HKkrbvdYr8qh2gQ0VHWf3EnFW6MgTlwIP5fxbGbL8AzQq0DIQoQ/zzUzwMBBAVni7zCR9/BEp2xzkAxB3Nss/AP2VY30Tg9yqWCGGRVNkcDWhO06eN7tHAA45zRhV4vv8pn3EjCgRjfyAhX+NPi+6zA78I6nPDoSzfHsqw8CFbMqDVmu+Bze1lrI4LZjcxabNG4jEJCe0BdHBsjDj3XrPUjx1N9YbYcsO6yS9fJUkpWoDVhw8tS5XFJelNpK2XnoK9i+VFaSXGvnr7XnIhhzWvJAzbyTMO7bDOHFEziS9NEFJrPTVurvErcz6LGufMzHU7mcvkbsqqBgJPe8x6AGwv2NhA8tTNy5p4ARJRrRK+/i+2ALJaIPpp5JgSveKbFpvuhcWytstoQgRe3blEr2riLCWh0N4PWW1kpfxnSyWTFa3asagsRH3XVImXHTEONeg4J8SeynZOlnEmyjU3Ilc+/2GpTg8D3nAcXM8tK3lLQTBpv9czwjtQkOOuLWdEsf5pCgtoOrb3xDw= 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)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199021)(36756003)(86362001)(110136005)(66556008)(66476007)(54906003)(4326008)(316002)(66946007)(107886003)(478600001)(6666004)(6486002)(7416002)(41300700001)(5660300002)(8936002)(8676002)(7406005)(2906002)(38100700002)(921005)(2616005)(83380400001)(6512007)(6506007)(186003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v02JbY16jTCFtltKjqx6yHgbTZKQGxkUbaFt3DZXk6V+5qgIsDje6CD+tmUV4q6YD8C64SGeUEystgChlqJ8v5gTnGc3aNY10Ciroer49arShxPiXpeofrXLLlbFQu69BWSEgcMtiS+Z/FWn/VLBoDHMO7ovMIZAlbr9S8CY8oD+4Z9fCQLPl8aimVYM5OZ2QJRguqKSPz33nnGT1sSldooFJP78+jALi0any3DhaSqyzQ5c71WDfodFdPN77Wpayl4LNsgRI3dWVi0OLQpxIcN6fB5yHkKbeANwNKX429Tb3adSdQQ5DEQhy2rwDwSQD5cJqs4pcUVkRptKETsF/w81PVItW1q5fpmV0//uPEf5psgz/drcde24QctD7/JVM3G3ye7TVCBSFIs0Uwg55qjHBnCz+vp9AqnlyOq5FdkNU0jTY3RH8IJaMmGMe4L45fYxTpE69h9u6ifTi0qYjDH0HzY8RbU8w9J4Zw+QQfk2ytKP5r2b3HWQl0BeQSkeULsemNw2scaPpE8pqI5dc7rqBosMMfMy1DHdiSQxUTOjVCt73qTirQD2yQb9Ea4njSPq+l2uStMsOug49PY64S/WvBGOMMfY9ZixhYwla9h0HbdzJ/Hpdi01hp/gtB8EZX0/A9fJcuCKg2Ld8eCJqjABP78Q/OapnAl9JURLiMuP4uTdJCzN8QJzMwOUO4c23F+xcKj469jjoPEALKQ27ZTNrQRQWzcdYtSJUn3pQe01VeP3Kqq7S5QMijt4oCgivsYix/lR0Dtba/kFwH7o1OT1W2bMTUVd10nU1avORE3XXg8r6XYmO/sKss++pNrQlrQTekaluXT+AACkCwIUugbN5hNCygGlGnXhhgPHCEBN5GstTZongcwrNfJAuTzQ0ZGaTmzVD3SXxEVszQJKv/fl+sNvR1SS3TsTyL+JR2wnl5ln4P8PcLOTOpDjdRKQZA6ERTBJmSBqc5edt0WGAiR67AjN8PU1xGLq5C6UKbYDPETzv/AlWJnRHHifuIHkNdIAqP/1whBk70VD1r75B2rxS77BVIxScnw1QCnS8TaOP77bmQlx5r8JTnbxs2ph3z9nDhBOdxYq4pj+7cUDofCP0Xg9xemPKN1K0qAo54/1CcRoHwIG2YwvwJpAbIy4zcuHVBhj3OKLRQ6F/wdQkk8f4BPAOExhoADAO/oYDnHlCuAB3nyr01iVrkD38MhVL0Z0yD3hlPgAMxZhR51yiVWlp/VvAoWi6PlWOPpCZZu9Zh1usKyRf72qsx8pRouybQ216Wv7ETVvcIlZ4l9pV2F5cDB82+S1rZ/NIowZzA5+RCkNkE5t3iF2+VHHgSRiJXQYwY74Jv0GhQ399yHOrB7lAhKHAwM/qqCg3OVHI7DM2ynl6reBUujArwfHrsnY/o2vmQ6e/d0rSSRqxGYs2Hy0MaJKW9J+DYqNgPfYBTaPqf0HjcyI7Wi8qhDNJ0UNNFKJr+T+E5sAUGMapWYl4obuX2Bvlxnc2JqGN046OWnK3mX++ILhvXYE6xMSlTcfEI3eru/WWyqtIjE6WkN+G00CnYZixDRhAgcKXhLQRYiKZA5n6EhvXlJWmVU3xFrn X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e15153d6-da58-4770-3404-08db6e9c4c38 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 19:02:57.7178 (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: VSipxwvi8jAscsPkljHGjmlz6rYZAdnvitxnyl8+NhFFXY22uHdPo8rjPrWBq7/5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5912 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,