* [PATCH v5 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
@ 2026-09-26 19:56 Praveen Talari
2026-09-26 19:56 ` [PATCH v5 1/2] spi: dt-bindings: Document ready-gpios property Praveen Talari
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Praveen Talari @ 2026-09-26 19:56 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, Krzysztof Kozlowski
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_optional().
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
Changes in v5:
- Use dev_err_probe() when the optional ready GPIO request fails,
instead of silently clearing it to NULL, so probe deferral and
genuine GPIO errors are handled correctly.
- Link to v4: https://patch.msgid.link/20260824-use_gpio_to_notify_master_of_spi_target_activity-v4-0-fde2ebf043db@oss.qualcomm.com
Changes in v4:
- Used devm_gpiod_get_optional() instead of
devm_gpiod_get_index_optional(), since a single GPIO is requested.
- Dropped the redundant mas->ready_gpio NULL checks before
gpiod_set_value(), since it already handles a NULL descriptor.
- Renamed target_gpio to ready_gpio to match the property name.
- Link to v3: https://patch.msgid.link/20260818-use_gpio_to_notify_master_of_spi_target_activity-v3-0-e1c9e0dabbda@oss.qualcomm.com
Changes in v3:
- Rebased on linux-next tip.
- Link to v2: https://patch.msgid.link/20260817-use_gpio_to_notify_master_of_spi_target_activity-v2-0-94d1eff3175f@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):
spi: dt-bindings: Document ready-gpios property
spi: qcom-geni: Use GPIO to notify master of SPI target activity
.../bindings/spi/qcom,sa8255p-geni-spi.yaml | 9 +++++++++
.../devicetree/bindings/spi/qcom,spi-geni-qcom.yaml | 9 +++++++++
drivers/spi/spi-geni-qcom.c | 21 +++++++++++++++++++--
3 files changed, 37 insertions(+), 2 deletions(-)
---
base-commit: f5f84daefcd92d7a630066635ecea1433ed5eac7
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 v5 1/2] spi: dt-bindings: Document ready-gpios property
2026-09-26 19:56 [PATCH v5 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
@ 2026-09-26 19:56 ` Praveen Talari
2026-09-26 19:56 ` [PATCH v5 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-10-04 19:54 ` [PATCH v5 0/2] " Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Praveen Talari @ 2026-09-26 19:56 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, Krzysztof Kozlowski
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.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
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
* [PATCH v5 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
2026-09-26 19:56 [PATCH v5 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-09-26 19:56 ` [PATCH v5 1/2] spi: dt-bindings: Document ready-gpios property Praveen Talari
@ 2026-09-26 19:56 ` Praveen Talari
2026-09-26 20:06 ` sashiko-bot
2026-10-04 19:54 ` [PATCH v5 0/2] " Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: Praveen Talari @ 2026-09-26 19:56 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_optional().
Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
drivers/spi/spi-geni-qcom.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index bced6279a062..91e75e213f92 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -10,6 +10,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/iopoll.h>
@@ -118,6 +119,7 @@ struct spi_geni_master {
int cur_xfer_mode;
const struct geni_spi_desc *dev_data;
struct notifier_block panic_nb;
+ struct gpio_desc *ready_gpio;
};
static void spi_slv_setup(struct spi_geni_master *mas)
@@ -176,6 +178,9 @@ static void handle_se_timeout(struct spi_controller *spi)
xfer = mas->cur_xfer;
mas->cur_xfer = NULL;
+ if (spi->target)
+ gpiod_set_value(mas->ready_gpio, 0);
+
/* The controller doesn't support the Cancel commnand in target mode */
if (!spi->target) {
reinit_completion(&mas->cancel_done);
@@ -936,8 +941,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)
+ gpiod_set_value(mas->ready_gpio, 1);
ret = 1;
+ }
+
return ret;
}
return setup_gsi_xfer(xfer, mas, slv, spi);
@@ -1023,6 +1032,8 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
if (dma_rx_status & RX_RESET_DONE)
complete(&mas->rx_reset_done);
if (!mas->tx_rem_bytes && !mas->rx_rem_bytes && xfer) {
+ if (spi->target)
+ gpiod_set_value(mas->ready_gpio, 0);
spi_finalize_current_transfer(spi);
mas->cur_xfer = NULL;
}
@@ -1192,8 +1203,14 @@ 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->ready_gpio = devm_gpiod_get_optional(dev, "ready",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(mas->ready_gpio))
+ return dev_err_probe(dev, PTR_ERR(mas->ready_gpio),
+ "Failed to request GPIO\n");
+ }
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 v5 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
2026-09-26 19:56 ` [PATCH v5 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
@ 2026-09-26 20:06 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-26 20:06 UTC (permalink / raw)
To: Praveen Talari; +Cc: robh, devicetree, conor+dt
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] spi: qcom-geni: missing ready_gpio deassertion in GENI_SE_FIFO mode
- [High] spi: qcom-geni: ready_gpio completely unhandled in GENI_GPI_DMA mode
--
commit b777efb262a38b2b19686188b7453a1af9e45b0c
Author: Praveen Talari <praveen.talari@oss.qualcomm.com>
spi: qcom-geni: Use GPIO to notify master of SPI target activity
This commit adds an optional ready GPIO to notify the SPI master of the
target's active state when operating in SPI target mode. The GPIO is
asserted when a transfer begins and deasserted upon completion, abort,
or timeout.
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index bced6279a0624..91e75e213f929 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
[ ... ]
> @@ -936,8 +941,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)
> + gpiod_set_value(mas->ready_gpio, 1);
> ret = 1;
> + }
> +
> return ret;
> }
> return setup_gsi_xfer(xfer, mas, slv, spi);
[Severity: High]
Should ready_gpio be asserted and deasserted for GENI_GPI_DMA mode as well?
If the hardware configuration supports GPI DMA, spi_geni_init() can select
GENI_GPI_DMA mode for the target. When spi_geni_transfer_one() delegates
directly to setup_gsi_xfer() here, the ready_gpio assertion is skipped.
Similarly, the DMA completion in spi_gsi_callback_result() does not seem to
deassert the GPIO.
Could this cause the SPI master to wait indefinitely for the ready signal on
platforms with GPI DMA enabled, leading to bus stalls and total communication
failure?
[ ... ]
> @@ -1023,6 +1032,8 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
> if (dma_rx_status & RX_RESET_DONE)
> complete(&mas->rx_reset_done);
> if (!mas->tx_rem_bytes && !mas->rx_rem_bytes && xfer) {
> + if (spi->target)
> + gpiod_set_value(mas->ready_gpio, 0);
> spi_finalize_current_transfer(spi);
> mas->cur_xfer = NULL;
> }
[Severity: High]
Does the GENI_SE_FIFO mode completion path in geni_spi_isr() also need to
deassert ready_gpio?
When a target SPI transfer falls back to GENI_SE_FIFO mode and the transfer
completes, geni_spi_isr() processes M_CMD_DONE_EN, calls
spi_finalize_current_transfer(), and clears mas->cur_xfer:
drivers/spi/spi-geni-qcom.c:geni_spi_isr() {
...
if (mas->cur_xfer_mode == GENI_SE_FIFO) {
...
if (m_irq & M_CMD_DONE_EN) {
if (mas->cur_xfer) {
spi_finalize_current_transfer(spi);
mas->cur_xfer = NULL;
...
}
However, the GPIO doesn't appear to be deasserted in this path.
If the ready_gpio remains permanently asserted after the first GENI_SE_FIFO
transfer completes successfully, could this break the target-ready handshake
protocol and cause the SPI master to incorrectly perceive the target as always
ready?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260927-use_gpio_to_notify_master_of_spi_target_activity-v5-0-9b973623080f@oss.qualcomm.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v5 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
2026-09-26 19:56 [PATCH v5 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-09-26 19:56 ` [PATCH v5 1/2] spi: dt-bindings: Document ready-gpios property Praveen Talari
2026-09-26 19:56 ` [PATCH v5 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
@ 2026-10-04 19:54 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-10-04 19:54 UTC (permalink / raw)
To: konrad.dybcio, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Andy Gross, Bjorn Andersson, Praveen Talari
Cc: chandana.chiluveru, Krzysztof Kozlowski, linux-arm-msm, linux-spi,
devicetree, linux-kernel, Krzysztof Kozlowski
On Sun, 27 Sep 2026 01:26:32 +0530, Praveen Talari wrote:
> 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 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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.4
Thanks!
[1/2] spi: dt-bindings: Document ready-gpios property
https://git.kernel.org/broonie/spi/c/ae0f8f861e28
[2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity
https://git.kernel.org/broonie/spi/c/bb5805a74e75
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-05 16:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-26 19:56 [PATCH v5 0/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-09-26 19:56 ` [PATCH v5 1/2] spi: dt-bindings: Document ready-gpios property Praveen Talari
2026-09-26 19:56 ` [PATCH v5 2/2] spi: qcom-geni: Use GPIO to notify master of SPI target activity Praveen Talari
2026-09-26 20:06 ` sashiko-bot
2026-10-04 19:54 ` [PATCH v5 0/2] " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox