From: Frank Min <Frank.Min@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Frank Min <Frank.Min@amd.com>, Hawking Zhang <Hawking.Zhang@amd.com>
Subject: [PATCH 3/9] drm/amdgpu: update table info retrieval from discovery binary
Date: Fri, 4 Dec 2026 22:24:02 +0800 [thread overview]
Message-ID: <20261204142408.988734-3-Frank.Min@amd.com> (raw)
In-Reply-To: <20261204142408.988734-1-Frank.Min@amd.com>
Update table info retrieval from discovery binary to align with
discovery table update.
Signed-off-by: Frank Min <Frank.Min@amd.com>
Reviewed-By: Hawking Zhang <Hawking.Zhang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 47 +++++++++++++------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 6fba2560a2abe..50b0112825c42 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -609,18 +609,36 @@ amdgpu_discovery_get_table_info_from_bin(uint8_t *discovery_bin,
uint16_t table_id)
{
struct binary_header *bhdr = (struct binary_header *)discovery_bin;
- struct binary_header_v2 *bhdrv2;
-
- switch (bhdr->version_major) {
- case 2:
- bhdrv2 = (struct binary_header_v2 *)discovery_bin;
- return &bhdrv2->table_list[table_id];
- case 1:
+ struct binary_header_v2 *bhdrv2 = (struct binary_header_v2 *)discovery_bin;
+ uint16_t version = le16_to_cpu(bhdr->version_major);
+ uint16_t binary_size = le16_to_cpu(bhdr->binary_size);
+ struct table_info *table_list;
+ uint16_t num_tables, i;
+ size_t table_offset;
+
+ switch (version) {
case 0:
- return &bhdr->table_list[table_id];
+ case 1:
+ table_list = bhdr->table_list;
+ num_tables = ARRAY_SIZE(bhdr->table_list);
+ break;
+ case 2:
+ table_list = bhdrv2->table_list;
+ num_tables = le16_to_cpu(bhdrv2->num_tables);
+ break;
default:
return NULL;
}
+
+ table_offset = (uint8_t *)table_list - discovery_bin;
+ if (table_offset + num_tables * sizeof(*table_list) > binary_size)
+ return NULL;
+
+ for (i = 0; i < num_tables; i++)
+ if (le16_to_cpu(table_list[i].table_id) == table_id)
+ return &table_list[i];
+
+ return NULL;
}
static int amdgpu_discovery_get_table_info(struct amdgpu_device *adev,
@@ -633,8 +651,8 @@ static int amdgpu_discovery_get_table_info(struct amdgpu_device *adev,
*info = amdgpu_discovery_get_table_info_from_bin(adev->discovery.bin,
table_id);
if (!*info) {
- dev_err(adev->dev, "Invalid ip discovery table version %d\n",
- bhdr->version_major);
+ dev_err(adev->dev, "Not found table for header version %d table id %d\n",
+ bhdr->version_major, table_id);
return -EINVAL;
}
@@ -645,15 +663,16 @@ static int amdgpu_discovery_table_check(struct amdgpu_device *adev,
uint8_t *discovery_bin,
uint16_t table_id)
{
- int r, act_val, exp_val, table_size;
+ int act_val, exp_val, table_size;
uint16_t offset, checksum;
struct table_info *info;
bool check_table = true;
char *table_name;
- r = amdgpu_discovery_get_table_info(adev, &info, table_id);
- if (r)
- return r;
+ info = amdgpu_discovery_get_table_info_from_bin(discovery_bin, table_id);
+ if (!info)
+ return 0;
+
offset = le16_to_cpu(info->offset);
checksum = le16_to_cpu(info->checksum);
--
2.43.0
next prev parent reply other threads:[~2026-12-04 14:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:24 [PATCH 1/9] drm/amdgpu: skip vm inv for kiq ring Frank Min
2026-12-04 14:24 ` [PATCH 2/9] drm/amdgpu: disable gfx 13 pipe 1 ring Frank Min
2026-12-04 14:55 ` sashiko-bot
2026-12-04 16:05 ` Alex Deucher
2026-12-04 14:24 ` Frank Min [this message]
2026-12-04 15:14 ` [PATCH 3/9] drm/amdgpu: update table info retrieval from discovery binary sashiko-bot
2026-12-04 16:19 ` Alex Deucher
2026-12-04 14:24 ` [PATCH 4/9] drm/amdgpu: add lsdma v8 fw query interface Frank Min
2026-12-04 15:25 ` sashiko-bot
2026-12-04 16:21 ` Alex Deucher
2026-12-04 14:24 ` [PATCH 5/9] drm/amdgpu: add lsdma v8 fw loading support Frank Min
2026-12-04 15:47 ` sashiko-bot
2026-12-04 14:24 ` [PATCH 6/9] drm/amdgpu: Fix system aperture size for gfx13 Frank Min
2026-12-04 16:01 ` sashiko-bot
2026-12-04 14:24 ` [PATCH 7/9] drm/amdgpu: remove the unused ring parameter in update_spm_vmid() " Frank Min
2026-12-04 16:03 ` Alex Deucher
2026-12-04 16:11 ` sashiko-bot
2026-12-04 14:24 ` [PATCH 8/9] drm/amdgpu: enable uni-mes " Frank Min
2026-12-04 16:41 ` sashiko-bot
2026-12-04 17:24 ` Alex Deucher
2026-12-04 14:24 ` [PATCH 9/9] drm/amdgpu: fix mutex unlock position for ucode loading Frank Min
2026-12-04 16:12 ` Alex Deucher
2026-12-04 16:52 ` sashiko-bot
2026-12-04 14:41 ` [PATCH 1/9] drm/amdgpu: skip vm inv for kiq ring sashiko-bot
2026-12-04 16:16 ` Alex Deucher
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=20261204142408.988734-3-Frank.Min@amd.com \
--to=frank.min@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=amd-gfx@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 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.