[PATCH] drm/xe/vf: Fix register value lookup

Matt Roper matthew.d.roper at intel.com
Thu Jul 18 21:53:35 UTC 2024


On Thu, Jul 18, 2024 at 10:31:55PM +0200, Michal Wajdeczko wrote:
> We should use the number of actual entries stored in the runtime
> register buffer, not the maximum number of entries that this buffer
> can hold, otherwise bsearch() may fail and we may miss the data and
> wrongly report unexpected access to some registers.
> 
> Fixes: 4edadc41a3a4 ("drm/xe/vf: Use register values obtained from the PF")
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Piotr Piórkowski <piotr.piorkowski at intel.com>
> Cc: Matt Roper <matthew.d.roper at intel.com>

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

> ---
>  drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> index 6a87d31c44e6..47222bd9988d 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> @@ -850,7 +850,7 @@ static struct vf_runtime_reg *vf_lookup_reg(struct xe_gt *gt, u32 addr)
>  
>  	xe_gt_assert(gt, IS_SRIOV_VF(gt_to_xe(gt)));
>  
> -	return bsearch(&key, runtime->regs, runtime->regs_size, sizeof(key),
> +	return bsearch(&key, runtime->regs, runtime->num_regs, sizeof(key),
>  		       vf_runtime_reg_cmp);
>  }
>  
> -- 
> 2.43.0
> 

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


More information about the Intel-xe mailing list