[PATCH v4 1/1] drm/xe: correct the calculation of remaining size

Matt Roper matthew.d.roper at intel.com
Thu Jan 18 23:11:41 UTC 2024


On Thu, Jan 18, 2024 at 02:20:51PM -0800, fei.yang at intel.com wrote:
> From: Fei Yang <fei.yang at intel.com>
> 
> In function write_pgtable, the calculation of chunk in the do-while
> loop is wrong, we should always compare against remaining size instead
> of the total size update->qwords.
> Also correct the assert. While one MI_STORE_DATA_IMM can take no more
> than 0x1fe qwords, the size of the pgtable can be 512 entries.

I just saw this v4 after I merged v3 to drm-xe-next.  But the assertion
change is logically different from the loop bound change, so it should
probably be a separate patch anyway (and with a Fixes: marker too).

Also, it would be best to avoid using a magic number if possible
(especially one written in the manner that makes it look like a field
value).  It looks like we use XE_PDES in other places where we need to
represent the number of entries inside a page table bo?


Matt

> 
> Signed-off-by: Fei Yang <fei.yang at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_migrate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index 44725f978f3e..04e9f723d316 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -1107,7 +1107,7 @@ static void write_pgtable(struct xe_tile *tile, struct xe_bb *bb, u64 ppgtt_ofs,
>  	 * This shouldn't be possible in practice.. might change when 16K
>  	 * pages are used. Hence the assert.
>  	 */
> -	xe_tile_assert(tile, update->qwords <= MAX_PTE_PER_SDI);
> +	xe_tile_assert(tile, update->qwords <= 0x1ff);
>  	if (!ppgtt_ofs)
>  		ppgtt_ofs = xe_migrate_vram_ofs(tile_to_xe(tile),
>  						xe_bo_addr(update->pt_bo, 0,
> @@ -1116,7 +1116,7 @@ static void write_pgtable(struct xe_tile *tile, struct xe_bb *bb, u64 ppgtt_ofs,
>  	do {
>  		u64 addr = ppgtt_ofs + ofs * 8;
>  
> -		chunk = min(update->qwords, MAX_PTE_PER_SDI);
> +		chunk = min(size, MAX_PTE_PER_SDI);
>  
>  		/* Ensure populatefn can do memset64 by aligning bb->cs */
>  		if (!(bb->len & 1))
> -- 
> 2.25.1
> 

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


More information about the Intel-xe mailing list