Skip to contentSkip to conversation

Document Media Controller IOCTL number assignments

PATCH Superseded Sakari Ailus 2 participants 6 messages May 26, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sakari Ailus

author maintainer
#0 lore raw

cover Document Media Controller IOCTL number assignments

Hello all,

The Media Controller uses IOCTL numbers with '|' type up to 0x81 but the range from 0x80 upwards is documented to belong to samples. The samples, however, are not currently using these values. Solve the problem by bumping the top of the MC range and the samples allocation by 0x10.

Some sample code in samples/rust/rust_misc_device.rs also uses MC IOCTL numbers below the current limit 0x80, it'd be nice to address that as well as align with the changes in this patch.

Sakari Ailus (2):
Documentation: Bump media IOCTL reserved numbers
media: uapi: Document IOCTL number assignment

 Documentation/userspace-api/ioctl/ioctl-number.rst | 4 ++--
 include/uapi/linux/media.h                         | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 1/2 Documentation: Bump media IOCTL reserved numbers

The Media Controller uses IOCTL numbers up to 0x81. Given that nothing appears to be using them for other purposes, even in the samples allocation (checked with $ git grep "#define.*_IO.*'|'"), just reassign the numbers up to 0x8f to linux/media.h and bump the samples allocation by 0x10.

---
 Documentation/userspace-api/ioctl/ioctl-number.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/userspace-api/ioctl/ioctl-number.rst +2 -2
index bc91756bde73..6b3be3fb0b15 100644
@@ -312,8 +312,8 @@ Code  Seq#    Include File                                           Comments
 'z'   40-7F                                                          CAN bus card conflict!
                                                                      <mailto:[email protected]>
 'z'   10-4F  drivers/s390/crypto/zcrypt_api.h                        conflict!
-'|'   00-7F  linux/media.h
-'|'   80-9F  samples/                                                Any sample and example drivers
+'|'   00-8F  linux/media.h
+'|'   90-AF  samples/                                                Any sample and example drivers
 0x80  00-1F  linux/fb.h
 0x81  00-1F  linux/vduse.h
 0x89  00-06  arch/x86/include/asm/sockios.h
Signature · 1 line
2.39.5
author maintainer
#4 lore raw

PATCH 2/2 media: uapi: Document IOCTL number assignment

In reply to Sakari Ailus

Document MC IOCTL number assignment in linux/media.h. In the past the assignment up to 0x7f was missed so to prevent that from happening again, document the value here as well.

---
 include/uapi/linux/media.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/media.h +4 -0
index 1c80b1d6bbaf..2808132fcf49 100644
@@ -381,6 +381,10 @@ struct media_v2_topology {
  */
 #define MEDIA_REQUEST_IOC_QUEUE		_IO('|',  0x80)
 #define MEDIA_REQUEST_IOC_REINIT	_IO('|',  0x81)
+/*
+ * Don't allocate new IOCTL numbers past 0x8f, MC IOCTL number assignment ends
+ * there!
+ */
 
 #ifndef __KERNEL__
 
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] Documentation: Bump media IOCTL reserved numbers

In reply to Sakari Ailus

Hi Sakari,

Thank you for the patch.

Quoted 5 lines · Sakari Ailus

The Media Controller uses IOCTL numbers up to 0x81. Given that nothing appears to be using them for other purposes, even in the samples allocation (checked with $ git grep "#define.*_IO.*'|'"), just reassign the numbers up to 0x8f to linux/media.h and bump the samples allocation by 0x10.

The commit message should explain why. The explanation is in the cover letter, just move it to this patch. With that,

Quoted 20 lines
---
 Documentation/userspace-api/ioctl/ioctl-number.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/userspace-api/ioctl/ioctl-number.rst +2 -2
index bc91756bde73..6b3be3fb0b15 100644
@@ -312,8 +312,8 @@ Code  Seq#    Include File                                           Comments
 'z'   40-7F                                                          CAN bus card conflict!
                                                                      <mailto:[email protected]>
 'z'   10-4F  drivers/s390/crypto/zcrypt_api.h                        conflict!
-'|'   00-7F  linux/media.h
-'|'   80-9F  samples/                                                Any sample and example drivers
+'|'   00-8F  linux/media.h
+'|'   90-AF  samples/                                                Any sample and example drivers
 0x80  00-1F  linux/fb.h
 0x81  00-1F  linux/vduse.h
 0x89  00-06  arch/x86/include/asm/sockios.h
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] media: uapi: Document IOCTL number assignment

In reply to Sakari Ailus

Hi Sakari,

Thank you for the patch.

Quoted 5 lines · Sakari Ailus

Document MC IOCTL number assignment in linux/media.h. In the past the assignment up to 0x7f was missed so to prevent that from happening again, document the value here as well.

Quoted 19 lines
---
 include/uapi/linux/media.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/media.h +4 -0
index 1c80b1d6bbaf..2808132fcf49 100644
@@ -381,6 +381,10 @@ struct media_v2_topology {
  */
 #define MEDIA_REQUEST_IOC_QUEUE		_IO('|',  0x80)
 #define MEDIA_REQUEST_IOC_REINIT	_IO('|',  0x81)
+/*
+ * Don't allocate new IOCTL numbers past 0x8f, MC IOCTL number assignment ends
+ * there!
+ */
 
 #ifndef __KERNEL__
 
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#3 lore raw

Re: [PATCH 1/2] Documentation: Bump media IOCTL reserved numbers

In reply to Laurent Pinchart

Hi Laurent,

Quoted 3 lines · Laurent Pinchart

Hi Sakari,

Thank you for the patch.

Thank you for the review.

Quoted 8 lines · Sakari Ailus
Quoted 5 lines

The Media Controller uses IOCTL numbers up to 0x81. Given that nothing appears to be using them for other purposes, even in the samples allocation (checked with $ git grep "#define.*_IO.*'|'"), just reassign the numbers up to 0x8f to linux/media.h and bump the samples allocation by 0x10.

Quoted 4 lines

The commit message should explain why. The explanation is in the cover letter, just move it to this patch. With that,

I'll use this in v2:

The Media Controller uses IOCTL type '|' with numbers up to 0x81 while numbers from 0x80 onwards are allocated for samples, creating a conflict between allocations for MC and samples. Given that nothing appears to be using numbers between 0x80 and 0x8f for other purposes than MC, even in the samples allocation (checked with $ git grep "#define.*_IO.*'|'"), just reassign the numbers up to 0x8f to linux/media.h and bump the samples allocation by 0x10.

Quoted 22 lines
Quoted 21 lines
---
 Documentation/userspace-api/ioctl/ioctl-number.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/userspace-api/ioctl/ioctl-number.rst +2 -2
index bc91756bde73..6b3be3fb0b15 100644
@@ -312,8 +312,8 @@ Code  Seq#    Include File                                           Comments
 'z'   40-7F                                                          CAN bus card conflict!
                                                                      <mailto:[email protected]>
 'z'   10-4F  drivers/s390/crypto/zcrypt_api.h                        conflict!
-'|'   00-7F  linux/media.h
-'|'   80-9F  samples/                                                Any sample and example drivers
+'|'   00-8F  linux/media.h
+'|'   90-AF  samples/                                                Any sample and example drivers
 0x80  00-1F  linux/fb.h
 0x81  00-1F  linux/vduse.h
 0x89  00-06  arch/x86/include/asm/sockios.h
Signature · 3 lines
Regards,

Sakari Ailus