From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 20 21:37:25 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E8F216A4D2 for ; Fri, 20 Oct 2006 21:37:25 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7B5D043E0F for ; Fri, 20 Oct 2006 21:35:10 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (jt36ko66jxmi8ps8@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id k9KLYr7H028248; Fri, 20 Oct 2006 14:34:53 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id k9KLYriD028247; Fri, 20 Oct 2006 14:34:53 -0700 (PDT) (envelope-from jmg) Date: Fri, 20 Oct 2006 14:34:53 -0700 From: John-Mark Gurney To: usleepless@gmail.com Message-ID: <20061020213453.GR23971@funkthat.com> Mail-Followup-To: usleepless@gmail.com, freebsd-hackers@freebsd.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-hackers@freebsd.org Subject: Re: Fwd: Removing Giant from a driver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Oct 2006 21:37:25 -0000 usleepless@gmail.com wrote this message on Sun, Oct 15, 2006 at 11:04 +0200: > i have been tweaking the pvr250 driver to support pvr150s/500s. now i > want to remove Giant from the code. > > problem is, i am not sure what to do. i have created a mutex which > replaces the spltty and splx calls. but this crashes my box :-) > > the original code looks like this: > /* > * Allocate a DMA tag for the scatter / gather list. > */ > error = bus_dma_tag_create(sc->parent_dmat, 1, 0, > BUS_SPACE_MAXADDR_32BIT, > BUS_SPACE_MAXADDR, NULL, NULL, > CXM_SG_BUFFERS > * sizeof(struct cxm_sg_entry), 1, > BUS_SPACE_MAXSIZE_32BIT, 0, > #if __FreeBSD_version >= 501102 > busdma_lock_mutex, &Giant, > #endif > &sc->enc_sg.dmat); > > what should it look like? You should be creating a mutex (using mtx_init) at attach time, and pass that mutex instead of Giant... > and how will i prevent the interrupt routine from interfering with > userland operations? can i place a "mtx_lock()" call in the interrupt > routine? Correct.... Fast interrupt handlers cannot use a sleeping mutex, but I doubt this driver is using a fast interrupt handler... > is there a howto somewhere? There are man pages on how to use the various locking primitives, but it is assumed that you have knowlege of concurrent programming... You can take a look at books on pthreads and other related matierals for info on using locks... If you figure out the licensing issues w/ the firmware, I'll import the driver into FreeBSD... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."