linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] platform: chrome: Simplify interrupt path
@ 2021-01-22  5:46 Gwendal Grignou
  2021-01-22  5:46 ` [PATCH v2 1/2] platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode Gwendal Grignou
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gwendal Grignou @ 2021-01-22  5:46 UTC (permalink / raw)
  To: rdunlap, groeck, enric.balletbo, bleung; +Cc: linux-kernel, Gwendal Grignou

rrespective of the transport (i2c, spi, ish, rpmsg), have all cros ec
interrupt stack call the threaded part (bottom half) of the interrupt
handler.
Fix an issue where EC could be stuck if it sends a message while the AP
is not powered on.

Changes since v1:
- fix merging issue and function comments syntax.

Gwendal Grignou (2):
  platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode
  platform: cros_ec: Call interrupt bottom half at probe time

 drivers/platform/chrome/cros_ec.c       | 33 ++++++++++++++++++++-----
 drivers/platform/chrome/cros_ec.h       |  4 ++-
 drivers/platform/chrome/cros_ec_ishtp.c |  6 +----
 drivers/platform/chrome/cros_ec_rpmsg.c |  6 +----
 4 files changed, 32 insertions(+), 17 deletions(-)

-- 
2.30.0.280.ga3ce27912f-goog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode
  2021-01-22  5:46 [PATCH v2 0/2] platform: chrome: Simplify interrupt path Gwendal Grignou
@ 2021-01-22  5:46 ` Gwendal Grignou
  2021-01-22  5:46 ` [PATCH v2 2/2] platform: cros_ec: Call interrupt bottom half at probe time Gwendal Grignou
  2021-01-26  9:25 ` [PATCH v2 0/2] platform: chrome: Simplify interrupt path Enric Balletbo i Serra
  2 siblings, 0 replies; 4+ messages in thread
From: Gwendal Grignou @ 2021-01-22  5:46 UTC (permalink / raw)
  To: rdunlap, groeck, enric.balletbo, bleung; +Cc: linux-kernel, Gwendal Grignou

Call the same bottom half for all EC protocols (threaded code).

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
Changes since v1:
- Fix merge issues, make changes in cros_ec.h instead of cros_ec_proto.h
- Fix function comments syntax.

 drivers/platform/chrome/cros_ec.c       | 26 +++++++++++++++++++------
 drivers/platform/chrome/cros_ec.h       |  4 +++-
 drivers/platform/chrome/cros_ec_ishtp.c |  6 +-----
 drivers/platform/chrome/cros_ec_rpmsg.c |  6 +-----
 4 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 3104680b7485..bf76a6c49c95 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -32,7 +32,14 @@ static struct cros_ec_platform pd_p = {
 	.cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX),
 };
 
-static irqreturn_t ec_irq_handler(int irq, void *data)
+/**
+ * cros_ec_irq_handler() - top half part of the interrupt handler
+ * @irq: IRQ id
+ * @data: (ec_dev) Device with events to process.
+ *
+ * Return: Wakeup the bottom half
+ */
+static irqreturn_t cros_ec_irq_handler(int irq, void *data)
 {
 	struct cros_ec_device *ec_dev = data;
 
@@ -51,7 +58,7 @@ static irqreturn_t ec_irq_handler(int irq, void *data)
  * Return: true if more events are still pending and this function should be
  * called again.
  */
-bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
+static bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
 {
 	bool wake_event;
 	bool ec_has_more_events;
@@ -73,9 +80,15 @@ bool cros_ec_handle_event(struct cros_ec_device *ec_dev)
 
 	return ec_has_more_events;
 }
-EXPORT_SYMBOL(cros_ec_handle_event);
 
-static irqreturn_t ec_irq_thread(int irq, void *data)
+/**
+ * cros_ec_irq_thread() - bottom half part of the interrupt handler
+ * @irq: IRQ id
+ * @data: (ec_dev) Device with events to process.
+ *
+ * Return: Interrupt handled.
+ */
+irqreturn_t cros_ec_irq_thread(int irq, void *data)
 {
 	struct cros_ec_device *ec_dev = data;
 	bool ec_has_more_events;
@@ -86,6 +99,7 @@ static irqreturn_t ec_irq_thread(int irq, void *data)
 
 	return IRQ_HANDLED;
 }
+EXPORT_SYMBOL(cros_ec_irq_thread);
 
 static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
 {
@@ -194,8 +208,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 
 	if (ec_dev->irq > 0) {
 		err = devm_request_threaded_irq(dev, ec_dev->irq,
-						ec_irq_handler,
-						ec_irq_thread,
+						cros_ec_irq_handler,
+						cros_ec_irq_thread,
 						IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 						"chromeos-ec", ec_dev);
 		if (err) {
diff --git a/drivers/platform/chrome/cros_ec.h b/drivers/platform/chrome/cros_ec.h
index e69fc1ff68b4..78363dcfdf23 100644
--- a/drivers/platform/chrome/cros_ec.h
+++ b/drivers/platform/chrome/cros_ec.h
@@ -8,12 +8,14 @@
 #ifndef __CROS_EC_H
 #define __CROS_EC_H
 
+#include <linux/interrupt.h>
+
 int cros_ec_register(struct cros_ec_device *ec_dev);
 int cros_ec_unregister(struct cros_ec_device *ec_dev);
 
 int cros_ec_suspend(struct cros_ec_device *ec_dev);
 int cros_ec_resume(struct cros_ec_device *ec_dev);
 
-bool cros_ec_handle_event(struct cros_ec_device *ec_dev);
+irqreturn_t cros_ec_irq_thread(int irq, void *data);
 
 #endif /* __CROS_EC_H */
diff --git a/drivers/platform/chrome/cros_ec_ishtp.c b/drivers/platform/chrome/cros_ec_ishtp.c
index 81364029af36..f00107017318 100644
--- a/drivers/platform/chrome/cros_ec_ishtp.c
+++ b/drivers/platform/chrome/cros_ec_ishtp.c
@@ -140,12 +140,8 @@ static void ish_evt_handler(struct work_struct *work)
 {
 	struct ishtp_cl_data *client_data =
 		container_of(work, struct ishtp_cl_data, work_ec_evt);
-	struct cros_ec_device *ec_dev = client_data->ec_dev;
-	bool ec_has_more_events;
 
-	do {
-		ec_has_more_events = cros_ec_handle_event(ec_dev);
-	} while (ec_has_more_events);
+	cros_ec_irq_thread(0, client_data->ec_dev);
 }
 
 /**
diff --git a/drivers/platform/chrome/cros_ec_rpmsg.c b/drivers/platform/chrome/cros_ec_rpmsg.c
index 30d0ba3b8889..d96d15b8ca94 100644
--- a/drivers/platform/chrome/cros_ec_rpmsg.c
+++ b/drivers/platform/chrome/cros_ec_rpmsg.c
@@ -149,12 +149,8 @@ cros_ec_rpmsg_host_event_function(struct work_struct *host_event_work)
 	struct cros_ec_rpmsg *ec_rpmsg = container_of(host_event_work,
 						      struct cros_ec_rpmsg,
 						      host_event_work);
-	struct cros_ec_device *ec_dev = dev_get_drvdata(&ec_rpmsg->rpdev->dev);
-	bool ec_has_more_events;
 
-	do {
-		ec_has_more_events = cros_ec_handle_event(ec_dev);
-	} while (ec_has_more_events);
+	cros_ec_irq_thread(0, dev_get_drvdata(&ec_rpmsg->rpdev->dev));
 }
 
 static int cros_ec_rpmsg_callback(struct rpmsg_device *rpdev, void *data,
-- 
2.30.0.280.ga3ce27912f-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] platform: cros_ec: Call interrupt bottom half at probe time
  2021-01-22  5:46 [PATCH v2 0/2] platform: chrome: Simplify interrupt path Gwendal Grignou
  2021-01-22  5:46 ` [PATCH v2 1/2] platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode Gwendal Grignou
@ 2021-01-22  5:46 ` Gwendal Grignou
  2021-01-26  9:25 ` [PATCH v2 0/2] platform: chrome: Simplify interrupt path Enric Balletbo i Serra
  2 siblings, 0 replies; 4+ messages in thread
From: Gwendal Grignou @ 2021-01-22  5:46 UTC (permalink / raw)
  To: rdunlap, groeck, enric.balletbo, bleung; +Cc: linux-kernel, Gwendal Grignou

While the AP was powered off, the EC may have send messages.
If the message is not serviced within 3s, the EC stops sending message.
Unlock the EC by purging stale messages at probe time.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
Changes since v1: None.

 drivers/platform/chrome/cros_ec.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index bf76a6c49c95..fc5aa1525d13 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -283,6 +283,13 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 
 	dev_info(dev, "Chrome EC device registered\n");
 
+	/*
+	 * Unlock EC that may be waiting for AP to process MKBP events.
+	 * If the AP takes to long to answer, the EC would stop sending events.
+	 */
+	if (ec_dev->mkbp_event_supported)
+		cros_ec_irq_thread(0, ec_dev);
+
 	return 0;
 }
 EXPORT_SYMBOL(cros_ec_register);
-- 
2.30.0.280.ga3ce27912f-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] platform: chrome: Simplify interrupt path
  2021-01-22  5:46 [PATCH v2 0/2] platform: chrome: Simplify interrupt path Gwendal Grignou
  2021-01-22  5:46 ` [PATCH v2 1/2] platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode Gwendal Grignou
  2021-01-22  5:46 ` [PATCH v2 2/2] platform: cros_ec: Call interrupt bottom half at probe time Gwendal Grignou
@ 2021-01-26  9:25 ` Enric Balletbo i Serra
  2 siblings, 0 replies; 4+ messages in thread
From: Enric Balletbo i Serra @ 2021-01-26  9:25 UTC (permalink / raw)
  To: Gwendal Grignou, groeck, rdunlap, bleung; +Cc: linux-kernel

On Thu, 21 Jan 2021 21:46:35 -0800, Gwendal Grignou wrote:
> rrespective of the transport (i2c, spi, ish, rpmsg), have all cros ec
> interrupt stack call the threaded part (bottom half) of the interrupt
> handler.
> Fix an issue where EC could be stuck if it sends a message while the AP
> is not powered on.
> 
> Changes since v1:
> - fix merging issue and function comments syntax.
> 
> [...]

Applied, thanks!

[1/2] platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode
      commit: 24c69043be1725606e876b47d496a0f9f87d176a
[2/2] platform: cros_ec: Call interrupt bottom half at probe time
      commit: 4daeb395f1754340927d8d58269593e4e3b6afcd

Best regards,
-- 
Enric Balletbo i Serra <enric.balletbo@collabora.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-26 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22  5:46 [PATCH v2 0/2] platform: chrome: Simplify interrupt path Gwendal Grignou
2021-01-22  5:46 ` [PATCH v2 1/2] platform: cros_ec: Call interrupt bottom half in ISH or RPMSG mode Gwendal Grignou
2021-01-22  5:46 ` [PATCH v2 2/2] platform: cros_ec: Call interrupt bottom half at probe time Gwendal Grignou
2021-01-26  9:25 ` [PATCH v2 0/2] platform: chrome: Simplify interrupt path Enric Balletbo i Serra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).