linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/13] gpiolib: add an ioctl() for monitoring line status changes
@ 2019-12-19 17:15 Bartosz Golaszewski
  2019-12-19 17:15 ` [PATCH v3 01/13] gpiolib: use 'unsigned int' instead of 'unsigned' in gpio_set_config() Bartosz Golaszewski
                   ` (12 more replies)
  0 siblings, 13 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2019-12-19 17:15 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Greg Kroah-Hartman
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

When discussing the recent user-space changes with Kent and while working
on dbus API for libgpiod I noticed that we really don't have any way of
keeping the line info synchronized between the kernel and user-space
processes. We can of course periodically re-read the line information or
even do it every time we want to read a property but this isn't optimal.

This series adds a new ioctl() that allows user-space to set up a watch on
the GPIO chardev file-descriptor which can then be polled for events
emitted by the kernel when the line is requested, released or its status
changed. This of course doesn't require the line to be requested. Multiple
user-space processes can watch the same lines.

This series also includes a variety of minor tweaks & fixes for problems
discovered during development. For instance it addresses a race-condition
in current line event fifo.

v1: https://lkml.org/lkml/2019/11/27/327

v1 -> v2:
- rework the main patch of the series: re-use the existing file-descriptor
  associated with an open character device
- add a patch adding a debug message when the line event kfifo is full and
  we're discarding another event
- rework the locking mechanism for lineevent kfifo: reuse the spinlock
  from the waitqueue structure
- other minor changes

v2 -> v3:
- added patches providing new implementation for some kfifo macros
- fixed a regression in the patch reworking the line event fifo: reading
  multiple events is now still possible
- reworked the structure for new ioctl: it's now padded such that there
  be no alignment issues if running a 64-bit kernel on 32-bit userspace
- fixed a bug where one process could disable the status watch of another
- use kstrtoul() instead of atoi() in gpio-watch for string validation

Bartosz Golaszewski (13):
  gpiolib: use 'unsigned int' instead of 'unsigned' in gpio_set_config()
  gpiolib: have a single place of calling set_config()
  gpiolib: convert the type of hwnum to unsigned int in
    gpiochip_get_desc()
  gpiolib: use gpiochip_get_desc() in linehandle_create()
  gpiolib: use gpiochip_get_desc() in lineevent_create()
  gpiolib: use gpiochip_get_desc() in gpio_ioctl()
  kfifo: provide noirqsave variants of spinlocked in and out helpers
  kfifo: provide kfifo_is_empty_spinlocked()
  gpiolib: rework the locking mechanism for lineevent kfifo
  gpiolib: emit a debug message when adding events to a full kfifo
  gpiolib: provide a dedicated function for setting lineinfo
  gpiolib: add new ioctl() for monitoring changes in line info
  tools: gpio: implement gpio-watch

 drivers/gpio/gpiolib.c      | 402 +++++++++++++++++++++++++++---------
 drivers/gpio/gpiolib.h      |   4 +-
 include/linux/gpio/driver.h |   3 +-
 include/linux/kfifo.h       |  73 +++++++
 include/uapi/linux/gpio.h   |  24 +++
 tools/gpio/.gitignore       |   1 +
 tools/gpio/Build            |   1 +
 tools/gpio/Makefile         |  11 +-
 tools/gpio/gpio-watch       | Bin 0 -> 26528 bytes
 tools/gpio/gpio-watch.c     |  99 +++++++++
 10 files changed, 514 insertions(+), 104 deletions(-)
 create mode 100755 tools/gpio/gpio-watch
 create mode 100644 tools/gpio/gpio-watch.c

-- 
2.23.0


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

end of thread, other threads:[~2019-12-24 12:09 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 17:15 [PATCH v3 00/13] gpiolib: add an ioctl() for monitoring line status changes Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 01/13] gpiolib: use 'unsigned int' instead of 'unsigned' in gpio_set_config() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 02/13] gpiolib: have a single place of calling set_config() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 03/13] gpiolib: convert the type of hwnum to unsigned int in gpiochip_get_desc() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 04/13] gpiolib: use gpiochip_get_desc() in linehandle_create() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 05/13] gpiolib: use gpiochip_get_desc() in lineevent_create() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 06/13] gpiolib: use gpiochip_get_desc() in gpio_ioctl() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 07/13] kfifo: provide noirqsave variants of spinlocked in and out helpers Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 08/13] kfifo: provide kfifo_is_empty_spinlocked() Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 09/13] gpiolib: rework the locking mechanism for lineevent kfifo Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 10/13] gpiolib: emit a debug message when adding events to a full kfifo Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 11/13] gpiolib: provide a dedicated function for setting lineinfo Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 12/13] gpiolib: add new ioctl() for monitoring changes in line info Bartosz Golaszewski
2019-12-19 17:24   ` Greg Kroah-Hartman
2019-12-20  8:45     ` Bartosz Golaszewski
2019-12-19 18:17   ` Andy Shevchenko
2019-12-20 11:25     ` Bartosz Golaszewski
2019-12-20 12:15       ` Andy Shevchenko
2019-12-20 17:29         ` Bartosz Golaszewski
2019-12-24 12:09           ` Bartosz Golaszewski
2019-12-24 12:08     ` Bartosz Golaszewski
2019-12-19 17:15 ` [PATCH v3 13/13] tools: gpio: implement gpio-watch Bartosz Golaszewski

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).