From patchwork Mon Nov 13 17:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13454296 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 19D7DC4167D for ; Mon, 13 Nov 2023 17:54:51 +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=QKIFMskw1nYeg7FWuAgxK6x6LWrtT3xfZ7IU9rxwo6E=; b=q/o6F60X9kqCkb bUE4mWWdlq63kFHPRVjJRlaLrBcmr6XoJ762L9+DL0JRE39GElRr7+tIkSpc5tG9gdz4YKmYyAQ8E gzH47+lq1l9vJMBSYUA25iPym/L2TNCSamEqCyJbiA1NHEF/wNvaI+NwpvhvC+81sLww57mn3glGu TkogYGcJIMIoP4h9m4c6AaSc4oWi8cIO5GhBtCLB49G5psRE97NlM1BTh1LKXGcsP07RaIy0HtJl7 7ZmfXdVMVZfzvwUxOoBCUMYlM4k0LOGaEsomF6ddpxrUqtOZzO26K+MPkvIxaXaq+DhyVJk8VMWv6 F2g6gCB/fjDU3NsFV1xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r2b8g-00ES4s-3B; Mon, 13 Nov 2023 17:54:23 +0000 Received: from mail-mw2nam12on2061e.outbound.protection.outlook.com ([2a01:111:f400:fe5a::61e] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r2b8E-00ERTJ-34 for linux-arm-kernel@lists.infradead.org; Mon, 13 Nov 2023 17:53:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+c69ROHw41QIQgDEhBul1w+O2nimljdOAT1iM3pjaHklZTb1w+911+lbWPIy3D1/GohN0DTzUL1Tj+EywLJdWfsfNoHii7h6ympaP0i26C0BduhHd4MPQqK85eBnczSZ88UrlPfHu8h/gPZQXeLSD7KACwIL0cllb9XmLilsQVLjeGBfcORBJzmUt2NTQdzvGazPqavpNrq07edq2K2RVYDCTywPCaUyS0xZr4hLzMDU8ntCkKi0cfhGwfBcdu2xWUBEFKXf1+ehySRwNzXio4LMnNcG2wOMftKfGLPbCumG4nfTVZR7WcFoxvra4sB/S6SEyjDyjz8qyoHXYtAdw== 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=vmSBMelYoeL8PSeZSGkueUwdtIkXI1yyhlC/bwoJEKY=; b=HvgunloEGOU73R9gcA8WlbGwy2WW52V/C1K+camCWh/Oj3D5YS1nlGVqyc31AaSo6cuj1u9H7FraW0iBRvha0i23wf/OzzkQByGAxrwm8bX6OtQ2ldrIgCyYes/yJLX5moPwkmG5I8Zl4RHSlmzBE/DGHsL+T/82MpZXemxU+9V+LgwrSfcw27uw2BuB6YIKMZTV1t9TsFzayOrOtTOiAaAg1QMQRLTfUZWuLjxq5G05b+0YyZTB4n1y/KJBXTAPF3jPmck7j8C0WPzG74aVCvUCKliSL0U9BmMDbstrjQbb2YA5kmngB9WFz1m3mCBrbEpflppdH2wjtNcAmhGXxw== 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=vmSBMelYoeL8PSeZSGkueUwdtIkXI1yyhlC/bwoJEKY=; b=SqfwTDFullYQqMGBhe/tCogcH/SThTFghXm1b2urtFXDEdBJjure5OyQXLOpSTx/3QSRetjsAGZdvXHNerRwkEwwkk1aGkrJnz52QJfQRLcHWg3FmqryaPIUm1dGqbL1Gr1dUiifm6eYkyGm82GaNepC22U6+NfcfeUESfAfk08rwgUaFfaIac5Ko95+A1xhn0fqGp88oSOkWDQfdK/qVKNpyNhtY7AMbBAMwWTEUPn4l2qhmn7rD0rJHt5xQ04TBZXoW8S/Q8wmqxAx6HAIb6U769+grAihwJdk0Inx7GsjLDMJUPHIKxUFlh4qd+WiVI37sL7nsHGxKFpRf+nTWg== 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 DM4PR12MB6038.namprd12.prod.outlook.com (2603:10b6:8:ab::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.29; Mon, 13 Nov 2023 17:53:39 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.6977.029; Mon, 13 Nov 2023 17:53:39 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Michael Shavit , Nicolin Chen , Shameerali Kolothum Thodi Subject: [PATCH v2 17/19] iommu/arm-smmu-v3: Use the identity/blocked domain during release Date: Mon, 13 Nov 2023 13:53:24 -0400 Message-ID: <17-v2-de8b10590bf5+400-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v2-de8b10590bf5+400-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR12CA0015.namprd12.prod.outlook.com (2603:10b6:208:a8::28) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB6038:EE_ X-MS-Office365-Filtering-Correlation-Id: bbf23e73-c94e-4830-d6dc-08dbe4717103 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fRrlqHmcpPtdbV56AAQF0ixFthAOG9TuIZcF3s/JowhZ0GLG0YdrhMS0KLBOyz2RqA0kFnbHHzqdXTutrdkoS89p8qIr4VeQDU7owPcGGva36XtPnX4orw9PZajUStRT2u+PHnvxtfKyBGgRusmHgUIuM3y6J/oG6cQwUge/9uvry56l6J04w8tlZNLsnugDrdGTpYBw8+6pfNeWrcA9v0m2DGALJMRrddNwnHu+ILMVROE9yF/1SNQLb352VaDr11LAF8BQHMS9xXB7B0izMLtGiee0Or9VRuzMuuVcTRewxegxq5Hgb39ME9SNNCaL7+hHJQj3KokBU8oqPLl74BCufGHRcETMMvVKlvLelYsGnn+Q+1+7fR2uwl8aNxrXhpPow/DRu8JyLylX9uRjcSoZw/ydcumDgj4KDV7Le2L8YMwMcQgXFeZSKsVMKmfmeMV170y7ix33My2VnIvFQfe0feb9tQx6svp/qptpdZClkcxEHqyF36BSgKoL3aIt3GKE7qZ0J5ivqw+sMJmXSWyti0ImlS0W44dzYVPEp1K8CriG4Tgj+bx36OMorvlE 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)(39860400002)(376002)(396003)(346002)(366004)(136003)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(36756003)(26005)(478600001)(6666004)(6486002)(6506007)(316002)(2616005)(6512007)(66556008)(66946007)(110136005)(38100700002)(66476007)(54906003)(5660300002)(8676002)(8936002)(4326008)(15650500001)(2906002)(83380400001)(86362001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YkFXhgJ22DTEEqS+c7LxfDPWsw3AaSbM/YN7id+zgm/sTFu48pTWoP9lsz6TsTUHdWKvdYbh35vfGzrHQI3dlRUdlIRJSfsdMHlbfgwTWNzYT4j7FTWwt9X2okD571qIyCmFJfSbtD7Oja7pBED+MUBwQgftnv/TWeQzk8gRGGYv6zf5MoAQ79pJrvUPD6Li+nDcKNmLdoV1lNuJWMhMhaUxecbo9t7ozWJubB9vvFfy2YozgkuIQjAm10UxYTOq9/Zflgmmwte7hZtQlBtpUlDzgIBM7wfHZmXsPHZrYkP8SDrrKURrOrYxjSOWRDd8fHjF2S9vbV68E+N+MBLL/rRh5a5whlv0E6ChgaP+f8UhPWyKj8OL09JdgzCY0275IMnjhftiz0ccfJySdEzeCHxmOMGdRYCIrcyL+NhWB9cF4Htjc9dk+A9FvsowUH8w7lL7u5zZgWtNnG+2211ba/VRksQulsjtwn4IF77fWmPTOZae8syf2i58fVc+wvbmEJ0n4EJkWuXHDI6yp7glfS6WGiuV2U1RYufL0PHrrHHbpo8qxtMnULHgyz18SCjF9/PMcVHutSt7OTqxl7kVntiptjUfb80SSktvi8sI+4wupJevtIpAz9x0rSsck7rexl/ZjejX+nxYXlq/UaGUKfksQMavSZrgYxJtoyQ5ITz/F4IP62q3jMNPwwrJstjivJ2NI1P0+9zr02ppuMYDXdjW2G2PuwjJpARnD+nNbIchv2QpgZN8Wr39LzwZqvxkAb4wW38cECPKM30qKQ0rfbcbjr/80PutuCYi7prduFy/q4B/7NpD1wG5dM6ba2pPIVsuVqHj+7sGuG6ujIaym/XcIgTiHCLkRNs53hbqRl4qS8GHTw4Dm3lUZ/Jp392PbU2N+cHnYAJjshpVjQjKnztDmWuhVYUymNfDCj6pqeg3fNRJKPU5gS1BCRX4MlM7rUAiJxK7PoQpbpHcF3Tll9F8jb86zgCuyoJNZ9Ey7ymke05eOdMaLHJ5GqLh4YWu8KbQ09xkPESrwPgMms1D2ZXUBY/KZcMt3f7M6pYJxqVZZPabx1VAc0PhTD+c/IjfW6e9KWyTJHjOipAc06xkXf8AkXjDoOMJ7F0gFj2WFl81dnP1bBHvv1LRYobmLUwABegOVa0jdHBVsLPXf4vJpe6iJAd4wNsazSH8BDAaxIiIRWzGOUYpNoGUcADX+annf8Mdp9Drpch3mogNIsvmEx6AIZEkG8I+qlxhtWG9AaGCbZB7/gdCS8oIls1D83haDZRwX9Ywv+WCVHfVNH5F02/cNu6oi2fTaumnIADu0BA+UnC6PNWsB/6jK/oTEzlSTI3RYkNGV8iojyruDo95+TlDUGfIQWl6N1KzuLkVHPKnalCYfkLEO7Fp4NbdjC0PSKc/kZQ//5TVkwbof6k9ouwU7i4H770sxPl9EpoooLoiNjcJkmIOQURKUqZT3ODhgKL/LFmLi5l5tm18I1ZWvhBn+zD97Q1FkYG5f0dyWvm13612Nann/JAfyVNO4fjw/QeSqIq6OQUb+XUYOjtMi5yz8WIesO1eIqV75ckO1YI= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbf23e73-c94e-4830-d6dc-08dbe4717103 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 17:53:28.2704 (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: VEs76haaxz6nHUBcSvXsK+ApMiWy7jt/Ix3lfIcetqJLjXr3xtZl63fvOff2DwT7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6038 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231113_095355_004203_BC52969B X-CRM114-Status: UNSURE ( 9.41 ) 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 core by having release call arm_smmu_attach_dev_identity/blocked() instead of open coding this. Signed-off-by: Jason Gunthorpe Reviewed-by: Nicolin Chen --- 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 48981c2ff7a746..331568e086c70a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2900,19 +2900,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)