From owner-svn-src-head@freebsd.org Mon Jan 9 17:10:51 2017 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 67A5ECA717A; Mon, 9 Jan 2017 17:10:51 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 213E5138F; Mon, 9 Jan 2017 17:10:51 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v09HAojV083510; Mon, 9 Jan 2017 17:10:50 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v09HAo4j083509; Mon, 9 Jan 2017 17:10:50 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201701091710.v09HAo4j083509@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Mon, 9 Jan 2017 17:10:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311797 - 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-head@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 09 Jan 2017 17:10:51 -0000 Author: ian Date: Mon Jan 9 17:10:50 2017 New Revision: 311797 URL: https://svnweb.freebsd.org/changeset/base/311797 Log: Add sdhci_handle_card_present_locked() that can be called from the interrupt handler which already holds the mutex, and have sdhci_handle_card_present() be just a tiny wrapper that does the locking for external callers. This should fix the recursive locking panics seen on rpi3. Reported by: Shawn Webb Modified: head/sys/dev/sdhci/sdhci.c Modified: head/sys/dev/sdhci/sdhci.c ============================================================================== --- head/sys/dev/sdhci/sdhci.c Mon Jan 9 17:09:53 2017 (r311796) +++ head/sys/dev/sdhci/sdhci.c Mon Jan 9 17:10:50 2017 (r311797) @@ -521,8 +521,8 @@ sdhci_card_task(void *arg, int pending) } } -void -sdhci_handle_card_present(struct sdhci_slot *slot, bool is_present) +static void +sdhci_handle_card_present_locked(struct sdhci_slot *slot, bool is_present) { bool was_present; @@ -537,7 +537,6 @@ sdhci_handle_card_present(struct sdhci_s * because once power is removed, a full card re-init is needed, and * that happens by deleting and recreating the child device. */ - SDHCI_LOCK(slot); was_present = slot->dev != NULL; if (!was_present && is_present) { taskqueue_enqueue_timeout(taskqueue_swi_giant, @@ -545,6 +544,14 @@ sdhci_handle_card_present(struct sdhci_s } else if (was_present && !is_present) { taskqueue_enqueue(taskqueue_swi_giant, &slot->card_task); } +} + +void +sdhci_handle_card_present(struct sdhci_slot *slot, bool is_present) +{ + + SDHCI_LOCK(slot); + sdhci_handle_card_present_locked(slot, is_present); SDHCI_UNLOCK(slot); } @@ -1402,7 +1409,7 @@ sdhci_generic_intr(struct sdhci_slot *sl WR4(slot, SDHCI_SIGNAL_ENABLE, slot->intmask); WR4(slot, SDHCI_INT_STATUS, intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)); - sdhci_handle_card_present(slot, present); + sdhci_handle_card_present_locked(slot, present); intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); } /* Handle command interrupts. */