Skip to contentSkip to conversation

Question about pxa2xx_spi.c

DISCUSSION Martin Qiu 2 participants 2 messages Jun 25, 2008 – Jul 9, 2008 1 message not in the archive SPI

lore
Share & tools
lore

Martin Qiu

author
#0 lore raw

Hiall,

I am newcomer for SPI devleopment. Here is one question regarding the pxa2xx_spi.c:

Why does it use tasklet to handle each spi_transfer, as spi_message is already use work queue thread to handle?

If one protocol driver wants to write a char to the device, then one spi_msg with only one spi_transfer is created, the spi_msg will first added to the workqueue, when it scheduled to run, it will put the spi_transfer to tasklet list waiting for handling, here is a 2 step wating, will it be effective for pxa2xx_spi.c? Is there any specail design thought for it? Thanks!

Best Regards
Martin

      ___________________________________________________________ 

雅虎邮箱,您的终生邮箱!
http://cn.mail.yahoo.com/

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source.
http://sourceforge.net/services/buy/index.php

_______________________________________________
spi-devel-general mailing list spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

A message that is not in the archive (sent off-list or not yet received): 961055.62866.qm-VrLyXnEWYAPFTsyTBrxSqPhMsxRAUFZ5QQ4Iyu8u01E@public.gmane.org

#2 lore raw
Quoted 8 lines · Martin Qiu

Hiall,

I am newcomer for SPI devleopment. Here is one question regarding the pxa2xx_spi.c:

Why does it use tasklet to handle each spi_transfer, as spi_message is already use work queue thread to handle?

This is the standard (if there is such a thing), or at least the typical, way to design Linux device drivers. See "Linux Device Drivers" by Corbet, et al., from O'Reilly. The workqueue services the message queue in response to calls from the protocol driver, while the tasklet is connected to the interrupt service routine (and also scheduled directly from the workqueue). Splitting the interrupt service routine into two parts (often called "top half" and "bottom half"), allows a separation of the tasks that must be performed immediately from the tasks that can be deferred. The top half, triggered directly by the hardware interrupt, does all the things required to be handled immediately, such as unloading hardware buffers and changing hardware registers. The bottom half is used for any further processing of the data associated with the interrupt that is not as time critical. This design allows the kernel to be more responsive to other hardware interrupts, and generally improves latency for all tasks.

In the case of pxa2xx_spi.c, the bottom half (performed in a tasklet) cleans up of the previous transfer (calling giveback) and sets up the next transfer. Neither of these tasks is hardware time critical, though of course, any delay does affect the overall throughput of SPI messages.

Quoted 8 lines

If one protocol driver wants to write a char to the device, then one spi_msg with only one spi_transfer is created, the spi_msg will first added to the workqueue, when it scheduled to run, it will put the spi_transfer to tasklet list waiting for handling, here is a 2 step wating, will it be effective for pxa2xx_spi.c? Is there any specail design thought for it? Thanks!

It seems to work well enough. I read SPI data at 11Mbit/sec, and while I added an internal DMA descriptor queue to the driver to reduce the sensitivity to latency, I was able to read 98% of the data at full speed without the extra queue. Even with the DMA descriptor queue, I still maintain all the workqueue and tasklet structure of the driver, and it keeps up on average. About 10-20% of CPU time is spent servicing the SPI at 11MBit/sec: adding all the time spent in workqueue, tasklet, interrupt service, protocol driver and userspace. Far more time is spent writing the data out to the network; I think because there is no DMA support on transmit in the driver for the 91c111 network chip used with the Gumstix.

Signature · 14 lines
Ned Forrester                                       nforrester-/[email protected]
Oceanographic Systems Lab                                  508-289-2226
Applied Ocean Physics and Engineering Dept.
Woods Hole Oceanographic Institution          Woods Hole, MA 02543, USA
http://www.whoi.edu/sbl/liteSite.do?litesiteid=7212
http://www.whoi.edu/hpb/Site.do?id=1532
http://www.whoi.edu/page.do?pid=10079


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08