From owner-svn-src-all@FreeBSD.ORG Sun Jul 18 07:23:00 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5A581065674; Sun, 18 Jul 2010 07:23:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BAAEC8FC13; Sun, 18 Jul 2010 07:23:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6I7N0RZ079423; Sun, 18 Jul 2010 07:23:00 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6I7N0Ys079421; Sun, 18 Jul 2010 07:23:00 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201007180723.o6I7N0Ys079421@svn.freebsd.org> From: Alexander Motin Date: Sun, 18 Jul 2010 07:23:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210208 - stable/8/sys/dev/ata X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 18 Jul 2010 07:23:01 -0000 Author: mav Date: Sun Jul 18 07:23:00 2010 New Revision: 210208 URL: http://svn.freebsd.org/changeset/base/210208 Log: MFC r209883, r209944: Make interrupt handler check that CAM bus initialization completed before touching it. It fixes possible panic during controller attach in ATA_CAM mode. While there, slightly improve attach errors handling. Modified: stable/8/sys/dev/ata/ata-all.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/ata/ata-all.c ============================================================================== --- stable/8/sys/dev/ata/ata-all.c Sun Jul 18 07:19:23 2010 (r210207) +++ stable/8/sys/dev/ata/ata-all.c Sun Jul 18 07:23:00 2010 (r210208) @@ -195,6 +195,7 @@ ata_attach(device_t dev) } if ((error = bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL, ata_interrupt, ch, &ch->ih))) { + bus_release_resource(dev, SYS_RES_IRQ, rid, ch->r_irq); device_printf(dev, "unable to setup interrupt\n"); return error; } @@ -218,8 +219,9 @@ ata_attach(device_t dev) device_get_unit(dev), &ch->state_mtx, 1, 0, devq); if (ch->sim == NULL) { device_printf(dev, "unable to allocate sim\n"); + cam_simq_free(devq); error = ENOMEM; - goto err2; + goto err1; } if (xpt_bus_register(ch->sim, dev, 0) != CAM_SUCCESS) { device_printf(dev, "unable to register xpt bus\n"); @@ -239,8 +241,9 @@ err3: xpt_bus_deregister(cam_sim_path(ch->sim)); err2: cam_sim_free(ch->sim, /*free_devq*/TRUE); + ch->sim = NULL; err1: - bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq); + bus_release_resource(dev, SYS_RES_IRQ, rid, ch->r_irq); mtx_unlock(&ch->state_mtx); return (error); #endif @@ -281,6 +284,7 @@ ata_detach(device_t dev) xpt_free_path(ch->path); xpt_bus_deregister(cam_sim_path(ch->sim)); cam_sim_free(ch->sim, /*free_devq*/TRUE); + ch->sim = NULL; mtx_unlock(&ch->state_mtx); #endif @@ -307,9 +311,12 @@ ata_conn_event(void *context, int dummy) union ccb *ccb; mtx_lock(&ch->state_mtx); + if (ch->sim == NULL) { + mtx_unlock(&ch->state_mtx); + return; + } ata_reinit(dev); - mtx_unlock(&ch->state_mtx); - if ((ccb = xpt_alloc_ccb()) == NULL) + if ((ccb = xpt_alloc_ccb_nowait()) == NULL) return; if (xpt_create_path(&ccb->ccb_h.path, NULL, cam_sim_path(ch->sim), @@ -318,6 +325,7 @@ ata_conn_event(void *context, int dummy) return; } xpt_rescan(ccb); + mtx_unlock(&ch->state_mtx); #else ata_reinit(dev); #endif