1. 13 Nov, 2018 40 commits
    • Alexandre Belloni's avatar
      uio: ensure class is registered before devices · adfbc0d1
      Alexandre Belloni authored
      [ Upstream commit ae61cf5b ]
      
      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
    • Waiman Long's avatar
      driver/dma/ioat: Call del_timer_sync() without holding prep_lock · 24e24952
      Waiman Long authored
      [ Upstream commit cfb03be6 ]
      
      The following lockdep splat was observed:
      
      [ 1222.241750] ======================================================
      [ 1222.271301] WARNING: possible circular locking dependency detected
      [ 1222.301060] 4.16.0-10.el8+5.x86_64+debug #1 Not tainted
      [ 1222.326659] ------------------------------------------------------
      [ 1222.356565] systemd-shutdow/1 is trying to acquire lock:
      [ 1222.382660]  ((&ioat_chan->timer)){+.-.}, at: [<00000000f71e1a28>] del_timer_sync+0x5/0xf0
      [ 1222.422928]
      [ 1222.422928] but task is already holding lock:
      [ 1222.451743]  (&(&ioat_chan->prep_lock)->rlock){+.-.}, at: [<000000008ea98b12>] ioat_shutdown+0x86/0x100 [ioatdma]
         :
      [ 1223.524987] Chain exists of:
      [ 1223.524987]   (&ioat_chan->timer) --> &(&ioat_chan->cleanup_lock)->rlock --> &(&ioat_chan->prep_lock)->rlock
      [ 1223.524987]
      [ 1223.594082]  Possible unsafe locking scenario:
      [ 1223.594082]
      [ 1223.622630]        CPU0                    CPU1
      [ 1223.645080]        ----                    ----
      [ 1223.667404]   lock(&(&ioat_chan->prep_lock)->rlock);
      [ 1223.691535]                                lock(&(&ioat_chan->cleanup_lock)->rlock);
      [ 1223.728657]                                lock(&(&ioat_chan->prep_lock)->rlock);
      [ 1223.765122]   lock((&ioat_chan->timer));
      [ 1223.784095]
      [ 1223.784095]  *** DEADLOCK ***
      [ 1223.784095]
      [ 1223.813492] 4 locks held by systemd-shutdow/1:
      [ 1223.834677]  #0:  (reboot_mutex){+.+.}, at: [<0000000056d33456>] SYSC_reboot+0x10f/0x300
      [ 1223.873310]  #1:  (&dev->mutex){....}, at: [<00000000258dfdd7>] device_shutdown+0x1c8/0x660
      [ 1223.913604]  #2:  (&dev->mutex){....}, at: [<0000000068331147>] device_shutdown+0x1d6/0x660
      [ 1223.954000]  #3:  (&(&ioat_chan->prep_lock)->rlock){+.-.}, at: [<000000008ea98b12>] ioat_shutdown+0x86/0x100 [ioatdma]
      
      In the ioat_shutdown() function:
      
      	spin_lock_bh(&ioat_chan->prep_lock);
      	set_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
      	del_timer_sync(&ioat_chan->timer);
      	spin_unlock_bh(&ioat_chan->prep_lock);
      
      According to the synchronization rule for the del_timer_sync() function,
      the caller must not hold locks which would prevent completion of the
      timer's handler.
      
      The timer structure has its own lock that manages its synchronization.
      Setting the IOAT_CHAN_DOWN bit should prevent other CPUs from
      trying to use that device anyway, there is probably no need to call
      del_timer_sync() while holding the prep_lock. So the del_timer_sync()
      call is now moved outside of the prep_lock critical section to prevent
      the circular lock dependency.
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24e24952
    • Loic Poulain's avatar
      usb: chipidea: Prevent unbalanced IRQ disable · 7987dfa6
      Loic Poulain authored
      [ Upstream commit 8b97d73c ]
      
      The ChipIdea IRQ is disabled before scheduling the otg work and
      re-enabled on otg work completion. However if the job is already
      scheduled we have to undo the effect of disable_irq int order to
      balance the IRQ disable-depth value.
      
      Fixes: be6b0c1b ("usb: chipidea: using one inline function to cover queue work operations")
      Signed-off-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7987dfa6
    • Horia Geantă's avatar
      crypto: caam - fix implicit casts in endianness helpers · 6a4e231f
      Horia Geantă authored
      [ Upstream commit aae733a3 ]
      
      Fix the following sparse endianness warnings:
      
      drivers/crypto/caam/regs.h:95:1: sparse: incorrect type in return expression (different base types) @@    expected unsigned int @@    got restricted __le32unsigned int @@
      drivers/crypto/caam/regs.h:95:1:    expected unsigned int
      drivers/crypto/caam/regs.h:95:1:    got restricted __le32 [usertype] <noident>
      drivers/crypto/caam/regs.h:95:1: sparse: incorrect type in return expression (different base types) @@    expected unsigned int @@    got restricted __be32unsigned int @@
      drivers/crypto/caam/regs.h:95:1:    expected unsigned int
      drivers/crypto/caam/regs.h:95:1:    got restricted __be32 [usertype] <noident>
      
      drivers/crypto/caam/regs.h:92:1: sparse: cast to restricted __le32
      drivers/crypto/caam/regs.h:92:1: sparse: cast to restricted __be32
      
      Fixes: 261ea058 ("crypto: caam - handle core endianness != caam endianness")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a4e231f
    • Vignesh R's avatar
      PCI: dwc: pci-dra7xx: Enable errata i870 for both EP and RC mode · 00de8eac
      Vignesh R authored
      [ Upstream commit 726d75a6 ]
      
      Errata i870 is applicable in both EP and RC mode. Therefore rename
      function dra7xx_pcie_ep_unaligned_memaccess(), that implements errata
      workaround, to dra7xx_pcie_unaligned_memaccess() and call it for both RC
      and EP. Make sure driver probe does not fail in case the workaround is not
      applied for RC mode in order to maintain DT backward compatibility.
      Reported-by: default avatarChris Welch <Chris.Welch@viavisolutions.com>
      Signed-off-by: default avatarVignesh R <vigneshr@ti.com>
      [lorenzo.pieralisi@arm.com: reworded the log]
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00de8eac
    • Suzuki K Poulose's avatar
      coresight: etb10: Fix handling of perf mode · 0d20b616
      Suzuki K Poulose authored
      [ Upstream commit 987d1e8d ]
      
      If the ETB is already enabled in sysfs mode, the ETB reports
      success even if a perf mode is requested. Fix this by checking
      the requested mode.
      
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      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>
      0d20b616
    • Tonghao Zhang's avatar
      PCI/MSI: Warn and return error if driver enables MSI/MSI-X twice · 8cc76433
      Tonghao Zhang authored
      [ Upstream commit 4c1ef72e ]
      
      It is a serious driver defect to enable MSI or MSI-X more than once.  Doing
      so may panic the kernel as in the stack trace below:
      
        Call Trace:
          sysfs_add_one+0xa5/0xd0
          create_dir+0x7c/0xe0
          sysfs_create_subdir+0x1c/0x20
          internal_create_group+0x6d/0x290
          sysfs_create_groups+0x4a/0xa0
          populate_msi_sysfs+0x1cd/0x210
          pci_enable_msix+0x31c/0x3e0
          igbuio_pci_open+0x72/0x300 [igb_uio]
          uio_open+0xcc/0x120 [uio]
          chrdev_open+0xa1/0x1e0
          [...]
          do_sys_open+0xf3/0x1f0
          SyS_open+0x1e/0x20
          system_call_fastpath+0x16/0x1b
          ---[ end trace 11042e2848880209 ]---
          Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffffa056b4fa
      
      We want to keep the WARN_ON() and stack trace so the driver can be fixed,
      but we can avoid the kernel panic by returning an error.  We may still get
      warnings like this:
      
        Call Trace:
          pci_enable_msix+0x3c9/0x3e0
          igbuio_pci_open+0x72/0x300 [igb_uio]
          uio_open+0xcc/0x120 [uio]
          chrdev_open+0xa1/0x1e0
          [...]
          do_sys_open+0xf3/0x1f0
          SyS_open+0x1e/0x20
          system_call_fastpath+0x16/0x1b
          ------------[ cut here ]------------
          WARNING: at fs/sysfs/dir.c:526 sysfs_add_one+0xa5/0xd0()
          sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/0000:01:00.1/msi_irqs'
      Signed-off-by: default avatarTonghao Zhang <xiangxia.m.yue@gmail.com>
      [bhelgaas: changelog, fix patch whitespace, remove !!]
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8cc76433
    • Chao Yu's avatar
      f2fs: fix to recover inode's i_flags during POR · 34068ae1
      Chao Yu authored
      [ Upstream commit 19c73a69 ]
      
      Testcase to reproduce this bug:
      1. mkfs.f2fs /dev/sdd
      2. mount -t f2fs /dev/sdd /mnt/f2fs
      3. touch /mnt/f2fs/file
      4. sync
      5. chattr +A /mnt/f2fs/file
      6. xfs_io -f /mnt/f2fs/file -c "fsync"
      7. godown /mnt/f2fs
      8. umount /mnt/f2fs
      9. mount -t f2fs /dev/sdd /mnt/f2fs
      10. lsattr /mnt/f2fs/file
      
      -----------------N- /mnt/f2fs/file
      
      But actually, we expect the corrct result is:
      
      -------A---------N- /mnt/f2fs/file
      
      The reason is we didn't recover inode.i_flags field during mount,
      fix it.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34068ae1
    • Shaohua Li's avatar
      MD: fix invalid stored role for a disk · 442e2ba5
      Shaohua Li authored
      [ Upstream commit d595567d ]
      
      If we change the number of array's device after device is removed from array,
      then add the device back to array, we can see that device is added as active
      role instead of spare which we expected.
      
      Please see the below link for details:
      https://marc.info/?l=linux-raid&m=153736982015076&w=2
      
      This is caused by that we prefer to use device's previous role which is
      recorded by saved_raid_disk, but we should respect the new number of
      conf->raid_disks since it could be changed after device is removed.
      Reported-by: default avatarGioh Kim <gi-oh.kim@profitbricks.com>
      Tested-by: default avatarGioh Kim <gi-oh.kim@profitbricks.com>
      Acked-by: default avatarGuoqing Jiang <gqjiang@suse.com>
      Signed-off-by: default avatarShaohua Li <shli@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      442e2ba5
    • Theodore Ts'o's avatar
      ext4: fix argument checking in EXT4_IOC_MOVE_EXT · e75ca3ba
      Theodore Ts'o authored
      [ Upstream commit f18b2b83 ]
      
      If the starting block number of either the source or destination file
      exceeds the EOF, EXT4_IOC_MOVE_EXT should return EINVAL.
      
      Also fixed the helper function mext_check_coverage() so that if the
      logical block is beyond EOF, make it return immediately, instead of
      looping until the block number wraps all the away around.  This takes
      long enough that if there are multiple threads trying to do pound on
      an the same inode doing non-sensical things, it can end up triggering
      the kernel's soft lockup detector.
      
      Reported-by: syzbot+c61979f6f2cba5cb3c06@syzkaller.appspotmail.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e75ca3ba
    • Alexandre Belloni's avatar
      usb: gadget: udc: atmel: handle at91sam9rl PMC · 19216bf2
      Alexandre Belloni authored
      [ Upstream commit bb80e4fa ]
      
      The at91sam9rl PMC is not quite the same as the at91sam9g45 one and now has
      its own compatible string. Add support for that.
      
      Fixes: 217bace8e548 ("ARM: dts: fix PMC compatible")
      Acked-by: default avatarCristian Birsan <cristian.birsan@microchip.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      19216bf2
    • Mika Westerberg's avatar
      PCI / ACPI: Enable wake automatically for power managed bridges · e1057385
      Mika Westerberg authored
      [ Upstream commit 6299cf9e ]
      
      We enable power management automatically for bridges where
      pci_bridge_d3_possible() returns true. However, these bridges may have
      ACPI methods such as _DSW that need to be called before D3 entry. For
      example in Lenovo Thinkpad X1 Carbon 6th _DSW method is used to prepare
      D3cold for the PCIe root port hosting Thunderbolt chain. Because wake is
      not enabled _DSW method is never called and the port does not enter
      D3cold properly consuming more power than necessary.
      
      Users can work this around by writing "enabled" to "wakeup" sysfs file
      under the device in question but that is not something an ordinary user
      is expected to do.
      
      Since we already automatically enable power management for PCIe ports
      with ->bridge_d3 set extend that to enable wake for them as well,
      assuming the port has any ACPI wakeup related objects implemented in the
      namespace (adev->wakeup.flags.valid is true). This ensures the necessary
      ACPI methods get called at appropriate times and allows the root port in
      Thinkpad X1 Carbon 6th to go into D3cold.
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e1057385
    • Jorgen Hansen's avatar
      VMCI: Resource wildcard match fixed · a9ecbed1
      Jorgen Hansen authored
      [ Upstream commit 11924ba5 ]
      
      When adding a VMCI resource, the check for an existing entry
      would ignore that the new entry could be a wildcard. This could
      result in multiple resource entries that would match a given
      handle. One disastrous outcome of this is that the
      refcounting used to ensure that delayed callbacks for VMCI
      datagrams have run before the datagram is destroyed can be
      wrong, since the refcount could be increased on the duplicate
      entry. This in turn leads to a use after free bug. This issue
      was discovered by Hangbin Liu using KASAN and syzkaller.
      
      Fixes: bc63dedb ("VMCI: resource object implementation")
      Reported-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Reviewed-by: default avatarAdit Ranadive <aditr@vmware.com>
      Reviewed-by: default avatarVishnu Dasa <vdasa@vmware.com>
      Signed-off-by: default avatarJorgen Hansen <jhansen@vmware.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>
      a9ecbed1
    • Dexuan Cui's avatar
      Drivers: hv: vmbus: Use cpumask_var_t for on-stack cpu mask · 4f485085
      Dexuan Cui authored
      [ Upstream commit 25355252 ]
      
      A cpumask structure on the stack can cause a warning with
      CONFIG_NR_CPUS=8192 (e.g. Ubuntu 16.04 and 18.04 use this):
      
      drivers/hv//channel_mgmt.c: In function ‘init_vp_index’:
      drivers/hv//channel_mgmt.c:702:1: warning: the frame size of 1032 bytes
        is larger than 1024 bytes [-Wframe-larger-than=]
      
      Nowadays it looks most distros enable CONFIG_CPUMASK_OFFSTACK=y, and
      hence we can work around the warning by using cpumask_var_t.
      Signed-off-by: default avatarDexuan Cui <decui@microsoft.com>
      Cc: K. Y. Srinivasan <kys@microsoft.com>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.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>
      4f485085
    • Javier Martinez Canillas's avatar
      tpm: suppress transmit cmd error logs when TPM 1.2 is disabled/deactivated · 6057caad
      Javier Martinez Canillas authored
      [ Upstream commit 0d6d0d62 ]
      
      For TPM 1.2 chips the system setup utility allows to set the TPM device in
      one of the following states:
      
        * Active: Security chip is functional
        * Inactive: Security chip is visible, but is not functional
        * Disabled: Security chip is hidden and is not functional
      
      When choosing the "Inactive" state, the TPM 1.2 device is enumerated and
      registered, but sending TPM commands fail with either TPM_DEACTIVATED or
      TPM_DISABLED depending if the firmware deactivated or disabled the TPM.
      
      Since these TPM 1.2 error codes don't have special treatment, inactivating
      the TPM leads to a very noisy kernel log buffer that shows messages like
      the following:
      
        tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78)
        tpm tpm0: A TPM error (6) occurred attempting to read a pcr value
        tpm tpm0: TPM is disabled/deactivated (0x6)
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting to read a pcr value
        ima: No TPM chip found, activating TPM-bypass! (rc=6)
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting get random
      
      Let's just suppress error log messages for the TPM_{DEACTIVATED,DISABLED}
      return codes, since this is expected when the TPM 1.2 is set to Inactive.
      
      In that case the kernel log is cleaner and less confusing for users, i.e:
      
        tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78)
        tpm tpm0: TPM is disabled/deactivated (0x6)
        ima: No TPM chip found, activating TPM-bypass! (rc=6)
      Reported-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6057caad
    • Honghui Zhang's avatar
      PCI: mediatek: Fix mtk_pcie_find_port() endpoint/port matching logic · 38ee346a
      Honghui Zhang authored
      [ Upstream commit 074d6f32 ]
      
      The Mediatek's host controller has two slots, each with its own control
      registers. The host driver needs to identify what slot is connected to
      what port in order to access the device's configuration space.
      
      Current code retrieving slot connected to a given endpoint device.
      
      Assuming each slot is connected to one endpoint device as below:
      
                      host bridge
        bus 0 --> __________|_______
                 |                  |
                 |                  |
               slot 0             slot 1
        bus 1 -->|        bus 2 --> |
                 |                  |
               EP 0               EP 1
      
      During PCI enumeration, system software will scan all the PCI devices on
      every bus starting from devfn 0. Using PCI_SLOT(devfn) for matching an
      endpoint to its slot is erroneous in that the devfn does not contain the
      hierarchical bus numbering in it. In order to match an endpoint with its
      slot (and related port), the PCI tree must be walked up to the root bus
      (where the root ports are situated) and then the PCI_SLOT(devfn)
      matching logic can be correctly applied for matching.
      
      This patch fixes the mtk_pcie_find_port() slot matching logic by adding
      appropriate PCI tree walking code to retrieve the slot/port a given
      endpoint is connected to.
      Signed-off-by: default avatarHonghui Zhang <honghui.zhang@mediatek.com>
      [lorenzo.pieralisi@arm.com: rewrote the commit log]
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: default avatarRyder Lee <ryder.lee@mediatek.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      38ee346a
    • Tudor.Ambarus@microchip.com's avatar
      usb: host: ohci-at91: fix request of irq for optional gpio · 07335466
      Tudor.Ambarus@microchip.com authored
      [ Upstream commit 325b9313 ]
      
      atmel,oc-gpio is optional. Request its irq only when atmel,oc is set
      in device tree.
      
      devm_gpiod_get_index_optional returns NULL if -ENOENT. Check its
      return value for NULL before error, because it is more probable that
      atmel,oc is not set.
      
      This fixes the following errors on boards where atmel,oc is not set in
      device tree:
      [    0.960000] at91_ohci 500000.ohci: failed to request gpio "overcurrent" IRQ
      [    0.960000] at91_ohci 500000.ohci: failed to request gpio "overcurrent" IRQ
      [    0.970000] at91_ohci 500000.ohci: failed to request gpio "overcurrent" IRQ
      Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@microchip.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.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>
      07335466
    • Selvin Xavier's avatar
      RDMA/bnxt_re: Fix recursive lock warning in debug kernel · 88018bc0
      Selvin Xavier authored
      [ Upstream commit d455f29f ]
      
      Fix possible recursive lock warning. Its a false warning as the locks are
      part of two differnt HW Queue data structure - cmdq and creq. Debug kernel
      is throwing the following warning and stack trace.
      
      [  783.914967] ============================================
      [  783.914970] WARNING: possible recursive locking detected
      [  783.914973] 4.19.0-rc2+ #33 Not tainted
      [  783.914976] --------------------------------------------
      [  783.914979] swapper/2/0 is trying to acquire lock:
      [  783.914982] 000000002aa3949d (&(&hwq->lock)->rlock){..-.}, at: bnxt_qplib_service_creq+0x232/0x350 [bnxt_re]
      [  783.914999]
      but task is already holding lock:
      [  783.915002] 00000000be73920d (&(&hwq->lock)->rlock){..-.}, at: bnxt_qplib_service_creq+0x2a/0x350 [bnxt_re]
      [  783.915013]
      other info that might help us debug this:
      [  783.915016]  Possible unsafe locking scenario:
      
      [  783.915019]        CPU0
      [  783.915021]        ----
      [  783.915034]   lock(&(&hwq->lock)->rlock);
      [  783.915035]   lock(&(&hwq->lock)->rlock);
      [  783.915037]
       *** DEADLOCK ***
      
      [  783.915038]  May be due to missing lock nesting notation
      
      [  783.915039] 1 lock held by swapper/2/0:
      [  783.915040]  #0: 00000000be73920d (&(&hwq->lock)->rlock){..-.}, at: bnxt_qplib_service_creq+0x2a/0x350 [bnxt_re]
      [  783.915044]
      stack backtrace:
      [  783.915046] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.19.0-rc2+ #33
      [  783.915047] Hardware name: Dell Inc. PowerEdge R730/0599V5, BIOS 1.0.4 08/28/2014
      [  783.915048] Call Trace:
      [  783.915049]  <IRQ>
      [  783.915054]  dump_stack+0x90/0xe3
      [  783.915058]  __lock_acquire+0x106c/0x1080
      [  783.915061]  ? sched_clock+0x5/0x10
      [  783.915063]  lock_acquire+0xbd/0x1a0
      [  783.915065]  ? bnxt_qplib_service_creq+0x232/0x350 [bnxt_re]
      [  783.915069]  _raw_spin_lock_irqsave+0x4a/0x90
      [  783.915071]  ? bnxt_qplib_service_creq+0x232/0x350 [bnxt_re]
      [  783.915073]  bnxt_qplib_service_creq+0x232/0x350 [bnxt_re]
      [  783.915078]  tasklet_action_common.isra.17+0x197/0x1b0
      [  783.915081]  __do_softirq+0xcb/0x3a6
      [  783.915084]  irq_exit+0xe9/0x100
      [  783.915085]  do_IRQ+0x6a/0x120
      [  783.915087]  common_interrupt+0xf/0xf
      [  783.915088]  </IRQ>
      
      Use nested notation for the spin_lock to avoid this warning.
      Signed-off-by: default avatarSelvin Xavier <selvin.xavier@broadcom.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      88018bc0
    • Denis Drozdov's avatar
      IB/ipoib: Clear IPCB before icmp_send · b0203472
      Denis Drozdov authored
      [ Upstream commit 4d6e4d12 ]
      
      IPCB should be cleared before icmp_send, since it may contain data from
      previous layers and the data could be misinterpreted as ip header options,
      which later caused the ihl to be set to an invalid value and resulted in
      the following stack corruption:
      
      [ 1083.031512] ib0: packet len 57824 (> 2048) too long to send, dropping
      [ 1083.031843] ib0: packet len 37904 (> 2048) too long to send, dropping
      [ 1083.032004] ib0: packet len 4040 (> 2048) too long to send, dropping
      [ 1083.032253] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.032481] ib0: packet len 23960 (> 2048) too long to send, dropping
      [ 1083.033149] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.033439] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.033700] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.034124] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.034387] ==================================================================
      [ 1083.034602] BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0xf08/0x1310
      [ 1083.034798] Write of size 4 at addr ffff880353457c5f by task kworker/u16:0/7
      [ 1083.034990]
      [ 1083.035104] CPU: 7 PID: 7 Comm: kworker/u16:0 Tainted: G           O      4.19.0-rc5+ #1
      [ 1083.035316] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
      [ 1083.035573] Workqueue: ipoib_wq ipoib_cm_skb_reap [ib_ipoib]
      [ 1083.035750] Call Trace:
      [ 1083.035888]  dump_stack+0x9a/0xeb
      [ 1083.036031]  print_address_description+0xe3/0x2e0
      [ 1083.036213]  kasan_report+0x18a/0x2e0
      [ 1083.036356]  ? __ip_options_echo+0xf08/0x1310
      [ 1083.036522]  __ip_options_echo+0xf08/0x1310
      [ 1083.036688]  icmp_send+0x7b9/0x1cd0
      [ 1083.036843]  ? icmp_route_lookup.constprop.9+0x1070/0x1070
      [ 1083.037018]  ? netif_schedule_queue+0x5/0x200
      [ 1083.037180]  ? debug_show_all_locks+0x310/0x310
      [ 1083.037341]  ? rcu_dynticks_curr_cpu_in_eqs+0x85/0x120
      [ 1083.037519]  ? debug_locks_off+0x11/0x80
      [ 1083.037673]  ? debug_check_no_obj_freed+0x207/0x4c6
      [ 1083.037841]  ? check_flags.part.27+0x450/0x450
      [ 1083.037995]  ? debug_check_no_obj_freed+0xc3/0x4c6
      [ 1083.038169]  ? debug_locks_off+0x11/0x80
      [ 1083.038318]  ? skb_dequeue+0x10e/0x1a0
      [ 1083.038476]  ? ipoib_cm_skb_reap+0x2b5/0x650 [ib_ipoib]
      [ 1083.038642]  ? netif_schedule_queue+0xa8/0x200
      [ 1083.038820]  ? ipoib_cm_skb_reap+0x544/0x650 [ib_ipoib]
      [ 1083.038996]  ipoib_cm_skb_reap+0x544/0x650 [ib_ipoib]
      [ 1083.039174]  process_one_work+0x912/0x1830
      [ 1083.039336]  ? wq_pool_ids_show+0x310/0x310
      [ 1083.039491]  ? lock_acquire+0x145/0x3a0
      [ 1083.042312]  worker_thread+0x87/0xbb0
      [ 1083.045099]  ? process_one_work+0x1830/0x1830
      [ 1083.047865]  kthread+0x322/0x3e0
      [ 1083.050624]  ? kthread_create_worker_on_cpu+0xc0/0xc0
      [ 1083.053354]  ret_from_fork+0x3a/0x50
      
      For instance __ip_options_echo is failing to proceed with invalid srr and
      optlen passed from another layer via IPCB
      
      [  762.139568] IPv4: __ip_options_echo rr=0 ts=0 srr=43 cipso=0
      [  762.139720] IPv4: ip_options_build: IPCB 00000000f3cd969e opt 000000002ccb3533
      [  762.139838] IPv4: __ip_options_echo in srr: optlen 197 soffset 84
      [  762.139852] IPv4: ip_options_build srr=0 is_frag=0 rr_needaddr=0 ts_needaddr=0 ts_needtime=0 rr=0 ts=0
      [  762.140269] ==================================================================
      [  762.140713] IPv4: __ip_options_echo rr=0 ts=0 srr=0 cipso=0
      [  762.141078] BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0x12ec/0x1680
      [  762.141087] Write of size 4 at addr ffff880353457c7f by task kworker/u16:0/7
      Signed-off-by: default avatarDenis Drozdov <denisd@mellanox.com>
      Reviewed-by: default avatarErez Shitrit <erezsh@mellanox.com>
      Reviewed-by: default avatarFeras Daoud <ferasda@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b0203472
    • Parav Pandit's avatar
      RDMA/core: Do not expose unsupported counters · 670ebdf0
      Parav Pandit authored
      [ Upstream commit 0f6ef65d ]
      
      If the provider driver (such as rdma_rxe) doesn't support pma counters,
      avoid exposing its directory similar to optional hw_counters directory.
      If core fails to read the PMA counter, return an error so that user can
      retry later if needed.
      
      Fixes: 35c4cbb1 ("IB/core: Create get_perf_mad function in sysfs.c")
      Reported-by: default avatarHolger Hoffstätte <holger@applied-asynchrony.com>
      Tested-by: default avatarHolger Hoffstätte <holger@applied-asynchrony.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      670ebdf0
    • Wenwen Wang's avatar
      scsi: megaraid_sas: fix a missing-check bug · 4877db2e
      Wenwen Wang authored
      [ Upstream commit 47db7873 ]
      
      In megasas_mgmt_compat_ioctl_fw(), to handle the structure
      compat_megasas_iocpacket 'cioc', a user-space structure megasas_iocpacket
      'ioc' is allocated before megasas_mgmt_ioctl_fw() is invoked to handle
      the packet. Since the two data structures have different fields, the data
      is copied from 'cioc' to 'ioc' field by field. In the copy process,
      'sense_ptr' is prepared if the field 'sense_len' is not null, because it
      will be used in megasas_mgmt_ioctl_fw(). To prepare 'sense_ptr', the
      user-space data 'ioc->sense_off' and 'cioc->sense_off' are copied and
      saved to kernel-space variables 'local_sense_off' and 'user_sense_off'
      respectively. Given that 'ioc->sense_off' is also copied from
      'cioc->sense_off', 'local_sense_off' and 'user_sense_off' should have the
      same value. However, 'cioc' is in the user space and a malicious user can
      race to change the value of 'cioc->sense_off' after it is copied to
      'ioc->sense_off' but before it is copied to 'user_sense_off'. By doing
      so, the attacker can inject different values into 'local_sense_off' and
      'user_sense_off'. This can cause undefined behavior in the following
      execution, because the two variables are supposed to be same.
      
      This patch enforces a check on the two kernel variables 'local_sense_off'
      and 'user_sense_off' to make sure they are the same after the copy. In
      case they are not, an error code EINVAL will be returned.
      Signed-off-by: default avatarWenwen Wang <wang6495@umn.edu>
      Acked-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4877db2e
    • Jim Mattson's avatar
      KVM: nVMX: Clear reserved bits of #DB exit qualification · 7d6c6f83
      Jim Mattson authored
      [ Upstream commit cfb634fe ]
      
      According to volume 3 of the SDM, bits 63:15 and 12:4 of the exit
      qualification field for debug exceptions are reserved (cleared to
      0). However, the SDM is incorrect about bit 16 (corresponding to
      DR6.RTM). This bit should be set if a debug exception (#DB) or a
      breakpoint exception (#BP) occurred inside an RTM region while
      advanced debugging of RTM transactional regions was enabled. Note that
      this is the opposite of DR6.RTM, which "indicates (when clear) that a
      debug exception (#DB) or breakpoint exception (#BP) occurred inside an
      RTM region while advanced debugging of RTM transactional regions was
      enabled."
      
      There is still an issue with stale DR6 bits potentially being
      misreported for the current debug exception.  DR6 should not have been
      modified before vectoring the #DB exception, and the "new DR6 bits"
      should be available somewhere, but it was and they aren't.
      
      Fixes: b96fb439 ("KVM: nVMX: fixes to nested virt interrupt injection")
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d6c6f83
    • David Howells's avatar
      UAPI: ndctl: Fix g++-unsupported initialisation in headers · be5658a1
      David Howells authored
      [ Upstream commit 9607871f ]
      
      The following code in the linux/ndctl header file:
      
      	static inline const char *nvdimm_bus_cmd_name(unsigned cmd)
      	{
      		static const char * const names[] = {
      			[ND_CMD_ARS_CAP] = "ars_cap",
      			[ND_CMD_ARS_START] = "ars_start",
      			[ND_CMD_ARS_STATUS] = "ars_status",
      			[ND_CMD_CLEAR_ERROR] = "clear_error",
      			[ND_CMD_CALL] = "cmd_call",
      		};
      
      		if (cmd < ARRAY_SIZE(names) && names[cmd])
      			return names[cmd];
      		return "unknown";
      	}
      
      is broken in a number of ways:
      
       (1) ARRAY_SIZE() is not generally defined.
      
       (2) g++ does not support "non-trivial" array initialisers fully yet.
      
       (3) Every file that calls this function will acquire a copy of names[].
      
      The same goes for nvdimm_cmd_name().
      
      Fix all three by converting to a switch statement where each case returns a
      string.  That way if cmd is a constant, the compiler can trivially reduce it
      and, if not, the compiler can use a shared lookup table if it thinks that is
      more efficient.
      
      A better way would be to remove these functions and their arrays from the
      header entirely.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be5658a1
    • Finn Thain's avatar
      scsi: esp_scsi: Track residual for PIO transfers · 94dc21c6
      Finn Thain authored
      [ Upstream commit fd47d919 ]
      
      If a target disconnects during a PIO data transfer the command may fail
      when the target reconnects:
      
      scsi host1: DMA length is zero!
      scsi host1: cur adr[04380000] len[00000000]
      
      The scsi bus is then reset. This happens because the residual reached
      zero before the transfer was completed.
      
      The usual residual calculation relies on the Transfer Count registers.
      That works for DMA transfers but not for PIO transfers. Fix the problem
      by storing the PIO transfer residual and using that to correctly
      calculate bytes_sent.
      
      Fixes: 6fe07aaf ("[SCSI] m68k: new mac_esp scsi driver")
      Tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94dc21c6
    • Michal Hocko's avatar
      cgroup, netclassid: add a preemption point to write_classid · 09d43edc
      Michal Hocko authored
      [ Upstream commit a90e90b7 ]
      
      We have seen a customer complaining about soft lockups on !PREEMPT
      kernel config with 4.4 based kernel
      
      [1072141.435366] NMI watchdog: BUG: soft lockup - CPU#21 stuck for 22s! [systemd:1]
      [1072141.444090] Modules linked in: mpt3sas raid_class binfmt_misc af_packet 8021q garp mrp stp llc xfs libcrc32c bonding iscsi_ibft iscsi_boot_sysfs msr ext4 crc16 jbd2 mbcache cdc_ether usbnet mii joydev hid_generic usbhid intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel ipmi_ssif mgag200 i2c_algo_bit ttm ipmi_devintf drbg ixgbe drm_kms_helper vxlan ansi_cprng ip6_udp_tunnel drm aesni_intel udp_tunnel aes_x86_64 iTCO_wdt syscopyarea ptp xhci_pci lrw iTCO_vendor_support pps_core gf128mul ehci_pci glue_helper sysfillrect mdio pcspkr sb_edac ablk_helper cryptd ehci_hcd sysimgblt xhci_hcd fb_sys_fops edac_core mei_me lpc_ich ses usbcore enclosure dca mfd_core ipmi_si mei i2c_i801 scsi_transport_sas usb_common ipmi_msghandler shpchp fjes wmi processor button acpi_pad btrfs xor raid6_pq sd_mod crc32c_intel megaraid_sas sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod md_mod autofs4
      [1072141.444146] Supported: Yes
      [1072141.444149] CPU: 21 PID: 1 Comm: systemd Not tainted 4.4.121-92.80-default #1
      [1072141.444150] Hardware name: LENOVO Lenovo System x3650 M5 -[5462P4U]- -[5462P4U]-/01GR451, BIOS -[TCE136H-2.70]- 06/13/2018
      [1072141.444151] task: ffff880191bd0040 ti: ffff880191bd4000 task.ti: ffff880191bd4000
      [1072141.444153] RIP: 0010:[<ffffffff815229f9>]  [<ffffffff815229f9>] update_classid_sock+0x29/0x40
      [1072141.444157] RSP: 0018:ffff880191bd7d58  EFLAGS: 00000286
      [1072141.444158] RAX: ffff883b177cb7c0 RBX: 0000000000000000 RCX: 0000000000000000
      [1072141.444159] RDX: 00000000000009c7 RSI: ffff880191bd7d5c RDI: ffff8822e29bb200
      [1072141.444160] RBP: ffff883a72230980 R08: 0000000000000101 R09: 0000000000000000
      [1072141.444161] R10: 0000000000000008 R11: f000000000000000 R12: ffffffff815229d0
      [1072141.444162] R13: 0000000000000000 R14: ffff881fd0a47ac0 R15: ffff880191bd7f28
      [1072141.444163] FS:  00007f3e2f1eb8c0(0000) GS:ffff882000340000(0000) knlGS:0000000000000000
      [1072141.444164] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [1072141.444165] CR2: 00007f3e2f200000 CR3: 0000001ffea4e000 CR4: 00000000001606f0
      [1072141.444166] Stack:
      [1072141.444166]  ffffffa800000246 00000000000009c7 ffffffff8121d583 ffff8818312a05c0
      [1072141.444168]  ffff8818312a1100 ffff880197c3b280 ffff881861422858 ffffffffffffffea
      [1072141.444170]  ffffffff81522b1c ffffffff81d0ca20 ffff8817fa17b950 ffff883fdd8121e0
      [1072141.444171] Call Trace:
      [1072141.444179]  [<ffffffff8121d583>] iterate_fd+0x53/0x80
      [1072141.444182]  [<ffffffff81522b1c>] write_classid+0x4c/0x80
      [1072141.444187]  [<ffffffff8111328b>] cgroup_file_write+0x9b/0x100
      [1072141.444193]  [<ffffffff81278bcb>] kernfs_fop_write+0x11b/0x150
      [1072141.444198]  [<ffffffff81201566>] __vfs_write+0x26/0x100
      [1072141.444201]  [<ffffffff81201bed>] vfs_write+0x9d/0x190
      [1072141.444203]  [<ffffffff812028c2>] SyS_write+0x42/0xa0
      [1072141.444207]  [<ffffffff815f58c3>] entry_SYSCALL_64_fastpath+0x1e/0xca
      [1072141.445490] DWARF2 unwinder stuck at entry_SYSCALL_64_fastpath+0x1e/0xca
      
      If a cgroup has many tasks with many open file descriptors then we would
      end up in a large loop without any rescheduling point throught the
      operation. Add cond_resched once per task.
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09d43edc
    • Geert Uytterhoeven's avatar
      thermal: da9062/61: Prevent hardware access during system suspend · 0a76f5c5
      Geert Uytterhoeven authored
      [ Upstream commit 760eea43 ]
      
      The workqueue used for monitoring the hardware may run while the device
      is already suspended.  Fix this by using the freezable system workqueue
      instead, cfr. commit 51e20d0e ("thermal: Prevent polling from
      happening during system suspend").
      
      Fixes: 608567aa ("thermal: da9062/61: Thermal junction temperature monitoring driver")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarSteve Twiss <stwiss.opensource@diasemi.com>
      Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a76f5c5
    • Martin Willi's avatar
      ath10k: schedule hardware restart if WMI command times out · ef5d27e1
      Martin Willi authored
      [ Upstream commit a9911937 ]
      
      When running in AP mode, ath10k sometimes suffers from TX credit
      starvation. The issue is hard to reproduce and shows up once in a
      few days, but has been repeatedly seen with QCA9882 and a large
      range of firmwares, including 10.2.4.70.67.
      
      Once the module is in this state, TX credits are never replenished,
      which results in "SWBA overrun" errors, as no beacons can be sent.
      Even worse, WMI commands run in a timeout while holding the conf
      mutex for three seconds each, making any further operations slow
      and the whole system unresponsive.
      
      The firmware/driver never recovers from that state automatically,
      and triggering TX flush or warm restarts won't work over WMI. So
      issue a hardware restart if a WMI command times out due to missing
      TX credits. This implies a connectivity outage of about 1.4s in AP
      mode, but brings back the interface and the whole system to a usable
      state. WMI command timeouts have not been seen in absent of this
      specific issue, so taking such drastic actions seems legitimate.
      Signed-off-by: default avatarMartin Willi <martin@strongswan.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef5d27e1
    • Sebastian Basierski's avatar
      ixgbevf: VF2VF TCP RSS · ca18ed44
      Sebastian Basierski authored
      [ Upstream commit 7fb94bd5 ]
      
      While VF2VF with RSS communication, RSS Type were wrongly recognized
      and RSS hash was not calculated as it should be. Packets was
      distributed on various queues by accident.
      This commit fixes that behaviour and causes proper RSS Type recognition.
      Signed-off-by: default avatarSebastian Basierski <sebastianx.basierski@intel.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca18ed44
    • Sara Sharon's avatar
      iwlwifi: mvm: fix BAR seq ctrl reporting · 8692ff19
      Sara Sharon authored
      [ Upstream commit 941ab4eb ]
      
      There is a bug in FW where the sequence control may be
      incorrect, and the driver overrides it with the value
      of the ieee80211 header.
      
      However, in BAR there is no sequence control in the header,
      which result with arbitrary sequence.
      
      This access to an unknown location is bad and it makes the
      logs very confusing - so fix it.
      Signed-off-by: default avatarSara Sharon <sara.sharon@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8692ff19
    • Andrew Lunn's avatar
      net: dsa: mv88e6xxx: Fix writing to a PHY page. · 189f9829
      Andrew Lunn authored
      [ Upstream commit c309b158 ]
      
      After changing to the needed page, actually write the value to the
      register!
      
      Fixes: 09cb7dfd ("net: dsa: mv88e6xxx: describe PHY page and SerDes")
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      189f9829
    • Douglas Anderson's avatar
      pinctrl: ssbi-gpio: Fix pm8xxx_pin_config_get() to be compliant · b7111ec0
      Douglas Anderson authored
      [ Upstream commit b432414b ]
      
      If you look at "pinconf-groups" in debugfs for ssbi-gpio you'll notice
      it looks like nonsense.
      
      The problem is fairly well described in commit 1cf86bc2 ("pinctrl:
      qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant") and
      commit 05e0c828 ("pinctrl: msm: Fix msm_config_group_get() to be
      compliant"), but it was pointed out that ssbi-gpio has the same
      problem.  Let's fix it there too.
      
      Fixes: b4c45fe9 ("pinctrl: qcom: ssbi: Family A gpio & mpp drivers")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7111ec0
    • Douglas Anderson's avatar
      pinctrl: spmi-mpp: Fix pmic_mpp_config_get() to be compliant · 49d44c0a
      Douglas Anderson authored
      [ Upstream commit 0d5b476f ]
      
      If you look at "pinconf-groups" in debugfs for ssbi-mpp you'll notice
      it looks like nonsense.
      
      The problem is fairly well described in commit 1cf86bc2 ("pinctrl:
      qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant") and
      commit 05e0c828 ("pinctrl: msm: Fix msm_config_group_get() to be
      compliant"), but it was pointed out that ssbi-mpp has the same
      problem.  Let's fix it there too.
      
      NOTE: in case it's helpful to someone reading this, the way to tell
      whether to do the -EINVAL or not is to look at the PCONFDUMP for a
      given attribute.  If the last element (has_arg) is false then you need
      to do the -EINVAL trick.
      
      ALSO NOTE: it seems unlikely that the values returned when we try to
      get PIN_CONFIG_BIAS_PULL_UP will actually be printed since "has_arg"
      is false for that one, but I guess it's still fine to return different
      values so I kept doing that.  It seems like another driver (ssbi-gpio)
      uses a custom attribute (PM8XXX_QCOM_PULL_UP_STRENGTH) for something
      similar so maybe a future change should do that here too.
      
      Fixes: cfb24f6e ("pinctrl: Qualcomm SPMI PMIC MPP pin controller driver")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarStephen Boyd <sboyd@kernel.org>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49d44c0a
    • Stephen Boyd's avatar
      pinctrl: qcom: spmi-mpp: Fix drive strength setting · 6b196dd5
      Stephen Boyd authored
      [ Upstream commit 89c68b10 ]
      
      It looks like we parse the drive strength setting here, but never
      actually write it into the hardware to update it. Parse the setting and
      then write it at the end of the pinconf setting function so that it
      actually sticks in the hardware.
      
      Fixes: 0e948042 ("pinctrl: qcom: spmi-mpp: Implement support for sink mode")
      Cc: Doug Anderson <dianders@chromium.org>
      Signed-off-by: default avatarStephen Boyd <swboyd@chromium.org>
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b196dd5
    • Hans de Goede's avatar
      ACPI / LPSS: Add alternative ACPI HIDs for Cherry Trail DMA controllers · 2a9dc99f
      Hans de Goede authored
      [ Upstream commit 24071406 ]
      
      Bay and Cherry Trail DSTDs represent a different set of devices depending
      on which OS the device think it is booting. One set of decices for Windows
      and another set of devices for Android which targets the Android-x86 Linux
      kernel fork (which e.g. used to have its own display driver instead of
      using the i915 driver).
      
      Which set of devices we are actually going to get is out of our control,
      this is controlled by the ACPI OSID variable, which gets either set through
      an EFI setup option, or sometimes is autodetected. So we need to support
      both.
      
      This commit adds support for the 80862286 and 808622C0 ACPI HIDs which we
      get for the first resp. second DMA controller on Cherry Trail devices when
      OSID is set to Android.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a9dc99f
    • Masami Hiramatsu's avatar
      kprobes: Return error if we fail to reuse kprobe instead of BUG_ON() · 0e0b860f
      Masami Hiramatsu authored
      [ Upstream commit 819319fc ]
      
      Make reuse_unused_kprobe() to return error code if
      it fails to reuse unused kprobe for optprobe instead
      of calling BUG_ON().
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: David S . Miller <davem@davemloft.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Naveen N . Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/153666124040.21306.14150398706331307654.stgit@devboxSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e0b860f
    • Paolo Valente's avatar
      block, bfq: correctly charge and reset entity service in all cases · d4d73f1f
      Paolo Valente authored
      [ Upstream commit cbeb869a ]
      
      BFQ schedules entities (which represent either per-process queues or
      groups of queues) as a function of their timestamps. In particular, as
      a function of their (virtual) finish times. The finish time of an
      entity is computed as a function of the budget assigned to the entity,
      assuming, tentatively, that the entity, once in service, will receive
      an amount of service equal to its budget. Then, when the entity is
      expired because it finishes to be served, this finish time is updated
      as a function of the actual service received by the entity. This
      allows the entity to be correctly charged with only the service
      received, and then to be correctly re-scheduled.
      
      Yet an entity may receive service also while not being the entity in
      service (in the scheduling environment of its parent entity), for
      several reasons. If the entity remains with no backlog while receiving
      this 'unofficial' service, then it is expired. Also on such an
      expiration, the finish time of the entity should be updated to account
      for only the service actually received by the entity. Unfortunately,
      such an update is not performed for an entity expiring without being
      the entity in service.
      
      In a similar vein, the service counter of the entity in service is
      reset when the entity is expired, to be ready to be used for next
      service cycle. This reset too should be performed also in case an
      entity is expired because it remains empty after receiving service
      while not being the entity in service. But in this case the reset is
      not performed.
      
      This commit performs the above update of the finish time and reset of
      the service received, also for an entity expiring while not being the
      entity in service.
      Signed-off-by: default avatarPaolo Valente <paolo.valente@linaro.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4d73f1f
    • Antoine Tenart's avatar
      net: phy: phylink: ensure the carrier is off when starting phylink · 4c2f34ab
      Antoine Tenart authored
      [ Upstream commit aeeb2e8f ]
      
      Phylink made an assumption about the carrier state being down when
      calling phylink_start(). If this assumption isn't satisfied, the
      internal phylink state could misbehave and a net device could end up not
      being functional.
      
      This patch fixes this by explicitly calling netif_carrier_off() in
      phylink_start().
      Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
      Acked-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c2f34ab
    • Arend van Spriel's avatar
      brcmfmac: fix for proper support of 160MHz bandwidth · 4484de12
      Arend van Spriel authored
      [ Upstream commit 330994e8 ]
      
      Decoding of firmware channel information was not complete for 160MHz
      support. This resulted in the following warning:
      
        WARNING: CPU: 2 PID: 2222 at .../broadcom/brcm80211/brcmutil/d11.c:196
      	brcmu_d11ac_decchspec+0x2e/0x100 [brcmutil]
        Modules linked in: brcmfmac(O) brcmutil(O) sha256_generic cfg80211 ...
        CPU: 2 PID: 2222 Comm: kworker/2:0 Tainted: G           O
        4.17.0-wt-testing-x64-00002-gf1bed50 #1
        Hardware name: Dell Inc. Latitude E6410/07XJP9, BIOS A07 02/15/2011
        Workqueue: events request_firmware_work_func
        RIP: 0010:brcmu_d11ac_decchspec+0x2e/0x100 [brcmutil]
        RSP: 0018:ffffc90000047bd0 EFLAGS: 00010206
        RAX: 000000000000e832 RBX: ffff8801146fe910 RCX: ffff8801146fd3c0
        RDX: 0000000000002800 RSI: 0000000000000070 RDI: ffffc90000047c30
        RBP: ffffc90000047bd0 R08: 0000000000000000 R09: ffffffffa0798c80
        R10: ffff88012bca55e0 R11: ffff880110a4ea00 R12: ffff8801146f8000
        R13: ffffc90000047c30 R14: ffff8801146fe930 R15: ffff8801138e02e0
        FS:  0000000000000000(0000) GS:ffff88012bc80000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f18ce8b8070 CR3: 000000000200a003 CR4: 00000000000206e0
        Call Trace:
         brcmf_setup_wiphybands+0x212/0x780 [brcmfmac]
         brcmf_cfg80211_attach+0xae2/0x11a0 [brcmfmac]
         brcmf_attach+0x1fc/0x4b0 [brcmfmac]
         ? __kmalloc+0x13c/0x1c0
         brcmf_pcie_setup+0x99b/0xe00 [brcmfmac]
         brcmf_fw_request_done+0x16a/0x1f0 [brcmfmac]
         request_firmware_work_func+0x36/0x60
         process_one_work+0x146/0x350
         worker_thread+0x4a/0x3b0
         kthread+0x102/0x140
         ? process_one_work+0x350/0x350
         ? kthread_bind+0x20/0x20
         ret_from_fork+0x35/0x40
        Code: 66 90 0f b7 07 55 48 89 e5 89 c2 88 47 02 88 47 03 66 81 e2 00 38
      	66 81 fa 00 18 74 6e 66 81 fa 00 20 74 39 66 81 fa 00 10 74 14 <0f>
      	0b 66 25 00 c0 74 20 66 3d 00 c0 75 20 c6 47 04 01 5d c3 66
        ---[ end trace 550c46682415b26d ]---
        brcmfmac: brcmf_construct_chaninfo: Ignoring unexpected firmware channel 50
      
      This patch adds the missing stuff to properly handle this.
      Reviewed-by: default avatarHante Meuleman <hante.meuleman@broadcom.com>
      Reviewed-by: default avatarPieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
      Reviewed-by: default avatarFranky Lin <franky.lin@broadcom.com>
      Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4484de12
    • YueHaibing's avatar
      pinctrl: qcom: spmi-mpp: Fix err handling of pmic_mpp_set_mux · 5c27d053
      YueHaibing authored
      [ Upstream commit 69f8455f ]
      
      'ret' should be returned while pmic_mpp_write_mode_ctl fails.
      
      Fixes: 0e948042 ("pinctrl: qcom: spmi-mpp: Implement support for sink mode")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c27d053
    • Ben Hutchings's avatar
      x86: boot: Fix EFI stub alignment · fcc506ca
      Ben Hutchings authored
      [ Upstream commit 9c1442a9 ]
      
      We currently align the end of the compressed image to a multiple of
      16.  However, the PE-COFF header included in the EFI stub says that
      the file alignment is 32 bytes, and when adding an EFI signature to
      the file it must first be padded to this alignment.
      
      sbsigntool commands warn about this:
      
        warning: file-aligned section .text extends beyond end of file
        warning: checksum areas are greater than image size. Invalid section table?
      
      Worse, pesign -at least when creating a detached signature- uses the
      hash of the unpadded file, resulting in an invalid signature if
      padding is required.
      
      Avoid both these problems by increasing alignment to 32 bytes when
      CONFIG_EFI_STUB is enabled.
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fcc506ca