From f1ea8481c2ae57930777910e5b8deb9f46d01c18 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Pince Date: Mon, 31 Jul 2023 14:58:56 +0200 Subject: Fix hsspi retention sleep race condition When the QM goes to retention sleep and the host wants to send a HSSPI message, there is a wait condition that will lead the host to wait SS_READY_TIMEOUT_MS before actually sending the message. This leads to extra timeouts on the host side. Bug: 291788159 Change-Id: Iad9f01a1758d5b5661f170ce456fbc73ae9a235c Signed-off-by: Jean-Christophe Pince --- hsspi.c | 5 +++++ hsspi.h | 1 + qm35-spi.c | 4 ++++ qm35.h | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hsspi.c b/hsspi.c index 3e361c3..1170ca1 100644 --- a/hsspi.c +++ b/hsspi.c @@ -139,6 +139,8 @@ static int hsspi_wait_ss_ready(struct hsspi *hsspi) { int ret; + hsspi->waiting_ss_rdy = true; + if (!test_bit(HSSPI_FLAGS_SS_BUSY, hsspi->flags)) { /* The ss_ready went low, so the fw is not busy anymore, * if the ss_ready is high, we can proceed, else, @@ -178,6 +180,8 @@ static int hsspi_wait_ss_ready(struct hsspi *hsspi) */ if (!gpiod_get_value(hsspi->gpio_ss_rdy)) return -EAGAIN; + + hsspi->waiting_ss_rdy = false; return 0; } @@ -266,6 +270,7 @@ static int spi_xfer(struct hsspi *hsspi, const void *tx, void *rx, hsspi->soc->flags); } + hsspi->waiting_ss_rdy = false; return ret; } diff --git a/hsspi.h b/hsspi.h index 9a2e65a..c57c849 100644 --- a/hsspi.h +++ b/hsspi.h @@ -174,6 +174,7 @@ struct hsspi { struct gpio_desc *gpio_exton; volatile bool xfer_ongoing; + volatile bool waiting_ss_rdy; }; /** diff --git a/qm35-spi.c b/qm35-spi.c index 7a7960e..00bd360 100644 --- a/qm35-spi.c +++ b/qm35-spi.c @@ -392,6 +392,10 @@ static irqreturn_t qm35_exton_handler(int irq, void *data) struct qm35_ctx *qm35_hdl = data; hsspi_clear_spi_slave_ready(&qm35_hdl->hsspi); + + if (qm35_hdl->hsspi.waiting_ss_rdy) + qm35_wakeup(&qm35_hdl->hsspi); + return IRQ_HANDLED; } diff --git a/qm35.h b/qm35.h index ea087fe..abbf505 100644 --- a/qm35.h +++ b/qm35.h @@ -24,7 +24,7 @@ #define QM_BOOT_MS 450 #define QM_BEFORE_RESET_MS 450 -#define DRV_VERSION "6.3.1-rc2" +#define DRV_VERSION "6.3.2-rc1" struct regulator; -- cgit v1.2.3