From patchwork Fri Jan 3 19:43:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 13925851 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 1C3FEE77188 for ; Fri, 3 Jan 2025 19:50:42 +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=k+LZ9DTi+hXK1XNyDsq/ydPO+gFKzeDHi5j6GDyNjCw=; b=JSum1drrMIZkzNz6TXpqRx3oYk 4DnnXc6HNzQNg/yZUb7JkG8PnxFvB9iw/K7ochGi7SRRb+f2yHakRlVJJUVE4rGxZ+7s633rpDJ27 UoKrbBLhKLre9H/p09+/HGQHxgK1NmpxbaUU1jei+k2bfcOMR2PcF7ESJJFzqbj+aDiPgI7KXX214 mCXIZHTGJz8EdCPVQwh4qdeBB0BczY59Q+PqN+fYtQWywXGkk1SxNmVftWDEjsRTfgKNvof2zBvRa ndh1caapW6nDzsnUj+Yz5te5Ms26gzFNQjE729QLnKKpChafde8O265bozXYd6BQe6mKTC6pmSoZG l1pfb30A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTngm-0000000DsUf-1qGY; Fri, 03 Jan 2025 19:50:32 +0000 Received: from mail-co1nam11on20627.outbound.protection.outlook.com ([2a01:111:f403:2416::627] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTnb7-0000000DqV5-109v for linux-arm-kernel@lists.infradead.org; Fri, 03 Jan 2025 19:44:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ezUkuroa2j01/QiF2j+m+39wMS7loOovUyysuMtkS4bHUGdRCFXRA6mdfP/EVkuKfT/53TNNxcRpuR0mSdet1ou5wq/nS8E1gAzP7QojCkpkHAswi/FTR3PS0ITyWY9nr6pt6wk0Bw8RRLkZKhdM7VSIIUatkfEikoIIW9GMc95kGW/YXMfkurFCJwGxnv150LY4jJyDNFNUkM/yhJbDtp5SygviSk6ICrtScDgTgIc7pUX3BS+dDk6VBXZ/A8Xd+Psz3hitILbZmyBOqRs6rjF7eO0vPqGmtyRhfHC3UfL0HTGcTjRJRGv7t+p2rCn/iNqKIM4AYbhO8xXM/sBFJg== 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=k+LZ9DTi+hXK1XNyDsq/ydPO+gFKzeDHi5j6GDyNjCw=; b=YM8sbYtquyiKOL2nf5ytzcBImNdtdWwtQNFkRKTDL6JmkNBbgF/VPZS2B/8j3MRCl1GTG1ilgvL+wW2uYPiKU49hBbp4bDuA62iGrMhjk0EB4Za0qVlN/M6OGDYx6lFPZ6SPvQQ49AuSsDEuQkrIZELbNkKtAztz3aQsvW2xrzI0pjcc57mjosB5LdRsqEOZZCRDztE6q/Qy+BM20dkcF6NRh9/pGQs1sQl39LsgvhhyGB4QTChMJW39Xk4sECowELJ+QKL5u3ANf6iLtejzYX5TG2I6qj18fgEYjxv41ZtOb7mI/6qbvIlmFOV0UkGHkDxXg/LO5HtmMINdZDis8g== 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=k+LZ9DTi+hXK1XNyDsq/ydPO+gFKzeDHi5j6GDyNjCw=; b=Ts/nmwc0k+pM0leG+Z8FHsaGEjaT7cEInT+xHxpKDAhlYnEZN5lbH6TSzNfx6bYwtfycioDaeSaFIcmJhl2YSRFgQM1E2FeDaw2bdo6daWnkDOQfL8LFGeRZeUM7nOUDn13Vn/51bu1ZL3MF3oxqwe0VqhDNwDEORZC3LQdDeM8/L1CmlSwGGubPh23RXydgIzoHbBB1IMhPb91F+1Y3I55WoyS5xW7I9z48b93UDFS5Hw1pmpaNj2zVJlgPTpK3m/HNQf/QGRCIYRF+Yoq2f2hTa0YR1jPIwkErIFfaEX8kPoeyy3y7xdnouZlbGR9G5DvzW0XxUzVvlG5fLCp3yQ== Received: from BLAPR03CA0092.namprd03.prod.outlook.com (2603:10b6:208:32a::7) by IA0PR12MB8839.namprd12.prod.outlook.com (2603:10b6:208:493::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.14; Fri, 3 Jan 2025 19:44:24 +0000 Received: from BN3PEPF0000B06B.namprd21.prod.outlook.com (2603:10b6:208:32a:cafe::13) by BLAPR03CA0092.outlook.office365.com (2603:10b6:208:32a::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8314.14 via Frontend Transport; Fri, 3 Jan 2025 19:44:24 +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 BN3PEPF0000B06B.mail.protection.outlook.com (10.167.243.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.0 via Frontend Transport; Fri, 3 Jan 2025 19:44:24 +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; Fri, 3 Jan 2025 11:44:07 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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; Fri, 3 Jan 2025 11:44:06 -0800 Received: from Asurada-Nvidia.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 3 Jan 2025 11:44:04 -0800 From: Nicolin Chen To: , , , CC: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 03/14] iommufd/fault: Move iommufd_fault_iopf_handler() to header Date: Fri, 3 Jan 2025 11:43:26 -0800 Message-ID: <92a5599bddd915c049fabf4832ec8b0f0c1471c6.1735933254.git.nicolinc@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06B:EE_|IA0PR12MB8839:EE_ X-MS-Office365-Filtering-Correlation-Id: bef94e04-ee1d-4c43-9cab-08dd2c2f06c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: cvZzrQsHTEAY6R/+m0Jf/OHC9iHMHXbCQyGn+4YOL1CFnjblCT5TpX25b/lUx0/4hKjOOA06XfZuRVL4v0E8qrTsx8Ov6NTASPDKqoQhnOaYquxI/6xWKAndinqf/kEcif0jjC9SuTFm6frVva/IqJ3fzau4rlUpyhSNXwUJItFv+YhEgT5BlH1jEQWm1eV3oYdQRQX8WsUMaHSBnxSHWYpp85BFuVRmJ+acXnsxMTFUoTXfqWYFGJwvRJHOs2OxWftrW8k/UpAvpY+NRcoQPdzw0Fjl6wJs9YPTakfcpx8A1tJilF4xWb2m5sesHXKXYrXuAOA6DGueanulV/5NnuCLRZ+UvtKt4XTzpaLkbKh/5jRo5163eC4EK6n/G8vt6BE4GJjOwzJMhVTBi6qrp2HgVXzVOR+wLgyZHRnbck0cMkP+kM/kx+SnjyW2YOPTPP69LgliBMJ4PcJM3lPzK1VCumor9I5xgDM1Yb7kBAplhm4tdUbhtNHQVsgtm8lWCV44xNmrEmS7a9FmK8+Wi8FhmOOhbRfdxbZ/iZGu0uYpLpNXqJYcGH2WADefQfK0gh9isRuZoRtd0UyxXaqQ/S7bH6CUIc7C+spVnN2BIQzEX35kiFyIxvJTR/VdBvcJ3g3nVZsrVSlntMam54JWnf0MlvNFRB6Vam1kQfsNTodEKi4Gk6PKPAFsG5pBjXl9y7+z2iAwGpBwCVMiXAz5hAc+82sBGx0jzaIAERgPmU8Wh+51RGcLZo/NtzjOE5Y1JiV/wQg8FQ4tf0F9uzTQd52gXkYKbKwWs+BHS2cyXOGdCcHuirKC6fePXEDNTRmYRrvMGTxTSGJuWJzGs4lT7Iis8Q2aF2XDkPqWO3y0HC38wzHu/GLIOQqLiFyFtT4d4Vk0O/k5LLCqmLxQ10uslZTgxqbmmzos0Vn5h+ktGc7tXRhbMuJr4HwTNj4o//gJpJ1HPX4fcbg1PBAmNVFIAQbjkVThl63uJThr9BC1vrn0WCawfuI7Bzl9hMiUujARiI9BS9rowmci5hsczCB6jiYChKgc8tb+3bKW42udl4NTL3au3AdC8YKcVZfX6aue9SKT76pd/4u2/WNE5hUTm0ClJQiFPiAK9hd94tiNQvui5c/Ve/Glpdg16L80wz41cQRlM/BSPuJVN2YkxHkkEQWoYCm3JZPRpdl+gK1r7GIXGYgOrMj/17EVkfaWzyNLfx4kAGAa5ATJEi8I4otu1ofvvgIjMORd41jlNZOWu81TxZw/89c+E+SvUhMj80Ymeudl7j5QpTqWWsnA8qCf3r6qrHOWQ1TVkcKSwPvcK7oZCnJ998LSt0v/djWNboYgzgzhqeWe/intiEkkXYMV4JUMXm0AjUMV3bx5gLTAkxvF//zE8LF/XlMf7xN/EdhmIdqEHOcJT4t7nSIE83q/xwaGJm1YWn1WosNj4KXjH/WdBSl4H2AhAG7H+9NychKTXprd/5ccivgxP0KaGWf3bnpvdB/RgoFpyF01i3WeFYE= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jan 2025 19:44:24.3146 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bef94e04-ee1d-4c43-9cab-08dd2c2f06c5 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: BN3PEPF0000B06B.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8839 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250103_114441_276261_2AEC36C9 X-CRM114-Status: GOOD ( 11.30 ) 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 The new vEVENTQ object will need a similar function for drivers to report the vIOMMU related events. Split the common part out to a smaller helper, and place it in the header so that CONFIG_IOMMUFD_DRIVER_CORE can include that in the driver.c file for drivers to use. Then keep iommufd_fault_iopf_handler() in the header too, since it's quite simple after all. Reviewed-by: Kevin Tian Signed-off-by: Nicolin Chen Reviewed-by: Lu Baolu --- drivers/iommu/iommufd/iommufd_private.h | 20 +++++++++++++++++++- drivers/iommu/iommufd/fault.c | 17 ----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index b6d706cf2c66..8b378705ee71 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -451,6 +451,17 @@ struct iommufd_fault { struct wait_queue_head wait_queue; }; +static inline int iommufd_fault_notify(struct iommufd_fault *fault, + struct list_head *new_fault) +{ + mutex_lock(&fault->mutex); + list_add_tail(new_fault, &fault->deliver); + mutex_unlock(&fault->mutex); + + wake_up_interruptible(&fault->wait_queue); + return 0; +} + struct iommufd_attach_handle { struct iommu_attach_handle handle; struct iommufd_device *idev; @@ -469,7 +480,14 @@ iommufd_get_fault(struct iommufd_ucmd *ucmd, u32 id) int iommufd_fault_alloc(struct iommufd_ucmd *ucmd); void iommufd_fault_destroy(struct iommufd_object *obj); -int iommufd_fault_iopf_handler(struct iopf_group *group); + +static inline int iommufd_fault_iopf_handler(struct iopf_group *group) +{ + struct iommufd_hw_pagetable *hwpt = + group->attach_handle->domain->fault_data; + + return iommufd_fault_notify(hwpt->fault, &group->node); +} int iommufd_fault_domain_attach_dev(struct iommufd_hw_pagetable *hwpt, struct iommufd_device *idev); diff --git a/drivers/iommu/iommufd/fault.c b/drivers/iommu/iommufd/fault.c index 1d1095fc8224..d188994e4e84 100644 --- a/drivers/iommu/iommufd/fault.c +++ b/drivers/iommu/iommufd/fault.c @@ -433,20 +433,3 @@ int iommufd_fault_alloc(struct iommufd_ucmd *ucmd) return rc; } - -int iommufd_fault_iopf_handler(struct iopf_group *group) -{ - struct iommufd_hw_pagetable *hwpt; - struct iommufd_fault *fault; - - hwpt = group->attach_handle->domain->fault_data; - fault = hwpt->fault; - - mutex_lock(&fault->mutex); - list_add_tail(&group->node, &fault->deliver); - mutex_unlock(&fault->mutex); - - wake_up_interruptible(&fault->wait_queue); - - return 0; -}