1. 15 Feb, 2019 8 commits
  2. 27 Nov, 2018 1 commit
  3. 13 Nov, 2018 1 commit
    • Alexandre Belloni's avatar
      uio: ensure class is registered before devices · adfbc0d1
      Alexandre Belloni authored
      [ Upstream commit ae61cf5b9913027c6953a79ed3894da4f47061bd ]
      
      When both uio and the uio drivers are built in the kernel, it is possible
      for a driver to register devices before the uio class is registered.
      
      This may result in a NULL pointer dereference later on in
      get_device_parent() when accessing the class glue_dirs spinlock.
      
      The trace looks like that:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000140
      [...]
      [<ffff0000089cc234>] _raw_spin_lock+0x14/0x48
      [<ffff0000084f56bc>] device_add+0x154/0x6a0
      [<ffff0000084f5e48>] device_create_groups_vargs+0x120/0x128
      [<ffff0000084f5edc>] device_create+0x54/0x60
      [<ffff0000086e72c0>] __uio_register_device+0x120/0x4a8
      [<ffff000008528b7c>] jaguar2_pci_probe+0x2d4/0x558
      [<ffff0000083fc18c>] local_pci_probe+0x3c/0xb8
      [<ffff0000083fd81c>] pci_device_probe+0x11c/0x180
      [<ffff0000084f88bc>] driver_probe_device+0x22c/0x2d8
      [<ffff0000084f8a24>] __driver_attach+0xbc/0xc0
      [<ffff0000084f69fc>] bus_for_each_dev+0x4c/0x98
      [<ffff0000084f81b8>] driver_attach+0x20/0x28
      [<ffff0000084f7d08>] bus_add_driver+0x1b8/0x228
      [<ffff0000084f93c0>] driver_register+0x60/0xf8
      [<ffff0000083fb918>] __pci_register_driver+0x40/0x48
      
      Return EPROBE_DEFER in that case so the driver can register the device
      later.
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      adfbc0d1
  4. 19 Sep, 2018 1 commit
  5. 12 Apr, 2018 1 commit
  6. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  7. 18 May, 2017 1 commit
  8. 16 May, 2017 1 commit
  9. 08 Apr, 2017 3 commits
    • Michal Sojka's avatar
      uio_mf624: Align memory regions to page size and set correct offsets · 270579d9
      Michal Sojka authored
      mf624 card has its registers not aligned to pages. Since commit
      b6550287 ("uio: we cannot mmap unaligned page contents") mmap()ing
      mf624 registers fails, because now the uio drivers must set
      uio_mem->addr to be page-aligned.
      
      We align the address here and set the newly introduced offs field to
      the offset of the mf264 registers within the page so that userspace
      can find the address of the mmap()ed register by reading
      /sys/class/uio/uio?/maps/map?/offset.
      
      Tested with real mf624 card.
      Signed-off-by: default avatarMichal Sojka <sojkam1@fel.cvut.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      270579d9
    • Michal Sojka's avatar
      uio_mf624: Refactor memory info initialization · a15d2ddb
      Michal Sojka authored
      No functional changes. Move initialization of struct uio_mem to a
      function. This will allow the next commit to change the initialization
      code at a single place rather that at three different places.
      Signed-off-by: default avatarMichal Sojka <sojkam1@fel.cvut.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a15d2ddb
    • Michal Sojka's avatar
      uio: Allow handling of non page-aligned memory regions · 171058fb
      Michal Sojka authored
      Since commit b6550287 ("uio: we cannot mmap unaligned page
      contents") addresses and sizes of UIO memory regions must be
      page-aligned. If the address in the BAR register is not
      page-aligned (which is the case of the mf264 card), the mentioned
      commit forces the UIO driver to round the address down to the page
      size. Then, there is no easy way for user-space to learn the offset of
      the actual memory region within the page, because the offset seen in
      /sys/class/uio/uio?/maps/map?/offset is calculated from the rounded
      address and thus it is always zero.
      
      Fix that problem by including the offset in struct uio_mem. UIO
      drivers can set this field and userspace can read its value from
      /sys/class/uio/uio?/maps/map?/offset.
      
      The following commits update the uio_mf264 driver to set this new offs
      field.
      
      Drivers for hardware with page-aligned BARs need not to be modified
      provided that they initialize struct uio_info (which contains uio_mem)
      with zeros.
      Signed-off-by: default avatarMichal Sojka <sojkam1@fel.cvut.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      171058fb
  10. 02 Mar, 2017 1 commit
  11. 25 Feb, 2017 1 commit
  12. 14 Feb, 2017 1 commit
  13. 10 Dec, 2016 1 commit
    • Arnd Bergmann's avatar
      uio-hv-generic: store physical addresses instead of virtual · 190cc65e
      Arnd Bergmann authored
      gcc warns about the newly added driver when phys_addr_t is wider than
      a pointer:
      
      drivers/uio/uio_hv_generic.c: In function 'hv_uio_mmap':
      drivers/uio/uio_hv_generic.c:71:17: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
          virt_to_phys((void *)info->mem[mi].addr) >> PAGE_SHIFT,
      drivers/uio/uio_hv_generic.c: In function 'hv_uio_probe':
      drivers/uio/uio_hv_generic.c:140:5: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
         = (phys_addr_t)dev->channel->ringbuffer_pages;
      drivers/uio/uio_hv_generic.c:147:3: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
         (phys_addr_t)vmbus_connection.int_page;
      drivers/uio/uio_hv_generic.c:153:3: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
         (phys_addr_t)vmbus_connection.monitor_pages[1];
      
      I can't see why we store a virtual address in a phys_addr_t here,
      as the only user of that variable converts it into a physical
      address anyway, so this moves the conversion to where it logically
      fits according to the types.
      
      Fixes: 95096f2f ("uio-hv-generic: new userspace i/o driver for VMBus")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      190cc65e
  14. 06 Dec, 2016 1 commit
  15. 29 Nov, 2016 1 commit
  16. 31 Aug, 2016 1 commit
  17. 01 May, 2016 1 commit
  18. 04 Oct, 2015 2 commits
    • Michal Hocko's avatar
      uio: fix false positive __might_sleep warning splat · edce5e6f
      Michal Hocko authored
      Andy has reported a __might_sleep warning
      [ 5174.883617] WARNING: CPU: 0 PID: 1532 at
      /home/agrover/git/kernel/kernel/sched/core.c:7389 __might_sleep+0x7d/0x90()
      [ 5174.884407] do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffffa02a5821>] uio_read+0x91/0x170 [uio]
      [ 5174.885198] Modules linked in: tcm_loop target_core_user uio target_core_pscsi target_core_file target_core_iblock iscsi_target_mod  target_core_mod uinput fuse nfsv3 nfs_acl nfs lockd grace fscache sunrpc microcode i2c_piix4 virtio_balloon i2c_core xfs libcrc32c crc32c_intel  virtio_net virtio_blk
      [ 5174.887351] CPU: 0 PID: 1532 Comm: tcmu-runner Not tainted 4.2.0-rc7+
      [ 5174.887853] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
      BIOS 1.8.1-20150318_183358- 04/01/2014
      [ 5174.888633]  ffffffff81a3b870 ffff880045393ca8 ffffffff817afaae
      0000000000000000
      [ 5174.889224]  ffff880045393cf8 ffff880045393ce8 ffffffff8109a846
      ffff880045393cd8
      [ 5174.889793]  ffffffffa02a7150 00000000000002dc 0000000000000000
      ffff880045008000
      [ 5174.890375] Call Trace:
      [ 5174.890562]  [<ffffffff817afaae>] dump_stack+0x4c/0x65
      [ 5174.890938]  [<ffffffff8109a846>] warn_slowpath_common+0x86/0xc0
      [ 5174.891388]  [<ffffffff8109a8c6>] warn_slowpath_fmt+0x46/0x50
      [ 5174.891808]  [<ffffffffa02a5821>] ? uio_read+0x91/0x170 [uio]
      [ 5174.892237]  [<ffffffffa02a5821>] ? uio_read+0x91/0x170 [uio]
      [ 5174.892653]  [<ffffffff810c584d>] __might_sleep+0x7d/0x90
      [ 5174.893055]  [<ffffffff811ea023>] __might_fault+0x43/0xa0
      [ 5174.893448]  [<ffffffff817b31ce>] ? schedule+0x3e/0x90
      [ 5174.893820]  [<ffffffffa02a58c2>] uio_read+0x132/0x170 [uio]
      [ 5174.894240]  [<ffffffff810cbb80>] ? wake_up_q+0x70/0x70
      [ 5174.894620]  [<ffffffff81236168>] __vfs_read+0x28/0xe0
      [ 5174.894993]  [<ffffffff81353233>] ? security_file_permission+0xa3/0xc0
      [ 5174.895541]  [<ffffffff8123678f>] ? rw_verify_area+0x4f/0xf0
      [ 5174.896006]  [<ffffffff812368ba>] vfs_read+0x8a/0x140
      [ 5174.896391]  [<ffffffff817b28f5>] ? __schedule+0x425/0xcc0
      [ 5174.896788]  [<ffffffff812375d9>] SyS_read+0x49/0xb0
      
      The warning is a false positive because uio_read doesn't depent on
      TASK_INTERRUPTIBLE after copy_to_user so it is safe to silence the
      warning by an explicit setting the state to TASK_RUNNING in the path
      which might call into TASK_RUNNING.
      Reported-by: default avatarAndy Grover <agrover@redhat.com>
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      edce5e6f
    • Luis de Bethencourt's avatar
      uio: uio_fsl_elbc_gpcm: Fix module autoload for OF platform driver · 0049ef9c
      Luis de Bethencourt authored
      This platform driver has a OF device ID table but the OF module
      alias information is not created so module autoloading won't work.
      Signed-off-by: default avatarLuis de Bethencourt <luis@debethencourt.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0049ef9c
  19. 05 Aug, 2015 3 commits
    • Geert Uytterhoeven's avatar
      uio: UIO_PRUSS should depend on HAS_DMA · 686079c9
      Geert Uytterhoeven authored
      If NO_DMA=y:
      
          ERROR: "dma_alloc_coherent" [drivers/uio/uio_pruss.ko] undefined!
          ERROR: "dma_free_coherent" [drivers/uio/uio_pruss.ko] undefined!
      
      Add a dependency on HAS_DMA to fix this.
      Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      686079c9
    • Vaishali Thakkar's avatar
      uio: uio_fsl_elbc_gpcm: Use module_platform_driver · d12f569c
      Vaishali Thakkar authored
      Use module_platform_driver for drivers whose init and exit functions
      only register and unregister, respectively.
      
      A simplified version of the Coccinelle semantic patch that performs
      this transformation is as follows:
      
      @a@
      identifier f, x;
      @@
      -static f(...) { return platform_driver_register(&x); }
      
      @b depends on a@
      identifier e, a.x;
      @@
      -static e(...) { platform_driver_unregister(&x); }
      
      @c depends on a && b@
      identifier a.f;
      declarer name module_init;
      @@
      -module_init(f);
      
      @d depends on a && b && c@
      identifier b.e, a.x;
      declarer name module_exit;
      declarer name module_platform_driver;
      @@
      -module_exit(e);
      +module_platform_driver(x);
      Signed-off-by: default avatarVaishali Thakkar <vthakkar1994@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d12f569c
    • Johannes Thumshirn's avatar
      uio: Destroy uio_idr on module exit · e2ef9393
      Johannes Thumshirn authored
      Destroy uio_idr on module exit, reclaiming the allocated memory.
      
      This was detected by the following semantic patch (written by Luis Rodriguez
      <mcgrof@suse.com>)
      <SmPL>
      @ defines_module_init @
      declarer name module_init, module_exit;
      declarer name DEFINE_IDR;
      identifier init;
      @@
      
      module_init(init);
      
      @ defines_module_exit @
      identifier exit;
      @@
      
      module_exit(exit);
      
      @ declares_idr depends on defines_module_init && defines_module_exit @
      identifier idr;
      @@
      
      DEFINE_IDR(idr);
      
      @ on_exit_calls_destroy depends on declares_idr && defines_module_exit @
      identifier declares_idr.idr, defines_module_exit.exit;
      @@
      
      exit(void)
      {
       ...
       idr_destroy(&idr);
       ...
      }
      
      @ missing_module_idr_destroy depends on declares_idr && defines_module_exit && !on_exit_calls_destroy @
      identifier declares_idr.idr, defines_module_exit.exit;
      @@
      
      exit(void)
      {
       ...
       +idr_destroy(&idr);
      }
      
      </SmPL>
      Signed-off-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2ef9393
  20. 13 Jun, 2015 3 commits
  21. 24 May, 2015 1 commit
  22. 03 Apr, 2015 1 commit
  23. 25 Mar, 2015 1 commit
  24. 20 Mar, 2015 1 commit
    • Brian Russell's avatar
      uio: Request/free irq separate from dev lifecycle · a087146c
      Brian Russell authored
      Separate irq request/free from the device lifecycle.
      After device unregister the parent module can call pci_disable_msi.
      >From the PCI MSI how to:
      
      "Before calling this function, a device driver must always call free_irq()
      on any interrupt for which it previously called request_irq().
      Failure to do so results in a BUG_ON(), leaving the device with
      MSI enabled and thus leaking its vector."
      
      So we need to separately free the irq at unregister to allow the device
      to be kept around in the case of it still having open FDs.
      Signed-off-by: default avatarBrian Russell <brussell@brocade.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a087146c
  25. 12 Jan, 2015 2 commits