Commit 51fb5ef2 authored by Michał Winiarski's avatar Michał Winiarski Committed by Rodrigo Vivi

drm/xe: Don't "peek" into GMD_ID

Now that MMIO init got moved to device early, we can use regular
xe_mmio_read helpers to get to GMD_ID register.
Signed-off-by: default avatarMichał Winiarski <michal.winiarski@intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 4f122766
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "xe_drv.h" #include "xe_drv.h"
#include "xe_gt.h" #include "xe_gt.h"
#include "xe_macros.h" #include "xe_macros.h"
#include "xe_mmio.h"
#include "xe_module.h" #include "xe_module.h"
#include "xe_pci_types.h" #include "xe_pci_types.h"
#include "xe_pm.h" #include "xe_pm.h"
...@@ -444,26 +445,22 @@ find_subplatform(const struct xe_device *xe, const struct xe_device_desc *desc) ...@@ -444,26 +445,22 @@ find_subplatform(const struct xe_device *xe, const struct xe_device_desc *desc)
return NULL; return NULL;
} }
static void peek_gmdid(struct xe_device *xe, u32 gmdid_offset, u32 *ver, u32 *revid) enum xe_gmdid_type {
GMDID_GRAPHICS,
GMDID_MEDIA
};
static void read_gmdid(struct xe_device *xe, enum xe_gmdid_type type, u32 *ver, u32 *revid)
{ {
struct pci_dev *pdev = to_pci_dev(xe->drm.dev); struct xe_gt *gt = xe_root_mmio_gt(xe);
void __iomem *map = pci_iomap_range(pdev, 0, gmdid_offset, sizeof(u32)); struct xe_reg gmdid_reg = GMD_ID;
u32 val; u32 val;
if (!map) { if (type == GMDID_MEDIA)
drm_err(&xe->drm, "Failed to read GMD_ID (%#x) from PCI BAR.\n", gmdid_reg.addr += MEDIA_GT_GSI_OFFSET;
gmdid_offset);
*ver = 0;
*revid = 0;
return; val = xe_mmio_read32(gt, gmdid_reg);
} *ver = REG_FIELD_GET(GMD_ID_ARCH_MASK, val) * 100 + REG_FIELD_GET(GMD_ID_RELEASE_MASK, val);
val = ioread32(map);
pci_iounmap(pdev, map);
*ver = REG_FIELD_GET(GMD_ID_ARCH_MASK, val) * 100 +
REG_FIELD_GET(GMD_ID_RELEASE_MASK, val);
*revid = REG_FIELD_GET(GMD_ID_REVID, val); *revid = REG_FIELD_GET(GMD_ID_REVID, val);
} }
...@@ -496,7 +493,8 @@ static void handle_gmdid(struct xe_device *xe, ...@@ -496,7 +493,8 @@ static void handle_gmdid(struct xe_device *xe,
{ {
u32 ver; u32 ver;
peek_gmdid(xe, GMD_ID.addr, &ver, graphics_revid); read_gmdid(xe, GMDID_GRAPHICS, &ver, graphics_revid);
for (int i = 0; i < ARRAY_SIZE(graphics_ip_map); i++) { for (int i = 0; i < ARRAY_SIZE(graphics_ip_map); i++) {
if (ver == graphics_ip_map[i].ver) { if (ver == graphics_ip_map[i].ver) {
xe->info.graphics_verx100 = ver; xe->info.graphics_verx100 = ver;
...@@ -511,7 +509,7 @@ static void handle_gmdid(struct xe_device *xe, ...@@ -511,7 +509,7 @@ static void handle_gmdid(struct xe_device *xe,
ver / 100, ver % 100); ver / 100, ver % 100);
} }
peek_gmdid(xe, GMD_ID.addr + 0x380000, &ver, media_revid); read_gmdid(xe, GMDID_MEDIA, &ver, media_revid);
/* Media may legitimately be fused off / not present */ /* Media may legitimately be fused off / not present */
if (ver == 0) if (ver == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment