[Intel-xe] [PATCH 2/2] drm/xe: Use FIELD_PREP/FIELD_GET for tile id encoding

Matthew Brost matthew.brost at intel.com
Wed Jul 19 03:16:59 UTC 2023


On Tue, Jul 18, 2023 at 12:39:24PM -0700, Lucas De Marchi wrote:
> Use FIELD_PREP()/FIELD_GET() to encode the tile id into flags. Besides
> protecting for eventual overflow it also makes it easier to see a new
> flag can't be added as BIT(7).
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>

Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_vm_types.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_vm_types.h b/drivers/gpu/drm/xe/xe_vm_types.h
> index 223b8f84c546..379c5d617d72 100644
> --- a/drivers/gpu/drm/xe/xe_vm_types.h
> +++ b/drivers/gpu/drm/xe/xe_vm_types.h
> @@ -150,8 +150,8 @@ struct xe_vm {
>  #define XE_VM_FLAG_SCRATCH_PAGE		BIT(4)
>  #define XE_VM_FLAG_FAULT_MODE		BIT(5)
>  #define XE_VM_FLAG_BANNED		BIT(6)
> -#define XE_VM_FLAG_TILE_ID(flags)	(((flags) >> 7) & 0x3)
> -#define XE_VM_FLAG_SET_TILE_ID(tile)	((tile)->id << 7)
> +#define XE_VM_FLAG_TILE_ID(flags)	FIELD_GET(GENMASK(8, 7), flags)
> +#define XE_VM_FLAG_SET_TILE_ID(tile)	FIELD_PREP(GENMASK(8, 7), (tile)->id)
>  	unsigned long flags;
>  
>  	/** @composite_fence_ctx: context composite fence */
> -- 
> 2.40.1
> 


More information about the Intel-xe mailing list