summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_device.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2023-08-17 23:30:41 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-21 19:43:39 +0300
commit44e694958b95395bd1c41508c88c8ca141bf9bd7 (patch)
tree1b3e18abe5f05a6716e6dee725a3c2c50d5db30c /drivers/gpu/drm/xe/xe_device.c
parenta839e365ac88f0fa9f8c7ae92b9e7e66bbd9e4d7 (diff)
downloadlinux-44e694958b95395bd1c41508c88c8ca141bf9bd7.tar.xz
drm/xe/display: Implement display support
As for display, the intent is to share the display code with the i915 driver so that there is maximum reuse there. We do this by recompiling i915/display code twice. Now that i915 has been adapted to support the Xe build, we can add the xe/display support. This initial work is a collaboration of many people and unfortunately this squashed patch won't fully honor the proper credits. But let's try to add a few from the squashed patches: Co-developed-by: Matthew Brost <matthew.brost@intel.com> Co-developed-by: Jani Nikula <jani.nikula@intel.com> Co-developed-by: Lucas De Marchi <lucas.demarchi@intel.com> Co-developed-by: Matt Roper <matthew.d.roper@intel.com> Co-developed-by: Mauro Carvalho Chehab <mchehab@kernel.org> Co-developed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Co-developed-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_device.c')
-rw-r--r--drivers/gpu/drm/xe/xe_device.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 5869ba7e0cdc..98d7e7fa12d8 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -18,6 +18,7 @@
#include "regs/xe_regs.h"
#include "xe_bo.h"
#include "xe_debugfs.h"
+#include "xe_display.h"
#include "xe_dma_buf.h"
#include "xe_drm_client.h"
#include "xe_drv.h"
@@ -190,6 +191,9 @@ static void xe_device_destroy(struct drm_device *dev, void *dummy)
if (xe->ordered_wq)
destroy_workqueue(xe->ordered_wq);
+ if (xe->unordered_wq)
+ destroy_workqueue(xe->unordered_wq);
+
ttm_device_fini(&xe->ttm);
}
@@ -199,6 +203,8 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
struct xe_device *xe;
int err;
+ xe_display_driver_set_hooks(&driver);
+
err = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &driver);
if (err)
return ERR_PTR(err);
@@ -237,14 +243,16 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
INIT_LIST_HEAD(&xe->pinned.evicted);
xe->ordered_wq = alloc_ordered_workqueue("xe-ordered-wq", 0);
- if (!xe->ordered_wq) {
- drm_err(&xe->drm, "Failed to allocate xe-ordered-wq\n");
+ xe->unordered_wq = alloc_workqueue("xe-unordered-wq", 0, 0);
+ if (!xe->ordered_wq || !xe->unordered_wq) {
+ drm_err(&xe->drm, "Failed to allocate xe workqueues\n");
err = -ENOMEM;
goto err_put;
}
- drmm_mutex_init(&xe->drm, &xe->sb_lock);
- xe->enabled_irq_mask = ~0;
+ err = xe_display_create(xe);
+ if (WARN_ON(err))
+ goto err_put;
return xe;
@@ -346,6 +354,9 @@ int xe_device_probe(struct xe_device *xe)
xe_pat_init_early(xe);
xe->info.mem_region_mask = 1;
+ err = xe_display_init_nommio(xe);
+ if (err)
+ return err;
for_each_tile(tile, xe, id) {
err = xe_tile_alloc(tile);
@@ -367,10 +378,14 @@ int xe_device_probe(struct xe_device *xe)
return err;
}
- err = xe_irq_install(xe);
+ err = xe_display_init_noirq(xe);
if (err)
return err;
+ err = xe_irq_install(xe);
+ if (err)
+ goto err;
+
for_each_gt(gt, xe, id) {
err = xe_gt_init_early(gt);
if (err)
@@ -392,6 +407,16 @@ int xe_device_probe(struct xe_device *xe)
/* Allocate and map stolen after potential VRAM resize */
xe_ttm_stolen_mgr_init(xe);
+ /*
+ * Now that GT is initialized (TTM in particular),
+ * we can try to init display, and inherit the initial fb.
+ * This is the reason the first allocation needs to be done
+ * inside display.
+ */
+ err = xe_display_init_noaccel(xe);
+ if (err)
+ goto err_irq_shutdown;
+
for_each_gt(gt, xe, id) {
err = xe_gt_init(gt);
if (err)
@@ -400,10 +425,16 @@ int xe_device_probe(struct xe_device *xe)
xe_heci_gsc_init(xe);
+ err = xe_display_init(xe);
+ if (err)
+ goto err_fini_display;
+
err = drm_dev_register(&xe->drm, 0);
if (err)
goto err_irq_shutdown;
+ xe_display_register(xe);
+
xe_debugfs_register(xe);
xe_pmu_register(&xe->pmu);
@@ -416,13 +447,30 @@ int xe_device_probe(struct xe_device *xe)
return 0;
+err_fini_display:
+ xe_display_driver_remove(xe);
+
err_irq_shutdown:
xe_irq_shutdown(xe);
+err:
+ xe_display_fini(xe);
return err;
}
+static void xe_device_remove_display(struct xe_device *xe)
+{
+ xe_display_unregister(xe);
+
+ drm_dev_unplug(&xe->drm);
+ xe_display_driver_remove(xe);
+}
+
void xe_device_remove(struct xe_device *xe)
{
+ xe_device_remove_display(xe);
+
+ xe_display_fini(xe);
+
xe_heci_gsc_fini(xe);
xe_irq_shutdown(xe);