From owner-svn-src-head@freebsd.org Sat Jul 18 16:56:52 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 614AD9A4B8E; Sat, 18 Jul 2015 16:56:52 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 37EF81B03; Sat, 18 Jul 2015 16:56:52 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6IGuqAr072188; Sat, 18 Jul 2015 16:56:52 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6IGuqEl072187; Sat, 18 Jul 2015 16:56:52 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201507181656.t6IGuqEl072187@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sat, 18 Jul 2015 16:56:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285678 - head/sys/dev/mmc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jul 2015 16:56:52 -0000 Author: ian Date: Sat Jul 18 16:56:51 2015 New Revision: 285678 URL: https://svnweb.freebsd.org/changeset/base/285678 Log: Deselect the sd card before re-selecting it when working around a problem with some cards that causes them to become deselected after probing for switch capabilities. The old workaround fixes the behavior with some cards, but causes problems with the cards the behave correctly and don't become deselected. Forcing a deselect then reselect appears to work correctly with all cards in initial testing. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Sat Jul 18 15:28:32 2015 (r285677) +++ head/sys/dev/mmc/mmc.c Sat Jul 18 16:56:51 2015 (r285678) @@ -1381,17 +1381,18 @@ mmc_discover_cards(struct mmc_softc *sc) } /* - * We reselect the card here. Some cards become - * unselected and timeout with the above two commands, - * although the state tables / diagrams in the standard - * suggest they go back to the transfer state. The only - * thing we use from the sd_status is the erase sector - * size, but it is still nice to get that right. It is - * normally harmless for cards not misbehaving. The - * Atmel bridge will complain about this command timing - * out. Others seem to handle it correctly, so it may - * be a combination of card and controller. + * We deselect then reselect the card here. Some cards + * become unselected and timeout with the above two + * commands, although the state tables / diagrams in the + * standard suggest they go back to the transfer state. + * Other cards don't become deselected, and if we + * atttempt to blindly re-select them, we get timeout + * errors from some controllers. So we deselect then + * reselect to handle all situations. The only thing we + * use from the sd_status is the erase sector size, but + * it is still nice to get that right. */ + mmc_select_card(sc, 0); mmc_select_card(sc, ivar->rca); mmc_app_sd_status(sc, ivar->rca, ivar->raw_sd_status); mmc_app_decode_sd_status(ivar->raw_sd_status,