[igt-dev] [PATCH i-g-t] tests/i915/module_load: Add probe subtest

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 11 13:41:48 UTC 2018


Quoting Arkadiusz Hiler (2018-12-11 13:02:06)
> The subtest is intended to be run as the very first thing on a machine with
> i915 blacklisted. It is supposed to be a catch-all for warnings/issues that
> happen during the initial module load.
> 
> If i915 turns out to be already loaded, the subtest simply skips.
> 
> Cc: Petri Latvala <petri.latvala at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
> ---
>  tests/i915/module_load.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/tests/i915/module_load.c b/tests/i915/module_load.c
> index 7fe83520..14552990 100644
> --- a/tests/i915/module_load.c
> +++ b/tests/i915/module_load.c
> @@ -324,8 +324,48 @@ hda_dynamic_debug(bool enable)
>         fclose(fp);
>  }
>  
> +static void
> +reprobe_connectors(int fd)
> +{
> +       int i, ret;
> +       struct drm_mode_get_connector conn;
> +
> +       drmModeResPtr res = drmModeGetResources(fd);
> +       if (!res)
> +               return;
> +
> +       for (i = 0; i < res->count_connectors; ++i) {
> +               memset(&conn, 0, sizeof(conn));
> +               conn.connector_id = res->connectors[i];
> +               ret = drmIoctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn);
> +               igt_assert_neq(ret, -EFAULT);

drmIoctl(GETCONNECTOR) returns 0 or -1.

There's an interesting compat issue with struct drm_mode_get_connector
and needs padding for 32b userspace on 64b kernel. Worth double checking
if that's been fixed in the headers or not, and if not provide a compat
struct, which can be zeroed inside the block with just a local C99
instantiation.

> +       }
> +
> +       drmModeFreeResources(res);

res is a global? Now a dangling pointer.

Since all you want is connectors[], you can just do GETRESOURCES and
just get the connectors[] into an onstack array. Give it 32 or 64 u32
and add a fixme if we ever need more (or do just a malloc for the large
array).
-Chris


More information about the igt-dev mailing list