From mboxrd@z Thu Jan 1 00:00:00 1970 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 7A64CCCF9F8 for ; Wed, 5 Nov 2025 15:13:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C681E10E79C; Wed, 5 Nov 2025 15:13:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="esVvuRuz"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A1A210E790; Wed, 5 Nov 2025 15:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1762355587; x=1793891587; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=asdtQj/+hV2mr/yssYTzEhfVXHR74n/WMiOIztsrQvw=; b=esVvuRuzlSKqLIDsPs7d+lcDTDYH7dURO7UkjnTKUA389I/wc4pdgBpq QmTonGhuey/d92KE7o71hRIPVJY4aqCw7CWyGnE2qC+VW9M8FbpAUwhrM GFRBaWcBeN23hLyBOJv7WGHq37dbJG99Sq6pshFIV/1X2MNRBodzoPUhf UlwR4y7U7j3PehzBHDLxYSuRENN133076GkkG1HYqzpHSslCDAa19M1H1 N4hPXzXKtrvNLGFewHt6LA895nSysqZLDHi7JsnUr12PAFqadzWVVC/IJ SJMHqriKxdwIRn9uzADY0WUyRL2J7B0A7VVlqZLv1e/6af7v/gNW6G6XC Q==; X-CSE-ConnectionGUID: tOMBUFH9SaGlhIAomQBQaQ== X-CSE-MsgGUID: o4zK7g2sS7WL4AwwZR8tQA== X-IronPort-AV: E=McAfee;i="6800,10657,11603"; a="81875936" X-IronPort-AV: E=Sophos;i="6.19,282,1754982000"; d="scan'208";a="81875936" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2025 07:13:07 -0800 X-CSE-ConnectionGUID: sBbGUgqtTUW+uZDZSbdMDg== X-CSE-MsgGUID: c+Pu6/kCTTG3OULzMJjeMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,282,1754982000"; d="scan'208";a="186766682" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2025 07:13:07 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.27; Wed, 5 Nov 2025 07:13:06 -0800 Received: from fmsedg901.ED.cps.intel.com (10.1.192.143) by FMSMSX903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.27 via Frontend Transport; Wed, 5 Nov 2025 07:13:06 -0800 Received: from BL0PR03CU003.outbound.protection.outlook.com (52.101.53.16) by edgegateway.intel.com (192.55.55.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.27; Wed, 5 Nov 2025 07:13:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JXjYmk0UNTKvnczLEhPq5zl1ElXBJB2X57ebnV49VxImBCMPP3bgmkWEKO3jAMYZyuuLbZiR1WquLhSPfXeg4eX5I0i6BdtrG7lVvuFo6mmMaeTQyw5sKM18CP/BSp00ODuftpP2iJX+anZYr4S9O4+av+g7KFk0woKRnLUPK5SMEMzCOd9IjyEicja4BVo4vpvbunq0vWiCSwJ+Ct3xK/pA0irAHXpPIj2sxvZJBaCZ69XawCzlQRmHuRWraGDRX6nY9kFnMVdRHq6AHwQwp5Mjo4UOvKRmjezSm/jXRjdgH4TnMXfKgLS9AghFYDb0Syj6J07EuofQHSQJmmiCNQ== 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=KQzEawINTQ9sdmQbZzsXV93fjTXCxLsOZ3g/3sZIVK8=; b=Q6VTT7vqJCppJ+/c1thQfN7Xa7lucldzNq1bZTClBuJOKVPd3IjJFMdATWgCEBJaRh5wplXIwMlhmbPVgFmmsBcGEbGsDQfjF9/978m7Edk3Spt0k07Ux4PfCO4VpQzpODHgseYT1UPWmPdOsvtouKEEBCzxQ53MJGsPUZBIl/L7P33AkONAw39EIU+Be4fqLO7JnpDqyUqxX5mnnhxcGflpBiYcMCJbUNk1xlZugXYdBXmYrk83LskIY9bCYzEgu4gHv49KvhDlXj59tfynyNNEIH8LA6yQbeXH40fzLp+kRfaSdzpAcEASZZaacaUCpGuSEvriMM0pfmPow30+mg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by PH8PR11MB8038.namprd11.prod.outlook.com (2603:10b6:510:25e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9275.16; Wed, 5 Nov 2025 15:13:03 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39%5]) with mapi id 15.20.9298.007; Wed, 5 Nov 2025 15:13:03 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Alex Williamson , Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Yishai Hadas , Kevin Tian , Shameer Kolothum , , , , Matthew Brost , "Michal Wajdeczko" CC: , Jani Nikula , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , "Lukasz Laguna" , Christoph Hellwig , =?UTF-8?q?Micha=C5=82=20Winiarski?= Subject: [PATCH v4 26/28] drm/xe/pf: Export helpers for VFIO Date: Wed, 5 Nov 2025 16:10:24 +0100 Message-ID: <20251105151027.540712-27-michal.winiarski@intel.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251105151027.540712-1-michal.winiarski@intel.com> References: <20251105151027.540712-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BE1P281CA0102.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:79::15) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|PH8PR11MB8038:EE_ X-MS-Office365-Filtering-Correlation-Id: fd278e5b-3363-4da3-1712-08de1c7dd0df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|7416014|366016|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?B?KzNCY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A2SU9lTVdrYVp3QldsekpU?= =?utf-8?B?cFBzQ01oV203TXEzcDEwbmw1UHZxRlYrbDIvbEtMZVI5UjZyRmRJT3oxaXJq?= =?utf-8?B?Q25KU3JGQWlPemJnQ1g3bDNlY2MwMjlZbDFVZ0JFaUZHVGwxUHUwdVBmUCtG?= =?utf-8?B?MUxsN05TNTMxRWJuRENNUEwwUnAxTFErOVBUUUNzUDNXblZHYnRHYWRQMnJK?= =?utf-8?Q?ndgIVf/Lp2FQN45QHWpiWFepKAi828=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(7416014)(366016)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RmhFSVhzVGJzMWs0ak1IN0pKejZNdUhJcFMrcHYxME5HNENnSDFYS21kdER6?= =?utf-8?B?MXFkRjZRNjdLZ0NrY20xdUg0ZXhMeXAybFJIRUY3UGVjWlI3WUk1YXdXclZL?= =?utf-8?B?eHdvSjhNNGFHaFZJMHl6MVlJbnd4VWxyMk5ITmo4QlJFNk4zc29MbTVNMC9D?= =?utf-8?B?TW9GazA4ZFhrUnNSZjF0VmozRHAxdHk0YU43RDJ2OHYyWmhGeG1ldElTdXFH?= =?utf-8?B?YkxQUDJZUFRSMGxicDlYR3BDUWk0T1N2TWM1cWdtOEx1RytaaHFPcHRnVW9w?= =?utf-8?B?QUJUNTBCWGhMdFBNWnpuNDZpVkU3d0VPRm1ON21TMWxId296bzN6WkJuZm1m?= =?utf-8?B?d3hTaitockJEbk9pS2s5Y1dmSCtjVHJkQ1NDdTRrWmN3ZDQ0ZGZaZ1RwekdY?= =?utf-8?B?c2lPRGd2OVI3Z3F5WHF3RjBORFRQSDBUYnFtOU5BQkU5T29Ea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DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2025 15:13:03.5349 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mgULaGbEwRjWOV9JShGQz1J4BBY+rJ3t4ZrN68aXoDThD+JsKaqwwootU8yaoUEFAfTWDix61NDYsYTSUs+4E3C4gOqOBaSSZj1ZCbSQLHo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB8038 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Vendor-specific VFIO driver for Xe will implement VF migration. Export everything that's needed for migration ops. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/xe/Makefile | 2 + drivers/gpu/drm/xe/xe_sriov_vfio.c | 247 +++++++++++++++++++++++++++++ include/drm/intel/xe_sriov_vfio.h | 30 ++++ 3 files changed, 279 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_sriov_vfio.c create mode 100644 include/drm/intel/xe_sriov_vfio.h diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index e4b273b025d2a..eef09c44fbde6 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -184,6 +184,8 @@ xe-$(CONFIG_PCI_IOV) += \ xe_sriov_pf_sysfs.o \ xe_tile_sriov_pf_debugfs.o +xe-$(CONFIG_XE_VFIO_PCI) += xe_sriov_vfio.o + # include helpers for tests even when XE is built-in ifdef CONFIG_DRM_XE_KUNIT_TEST xe-y += tests/xe_kunit_helpers.o diff --git a/drivers/gpu/drm/xe/xe_sriov_vfio.c b/drivers/gpu/drm/xe/xe_sriov_vfio.c new file mode 100644 index 0000000000000..5aed2efbf6502 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_sriov_vfio.c @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2025 Intel Corporation + */ + +#include + +#include "xe_assert.h" +#include "xe_pci.h" +#include "xe_pm.h" +#include "xe_sriov_pf_control.h" +#include "xe_sriov_pf_helpers.h" +#include "xe_sriov_pf_migration.h" + +/** + * xe_sriov_vfio_get_pf() - Get PF &xe_device. + * @pdev: the VF &pci_dev device + * + * Return: pointer to PF &xe_device, NULL otherwise. + */ +struct xe_device *xe_sriov_vfio_get_pf(struct pci_dev *pdev) +{ + return xe_pci_get_pf(pdev); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_get_pf, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_migration_supported() - Check if migration is supported. + * @xe: the PF &xe_device + * + * Return: true if migration is supported, false otherwise. + */ +bool xe_sriov_vfio_migration_supported(struct xe_device *xe) +{ + return xe_sriov_pf_migration_supported(xe); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_migration_supported, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_wait_flr_done() - Wait for VF FLR completion. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * This function will wait until VF FLR is processed by PF on all tiles (or + * until timeout occurs). + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_wait_flr_done(struct xe_device *xe, unsigned int vfid) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + return xe_sriov_pf_control_wait_flr(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_wait_flr_done, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_suspend_device() - Suspend VF. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * This function will pause VF on all tiles/GTs. + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_suspend_device(struct xe_device *xe, unsigned int vfid) +{ + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + return xe_sriov_pf_control_pause_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_suspend_device, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_resume_device() - Resume VF. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * This function will resume VF on all tiles. + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_resume_device(struct xe_device *xe, unsigned int vfid) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + return xe_sriov_pf_control_resume_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_resume_device, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_stop_copy_enter() - Initiate a VF device migration data save. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_stop_copy_enter(struct xe_device *xe, unsigned int vfid) +{ + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + return xe_sriov_pf_control_trigger_save_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_stop_copy_enter, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_stop_copy_exit() - Finish a VF device migration data save. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_stop_copy_exit(struct xe_device *xe, unsigned int vfid) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + return xe_sriov_pf_control_finish_save_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_stop_copy_exit, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_resume_data_enter() - Initiate a VF device migration data restore. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_resume_data_enter(struct xe_device *xe, unsigned int vfid) +{ + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + return xe_sriov_pf_control_trigger_restore_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_resume_data_enter, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_resume_data_exit() - Finish a VF device migration data restore. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_resume_data_exit(struct xe_device *xe, unsigned int vfid) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + return xe_sriov_pf_control_finish_restore_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_resume_data_exit, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_error() - Move VF device to error state. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * Reset is needed to move it out of error state. + * + * Return: 0 on success or a negative error code on failure. + */ +int xe_sriov_vfio_error(struct xe_device *xe, unsigned int vfid) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + return xe_sriov_pf_control_stop_vf(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_error, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_data_read() - Read migration data from the VF device. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * @buf: start address of userspace buffer + * @len: requested read size from userspace + * + * Return: number of bytes that has been successfully read, + * 0 if no more migration data is available, -errno on failure. + */ +ssize_t xe_sriov_vfio_data_read(struct xe_device *xe, unsigned int vfid, + char __user *buf, size_t len) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + return xe_sriov_pf_migration_read(xe, vfid, buf, len); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_data_read, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_data_write() - Write migration data to the VF device. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * @buf: start address of userspace buffer + * @len: requested write size from userspace + * + * Return: number of bytes that has been successfully written, -errno on failure. + */ +ssize_t xe_sriov_vfio_data_write(struct xe_device *xe, unsigned int vfid, + const char __user *buf, size_t len) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + return xe_sriov_pf_migration_write(xe, vfid, buf, len); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_data_write, "xe-vfio-pci"); + +/** + * xe_sriov_vfio_stop_copy_size() - Get a size estimate of VF device migration data. + * @xe: the PF &xe_device + * @vfid: the VF identifier (can't be 0) + * + * Return: migration data size in bytes or a negative error code on failure. + */ +ssize_t xe_sriov_vfio_stop_copy_size(struct xe_device *xe, unsigned int vfid) +{ + if (vfid == PFID || vfid > xe_sriov_pf_get_totalvfs(xe)) + return -EINVAL; + + xe_assert(xe, !xe_pm_runtime_suspended(xe)); + + return xe_sriov_pf_migration_size(xe, vfid); +} +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_stop_copy_size, "xe-vfio-pci"); diff --git a/include/drm/intel/xe_sriov_vfio.h b/include/drm/intel/xe_sriov_vfio.h new file mode 100644 index 0000000000000..bcd7085a81c55 --- /dev/null +++ b/include/drm/intel/xe_sriov_vfio.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright © 2025 Intel Corporation + */ + +#ifndef _XE_SRIOV_VFIO_H_ +#define _XE_SRIOV_VFIO_H_ + +#include + +struct pci_dev; +struct xe_device; + +struct xe_device *xe_sriov_vfio_get_pf(struct pci_dev *pdev); +bool xe_sriov_vfio_migration_supported(struct xe_device *xe); +int xe_sriov_vfio_wait_flr_done(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_suspend_device(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_resume_device(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_stop_copy_enter(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_stop_copy_exit(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_resume_data_enter(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_resume_data_exit(struct xe_device *xe, unsigned int vfid); +int xe_sriov_vfio_error(struct xe_device *xe, unsigned int vfid); +ssize_t xe_sriov_vfio_data_read(struct xe_device *xe, unsigned int vfid, + char __user *buf, size_t len); +ssize_t xe_sriov_vfio_data_write(struct xe_device *xe, unsigned int vfid, + const char __user *buf, size_t len); +ssize_t xe_sriov_vfio_stop_copy_size(struct xe_device *xe, unsigned int vfid); + +#endif -- 2.51.2