Re: Fwd: Removing Giant from a driver



usleepless@xxxxxxxxx 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."
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Fwd: Removing Giant from a driver
    ... pass that mutex instead of Giant... ... I doubt this driver is using a fast interrupt handler... ... - hauppauge firmware is needed ...
    (freebsd-hackers)
  • Re: Fwd: Removing Giant from a driver
    ... pass that mutex instead of Giant... ... I doubt this driver is using a fast interrupt handler... ... A fast interrupt handler doesn't context switch, ... don't understand what Giant is good for. ...
    (freebsd-hackers)
  • Re: need some debugging help
    ... >>Anyway, I got some debugging output, and I've attached dmesg output. ... - I tried holding Giant when calling tsleep, ... - I tried not holding a mutex at all when calling tsleep, ...
    (freebsd-current)
  • Re: crash in tty code in 6.1.. fixed since?
    ... explicitly drop/pickup the mutex so that you would have handled the race ... What I mean is that if you had a mutex here instead than Giant what would have probabilly happened is having code like this: ... What changes really here is that you explicitly check again the state of t_session ptr since it can be changed while dropping/pickingup again the tty_mtx. ... With Giant the problem is that the dropping/pickingup happens implicitly in our primitives so you can just make mistakes like these. ...
    (freebsd-current)
  • Re: If GIANT is locked can the MPSAFE parts run in parallel?
    ... Giant is a mutex like any other mutex, so as long as the MPSAFE subsystem isn't being invoked by something holding Giant, it generally won't run with it. ... Even if the network stack is sometimes executed with Giant held, that doesn't prevent the network stack from executing in parallel on other CPUs, it just serializes with respect to other Giant holders executing. ...
    (freebsd-arch)