[PATCH v1 3/3] spi: geni-qcom: Add target abort support

Praveen Talari posted 3 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH v1 3/3] spi: geni-qcom: Add target abort support
Posted by Praveen Talari 2 weeks, 4 days ago
SPI target mode currently lacks a mechanism to gracefully abort ongoing
transfers when the client or core needs to cancel active transactions.

Implement spi_geni_target_abort() to handle aborting SPI target
operations when the client and core want to cancel ongoing transfers.
This provides a mechanism for graceful termination of active SPI
transactions in target mode.

Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
---
 drivers/spi/spi-geni-qcom.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index e5320e2fb834..231fd31de048 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -1009,6 +1009,17 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static int spi_geni_target_abort(struct spi_controller *spi)
+{
+	if (!spi->cur_msg)
+		return 0;
+
+	handle_se_timeout(spi, spi->cur_msg);
+	spi_finalize_current_transfer(spi);
+
+	return 0;
+}
+
 static int spi_geni_probe(struct platform_device *pdev)
 {
 	int ret, irq;
@@ -1082,6 +1093,9 @@ static int spi_geni_probe(struct platform_device *pdev)
 	init_completion(&mas->rx_reset_done);
 	spin_lock_init(&mas->lock);
 
+	if (spi->target)
+		spi->target_abort = spi_geni_target_abort;
+
 	ret = geni_icc_get(&mas->se, NULL);
 	if (ret)
 		return ret;
-- 
2.34.1
Re: [PATCH v1 3/3] spi: geni-qcom: Add target abort support
Posted by Konrad Dybcio 1 week, 6 days ago
On 1/22/26 4:10 PM, Praveen Talari wrote:
> SPI target mode currently lacks a mechanism to gracefully abort ongoing
> transfers when the client or core needs to cancel active transactions.
> 
> Implement spi_geni_target_abort() to handle aborting SPI target
> operations when the client and core want to cancel ongoing transfers.
> This provides a mechanism for graceful termination of active SPI
> transactions in target mode.
> 
> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
> ---
>  drivers/spi/spi-geni-qcom.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index e5320e2fb834..231fd31de048 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
> @@ -1009,6 +1009,17 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> +static int spi_geni_target_abort(struct spi_controller *spi)
> +{
> +	if (!spi->cur_msg)
> +		return 0;
> +
> +	handle_se_timeout(spi, spi->cur_msg);

I can't help but notice this function never even dereferences this
argument

Konrad
Re: [PATCH v1 3/3] spi: geni-qcom: Add target abort support
Posted by Praveen Talari 1 week, 5 days ago
Hi Konrad

On 1/27/2026 6:51 PM, Konrad Dybcio wrote:
> On 1/22/26 4:10 PM, Praveen Talari wrote:
>> SPI target mode currently lacks a mechanism to gracefully abort ongoing
>> transfers when the client or core needs to cancel active transactions.
>>
>> Implement spi_geni_target_abort() to handle aborting SPI target
>> operations when the client and core want to cancel ongoing transfers.
>> This provides a mechanism for graceful termination of active SPI
>> transactions in target mode.
>>
>> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
>> ---
>>   drivers/spi/spi-geni-qcom.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
>> index e5320e2fb834..231fd31de048 100644
>> --- a/drivers/spi/spi-geni-qcom.c
>> +++ b/drivers/spi/spi-geni-qcom.c
>> @@ -1009,6 +1009,17 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
>>   	return IRQ_HANDLED;
>>   }
>>   
>> +static int spi_geni_target_abort(struct spi_controller *spi)
>> +{
>> +	if (!spi->cur_msg)
>> +		return 0;
>> +
>> +	handle_se_timeout(spi, spi->cur_msg);
> 
> I can't help but notice this function never even dereferences this
> argument

Yes, you’re correct. Since the argument is never dereferenced, it is 
safe to pass either cur_msg or NULL here.

Thank,
Praveen

> 
> Konrad

Re: [PATCH v1 3/3] spi: geni-qcom: Add target abort support
Posted by Konrad Dybcio 1 week, 4 days ago
On 1/28/26 5:28 PM, Praveen Talari wrote:
> Hi Konrad
> 
> On 1/27/2026 6:51 PM, Konrad Dybcio wrote:
>> On 1/22/26 4:10 PM, Praveen Talari wrote:
>>> SPI target mode currently lacks a mechanism to gracefully abort ongoing
>>> transfers when the client or core needs to cancel active transactions.
>>>
>>> Implement spi_geni_target_abort() to handle aborting SPI target
>>> operations when the client and core want to cancel ongoing transfers.
>>> This provides a mechanism for graceful termination of active SPI
>>> transactions in target mode.
>>>
>>> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
>>> ---
>>>   drivers/spi/spi-geni-qcom.c | 14 ++++++++++++++
>>>   1 file changed, 14 insertions(+)
>>>
>>> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
>>> index e5320e2fb834..231fd31de048 100644
>>> --- a/drivers/spi/spi-geni-qcom.c
>>> +++ b/drivers/spi/spi-geni-qcom.c
>>> @@ -1009,6 +1009,17 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
>>>       return IRQ_HANDLED;
>>>   }
>>>   +static int spi_geni_target_abort(struct spi_controller *spi)
>>> +{
>>> +    if (!spi->cur_msg)
>>> +        return 0;
>>> +
>>> +    handle_se_timeout(spi, spi->cur_msg);
>>
>> I can't help but notice this function never even dereferences this
>> argument
> 
> Yes, you’re correct. Since the argument is never dereferenced, it is safe to pass either cur_msg or NULL here.

Would you like to send a patch removing the unused argument?

Konrad
Re: [PATCH v1 3/3] spi: geni-qcom: Add target abort support
Posted by Praveen Talari 1 week, 4 days ago
Hi Konrad,

On 1/29/2026 5:12 PM, Konrad Dybcio wrote:
> On 1/28/26 5:28 PM, Praveen Talari wrote:
>> Hi Konrad
>>
>> On 1/27/2026 6:51 PM, Konrad Dybcio wrote:
>>> On 1/22/26 4:10 PM, Praveen Talari wrote:
>>>> SPI target mode currently lacks a mechanism to gracefully abort ongoing
>>>> transfers when the client or core needs to cancel active transactions.
>>>>
>>>> Implement spi_geni_target_abort() to handle aborting SPI target
>>>> operations when the client and core want to cancel ongoing transfers.
>>>> This provides a mechanism for graceful termination of active SPI
>>>> transactions in target mode.
>>>>
>>>> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
>>>> ---
>>>>    drivers/spi/spi-geni-qcom.c | 14 ++++++++++++++
>>>>    1 file changed, 14 insertions(+)
>>>>
>>>> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
>>>> index e5320e2fb834..231fd31de048 100644
>>>> --- a/drivers/spi/spi-geni-qcom.c
>>>> +++ b/drivers/spi/spi-geni-qcom.c
>>>> @@ -1009,6 +1009,17 @@ static irqreturn_t geni_spi_isr(int irq, void *data)
>>>>        return IRQ_HANDLED;
>>>>    }
>>>>    +static int spi_geni_target_abort(struct spi_controller *spi)
>>>> +{
>>>> +    if (!spi->cur_msg)
>>>> +        return 0;
>>>> +
>>>> +    handle_se_timeout(spi, spi->cur_msg);
>>>
>>> I can't help but notice this function never even dereferences this
>>> argument
>>
>> Yes, you’re correct. Since the argument is never dereferenced, it is safe to pass either cur_msg or NULL here.
> 
> Would you like to send a patch removing the unused argument?

Sure, will update new patch in next version.

Thanks,
Praveen Talari

> 
> Konrad