[Intel-xe] [PATCH 4/4] drm/xe/display: Use xe_display_driver prefix
Lucas De Marchi
lucas.demarchi at intel.com
Wed May 10 19:54:24 UTC 2023
Use a separate xe_display_driver prefix for functions dealing with the
DRM driver struct or the early probe. This splits
xe_display_set_driver_hooks() in 2: one to allow the driver to defer the
probe if the display needs that and the other to set the additional
hooks in the driver struct. Although the hooks are set by every device
binding to the module, they only depend on the module param
enable_display, so that is safe.
Since unset_driver_hooks() is not really tweaking the driver, but rather
the driver_features saved in the device, rename it to
unset_display_features() to clarify that.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
drivers/gpu/drm/xe/xe_device.c | 4 +--
drivers/gpu/drm/xe/xe_display.c | 44 ++++++++++++++++++++-------------
drivers/gpu/drm/xe/xe_display.h | 8 +++---
drivers/gpu/drm/xe/xe_pci.c | 4 +++
4 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 1daacc533083..cb37e8556b37 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -171,9 +171,7 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
struct xe_device *xe;
int err;
- err = xe_display_set_driver_hooks(pdev, &driver);
- if (err)
- return ERR_PTR(err);
+ xe_display_driver_set_hooks(&driver);
err = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
if (err)
diff --git a/drivers/gpu/drm/xe/xe_display.c b/drivers/gpu/drm/xe/xe_display.c
index 43c5af1ff80e..d1782e0737ed 100644
--- a/drivers/gpu/drm/xe/xe_display.c
+++ b/drivers/gpu/drm/xe/xe_display.c
@@ -34,37 +34,47 @@
/* Xe device functions */
+/**
+ * xe_display_driver_probe_defer - Detect if we need to wait for other drivers
+ * early on
+ * @pdev: PCI device
+ *
+ * Returns: 0 if probe can continue, -EPROBE_DEFER otherwise
+ */
+int xe_display_driver_probe_defer(struct pci_dev *pdev)
+{
+ if (!enable_display)
+ return 0;
+
+ return intel_display_driver_probe_defer(pdev);
+}
+
static void xe_display_last_close(struct drm_device *dev)
{
- intel_fbdev_restore_mode(to_xe_device(dev));
+ struct xe_device *xe = to_xe_device(dev);
+
+ if (xe->info.enable_display)
+ intel_fbdev_restore_mode(to_xe_device(dev));
}
/**
- * xe_display_set_driver_hooks - set driver flags and hooks for display
- * @pdev: PCI device
+ * xe_display_driver_set_hooks - Add driver flags and hooks for display
* @driver: DRM device driver
*
* Set features and function hooks in @driver that are needed for driving the
- * display IP, when that is enabled.
- *
- * Returns: 0 on success
+ * display IP. This sets the driver's capability of driving display, regardless
+ * if the device has it enabled
*/
-int xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver)
+void xe_display_driver_set_hooks(struct drm_driver *driver)
{
if (!enable_display)
- return 0;
-
- /* Detect if we need to wait for other drivers early on */
- if (intel_display_driver_probe_defer(pdev))
- return -EPROBE_DEFER;
+ return;
driver->driver_features |= DRIVER_MODESET | DRIVER_ATOMIC;
driver->lastclose = xe_display_last_close;
-
- return 0;
}
-static void unset_driver_hooks(struct xe_device *xe)
+static void unset_display_features(struct xe_device *xe)
{
xe->drm.driver_features &= ~(DRIVER_MODESET | DRIVER_ATOMIC);
}
@@ -488,7 +498,7 @@ __diag_ignore_all("-Woverride-init", "Allow field overrides in table");
void xe_display_info_init(struct xe_device *xe)
{
if (!xe->info.enable_display) {
- unset_driver_hooks(xe);
+ unset_display_features(xe);
return;
}
@@ -539,7 +549,7 @@ void xe_display_info_init(struct xe_device *xe)
default:
drm_warn(&xe->drm, "Unknown display IP\n");
xe->info.enable_display = false;
- unset_driver_hooks(xe);
+ unset_display_features(xe);
return;
}
}
diff --git a/drivers/gpu/drm/xe/xe_display.h b/drivers/gpu/drm/xe/xe_display.h
index 84c556111c91..9e29de012df7 100644
--- a/drivers/gpu/drm/xe/xe_display.h
+++ b/drivers/gpu/drm/xe/xe_display.h
@@ -12,7 +12,8 @@ struct drm_driver;
#if IS_ENABLED(CONFIG_DRM_XE_DISPLAY)
-int xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver);
+int xe_display_driver_probe_defer(struct pci_dev *pdev);
+void xe_display_driver_set_hooks(struct drm_driver *driver);
int xe_display_create(struct xe_device *xe);
@@ -47,8 +48,9 @@ void xe_display_pm_resume(struct xe_device *xe);
#else
-static inline int
-xe_display_set_driver_hooks(struct pci_dev *pdev, struct drm_driver *driver) { return 0; }
+static inline int xe_display_driver_probe_defer(struct pci_dev *pdev) { return 0; }
+
+static inline void xe_display_driver_set_hooks(struct drm_driver *driver) { }
static inline int
xe_display_create(struct xe_device *xe) { return 0; }
diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
index 3fa3e8706d98..8b3d4d5006e8 100644
--- a/drivers/gpu/drm/xe/xe_pci.c
+++ b/drivers/gpu/drm/xe/xe_pci.c
@@ -618,6 +618,10 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return -ENODEV;
}
+ err = xe_display_driver_probe_defer(pdev);
+ if (err)
+ return err;
+
xe = xe_device_create(pdev, ent);
if (IS_ERR(xe))
return PTR_ERR(xe);
--
2.40.1
More information about the Intel-xe
mailing list