Commit c403993a authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'for-linus-4.20' of https://github.com/cminyard/linux-ipmi

Pull IPMI updates from Corey Minyard:
 "Lots of small changes to the IPMI driver. Most of the changes are
  logging cleanup and style fixes. There are a few smaller bug fixes"

* tag 'for-linus-4.20' of https://github.com/cminyard/linux-ipmi: (21 commits)
  ipmi: Fix timer race with module unload
  ipmi:ssif: Add support for multi-part transmit messages > 2 parts
  MAINTAINERS: Add file patterns for ipmi device tree bindings
  ipmi: Remove platform driver overrides and use the id_table
  ipmi: Free the address list on module cleanup
  ipmi: Don't leave holes in the I2C address list in the ssif driver
  ipmi: fix return value of ipmi_set_my_LUN
  ipmi: Convert pr_xxx() to dev_xxx() in the BT code
  ipmi:dmi: Ignore IPMI SMBIOS entries with a zero base address
  ipmi:dmi: Use pr_fmt in the IPMI DMI code
  ipmi: Change to ktime_get_ts64()
  ipmi_si: fix potential integer overflow on large shift
  ipmi_si_pci: fix NULL device in ipmi_si error message
  ipmi: Convert printk(KERN_<level> to pr_<level>(
  ipmi: Use more common logging styles
  ipmi: msghandler: Add and use pr_fmt and dev_fmt, remove PFX
  pci:ipmi: Move IPMI PCI class id defines to pci_ids.h
  ipmi: Finally get rid of ipmi_user_t and ipmi_smi_t
  ipmi:powernv: Convert ipmi_smi_t to struct ipmi_smi
  hwmon:ibm: Change ipmi_user_t to struct ipmi_user *
  ...
parents 6fd577cd 0711e8c1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7666,6 +7666,7 @@ M: Corey Minyard <minyard@acm.org>
L:	openipmi-developer@lists.sourceforge.net (moderated for non-subscribers)
W:	http://openipmi.sourceforge.net/
S:	Supported
F:	Documentation/devicetree/bindings/ipmi/
F:	Documentation/IPMI.txt
F:	drivers/char/ipmi/
F:	include/linux/ipmi*
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ struct acpi_ipmi_device {
	spinlock_t tx_msg_lock;
	acpi_handle handle;
	struct device *dev;
	ipmi_user_t user_interface;
	struct ipmi_user *user_interface;
	int ipmi_ifnum; /* IPMI interface number */
	long curr_msgid;
	bool dead;
@@ -125,7 +125,7 @@ ipmi_dev_alloc(int iface, struct device *dev, acpi_handle handle)
{
	struct acpi_ipmi_device *ipmi_device;
	int err;
	ipmi_user_t user;
	struct ipmi_user *user;

	ipmi_device = kzalloc(sizeof(*ipmi_device), GFP_KERNEL);
	if (!ipmi_device)
+34 −32
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@
 *  Author:	Rocky Craig <first.last@hp.com>
 */

#define DEBUG /* So dev_dbg() is always available. */

#include <linux/kernel.h> /* For printk. */
#include <linux/string.h>
#include <linux/module.h>
@@ -215,11 +217,11 @@ static int bt_start_transaction(struct si_sm_data *bt,
		return IPMI_NOT_IN_MY_STATE_ERR;

	if (bt_debug & BT_DEBUG_MSG) {
		printk(KERN_WARNING "BT: +++++++++++++++++ New command\n");
		printk(KERN_WARNING "BT: NetFn/LUN CMD [%d data]:", size - 2);
		dev_dbg(bt->io->dev, "+++++++++++++++++ New command\n");
		dev_dbg(bt->io->dev, "NetFn/LUN CMD [%d data]:", size - 2);
		for (i = 0; i < size; i ++)
			printk(" %02x", data[i]);
		printk("\n");
			pr_cont(" %02x", data[i]);
		pr_cont("\n");
	}
	bt->write_data[0] = size + 1;	/* all data plus seq byte */
	bt->write_data[1] = *data;	/* NetFn/LUN */
@@ -260,10 +262,10 @@ static int bt_get_result(struct si_sm_data *bt,
		memcpy(data + 2, bt->read_data + 4, msg_len - 2);

	if (bt_debug & BT_DEBUG_MSG) {
		printk(KERN_WARNING "BT: result %d bytes:", msg_len);
		dev_dbg(bt->io->dev, "result %d bytes:", msg_len);
		for (i = 0; i < msg_len; i++)
			printk(" %02x", data[i]);
		printk("\n");
			pr_cont(" %02x", data[i]);
		pr_cont("\n");
	}
	return msg_len;
}
@@ -274,8 +276,7 @@ static int bt_get_result(struct si_sm_data *bt,
static void reset_flags(struct si_sm_data *bt)
{
	if (bt_debug)
		printk(KERN_WARNING "IPMI BT: flag reset %s\n",
					status2txt(BT_STATUS));
		dev_dbg(bt->io->dev, "flag reset %s\n", status2txt(BT_STATUS));
	if (BT_STATUS & BT_H_BUSY)
		BT_CONTROL(BT_H_BUSY);	/* force clear */
	BT_CONTROL(BT_CLR_WR_PTR);	/* always reset */
@@ -301,14 +302,14 @@ static void drain_BMC2HOST(struct si_sm_data *bt)
	BT_CONTROL(BT_B2H_ATN);		/* some BMCs are stubborn */
	BT_CONTROL(BT_CLR_RD_PTR);	/* always reset */
	if (bt_debug)
		printk(KERN_WARNING "IPMI BT: stale response %s; ",
		dev_dbg(bt->io->dev, "stale response %s; ",
			status2txt(BT_STATUS));
	size = BMC2HOST;
	for (i = 0; i < size ; i++)
		BMC2HOST;
	BT_CONTROL(BT_H_BUSY);		/* now clear */
	if (bt_debug)
		printk("drained %d bytes\n", size + 1);
		pr_cont("drained %d bytes\n", size + 1);
}

static inline void write_all_bytes(struct si_sm_data *bt)
@@ -316,11 +317,11 @@ static inline void write_all_bytes(struct si_sm_data *bt)
	int i;

	if (bt_debug & BT_DEBUG_MSG) {
		printk(KERN_WARNING "BT: write %d bytes seq=0x%02X",
		dev_dbg(bt->io->dev, "write %d bytes seq=0x%02X",
			bt->write_count, bt->seq);
		for (i = 0; i < bt->write_count; i++)
			printk(" %02x", bt->write_data[i]);
		printk("\n");
			pr_cont(" %02x", bt->write_data[i]);
		pr_cont("\n");
	}
	for (i = 0; i < bt->write_count; i++)
		HOST2BMC(bt->write_data[i]);
@@ -340,8 +341,8 @@ static inline int read_all_bytes(struct si_sm_data *bt)

	if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) {
		if (bt_debug & BT_DEBUG_MSG)
			printk(KERN_WARNING "BT: bad raw rsp len=%d\n",
				bt->read_count);
			dev_dbg(bt->io->dev,
				"bad raw rsp len=%d\n", bt->read_count);
		bt->truncated = 1;
		return 1;	/* let next XACTION START clean it up */
	}
@@ -352,13 +353,13 @@ static inline int read_all_bytes(struct si_sm_data *bt)
	if (bt_debug & BT_DEBUG_MSG) {
		int max = bt->read_count;

		printk(KERN_WARNING "BT: got %d bytes seq=0x%02X",
			max, bt->read_data[2]);
		dev_dbg(bt->io->dev,
			"got %d bytes seq=0x%02X", max, bt->read_data[2]);
		if (max > 16)
			max = 16;
		for (i = 0; i < max; i++)
			printk(KERN_CONT " %02x", bt->read_data[i]);
		printk(KERN_CONT "%s\n", bt->read_count == max ? "" : " ...");
			pr_cont(" %02x", bt->read_data[i]);
		pr_cont("%s\n", bt->read_count == max ? "" : " ...");
	}

	/* per the spec, the (NetFn[1], Seq[2], Cmd[3]) tuples must match */
@@ -368,9 +369,10 @@ static inline int read_all_bytes(struct si_sm_data *bt)
			return 1;

	if (bt_debug & BT_DEBUG_MSG)
		printk(KERN_WARNING "IPMI BT: bad packet: "
		"want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
		bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3],
		dev_dbg(bt->io->dev,
			"IPMI BT: bad packet: want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
			bt->write_data[1] | 0x04, bt->write_data[2],
			bt->write_data[3],
			bt->read_data[1],  bt->read_data[2],  bt->read_data[3]);
	return 0;
}
@@ -394,7 +396,7 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt,
		break;
	}

	printk(KERN_WARNING "IPMI BT: %s in %s %s ", 	/* open-ended line */
	dev_warn(bt->io->dev, "IPMI BT: %s in %s %s ", /* open-ended line */
		 reason, STATE2TXT, STATUS2TXT);

	/*
@@ -403,20 +405,20 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt,
	 */
	(bt->error_retries)++;
	if (bt->error_retries < bt->BT_CAP_retries) {
		printk("%d retries left\n",
		pr_cont("%d retries left\n",
			bt->BT_CAP_retries - bt->error_retries);
		bt->state = BT_STATE_RESTART;
		return SI_SM_CALL_WITHOUT_DELAY;
	}

	printk(KERN_WARNING "failed %d retries, sending error response\n",
	dev_warn(bt->io->dev, "failed %d retries, sending error response\n",
		 bt->BT_CAP_retries);
	if (!bt->nonzero_status)
		printk(KERN_ERR "IPMI BT: stuck, try power cycle\n");
		dev_err(bt->io->dev, "stuck, try power cycle\n");

	/* this is most likely during insmod */
	else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
		printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
		dev_warn(bt->io->dev, "BT reset (takes 5 secs)\n");
		bt->state = BT_STATE_RESET1;
		return SI_SM_CALL_WITHOUT_DELAY;
	}
@@ -452,7 +454,7 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
	status = BT_STATUS;
	bt->nonzero_status |= status;
	if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
		printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
		dev_dbg(bt->io->dev, "BT: %s %s TO=%ld - %ld\n",
			STATE2TXT,
			STATUS2TXT,
			bt->timeout,
+5 −6
Original line number Diff line number Diff line
@@ -818,8 +818,7 @@ static void ipmi_new_smi(int if_num, struct device *device)

	entry = kmalloc(sizeof(*entry), GFP_KERNEL);
	if (!entry) {
		printk(KERN_ERR "ipmi_devintf: Unable to create the"
		       " ipmi class device link\n");
		pr_err("ipmi_devintf: Unable to create the ipmi class device link\n");
		return;
	}
	entry->dev = dev;
@@ -861,18 +860,18 @@ static int __init init_ipmi_devintf(void)
	if (ipmi_major < 0)
		return -EINVAL;

	printk(KERN_INFO "ipmi device interface\n");
	pr_info("ipmi device interface\n");

	ipmi_class = class_create(THIS_MODULE, "ipmi");
	if (IS_ERR(ipmi_class)) {
		printk(KERN_ERR "ipmi: can't register device class\n");
		pr_err("ipmi: can't register device class\n");
		return PTR_ERR(ipmi_class);
	}

	rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
	if (rv < 0) {
		class_destroy(ipmi_class);
		printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
		pr_err("ipmi: can't get major %d\n", ipmi_major);
		return rv;
	}

@@ -884,7 +883,7 @@ static int __init init_ipmi_devintf(void)
	if (rv) {
		unregister_chrdev(ipmi_major, DEVICE_NAME);
		class_destroy(ipmi_class);
		printk(KERN_WARNING "ipmi: can't register smi watcher\n");
		pr_warn("ipmi: can't register smi watcher\n");
		return rv;
	}

+15 −16
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@
 * allow autoloading of the IPMI drive based on SMBIOS entries.
 */

#define pr_fmt(fmt) "%s" fmt, "ipmi:dmi: "
#define dev_fmt pr_fmt

#include <linux/ipmi.h>
#include <linux/init.h>
#include <linux/dmi.h>
@@ -41,7 +44,7 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,
	unsigned int num_r = 1, size;
	struct property_entry p[5];
	unsigned int pidx = 0;
	char *name, *override;
	char *name;
	int rv;
	enum si_type si_type;
	struct ipmi_dmi_info *info;
@@ -49,11 +52,9 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,
	memset(p, 0, sizeof(p));

	name = "dmi-ipmi-si";
	override = "ipmi_si";
	switch (type) {
	case IPMI_DMI_TYPE_SSIF:
		name = "dmi-ipmi-ssif";
		override = "ipmi_ssif";
		offset = 1;
		size = 1;
		si_type = SI_TYPE_INVALID;
@@ -71,7 +72,7 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,
		si_type = SI_SMIC;
		break;
	default:
		pr_err("ipmi:dmi: Invalid IPMI type: %d\n", type);
		pr_err("Invalid IPMI type: %d\n", type);
		return;
	}

@@ -83,7 +84,7 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,

	info = kmalloc(sizeof(*info), GFP_KERNEL);
	if (!info) {
		pr_warn("ipmi:dmi: Could not allocate dmi info\n");
		pr_warn("Could not allocate dmi info\n");
	} else {
		info->si_type = si_type;
		info->flags = flags;
@@ -95,13 +96,9 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,

	pdev = platform_device_alloc(name, ipmi_dmi_nr);
	if (!pdev) {
		pr_err("ipmi:dmi: Error allocation IPMI platform device\n");
		pr_err("Error allocation IPMI platform device\n");
		return;
	}
	pdev->driver_override = kasprintf(GFP_KERNEL, "%s",
					  override);
	if (!pdev->driver_override)
		goto err;

	if (type == IPMI_DMI_TYPE_SSIF) {
		p[pidx++] = PROPERTY_ENTRY_U16("i2c-addr", base_addr);
@@ -141,22 +138,20 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,

	rv = platform_device_add_resources(pdev, r, num_r);
	if (rv) {
		dev_err(&pdev->dev,
			"ipmi:dmi: Unable to add resources: %d\n", rv);
		dev_err(&pdev->dev, "Unable to add resources: %d\n", rv);
		goto err;
	}

add_properties:
	rv = platform_device_add_properties(pdev, p);
	if (rv) {
		dev_err(&pdev->dev,
			"ipmi:dmi: Unable to add properties: %d\n", rv);
		dev_err(&pdev->dev, "Unable to add properties: %d\n", rv);
		goto err;
	}

	rv = platform_device_add(pdev);
	if (rv) {
		dev_err(&pdev->dev, "ipmi:dmi: Unable to add device: %d\n", rv);
		dev_err(&pdev->dev, "Unable to add device: %d\n", rv);
		goto err;
	}

@@ -217,6 +212,10 @@ static void __init dmi_decode_ipmi(const struct dmi_header *dm)
	slave_addr = data[DMI_IPMI_SLAVEADDR];

	memcpy(&base_addr, data + DMI_IPMI_ADDR, sizeof(unsigned long));
	if (!base_addr) {
		pr_err("Base address is zero, assuming no IPMI interface\n");
		return;
	}
	if (len >= DMI_IPMI_VER2_LENGTH) {
		if (type == IPMI_DMI_TYPE_SSIF) {
			offset = 0;
@@ -263,7 +262,7 @@ static void __init dmi_decode_ipmi(const struct dmi_header *dm)
				offset = 16;
				break;
			default:
				pr_err("ipmi:dmi: Invalid offset: 0\n");
				pr_err("Invalid offset: 0\n");
				return;
			}
		}
Loading