diff options
author | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-01-20 15:43:58 +0100 |
---|---|---|
committer | Rodrigo Vivi <rodrigo.vivi@intel.com> | 2023-12-19 18:27:43 -0500 |
commit | a93bcc3acf1fdf55b1906e37744ebab9be884a5d (patch) | |
tree | 5570f12d2603556a8cee22c6ffcde15f9a8c03ce | |
parent | b3ab1b918e59c84ddaf190f75ba93be6cdea1fcb (diff) |
drm/xe: skip Kunit tests requiring real hardware when running on UML
Some tests are meant to run only on real hardware. Skip those,
if no device was found.
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
-rw-r--r-- | drivers/gpu/drm/xe/xe_pci.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c index 49f1f0489f1c..b61bde17f123 100644 --- a/drivers/gpu/drm/xe/xe_pci.c +++ b/drivers/gpu/drm/xe/xe_pci.c @@ -615,16 +615,23 @@ void xe_unregister_pci_driver(void) } #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST) -static int dev_to_xe_device_fn(struct device *dev, void *data) +struct kunit_test_data { + int ndevs; + xe_device_fn xe_fn; +}; + +static int dev_to_xe_device_fn(struct device *dev, void *__data) { struct drm_device *drm = dev_get_drvdata(dev); - int (*xe_fn)(struct xe_device *xe) = data; + struct kunit_test_data *data = __data; int ret = 0; int idx; + data->ndevs++; + if (drm_dev_enter(drm, &idx)) - ret = xe_fn(to_xe_device(dev_get_drvdata(dev))); + ret = data->xe_fn(to_xe_device(dev_get_drvdata(dev))); drm_dev_exit(idx); return ret; @@ -645,7 +652,18 @@ static int dev_to_xe_device_fn(struct device *dev, void *data) */ int xe_call_for_each_device(xe_device_fn xe_fn) { - return driver_for_each_device(&xe_pci_driver.driver, NULL, - xe_fn, dev_to_xe_device_fn); + int ret; + struct kunit_test_data data = { + .xe_fn = xe_fn, + .ndevs = 0, + }; + + ret = driver_for_each_device(&xe_pci_driver.driver, NULL, + &data, dev_to_xe_device_fn); + + if (!data.ndevs) + kunit_skip(current->kunit_test, "test runs only on hardware\n"); + + return ret; } #endif |