From nobody Tue Dec 07 06:14:12 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4C82418D4B2B; Tue, 7 Dec 2021 06:14:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J7VPJ71sfz3GMN; Tue, 7 Dec 2021 06:14:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D12991AADD; Tue, 7 Dec 2021 06:14:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B76EC4J088741; Tue, 7 Dec 2021 06:14:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B76ECXL088740; Tue, 7 Dec 2021 06:14:12 GMT (envelope-from git) Date: Tue, 7 Dec 2021 06:14:12 GMT Message-Id: <202112070614.1B76ECXL088740@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: 43c4b47b75f3 - main - flex_spi: Don't try to destroy disk if it doesn't exist List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 43c4b47b75f37313c122799fdf7488251bdc7cf7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638857653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rcc6/guIop1wmPjSqSUytiIEDVkLTzCcJWkCWi0O9Ho=; b=yQ9yE54AQwXPLD5uaEevHZBcY5NOEkmuygNhSduaTcT7jKQT7GzTG+fRU4XvL1zlYpKrpi mqUhTgTcAKlAcL/44eg0kL2fuxYKfHOnHjF8fq/gXAOVhdyZUMZW4bTNaGxdtytkAJ+syV q5RJWIydASpjLJQ0K6JUq+8RKGV5qT9a6gQus7gapO3OYbPc7kZjAuWXQonyBlzrSr4Ujq bAb2YZO88T3VDZMK0AnkvzKdWTzbuAceAelgc4k3ZjVx/yhc9Xo262M41rHwZVrx76X0E/ 9bH+faKtTmRy7ExqBkeUoQfuPt1M2QZXqtk/uunsc0vB8oSQFAwT4OvnY52vnQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638857653; a=rsa-sha256; cv=none; b=iDhh42675XNESi7xJe40h/JISPiYJUb9ekPZ5A21hoM5y2gXS460iVDYHbHT3DnfkoFdzO KfsyUJrhEqLnUtTYhuAE3r5QGlSYBbJl+uPv/YJ5iKczCi7PL9O7YpJTun9iTm1aBjNBAt vqzblLhT5aJyth925ztgyqsFlbVYlQV6N6jgUhcc7zA+vSNqtdW8GoeNwl7sicfKQaDOW4 n582BDEaBeujl3zpxKGUoWvatkaNFu51cTYZgt4otEK4vycOfmCUs0dbXKJdNQFqsvbRJR 1KfoBt7BUX4HdDFyfQbAp3SIKm0N/TzRUL7rkssHI7YeJm+yNVPxNpq19p/ecA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=43c4b47b75f37313c122799fdf7488251bdc7cf7 commit 43c4b47b75f37313c122799fdf7488251bdc7cf7 Author: Kornel Duleba AuthorDate: 2021-12-06 14:17:04 +0000 Commit: Wojciech Macek CommitDate: 2021-12-07 06:13:53 +0000 flex_spi: Don't try to destroy disk if it doesn't exist Try to stop and destroy the dist only if the driver has been successfully attached. Otherwise a kernel panic will be triggered from disk_destroy. The issue was observed on a board that missed SPI clock description in DT. --- sys/dev/flash/flexspi/flex_spi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/dev/flash/flexspi/flex_spi.c b/sys/dev/flash/flexspi/flex_spi.c index fc85919fc2f8..fea3134730f1 100644 --- a/sys/dev/flash/flexspi/flex_spi.c +++ b/sys/dev/flash/flexspi/flex_spi.c @@ -824,6 +824,9 @@ flex_spi_detach(device_t dev) sc = device_get_softc(dev); err = 0; + if (!device_is_attached(dev)) + goto free_resources; + mtx_lock(&sc->disk_mtx); if (sc->taskstate == TSTATE_RUNNING) { sc->taskstate = TSTATE_STOPPING; @@ -848,7 +851,7 @@ flex_spi_detach(device_t dev) } /* Disable hardware. */ - +free_resources: /* Release memory resource. */ if (sc->mem_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY,