mbox series

[0/5] Rewrite GPIO SPI to use descriptors

Message ID 20180101133749.29567-1-linus.walleij@linaro.org
Headers show
Series Rewrite GPIO SPI to use descriptors | expand

Message

Linus Walleij Jan. 1, 2018, 1:37 p.m. UTC
Just as it says, this rewrites the GPIO bit-banged SPI driver to
just use GPIO descriptors and pushes the configuration of the GPIO
lines down into devices trees and board files.

As there is a patch to the GPIO core, I can provide a tag to
be pulled from the GPIO tree so I can pull the first patch
into the GPIO devel branch for next as well.

There is a testing branch based on v4.15-rc1 already if people
just want to pull it in and test it from there:

https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git/log/?h=gpio-descriptors-spi

Please test it if you can.

Linus Walleij (5):
  gpio: of: Support SPI nonstandard GPIO properties
  spi: spi-gpio: Rewrite to use GPIO descriptors
  spi: spi-gpio: Augment device tree bindings
  spi: spi-gpio: Make optional chipselect handling more explicit
  spi: spi-gpio: Delete references to non-GENERIC_BITBANG

 Documentation/devicetree/bindings/spi/spi-gpio.txt |  24 +-
 arch/arm/mach-pxa/cm-x300.c                        |  21 +-
 arch/arm/mach-pxa/raumfeld.c                       |  26 +-
 arch/arm/mach-s3c24xx/mach-jive.c                  |  55 ++--
 arch/arm/mach-s3c24xx/mach-qt2410.c                |  26 +-
 arch/arm/mach-s3c64xx/mach-smartq.c                |  22 +-
 arch/mips/alchemy/devboards/db1000.c               |  24 +-
 arch/mips/jz4740/board-qi_lb60.c                   |  26 +-
 drivers/gpio/gpiolib-of.c                          |  36 +++
 drivers/misc/eeprom/digsy_mtc_eeprom.c             |  29 +-
 drivers/spi/spi-gpio.c                             | 293 ++++++---------------
 include/linux/spi/spi_gpio.h                       |  49 +---
 12 files changed, 311 insertions(+), 320 deletions(-)

-- 
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Linus Walleij Jan. 2, 2018, 8:15 a.m. UTC | #1
On Mon, Jan 1, 2018 at 2:37 PM, Linus Walleij <linus.walleij@linaro.org> wrote:

> Just as it says, this rewrites the GPIO bit-banged SPI driver to

> just use GPIO descriptors and pushes the configuration of the GPIO

> lines down into devices trees and board files.


I pulled this into my Gemini tree where I have a bit-banged SPI device
based on device tree, and everything works smoothly. So all DT-based
users of GPIO SPI should be working fine after this series.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Trent Piepho Jan. 2, 2018, 6:42 p.m. UTC | #2
T24gTW9uLCAyMDE4LTAxLTAxIGF0IDE0OjM3ICswMTAwLCBMaW51cyBXYWxsZWlqIHdyb3RlOg0K
PiBKdXN0IGFzIGl0IHNheXMsIHRoaXMgcmV3cml0ZXMgdGhlIEdQSU8gYml0LWJhbmdlZCBTUEkg
ZHJpdmVyIHRvDQo+IGp1c3QgdXNlIEdQSU8gZGVzY3JpcHRvcnMgYW5kIHB1c2hlcyB0aGUgY29u
ZmlndXJhdGlvbiBvZiB0aGUgR1BJTw0KPiBsaW5lcyBkb3duIGludG8gZGV2aWNlcyB0cmVlcyBh
bmQgYm9hcmQgZmlsZXMuDQoNCkFueSBiZWZvcmUvYWZ0ZXIgYmVuY2htYXJrIGZvciBzcGVlZCBv
ciBjb2RlIHNpemU/DQoNCj4gDQo+ICAxMiBmaWxlcyBjaGFuZ2VkLCAzMTEgaW5zZXJ0aW9ucygr
KSwgMzIwIGRlbGV0aW9ucygtKQ0KPiANCg0KTG9va3MgbGlrZSBjb2RlIHNpemUgaXMgcHJldHR5
IGV2ZW4u
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Jan. 2, 2018, 11:17 p.m. UTC | #3
On Tue, Jan 2, 2018 at 7:42 PM, Trent Piepho <tpiepho@impinj.com> wrote:
> On Mon, 2018-01-01 at 14:37 +0100, Linus Walleij wrote:

>> Just as it says, this rewrites the GPIO bit-banged SPI driver to

>> just use GPIO descriptors and pushes the configuration of the GPIO

>> lines down into devices trees and board files.

>

> Any before/after benchmark for speed or code size?


Not really, the main motivation for the change is neither performance
nor object code size, but to get rid of the global GPIO numbers, which
does not scale very well and makes stuff messy. Istead we aim
to make code deal with abstract GPIO handles known as
GPIO descriptors.

The motivation is the same as for moving IRQ numbers to IRQ
descriptors which has been going on for some time: it is easy when
you have just say 64 IRQs or GPIOs. The subsystems were designed
for that. As the number IRQ controllers and GPIO controllers on
a system grows, managing the number space and the hardware
descriptions becomes a pain.

I'd be surprised if either performance or object code size is affected
in a bad way though. I don't have any high-speed SPI devices I can test
really, and loopback would require some special hardware set-up I
don't have.

The last patch in the series remove remnants of an unused mechanism
that seemed to be for performance critical bitbanged SPI, that was never
put to use, I kind of assume noone is really doing performance critical
SPI over GPIO but I've been wrong before.

> Looks like code size is pretty even.


Number of lines yes, readability I would argue is better but it is a matter
of taste. I would hope some bytes have been pushed away from
the core and into the board files (etc) but I could be wrong.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown Jan. 3, 2018, 4:24 p.m. UTC | #4
On Wed, Jan 03, 2018 at 12:17:07AM +0100, Linus Walleij wrote:

> I'd be surprised if either performance or object code size is affected

> in a bad way though. I don't have any high-speed SPI devices I can test

> really, and loopback would require some special hardware set-up I

> don't have.


You could just do something like spin on register reads on some device
or something?  Something like dumping a regmap via debugfs would do the
trick probably.  I too would be surprised if there were a substantial
hit but it'd be good to check, while they've never been fast equally the
slowness can make people more sensitive to performance (including impact
on the rest of the system).  One of the reasons people can end up with
the GPIO controller is discovering some hardware bug in a hardware
controller (like the issues a lot of the Freescale controllers have with
trying to deassert chip select on every word transferred).

> The last patch in the series remove remnants of an unused mechanism

> that seemed to be for performance critical bitbanged SPI, that was never

> put to use, I kind of assume noone is really doing performance critical

> SPI over GPIO but I've been wrong before.


It was never really possible to upstream users of that code, AFAICT it
was always for custom out of tree builds.
Linus Walleij Jan. 6, 2018, 11:18 p.m. UTC | #5
On Wed, Jan 3, 2018 at 5:24 PM, Mark Brown <broonie@kernel.org> wrote:
> On Wed, Jan 03, 2018 at 12:17:07AM +0100, Linus Walleij wrote:

>

>> I'd be surprised if either performance or object code size is affected

>> in a bad way though. I don't have any high-speed SPI devices I can test

>> really, and loopback would require some special hardware set-up I

>> don't have.

>

> You could just do something like spin on register reads on some device

> or something?  Something like dumping a regmap via debugfs would do the

> trick probably.


OK I tried this on my new Ilitek ILI9322 panel driver:

A script like this dumping the regmap 10000 times (it
has no caching obviously) on an otherwise idle system
in two iterations before and after the patches:

#!/bin/sh
for run in `seq 10000`
do
    cat /debug/regmap/spi0.0/registers > /dev/null
done

Before the patch:
time test.sh
real    3m 41.03s
user    0m 29.41s
sys     3m 7.22s

time test.sh
real    3m 44.24s
user    0m 32.31s
sys     3m 7.60s

After the patch:

time test.sh
real    3m 41.32s
user    0m 28.92s
sys     3m 8.08s

time test.sh
real    3m 39.92s
user    0m 30.20s
sys     3m 5.56s

So any performance differences seems to be in the error margin.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html