Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>, <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v6 06/12] drm/xe: Improve xe_gt_sriov_pf_config GGTT handling
Date: Wed, 15 Oct 2025 20:53:24 +0200	[thread overview]
Message-ID: <aad00c02-ab6a-42f1-affa-0775a006858d@intel.com> (raw)
In-Reply-To: <20251014211956.1607561-20-dev@lankhorst.se>



On 10/14/2025 11:20 PM, Maarten Lankhorst wrote:
> Do not directly dereference xe_ggtt_node, and add
> a member to store the GGTT size.
> 
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
> ---
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c       | 15 ++++++++-------
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h |  8 ++++++--
>  2 files changed, 14 insertions(+), 9 deletions(-)
> 
> 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 2289756761636..c0dfffd5c553b 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -264,7 +264,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config,
>  	if (!xe_ggtt_node_allocated(node))
>  		return 0;
>  
> -	return encode_ggtt(cfg, node->base.start, node->base.size, details);
> +	return encode_ggtt(cfg, xe_ggtt_node_addr(node), config->ggtt_size, details);
>  }
>  
>  /* Return: number of configuration dwords written */
> @@ -495,13 +495,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>  
>  	xe_ggtt_assign(node, vfid);
>  	xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
> -				vfid, node->base.start, node->base.start + node->base.size - 1);
> +				vfid, xe_ggtt_node_addr(node), xe_ggtt_node_addr(node) + size - 1);
>  
> -	err = pf_distribute_config_ggtt(gt->tile, vfid, node->base.start, node->base.size);
> +	err = pf_distribute_config_ggtt(gt->tile, vfid, xe_ggtt_node_addr(node), size);
>  	if (unlikely(err))
>  		goto err;
>  
>  	config->ggtt_region = node;
> +	config->ggtt_size = size;
>  	return 0;
>  err:
>  	pf_release_ggtt(tile, node);
> @@ -514,7 +515,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_main_type(gt));
> -	return xe_ggtt_node_allocated(node) ? node->base.size : 0;
> +	return xe_ggtt_node_allocated(node) ? config->ggtt_size : 0;
>  }
>  
>  /**
> @@ -2516,11 +2517,11 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
>  		if (!xe_ggtt_node_allocated(config->ggtt_region))
>  			continue;
>  
> -		string_get_size(config->ggtt_region->base.size, 1, STRING_UNITS_2,
> +		string_get_size(config->ggtt_size, 1, STRING_UNITS_2,
>  				buf, sizeof(buf));
>  		drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
> -			   n, config->ggtt_region->base.start,
> -			   config->ggtt_region->base.start + config->ggtt_region->base.size - 1,
> +			   n, xe_ggtt_node_addr(config->ggtt_region),
> +			   xe_ggtt_node_addr(config->ggtt_region) + config->ggtt_size - 1,
>  			   buf);
>  	}
>  
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> index 686c7b3b6d7a5..9a8e66c8b539f 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> @@ -17,10 +17,14 @@ struct xe_bo;
>   * Used by the PF driver to maintain per-VF provisioning data.
>   */
>  struct xe_gt_sriov_config {
> -	/** @ggtt_region: GGTT region assigned to the VF. */
> -	struct xe_ggtt_node *ggtt_region;
>  	/** @lmem_obj: LMEM allocation for use by the VF. */
>  	struct xe_bo *lmem_obj;
> +
> +	/** @ggtt_region: GGTT region assigned to the VF. */
> +	struct xe_ggtt_node *ggtt_region;
> +	/** @ggtt_size: Size of GGTT region */
> +	u64 ggtt_size;

can't we just add another helper on GGTT side to get the size of the node?

	u64 xe_ggtt_node_size(node);

there is one for xe_bo, why can't we have another for xe_ggtt_node ?
> +
>  	/** @num_ctxs: number of GuC contexts IDs.  */
>  	u16 num_ctxs;
>  	/** @begin_ctx: start index of GuC context ID range. */


  reply	other threads:[~2025-10-15 18:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 21:19 [PATCH v6 00/12] drm/xe: Make all xe_ggtt structs private Maarten Lankhorst
2025-10-14 21:19 ` [PATCH v6 01/12] drm/xe: Start using ggtt->start in preparation of balloon removal Maarten Lankhorst
2025-10-14 21:19 ` [PATCH v6 02/12] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 03/12] drm/xe: Add xe_ggtt_node_addr() to avoid dereferencing xe_ggtt_node Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 04/12] drm/xe/display: Avoid " Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 05/12] drm/xe: Do not dereference ggtt_node in xe_bo.c Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 06/12] drm/xe: Improve xe_gt_sriov_pf_config GGTT handling Maarten Lankhorst
2025-10-15 18:53   ` Michal Wajdeczko [this message]
2025-10-14 21:20 ` [PATCH v6 07/12] drm/xe: Privatize xe_ggtt_node Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 08/12] drm/xe: Make xe_ggtt_node offset relative to starting offset Maarten Lankhorst
2025-10-15 19:37   ` Michal Wajdeczko
2025-10-14 21:20 ` [PATCH v6 09/12] drm/xe: Rewrite GGTT VF initialisation Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 10/12] drm/xe: Move struct xe_ggtt to xe_ggtt.c Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 11/12] drm/xe: Make xe_ggtt_node_insert return a node Maarten Lankhorst
2025-10-14 21:20 ` [PATCH v6 12/12] drm/xe: Remove xe_ggtt_node_allocated Maarten Lankhorst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aad00c02-ab6a-42f1-affa-0775a006858d@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=dev@lankhorst.se \
    --cc=intel-xe@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox