1. 30 May, 2018 40 commits
    • Qi Hou's avatar
      dmaengine: pl330: fix a race condition in case of threaded irqs · e41de468
      Qi Hou authored
      [ Upstream commit a3ca8312 ]
      
      When booting up with "threadirqs" in command line, all irq handlers of the DMA
      controller pl330 will be threaded forcedly. These threads will race for the same
      list, pl330->req_done.
      
      Before the callback, the spinlock was released. And after it, the spinlock was
      taken. This opened an race window where another threaded irq handler could steal
      the spinlock and be permitted to delete entries of the list, pl330->req_done.
      
      If the later deleted an entry that was still referred to by the former, there would
      be a kernel panic when the former was scheduled and tried to get the next sibling
      of the deleted entry.
      
      The scenario could be depicted as below:
      
        Thread: T1  pl330->req_done  Thread: T2
            |             |              |
            |          -A-B-C-D-         |
          Locked          |              |
            |             |           Waiting
          Del A           |              |
            |          -B-C-D-           |
          Unlocked        |              |
            |             |           Locked
          Waiting         |              |
            |             |            Del B
            |             |              |
            |           -C-D-         Unlocked
          Waiting         |              |
            |
          Locked
            |
         get C via B
            \
             - Kernel panic
      
      The kernel panic looked like as below:
      
      Unable to handle kernel paging request at virtual address dead000000000108
      pgd = ffffff8008c9e000
      [dead000000000108] *pgd=000000027fffe003, *pud=000000027fffe003, *pmd=0000000000000000
      Internal error: Oops: 96000044 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 85 Comm: irq/59-66330000 Not tainted 4.8.24-WR9.0.0.12_standard #2
      Hardware name: Broadcom NS2 SVK (DT)
      task: ffffffc1f5cc3c00 task.stack: ffffffc1f5ce0000
      PC is at pl330_irq_handler+0x27c/0x390
      LR is at pl330_irq_handler+0x2a8/0x390
      pc : [<ffffff80084cb694>] lr : [<ffffff80084cb6c0>] pstate: 800001c5
      sp : ffffffc1f5ce3d00
      x29: ffffffc1f5ce3d00 x28: 0000000000000140
      x27: ffffffc1f5c530b0 x26: dead000000000100
      x25: dead000000000200 x24: 0000000000418958
      x23: 0000000000000001 x22: ffffffc1f5ccd668
      x21: ffffffc1f5ccd590 x20: ffffffc1f5ccd418
      x19: dead000000000060 x18: 0000000000000001
      x17: 0000000000000007 x16: 0000000000000001
      x15: ffffffffffffffff x14: ffffffffffffffff
      x13: ffffffffffffffff x12: 0000000000000000
      x11: 0000000000000001 x10: 0000000000000840
      x9 : ffffffc1f5ce0000 x8 : ffffffc1f5cc3338
      x7 : ffffff8008ce2020 x6 : 0000000000000000
      x5 : 0000000000000000 x4 : 0000000000000001
      x3 : dead000000000200 x2 : dead000000000100
      x1 : 0000000000000140 x0 : ffffffc1f5ccd590
      
      Process irq/59-66330000 (pid: 85, stack limit = 0xffffffc1f5ce0020)
      Stack: (0xffffffc1f5ce3d00 to 0xffffffc1f5ce4000)
      3d00: ffffffc1f5ce3d80 ffffff80080f09d0 ffffffc1f5ca0c00 ffffffc1f6f7c600
      3d20: ffffffc1f5ce0000 ffffffc1f6f7c600 ffffffc1f5ca0c00 ffffff80080f0998
      3d40: ffffffc1f5ce0000 ffffff80080f0000 0000000000000000 0000000000000000
      3d60: ffffff8008ce202c ffffff8008ce2020 ffffffc1f5ccd668 ffffffc1f5c530b0
      3d80: ffffffc1f5ce3db0 ffffff80080f0d70 ffffffc1f5ca0c40 0000000000000001
      3da0: ffffffc1f5ce0000 ffffff80080f0cfc ffffffc1f5ce3e20 ffffff80080bf4f8
      3dc0: ffffffc1f5ca0c80 ffffff8008bf3798 ffffff8008955528 ffffffc1f5ca0c00
      3de0: ffffff80080f0c30 0000000000000000 0000000000000000 0000000000000000
      3e00: 0000000000000000 0000000000000000 0000000000000000 ffffff80080f0b68
      3e20: 0000000000000000 ffffff8008083690 ffffff80080bf420 ffffffc1f5ca0c80
      3e40: 0000000000000000 0000000000000000 0000000000000000 ffffff80080cb648
      3e60: ffffff8008b1c780 0000000000000000 0000000000000000 ffffffc1f5ca0c00
      3e80: ffffffc100000000 ffffff8000000000 ffffffc1f5ce3e90 ffffffc1f5ce3e90
      3ea0: 0000000000000000 ffffff8000000000 ffffffc1f5ce3eb0 ffffffc1f5ce3eb0
      3ec0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3ee0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3f00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3f20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3f40: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3f60: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3f80: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3fa0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      3fc0: 0000000000000000 0000000000000005 0000000000000000 0000000000000000
      3fe0: 0000000000000000 0000000000000000 0000000275ce3ff0 0000000275ce3ff8
      Call trace:
      Exception stack(0xffffffc1f5ce3b30 to 0xffffffc1f5ce3c60)
      3b20:                                   dead000000000060 0000008000000000
      3b40: ffffffc1f5ce3d00 ffffff80084cb694 0000000000000008 0000000000000e88
      3b60: ffffffc1f5ce3bb0 ffffff80080dac68 ffffffc1f5ce3b90 ffffff8008826fe4
      3b80: 00000000000001c0 00000000000001c0 ffffffc1f5ce3bb0 ffffff800848dfcc
      3ba0: 0000000000020000 ffffff8008b15ae4 ffffffc1f5ce3c00 ffffff800808f000
      3bc0: 0000000000000010 ffffff80088377f0 ffffffc1f5ccd590 0000000000000140
      3be0: dead000000000100 dead000000000200 0000000000000001 0000000000000000
      3c00: 0000000000000000 ffffff8008ce2020 ffffffc1f5cc3338 ffffffc1f5ce0000
      3c20: 0000000000000840 0000000000000001 0000000000000000 ffffffffffffffff
      3c40: ffffffffffffffff ffffffffffffffff 0000000000000001 0000000000000007
      [<ffffff80084cb694>] pl330_irq_handler+0x27c/0x390
      [<ffffff80080f09d0>] irq_forced_thread_fn+0x38/0x88
      [<ffffff80080f0d70>] irq_thread+0x140/0x200
      [<ffffff80080bf4f8>] kthread+0xd8/0xf0
      [<ffffff8008083690>] ret_from_fork+0x10/0x40
      Code: f2a00838 f9405763 aa1c03e1 aa1503e0 (f9000443)
      ---[ end trace f50005726d31199c ]---
      Kernel panic - not syncing: Fatal exception in interrupt
      SMP: stopping secondary CPUs
      SMP: failed to stop secondary CPUs 0-1
      Kernel Offset: disabled
      Memory Limit: none
      ---[ end Kernel panic - not syncing: Fatal exception in interrupt
      
      To fix this, re-start with the list-head after dropping the lock then
      re-takeing it.
      Reviewed-by: default avatarFrank Mori Hess <fmh6jj@gmail.com>
      Tested-by: default avatarFrank Mori Hess <fmh6jj@gmail.com>
      Signed-off-by: default avatarQi Hou <qi.hou@windriver.com>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e41de468
    • Ming Lei's avatar
      block: null_blk: fix 'Invalid parameters' when loading module · a6494884
      Ming Lei authored
      [ Upstream commit 66231ad3 ]
      
      On ARM64, the default page size has been 64K on some distributions, and
      we should allow ARM64 people to play null_blk.
      
      This patch fixes the issue by extend page bitmap size for supporting
      other non-4KB PAGE_SIZE.
      
      Cc: Bart Van Assche <Bart.VanAssche@wdc.com>
      Cc: Shaohua Li <shli@kernel.org>
      Cc: Kyungchan Koh <kkc6196@fb.com>,
      Cc: weiping zhang <zhangweiping@didichuxing.com>
      Cc: Yi Zhang <yi.zhang@redhat.com>
      Reported-by: default avatarYi Zhang <yi.zhang@redhat.com>
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6494884
    • Dexuan Cui's avatar
      tools: hv: fix compiler warnings about major/target_fname · f0078d20
      Dexuan Cui authored
      [ Upstream commit 1330fc35 ]
      
      This patch fixes the below warnings with new glibc and gcc:
      
      hv_vss_daemon.c:100:13: warning: In the GNU C Library, "major" is defined
       by <sys/sysmacros.h>. For historical compatibility, it is currently
      defined by <sys/types.h> as well, but we plan to  remove this soon.
      To use "major", include <sys/sysmacros.h>  directly.
      
      hv_fcopy_daemon.c:42:2: note: 'snprintf' output between 2 and 1040
      bytes into a destination of size 260
      Signed-off-by: default avatarDexuan Cui <decui@microsoft.com>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: K. Y. Srinivasan <kys@microsoft.com>
      Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0078d20
    • Linus Walleij's avatar
      drm/bridge: sii902x: Retry status read after DDI I2C · f85634b7
      Linus Walleij authored
      [ Upstream commit 2e7a66a8 ]
      
      The following happens when connection a DVI output driven
      from the SiI9022 using a DVI-to-VGA adapter plug:
      
      i2c i2c-0: sendbytes: NAK bailout.
      i2c i2c-0: sendbytes: NAK bailout.
      
      Then no picture. Apparently the I2C engine inside the SiI9022
      is not smart enough to try to fall back to DDC I2C. Or the
      vendor have not integrated the electronics properly. I don't
      know which one it is.
      
      After this, the I2C bus seems stalled and the first attempt to
      read the status register fails, and the code returns with
      negative return value, and the display fails to initialized.
      
      Instead, retry status readout five times and continue even
      if this fails.
      
      Tested on the ARM Versatile Express with a DVI-to-VGA
      connector, it now gives picture.
      
      Introduce a helper struct device *dev variable to make
      the code more readable.
      
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: default avatarLiviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20180305101702.13441-1-linus.walleij@linaro.orgSigned-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f85634b7
    • Vivek Gautam's avatar
      phy: qcom-qmp: Fix phy pipe clock gating · 3b64e1cf
      Vivek Gautam authored
      [ Upstream commit f8ba22a3 ]
      
      Pipe clock comes out of the phy and is available as long as
      the phy is turned on. Clock controller fails to gate this
      clock after the phy is turned off and generates a warning.
      
      / # [   33.048561] gcc_usb3_phy_pipe_clk status stuck at 'on'
      [   33.048585] ------------[ cut here ]------------
      [   33.052621] WARNING: CPU: 1 PID: 18 at ../drivers/clk/qcom/clk-branch.c:97 clk_branch_wait+0xf0/0x108
      [   33.057384] Modules linked in:
      [   33.066497] CPU: 1 PID: 18 Comm: kworker/1:0 Tainted: G        W       4.12.0-rc7-00024-gfe926e34c36d-dirty #96
      [   33.069451] Hardware name: Qualcomm Technologies, Inc. DB820c (DT)
      ...
      [   33.278565] [<ffff00000849b27c>] clk_branch_wait+0xf0/0x108
      [   33.286375] [<ffff00000849b2f4>] clk_branch2_disable+0x28/0x34
      [   33.291761] [<ffff0000084868dc>] clk_core_disable+0x5c/0x88
      [   33.297660] [<ffff000008487d68>] clk_core_disable_lock+0x20/0x34
      [   33.303129] [<ffff000008487d98>] clk_disable+0x1c/0x24
      [   33.309384] [<ffff0000083ccd78>] qcom_qmp_phy_poweroff+0x20/0x48
      [   33.314328] [<ffff0000083c53f4>] phy_power_off+0x80/0xdc
      [   33.320492] [<ffff00000875c950>] dwc3_core_exit+0x94/0xa0
      [   33.325784] [<ffff00000875c9ac>] dwc3_suspend_common+0x50/0x60
      [   33.331080] [<ffff00000875ca04>] dwc3_runtime_suspend+0x48/0x6c
      [   33.336810] [<ffff0000085b82f4>] pm_generic_runtime_suspend+0x28/0x38
      [   33.342627] [<ffff0000085bace0>] __rpm_callback+0x150/0x254
      [   33.349222] [<ffff0000085bae08>] rpm_callback+0x24/0x78
      [   33.354604] [<ffff0000085b9fd8>] rpm_suspend+0xe0/0x4e4
      [   33.359813] [<ffff0000085bb784>] pm_runtime_work+0xdc/0xf0
      [   33.365028] [<ffff0000080d7b30>] process_one_work+0x12c/0x28c
      [   33.370576] [<ffff0000080d7ce8>] worker_thread+0x58/0x3b8
      [   33.376393] [<ffff0000080dd4a8>] kthread+0x100/0x12c
      [   33.381776] [<ffff0000080836c0>] ret_from_fork+0x10/0x50
      
      Fix this by disabling it as the first thing in phy_exit().
      
      Fixes: e78f3d15 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets")
      Signed-off-by: default avatarVivek Gautam <vivek.gautam@codeaurora.org>
      Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b64e1cf
    • Takashi Iwai's avatar
      ALSA: vmaster: Propagate slave error · 10626a0c
      Takashi Iwai authored
      [ Upstream commit 2e2c177c ]
      
      In slave_update() of vmaster code ignores the error from the slave
      get() callback and copies the values.  It's not only about the missing
      error code but also that this may potentially lead to a leak of
      uninitialized variables when the slave get() don't clear them.
      
      This patch fixes slave_update() not to copy the potentially
      uninitialized values when an error is returned from the slave get()
      callback, and to propagate the error value properly.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      10626a0c
    • Shawn Lin's avatar
      phy: rockchip-emmc: retry calpad busy trimming · b1ebc21c
      Shawn Lin authored
      [ Upstream commit a4781c2a ]
      
      It turns out that 5us isn't enough for all cases, so let's
      retry some more times to wait for caldone.
      Signed-off-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
      Tested-by: default avatarZiyuan Xu <xzy.xu@rock-chips.com>
      Signed-off-by: default avatarCaesar Wang <wxt@rock-chips.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1ebc21c
    • Ivan Gorinov's avatar
      x86/devicetree: Fix device IRQ settings in DT · 1fadfed8
      Ivan Gorinov authored
      [ Upstream commit 0a5169ad ]
      
      IRQ parameters for the SoC devices connected directly to I/O APIC lines
      (without PCI IRQ routing) may be specified in the Device Tree.
      
      Called from DT IRQ parser, irq_create_fwspec_mapping() calls
      irq_domain_alloc_irqs() with a pointer to irq_fwspec structure as @arg.
      
      But x86-specific DT IRQ allocation code casts @arg to of_phandle_args
      structure pointer and crashes trying to read the IRQ parameters. The
      function was not converted when the mapping descriptor was changed to
      irq_fwspec in the generic irqdomain code.
      
      Fixes: 11e4438e ("irqdomain: Introduce a firmware-specific IRQ specifier structure")
      Signed-off-by: default avatarIvan Gorinov <ivan.gorinov@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Link: https://lkml.kernel.org/r/a234dee27ea60ce76141872da0d6bdb378b2a9ee.1520450752.git.ivan.gorinov@intel.comSigned-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1fadfed8
    • Ivan Gorinov's avatar
      x86/devicetree: Initialize device tree before using it · 5e54596b
      Ivan Gorinov authored
      [ Upstream commit 628df9dc ]
      
      Commit 08d53aa5 added CRC32 calculation in early_init_dt_verify() and
      checking in late initcall of_fdt_raw_init(), making early_init_dt_verify()
      mandatory.
      
      The required call to early_init_dt_verify() was not added to the
      x86-specific implementation, causing failure to create the sysfs entry in
      of_fdt_raw_init().
      
      Fixes: 08d53aa5 ("of/fdt: export fdt blob as /sys/firmware/fdt")
      Signed-off-by: default avatarIvan Gorinov <ivan.gorinov@intel.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Link: https://lkml.kernel.org/r/c8c7e941efc63b5d25ebf9b6350b0f3df38f6098.1520450752.git.ivan.gorinov@intel.comSigned-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e54596b
    • Andreas Gruenbacher's avatar
      gfs2: Fix fallocate chunk size · c78e4a47
      Andreas Gruenbacher authored
      [ Upstream commit 174d1232 ]
      
      The chunk size of allocations in __gfs2_fallocate is calculated
      incorrectly.  The size can collapse, causing __gfs2_fallocate to
      allocate one block at a time, which is very inefficient.  This needs
      fixing in two places:
      
      In gfs2_quota_lock_check, always set ap->allowed to UINT_MAX to indicate
      that there is no quota limit.  This fixes callers that rely on
      ap->allowed to be set even when quotas are off.
      
      In __gfs2_fallocate, reset max_blks to UINT_MAX in each iteration of the
      loop to make sure that allocation limits from one resource group won't
      spill over into another resource group.
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c78e4a47
    • Bjorn Andersson's avatar
      soc: qcom: wcnss_ctrl: Fix increment in NV upload · c1dab787
      Bjorn Andersson authored
      [ Upstream commit 90c29ed7 ]
      
      hdr.len includes both the size of the header and the fragment, so using
      this when stepping through the firmware causes us to skip 16 bytes every
      chunk of 3072 bytes; causing only the first fragment to actually be
      valid data.
      
      Instead use fragment size steps through the firmware blob.
      
      Fixes: ea7a1f27 ("soc: qcom: Introduce WCNSS_CTRL SMD client")
      Reported-by: default avatarWill Newton <will.newton@gmail.com>
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarAndy Gross <andy.gross@linaro.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1dab787
    • Ilia Lin's avatar
      arm64: dts: qcom: Fix SPI5 config on MSM8996 · 0a3b66b5
      Ilia Lin authored
      [ Upstream commit e723795c ]
      
      Set correct clocks and interrupt values.
      Fixes the incorrect SPI master configuration. This is
      mandatory to make the SPI5 interface functional.
      Signed-off-by: default avatarIlia Lin <ilialin@codeaurora.org>
      Signed-off-by: default avatarAndy Gross <andy.gross@linaro.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a3b66b5
    • Kan Liang's avatar
      perf/x86/intel: Fix event update for auto-reload · b9e85251
      Kan Liang authored
      [ Upstream commit d31fc13f ]
      
      There is a bug when reading event->count with large PEBS enabled.
      
      Here is an example:
      
        # ./read_count
        0x71f0
        0x122c0
        0x1000000001c54
        0x100000001257d
        0x200000000bdc5
      
      In fixed period mode, the auto-reload mechanism could be enabled for
      PEBS events, but the calculation of event->count does not take the
      auto-reload values into account.
      
      Anyone who reads event->count will get the wrong result, e.g x86_pmu_read().
      
      This bug was introduced with the auto-reload mechanism enabled since
      commit:
      
        851559e3 ("perf/x86/intel: Use the PEBS auto reload mechanism when possible")
      
      Introduce intel_pmu_save_and_restart_reload() to calculate the
      event->count only for auto-reload.
      
      Since the counter increments a negative counter value and overflows on
      the sign switch, giving the interval:
      
              [-period, 0]
      
      the difference between two consequtive reads is:
      
       A) value2 - value1;
          when no overflows have happened in between,
       B) (0 - value1) + (value2 - (-period));
          when one overflow happened in between,
       C) (0 - value1) + (n - 1) * (period) + (value2 - (-period));
          when @n overflows happened in between.
      
      Here A) is the obvious difference, B) is the extension to the discrete
      interval, where the first term is to the top of the interval and the
      second term is from the bottom of the next interval and C) the extension
      to multiple intervals, where the middle term is the whole intervals
      covered.
      
      The equation for all cases is:
      
          value2 - value1 + n * period
      
      Previously the event->count is updated right before the sample output.
      But for case A, there is no PEBS record ready. It needs to be specially
      handled.
      
      Remove the auto-reload code from x86_perf_event_set_period() since
      we'll not longer call that function in this case.
      
      Based-on-code-from: Peter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Fixes: 851559e3 ("perf/x86/intel: Use the PEBS auto reload mechanism when possible")
      Link: http://lkml.kernel.org/r/1518474035-21006-2-git-send-email-kan.liang@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9e85251
    • Kan Liang's avatar
      perf/x86/intel: Fix large period handling on Broadwell CPUs · 359769ca
      Kan Liang authored
      [ Upstream commit f605cfca ]
      
      Large fixed period values could be truncated on Broadwell, for example:
      
        perf record -e cycles -c 10000000000
      
      Here the fixed period is 0x2540BE400, but the period which finally applied is
      0x540BE400 - which is wrong.
      
      The reason is that x86_pmu::limit_period() uses an u32 parameter, so the
      high 32 bits of 'period' get truncated.
      
      This bug was introduced in:
      
        commit 294fe0f5 ("perf/x86/intel: Add INST_RETIRED.ALL workarounds")
      
      It's safe to use u64 instead of u32:
      
       - Although the 'left' is s64, the value of 'left' must be positive when
         calling limit_period().
      
       - bdw_limit_period() only modifies the lowest 6 bits, it doesn't touch
         the higher 32 bits.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Fixes: 294fe0f5 ("perf/x86/intel: Add INST_RETIRED.ALL workarounds")
      Link: http://lkml.kernel.org/r/1519926894-3520-1-git-send-email-kan.liang@linux.intel.com
      [ Rewrote unacceptably bad changelog. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      359769ca
    • Mark Rutland's avatar
      efi/arm*: Only register page tables when they exist · ecaa7bd3
      Mark Rutland authored
      [ Upstream commit 6b31a2fa ]
      
      Currently the arm/arm64 runtime code registers the runtime servies
      pagetables with ptdump regardless of whether runtime services page
      tables have been created.
      
      As efi_mm.pgd is NULL in these cases, attempting to dump the efi page
      tables results in a NULL pointer dereference in the ptdump code:
      
      /sys/kernel/debug# cat efi_page_tables
      [  479.522600] Unable to handle kernel NULL pointer dereference at virtual address 00000000
      [  479.522715] Mem abort info:
      [  479.522764]   ESR = 0x96000006
      [  479.522850]   Exception class = DABT (current EL), IL = 32 bits
      [  479.522899]   SET = 0, FnV = 0
      [  479.522937]   EA = 0, S1PTW = 0
      [  479.528200] Data abort info:
      [  479.528230]   ISV = 0, ISS = 0x00000006
      [  479.528317]   CM = 0, WnR = 0
      [  479.528317] user pgtable: 4k pages, 48-bit VAs, pgd = 0000000064ab0cb0
      [  479.528449] [0000000000000000] *pgd=00000000fbbe4003, *pud=00000000fb66e003, *pmd=0000000000000000
      [  479.528600] Internal error: Oops: 96000006 [#1] PREEMPT SMP
      [  479.528664] Modules linked in:
      [  479.528699] CPU: 0 PID: 2457 Comm: cat Not tainted 4.15.0-rc3-00065-g2ad2ee7ecb5c-dirty #7
      [  479.528799] Hardware name: FVP Base (DT)
      [  479.528899] pstate: 00400009 (nzcv daif +PAN -UAO)
      [  479.528941] pc : walk_pgd.isra.1+0x20/0x1d0
      [  479.529011] lr : ptdump_walk_pgd+0x30/0x50
      [  479.529105] sp : ffff00000bf4bc20
      [  479.529185] x29: ffff00000bf4bc20 x28: 0000ffff9d22e000
      [  479.529271] x27: 0000000000020000 x26: ffff80007b4c63c0
      [  479.529358] x25: 00000000014000c0 x24: ffff80007c098900
      [  479.529445] x23: ffff00000bf4beb8 x22: 0000000000000000
      [  479.529532] x21: ffff00000bf4bd70 x20: 0000000000000001
      [  479.529618] x19: ffff00000bf4bcb0 x18: 0000000000000000
      [  479.529760] x17: 000000000041a1c8 x16: ffff0000082139d8
      [  479.529800] x15: 0000ffff9d3c6030 x14: 0000ffff9d2527f4
      [  479.529924] x13: 00000000000003f3 x12: 0000000000000038
      [  479.530000] x11: 0000000000000003 x10: 0101010101010101
      [  479.530099] x9 : 0000000017e94050 x8 : 000000000000003f
      [  479.530226] x7 : 0000000000000000 x6 : 0000000000000000
      [  479.530313] x5 : 0000000000000001 x4 : 0000000000000000
      [  479.530416] x3 : ffff000009069fd8 x2 : 0000000000000000
      [  479.530500] x1 : 0000000000000000 x0 : 0000000000000000
      [  479.530599] Process cat (pid: 2457, stack limit = 0x000000005d1b0e6f)
      [  479.530660] Call trace:
      [  479.530746]  walk_pgd.isra.1+0x20/0x1d0
      [  479.530833]  ptdump_walk_pgd+0x30/0x50
      [  479.530907]  ptdump_show+0x10/0x20
      [  479.530920]  seq_read+0xc8/0x470
      [  479.531023]  full_proxy_read+0x60/0x90
      [  479.531100]  __vfs_read+0x18/0x100
      [  479.531180]  vfs_read+0x88/0x160
      [  479.531267]  SyS_read+0x48/0xb0
      [  479.531299]  el0_svc_naked+0x20/0x24
      [  479.531400] Code: 91400420 f90033a0 a90707a2 f9403fa0 (f9400000)
      [  479.531499] ---[ end trace bfe8e28d8acb2b67 ]---
      Segmentation fault
      
      Let's avoid this problem by only registering the tables after their
      successful creation, which is also less confusing when EFI runtime
      services are not in use.
      Reported-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180308080020.22828-2-ard.biesheuvel@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecaa7bd3
    • Maurizio Lombardi's avatar
      cdrom: do not call check_disk_change() inside cdrom_open() · e6e5de32
      Maurizio Lombardi authored
      [ Upstream commit 2bbea6e1 ]
      
      when mounting an ISO filesystem sometimes (very rarely)
      the system hangs because of a race condition between two tasks.
      
      PID: 6766   TASK: ffff88007b2a6dd0  CPU: 0   COMMAND: "mount"
       #0 [ffff880078447ae0] __schedule at ffffffff8168d605
       #1 [ffff880078447b48] schedule_preempt_disabled at ffffffff8168ed49
       #2 [ffff880078447b58] __mutex_lock_slowpath at ffffffff8168c995
       #3 [ffff880078447bb8] mutex_lock at ffffffff8168bdef
       #4 [ffff880078447bd0] sr_block_ioctl at ffffffffa00b6818 [sr_mod]
       #5 [ffff880078447c10] blkdev_ioctl at ffffffff812fea50
       #6 [ffff880078447c70] ioctl_by_bdev at ffffffff8123a8b3
       #7 [ffff880078447c90] isofs_fill_super at ffffffffa04fb1e1 [isofs]
       #8 [ffff880078447da8] mount_bdev at ffffffff81202570
       #9 [ffff880078447e18] isofs_mount at ffffffffa04f9828 [isofs]
      #10 [ffff880078447e28] mount_fs at ffffffff81202d09
      #11 [ffff880078447e70] vfs_kern_mount at ffffffff8121ea8f
      #12 [ffff880078447ea8] do_mount at ffffffff81220fee
      #13 [ffff880078447f28] sys_mount at ffffffff812218d6
      #14 [ffff880078447f80] system_call_fastpath at ffffffff81698c49
          RIP: 00007fd9ea914e9a  RSP: 00007ffd5d9bf648  RFLAGS: 00010246
          RAX: 00000000000000a5  RBX: ffffffff81698c49  RCX: 0000000000000010
          RDX: 00007fd9ec2bc210  RSI: 00007fd9ec2bc290  RDI: 00007fd9ec2bcf30
          RBP: 0000000000000000   R8: 0000000000000000   R9: 0000000000000010
          R10: 00000000c0ed0001  R11: 0000000000000206  R12: 00007fd9ec2bc040
          R13: 00007fd9eb6b2380  R14: 00007fd9ec2bc210  R15: 00007fd9ec2bcf30
          ORIG_RAX: 00000000000000a5  CS: 0033  SS: 002b
      
      This task was trying to mount the cdrom.  It allocated and configured a
      super_block struct and owned the write-lock for the super_block->s_umount
      rwsem. While exclusively owning the s_umount lock, it called
      sr_block_ioctl and waited to acquire the global sr_mutex lock.
      
      PID: 6785   TASK: ffff880078720fb0  CPU: 0   COMMAND: "systemd-udevd"
       #0 [ffff880078417898] __schedule at ffffffff8168d605
       #1 [ffff880078417900] schedule at ffffffff8168dc59
       #2 [ffff880078417910] rwsem_down_read_failed at ffffffff8168f605
       #3 [ffff880078417980] call_rwsem_down_read_failed at ffffffff81328838
       #4 [ffff8800784179d0] down_read at ffffffff8168cde0
       #5 [ffff8800784179e8] get_super at ffffffff81201cc7
       #6 [ffff880078417a10] __invalidate_device at ffffffff8123a8de
       #7 [ffff880078417a40] flush_disk at ffffffff8123a94b
       #8 [ffff880078417a88] check_disk_change at ffffffff8123ab50
       #9 [ffff880078417ab0] cdrom_open at ffffffffa00a29e1 [cdrom]
      #10 [ffff880078417b68] sr_block_open at ffffffffa00b6f9b [sr_mod]
      #11 [ffff880078417b98] __blkdev_get at ffffffff8123ba86
      #12 [ffff880078417bf0] blkdev_get at ffffffff8123bd65
      #13 [ffff880078417c78] blkdev_open at ffffffff8123bf9b
      #14 [ffff880078417c90] do_dentry_open at ffffffff811fc7f7
      #15 [ffff880078417cd8] vfs_open at ffffffff811fc9cf
      #16 [ffff880078417d00] do_last at ffffffff8120d53d
      #17 [ffff880078417db0] path_openat at ffffffff8120e6b2
      #18 [ffff880078417e48] do_filp_open at ffffffff8121082b
      #19 [ffff880078417f18] do_sys_open at ffffffff811fdd33
      #20 [ffff880078417f70] sys_open at ffffffff811fde4e
      #21 [ffff880078417f80] system_call_fastpath at ffffffff81698c49
          RIP: 00007f29438b0c20  RSP: 00007ffc76624b78  RFLAGS: 00010246
          RAX: 0000000000000002  RBX: ffffffff81698c49  RCX: 0000000000000000
          RDX: 00007f2944a5fa70  RSI: 00000000000a0800  RDI: 00007f2944a5fa70
          RBP: 00007f2944a5f540   R8: 0000000000000000   R9: 0000000000000020
          R10: 00007f2943614c40  R11: 0000000000000246  R12: ffffffff811fde4e
          R13: ffff880078417f78  R14: 000000000000000c  R15: 00007f2944a4b010
          ORIG_RAX: 0000000000000002  CS: 0033  SS: 002b
      
      This task tried to open the cdrom device, the sr_block_open function
      acquired the global sr_mutex lock. The call to check_disk_change()
      then saw an event flag indicating a possible media change and tried
      to flush any cached data for the device.
      As part of the flush, it tried to acquire the super_block->s_umount
      lock associated with the cdrom device.
      This was the same super_block as created and locked by the previous task.
      
      The first task acquires the s_umount lock and then the sr_mutex_lock;
      the second task acquires the sr_mutex_lock and then the s_umount lock.
      
      This patch fixes the issue by moving check_disk_change() out of
      cdrom_open() and let the caller take care of it.
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e6e5de32
    • Kan Liang's avatar
      perf/x86/intel: Properly save/restore the PMU state in the NMI handler · 017f2ee2
      Kan Liang authored
      [ Upstream commit 82d71ed0 ]
      
      The PMU is disabled in intel_pmu_handle_irq(), but cpuc->enabled is not updated
      accordingly.
      
      This is fine in current usage because no-one checks it - but fix it
      for future code: for example, the drain_pebs() will be modified to
      fix an auto-reload bug.
      
      Properly save/restore the old PMU state.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: kernel test robot <fengguang.wu@intel.com>
      Link: http://lkml.kernel.org/r/6f44ee84-56f8-79f1-559b-08e371eaeb78@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      017f2ee2
    • Guenter Roeck's avatar
      hwmon: (pmbus/adm1275) Accept negative page register values · 8f8ebc0b
      Guenter Roeck authored
      [ Upstream commit ecb29abd ]
      
      A negative page register value means that no page needs to be
      selected. This is used by status register read operations and needs
      to be accepted. The failure to do so so results in missed status
      and limit registers.
      
      Fixes: da8e48ab ("hwmon: (pmbus) Always call _pmbus_read_byte in core driver")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f8ebc0b
    • Guenter Roeck's avatar
      hwmon: (pmbus/max8688) Accept negative page register values · afcbcb43
      Guenter Roeck authored
      [ Upstream commit a46f8cd6 ]
      
      A negative page register value means that no page needs to be
      selected. This is used by status register evaluations and needs
      to be accepted.
      
      Fixes: da8e48ab ("hwmon: (pmbus) Always call _pmbus_read_byte in core driver")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      afcbcb43
    • Eric Anholt's avatar
      drm/panel: simple: Fix the bus format for the Ontat panel · 127b06ef
      Eric Anholt authored
      [ Upstream commit 5651e5e0 ]
      
      This fixes bad color output.  When I was first testing the device I
      had the DPI hardware set to 666 mode, but apparently in the refactor
      to use the bus_format information from the panel driver, I failed to
      actually update the panel.
      Signed-off-by: default avatarEric Anholt <eric@anholt.net>
      Fixes: e8b6f561 ("drm/panel: simple: Add the 7" DPI panel from Adafruit")
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20180309233332.1769-1-eric@anholt.netSigned-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      127b06ef
    • Peter Zijlstra's avatar
      perf/core: Fix perf_output_read_group() · ede5dd78
      Peter Zijlstra authored
      [ Upstream commit 9e5b127d ]
      
      Mark reported his arm64 perf fuzzer runs sometimes splat like:
      
        armv8pmu_read_counter+0x1e8/0x2d8
        armpmu_event_update+0x8c/0x188
        armpmu_read+0xc/0x18
        perf_output_read+0x550/0x11e8
        perf_event_read_event+0x1d0/0x248
        perf_event_exit_task+0x468/0xbb8
        do_exit+0x690/0x1310
        do_group_exit+0xd0/0x2b0
        get_signal+0x2e8/0x17a8
        do_signal+0x144/0x4f8
        do_notify_resume+0x148/0x1e8
        work_pending+0x8/0x14
      
      which asserts that we only call pmu::read() on ACTIVE events.
      
      The above callchain does:
      
        perf_event_exit_task()
          perf_event_exit_task_context()
            task_ctx_sched_out() // INACTIVE
            perf_event_exit_event()
              perf_event_set_state(EXIT) // EXIT
              sync_child_event()
                perf_event_read_event()
                  perf_output_read()
                    perf_output_read_group()
                      leader->pmu->read()
      
      Which results in doing a pmu::read() on an !ACTIVE event.
      
      I _think_ this is 'new' since we added attr.inherit_stat, which added
      the perf_event_read_event() to the exit path, without that
      perf_event_read_output() would only trigger from samples and for
      @event to trigger a sample, it's leader _must_ be ACTIVE too.
      
      Still, adding this check makes it consistent with the @sub case for
      the siblings.
      Reported-and-Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ede5dd78
    • Pierre Bourdon's avatar
      max17042: propagate of_node to power supply device · 8ba9b030
      Pierre Bourdon authored
      [ Upstream commit 66ec32fc ]
      
      max17042_get_status uses the core power_supply_am_i_supplied. That
      function relies on DT properties to figure out the power supply
      topology, and will error out without DT.
      
      Fixes max17042 battery status being reported as "unknown".
      Signed-off-by: default avatarPierre Bourdon <delroth@google.com>
      Signed-off-by: default avatarAndre Heider <a.heider@gmail.com>
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.co.uk>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ba9b030
    • leilei.lin's avatar
      perf/core: Fix installing cgroup events on CPU · ed6244e8
      leilei.lin authored
      [ Upstream commit 33801b94 ]
      
      There's two problems when installing cgroup events on CPUs: firstly
      list_update_cgroup_event() only tries to set cpuctx->cgrp for the
      first event, if that mismatches on @cgrp we'll not try again for later
      additions.
      
      Secondly, when we install a cgroup event into an active context, only
      issue an event reprogram when the event matches the current cgroup
      context. This avoids a pointless event reprogramming.
      Signed-off-by: default avatarleilei.lin <leilei.lin@alibaba-inc.com>
      [ Improved the changelog and comments. ]
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: brendan.d.gregg@gmail.com
      Cc: eranian@gmail.com
      Cc: linux-kernel@vger.kernel.org
      Cc: yang_oliver@hotmail.com
      Link: http://lkml.kernel.org/r/20180306093637.28247-1-linxiulei@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed6244e8
    • Chao Yu's avatar
      f2fs: fix to check extent cache in f2fs_drop_extent_tree · 82e93a83
      Chao Yu authored
      [ Upstream commit bf617f7a ]
      
      If noextent_cache mount option is on, we will never initialize extent tree
      in inode, but still we're going to access it in f2fs_drop_extent_tree,
      result in kernel panic as below:
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
       IP: _raw_write_lock+0xc/0x30
       Call Trace:
        ? f2fs_drop_extent_tree+0x41/0x70 [f2fs]
        f2fs_fallocate+0x5a0/0xdd0 [f2fs]
        ? common_file_perm+0x47/0xc0
        ? apparmor_file_permission+0x1a/0x20
        vfs_fallocate+0x15b/0x290
        SyS_fallocate+0x44/0x70
        do_syscall_64+0x6e/0x160
        entry_SYSCALL64_slow_path+0x25/0x25
      
      This patch fixes to check extent cache status before using in
      f2fs_drop_extent_tree.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82e93a83
    • Chao Yu's avatar
      f2fs: fix to clear CP_TRIMMED_FLAG · fc8cf0e7
      Chao Yu authored
      [ Upstream commit cd36d7a1 ]
      
      Once CP_TRIMMED_FLAG is set, after a reboot, we will never issue discard
      before LBA becomes invalid again, fix it by clearing the flag in
      checkpoint without CP_TRIMMED reason.
      
      Fixes: 1f43e2ad ("f2fs: introduce CP_TRIMMED_FLAG to avoid unneeded discard")
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc8cf0e7
    • Chao Yu's avatar
      f2fs: fix to set KEEP_SIZE bit in f2fs_zero_range · 393e472d
      Chao Yu authored
      [ Upstream commit 17cd07ae ]
      
      As Jayashree Mohan reported:
      
      A simple workload to reproduce this would be :
      1. create foo
      2. Write (8K - 16K)  // foo size = 16K now
      3. fsync()
      4. falloc zero_range , keep_size (4202496 - 4210688) // foo size must be 16K
      5. fdatasync()
      Crash now
      
      On recovery, we see that the file size is 4210688 and not 16K, which
      violates the semantics of keep_size flag. We have a test case to
      reproduce this using CrashMonkey on 4.15 kernel. Try this out by
      simply running :
       ./c_harness -f /dev/sda -d /dev/cow_ram0 -t f2fs -e 102400  -P -v
       tests/generic_468_zero.so
      
      The root cause is that we miss to set KEEP_SIZE bit correctly in zero_range
      when zeroing block cross EOF with FALLOC_FL_KEEP_SIZE, let's fix this
      missing case.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      393e472d
    • Vaibhav Jain's avatar
      cxl: Check if PSL data-cache is available before issue flush request · d71b8b0d
      Vaibhav Jain authored
      [ Upstream commit 94322ed8 ]
      
      PSL9D doesn't have a data-cache that needs to be flushed before
      resetting the card. However when cxl tries to flush data-cache on such
      a card, it times-out as PSL_Control register never indicates flush
      operation complete due to missing data-cache. This is usually
      indicated in the kernel logs with this message:
      
      "WARNING: cache flush timed out"
      
      To fix this the patch checks PSL_Debug register CDC-Field(BIT:27)
      which indicates the absence of a data-cache and sets a flag
      'no_data_cache' in 'struct cxl_native' to indicate this. When
      cxl_data_cache_flush() is called it checks the flag and if set bails
      out early without requesting a data-cache flush operation to the PSL.
      Signed-off-by: default avatarVaibhav Jain <vaibhav@linux.vnet.ibm.com>
      Acked-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
      Acked-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d71b8b0d
    • Alistair Popple's avatar
      powerpc/powernv/npu: Fix deadlock in mmio_invalidate() · bf3a501c
      Alistair Popple authored
      [ Upstream commit 2b74e2a9 ]
      
      When sending TLB invalidates to the NPU we need to send extra flushes due
      to a hardware issue. The original implementation would lock the all the
      ATSD MMIO registers sequentially before unlocking and relocking each of
      them sequentially to do the extra flush.
      
      This introduced a deadlock as it is possible for one thread to hold one
      ATSD register whilst waiting for another register to be freed while the
      other thread is holding that register waiting for the one in the first
      thread to be freed.
      
      For example if there are two threads and two ATSD registers:
      
        Thread A	Thread B
        ----------------------
        Acquire 1
        Acquire 2
        Release 1	Acquire 1
        Wait 1	Wait 2
      
      Both threads will be stuck waiting to acquire a register resulting in an
      RCU stall warning or soft lockup.
      
      This patch solves the deadlock by refactoring the code to ensure registers
      are not released between flushes and to ensure all registers are either
      acquired or released together and in order.
      
      Fixes: bbd5ff50 ("powerpc/powernv/npu-dma: Add explicit flush when sending an ATSD")
      Signed-off-by: default avatarAlistair Popple <alistair@popple.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf3a501c
    • Mathieu Malaterre's avatar
      powerpc: Add missing prototype for arch_irq_work_raise() · dc81e718
      Mathieu Malaterre authored
      [ Upstream commit f5246862 ]
      
      In commit 4f8b50bb ("irq_work, ppc: Fix up arch hooks") a new
      function arch_irq_work_raise() was added without a prototype in header
      irq_work.h.
      
      Fix the following warning (treated as error in W=1):
        arch/powerpc/kernel/time.c:523:6: error: no previous prototype for ‘arch_irq_work_raise’
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dc81e718
    • Christophe JAILLET's avatar
      903c66e3
    • Christophe JAILLET's avatar
      drm/meson: Fix some error handling paths in 'meson_drv_bind_master()' · b4d7f0da
      Christophe JAILLET authored
      [ Upstream commit 2c18107b ]
      
      If one of these functions fail, we whould free 'drm', as alreadry done in
      the other error handling paths, below and above.
      
      Fixes: bbbe775e ("drm: Add support for Amlogic Meson Graphic Controller")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/df47e03d36c2cf7bc37ec3105fc47c16555bd946.1520885192.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4d7f0da
    • Kamlakant Patel's avatar
      ipmi_ssif: Fix kernel panic at msg_done_handler · 6eaf0dd1
      Kamlakant Patel authored
      [ Upstream commit f002612b ]
      
      This happens when BMC doesn't return any data and the code is trying
      to print the value of data[2].
      
      Getting following crash:
      [  484.728410] Unable to handle kernel NULL pointer dereference at virtual address 00000002
      [  484.736496] pgd = ffff0000094a2000
      [  484.739885] [00000002] *pgd=00000047fcffe003, *pud=00000047fcffd003, *pmd=0000000000000000
      [  484.748158] Internal error: Oops: 96000005 [#1] SMP
      [...]
      [  485.101451] Call trace:
      [...]
      [  485.188473] [<ffff000000a46e68>] msg_done_handler+0x668/0x700 [ipmi_ssif]
      [  485.195249] [<ffff000000a456b8>] ipmi_ssif_thread+0x110/0x128 [ipmi_ssif]
      [  485.202038] [<ffff0000080f1430>] kthread+0x108/0x138
      [  485.206994] [<ffff0000080838e0>] ret_from_fork+0x10/0x30
      [  485.212294] Code: aa1903e1 aa1803e0 b900227f 95fef6a5 (39400aa3)
      
      Adding a check to validate the data len before printing data[2] to fix this issue.
      Signed-off-by: default avatarKamlakant Patel <kamlakant.patel@cavium.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6eaf0dd1
    • Milton Miller's avatar
      watchdog: aspeed: Fix translation of reset mode to ctrl register · b5c7dedc
      Milton Miller authored
      [ Upstream commit d2fc8db6 ]
      
      Assert RESET_SYSTEM bit for any reset and set MODE field from reset
      type.
      
      The watchdog control register has a RESET_SYSTEM bit that is really
      closer to activate a reset, and RESET_SYSTEM_MODE field that chooses
      how much to reset.
      
      Before this patch, a node without these optional property would do a
      SOC reset, but a node with properties requesting a cpu or SOC reset
      would do nothing and a node requesting a system reset would do a
      SOC reset.
      
      Fixes: b7f0b8ad ("drivers/watchdog: ASPEED reference dev tree properties for config")
      Signed-off-by: default avatarMilton Miller <miltonm@us.ibm.com>
      Signed-off-by: default avatarEddie James <eajames@linux.vnet.ibm.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5c7dedc
    • Brian Norris's avatar
      watchdog: dw: RMW the control register · e2906fc8
      Brian Norris authored
      [ Upstream commit a81abbb4 ]
      
      RK3399 has rst_pulse_length in CONTROL_REG[4:2], determining the length
      of pulse to issue for system reset. We shouldn't clobber this value,
      because that might make the system reset ineffective. On RK3399, we're
      seeing that a value of 000b (meaning 2 cycles) yields an unreliable
      (partial?) reset, and so we only fully reset after the watchdog fires a
      second time. If we retain the system default (010b, or 8 clock cycles),
      then the watchdog reset is much more reliable.
      
      Read-modify-write retains the system value and improves reset
      reliability.
      
      It seems we were intentionally clobbering the response mode previously,
      to ensure we performed a system reset (we don't support an interrupt
      notification), so retain that explicitly.
      Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2906fc8
    • Rafael J. Wysocki's avatar
      PCI: Restore config space on runtime resume despite being unbound · e2b3fa0c
      Rafael J. Wysocki authored
      [ Upstream commit 5775b843 ]
      
      We leave PCI devices not bound to a driver in D0 during runtime suspend.
      But they may have a parent which is bound and can be transitioned to
      D3cold at runtime.  Once the parent goes to D3cold, the unbound child
      may go to D3cold as well.  When the child goes to D3cold, its internal
      state, including configuration of BARs, MSI, ASPM, MPS, etc., is lost.
      
      One example are recent hybrid graphics laptops which cut power to the
      discrete GPU when the root port above it goes to ACPI power state D3.
      Users may provoke this by unbinding the GPU driver and allowing runtime
      PM on the GPU via sysfs:  The PM core will then treat the GPU as
      "suspended", which in turn allows the root port to runtime suspend,
      causing the power resources listed in its _PR3 object to be powered off.
      The GPU's BARs will be uninitialized when a driver later probes it.
      
      Another example are hybrid graphics laptops where the GPU itself (rather
      than the root port) is capable of runtime suspending to D3cold.  If the
      GPU's integrated HDA controller is not bound and the GPU's driver
      decides to runtime suspend to D3cold, the HDA controller's BARs will be
      uninitialized when a driver later probes it.
      
      Fix by saving and restoring config space over a runtime suspend cycle
      even if the device is not bound.
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Tested-by: Peter Wu <peter@lekensteyn.nl>              # Nvidia Optimus
      Tested-by: Lukas Wunner <lukas@wunner.de>              # MacBook Pro
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      [lukas: add commit message, bikeshed code comments for clarity]
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/92fb6e6ae2730915eb733c08e2f76c6a313e3860.1520068884.git.lukas@wunner.deSigned-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2b3fa0c
    • Mathias Kresin's avatar
      MIPS: ath79: Fix AR724X_PLL_REG_PCIE_CONFIG offset · 12c663e4
      Mathias Kresin authored
      [ Upstream commit 05454c1b ]
      
      According to the QCA u-boot source the "PCIE Phase Lock Loop
      Configuration (PCIE_PLL_CONFIG)" register is for all SoCs except the
      QCA955X and QCA956X at offset 0x10.
      
      Since the PCIE PLL config register is only defined for the AR724x fix
      only this value. The value is wrong since the day it was added and isn't
      used by any driver yet.
      Signed-off-by: default avatarMathias Kresin <dev@kresin.me>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/16048/Signed-off-by: default avatarJames Hogan <jhogan@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12c663e4
    • Ursula Braun's avatar
      net/smc: pay attention to MAX_ORDER for CQ entries · 2a0bc4ad
      Ursula Braun authored
      [ Upstream commit c9f4c6cf ]
      
      smc allocates a certain number of CQ entries for used RoCE devices. For
      mlx5 devices the chosen constant number results in a large allocation
      causing this warning:
      
      [13355.124656] WARNING: CPU: 3 PID: 16535 at mm/page_alloc.c:3883 __alloc_pages_nodemask+0x2be/0x10c0
      [13355.124657] Modules linked in: smc_diag(O) smc(O) xt_CHECKSUM iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp bridge stp llc ip6table_filter ip6_tables iptable_filter mlx5_ib ib_core sunrpc mlx5_core s390_trng rng_core ghash_s390 prng aes_s390 des_s390 des_generic sha512_s390 sha256_s390 sha1_s390 sha_common ptp pps_core eadm_sch dm_multipath dm_mod vhost_net tun vhost tap sch_fq_codel kvm ip_tables x_tables autofs4 [last unloaded: smc]
      [13355.124672] CPU: 3 PID: 16535 Comm: kworker/3:0 Tainted: G           O    4.14.0uschi #1
      [13355.124673] Hardware name: IBM 3906 M04 704 (LPAR)
      [13355.124675] Workqueue: events smc_listen_work [smc]
      [13355.124677] task: 00000000e2f22100 task.stack: 0000000084720000
      [13355.124678] Krnl PSW : 0704c00180000000 000000000029da76 (__alloc_pages_nodemask+0x2be/0x10c0)
      [13355.124681]            R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3
      [13355.124682] Krnl GPRS: 0000000000000000 00550e00014080c0 0000000000000000 0000000000000001
      [13355.124684]            000000000029d8b6 00000000f3bfd710 0000000000000000 00000000014080c0
      [13355.124685]            0000000000000009 00000000ec277a00 0000000000200000 0000000000000000
      [13355.124686]            0000000000000000 00000000000001ff 000000000029d8b6 0000000084723720
      [13355.124708] Krnl Code: 000000000029da6a: a7110200		tmll	%r1,512
                                000000000029da6e: a774ff29		brc	7,29d8c0
                               #000000000029da72: a7f40001		brc	15,29da74
                               >000000000029da76: a7f4ff25		brc	15,29d8c0
                                000000000029da7a: a7380000		lhi	%r3,0
                                000000000029da7e: a7f4fef1		brc	15,29d860
                                000000000029da82: 5820f0c4		l	%r2,196(%r15)
                                000000000029da86: a53e0048		llilh	%r3,72
      [13355.124720] Call Trace:
      [13355.124722] ([<000000000029d8b6>] __alloc_pages_nodemask+0xfe/0x10c0)
      [13355.124724]  [<000000000013bd1e>] s390_dma_alloc+0x6e/0x148
      [13355.124733]  [<000003ff802eeba6>] mlx5_dma_zalloc_coherent_node+0x8e/0xe0 [mlx5_core]
      [13355.124740]  [<000003ff802eee18>] mlx5_buf_alloc_node+0x70/0x108 [mlx5_core]
      [13355.124744]  [<000003ff804eb410>] mlx5_ib_create_cq+0x558/0x898 [mlx5_ib]
      [13355.124749]  [<000003ff80407d40>] ib_create_cq+0x48/0x88 [ib_core]
      [13355.124751]  [<000003ff80109fba>] smc_ib_setup_per_ibdev+0x52/0x118 [smc]
      [13355.124753]  [<000003ff8010bcb6>] smc_conn_create+0x65e/0x728 [smc]
      [13355.124755]  [<000003ff801081a2>] smc_listen_work+0x2d2/0x540 [smc]
      [13355.124756]  [<0000000000162c66>] process_one_work+0x1be/0x440
      [13355.124758]  [<0000000000162f40>] worker_thread+0x58/0x458
      [13355.124759]  [<0000000000169e7e>] kthread+0x14e/0x168
      [13355.124760]  [<00000000009ce8be>] kernel_thread_starter+0x6/0xc
      [13355.124762]  [<00000000009ce8b8>] kernel_thread_starter+0x0/0xc
      [13355.124762] Last Breaking-Event-Address:
      [13355.124764]  [<000000000029da72>] __alloc_pages_nodemask+0x2ba/0x10c0
      [13355.124764] ---[ end trace 34be38b581c0b585 ]---
      
      This patch reduces the smc constant for the maximum number of allocated
      completion queue entries SMC_MAX_CQE by 2 to avoid high round up values
      in the mlx5 code, and reduces the number of allocated completion queue
      entries even more, if the final allocation for an mlx5 device hits the
      MAX_ORDER limit.
      Reported-by: default avatarIhnken Menssen <menssen@de.ibm.com>
      Signed-off-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a0bc4ad
    • Christophe Jaillet's avatar
      spi: bcm-qspi: fIX some error handling paths · 289e6fa3
      Christophe Jaillet authored
      [ Upstream commit bc3cc752 ]
      
      For some reason, commit c0368e4d ("spi: bcm-qspi: Fix use after free
      in bcm_qspi_probe() in error path") has updated some gotos, but not all of
      them.
      
      This looks spurious, so fix it.
      
      Fixes: fa236a7e ("spi: bcm-qspi: Add Broadcom MSPI driver")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      289e6fa3
    • Christophe Jaillet's avatar
      regulator: gpio: Fix some error handling paths in 'gpio_regulator_probe()' · 1fae5e92
      Christophe Jaillet authored
      [ Upstream commit ed8cffda ]
      
      Re-order error handling code and gotos to avoid leaks in error handling
      paths.
      
      Fixes: 9f946099 ("regulator: gpio: fix parsing of gpio list")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1fae5e92
    • Leo Yan's avatar
      coresight: Use %px to print pcsr instead of %p · 9fe2e97e
      Leo Yan authored
      [ Upstream commit 831c326f ]
      
      Commit ad67b74d ("printk: hash addresses printed with %p") lets
      printk specifier %p to hash all addresses before printing, this was
      resulting in the high 32 bits of pcsr can only output zeros.  So
      module cannot completely print pc value and it's pointless for debugging
      purpose.
      
      This patch fixes this by using %px to print pcsr instead.
      
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9fe2e97e