ibm-acpi bay and acpi generic bay convergence
Kristen,
I just compared ibm-acpi bay stuff with what is in the generic driver. Here's a initial take of stuff to do:
1. The generic driver only handles hotplug bays (_EJ0). I'd like to also handle warm/coldplug bays (_EJ3).
Warm/coldplug bays are available on ThinkPads model 600e/x, A2Xm/p, A3Xm/p. They are otherwise as hard (or easy) to handle as any other thinkpad bay.
I don't know if for such bays it would be better to eject when preparing for a suspend instead of immediately, as they lack the required hardware to allow for safe removal of devices while the machine is still on.
2. The current logic for is_ata probably won't get everything PATA. I assume nobody is doing SATA bays without the SATA namespace nodes, but that is also a possible source of error. I didn't have time to manually check the ThinkPad DSDTs I have around to see if there is a known failure for PATA, yet.
If is_ata could try harder to identify a PATA/SATA device that is missing the usual nodes, it would be better. However, I have *no* idea on how to do that.
It is, however, a good enough reason to export an API to allow drivers like ibm-acpi to inform ACPI_BAY that a given handle should be added as a bay -- this allows us to use higly model-specific knowledge (like a fixed map between DSDT namespace to PATA port) to locate every bay. That would also require an API for ibm-acpi to know if ACPI_BAY gets loaded/unloaded...
If we were using anything less limited than the platform bus, we could even do this properly and just have ibm-acpi register bay devices that the driver model would match with a bay driver (ACPI_BAY). That would also make it extremely easy to deal with device-specific attributes, and inter-module communication. Can we have that proper bus for ACPI stuff, pretty please?
3. is_ejectable_bay is too simple-minded. It could work for batteries, if it didn't try so hard to detect only sata/ata devices as bays. Maybe it can be changed to try to detect anything that can be ejected and which is not a dock? It would find thinkpad batteries, then.
Alternatively, I can use the API I asked for (2) to register the battery bay handler. But that looks less optimal, right now.
I need to do some tests to check what happens in a thinkpad when you swap an ATAPI device with a battery, let's hope IBM did the right thing re. the event sources since they have two bay handles that belong to the same bay, and that Lenovo didn't break it.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
Quoted 5 lines · Henrique de Moraes Holschuh
3.
is_ejectable_bayis too simple-minded. It could work for batteries, if it didn't try so hard to detect only sata/ata devices as bays. Maybe it can be changed to try to detect anything that can be ejected and which is not a dock? It would find thinkpad batteries, then.
Quoted 8 lines
Alternatively, I can use the API I asked for (2) to register the battery bay handler. But that looks less optimal, right now.
I need to do some tests to check what happens in a thinkpad when you swap an ATAPI device with a battery, let's hope IBM did the right thing re. the event sources since they have two bay handles that belong to the same bay, and that Lenovo didn't break it.
Well, I have done the tests. A quick hack to is_ejectable_bay so that it registers anything that is not a dock lets ACPI_BAY handle thinkpad bay batteries almost perfectly in a T43. It is that simple.
So the first step is to improve is_ejectable_bay. What reason did you have to limit it only to devices where is_ata returns true? Is there a reason why anything that is not a dock and is ejectable should not be handled as a bay ?
Back to thinkpad bay batteries: The ACPI firmware in a T43 knows what you inserted in the bay (even before you press the lever!), and directs *all* bay events to either the BAT1 node or the relevant IDE0 node. I don't know if the other thinkpad firmwares are also this fine, but if they are, it will just work.
ThinkPad bay events: *IF* you have not ejected the device, you get one event when the bay release lever is unlocked (eject request), and one when the device is pulled off (and phisically disconnected) (hotunplug notification). If you eject the device, you receive no further eject events.
You receive one event when the lever is inserted if there is something inside the bay (hotplug).
The only drawback is that the user gets two bays (bay.0/bay.1) which are actually the same thing. Ejecting either will eject the device, which may cause issues if the _EJ0 ACPI firmware is different... you really should eject them using the correct handler for the device inside the bay.
_STA is decoupled, and will report 1 only for the node with the correct device type, which is nice. This CAN be used to mask off eject requests on bays that have nothing inside, but I don't know if that is desired as a general setup.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh
A message that is not in the archive (sent off-list or not yet received): 20070317192429.GA6508-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org
Quoted 15 lines · On Sat, 17 Mar 2007 16:24:29 -0300 Henrique de Moraes Holschuh…
Quoted 5 lines · Henrique de Moraes Holschuh
3.
is_ejectable_bayis too simple-minded. It could work for batteries, if it didn't try so hard to detect only sata/ata devices as bays. Maybe it can be changed to try to detect anything that can be ejected and which is not a dock? It would find thinkpad batteries, then.Quoted 8 lines
Alternatively, I can use the API I asked for (2) to register the battery bay handler. But that looks less optimal, right now.
I need to do some tests to check what happens in a thinkpad when you swap an ATAPI device with a battery, let's hope IBM did the right thing re. the event sources since they have two bay handles that belong to the same bay, and that Lenovo didn't break it.
Quoted 8 lines
Well, I have done the tests. A quick hack to
is_ejectable_bayso that it registers anything that is not a dock letsACPI_BAYhandle thinkpad bay batteries almost perfectly in a T43. It is that simple.So the first step is to improve
is_ejectable_bay. What reason did you have to limit it only to devices whereis_atareturns true? Is there a reason why anything that is not a dock and is ejectable should not be handled as a bay ?
The only reason the generic bay driver is limited to only ata devices is simply because that's all I decided to implement for the first revision of the driver. So, the perfect time to expand is now :).
Yes - there's a reason why we can't just blindly claim anything ejectable that isn't a dock. PCI Hotplug for example. What I think would be ideal would be if the bay driver could register for events on anything ejectable iff no other driver has claimed them. I couldn't find an easy way to do this last time I checked (months ago). Seems like we might have to change the way ACPI notifications are sent - I was hoping they could be changed to be more like interrupts - so that you could have a return code from the notification call that indicates whether the driver handled the event or not - and allow multiple drivers to register for the same event. This would also make it possible to eliminate weird stuff like what I'm doing with the dock driver to allow the bay driver to get dock notifications - the bay driver could just check to see if it's dependent on another object using _EJD and then request events on that object as well.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 10 lines · Kristen Carlson Accardi
Quoted 4 lines · Henrique de Moraes Holschuh
So the first step is to improve
is_ejectable_bay. What reason did you have to limit it only to devices whereis_atareturns true? Is there a reason why anything that is not a dock and is ejectable should not be handled as a bay ?The only reason the generic bay driver is limited to only ata devices is simply because that's all I decided to implement for the first revision of the driver. So, the perfect time to expand is now :).
Quoted 13 lines
Yes - there's a reason why we can't just blindly claim anything ejectable that isn't a dock. PCI Hotplug for example. What I think would be ideal would be if the bay driver could register for events on anything ejectable iff no other driver has claimed them. I couldn't find an easy way to do this last time I checked (months ago). Seems like we might have to change the way ACPI notifications are sent - I was hoping they could be changed to be more like interrupts - so that you could have a return code from the notification call that indicates whether the driver handled the event or not - and allow multiple drivers to register for the same event. This would also make it possible to eliminate weird stuff like what I'm doing with the dock driver to allow the bay driver to get dock notifications - the bay driver could just check to see if it's dependent on another object using
_EJDand then request events on that object as well.
I like this idea quite a lot. Only, we probably need to not only support a "walk until someone consumes the event" chain, but also a "notify every interested party that an event has happened and was consumed/was not consumed" functionality. You also may wany the "consume event" chain to understand priorities when inserting drivers in it, so that you can be a "well, if nobody else wants it..." consumer or a "me! me! me!" consumer.
It is not complete (it doesn't allow ibm-acpi to talk to bay and dock without using module dependencies for example), but it is quite a good start.
Signature · 4 lines
"One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie." -- The Silicon Valley Tarot Henrique Holschuh