All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] DMA: shdma: fix CHCLR register address calculation
@ 2013-07-02 15:37 ` Guennadi Liakhovetski
  0 siblings, 0 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-02 15:37 UTC (permalink / raw)
  To: linux-sh; +Cc: Koul, Vinod, Magnus Damm, linux-kernel, Kuninori Morimoto

struct sh_dmae_device::chan_reg is a pointer to u32, therefore when adding
offsets to it care should be taken to add offsets in sizeof(u32) units, not
in bytes. This patch corrects such a bug. While at it we also remove the
redundant parameter of the affected function.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---

This is a theoretical fix, I don't have a test-case for it, but the 
original calculation does seem to be buggy to me. Reviews and tests are 
welcome.

 drivers/dma/sh/shdma.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
index 98b2693..c7950be 100644
--- a/drivers/dma/sh/shdma.c
+++ b/drivers/dma/sh/shdma.c
@@ -51,12 +51,12 @@
 static DEFINE_SPINLOCK(sh_dmae_lock);
 static LIST_HEAD(sh_dmae_devices);
 
-static void chclr_write(struct sh_dmae_chan *sh_dc, u32 data)
+static void channel_clear(struct sh_dmae_chan *sh_dc)
 {
 	struct sh_dmae_device *shdev = to_sh_dev(sh_dc);
 
-	__raw_writel(data, shdev->chan_reg +
-		     shdev->pdata->channel[sh_dc->shdma_chan.id].chclr_offset);
+	__raw_writel(0, shdev->chan_reg +
+		shdev->pdata->channel[sh_dc->shdma_chan.id].chclr_offset / sizeof(u32));
 }
 
 static void sh_dmae_writel(struct sh_dmae_chan *sh_dc, u32 data, u32 reg)
@@ -135,7 +135,7 @@ static int sh_dmae_rst(struct sh_dmae_device *shdev)
 		for (i = 0; i < shdev->pdata->channel_num; i++) {
 			struct sh_dmae_chan *sh_chan = shdev->chan[i];
 			if (sh_chan)
-				chclr_write(sh_chan, 0);
+				channel_clear(sh_chan);
 		}
 	}
 
-- 
1.7.2.5


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

* [PATCH] DMA: shdma: fix CHCLR register address calculation
@ 2013-07-02 15:37 ` Guennadi Liakhovetski
  0 siblings, 0 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2013-07-02 15:37 UTC (permalink / raw)
  To: linux-sh; +Cc: Koul, Vinod, Magnus Damm, linux-kernel, Kuninori Morimoto

struct sh_dmae_device::chan_reg is a pointer to u32, therefore when adding
offsets to it care should be taken to add offsets in sizeof(u32) units, not
in bytes. This patch corrects such a bug. While at it we also remove the
redundant parameter of the affected function.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
---

This is a theoretical fix, I don't have a test-case for it, but the 
original calculation does seem to be buggy to me. Reviews and tests are 
welcome.

 drivers/dma/sh/shdma.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
index 98b2693..c7950be 100644
--- a/drivers/dma/sh/shdma.c
+++ b/drivers/dma/sh/shdma.c
@@ -51,12 +51,12 @@
 static DEFINE_SPINLOCK(sh_dmae_lock);
 static LIST_HEAD(sh_dmae_devices);
 
-static void chclr_write(struct sh_dmae_chan *sh_dc, u32 data)
+static void channel_clear(struct sh_dmae_chan *sh_dc)
 {
 	struct sh_dmae_device *shdev = to_sh_dev(sh_dc);
 
-	__raw_writel(data, shdev->chan_reg +
-		     shdev->pdata->channel[sh_dc->shdma_chan.id].chclr_offset);
+	__raw_writel(0, shdev->chan_reg +
+		shdev->pdata->channel[sh_dc->shdma_chan.id].chclr_offset / sizeof(u32));
 }
 
 static void sh_dmae_writel(struct sh_dmae_chan *sh_dc, u32 data, u32 reg)
@@ -135,7 +135,7 @@ static int sh_dmae_rst(struct sh_dmae_device *shdev)
 		for (i = 0; i < shdev->pdata->channel_num; i++) {
 			struct sh_dmae_chan *sh_chan = shdev->chan[i];
 			if (sh_chan)
-				chclr_write(sh_chan, 0);
+				channel_clear(sh_chan);
 		}
 	}
 
-- 
1.7.2.5


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

* Re: [PATCH] DMA: shdma: fix CHCLR register address calculation
  2013-07-02 15:37 ` Guennadi Liakhovetski
@ 2013-08-25  7:46   ` Vinod Koul
  -1 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2013-08-25  7:34 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: linux-sh, Magnus Damm, linux-kernel, Kuninori Morimoto

On Tue, Jul 02, 2013 at 05:37:58PM +0200, Guennadi Liakhovetski wrote:
> struct sh_dmae_device::chan_reg is a pointer to u32, therefore when adding
> offsets to it care should be taken to add offsets in sizeof(u32) units, not
> in bytes. This patch corrects such a bug. While at it we also remove the
> redundant parameter of the affected function.
Applied, thanks

~Vinod

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

* Re: [PATCH] DMA: shdma: fix CHCLR register address calculation
@ 2013-08-25  7:46   ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2013-08-25  7:46 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: linux-sh, Magnus Damm, linux-kernel, Kuninori Morimoto

On Tue, Jul 02, 2013 at 05:37:58PM +0200, Guennadi Liakhovetski wrote:
> struct sh_dmae_device::chan_reg is a pointer to u32, therefore when adding
> offsets to it care should be taken to add offsets in sizeof(u32) units, not
> in bytes. This patch corrects such a bug. While at it we also remove the
> redundant parameter of the affected function.
Applied, thanks

~Vinod

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

end of thread, other threads:[~2013-08-25  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-02 15:37 [PATCH] DMA: shdma: fix CHCLR register address calculation Guennadi Liakhovetski
2013-07-02 15:37 ` Guennadi Liakhovetski
2013-08-25  7:34 ` Vinod Koul
2013-08-25  7:46   ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.