From owner-freebsd-firewire@FreeBSD.ORG Mon Jan 19 11:06:57 2009 Return-Path: Delivered-To: freebsd-firewire@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4F3C3106566B for ; Mon, 19 Jan 2009 11:06:57 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 222A18FC1B for ; Mon, 19 Jan 2009 11:06:57 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n0JB6vKW062941 for ; Mon, 19 Jan 2009 11:06:57 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n0JB6ubZ062937 for freebsd-firewire@FreeBSD.org; Mon, 19 Jan 2009 11:06:56 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 19 Jan 2009 11:06:56 GMT Message-Id: <200901191106.n0JB6ubZ062937@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-firewire@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-firewire@FreeBSD.org X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2009 11:06:57 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/113785 firewire [firewire] dropouts when playing DV on firewire o kern/74238 firewire [firewire] fw_rcv: unknown response; firewire ad-hoc w 2 problems total. From owner-freebsd-firewire@FreeBSD.ORG Tue Jan 20 03:50:14 2009 Return-Path: Delivered-To: freebsd-firewire@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E4BB106566B for ; Tue, 20 Jan 2009 03:50:14 +0000 (UTC) (envelope-from sean.bruno@dsl-only.net) Received: from iron2.pdx.net (iron2.pdx.net [69.64.224.71]) by mx1.freebsd.org (Postfix) with ESMTP id BB7378FC12 for ; Tue, 20 Jan 2009 03:50:13 +0000 (UTC) (envelope-from sean.bruno@dsl-only.net) Received: (qmail 2370 invoked from network); 19 Jan 2009 19:50:12 -0800 Received: from 069-064-235-060.pdx.net (HELO ?192.168.1.51?) (69.64.235.60) by iron2.pdx.net with SMTP; 19 Jan 2009 19:50:11 -0800 From: Sean Bruno To: freebsd-firewire Content-Type: multipart/mixed; boundary="=-xypXswgjkkGUKFRM3GFa" Date: Mon, 19 Jan 2009 19:50:12 -0800 Message-Id: <1232423412.8966.2.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 (2.24.2-3.fc10) Cc: scottl@freebsd.org Subject: Firewire patch X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jan 2009 03:50:14 -0000 --=-xypXswgjkkGUKFRM3GFa Content-Type: text/plain Content-Transfer-Encoding: 7bit Sorry it's taking me so long to wrap my brain around this code folks. Here is a small-ish patch I'd like to get comitted soon. This removes the filter implementation of the bus reset interrupt. It moves some malloc's into a more appropriate area and fixes a potential deadlock in SBP. Take a peak and give it a spin on stable/7 Sean --=-xypXswgjkkGUKFRM3GFa Content-Disposition: attachment; filename="firewire.diff" Content-Type: text/x-patch; name="firewire.diff"; charset="UTF-8" Content-Transfer-Encoding: 7bit Index: fwohci_pci.c =================================================================== --- fwohci_pci.c (revision 187454) +++ fwohci_pci.c (working copy) @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: stable/7/sys/dev/firewire/fwohci_pci.c 170374 2007-06-06 14:31:36Z simokawa $ */ #define BOUNCE_BUFFER_TEST 0 @@ -337,11 +337,8 @@ err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE, -#if FWOHCI_INTFILT - fwohci_filt, NULL, sc, &sc->ih); -#else NULL, (driver_intr_t *) fwohci_intr, sc, &sc->ih); -#endif + #if defined(__DragonFly__) || __FreeBSD_version < 500000 /* XXX splcam() should mask this irq for sbp.c*/ err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_CAM, Index: firewire.c =================================================================== --- firewire.c (revision 187454) +++ firewire.c (working copy) @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: stable/7/sys/dev/firewire/firewire.c 171513 2007-07-20 03:42:57Z simokawa $ * */ @@ -429,6 +429,16 @@ fwdev_makedev(sc); + fc->crom_src_buf = (struct crom_src_buf *)malloc( + sizeof(struct crom_src_buf), + M_FW, M_NOWAIT | M_ZERO); + fc->topology_map = (struct fw_topology_map *)malloc( + sizeof(struct fw_topology_map), + M_FW, M_NOWAIT | M_ZERO); + fc->speed_map = (struct fw_speed_map *)malloc( + sizeof(struct fw_speed_map), + M_FW, M_NOWAIT | M_ZERO); + mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF); mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF); CALLOUT_INIT(&fc->timeout_callout); @@ -450,7 +460,9 @@ bus_generic_attach(dev); /* bus_reset */ + FW_GLOCK(fc); fw_busreset(fc, FWBUSNOTREADY); + FW_GUNLOCK(fc); fc->ibr(fc); return 0; @@ -638,11 +650,6 @@ { struct crom_src *src; - fc->crom_src_buf = (struct crom_src_buf *) - malloc(sizeof(struct crom_src_buf), M_FW, M_WAITOK | M_ZERO); - if (fc->crom_src_buf == NULL) - return; - src = &fc->crom_src_buf->src; bzero(src, sizeof(struct crom_src)); @@ -659,7 +666,7 @@ src->businfo.cyc_clk_acc = 100; src->businfo.max_rec = fc->maxrec; src->businfo.max_rom = MAXROM_4; - src->businfo.generation = 1; + src->businfo.generation = 0; src->businfo.link_spd = fc->speed; src->businfo.eui64.hi = fc->eui.hi; @@ -678,9 +685,6 @@ struct crom_src *src; struct crom_chunk *root; - if (fc->crom_src_buf == NULL) - fw_init_crom(fc); - buf = fc->crom_src_buf; src = fc->crom_src; root = fc->crom_root; @@ -711,18 +715,18 @@ struct firewire_dev_comm *fdc; struct crom_src *src; device_t *devlistp; - void *newrom; int i, devcnt; - switch(fc->status){ - case FWBUSMGRELECT: - callout_stop(&fc->bmr_callout); - break; - default: - break; - } + FW_GLOCK_ASSERT(fc); + if (fc->status == FWBUSMGRELECT) + callout_stop(&fc->bmr_callout); + fc->status = new_status; fw_reset_csr(fc); + + if (fc->status == FWBUSNOTREADY) + fw_init_crom(fc); + fw_reset_crom(fc); if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { @@ -735,19 +739,19 @@ free(devlistp, M_TEMP); } - newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO); src = &fc->crom_src_buf->src; - crom_load(src, (uint32_t *)newrom, CROMSIZE); - if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) { - /* bump generation and reload */ - src->businfo.generation ++; - /* generation must be between 0x2 and 0xF */ - if (src->businfo.generation < 2) - src->businfo.generation ++; - crom_load(src, (uint32_t *)newrom, CROMSIZE); - bcopy(newrom, (void *)fc->config_rom, CROMSIZE); - } - free(newrom, M_FW); + /* + * If the old config rom needs to be overwritten, + * bump the businfo.generation indicator to + * indicate that we need to be reprobed + */ + if (bcmp(src, fc->config_rom, CROMSIZE) != 0) { + /* generation is a 2 bit field */ + /* valid values are only from 0 - 3 */ + src->businfo.generation = 1; + bcopy(src, (void *)fc->config_rom, CROMSIZE); + } else + src->businfo.generation = 0; } /* Call once after reboot */ @@ -803,13 +807,6 @@ fc->ir[i]->maxq = FWMAXQUEUE; fc->it[i]->maxq = FWMAXQUEUE; } -/* Initialize csr registers */ - fc->topology_map = (struct fw_topology_map *)malloc( - sizeof(struct fw_topology_map), - M_FW, M_NOWAIT | M_ZERO); - fc->speed_map = (struct fw_speed_map *)malloc( - sizeof(struct fw_speed_map), - M_FW, M_NOWAIT | M_ZERO); CSRARC(fc, TOPO_MAP) = 0x3f1 << 16; CSRARC(fc, TOPO_MAP + 4) = 1; CSRARC(fc, SPED_MAP) = 0x3f1 << 16; @@ -1555,7 +1552,7 @@ /* unchanged ? */ if (bcmp(&csr[0], &fwdev->csrrom[0], sizeof(uint32_t) * 5) == 0) { if (firewire_debug) - printf("node%d: crom unchanged\n", node); + device_printf(fc->dev, "node(%d): crom unchanged\n", node); return (0); } Index: fwohci.c =================================================================== --- fwohci.c (revision 187454) +++ fwohci.c (working copy) @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: stable/7/sys/dev/firewire/fwohci.c 170427 2007-06-08 09:04:30Z simokawa $ * */ @@ -1003,7 +1003,7 @@ if (maxdesc < db_tr->dbcnt) { maxdesc = db_tr->dbcnt; if (firewire_debug) - device_printf(sc->fc.dev, "maxdesc: %d\n", maxdesc); + device_printf(sc->fc.dev, "%s: maxdesc %d\n", __func__, maxdesc); } /* last db */ LAST_DB(db_tr, db); @@ -1843,6 +1843,7 @@ struct firewire_comm *fc = (struct firewire_comm *)sc; uint32_t node_id, plen; + FW_GLOCK_ASSERT(fc); if ((stat & OHCI_INT_PHY_BUS_R) && (fc->status != FWBUSRESET)) { fc->status = FWBUSRESET; /* Disable bus reset interrupt until sid recv. */ @@ -1885,8 +1886,8 @@ plen = OREAD(sc, OHCI_SID_CNT); fc->nodeid = node_id & 0x3f; - device_printf(fc->dev, "node_id=0x%08x, gen=%d, ", - node_id, (plen >> 16) & 0xff); + device_printf(fc->dev, "node_id=0x%08x, SelfID Count=%d, ", + fc->nodeid, (plen >> 16) & 0xff); if (!(node_id & OHCI_NODE_VALID)) { printf("Bus reset failure\n"); goto sidout; @@ -1997,9 +1998,11 @@ { struct fwohci_softc *sc = (struct fwohci_softc *)arg; + FW_GLOCK(&sc->fc); fw_busreset(&sc->fc, FWBUSRESET); OWRITE(sc, OHCI_CROMHDR, ntohl(sc->fc.config_rom[0])); OWRITE(sc, OHCI_BUS_OPT, ntohl(sc->fc.config_rom[2])); + FW_GUNLOCK(&sc->fc); } static void @@ -2062,6 +2065,7 @@ { uint32_t stat, irstat, itstat; + FW_GLOCK_ASSERT(&sc->fc); stat = OREAD(sc, FWOHCI_INTSTAT); if (stat == 0xffffffff) { device_printf(sc->fc.dev, @@ -2091,29 +2095,23 @@ return (FILTER_HANDLED); } -int -fwohci_filt(void *arg) +void +fwohci_intr(void *arg) { struct fwohci_softc *sc = (struct fwohci_softc *)arg; - if (!(sc->intmask & OHCI_INT_EN)) { - /* polling mode */ - return (FILTER_STRAY); - } - return (fwohci_check_stat(sc)); + FW_GLOCK(&sc->fc); + fwohci_check_stat(sc); + FW_GUNLOCK(&sc->fc); } void -fwohci_intr(void *arg) -{ - fwohci_filt(arg); -} - -void fwohci_poll(struct firewire_comm *fc, int quick, int count) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; + FW_GLOCK(fc); fwohci_check_stat(sc); + FW_GUNLOCK(fc); } static void @@ -2471,6 +2469,7 @@ * Make sure our cached values from the config rom are * initialised. */ + FW_GLOCK(fc); OWRITE(sc, OHCI_CROMHDR, ntohl(sc->fc.config_rom[0])); OWRITE(sc, OHCI_BUS_OPT, ntohl(sc->fc.config_rom[2])); @@ -2487,6 +2486,7 @@ fun |= FW_PHY_ISBR | FW_PHY_RHB; fun = fwphy_wrdata(sc, FW_PHY_ISBR_REG, fun); #endif + FW_GUNLOCK(fc); } void Index: sbp.c =================================================================== --- sbp.c (revision 187454) +++ sbp.c (working copy) @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: stable/7/sys/dev/firewire/sbp.c 170872 2007-06-17 05:55:54Z scottl $ * */ @@ -1255,11 +1255,18 @@ htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS )<< 16)); xfer->send.payload[1] = htonl((uint32_t)ocb->bus_addr); + /* + * sbp_xfer_free() will attempt to acquire + * the SBP lock on entrance. Also, this removes + * a LOR between the firewire layer and sbp + */ + SBP_UNLOCK(sdev->target->sbp); if(fw_asyreq(xfer->fc, -1, xfer) != 0){ sbp_xfer_free(xfer); ocb->ccb->ccb_h.status = CAM_REQ_INVALID; xpt_done(ocb->ccb); } + SBP_LOCK(sdev->target->sbp); } static void Index: fwohcivar.h =================================================================== --- fwohcivar.h (revision 187454) +++ fwohcivar.h (working copy) @@ -31,18 +31,12 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: stable/7/sys/dev/firewire/fwohcivar.h 170374 2007-06-06 14:31:36Z simokawa $ * */ #include -#if defined(__DragonFly__) || __FreeBSD_version < 700043 -#define FWOHCI_INTFILT 0 -#else -#define FWOHCI_INTFILT 1 -#endif - typedef struct fwohci_softc { struct firewire_comm fc; bus_space_tag_t bst; --=-xypXswgjkkGUKFRM3GFa-- From owner-freebsd-firewire@FreeBSD.ORG Wed Jan 21 05:16:11 2009 Return-Path: Delivered-To: freebsd-firewire@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A77DF106566B for ; Wed, 21 Jan 2009 05:16:11 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (pool-71-117-207-61.ptldor.fios.verizon.net [71.117.207.61]) by mx1.freebsd.org (Postfix) with ESMTP id B85B38FC1A for ; Wed, 21 Jan 2009 05:16:06 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: by sopwith.solgatos.com (Postfix, from userid 66) id 3DEE9B64F; Tue, 20 Jan 2009 21:04:04 -0800 (PST) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id AAA00037; Wed, 21 Jan 2009 00:10:16 GMT Message-Id: <200901210010.AAA00037@sopwith.solgatos.com> To: freebsd-firewire In-reply-to: Your message of "Mon, 19 Jan 2009 19:50:12 PST." <1232423412.8966.2.camel@localhost.localdomain> Date: Tue, 20 Jan 2009 16:10:16 +0000 From: Dieter Cc: Subject: Re: Firewire patch X-BeenThere: freebsd-firewire@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Firewire support in FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2009 05:16:11 -0000 > Hrm ... I don't seem to have sent this to you. Weird. That's ok, I'm subscribed to the -firewire@ list and saw it there. BTW, your ISP doesn't like me so I can't email you off-list. Probably the usual brain dead throw-the-baby-out-with-the-bathwater attempts at spam reduction. > Here is a small-ish patch I'd like to get comitted soon. This removes > the filter implementation of the bus reset interrupt. It moves some > malloc's into a more appropriate area and fixes a potential deadlock in > SBP. > > Take a peak and give it a spin on stable/7 I looked at it, but I don't understand it well enough to count as a code reviewer. I applied this patch to 7.0. (Still waiting for the 7.1 bloatfest to finish downloading...) Patch rejected the FWOHCI_INTFILT stuff, but I think the code does what you want. However I'm not sure what all has changed between 7.0 and whatever bleeding-edge bits you're working with, there could be something significant. Results: The hack to put the NEC controller into non-CYCLEMASTER mode still works, and video plays ok. So it looks like your patch probably doesn't break anything for me. The patch did not fix PR 118093 (bus reset still blocks Ethernet), or PR 113785 (the VIA controller still refuses to go into non-CYCLEMASTER mode). While I had the camcorder plugged into the VIA, I booted the kernel with your previous patch (2008-01-05), but no joy. I wonder if the VIA controller might be faster or slower than the NEC, so fixing the locking might fix PR 113785. If you'd like me to do further testing, such as with 7.1 once I get it installed, and/or I can add my workaround for PR 118093 (change some printfs to log(9)) and leave your patch in and test it for more than a minute or two, let me know.