mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] pch_dma: Fix suspend issue
@ 2011-10-11 12:43 Tomoya MORINAGA
  2011-10-11 12:43 ` [PATCH 2/2] pch_dma: Modify redundant memory allocation Tomoya MORINAGA
  2011-10-11 17:01 ` [PATCH 1/2 v2] pch_dma: Fix suspend issue Vinod Koul
  0 siblings, 2 replies; 4+ messages in thread
From: Tomoya MORINAGA @ 2011-10-11 12:43 UTC (permalink / raw)
  To: Dan Williams, Vinod Koul, linux-kernel
  Cc: qi.wang, yong.y.wang, joel.clark, kok.howg.ewe, Tomoya MORINAGA

Currently, executing suspend/hibernation,
memory access violation occurs.

In pch_dma_save_regs() called by suspend(),
you can see the following code.

static void pch_dma_save_regs(struct pch_dma *pd)
{
snip...
        list_for_each_entry_safe(chan, _c, &pd->dma.channels, device_node) {
                pd_chan = to_pd_chan(chan);

                pd->ch_regs[i].dev_addr = channel_readl(pd_chan, DEV_ADDR);
                pd->ch_regs[i].mem_addr = channel_readl(pd_chan, MEM_ADDR);
                pd->ch_regs[i].size = channel_readl(pd_chan, SIZE);
                pd->ch_regs[i].next = channel_readl(pd_chan, NEXT);

                i++;
        }
}

Max loop count is 12 defined at pci_table.
So, this caused memory access violation.

This patch fixes the issue
 - Modify array size (MAX_CHAN_NR)

Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
---
 drivers/dma/pch_dma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index ff5b38f..e72bfeb 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -59,7 +59,7 @@
 #define DMA_DESC_FOLLOW_WITHOUT_IRQ	0x2
 #define DMA_DESC_FOLLOW_WITH_IRQ	0x3
 
-#define MAX_CHAN_NR			8
+#define MAX_CHAN_NR			12
 
 static unsigned int init_nr_desc_per_channel = 64;
 module_param(init_nr_desc_per_channel, uint, 0644);
-- 
1.7.4.4


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

* [PATCH 2/2] pch_dma: Modify redundant memory allocation
  2011-10-11 12:43 [PATCH 1/2 v2] pch_dma: Fix suspend issue Tomoya MORINAGA
@ 2011-10-11 12:43 ` Tomoya MORINAGA
  2011-10-11 13:57   ` Vinod Koul
  2011-10-11 17:01 ` [PATCH 1/2 v2] pch_dma: Fix suspend issue Vinod Koul
  1 sibling, 1 reply; 4+ messages in thread
From: Tomoya MORINAGA @ 2011-10-11 12:43 UTC (permalink / raw)
  To: Dan Williams, Vinod Koul, linux-kernel
  Cc: qi.wang, yong.y.wang, joel.clark, kok.howg.ewe, Tomoya MORINAGA

nr_channels is defined in "struct pch_dma".
and struct pch_dma_chan is defined in "struct pch_dma".
So, "sizeof(struct pch_dma_chan) * nr_channels" is unnecessary.

Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
---
 drivers/dma/pch_dma.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index e72bfeb..d78f526 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -811,8 +811,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
 	int i;
 
 	nr_channels = id->driver_data;
-	pd = kzalloc(sizeof(struct pch_dma)+
-		sizeof(struct pch_dma_chan) * nr_channels, GFP_KERNEL);
+	pd = kzalloc(sizeof(struct pch_dma), GFP_KERNEL);
 	if (!pd)
 		return -ENOMEM;
 
-- 
1.7.4.4


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

* Re: [PATCH 2/2] pch_dma: Modify redundant memory allocation
  2011-10-11 12:43 ` [PATCH 2/2] pch_dma: Modify redundant memory allocation Tomoya MORINAGA
@ 2011-10-11 13:57   ` Vinod Koul
  0 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2011-10-11 13:57 UTC (permalink / raw)
  To: Tomoya MORINAGA
  Cc: Dan Williams, linux-kernel, qi.wang, yong.y.wang, joel.clark,
	kok.howg.ewe

On Tue, 2011-10-11 at 21:43 +0900, Tomoya MORINAGA wrote:
> nr_channels is defined in "struct pch_dma".
> and struct pch_dma_chan is defined in "struct pch_dma".
> So, "sizeof(struct pch_dma_chan) * nr_channels" is unnecessary.
> 
> Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
> ---
>  drivers/dma/pch_dma.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
> index e72bfeb..d78f526 100644
> --- a/drivers/dma/pch_dma.c
> +++ b/drivers/dma/pch_dma.c
> @@ -811,8 +811,7 @@ static int __devinit pch_dma_probe(struct pci_dev *pdev,
>  	int i;
>  
>  	nr_channels = id->driver_data;
> -	pd = kzalloc(sizeof(struct pch_dma)+
> -		sizeof(struct pch_dma_chan) * nr_channels, GFP_KERNEL);
> +	pd = kzalloc(sizeof(struct pch_dma), GFP_KERNEL);
kernel convention is 
	sizeof(*pd)

>  	if (!pd)
>  		return -ENOMEM;
>  


-- 
~Vinod


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

* Re: [PATCH 1/2 v2] pch_dma: Fix suspend issue
  2011-10-11 12:43 [PATCH 1/2 v2] pch_dma: Fix suspend issue Tomoya MORINAGA
  2011-10-11 12:43 ` [PATCH 2/2] pch_dma: Modify redundant memory allocation Tomoya MORINAGA
@ 2011-10-11 17:01 ` Vinod Koul
  1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2011-10-11 17:01 UTC (permalink / raw)
  To: Tomoya MORINAGA
  Cc: Dan Williams, linux-kernel, qi.wang, yong.y.wang, joel.clark,
	kok.howg.ewe

On Tue, 2011-10-11 at 21:43 +0900, Tomoya MORINAGA wrote:
> Currently, executing suspend/hibernation,
> memory access violation occurs.
> 
> In pch_dma_save_regs() called by suspend(),
> you can see the following code.
> 
> static void pch_dma_save_regs(struct pch_dma *pd)
> {
> snip...
>         list_for_each_entry_safe(chan, _c, &pd->dma.channels, device_node) {
>                 pd_chan = to_pd_chan(chan);
> 
>                 pd->ch_regs[i].dev_addr = channel_readl(pd_chan, DEV_ADDR);
>                 pd->ch_regs[i].mem_addr = channel_readl(pd_chan, MEM_ADDR);
>                 pd->ch_regs[i].size = channel_readl(pd_chan, SIZE);
>                 pd->ch_regs[i].next = channel_readl(pd_chan, NEXT);
> 
>                 i++;
>         }
> }
> 
> Max loop count is 12 defined at pci_table.
> So, this caused memory access violation.
> 
> This patch fixes the issue
>  - Modify array size (MAX_CHAN_NR)
> 
> Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.lapis-semi.com>
> ---
>  drivers/dma/pch_dma.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
> index ff5b38f..e72bfeb 100644
> --- a/drivers/dma/pch_dma.c
> +++ b/drivers/dma/pch_dma.c
> @@ -59,7 +59,7 @@
>  #define DMA_DESC_FOLLOW_WITHOUT_IRQ	0x2
>  #define DMA_DESC_FOLLOW_WITH_IRQ	0x3
>  
> -#define MAX_CHAN_NR			8
> +#define MAX_CHAN_NR			12
>  
>  static unsigned int init_nr_desc_per_channel = 64;
>  module_param(init_nr_desc_per_channel, uint, 0644);
Applied only 1/2. 2/2 needs modifications

Thanks

-- 
~Vinod


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

end of thread, other threads:[~2011-10-11 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-11 12:43 [PATCH 1/2 v2] pch_dma: Fix suspend issue Tomoya MORINAGA
2011-10-11 12:43 ` [PATCH 2/2] pch_dma: Modify redundant memory allocation Tomoya MORINAGA
2011-10-11 13:57   ` Vinod Koul
2011-10-11 17:01 ` [PATCH 1/2 v2] pch_dma: Fix suspend issue Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®