1. 10 Jan, 2019 2 commits
  2. 09 Jan, 2019 8 commits
    • Martin Sperl's avatar
      spi: core: avoid waking pump thread from spi_sync instead run teardown delayed · 412e6037
      Martin Sperl authored
      When spi_sync is running alone with no other spi devices connected
      to the bus the worker thread is woken during spi_finalize_current_message
      to run the teardown code every time.
      
      This is totally unnecessary in the case that there is no message queued.
      
      On a multi-core system this results in one wakeup of the thread for each
      spi_message processed via spi_sync where in most cases the teardown does
      not happen as the hw is already in use.
      
      This patch now delays the teardown by 1 second by using a separate
      kthread_delayed_work for the teardown.
      
      This avoids waking the kthread too often.
      
      For spi_sync transfers in a tight loop (say 40k messages/s) this
      avoids the penalty of waking the worker thread 40k times/s.
      On a rasperry pi 3 with 4 cores the results in 32% of a single core
      only to find out that there is nothing in the queue and it can go back
      to sleep.
      
      With this patch applied the spi-worker is woken exactly once: after
      the load finishes and the spi bus is idle for 1 second.
      
      I believe I have also seen situations where during a spi_sync loop
      the worker thread (triggered by the last message finished) is slightly
      faster and _wins_ the race to process the message, so we are actually
      running the kthread and letting it do some work...
      
      This is also no longer observed with this patch applied as.
      
      Tested with a new CAN controller driver for the mcp2517fd which
      uses spi_sync for interrupt handling and spi_async for scheduling
      of can frames for transmission (in a different thread)
      
      Some statistics when receiving 100000 CAN frames with the mcp25xxfd driver
      on a Raspberry pi 3:
      
      without the patch:
      ------------------
      root@raspcm3:~# for x in $(pgrep spi0) $(pgrep irq/94-mcp25xxf) ; do awk '{printf "%-20s %6i\n", $2,$15}' /proc/$x/stat; done
      (spi0)                    5
      (irq/94-mcp25xxf)         0
      root@raspcm3:~# vmstat 1
      procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
       r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
       1  0      0 821960  13592  50848    0    0    80     2 1986  105  1  2 97  0  0
       0  0      0 821968  13592  50876    0    0     0     0 8046   30  0  0 100  0  0
       0  0      0 821936  13592  50876    0    0     0     0 8032   24  0  0 100  0  0
       0  0      0 821936  13592  50876    0    0     0     0 8035   30  0  0 100  0  0
       0  0      0 821936  13592  50876    0    0     0     0 8033   22  0  0 100  0  0
       2  0      0 821936  13592  50876    0    0     0     0 11598 7129  0  3 97  0  0
       1  0      0 821872  13592  50876    0    0     0     0 37741 59003  0 31 69  0  0
       2  0      0 821840  13592  50876    0    0     0     0 37762 59078  0 29 71  0  0
       2  0      0 821776  13592  50876    0    0     0     0 37593 58792  0 28 72  0  0
       1  0      0 821744  13592  50876    0    0     0     0 37642 58881  0 30 70  0  0
       2  0      0 821680  13592  50876    0    0     0     0 37490 58602  0 27 73  0  0
       1  0      0 821648  13592  50876    0    0     0     0 37412 58418  0 29 71  0  0
       1  0      0 821584  13592  50876    0    0     0     0 37337 58288  0 27 73  0  0
       1  0      0 821552  13592  50876    0    0     0     0 37584 58774  0 27 73  0  0
       0  0      0 821520  13592  50876    0    0     0     0 18363 20566  0  9 91  0  0
       0  0      0 821520  13592  50876    0    0     0     0 8037   32  0  0 100  0  0
       0  0      0 821520  13592  50876    0    0     0     0 8031   23  0  0 100  0  0
       0  0      0 821520  13592  50876    0    0     0     0 8034   26  0  0 100  0  0
       0  0      0 821520  13592  50876    0    0     0     0 8033   24  0  0 100  0  0
      ^C
      root@raspcm3:~# for x in $(pgrep spi0) $(pgrep irq/94-mcp25xxf) ; do awk '{printf "%-20s %6i\n", $2,$15}' /proc/$x/stat; done
      (spi0)                  228
      (irq/94-mcp25xxf)       794
      root@raspcm3:~# cat /proc/interrupts
                 CPU0       CPU1       CPU2       CPU3
       17:         34          0          0          0  ARMCTRL-level   1 Edge      3f00b880.mailbox
       27:          1          0          0          0  ARMCTRL-level  35 Edge      timer
       33:    1416870          0          0          0  ARMCTRL-level  41 Edge      3f980000.usb, dwc2_hsotg:usb1
       34:          1          0          0          0  ARMCTRL-level  42 Edge      vc4
       35:          0          0          0          0  ARMCTRL-level  43 Edge      3f004000.txp
       40:       1753          0          0          0  ARMCTRL-level  48 Edge      DMA IRQ
       42:         11          0          0          0  ARMCTRL-level  50 Edge      DMA IRQ
       44:         11          0          0          0  ARMCTRL-level  52 Edge      DMA IRQ
       45:          0          0          0          0  ARMCTRL-level  53 Edge      DMA IRQ
       66:          0          0          0          0  ARMCTRL-level  74 Edge      vc4 crtc
       69:          0          0          0          0  ARMCTRL-level  77 Edge      vc4 crtc
       70:          0          0          0          0  ARMCTRL-level  78 Edge      vc4 crtc
       77:         20          0          0          0  ARMCTRL-level  85 Edge      3f205000.i2c, 3f804000.i2c, 3f805000.i2c
       78:       6346          0          0          0  ARMCTRL-level  86 Edge      3f204000.spi
       80:        205          0          0          0  ARMCTRL-level  88 Edge      mmc0
       81:        493          0          0          0  ARMCTRL-level  89 Edge      uart-pl011
       89:          0          0          0          0  bcm2836-timer   0 Edge      arch_timer
       90:       4291       3821       2180       1649  bcm2836-timer   1 Edge      arch_timer
       94:      14289          0          0          0  pinctrl-bcm2835  16 Level     mcp25xxfd
      IPI0:          0          0          0          0  CPU wakeup interrupts
      IPI1:          0          0          0          0  Timer broadcast interrupts
      IPI2:       3645     242371       7919       1328  Rescheduling interrupts
      IPI3:        112        543        273        194  Function call interrupts
      IPI4:          0          0          0          0  CPU stop interrupts
      IPI5:          1          0          0          0  IRQ work interrupts
      IPI6:          0          0          0          0  completion interrupts
      Err:          0
      
      top shows 93% for the mcp25xxfd interrupt handler, 31% for spi0.
      
      with the patch:
      ---------------
      root@raspcm3:~# for x in $(pgrep spi0) $(pgrep irq/94-mcp25xxf) ; do awk '{printf "%-20s %6i\n", $2,$15}' /proc/$x/stat; done
      (spi0)                    0
      (irq/94-mcp25xxf)         0
      root@raspcm3:~# vmstat 1
      procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
       0  0      0 804768  13584  62628    0    0     0     0 8038   24  0  0 100  0  0
       0  0      0 804768  13584  62628    0    0     0     0 8042   25  0  0 100  0  0
       1  0      0 804704  13584  62628    0    0     0     0 9603 2967  0 20 80  0  0
       1  0      0 804672  13584  62628    0    0     0     0 9828 3380  0 24 76  0  0
       1  0      0 804608  13584  62628    0    0     0     0 9823 3375  0 23 77  0  0
       1  0      0 804608  13584  62628    0    0     0    12 9829 3394  0 23 77  0  0
       1  0      0 804544  13584  62628    0    0     0     0 9816 3362  0 22 78  0  0
       1  0      0 804512  13584  62628    0    0     0     0 9817 3367  0 23 77  0  0
       1  0      0 804448  13584  62628    0    0     0     0 9822 3370  0 22 78  0  0
       1  0      0 804416  13584  62628    0    0     0     0 9815 3367  0 23 77  0  0
       0  0      0 804352  13584  62628    0    0     0    84 9222 2250  0 14 86  0  0
       0  0      0 804352  13592  62620    0    0     0    24 8131  209  0  0 93  7  0
       0  0      0 804320  13592  62628    0    0     0     0 8041   27  0  0 100  0  0
       0  0      0 804352  13592  62628    0    0     0     0 8040   26  0  0 100  0  0
      root@raspcm3:~# for x in $(pgrep spi0) $(pgrep irq/94-mcp25xxf) ; do awk '{printf "%-20s %6i\n", $2,$15}' /proc/$x/stat; done
      (spi0)                    0
      (irq/94-mcp25xxf)       767
      root@raspcm3:~# cat /proc/interrupts
                 CPU0       CPU1       CPU2       CPU3
       17:         29          0          0          0  ARMCTRL-level   1 Edge      3f00b880.mailbox
       27:          1          0          0          0  ARMCTRL-level  35 Edge      timer
       33:    1024412          0          0          0  ARMCTRL-level  41 Edge      3f980000.usb, dwc2_hsotg:usb1
       34:          1          0          0          0  ARMCTRL-level  42 Edge      vc4
       35:          0          0          0          0  ARMCTRL-level  43 Edge      3f004000.txp
       40:       1773          0          0          0  ARMCTRL-level  48 Edge      DMA IRQ
       42:         11          0          0          0  ARMCTRL-level  50 Edge      DMA IRQ
       44:         11          0          0          0  ARMCTRL-level  52 Edge      DMA IRQ
       45:          0          0          0          0  ARMCTRL-level  53 Edge      DMA IRQ
       66:          0          0          0          0  ARMCTRL-level  74 Edge      vc4 crtc
       69:          0          0          0          0  ARMCTRL-level  77 Edge      vc4 crtc
       70:          0          0          0          0  ARMCTRL-level  78 Edge      vc4 crtc
       77:         20          0          0          0  ARMCTRL-level  85 Edge      3f205000.i2c, 3f804000.i2c, 3f805000.i2c
       78:       6417          0          0          0  ARMCTRL-level  86 Edge      3f204000.spi
       80:        237          0          0          0  ARMCTRL-level  88 Edge      mmc0
       81:        489          0          0          0  ARMCTRL-level  89 Edge      uart-pl011
       89:          0          0          0          0  bcm2836-timer   0 Edge      arch_timer
       90:       4048       3704       2383       1892  bcm2836-timer   1 Edge      arch_timer
       94:      14287          0          0          0  pinctrl-bcm2835  16 Level     mcp25xxfd
      IPI0:          0          0          0          0  CPU wakeup interrupts
      IPI1:          0          0          0          0  Timer broadcast interrupts
      IPI2:       2361       2948       7890       1616  Rescheduling interrupts
      IPI3:         65        617        301        166  Function call interrupts
      IPI4:          0          0          0          0  CPU stop interrupts
      IPI5:          1          0          0          0  IRQ work interrupts
      IPI6:          0          0          0          0  completion interrupts
      Err:          0
      top shows 91% for the mcp25xxfd interrupt handler, 0% for spi0
      
      So we see that spi0 is no longer getting scheduled wasting CPU cycles
      There are a lot less context switches and corresponding Rescheduling interrupts
      All of these show that this improves efficiency of the system and reduces
      CPU utilization.
      Signed-off-by: default avatarMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      412e6037
    • Linus Walleij's avatar
      spi: dw: Convert to use CS GPIO descriptors · 9400c41e
      Linus Walleij authored
      This converts the DesignWare (dw) SPI master driver to
      use GPIO descriptors for chip select handling.
      
      This driver has a duplicate DT parser in addition to the
      one in the core, sets up the line as non-asserted and
      relies on the core to drive the GPIOs.
      
      It is a pretty straight-forward conversion.
      
      Cc: Talel Shenhar <talel@amazon.com>
      Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Linuxarm <linuxarm@huawei.com>
      Tested-by: default avatarJay Fang <f.fangjian@huawei.com>
      Reviewed-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      9400c41e
    • Linus Walleij's avatar
      spi: davinci: Convert to use CS GPIO descriptors · 101a68e7
      Linus Walleij authored
      This converts the DaVinci SPI master driver to use GPIO
      descriptors for chip select handling.
      
      DaVinci parses the device tree a second time for the chip
      select GPIOs (no relying on the parsing already happening
      in the SPI core) and handles inversion semantics locally.
      
      We simply drop the extra parsing and set up and move the
      CS handling to the core and gpiolib. The fact that the
      driver is actively driving the GPIO in the
      davinci_spi_chipselect() callback is confusing since the
      host does not set SPI_MASTER_GPIO_SS so this should not
      ever get called when using GPIO CS. I put in a comment
      about this.
      
      This driver also supports instantiation from board files,
      but these are all using native chip selects so no problem
      with GPIO lines here.
      
      Cc: David Lechner <david@lechnology.com>
      Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
      Cc: Linuxarm <linuxarm@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      101a68e7
    • Linus Walleij's avatar
      spi: clps711x: Convert to use CS GPIO descriptors · 054320b2
      Linus Walleij authored
      This converts the CLPS711x SPI master driver to use GPIO
      descriptors for chip select handling.
      
      The CLPS711x driver was merely requesting the GPIO and
      setting the CS line non-asserted so this was a pretty
      straight-forward conversion. The setup callback goes away.
      
      Cc: Alexander Shiyan <shc_work@mail.ru>
      Cc: Linuxarm <linuxarm@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      054320b2
    • Linus Walleij's avatar
      spi: cadence: Convert to use CS GPIO descriptors · cfeefa79
      Linus Walleij authored
      This converts the Cadence SPI master driver to use GPIO
      descriptors for chip select handling.
      
      The Cadence driver was allocating a state container just
      to hold the requested GPIO line and contained lots of
      polarity inversion code. As this is all handled by gpiolib
      and a simple devm_* request in the core, and as the driver
      is fully device tree only, most of this code chunk goes
      away in favour of central handling. The setup/cleanup
      callbacks goes away.
      
      This driver does NOT drive the CS line by setting the
      value of the GPIO so it relies on the SPI core to do
      this, which should work just fine with the descriptors.
      
      Cc: Wei Yongjun <weiyongjun1@huawei.com>
      Cc: Janek Kotas <jank@cadence.com>
      Cc: Linuxarm <linuxarm@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      cfeefa79
    • Linus Walleij's avatar
      spi: atmel: Convert to use CS GPIO descriptors · efc92fbb
      Linus Walleij authored
      This converts the Atmel SPI master driver to use GPIO descriptors
      for chip select handling.
      
      The Atmel driver has duplicate code to look up and initialize CS
      GPIOs from the device tree, so this is removed. It further has code
      to retrieve a CS GPIO from .controller_data but this seems to be
      completely unused in the kernel (legacy codepath?) so I deleted
      this support. It keeps track of polarity when switching the CS, but
      this is not needed anymore since we moved this over to the gpiolib.
      
      The local handling of the "npcs_pin" (I guess this might mean
      "negative polarity chip select pin") is preserved, but I strongly
      suspect this can be switched over to handling by the core and
      using the SPI_MASTER_GPIO_SS flag on the master to assure that
      the additional CS handling in the driver is also done.
      
      Cc: Eugen Hristev <eugen.hristev@microchip.com>
      Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
      Cc: Radu Pirea <radu.pirea@microchip.com>
      Cc: Linuxarm <linuxarm@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      efc92fbb
    • Linus Walleij's avatar
      spi: ath79: Convert to use CS GPIO descriptors · 8db79547
      Linus Walleij authored
      This converts the ATH79 SPI master driver to use GPIO descriptors
      for chip select handling.
      
      The ATH79 driver was requesting the GPIO and driving it from the
      bitbang .chipselect callback. Do not request it anymore as the SPI
      core will request it, remove the line inversion semantics for the
      GPIO case (handled by gpiolib) and let the SPI core deal with
      requesting the GPIO line from the device tree node of the controller.
      
      This driver can be instantiated from a board file (no device tree)
      but the board files only use native CS (no GPIO lines) so we should
      be fine just letting the SPI core grab the GPIO from the device.
      
      The fact that the driver is actively driving the GPIO in the
      ath79_spi_chipselect() callback is confusing since the host does
      not set SPI_MASTER_GPIO_SS so this should not ever get called when
      using GPIO CS. I put in a comment about this.
      
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Alban Bedel <albeu@free.fr>
      Cc: Linuxarm <linuxarm@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      8db79547
    • Linus Walleij's avatar
      spi: Optionally use GPIO descriptors for CS GPIOs · f3186dd8
      Linus Walleij authored
      This augments the SPI core to optionally use GPIO descriptors
      for chip select on a per-master-driver opt-in basis.
      
      Drivers using this will rely on the SPI core to look up
      GPIO descriptors associated with the device, such as
      when using device tree or board files with GPIO descriptor
      tables.
      
      When getting descriptors from the device tree, this will in
      turn activate the code in gpiolib that was
      added in commit 6953c57a
      ("gpio: of: Handle SPI chipselect legacy bindings")
      which means that these descriptors are aware of the active
      low semantics that is the default for SPI CS GPIO lines
      and we can assume that all of these are "active high" and
      thus assign SPI_CS_HIGH to all CS lines on the DT path.
      
      The previously used gpio_set_value() would call down into
      gpiod_set_raw_value() and ignore the polarity inversion
      semantics.
      
      It seems like many drivers go to great lengths to set up the
      CS GPIO line as non-asserted, respecting SPI_CS_HIGH. We pull
      this out of the SPI drivers and into the core, and by simply
      requesting the line as GPIOD_OUT_LOW when retrieveing it from
      the device and relying on the gpiolib to handle any inversion
      semantics. This way a lot of code can be simplified and
      removed in each converted driver.
      
      The end goal after dealing with each driver in turn, is to
      delete the non-descriptor path (of_spi_register_master() for
      example) and let the core deal with only descriptors.
      
      The different SPI drivers have complex interactions with the
      core so we cannot simply change them all over, we need to use
      a stepwise, bisectable approach so that each driver can be
      converted and fixed in isolation.
      
      This patch has the intended side effect of adding support for
      ACPI GPIOs as it starts relying on gpiod_get_*() to get
      the GPIO handle associated with the device.
      
      Cc: Linuxarm <linuxarm@huawei.com>
      Acked-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
      Tested-by: default avatarFangjian (Turing) <f.fangjian@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      f3186dd8
  3. 07 Jan, 2019 25 commits
  4. 06 Jan, 2019 5 commits
    • Linus Torvalds's avatar
      Change mincore() to count "mapped" pages rather than "cached" pages · 574823bf
      Linus Torvalds authored
      The semantics of what "in core" means for the mincore() system call are
      somewhat unclear, but Linux has always (since 2.3.52, which is when
      mincore() was initially done) treated it as "page is available in page
      cache" rather than "page is mapped in the mapping".
      
      The problem with that traditional semantic is that it exposes a lot of
      system cache state that it really probably shouldn't, and that users
      shouldn't really even care about.
      
      So let's try to avoid that information leak by simply changing the
      semantics to be that mincore() counts actual mapped pages, not pages
      that might be cheaply mapped if they were faulted (note the "might be"
      part of the old semantics: being in the cache doesn't actually guarantee
      that you can access them without IO anyway, since things like network
      filesystems may have to revalidate the cache before use).
      
      In many ways the old semantics were somewhat insane even aside from the
      information leak issue.  From the very beginning (and that beginning is
      a long time ago: 2.3.52 was released in March 2000, I think), the code
      had a comment saying
      
        Later we can get more picky about what "in core" means precisely.
      
      and this is that "later".  Admittedly it is much later than is really
      comfortable.
      
      NOTE! This is a real semantic change, and it is for example known to
      change the output of "fincore", since that program literally does a
      mmmap without populating it, and then doing "mincore()" on that mapping
      that doesn't actually have any pages in it.
      
      I'm hoping that nobody actually has any workflow that cares, and the
      info leak is real.
      
      We may have to do something different if it turns out that people have
      valid reasons to want the old semantics, and if we can limit the
      information leak sanely.
      
      Cc: Kevin Easton <kevin@guarana.org>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Masatake YAMATO <yamato@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      574823bf
    • Linus Torvalds's avatar
      Fix 'acccess_ok()' on alpha and SH · 94bd8a05
      Linus Torvalds authored
      Commit 594cc251 ("make 'user_access_begin()' do 'access_ok()'")
      broke both alpha and SH booting in qemu, as noticed by Guenter Roeck.
      
      It turns out that the bug wasn't actually in that commit itself (which
      would have been surprising: it was mostly a no-op), but in how the
      addition of access_ok() to the strncpy_from_user() and strnlen_user()
      functions now triggered the case where those functions would test the
      access of the very last byte of the user address space.
      
      The string functions actually did that user range test before too, but
      they did it manually by just comparing against user_addr_max().  But
      with user_access_begin() doing the check (using "access_ok()"), it now
      exposed problems in the architecture implementations of that function.
      
      For example, on alpha, the access_ok() helper macro looked like this:
      
        #define __access_ok(addr, size) \
              ((get_fs().seg & (addr | size | (addr+size))) == 0)
      
      and what it basically tests is of any of the high bits get set (the
      USER_DS masking value is 0xfffffc0000000000).
      
      And that's completely wrong for the "addr+size" check.  Because it's
      off-by-one for the case where we check to the very end of the user
      address space, which is exactly what the strn*_user() functions do.
      
      Why? Because "addr+size" will be exactly the size of the address space,
      so trying to access the last byte of the user address space will fail
      the __access_ok() check, even though it shouldn't.  As a result, the
      user string accessor functions failed consistently - because they
      literally don't know how long the string is going to be, and the max
      access is going to be that last byte of the user address space.
      
      Side note: that alpha macro is buggy for another reason too - it re-uses
      the arguments twice.
      
      And SH has another version of almost the exact same bug:
      
        #define __addr_ok(addr) \
              ((unsigned long __force)(addr) < current_thread_info()->addr_limit.seg)
      
      so far so good: yes, a user address must be below the limit.  But then:
      
        #define __access_ok(addr, size)         \
              (__addr_ok((addr) + (size)))
      
      is wrong with the exact same off-by-one case: the case when "addr+size"
      is exactly _equal_ to the limit is actually perfectly fine (think "one
      byte access at the last address of the user address space")
      
      The SH version is actually seriously buggy in another way: it doesn't
      actually check for overflow, even though it did copy the _comment_ that
      talks about overflow.
      
      So it turns out that both SH and alpha actually have completely buggy
      implementations of access_ok(), but they happened to work in practice
      (although the SH overflow one is a serious serious security bug, not
      that anybody likely cares about SH security).
      
      This fixes the problems by using a similar macro on both alpha and SH.
      It isn't trying to be clever, the end address is based on this logic:
      
              unsigned long __ao_end = __ao_a + __ao_b - !!__ao_b;
      
      which basically says "add start and length, and then subtract one unless
      the length was zero".  We can't subtract one for a zero length, or we'd
      just hit an underflow instead.
      
      For a lot of access_ok() users the length is a constant, so this isn't
      actually as expensive as it initially looks.
      Reported-and-tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      94bd8a05
    • Linus Torvalds's avatar
      Merge tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt · baa67073
      Linus Torvalds authored
      Pull fscrypt updates from Ted Ts'o:
       "Add Adiantum support for fscrypt"
      
      * tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt:
        fscrypt: add Adiantum support
      baa67073
    • Linus Torvalds's avatar
      Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · 21524046
      Linus Torvalds authored
      Pull ext4 bug fixes from Ted Ts'o:
       "Fix a number of ext4 bugs"
      
      * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        ext4: fix special inode number checks in __ext4_iget()
        ext4: track writeback errors using the generic tracking infrastructure
        ext4: use ext4_write_inode() when fsyncing w/o a journal
        ext4: avoid kernel warning when writing the superblock to a dead device
        ext4: fix a potential fiemap/page fault deadlock w/ inline_data
        ext4: make sure enough credits are reserved for dioread_nolock writes
      21524046
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-4.21-1' of git://git.infradead.org/users/hch/dma-mapping · e2b745f4
      Linus Torvalds authored
      Pull dma-mapping fixes from Christoph Hellwig:
       "Fix various regressions introduced in this cycles:
      
         - fix dma-debug tracking for the map_page / map_single
           consolidatation
      
         - properly stub out DMA mapping symbols for !HAS_DMA builds to avoid
           link failures
      
         - fix AMD Gart direct mappings
      
         - setup the dma address for no kernel mappings using the remap
           allocator"
      
      * tag 'dma-mapping-4.21-1' of git://git.infradead.org/users/hch/dma-mapping:
        dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING for remapped allocations
        x86/amd_gart: fix unmapping of non-GART mappings
        dma-mapping: remove a few unused exports
        dma-mapping: properly stub out the DMA API for !CONFIG_HAS_DMA
        dma-mapping: remove dmam_{declare,release}_coherent_memory
        dma-mapping: implement dmam_alloc_coherent using dmam_alloc_attrs
        dma-mapping: implement dma_map_single_attrs using dma_map_page_attrs
      e2b745f4