* [PATCH v2 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
@ 2026-08-17 16:16 Praveen Talari
2026-08-17 16:16 ` [PATCH v2 1/2] dt-bindings: spi: qcom-geni: Document ready-gpios property Praveen Talari
2026-08-17 16:16 ` [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
0 siblings, 2 replies; 5+ messages in thread
From: Praveen Talari @ 2026-08-17 16:16 UTC (permalink / raw)
To: konrad.dybcio, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Andy Gross, Bjorn Andersson
Cc: chandana.chiluveru, Krzysztof Kozlowski, linux-arm-msm, linux-spi,
devicetree, linux-kernel, Praveen Talari
When operating in SPI target mode, the GENI controller relies on an
external GPIO to notify the SPI master about the target's active state.
Add support for an optional device GPIO that is asserted when a target
transfer begins and deasserted when the transfer completes, is aborted,
or hits a timeout. This allows the target to explicitly signal its
availability to the master and ensures the GPIO is released in all error
and completion paths, preventing the master from observing a stale or
incorrect target ready indication.
The ready GPIO is intentionally made optional and is requested only
when target mode is enabled. This preserves existing behaviour for
systems that do not require the signal and avoids regressions on
deployed platforms where the GPIO is already controlled from userspace.
Targets without a ready GPIO continue to operate unchanged by using
devm_gpiod_get_index_optional().
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
Changes in v2:
- Used ready-gpio instead of target-gpio.
- Updated commit text.
- Link to v1: https://patch.msgid.link/20260806-use_gpio_to_notify_master_of_spi_target_activity-v1-0-c363a9b5df69@oss.qualcomm.com
---
Praveen Talari (2):
dt-bindings: spi: qcom-geni: Document ready-gpios property
spi: qcom-geni: Use GPIO to notify master of SPI target activity
.../bindings/spi/qcom,sa8255p-geni-spi.yaml | 9 ++++++++
.../bindings/spi/qcom,spi-geni-qcom.yaml | 9 ++++++++
drivers/spi/spi-geni-qcom.c | 25 ++++++++++++++++++++--
3 files changed, 41 insertions(+), 2 deletions(-)
---
base-commit: 78bc8af4affb9a732504eb22eeac7d1e50883853
change-id: 20260729-use_gpio_to_notify_master_of_spi_target_activity-5f62a9e14875
Best regards,
--
Praveen Talari <praveen.talari@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/2] dt-bindings: spi: qcom-geni: Document ready-gpios property 2026-08-17 16:16 [PATCH v2 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari @ 2026-08-17 16:16 ` Praveen Talari 2026-08-17 16:32 ` Mark Brown 2026-08-17 16:16 ` [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari 1 sibling, 1 reply; 5+ messages in thread From: Praveen Talari @ 2026-08-17 16:16 UTC (permalink / raw) To: konrad.dybcio, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross, Bjorn Andersson Cc: chandana.chiluveru, Krzysztof Kozlowski, linux-arm-msm, linux-spi, devicetree, linux-kernel, Praveen Talari When operating in SPI target (slave) mode, the GENI SPI controller can use an external GPIO to notify the SPI master about the target's active state. Document the optional ready-gpios property for the qcom,spi-geni-qcom and qcom,sa8255p-geni-spi bindings, restricted to spi-slave nodes. Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com> --- Documentation/devicetree/bindings/spi/qcom,sa8255p-geni-spi.yaml | 9 +++++++++ Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.yaml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/qcom,sa8255p-geni-spi.yaml b/Documentation/devicetree/bindings/spi/qcom,sa8255p-geni-spi.yaml index 6552303a4f52..33eddb395a0a 100644 --- a/Documentation/devicetree/bindings/spi/qcom,sa8255p-geni-spi.yaml +++ b/Documentation/devicetree/bindings/spi/qcom,sa8255p-geni-spi.yaml @@ -39,6 +39,12 @@ properties: - const: power - const: perf + ready-gpios: + description: + GPIO used by the SPI target to notify the SPI master when it is + ready to service a transfer. Only applicable in target (slave) mode. + maxItems: 1 + required: - compatible - reg @@ -46,6 +52,9 @@ required: - power-domains - power-domain-names +dependencies: + ready-gpios: [ spi-slave ] + allOf: - $ref: /schemas/spi/spi-controller.yaml# diff --git a/Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.yaml b/Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.yaml index edf399681d7a..8d1c78701657 100644 --- a/Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.yaml +++ b/Documentation/devicetree/bindings/spi/qcom,spi-geni-qcom.yaml @@ -67,6 +67,12 @@ properties: reg: maxItems: 1 + ready-gpios: + description: + GPIO used by the SPI target to notify the SPI master when it is + ready to service a transfer. Only applicable in target (slave) mode. + maxItems: 1 + required: - compatible - clocks @@ -74,6 +80,9 @@ required: - interrupts - reg +dependencies: + ready-gpios: [ spi-slave ] + unevaluatedProperties: false examples: -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: spi: qcom-geni: Document ready-gpios property 2026-08-17 16:16 ` [PATCH v2 1/2] dt-bindings: spi: qcom-geni: Document ready-gpios property Praveen Talari @ 2026-08-17 16:32 ` Mark Brown 0 siblings, 0 replies; 5+ messages in thread From: Mark Brown @ 2026-08-17 16:32 UTC (permalink / raw) To: Praveen Talari Cc: konrad.dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross, Bjorn Andersson, chandana.chiluveru, Krzysztof Kozlowski, linux-arm-msm, linux-spi, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 551 bytes --] On Mon, Aug 17, 2026 at 09:46:52PM +0530, Praveen Talari wrote: > When operating in SPI target (slave) mode, the GENI SPI controller can > use an external GPIO to notify the SPI master about the target's > active state. Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity 2026-08-17 16:16 [PATCH v2 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari 2026-08-17 16:16 ` [PATCH v2 1/2] dt-bindings: spi: qcom-geni: Document ready-gpios property Praveen Talari @ 2026-08-17 16:16 ` Praveen Talari 2026-08-17 16:28 ` sashiko-bot 1 sibling, 1 reply; 5+ messages in thread From: Praveen Talari @ 2026-08-17 16:16 UTC (permalink / raw) To: konrad.dybcio, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Andy Gross, Bjorn Andersson Cc: chandana.chiluveru, Krzysztof Kozlowski, linux-arm-msm, linux-spi, devicetree, linux-kernel, Praveen Talari When operating in SPI target mode, the GENI controller relies on an external GPIO to notify the SPI master about the target's active state. Add support for an optional ready GPIO that is asserted when a target transfer begins and deasserted when the transfer completes, is aborted, or hits a timeout. This allows the target to explicitly signal its availability to the master and ensures the GPIO is released in all error and completion paths, preventing the master from observing a stale or incorrect target-ready indication. The ready GPIO is intentionally made optional and is requested only when target mode is enabled. This preserves existing behaviour for systems that do not require the signal and avoids regressions on deployed platforms where the GPIO is already controlled from userspace. Targets without a ready GPIO continue to operate unchanged by using devm_gpiod_get_index_optional(). Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com> --- drivers/spi/spi-geni-qcom.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index d262206ed663..5ebbeac70382 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -8,6 +8,7 @@ #include <linux/dmaengine.h> #include <linux/dma-mapping.h> #include <linux/dma/qcom-gpi-dma.h> +#include <linux/gpio/consumer.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/log2.h> @@ -113,6 +114,7 @@ struct spi_geni_master { struct dma_chan *rx; int cur_xfer_mode; const struct geni_spi_desc *dev_data; + struct gpio_desc *target_gpio; }; static void spi_slv_setup(struct spi_geni_master *mas) @@ -171,6 +173,9 @@ static void handle_se_timeout(struct spi_controller *spi) xfer = mas->cur_xfer; mas->cur_xfer = NULL; + if (spi->target && mas->target_gpio) + gpiod_set_value(mas->target_gpio, 0); + /* The controller doesn't support the Cancel commnand in target mode */ if (!spi->target) { reinit_completion(&mas->cancel_done); @@ -928,8 +933,12 @@ static int spi_geni_transfer_one(struct spi_controller *spi, if (mas->cur_xfer_mode == GENI_SE_FIFO || mas->cur_xfer_mode == GENI_SE_DMA) { ret = setup_se_xfer(xfer, mas, slv->mode, spi); /* SPI framework expects +ve ret code to wait for transfer complete */ - if (!ret) + if (!ret) { + if (spi->target && mas->target_gpio) + gpiod_set_value(mas->target_gpio, 1); ret = 1; + } + return ret; } return setup_gsi_xfer(xfer, mas, slv, spi); @@ -969,6 +978,8 @@ static irqreturn_t geni_spi_isr(int irq, void *data) if (mas->cur_xfer) { spi_finalize_current_transfer(spi); mas->cur_xfer = NULL; + if (spi->target && mas->target_gpio) + gpiod_set_value(mas->target_gpio, 0); /* * If this happens, then a CMD_DONE came before all the * Tx buffer bytes were sent out. This is unusual, log @@ -1012,6 +1023,8 @@ static irqreturn_t geni_spi_isr(int irq, void *data) if (!mas->tx_rem_bytes && !mas->rx_rem_bytes && xfer) { spi_finalize_current_transfer(spi); mas->cur_xfer = NULL; + if (spi->target && mas->target_gpio) + gpiod_set_value(mas->target_gpio, 0); } } @@ -1116,8 +1129,16 @@ static int spi_geni_probe(struct platform_device *pdev) init_completion(&mas->rx_reset_done); spin_lock_init(&mas->lock); - if (spi->target) + if (spi->target) { spi->target_abort = spi_geni_target_abort; + mas->target_gpio = devm_gpiod_get_index_optional(dev, "ready", 0, + GPIOD_OUT_LOW); + if (IS_ERR(mas->target_gpio)) { + dev_err(dev, "Failed to request GPIO: %ld\n", + PTR_ERR(mas->target_gpio)); + mas->target_gpio = NULL; + } + } pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, 250); -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity 2026-08-17 16:16 ` [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari @ 2026-08-17 16:28 ` sashiko-bot 0 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-08-17 16:28 UTC (permalink / raw) To: Praveen Talari; +Cc: devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] The driver incorrectly swallows errors from `devm_gpiod_get_index_optional()`, breaking deferred probing (-EPROBE_DEFER). - [High] The target ready GPIO is completely ignored when the SPI controller operates in GPI DMA mode (`GENI_GPI_DMA`). - [High] A race condition between hardware initiation and GPIO assertion can leave the ready GPIO permanently stuck high. -- --- Patch [2]: [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity --- commit d3635e8d846f952a724421a12c51192475a16e09 Author: Praveen Talari <praveen.talari@oss.qualcomm.com> spi: qcom-geni: Use GPIO to notify master of SPI target activity When operating in SPI target mode, the GENI controller relies on an external GPIO to notify the SPI master about the target's active state. Add support for an optional ready GPIO that is asserted when a target transfer begins and deasserted when the transfer completes, is aborted, or hits a timeout. This allows the target to explicitly signal its availability to the master and ensures the GPIO is released in all error and completion paths, preventing the master from observing a stale or incorrect target-ready indication. > diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c > index 6c57f8309a3b2..bbe040383d530 100644 > --- a/drivers/spi/spi-geni-qcom.c > +++ b/drivers/spi/spi-geni-qcom.c [ ... ] > @@ -938,8 +943,12 @@ static int spi_geni_transfer_one(struct spi_controller *spi, > if (mas->cur_xfer_mode == GENI_SE_FIFO || mas->cur_xfer_mode == GENI_SE_DMA) { > ret = setup_se_xfer(xfer, mas, slv->mode, spi); > /* SPI framework expects +ve ret code to wait for transfer complete */ > - if (!ret) > + if (!ret) { > + if (spi->target && mas->target_gpio) > + gpiod_set_value(mas->target_gpio, 1); [Severity: High] Is there a race condition here between hardware initiation and GPIO assertion that could leave the ready GPIO permanently stuck high? When setup_se_xfer() arms the hardware and drops the spinlock: drivers/spi/spi-geni-qcom.c:setup_se_xfer() { ... spin_unlock_irq(&mas->lock); return ret; } If the SPI master immediately sends clocks, the hardware can complete the transfer and trigger geni_spi_isr() on another CPU before we assert the GPIO here. The ISR finalizes the transfer and deasserts the GPIO to 0. Afterwards, this code resumes and unconditionally asserts the GPIO to 1, overriding the completed state. > ret = 1; > + } > + > return ret; > } > return setup_gsi_xfer(xfer, mas, slv, spi); [Severity: High] Does this bypass the GPIO assertion logic when the SPI controller operates in GPI DMA mode (GENI_GPI_DMA)? The GPIO assertion logic appears to be restricted to SE DMA and FIFO paths, skipping the GPI DMA fallback path completely. Furthermore, is the GPIO deassertion also missing in the GPI DMA completion handler? drivers/spi/spi-geni-qcom.c:spi_gsi_callback_result() { ... if (!result->residue) { spi->cur_msg->status = 0; dev_dbg(&spi->dev, "DMA txn completed\n"); } ... } [ ... ] > @@ -1131,8 +1144,16 @@ static int spi_geni_probe(struct platform_device *pdev) > init_completion(&mas->rx_reset_done); > spin_lock_init(&mas->lock); > > - if (spi->target) > + if (spi->target) { > spi->target_abort = spi_geni_target_abort; > + mas->target_gpio = devm_gpiod_get_index_optional(dev, "ready", 0, > + GPIOD_OUT_LOW); > + if (IS_ERR(mas->target_gpio)) { > + dev_err(dev, "Failed to request GPIO: %ld\n", > + PTR_ERR(mas->target_gpio)); > + mas->target_gpio = NULL; [Severity: High] Does this incorrectly swallow errors from devm_gpiod_get_index_optional(), breaking deferred probing (-EPROBE_DEFER)? If the GPIO provider probes after the SPI controller, devm_gpiod_get_index_optional() will return -EPROBE_DEFER, but this catches the error, logs it, and sets the pointer to NULL instead of propagating the error to allow retrying later. > + } > + } > > pm_runtime_use_autosuspend(&pdev->dev); > pm_runtime_set_autosuspend_delay(&pdev->dev, 250); -- Sashiko AI review · https://sashiko.dev/#/patchset/20260817-use_gpio_to_notify_master_of_spi_target_activity-v2-0-94d1eff3175f@oss.qualcomm.com?part=2 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-17 16:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-17 16:16 [PATCH v2 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari 2026-08-17 16:16 ` [PATCH v2 1/2] dt-bindings: spi: qcom-geni: Document ready-gpios property Praveen Talari 2026-08-17 16:32 ` Mark Brown 2026-08-17 16:16 ` [PATCH v2 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari 2026-08-17 16:28 ` sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox