diff mbox

[U-Boot,v2] mmc: mxsmmc: Fix operation with DMA

Message ID CAOMZO5DKyzNe+sqz3b1CioNY-OmBpwP1N_cMbKyk1H-Gf=Yerg@mail.gmail.com
State Superseded
Delegated to: Stefano Babic
Headers show

Commit Message

Fabio Estevam April 2, 2012, 7:18 p.m. UTC
On Mon, Apr 2, 2012 at 4:03 PM, Marek Vasut <marex@denx.de> wrote:

> Because that's called before relocation ;-)

What about this?

Too ugly? Or any better place for calling  mxs_dma_init()?

Comments

Marek Vasut April 2, 2012, 7:26 p.m. UTC | #1
Dear Fabio Estevam,

> On Mon, Apr 2, 2012 at 4:03 PM, Marek Vasut <marex@denx.de> wrote:
> > Because that's called before relocation ;-)
> 
> What about this?
> 
> --- a/drivers/dma/apbh_dma.c
> +++ b/drivers/dma/apbh_dma.c
> @@ -35,6 +35,7 @@
> 
>  static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];
> 
> +static int first;
>  /*
>   * Test is the DMA channel is valid channel
>   */
> @@ -346,6 +347,10 @@ struct mxs_dma_desc *mxs_dma_desc_alloc(void)
>         struct mxs_dma_desc *pdesc;
>         uint32_t size;
> 
> +       if (!first)
> +               mxs_dma_init();
> +       first++;
> +
>         size = roundup(sizeof(struct mxs_dma_desc), MXS_DMA_ALIGNMENT);
>         pdesc = memalign(MXS_DMA_ALIGNMENT, size);
> 
> Too ugly? Or any better place for calling  mxs_dma_init()?

I'd say arch_misc_init(), if it was before nand_init() though. Maybe we need 
arch_early_init_r() ?

Best regards,
Marek Vasut
Anatolij Gustschin April 2, 2012, 7:30 p.m. UTC | #2
Hi Fabio,

On Mon, 2 Apr 2012 16:18:18 -0300
Fabio Estevam <festevam@gmail.com> wrote:

> On Mon, Apr 2, 2012 at 4:03 PM, Marek Vasut <marex@denx.de> wrote:
> 
> > Because that's called before relocation ;-)
> 
> What about this?
> 
> --- a/drivers/dma/apbh_dma.c
> +++ b/drivers/dma/apbh_dma.c
> @@ -35,6 +35,7 @@
> 
>  static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];
> 
> +static int first;
>  /*
>   * Test is the DMA channel is valid channel
>   */
> @@ -346,6 +347,10 @@ struct mxs_dma_desc *mxs_dma_desc_alloc(void)
>         struct mxs_dma_desc *pdesc;
>         uint32_t size;
> 
> +       if (!first)
> +               mxs_dma_init();
> +       first++;
> +
>         size = roundup(sizeof(struct mxs_dma_desc), MXS_DMA_ALIGNMENT);
>         pdesc = memalign(MXS_DMA_ALIGNMENT, size);
> 
> Too ugly? Or any better place for calling  mxs_dma_init()?

Won't calling mxs_dma_init() from arch_misc_init() work?

Thanks,
Anatolij
Marek Vasut April 2, 2012, 7:38 p.m. UTC | #3
Dear Anatolij Gustschin,

> Hi Fabio,
> 
> On Mon, 2 Apr 2012 16:18:18 -0300
> 
> Fabio Estevam <festevam@gmail.com> wrote:
> > On Mon, Apr 2, 2012 at 4:03 PM, Marek Vasut <marex@denx.de> wrote:
> > > Because that's called before relocation ;-)
> > 
> > What about this?
> > 
> > --- a/drivers/dma/apbh_dma.c
> > +++ b/drivers/dma/apbh_dma.c
> > @@ -35,6 +35,7 @@
> > 
> >  static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];
> > 
> > +static int first;
> > 
> >  /*
> >  
> >   * Test is the DMA channel is valid channel
> >   */
> > 
> > @@ -346,6 +347,10 @@ struct mxs_dma_desc *mxs_dma_desc_alloc(void)
> > 
> >         struct mxs_dma_desc *pdesc;
> >         uint32_t size;
> > 
> > +       if (!first)
> > +               mxs_dma_init();
> > +       first++;
> > +
> > 
> >         size = roundup(sizeof(struct mxs_dma_desc), MXS_DMA_ALIGNMENT);
> >         pdesc = memalign(MXS_DMA_ALIGNMENT, size);
> > 
> > Too ugly? Or any better place for calling  mxs_dma_init()?
> 
> Won't calling mxs_dma_init() from arch_misc_init() work?

No, because that's called after NAND is inited. And NAND needs DMA for it's init 
:(

> 
> Thanks,
> Anatolij

Best regards,
Marek Vasut
Fabio Estevam April 2, 2012, 7:50 p.m. UTC | #4
On Mon, Apr 2, 2012 at 4:38 PM, Marek Vasut <marex@denx.de> wrote:

>> Won't calling mxs_dma_init() from arch_misc_init() work?
>
> No, because that's called after NAND is inited. And NAND needs DMA for it's init
> :(

Correct.

Should we go with my ugly hack then?

Or what do you mean when you proposed arch_early_init_r ?
Marek Vasut April 2, 2012, 7:54 p.m. UTC | #5
Dear Fabio Estevam,

> On Mon, Apr 2, 2012 at 4:38 PM, Marek Vasut <marex@denx.de> wrote:
> >> Won't calling mxs_dma_init() from arch_misc_init() work?
> > 
> > No, because that's called after NAND is inited. And NAND needs DMA for
> > it's init
> > 
> > :(
> 
> Correct.
> 
> Should we go with my ugly hack then?
> 
> Or what do you mean when you proposed arch_early_init_r ?

Yes another hook function that'd be called early in board_init_r()

btw. Fabio, I really appreciate your work on this, sorry to keep tormenting you 
so much.

Best regards,
Marek Vasut
diff mbox

Patch

--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -35,6 +35,7 @@ 

 static struct mxs_dma_chan mxs_dma_channels[MXS_MAX_DMA_CHANNELS];

+static int first;
 /*
  * Test is the DMA channel is valid channel
  */
@@ -346,6 +347,10 @@  struct mxs_dma_desc *mxs_dma_desc_alloc(void)
        struct mxs_dma_desc *pdesc;
        uint32_t size;

+       if (!first)
+               mxs_dma_init();
+       first++;
+
        size = roundup(sizeof(struct mxs_dma_desc), MXS_DMA_ALIGNMENT);
        pdesc = memalign(MXS_DMA_ALIGNMENT, size);