[PATCH i-g-t 5/6] tools/intel_reg: Add wrapper for reg access init

Matt Roper matthew.d.roper at intel.com
Fri Sep 20 17:35:49 UTC 2024


On Wed, Sep 18, 2024 at 09:36:28AM -0700, Lucas De Marchi wrote:
> Extract helper function so it can be extended to xe.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
>  tools/intel_reg.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/intel_reg.c b/tools/intel_reg.c
> index c5800cf05..906ae9b84 100644
> --- a/tools/intel_reg.c
> +++ b/tools/intel_reg.c
> @@ -800,6 +800,11 @@ static int parse_reg(struct config *config, struct reg *reg, const char *s)
>  	return ret;
>  }
>  
> +static int register_access_init(struct config *config)
> +{
> +	return intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
> +}
> +
>  /* XXX: add support for register ranges, maybe REGISTER..REGISTER */
>  static int intel_reg_read(struct config *config, int argc, char *argv[])
>  {
> @@ -812,8 +817,8 @@ static int intel_reg_read(struct config *config, int argc, char *argv[])
>  
>  	if (config->mmiofile)
>  		intel_mmio_use_dump_file(&config->mmio_data, config->mmiofile);
> -	else
> -		intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
> +	else if (register_access_init(config) < 0)
> +		return EXIT_FAILURE;

The new EXIT_FAILURE returns are still impossible until the next patch,
right?  It doesn't look like intel_register_access_init() can ever fail.

Reviewed-by: Matt Roper <matthew.d.roper at intel.com>

>  
>  	for (i = 1; i < argc; i++) {
>  		struct reg reg;
> @@ -843,7 +848,9 @@ static int intel_reg_write(struct config *config, int argc, char *argv[])
>  		return EXIT_FAILURE;
>  	}
>  
> -	intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
> +
> +	if (register_access_init(config) < 0)
> +		return EXIT_FAILURE;
>  
>  	for (i = 1; i < argc; i += 2) {
>  		struct reg reg;
> @@ -880,8 +887,8 @@ static int intel_reg_dump(struct config *config, int argc, char *argv[])
>  
>  	if (config->mmiofile)
>  		intel_mmio_use_dump_file(&config->mmio_data, config->mmiofile);
> -	else
> -		intel_register_access_init(&config->mmio_data, config->pci_dev, 0, -1);
> +	else if (register_access_init(config) < 0)
> +		return EXIT_FAILURE;
>  
>  	for (i = 0; i < config->regcount; i++) {
>  		reg = &config->regs[i];
> -- 
> 2.46.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the igt-dev mailing list