public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Laguna, Lukasz" <lukasz.laguna@intel.com>
To: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>
Cc: <kamil.konieczny@linux.intel.com>,
	<adam.miszczak@linux.intel.com>, <jakub1.kolakowski@intel.com>
Subject: Re: [PATCH v2 i-g-t 4/4] tests/intel/xe_sriov_vfio: Add region-info subtest
Date: Mon, 30 Mar 2026 10:19:28 +0200	[thread overview]
Message-ID: <d30c79be-5f0b-4c03-8ca1-d16e84dd0778@intel.com> (raw)
In-Reply-To: <20260327140627.64574-5-marcin.bernatowicz@linux.intel.com>


On 3/27/2026 15:06, Marcin Bernatowicz wrote:
> Bind a VF to xe-vfio-pci, open the VFIO device, and query VFIO region
> information. This provides basic coverage for VFIO BAR exposure and
> device region enumeration.
>
> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
> Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
> Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
> Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> Cc: Lukasz Laguna <lukasz.laguna@intel.com>

Reviewed-by: Lukasz Laguna <lukasz.laguna@intel.com>

> ---
> v2:
> - Introduce vf_num variable for clarity (Lukasz)
> - Remove unnecessary unbind (Lukasz)
> ---
>   tests/intel/xe_sriov_vfio.c | 85 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 85 insertions(+)
>
> diff --git a/tests/intel/xe_sriov_vfio.c b/tests/intel/xe_sriov_vfio.c
> index 6a86b3780..f42deaea6 100644
> --- a/tests/intel/xe_sriov_vfio.c
> +++ b/tests/intel/xe_sriov_vfio.c
> @@ -28,6 +28,9 @@
>    *
>    * SUBTEST: open-basic
>    * Description: Bind VF to xe-vfio-pci and perform minimal VFIO group open and status ioctl.
> + *
> + * SUBTEST: region-info
> + * Description: Bind VF to xe-vfio-pci, open VFIO device and query VFIO region info (BAR sizes).
>    */
>   
>   IGT_TEST_DESCRIPTION("Xe SR-IOV VFIO tests (xe-vfio-pci)");
> @@ -218,6 +221,58 @@ static void vfio_open_basic(const char *pci_slot)
>   	vfio_close_device(&fds);
>   }
>   
> +static void vfio_open_device(const char *pci_slot, struct vfio_dev_fds *out)
> +{
> +	struct vfio_group_status group_status;
> +	int ret;
> +
> +	vfio_open_group(pci_slot, out, &group_status);
> +
> +	igt_require_f(group_status.flags & VFIO_GROUP_FLAGS_VIABLE,
> +		      "VFIO group %s is not viable (flags=0x%x)\n",
> +		      out->group_id, group_status.flags);
> +
> +	ret = ioctl(out->group_fd, VFIO_GROUP_SET_CONTAINER, &out->container_fd);
> +	igt_require_f(ret == 0, "VFIO_GROUP_SET_CONTAINER failed (%d)\n", -errno);
> +
> +	ret = ioctl(out->container_fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
> +	igt_require_f(ret == 0, "VFIO_SET_IOMMU(VFIO_TYPE1_IOMMU) failed (%d)\n", -errno);
> +
> +	out->device_fd = ioctl(out->group_fd, VFIO_GROUP_GET_DEVICE_FD, (char *)pci_slot);
> +	igt_assert_f(out->device_fd >= 0, "VFIO_GROUP_GET_DEVICE_FD(%s) failed (%d)\n",
> +		     pci_slot, -errno);
> +}
> +
> +static void vfio_dump_region_info(int device_fd)
> +{
> +	struct vfio_device_info dinfo = { .argsz = sizeof(dinfo) };
> +	int ret;
> +
> +	ret = ioctl(device_fd, VFIO_DEVICE_GET_INFO, &dinfo);
> +	igt_assert_f(ret == 0, "VFIO_DEVICE_GET_INFO failed (%d)\n", -errno);
> +
> +	igt_info("VFIO device: flags=0x%x num_regions=%u num_irqs=%u\n",
> +		 dinfo.flags, dinfo.num_regions, dinfo.num_irqs);
> +
> +	for (uint32_t i = 0; i < dinfo.num_regions; i++) {
> +		struct vfio_region_info rinfo = {
> +			.argsz = sizeof(rinfo),
> +			.index = i,
> +		};
> +
> +		ret = ioctl(device_fd, VFIO_DEVICE_GET_REGION_INFO, &rinfo);
> +		igt_assert_f(ret == 0, "VFIO_DEVICE_GET_REGION_INFO(index=%u) failed (%d)\n",
> +			     i, -errno);
> +
> +		igt_info("region[%u]: size=%llu offset=%llu flags=0x%x caps=%u\n",
> +			 i,
> +			 (unsigned long long)rinfo.size,
> +			 (unsigned long long)rinfo.offset,
> +			 rinfo.flags,
> +			 rinfo.cap_offset);
> +	}
> +}
> +
>   static void open_pf(void)
>   {
>   	int fd;
> @@ -343,6 +398,36 @@ int igt_main()
>   		igt_sriov_disable_vfs(pf_fd);
>   	}
>   
> +	igt_describe("Bind VF to xe-vfio-pci and query VFIO region info (BAR sizes). ");
> +	igt_subtest("region-info") {
> +		unsigned int vf_num = 1;
> +		struct vfio_dev_fds fds;
> +		char *slot = NULL;
> +
> +		igt_skip_on_f(igt_kmod_load(XE_VFIO_PCI_MOD, NULL),
> +			      "Failed to load %s\n", XE_VFIO_PCI_MOD);
> +
> +		open_pf();
> +
> +		igt_sriov_disable_driver_autoprobe(pf_fd);
> +		igt_sriov_enable_vfs(pf_fd, vf_num);
> +
> +		igt_require_f(!igt_pci_system_reinit(), "Failed to refresh PCI state\n");
> +		igt_sriov_enable_driver_autoprobe(pf_fd);
> +
> +		slot = vf_pci_slot_alloc(vf_num);
> +
> +		vf_bind_override(vf_num, XE_VFIO_PCI_DRV);
> +
> +		vfio_open_device(slot, &fds);
> +		vfio_dump_region_info(fds.device_fd);
> +		vfio_close_device(&fds);
> +
> +		vf_unbind_override(vf_num);
> +		free(slot);
> +		igt_sriov_disable_vfs(pf_fd);
> +	}
> +
>   	igt_fixture() {
>   		cleanup_pf();
>   		restore_xe_vfio_module();

  reply	other threads:[~2026-03-30  8:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-27 14:06 [PATCH v2 i-g-t 0/4] tests/intel/xe_sriov_vfio: Add basic VFIO coverage Marcin Bernatowicz
2026-03-27 14:06 ` [PATCH v2 i-g-t 1/4] tests/intel/xe_sriov_vfio: Add VFIO module load/unload subtest Marcin Bernatowicz
2026-03-30  8:18   ` Laguna, Lukasz
2026-03-27 14:06 ` [PATCH v2 i-g-t 2/4] tests/intel/xe_sriov_vfio: Add dynamic bind-unbind-vfs subtest Marcin Bernatowicz
2026-03-30  8:18   ` Laguna, Lukasz
2026-03-27 14:06 ` [PATCH v2 i-g-t 3/4] tests/intel/xe_sriov_vfio: Add open-basic subtest Marcin Bernatowicz
2026-03-30  8:19   ` Laguna, Lukasz
2026-03-27 14:06 ` [PATCH v2 i-g-t 4/4] tests/intel/xe_sriov_vfio: Add region-info subtest Marcin Bernatowicz
2026-03-30  8:19   ` Laguna, Lukasz [this message]
2026-03-27 22:25 ` ✓ Xe.CI.BAT: success for tests/intel/xe_sriov_vfio: Add basic VFIO coverage (rev2) Patchwork
2026-03-27 22:57 ` ✓ i915.CI.BAT: " Patchwork
2026-03-28 15:53 ` ✓ Xe.CI.FULL: " Patchwork
2026-03-29  3:48 ` ✗ i915.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d30c79be-5f0b-4c03-8ca1-d16e84dd0778@intel.com \
    --to=lukasz.laguna@intel.com \
    --cc=adam.miszczak@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jakub1.kolakowski@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=marcin.bernatowicz@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox