Skip to contentSkip to conversation

New IOCTLs

DISCUSSION Singaravelan Nallasellan 6 participants 8 messages Sep 17, 2008 – Dec 1, 2008

lore
Share & tools
lore
#0 lore raw

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.
Can somebody provide the reason behind the decision? Are there any better approach to implement the device control interface other than sysfs interface. I have some issues in using the sysfs interface. Thanks in advance.

#1 lore raw
Quoted 3 lines · On Wed, 17 Sep 2008 22:25:35 +0530 "Singaravelan Nallasellan"…

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.

I don't know who told you that but its not true.

#2 lore raw
In reply to Singaravelan Nallasellan
Quoted 3 lines · Singaravelan Nallasellan

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.

New IOCTL's are *not* in the "not accepting any new" state. However, there *will* be questioning whether a new IOCTL is the proper API, or if there should be some other interface instead (sysfs, debugfs, netlink, and so on).

The basic problem with IOCTLs is that they tend to quickly become ugly design, with little attention paid to things like proper 32/64 bit interfaces (what happens when a 32-bit program tries to pass a parameter to a 32-bit kernel, and to a 64-bit kernel?).

Maybe an ioctl is the right way to send your device control messages. Maybe some other API is better. What sort of messages need to be sent, and what sort of throughput/latency requirements are there, and so on? If you tell us more about what you're trying to get to/from userspace and the device, we can better suggest what to do...

#3 lore raw
In reply to Singaravelan Nallasellan
Quoted 7 lines · Singaravelan Nallasellan

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.
Can somebody provide the reason behind the decision? Are there any better approach to implement the device control interface other than sysfs interface. I have some issues in using the sysfs interface. Thanks in advance.

IOCTLs are discouraged, but not strictly forbidden. Is there something about sysfs that would make it an unsuitable interface, or are you just having trouble finding good documentation on using it?

-- Chris

#4 lore raw

Thank you for your response.

The driver needs to assign an id for each open and create a sysfs entry based on that id and expose some properties.

For example, if the driver assigns an id 2, the sysfs entry will be as below:
/sys/class/xxx/<drivername>/2/version

When the driver close is invoked, it will have to remove the entry.

The issue here is that the application needs:
1. To know the id it should use to access properties after the open.
2. To have exclusive access to the sysfs entries. No other application should and open the entry and use it. There is a chance the the other application could open the entries before this application opens it.

The driver allows multiple opens and assigns any random id.

I appreciate your suggestion on alternate ways to implement the functionality.

Quoted 16 lines · Chris Snook
Quoted 8 lines · Singaravelan Nallasellan

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.
Can somebody provide the reason behind the decision? Are there any better approach to implement the device control interface other than sysfs interface. I have some issues in using the sysfs interface. Thanks in advance.

IOCTLs are discouraged, but not strictly forbidden. Is there something about sysfs that would make it an unsuitable interface, or are you just having trouble finding good documentation on using it?

-- Chris

#5 lore raw
Quoted 16 lines · Singaravelan Nallasellan

Thank you for your response.

The driver needs to assign an id for each open and create a sysfs entry based on that id and expose some properties.

For example, if the driver assigns an id 2, the sysfs entry will be as below:
/sys/class/xxx/<drivername>/2/version

When the driver close is invoked, it will have to remove the entry.

The issue here is that the application needs:
1. To know the id it should use to access properties after the open.
2. To have exclusive access to the sysfs entries. No other application should and open the entry and use it. There is a chance the the other application could open the entries before this application opens it.

Quoted 3 lines

The driver allows multiple opens and assigns any random id.

I appreciate your suggestion on alternate ways to implement the functionality.

What about using configfs? A user could create an id using mkdir in the driver's configfs subsystem, and this would make the driver create the matching sysfs entry.

# mkdir /sys/kernel/config/<driver_subsys>/2
-> reserve id 2 for the caller, and create /sys/class/xxx/<drivername>/2

You could even put whatever configuration items inside configfs instead of sysfs.

Louis

Quoted 24 lines · Chris Snook
Quoted 10 lines
Quoted 8 lines · Singaravelan Nallasellan

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.
Can somebody provide the reason behind the decision? Are there any better approach to implement the device control interface other than sysfs interface. I have some issues in using the sysfs interface. Thanks in advance.

Quoted 6 lines

IOCTLs are discouraged, but not strictly forbidden. Is there something about sysfs that would make it an unsuitable interface, or are you just having trouble finding good documentation on using it?

-- Chris

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 4 lines
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes
#6 lore raw
In reply to Singaravelan Nallasellan
Quoted 16 lines · Singaravelan Nallasellan

Thank you for your response.

The driver needs to assign an id for each open and create a sysfs entry based on that id and expose some properties.

For example, if the driver assigns an id 2, the sysfs entry will be as below:
/sys/class/xxx/<drivername>/2/version

When the driver close is invoked, it will have to remove the entry.

The issue here is that the application needs:
1. To know the id it should use to access properties after the open.
2. To have exclusive access to the sysfs entries. No other application should and open the entry and use it. There is a chance the the other application could open the entries before this application opens it.

Quoted 3 lines

The driver allows multiple opens and assigns any random id.

I appreciate your suggestion on alternate ways to implement the functionality.

If you really need for each file descriptor that opens your device to have a unique context and set of properties that may be different from the rest, then an IOCTL might be legitimate here. If the device behaves the same way independent of context, then it's really just a locking issue, sysfs is the way to go.

-- Chris

Quoted 20 lines · Chris Snook
Quoted 8 lines
Quoted 7 lines · Singaravelan Nallasellan

I need to send device control messages to the driver. I am planning to use the IOCTLs. But I came to know that Linux community does not accept any new IOCTLs anymore.
Can somebody provide the reason behind the decision? Are there any better approach to implement the device control interface other than sysfs interface. I have some issues in using the sysfs interface. Thanks in advance.

Quoted 6 lines

IOCTLs are discouraged, but not strictly forbidden. Is there something about sysfs that would make it an unsuitable interface, or are you just having trouble finding good documentation on using it?

-- Chris

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw
In reply to Singaravelan Nallasellan

* Singaravelan Nallasellan <[email protected]> wrote:

Hi,

Quoted 6 lines

The driver needs to assign an id for each open and create a sysfs entry based on that id and expose some properties.

For example, if the driver assigns an id 2, the sysfs entry will be as below:
/sys/class/xxx/<drivername>/2/version

Quoted 7 lines

When the driver close is invoked, it will have to remove the entry.

The issue here is that the application needs:
1. To know the id it should use to access properties after the open.
2. To have exclusive access to the sysfs entries. No other application should and open the entry and use it. There is a chance the the other application could open the entries before this application opens it.

Simply add an clone file, reading from it creates new context and sends back its ID.

box:/ # cat /sys/class/xxx/foodriver/clone
3

box:/ # cat /sys/class/xxx/foodriver/3/version
1.0

...

To destroy the context:
box:/ # echo "release" > /sys/class/xxx/foodriver/3/ctl

cu

Signature · 8 lines
---------------------------------------------------------------------
 Enrico Weigelt    ==   metux IT service - http://www.metux.de/
---------------------------------------------------------------------
 Please visit the OpenSource QM Taskforce:
 	http://wiki.metux.de/public/OpenSource_QM_Taskforce
 Patches / Fixes for a lot dozens of packages in dozens of versions:
	http://patches.metux.de/
---------------------------------------------------------------------