Re: [PATCH] pch_dma: Fix suspend issue

From: Vinod Koul
Date: Fri Oct 07 2011 - 02:21:52 EST


On Fri, 2011-10-07 at 14:54 +0900, Tomoya MORINAGA wrote:
> (2011/10/07 14:00), Vinod Koul wrote:
> > How would changing the max number of descriptors fix the memory
> > violation?
> >
>
> In probe of pch_dma, you can see the following code.
>
> for (i = 0; i < nr_channels; i++) {
>
> snip...
>
> pd_chan->membase = &regs->desc[i];
>
> snip...
>
> }
>
> Max value of nr_channels is 12 defined at pci_table.
> So, this caused memory access violation.
This is all is due to not saving nr_channels in probe and using that
instead.

Looking deeper, struct pch_dma defines array of length MAX_CHAN_NR for
channels. Then why do you allocate memory in probe as
pd = kzalloc(sizeof(struct pch_dma)+
sizeof(struct pch_dma_chan) * nr_channels, GFP_KERNEL);
what is the point in allocating additional memory for each channel?

Given this, why should there be predefined channel array in pcm_dma?

It would be great if we could fix this by dynamically allocating memory
for channels based on nr_channels and not wasting due to a static array.

--
~Vinod

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/