Skip to contentSkip to conversation

Compile ipmi_devintf into ipmi_msghandler

PATCH New [email protected] 1 participant 4 messages Oct 23, 2014 IPMI

lore
Share & tools
lore
#0 lore raw

cover Compile ipmi_devintf into ipmi_msghandler

This removes the ipmi_devintf to be a module, but it will automatically be compiled in if ipmi_msghandler is set.
This will remove the overhead of an additional module (unneeded memory and sysfs files and additional autoloading of the userspace interface (which was broken) is not needed anymore.

Would be great to see this queued up in an upstream git tree, scheduled for inclusion for Linus' tree.

Thanks!

Thomas

Signature · 1 line
Thomas Renninger,SUSE LINUX GmbH; Maxfeldstrasse 5; D-90409 Nuernberg; Zi. 2.3-10,+49-911-740 53-675,,serv=loki,mail=imap,type=real <[email protected]>
#1 lore raw

PATCH 1/3 IPMI: Move/rename ipmi_msghandler.c to ipmi_handler.c

No code change done.
This is necessary to compile ipmi_devintf.c into the ipmi_msghandler module without renaming the module.
git history can still be obtained via:
git --follow drivers/char/ipmi/ipmi_handler.c
git blame drivers/char/ipmi/ipmi_handler.c still just works and also shows modifications prior to the rename.

drivers/char/ipmi/Makefile +2 -0
Index: kernel_ipmi/drivers/char/ipmi/Makefile
===================================================================
@@ -5,6 +5,8 @@
 ipmi_si-y := ipmi_si_intf.o ipmi_kcs_sm.o ipmi_smic_sm.o ipmi_bt_sm.o
 
 obj-$(CONFIG_IPMI_HANDLER) += ipmi_msghandler.o
+ipmi_msghandler-objs := ipmi_handler.o
+
 obj-$(CONFIG_IPMI_DEVICE_INTERFACE) += ipmi_devintf.o
 obj-$(CONFIG_IPMI_SI) += ipmi_si.o
 obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o
drivers/char/ipmi/ipmi_handler.c new file +4616 -0

2,992 lines not on this page · raw message

drivers/char/ipmi/ipmi_msghandler.c deleted +0 -4616

4,616 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 2/3 ipmi: Setup ipmi_devintf automatically if ipmi_msghandler gets loaded

In reply to [email protected]

This removes the ipmi_devintf to be a module, but it will automatically be compiled into ipmi_msghandler module if IPMI_HANDLER is set.

This will allow userspace IPMI support via autoloading.
There already was a kind of autoloading mechanism (gets deleted with this patch):
-MODULE_ALIAS("platform:ipmi_si");
But:
- It's wrong: There are other low lever drivers which can be used by ipmi_devintf
- It does not work
- There is no need to keep ipmi_devintf as a module (resource and load time overhead)

drivers/char/ipmi/Kconfig +2 -6
Index: kernel_ipmi/drivers/char/ipmi/Kconfig
===================================================================
@@ -8,6 +8,8 @@ menuconfig IPMI_HANDLER
        help
          This enables the central IPMI message handler, required for IPMI
 	 to work.
+	 It also provides userspace interface /dev/ipmiX, so that userspace
+	 tools can query the BMC.
 
          IPMI is a standard for managing sensors (temperature,
          voltage, etc.) in a system.
@@ -37,12 +39,6 @@ config IPMI_PANIC_STRING
 	  You can fetch these events and use the sequence numbers to piece the
 	  string together.
 
-config IPMI_DEVICE_INTERFACE
-       tristate 'Device interface for IPMI'
-       help
-         This provides an IOCTL interface to the IPMI message handler so
-	 userland processes may use IPMI.  It supports poll() and select().
-
 config IPMI_SI
        tristate 'IPMI System Interface handler'
        help
drivers/char/ipmi/ipmi_devintf.c +2 -9
Index: kernel_ipmi/drivers/char/ipmi/ipmi_devintf.c
===================================================================
@@ -928,7 +928,7 @@ static struct ipmi_smi_watcher smi_watch
 	.smi_gone = ipmi_smi_gone,
 };
 
-static int __init init_ipmi_devintf(void)
+int __init init_ipmi_devintf(void)
 {
 	int rv;
 
@@ -964,9 +964,8 @@ static int __init init_ipmi_devintf(void
 
 	return 0;
 }
-module_init(init_ipmi_devintf);
 
-static void __exit cleanup_ipmi(void)
+void cleanup_ipmi_dev(void)
 {
 	struct ipmi_reg_list *entry, *entry2;
 	mutex_lock(&reg_list_mutex);
@@ -980,9 +979,3 @@ static void __exit cleanup_ipmi(void)
 	ipmi_smi_watcher_unregister(&smi_watcher);
 	unregister_chrdev(ipmi_major, DEVICE_NAME);
 }
-module_exit(cleanup_ipmi);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Corey Minyard <[email protected]>");
-MODULE_DESCRIPTION("Linux device interface for the IPMI message handler.");
-MODULE_ALIAS("platform:ipmi_si");
drivers/char/ipmi/ipmi_handler.c +16 -2
Index: kernel_ipmi/drivers/char/ipmi/ipmi_handler.c
===================================================================
@@ -47,6 +47,8 @@
 #include <linux/rcupdate.h>
 #include <linux/interrupt.h>
 
+#include "ipmi_devintf.h"
+
 #define PFX "IPMI message handler: "
 
 #define IPMI_DRIVER_VERSION "39.2"
@@ -4560,13 +4562,24 @@ static int ipmi_init_msghandler(void)
 	return 0;
 }
 
+static void cleanup_ipmi(void);
+
 static int __init ipmi_init_msghandler_mod(void)
 {
-	ipmi_init_msghandler();
+	int ret;
+
+	ret = ipmi_init_msghandler();
+	if (ret)
+		return ret;
+	ret = init_ipmi_devintf();
+	if (ret) {
+		cleanup_ipmi();
+		return ret;
+	}
 	return 0;
 }
 
-static void __exit cleanup_ipmi(void)
+static void cleanup_ipmi(void)
 {
 	int count;
 
@@ -4605,6 +4618,7 @@ static void __exit cleanup_ipmi(void)
 	if (count != 0)
 		printk(KERN_WARNING PFX "recv message count %d at exit\n",
 		       count);
+	cleanup_ipmi_dev();
 }
 module_exit(cleanup_ipmi);
 
drivers/char/ipmi/Makefile +1 -2
Index: kernel_ipmi/drivers/char/ipmi/Makefile
===================================================================
@@ -5,9 +5,8 @@
 ipmi_si-y := ipmi_si_intf.o ipmi_kcs_sm.o ipmi_smic_sm.o ipmi_bt_sm.o
 
 obj-$(CONFIG_IPMI_HANDLER) += ipmi_msghandler.o
-ipmi_msghandler-objs := ipmi_handler.o
+ipmi_msghandler-objs := ipmi_handler.o ipmi_devintf.o
 
-obj-$(CONFIG_IPMI_DEVICE_INTERFACE) += ipmi_devintf.o
 obj-$(CONFIG_IPMI_SI) += ipmi_si.o
 obj-$(CONFIG_IPMI_WATCHDOG) += ipmi_watchdog.o
 obj-$(CONFIG_IPMI_POWEROFF) += ipmi_poweroff.o
drivers/char/ipmi/ipmi_devintf.h new file +38 -0
Index: kernel_ipmi/drivers/char/ipmi/ipmi_devintf.h
===================================================================
@@ -0,0 +1,38 @@
+/*
+ * ipmi_devintf.h
+ *
+ * Linux device interface header file for the IPMI message handler.
+ *
+ * Author: Thomas Renninger <[email protected]>
+ * Copyright 2014 SuSE Linux GmbH
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ *
+ *
+ *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _IPMI_DEVINTF_H_
+#define _IPMI_DEVINTF_H_
+
+void cleanup_ipmi_dev(void);
+
+int init_ipmi_devintf(void);
+
+#endif /* _IPMI_DEVINTF_H_ */
#3 lore raw

PATCH 3/3 ipmi: Remove ipmi_major module parameter

In reply to [email protected]

There should be no need to specify the major number of /dev/ipmiX via module parameter.
Major number is now always allocated dynamically.

drivers/char/ipmi/ipmi_devintf.c +1 -14
Index: kernel_ipmi/drivers/char/ipmi/ipmi_devintf.c
===================================================================
@@ -868,13 +868,6 @@ static const struct file_operations ipmi
 #define DEVICE_NAME     "ipmidev"
 
 static int ipmi_major;
-module_param(ipmi_major, int, 0);
-MODULE_PARM_DESC(ipmi_major, "Sets the major number of the IPMI device.  By"
-		 " default, or if you set it to zero, it will choose the next"
-		 " available device.  Setting it to -1 will disable the"
-		 " interface.  Other values will set the major device number"
-		 " to that value.");
-
 /* Keep track of the devices that are registered. */
 struct ipmi_reg_list {
 	dev_t            dev;
@@ -932,9 +925,6 @@ int __init init_ipmi_devintf(void)
 {
 	int rv;
 
-	if (ipmi_major < 0)
-		return -EINVAL;
-
 	printk(KERN_INFO "ipmi device interface\n");
 
 	ipmi_class = class_create(THIS_MODULE, "ipmi");
@@ -948,11 +938,8 @@ int __init init_ipmi_devintf(void)
 		class_destroy(ipmi_class);
 		printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
 		return rv;
-	}
-
-	if (ipmi_major == 0) {
+	} else
 		ipmi_major = rv;
-	}
 
 	rv = ipmi_smi_watcher_register(&smi_watcher);
 	if (rv) {