From patchwork Wed Aug 23 16:47:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13363016 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 ECC60C6FA8F for ; Wed, 23 Aug 2023 18:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=lp2lrjG+gcZBwKaZgi1PgSHcf1FuE9WHhgax0sHibO8=; b=Ru2ZPEhmV0Mpg17IC/JEuyqdUi C4rX0BjbfwJTcG1qIn3YhowUAue/Kyr8DZxvE82sfnfcRRB597clCv3qn9V9dPVfZ6shfCWu8a9J6 m9cGuJrNDWbWB5a0f7zqqVuJb9UlWXiRuRuEorzDvfJ8BmA+ds3Ej4y0r0D3Z1ViqkbmRrSS3tK0n 9XHi/8JRCKb4If1bXqqQJALGBu2KIueSRJgZO5YJfmYOORC76Ale8ZhtpnVqghho+UK1Bej3HGh0s 1U3FZ/JDJGrXfxDGMht4loSqhNgPaXe8P4pcOJRa/BVd3eC8Y1Ym22XJQTRLlcKzS0inw4aCCyhFQ v977Y2+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYs9j-001GUl-30; Wed, 23 Aug 2023 18:00:35 +0000 Received: from mail-bn8nam12on20629.outbound.protection.outlook.com ([2a01:111:f400:fe5b::629] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYr1V-0016EL-24; Wed, 23 Aug 2023 16:48:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WF/42T30B/k7wJJLsd8VHYD+5AAkLC2VdXzRrmYB6tSvxUi5UrFfViTjtVfKiYGzVPvHHhgyTK0vEbBzPB1lJGyaUYjLGhxom2ZSIE2x96tTjTpfZTLlpUIinARc+qfj2WyYJ/LsW1fIzTEPkvxpDiZW/j1ie4y6r1oyVbu1lCcg5/BNwciXhxofp1nlQvTf9fM9YtSlRqA5LZGt5ee6VaAI2YzyYa8C2GdOt69DrhUQbrBoFLno3l4SxvPzeAdFj+l98GcHVatK9G6TaOMYzdvc6+PNen1qh2WSVLDInBhCndbjFrcRUEihKQspK0+5Dxt4VSt4A/ZNczEIlh8muw== 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=lp2lrjG+gcZBwKaZgi1PgSHcf1FuE9WHhgax0sHibO8=; b=DeDIvnPAzD9hWKqOA+b/yxNpswsQ60P8cXtLrs9FvEu++WyfY0ECQYD65CmYokh61iRWIj/2o3ZewFl6GiFerR8zKts+q4z91O1cY50XL5SBs1nmfXZm3ShEiB8y6a65E+aFMhBrHTyCxb1wSIBMpZ4MVHthtJrwUDy16a4nRuZpb9Sj4Qu+nfTOQ+3saDQzxhYr+w2GR95eE/CqzCFZPhbIQa9u5huWS9TxivzQcKIj0af9mlR3U8EgpZ5HTvYasWEPqHHIUVroKOR5k2a8FzGJjXA2q9MzMsLMCE4qOJUPFX0vNlfXuw9SapNPM1AhBNJdmsqdx5pFW2d6zuY2aw== 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=lp2lrjG+gcZBwKaZgi1PgSHcf1FuE9WHhgax0sHibO8=; b=RPa4kVUvJArbZ6PLoJruVTtB7aqCW3sFWfqufJQO4W6SIIe3IwTUDborDRfWJ9dqoZCxRXTwa5BjqMtcfzYbGJjSbI48VYi5lsNInv4Fc8GRjtn/YZntp5O4c0JWntd02NUJqtzmfLogbQ9C0GWDet2ufHBja0V5dWO7BO+pJ92GZ2pSCQy6mvx2FbsKb4KdoZLWj67L+kQkZ5cvMwtWOU2gIE4/mzTRYz8Jlh/ctGdroYnL0tLg0BTKRJjQ1AQp0oBjMRscGyKiUIzWg0jWgA0aXalFGJXpcVwA4DN9PP2O8ZL5De1LQPNEeTfA6UVhJkAF7Wl6TRqSPe/g9tnStA== 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 CY5PR12MB6346.namprd12.prod.outlook.com (2603:10b6:930:21::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Wed, 23 Aug 2023 16:47:49 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::5111:16e8:5afe:1da1]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::5111:16e8:5afe:1da1%6]) with mapi id 15.20.6699.020; Wed, 23 Aug 2023 16:47:49 +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 v7 13/24] iommu/omap: Implement an IDENTITY domain Date: Wed, 23 Aug 2023 13:47:27 -0300 Message-ID: <13-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: CH0PR03CA0393.namprd03.prod.outlook.com (2603:10b6:610:11b::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_|CY5PR12MB6346:EE_ X-MS-Office365-Filtering-Correlation-Id: f2b64f42-3da2-45c0-6634-08dba3f8ab98 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VXrszHdGdMjb9IswWKxVkIrNXTYr/KKAKKdC04ZX9TMDm2mGDSEjQbQzJnVDk8CHVOZWbhjI8MyRP4ocU4CoON3NQqBWvnnVEgSflHKexTdbYfTvz4WBpePx4Vu7eUx6wR5vdNM95RYpkpuAsBrvlGrYGdZoQ4AWNwdAvnckJNZMJ1hlm/sbDGKeobwt5BaRVdfW7bKhjlLunwtpoEpdiJF1u/fSdQqgr9w48CDzdvO8uvgHLwg5fqtmkNoSPDfsTqASOSxqQ6otj2/wyR/xiKBN5Tx4PMHSj1pQgcIknZ3ZrAw3CrLrEcx1shyUcAfhd1KQpKS5OR3dKDsjvO102opGvPQOPu2NRmBFG09pxJz9C+P/aVXrnDLb2GmZBe2QtdCCajosmmPwqJkmG+yoUGsr4uySHPeciy8yQ/pMJt+54ZlQaZe7ujUzz8ahI4Q2ZqYgqScF6M6hIgedjGph9etp1ZCWNhy5vUAmhfrNMRhwLaAuyGtinKz/iIy3LW2n17hGM4XrGyvZKHWzDkSZ1l30AmlQ+J3297e6eFw5FC5Lo6OSYG9ysvM1e5ZV3IxL7wkbcydyljH8pgT7hfxFuCn5Bmuv17qYOxi20FVbCNs= 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:(13230031)(376002)(396003)(136003)(346002)(366004)(39860400002)(186009)(1800799009)(451199024)(54906003)(66476007)(66946007)(6512007)(316002)(66556008)(110136005)(8676002)(8936002)(107886003)(2616005)(4326008)(36756003)(41300700001)(921005)(478600001)(6666004)(6506007)(38100700002)(6486002)(83380400001)(7416002)(2906002)(7406005)(86362001)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PhBoaz1HzP+7zqOwDM8SXLjZx7jraRURUEuZ0AnYALFpSTz6MneAhkdXFGsHSDqWO9a1guYPC7Qm/TWfLZobpJp8eXI/rywy6WZOlLuJSS3RupdQf9jmeguEm8ium/ctUcPKYu0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ysYQX1NmDlCagx+95v5HKqszu/ZKJl5LmkRoePoraRpNrH3FmNyvzS+Hg22DsjmUP4A2m2cF4reXFB182g3b5x9pSKorjS3gGI2HuEpkxfeJ1WWYS5Rtfu3CBu7WpEtGnVXvVP8tXEKWiP0JR3se6zvKuRsm+rcfujR3/qxPYD91Z89WC9VIUJYFZh0YZzf4yWP0QdLNNLaGE+w7wJz9QKi6Y3SC6k0AtVbaus0kxalJtXgps4RtVXsWUf6CAxO6yBFdmqjmVJ5S+Wk7+QknPMV6QxD6PQbF1kJHEVCUWQQP5XamCD3NOiNP4bRIYKnepHUfZru3sRfBL6fClRYpqjwTRfADN0e2Y6fM5Lf5dDHavxI6G8kwntre9epwQqIjuAn X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2b64f42-3da2-45c0-6634-08dba3f8ab98 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2023 16:47:43.2257 (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: /ENBC/d1FpZw0JjSvUolFd8Fc+obA4aKed5PT3EJHS2vuyGzabTkkpJ+J8YgxVnU X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6346 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230823_094801_699690_093CB2F8 X-CRM114-Status: GOOD ( 14.13 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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 Reviewed-by: Lu Baolu Signed-off-by: Jason Gunthorpe Reviewed-by: Jerry Snitselaar --- 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,