linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: qcom: bam_dma: check if the runtime pm enabled
@ 2018-05-14 16:18 Srinivas Kandagatla
  2018-05-17  5:21 ` Vinod
  0 siblings, 1 reply; 3+ messages in thread
From: Srinivas Kandagatla @ 2018-05-14 16:18 UTC (permalink / raw)
  To: agross, vkoul, dmaengine
  Cc: linux-arm-msm, linux-kernel, linux-arm-kernel, Srinivas Kandagatla

Disabling pm runtime at probe is not sufficient to get BAM working
on remotely controller instances. pm_runtime_get_sync() would return
-EACCES in such cases.
So check if runtime pm is enabled before returning error from bam functions.

Fixes: 5b4a68952a89 ("dmaengine: qcom: bam_dma: disable runtime pm on remote controlled")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/dma/qcom/bam_dma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index d29275b97e84..5f4babebc508 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -540,7 +540,7 @@ static void bam_free_chan(struct dma_chan *chan)
 	int ret;
 
 	ret = pm_runtime_get_sync(bdev->dev);
-	if (ret < 0)
+	if (pm_runtime_enabled(bdev->dev) && ret < 0)
 		return;
 
 	vchan_free_chan_resources(to_virt_chan(chan));
@@ -721,7 +721,7 @@ static int bam_pause(struct dma_chan *chan)
 	int ret;
 
 	ret = pm_runtime_get_sync(bdev->dev);
-	if (ret < 0)
+	if (pm_runtime_enabled(bdev->dev) && ret < 0)
 		return ret;
 
 	spin_lock_irqsave(&bchan->vc.lock, flag);
@@ -747,7 +747,7 @@ static int bam_resume(struct dma_chan *chan)
 	int ret;
 
 	ret = pm_runtime_get_sync(bdev->dev);
-	if (ret < 0)
+	if (pm_runtime_enabled(bdev->dev) && ret < 0)
 		return ret;
 
 	spin_lock_irqsave(&bchan->vc.lock, flag);
@@ -853,7 +853,7 @@ static irqreturn_t bam_dma_irq(int irq, void *data)
 		tasklet_schedule(&bdev->task);
 
 	ret = pm_runtime_get_sync(bdev->dev);
-	if (ret < 0)
+	if (pm_runtime_enabled(bdev->dev) && ret < 0)
 		return ret;
 
 	if (srcs & BAM_IRQ) {
@@ -970,7 +970,7 @@ static void bam_start_dma(struct bam_chan *bchan)
 		return;
 
 	ret = pm_runtime_get_sync(bdev->dev);
-	if (ret < 0)
+	if (pm_runtime_enabled(bdev->dev) && ret < 0)
 		return;
 
 	while (vd && !IS_BUSY(bchan)) {
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: qcom: bam_dma: check if the runtime pm enabled
  2018-05-14 16:18 [PATCH] dmaengine: qcom: bam_dma: check if the runtime pm enabled Srinivas Kandagatla
@ 2018-05-17  5:21 ` Vinod
  2018-05-17  9:20   ` Srinivas Kandagatla
  0 siblings, 1 reply; 3+ messages in thread
From: Vinod @ 2018-05-17  5:21 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: agross, dmaengine, linux-arm-msm, linux-kernel, linux-arm-kernel

On 14-05-18, 17:18, Srinivas Kandagatla wrote:
> Disabling pm runtime at probe is not sufficient to get BAM working
> on remotely controller instances. pm_runtime_get_sync() would return
> -EACCES in such cases.
> So check if runtime pm is enabled before returning error from bam functions.
> 
> Fixes: 5b4a68952a89 ("dmaengine: qcom: bam_dma: disable runtime pm on remote controlled")
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/dma/qcom/bam_dma.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
> index d29275b97e84..5f4babebc508 100644
> --- a/drivers/dma/qcom/bam_dma.c
> +++ b/drivers/dma/qcom/bam_dma.c
> @@ -540,7 +540,7 @@ static void bam_free_chan(struct dma_chan *chan)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(bdev->dev);
> -	if (ret < 0)
> +	if (pm_runtime_enabled(bdev->dev) && ret < 0)

would it make sense to first check enabled and do _get_sync() 

        if (pm_runtime_enabled()) {
                ret = pm_runtime_get_sync() {
                ...
                }
        }

thus making clear in code that we do calls only when it is enabled. Also you can
add a local macro for this code and use that rather than copy pasting :)

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: qcom: bam_dma: check if the runtime pm enabled
  2018-05-17  5:21 ` Vinod
@ 2018-05-17  9:20   ` Srinivas Kandagatla
  0 siblings, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2018-05-17  9:20 UTC (permalink / raw)
  To: Vinod; +Cc: agross, dmaengine, linux-arm-msm, linux-kernel, linux-arm-kernel



On 17/05/18 06:21, Vinod wrote:
> On 14-05-18, 17:18, Srinivas Kandagatla wrote:
>> Disabling pm runtime at probe is not sufficient to get BAM working
>> on remotely controller instances. pm_runtime_get_sync() would return
>> -EACCES in such cases.
>> So check if runtime pm is enabled before returning error from bam functions.
>>
>> Fixes: 5b4a68952a89 ("dmaengine: qcom: bam_dma: disable runtime pm on remote controlled")
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/dma/qcom/bam_dma.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
>> index d29275b97e84..5f4babebc508 100644
>> --- a/drivers/dma/qcom/bam_dma.c
>> +++ b/drivers/dma/qcom/bam_dma.c
>> @@ -540,7 +540,7 @@ static void bam_free_chan(struct dma_chan *chan)
>>   	int ret;
>>   
>>   	ret = pm_runtime_get_sync(bdev->dev);
>> -	if (ret < 0)
>> +	if (pm_runtime_enabled(bdev->dev) && ret < 0)
> 
> would it make sense to first check enabled and do _get_sync()
>
Both of them check the disable_depth, however doing it the way you 
suggested would avoid some additional calls.

>          if (pm_runtime_enabled()) {
>                  ret = pm_runtime_get_sync() {
>                  ...
>                  }
>          }
sound like good idea!
> 
Just noticed that some of the drivers use:

         err = pm_runtime_get_sync(dev);
         if (err < 0 && err !=-EACCES)
		return;

others warp up this into local function.

Will send a v2!


thanks,
srini

> thus making clear in code that we do calls only when it is enabled. Also you can
> add a local macro for this code and use that rather than copy pasting :)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-17  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 16:18 [PATCH] dmaengine: qcom: bam_dma: check if the runtime pm enabled Srinivas Kandagatla
2018-05-17  5:21 ` Vinod
2018-05-17  9:20   ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).