Skip to contentSkip to conversation

ipmi: Add the i2c-addr property for SSIF interfaces

PATCH New [email protected] 1 participant 2 messages Apr 24, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/4 ipmi: Add the i2c-addr property for SSIF interfaces

From: Corey Minyard <[email protected]>

This is required for SSIF to work.

There was no way to know if the interface being added was SI or SSIF from the platform data, but that was required so the i2c-addr is only added for SSIF interfaces. So add a field for that.

Also rework the logic a bit so that ipmi-type is not set for SSIF interfaces, as it is not necessary for that.

Fixes 3cd83bac481d ("ipmi: Consolidate the adding of platform devices")
---
 drivers/char/ipmi/ipmi_dmi.c         |  2 ++
 drivers/char/ipmi/ipmi_plat_data.c   | 27 +++++++++++++++------------
 drivers/char/ipmi/ipmi_plat_data.h   |  3 +++
 drivers/char/ipmi/ipmi_si_hardcode.c |  1 +
 drivers/char/ipmi/ipmi_si_hotmod.c   |  1 +
 5 files changed, 22 insertions(+), 12 deletions(-)
drivers/char/ipmi/ipmi_dmi.c +2 -0
index f2411468f33f..f38e651dd1b5 100644
@@ -47,9 +47,11 @@ static void __init dmi_add_platform_ipmi(unsigned long base_addr,
 	memset(&p, 0, sizeof(p));
 
 	name = "dmi-ipmi-si";
+	p.iftype = IPMI_PLAT_IF_SI;
 	switch (type) {
 	case IPMI_DMI_TYPE_SSIF:
 		name = "dmi-ipmi-ssif";
+		p.iftype = IPMI_PLAT_IF_SSIF;
 		p.type = SI_TYPE_INVALID;
 		break;
 	case IPMI_DMI_TYPE_BT:
drivers/char/ipmi/ipmi_plat_data.c +15 -12
index 8f0ca2a848eb..28471ff2a3a3 100644
@@ -12,7 +12,7 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst,
 					  struct ipmi_plat_data *p)
 {
 	struct platform_device *pdev;
-	unsigned int num_r = 1, size, pidx = 0;
+	unsigned int num_r = 1, size = 0, pidx = 0;
 	struct resource r[4];
 	struct property_entry pr[6];
 	u32 flags;
@@ -21,19 +21,22 @@ struct platform_device *ipmi_platform_add(const char *name, unsigned int inst,
 	memset(pr, 0, sizeof(pr));
 	memset(r, 0, sizeof(r));
 
-	if (p->type == SI_BT)
-		size = 3;
-	else if (p->type == SI_TYPE_INVALID)
-		size = 0;
-	else
-		size = 2;
+	if (p->iftype == IPMI_PLAT_IF_SI) {
+		if (p->type == SI_BT)
+			size = 3;
+		else if (p->type != SI_TYPE_INVALID)
+			size = 2;
+
+		if (p->regsize == 0)
+			p->regsize = DEFAULT_REGSIZE;
+		if (p->regspacing == 0)
+			p->regspacing = p->regsize;
 
-	if (p->regsize == 0)
-		p->regsize = DEFAULT_REGSIZE;
-	if (p->regspacing == 0)
-		p->regspacing = p->regsize;
+		pr[pidx++] = PROPERTY_ENTRY_U8("ipmi-type", p->type);
+	} else if (p->iftype == IPMI_PLAT_IF_SSIF) {
+		pr[pidx++] = PROPERTY_ENTRY_U16("i2c-addr", p->addr);
+	}
 
-	pr[pidx++] = PROPERTY_ENTRY_U8("ipmi-type", p->type);
 	if (p->slave_addr)
 		pr[pidx++] = PROPERTY_ENTRY_U8("slave-addr", p->slave_addr);
 	pr[pidx++] = PROPERTY_ENTRY_U8("addr-source", p->addr_source);
drivers/char/ipmi/ipmi_plat_data.h +3 -0
index 567cfcec8ada..9ba744ea9571 100644
@@ -6,7 +6,10 @@
 
 #include <linux/ipmi.h>
 
+enum ipmi_plat_interface_type { IPMI_PLAT_IF_SI, IPMI_PLAT_IF_SSIF };
+
 struct ipmi_plat_data {
+	enum ipmi_plat_interface_type iftype;
 	unsigned int type; /* si_type for si, SI_INVALID for others */
 	unsigned int space; /* addr_space for si, intf# for ssif. */
 	unsigned long addr;
drivers/char/ipmi/ipmi_si_hardcode.c +1 -0
index 682221eebd66..f6ece7569504 100644
@@ -83,6 +83,7 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
 
 	memset(&p, 0, sizeof(p));
 
+	p.iftype = IPMI_PLAT_IF_SI;
 	if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) {
 		p.type = SI_KCS;
 	} else if (strcmp(si_type_str, "smic") == 0) {
drivers/char/ipmi/ipmi_si_hotmod.c +1 -0
index 03140f6cdf6f..42a925f8cf69 100644
@@ -108,6 +108,7 @@ static int parse_hotmod_str(const char *curr, enum hotmod_op *op,
 	int rv;
 	unsigned int ival;
 
+	h->iftype = IPMI_PLAT_IF_SI;
 	rv = parse_str(hotmod_ops, &ival, "operation", &curr);
 	if (rv)
 		return rv;
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/4 ipmi:ssif: compare block number correctly for multi-part return messages

In reply to a message not in the archive

From: Kamlakant Patel <[email protected]>

According to ipmi spec, block number is a number that is incremented, starting with 0, for each new block of message data returned using the middle transaction.

Here, the 'blocknum' is data[0] which always starts from zero(0) and 'ssif_info->multi_pos' starts from 1.
So, we need to add +1 to blocknum while comparing with multi_pos.

Fixes 7d6380cd40f79 ("ipmi:ssif: Fix handling of multi-part return messages").

Message-Id: <[email protected]>

[Also added a debug log if the block numbers don't match.]
---
 drivers/char/ipmi/ipmi_ssif.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/char/ipmi/ipmi_ssif.c +5 -1
index 8b5aec5430f1..aaccb0ff1ea6 100644
@@ -727,12 +727,16 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 			/* End of read */
 			len = ssif_info->multi_len;
 			data = ssif_info->data;
-		} else if (blocknum != ssif_info->multi_pos) {
+		} else if (blocknum + 1 != ssif_info->multi_pos) {
 			/*
 			 * Out of sequence block, just abort.  Block
 			 * numbers start at zero for the second block,
 			 * but multi_pos starts at one, so the +1.
 			 */
+			if (ssif_info->ssif_debug & SSIF_DEBUG_MSG)
+				dev_dbg(&ssif_info->client->dev,
+					"Received message out of sequence, expected %u, got %u\n",
+					ssif_info->multi_pos - 1, blocknum);
 			result = -EIO;
 		} else {
 			ssif_inc_stat(ssif_info, received_message_parts);
Signature · 1 line
2.17.1