From patchwork Wed Jun 19 00:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13703268 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 D65A2C27C4F for ; Wed, 19 Jun 2024 00:23:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJj68-0002qz-Kg; Tue, 18 Jun 2024 20:22:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJj66-0002pw-8y; Tue, 18 Jun 2024 20:22:46 -0400 Received: from mail-dm6nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2415::600] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sJj64-00088y-30; Tue, 18 Jun 2024 20:22:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=diJcjUYft7v07t2b3ErWXmhvUdHDxeyVU2XRxMq+bd2jY9BUMgSFLxcbqFH8+mvDa8MlU6dCvyUIYpYQCSgrm3Ykm4YyIZvD/DdUTXzAlxDSUSOjgpGG3dgbE5vlYz3KEFKKpQB5264f4CnIKyeztQz6yE6MMr1NUpImKKE7cSx6smo8gHLTNTRcgYZuX1sYPJYfvlNlCsOzf0J8lUDpJjwmBEgQ+vGIFzQLV7C2KLZFdtGE4VRHm7y1R9Xk6OOFvXp2uP3IxQXfoABTf0qHIead7kVOpXim+rYMTB/7+kIsy1kO/PALAfrVv8xaPV4NNvDXLQ/hULIHYT8QDA8mxw== 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=QYa5DgS4iz5vAhj9GhMi49jvzDT04jztH6e4QM2g2vI=; b=E5ZVfDrx1PynzkwpUmkfVmo0Twk8jKMDGiq81FOW04kbKwp2nGb1YMrwOsNapkiwmCUmAlL9uNIxYItOl4aXbbNFuPg3oZSu2ema3xqXGjamMfgd1dxTCzHXmKuZop4JSXEiWb+SJTxTKlOUUhUN8511E4sCa5gULC6Lg7T91EIk4qDychbibmdegdeBfh36Y7eMxAG+GTm8OJ3+57P+v8ZNy32elO+LGl0UJmTqyrKqHrPp5dlXb4L5jii0UIy/Nv/uVgZifvvdCY9N56LYetnsZuZ4EKcAVzABvhYAqUdYWAaMfLLNKsIMhxPV2ve693Vk7MDC95tnEDY0lWnTtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=QYa5DgS4iz5vAhj9GhMi49jvzDT04jztH6e4QM2g2vI=; b=cydVVm/Id7ebDxrG33DXLIlKvDdF3FgkItt6vw0mMST+tPlM6ijjrBtI2KrUB5VsqDAbuSl3eIMPnnL6EmzzFtMCFTq1xoukLQETG2n06DBPsItjulGPeeHcpHMXEQftGBET9kJf1therk3p1WLatRTruYLRlyPGFKRI85eRNEAhdtvp5XgxElhCa2yFqyHlNegBbxIcItRO9+5x0jwn90vWTpRptVX+U+aqYoMKB+GyXRXsjVtQIKB3FCxJ7q81Lr67gZWhOPW73vOGSU4QMmu8Ky86IMZGk/otHLV/jrurzv/6NJEGBl7YMR+eUceAX2dQlefmwSn1hwVphskcOA== Received: from CH0PR04CA0041.namprd04.prod.outlook.com (2603:10b6:610:77::16) by PH7PR12MB7965.namprd12.prod.outlook.com (2603:10b6:510:270::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31; Wed, 19 Jun 2024 00:22:35 +0000 Received: from CH3PEPF00000011.namprd21.prod.outlook.com (2603:10b6:610:77:cafe::34) by CH0PR04CA0041.outlook.office365.com (2603:10b6:610:77::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.32 via Frontend Transport; Wed, 19 Jun 2024 00:22:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CH3PEPF00000011.mail.protection.outlook.com (10.167.244.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7719.0 via Frontend Transport; Wed, 19 Jun 2024 00:22:34 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 18 Jun 2024 17:22:24 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 18 Jun 2024 17:22:23 -0700 Received: from Asurada-Nvidia.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 18 Jun 2024 17:22:23 -0700 From: Nicolin Chen To: , CC: , Subject: [PATCH] hw/arm/smmu-common: Replace smmu_iommu_mr with smmu_find_sdev Date: Tue, 18 Jun 2024 17:22:18 -0700 Message-ID: <20240619002218.926674-1-nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000011:EE_|PH7PR12MB7965:EE_ X-MS-Office365-Filtering-Correlation-Id: 18484dfc-ba97-4d9d-a8bb-08dc8ff5eaa3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|376011|82310400023|1800799021|36860700010; X-Microsoft-Antispam-Message-Info: TTpGAOtTjLD83S0A6vyhURwnApD4IrI5+PnvaRm3mYNK3cuQT9peHdrRBamWycYUNbuKTIzlujKm+aTzPwL5OVFSmhXz2NtOokl9h1WsnG/cDmWkkqg6jVYxwefJL3pD6jbTj33HvEjAyLyFwOgE6NWLc3JqNds0v9WZI/NMRNn4Jia4oxZBF9z5maLJu2WnH9gcl3vZ7f03bBqniRn8RcXv1cfMOf4zPEaqFMOL9/4pBK7WhG39JfYMCnTjIZmug9+8FIr1Qxjt11SbAIecgheA+vKHjZrxfUW5qFnr667VYirwFLHBQmWAz/ngkomjYrK3YyjyynzeeFQSG6rxjMVcPsdoL3cjRjDAl2sbQt/jHg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Y:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230037)(376011)(82310400023)(1800799021)(36860700010); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2024 00:22:34.4402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18484dfc-ba97-4d9d-a8bb-08dc8ff5eaa3 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.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000011.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7965 Received-SPF: softfail client-ip=2a01:111:f403:2415::600; envelope-from=nicolinc@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.148, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The caller of smmu_iommu_mr wants to get sdev for smmuv3_flush_config(). Do it directly instead of bridging with an iommu mr pointer. Signed-off-by: Nicolin Chen --- hw/arm/smmu-common.c | 8 ++------ hw/arm/smmuv3.c | 12 ++++-------- include/hw/arm/smmu-common.h | 4 ++-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 1ce706bf94..b6601cc102 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -620,20 +620,16 @@ static const PCIIOMMUOps smmu_ops = { .get_address_space = smmu_find_add_as, }; -IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid) +SMMUDevice *smmu_find_sdev(SMMUState *s, uint32_t sid) { uint8_t bus_n, devfn; SMMUPciBus *smmu_bus; - SMMUDevice *smmu; bus_n = PCI_BUS_NUM(sid); smmu_bus = smmu_find_smmu_pcibus(s, bus_n); if (smmu_bus) { devfn = SMMU_PCI_DEVFN(sid); - smmu = smmu_bus->pbdev[devfn]; - if (smmu) { - return &smmu->iommu; - } + return smmu_bus->pbdev[devfn]; } return NULL; } diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 2d1e0d55ec..445e04ddf7 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1218,20 +1218,18 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) case SMMU_CMD_CFGI_STE: { uint32_t sid = CMD_SID(&cmd); - IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid); - SMMUDevice *sdev; + SMMUDevice *sdev = smmu_find_sdev(bs, sid); if (CMD_SSEC(&cmd)) { cmd_error = SMMU_CERROR_ILL; break; } - if (!mr) { + if (!sdev) { break; } trace_smmuv3_cmdq_cfgi_ste(sid); - sdev = container_of(mr, SMMUDevice, iommu); smmuv3_flush_config(sdev); break; @@ -1260,20 +1258,18 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) case SMMU_CMD_CFGI_CD_ALL: { uint32_t sid = CMD_SID(&cmd); - IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, sid); - SMMUDevice *sdev; + SMMUDevice *sdev = smmu_find_sdev(bs, sid); if (CMD_SSEC(&cmd)) { cmd_error = SMMU_CERROR_ILL; break; } - if (!mr) { + if (!sdev) { break; } trace_smmuv3_cmdq_cfgi_cd(sid); - sdev = container_of(mr, SMMUDevice, iommu); smmuv3_flush_config(sdev); break; } diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 5ec2e6c1a4..687b7ca132 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -182,8 +182,8 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, */ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova); -/* Return the iommu mr associated to @sid, or NULL if none */ -IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid); +/* Return the SMMUDevice associated to @sid, or NULL if none */ +SMMUDevice *smmu_find_sdev(SMMUState *s, uint32_t sid); #define SMMU_IOTLB_MAX_SIZE 256