From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sascha Hauer Subject: Re: [PATCH] mmc: mxs: fix card detection function for broken card detect Date: Mon, 28 Apr 2014 11:36:19 +0200 Message-ID: <20140428093619.GP5858@pengutronix.de> References: <20140428091341.GA5918@pengutronix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from metis.ext.pengutronix.de ([92.198.50.35]:39144 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbaD1JgV (ORCPT ); Mon, 28 Apr 2014 05:36:21 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-mmc-owner@vger.kernel.org List-Id: linux-mmc@vger.kernel.org To: Ulf Hansson Cc: Daniel Willmann , Chris Ball , linux-mmc , "linux-kernel@vger.kernel.org" , Shawn Guo On Mon, Apr 28, 2014 at 11:31:03AM +0200, Ulf Hansson wrote: > On 28 April 2014 11:13, Sascha Hauer wrote: > > On Sat, Apr 19, 2014 at 11:59:18PM +0200, Daniel Willmann wrote: > >> Return -ENOSYS in get_cd if broken-cd is specified in the device tree. > >> > >> Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card > >> detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This > >> driver sets this flag unconditionally as it does not support a card > >> detect interrupt. Instead, broken-cd means that there is no card detect > >> signal connected. > >> > >> The mmc core checks the get_cd function return value to determine if a > >> card is present. Only for a non-zero return value it will attempt to > >> initialize the card. So retuning -ENOSYS will allow the card to be > >> initialized. > >> For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if > >> the card detect GPIO is not valid. > > > > Short answer for fixing this regression: > > > > Acked-by: Sascha Hauer > > > > Long answer: > > > > This is broken in the MMC OF parser. When the parser finds the > > 'broken-cd' property it just sets the MMC_CAP_NEEDS_POLL flag. This is > > wrong. broken-cd means that we cannot rely on any card detection, but > > instead have to talk to the card to find out if it's available. > > Currently there is no flag to signal this situation, so the host driver > > has to handle this by returning true in the get_cd callback, just like > > the patch below does. > > > > IMO the correct solution would be to add a MMC_CAP_CD_NEEDS_TALK_TO_CARD > > flag to the core. > > > > So if I understand correct, you want the host-ops->get_cd function to > be invoked from the mmc rescan - only when it actually can provide > useful information? Yes. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |