From patchwork Thu Aug 3 00:08:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13339025 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 CBD04C00528 for ; Thu, 3 Aug 2023 00:09: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=q4EZcA9piRHiA3llcthFuTAhGU/h2m7R5aYgV9JdfTQ=; b=q06cvEjwWrre+n K1frplSLq3WezypHOnoelrTltU/bNLzyOv9ydUljoeouSxZQ76hCBaQZirje/ipr39C3Z5n/2coBf Hg4iDqhrFj+QXP7IZeZMVjCEQ2kzZ3IICaaW4ER3U2yZnBLMMOGUmmMDku4HGSmeuy5phYnyG0spK c85ez23TlcYaksBLV01IVRdFhh/HOgzEcsQuMHVlRfGB2UG6LbGuxg6zHTO0Pok45aVLKCIsjLG7+ ZO5JKLAcrTO71N40R9zI0yIHsDTVtOhJvysry3cxUU+mj5cnsiZiJbNGL3oJ+GiNxm5vjoMz9Rzcv Dj/SzdcKnPadUuoYO/pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRLtO-006CpZ-2t; Thu, 03 Aug 2023 00:08:38 +0000 Received: from mail-dm6nam10on20631.outbound.protection.outlook.com ([2a01:111:f400:7e88::631] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRLtG-006Cej-1y; Thu, 03 Aug 2023 00:08:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QNrEWueMnOUiexLFc2X6dwlStMlqTBLxWHRST6NeREjUk94VRkxn5PcrqOJ+fGbVD7uvzK2ws4K1muO8a7UN0iIWr4mIUzXXXCT24BsGG1KxF4iqDwyBhKLbt/85vjUUYjRMODPR59MeeWa6b3Wu2P/xdYCCYAwjhkzSSlPVjt0yraMkk3xCjk3FrVW72sEg+Q7/MoD+4c7kbTtcnYXrLGWz0nwkGYz/g9RlYTaGafWKdMDnY3lA5EtvwS0Nk07WFFwRvvmnIEiPcmO+QiH6qr0F1Se/cYplGgSmRrOkJNBdNL9ivSld2OBq8X96PmkrbNvDyc0IgPeuDA6qHwuNiQ== 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=2PBD3BXOVWRc/f35qHZJJJCRX+RoW6GH1RDzoMlN1lo=; b=CMzvzAiXqt/JGZED/N2Z3EV+z7VOQGO4KQ9ex6tnuvOvd5nldj72TSmQDYBdTLfPZ9J4VXUQbjAHaRDpV13ZLo8QvXyPpBkLzX5UeT35wGoDSdAEXQDefpTiOih3g/YBscYmeRhEjLCmVJFEW6WXc/QUMEafbJgovOOj0I6ljoWRGz9eNPUN1Ja9hUNmiN55WAPtcDkd3+N+ch+HFC84TZhBILi8R2MHwHKiXE1dZgs1AIm+cRqwEGuKmKx1DQP1a0TcK1LaPO273oR+SJiuw4nHLzQYpjckz4CCHHtl6v2qNMb8k2ChVQvjMgODB6GdstNr76fG4baXcip8PiofCQ== 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=2PBD3BXOVWRc/f35qHZJJJCRX+RoW6GH1RDzoMlN1lo=; b=m8hlS1R7uUnQ0X0ivQgKoVMe2TxCz6tDf70YKlSpMOoVBC09VbZFg034yD3Pi5kn12cLjxULk/VkXO4crQfedHuJgqR0ksevc89QHE8zQbURdzODA7TtAW5pWHxTrVn86ZY5GgTN8mZtreIb+C2pLbrIO/gPC/YrB7GinoAIJVPJNelTBjGDEZ3AJAAbb1bDt4ychQlizl7DPDGFeKZYssbIxhkb4w8BC2V59ORes3b5oqYUY1DDdWgFYKGXIqcWuAg/XuCefdkb2vrV6fB2eXTDSI8gVQItCtCr5LuERZLviCpxWnzKb84iuIYfOLDKK4/m+TWAMtOU0brU0MMHsQ== 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 MN0PR12MB5809.namprd12.prod.outlook.com (2603:10b6:208:375::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.44; Thu, 3 Aug 2023 00:08:15 +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.6631.045; Thu, 3 Aug 2023 00:08:15 +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 v6 19/25] iommu/mtk_iommu: Add an IOMMU_IDENTITIY_DOMAIN Date: Wed, 2 Aug 2023 21:08:06 -0300 Message-ID: <19-v6-e8114faedade+425-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v6-e8114faedade+425-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: BLAPR03CA0127.namprd03.prod.outlook.com (2603:10b6:208:32e::12) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN0PR12MB5809:EE_ X-MS-Office365-Filtering-Correlation-Id: 3225a828-dfe6-4eef-b3b7-08db93b5bb0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fQ6NE1JIp6e35ENq5wO6GMYsRFI0KXLUWvyH0MD7Az2GeB+IJRCkwIUdkpnwkJocpwjtRvreYvjNdjJrMgy8qFqEU4vw3R0kA3CGOU5dh7LEsCyV0RXee8X/XfHsiteGHMS4UTLX+KxmyhMML9rJd62H4BaM8nkT8LizG4CrUw4E9EJ3blcfRd97GkYvzNDp57g8dCQxen5ITJH2P96tmpAstyshLHHyTBgY422R43UcJ9/t+2oVScKG2kyiryTeOle+vFSclYwbRCPHSnCtrsDZMqsd1Js788M5FOOBYVJdfVEDplR13+VfRF5y59SW7GzVM5JK7vY9veIJ/yAFhlhbggj149LqrU5AewbEcgFBRyumMqXqbFhZhP6zEzz5GjldqiHiXNYgkU7Xq/j82oEaS3x66eIs8TOEoHjavb6HsW6SCAQJLmfSZVcKU3sQIZWyoNchCkrneIIY8UZ6SzKellt9zcJjosf4ywFMWcs1PSDWNezePREla5PDxsULTS5aFk35qIHfn1bwvV9o6OJnsuOYlp42SzXW6BdqZ8mXL2bKVnuHFZejXzJ2Az/+FR8BRlr34UpeZTslsR9oMQp9Oes0UV1apJoDheYGIy4= 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)(366004)(376002)(396003)(136003)(346002)(39860400002)(451199021)(110136005)(6512007)(54906003)(6486002)(6666004)(921005)(478600001)(38100700002)(41300700001)(5660300002)(316002)(66476007)(66946007)(8676002)(4326008)(8936002)(66556008)(2616005)(83380400001)(7406005)(26005)(107886003)(186003)(6506007)(7416002)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WBsrs6JzdjKbl+poKKzs09KIldiMTQQm/pczdvksjsKF+oUSIuF6pYoHHO6OqfPg70/wwDuNSRaZNVZUHhpwG16v2NYY6jS53OVivcEr9Ue8ZVfgytDc/aNJ3xTQJkAvcSDDiwSSfwzU2/OQhLauqHXs6aYza5WcWBC3cGUwMkHdf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92QfWo0E7vs44Uo8QUhdhiUv3pN7boxTuoJqi/KO53Inmj7QLbba27nRJxZwjj2/jB0JLVdyakK/1eiveB2Rr86fkIeXo4lgcFY5YCz2hZE17YmyF8SbH/EELNkGmuzatIokMcsv1e0r2499JDRlDYakKCvNDRIGZD+yu7xUhxR1TJ5ikkERh4s+IYL79Ii3PJzBzgev5dqOVGq7ylbqny7XA6rGM0W2GKDfCZsX3m5WLJXjFlp5BvLwkh4RDKfjAiryGSLR0swjy+x/N4hcsoHYb1mFLioNv+qNjeiRSEEEuuGRFrL2K4VzoUZeRsTiKkNHnzzwnk X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3225a828-dfe6-4eef-b3b7-08db93b5bb0d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2023 00:08:14.2758 (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: DI1VL8RhrcKWWECllTB+EZUuUL+Yn+0p+AQpehmasTCGxwxzW+XaY2JFf/FCZJoZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5809 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230802_170830_663772_DDB6EF5D X-CRM114-Status: GOOD ( 10.68 ) 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 This brings back the ops->detach_dev() code that commit 1b932ceddd19 ("iommu: Remove detach_dev callbacks") deleted and turns it into an IDENTITY domain. Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/iommu/mtk_iommu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index e93906d6e112e8..fdb7f5162b1d64 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -753,6 +753,28 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, return ret; } +static int mtk_iommu_identity_attach(struct iommu_domain *identity_domain, + struct device *dev) +{ + struct iommu_domain *domain = iommu_get_domain_for_dev(dev); + struct mtk_iommu_data *data = dev_iommu_priv_get(dev); + + if (domain == identity_domain || !domain) + return 0; + + mtk_iommu_config(data, dev, false, 0); + return 0; +} + +static struct iommu_domain_ops mtk_iommu_identity_ops = { + .attach_dev = mtk_iommu_identity_attach, +}; + +static struct iommu_domain mtk_iommu_identity_domain = { + .type = IOMMU_DOMAIN_IDENTITY, + .ops = &mtk_iommu_identity_ops, +}; + static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t pgsize, size_t pgcount, int prot, gfp_t gfp, size_t *mapped) @@ -972,6 +994,7 @@ static void mtk_iommu_get_resv_regions(struct device *dev, } static const struct iommu_ops mtk_iommu_ops = { + .identity_domain = &mtk_iommu_identity_domain, .domain_alloc = mtk_iommu_domain_alloc, .probe_device = mtk_iommu_probe_device, .release_device = mtk_iommu_release_device,