[Haifux] Telling the kernel business is closed (my weekly riddle)

Eli Billauer eli at billauer.co.il
Mon Jun 27 01:29:29 MSD 2011


Hi,


Yet another convention question regarding device drivers. As you may 
recall, I'm working on some hardware along with its Linux driver.


I just discovered that under certain conditions, my little piece of 
hardware may turn unreliable. The blame is on the chip I'm working on, 
so I can't fix this. Fortunately, the chip tells me something has gone 
deadly wrong, so the least I can do is to report it to the driver.


PCIe has an error reporting mechanism for this purpose, but I'm not sure 
if I can rely on errors of that sort being reported loud enough to the 
user. I want any communication with the device to stop immediately with 
an error message, or people will start blaming me for data being messed 
up (which is what the error is about).


The brute-force way to do this is to check a device-global flag every 
invocation of read(), write(), and other relevant methods. Maybe also 
before returning a successful value. If the flag is set ( = problem 
detected) return some -EDROPDEAD, so that application software reacts, 
and maybe someone will go to /var/log/messages to get a better idea of 
what happened. (I think I'll settle for -ENODEV)


So here comes my question: Is there a convention for how a device driver 
can tell the kernel that certain devices (as in /dev/something) have 
turned unusable, in particular when some of them are already open? I 
guess this is related to hotpluggable devices, but in the latter case I 
suppose it's the kernel informing the device driver about the event, and 
not vice versa.


Thanks in advance and see you tomorrow.

    Eli

-- 
Web: http://www.billauer.co.il




More information about the Haifux mailing list