All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: Mukul Joshi <mukul.joshi@amd.com>, amd-gfx@lists.freedesktop.org
Cc: Felix.Kuehling@amd.com, Harish.Kasiviswanathan@amd.com,
	philip.yang@amd.com
Subject: Re: [PATCHv2 6/8] drm/amdgpu: Enable UALink loopback mode
Date: Wed, 28 Oct 2026 12:03:07 +0530	[thread overview]
Message-ID: <859ab8ce-6f32-4e10-9e40-1d007ca2a714@amd.com> (raw)
In-Reply-To: <20261027195913.1794477-7-mukul.joshi@amd.com>



On 28-Oct-26 1:24 AM, Mukul Joshi wrote:
> In UALink loopback mode a single GPU acts as both the exporter (accel
> ID 1) and the importer (accel ID 0). This lets the existing tests export
> a BO and import it on the same device, traversing the UALink HW
> pipeline.
> 
> Add amdgpu_ualink_loopback_detect(), the single place that decides
> whether loopback is enabled. It runs right after the UALink info is
> queried from PSP, before any per-peer setup. When loopback is enabled:
> 
> - There is no user-space agent to configure the pod, so synthesize the
>    pPod/vPod configuration with both accel IDs active.
> 
> - Activate the device directly instead of through the cross-GPU vpod
>    activation path, which needs peer GPUs and a user-space vpod commit.
> 
> The mechanism that requests loopback mode is added separately, so
> amdgpu_ualink_loopback_requested() returns false for now. The normal
> activation path is unchanged when loopback is not enabled.
> 
> Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 128 ++++++++++++++++++++-
>   1 file changed, 123 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> index e6272446ff4f..14b9c05a0f0f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
> @@ -63,6 +63,7 @@ static int amdgpu_ualink_ring_resync_ptrs(struct amdgpu_device *adev,
>   static int amdgpu_ualink_loopback_self_interrupt(struct amdgpu_device *adev,
>   						 u32 sender_accel_id, u32 dw0,
>   						 u32 dw1, u32 dw2, u32 dw3);
> +static void activate_accelerator(struct amdgpu_device *adev);
>   
>   #define STRIP_NPA(addr)						\
>   	(((u64)(addr) & ~AMDGPU_UALINK_NPA_ADDR_GPUID_MASK))
> @@ -93,19 +94,130 @@ static int amdgpu_ualink_drm_client_create(struct amdgpu_device *adev)
>   }
>   
>   /*
> - * amdgpu_ualink_loopback_init - set up UALink loopback mode
> + * amdgpu_ualink_loopback_requested - check whether UALink loopback is requested
>    *
> - * Called once loopback mode has been detected. Allocates the ordered
> - * workqueue used to emulate exporter->importer interrupts in SW.
> + * There is no mechanism to request loopback mode yet, so it stays disabled.
> + */
> +static bool amdgpu_ualink_loopback_requested(struct amdgpu_device *adev)
> +{
> +	return false;
> +}
> +
> +/*
> + * amdgpu_ualink_loopback_detect - detect UALink loopback mode
> + *
> + * This is the only place that decides whether loopback mode is enabled. It
> + * must run before any per-peer setup, since enabling loopback changes the
> + * accelerator IDs returned by ualink_exp_accel_id() and ualink_imp_accel_id().
> + */
> +static void amdgpu_ualink_loopback_detect(struct amdgpu_device *adev)
> +{
> +	if (!amdgpu_ualink_loopback_requested(adev))
> +		return;
> +
> +	adev->ualink.loopback.enabled = true;
> +	adev->ualink.loopback.exporter_accel_id =
> +		AMDGPU_UALINK_LOOPBACK_EXPORTER_ACCID;
> +	adev->ualink.loopback.importer_accel_id =
> +		AMDGPU_UALINK_LOOPBACK_IMPORTER_ACCID;

A better place for this is amdgpu_ualink_loopback_populate_info which 
fills all the static info for loopback mode.

Then you may deprecate requested() also as detect() is good enough to 
find whether loopback mode is requested and sets loopback enabled.

Thanks,
Lijo
> +}
> +
> +/*
> + * amdgpu_ualink_loopback_populate_info - synthesize pPod/vPod config for loopback
> + *
> + * In loopback there is no user-space agent (AIFM / xncmdclient) writing the
> + * UALink sysfs nodes to configure the pod, so populate adev->ualink.info
> + * directly. The layout is fixed and known: a single GPU alone in its own
> + * physical pod, presented as accelerator ID 1 (the exporter) and also owning
> + * accelerator ID 0 (the importer). The values are made self-consistent so
> + * check_vpod_info() would pass and amdgpu_ualink_metadata_init() programs the
> + * importer's ring buffers / GART NPA mappings / MP nHT receive metadata.
> + */
> +static void amdgpu_ualink_loopback_populate_info(struct amdgpu_device *adev)
> +{
> +	struct amdgpu_ualink_info *info = adev->ualink.info;
> +	u32 exporter = adev->ualink.loopback.exporter_accel_id; /* 1 */
> +	u32 importer = adev->ualink.loopback.importer_accel_id; /* 0 */
> +
> +	/* Physical pod: this GPU is presented as the exporter accel ID in its
> +	 * own pod. ppod.size must be large enough to contain both the exporter
> +	 * and importer accel IDs. ppod.id must be unique within the system
> +	 * (matters for 1P4G, where every loopback GPU is its own physical pod).
> +	 */
> +	info->ppod.accel_id = exporter;
> +	info->ppod.size = max(exporter, importer) + 1;	/* == 2 */
> +	uuid_gen(&info->ppod.id);
> +
> +	/* Virtual pod: mark BOTH the exporter and the importer active so the
> +	 * per-peer setup (amdgpu_ualink_metadata_init()) programs the importer's
> +	 * resources for the importer accel ID. Preserve the address mode queried
> +	 * from firmware if it is valid (keeps source-identification HW working),
> +	 * otherwise default to source-aliasing (MI450).
> +	 */
> +	info->vpod.id = 0;
> +	info->vpod.size = 2;
> +	if (info->vpod.addr_mode >= AMDGPU_UALINK_ADDR_MODE_MAX)
> +		info->vpod.addr_mode = AMDGPU_UALINK_ADDR_MODE_SOURCE_ALIAS;
> +	bitmap_zero(info->vpod.active_accel_bits, AMDGPU_UALINK_ACCEL_MAX);
> +	set_bit(exporter, info->vpod.active_accel_bits);
> +	set_bit(importer, info->vpod.active_accel_bits);
> +
> +	/* Only the exporter (this GPU's own accel ID) is a local accelerator;
> +	 * the importer is reached through the (loopback) remote/NPA path.
> +	 */
> +	info->n_local_accels = 1;
> +	info->local_accels[0] = exporter;
> +
> +	/* Mark the pod vpod-configured so the activation path proceeds. */
> +	info->accel_state = AMDGPU_UALINK_ACCEL_STATE_VPOD_CONFIGURED;
> +}
> +
> +/*
> + * amdgpu_ualink_loopback_activate - bring up the UALink manager for loopback
> + *
> + * The normal activation is driven by the sysfs vpod_config/commit path via
> + * activate_local_vpod(), which derives the local accelerators from peer GPUs
> + * and runs a cross-GPU integrity check. Neither applies in loopback (the
> + * importer is not a separate GPU), so activate this device directly.
> + */
> +static int amdgpu_ualink_loopback_activate(struct amdgpu_device *adev)
> +{
> +	mutex_lock(&mgpu_info.mutex);
> +	activate_accelerator(adev);
> +	mutex_unlock(&mgpu_info.mutex);
> +
> +	if (adev->ualink.info->accel_state < AMDGPU_UALINK_ACCEL_STATE_ACTIVE) {
> +		dev_err(adev->dev, "UALink loopback activation did not reach ACTIVE\n");
> +		return -EIO;
> +	}
> +
> +	return 0;
> +}
> +
> +/*
> + * amdgpu_ualink_loopback_init - set up and activate UALink loopback mode
> + *
> + * Called once loopback mode has been detected, after the initial pod/vpod
> + * configuration has been queried into adev->ualink.info. Synthesizes the pod
> + * configuration (there is no user-space agent to write the UALink sysfs nodes
> + * in loopback), allocates the ordered workqueue used to emulate
> + * exporter->importer interrupts in SW and activates the device.
>    */
>   static int amdgpu_ualink_loopback_init(struct amdgpu_device *adev)
>   {
> +	amdgpu_ualink_loopback_populate_info(adev);
> +
>   	adev->ualink.loopback.wq =
>   		alloc_ordered_workqueue("amdgpu_ualink_loopback", 0);
>   	if (!adev->ualink.loopback.wq)
>   		return -ENOMEM;
>   
> -	return 0;
> +	dev_info(adev->dev,
> +		 "UALink loopback enabled (exporter accel %u, importer accel %u)\n",
> +		 adev->ualink.loopback.exporter_accel_id,
> +		 adev->ualink.loopback.importer_accel_id);
> +
> +	return amdgpu_ualink_loopback_activate(adev);
>   }
>   
>   static void amdgpu_ualink_object_fini(struct amdgpu_device *adev)
> @@ -495,10 +607,16 @@ int ualink_ip_late_init(struct amdgpu_ip_block *ip_block)
>   	if (r)
>   		return r;
>   
> +	amdgpu_ualink_loopback_detect(adev);
> +
>   	scoped_guard(mutex, &mgpu_info.mutex) {
>   		amdgpu_ualink_info_set_accel_state(adev, adev->ualink.info,
>   						   cfg_state);
> -		__amdgpu_ualink_activate_vpod_locked(adev);
> +		/* Loopback has no peer GPUs and no user-space vpod commit, so it
> +		 * cannot use the normal cross-GPU activation path.
> +		 */
> +		if (!adev->ualink.loopback.enabled)
> +			__amdgpu_ualink_activate_vpod_locked(adev);
>   	}
>   
>   	if (adev->ualink.loopback.enabled) {


  parent reply	other threads:[~2026-10-28  6:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 19:54 [PATCHv2 0/8] Add UALink Loopback support Mukul Joshi
2026-10-27 19:54 ` [PATCHv2 1/8] drm/amdgpu: Add UALink loopback infrastructure Mukul Joshi
2026-10-27 20:22   ` Felix Kuehling
2026-10-27 20:45     ` Mukul Joshi
2026-10-27 20:56       ` Felix Kuehling
2026-10-28  6:06         ` Lazar, Lijo
2026-10-27 19:54 ` [PATCHv2 2/8] drm/amdgpu: Support VMID 0 GPUVA completion WB address for UALink Mukul Joshi
2026-10-27 21:23   ` Felix Kuehling
2026-10-27 19:54 ` [PATCHv2 3/8] drm/amdgpu: Emulate exporter->importer UALink messages in loopback Mukul Joshi
2026-10-27 21:34   ` Felix Kuehling
2026-10-27 19:54 ` [PATCHv2 4/8] drm/amdgpu: Attribute UALink loopback messages to the correct sender Mukul Joshi
2026-10-27 21:38   ` Felix Kuehling
2026-10-28  6:23   ` Lazar, Lijo
2026-10-28 13:53     ` Mukul Joshi
2026-10-28 14:00       ` Lazar, Lijo
2026-10-28 14:43         ` Mukul Joshi
2026-10-27 19:54 ` [PATCHv2 5/8] drm/amdgpu: Set up UALink rings and metadata for loopback Mukul Joshi
2026-10-27 20:20   ` Felix Kuehling
2026-10-27 19:54 ` [PATCHv2 6/8] drm/amdgpu: Enable UALink loopback mode Mukul Joshi
2026-10-27 21:45   ` Felix Kuehling
2026-10-28  6:33   ` Lazar, Lijo [this message]
2026-10-27 19:54 ` [PATCHv2 7/8] drm/amdgpu: Reject config updates in " Mukul Joshi
2026-10-27 21:06   ` Felix Kuehling
2026-10-27 19:54 ` [PATCHv2 8/8] drm/amdgpu: Temporarily enable UALink loopback via module parameter Mukul Joshi
2026-10-27 21:47   ` Felix Kuehling

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=859ab8ce-6f32-4e10-9e40-1d007ca2a714@amd.com \
    --to=lijo.lazar@amd.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Harish.Kasiviswanathan@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=mukul.joshi@amd.com \
    --cc=philip.yang@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.