linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau: check ioctl command codes better
@ 2025-07-11  7:24 Arnd Bergmann
  2025-07-11 17:41 ` Danilo Krummrich
  2025-07-11 18:06 ` Danilo Krummrich
  0 siblings, 2 replies; 11+ messages in thread
From: Arnd Bergmann @ 2025-07-11  7:24 UTC (permalink / raw)
  To: Lyude Paul, Danilo Krummrich, David Airlie, Simona Vetter,
	Ben Skeggs
  Cc: Arnd Bergmann, Ben Skeggs, Timur Tabi, Dave Airlie,
	Thomas Zimmermann, dri-devel, nouveau, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

nouveau_drm_ioctl() only checks the _IOC_NR() bits in the DRM_NOUVEAU_NVIF
command, but ignores the type and direction bits, so any command with
'7' in the low eight bits gets passed into nouveau_abi16_ioctl() instead
of drm_ioctl().

Check for all the bits except the size that is handled inside of the handler.

Fixes: 27111a23d01c ("drm/nouveau: expose the full object/event interfaces to userspace")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 1527b801f013..506eeb44f0d4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1284,6 +1284,9 @@ nouveau_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
 };
 
+#define DRM_IOCTL_NOUVEAU_NVIV _IOC(_IOC_READ|_IOC_WRITE, DRM_IOCTL_BASE, \
+				    DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
+
 long
 nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -1297,14 +1300,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		return ret;
 	}
 
-	switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
-	case DRM_NOUVEAU_NVIF:
+	if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIV)
 		ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
-		break;
-	default:
+	else
 		ret = drm_ioctl(file, cmd, arg);
-		break;
-	}
 
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);
-- 
2.39.5


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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-11  7:24 [PATCH] drm/nouveau: check ioctl command codes better Arnd Bergmann
@ 2025-07-11 17:41 ` Danilo Krummrich
  2025-07-11 18:01   ` Arnd Bergmann
  2025-07-11 18:06 ` Danilo Krummrich
  1 sibling, 1 reply; 11+ messages in thread
From: Danilo Krummrich @ 2025-07-11 17:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Lyude Paul, David Airlie, Simona Vetter, Ben Skeggs,
	Arnd Bergmann, Ben Skeggs, Timur Tabi, Dave Airlie,
	Thomas Zimmermann, dri-devel, nouveau, linux-kernel

On Fri Jul 11, 2025 at 9:24 AM CEST, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> nouveau_drm_ioctl() only checks the _IOC_NR() bits in the DRM_NOUVEAU_NVIF
> command, but ignores the type and direction bits, so any command with
> '7' in the low eight bits gets passed into nouveau_abi16_ioctl() instead
> of drm_ioctl().
>
> Check for all the bits except the size that is handled inside of the handler.
>
> Fixes: 27111a23d01c ("drm/nouveau: expose the full object/event interfaces to userspace")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 1527b801f013..506eeb44f0d4 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1284,6 +1284,9 @@ nouveau_ioctls[] = {
>  	DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
>  };
>  
> +#define DRM_IOCTL_NOUVEAU_NVIV _IOC(_IOC_READ|_IOC_WRITE, DRM_IOCTL_BASE, \
> +				    DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)

Is there any intention behind NVIV vs NVIF? Indicator that size is not
considered?

> +
>  long
>  nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  {
> @@ -1297,14 +1300,10 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  		return ret;
>  	}
>  
> -	switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
> -	case DRM_NOUVEAU_NVIF:
> +	if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIV)
>  		ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
> -		break;
> -	default:
> +	else
>  		ret = drm_ioctl(file, cmd, arg);
> -		break;
> -	}
>  
>  	pm_runtime_mark_last_busy(dev->dev);
>  	pm_runtime_put_autosuspend(dev->dev);


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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-11 17:41 ` Danilo Krummrich
@ 2025-07-11 18:01   ` Arnd Bergmann
  0 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2025-07-11 18:01 UTC (permalink / raw)
  To: Danilo Krummrich, Arnd Bergmann
  Cc: Lyude Paul, Dave Airlie, Simona Vetter, bskeggs@redhat.com,
	Ben Skeggs, Timur Tabi, Dave Airlie, Thomas Zimmermann, dri-devel,
	nouveau@lists.freedesktop.org, linux-kernel

On Fri, Jul 11, 2025, at 19:41, Danilo Krummrich wrote:
> On Fri Jul 11, 2025 at 9:24 AM CEST, Arnd Bergmann wrote:
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> index 1527b801f013..506eeb44f0d4 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> @@ -1284,6 +1284,9 @@ nouveau_ioctls[] = {
>>  	DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
>>  };
>>  
>> +#define DRM_IOCTL_NOUVEAU_NVIV _IOC(_IOC_READ|_IOC_WRITE, DRM_IOCTL_BASE, \
>> +				    DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
>
> Is there any intention behind NVIV vs NVIF? Indicator that size is not
> considered?

No, just a typo, my mistake.

      Arnd

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-11  7:24 [PATCH] drm/nouveau: check ioctl command codes better Arnd Bergmann
  2025-07-11 17:41 ` Danilo Krummrich
@ 2025-07-11 18:06 ` Danilo Krummrich
  1 sibling, 0 replies; 11+ messages in thread
From: Danilo Krummrich @ 2025-07-11 18:06 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Lyude Paul, David Airlie, Simona Vetter, Ben Skeggs,
	Arnd Bergmann, Ben Skeggs, Timur Tabi, Dave Airlie,
	Thomas Zimmermann, dri-devel, nouveau, linux-kernel

On Fri Jul 11, 2025 at 9:24 AM CEST, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> nouveau_drm_ioctl() only checks the _IOC_NR() bits in the DRM_NOUVEAU_NVIF
> command, but ignores the type and direction bits, so any command with
> '7' in the low eight bits gets passed into nouveau_abi16_ioctl() instead
> of drm_ioctl().
>
> Check for all the bits except the size that is handled inside of the handler.
>
> Fixes: 27111a23d01c ("drm/nouveau: expose the full object/event interfaces to userspace")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to drm-misc-fixes, thanks!

  [ Fix up two checkpatch warnings and a typo. - Danilo ]

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
@ 2025-07-21 12:22 Satadru Pramanik
  2025-07-21 12:37 ` Arnd Bergmann
  2025-07-22 10:29 ` Chris Bainbridge
  0 siblings, 2 replies; 11+ messages in thread
From: Satadru Pramanik @ 2025-07-21 12:22 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: airlied, airlied, arnd, bskeggs, bskeggs, open list:DRM DRIVERS,
	open list, Lyude Paul, nouveau, simona, ttabi, Thomas Zimmermann,
	Satadru Pramanik

Hello all,

I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
nouveau drivers on my machine.

glxinfo -B reports that I'm using llvmpipe.

Reverting this in 6.16-rc7 restores nouveau acceleration, and glxinfo
then reports: "OpenGL renderer string: NVE7"

inxi -G
Graphics:
  Device-1: NVIDIA GK107M [GeForce GT 750M Mac Edition] driver: nouveau
    v: kernel
  Display: wayland server: X.Org v: 24.1.8 with: Xwayland v: 24.1.8
    compositor: gnome-shell v: 48.0 driver: X: loaded: modesetting
    unloaded: fbdev,vesa dri: nouveau gpu: nouveau resolution: 2880x1800~60Hz
  API: EGL v: 1.5 drivers: nouveau,swrast
    platforms: gbm,wayland,x11,surfaceless,device
  API: OpenGL v: 4.5 compat-v: 4.3 vendor: mesa
    v: 25.2.0~rc1+git2507191056.03f67b52319~p~mesarc0 renderer: NVE7
  API: Vulkan v: 1.4.304 drivers: N/A surfaces: xcb,xlib,wayland
  Info: Tools: api: eglinfo, glxinfo, vulkaninfo x11: xdriinfo, xdpyinfo,
    xprop, xrandr

Best,
Satadru Pramanik

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-21 12:22 Satadru Pramanik
@ 2025-07-21 12:37 ` Arnd Bergmann
       [not found]   ` <CAFrh3J-SpU03=Kgi8vj1XLsMfruQyF1Rew6L2+aYUgZnkTLJAw@mail.gmail.com>
  2025-07-22 10:29 ` Chris Bainbridge
  1 sibling, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2025-07-21 12:37 UTC (permalink / raw)
  To: Satadru Pramanik, Arnd Bergmann
  Cc: Dave Airlie, Dave Airlie, Ben Skeggs, bskeggs@redhat.com,
	open list:DRM DRIVERS, open list, Lyude Paul,
	nouveau@lists.freedesktop.org, Simona Vetter, Timur Tabi,
	Thomas Zimmermann

On Mon, Jul 21, 2025, at 14:22, Satadru Pramanik wrote:
> Hello all,
>
> I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
> nouveau drivers on my machine.
>
> glxinfo -B reports that I'm using llvmpipe.

Thanks for the report!  Can you run the failing command with
'strace -f -o logfile.txt -e trace=ioctl ...' to see which command
it tries?

Either I made a stupid mistake in my patch and don't catch the
intended command any more, or the command that gets sent is actually
different from the one that the kernel expects.

      Arnd

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
       [not found]   ` <CAFrh3J-SpU03=Kgi8vj1XLsMfruQyF1Rew6L2+aYUgZnkTLJAw@mail.gmail.com>
@ 2025-07-21 13:50     ` Arnd Bergmann
  2025-07-21 15:23       ` Satadru Pramanik
  0 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2025-07-21 13:50 UTC (permalink / raw)
  To: Satadru Pramanik
  Cc: Dave Airlie, Dave Airlie, Ben Skeggs, bskeggs, bskeggs,
	open list:DRM DRIVERS, open list, Lyude Paul, nouveau, nouveau,
	Simona Vetter, Timur Tabi, Thomas Zimmermann

On Mon, Jul 21, 2025, at 14:50, Satadru Pramanik wrote:
> Sure!
>
> Here you go.
>
> The command I ran was 'glxinfo -B'
>
> diff glxinfo_working.txt glxinfo_broken.txt

Unfortunately, the 'diff' output makes this a little harder,
try 'diff -u' next time. I suppose passing "-X raw" to strace
would also help since the ioctl commands are heavily overloaded.

> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x48), 0x7ffc5a254340) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0x88),
> 0x7ffc5a254390) = 0

I think this is where it goes wrong first: (0x64, 0x47)
is the correct type and number for NVIF, but after my patch
I only accept the _IOC_READ|_IOC_WRITE caller but not _IOC_WRITE.

> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254250) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0

> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0

More of the same

> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)

This one manages to actually overload a command from another
driver, but DRM_IOCTL_XE_EXEC_QUEUE_DESTROY happens to also work
out to _IOC(_IOC_WRITE, 0x64, 0x47, 0x18).

Obviously these commands still need to be supported, so we need
to (at least) allow both _IOC_READ and _IOC_READ|_IOC_WRITE versions
of it.

Maintainers, do you prefer to just revert back to the original
version, or should we do another round that allows exactly the
necessary commands?

It does get pretty ugly at that point, and is not that far off
the origial version, with only really the _IOC_TYPE check remaining:

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 7bb64fcdd497..8bc61dfe7d9d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -1284,7 +1284,7 @@ nouveau_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
 };
 
-#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_READ | _IOC_WRITE, DRM_IOCTL_BASE, \
+#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_WRITE, DRM_IOCTL_BASE, \
 				    DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
 
 long
@@ -1300,7 +1300,7 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 		return ret;
 	}
 
-	if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIF)
+	if ((cmd & ~(IOCSIZE_MASK | IOC_OUT) == DRM_IOCTL_NOUVEAU_NVIF)
 		ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
 	else
 		ret = drm_ioctl(file, cmd, arg);

    Arnd

-----
(full quote below, as the reply was off-list)

> 1,129c1,20
> < 10221 ioctl(4, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> < 10221 ioctl(4, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> < 10221 ioctl(4, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254e20) =
> 0
> < 10221 ioctl(4, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254e20) =
> 0
> < 10221 ioctl(5, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> < 10221 ioctl(5, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> < 10221 ioctl(5, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254340) =
> 0
> < 10221 ioctl(5, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254340) =
> 0
> < 10221 ioctl(6, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> < 10221 ioctl(6, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x48), 0x7ffc5a254340) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0x88),
> 0x7ffc5a254390) = 0
> < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254330) =
> 0
> < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254330) =
> 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_CHANNEL_ALLOC, 0x7ffc5a2541b0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a2541c0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254210) =
> 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254250) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a2541e0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a2542a0) =
> 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> 0x7ffc5a254200) = 0
> < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254230) = 0
> < 10221 ioctl(6, DRM_IOCTL_GET_CAP, 0x7ffc5a254270) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a2549f0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a2548f0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254a10) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a2546c0) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254a10) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254a40) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254a30) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254c70) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254ba0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254c80) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254730) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254a30) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254a60) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254a50) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254c70) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254ba0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254c80) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254730) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254f70) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254ee0) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254e10) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254ef0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f30) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f30) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)
> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)
> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)
> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)
> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)
> < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> EBADF (Bad file descriptor)
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_CHANNEL_FREE, 0x7ffc5a2550b8) = 0
> < 10222 +++ exited with 0 +++
> < 10221 +++ exited with 0 +++
> ---
>> 5236  ioctl(4, UDMABUF_CREATE, 0x7fffd017e990) = 6
>> 5236  ioctl(6, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, 0x7fffd017ea00) = 0
>> 5252  +++ exited with 0 +++
>> 5251  +++ exited with 0 +++
>> 5249  +++ exited with 0 +++
>> 5248  +++ exited with 0 +++
>> 5250  +++ exited with 0 +++
>> 5247  +++ exited with 0 +++
>> 5246  +++ exited with 0 +++
>> 5245  +++ exited with 0 +++
>> 5237  +++ exited with 0 +++
>> 5238  +++ exited with 0 +++
>> 5239  +++ exited with 0 +++
>> 5240  +++ exited with 0 +++
>> 5241  +++ exited with 0 +++
>> 5242  +++ exited with 0 +++
>> 5243  +++ exited with 0 +++
>> 5244  +++ exited with 0 +++
>> 5253  +++ exited with 0 +++
>> 5236  +++ exited with 0 +++
>
> On Mon, Jul 21, 2025 at 8:38 AM Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> On Mon, Jul 21, 2025, at 14:22, Satadru Pramanik wrote:
>> > Hello all,
>> >
>> > I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
>> > nouveau drivers on my machine.
>> >
>> > glxinfo -B reports that I'm using llvmpipe.
>>
>> Thanks for the report!  Can you run the failing command with
>> 'strace -f -o logfile.txt -e trace=ioctl ...' to see which command
>> it tries?
>>
>> Either I made a stupid mistake in my patch and don't catch the
>> intended command any more, or the command that gets sent is actually
>> different from the one that the kernel expects.
>>
>>       Arnd
>
> Attachments:
> * glxinfo_working.txt
> * glxinfo_broken.txt

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-21 13:50     ` Arnd Bergmann
@ 2025-07-21 15:23       ` Satadru Pramanik
  0 siblings, 0 replies; 11+ messages in thread
From: Satadru Pramanik @ 2025-07-21 15:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Dave Airlie, Dave Airlie, Ben Skeggs, bskeggs,
	open list:DRM DRIVERS, open list, Lyude Paul, nouveau,
	Simona Vetter, Timur Tabi, Thomas Zimmermann

[-- Attachment #1: Type: text/plain, Size: 18787 bytes --]

Unfortunately, that doesn't seem to fix the issue.

glxinfo -B still shows llvmpipe being used, just like on stock 6.16-rc7:
glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: llvmpipe (LLVM 19.1.7, 256 bits) (0xffffffff)
    Version: 25.2.0
    Accelerated: no
    Video memory: 15388MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 0 MB, largest block: 0 MB
    VBO free aux. memory - total: 12389 MB, largest block: 12389 MB
    Texture free memory - total: 0 MB, largest block: 0 MB
    Texture free aux. memory - total: 12389 MB, largest block: 12389 MB
    Renderbuffer free memory - total: 0 MB, largest block: 0 MB
    Renderbuffer free aux. memory - total: 12389 MB, largest block: 12389 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 0 MB
    Total available memory: 15388 MB
    Currently available dedicated video memory: 0 MB
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 19.1.7, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa
25.2.0~rc1+git2507191056.03f67b52319~p~mesarc0
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa
25.2.0~rc1+git2507191056.03f67b52319~p~mesarc0
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa
25.2.0~rc1+git2507191056.03f67b52319~p~mesarc0
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

I ran `strace -f -o glxinfo_after_new_patch.txt -e trace=ioctl -X raw
glxinfo -B` to get the output attached.

I also ran `strace -f -o glxinfo_after_new_patch_no_X.txt -e
trace=ioctl glxinfo -B` and that output is also attached.

(This latter output is substantially the same as the output from
running this on stock 6.16-rc7.)

I'm happy to test any other patches.

Best,

Satadru

On Mon, Jul 21, 2025 at 9:50 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Mon, Jul 21, 2025, at 14:50, Satadru Pramanik wrote:
> > Sure!
> >
> > Here you go.
> >
> > The command I ran was 'glxinfo -B'
> >
> > diff glxinfo_working.txt glxinfo_broken.txt
>
> Unfortunately, the 'diff' output makes this a little harder,
> try 'diff -u' next time. I suppose passing "-X raw" to strace
> would also help since the ioctl commands are heavily overloaded.
>
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x48), 0x7ffc5a254340) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0x88),
> > 0x7ffc5a254390) = 0
>
> I think this is where it goes wrong first: (0x64, 0x47)
> is the correct type and number for NVIF, but after my patch
> I only accept the _IOC_READ|_IOC_WRITE caller but not _IOC_WRITE.
>
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254250) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
>
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
>
> More of the same
>
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
>
> This one manages to actually overload a command from another
> driver, but DRM_IOCTL_XE_EXEC_QUEUE_DESTROY happens to also work
> out to _IOC(_IOC_WRITE, 0x64, 0x47, 0x18).
>
> Obviously these commands still need to be supported, so we need
> to (at least) allow both _IOC_READ and _IOC_READ|_IOC_WRITE versions
> of it.
>
> Maintainers, do you prefer to just revert back to the original
> version, or should we do another round that allows exactly the
> necessary commands?
>
> It does get pretty ugly at that point, and is not that far off
> the origial version, with only really the _IOC_TYPE check remaining:
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 7bb64fcdd497..8bc61dfe7d9d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -1284,7 +1284,7 @@ nouveau_ioctls[] = {
>         DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
>  };
>
> -#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_READ | _IOC_WRITE, DRM_IOCTL_BASE, \
> +#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_WRITE, DRM_IOCTL_BASE, \
>                                     DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
>
>  long
> @@ -1300,7 +1300,7 @@ nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>                 return ret;
>         }
>
> -       if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIF)
> +       if ((cmd & ~(IOCSIZE_MASK | IOC_OUT) == DRM_IOCTL_NOUVEAU_NVIF)
>                 ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
>         else
>                 ret = drm_ioctl(file, cmd, arg);
>
>     Arnd
>
> -----
> (full quote below, as the reply was off-list)
>
> > 1,129c1,20
> > < 10221 ioctl(4, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> > < 10221 ioctl(4, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> > < 10221 ioctl(4, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254e20) =
> > 0
> > < 10221 ioctl(4, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254e20) =
> > 0
> > < 10221 ioctl(5, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> > < 10221 ioctl(5, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> > < 10221 ioctl(5, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254340) =
> > 0
> > < 10221 ioctl(5, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254340) =
> > 0
> > < 10221 ioctl(6, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> > < 10221 ioctl(6, DRM_IOCTL_VERSION, 0x5564c66a4e50) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x48), 0x7ffc5a254340) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0x88),
> > 0x7ffc5a254390) = 0
> > < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254330) =
> > 0
> > < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254330) =
> > 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_CHANNEL_ALLOC, 0x7ffc5a2541b0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a2541c0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254110) = 0
> > < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a254210) =
> > 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254250) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a2541e0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> > < 10221 ioctl(6, DRM_IOCTL_ETNAVIV_GET_PARAM or
> > DRM_IOCTL_EXYNOS_GEM_CREATE or DRM_IOCTL_IVPU_GET_PARAM or
> > DRM_IOCTL_LIMA_GET_PARAM or DRM_IOCTL_NOUVEAU_GETPARAM or
> > DRM_IOCTL_OMAP_GET_PARAM or DRM_IOCTL_PVR_DEV_QUERY or
> > DRM_IOCTL_QAIC_MANAGE or DRM_IOCTL_TEGRA_GEM_CREATE, 0x7ffc5a2542a0) =
> > 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254260) = 0
> > < 10221 ioctl(6, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x47, 0xa0),
> > 0x7ffc5a254200) = 0
> > < 10221 ioctl(6, _IOC(_IOC_WRITE, 0x64, 0x47, 0x38), 0x7ffc5a254240) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254230) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GET_CAP, 0x7ffc5a254270) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a2549f0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254940) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a2548f0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254a10) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a2546c0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a2547a8) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254a10) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254960) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254a40) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254a30) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254c70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254ba0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254c80) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254730) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254a30) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254980) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_CPU_PREP, 0x7ffc5a254a60) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254a50) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254c70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254ba0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254c80) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254cc0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254d00) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254730) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_PRIME_HANDLE_TO_FD, 0x7ffc5a254818) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254f70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254ee0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_NEW, 0x7ffc5a254e10) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_GEM_PUSHBUF, 0x7ffc5a254ef0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f30) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f30) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a254f70) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a2550b0) = 0
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
> > < 10221 ioctl(7, DRM_IOCTL_XE_EXEC_QUEUE_DESTROY, 0x7ffc5a2550e0) = -1
> > EBADF (Bad file descriptor)
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> > < 10221 ioctl(6, DRM_IOCTL_GEM_CLOSE, 0x7ffc5a255060) = 0
> > < 10221 ioctl(6, DRM_IOCTL_NOUVEAU_CHANNEL_FREE, 0x7ffc5a2550b8) = 0
> > < 10222 +++ exited with 0 +++
> > < 10221 +++ exited with 0 +++
> > ---
> >> 5236  ioctl(4, UDMABUF_CREATE, 0x7fffd017e990) = 6
> >> 5236  ioctl(6, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, 0x7fffd017ea00) = 0
> >> 5252  +++ exited with 0 +++
> >> 5251  +++ exited with 0 +++
> >> 5249  +++ exited with 0 +++
> >> 5248  +++ exited with 0 +++
> >> 5250  +++ exited with 0 +++
> >> 5247  +++ exited with 0 +++
> >> 5246  +++ exited with 0 +++
> >> 5245  +++ exited with 0 +++
> >> 5237  +++ exited with 0 +++
> >> 5238  +++ exited with 0 +++
> >> 5239  +++ exited with 0 +++
> >> 5240  +++ exited with 0 +++
> >> 5241  +++ exited with 0 +++
> >> 5242  +++ exited with 0 +++
> >> 5243  +++ exited with 0 +++
> >> 5244  +++ exited with 0 +++
> >> 5253  +++ exited with 0 +++
> >> 5236  +++ exited with 0 +++
> >
> > On Mon, Jul 21, 2025 at 8:38 AM Arnd Bergmann <arnd@arndb.de> wrote:
> >>
> >> On Mon, Jul 21, 2025, at 14:22, Satadru Pramanik wrote:
> >> > Hello all,
> >> >
> >> > I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
> >> > nouveau drivers on my machine.
> >> >
> >> > glxinfo -B reports that I'm using llvmpipe.
> >>
> >> Thanks for the report!  Can you run the failing command with
> >> 'strace -f -o logfile.txt -e trace=ioctl ...' to see which command
> >> it tries?
> >>
> >> Either I made a stupid mistake in my patch and don't catch the
> >> intended command any more, or the command that gets sent is actually
> >> different from the one that the kernel expects.
> >>
> >>       Arnd
> >
> > Attachments:
> > * glxinfo_working.txt
> > * glxinfo_broken.txt

[-- Attachment #2: glxinfo_after_new_patch.txt --]
[-- Type: text/plain, Size: 598 bytes --]

5098  ioctl(4, 0x40187542, 0x7ffdf49c6540) = 6
5098  ioctl(6, 0xc0086202, 0x7ffdf49c65b0) = 0
5110  +++ exited with 0 +++
5114  +++ exited with 0 +++
5111  +++ exited with 0 +++
5109  +++ exited with 0 +++
5113  +++ exited with 0 +++
5112  +++ exited with 0 +++
5108  +++ exited with 0 +++
5107  +++ exited with 0 +++
5099  +++ exited with 0 +++
5101  +++ exited with 0 +++
5100  +++ exited with 0 +++
5102  +++ exited with 0 +++
5103  +++ exited with 0 +++
5104  +++ exited with 0 +++
5105  +++ exited with 0 +++
5106  +++ exited with 0 +++
5115  +++ exited with 0 +++
5098  +++ exited with 0 +++

[-- Attachment #3: new_nouveau.patch --]
[-- Type: text/x-patch, Size: 901 bytes --]

diff -Npaur a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c	2025-07-21 10:31:33.191428569 -0400
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c	2025-07-21 10:33:25.371736507 -0400
@@ -1284,7 +1284,7 @@ nouveau_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(NOUVEAU_EXEC, nouveau_exec_ioctl_exec, DRM_RENDER_ALLOW),
 };
 
-#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_READ | _IOC_WRITE, DRM_IOCTL_BASE, \
+#define DRM_IOCTL_NOUVEAU_NVIF _IOC(_IOC_WRITE, DRM_IOCTL_BASE, \
 				    DRM_COMMAND_BASE + DRM_NOUVEAU_NVIF, 0)
 
 long
@@ -1300,7 +1300,7 @@ nouveau_drm_ioctl(struct file *file, uns
 		return ret;
 	}
 
-	if ((cmd & ~IOCSIZE_MASK) == DRM_IOCTL_NOUVEAU_NVIF)
+	if ((cmd & ~IOCSIZE_MASK | IOC_OUT) == DRM_IOCTL_NOUVEAU_NVIF)
 		ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
 	else
 		ret = drm_ioctl(file, cmd, arg);

[-- Attachment #4: glxinfo_after_new_patch_no_X.txt --]
[-- Type: text/plain, Size: 622 bytes --]

6412  ioctl(4, UDMABUF_CREATE, 0x7ffe9d5c4440) = 6
6412  ioctl(6, DMA_BUF_IOCTL_EXPORT_SYNC_FILE, 0x7ffe9d5c44b0) = 0
6428  +++ exited with 0 +++
6425  +++ exited with 0 +++
6426  +++ exited with 0 +++
6423  +++ exited with 0 +++
6427  +++ exited with 0 +++
6422  +++ exited with 0 +++
6424  +++ exited with 0 +++
6421  +++ exited with 0 +++
6413  +++ exited with 0 +++
6414  +++ exited with 0 +++
6415  +++ exited with 0 +++
6417  +++ exited with 0 +++
6418  +++ exited with 0 +++
6416  +++ exited with 0 +++
6419  +++ exited with 0 +++
6420  +++ exited with 0 +++
6429  +++ exited with 0 +++
6412  +++ exited with 0 +++

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-21 12:22 Satadru Pramanik
  2025-07-21 12:37 ` Arnd Bergmann
@ 2025-07-22 10:29 ` Chris Bainbridge
  2025-07-22 10:52   ` Arnd Bergmann
  1 sibling, 1 reply; 11+ messages in thread
From: Chris Bainbridge @ 2025-07-22 10:29 UTC (permalink / raw)
  To: Satadru Pramanik
  Cc: Arnd Bergmann, airlied, airlied, arnd, bskeggs, bskeggs,
	open list:DRM DRIVERS, open list, Lyude Paul, nouveau, simona,
	ttabi, Thomas Zimmermann, regressions

On Mon, Jul 21, 2025 at 08:22:48AM -0400, Satadru Pramanik wrote:
> Hello all,
> 
> I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
> nouveau drivers on my machine.
> 
> glxinfo -B reports that I'm using llvmpipe.
> 
> Reverting this in 6.16-rc7 restores nouveau acceleration, and glxinfo
> then reports: "OpenGL renderer string: NVE7"
> 
> inxi -G
> Graphics:
>   Device-1: NVIDIA GK107M [GeForce GT 750M Mac Edition] driver: nouveau
>     v: kernel
>   Display: wayland server: X.Org v: 24.1.8 with: Xwayland v: 24.1.8
>     compositor: gnome-shell v: 48.0 driver: X: loaded: modesetting
>     unloaded: fbdev,vesa dri: nouveau gpu: nouveau resolution: 2880x1800~60Hz
>   API: EGL v: 1.5 drivers: nouveau,swrast
>     platforms: gbm,wayland,x11,surfaceless,device
>   API: OpenGL v: 4.5 compat-v: 4.3 vendor: mesa
>     v: 25.2.0~rc1+git2507191056.03f67b52319~p~mesarc0 renderer: NVE7
>   API: Vulkan v: 1.4.304 drivers: N/A surfaces: xcb,xlib,wayland
>   Info: Tools: api: eglinfo, glxinfo, vulkaninfo x11: xdriinfo, xdpyinfo,
>     xprop, xrandr
> 
> Best,
> Satadru Pramanik

I also bisected an issue to this commit. On my laptop, this commit
results in an intermittent desktop crash (Xorg segfault) when changing
display scale, which can be more reliably reproduced with:

for x in {1..100}; do
  xrandr --output eDP-1 --mode 2560x1600 --scale 0.5 --filter nearest
  xrandr --output eDP-1 --mode 2560x1600 --scale 1 --filter nearest
done

I also see the same glxinfo llvmpipe change that Satadru reported.
Reverting the commit fixes my scale test case, and also the glxinfo
renderer.

#regzbot introduced: e5478166dffb51fa64e76cdbb5c24421f22f2d43 ^
#regzbot title: nouveau hardware acceleration broken

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-22 10:29 ` Chris Bainbridge
@ 2025-07-22 10:52   ` Arnd Bergmann
  2025-07-22 11:45     ` Danilo Krummrich
  0 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2025-07-22 10:52 UTC (permalink / raw)
  To: Chris Bainbridge, Satadru Pramanik
  Cc: Arnd Bergmann, Dave Airlie, Dave Airlie, Ben Skeggs,
	bskeggs@redhat.com, open list:DRM DRIVERS, open list, Lyude Paul,
	nouveau@lists.freedesktop.org, Simona Vetter, Timur Tabi,
	Thomas Zimmermann, regressions

On Tue, Jul 22, 2025, at 12:29, Chris Bainbridge wrote:
> On Mon, Jul 21, 2025 at 08:22:48AM -0400, Satadru Pramanik wrote:
>> Hello all,
>> 
>> I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
>> nouveau drivers on my machine.
>> 
>> glxinfo -B reports that I'm using llvmpipe.
>> 
>> Reverting this in 6.16-rc7 restores nouveau acceleration, and glxinfo
>> then reports: "OpenGL renderer string: NVE7"
>
> I also bisected an issue to this commit. On my laptop, this commit
> results in an intermittent desktop crash (Xorg segfault) when changing
> display scale, which can be more reliably reproduced with:
>
> for x in {1..100}; do
>   xrandr --output eDP-1 --mode 2560x1600 --scale 0.5 --filter nearest
>   xrandr --output eDP-1 --mode 2560x1600 --scale 1 --filter nearest
> done
>

I won't have time to work on fixing my patch before the merge window,
let's just revert it.

      Arnd

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

* Re: [PATCH] drm/nouveau: check ioctl command codes better
  2025-07-22 10:52   ` Arnd Bergmann
@ 2025-07-22 11:45     ` Danilo Krummrich
  0 siblings, 0 replies; 11+ messages in thread
From: Danilo Krummrich @ 2025-07-22 11:45 UTC (permalink / raw)
  To: Arnd Bergmann, Satadru Pramanik
  Cc: Chris Bainbridge, Arnd Bergmann, Dave Airlie, Dave Airlie,
	Ben Skeggs, open list:DRM DRIVERS, open list, Lyude Paul,
	nouveau@lists.freedesktop.org, Simona Vetter, Timur Tabi,
	Thomas Zimmermann, regressions

On 7/22/25 12:52 PM, Arnd Bergmann wrote:
> On Tue, Jul 22, 2025, at 12:29, Chris Bainbridge wrote:
>> On Mon, Jul 21, 2025 at 08:22:48AM -0400, Satadru Pramanik wrote:
>>> Hello all,
>>>
>>> I suspect this commit in 6.16-rc7 has broken acceleration with Mesa's
>>> nouveau drivers on my machine.

Thanks for the report!

Please make sure to keep maintainers in the loop, for some reason I was removed
from the recipient list for this regression report.

>>>
>>> glxinfo -B reports that I'm using llvmpipe.
>>>
>>> Reverting this in 6.16-rc7 restores nouveau acceleration, and glxinfo
>>> then reports: "OpenGL renderer string: NVE7"
>>
>> I also bisected an issue to this commit. On my laptop, this commit
>> results in an intermittent desktop crash (Xorg segfault) when changing
>> display scale, which can be more reliably reproduced with:
>>
>> for x in {1..100}; do
>>    xrandr --output eDP-1 --mode 2560x1600 --scale 0.5 --filter nearest
>>    xrandr --output eDP-1 --mode 2560x1600 --scale 1 --filter nearest
>> done
>>
> 
> I won't have time to work on fixing my patch before the merge window,
> let's just revert it.

@Arnd: Yes, given the short timeframe I think that's the best. Can you please 
send the revert?

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

end of thread, other threads:[~2025-07-22 11:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11  7:24 [PATCH] drm/nouveau: check ioctl command codes better Arnd Bergmann
2025-07-11 17:41 ` Danilo Krummrich
2025-07-11 18:01   ` Arnd Bergmann
2025-07-11 18:06 ` Danilo Krummrich
  -- strict thread matches above, loose matches on Subject: below --
2025-07-21 12:22 Satadru Pramanik
2025-07-21 12:37 ` Arnd Bergmann
     [not found]   ` <CAFrh3J-SpU03=Kgi8vj1XLsMfruQyF1Rew6L2+aYUgZnkTLJAw@mail.gmail.com>
2025-07-21 13:50     ` Arnd Bergmann
2025-07-21 15:23       ` Satadru Pramanik
2025-07-22 10:29 ` Chris Bainbridge
2025-07-22 10:52   ` Arnd Bergmann
2025-07-22 11:45     ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).