Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM
@ 2026-10-20 10:05 Thomas Hellström
  2026-10-20 13:35 ` Rodrigo Vivi
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Hellström @ 2026-10-20 10:05 UTC (permalink / raw)
  To: intel-xe; +Cc: Thomas Hellström, Matthew Brost, Rodrigo Vivi, stable

If evicting VRAM to system memory fails with -ENOMEM during runtime
suspend to D3cold, the error is returned to the runtime PM core.
Runtime PM treats any error other than -EAGAIN or -EBUSY from the
->runtime_suspend() callback as fatal, records it in
dev->power.runtime_error, and refuses further runtime PM operations
on the device until the error is cleared.

Memory shortage is a transient condition, and with eviction now using
__GFP_RETRY_MAYFAIL it is also more likely to occur. Convert -ENOMEM
from the eviction to -EAGAIN so that the device stays active and
runtime suspend is retried at a later idle transition.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.8+
Assisted-by: LLM
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_pm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index daa7ba2df317..9bf57ed1ea59 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -649,8 +649,16 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
 
 	if (xe->d3cold.allowed) {
 		err = xe_bo_evict_all(xe);
-		if (err)
+		if (err) {
+			/*
+			 * Runtime PM treats errors other than -EAGAIN and
+			 * -EBUSY as fatal, so report memory shortage as
+			 * transient to allow a later retry.
+			 */
+			if (err == -ENOMEM)
+				err = -EAGAIN;
 			goto out_resume;
+		}
 	}
 
 	for_each_gt(gt, xe, id) {
-- 
2.56.0


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

* Re: [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM
  2026-10-20 10:05 [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM Thomas Hellström
@ 2026-10-20 13:35 ` Rodrigo Vivi
  2026-10-20 16:08   ` Matthew Brost
  0 siblings, 1 reply; 5+ messages in thread
From: Rodrigo Vivi @ 2026-10-20 13:35 UTC (permalink / raw)
  To: Thomas Hellström; +Cc: intel-xe, Matthew Brost, stable

On Tue, Oct 20, 2026 at 12:05:45PM +0200, Thomas Hellström wrote:
> If evicting VRAM to system memory fails with -ENOMEM during runtime
> suspend to D3cold, the error is returned to the runtime PM core.
> Runtime PM treats any error other than -EAGAIN or -EBUSY from the
> ->runtime_suspend() callback as fatal, records it in
> dev->power.runtime_error, and refuses further runtime PM operations
> on the device until the error is cleared.

oh!

> 
> Memory shortage is a transient condition, and with eviction now using
> __GFP_RETRY_MAYFAIL it is also more likely to occur. Convert -ENOMEM
> from the eviction to -EAGAIN so that the device stays active and
> runtime suspend is retried at a later idle transition.
> 
> Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: intel-xe@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.8+
> Assisted-by: LLM
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
>  drivers/gpu/drm/xe/xe_pm.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> index daa7ba2df317..9bf57ed1ea59 100644
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -649,8 +649,16 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
>  
>  	if (xe->d3cold.allowed) {
>  		err = xe_bo_evict_all(xe);
> -		if (err)
> +		if (err) {
> +			/*
> +			 * Runtime PM treats errors other than -EAGAIN and
> +			 * -EBUSY as fatal, so report memory shortage as
> +			 * transient to allow a later retry.
> +			 */
> +			if (err == -ENOMEM)
> +				err = -EAGAIN;

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

>  			goto out_resume;
> +		}
>  	}
>  
>  	for_each_gt(gt, xe, id) {
> -- 
> 2.56.0
> 

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

* Re: [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM
  2026-10-20 13:35 ` Rodrigo Vivi
@ 2026-10-20 16:08   ` Matthew Brost
  2026-10-20 20:19     ` Rodrigo Vivi
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Brost @ 2026-10-20 16:08 UTC (permalink / raw)
  To: Rodrigo Vivi; +Cc: Thomas Hellström, intel-xe, stable

On Tue, Oct 20, 2026 at 09:35:20AM -0400, Rodrigo Vivi wrote:
> On Tue, Oct 20, 2026 at 12:05:45PM +0200, Thomas Hellström wrote:
> > If evicting VRAM to system memory fails with -ENOMEM during runtime
> > suspend to D3cold, the error is returned to the runtime PM core.
> > Runtime PM treats any error other than -EAGAIN or -EBUSY from the
> > ->runtime_suspend() callback as fatal, records it in
> > dev->power.runtime_error, and refuses further runtime PM operations
> > on the device until the error is cleared.
> 
> oh!
> 

I'm poked around core PM code but had a hard time verifying the above
claim is correct.

Any code references to help me verify this is correct?

Matt

> > 
> > Memory shortage is a transient condition, and with eviction now using
> > __GFP_RETRY_MAYFAIL it is also more likely to occur. Convert -ENOMEM
> > from the eviction to -EAGAIN so that the device stays active and
> > runtime suspend is retried at a later idle transition.
> > 
> > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> > Cc: Matthew Brost <matthew.brost@intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: intel-xe@lists.freedesktop.org
> > Cc: <stable@vger.kernel.org> # v6.8+
> > Assisted-by: LLM
> > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_pm.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> > index daa7ba2df317..9bf57ed1ea59 100644
> > --- a/drivers/gpu/drm/xe/xe_pm.c
> > +++ b/drivers/gpu/drm/xe/xe_pm.c
> > @@ -649,8 +649,16 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
> >  
> >  	if (xe->d3cold.allowed) {
> >  		err = xe_bo_evict_all(xe);
> > -		if (err)
> > +		if (err) {
> > +			/*
> > +			 * Runtime PM treats errors other than -EAGAIN and
> > +			 * -EBUSY as fatal, so report memory shortage as
> > +			 * transient to allow a later retry.
> > +			 */
> > +			if (err == -ENOMEM)
> > +				err = -EAGAIN;
> 
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> 
> >  			goto out_resume;
> > +		}
> >  	}
> >  
> >  	for_each_gt(gt, xe, id) {
> > -- 
> > 2.56.0
> > 

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

* Re: [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM
  2026-10-20 16:08   ` Matthew Brost
@ 2026-10-20 20:19     ` Rodrigo Vivi
  2026-10-21 15:19       ` Thomas Hellström
  0 siblings, 1 reply; 5+ messages in thread
From: Rodrigo Vivi @ 2026-10-20 20:19 UTC (permalink / raw)
  To: Matthew Brost; +Cc: Thomas Hellström, intel-xe, stable

On Tue, Oct 20, 2026 at 09:08:43AM -0700, Matthew Brost wrote:
> On Tue, Oct 20, 2026 at 09:35:20AM -0400, Rodrigo Vivi wrote:
> > On Tue, Oct 20, 2026 at 12:05:45PM +0200, Thomas Hellström wrote:
> > > If evicting VRAM to system memory fails with -ENOMEM during runtime
> > > suspend to D3cold, the error is returned to the runtime PM core.
> > > Runtime PM treats any error other than -EAGAIN or -EBUSY from the
> > > ->runtime_suspend() callback as fatal, records it in
> > > dev->power.runtime_error, and refuses further runtime PM operations
> > > on the device until the error is cleared.
> > 
> > oh!
> > 
> 
> I'm poked around core PM code but had a hard time verifying the above
> claim is correct.
> 
> Any code references to help me verify this is correct?

drivers/base/power/runtime.c
rpm_callback()

if (retval != -EAGAIN && retval != -EBUSY)
                 dev->power.runtime_error = retval;

that prevents new calls while this is not cleared.

> 
> Matt
> 
> > > 
> > > Memory shortage is a transient condition, and with eviction now using
> > > __GFP_RETRY_MAYFAIL it is also more likely to occur. Convert -ENOMEM
> > > from the eviction to -EAGAIN so that the device stays active and
> > > runtime suspend is retried at a later idle transition.
> > > 
> > > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> > > Cc: Matthew Brost <matthew.brost@intel.com>
> > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > Cc: intel-xe@lists.freedesktop.org
> > > Cc: <stable@vger.kernel.org> # v6.8+
> > > Assisted-by: LLM
> > > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/xe/xe_pm.c | 10 +++++++++-
> > >  1 file changed, 9 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> > > index daa7ba2df317..9bf57ed1ea59 100644
> > > --- a/drivers/gpu/drm/xe/xe_pm.c
> > > +++ b/drivers/gpu/drm/xe/xe_pm.c
> > > @@ -649,8 +649,16 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
> > >  
> > >  	if (xe->d3cold.allowed) {
> > >  		err = xe_bo_evict_all(xe);
> > > -		if (err)
> > > +		if (err) {
> > > +			/*
> > > +			 * Runtime PM treats errors other than -EAGAIN and
> > > +			 * -EBUSY as fatal, so report memory shortage as
> > > +			 * transient to allow a later retry.
> > > +			 */
> > > +			if (err == -ENOMEM)
> > > +				err = -EAGAIN;
> > 
> > Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > 
> > >  			goto out_resume;
> > > +		}
> > >  	}
> > >  
> > >  	for_each_gt(gt, xe, id) {
> > > -- 
> > > 2.56.0
> > > 

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

* Re: [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM
  2026-10-20 20:19     ` Rodrigo Vivi
@ 2026-10-21 15:19       ` Thomas Hellström
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Hellström @ 2026-10-21 15:19 UTC (permalink / raw)
  To: Rodrigo Vivi, Matthew Brost; +Cc: intel-xe, stable

On Tue, 2026-10-20 at 16:19 -0400, Rodrigo Vivi wrote:
> On Tue, Oct 20, 2026 at 09:08:43AM -0700, Matthew Brost wrote:
> > On Tue, Oct 20, 2026 at 09:35:20AM -0400, Rodrigo Vivi wrote:
> > > On Tue, Oct 20, 2026 at 12:05:45PM +0200, Thomas Hellström wrote:
> > > > If evicting VRAM to system memory fails with -ENOMEM during
> > > > runtime
> > > > suspend to D3cold, the error is returned to the runtime PM
> > > > core.
> > > > Runtime PM treats any error other than -EAGAIN or -EBUSY from
> > > > the
> > > > ->runtime_suspend() callback as fatal, records it in
> > > > dev->power.runtime_error, and refuses further runtime PM
> > > > operations
> > > > on the device until the error is cleared.
> > > 
> > > oh!
> > > 
> > 
> > I'm poked around core PM code but had a hard time verifying the
> > above
> > claim is correct.
> > 
> > Any code references to help me verify this is correct?
> 
> drivers/base/power/runtime.c
> rpm_callback()
> 
> if (retval != -EAGAIN && retval != -EBUSY)
>                  dev->power.runtime_error = retval;
> 
> that prevents new calls while this is not cleared.

This patch needs a prereq change, since if we return -ENOMEM, there's
nothing that drops any allocated backup for pinned bos.

So will hold off this patch for a while since it increases the
likelyhood that this will happen.

/Thomas


> 
> > 
> > Matt
> > 
> > > > 
> > > > Memory shortage is a transient condition, and with eviction now
> > > > using
> > > > __GFP_RETRY_MAYFAIL it is also more likely to occur. Convert -
> > > > ENOMEM
> > > > from the eviction to -EAGAIN so that the device stays active
> > > > and
> > > > runtime suspend is retried at a later idle transition.
> > > > 
> > > > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for
> > > > Intel GPUs")
> > > > Cc: Matthew Brost <matthew.brost@intel.com>
> > > > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > > Cc: intel-xe@lists.freedesktop.org
> > > > Cc: <stable@vger.kernel.org> # v6.8+
> > > > Assisted-by: LLM
> > > > Signed-off-by: Thomas Hellström
> > > > <thomas.hellstrom@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/xe/xe_pm.c | 10 +++++++++-
> > > >  1 file changed, 9 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/xe/xe_pm.c
> > > > b/drivers/gpu/drm/xe/xe_pm.c
> > > > index daa7ba2df317..9bf57ed1ea59 100644
> > > > --- a/drivers/gpu/drm/xe/xe_pm.c
> > > > +++ b/drivers/gpu/drm/xe/xe_pm.c
> > > > @@ -649,8 +649,16 @@ int xe_pm_runtime_suspend(struct xe_device
> > > > *xe)
> > > >  
> > > >  	if (xe->d3cold.allowed) {
> > > >  		err = xe_bo_evict_all(xe);
> > > > -		if (err)
> > > > +		if (err) {
> > > > +			/*
> > > > +			 * Runtime PM treats errors other than
> > > > -EAGAIN and
> > > > +			 * -EBUSY as fatal, so report memory
> > > > shortage as
> > > > +			 * transient to allow a later retry.
> > > > +			 */
> > > > +			if (err == -ENOMEM)
> > > > +				err = -EAGAIN;
> > > 
> > > Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > 
> > > >  			goto out_resume;
> > > > +		}
> > > >  	}
> > > >  
> > > >  	for_each_gt(gt, xe, id) {
> > > > -- 
> > > > 2.56.0
> > > > 

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

end of thread, other threads:[~2026-10-21 15:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 10:05 [PATCH] drm/xe: Don't fail runtime suspend permanently on VRAM eviction -ENOMEM Thomas Hellström
2026-10-20 13:35 ` Rodrigo Vivi
2026-10-20 16:08   ` Matthew Brost
2026-10-20 20:19     ` Rodrigo Vivi
2026-10-21 15:19       ` 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