From patchwork Fri Jun 9 19:56:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13274409 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 BF65FC7EE45 for ; Fri, 9 Jun 2023 19:58:24 +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=7PFOSgOZ9n+uFPtf0WaeH/0bVoVMMUZrETUOwCFOLv4=; b=iyGK48xTWswh5N wYFNdp5IvXtxs27NzCE3hEmJf3ajSoIb0Wrbffq/PcWaqMTmp9xct6nZ/spj8oBsCKsmM1VapFQzJ Hnlz2gegyY+3dNVqQ9Os22utlPgHbZjB8xG7/yySA5JAQR0FKB97/vhh9Ifo0DuFgW7HebMv77mL+ TFyRBMtJxomJ5gtqKNYVPNOhO3409EY6Hm5imKk9PxQ1j7yUX2BuZXS7HiNRGZUwalVn6kzMjKeWS lIB+XE4QUKFSzWkKKzDoBgd7dbYmYYnQvHry/S3jtUtV+4iUyLJNYbKyBxiSGZa+1Bu37XJXmk9E7 SHYbgpllpLOYg5r13kgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7iF5-00E5l5-12; Fri, 09 Jun 2023 19:57:51 +0000 Received: from mail-dm6nam12on20611.outbound.protection.outlook.com ([2a01:111:f400:fe59::611] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7iDt-00E4TN-0o; Fri, 09 Jun 2023 19:56:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CVHGT8nYRKuvHLh3U9XNZUJt8IR1tJrtjX/B1UtxCSYq5mRXvKgIXVk35ICFUJnGe6fggOHnDn+kMooAL00lbGSj00tQ5PDwuvECmD34law3eG2F4rGxXoLk5/hfh1JB//61T3JRzXgoZNuPpRC/gMkphNnRssRQMoq2XTHizCqlqKAP98GWyc4cZSO9w2iG//bCL2ABb5FBIipq+dqp13fgEHsG8/QZ6WnsPaX9I3UvCAjPbilQsLetIWRRro78kv3/s20RP0q6xK0dLs4jW1nuG53oYLQQDwZByM41eyEhSXMQj1A2LLaMDQ+tSmKV1mpdZlUpw+rhwWHPOMDSlQ== 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=WKNaZwKctNyYbRBuZB+xdODMOwwW/nmEM/YaUXrFqNI=; b=h0wx72RqqvSLBaCJ3dorWdFv0lQzBmf5F1OyOrQEdcW7AUn6k/k+qW8WQU13dNyd6j5ZBVciNj9JQNaQ1W4SUGW4xXa+87szoOluuxmn3h9jUxa0P705N+qZ8+xGzQA7L/f2I07WBo9ERpfmfqYS4KLckXfRAGYKhnrW2qH09RTTMsPiAddOo31SfAo+bUase9MuIgCRwlF4113kvurYa35uOI9H50fRDHXy6umHCqaF3VOmPcQol3k2W9y5KYfaI0RHz8+u+q3A9tUqt7GlK8B5HcEqglHXRRczbsW62mzxomBlPkfXnJgHG5bqj1Zjs883jzmQ65LmyKRQDYW8Qg== 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=WKNaZwKctNyYbRBuZB+xdODMOwwW/nmEM/YaUXrFqNI=; b=bMBF32L423d19120rb6u5LRxm+r2QPVdpaA2lylSPxCuAV3msczT/q+bhJfLByRHB/s+5RgWR/0bPkv2nj9h8aAuxptSeh3DwQRblBn2MAYhVC5Ies5X/mCBPlaV+h8eq5aQ1CLx541zy1m7nj2BSfVeYiCHQTRyceEWzY64tcnsnY/ntnE1HWfZpmH0fRRPeHKnEtOXSpPLj6FtjB0yRuMAgWxnRKR2wqF9suTYLBhiDgmTJ4ViqbmxuIsHykeLRqqd5Rgk6XpVy6LbULuSXOxaYKlW3oMJsLTILagDcFmNl+h2Nb++fN463C1XabVG5+7jvbOE8QwGe6gt0oF2DQ== 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 MN0PR12MB5785.namprd12.prod.outlook.com (2603:10b6:208:374::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.36; Fri, 9 Jun 2023 19:56:24 +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:24 +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 19/25] iommu/mtk_iommu: Add an IOMMU_IDENTITIY_DOMAIN Date: Fri, 9 Jun 2023 16:56:07 -0300 Message-Id: <19-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: SJ0PR03CA0379.namprd03.prod.outlook.com (2603:10b6:a03:3a1::24) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN0PR12MB5785:EE_ X-MS-Office365-Filtering-Correlation-Id: cc2108ec-7028-4271-6267-08db6923993e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 00oGCDwASLtfRkMx+O0VHOY6cgwuctTFEbT5bvZOs7s5zty/ma6+GZrc0/eQqbsvlrWycIxB33yb7pacWK4/FUhU7sX1dQVLmWkdNqlNdxaX+qRBrnln8n8XPcgCt3V6TLR2bfkMiEoUUT195QLdOdGFrFXuy1KF5UjTZJnIwfQjImdp2GSRo0RaU2iaxnPmlvRbhFQ6dDIvU9fhl8OHPIJ8fYU+wia78Qp40QkDCMvSZcPG56/Hm/aHjkqT9vLYEQ8nj1X53i02K9woMjaywpSyBUW4ooFNOnH+RaWDewOjRXzCjqfg2XvucV27gSrrsAGOAF0yf48VfsOn71Tg9hXgx9qEfVE2Raq/nYkwlJSSl8lTBNNBzUV03jVifflNBgbIvezTEmsErPruJF9tJURVC3yAyReg1OhVZBJZ7sBghS97QKHraaf5Dj2Do2SbmNK3Ki3lAE0WOSNVwcw6ZKfklwV43zj2/N5g6dm7czI2gFRO43fchJrgzmM7vpw5iS+yrhMZh1E8q8s9GFIr64LRWDBOSZJwxzPAMlJhUwDZ00/tp3FGzQ6CTmZPVU3nI1LKilRKOFqY6YulVkC1kiyAtNW0FOFlNcv+l1kx/pQ= 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)(396003)(136003)(39860400002)(346002)(366004)(376002)(451199021)(83380400001)(7416002)(7406005)(110136005)(478600001)(8676002)(8936002)(4326008)(86362001)(66476007)(66946007)(921005)(66556008)(5660300002)(38100700002)(41300700001)(316002)(6666004)(6486002)(36756003)(2906002)(54906003)(6512007)(107886003)(186003)(26005)(6506007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hvh/cn4TFtO9rbj2biQhs41HjQ276LzJuSKSrEs6uL8PcobCrKIGhVqgbH7s2zrk4HDDO9xv9mYwl+JOBLp4CV/v7bDf/a8Hrk2n1PTS0be2mmYiamG9rlv/OB6edATqQQ3CMxER2f6x2DPvWgZvLcwu9B6Z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5jxIGZx1wh19IYZ6+xEzF2n0t5iyGs+wQdVrNiclawNSEsLR2GD2460LYi240PtrntHZwF+V9iWg8gwMBBKVdAX1E9qZmrHlaw/aPzV7jCtAVZFwwTB3+opgSsbFrfhpiTjX1U+2mTDyKLvkuY1TJdsXPDzePg5MZZqajeLZVUDr6Js4NGXfZuyXGHl8OGkITjF37Qq9/juJ+Nk5xFLR3IesOyFeqBEbaO9VvFfsRufAE+wPBUy8RmoBEyYMlkJjA++cbx93kDLZvmBu2Yg0+FXi1DSq8i9THq0SQRg0rNgNBy2Bf5Emu1yQw8ErVl866nDzwhDDJ2Du2OPTzqr5w7gMltkAji3yodo3C/SubN72 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc2108ec-7028-4271-6267-08db6923993e 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:22.0757 (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: JEPosMkPTtTOgKSQCu0q3P3dn5UbdNfOKe1dQwUp/ycc915mrTMNb2q8tDCWo+Oj X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5785 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_125637_303674_51E462FE X-CRM114-Status: GOOD ( 10.46 ) 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 --- 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,