Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] drm/xe: Fix xe_pm_runtime_get_if_active return
@ 2024-05-08 20:07 Rodrigo Vivi
  2024-05-08 20:07 ` [PATCH 2/7] drm/xe: Fix xe_pm_runtime_get_if_in_use documentation Rodrigo Vivi
                   ` (13 more replies)
  0 siblings, 14 replies; 22+ messages in thread
From: Rodrigo Vivi @ 2024-05-08 20:07 UTC (permalink / raw)
  To: intel-xe; +Cc: Rodrigo Vivi, Francois Dugast, Thomas Hellström

Current callers of this function are already taking the result
to a boolean and using in an if. It might be a problem because
current function might return negative error codes on failure,
without increasing the reference counter.

In this scenario we could end up with extra 'put' call ending
in unbalanced scenarios.

Let's fix it, while aligning with the current xe_pm_get_if_in_use
style.

Cc: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/xe/xe_pm.c | 8 ++++----
 drivers/gpu/drm/xe/xe_pm.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index c1831106ea4b..d14741f35cc4 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -505,12 +505,12 @@ int xe_pm_runtime_get_ioctl(struct xe_device *xe)
  * xe_pm_runtime_get_if_active - Get a runtime_pm reference if device active
  * @xe: xe device instance
  *
- * Returns: Any number greater than or equal to 0 for success, negative error
- * code otherwise.
+ * Return: True if device is awake (regardless the previous number of references)
+ * and a new reference was taken, false otherwise.
  */
-int xe_pm_runtime_get_if_active(struct xe_device *xe)
+bool xe_pm_runtime_get_if_active(struct xe_device *xe)
 {
-	return pm_runtime_get_if_active(xe->drm.dev);
+	return pm_runtime_get_if_active(xe->drm.dev) > 0;
 }
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index 18b0613fe57b..f694005db278 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -29,7 +29,7 @@ int xe_pm_runtime_resume(struct xe_device *xe);
 void xe_pm_runtime_get(struct xe_device *xe);
 int xe_pm_runtime_get_ioctl(struct xe_device *xe);
 void xe_pm_runtime_put(struct xe_device *xe);
-int xe_pm_runtime_get_if_active(struct xe_device *xe);
+bool xe_pm_runtime_get_if_active(struct xe_device *xe);
 bool xe_pm_runtime_get_if_in_use(struct xe_device *xe);
 void xe_pm_runtime_get_noresume(struct xe_device *xe);
 bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread
* [PATCH 1/7] drm/xe: Fix xe_pm_runtime_get_if_active return
@ 2024-05-09 19:16 Rodrigo Vivi
  2024-05-09 19:16 ` [PATCH 3/7] drm/xe: Relax runtime pm protection during execution Rodrigo Vivi
  0 siblings, 1 reply; 22+ messages in thread
From: Rodrigo Vivi @ 2024-05-09 19:16 UTC (permalink / raw)
  To: intel-xe; +Cc: Rodrigo Vivi, Francois Dugast, Thomas Hellström

Current callers of this function are already taking the result
to a boolean and using in an if. It might be a problem because
current function might return negative error codes on failure,
without increasing the reference counter.

In this scenario we could end up with extra 'put' call ending
in unbalanced scenarios.

Let's fix it, while aligning with the current xe_pm_get_if_in_use
style.

Tested-by: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/xe/xe_pm.c | 8 ++++----
 drivers/gpu/drm/xe/xe_pm.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index c1831106ea4b..d14741f35cc4 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -505,12 +505,12 @@ int xe_pm_runtime_get_ioctl(struct xe_device *xe)
  * xe_pm_runtime_get_if_active - Get a runtime_pm reference if device active
  * @xe: xe device instance
  *
- * Returns: Any number greater than or equal to 0 for success, negative error
- * code otherwise.
+ * Return: True if device is awake (regardless the previous number of references)
+ * and a new reference was taken, false otherwise.
  */
-int xe_pm_runtime_get_if_active(struct xe_device *xe)
+bool xe_pm_runtime_get_if_active(struct xe_device *xe)
 {
-	return pm_runtime_get_if_active(xe->drm.dev);
+	return pm_runtime_get_if_active(xe->drm.dev) > 0;
 }
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
index 18b0613fe57b..f694005db278 100644
--- a/drivers/gpu/drm/xe/xe_pm.h
+++ b/drivers/gpu/drm/xe/xe_pm.h
@@ -29,7 +29,7 @@ int xe_pm_runtime_resume(struct xe_device *xe);
 void xe_pm_runtime_get(struct xe_device *xe);
 int xe_pm_runtime_get_ioctl(struct xe_device *xe);
 void xe_pm_runtime_put(struct xe_device *xe);
-int xe_pm_runtime_get_if_active(struct xe_device *xe);
+bool xe_pm_runtime_get_if_active(struct xe_device *xe);
 bool xe_pm_runtime_get_if_in_use(struct xe_device *xe);
 void xe_pm_runtime_get_noresume(struct xe_device *xe);
 bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread
* [PATCH 0/7] Unlock deeper package-C states (PC-10) and D3Cold
@ 2024-05-03 19:13 Rodrigo Vivi
  2024-05-03 19:13 ` [PATCH 3/7] drm/xe: Relax runtime pm protection during execution Rodrigo Vivi
  0 siblings, 1 reply; 22+ messages in thread
From: Rodrigo Vivi @ 2024-05-03 19:13 UTC (permalink / raw)
  To: intel-xe
  Cc: lucas.demarchi, matthew.brost, francois.dugast, thomas.hellstrom,
	matthew.auld, anshuman.gupta, Rodrigo Vivi

For integrated graphics, this series mean the unlock of
deeper package-C states. With this, on MTL I'm glad to
see PC-10 even with display enabled (with eDP PSR).

On my DG2 I'm gladly getting the big saves of D3Cold when
display is off/idle. And everything working niftly on
the desktop environment.

But in order to achieve that, we need to relax the runtime
PM protection around VMs and exec_queue, as explained on
each individual patch touching them.

Please let me know your thoughts, specially around those
relaxation cases.

Thanks,
Rodrigo.

Rodrigo Vivi (7):
  drm/xe: Fix xe_pm_runtime_get_if_active return
  drm/xe: Fix xe_pm_runtime_get_if_in_use documentation
  drm/xe: Relax runtime pm protection during execution
  drm/xe: Relax runtime pm protection around VM
  drm/xe: Prepare display for D3Cold
  drm/xe: Stop checking for power_lost on D3Cold
  drm/xe: Enable D3Cold on 'low' VRAM utilization

 drivers/gpu/drm/xe/display/xe_display.c | 10 ++++---
 drivers/gpu/drm/xe/display/xe_display.h |  8 ++---
 drivers/gpu/drm/xe/xe_bo.c              | 17 ++++++++++-
 drivers/gpu/drm/xe/xe_device_types.h    |  3 --
 drivers/gpu/drm/xe/xe_exec_queue.c      | 14 ---------
 drivers/gpu/drm/xe/xe_guc.c             | 27 -----------------
 drivers/gpu/drm/xe/xe_guc.h             |  1 -
 drivers/gpu/drm/xe/xe_guc_submit.c      |  3 ++
 drivers/gpu/drm/xe/xe_pm.c              | 40 +++++++++++++------------
 drivers/gpu/drm/xe/xe_pm.h              |  9 ++----
 drivers/gpu/drm/xe/xe_sched_job.c       | 10 ++-----
 drivers/gpu/drm/xe/xe_vm.c              |  6 ++--
 12 files changed, 58 insertions(+), 90 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-05-13 13:17 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 20:07 [PATCH 1/7] drm/xe: Fix xe_pm_runtime_get_if_active return Rodrigo Vivi
2024-05-08 20:07 ` [PATCH 2/7] drm/xe: Fix xe_pm_runtime_get_if_in_use documentation Rodrigo Vivi
2024-05-08 20:07 ` [PATCH 3/7] drm/xe: Relax runtime pm protection during execution Rodrigo Vivi
2024-05-08 20:07 ` [PATCH 4/7] drm/xe: Relax runtime pm protection around VM Rodrigo Vivi
2024-05-09 15:48   ` Matthew Brost
2024-05-13 13:16     ` Thomas Hellström
2024-05-08 20:07 ` [PATCH 5/7] drm/xe: Prepare display for D3Cold Rodrigo Vivi
2024-05-09 11:36   ` Gupta, Anshuman
2024-05-08 20:07 ` [PATCH 6/7] drm/xe: Stop checking for power_lost on D3Cold Rodrigo Vivi
2024-05-08 20:07 ` [PATCH 7/7] drm/xe: Enable D3Cold on 'low' VRAM utilization Rodrigo Vivi
2024-05-09 15:37   ` Matthew Brost
2024-05-08 20:13 ` ✓ CI.Patch_applied: success for series starting with [1/7] drm/xe: Fix xe_pm_runtime_get_if_active return Patchwork
2024-05-08 20:14 ` ✓ CI.checkpatch: " Patchwork
2024-05-08 20:15 ` ✓ CI.KUnit: " Patchwork
2024-05-08 20:26 ` ✓ CI.Build: " Patchwork
2024-05-08 20:29 ` ✓ CI.Hooks: " Patchwork
2024-05-08 20:30 ` ✓ CI.checksparse: " Patchwork
2024-05-08 21:03 ` ✓ CI.BAT: " Patchwork
2024-05-09  8:20 ` ✗ CI.FULL: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-05-09 19:16 [PATCH 1/7] " Rodrigo Vivi
2024-05-09 19:16 ` [PATCH 3/7] drm/xe: Relax runtime pm protection during execution Rodrigo Vivi
2024-05-03 19:13 [PATCH 0/7] Unlock deeper package-C states (PC-10) and D3Cold Rodrigo Vivi
2024-05-03 19:13 ` [PATCH 3/7] drm/xe: Relax runtime pm protection during execution Rodrigo Vivi
2024-05-06 11:57   ` Thomas Hellström

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox