[Intel-gfx] [PATCH 03/15] drm/i915: allocate i915->gt0 dynamically
Jani Nikula
jani.nikula at intel.com
Thu Sep 28 18:08:47 UTC 2023
Convert i915->gt0 to a pointer, and allocate it dynamically.
Signed-off-by: Jani Nikula <jani.nikula at intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt.c | 8 +++++++-
drivers/gpu/drm/i915/i915_drv.h | 8 ++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c
index 93062c35e072..a3d68ff4b191 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -62,7 +62,13 @@ void intel_gt_common_init_early(struct intel_gt *gt)
/* Preliminary initialization of Tile 0 */
int intel_root_gt_init_early(struct drm_i915_private *i915)
{
- struct intel_gt *gt = to_gt(i915);
+ struct intel_gt *gt;
+
+ gt = drmm_kzalloc(&i915->drm, sizeof(*gt), GFP_KERNEL);
+ if (!gt)
+ return -ENOMEM;
+
+ i915->gt0 = gt;
gt->i915 = i915;
gt->uncore = &i915->uncore;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 511eba3bbdba..a1cb16afa46d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -318,10 +318,10 @@ struct drm_i915_private {
struct i915_hwmon *hwmon;
/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
- struct intel_gt gt0;
+ struct intel_gt *gt0;
/*
- * i915->gt[0] == &i915->gt0
+ * i915->gt[0] == i915->gt0
*/
struct intel_gt *gt[I915_MAX_GT];
@@ -382,9 +382,9 @@ static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
return pci_get_drvdata(pdev);
}
-static inline struct intel_gt *to_gt(struct drm_i915_private *i915)
+static inline struct intel_gt *to_gt(const struct drm_i915_private *i915)
{
- return &i915->gt0;
+ return i915->gt0;
}
/* Simple iterator over all initialised engines */
--
2.39.2
More information about the Intel-gfx
mailing list