From patchwork Tue Mar 3 22:53:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 5927121 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 024A49F380 for ; Tue, 3 Mar 2015 23:30:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 126232028D for ; Tue, 3 Mar 2015 23:30:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 79B3E2012B for ; Tue, 3 Mar 2015 23:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932216AbbCCXaI (ORCPT ); Tue, 3 Mar 2015 18:30:08 -0500 Received: from pmta2.delivery10.ore.mailhop.org ([54.69.62.154]:58887 "EHLO pmta2.delivery10.ore.mailhop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757146AbbCCXaF (ORCPT ); Tue, 3 Mar 2015 18:30:05 -0500 X-Greylist: delayed 1840 seconds by postgrey-1.27 at vger.kernel.org; Tue, 03 Mar 2015 18:30:05 EST Received: from smtp1.ore.mailhop.org (172.31.36.112) by pmta2.delivery1.ore.mailhop.org id hup21420u508 for ; Tue, 3 Mar 2015 22:59:44 +0000 (envelope-from ) Received: from 104.193.169-186.public.monkeybrains.net ([104.193.169.186] helo=atomide.com) by smtp1.ore.mailhop.org with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.82) (envelope-from ) id 1YSvme-00039d-A8; Tue, 03 Mar 2015 22:59:24 +0000 X-Mail-Handler: DuoCircle Outbound SMTP X-Originating-IP: 104.193.169.186 X-Report-Abuse-To: abuse@duocircle.com (see https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information for abuse reporting information) X-MHO-User: U2FsdGVkX19TxOa/eVBEEncjCYSTD34E Date: Tue, 3 Mar 2015 14:53:55 -0800 From: Tony Lindgren To: NeilBrown Cc: Ulf Hansson , Andreas Fenkart , linux-mmc , lkml , GTA04 owners , NeilBrown , linux-omap , Florian Vaussard , Ash Charles Subject: Re: [PATCH 3/4] mmc: sdio: support switching to 1-bit before turning off clocks Message-ID: <20150303225355.GE3756@atomide.com> References: <20150224024023.22719.32436.stgit@notabene.brown> <20150224024223.22719.91536.stgit@notabene.brown> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150224024223.22719.91536.stgit@notabene.brown> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * NeilBrown [150223 18:47]: > According to section 7.1.2 of > > http://www.sandisk.com/media/File/OEM/Manuals/SD_SDIO_specsv1.pdf > > In the case where the interrupt mechanism is used to wake the host while > the card is in a low power state (i.e. no clocks), Both the card and the > host shall be placed into the 1-bit SD mode prior to stopping the clock. > > This is particularly important for the Marvell "libertas" wifi chip > in the GTA04. While in 4-bit mode it will only signal an interrupt > when the clock is running (which is why setting CLKEXTFREE is > important). > In 1-bit mode, the interrupt is asynchronous (explained in OMAP3 > TRM description of the CIRQ flag to MMCHS_STAT: > > In 1-bit mode, interrupt source is asynchronous (can be a source of > asynchronous wakeup). > In 4-bit mode, interrupt source is sampled during the interrupt > cycle. > > ) > > It is awkward to simply set 1-bit mode in ->runtime_suspend > as that will call mmc_set_ios which calls ops->set_ios(), > which will likely call pm_runtime_get_sync(), on the device that > is currently suspending. This deadlocks. > > So: > - create a work_struct to schedule setting of 1-bit mode > - introduce an 'sdio_narrowed' state flag which transitions: > 0 (normal) -> 1 (convert to 1-bit pending) -> > 2 (have switch to 1-bit mode) -> 0 (normal) > - create a function mmc_sdio_want_no_clocks() which can be called > when the driver wants to turn off clocks (presumably after an > idle timeout). This either succeeds (in 1-bit mode) or fails > and schedules the work to switch to 1-bit mode. > - when the host is claimed, if sdio_narrowed is 2, restore the > 4-bit bus > - When the host is released, if sdio_narrowed is 1, then some > caller other than our worker claimed the host first, so > clear sdio_narrowed. > > This all allows a graceful and race-free switch to 1-bit mode > before switching off the clocks, if SDIO interrupts are enabled. > > A host should call mmc_sdio_want_no_clocks() when about to turn off > clocks if sdio interrupts are enabled, and the ->disable() function > should not use a timeout (pm_runtime_put_autosuspend) if > ->sdio_narrowed is 2. Wow! A mystery finally solved for why libertas_sdio using devices like overo won't work for the wakeirqs.. The interface has to be in 1-bit mode for libertas to produce any SDIO interrupts.. Below is a patch enabling some more SDIO wakeirqs. Seems to work on overo now too :) So tor the whole series, please feel free to add: Tested-by: Tony Lindgren 8< ------------------- From: Tony Lindgren Date: Thu, 26 Feb 2015 16:16:03 -0800 Subject: [PATCH] ARM: dts: Fix omap3 SDIO wakeirqs for devices using sdio_libertas Turns out the the MMC interface needs to be in 1-bit mode for the libertas card to send any SDIO interrupts as pointed out by NeilBrown . Now that the MMC framework is getting fixed for setting 1-bit mode for idle, we can enable SDIO wakeirqs for libertas using devices too. Cc: Andreas Fenkart Cc: Ash Charles Cc: Florian Vaussard Cc: NeilBrown Signed-off-by: Tony Lindgren --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/arch/arm/boot/dts/omap3-gta04.dtsi +++ b/arch/arm/boot/dts/omap3-gta04.dtsi @@ -367,6 +367,7 @@ }; &mmc2 { + interrupts-extended = <&intc 86 &omap3_pmx_core 0x12e>; vmmc-supply = <&vaux4>; bus-width = <4>; ti,non-removable; --- a/arch/arm/boot/dts/omap3-overo-base.dtsi +++ b/arch/arm/boot/dts/omap3-overo-base.dtsi @@ -185,6 +185,7 @@ &mmc2 { pinctrl-names = "default"; pinctrl-0 = <&mmc2_pins>; + interrupts-extended = <&intc 86 &omap3_pmx_core 0x12e>; vmmc-supply = <&w3cbw003c_npoweron>; vqmmc-supply = <&w3cbw003c_bt_nreset>; vmmc_aux-supply = <&w3cbw003c_wifi_nreset>;