1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

drm/i915/display: Handle GMD_ID identification in display code

For platforms with GMD_ID support (i.e., everything MTL and beyond),
identification of the display IP present should be based on the contents
of the GMD_ID register rather than a PCI devid match.

Note that since GMD_ID readout requires access to the PCI BAR, a slight
change to the driver init sequence is needed --- pci_enable_device() is
now called before i915_driver_create().

v2:
 - Fix use of uninitialized i915 pointer in error path if
   pci_enable_device() fails before the i915 device is created.  (lkp)
 - Use drm_device parameter to intel_display_device_probe.  This goes
   against i915 conventions, but since the primary goal here is to make
   it easy to call this function from other drivers (like Xe) and since
   we don't need anything from the i915 structure, this seems like an
   exception where drm_device is a more natural fit.
v3:
 - Go back do drm_i915_private for intel_display_device_probe.  (Jani)
 - Move forward decl to top of header.  (Jani)

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230523195609.73627-6-matthew.d.roper@intel.com
This commit is contained in:
Matt Roper 2023-05-23 12:56:08 -07:00
parent 69d439818f
commit 12e6f6dc78
4 changed files with 85 additions and 17 deletions

View file

@ -5,7 +5,10 @@
#include <drm/i915_pciids.h> #include <drm/i915_pciids.h>
#include <drm/drm_color_mgmt.h> #include <drm/drm_color_mgmt.h>
#include <linux/pci.h>
#include "i915_drv.h"
#include "i915_reg.h"
#include "intel_display_device.h" #include "intel_display_device.h"
#include "intel_display_power.h" #include "intel_display_power.h"
#include "intel_display_reg_defs.h" #include "intel_display_reg_defs.h"
@ -700,19 +703,73 @@ static const struct {
INTEL_RPLP_IDS(&xe_lpd_display), INTEL_RPLP_IDS(&xe_lpd_display),
INTEL_DG2_IDS(&xe_hpd_display), INTEL_DG2_IDS(&xe_hpd_display),
/* FIXME: Replace this with a GMD_ID lookup */ /*
INTEL_MTL_IDS(&xe_lpdp_display), * Do not add any GMD_ID-based platforms to this list. They will
* be probed automatically based on the IP version reported by
* the hardware.
*/
}; };
const struct intel_display_device_info * static const struct {
intel_display_device_probe(u16 pci_devid) u16 ver;
u16 rel;
const struct intel_display_device_info *display;
} gmdid_display_map[] = {
{ 14, 0, &xe_lpdp_display },
};
static const struct intel_display_device_info *
probe_gmdid_display(struct drm_i915_private *i915, u16 *ver, u16 *rel, u16 *step)
{ {
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
void __iomem *addr;
u32 val;
int i; int i;
addr = pci_iomap_range(pdev, 0, i915_mmio_reg_offset(GMD_ID_DISPLAY), sizeof(u32));
if (!addr) {
drm_err(&i915->drm, "Cannot map MMIO BAR to read display GMD_ID\n");
return &no_display;
}
val = ioread32(addr);
pci_iounmap(pdev, addr);
if (val == 0)
/* Platform doesn't have display */
return &no_display;
*ver = REG_FIELD_GET(GMD_ID_ARCH_MASK, val);
*rel = REG_FIELD_GET(GMD_ID_RELEASE_MASK, val);
*step = REG_FIELD_GET(GMD_ID_STEP, val);
for (i = 0; i < ARRAY_SIZE(gmdid_display_map); i++)
if (*ver == gmdid_display_map[i].ver &&
*rel == gmdid_display_map[i].rel)
return gmdid_display_map[i].display;
drm_err(&i915->drm, "Unrecognized display IP version %d.%02d; disabling display.\n",
*ver, *rel);
return &no_display;
}
const struct intel_display_device_info *
intel_display_device_probe(struct drm_i915_private *i915, bool has_gmdid,
u16 *gmdid_ver, u16 *gmdid_rel, u16 *gmdid_step)
{
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
int i;
if (has_gmdid)
return probe_gmdid_display(i915, gmdid_ver, gmdid_rel, gmdid_step);
for (i = 0; i < ARRAY_SIZE(intel_display_ids); i++) { for (i = 0; i < ARRAY_SIZE(intel_display_ids); i++) {
if (intel_display_ids[i].devid == pci_devid) if (intel_display_ids[i].devid == pdev->device)
return intel_display_ids[i].info; return intel_display_ids[i].info;
} }
drm_dbg(&i915->drm, "No display ID found for device ID %04x; disabling display.\n",
pdev->device);
return &no_display; return &no_display;
} }

View file

@ -10,6 +10,8 @@
#include "display/intel_display_limits.h" #include "display/intel_display_limits.h"
struct drm_i915_private;
#define DEV_INFO_DISPLAY_FOR_EACH_FLAG(func) \ #define DEV_INFO_DISPLAY_FOR_EACH_FLAG(func) \
/* Keep in alphabetical order */ \ /* Keep in alphabetical order */ \
func(cursor_needs_physical); \ func(cursor_needs_physical); \
@ -81,6 +83,7 @@ struct intel_display_device_info {
}; };
const struct intel_display_device_info * const struct intel_display_device_info *
intel_display_device_probe(u16 pci_devid); intel_display_device_probe(struct drm_i915_private *i915, bool has_gmdid,
u16 *ver, u16 *rel, u16 *step);
#endif #endif

View file

@ -754,13 +754,17 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct drm_i915_private *i915; struct drm_i915_private *i915;
int ret; int ret;
i915 = i915_driver_create(pdev, ent);
if (IS_ERR(i915))
return PTR_ERR(i915);
ret = pci_enable_device(pdev); ret = pci_enable_device(pdev);
if (ret) if (ret) {
goto out_fini; pr_err("Failed to enable graphics device: %pe\n", ERR_PTR(ret));
return ret;
}
i915 = i915_driver_create(pdev, ent);
if (IS_ERR(i915)) {
ret = PTR_ERR(i915);
goto out_pci_disable;
}
ret = i915_driver_early_probe(i915); ret = i915_driver_early_probe(i915);
if (ret < 0) if (ret < 0)
@ -843,7 +847,6 @@ out_runtime_pm_put:
i915_driver_late_release(i915); i915_driver_late_release(i915);
out_pci_disable: out_pci_disable:
pci_disable_device(pdev); pci_disable_device(pdev);
out_fini:
i915_probe_error(i915, "Device initialization failed (%d)\n", ret); i915_probe_error(i915, "Device initialization failed (%d)\n", ret);
return ret; return ret;
} }

View file

@ -345,7 +345,6 @@ static void ip_ver_read(struct drm_i915_private *i915, u32 offset, struct intel_
static void intel_ipver_early_init(struct drm_i915_private *i915) static void intel_ipver_early_init(struct drm_i915_private *i915)
{ {
struct intel_runtime_info *runtime = RUNTIME_INFO(i915); struct intel_runtime_info *runtime = RUNTIME_INFO(i915);
struct intel_display_runtime_info *display_runtime = DISPLAY_RUNTIME_INFO(i915);
if (!HAS_GMD_ID(i915)) { if (!HAS_GMD_ID(i915)) {
drm_WARN_ON(&i915->drm, RUNTIME_INFO(i915)->graphics.ip.ver > 12); drm_WARN_ON(&i915->drm, RUNTIME_INFO(i915)->graphics.ip.ver > 12);
@ -366,8 +365,6 @@ static void intel_ipver_early_init(struct drm_i915_private *i915)
RUNTIME_INFO(i915)->graphics.ip.ver = 12; RUNTIME_INFO(i915)->graphics.ip.ver = 12;
RUNTIME_INFO(i915)->graphics.ip.rel = 70; RUNTIME_INFO(i915)->graphics.ip.rel = 70;
} }
ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_DISPLAY),
(struct intel_ip_version *)&display_runtime->ip);
ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_MEDIA), ip_ver_read(i915, i915_mmio_reg_offset(GMD_ID_MEDIA),
&runtime->media.ip); &runtime->media.ip);
} }
@ -574,6 +571,7 @@ void intel_device_info_driver_create(struct drm_i915_private *i915,
{ {
struct intel_device_info *info; struct intel_device_info *info;
struct intel_runtime_info *runtime; struct intel_runtime_info *runtime;
u16 ver, rel, step;
/* Setup the write-once "constant" device info */ /* Setup the write-once "constant" device info */
info = mkwrite_device_info(i915); info = mkwrite_device_info(i915);
@ -584,11 +582,18 @@ void intel_device_info_driver_create(struct drm_i915_private *i915,
memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime)); memcpy(runtime, &INTEL_INFO(i915)->__runtime, sizeof(*runtime));
/* Probe display support */ /* Probe display support */
info->display = intel_display_device_probe(device_id); info->display = intel_display_device_probe(i915, info->has_gmd_id,
&ver, &rel, &step);
memcpy(DISPLAY_RUNTIME_INFO(i915), memcpy(DISPLAY_RUNTIME_INFO(i915),
&DISPLAY_INFO(i915)->__runtime_defaults, &DISPLAY_INFO(i915)->__runtime_defaults,
sizeof(*DISPLAY_RUNTIME_INFO(i915))); sizeof(*DISPLAY_RUNTIME_INFO(i915)));
if (info->has_gmd_id) {
DISPLAY_RUNTIME_INFO(i915)->ip.ver = ver;
DISPLAY_RUNTIME_INFO(i915)->ip.rel = rel;
DISPLAY_RUNTIME_INFO(i915)->ip.step = step;
}
runtime->device_id = device_id; runtime->device_id = device_id;
} }