From 36d19a15304a7225a43e3405f4473975e4fc3d6b Mon Sep 17 00:00:00 2001 From: Lucas De Marchi <lucas.demarchi@intel.com> Date: Wed, 1 Mar 2023 17:34:08 -0800 Subject: [PATCH] drm/xe/display: Move display sw init to xe_display.c 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@intel.com> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://lore.kernel.org/r/20230302013411.3262608-5-lucas.demarchi@intel.com --- drivers/gpu/drm/xe/xe_device.c | 29 ++--------------- drivers/gpu/drm/xe/xe_display.c | 55 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_display.h | 5 +++ 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index f77eaeee4a8e7..6fff677744b5d 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -166,7 +166,6 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy) if (xe->ordered_wq) destroy_workqueue(xe->ordered_wq); - destroy_workqueue(xe->display.hotplug.dp_wq); ttm_device_fini(&xe->ttm); } @@ -225,31 +224,9 @@ struct xe_device *xe_device_create(struct pci_dev *pdev, goto err_put; } - /* 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_dpt = true; - xe->params.enable_fbc = -1; - xe->params.enable_psr = -1; - xe->params.enable_psr2_sel_fetch = -1; - xe->params.enable_sagv = true; - xe->params.panel_use_ssc = -1; + err = xe_display_create(xe); + if (WARN_ON(err)) + goto err_put; return xe; diff --git a/drivers/gpu/drm/xe/xe_display.c b/drivers/gpu/drm/xe/xe_display.c index b8a4305d508f7..afff26c580156 100644 --- a/drivers/gpu/drm/xe/xe_display.c +++ b/drivers/gpu/drm/xe/xe_display.c @@ -62,6 +62,61 @@ 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_dpt = true; + xe->params.enable_fbc = -1; + xe->params.enable_psr = -1; + xe->params.enable_psr2_sel_fetch = -1; + xe->params.enable_sagv = true; + 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 7ceabcef938a6..e5ddbf4a57d29 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; } -- GitLab