From patchwork Mon Feb 26 17:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13572541 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 88DF9C5478C for ; Mon, 26 Feb 2024 17:11:50 +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=5sfahZyovKNtWs9AV6MnM+a9bw9QX4TZU6RrvRneTg0=; b=2xDXYnMhHSuXOn 6m73Gt5xeYtO+lQrBd4zAb3j5yqqPV71bvYNwycdJeXAsKC+Ajbeprl5t0Dw6eYCEFwu3hMqgR0mg avto0hymPeDjE1FdJwBbkNwQ1pZMaKssJ4ksFj4F19KbWs41nWZlahMm7MKpOHMz3HvKb1uE9vJKS eAotNSYE3hMbKRWj+QaLLUMqOrep1uyM9fKZyz4N+cRnDldkjP+f9OqLgnCjm6OAlchrmsjBJH5OY JdT4a5WUFLpuM2iXUDjzMVLGGmOPxynxXuFustohAmsL5Nhticw1pkpAJHn5scCA2pbKwQSo9ZX6v D6OTcIqtOJ0dnpG/fA5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reeVn-00000001rVy-3Vbo; Mon, 26 Feb 2024 17:11:31 +0000 Received: from mail-dm6nam12on20600.outbound.protection.outlook.com ([2a01:111:f403:2417::600] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reeSO-00000001ph5-1Tg9 for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2024 17:08:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rw28FjVxULC20x2h4wO/E3GNWkUMX05M9kTZt/UUmdEgZuthXXtcIF9IqX4h/EOrCwFCcvwu+LX2R3sY/ykR2etMoXcgVnqwOEH36Bi9MUFV59Irdc8JMiEK1xFbs3R55p9UTTH6UFawXiKft+pA65ezqCDtfNb1IYsceeMK6dS44NggliJ01smfuRtOMRA/4NZA6hvglQyM/mVIAqF1HBtVA8QfO028h1dtfXQL6ZgIteJvvqerSOriWWFHJfe0dPx1LvCl35k50gyFydEoi7Hy3+c8fJHIKkxyvBF9Eh4mDaqjOd6mNOpluEwTeNjp56YnMfAk1gD75iMHVEEG2g== 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=7bsm4AyVj6JAv4irvxq8zb1l2uVRXCJk8t63xPJB2GM=; b=EGbLGuqVlA3zXF3jlgHH+M/oZaBoyH1KXHXRTcgtywFu96/45j0f/hNT3h8lnfuqfxRDa0peSUa2kOpeh4/rlZ1U72NKb0rZeeb0iAR1A+45vBqclbbJ6/FOEMLB2+x08LmrQf6E2Siyg6LjFGdKaGgrcIHuRu95oB67HaD1sBb6mJbhEGOujR5D+hE8+PXWR/ivDWPXU2IMzW1/ywRqIo9curjgQPVWZzfsMl8Kg9EojtEpsp/J7nGjpxUw+m8UzoyJSy1xK06dE1hk0iI33KxOjAsEUd9oy8LVenTNTVwK6f07Zfgf/8ZLErjM5OU5p7K4PisM6tuxYxoLnXWY9g== 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=7bsm4AyVj6JAv4irvxq8zb1l2uVRXCJk8t63xPJB2GM=; b=J1A5cWx/mHF6xbQdgLAmt3YhuL3gItyFyTowMGvvWAV3/9l5AzUxmSvqL8iBr8WQWNg8bapcxGi6k82e+Wvjuh+9BgMu55m4MJuMFmH+YbUIfKaU6TDxbjcFAXQnMWINweL3y8poF0yKXPVCBUqbc1wnxxcePEghzLglaxaEbouqdvwB/ES4LCpNcDeJ/UW2R6oAOPwuidrVtDGYEYbwIwLR18aTtTIwjJeYtmcF+EOkbsXehqbtBVZe7ES1s/q+kryBM3Iy5uLhcSK5SoPAcAbM8N2v/GUqSs/cCYtMtcXtc+fCMpIf5splgI1HT/McnGns84BqrBdj0xwDI8MA/Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by PH7PR12MB6905.namprd12.prod.outlook.com (2603:10b6:510:1b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.33; Mon, 26 Feb 2024 17:07:36 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::2e3e:c7c0:84da:3941]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::2e3e:c7c0:84da:3941%6]) with mapi id 15.20.7316.034; Mon, 26 Feb 2024 17:07:36 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Lu Baolu , Jean-Philippe Brucker , Joerg Roedel , Moritz Fischer , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameerali Kolothum Thodi , Mostafa Saleh , Zhangfei Gao Subject: [PATCH v6 14/16] iommu/arm-smmu-v3: Use the identity/blocked domain during release Date: Mon, 26 Feb 2024 13:07:25 -0400 Message-ID: <14-v6-96275f25c39d+2d4-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v6-96275f25c39d+2d4-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR16CA0052.namprd16.prod.outlook.com (2603:10b6:208:234::21) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|PH7PR12MB6905:EE_ X-MS-Office365-Filtering-Correlation-Id: 440554e3-6684-492b-050d-08dc36ed6b0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R56mmCAsDp/lDa+JLaQUJ+ivTsdDuOxLUgp1QnumNJzp5G1HOG7mtVOLp/cUSlBoynbI/ITkg08Jrv478CTBf8ztah1Uzh0UNpfjmXIbtSF8bYyUS0vHUukkdJ1416WAk5bt9+6ZqHHcwOKjj8C+eJiuPx/d36tPqVuK1uVxlrNcTk3wS+ebGWstUOcKrrB5hJH0GeOYva86iaQwiKrrqoaEFVnTVaQGXx8DOfrtaqYzgFNx6k5oQ7J55tWP/4fE+CixvBL+appzE1cryrnL7b6u9wVtR1w6XDj217F9k+Mpa2ESRn5ivo0Dhrf/+s8uTfD1q6MMNFtvypNHN29lCWnB2lH+NIyb7rTOmabrdwpUw+0ukEEXvSj7GbrHaPwG+jscBnwQ34XwyXMfYlv1cpNfHBtHMgPCNiXEdCO05bDMjRc6bfMzeVM/8lIekTaW2Fq8rDk1dg169ftTTz5h/lHsJS7A7pMugyHpmECP/SdaBSbGLhu1uGhwGBUGwJEhENa0PmeyiMBjmaFwpYJN6wpwFECER0sypSEO8AVXW9r4PHDI1Tvmf2LtZGoYD86leSz5Cy1AtCivrHCihgnr2hv6Wd3tVoJTRxEI637h4bHmLy4EN/2xki9PcKhfll0Q X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zW0GhHDUQ/N+iZSh1T7/7VxEEmT32PMqda52ptUbSXcUdfCm7mQMg5csYkQcs9Vz92+LkPIAcPVLGQgqz9XvSdzPaCQvSZFeaZVN74RRtkO8QRP7RdV4nmTi+mx3H+q0WMsLaEoxzS3cWpv4lqg5ce0wlz+JEM4+KW5ss3RmCgkxqwJw/lKBgqZa49sPD0MYJKUfrFmdSLNrRGUuSX7baUZE0AdAbDB064GQ80VDPZzS2bKsJ3ITcdC17btmUZHvu/VwF6dbdnjxamEE06WeN5SeXlVJhg6q/SVRRp1OT4YvDmVoqBjuXec3bzc30xJMOxuW3N3RrVghTVUtjd4UrlzWJ356NZi0DKeBTZKWBK40cfZ/LmOAiow01XS2tg/FJRDmFUXd3LXfYIyw0LdKe68wCMOA0o/xSq0VYeuguL4howyaMIyPdfEWtd5A/cLfH1TYjiDqC5mhYXNKQq4B9QqJepSY+oXROVUXA0XgPPWb2YXjbo/K3yyZhyH0037Kbwzke74HGtbheXBsGEr10jIiF4g8AgX+1UypVMKOZWKBxcWwiCRo5UtYErGmcgmblGd26f8yuj90paNcYLPG1Vrz/fo2VuKH0bjMo04ePijG+3lQBW/7YOrqzD7uAhjZvlEjejAidDwzwpPdiw8PP3WQ62urmmUPB6zhcIosIsxHTFpM3kZK4ZOQP08bRwVLdokFGaJxYLnli/+1jBqo6sKbTNteAj4LPaD02rGTzbpWjV6vDGbbfmpCQQdUi/YKI/iypjca4M0bLMZ9N49eOSH/X9XKls2DFnFesN79W+EdNbXL5FF8dJZ4RrqjtZyPyXt1E/RCUXI9xyE33vehUGPpG86BPVRXNoPjAQwHKbDELe+QE+0T+rHsNleey5Fi2veQYADc+nq1HLAyT3J6QTFz3wBxn8E05R2bmW0rLkjsmnZIVyWecymiyETa75G1ptYxfiR4Ovjgn54cGLOW46eR9Tss6fjaBl9gduMvgly8EzDXKU7KB6zg/7KobDrKoM/GvNh396d6v9IWoJYhO3GkZ7nWp1IVH8t8iWlrfMjKEvTWi/rXDs4JU+N2IaCOflXMWAwFQhQVOlK2Ae0XfxOQSYV4zmStnETGcIpxF5Ewa+QvWCd6Rwt3rfSHK1m0lP9+A3DFe7bkCNZj97jg8VJrPCD0xRkZvnhzDo2kEQaIdBuFZ5fRwNjKfiAXKC+DK6Ge10hJCgHx64ywhKWnNkD3Q+srXFdN0ajM56bLwZDBFaC08ZMSQviVsbiIWXI3nrECCkNxju2REBvdInBT91wRvKzoVooSQCsENCXpxHsRTG2+buJrfEY6rpnY1PYuwWoqp+BbVLMEDaZ9X1qDzJyadnpadP23IcxOlJIJwoRG8K+qlMCFPKCgZR6M4gvQzlVXT4cp9nqWPgAEA9J0WzBtgQtlCpEs0jAhkrVZGLqr+ttfIviakhf2Y1PBdqD7h46OqzAD2U7e1agB97tuz5b980DqDizHPFxf15sgnS7uutlF9WTo3s0R01/1I89jxZoIHQuXdOGMH041huXzWsbP66wsWxjYCUjvdRgIg+rE7BgZXxF9dMRETLfl1p+z X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 440554e3-6684-492b-050d-08dc36ed6b0f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 17:07:31.2294 (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: m5w6i5Q3W+Ab3Ip5ta/kUKWXFPNWl3N6eC5iiAo2OK4PF1XXgNCyZoKU16WnILZz X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6905 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240226_090800_660236_06E8D064 X-CRM114-Status: UNSURE ( 9.01 ) X-CRM114-Notice: Please train this message. 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 Consolidate some more code by having release call arm_smmu_attach_dev_identity/blocked() instead of open coding this. Reviewed-by: Nicolin Chen Tested-by: Shameer Kolothum Tested-by: Nicolin Chen Tested-by: Moritz Fischer Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index baec827e6ae446..1303e9c603fc6a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2924,19 +2924,16 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) static void arm_smmu_release_device(struct device *dev) { struct arm_smmu_master *master = dev_iommu_priv_get(dev); - struct arm_smmu_ste target; if (WARN_ON(arm_smmu_master_sva_enabled(master))) iopf_queue_remove_device(master->smmu->evtq.iopf, dev); /* Put the STE back to what arm_smmu_init_strtab() sets */ if (disable_bypass && !dev->iommu->require_direct) - arm_smmu_make_abort_ste(&target); + arm_smmu_attach_dev_blocked(&arm_smmu_blocked_domain, dev); else - arm_smmu_make_bypass_ste(&target); - arm_smmu_install_ste_for_dev(master, &target); + arm_smmu_attach_dev_identity(&arm_smmu_identity_domain, dev); - arm_smmu_detach_dev(master); arm_smmu_disable_pasid(master); arm_smmu_remove_master(master); if (master->cd_table.cdtab)