Re: [PATCH 21/32] mmc: bcm2835-sdhost: Add new driver for the internal SD controller.

From: Gerd Hoffmann
Date: Tue Jun 21 2016 - 09:27:43 EST


Hi,

> > + mmiowb();
> > +}
>
> What is the barrier for? Same question for all the other instances

No idea. Removed them all, seems to work fine still.
Guess writel() & friends have the needed barriers on arm?

> > +
> > +static void bcm2835_sdhost_reset(struct mmc_host *mmc)
> > +{
> > + struct bcm2835_host *host = mmc_priv(mmc);
> > + unsigned long flags;
> > +
> > + spin_lock_irqsave(&host->lock, flags);
> > + bcm2835_sdhost_reset_internal(host);
> > + spin_unlock_irqrestore(&host->lock, flags);
> > +}
>
> The spinlock seems to only protect the reset from happening concurrently
> with bcm2835_sdhost_dma_complete() here. So if you ensure that this
> function is no longer pending, you can probably use msleep() above.

There is also a tasklet. And IRQs. But bcm2835_sdhost_reset_internal
clears hcfg (temporately), so IRQs shouldn't be a problem I think. So how
about this?

@@ -334,9 +334,10 @@ static void bcm2835_sdhost_reset(struct mmc_host *mmc)
struct bcm2835_host *host = mmc_priv(mmc);
unsigned long flags;

- spin_lock_irqsave(&host->lock, flags);
+ if (host->dma_chan)
+ dmaengine_terminate_sync(host->dma_chan);
+ tasklet_kill(&host->finish_tasklet);
bcm2835_sdhost_reset_internal(host);
- spin_unlock_irqrestore(&host->lock, flags);
}


> > + if (IS_ERR_OR_NULL(host->dma_chan_tx) ||
> > + IS_ERR_OR_NULL(host->dma_chan_rx)) {
> > + pr_err("%s: unable to initialise DMA channels. Falling back to PIO\n",
> > + mmc_hostname(mmc));
>
> When are these ever NULL?

When there are no dma channels configured in the device tree.

cheers,
Gerd