[igt-dev] [PATCH i-g-t 1/2] i915: Add test to assert that the PCI-ID is known

Mika Kuoppala mika.kuoppala at linux.intel.com
Tue May 19 14:48:37 UTC 2020


Chris Wilson <chris at chris-wilson.co.uk> writes:

> We do want to ensure that the igt identification table is kept up to
> date, and so would like to be warned if being run on an unknown chipset.
> Instead of refusing to run any test, have a specific test for the
> unknown chipset.
>
> Suggested-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
> ---
>  tests/Makefile.sources  |  3 ++
>  tests/i915/i915_pciid.c | 62 +++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build       |  1 +
>  3 files changed, 66 insertions(+)
>  create mode 100644 tests/i915/i915_pciid.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index c450fa0ed..f1df13465 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -475,6 +475,9 @@ i915_hangman_SOURCES = i915/i915_hangman.c
>  TESTS_progs += i915_module_load
>  i915_module_load_SOURCES = i915/i915_module_load.c
>  
> +TESTS_progs += i915_pciid
> +i915_pciid_SOURCES = i915/i915_pciid.c
> +
>  TESTS_progs += i915_pm_backlight
>  i915_pm_backlight_SOURCES = i915/i915_pm_backlight.c
>  
> diff --git a/tests/i915/i915_pciid.c b/tests/i915/i915_pciid.c
> new file mode 100644
> index 000000000..03d0409c3
> --- /dev/null
> +++ b/tests/i915/i915_pciid.c
> @@ -0,0 +1,62 @@
> +/*
> + * Copyright © 2020 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + */
> +
> +#include <sys/ioctl.h>
> +
> +#include "drm.h"
> +#include "drmtest.h"
> +#include "i915_drm.h"
> +#include "intel_chipset.h"
> +
> +IGT_TEST_DESCRIPTION("Check that igt/i915 know about this PCI-ID");
> +
> +static bool has_known_intel_chipset(int fd)
> +{
> +	int devid = 0;
> +	struct drm_i915_getparam gp = {
> +		.param = I915_PARAM_CHIPSET_ID,
> +		.value = &devid,
> +	};
> +	const struct intel_device_info *info;
> +
> +	if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
> +		return false;
> +
> +	info = intel_get_device_info(devid);
> +	if (!info) {
> +		igt_warn("Unrecongised PCI-ID: %04x\n", devid);
> +		return false;
> +	}
> +
> +	igt_info("PCI-ID: %#04x, gen %d, %s\n",
> +		 devid, ffs(info->gen), info->codename);

Going past intel_gen but we get the raw non tampered
values into log.

Reviewed-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>

> +	return true;
> +}
> +
> +igt_simple_main
> +{
> +	int intel = drm_open_driver(DRIVER_INTEL);
> +
> +	igt_assert(has_known_intel_chipset(intel));
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 88e4875b6..d021af682 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -218,6 +218,7 @@ i915_progs = [
>  	'i915_getparams_basic',
>  	'i915_hangman',
>  	'i915_module_load',
> +	'i915_pciid',
>  	'i915_pm_backlight',
>  	'i915_pm_lpsp',
>  	'i915_pm_rpm',
> -- 
> 2.26.2


More information about the igt-dev mailing list