From patchwork Wed Aug 7 20:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13756718 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 96A44C3DA7F for ; Wed, 7 Aug 2024 20:20:07 +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:Content-Type: Content-Transfer-Encoding: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=TZrvfVns3n+wE19BdpBxEW0UC6D8M1vjafDg+cBNr3Y=; b=10mC4u92Tjk7jqaDlqr/a7UtjZ euR7jLyL62tXqHltBYDDZ+h8rWNAqhZwGfESGNcvmseK0pBHEqaEcsjxtUtQCHs2+VtW118e0N2S4 ygMkecA9hGlXGLjul5yc4i/VApyn53aLLXBSwDpSmti8jomAxWa3m7DnRLzMsqlAq1DNDYuoli+/f DE1daJbu6/G9J9KM3ezvL+RgIKfjg0qcl8qNEj2puZXMj51PqqaY0CyJv6gWtBZClS23ftV+9Z6cB G4OzGbgRaZU8ckJSMwu3q2MkDNyI5PCCgnY9sSNmJ1UxDxDBQ7vdPWj57mwzHGtJBGqM+w3QyBw5K 73Sm1Ecg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbn8Y-00000006BiP-0V81; Wed, 07 Aug 2024 20:19:58 +0000 Received: from mail-co1nam11on20601.outbound.protection.outlook.com ([2a01:111:f403:2416::601] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbn0j-000000069NS-2y7a for linux-arm-kernel@lists.infradead.org; Wed, 07 Aug 2024 20:11:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o+8aj+e570Ux3syfMi5glUypvm7+D+V0tflm3kKZ2lzDZHV3gF/w7QDsoWeQE2kGqC9amzZv30b4zUeWd9lfsScwAvOg2UIBRHVZkpyM46bvn2KHCirJ2HTMm0WZwZPOiipyuv1KNGzta2/Z0e3DyKRNveYS5lFUpdRKXtIKnWCejJmBumMG/WG9Mqc3s+g9k9nVxCoZ84kqcOOWlBk1q9IkiOG/dl1XOZyRoeKGbNj7RoNHYedTUcCyG77WyQTGou+tLXQptJ+D6bowoOZ954yj13rDwp8i/9JeyY7K7ZHELr1khnmBJ7dKA6yfIApOiIPI4qLNCg5g6ZquCQFxJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TZrvfVns3n+wE19BdpBxEW0UC6D8M1vjafDg+cBNr3Y=; b=t0y/R9TmNJzWyyMiS4WcROmC/XGjPyXPSIyoHbHks+Txw2V+WAhAP/qjceKlpmWgwQ9zINMn9PZPfZXf4+O5Etd48oVSHrb/TF4Wjs6ztzNasM0genL9y1Y8D5DqeP+0H6EaMk/j7bLxUEy1q/w+3UNc7oACG6+nTbhJ7gHtfihXFe7fWb8Rtj8oIJsiDY+5BFHnN0Lks/dTOGffpShyLZe+PqK5Oezhg1jRACIw55qjFv+Ijy+7mh+YToRd1PsyP6ihq9Uzi9s6CJj/jCzZ9y7Zu2+37Qg3sTMqoRg4cRj1vjbP9VK+tfO3fI7jR1HP+lbE87P3fB8iDYG9e+DocA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=TZrvfVns3n+wE19BdpBxEW0UC6D8M1vjafDg+cBNr3Y=; b=BQwEgn6K4lAosxLyX0nMiyUoV0KbyjKEHtaSQtHFr1u+An9hXgyX7ZIyI/Nlsb5waN3AJvsYrJ6qCLFZ8k6rLFLPXp5BC2e3O7jUddVyMqQaApD+gobZTMrXbuFdGIPsc3KjqagoaRBQR/NPfdH8ttuLUvf00okVbm4f3a/uXSbx4KEvt/CCf4G67MFmtkMnVPGmbXrBADm4HgEBC5aeHkOiOTHQ+paTwcvFmSITKjHdSGp3F7dyI9AggakOYZF4AephPkcvdxBkAr5H71coWKwB+zywpDVZfjukBfpn1YiUT3ih6MXHtvjNVUmgbTw3sCvBadw38ARRckePQshjLA== Received: from CH5P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:1f3::8) by SJ0PR12MB7036.namprd12.prod.outlook.com (2603:10b6:a03:483::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.22; Wed, 7 Aug 2024 20:11:42 +0000 Received: from CH2PEPF0000009F.namprd02.prod.outlook.com (2603:10b6:610:1f3:cafe::98) by CH5P223CA0013.outlook.office365.com (2603:10b6:610:1f3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.14 via Frontend Transport; Wed, 7 Aug 2024 20:11:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF0000009F.mail.protection.outlook.com (10.167.244.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.8 via Frontend Transport; Wed, 7 Aug 2024 20:11:41 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 13:11:25 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 7 Aug 2024 13:11:25 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 7 Aug 2024 13:11:24 -0700 From: Nicolin Chen To: , , CC: , , , , , , , , , Subject: [PATCH v1 14/16] iommu/arm-smmu-v3: Extract an __arm_smmu_cache_invalidate_user helper Date: Wed, 7 Aug 2024 13:10:55 -0700 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000009F:EE_|SJ0PR12MB7036:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b1aad55-d505-4642-ef22-08dcb71d2722 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: /cQrJXafNOFvPVC0IrT1IE5C9HsVjjDZY8SURwcHI4ANp+b8EFZCEX4ft/mG7KJ1SAhA92rpVwdgzemKwAXh8b2drqGh8KZMgRtskd8oAut9lV3biW1ViIEb+ddmyAIyrkisnzR0GM+Mcz4qB1rTDVTh1yosSLheCzqAzqfoap+jHwYETnG6maQb+KUM+H1hMD+bAu/wETpN0Lzih58p3G6H9cK8LRZGR55B98xjTArO0ArcP9hCMD4wAVCOneVD4wC+zZwIWvmu7x+7rpL5XDrBLBFh9cAp6AH/1kb75INfnQvUBdanNcntdj1xUJgfbrqvWAr14DcEdb54SdwEQEVgehOq/xifOxp2onwenbFYslu+8NETICgui3UPWbRO2KSr3PE7tAdmcdxSBv6vEYuzSMJV5h1IHPaqx9znrgICi62KqbPDVNLWEywsxA7HxVC1nu0Nq9RBZT18HknxMadMWmXFMmE8f7I0p5OtAQIC1OuTBbEDxhotpLmLfqGOlKDO7OE6l0YwS56myqrXGxjtCLXutVxSRXaVkbllL0ey/y2e0RUI+9P4iuihKQgn3c7aKK53df21gna+EP/DFT4uHNUSPBsdvSfvKTGBv82AwpSDV0SBK0RlOUmbDlXwsQ1snFxqarFBeRV/IWdfojfpXWcxdcFuVhaLD0Kpz66Jq7mCEnVF2Rh2AyfY4PhzGZgV5Z9ues87nzqopxXn+FB2pSJgsEImQ3oSFXwKjn++xGG6K9r7pl4LXj/1Vz+oAdXfKecdYndJ9fVAmKL69e6iYIfI1Dc5dBb5dxv8zBf2m5oMVhrR0qrDZ8anLavaWsyx2n9AhoNsjrIsIbJYQkFfTxnRXsan+Xoa16E7nSqxbH1LEBQRfZru2luiuJ7GgFlEInCBFePShW2RDOF9s9ridgjWaW+00rmoqniIit8VRapXnigTQK0DRDPUZ6Q9RB35CCkKvCxKffwwWvHQChsUiT29i1ky3pjcp85mjA0q5FNwWK+BdYL0iqRqaZrZB91Zd2s9XtiB2q2pPg64IXqfjgGg39Z1/SmUwXPWNj0nVzs+kd/JQltNsXUerIh0TNCnUGXfrQyLlp3KmDKw7zIMVdUb2xYYnD062wA6IM3dOMZ1kIBF0i8EYepoNqIFvENMMX3/kRgCPlMU9Qwq6caYc+LMMrS9skGlcfi4XB3AggsXh7tYBJE6F4RhAs36Xx2Kr41TOpRDxrlwMMVJD8jYlcSY1wZKeKrsvoN8hBbxvneOKYZrudaSZYTi7TZZx+kyg4RhCsCfUE5KYYm6CzPMeEz2qjFeWyaorG7L6AD9sHu0H2fnkVWmbtthyWf6hTh0Q+S/DDqC1Wbd1zi9KtaDkvMohZeEzQ6qSUdqYjREg/DcB+YO/jhOlL/8EgL+WcbDxPnehyyD7ZqS7gtLh+fmi+X/EvnEWyWCJTKv496eSW71A3sHug1HUMTlKumQ X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 20:11:41.6897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b1aad55-d505-4642-ef22-08dcb71d2722 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF0000009F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7036 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240807_131153_782231_F52DD0E1 X-CRM114-Status: GOOD ( 12.67 ) 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 Extract a helper accepting an s2_parent input directly so the following patch can take advantage of it for viommu's cache invalidate callback, which doesn't have a nested domain but a viommu object linked to an S2 parent domain. Signed-off-by: Nicolin Chen --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 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 558cf3bb24e0..ec76377d505c 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3227,10 +3227,10 @@ static void arm_smmu_domain_nested_free(struct iommu_domain *domain) * Enforce the VMID on the command. */ static int -arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain, +arm_smmu_convert_user_cmd(struct arm_smmu_domain *s2_parent, struct iommu_hwpt_arm_smmuv3_invalidate *cmd) { - u16 vmid = nested_domain->s2_parent->s2_cfg.vmid; + u16 vmid = s2_parent->s2_cfg.vmid; cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); @@ -3255,12 +3255,10 @@ arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain, return 0; } -static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain, - struct iommu_user_data_array *array) +static int __arm_smmu_cache_invalidate_user(struct arm_smmu_domain *s2_parent, + struct iommu_user_data_array *array) { - struct arm_smmu_nested_domain *nested_domain = - container_of(domain, struct arm_smmu_nested_domain, domain); - struct arm_smmu_device *smmu = nested_domain->s2_parent->smmu; + struct arm_smmu_device *smmu = s2_parent->smmu; struct iommu_hwpt_arm_smmuv3_invalidate *last_batch; struct iommu_hwpt_arm_smmuv3_invalidate *cmds; struct iommu_hwpt_arm_smmuv3_invalidate *cur; @@ -3282,7 +3280,7 @@ static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain, last_batch = cmds; while (cur != end) { - ret = arm_smmu_convert_user_cmd(nested_domain, cur); + ret = arm_smmu_convert_user_cmd(s2_parent, cur); if (ret) goto out; @@ -3305,6 +3303,16 @@ static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain, return ret; } +static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain, + struct iommu_user_data_array *array) +{ + struct arm_smmu_nested_domain *nested_domain = + container_of(domain, struct arm_smmu_nested_domain, domain); + + return __arm_smmu_cache_invalidate_user( + nested_domain->s2_parent, array); +} + static struct iommu_domain * arm_smmu_get_msi_mapping_domain(struct iommu_domain *domain) {