Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IPMI: Add one interface to get more info of low-level IPMI device

The IPMI smi_watcher will be used to catch the IPMI interface as they
come or go. In order to communicate with the correct IPMI device, it
should be confirmed whether it is what we wanted especially on the
system with multiple IPMI devices. But the new_smi callback function
of smi_watcher provides very limited info(only the interface number
and dev pointer) and there is no detailed info about the low level
interface. For example: which mechansim registers the IPMI
interface(ACPI, PCI, DMI and so on).

This is to add one interface that can get more info of low-level IPMI
device. For example: the ACPI device handle will be returned for the
pnp_acpi IPMI device.

Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Zhao Yakui and committed by
Len Brown
16f4232c cf7d7e5a

+89 -4
+27
drivers/char/ipmi/ipmi_msghandler.c
··· 970 970 } 971 971 EXPORT_SYMBOL(ipmi_create_user); 972 972 973 + int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data) 974 + { 975 + int rv = 0; 976 + ipmi_smi_t intf; 977 + struct ipmi_smi_handlers *handlers; 978 + 979 + mutex_lock(&ipmi_interfaces_mutex); 980 + list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 981 + if (intf->intf_num == if_num) 982 + goto found; 983 + } 984 + /* Not found, return an error */ 985 + rv = -EINVAL; 986 + mutex_unlock(&ipmi_interfaces_mutex); 987 + return rv; 988 + 989 + found: 990 + handlers = intf->handlers; 991 + rv = -ENOSYS; 992 + if (handlers->get_smi_info) 993 + rv = handlers->get_smi_info(intf->send_info, data); 994 + mutex_unlock(&ipmi_interfaces_mutex); 995 + 996 + return rv; 997 + } 998 + EXPORT_SYMBOL(ipmi_get_smi_info); 999 + 973 1000 static void free_user(struct kref *ref) 974 1001 { 975 1002 ipmi_user_t user = container_of(ref, struct ipmi_user, refcount);
+16 -4
drivers/char/ipmi/ipmi_si_intf.c
··· 57 57 #include <asm/irq.h> 58 58 #include <linux/interrupt.h> 59 59 #include <linux/rcupdate.h> 60 + #include <linux/ipmi.h> 60 61 #include <linux/ipmi_smi.h> 61 62 #include <asm/io.h> 62 63 #include "ipmi_si_sm.h" ··· 108 107 }; 109 108 static char *si_to_str[] = { "kcs", "smic", "bt" }; 110 109 111 - enum ipmi_addr_src { 112 - SI_INVALID = 0, SI_HOTMOD, SI_HARDCODED, SI_SPMI, SI_ACPI, SI_SMBIOS, 113 - SI_PCI, SI_DEVICETREE, SI_DEFAULT 114 - }; 115 110 static char *ipmi_addr_src_to_str[] = { NULL, "hotmod", "hardcoded", "SPMI", 116 111 "ACPI", "SMBIOS", "PCI", 117 112 "device-tree", "default" }; ··· 288 291 struct task_struct *thread; 289 292 290 293 struct list_head link; 294 + union ipmi_smi_info_union addr_info; 291 295 }; 292 296 293 297 #define smi_inc_stat(smi, stat) \ ··· 1184 1186 return 0; 1185 1187 } 1186 1188 1189 + static int get_smi_info(void *send_info, struct ipmi_smi_info *data) 1190 + { 1191 + struct smi_info *smi = send_info; 1192 + 1193 + data->addr_src = smi->addr_source; 1194 + data->dev = smi->dev; 1195 + data->addr_info = smi->addr_info; 1196 + get_device(smi->dev); 1197 + 1198 + return 0; 1199 + } 1200 + 1187 1201 static void set_maintenance_mode(void *send_info, int enable) 1188 1202 { 1189 1203 struct smi_info *smi_info = send_info; ··· 1207 1197 static struct ipmi_smi_handlers handlers = { 1208 1198 .owner = THIS_MODULE, 1209 1199 .start_processing = smi_start_processing, 1200 + .get_smi_info = get_smi_info, 1210 1201 .sender = sender, 1211 1202 .request_events = request_events, 1212 1203 .set_maintenance_mode = set_maintenance_mode, ··· 2167 2156 printk(KERN_INFO PFX "probing via ACPI\n"); 2168 2157 2169 2158 handle = acpi_dev->handle; 2159 + info->addr_info.acpi_info.acpi_handle = handle; 2170 2160 2171 2161 /* _IFT tells us the interface type: KCS, BT, etc */ 2172 2162 status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp);
+38
include/linux/ipmi.h
··· 454 454 /* Validate that the given IPMI address is valid. */ 455 455 int ipmi_validate_addr(struct ipmi_addr *addr, int len); 456 456 457 + /* 458 + * How did the IPMI driver find out about the device? 459 + */ 460 + enum ipmi_addr_src { 461 + SI_INVALID = 0, SI_HOTMOD, SI_HARDCODED, SI_SPMI, SI_ACPI, SI_SMBIOS, 462 + SI_PCI, SI_DEVICETREE, SI_DEFAULT 463 + }; 464 + 465 + union ipmi_smi_info_union { 466 + /* 467 + * the acpi_info element is defined for the SI_ACPI 468 + * address type 469 + */ 470 + struct { 471 + void *acpi_handle; 472 + } acpi_info; 473 + }; 474 + 475 + struct ipmi_smi_info { 476 + enum ipmi_addr_src addr_src; 477 + 478 + /* 479 + * Base device for the interface. Don't forget to put this when 480 + * you are done. 481 + */ 482 + struct device *dev; 483 + 484 + /* 485 + * The addr_info provides more detailed info for some IPMI 486 + * devices, depending on the addr_src. Currently only SI_ACPI 487 + * info is provided. 488 + */ 489 + union ipmi_smi_info_union addr_info; 490 + }; 491 + 492 + /* This is to get the private info of ipmi_smi_t */ 493 + extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data); 494 + 457 495 #endif /* __KERNEL__ */ 458 496 459 497
+8
include/linux/ipmi_smi.h
··· 39 39 #include <linux/module.h> 40 40 #include <linux/device.h> 41 41 #include <linux/platform_device.h> 42 + #include <linux/ipmi.h> 42 43 43 44 /* This files describes the interface for IPMI system management interface 44 45 drivers to bind into the IPMI message handler. */ ··· 86 85 this call. */ 87 86 int (*start_processing)(void *send_info, 88 87 ipmi_smi_t new_intf); 88 + 89 + /* 90 + * Get the detailed private info of the low level interface and store 91 + * it into the structure of ipmi_smi_data. For example: the 92 + * ACPI device handle will be returned for the pnp_acpi IPMI device. 93 + */ 94 + int (*get_smi_info)(void *send_info, struct ipmi_smi_info *data); 89 95 90 96 /* Called to enqueue an SMI message to be sent. This 91 97 operation is not allowed to fail. If an error occurs, it