Skip to contentSkip to conversation

mei: reset flow fix

PATCH New Tomas Winkler 1 participant 3 messages Feb 2, 2017

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

cover mei: reset flow fix

These patches should fix possible stall after device reset. The patches should be applied to the stable kernels 4.4 and newer as well, however, they do not apply cleanly hence a separate
patch will be sent after are applied upstream.

Alexander Usyskin (2):
mei: me: add a wrapper to set host generated data interrupt
mei: me: generate an interrupt if the hw indicates reset.

 drivers/misc/mei/hw-me.c | 37 +++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 mei: me: add a wrapper to set host generated data interrupt

From: Alexander Usyskin <[email protected]>

Consolidate setting H_IG, an interrupt from host towards hw, into a wrapper to eliminate code duplication.

---
 drivers/misc/mei/hw-me.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/misc/mei/hw-me.c +15 -6
index befeac52c349..23294b845c42 100644
@@ -140,6 +140,19 @@ static inline void mei_hcsr_set(struct mei_device *dev, u32 reg)
 }
 
 /**
+ * mei_hcsr_set_hig - set host interrupt (set H_IG)
+ *
+ * @dev: the device structure
+ */
+static inline void mei_hcsr_set_hig(struct mei_device *dev)
+{
+	u32 hcsr;
+
+	hcsr = mei_hcsr_read(dev) | H_IG;
+	mei_hcsr_set(dev, hcsr);
+}
+
+/**
  * mei_me_d0i3c_read - Reads 32bit data from the D0I3C register
  *
  * @dev: the device structure
@@ -505,7 +518,6 @@ static int mei_me_hbuf_write(struct mei_device *dev,
 	unsigned long rem;
 	unsigned long length = header->length;
 	u32 *reg_buf = (u32 *)buf;
-	u32 hcsr;
 	u32 dw_cnt;
 	int i;
 	int empty_slots;
@@ -532,8 +544,7 @@ static int mei_me_hbuf_write(struct mei_device *dev,
 		mei_me_hcbww_write(dev, reg);
 	}
 
-	hcsr = mei_hcsr_read(dev) | H_IG;
-	mei_hcsr_set(dev, hcsr);
+	mei_hcsr_set_hig(dev);
 	if (!mei_me_hw_is_ready(dev))
 		return -EIO;
 
@@ -580,7 +591,6 @@ static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer,
 		    unsigned long buffer_length)
 {
 	u32 *reg_buf = (u32 *)buffer;
-	u32 hcsr;
 
 	for (; buffer_length >= sizeof(u32); buffer_length -= sizeof(u32))
 		*reg_buf++ = mei_me_mecbrw_read(dev);
@@ -591,8 +601,7 @@ static int mei_me_read_slots(struct mei_device *dev, unsigned char *buffer,
 		memcpy(reg_buf, &reg, buffer_length);
 	}
 
-	hcsr = mei_hcsr_read(dev) | H_IG;
-	mei_hcsr_set(dev, hcsr);
+	mei_hcsr_set_hig(dev);
 	return 0;
 }
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 mei: me: generate an interrupt if the hw indicates reset.

In reply to Tomas Winkler

From: Alexander Usyskin <[email protected]>

In rare case the driver may lose connection with the device after device reset due to a missed interrupt. The driver will unlock the flow by generating an interrupt towards the firmware (HIG) when the device is in the resetting state. The FW is able to ignore the interrupt during orderly flow. The effected platforms are skylake and newer.

---
 drivers/misc/mei/hw-me.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/misc/mei/hw-me.c +16 -0
index 23294b845c42..71216affcab1 100644
@@ -394,6 +394,19 @@ static bool mei_me_hw_is_ready(struct mei_device *dev)
 }
 
 /**
+ * mei_me_hw_is_resetting - check whether the me(hw) is in reset
+ *
+ * @dev: mei device
+ * Return: bool
+ */
+static bool mei_me_hw_is_resetting(struct mei_device *dev)
+{
+	u32 mecsr = mei_me_mecsr_read(dev);
+
+	return (mecsr & ME_RST_HRA) == ME_RST_HRA;
+}
+
+/**
  * mei_me_hw_ready_wait - wait until the me(hw) has turned ready
  *  or timeout is reached
  *
@@ -1219,6 +1232,9 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
 		goto end;
 	}
 
+	if (mei_me_hw_is_resetting(dev))
+		mei_hcsr_set_hig(dev);
+
 	mei_me_pg_intr(dev, me_intr_src(hcsr));
 
 	/*  check if we need to start the dev */
Signature · 1 line
2.7.4