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 0B8F1D10F34 for ; Wed, 26 Nov 2025 12:50:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B161710E5F5; Wed, 26 Nov 2025 12:50:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=shazbot.org header.i=@shazbot.org header.b="qdqbeodx"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="VDYg48Yq"; dkim-atps=neutral X-Greylist: delayed 419 seconds by postgrey-1.36 at gabe; Tue, 25 Nov 2025 18:41:07 UTC Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) by gabe.freedesktop.org (Postfix) with ESMTPS id B547B10E439 for ; Tue, 25 Nov 2025 18:41:07 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id A2D041D000C7; Tue, 25 Nov 2025 13:34:07 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Tue, 25 Nov 2025 13:34:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1764095647; x=1764182047; bh=F0IpR5aPqfm9XY0htrmR71S0FnmwAcLKnqO8oA47JqI=; b= qdqbeodxTOuavSU8Jmqwf5n2cwtZRx0EolpcdTsqZ+Dj3oaOMjHME/tUbsBFLmOH tMuDEabcZ9+Mr/tXBWZ2k6AplvoGDne5QmEbujdLErq69NVhydjBfnf7dMEuTlCG 1sNq6gMYq2YmnWcd1b7Op2QKazMBH6lJpWOF1up6WeVhDpRbcrTTylSXKp6wtcVC Ri3s+ZnOb86Quoz0N1IT6cy6CeBhYeDUVt8F8YsYcx2W7Bz9TFaKJ0FjFqNnqRcD 11H9Lkx5d5gKeHz8VW4NeKXYqyqUlpn71lT143s8sXPbEDlAUcaVCC4ipkWCDdWV XqBdQ5E3xZOz8guCervEPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1764095647; x= 1764182047; bh=F0IpR5aPqfm9XY0htrmR71S0FnmwAcLKnqO8oA47JqI=; b=V DYg48YqVwRHFzlSubi8599r21bBXbSlPtP4K3oM6CQ3tCqAAfAclBBToBFOSCDwr IeVO2aCmMajpUV1uzOQwyzcdrZs/YCMIZKi9Qr7CwKpFIXs11T3v2y1xnrRecPzA 6okyXuzSBrs3cpUOay2Q+cL2+H6eAjbEi/PvKr9URDpti81Q8+Fe3t5JXNgrtiSq YrwJOXKYGPHvxLGNGkNNAMeunL3xOOt1fReRC27/SCCe0bawU7cIbOsLWwLLRQWx Mg0QPA8HBP9xyfr4GZHgbLYOXLYGTm9tChbucp787LQLBvI+ncKCtmw5ug35DJFy ZPYAAFuXmIhZ6AmX6L9yg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvgedvvddtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkjghfgggtgfesthhqredttddtjeenucfhrhhomheptehlvgigucgh ihhllhhirghmshhonhcuoegrlhgvgiesshhhrgiisghothdrohhrgheqnecuggftrfgrth htvghrnhepgfffvdefjeejueevfeetudfhgeetfeeuheetfeekjedvuddvueehffdtgeej keetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hlvgigsehshhgriigsohhtrdhorhhgpdhnsggprhgtphhtthhopedvuddpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepmhhitghhrghlrdifihhnihgrrhhskhhisehinhhtvg hlrdgtohhmpdhrtghpthhtoheplhhutggrshdruggvmhgrrhgthhhisehinhhtvghlrdgt ohhmpdhrtghpthhtohepthhhohhmrghsrdhhvghllhhsthhrohhmsehlihhnuhigrdhinh htvghlrdgtohhmpdhrtghpthhtoheprhhoughrihhgohdrvhhivhhisehinhhtvghlrdgt ohhmpdhrtghpthhtohepjhhgghesiihivghpvgdrtggrpdhrtghpthhtohephihishhhrg hihhesnhhvihguihgrrdgtohhmpdhrtghpthhtohepkhgvvhhinhdrthhirghnsehinhht vghlrdgtohhmpdhrtghpthhtohepshhkohhlohhthhhumhhthhhosehnvhhiughirgdrtg homhdprhgtphhtthhopehinhhtvghlqdigvgeslhhishhtshdrfhhrvggvuggvshhkthho phdrohhrgh X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Nov 2025 13:34:04 -0500 (EST) Date: Tue, 25 Nov 2025 11:34:03 -0700 From: Alex Williamson To: =?UTF-8?B?TWljaGHFgg==?= Winiarski Cc: Lucas De Marchi , Thomas =?UTF-8?B?SGVsbHN0?= =?UTF-8?B?csO2bQ==?= , Rodrigo Vivi , Jason Gunthorpe , Yishai Hadas , Kevin Tian , Shameer Kolothum , , , , Matthew Brost , "Michal Wajdeczko" , , Jani Nikula , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , "Lukasz Laguna" , Christoph Hellwig Subject: Re: [PATCH v6 3/4] drm/xe/pf: Export helpers for VFIO Message-ID: <20251125113403.6156f03a.alex@shazbot.org> In-Reply-To: <20251124230841.613894-4-michal.winiarski@intel.com> References: <20251124230841.613894-1-michal.winiarski@intel.com> <20251124230841.613894-4-michal.winiarski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Wed, 26 Nov 2025 12:49:56 +0000 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Tue, 25 Nov 2025 00:08:40 +0100 Micha=C5=82 Winiarski wrote: > +/** > + * xe_sriov_vfio_wait_flr_done() - Wait for VF FLR completion. > + * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf() > + * @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 (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(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 obtained by calling xe_sriov_vfio_get_pf() > + * @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) > +{ > + if (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(xe); > + > + 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 obtained by calling xe_sriov_vfio_get_pf() > + * @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 (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(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 obtained by calling xe_sriov_vfio_get_pf() > + * @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 vfi= d) > +{ > + if (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(xe); > + > + 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 sa= ve. > + * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf() > + * @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 (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(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 da= ta restore. > + * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf() > + * @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 v= fid) > +{ > + if (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(xe); > + > + 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 obtained by calling xe_sriov_vfio_get_pf() > + * @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 vf= id) > +{ > + if (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(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 obtained by calling xe_sriov_vfio_get_pf() > + * @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 (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(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 obtained by calling xe_sriov_vfio_get_pf() > + * @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 (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(xe); > + > + 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 obtained by calling xe_sriov_vfio_get_pf() > + * @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 (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(xe); > + > + 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 mig= ration data. > + * @xe: the PF &xe_device obtained by calling xe_sriov_vfio_get_pf() > + * @vfid: the VF identifier (can't be 0) > + * > + * Return: migration data size in bytes or a negative error code on fail= ure. > + */ > +ssize_t xe_sriov_vfio_stop_copy_size(struct xe_device *xe, unsigned int = vfid) > +{ > + if (!IS_SRIOV_PF(xe)) > + return -EPERM; > + if (vfid =3D=3D PFID || vfid > xe_sriov_pf_num_vfs(xe)) > + return -EINVAL; > + > + guard(xe_pm_runtime_noresume)(xe); > + > + return xe_sriov_pf_migration_size(xe, vfid); > +} > +EXPORT_SYMBOL_FOR_MODULES(xe_sriov_vfio_stop_copy_size, "xe-vfio-pci"); The duplicated testing and identical structure of most of the above functions suggests a helper, if not full on definition by macro. Thanks, Alex