Received: by 10.223.176.5 with SMTP id f5csp2405445wra; Thu, 8 Feb 2018 13:34:05 -0800 (PST) X-Google-Smtp-Source: AH8x224HrDkHlurNaTRGg7P27U5FKECdI5Rs8svus99yFwY3t8ekA+bfRX7dehh3thFoA9Ze+cj0 X-Received: by 10.98.186.18 with SMTP id k18mr416147pff.115.1518125645480; Thu, 08 Feb 2018 13:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518125645; cv=none; d=google.com; s=arc-20160816; b=Xj7Zf5WW2Q9YQ6tnI6vi2WMv4cnErNOXtOY1NhDWJ91bGZIMyeEtp8DRdfUINTpq2H 3k8vcCfQWHqKTCQwD1cvdw/HjnRxiHlGS8WGHLW6xBkpT7Vm6kd5jgTpbIg3EZ8ZOplj +Jrw4xhpk/4HcHds11cFO9q8J1K/NX6IPCkcLbpvCKJdddJkzVTwZTLANddxTO8HZ28Z sIv0zuxEItCO6WnJJHJn/Cbvh2y1/Toyxy7/p4phWIk/mrTw7ru9d4JmzSdCnFkmmULL aer9nxStFQdKsDk28IGsPYIzPkzWR4WqJ9bhqBNVPrarLckD93T/xuBhRZAfcBDPR8hk ARpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=pcnIXapY1IoZcMiQshzuDW86U3lrbuucc/Uj+VE9O7w=; b=xE0vRr57mUJF3OPZGdKfmXSohEsDOpEbOPxrN+V0ACttgv1Oz/NMFG88k496EXSBoC OH6+dFjrmk+GQYfHsOaKrSRpe4Ah+C1a26LXb3Fk8aoY+PdmN88aJ3kNdkoMCMabvUf3 QLUAXODJcw+JQFuicku+56Y5aajvVDTqalZvba/7PST32K7n08cx/jryXk1ZcAKfNmjC SaZcvhYiLatSzTxwzs6z4cIG8ujpu00bNLCz8xBTRWULmKCBv/Dl3WhJZ/QaSdAkhOaH gUjR3nHq3JN5TfN+V1CIfydPQu7VFtXWvnVQJ8lh1qyarNlkjec25ibW679+XC7fmS2i jGlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvbhPLFr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si444909pgf.26.2018.02.08.13.33.32; Thu, 08 Feb 2018 13:34:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvbhPLFr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752403AbeBHVbm (ORCPT + 99 others); Thu, 8 Feb 2018 16:31:42 -0500 Received: from mail-it0-f45.google.com ([209.85.214.45]:52294 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752335AbeBHVbk (ORCPT ); Thu, 8 Feb 2018 16:31:40 -0500 Received: by mail-it0-f45.google.com with SMTP id o13so8364924ito.2 for ; Thu, 08 Feb 2018 13:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=pcnIXapY1IoZcMiQshzuDW86U3lrbuucc/Uj+VE9O7w=; b=VvbhPLFrcVAUa9H2vt/ZhffYC0fiXKQDb2AXXXekGTt4adtUi7tJiLOfGoQjflDL1k 3u4fCG/iwYQOClQlwph40Mzc3Wj2Py/bBc2fl/ULMkZ1EK2soKuqo0XCDpfhbXJkB/r8 huf9AY50tq5n/VB6hsHHKa68LBVxZtWPVv9UA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pcnIXapY1IoZcMiQshzuDW86U3lrbuucc/Uj+VE9O7w=; b=jzqCHM494J/tw7OumV2QdRnaOMnrjPLc7iyrEIrqO89CgMoq5u2vMWRjmNMqwDk69z d3eqUqprf/Ncofq+VGfhxv5PZgAacK84tEyFnMleYkSadytcNQCvheHw+y8RqYX5bVnI Uxks+RzPOmM/Omw+yCdKXydH1oiQLJIiBAapooI1+uaQmdTvVW0byzn9udKUcY/SxFSH gfqmM1hlEbKNzxzWenRNOO7Fh/IWZJf9n/N8L5AO4N5B+4eAVsQF0d3aAUOleKFyudk0 ntbHqo8UHyqs8wrFGHxL6FE2QCxHRHyGQhzgjVUciZy6oD11hSKyFooFIyYgl0xuJV5I 2ffg== X-Gm-Message-State: APf1xPBy98Yt5kTC8zf6VCF68tNDWen6wCMc2mrUWhG1PY4eLUw57Saj bAr23p/xxZjwYt8Lf1e3ESM3AjBLY9BaddxGhW5YKg== X-Received: by 10.36.151.142 with SMTP id k136mr853283ite.116.1518125499521; Thu, 08 Feb 2018 13:31:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.91.65 with HTTP; Thu, 8 Feb 2018 13:31:39 -0800 (PST) In-Reply-To: <20180208145952.qlq4sxohqd3s7m7o@qschulz> References: <20170721143502.1991-1-quentin.schulz@free-electrons.com> <20170721143502.1991-3-quentin.schulz@free-electrons.com> <4015f7df-36ca-c762-5b9a-94a270f65475@redhat.com> <20180208145952.qlq4sxohqd3s7m7o@qschulz> From: Ulf Hansson Date: Thu, 8 Feb 2018 22:31:39 +0100 Message-ID: Subject: Re: [PATCH 2/2] mmc: Add mmc_force_detect_change_begin / _end functions To: Quentin Schulz Cc: Hans de Goede , Quentin Schulz , Greg Kroah-Hartman , Linus Walleij , Shawn Lin , Adrian Hunter , Baolin Wang , Maxime Ripard , Thomas Petazzoni , "linux-kernel@vger.kernel.org" , "linux-mmc@vger.kernel.org" , driverdevel , Icenowy Zheng , Chen-Yu Tsai Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8 February 2018 at 15:59, Quentin Schulz 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 wrote: >> > Hi, >> > >> > >> > On 21-07-17 16:35, Quentin Schulz wrote: >> >> >> >> From: Hans de Goede >> >> >> >> 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 >> >> Cc: Maxime Ripard >> >> Cc: Chen-Yu Tsai >> >> Signed-off-by: Hans de Goede >> > >> > >> > 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. Sorry for the delay! Br Uffe