2015-11-09 12:35:57

by Saurabh Sengar

[permalink] [raw]
Subject: [PATCH] dma: mic_x100: add missing spin_unlock

spin lock should be released while returning from function

Signed-off-by: Saurabh Sengar <[email protected]>
---
drivers/dma/mic_x100_dma.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index 068e920..7f6d477 100644
--- a/drivers/dma/mic_x100_dma.c
+++ b/drivers/dma/mic_x100_dma.c
@@ -317,17 +317,21 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
struct device *dev = mic_dma_ch_to_device(mic_ch);
int result;
+ struct dma_async_tx_descriptor *tx = NULL;

if (!len && !flags)
- return NULL;
+ return tx;

spin_lock(&mic_ch->prep_lock);
result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
if (result >= 0)
- return allocate_tx(mic_ch);
- dev_err(dev, "Error enqueueing dma, error=%d\n", result);
+ tx = allocate_tx(mic_ch);
+
+ if(!tx)
+ dev_err(dev, "Error enqueueing dma, error=%d\n", result);
+
spin_unlock(&mic_ch->prep_lock);
- return NULL;
+ return tx;
}

static struct dma_async_tx_descriptor *
@@ -335,13 +339,14 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
{
struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
int ret;
+ struct dma_async_tx_descriptor *tx = NULL;

spin_lock(&mic_ch->prep_lock);
ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
if (!ret)
- return allocate_tx(mic_ch);
+ tx = allocate_tx(mic_ch);
spin_unlock(&mic_ch->prep_lock);
- return NULL;
+ return tx;
}

/* Return the status of the transaction */
--
1.9.1


2015-11-30 15:24:29

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH] dma: mic_x100: add missing spin_unlock

On Mon, Nov 09, 2015 at 06:05:39PM +0530, Saurabh Sengar wrote:
> spin lock should be released while returning from function
>
> Signed-off-by: Saurabh Sengar <[email protected]>
> ---
> drivers/dma/mic_x100_dma.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
> index 068e920..7f6d477 100644
> --- a/drivers/dma/mic_x100_dma.c
> +++ b/drivers/dma/mic_x100_dma.c
> @@ -317,17 +317,21 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
> struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
> struct device *dev = mic_dma_ch_to_device(mic_ch);
> int result;
> + struct dma_async_tx_descriptor *tx = NULL;
>
> if (!len && !flags)
> - return NULL;
> + return tx;

This one doesn't make sense, tx will be NULL here, so orignal one is fine

>
> spin_lock(&mic_ch->prep_lock);
> result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
> if (result >= 0)
> - return allocate_tx(mic_ch);
> - dev_err(dev, "Error enqueueing dma, error=%d\n", result);
> + tx = allocate_tx(mic_ch);
> +
> + if(!tx)
> + dev_err(dev, "Error enqueueing dma, error=%d\n", result);
> +
> spin_unlock(&mic_ch->prep_lock);
> - return NULL;
> + return tx;
> }
>
> static struct dma_async_tx_descriptor *
> @@ -335,13 +339,14 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
> {
> struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
> int ret;
> + struct dma_async_tx_descriptor *tx = NULL;
>
> spin_lock(&mic_ch->prep_lock);
> ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
> if (!ret)
> - return allocate_tx(mic_ch);
> + tx = allocate_tx(mic_ch);
> spin_unlock(&mic_ch->prep_lock);
> - return NULL;
> + return tx;
> }
>
> /* Return the status of the transaction */
> --
> 1.9.1
>

--
~Vinod

2015-11-30 15:49:19

by Saurabh Sengar

[permalink] [raw]
Subject: [PATCH v2] dma: mic_x100: add missing spin_unlock

spin lock should be released while returning from function

Signed-off-by: Saurabh Sengar <[email protected]>
---
v2: fixed comment from Vinod Koul
drivers/dma/mic_x100_dma.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
index 068e920..cddfa8d 100644
--- a/drivers/dma/mic_x100_dma.c
+++ b/drivers/dma/mic_x100_dma.c
@@ -317,6 +317,7 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
struct device *dev = mic_dma_ch_to_device(mic_ch);
int result;
+ struct dma_async_tx_descriptor *tx = NULL;

if (!len && !flags)
return NULL;
@@ -324,10 +325,13 @@ mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
spin_lock(&mic_ch->prep_lock);
result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
if (result >= 0)
- return allocate_tx(mic_ch);
- dev_err(dev, "Error enqueueing dma, error=%d\n", result);
+ tx = allocate_tx(mic_ch);
+
+ if (!tx)
+ dev_err(dev, "Error enqueueing dma, error=%d\n", result);
+
spin_unlock(&mic_ch->prep_lock);
- return NULL;
+ return tx;
}

static struct dma_async_tx_descriptor *
@@ -335,13 +339,14 @@ mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
{
struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
int ret;
+ struct dma_async_tx_descriptor *tx = NULL;

spin_lock(&mic_ch->prep_lock);
ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
if (!ret)
- return allocate_tx(mic_ch);
+ tx = allocate_tx(mic_ch);
spin_unlock(&mic_ch->prep_lock);
- return NULL;
+ return tx;
}

/* Return the status of the transaction */
--
1.9.1

2015-12-05 10:28:38

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH v2] dma: mic_x100: add missing spin_unlock

On Mon, Nov 30, 2015 at 09:19:04PM +0530, Saurabh Sengar wrote:
> spin lock should be released while returning from function

Applying after fixing the subsytem name


--
~Vinod