<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I am happy to use EOPNOTSUPP but I must point out that this is not the pattern used across the kernel, the standard is to use ENOTTY, which is also the default that fs/ioctl.c returns when no handler is present. Userspace tooling such as strace and glibc specifically
 expectect ENOTTY to indicate invalid or unsupported IOCTL.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Sent:</b> Tuesday, 8 July 2025 5:01 PM<br>
<b>To:</b> McRae, Geoffrey <Geoffrey.McRae@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH v2 1/1] drm/amdkfd: return -ENOTTY for unsupported IOCTLs</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 08.07.25 06:22, Geoffrey McRae wrote:<br>
> Some kfd ioctls may not be available depending on the kernel version the<br>
> user is running, as such we need to report -ENOTTY so userland can<br>
> determine the cause of the ioctl failure.<br>
<br>
In general sounds like a good idea, but ENOTTY is potentially a bit misleading.<br>
<br>
We usually use EOPNOTSUPP for that even if its not the original meaning of that error code.<br>
<br>
Regards,<br>
Christian.<br>
<br>
> <br>
> Signed-off-by: Geoffrey McRae <geoffrey.mcrae@amd.com><br>
> ---<br>
>  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 8 ++++++--<br>
>  1 file changed, 6 insertions(+), 2 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c<br>
> index a2149afa5803..36396b7318e7 100644<br>
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c<br>
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c<br>
> @@ -3253,8 +3253,10 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)<br>
>        int retcode = -EINVAL;<br>
>        bool ptrace_attached = false;<br>
>  <br>
> -     if (nr >= AMDKFD_CORE_IOCTL_COUNT)<br>
> +     if (nr >= AMDKFD_CORE_IOCTL_COUNT) {<br>
> +             retcode = -ENOTTY;<br>
>                goto err_i1;<br>
> +     }<br>
>  <br>
>        if ((nr >= AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) {<br>
>                u32 amdkfd_size;<br>
> @@ -3267,8 +3269,10 @@ static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)<br>
>                        asize = amdkfd_size;<br>
>  <br>
>                cmd = ioctl->cmd;<br>
> -     } else<br>
> +     } else {<br>
> +             retcode = -ENOTTY;<br>
>                goto err_i1;<br>
> +     }<br>
>  <br>
>        dev_dbg(kfd_device, "ioctl cmd 0x%x (#0x%x), arg 0x%lx\n", cmd, nr, arg);<br>
>  <br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>