From owner-p4-projects@FreeBSD.ORG Fri Jun 1 22:11:36 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id ED14E1065673; Fri, 1 Jun 2012 22:11:35 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B311B106566C for ; Fri, 1 Jun 2012 22:11:35 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 7ACE78FC08 for ; Fri, 1 Jun 2012 22:11:35 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id q51MBZMZ011414 for ; Fri, 1 Jun 2012 22:11:35 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q51MBZDB011407 for perforce@freebsd.org; Fri, 1 Jun 2012 22:11:35 GMT (envelope-from brooks@freebsd.org) Date: Fri, 1 Jun 2012 22:11:35 GMT Message-Id: <201206012211.q51MBZDB011407@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 212127 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2012 22:11:36 -0000 http://p4web.freebsd.org/@@212127?ac=10 Change 212127 by brooks@brooks_ecr_current on 2012/06/01 22:10:33 Push the attach routine in the right direction. I think it is at least no longer a panic(9) implemenation. Lock around the ERASE ioctl. Affected files ... .. //depot/projects/ctsrd/beribsd/src/sys/dev/isf/isf.c#5 edit .. //depot/projects/ctsrd/beribsd/src/sys/dev/isf/isf.h#5 edit .. //depot/projects/ctsrd/beribsd/src/sys/dev/isf/isf_nexus.c#4 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/sys/dev/isf/isf.c#5 (text+ko) ==== @@ -302,6 +302,7 @@ uint16_t w, status; off_t off; + ISF_LOCK(sc); for (off = blk_off; off < blk_off + size; off += 2) { w = bus_read_2(sc->isf_res, off); if (w == 0xFFFF) @@ -321,6 +322,7 @@ isf_write_cmd(sc, off, ISF_CMD_RA); } + ISF_UNLOCK(sc); } /* @@ -384,8 +386,12 @@ ISF_LOCK(sc); do { bp = bioq_first(&sc->isf_bioq); - if (bp == NULL) - ISF_SLEEP(sc); + if (bp == NULL) { + if (sc->isf_doomed) + kproc_exit(0); + else + ISF_SLEEP(sc, sc); + } } while (bp == NULL); bioq_remove(&sc->isf_bioq, bp); @@ -472,6 +478,7 @@ { struct disk *disk; + sc->isf_doomed = 0; kproc_create(&isf_task, sc, &sc->isf_proc, 0, 0, "isf"); disk = disk_alloc(); @@ -502,6 +509,10 @@ ISF_LOCK_ASSERT(sc); KASSERT(sc->isf_disk != NULL, ("%s: isf_disk NULL", __func__)); + sc->isf_doomed = 0; + ISF_WAKEUP(sc); + ISF_SLEEP(sc, sc->isf_proc); + /* * XXXRW: Is it OK to call disk_destroy() under the mutex, or should * we be deferring that to the calling context once it is released? @@ -539,6 +550,7 @@ isf_read_reg(sc, ISF_REG_ID)); return (ENXIO); } + isf_write_cmd(sc, 0, ISF_CMD_RA); bioq_init(&sc->isf_bioq); ISF_LOCK_INIT(sc); @@ -558,10 +570,11 @@ * * XXXRW: Is the locking here right? */ + ISF_LOCK(sc); isf_disk_remove(sc); - ISF_UNLOCK(sc); bioq_flush(&sc->isf_bioq, NULL, ENXIO); KASSERT(bioq_first(&sc->isf_bioq) == NULL, ("%s: non-empty bioq", __func__)); + ISF_UNLOCK(sc); ISF_LOCK_DESTROY(sc); } ==== //depot/projects/ctsrd/beribsd/src/sys/dev/isf/isf.h#5 (text+ko) ==== @@ -60,6 +60,7 @@ struct mtx isf_lock; struct disk *isf_disk; struct proc *isf_proc; + int isf_doomed; /* * Fields relating to in-progress and pending I/O, if any. @@ -73,7 +74,7 @@ #define ISF_LOCK_DESTROY(sc) mtx_destroy(&(sc)->isf_lock) #define ISF_LOCK_INIT(sc) mtx_init(&(sc)->isf_lock, "isf", NULL, \ MTX_DEF) -#define ISF_SLEEP(sc) mtx_sleep((sc), &(sc)->isf_lock, PRIBIO, \ +#define ISF_SLEEP(sc, wait) mtx_sleep((wait), &(sc)->isf_lock, PRIBIO, \ "isf", 0) #define ISF_UNLOCK(sc) mtx_unlock(&(sc)->isf_lock) #define ISF_WAKEUP(sc) wakeup((sc)) ==== //depot/projects/ctsrd/beribsd/src/sys/dev/isf/isf_nexus.c#4 (text+ko) ====