[01/12] i2c: qup: fixed releasing dma without flush operation completion

Message ID 1517644697-30806-2-git-send-email-absahu@codeaurora.org
State New
Headers show
Series
  • Major code reorganization to make all i2c transfers working
Related show

Commit Message

Abhishek Sahu Feb. 3, 2018, 7:58 a.m.
The QUP BSLP BAM generates the following error sometimes if the
current I2C DMA transfer fails and the flush operation has been
scheduled

    “bam-dma-engine 7884000.dma: Cannot free busy channel”

If any I2C error comes during BAM DMA transfer, then the QUP I2C
interrupt will be generated and the flush operation will be
carried out to make i2c consume all scheduled DMA transfer.
Currently, the same completion structure is being used for BAM
transfer which has already completed without reinit. It will make
flush operation wait_for_completion_timeout completed immediately
and will proceed for freeing the DMA resources where the
descriptors are still in process.

Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
---
 drivers/i2c/busses/i2c-qup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Sricharan R Feb. 8, 2018, 2:03 p.m. | #1
Hi Abhishek,

On 2/3/2018 1:28 PM, Abhishek Sahu wrote:
> The QUP BSLP BAM generates the following error sometimes if the
> current I2C DMA transfer fails and the flush operation has been
> scheduled
> 
>     “bam-dma-engine 7884000.dma: Cannot free busy channel”
> 
> If any I2C error comes during BAM DMA transfer, then the QUP I2C
> interrupt will be generated and the flush operation will be
> carried out to make i2c consume all scheduled DMA transfer.
> Currently, the same completion structure is being used for BAM
> transfer which has already completed without reinit. It will make
> flush operation wait_for_completion_timeout completed immediately
> and will proceed for freeing the DMA resources where the
> descriptors are still in process.
> 
> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
> ---
>  drivers/i2c/busses/i2c-qup.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index 08f8e01..9faa26c41a 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2009-2013, 2016-2018, The Linux Foundation. All rights reserved.

Not sure, if this was an intended change. But given that you are fixing this,
you can change the header to the new SPDX one.

>   * Copyright (c) 2014, Sony Mobile Communications AB.
>   *
>   *
> @@ -844,6 +844,8 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
>  	}
>  
>  	if (ret || qup->bus_err || qup->qup_err) {
> +		reinit_completion(&qup->xfer);
> +
>  		if (qup_i2c_change_state(qup, QUP_RUN_STATE)) {
>  			dev_err(qup->dev, "change to run state timed out");
>  			goto desc_err;
> 

Except for the above nit,
  Acked-by: Sricharan R <sricharan@codeaurora.org>

Regards,
 Sricharan
Abhishek Sahu Feb. 19, 2018, 10:24 a.m. | #2
On 2018-02-08 19:33, Sricharan R wrote:
> Hi Abhishek,
> 
> On 2/3/2018 1:28 PM, Abhishek Sahu wrote:
>> The QUP BSLP BAM generates the following error sometimes if the
>> current I2C DMA transfer fails and the flush operation has been
>> scheduled
>> 
>>     “bam-dma-engine 7884000.dma: Cannot free busy channel”
>> 
>> If any I2C error comes during BAM DMA transfer, then the QUP I2C
>> interrupt will be generated and the flush operation will be
>> carried out to make i2c consume all scheduled DMA transfer.
>> Currently, the same completion structure is being used for BAM
>> transfer which has already completed without reinit. It will make
>> flush operation wait_for_completion_timeout completed immediately
>> and will proceed for freeing the DMA resources where the
>> descriptors are still in process.
>> 
>> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
>> ---
>>  drivers/i2c/busses/i2c-qup.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/i2c/busses/i2c-qup.c 
>> b/drivers/i2c/busses/i2c-qup.c
>> index 08f8e01..9faa26c41a 100644
>> --- a/drivers/i2c/busses/i2c-qup.c
>> +++ b/drivers/i2c/busses/i2c-qup.c
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2009-2013, The Linux Foundation. All rights 
>> reserved.
>> + * Copyright (c) 2009-2013, 2016-2018, The Linux Foundation. All 
>> rights reserved.
> 
> Not sure, if this was an intended change. But given that you are fixing 
> this,

  Thanks Sricharan.
  Since this is the first patch, so I updated the year.

> you can change the header to the new SPDX one.
> 

  Yes that would be better.
  I will fix that also.

  Thanks,
  Abhishek

>>   * Copyright (c) 2014, Sony Mobile Communications AB.
>>   *
>>   *
>> @@ -844,6 +844,8 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev 
>> *qup, struct i2c_msg *msg,
>>  	}
>> 
>>  	if (ret || qup->bus_err || qup->qup_err) {
>> +		reinit_completion(&qup->xfer);
>> +
>>  		if (qup_i2c_change_state(qup, QUP_RUN_STATE)) {
>>  			dev_err(qup->dev, "change to run state timed out");
>>  			goto desc_err;
>> 
> 
> Except for the above nit,
>   Acked-by: Sricharan R <sricharan@codeaurora.org>
> 
> Regards,
>  Sricharan

Patch

diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index 08f8e01..9faa26c41a 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -1,5 +1,5 @@ 
 /*
- * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2013, 2016-2018, The Linux Foundation. All rights reserved.
  * Copyright (c) 2014, Sony Mobile Communications AB.
  *
  *
@@ -844,6 +844,8 @@  static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
 	}
 
 	if (ret || qup->bus_err || qup->qup_err) {
+		reinit_completion(&qup->xfer);
+
 		if (qup_i2c_change_state(qup, QUP_RUN_STATE)) {
 			dev_err(qup->dev, "change to run state timed out");
 			goto desc_err;