From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F6113328E5; Tue, 25 Nov 2025 18:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.146 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764095655; cv=none; b=cgW+2mKTd87UgUVPLwV/G09bqLM02zt+TP0lZdErFHS2GT2lQbdSKurL6TGEFcUKyAGYrG018jr/zDG2wkI9FNFygeR5B6gVPu7fi5OejD1LPdk4pFifoJo69Uh7EjjEySAS6o+z+8MRxUdSBhxPAyLn5kdNhYuJXTYrdsO0Rq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764095655; c=relaxed/simple; bh=pTTNRwp9pRTR+lKIBJxL2n2VGK8cqgABoUyjS6zAqAY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o0nWdmeDDaeYu7HQIGcIJREAAvwEJvDeAkR6afHzr6fSiInFu6EZG3+gK8rlWwl6xWlq+qbi8MKIrxMeSUYq6c5Kr05lt/+83RQdec4iyiiUHFHJnro1isztEdSBkuAyKmS0XNb9C38cXXsHgex/7CfmT3apFcBZXdCGK9Gx7Uk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b=qdqbeodx; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VDYg48Yq; arc=none smtp.client-ip=202.12.124.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shazbot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b="qdqbeodx"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VDYg48Yq" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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