1. 25 9月, 2018 3 次提交
  2. 24 9月, 2018 2 次提交
    • J
      gpiolib: Fix array members of same chip processed separately · c4c958aa
      Janusz Krzysztofik 提交于
      New code introduced by commit bf9346f5 ("gpiolib: Identify arrays
      matching GPIO hardware") forcibly tries to find an array member which
      has its array index number equal to its hardware pin number and set
      up an array info for possible fast bitmap processing of all arrray
      pins belonging to that chip which also satisfy that numbering rule.
      
      Depending on array content, it may happen that consecutive array
      members which belong to the same chip but don't have array indexes
      equal to their pin hardware numbers will be split into groups, some of
      them processed together via the fast bitmap path, and rest of them
      separetely.  However, applications may expect all those pins being
      processed together with a single call to .set_multiple() chip callback,
      like that was done before the change.
      
      Limit applicability of fast bitmap processing path to cases where all
      pins of consecutive array members starting from 0 which belong to the
      same chip have their hardware numbers equal to their corresponding
      array indexes.  That should still speed up processing of applications
      using whole GPIO banks as I/O ports, while not breaking simultaneous
      manipulation of consecutive pins of the same chip which don't follow
      the equal numbering rule.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      c4c958aa
    • J
      gpiolib: Fix missing updates of bitmap index · 35ae7f96
      Janusz Krzysztofik 提交于
      In new code introduced by commit b17566a6 ("gpiolib: Implement fast
      processing path in get/set array"), bitmap index is not updated with
      next found zero bit position as it should while skipping over pins
      already processed via fast bitmap path, possibly resulting in an
      infinite loop.  Fix it.
      Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Tested-by: NMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      35ae7f96
  3. 17 9月, 2018 1 次提交
  4. 14 9月, 2018 1 次提交
  5. 13 9月, 2018 5 次提交
    • J
      gpiolib: Implement fast processing path in get/set array · b17566a6
      Janusz Krzysztofik 提交于
      Certain GPIO descriptor arrays returned by gpio_get_array() may contain
      information on direct mapping of array members to pins of a single GPIO
      chip in hardware order.  In such cases, bitmaps of values can be passed
      directly from/to the chip's .get/set_multiple() callbacks without
      wasting time on iterations.
      
      Add respective code to gpiod_get/set_array_bitmap_complex() functions.
      Pins not applicable for fast path are processed as before, skipping
      over the 'fast' ones.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      b17566a6
    • J
      gpiolib: Pass array info to get/set array functions · 77588c14
      Janusz Krzysztofik 提交于
      In order to make use of array info obtained from gpiod_get_array() and
      speed up processing of arrays matching single GPIO chip layout, that
      information must be passed to get/set array functions.  Extend the
      functions' API with that additional parameter and update all users.
      Pass NULL if a user builds an array itself from single GPIOs.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Peter Korsgaard <peter.korsgaard@barco.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Rojhalat Ibrahim <imr@rtschenk.de>
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Cc: Kishon Vijay Abraham I <kishon@ti.com>
      Cc: Tony Lindgren <tony@atomide.com>
      Cc: Lars-Peter Clausen <lars@metafoo.de>
      Cc: Michael Hennerich <Michael.Hennerich@analog.com>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: Hartmut Knaack <knaack.h@gmx.de>
      Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Yegor Yefremov <yegorslists@googlemail.com>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      77588c14
    • J
      gpiolib: Identify arrays matching GPIO hardware · bf9346f5
      Janusz Krzysztofik 提交于
      Certain GPIO array lookup results may map directly to GPIO pins of a
      single GPIO chip in hardware order.  If that condition is recognized
      and handled efficiently, significant performance gain of get/set array
      functions may be possible.
      
      While processing a request for an array of GPIO descriptors, identify
      those which represent corresponding pins of a single GPIO chip.  Skip
      over pins which require open source or open drain special processing.
      Moreover, identify pins which require inversion.  Pass a pointer to
      that information with the array to the caller so it can benefit from
      enhanced performance as soon as get/set array functions can accept and
      make efficient use of it.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      bf9346f5
    • J
      gpiolib: Pass bitmaps, not integer arrays, to get/set array · b9762beb
      Janusz Krzysztofik 提交于
      Most users of get/set array functions iterate consecutive bits of data,
      usually a single integer, while processing array of results obtained
      from, or building an array of values to be passed to those functions.
      Save time wasted on those iterations by changing the functions' API to
      accept bitmaps.
      
      All current users are updated as well.
      
      More benefits from the change are expected as soon as planned support
      for accepting/passing those bitmaps directly from/to respective GPIO
      chip callbacks if applicable is implemented.
      
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
      Cc: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
      Cc: Lukas Wunner <lukas@wunner.de>
      Cc: Peter Korsgaard <peter.korsgaard@barco.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Rojhalat Ibrahim <imr@rtschenk.de>
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Cc: Kishon Vijay Abraham I <kishon@ti.com>
      Cc: Tony Lindgren <tony@atomide.com>
      Cc: Lars-Peter Clausen <lars@metafoo.de>
      Cc: Michael Hennerich <Michael.Hennerich@analog.com>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: Hartmut Knaack <knaack.h@gmx.de>
      Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jslaby@suse.com>
      Cc: Yegor Yefremov <yegorslists@googlemail.com>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: NJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      b9762beb
    • U
      gpiolib: Don't support irq sharing for userspace · fa38869b
      Uwe Kleine-König 提交于
      This concerns gpio edge detection for GPIO IRQs used from
      userspace for GPIO event listeners.
      
      Trying to work out the right event if it's not sure that the
      examined gpio actually moved is impossible.
      
      Consider two gpios "gpioA" and "gpioB" that share an interrupt.
      gpioA's irq should trigger on any edge, gpioB's on a falling edge.
      If now the common irq fires and both gpio lines are high, there
      are several possibilities that could have happend:
      
       a) gpioA just had a low-to-high edge
       b) gpioB just had a high-to-low-to-high spike
       c) a combination of both a) and b)
      
      While c) is unlikely (in most setups) a) and b) alone are bad
      enough. Currently the code assumes case a) unconditionally and
      doesn't report an event for gpioB. Note that even if there is no
      irq sharing involved a spike for a gpio might not result in an
      event if it's configured to trigger for a single edge only.
      
      The only way to improve this is to drop support for interrupt
      sharing. This way a spike results in an event for the right gpio
      at least. Note that apart from dropping IRQF_SHARED this
      effectively undoes commit df1e76f2
      ("gpiolib: skip unwanted events, don't convert them to opposite edge").
      
      This obviously breaks setups that rely on interrupt sharing,
      but given that this cannot be reliable, this is probably an
      acceptable trade-off.
      Signed-off-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      [Assuming there are no users of interrupt sharing yet]
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      fa38869b
  6. 10 9月, 2018 4 次提交
    • H
      gpiolib: override irq_enable/disable · 461c1a7d
      Hans Verkuil 提交于
      When using the gpiolib irqchip helpers install irq_enable/disable
      hooks for the irqchip to ensure that gpiolib knows when the irq
      is enabled or disabled, allowing drivers to disable the irq and then
      use it as an output pin, and later switch the direction to input and
      re-enable the irq.
      Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      461c1a7d
    • H
      gpiolib: add flag to indicate if the irq is disabled · 4e9439dd
      Hans Verkuil 提交于
      GPIO drivers call gpiochip_(un)lock_as_irq whenever they want to use a gpio
      as an interrupt. This is done when the irq is requested and it marks the
      gpio as in use by an interrupt.
      
      This is problematic for cases where a gpio pin is used as an interrupt
      pin, then, after the irq is disabled, is used as a regular gpio pin.
      Currently it is not possible to do this other than by first freeing
      the interrupt so gpiochip_unlock_as_irq is called, since an attempt to
      switch the gpio direction for output will fail since gpiolib believes
      that the gpio is in use for an interrupt and it does not know that it
      the irq is actually disabled.
      
      There are currently two drivers that would like to be able to do this:
      the tda998x_drv.c driver where a regular gpio pin needs to be temporarily
      reconfigured as an interrupt pin during CEC calibration, and the cec-gpio
      driver where you want to configure the gpio pin as an interrupt while
      waiting for traffic over the CEC bus, or as a regular pin when receiving or
      transmitting a CEC message.
      
      The solution is to add a new flag that is set when the irq is enabled,
      and have gpiod_direction_output check for that flag.
      
      We also add functions that drivers that do not use GPIOLIB_IRQCHIP
      can call when they enable/disable the irq.
      Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      4e9439dd
    • H
      gliolib: set hooks in gpiochip_set_irq_hooks() · ca620f2d
      Hans Verkuil 提交于
      Centralize setting the irq_request/release_resources callbacks
      in one function since we'll be adding more callbacks to that.
      
      Also fix the removal of the callback overrides: this should
      only be done if we actually installed our own callback there.
      Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ca620f2d
    • H
      gpiolib: export gpiochip_irq_reqres/relres() · 4e6b8238
      Hans Verkuil 提交于
      GPIO drivers that do not use GPIOLIB_IRQCHIP can hook these into
      the irq_request_resource and irq_release_resource callbacks of the
      irq_chip so they correctly 'get' the module and lock the gpio line
      for IRQ use.
      
      This will simplify driver code.
      Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      4e6b8238
  7. 11 8月, 2018 2 次提交
  8. 07 8月, 2018 1 次提交
  9. 30 7月, 2018 1 次提交
  10. 16 7月, 2018 2 次提交
  11. 13 7月, 2018 2 次提交
  12. 09 7月, 2018 3 次提交
  13. 18 6月, 2018 1 次提交
    • L
      gpio: Add API to explicitly name a consumer · 90b39402
      Linus Walleij 提交于
      The GPIO (descriptor) API registers a "label" naming what is
      currently using the GPIO line. Typically this is taken from
      things like the device tree node, so "reset-gpios" will result
      in he line being labeled "reset".
      
      The technical effect is pretty much zero: the use is for
      debug and introspection, such as "lsgpio" and debugfs files.
      
      However sometimes the user want this cuddly feeling of
      listing all GPIO lines and seeing exactly what they are for
      and it gives a very fulfilling sense of control. Especially
      in the cases when the device tree node doesn't provide a
      good name, or anonymous GPIO lines assigned just to
      "gpios" in the device tree because the usage is implicit.
      
      For these cases it may be nice to be able to label the
      line directly and explicitly.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      90b39402
  14. 07 6月, 2018 1 次提交
    • K
      treewide: Use struct_size() for kmalloc()-family · acafe7e3
      Kees Cook 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
      uses. It was done via automatic conversion with manual review for the
      "CHECKME" non-standard cases noted below, using the following Coccinelle
      script:
      
      // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
      //                      sizeof *pkey_cache->table, GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // Same pattern, but can't trivially locate the trailing element name,
      // or variable name.
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      expression SOMETHING, COUNT, ELEMENT;
      @@
      
      - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
      + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      acafe7e3
  15. 24 5月, 2018 1 次提交
  16. 23 5月, 2018 1 次提交
  17. 16 5月, 2018 2 次提交
  18. 27 4月, 2018 1 次提交
  19. 26 4月, 2018 1 次提交
  20. 27 3月, 2018 3 次提交
  21. 02 3月, 2018 1 次提交
  22. 12 2月, 2018 1 次提交
    • L
      vfs: do bulk POLL* -> EPOLL* replacement · a9a08845
      Linus Torvalds 提交于
      This is the mindless scripted replacement of kernel use of POLL*
      variables as described by Al, done by this script:
      
          for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
              L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
              for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
          done
      
      with de-mangling cleanups yet to come.
      
      NOTE! On almost all architectures, the EPOLL* constants have the same
      values as the POLL* constants do.  But they keyword here is "almost".
      For various bad reasons they aren't the same, and epoll() doesn't
      actually work quite correctly in some cases due to this on Sparc et al.
      
      The next patch from Al will sort out the final differences, and we
      should be all done.
      Scripted-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a9a08845