public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: Shawn Guo <shawn.guo@freescale.com>,
	s.hauer@pengutronix.de, cjb@laptop.org,
	linux-mmc@vger.kernel.org, u.kleine-koenig@pengutronix.de
Subject: Re: [PATCH 1/7] mmc: mxs-mmc: add mmc host driver for i.MX23/28
Date: Thu, 10 Feb 2011 18:17:41 +0100	[thread overview]
Message-ID: <201102101817.42099.arnd@arndb.de> (raw)
In-Reply-To: <20110211003533.GA9151@S2100-06.ap.freescale.net>

On Friday 11 February 2011, Shawn Guo wrote:
> 
> > > +	struct resource			*res;
> > > +	struct resource			*dma_res;
> > > +	struct clk			*clk;
> > 
> > are visible in the parent.
> > 
> It seems this is a generally used approach, seen in mxcmmc and pxamci.

Just because someone else is doing it, it doesn't have to be a good
idea ;-)

But you're right, it seems to be done this way almost everywhere.
Unless Chris has a more definite opinion here, I don't mind if
you follow the same pattern.

If someone decides that it's really a bad idea, we should change
all drivers at once.

> > > +	struct mxs_dma_data		dma_data;
> > 
> > Why do you need host specific DMA structures? Please stick to
> > the generic dma-engine API if possible.
> > 
> I'm sticking to the generic dmaengine api.  The mxs dma hardware
> has separate irq line for every single dma channel, which needs to
> be told by client driver.

I'm not convinced, it still sounds like a layering violation to
have specific information about the DMA controller in the
platform data of a driver using the dma engine API.

Why can't you put the interrupt number into the platform data of
the dma engine device? Your filter function already identifies
the number of the DMA channel.

> > > +static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
> > > +{
> > > +	struct mxs_mmc_host *host = dev_id;
> > > +	u32 stat;
> > > +
> > > +	stat = __raw_readl(host->base + HW_SSP_CTRL1);
> > > +	__mxs_clrl(stat & MXS_MMC_IRQ_BITS, host->base + HW_SSP_CTRL1);
> > > +
> > > +	if (host->cmd && (stat & MXS_MMC_ERR_BITS))
> > > +		host->status = __raw_readl(host->base + HW_SSP_STATUS);
> > > +
> > > +	if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
> > > +		mmc_signal_sdio_irq(host->mmc);
> > > +
> > > +	return IRQ_HANDLED;
> > > +}
> > 
> > You use spin_lock_irqsave in mxs_mmc_enable_sdio_irq, but don't
> > actually use the spinlock in the interrupt handler. This means
> > that either your interrupt handler is broken because it doesn't
> > lock, or that you don't actually need the _irqsave part.
> > 
> I do not understand this one.  I'm seeing mxcmmc and pxamci use
> spin_lock_irqsave/irqrestore in the similar way.

The difference is that e.g. mxcmci_irq() takes the spinlock that is
used to protect the host->use_sdio flag, serializing the the
code that initializes sdio with the code that uses it.

[Actually, mxcmci_irq() also looks wrong, because it releases the
spinlock before calling mmc_signal_sdio_irq(), so sdio may be
disabled by then, but that is a slightly different bug]

What I meant is that you take care to avoid getting into the
interrupt handler while holding the spinlock, but in the handler,
you don't check if the lock is held. It can't be correct to
serialize just half the cases.

	Arnd

  reply	other threads:[~2011-02-10 17:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-05  2:18 [PATCH 0/7] Add mmc driver for i.MX23/28 Shawn Guo
2011-02-05  2:18 ` [PATCH 1/7] mmc: mxs-mmc: add mmc host " Shawn Guo
2011-02-04 20:26   ` Arnd Bergmann
2011-02-11  0:35     ` Shawn Guo
2011-02-10 17:17       ` Arnd Bergmann [this message]
2011-02-11 23:14         ` Shawn Guo
2011-02-11 15:51           ` Arnd Bergmann
2011-02-12  0:55             ` Shawn Guo
2011-02-11 20:04               ` Arnd Bergmann
2011-02-12 14:04                 ` Shawn Guo
2011-02-12  8:59                   ` Arnd Bergmann
2011-02-12 17:23                     ` Shawn Guo
2011-02-12 10:07                       ` Arnd Bergmann
2011-02-12 18:37                         ` Shawn Guo
2011-02-12 17:30                           ` Arnd Bergmann
2011-02-13 17:53       ` Shawn Guo
2011-02-13 15:34         ` Arnd Bergmann
2011-02-13 23:52           ` Shawn Guo
2011-02-13 16:10             ` Arnd Bergmann
2011-02-08 11:41   ` Lothar Waßmann
2011-02-11 22:11     ` Shawn Guo
2011-02-11 14:40       ` Lothar Waßmann
2011-02-12  1:08         ` Shawn Guo
2011-02-09  7:46   ` Lothar Waßmann
2011-02-11 22:08     ` Shawn Guo
2011-02-11 14:52       ` Lothar Waßmann
2011-02-11 23:48         ` Shawn Guo
2011-02-05  2:18 ` [PATCH 2/7] ARM: mxs/clock: fix base address missing in name##_set_parent Shawn Guo
2011-02-05  2:18 ` [PATCH 3/7] ARM: mxs: make ssp error irq definition consistent Shawn Guo
2011-02-05  2:18 ` [PATCH 4/7] ARM: mxs: dynamically allocate mmc device Shawn Guo
2011-02-05  2:18 ` [PATCH 5/7] ARM: mxs: fix typo "GPO" in iomux-mx23.h Shawn Guo
2011-02-05  2:18 ` [PATCH 6/7] ARM: mxs/mx23evk: add mmc device Shawn Guo
2011-02-05  2:18 ` [PATCH 7/7] ARM: mxs/mx28evk: " Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201102101817.42099.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=cjb@laptop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawn.guo@freescale.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox