Skip to contentSkip to conversation

ipmi: support for AML access to IPMI via opregion

RFC PATCH New Bjorn Helgaas 1 participant 1 message Nov 18, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ipmi: support for AML access to IPMI via opregion

This is just a sample of how I think we might be able to connect the ACPI opregion support with the IPMI hardware driver in ipmi_si_intf.c. The idea is that whenever ipmi_si_intf.c finds an interface in the namespace, it calls the opregion "acpi_ipmi_add()" function, which registers the opregion handler.

This applies on top of my previous patch series and your "Add the IPMI opregion driver" patch.

The opregion support doesn't talk directly to the hardware (it doesn't touch the I/O or MMIO resources and it doesn't field interrupts), so I don't think it's quite right for this code to register directly as a driver for the IPMI interface.

I don't have any way to test this, of course, but it does compile for me, at least with the IPMI stuff compiled in statically. If these were all modules, I think we'd have to load them in this order:

ipmi_msghandler
ipmi (the opregion one; maybe needs a better name) ipmi_si (contains ipmi_si_intf.o, ipmi_kcs_sm.o, etc)

One issue is that this makes "ipmi" (the opregion piece) required -- since ipmi_si_intf.c calls it directly, we can't load ipmi_si unless ipmi has already been loaded.

---
 drivers/acpi/Kconfig             |    7 ++--
 drivers/acpi/ipmi.c              |   71 +++-----------------------------------
 drivers/char/ipmi/ipmi_si_intf.c |   10 +++++
 include/acpi/acpi_drivers.h      |    4 ++
 4 files changed, 23 insertions(+), 69 deletions(-)
drivers/acpi/Kconfig +4 -3
index 23cd08a..fee5b3d 100644
@@ -211,11 +211,12 @@ config ACPI_IPMI
 	select IPMI_HANDLER
 	select IPMI_SI
 	help
-	  This driver enables the ACPI to access the BMC controller. And it
-	  uses the IPMI request/response message to communicate with BMC
-	  controller, which can be found on on the server.
+	  This driver enables ACPI AML access to the BMC controller.  It
+	  uses IPMI request/response messages to communicate with the BMC
+	  controller.
 
 	  To compile this driver as a module, choose M here:
+	  the module will be called ipmi.
 
 config ACPI_HOTPLUG_CPU
 	bool
drivers/acpi/ipmi.c +6 -65

112 lines not on this page · raw message

drivers/char/ipmi/ipmi_si_intf.c +9 -1
index 679cd08..d0ab282 100644
@@ -1807,6 +1807,7 @@ static __devinit void hardcode_find_bmc(void)
 #ifdef CONFIG_ACPI
 
 #include <linux/acpi.h>
+#include <acpi/acpi_drivers.h>
 
 /*
  * Once we get an ACPI failure, we don't try any more, because we go
@@ -2033,6 +2034,7 @@ static int __devinit ipmi_pnp_probe(struct pnp_dev *dev,
 	acpi_handle handle;
 	acpi_status status;
 	unsigned long long tmp;
+	int ret;
 
 	acpi_dev = pnp_acpi_device(dev);
 	if (!acpi_dev)
@@ -2096,7 +2098,12 @@ static int __devinit ipmi_pnp_probe(struct pnp_dev *dev,
 	info->dev = &acpi_dev->dev;
 	pnp_set_drvdata(dev, info);
 
-	return try_smi_init(info);
+	ret = try_smi_init(info);
+	if (ret)
+		return ret;
+
+	acpi_ipmi_add(acpi_dev);
+	return 0;
 
 err_free:
 	kfree(info);
@@ -2107,6 +2114,7 @@ static void __devexit ipmi_pnp_remove(struct pnp_dev *dev)
 {
 	struct smi_info *info = pnp_get_drvdata(dev);
 
+	acpi_ipmi_remove(pnp_acpi_device(dev));
 	cleanup_one_si(info);
 }
 
include/acpi/acpi_drivers.h +4 -0
index 0c0522f..ce88cb1 100644
@@ -153,4 +153,8 @@ static inline void unregister_hotplug_dock_device(acpi_handle handle)
 }
 #endif
 
+/* IPMI opregion driver */
+extern int acpi_ipmi_add(struct acpi_device *device);
+extern int acpi_ipmi_remove(struct acpi_device *device);
+
 #endif /*__ACPI_DRIVERS_H__*/