Re: [PATCH 1/4] drm/i915: abstract PCH type detection from PCH id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 05, 2018 at 05:31:36PM +0000, Jani Nikula wrote:
> Make the logic in intel_detect_pch() easier to follow, and make the PCH
> id to type mapping reusable. No functional changes.

I wondered here if we should change intel_pch from enum to array
{ pch_id, pch_type, supported_platforms, "name" }

but besides requiring a loop at this point supported_platforms would be tricky one.

so, never mind...

> 
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx>

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 148 ++++++++++++++++++++--------------------
>  1 file changed, 73 insertions(+), 75 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index e9f1daf258fe..08e97b6e976b 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -122,6 +122,75 @@ static bool i915_error_injected(struct drm_i915_private *dev_priv)
>  		      i915_error_injected(dev_priv) ? KERN_DEBUG : KERN_ERR, \
>  		      fmt, ##__VA_ARGS__)
>  
> +/* Map PCH device id to PCH type, or PCH_NONE if unknown. */
> +static enum intel_pch
> +intel_pch_type(const struct drm_i915_private *dev_priv, unsigned short id)
> +{
> +	switch (id) {
> +	case INTEL_PCH_IBX_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
> +		WARN_ON(!IS_GEN5(dev_priv));
> +		return PCH_IBX;
> +	case INTEL_PCH_CPT_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found CougarPoint PCH\n");
> +		WARN_ON(!IS_GEN6(dev_priv) && !IS_IVYBRIDGE(dev_priv));
> +		return PCH_CPT;
> +	case INTEL_PCH_PPT_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found PantherPoint PCH\n");
> +		WARN_ON(!IS_GEN6(dev_priv) && !IS_IVYBRIDGE(dev_priv));
> +		/* PantherPoint is CPT compatible */
> +		return PCH_CPT;
> +	case INTEL_PCH_LPT_DEVICE_ID_TYPE:
> +		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));
> +		return PCH_LPT;
> +	case INTEL_PCH_LPT_LP_DEVICE_ID_TYPE:
> +		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));
> +		return PCH_LPT;
> +	case INTEL_PCH_WPT_DEVICE_ID_TYPE:
> +		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));
> +		/* WildcatPoint is LPT compatible */
> +		return PCH_LPT;
> +	case INTEL_PCH_WPT_LP_DEVICE_ID_TYPE:
> +		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));
> +		/* WildcatPoint is LPT compatible */
> +		return PCH_LPT;
> +	case INTEL_PCH_SPT_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found SunrisePoint PCH\n");
> +		WARN_ON(!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv));
> +		return PCH_SPT;
> +	case INTEL_PCH_SPT_LP_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found SunrisePoint LP PCH\n");
> +		WARN_ON(!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv));
> +		return PCH_SPT;
> +	case INTEL_PCH_KBP_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found Kaby Lake PCH (KBP)\n");
> +		WARN_ON(!IS_SKYLAKE(dev_priv) && !IS_KABYLAKE(dev_priv) &&
> +			!IS_COFFEELAKE(dev_priv));
> +		return PCH_KBP;
> +	case INTEL_PCH_CNP_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found Cannon Lake PCH (CNP)\n");
> +		WARN_ON(!IS_CANNONLAKE(dev_priv) && !IS_COFFEELAKE(dev_priv));
> +		return PCH_CNP;
> +	case INTEL_PCH_CNP_LP_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found Cannon Lake LP PCH (CNP-LP)\n");
> +		WARN_ON(!IS_CANNONLAKE(dev_priv) && !IS_COFFEELAKE(dev_priv));
> +		return PCH_CNP;
> +	case INTEL_PCH_ICP_DEVICE_ID_TYPE:
> +		DRM_DEBUG_KMS("Found Ice Lake PCH\n");
> +		WARN_ON(!IS_ICELAKE(dev_priv));
> +		return PCH_ICP;
> +	default:
> +		return PCH_NONE;
> +	}
> +}
>  
>  static enum intel_pch intel_virt_detect_pch(struct drm_i915_private *dev_priv)
>  {
> @@ -183,6 +252,7 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
>  	 */
>  	while ((pch = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, pch))) {
>  		unsigned short id;
> +		enum intel_pch pch_type;
>  
>  		if (pch->vendor != PCI_VENDOR_ID_INTEL)
>  			continue;
> @@ -191,81 +261,9 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
>  
>  		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));
> +		pch_type = intel_pch_type(dev_priv, id);
> +		if (pch_type != PCH_NONE) {
> +			dev_priv->pch_type = pch_type;
>  		} else if (id == INTEL_PCH_P2X_DEVICE_ID_TYPE ||
>  			   id == INTEL_PCH_P3X_DEVICE_ID_TYPE ||
>  			   (id == INTEL_PCH_QEMU_DEVICE_ID_TYPE &&
> -- 
> 2.11.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux