[Intel-xe] [PATCH 4/7] drm/xe/display: Move display sw init to xe_display.c
Lucas De Marchi
lucas.demarchi at intel.com
Thu Mar 2 01:34:08 UTC 2023
Instead of having all the fields initialized in xe_device_create(), move
the display part to xe_display_create(). Right now the name "_create()"
is not so good as it's basically initializing the fields from xe_device.
There is still work needed to move fields to the display substruct so it
can be an opaque struct. However, there are already several _init_*()
functions, so use the create() suffix in the hope the struct will be
made opaque soon.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 27 ++---------------
drivers/gpu/drm/xe/xe_display.c | 53 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_display.h | 5 ++++
3 files changed, 61 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 8b0a6cd6fd65..1553949d12b6 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -158,7 +158,6 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)
{
struct xe_device *xe = to_xe_device(dev);
- destroy_workqueue(xe->display.hotplug.dp_wq);
destroy_workqueue(xe->ordered_wq);
ttm_device_fini(&xe->ttm);
}
@@ -211,29 +210,9 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
- /* Initialize display parts here.. */
- spin_lock_init(&xe->display.fb_tracking.lock);
-
- xe->display.hotplug.dp_wq = alloc_ordered_workqueue("xe-dp", 0);
-
- drmm_mutex_init(&xe->drm, &xe->sb_lock);
- drmm_mutex_init(&xe->drm, &xe->display.backlight.lock);
- drmm_mutex_init(&xe->drm, &xe->display.audio.mutex);
- drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex);
- drmm_mutex_init(&xe->drm, &xe->display.pps.mutex);
- drmm_mutex_init(&xe->drm, &xe->display.hdcp.comp_mutex);
- xe->enabled_irq_mask = ~0;
-
- xe->params.invert_brightness = -1;
- xe->params.vbt_sdvo_panel_type = -1;
- xe->params.disable_power_well = -1;
- xe->params.enable_dc = -1;
- xe->params.enable_dpcd_backlight = -1;
- xe->params.enable_dp_mst = -1;
- xe->params.enable_fbc = -1;
- xe->params.enable_psr = -1;
- xe->params.enable_psr2_sel_fetch = -1;
- xe->params.panel_use_ssc = -1;
+ err = xe_display_create(xe);
+ if (WARN_ON(err))
+ goto err_put;
err = drmm_add_action_or_reset(&xe->drm, xe_device_destroy, NULL);
if (err)
diff --git a/drivers/gpu/drm/xe/xe_display.c b/drivers/gpu/drm/xe/xe_display.c
index 19c1f9945911..34bdb2d60938 100644
--- a/drivers/gpu/drm/xe/xe_display.c
+++ b/drivers/gpu/drm/xe/xe_display.c
@@ -55,6 +55,59 @@ int xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver)
return 0;
}
+static void display_destroy(struct drm_device *dev, void *dummy)
+{
+ struct xe_device *xe = to_xe_device(dev);
+
+ destroy_workqueue(xe->display.hotplug.dp_wq);
+}
+
+/**
+ * xe_display_create - create display struct
+ * @xe: XE device instance
+ *
+ * Initialize all fields used by the display part.
+ *
+ * TODO: once everything can be inside a single struct, make the struct opaque
+ * to the rest of xe and return it to be xe->display.
+ *
+ * Returns: 0 on success
+ */
+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);
+
+ drmm_mutex_init(&xe->drm, &xe->sb_lock);
+ drmm_mutex_init(&xe->drm, &xe->display.backlight.lock);
+ drmm_mutex_init(&xe->drm, &xe->display.audio.mutex);
+ drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex);
+ drmm_mutex_init(&xe->drm, &xe->display.pps.mutex);
+ drmm_mutex_init(&xe->drm, &xe->display.hdcp.comp_mutex);
+ xe->enabled_irq_mask = ~0;
+
+ xe->params.invert_brightness = -1;
+ xe->params.vbt_sdvo_panel_type = -1;
+ xe->params.disable_power_well = -1;
+ xe->params.enable_dc = -1;
+ xe->params.enable_dpcd_backlight = -1;
+ xe->params.enable_dp_mst = -1;
+ xe->params.enable_fbc = -1;
+ xe->params.enable_psr = -1;
+ xe->params.enable_psr2_sel_fetch = -1;
+ xe->params.panel_use_ssc = -1;
+
+ err = drmm_add_action_or_reset(&xe->drm, display_destroy, NULL);
+ if (err)
+ return err;
+
+ return 0;
+}
+
void xe_display_fini_nommio(struct drm_device *dev, void *dummy)
{
struct xe_device *xe = to_xe_device(dev);
diff --git a/drivers/gpu/drm/xe/xe_display.h b/drivers/gpu/drm/xe/xe_display.h
index cc908d8a7cd9..cb5298ceed3b 100644
--- a/drivers/gpu/drm/xe/xe_display.h
+++ b/drivers/gpu/drm/xe/xe_display.h
@@ -14,6 +14,8 @@
int xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver);
+int xe_display_create(struct xe_device *xe);
+
int xe_display_init_nommio(struct xe_device *xe);
void xe_display_fini_nommio(struct drm_device *dev, void *dummy);
@@ -46,6 +48,9 @@ void xe_display_pm_resume(struct xe_device *xe);
static inline int
xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver) { return 0; }
+static inline int
+xe_display_create(struct xe_device *xe) { return 0; }
+
static inline int
xe_display_enable(struct pci_dev *pdev, struct drm_driver *driver) { return 0; };
--
2.39.0
More information about the Intel-xe
mailing list