[PATCH] drm/xe/debugfs: fixed the return value of wedged_mode_set

Rodrigo Vivi rodrigo.vivi at intel.com
Fri Feb 14 15:11:25 UTC 2025


On Thu, Feb 13, 2025 at 06:13:12PM -0500, Rodrigo Vivi wrote:
> On Fri, Feb 14, 2025 at 06:36:15AM +0800, Xin Wang wrote:
> > It is generally expected that the write() function should return a
> > positive value indicating the number of bytes written or a negative
> > error code if an error occurs. Returning 0 is unusual and can lead
> > to unexpected behavior.
> > 
> > When the user program writes the same value to wedged_mode twice in
> > a row, a lockup will occur, because the value expected to be
> > returned by the write() function inside the program should be equal
> > to the actual written value instead of 0.
> > 
> > To reproduce the issue:
> > echo 1 > /sys/kernel/debug/dri/0/wedged_mode
> > echo 1 > /sys/kernel/debug/dri/0/wedged_mode   <- lockup here
> > 
> > Signed-off-by: Xin Wang <x.wang at intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
> > Cc: Fei Yang <fei.yang at intel.com>
> > Cc: Shuicheng Lin <shuicheng.lin at intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_debugfs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> > index 56cb3788e752..b46075edf60a 100644
> > --- a/drivers/gpu/drm/xe/xe_debugfs.c
> > +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> > @@ -167,7 +167,7 @@ static ssize_t wedged_mode_set(struct file *f, const char __user *ubuf,
> >  		return -EINVAL;
> >  
> >  	if (xe->wedged.mode == wedged_mode)
> > -		return 0;
> > +		return size;
> 
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi at intel.com>

pushed to drm-xe-next. Thanks for the fix

> 
> >  
> >  	xe->wedged.mode = wedged_mode;
> >  
> > -- 
> > 2.43.0
> > 


More information about the Intel-xe mailing list