linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Pratyush Anand <pratyush.anand@st.com>,
	spear-devel <spear-devel@list.st.com>,
	Mohit KUMAR <Mohit.KUMAR@st.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	linux-mmc@vger.kernel.org, Chris Ball <chris@printf.net>
Subject: Re: [PATCH RFC 07/31] mmc: sdhci: push card_tasklet into threaded irq handler
Date: Wed, 19 Feb 2014 10:50:11 +0000	[thread overview]
Message-ID: <20140219105011.GU21483@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <CAKohpo=ZrLRsTyCH86x7TbGE2XJnpXNb1ZDvYyzDUupAwTtS9Q@mail.gmail.com>

On Wed, Feb 19, 2014 at 03:39:35PM +0530, Viresh Kumar wrote:
> On 19 February 2014 15:22, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > If you don't want to use a regulator, then the right way to do this is to
> > use the set_ios callback and check the power field - anything which is not
> > MMC_POWER_OFF should result in power to the card being turned on.
> 
> I didn't get that completely here.. sorry completely out of touch on
> this driver.
> The power GPIO here is controlling the power to card socket. Once the card
> is inserted, we need to enable power to the socket so that controller can
> read back information from card.

Yes, and how is this different from any other implementation where power
to the socket is controlled?

This is what happens:
- You detect a card insertion/removal event
- You tell the mmc core about it via mmc_detect_change()
- The mmc core looks at the current state, and if the socket is powered down,
  it first goes through the power up sequence:
  - Apply power to the socket
    (a call to set_ios with MMC_POWER_UP and zero clock)
  - Apply clock to the socket
    (a call to set_ios with MMC_POWER_ON and non-zero clock)
  - Wait 74 clock cycles (as required by the spec)
- Start the detection by sending commands to the cards
- If no cards are detected, power down the socket

> And this set_ios callback is not available to drivers above sdhci.c, i.e.
> glues like sdhci-pltfm or spear.. so, how we can we get that back in
> sdhci-spear.c?

This is the crux of the issue which this patch set tries to address.  sdhci
has become - as I've now described it several times - "a patchwork quilt of
hacks all cooperating to give the impression of a working driver".

This is just another such hack, because rather than fixing sdhci.c properly,
you've hacked around it, thereby making sdhci.c worse.

What you could have done is turned the power control code in sdhci.c into
a library function, and sdhci_do_set_ios() calls a method in the sdhci_ops
to control the power.  What this means is that:

- if you use the standard sdhci power control support, then you can just
  hook the standard function in there.
- if you need to do something extra, you can place your function there
  to do your own stuff, and call the standard function to do the standard
  bits.
- if you don't need the standard functionality, then you can handle the
  power control entirely within your driver.

Not only does this result in a much cleaner implementation, it means that
going forward, any other such quirky stuff can be handled in the same way
by the "glues" rather than having to augment the horrid quirk/quirk2 stuff,
or coming up with hacks like sdhci-spear.c

If you have a look through this patch set, I've already done that with a
number of these methods - set_clock, set_uhs_signaling and reset.

Moreover, you don't end up fiddling with sdhci internals (such as the
card_tasklet) which then impact on attempts to clean that code up, which
is exactly why we're discussing this. :)

> Again, I can't test any modifications to this code and we need help from
> Pratyush/Mohit on this..

The important thing is we understand why the code is the way it is today,
and work out some way of cleaning this up.  Do you think the above will
work?

-- 
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".

  reply	other threads:[~2014-02-19 10:50 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-18 15:08 [PATCH RFC 00/31] SDHCI and SDIO IRQ improvements Russell King - ARM Linux
2014-02-18 15:09 ` [PATCH RFC 01/31] genirq: Provide synchronize_hardirq() Russell King
2014-02-18 15:09 ` [PATCH RFC 02/31] genirq: Provide irq_wake_thread() Russell King
2014-02-18 15:09 ` [PATCH RFC 03/31] mmc: sdio_irq: rework sdio irq handling Russell King
2014-02-19  3:40   ` Nicolas Pitre
2014-02-19  9:44     ` Russell King - ARM Linux
2014-02-18 15:09 ` [PATCH RFC 04/31] mmc: sdhci: clean up interrupt handling Russell King
2014-02-18 15:09 ` [PATCH RFC 05/31] mmc: sdhci: clean up sdio interrupt enable handling Russell King
2014-02-18 15:09 ` [PATCH RFC 06/31] mmc: sdhci: convert to new SDIO IRQ handling Russell King
2014-02-18 15:09 ` [PATCH RFC 07/31] mmc: sdhci: push card_tasklet into threaded irq handler Russell King
2014-02-18 17:57   ` Russell King - ARM Linux
2014-02-19  6:13     ` Viresh Kumar
2014-02-19  9:43       ` Russell King - ARM Linux
2014-02-19  9:48         ` Viresh Kumar
2014-02-19  9:52           ` Russell King - ARM Linux
2014-02-19 10:09             ` Viresh Kumar
2014-02-19 10:50               ` Russell King - ARM Linux [this message]
2014-02-19 10:55                 ` Viresh Kumar
2014-02-20 10:59                   ` Russell King - ARM Linux
2014-02-20 11:18                     ` Viresh Kumar
2014-02-21 10:37                       ` Russell King - ARM Linux
2014-02-21 10:41                         ` [PATCH 1/5] mmc: sdhci-spear: fix error handling paths for DT Russell King
2014-02-24  5:59                           ` Viresh Kumar
2014-02-21 10:41                         ` [PATCH 2/5] mmc: sdhci-spear: fix platform_data usage Russell King
2014-02-21 10:41                         ` [PATCH 3/5] mmc: sdhci-spear: simplify resource handling Russell King
2014-02-21 10:41                         ` [PATCH 4/5] mmc: sdhci-spear: remove support for power gpio Russell King
2014-02-21 10:41                         ` [PATCH 5/5] mmc: sdhci-spear: use generic card detection gpio support Russell King
2014-02-24  6:11                           ` Pratyush Anand
2014-02-22 18:27                         ` [PATCH RFC 07/31] mmc: sdhci: push card_tasklet into threaded irq handler Chris Ball
2014-02-22 19:05                           ` Russell King - ARM Linux
2014-02-22 19:11                             ` Chris Ball
2014-02-18 15:09 ` [PATCH RFC 08/31] mmc: sdhci: allow sdio interrupts while sdhci runtime suspended Russell King
2014-02-18 15:09 ` [PATCH RFC 09/31] mmc: sdhci: more efficient interrupt enable register handling Russell King
2014-02-18 15:09 ` [PATCH RFC 10/31] mmc: sdhci: plug hole in disabling card detection interrupts Russell King
2014-02-18 15:09 ` [PATCH RFC 11/31] mmc: sdhci: convert generic bus width setup to library function Russell King
2014-02-18 15:10 ` [PATCH RFC 12/31] mmc: sdhci: convert reset into a " Russell King
2014-02-18 15:10 ` [PATCH RFC 13/31] mmc: sdhci: move FSL ESDHC reset handling quirk into esdhc code Russell King
2014-02-18 15:10 ` [PATCH RFC 14/31] mmc: sdhci: avoid sync'ing the SG if there's no misalignment Russell King
2014-02-18 15:10 ` [PATCH RFC 15/31] mmc: sdhci: convert ADMA descriptors to a coherent allocation Russell King
2014-02-18 15:10 ` [PATCH RFC 16/31] mmc: sdhci: clean up sdhci_update_clock()/sdhci_set_clock() Russell King
2014-02-18 15:10 ` [PATCH RFC 17/31] mmc: sdhci: move setting host->clock into sdhci_do_set_ios() Russell King
2014-02-18 15:10 ` [PATCH RFC 18/31] mmc: sdhci: move setting mmc->actual_clock into set_clock handlers Russell King
2014-02-18 15:10 ` [PATCH RFC 19/31] mmc: sdhci: convert sdhci_set_clock() into a library function Russell King
2014-02-18 15:10 ` [PATCH RFC 20/31] mmc: sdhci-esdhc-imx: avoid DMA to kernel stack Russell King
2014-02-18 15:10 ` [PATCH RFC 21/31] mmc: sdhci-esdhc-imx: avoid runtime_pm_get_sync() in esdhc_prepare_tuning() Russell King
2014-02-18 15:10 ` [PATCH RFC 22/31] mmc: sdhci-esdhc-imx: fix lockdep splat upon tuning Russell King
2014-02-18 15:11 ` [PATCH RFC 23/31] mmc: sdhci: hack up driver to make it more compliant with UHS-1 Russell King
2014-02-18 15:11 ` [PATCH RFC 24/31] mmc: sdhci: set_uhs_signaling() need not return a value Russell King
2014-02-18 15:11 ` [PATCH RFC 25/31] mmc: sdhci: convert sdhci_set_uhs_signaling() into a library function Russell King
2014-02-18 15:11 ` [PATCH RFC 26/31] mmc: sdhci: cache timing information locally Russell King
2014-02-18 15:11 ` [PATCH RFC 27/31] mmc: sdhci: clean up sdhci_execute_tuning() decision Russell King
2014-02-18 15:11 ` [PATCH RFC 28/31] mmc: sdhci-esdhc-imx: remove emulation of uhs_mode Russell King
2014-02-18 15:11 ` [PATCH RFC 29/31] mmc: sdhci-of-esdhc: remove platform_suspend/platform_resume callbacks Russell King
2014-02-18 15:11 ` [PATCH RFC 30/31] mmc: sdhci: " Russell King
2014-02-18 15:11 ` [PATCH RFC 31/31] mmc: sdhci-tegra: get rid of special PRESENT_STATE register handling Russell King
2014-02-19 20:04   ` Stephen Warren
2014-02-19 23:22     ` Russell King - ARM Linux
     [not found]       ` <20140219232253.GW21483-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2014-02-19 23:28         ` Russell King - ARM Linux

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=20140219105011.GU21483@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=Mohit.KUMAR@st.com \
    --cc=chris@printf.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=pratyush.anand@st.com \
    --cc=spear-devel@list.st.com \
    --cc=viresh.kumar@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).