[Intel-xe] [PATCH 5/5] drm/xe: Fix GMD_ID to revid

Gustavo Sousa gustavo.sousa at intel.com
Tue Jun 13 14:17:15 UTC 2023


Quoting Lucas De Marchi (2023-06-11 19:24:47-03:00)
>In order to calculate revid, let peek_gmdid() return the raw value of
>the register, then calculate arch, release and rev. Also rename the
>variables to make clear what are the assigned values.
>
>Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>

Since we are touching this, we could as well rename GMD_ID_REVID to
GMD_ID_REVID_MASK just for consistency.

Reviewed-by: Gustavo Sousa <gustavo.sousa at intel.com>

>---
> drivers/gpu/drm/xe/xe_pci.c       | 29 ++++++++++++++++-------------
> drivers/gpu/drm/xe/xe_pci_types.h |  2 +-
> 2 files changed, 17 insertions(+), 14 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
>index bd1f59b49928..06d9d21c7cd3 100644
>--- a/drivers/gpu/drm/xe/xe_pci.c
>+++ b/drivers/gpu/drm/xe/xe_pci.c
>@@ -407,8 +407,7 @@ static u32 peek_gmdid(struct xe_device *xe, u32 gmdid_offset)
>         ver = ioread32(map);
>         pci_iounmap(pdev, map);
> 
>-        return REG_FIELD_GET(GMD_ID_ARCH_MASK, ver) * 100 +
>-                REG_FIELD_GET(GMD_ID_RELEASE_MASK, ver);
>+        return ver;
> }
> 
> /*
>@@ -442,13 +441,15 @@ static void handle_gmdid(struct xe_device *xe,
>                          u32 *graphics_revid,
>                          u32 *media_revid)
> {
>-        u32 ver;
>+        u32 verx100, gmdid;
> 
>-        ver = peek_gmdid(xe, GMD_ID.addr);
>-        *graphics_revid = REG_FIELD_GET(GMD_ID_REVID, ver);
>+        gmdid = peek_gmdid(xe, GMD_ID.addr);
>+        verx100 = REG_FIELD_GET(GMD_ID_ARCH_MASK, gmdid) * 100 +
>+                  REG_FIELD_GET(GMD_ID_RELEASE_MASK, gmdid);
>+        *graphics_revid = REG_FIELD_GET(GMD_ID_REVID, gmdid);
>         for (int i = 0; i < ARRAY_SIZE(graphics_ip_map); i++) {
>-                if (ver == graphics_ip_map[i].ver) {
>-                        xe->info.graphics_verx100 = ver;
>+                if (verx100 == graphics_ip_map[i].verx100) {
>+                        xe->info.graphics_verx100 = verx100;
>                         *graphics = graphics_ip_map[i].ip;
> 
>                         break;
>@@ -457,14 +458,16 @@ static void handle_gmdid(struct xe_device *xe,
> 
>         if (!xe->info.graphics_verx100) {
>                 drm_err(&xe->drm, "Hardware reports unknown graphics version %u.%02u\n",
>-                        ver / 100, ver % 100);
>+                        verx100 / 100, verx100 % 100);
>         }
> 
>-        ver = peek_gmdid(xe, GMD_ID.addr + 0x380000);
>-        *media_revid = REG_FIELD_GET(GMD_ID_REVID, ver);
>+        gmdid = peek_gmdid(xe, GMD_ID.addr + 0x380000);
>+        verx100 = REG_FIELD_GET(GMD_ID_ARCH_MASK, gmdid) * 100 +
>+                  REG_FIELD_GET(GMD_ID_RELEASE_MASK, gmdid);
>+        *media_revid = REG_FIELD_GET(GMD_ID_REVID, gmdid);
>         for (int i = 0; i < ARRAY_SIZE(media_ip_map); i++) {
>-                if (ver == media_ip_map[i].ver) {
>-                        xe->info.media_verx100 = ver;
>+                if (verx100 == media_ip_map[i].verx100) {
>+                        xe->info.media_verx100 = verx100;
>                         *media = media_ip_map[i].ip;
> 
>                         break;
>@@ -473,7 +476,7 @@ static void handle_gmdid(struct xe_device *xe,
> 
>         if (!xe->info.media_verx100) {
>                 drm_err(&xe->drm, "Hardware reports unknown media version %u.%02u\n",
>-                        ver / 100, ver % 100);
>+                        verx100 / 100, verx100 % 100);
>         }
> }
> 
>diff --git a/drivers/gpu/drm/xe/xe_pci_types.h b/drivers/gpu/drm/xe/xe_pci_types.h
>index ba31b933eb8e..70858836cc5b 100644
>--- a/drivers/gpu/drm/xe/xe_pci_types.h
>+++ b/drivers/gpu/drm/xe/xe_pci_types.h
>@@ -37,7 +37,7 @@ struct xe_media_desc {
> };
> 
> struct gmdid_map {
>-        unsigned int ver;
>+        unsigned int verx100;
>         const void *ip;
> };
> 
>-- 
>2.40.1
>


More information about the Intel-xe mailing list