diff mbox

[2/4] drm/i915: clean up virtual PCH special case handling

Message ID 20180531115624.30269-3-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula May 31, 2018, 11:56 a.m. UTC
Use intel_pch_type() also for mapping the no PCH case (PCH id 0) to
PCH_NONE to simplify code.

Also make sure that intel_pch_type() knows all the PCH ids returned by
intel_virt_detect_pch(). Loudly fail if this isn't the case; this
shouldn't happen anyway.

Cc: Colin Xu <Colin.Xu@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Colin Xu June 2, 2018, 12:50 a.m. UTC | #1
On 05/31/2018 07:56 PM, Jani Nikula wrote:
> Use intel_pch_type() also for mapping the no PCH case (PCH id 0) to
> PCH_NONE to simplify code.
>
> Also make sure that intel_pch_type() knows all the PCH ids returned by
> intel_virt_detect_pch(). Loudly fail if this isn't the case; this
> shouldn't happen anyway.
>
> Cc: Colin Xu <Colin.Xu@intel.com>
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_drv.c | 13 ++++++-------
>   1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index c42e389a27f3..1842a067a604 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -282,13 +282,12 @@ static void intel_detect_pch(struct drm_i915_private *dev_priv)
>   		} else if (intel_is_virt_pch(id, pch->subsystem_vendor,
>   					 pch->subsystem_device)) {
>   			id = intel_virt_detect_pch(dev_priv);
> -			if (id) {
> -				pch_type = intel_pch_type(dev_priv, id);
> -				if (WARN_ON(pch_type == PCH_NONE))
> -					pch_type = PCH_NOP;
> -			} else {
> -				pch_type = PCH_NONE;
> -			}
> +			pch_type = intel_pch_type(dev_priv, id);
> +
> +			/* Sanity check virtual PCH id */
> +			if (WARN_ON(id && pch_type == PCH_NONE))
> +				id = 0;
> +
>   			dev_priv->pch_type = pch_type;
>   			dev_priv->pch_id = id;
>   			break;

Tested on BXT gvt-g and got expected behaviour.

Tested-by: Colin Xu <Colin.Xu@intel.com>
Reviewed-by: Colin Xu <Colin.Xu@intel.com>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index c42e389a27f3..1842a067a604 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -282,13 +282,12 @@  static void intel_detect_pch(struct drm_i915_private *dev_priv)
 		} else if (intel_is_virt_pch(id, pch->subsystem_vendor,
 					 pch->subsystem_device)) {
 			id = intel_virt_detect_pch(dev_priv);
-			if (id) {
-				pch_type = intel_pch_type(dev_priv, id);
-				if (WARN_ON(pch_type == PCH_NONE))
-					pch_type = PCH_NOP;
-			} else {
-				pch_type = PCH_NONE;
-			}
+			pch_type = intel_pch_type(dev_priv, id);
+
+			/* Sanity check virtual PCH id */
+			if (WARN_ON(id && pch_type == PCH_NONE))
+				id = 0;
+
 			dev_priv->pch_type = pch_type;
 			dev_priv->pch_id = id;
 			break;