From owner-svn-src-head@freebsd.org Fri Sep 4 18:29:59 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA8273CB469; Fri, 4 Sep 2020 18:29:59 +0000 (UTC) (envelope-from bz@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BjmS74zV8z4Qv2; Fri, 4 Sep 2020 18:29:59 +0000 (UTC) (envelope-from bz@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F65910A5D; Fri, 4 Sep 2020 18:29:59 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 084ITx7t002034; Fri, 4 Sep 2020 18:29:59 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 084ITx6G002032; Fri, 4 Sep 2020 18:29:59 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202009041829.084ITx6G002032@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Fri, 4 Sep 2020 18:29:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365335 - head/sys/dev/usb/storage X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/dev/usb/storage X-SVN-Commit-Revision: 365335 X-SVN-Commit-Repository: base 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.33 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: Fri, 04 Sep 2020 18:29:59 -0000 Author: bz Date: Fri Sep 4 18:29:59 2020 New Revision: 365335 URL: https://svnweb.freebsd.org/changeset/base/365335 Log: umass: enhance debugging Investigating a hang I found having some more error information available would be helpful, so be more verbose and also tell cam/xpt status in case of error/panic. Reviewed by: hselasky MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26287 Modified: head/sys/dev/usb/storage/umass.c Modified: head/sys/dev/usb/storage/umass.c ============================================================================== --- head/sys/dev/usb/storage/umass.c Fri Sep 4 18:26:35 2020 (r365334) +++ head/sys/dev/usb/storage/umass.c Fri Sep 4 18:29:59 2020 (r365335) @@ -2063,6 +2063,7 @@ static int umass_cam_attach_sim(struct umass_softc *sc) { struct cam_devq *devq; /* Per device Queue */ + cam_status status; /* * A HBA is attached to the CAM layer. @@ -2091,11 +2092,12 @@ umass_cam_attach_sim(struct umass_softc *sc) } mtx_lock(&sc->sc_mtx); - - if (xpt_bus_register(sc->sc_sim, sc->sc_dev, - sc->sc_unit) != CAM_SUCCESS) { + status = xpt_bus_register(sc->sc_sim, sc->sc_dev, sc->sc_unit); + if (status != CAM_SUCCESS) { cam_sim_free(sc->sc_sim, /* free_devq */ TRUE); mtx_unlock(&sc->sc_mtx); + printf("%s: xpt_bus_register failed with status %#x\n", + __func__, status); return (ENOMEM); } mtx_unlock(&sc->sc_mtx); @@ -2121,14 +2123,22 @@ umass_cam_attach(struct umass_softc *sc) static void umass_cam_detach_sim(struct umass_softc *sc) { + cam_status status; + if (sc->sc_sim != NULL) { - if (xpt_bus_deregister(cam_sim_path(sc->sc_sim))) { + status = xpt_bus_deregister(cam_sim_path(sc->sc_sim)); + if (status == CAM_REQ_CMP) { /* accessing the softc is not possible after this */ sc->sc_sim->softc = NULL; + DPRINTF(sc, UDMASS_SCSI, "%s: %s:%d:%d caling " + "cam_sim_free sim %p refc %u mtx %p\n", + __func__, sc->sc_name, cam_sim_path(sc->sc_sim), + sc->sc_unit, sc->sc_sim, + sc->sc_sim->refcount, sc->sc_sim->mtx); cam_sim_free(sc->sc_sim, /* free_devq */ TRUE); } else { - panic("%s: CAM layer is busy\n", - sc->sc_name); + panic("%s: %s: CAM layer is busy: %#x\n", + __func__, sc->sc_name, status); } sc->sc_sim = NULL; }