Commit 40ace64b authored by Jani Nikula's avatar Jani Nikula

drm/i915: have virtual PCH detection return a PCH id

Simplify intel_virt_detect_pch() by making it return a PCH id rather
than returning the PCH type and setting PCH id for some PCHs. Map the
PCH id to PCH type using the shared routine. This gives us sanity check
on the supported combinations also in the virtualized setting.
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/197cf635261a1c628371ffaaee90e8647493af4d.1517851783.git.jani.nikula@intel.com
parent 435ad2c0
...@@ -202,9 +202,10 @@ static bool intel_is_virt_pch(unsigned short id, ...@@ -202,9 +202,10 @@ static bool intel_is_virt_pch(unsigned short id,
sdevice == PCI_SUBDEVICE_ID_QEMU)); sdevice == PCI_SUBDEVICE_ID_QEMU));
} }
static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv) static unsigned short
intel_virt_detect_pch(const struct drm_i915_private *dev_priv)
{ {
enum intel_pch ret = PCH_NOP; unsigned short id = 0;
/* /*
* In a virtualized passthrough environment we can be in a * In a virtualized passthrough environment we can be in a
...@@ -213,28 +214,25 @@ static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv) ...@@ -213,28 +214,25 @@ static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
* make an educated guess as to which PCH is really there. * make an educated guess as to which PCH is really there.
*/ */
if (IS_GEN5(dev_priv)) { if (IS_GEN5(dev_priv))
ret = PCH_IBX; id = INTEL_PCH_IBX_DEVICE_ID_TYPE;
DRM_DEBUG_KMS("Assuming Ibex Peak PCH\n"); else if (IS_GEN6(dev_priv) || IS_IVYBRIDGE(dev_priv))
} else if (IS_GEN6(dev_priv) || IS_IVYBRIDGE(dev_priv)) { id = INTEL_PCH_CPT_DEVICE_ID_TYPE;
ret = PCH_CPT; else if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv))
DRM_DEBUG_KMS("Assuming CougarPoint PCH\n"); id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE;
} else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
ret = PCH_LPT; id = INTEL_PCH_LPT_DEVICE_ID_TYPE;
if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv)) else if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
dev_priv->pch_id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE; id = INTEL_PCH_SPT_DEVICE_ID_TYPE;
else else if (IS_COFFEELAKE(dev_priv) || IS_CANNONLAKE(dev_priv))
dev_priv->pch_id = INTEL_PCH_LPT_DEVICE_ID_TYPE; id = INTEL_PCH_CNP_DEVICE_ID_TYPE;
DRM_DEBUG_KMS("Assuming LynxPoint PCH\n");
} else if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { if (id)
ret = PCH_SPT; DRM_DEBUG_KMS("Assuming PCH ID %04x\n", id);
DRM_DEBUG_KMS("Assuming SunrisePoint PCH\n"); else
} else if (IS_COFFEELAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) { DRM_DEBUG_KMS("Assuming no PCH\n");
ret = PCH_CNP;
DRM_DEBUG_KMS("Assuming CannonPoint PCH\n");
}
return ret; return id;
} }
static void intel_detect_pch(struct drm_i915_private *dev_priv) static void intel_detect_pch(struct drm_i915_private *dev_priv)
...@@ -269,19 +267,25 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv) ...@@ -269,19 +267,25 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
id = pch->device & INTEL_PCH_DEVICE_ID_MASK; id = pch->device & INTEL_PCH_DEVICE_ID_MASK;
dev_priv->pch_id = id;
pch_type = intel_pch_type(dev_priv, id); pch_type = intel_pch_type(dev_priv, id);
if (pch_type != PCH_NONE) { if (pch_type != PCH_NONE) {
dev_priv->pch_type = pch_type; dev_priv->pch_type = pch_type;
dev_priv->pch_id = id;
break;
} else if (intel_is_virt_pch(id, pch->subsystem_vendor, } else if (intel_is_virt_pch(id, pch->subsystem_vendor,
pch->subsystem_device)) { pch->subsystem_device)) {
dev_priv->pch_type = intel_virt_detect_pch(dev_priv); id = intel_virt_detect_pch(dev_priv);
} else { if (id) {
continue; pch_type = intel_pch_type(dev_priv, id);
if (WARN_ON(pch_type == PCH_NONE))
pch_type = PCH_NOP;
} else {
pch_type = PCH_NOP;
}
dev_priv->pch_type = pch_type;
dev_priv->pch_id = id;
break;
} }
break;
} }
if (!pch) if (!pch)
DRM_DEBUG_KMS("No PCH found.\n"); DRM_DEBUG_KMS("No PCH found.\n");
......
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