Date:2013-04-30 00:55:25 (6 years 7 months ago)
Author:Werner Almesberger
Commit:ff9c7a8ce458031330034aa64bb273a56207fe1b
Message:atben/misc/atben-spi-performance.txt: SPI performance comparison

This was earlier posted to the mailing lists. Updated the URLs.
Files: atben/misc/atben-spi-performance.txt (1 diff)

Change Details

atben/misc/atben-spi-performance.txt
1Performance analysis of SPI drivers for ATBEN
2=============================================
3
4This was originally posted on April 10 2013 to the linux-zigbee and
5the qi-hardware list. The URLs have been updated for stability.
6
7What this is all about
8----------------------
9
10The ATBEN board on the Ben NanoNote needs a bit-banging SPI driver.
11There are several ways to implement this, ranging from reuse of the
12generic spi-gpio driver to an optimized driver that's specific for
13this platform.
14
15I implemented several such approaches and measured their performance
16in the Ben NanoNote. Below are my findings.
17
18Comments welcome.
19
20
21Cast and characters
22-------------------
23
24spi_atben_gpio: NanoNote-specific framework for setting up the
25AT86RF230/1 with SPI-GPIO or one of the optimized drivers (below).
26The name derives from spi_atben (see below) and should be changed
27(maybe to atben_spi or atben_spi_gpio ?) since it is not an SPI
28driver but merely a framework that provides configuration data and
29performs miscellaneous platform setup.
30https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/net/ieee802154/spi_atben_gpio.c
31
32spi_atben: like spi_atben_gpio, but contains a highly optimized
33SPI driver for the ATBEN configuration in the Ben NanoNote.
34https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/net/ieee802154/spi_atben.c
35
36spi-jz4740-gpio: SPI-GPIO driver optimized for the Jz4740. Uses the
37optimized register accesses from spi_atben but pin assignment is not
38restricted to ATBEN. The only limitation is that MOSI, MISO, and
39SCLK must be on the same port.
40https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/spi/spi-jz4740-gpio.c
41
42spi-gpio-atben: task-specific SPI-GPIO driver using the #include
43"spi-gpio.c" method. Replaces gpiolib functions with register
44accesses specific to the ATBEN configuration in the Ben NanoNote.
45Note that some of the code could be moved into Jz4740
46architecture-specific GPIO support.
47https://github.com/wpwrak/ben-wpan-linux/blob/perfcomp/drivers/spi/spi-gpio-atben.c
48
49In the following sections, we abbreviate the stack configurations
50as follows:
51
52Abbreviation Framework Transport Chip driver
53--------------- --------------- --------------- -----------
54spi-gpio spi_atben_gpio spi-gpio at86rf230
55spi-gpio-atben spi_atben_gpio spi-gpio-atben at86rf230
56spi-jz4740-gpio spi_atben_gpio spi-jz4740-gpio at86rf230
57spi_atben spi_atben at86rf230
58
59
60Measurements
61------------
62
63Access time to AT86RF231 registers and buffer, in microseconds, on
64an otherwise idle Ben NanoNote:
65
66Driver read from 0x51 read 120 bytes from buffer
67| | write 0x0a to 0x15 write 1 byte to buffer (0x33)
68| | | read 1 byte from buffer write 120 bytes
69| | | | | | |
70spi-gpio 81 85 186 1696 97 1596
71spi-gpio-atben 63 59 123 498 65 437
72spi-jz4740-gpio 10 8 21 280 10 231
73spi_atben 10 7 21 280 10 230
74
75Data rate for hypothetical buffer accesses of infinite length.
76I.e., kbps = 1000*119*8/(t_write120-t_write1)
77
78Driver buffer read (kbps) buffer write (kbps)
79--------------- ----------------------- -------------------
80spi-gpio 630 635
81spi-gpio-atben 2549 2559
82spi-jz4740-gpio 3676 4308
83spi_atben 3676 4327
84
85At the air interface, IEEE 802.15.4 has a data rate of 250 kbps.
86The AT86RF231 transceiver also supports non-standard higher data
87rates up to 2 Mbps.
88
89Driver(s) Code size (lines)
90--------------------------------------- -----------------
91spi_atben_gpio 128
92spi_atben_gpio + spi-gpio-atben 128+ 53
93spi_atben_gpio + spi-jz4740-gpio 128+416
94spi_atben 423
95
96
97Computational cost
98------------------
99
100The high-level operations of sending and receiving produce the
101following major low-level operations:
102
103Operation register buffer waitqueue
104        read write read write
105--------------- ------- ------- ------- ------- ---------
106reception 1 - 1 - 1
107transmission 9 4 - 1 1
108
109Using the measured data from above, we get the following total
110computational overhead in microseconds, without considering the
111waitqueue scheduling delay:
112
113Driver reception transmission
114        1 120 127 1 120 125 (bytes)
115--------------- ------- ------- ------- ------- ------- -------
116spi-gpio 267 1777 1866 1166 2665 2727
117spi-gpio-atben 186 561 583 868 1240 1256
118spi-jz4740-gpio 31 290 304 132 353 362
119
120Note that the minimum frame length in IEEE 802.15.4 is 5 bytes.
121The values for 125 (excluding CRC) and 127 (including CRC) bytes
122are extrapolated.
123
124According to [1], maximum-sized frames can be sent/received,
125including CSMA/CA and acknowledgement, at a rate between one
126every 4928 us and one every 7168 us.
127
128We would therefore get the following maximum CPU load:
129
130Driver Reception Transmission
131--------------- --------------- ------------
132spi-gpio 38% 55%
133spi-gpio-atben 12% 25%
134spi-jz4740-gpio 6% 7%
135
136
137Observations
138------------
139
140spi-gpio needs the smallest amount of new code but is also very
141inefficient, making it questionable whether this configuration
142would yield acceptable performance in regular use.
143
144With spi-gpio-atben, only a small amount of code is added, but
145buffer accesses become almost 4 times faster. Register reads and
146writes are still fairly slow.
147
148spi_atben and spi-jz4740-gpio both achieve the best performance
149without significant differences between them. Both add a complete
150SPI driver. Of the two, spi-jz4740-gpio is preferable, because it
151uses the nearly universal spi_atben_gpio framework driver.
152
153
154Conclusion
155----------
156
157I think performance trumps most other considerations in this case.
158spi-gpio is clearly too inefficient. spi_atben_gpio with
159spi-jz4740-gpio offers the best performance and has a low impact
160on the system load (< 10%). In case this solution would be met
161with strong resistance for some reason, spi-gpio-atben would offer
162a compromise between performance and the amount of code.
163
164
165References
166----------
167
168[1] http://www.jennic.com/files/support_files/JN-AN-1035%20Calculating%20802-15-4%20Data%20Rates-1v0.pdf
169
170_______________________________________________
171Qi Hardware Discussion List
172Mail to list (members only): discussion@lists.en.qi-hardware.com
173Subscribe or Unsubscribe: http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Archive Download the corresponding diff file



interactive