linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Spinlock vs mutexes for spi network driver
@ 2010-03-17 20:49 Amit Uttamchandani
       [not found] ` <20100317204915.GB6358-QCuvCd35e3/QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Amit Uttamchandani @ 2010-03-17 20:49 UTC (permalink / raw)
  To: spi-devel


I have modified 'drivers/net/ethoc.c' for spi communication and it is
able to transmit/receive packets. However, I am confused about using
spinlocks vs mutexes for locking access to the spi device.

e.g. For the transmit function I use a work_queue to schedule the
transmits. In the handler function, I use a mutex to lock the device.
Could I be using a spinlock here instead? Should I use a spinlock to
disable the irq while I'm in the middle of transmitting data?

The ethoc device sends out an interrupt everytime a packet is
successfully transmitted and received. So it has to be acked otherwise
the interrupt line stays high and no transmit or receive can happen
(which why I'm not use if I should use the spin_lock_irq variant in this
case).

Some other spi net drivers such as ks8851.c have mutexes around all spi
device accesses, which I guess is to prevent simultaneous uses of the
device. Is this a good idea? Doesn't the spi_transfer calls schedule
device accesses already?

Thanks for any comment on this.

Amit

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-19  9:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 20:49 Spinlock vs mutexes for spi network driver Amit Uttamchandani
     [not found] ` <20100317204915.GB6358-QCuvCd35e3/QT0dZR+AlfA@public.gmane.org>
2010-03-17 21:28   ` Ned Forrester
     [not found]     ` <4BA14970.3050603-/d+BM93fTQY@public.gmane.org>
2010-03-18 16:46       ` Amit Uttamchandani
     [not found]         ` <20100318164641.GA22298-QCuvCd35e3/QT0dZR+AlfA@public.gmane.org>
2010-03-18 17:28           ` Ned Forrester
     [not found]             ` <4BA262B1.5050001-/d+BM93fTQY@public.gmane.org>
2010-03-18 20:09               ` Amit Uttamchandani
     [not found]                 ` <20100318200940.GC16834-QCuvCd35e3/QT0dZR+AlfA@public.gmane.org>
2010-03-18 22:11                   ` Ned Forrester
     [not found]                     ` <4BA2A4F4.60207-/d+BM93fTQY@public.gmane.org>
2010-03-18 23:14                       ` Ned Forrester
2010-03-19  9:35                       ` Amit Uttamchandani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).