From owner-freebsd-firewire@FreeBSD.ORG Wed Jan 7 05:13:17 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 2B7F0106566C; Wed, 7 Jan 2009 05:13:17 +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 2478C8FC14; Wed, 7 Jan 2009 05:13:16 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: by sopwith.solgatos.com (Postfix, from userid 66) id 46D69B650; Tue, 6 Jan 2009 05:06:32 -0800 (PST) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id RAA08944; Tue, 6 Jan 2009 17:33:21 GMT Message-Id: <200901061733.RAA08944@sopwith.solgatos.com> To: bug-followup@FreeBSD.org, freebsd-firewire@FreeBSD.org In-reply-to: Your message of "Mon, 05 Jan 2009 22:20:03 PST." <1231222803.21260.17.camel@localhost.localdomain> Date: Tue, 06 Jan 2009 09:33:21 +0000 From: Dieter Cc: Subject: Re: kern/118093: [firewire] firewire bus reset hogs CPU, causing data to be lost 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, 07 Jan 2009 05:13:17 -0000 In message <1231222803.21260.17.camel@localhost.localdomain>, Sean Bruno writes: > > > uint32_t fun; > > > > > > + FW_GLOCK(fc); > > > device_printf(fc->dev, "Initiate bus reset\n"); > > > sc = (struct fwohci_softc *)fc; > > > > > > @@ -2487,6 +2495,7 @@ > > > fun |= FW_PHY_ISBR | FW_PHY_RHB; > > > fun = fwphy_wrdata(sc, FW_PHY_ISBR_REG, fun); > > > #endif > > > + FW_GUNLOCK(fc); > > > } > > > > Does the lock need to protect the printf? > > These are gross, overpowered, way to heavy handed locks that I'm playing > with. I need to prevent pre-emption of certain events while they are in > progress. One of these events is the firewire's assertion of "bus > reset" on the firewire device. I see the h/w interrupt firing before > this code can actually complete, causing the driver to be confused on > occasion. I understand the basic concept of locking, or at least I did many many years ago when spls really were levels. Since then they changed spls to not be levels (at least that's what the man page says) and later replaced with mutex. I assume these changes are at least in part to better support SMP. What I don't understand is things like getting a lock and immediately releasing it, which appears to me to protect nothing. Or why the printf needs to be inside the locked section of code. I thought the goal was to hold a lock for as short a time as possible, and it is not clear to me why the printf needs to be protected.