Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Quentin Schulz <quentin.schulz@bootlin.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Quentin Schulz <quentin.schulz@free-electrons.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Shawn Lin <shawn.lin@rock-chips.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Baolin Wang <baolin.wang@linaro.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	driverdevel <devel@driverdev.osuosl.org>,
	Icenowy Zheng <icenowy@aosc.xyz>, Chen-Yu Tsai <wens@csie.org>
Subject: Re: [PATCH 2/2] mmc: Add mmc_force_detect_change_begin / _end functions
Date: Fri, 9 Feb 2018 09:05:41 +0100	[thread overview]
Message-ID: <20180209080541.edgjbhjo542vq3h6@qschulz> (raw)
In-Reply-To: <CAPDyKFrbRVgOFRKpO5TdwHO-XQ035exrUt_bgM=BaxnEPmCvrw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6287 bytes --]

Hi Ulf,

On Thu, Feb 08, 2018 at 10:31:39PM +0100, Ulf Hansson wrote:
> On 8 February 2018 at 15:59, Quentin Schulz <quentin.schulz@bootlin.com> wrote:
> > Hi Ulf,
> >
> > On Wed, Aug 30, 2017 at 03:43:49PM +0200, Ulf Hansson wrote:
> >> On 30 August 2017 at 14:44, Hans de Goede <hdegoede@redhat.com> wrote:
> >> > Hi,
> >> >
> >> >
> >> > On 21-07-17 16:35, Quentin Schulz wrote:
> >> >>
> >> >> From: Hans de Goede <hdegoede@redhat.com>
> >> >>
> >> >> Some sdio devices have a multiple stage bring-up process. Specifically
> >> >> the esp8089 (for which an out of tree driver is available) loads firmware
> >> >> on the first call to its sdio-drivers' probe function and then resets
> >> >> the device causing it to reboot from its RAM with the new firmware.
> >> >>
> >> >> When this sdio device reboots it comes back up in 1 bit 400 KHz mode
> >> >> again, and we need to walk through the whole ios negatiation and sdio
> >> >> setup
> >> >> again.
> >> >>
> >> >> There are 2 problems with this:
> >> >>
> >> >> 1) Typically these devices are soldered onto some (ARM) tablet / SBC
> >> >> PCB and as such are described in devicetree as "non-removable", which
> >> >> causes the mmc-core to scan them only once and not poll for the device
> >> >> dropping of the bus. Normally this is the right thing todo but in the
> >> >> eso8089 example we need the mmc-core to notice the module has disconnected
> >> >> (since it is now in 1 bit mode again it will not talk to the host in 4 bit
> >> >> mode). This can be worked around by using "broken-cd" in devicetree
> >> >> instead of "non-removable", but that is not a proper fix since the device
> >> >> really is non-removable.
> >> >>
> >> >> 2) When the mmc-core detects the device has disconnected it will poweroff
> >> >> the device, causing the RAM loaded firmware to be lost. This can be worked
> >> >> around in devicetree by using regulator-always-on (and avoiding the use of
> >> >> mmc-pwrseq), but again that is more of a hack then a proper fix.
> >> >>
> >> >> This commmit fixes 1) by adding a mmc_force_detect_change function which
> >> >> will cause scanning for device removal / insertion until a new device is
> >> >> detected. 2) Is fixed by a keep_power flag to the mmc_force_detect_change
> >> >> function which when set causes the mmc-core to keep the power to the
> >> >> device
> >> >> on during the rescan.
> >> >>
> >> >> Cc: Icenowy Zheng <icenowy@aosc.xyz>
> >> >> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> >> >> Cc: Chen-Yu Tsai <wens@csie.org>
> >> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >> >
> >> >
> >> > So when I posted this patch quite a while back, there was some discussion
> >> > about this and a consensus that this is not the right solution.
> >> >
> >> > So first of all lets describe the problem:
> >> >
> >> > The esp8089 sdio wifi chip is really an ARM core with a wifi phy
> >> > connected to it (as many wifi chipsets are).
> >> >
> >> > But this one comes up in some really generic sdio capable boot-loader
> >> > mode and we need to feed it firmware and then reboot it into the
> >> > new firmware.
> >> >
> >> > The reboot is where the problems happens. It seems to fallback
> >> > from the negotiated 4 wire sdio mode to single wire spi mode then.
> >> >
> >> > The out of tree version of the driver deals with this by not setting
> >> > the non-removable flag as well as setting the broken_cd flag so that
> >> > the mmc core polls the device, after the reboot the poll fails
> >> > because the mmc-controller and the esp8089 are using a different
> >> > amount of wires so the mmc-cmd the poll uses times out.
> >> >
> >> > After which the esp8089 drivers remove function gets called, and
> >> > the mmc stack re-discovers the esp8089 by restarting the whole
> >> > number of wires (and speed) used negotiation. After which the
> >> > esp8089 driver's probe function gets called (again) and on
> >> > firmware loading is has set a global flag, so now it actually
> >> > acts as a wifi driver rather then trying to load the firmware
> >> > a second time.
> >> >
> >> > Since I did not want to rely on broken_cd polling I came up
> >> > with the hack which is this patch.
> >> >
> >> > So when this patch was first discussed we came to the conclusion
> >> > that what we really need is some sort of mmc_reprobe_device
> >> > function which the driver can call from probe which will
> >> > redo the number of wires (and speed) used negotiation,
> >> > while keeping the sdio_function device as is so that probe can
> >> > simply continue after this and we also don't need the ugly
> >> > global flag.
> >> >
> >> > The idea would be for this function to be some wrapper
> >> > around mmc_init_card() which resets the ios settings as is
> >> > normally done on remove and then call mmc_init_card()
> >> > passing in the existing card the same way as is done
> >> > one resume, so that the existing card / sdio_function
> >> > devices get reused.
> >> >
> >> > IIRC Ulf would look into writing this mmc_reprobe_device
> >> > function and then I would test it with the esp8089, but
> >> > Ulf never got around to writing the function and I ended
> >> > up working on other things too.
> >>
> >> Thanks for summary!
> >>
> >> Just to let you know, I haven't forgot about this problem. I am
> >> planning for a major update of the SDIO for power management support,
> >> within a not too far future.
> >> The issue described above, is then also one of the things I also plan
> >> to look into.
> >>
> >
> > I'd like to know if any progress has been made on that problem (I may
> > have missed patches).
> > Had you had the time to look at the issue?
> 
> I have looked at the issue, but not manage to cook some patches for it.
> 
> However, it's on my top of my TODO list for mmc. No promises, but
> perhaps and hopefully I manage to get something posted during the
> coming release cycle.
> 

Cool! If you ever need some testing, I'd be glad to test your patches
(even if they are in a draft/RFC state).

Also, when you send patches, I'd appreciate being Cc'ed so that I can
put my Tested-by :) Thanks!

Best regards,
Quentin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2018-02-09  8:05 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21 14:35 [PATCH 0/2] add ESP8089 WiFi chip driver Quentin Schulz
2017-07-21 14:35 ` [PATCH 1/2] staging: net: wireless: add ESP8089 WiFi driver Quentin Schulz
2017-07-21 15:01   ` Greg KH
2017-07-21 16:47     ` Quentin Schulz
2017-07-21 16:52       ` Marcel Holtmann
2017-07-21 17:05         ` Quentin Schulz
2017-07-25  8:31           ` Kalle Valo
2017-07-21 15:01   ` Marcel Holtmann
2017-07-23  7:06   ` kbuild test robot
2017-07-23  8:25   ` kbuild test robot
2017-07-23  8:25   ` [PATCH] staging: net: wireless: fix badzero.cocci warnings kbuild test robot
2017-07-25 10:31   ` [PATCH 1/2] staging: net: wireless: add ESP8089 WiFi driver Dan Carpenter
2017-07-21 14:35 ` [PATCH 2/2] mmc: Add mmc_force_detect_change_begin / _end functions Quentin Schulz
2017-07-22 14:07   ` Shawn Lin
2017-08-30 12:44   ` Hans de Goede
2017-08-30 13:43     ` Ulf Hansson
2018-02-08 14:59       ` Quentin Schulz
2018-02-08 21:31         ` Ulf Hansson
2018-02-09  8:05           ` Quentin Schulz [this message]
2018-02-09 14:01             ` Ulf Hansson
2018-03-23  7:25               ` Quentin Schulz
2018-09-26 14:44               ` Frieder Schrempf
2018-09-26 20:19                 ` Hans de Goede
2018-09-27  8:14                   ` Maxime Ripard
2018-10-08  9:53                     ` Frieder Schrempf
2018-10-09  7:52                       ` Quentin Schulz
2018-10-09 14:03                         ` Frieder Schrempf

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=20180209080541.edgjbhjo542vq3h6@qschulz \
    --to=quentin.schulz@bootlin.com \
    --cc=adrian.hunter@intel.com \
    --cc=baolin.wang@linaro.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=icenowy@aosc.xyz \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=quentin.schulz@free-electrons.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wens@csie.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