[PATCH i-g-t 6/6] tools/intel_reg: Add forcewake support to xe

Ville Syrjälä ville.syrjala at linux.intel.com
Fri Sep 20 17:43:31 UTC 2024


On Wed, Sep 18, 2024 at 09:36:29AM -0700, Lucas De Marchi wrote:
> Now that the igt lib is prepared, start passing the open driver fd so
> the correct forcewake is taken.
> 
> Before:
> $ sudo ./build/tools/intel_reg read 0x2358
>                                     (0x00002358): 0xffffffff
> 
> After:
> $ sudo ./build/tools/intel_reg read 0x2358
> Opened device: /dev/dri/card0
>                                     (0x00002358): 0x91e59eeb
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
>  tools/intel_reg.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/intel_reg.c b/tools/intel_reg.c
> index 906ae9b84..b650c3697 100644
> --- a/tools/intel_reg.c
> +++ b/tools/intel_reg.c
> @@ -802,7 +802,18 @@ static int parse_reg(struct config *config, struct reg *reg, const char *s)
>  
>  static int register_access_init(struct config *config)
>  {
> -	return intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
> +	int drm_fd = __drm_open_driver(DRIVER_INTEL | DRIVER_XE);
> +	int ret;
> +
> +	if (drm_fd < 0) {
> +		fprintf(stderr, "could not open i915 or xe device\n");
> +		return EXIT_FAILURE;

Nak. The tool must work without a driver.

> +	}
> +
> +	ret = intel_register_access_init(&config->mmio_data, config->pci_dev, 0, drm_fd);
> +	close(drm_fd);
> +
> +	return ret;
>  }
>  
>  /* XXX: add support for register ranges, maybe REGISTER..REGISTER */
> -- 
> 2.46.1

-- 
Ville Syrjälä
Intel


More information about the igt-dev mailing list