All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: fix sysfs ip base addr for 64bit in standalone mode
@ 2026-08-13 15:10 Mukul Joshi
  2026-08-13 15:28 ` Alex Deucher
  0 siblings, 1 reply; 3+ messages in thread
From: Mukul Joshi @ 2026-08-13 15:10 UTC (permalink / raw)
  To: amd-gfx; +Cc: mario.limonciello, Mukul Joshi

In standalone mode the ip_discovery sysfs tree is built from a verbatim
copy of the discovery binary taken before reg_base_init() collapses the
64bit base addresses in place. Decoding as 32bit there yields interleaved
zeros. Decode base_address_64[] in that case; keep reading the already
collapsed adev->discovery.bin as-is otherwise.

Fixes: 3ee1065e9830 ("drm/amdgpu: Export ip_discovery sysfs on probe failure")
Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index b5bc0d71653d..8745b0a66f1d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -1308,8 +1308,19 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
 					ip_hw_instance->num_instance);
 			ip_hw_instance->num_base_addresses = ip->num_base_address;
 
-			for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++)
-				ip_hw_instance->base_addr[kk] = ip->base_address[kk];
+			for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++) {
+				/*
+				 * Standalone mode uses a raw copy of the discovery
+				 * binary; decode 64-bit addresses here. The shared
+				 * bin is already collapsed to 32-bit in place.
+				 */
+				if (reg_base_64 && ip_top->standalone_mode)
+					ip_hw_instance->base_addr[kk] =
+						lower_32_bits(le64_to_cpu(ip->base_address_64[kk])) & 0x3FFFFFFF;
+				else
+					ip_hw_instance->base_addr[kk] =
+						le32_to_cpu(ip->base_address[kk]);
+			}
 
 			kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
 			ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: fix sysfs ip base addr for 64bit in standalone mode
  2026-08-13 15:10 [PATCH] drm/amdgpu: fix sysfs ip base addr for 64bit in standalone mode Mukul Joshi
@ 2026-08-13 15:28 ` Alex Deucher
  2026-08-13 15:43   ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Deucher @ 2026-08-13 15:28 UTC (permalink / raw)
  To: Mukul Joshi; +Cc: amd-gfx, mario.limonciello

On Thu, Aug 13, 2026 at 11:20 AM Mukul Joshi <mukul.joshi@amd.com> wrote:
>
> In standalone mode the ip_discovery sysfs tree is built from a verbatim
> copy of the discovery binary taken before reg_base_init() collapses the
> 64bit base addresses in place. Decoding as 32bit there yields interleaved
> zeros. Decode base_address_64[] in that case; keep reading the already
> collapsed adev->discovery.bin as-is otherwise.
>
> Fixes: 3ee1065e9830 ("drm/amdgpu: Export ip_discovery sysfs on probe failure")
> Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> index b5bc0d71653d..8745b0a66f1d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> @@ -1308,8 +1308,19 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
>                                         ip_hw_instance->num_instance);
>                         ip_hw_instance->num_base_addresses = ip->num_base_address;
>
> -                       for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++)
> -                               ip_hw_instance->base_addr[kk] = ip->base_address[kk];
> +                       for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++) {
> +                               /*
> +                                * Standalone mode uses a raw copy of the discovery
> +                                * binary; decode 64-bit addresses here. The shared
> +                                * bin is already collapsed to 32-bit in place.
> +                                */
> +                               if (reg_base_64 && ip_top->standalone_mode)
> +                                       ip_hw_instance->base_addr[kk] =
> +                                               lower_32_bits(le64_to_cpu(ip->base_address_64[kk])) & 0x3FFFFFFF;
> +                               else
> +                                       ip_hw_instance->base_addr[kk] =
> +                                               le32_to_cpu(ip->base_address[kk]);
> +                       }
>
>                         kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
>                         ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
> --
> 2.54.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amdgpu: fix sysfs ip base addr for 64bit in standalone mode
  2026-08-13 15:28 ` Alex Deucher
@ 2026-08-13 15:43   ` Mario Limonciello
  0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-08-13 15:43 UTC (permalink / raw)
  To: Alex Deucher, Mukul Joshi; +Cc: amd-gfx



On 8/13/26 10:28, Alex Deucher wrote:
> On Thu, Aug 13, 2026 at 11:20 AM Mukul Joshi <mukul.joshi@amd.com> wrote:
>>
>> In standalone mode the ip_discovery sysfs tree is built from a verbatim
>> copy of the discovery binary taken before reg_base_init() collapses the
>> 64bit base addresses in place. Decoding as 32bit there yields interleaved
>> zeros. Decode base_address_64[] in that case; keep reading the already
>> collapsed adev->discovery.bin as-is otherwise.
>>
>> Fixes: 3ee1065e9830 ("drm/amdgpu: Export ip_discovery sysfs on probe failure")
>> Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Cc: stable@vger.kernel.org
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>

> 
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 15 +++++++++++++--
>>   1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
>> index b5bc0d71653d..8745b0a66f1d 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
>> @@ -1308,8 +1308,19 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev,
>>                                          ip_hw_instance->num_instance);
>>                          ip_hw_instance->num_base_addresses = ip->num_base_address;
>>
>> -                       for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++)
>> -                               ip_hw_instance->base_addr[kk] = ip->base_address[kk];
>> +                       for (kk = 0; kk < ip_hw_instance->num_base_addresses; kk++) {
>> +                               /*
>> +                                * Standalone mode uses a raw copy of the discovery
>> +                                * binary; decode 64-bit addresses here. The shared
>> +                                * bin is already collapsed to 32-bit in place.
>> +                                */
>> +                               if (reg_base_64 && ip_top->standalone_mode)
>> +                                       ip_hw_instance->base_addr[kk] =
>> +                                               lower_32_bits(le64_to_cpu(ip->base_address_64[kk])) & 0x3FFFFFFF;
>> +                               else
>> +                                       ip_hw_instance->base_addr[kk] =
>> +                                               le32_to_cpu(ip->base_address[kk]);
>> +                       }
>>
>>                          kobject_init(&ip_hw_instance->kobj, &ip_hw_instance_ktype);
>>                          ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset;
>> --
>> 2.54.0
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-13 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 15:10 [PATCH] drm/amdgpu: fix sysfs ip base addr for 64bit in standalone mode Mukul Joshi
2026-08-13 15:28 ` Alex Deucher
2026-08-13 15:43   ` Mario Limonciello

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.