The PCH type is an unnecessary level of abstraction that's an extra maintenance burden. Switch to using PCH ids directly. This also simplifies the virtual PCH detection. The downside is code size increase for conditions that match several PCH ids: text data bss dec hex filename -1709581 68900 4612 1783093 1b3535 drivers/gpu/drm/i915/i915.ko +1710634 68900 4612 1784146 1b3952 drivers/gpu/drm/i915/i915.ko Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_drv.c | 46 +++++++++------------------- drivers/gpu/drm/i915/i915_drv.h | 68 +++++++++++++++++++++++------------------ 2 files changed, 53 insertions(+), 61 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index e9f1daf258fe..a027d753fb6a 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c @@ -123,9 +123,9 @@ static bool i915_error_injected(struct drm_i915_private *dev_priv) fmt, ##__VA_ARGS__) -static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv) +static unsigned int intel_virt_detect_pch(struct drm_i915_private *dev_priv) { - enum intel_pch ret = PCH_NOP; + unsigned int id = INTEL_PCH_NOP; /* * In a virtualized passthrough environment we can be in a @@ -135,27 +135,26 @@ static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *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)) { - ret = PCH_CPT; + id = INTEL_PCH_CPT_DEVICE_ID_TYPE; DRM_DEBUG_KMS("Assuming CougarPoint PCH\n"); + } else if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv)) { + id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE; + DRM_DEBUG_KMS("Assuming LynxPoint LP PCH\n"); } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) { - ret = PCH_LPT; - if (IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv)) - dev_priv->pch_id = INTEL_PCH_LPT_LP_DEVICE_ID_TYPE; - else - dev_priv->pch_id = INTEL_PCH_LPT_DEVICE_ID_TYPE; + id = INTEL_PCH_LPT_DEVICE_ID_TYPE; DRM_DEBUG_KMS("Assuming LynxPoint PCH\n"); } else if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) { - ret = PCH_SPT; + id = INTEL_PCH_SPT_DEVICE_ID_TYPE; DRM_DEBUG_KMS("Assuming SunrisePoint PCH\n"); } else if (IS_COFFEELAKE(dev_priv) || IS_CANNONLAKE(dev_priv)) { - ret = PCH_CNP; + id = INTEL_PCH_CNP_DEVICE_ID_TYPE; DRM_DEBUG_KMS("Assuming CannonPoint PCH\n"); } - return ret; + return id; } static void intel_detect_pch(struct drm_i915_private *dev_priv) @@ -166,7 +165,7 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv) * (which really amounts to a PCH but no South Display). */ if (INTEL_INFO(dev_priv)->num_pipes == 0) { - dev_priv->pch_type = PCH_NOP; + dev_priv->pch_id = INTEL_PCH_NOP; return; } @@ -189,81 +188,63 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv) id = pch->device & INTEL_PCH_DEVICE_ID_MASK; - dev_priv->pch_id = id; - if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_IBX; DRM_DEBUG_KMS("Found Ibex Peak PCH\n"); WARN_ON(!IS_GEN5(dev_priv)); } else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_CPT; DRM_DEBUG_KMS("Found CougarPoint PCH\n"); WARN_ON(!IS_GEN6(dev_priv) && !IS_IVYBRIDGE(dev_priv)); } else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) { - /* PantherPoint is CPT compatible */ - dev_priv->pch_type = PCH_CPT; DRM_DEBUG_KMS("Found PantherPoint PCH\n"); WARN_ON(!IS_GEN6(dev_priv) && !IS_IVYBRIDGE(dev_priv)); } else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_LPT; DRM_DEBUG_KMS("Found LynxPoint PCH\n"); WARN_ON(!IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv)); WARN_ON(IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv)); } else if (id == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_LPT; DRM_DEBUG_KMS("Found LynxPoint LP PCH\n"); WARN_ON(!IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv)); WARN_ON(!IS_HSW_ULT(dev_priv) && !IS_BDW_ULT(dev_priv)); } else if (id == INTEL_PCH_WPT_DEVICE_ID_TYPE) { - /* WildcatPoint is LPT compatible */ - dev_priv->pch_type = PCH_LPT; DRM_DEBUG_KMS("Found WildcatPoint PCH\n"); WARN_ON(!IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv)); WARN_ON(IS_HSW_ULT(dev_priv) || IS_BDW_ULT(dev_priv)); } else if (id == INTEL_PCH_WPT_LP_DEVICE_ID_TYPE) { - /* WildcatPoint is LPT compatible */ - dev_priv->pch_type = PCH_LPT; DRM_DEBUG_KMS("Found WildcatPoint LP PCH\n"); WARN_ON(!IS_HASWELL(dev_priv) && !IS_BROADWELL(dev_priv)); WARN_ON(!IS_HSW_ULT(dev_priv) && !IS_BDW_ULT(dev_priv)); } else if (id == INTEL_PCH_SPT_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_SPT; DRM_DEBUG_KMS("Found SunrisePoint PCH\n"); WARN_ON(!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv)); } else if (id == INTEL_PCH_SPT_LP_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_SPT; DRM_DEBUG_KMS("Found SunrisePoint LP PCH\n"); WARN_ON(!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv)); } else if (id == INTEL_PCH_KBP_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_KBP; DRM_DEBUG_KMS("Found Kaby Lake PCH (KBP)\n"); WARN_ON(!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv) && !IS_COFFEELAKE(dev_priv)); } else if (id == INTEL_PCH_CNP_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_CNP; DRM_DEBUG_KMS("Found Cannon Lake PCH (CNP)\n"); WARN_ON(!IS_CANNONLAKE(dev_priv) && !IS_COFFEELAKE(dev_priv)); } else if (id == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_CNP; DRM_DEBUG_KMS("Found Cannon Lake LP PCH (CNP-LP)\n"); WARN_ON(!IS_CANNONLAKE(dev_priv) && !IS_COFFEELAKE(dev_priv)); } else if (id == INTEL_PCH_ICP_DEVICE_ID_TYPE) { - dev_priv->pch_type = PCH_ICP; DRM_DEBUG_KMS("Found Ice Lake PCH\n"); WARN_ON(!IS_ICELAKE(dev_priv)); } else if (id == INTEL_PCH_P2X_DEVICE_ID_TYPE || @@ -273,11 +254,12 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv) PCI_SUBVENDOR_ID_REDHAT_QUMRANET && pch->subsystem_device == PCI_SUBDEVICE_ID_QEMU)) { - dev_priv->pch_type = intel_virt_detect_pch(dev_priv); + id = intel_virt_detect_pch(dev_priv); } else { continue; } + dev_priv->pch_id = id; break; } if (!pch) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a1454045629a..0e178735be47 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -778,18 +778,6 @@ struct i915_psr { void (*setup_vsc)(struct intel_dp *, const struct intel_crtc_state *); }; -enum intel_pch { - PCH_NONE = 0, /* No PCH present */ - PCH_IBX, /* Ibexpeak PCH */ - PCH_CPT, /* Cougarpoint/Pantherpoint PCH */ - PCH_LPT, /* Lynxpoint/Wildcatpoint PCH */ - PCH_SPT, /* Sunrisepoint PCH */ - PCH_KBP, /* Kaby Lake PCH */ - PCH_CNP, /* Cannon Lake PCH */ - PCH_ICP, /* Ice Lake PCH */ - PCH_NOP, -}; - enum intel_sbi_destination { SBI_ICLK, SBI_MPHY, @@ -1973,8 +1961,7 @@ struct drm_i915_private { /* Display functions */ struct drm_i915_display_funcs display; - /* PCH chipset type */ - enum intel_pch pch_type; + /* PCH chipset id */ unsigned short pch_id; unsigned long quirks; @@ -2842,6 +2829,9 @@ intel_info(const struct drm_i915_private *dev_priv) #define HAS_POOLED_EU(dev_priv) ((dev_priv)->info.has_pooled_eu) +#define INTEL_PCH_NONE 0x0000 +#define INTEL_PCH_NOP 0xffff + #define INTEL_PCH_DEVICE_ID_MASK 0xff80 #define INTEL_PCH_IBX_DEVICE_ID_TYPE 0x3b00 #define INTEL_PCH_CPT_DEVICE_ID_TYPE 0x1c00 @@ -2860,25 +2850,45 @@ intel_info(const struct drm_i915_private *dev_priv) #define INTEL_PCH_P3X_DEVICE_ID_TYPE 0x7000 #define INTEL_PCH_QEMU_DEVICE_ID_TYPE 0x2900 /* qemu q35 has 2918 */ -#define INTEL_PCH_TYPE(dev_priv) ((dev_priv)->pch_type) #define INTEL_PCH_ID(dev_priv) ((dev_priv)->pch_id) -#define HAS_PCH_ICP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_ICP) -#define HAS_PCH_CNP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_CNP) -#define HAS_PCH_CNP_LP(dev_priv) \ - (INTEL_PCH_ID(dev_priv) == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE) -#define HAS_PCH_KBP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_KBP) -#define HAS_PCH_SPT(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_SPT) -#define HAS_PCH_LPT(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_LPT) + +#define HAS_PCH_NOP(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_NOP) +#define HAS_PCH_SPLIT(dev_priv) \ + (INTEL_PCH_ID(dev_priv) != INTEL_PCH_NONE) + +/* IbexPeak PCH */ +#define HAS_PCH_IBX(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_IBX_DEVICE_ID_TYPE) +/* CougarPoint/PantherPoint PCH */ +#define HAS_PCH_CPT(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_CPT_DEVICE_ID_TYPE || \ + INTEL_PCH_ID(dev_priv) == INTEL_PCH_PPT_DEVICE_ID_TYPE) +/* LynxPoint/WildcatPoint PCH */ +#define HAS_PCH_LPT_H(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_LPT_DEVICE_ID_TYPE || \ + INTEL_PCH_ID(dev_priv) == INTEL_PCH_WPT_DEVICE_ID_TYPE) #define HAS_PCH_LPT_LP(dev_priv) \ (INTEL_PCH_ID(dev_priv) == INTEL_PCH_LPT_LP_DEVICE_ID_TYPE || \ INTEL_PCH_ID(dev_priv) == INTEL_PCH_WPT_LP_DEVICE_ID_TYPE) -#define HAS_PCH_LPT_H(dev_priv) \ - (INTEL_PCH_ID(dev_priv) == INTEL_PCH_LPT_DEVICE_ID_TYPE || \ - INTEL_PCH_ID(dev_priv) == INTEL_PCH_WPT_DEVICE_ID_TYPE) -#define HAS_PCH_CPT(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_CPT) -#define HAS_PCH_IBX(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_IBX) -#define HAS_PCH_NOP(dev_priv) (INTEL_PCH_TYPE(dev_priv) == PCH_NOP) -#define HAS_PCH_SPLIT(dev_priv) (INTEL_PCH_TYPE(dev_priv) != PCH_NONE) +#define HAS_PCH_LPT(dev_priv) \ + (HAS_PCH_LPT_H(dev_priv) || HAS_PCH_LPT_LP(dev_priv)) +/* SunrisePoint PCH */ +#define HAS_PCH_SPT(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_SPT_DEVICE_ID_TYPE || \ + INTEL_PCH_ID(dev_priv) == INTEL_PCH_SPT_LP_DEVICE_ID_TYPE) +/* KabyLake PCH */ +#define HAS_PCH_KBP(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_KBP_DEVICE_ID_TYPE) +/* CannonLake PCH */ +#define HAS_PCH_CNP(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_CNP_DEVICE_ID_TYPE || \ + INTEL_PCH_ID(dev_priv) == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE) +#define HAS_PCH_CNP_LP(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_CNP_LP_DEVICE_ID_TYPE) +/* IceLake PCH */ +#define HAS_PCH_ICP(dev_priv) \ + (INTEL_PCH_ID(dev_priv) == INTEL_PCH_ICP_DEVICE_ID_TYPE) #define HAS_GMCH_DISPLAY(dev_priv) ((dev_priv)->info.has_gmch_display) -- 2.11.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx