acpiphp extension for 2.6.7
PATCH 1/1 acpiphp extension for 2.6.7
According to the specification, ACPI does not have a standard way of querying or manipulating the attention LED of hotplug slots. Here is a patch that allows for device specific ACPI code to be registered with the acpiphp driver as callbacks for setting/getting the status of the attention LED.
This patch was made against the 2.6.7 mainline kernel and adds the first driver to take advantage of the acpiphp attention LED callbacks, supporting about 5 of IBM's platforms that use acpiphp. It also some other functionality in addition to the LED getter/setter callback that IBM's active PCI team needed from their hotplug userspace program. It adds reading events from the hotplug slot and forwarding them on to the ACPI subsystem and exporting a binary table in the /sys/bus/pci/slots/apci_table file.
--Vernon
drivers/pci/hotplug/Kconfig +12 -0
@@ -88,6 +88,18 @@ When in doubt, say N. +config HOTPLUG_PCI_ACPI_IBM + tristate "ACPI PCI Hotplug driver IBM extensions" + depends on HOTPLUG_PCI_ACPI + help + Say Y here if you have an IBM system that supports PCI Hotplug using + ACPI. + + To compile this driver as a module, choose M here: the + module will be called acpiphp_ibm. + + When in doubt, say N. + config HOTPLUG_PCI_CPCI bool "CompactPCI Hotplug driver" depends on HOTPLUG_PCI
drivers/pci/hotplug/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o +obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o
drivers/pci/hotplug/acpiphp.h +22 -0
@@ -172,6 +172,22 @@ }; +/** +* struct acpiphp_attention_info - device specific attention registration +* +* ACPI has no generic method of setting/getting attention status +* this allows for device specific driver registration +*/ +typedef int (*acpiphp_set_attn_callback )(struct hotplug_slot *slot,u8 status); +typedef int (*acpiphp_get_attn_callback )(struct hotplug_slot *slot,u8 *status); +struct acpiphp_attention_info +{ +acpiphp_set_attn_callback set_attn; +acpiphp_get_attn_callback get_attn; +struct module *owner; +}; + +/* PCI bus bridge HID */ #define ACPI_PCI_HOST_HID "PNP0A03"
@@ -212,6 +228,12 @@/* function prototypes */ +/* acpiphp_core.c */ +extern int acpiphp_register_attention_info ( +struct acpiphp_attention_info *info); +extern int acpiphp_unregister_attention_info ( +struct acpiphp_attention_info *info); +/* acpiphp_glue.c */ extern int acpiphp_glue_init (void );extern void acpiphp_glue_exit (void );
drivers/pci/hotplug/acpiphp_core.c +118 -16
193 lines not on this page · raw message
drivers/pci/hotplug/acpiphp_glue.c +0 -14
@@ -1302,20 +1302,6 @@/* -* attention LED ON: 1 -* OFF: 0 -* -* TBD -* no direct attention led status information via ACPI -* -*/ -u8 acpiphp_get_attention_status (struct acpiphp_slot *slot) -{ -return 0 ; -} - - -/* * latch closed: 1 * latch open: 0 */
drivers/pci/hotplug/acpiphp_ibm.c +471 -0
471 lines not on this page · raw message
Quoted 5 lines · Vernon Mauery
According to the specification, ACPI does not have a standard way of querying or manipulating the attention LED of hotplug slots. Here is a patch that allows for device specific ACPI code to be registered with the acpiphp driver as callbacks for setting/getting the status of the attention LED.
The LED stuff looks good (few minor comments below), but the ACPI table info should be moved to the ACPI core to provide this to all ACPI tables in the /sys/firmware/acpi tree.
Quoted 1 line
+static struct
acpiphp_attention_infoattention_info;
This should just be a pointer, not the whole structure. Then just set it to whatever pointer is passed to you from the module.
Quoted 7 lines
drivers/pci/hotplug/acpiphp_core.c +7
-0+/** +* acpiphp_register_attention_info - set attention LED callback +* +* this is used to register a hardware specific acpi driver +* that manipulates the attention LED. All the fields in +* info must be set. +*
drivers/pci/hotplug/acpiphp_core.c line 109
Quoted 10 lines
drivers/pci/hotplug/acpiphp_core.c +10
-0+*/ +int acpiphp_register_attention_info (struct acpiphp_attention_info *info) +{ +int retval =0 ; +unsigned long flags; + +if (!info || !info->owner || !info->set_attn || !info->get_attn) + retval =-1 ; +else { +spin_lock_irqsave (&attn_info_lock, flags);
Why lock here? What could race?
And why the irqsave lock?
Quoted 66 lines
drivers/pci/hotplug/acpiphp_core.c +46
-7+if (!attention_info.owner) +memcpy (&attention_info, info, +sizeof (struct acpiphp_attention_info )); +spin_unlock_irqrestore (&attn_info_lock, flags); + } +return retval; +} + + +/** +* acpiphp_unregister_attention_info - unset attention LED callback +* +* this is used to un-register a hardware specific acpi driver +* that manipulates the attention LED. Both fields must +* match the current attention info to reset it. +* +*/ +int acpiphp_unregister_attention_info (struct acpiphp_attention_info *info) +{ +int retval =0 ; +unsigned long flags; + +if (!info || !info->owner || !info->set_attn || !info->get_attn) + retval =-1 ; +else { +spin_lock_irqsave (&attn_info_lock, flags); +if (memcmp (&attention_info, info, +sizeof (struct acpiphp_attention_info )) ==0 ) +memset (&attention_info,0 , +sizeof (struct acpiphp_attention_info )); +else + retval =-1 ; +spin_unlock_irqrestore (&attn_info_lock, flags); + } +return retval; +} + +/** * enable_slot - power on and enable a slot * @hotplug_slot: slot to enable @@ -120,29 +184,33 @@/** * set_attention_status - set attention LED * -* TBD: * ACPI doesn't have known method to manipulate -* attention status LED. +* attention status LED, so we use a callback that +* was registered with us. This allows hardware specific +* ACPI implementations to blink the light for us. * */ -static int set_attention_status (struct hotplug_slot *hotplug_slot,u8 status) +static int set_attention_status (struct hotplug_slot *hotplug_slot,u8 status) { +int retval =-1 ; +unsigned long flags; +struct acpiphp_attention_info info; +dbg ("%s - physical_slot = %s\n" , __FUNCTION__, hotplug_slot->name); -switch (status) { -case 0 : -/* FIXME turn light off */ - hotplug_slot->info->attention_status =0 ;
drivers/pci/hotplug/acpiphp_core.c line 203
Quoted 10 lines
drivers/pci/hotplug/acpiphp_core.c +3
-7-break ; - -case 1 : -default : -/* FIXME turn light on */ - hotplug_slot->info->attention_status =1 ; -break ; +spin_lock_irqsave (&attn_info_lock, flags); +memcpy (&info, &attention_info,sizeof (struct acpiphp_attention_info )); +spin_unlock_irqrestore (&attn_info_lock, flags);
Again, why lock? And why copy the whole structure? And it's on the stack, which isn't very nice. Same comment applies to the get_ function.
drivers/pci/hotplug/acpiphp_core.c line 211
Quoted 9 lines
drivers/pci/hotplug/acpiphp_core.c +6
-1+ +if (info.set_attn &&try_module_get (info.owner)) { + retval = info.set_attn (hotplug_slot, status); +module_put (info.owner); } -return 0 ; +if (!retval) + hotplug_slot->info->attention_status = (status) ?1 :0 ;
Why change the value based on the return value of the call? This shouldn't be set at all.
thanks,
greg k-h
Quoted 11 lines · Greg KH
drivers/pci/hotplug/acpiphp_core.c line 109
Quoted 9 lines
drivers/pci/hotplug/acpiphp_core.c +9
-0+int acpiphp_register_attention_info (struct acpiphp_attention_info *info) +{ +int retval =0 ; +unsigned long flags; + +if (!info || !info->owner || !info->set_attn || !info->get_attn) + retval =-1 ; +else { +spin_lock_irqsave (&attn_info_lock, flags);Why lock here? What could race?
If this function is only ever called from a module's init_module function, then our global data is protected by the kernel's module_mutex. But is the assumption that it is never called from other code safe to make? It manipulates global data, so it needs to be protected somehow...
Quoted 1 line
And why the irqsave lock?
Not sure. That can be changed.
Quoted 19 lines
Quoted 19 lines
drivers/pci/hotplug/acpiphp_core.c +5
-11-static int set_attention_status (struct hotplug_slot *hotplug_slot,u8 status) +static int set_attention_status (struct hotplug_slot *hotplug_slot,u8 status) { +int retval =-1 ; +unsigned long flags; +struct acpiphp_attention_info info; +dbg ("%s - physical_slot = %s\n" , __FUNCTION__, hotplug_slot->name); -switch (status) { -case 0 : -/* FIXME turn light off */ - hotplug_slot->info->attention_status =0 ; -break ; - -case 1 : -default : -/* FIXME turn light on */ - hotplug_slot->info->attention_status =1 ;
Quoted 8 lines
drivers/pci/hotplug/acpiphp_core.c line 203
Quoted 4 lines
drivers/pci/hotplug/acpiphp_core.c +3
-1-break ; +spin_lock_irqsave (&attn_info_lock, flags); +memcpy (&info, &attention_info,sizeof (struct acpiphp_attention_info )); +spin_unlock_irqrestore (&attn_info_lock, flags);Again, why lock? And why copy the whole structure? And it's on the stack, which isn't very nice. Same comment applies to the
get_function.
Getting a local copy of the data structure within the lock ensures that this function is reentrant. But if we can make the same guarantee that this funtion is called only on module_exit (again protected by the module_mutex) then we can move to a pointer and no local lock.
Quoted 6 lines
Quoted 6 lines
drivers/pci/hotplug/acpiphp_core.c +4
-0+ +if (info.set_attn &&try_module_get (info.owner)) { + retval = info.set_attn (hotplug_slot, status); +module_put (info.owner); }
Quoted 6 lines
drivers/pci/hotplug/acpiphp_core.c line 211
Quoted 3 lines
drivers/pci/hotplug/acpiphp_core.c +2
-1-return 0 ; +if (!retval) + hotplug_slot->info->attention_status = (status) ?1 :0 ;Why change the value based on the return value of the call? This shouldn't be set at all.
Oops. This was a snippet of legacy code that was around before I figured out how to read the LED value from hardware. I will drop it.
--Vernon
Quoted 3 lines · Greg KH
The LED stuff looks good (few minor comments below), but the ACPI table info should be moved to the ACPI core to provide this to all ACPI tables in the
/sys/firmware/acpitree.
I took it out of this patch, but it might be a while until I can figure out how to correctly modify the ACPI core to do that...
But the rest of your changes I implemented and have included in this patch.
--Vernon
drivers/pci/hotplug/Kconfig +12 -0
@@ -88,6 +88,18 @@ When in doubt, say N. +config HOTPLUG_PCI_ACPI_IBM + tristate "ACPI PCI Hotplug driver IBM extensions" + depends on HOTPLUG_PCI_ACPI + help + Say Y here if you have an IBM system that supports PCI Hotplug using + ACPI. + + To compile this driver as a module, choose M here: the + module will be called acpiphp_ibm. + + When in doubt, say N. + config HOTPLUG_PCI_CPCI bool "CompactPCI Hotplug driver" depends on HOTPLUG_PCI
drivers/pci/hotplug/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o +obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o
drivers/pci/hotplug/acpiphp.h +22 -0
@@ -172,6 +172,22 @@ }; +/** +* struct acpiphp_attention_info - device specific attention registration +* +* ACPI has no generic method of setting/getting attention status +* this allows for device specific driver registration +*/ +typedef int (*acpiphp_set_attn_callback )(struct hotplug_slot *slot,u8 status); +typedef int (*acpiphp_get_attn_callback )(struct hotplug_slot *slot,u8 *status); +struct acpiphp_attention_info +{ +acpiphp_set_attn_callback set_attn; +acpiphp_get_attn_callback get_attn; +struct module *owner; +}; + +/* PCI bus bridge HID */ #define ACPI_PCI_HOST_HID "PNP0A03"
@@ -212,6 +228,12 @@/* function prototypes */ +/* acpiphp_core.c */ +extern int acpiphp_register_attention_info ( +struct acpiphp_attention_info *info); +extern int acpiphp_unregister_attention_info ( +struct acpiphp_attention_info *info); +/* acpiphp_glue.c */ extern int acpiphp_glue_init (void );extern void acpiphp_glue_exit (void );
drivers/pci/hotplug/acpiphp_core.c +84 -16
153 lines not on this page · raw message
drivers/pci/hotplug/acpiphp_glue.c +0 -14
@@ -1302,20 +1302,6 @@/* -* attention LED ON: 1 -* OFF: 0 -* -* TBD -* no direct attention led status information via ACPI -* -*/ -u8 acpiphp_get_attention_status (struct acpiphp_slot *slot) -{ -return 0 ; -} - - -/* * latch closed: 1 * latch open: 0 */
drivers/pci/hotplug/acpiphp_ibm.c +426 -0
426 lines not on this page · raw message
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
cover acpiphp extension for 2.6.7
In reply to Greg KHAfter much discussion, dissection, rewriting and reading (documentation of course), I finally think this patch is ready to be included in the kernel. I have chosen to split it into 2 parts because really, that's what it is -- a patch to acpiphp that allows other modules to register attention LED callback functions and also a new module that does just that for the IBM ACPI systems. These patches were made against the 2.6.7 kernel tree.
01 - acpiphp-attention.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
02 - acpiphp_ibm-v1.0.1c.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to /proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
The two patches are to follow.
--Vernon
Quoted 7 lines · Vernon Mauery
After much discussion, dissection, rewriting and reading (documentation of course), I finally think this patch is ready to be included in the kernel. I have chosen to split it into 2 parts because really, that's what it is -- a patch to acpiphp that allows other modules to register attention LED callback functions and also a new module that does just that for the IBM ACPI systems. These patches were made against the 2.6.7 kernel tree.
I'm going to hold off applying these till you address the issues raised on the mailing list.
thanks,
greg k-h
cover acpiphp extension for 2.6.7 (take 3)
Quoted 2 lines · Greg KH
I'm going to hold off applying these till you address the issues raised on the mailing list.
Greg,
I think I have fixed the problems that have been discussed on the lists. Many of the fixes had to do with too many checks on pointers. I killed all the checks except for the ones that would make the machine oops immediately. That was the guideline I used to make the decision on what was a worthy check or not. Let me know what you think about the new version
Just for good measure, the description is included below again. :)
The two patches are to follow
--Vernon
After much discussion, dissection, rewriting and reading (documentation of course), I finally think this patch is ready to be included in the kernel. I have chosen to split it into 2 parts because really, that's what it is -- a patch to acpiphp that allows other modules to register attention LED callback functions and also a new module that does just that for the IBM ACPI systems. These patches were made against the 2.6.7 kernel tree.
01 - acpiphp-attention-v0.1d.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
02 - acpiphp_ibm-v1.0.1d.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to /proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
PATCH 1/2 acpiphp extension for 2.6.7 (take 3)
In reply to Greg KH01 - acpiphp-attention-v0.1d.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
acpiphp.h | 16 +++++++ acpiphp_core.c | 127 ++++++++++++++++++++++++++++++++++++++++++++------------- acpiphp_glue.c | 14 ------ 3 files changed, 115 insertions(+), 42 deletions(-)
=====================================================================
drivers/pci/hotplug/acpiphp.h +16 -0
@@ -171,6 +171,18 @@struct pci_resource *bus_head; }; +/** +* struct acpiphp_attention_info - device specific attention registration +* +* ACPI has no generic method of setting/getting attention status +* this allows for device specific driver registration +*/ +struct acpiphp_attention_info +{ +int (*set_attn)(struct hotplug_slot *slot,u8 status); +int (*get_attn)(struct hotplug_slot *slot,u8 *status); +struct module *owner; +};/* PCI bus bridge HID */ #define ACPI_PCI_HOST_HID "PNP0A03"
@@ -212,6 +224,10 @@/* function prototypes */ +/* acpiphp_core.c */ +extern int acpiphp_register_attention (struct acpiphp_attention_info *info); +extern int acpiphp_unregister_attention (struct acpiphp_attention_info *info); +/* acpiphp_glue.c */ extern int acpiphp_glue_init (void );extern void acpiphp_glue_exit (void );
drivers/pci/hotplug/acpiphp_core.c +99 -28
172 lines not on this page · raw message
drivers/pci/hotplug/acpiphp_glue.c +0 -14
@@ -1302,20 +1302,6 @@/* -* attention LED ON: 1 -* OFF: 0 -* -* TBD -* no direct attention led status information via ACPI -* -*/ -u8 acpiphp_get_attention_status (struct acpiphp_slot *slot) -{ -return 0 ; -} - - -/* * latch closed: 1 * latch open: 0 */
PATCH 2/2 acpiphp extension for 2.6.7 (take 3)
In reply to Greg KH02 - acpiphp_ibm-v1.0.1d.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to /proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
Kconfig | 12 + Makefile | 1 acpiphp_ibm.c | 474 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 487 insertions(+)
=====================================================================
drivers/pci/hotplug/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o +obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o
drivers/pci/hotplug/Kconfig +12 -0
@@ -88,6 +88,18 @@ When in doubt, say N. +config HOTPLUG_PCI_ACPI_IBM + tristate "ACPI PCI Hotplug driver IBM extensions" + depends on HOTPLUG_PCI_ACPI + help + Say Y here if you have an IBM system that supports PCI Hotplug using + ACPI. + + To compile this driver as a module, choose M here: the + module will be called acpiphp_ibm. + + When in doubt, say N. + config HOTPLUG_PCI_CPCI bool "CompactPCI Hotplug driver" depends on HOTPLUG_PCI
drivers/pci/hotplug/acpiphp_ibm.c +474 -0
474 lines not on this page · raw message
PATCH 1/2 acpiphp extension for 2.6.7
In reply to Greg KH01 - acpiphp-attention.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
acpiphp.h | 22 ++++++++++++ acpiphp_core.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++---------- acpiphp_glue.c | 14 ------- 3 files changed, 106 insertions(+), 30 deletions(-)
=====================================================================
drivers/pci/hotplug/acpiphp.h +22 -0
@@ -172,6 +172,22 @@ }; +/** +* struct acpiphp_attention_info - device specific attention registration +* +* ACPI has no generic method of setting/getting attention status +* this allows for device specific driver registration +*/ +typedef int (*acpiphp_set_attn_callback )(struct hotplug_slot *slot,u8 status); +typedef int (*acpiphp_get_attn_callback )(struct hotplug_slot *slot,u8 *status); +struct acpiphp_attention_info +{ +acpiphp_set_attn_callback set_attn; +acpiphp_get_attn_callback get_attn; +struct module *owner; +}; + +/* PCI bus bridge HID */ #define ACPI_PCI_HOST_HID "PNP0A03"
@@ -212,6 +228,12 @@/* function prototypes */ +/* acpiphp_core.c */ +extern int acpiphp_register_attention_info ( +struct acpiphp_attention_info *info); +extern int acpiphp_unregister_attention_info ( +struct acpiphp_attention_info *info); +/* acpiphp_glue.c */ extern int acpiphp_glue_init (void );extern void acpiphp_glue_exit (void );
drivers/pci/hotplug/acpiphp_core.c +84 -16
153 lines not on this page · raw message
drivers/pci/hotplug/acpiphp_glue.c +0 -14
@@ -1302,20 +1302,6 @@/* -* attention LED ON: 1 -* OFF: 0 -* -* TBD -* no direct attention led status information via ACPI -* -*/ -u8 acpiphp_get_attention_status (struct acpiphp_slot *slot) -{ -return 0 ; -} - - -/* * latch closed: 1 * latch open: 0 */
PATCH 2/2 acpiphp extension for 2.6.7
In reply to Greg KH02 - acpiphp_ibm-v1.0.1c.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to /proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
Kconfig | 12 + Makefile | 1 acpiphp_ibm.c | 476 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 489 insertions(+)
=====================================================================
drivers/pci/hotplug/Kconfig +12 -0
@@ -88,6 +88,18 @@ When in doubt, say N. +config HOTPLUG_PCI_ACPI_IBM + tristate "ACPI PCI Hotplug driver IBM extensions" + depends on HOTPLUG_PCI_ACPI + help + Say Y here if you have an IBM system that supports PCI Hotplug using + ACPI. + + To compile this driver as a module, choose M here: the + module will be called acpiphp_ibm. + + When in doubt, say N. + config HOTPLUG_PCI_CPCI bool "CompactPCI Hotplug driver" depends on HOTPLUG_PCI
drivers/pci/hotplug/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o +obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o
drivers/pci/hotplug/acpiphp_ibm.c +476 -0
476 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 1089216410.24908.5.camel@bluerat
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 1089328415.2089.194.camel@bluerat
A message that is not in the archive (sent off-list or not yet received): [email protected]
cover acpiphp extension for 2.6.7 (final)
Quoted 8 lines · Greg KH
Those checks are fine with me, I don't have a problem with them.
Quoted 2 lines
Either way, after I make the other fixes (and possibly this one), should I resubmit both patches together or just 1 of 2 alone?
Resend both of them, that way I'm reminded that they both need to be applied :)
Just for good measure, the description is included below again. :)
The two patches are to follow
--Vernon
After much discussion, dissection, rewriting and reading (documentation of course), I finally think this patch is ready to be included in the kernel. I have chosen to split it into 2 parts because really, that's what it is -- a patch to acpiphp that allows other modules to register attention LED callback functions and also a new module that does just that for the IBM ACPI systems. These patches were made against the 2.6.7 kernel tree.
01 - acpiphp-attention-v0.1d.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
02 - acpiphp_ibm-v1.0.1d.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to /proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
PATCH 1/2 acpiphp extension for 2.6.7 (final)
In reply to a message not in the archive01 - acpiphp-attention-v0.1e.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
acpiphp.h | 16 +++++++ acpiphp_core.c | 127 ++++++++++++++++++++++++++++++++++++++++++++------------- acpiphp_glue.c | 14 ------ 3 files changed, 115 insertions(+), 42 deletions(-)
=====================================================================
drivers/pci/hotplug/acpiphp.h +16 -0
@@ -171,6 +171,18 @@struct pci_resource *bus_head; }; +/** +* struct acpiphp_attention_info - device specific attention registration +* +* ACPI has no generic method of setting/getting attention status +* this allows for device specific driver registration +*/ +struct acpiphp_attention_info +{ +int (*set_attn)(struct hotplug_slot *slot,u8 status); +int (*get_attn)(struct hotplug_slot *slot,u8 *status); +struct module *owner; +};/* PCI bus bridge HID */ #define ACPI_PCI_HOST_HID "PNP0A03"
@@ -212,6 +224,10 @@/* function prototypes */ +/* acpiphp_core.c */ +extern int acpiphp_register_attention (struct acpiphp_attention_info *info); +extern int acpiphp_unregister_attention (struct acpiphp_attention_info *info); +/* acpiphp_glue.c */ extern int acpiphp_glue_init (void );extern void acpiphp_glue_exit (void );
drivers/pci/hotplug/acpiphp_core.c +99 -28
172 lines not on this page · raw message
drivers/pci/hotplug/acpiphp_glue.c +0 -14
@@ -1302,20 +1302,6 @@/* -* attention LED ON: 1 -* OFF: 0 -* -* TBD -* no direct attention led status information via ACPI -* -*/ -u8 acpiphp_get_attention_status (struct acpiphp_slot *slot) -{ -return 0 ; -} - - -/* * latch closed: 1 * latch open: 0 */
Greg KH
AppliedRe: [PATCH] [1/2] acpiphp extension for 2.6.7 (final)
Quoted 10 lines · Vernon Mauery
01 - acpiphp-attention-v0.1e.patch
This patch adds the ability to register callback functions with the acpiphp core to set and get the current attention LED status. The reason this is needed is because there is not set ACPI standard for how this is done so each hardware platform may implement it differently. To keep hardware specific code out of acpiphp, we allow other modules to register their code with it.
Quoted 6 lines
acpiphp.h | 16 +++++++ acpiphp_core.c | 127 ++++++++++++++++++++++++++++++++++++++++++++------------- acpiphp_glue.c | 14 ------ 3 files changed, 115 insertions(+), 42 deletions(-)Signed-off-by Vernon Mauery <[email protected]>
Applied, thanks.
greg k-h
PATCH 2/2 acpiphp extension for 2.6.7 (final)
In reply to a message not in the archive02 - acpiphp_ibm-v1.0.1e.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to /proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
Kconfig | 12 + Makefile | 1 acpiphp_ibm.c | 474 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 487 insertions(+)
=====================================================================
drivers/pci/hotplug/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_HOTPLUG_PCI_COMPAQ) += cpqphp.o obj-$(CONFIG_HOTPLUG_PCI_IBM) += ibmphp.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o +obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_ZT5550) += cpcihp_zt5550.o obj-$(CONFIG_HOTPLUG_PCI_CPCI_GENERIC) += cpcihp_generic.o obj-$(CONFIG_HOTPLUG_PCI_PCIE) += pciehp.o
drivers/pci/hotplug/Kconfig +12 -0
@@ -88,6 +88,18 @@ When in doubt, say N. +config HOTPLUG_PCI_ACPI_IBM + tristate "ACPI PCI Hotplug driver IBM extensions" + depends on HOTPLUG_PCI_ACPI + help + Say Y here if you have an IBM system that supports PCI Hotplug using + ACPI. + + To compile this driver as a module, choose M here: the + module will be called acpiphp_ibm. + + When in doubt, say N. + config HOTPLUG_PCI_CPCI bool "CompactPCI Hotplug driver" depends on HOTPLUG_PCI
drivers/pci/hotplug/acpiphp_ibm.c +474 -0
474 lines not on this page · raw message
Greg KH
AppliedRe: [PATCH] [2/2] acpiphp extension for 2.6.7 (final)
Quoted 10 lines · Vernon Mauery
02 - acpiphp_ibm-v1.0.1e.patch
This patch adds the first driver that actually uses the callback function for attention LEDs that the acpiphp-attention patch adds. It searches the ACPI namespace for IBM hardware, sets up the callbacks and sets up a handler to read ACPI events and forward them on to
/proc/acpi/event. It also exports an ACPI table that shows current hotplug status to userland.
Quoted 6 lines
Kconfig | 12 + Makefile | 1 acpiphp_ibm.c | 474 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 487 insertions(+)Signed-off-by Vernon Mauery <[email protected]>
Applied, thanks.
greg k-h
PATCH 1/1 acpiphp extension fixes for 2.6.9-rc2
In reply to a message not in the archiveThis patch fixes an off by one error that one of the IBM machines that uses the acpiphp_ibm driver. The slots were numbered starting at 0 in BIOS instead of starting at 1 like the pci hotplug subsystem names them. So this patch provides a lookup to translate the Linux slot numbers to the internal ACPI numbers.
acpiphp_ibm.c | 96 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 59 insertions(+), 37 deletions(-)
=====================================================================
drivers/pci/hotplug/acpiphp_ibm.c +59 -37
@@ -64,6 +64,8 @@#define IBM_HARDWARE_ID1 "IBM37D0"#define IBM_HARDWARE_ID2 "IBM37D4" +#define hpslot_to_sun (A ) (((struct slot *)((A)->private))->acpi_slot->sun) +/* union apci_descriptor - allows access to the * various device descriptors that are embedded in the * aPCI table
@@ -128,6 +130,42 @@ .owner = THIS_MODULE, }; +/** +* ibm_slot_from_id - workaround for bad ibm hardware +* @id: the slot number that linux refers to the slot by +* +* Description: this method returns the aCPI slot descriptor +* corresponding to the Linux slot number. This descriptor +* has info about the aPCI slot id and attention status. +* This descriptor must be freed using kfree when done. +**/ +static union apci_descriptor *ibm_slot_from_id (int id) +{ +int ind =0 , size; +union apci_descriptor *ret =NULL , *des; +char *table; + + size =ibm_get_table_from_acpi (&table); + des = (union apci_descriptor *)table; +if (memcmp (des->header.sig,"aPCI" ,4 ) !=0 ) + goto ibm_slot_done; + + des = (union apci_descriptor *)&table[ind += des->header.len]; +while (ind < size && (des->generic.type !=0x82 || + des->slot.slot_num != id)) + des = (union apci_descriptor *)&table[ind += des->generic.len]; + +if (ind < size && des->slot.slot_num == id) + ret = des; + +ibm_slot_done: +kfree (table); +if (ret) { + ret =kmalloc (sizeof (union apci_descriptor ),GFP_KERNEL ); +memcpy (ret, des,sizeof (union apci_descriptor )); + } +return ret; +}/** * ibm_set_attention_status - callback method to set the attention LED
@@ -139,32 +177,34 @@**/ static int ibm_set_attention_status (struct hotplug_slot *slot,u8 status) { -int retval =0 ;union acpi_object args[2 ];struct acpi_object_list params = { .pointer = args, .count =2 };acpi_status stat; -unsigned long rc =0 ; -struct acpiphp_slot *acpi_slot; +unsigned long rc; +union apci_descriptor *ibm_slot; - acpi_slot = ((struct slot *)(slot->private))->acpi_slot; + ibm_slot =ibm_slot_from_id (hpslot_to_sun (slot)); -dbg ("%s: set slot %d attention status to %d\n" , __FUNCTION__, - acpi_slot->sun, (status ?1 :0 )); +dbg ("%s: set slot %d (%d) attention status to %d\n" , __FUNCTION__, + ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, + (status ?1 :0 )); args[0 ].type =ACPI_TYPE_INTEGER ; - args[0 ].integer.value = acpi_slot->sun; + args[0 ].integer.value = ibm_slot->slot.slot_id; args[1 ].type =ACPI_TYPE_INTEGER ; args[1 ].integer.value = (status) ?1 :0 ; +kfree (ibm_slot); + stat =acpi_evaluate_integer (ibm_acpi_handle,"APLS" , ¶ms, &rc);if (ACPI_FAILURE (stat)) { - retval = -ENODEV ;err ("APLS evaluation failed: 0x%08x\n" , stat); +return -ENODEV ; }else if (!rc) { - retval = -ERANGE ;err ("APLS method failed: 0x%08lx\n" , rc); +return -ERANGE ; } -return retval; +return 0 ; }/**
@@ -181,38 +221,20 @@**/ static int ibm_get_attention_status (struct hotplug_slot *slot,u8 *status) { -int retval = -EINVAL , ind =0 , size; -char *table =NULL ; -struct acpiphp_slot *acpi_slot;union apci_descriptor *des; - acpi_slot = ((struct slot *)(slot->private))->acpi_slot; + des =ibm_slot_from_id (hpslot_to_sun (slot)); - size =ibm_get_table_from_acpi (&table); -if (size <=0 || !table) - goto get_attn_done; -// read the header - des = (union apci_descriptor *)&table[ind]; -if (memcmp (des->header.sig,"aPCI" ,4 ) !=0 ) - goto get_attn_done; - des = (union apci_descriptor *)&table[ind += des->header.len]; -while (ind < size && (des->generic.type !=0x82 || - des->slot.slot_id != acpi_slot->sun)) - des = (union apci_descriptor *)&table[ind += des->generic.len]; -if (ind < size && des->slot.slot_id == acpi_slot->sun) { - retval =0 ; -if (des->slot.attn &0xa0 || des->slot.status[1 ] &0x08 ) - *status =1 ; -else - *status =0 ; - } +if (des->slot.attn &0xa0 || des->slot.status[1 ] &0x08 ) + *status =1 ; +else + *status =0 ; -dbg ("%s: get slot %d attention status is %d retval=%x\n" , - __FUNCTION__, acpi_slot->sun, *status, retval); +dbg ("%s: get slot %d (%d) attention status is %d\n" , __FUNCTION__, + des->slot.slot_num, des->slot.slot_id, *status); -get_attn_done: -kfree (table); -return retval; +kfree (des); +return 0 ; }/**
Re: [PATCH] acpiphp extension fixes for 2.6.9-rc2
Quoted 1 line · Vernon Mauery
This patch fixes an off by one error that one of the IBM machines that
I realized today that I had an off by one error myself. I had one line in the wrong place by one (i.e. accessing a pointer into the table after calling kfree on the table). So, please disregard the last patch and apply this one instead.
For the record...
This patch fixes an off by one error that one of the IBM machines that uses the acpiphp_ibm driver. The slots were numbered starting at 0 in BIOS instead of starting at 1 like the pci hotplug subsystem names them. So this patch provides a lookup to translate the Linux slot numbers to the internal ACPI numbers.
acpiphp_ibm.c | 101 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 63 insertions(+), 38 deletions(-)
=====================================================================
drivers/pci/hotplug/acpiphp_ibm.c +63 -38
@@ -64,6 +64,8 @@#define IBM_HARDWARE_ID1 "IBM37D0"#define IBM_HARDWARE_ID2 "IBM37D4" +#define hpslot_to_sun (A ) (((struct slot *)((A)->private))->acpi_slot->sun) +/* union apci_descriptor - allows access to the * various device descriptors that are embedded in the * aPCI table
@@ -84,6 +86,7 @@u8 attn;u8 status[2 ];u8 sun; +u8 res[3 ]; } slot;struct {u8 type;
@@ -128,6 +131,43 @@ .owner = THIS_MODULE, }; +/** +* ibm_slot_from_id - workaround for bad ibm hardware +* @id: the slot number that linux refers to the slot by +* +* Description: this method returns the aCPI slot descriptor +* corresponding to the Linux slot number. This descriptor +* has info about the aPCI slot id and attention status. +* This descriptor must be freed using kfree when done. +**/ +static union apci_descriptor *ibm_slot_from_id (int id) +{ +int ind =0 , size; +union apci_descriptor *ret =NULL , *des; +char *table; + + size =ibm_get_table_from_acpi (&table); + des = (union apci_descriptor *)table; +if (memcmp (des->header.sig,"aPCI" ,4 ) !=0 ) + goto ibm_slot_done; + + des = (union apci_descriptor *)&table[ind += des->header.len]; +while (ind < size && (des->generic.type !=0x82 || + des->slot.slot_num != id)) { + des = (union apci_descriptor *)&table[ind += des->generic.len]; + } + +if (ind < size && des->slot.slot_num == id) + ret = des; + +ibm_slot_done: +if (ret) { + ret =kmalloc (sizeof (union apci_descriptor ),GFP_KERNEL ); +memcpy (ret, des,sizeof (union apci_descriptor )); + } +kfree (table); +return ret; +}/** * ibm_set_attention_status - callback method to set the attention LED
@@ -139,32 +179,34 @@**/ static int ibm_set_attention_status (struct hotplug_slot *slot,u8 status) { -int retval =0 ;union acpi_object args[2 ];struct acpi_object_list params = { .pointer = args, .count =2 };acpi_status stat; -unsigned long rc =0 ; -struct acpiphp_slot *acpi_slot; +unsigned long rc; +union apci_descriptor *ibm_slot; - acpi_slot = ((struct slot *)(slot->private))->acpi_slot; + ibm_slot =ibm_slot_from_id (hpslot_to_sun (slot)); -dbg ("%s: set slot %d attention status to %d\n" , __FUNCTION__, - acpi_slot->sun, (status ?1 :0 )); +dbg ("%s: set slot %d (%d) attention status to %d\n" , __FUNCTION__, + ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, + (status ?1 :0 )); args[0 ].type =ACPI_TYPE_INTEGER ; - args[0 ].integer.value = acpi_slot->sun; + args[0 ].integer.value = ibm_slot->slot.slot_id; args[1 ].type =ACPI_TYPE_INTEGER ; args[1 ].integer.value = (status) ?1 :0 ; +kfree (ibm_slot); + stat =acpi_evaluate_integer (ibm_acpi_handle,"APLS" , ¶ms, &rc);if (ACPI_FAILURE (stat)) { - retval = -ENODEV ;err ("APLS evaluation failed: 0x%08x\n" , stat); +return -ENODEV ; }else if (!rc) { - retval = -ERANGE ;err ("APLS method failed: 0x%08lx\n" , rc); +return -ERANGE ; } -return retval; +return 0 ; }/**
@@ -181,38 +223,21 @@**/ static int ibm_get_attention_status (struct hotplug_slot *slot,u8 *status) { -int retval = -EINVAL , ind =0 , size; -char *table =NULL ; -struct acpiphp_slot *acpi_slot; -union apci_descriptor *des; +union apci_descriptor *ibm_slot; - acpi_slot = ((struct slot *)(slot->private))->acpi_slot; + ibm_slot =ibm_slot_from_id (hpslot_to_sun (slot)); - size =ibm_get_table_from_acpi (&table); -if (size <=0 || !table) - goto get_attn_done; -// read the header - des = (union apci_descriptor *)&table[ind]; -if (memcmp (des->header.sig,"aPCI" ,4 ) !=0 ) - goto get_attn_done; - des = (union apci_descriptor *)&table[ind += des->header.len]; -while (ind < size && (des->generic.type !=0x82 || - des->slot.slot_id != acpi_slot->sun)) - des = (union apci_descriptor *)&table[ind += des->generic.len]; -if (ind < size && des->slot.slot_id == acpi_slot->sun) { - retval =0 ; -if (des->slot.attn &0xa0 || des->slot.status[1 ] &0x08 ) - *status =1 ; -else - *status =0 ; - } +if (ibm_slot->slot.attn &0xa0 || ibm_slot->slot.status[1 ] &0x08 ) + *status =1 ; +else + *status =0 ; -dbg ("%s: get slot %d attention status is %d retval=%x\n" , - __FUNCTION__, acpi_slot->sun, *status, retval); +dbg ("%s: get slot %d (%d) attention status is %d\n" , __FUNCTION__, + ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, + *status); -get_attn_done: -kfree (table); -return retval; +kfree (ibm_slot); +return 0 ; }/**
Greg KH
AppliedRe: [PATCH] acpiphp extension fixes for 2.6.9-rc2
Quoted 16 lines · Vernon Mauery
Quoted 1 line · Vernon Mauery
This patch fixes an off by one error that one of the IBM machines that
I realized today that I had an off by one error myself. I had one line in the wrong place by one (i.e. accessing a pointer into the table after calling kfree on the table). So, please disregard the last patch and apply this one instead.
For the record...
This patch fixes an off by one error that one of the IBM machines that uses the
acpiphp_ibmdriver. The slots were numbered starting at 0 in BIOS instead of starting at 1 like the pci hotplug subsystem names them. So this patch provides a lookup to translate the Linux slot numbers to the internal ACPI numbers.
Quoted 4 lines
acpiphp_ibm.c | 101 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 63 insertions(+), 38 deletions(-)Signed-off-by Vernon Mauery <[email protected]>
Applied, thanks.
greg k-h