From owner-svn-src-all@FreeBSD.ORG Sat Feb 15 17:59:33 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8AD47A84; Sat, 15 Feb 2014 17:59:33 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7736E1B1F; Sat, 15 Feb 2014 17:59:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1FHxX85034121; Sat, 15 Feb 2014 17:59:33 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1FHxXNH034120; Sat, 15 Feb 2014 17:59:33 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201402151759.s1FHxXNH034120@svn.freebsd.org> From: Ian Lepore Date: Sat, 15 Feb 2014 17:59:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261940 - head/sys/dev/sdhci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2014 17:59:33 -0000 Author: ian Date: Sat Feb 15 17:59:32 2014 New Revision: 261940 URL: http://svnweb.freebsd.org/changeset/base/261940 Log: Increase the wait time for acquiring the bus from 10 to 250ms. Normally it never needs to wait here at all; waiting is done at the end of the prior command. When doing a crash dump, the normal interrupt mechanism isn't used; instead the interrupt handler is called repeatedly in a polling-like manner. This can subvert hardware-specific drivers and lead to trying to start a new command while the previous command is still busy on the bus. Since the SD spec says the longest a card can take to execute any command is 250ms, use that as a timeout. Modified: head/sys/dev/sdhci/sdhci.c Modified: head/sys/dev/sdhci/sdhci.c ============================================================================== --- head/sys/dev/sdhci/sdhci.c Sat Feb 15 17:55:35 2014 (r261939) +++ head/sys/dev/sdhci/sdhci.c Sat Feb 15 17:59:32 2014 (r261940) @@ -767,8 +767,17 @@ sdhci_start_command(struct sdhci_slot *s /* We shouldn't wait for DAT for stop commands. */ if (cmd == slot->req->stop) mask &= ~SDHCI_DAT_INHIBIT; - /* Wait for bus no more then 10 ms. */ - timeout = 10; + /* + * Wait for bus no more then 250 ms. Typically there will be no wait + * here at all, but when writing a crash dump we may be bypassing the + * host platform's interrupt handler, and in some cases that handler + * may be working around hardware quirks such as not respecting r1b + * busy indications. In those cases, this wait-loop serves the purpose + * of waiting for the prior command and data transfers to be done, and + * SD cards are allowed to take up to 250ms for write and erase ops. + * (It's usually more like 20-30ms in the real world.) + */ + timeout = 250; while (state & mask) { if (timeout == 0) { slot_printf(slot, "Controller never released "