From e86f9a60985daab56af4d76fad9a2c851788766c Mon Sep 17 00:00:00 2001
From: Lucas De Marchi <lucas.demarchi@intel.com>
Date: Fri, 10 Mar 2023 11:14:30 -0800
Subject: [PATCH] drm/xe/display: Fix module load without display IP

When the device info initialization moved to the display part, one use
case was left behind: platforms without display IP. In order to keep the
knowledge about the display in xe_display.c, xe_display_info_init()
should be the place where this is set.

Remove the warning and set the info accordingly. This moves a later
check from  intel_device_info_runtime_init() into a very earlier one,
when no HW access is being done yet.

Fixes: 2a0f49c7ae5b ("drm/xe/display: Move device info initialization to display")
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Link: https://lore.kernel.org/r/20230310191430.2229799-1-lucas.demarchi@intel.com
---
 .../gpu/drm/xe/display/ext/intel_device_info.c    |  6 ------
 drivers/gpu/drm/xe/xe_display.c                   | 15 +++++++++------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/ext/intel_device_info.c b/drivers/gpu/drm/xe/display/ext/intel_device_info.c
index a4c844aa8be6..9a54611037b5 100644
--- a/drivers/gpu/drm/xe/display/ext/intel_device_info.c
+++ b/drivers/gpu/drm/xe/display/ext/intel_device_info.c
@@ -109,12 +109,6 @@ void intel_device_info_runtime_init(struct drm_i915_private *dev_priv)
 			runtime->has_dsc = 0;
 	}
 
-	if (!HAS_DISPLAY(dev_priv)) {
-		dev_priv->drm.driver_features &= ~(DRIVER_MODESET |
-						   DRIVER_ATOMIC);
-		memset(runtime, 0, sizeof(*runtime));
-	}
-
 	runtime->rawclk_freq = intel_read_rawclk(dev_priv);
 	drm_dbg(&dev_priv->drm, "rawclk rate: %d kHz\n", runtime->rawclk_freq);
 }
diff --git a/drivers/gpu/drm/xe/xe_display.c b/drivers/gpu/drm/xe/xe_display.c
index c1987cea359a..7b513da80315 100644
--- a/drivers/gpu/drm/xe/xe_display.c
+++ b/drivers/gpu/drm/xe/xe_display.c
@@ -63,6 +63,11 @@ int xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver)
 	return 0;
 }
 
+static void unset_driver_hooks(struct xe_device *xe)
+{
+	xe->drm.driver_features &= ~(DRIVER_MODESET | DRIVER_ATOMIC);
+}
+
 static void display_destroy(struct drm_device *dev, void *dummy)
 {
 	struct xe_device *xe = to_xe_device(dev);
@@ -85,7 +90,6 @@ int xe_display_create(struct xe_device *xe)
 {
 	int err;
 
-	/* Initialize display parts here.. */
 	spin_lock_init(&xe->display.fb_tracking.lock);
 
 	xe->display.hotplug.dp_wq = alloc_ordered_workqueue("xe-dp", 0);
@@ -525,11 +529,10 @@ void xe_display_info_init(struct xe_device *xe)
 		xe->info.display = (struct xe_device_display_info) { XE_LPDP };
 		break;
 	default:
-		/*
-		 * If platform doesn't have display, enable_display should
-		 * had been forced to false already at this point
-		 */
-		drm_WARN_ON(&xe->drm, 1);
+		drm_dbg(&xe->drm, "No display IP, skipping\n");
+		xe->info.enable_display = false;
+		unset_driver_hooks(xe);
+		return;
 	}
 }
 
-- 
GitLab