[PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node

Matthew Brost matthew.brost at intel.com
Wed Jul 17 23:27:56 UTC 2024


On Thu, Jul 11, 2024 at 01:11:50PM -0400, Rodrigo Vivi wrote:
> Continue with the encapsulation of drm_mm_node inside xe_ggtt.
> 
> Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

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

> ---
>  drivers/gpu/drm/xe/display/xe_fb_pin.c     |  2 +-
>  drivers/gpu/drm/xe/xe_ggtt.c               | 11 +++++++++++
>  drivers/gpu/drm/xe/xe_ggtt.h               |  1 +
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 12 ++++++------
>  4 files changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index db74c3395ef8..de4930b67a29 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -323,7 +323,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
>  
>  	if (vma->dpt)
>  		xe_bo_unpin_map_no_vm(vma->dpt);
> -	else if (!drm_mm_node_allocated(&vma->bo->ggtt_node.base) ||
> +	else if (!xe_ggtt_node_allocated(&vma->bo->ggtt_node) ||
>  		 vma->bo->ggtt_node.base.start != vma->node.base.start)
>  		xe_ggtt_node_remove(ggtt, &vma->node, false);
>  
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 3ab29588a068..67337bfeb81e 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -477,6 +477,17 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
>  	drm_dev_exit(idx);
>  }
>  
> +/**
> + * xe_ggtt_node_allocated - Check if node is allocated
> + * @node: the &xe_ggtt_node to be inspected
> + *
> + * Return: True if allocated, False otherwise.
> + */
> +bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
> +{
> +	return drm_mm_node_allocated(&node->base);
> +}
> +
>  /**
>   * xe_ggtt_map_bo - Map the BO into GGTT
>   * @ggtt: the &xe_ggtt where node will be mapped
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 5147930357de..f816b3c0732b 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -23,6 +23,7 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt,
>  			       u32 size, u32 align, u32 mm_flags);
>  void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
>  			 bool invalidate);
> +bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
>  void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
>  int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
>  int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index dfa71bcd0f56..efaf188290ea 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -235,7 +235,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
>  {
>  	u32 n = 0;
>  
> -	if (drm_mm_node_allocated(&config->ggtt_region.base)) {
> +	if (xe_ggtt_node_allocated(&config->ggtt_region)) {
>  		cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
>  		cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
>  		cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
> @@ -376,7 +376,7 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
>  {
>  	struct xe_ggtt *ggtt = tile->mem.ggtt;
>  
> -	if (drm_mm_node_allocated(&node->base)) {
> +	if (xe_ggtt_node_allocated(node)) {
>  		/*
>  		 * explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
>  		 * is redundant, as PTE will be implicitly re-assigned to PF by
> @@ -406,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>  
>  	size = round_up(size, alignment);
>  
> -	if (drm_mm_node_allocated(&node->base)) {
> +	if (xe_ggtt_node_allocated(node)) {
>  		err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
>  		if (unlikely(err))
>  			return err;
>  
>  		pf_release_ggtt(tile, node);
>  	}
> -	xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
> +	xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
>  
>  	if (!size)
>  		return 0;
> @@ -439,7 +439,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
>  	struct xe_ggtt_node *node = &config->ggtt_region;
>  
>  	xe_gt_assert(gt, !xe_gt_is_media_type(gt));
> -	return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
> +	return xe_ggtt_node_allocated(node) ? node->base.size : 0;
>  }
>  
>  /**
> @@ -2021,7 +2021,7 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
>  
>  	for (n = 1; n <= total_vfs; n++) {
>  		config = &gt->sriov.pf.vfs[n].config;
> -		if (!drm_mm_node_allocated(&config->ggtt_region.base))
> +		if (!xe_ggtt_node_allocated(&config->ggtt_region))
>  			continue;
>  
>  		string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> -- 
> 2.45.2
> 


More information about the Intel-xe mailing list