diff mbox series

[2/3] drm/i915: allocate i915->gt0 dynamically

Message ID 01bf968aa431b77d491790178cbeece18b5fc4c0.1696236329.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: nuke i915->gt0 | expand

Commit Message

Jani Nikula Oct. 2, 2023, 8:47 a.m. UTC
Convert i915->gt0 to a pointer, and allocate it dynamically.

Signed-off-by: Jani Nikula <jani.nikula@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(-)

Comments

Gustavo Sousa Oct. 2, 2023, 2:20 p.m. UTC | #1
Quoting Jani Nikula (2023-10-02 05:47:03-03:00)
>Convert i915->gt0 to a pointer, and allocate it dynamically.
>
>Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Gustavo Sousa <gustavo.sousa@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 454b9923cda9..b293ace6745d 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
>
Andi Shyti Oct. 3, 2023, 6:54 a.m. UTC | #2
Hi Jani,

On Mon, Oct 02, 2023 at 11:47:03AM +0300, Jani Nikula wrote:
> Convert i915->gt0 to a pointer, and allocate it dynamically.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> 

Thanks,
Andi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c
index 454b9923cda9..b293ace6745d 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 */