1. 04 Jan, 2020 40 commits
    • Ben Zhang's avatar
      ASoC: rt5677: Mark reg RT5677_PWR_ANLG2 as volatile · 18305963
      Ben Zhang authored
      [ Upstream commit eabf424f ]
      
      The codec dies when RT5677_PWR_ANLG2(MX-64h) is set to 0xACE1
      while it's streaming audio over SPI. The DSP firmware turns
      on PLL2 (MX-64 bit 8) when SPI streaming starts.  However regmap
      does not believe that register can change by itself. When
      BST1 (bit 15) is turned on with regmap_update_bits(), it doesn't
      read the register first before write, so PLL2 power bit is
      cleared by accident.
      
      Marking MX-64h as volatile in regmap solved the issue.
      Signed-off-by: default avatarBen Zhang <benzh@chromium.org>
      Signed-off-by: default avatarCurtis Malainey <cujomalainey@chromium.org>
      Link: https://lore.kernel.org/r/20191106011335.223061-6-cujomalainey@chromium.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18305963
    • Chuhong Yuan's avatar
      spi: pxa2xx: Add missed security checks · 4a9d8865
      Chuhong Yuan authored
      [ Upstream commit 5eb263ef ]
      
      pxa2xx_spi_init_pdata misses checks for devm_clk_get and
      platform_get_irq.
      Add checks for them to fix the bugs.
      
      Since ssp->clk and ssp->irq are used in probe, they are mandatory here.
      So we cannot use _optional() for devm_clk_get and platform_get_irq.
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Link: https://lore.kernel.org/r/20191109080943.30428-1-hslester96@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4a9d8865
    • Robert Richter's avatar
      EDAC/ghes: Fix grain calculation · bd5facda
      Robert Richter authored
      [ Upstream commit 7088e29e ]
      
      The current code to convert a physical address mask to a grain
      (defined as granularity in bytes) is:
      
      	e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK);
      
      This is broken in several ways:
      
      1) It calculates to wrong grain values. E.g., a physical address mask
      of ~0xfff should give a grain of 0x1000. Without considering
      PAGE_MASK, there is an off-by-one. Things are worse when also
      filtering it with ~PAGE_MASK. This will calculate to a grain with the
      upper bits set. In the example it even calculates to ~0.
      
      2) The grain does not depend on and is unrelated to the kernel's
      page-size. The page-size only matters when unmapping memory in
      memory_failure(). Smaller grains are wrongly rounded up to the
      page-size, on architectures with a configurable page-size (e.g. arm64)
      this could round up to the even bigger page-size of the hypervisor.
      
      Fix this with:
      
      	e->grain = ~mem_err->physical_addr_mask + 1;
      
      The grain_bits are defined as:
      
      	grain = 1 << grain_bits;
      
      Change also the grain_bits calculation accordingly, it is the same
      formula as in edac_mc.c now and the code can be unified.
      
      The value in ->physical_addr_mask coming from firmware is assumed to
      be contiguous, but this is not sanity-checked. However, in case the
      mask is non-contiguous, a conversion to grain_bits effectively
      converts the grain bit mask to a power of 2 by rounding it up.
      Suggested-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarRobert Richter <rrichter@marvell.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Link: https://lkml.kernel.org/r/20191106093239.25517-11-rrichter@marvell.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd5facda
    • Chuhong Yuan's avatar
      media: si470x-i2c: add missed operations in remove · 4111f10e
      Chuhong Yuan authored
      [ Upstream commit 2df200ab ]
      
      The driver misses calling v4l2_ctrl_handler_free and
      v4l2_device_unregister in remove like what is done in probe failure.
      Add the calls to fix it.
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4111f10e
    • Mike Isely's avatar
      media: pvrusb2: Fix oops on tear-down when radio support is not present · 61d8117f
      Mike Isely authored
      [ Upstream commit 7f404ae9 ]
      
      In some device configurations there's no radio or radio support in the
      driver.  That's OK, as the driver sets itself up accordingly.  However
      on tear-down in these caes it's still trying to tear down radio
      related context when there isn't anything there, leading to
      dereferences through a null pointer and chaos follows.
      
      How this bug survived unfixed for 11 years in the pvrusb2 driver is a
      mystery to me.
      
      [hverkuil: fix two checkpatch warnings]
      Signed-off-by: default avatarMike Isely <isely@pobox.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      61d8117f
    • Miaoqing Pan's avatar
      ath10k: fix get invalid tx rate for Mesh metric · 807185ff
      Miaoqing Pan authored
      [ Upstream commit 05a11003 ]
      
      ath10k does not provide transmit rate info per MSDU
      in tx completion, mark that as -1 so mac80211
      will ignore the rates. This fixes mac80211 update Mesh
      link metric with invalid transmit rate info.
      
      Tested HW: QCA9984
      Tested FW: 10.4-3.9.0.2-00035
      Signed-off-by: default avatarHou Bao Hou <houbao@codeaurora.org>
      Signed-off-by: default avatarAnilkumar Kolli <akolli@codeaurora.org>
      Signed-off-by: default avatarMiaoqing Pan <miaoqing@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      807185ff
    • Masami Hiramatsu's avatar
      perf probe: Filter out instances except for inlined subroutine and subprogram · 3c8d7fa8
      Masami Hiramatsu authored
      [ Upstream commit da6cb952 ]
      
      Filter out instances except for inlined_subroutine and subprogram DIE in
      die_walk_instances() and die_is_func_instance().
      
      This fixes an issue that perf probe sets some probes on calling address
      instead of a target function itself.
      
      When perf probe walks on instances of an abstruct origin (a kind of
      function prototype of inlined function), die_walk_instances() can also
      pass a GNU_call_site (a GNU extension for call site) to callback. Since
      it is not an inlined instance of target function, we have to filter out
      when searching a probe point.
      
      Without this patch, perf probe sets probes on call site address too.This
      can happen on some function which is marked "inlined", but has actual
      symbol. (I'm not sure why GCC mark it "inlined"):
      
        # perf probe -D vfs_read
        p:probe/vfs_read _text+2500017
        p:probe/vfs_read_1 _text+2499468
        p:probe/vfs_read_2 _text+2499563
        p:probe/vfs_read_3 _text+2498876
        p:probe/vfs_read_4 _text+2498512
        p:probe/vfs_read_5 _text+2498627
      
      With this patch:
      
      Slightly different results, similar tho:
      
        # perf probe -D vfs_read
        p:probe/vfs_read _text+2498512
      
      Committer testing:
      
        # uname -a
        Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
      
      Before:
      
        # perf probe -D vfs_read
        p:probe/vfs_read _text+3131557
        p:probe/vfs_read_1 _text+3130975
        p:probe/vfs_read_2 _text+3131047
        p:probe/vfs_read_3 _text+3130380
        p:probe/vfs_read_4 _text+3130000
        # uname -a
        Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
        #
      
      After:
      
        # perf probe -D vfs_read
        p:probe/vfs_read _text+3130000
        #
      
      Fixes: db0d2c64 ("perf probe: Search concrete out-of-line instances")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157241937063.32002.11024544873990816590.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c8d7fa8
    • Masami Hiramatsu's avatar
      perf probe: Skip end-of-sequence and non statement lines · b89ad0c6
      Masami Hiramatsu authored
      [ Upstream commit f4d99bdf ]
      
      Skip end-of-sequence and non-statement lines while walking through lines
      list.
      
      The "end-of-sequence" line information means:
      
       "the current address is that of the first byte after the
        end of a sequence of target machine instructions."
       (DWARF version 4 spec 6.2.2)
      
      This actually means out of scope and we can not probe on it.
      
      On the other hand, the statement lines (is_stmt) means:
      
       "the current instruction is a recommended breakpoint location.
        A recommended breakpoint location is intended to “represent”
        a line, a statement and/or a semantically distinct subpart
        of a statement."
      
       (DWARF version 4 spec 6.2.2)
      
      So, non-statement line info also should be skipped.
      
      These can reduce unneeded probe points and also avoid an error.
      
      E.g. without this patch:
      
        # perf probe -a "clear_tasks_mm_cpumask:1"
        Added new events:
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
          probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1)
          probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1)
          probe:clear_tasks_mm_cpumask_3 (on clear_tasks_mm_cpumask:1)
          probe:clear_tasks_mm_cpumask_4 (on clear_tasks_mm_cpumask:1)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:clear_tasks_mm_cpumask_4 -aR sleep 1
      
        #
      
      This puts 5 probes on one line, but acutally it's not inlined function.
      This is because there are many non statement instructions at the
      function prologue.
      
      With this patch:
      
        # perf probe -a "clear_tasks_mm_cpumask:1"
        Added new event:
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
      
        #
      
      Now perf-probe skips unneeded addresses.
      
      Committer testing:
      
      Slightly different results, but similar:
      
      Before:
      
        # uname -a
        Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
        #
        # perf probe -a "clear_tasks_mm_cpumask:1"
        Added new events:
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
          probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1)
          probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:clear_tasks_mm_cpumask_2 -aR sleep 1
      
        #
      
      After:
      
        # perf probe -a "clear_tasks_mm_cpumask:1"
        Added new event:
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
      
        # perf probe -l
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
        #
      
      Fixes: 4cc9cec6 ("perf probe: Introduce lines walker interface")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157241936090.32002.12156347518596111660.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b89ad0c6
    • Masami Hiramatsu's avatar
      perf probe: Fix to show calling lines of inlined functions · 8466b890
      Masami Hiramatsu authored
      [ Upstream commit 86c0bf85 ]
      
      Fix to show calling lines of inlined functions (where an inline function
      is called).
      
      die_walk_lines() filtered out the lines inside inlined functions based
      on the address. However this also filtered out the lines which call
      those inlined functions from the target function.
      
      To solve this issue, check the call_file and call_line attributes and do
      not filter out if it matches to the line information.
      
      Without this fix, perf probe -L doesn't show some lines correctly.
      (don't see the lines after 17)
      
        # perf probe -L vfs_read
        <vfs_read@/home/mhiramat/ksrc/linux/fs/read_write.c:0>
              0  ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
              1  {
              2         ssize_t ret;
      
              4         if (!(file->f_mode & FMODE_READ))
                                return -EBADF;
              6         if (!(file->f_mode & FMODE_CAN_READ))
                                return -EINVAL;
              8         if (unlikely(!access_ok(buf, count)))
                                return -EFAULT;
      
             11         ret = rw_verify_area(READ, file, pos, count);
             12         if (!ret) {
             13                 if (count > MAX_RW_COUNT)
                                        count =  MAX_RW_COUNT;
             15                 ret = __vfs_read(file, buf, count, pos);
             16                 if (ret > 0) {
                                        fsnotify_access(file);
                                        add_rchar(current, ret);
                                }
      
      With this fix:
      
        # perf probe -L vfs_read
        <vfs_read@/home/mhiramat/ksrc/linux/fs/read_write.c:0>
              0  ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
              1  {
              2         ssize_t ret;
      
              4         if (!(file->f_mode & FMODE_READ))
                                return -EBADF;
              6         if (!(file->f_mode & FMODE_CAN_READ))
                                return -EINVAL;
              8         if (unlikely(!access_ok(buf, count)))
                                return -EFAULT;
      
             11         ret = rw_verify_area(READ, file, pos, count);
             12         if (!ret) {
             13                 if (count > MAX_RW_COUNT)
                                        count =  MAX_RW_COUNT;
             15                 ret = __vfs_read(file, buf, count, pos);
             16                 if (ret > 0) {
             17                         fsnotify_access(file);
             18                         add_rchar(current, ret);
                                }
             20                 inc_syscr(current);
                        }
      
      Fixes: 4cc9cec6 ("perf probe: Introduce lines walker interface")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157241937995.32002.17899884017011512577.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8466b890
    • Masami Hiramatsu's avatar
      perf probe: Return a better scope DIE if there is no best scope · 4ec7e16d
      Masami Hiramatsu authored
      [ Upstream commit c701636a ]
      
      Make find_best_scope() returns innermost DIE at given address if there
      is no best matched scope DIE. Since Gcc sometimes generates intuitively
      strange line info which is out of inlined function address range, we
      need this fixup.
      
      Without this, sometimes perf probe failed to probe on a line inside an
      inlined function:
      
        # perf probe -D ksys_open:3
        Failed to find scope of probe point.
          Error: Failed to add events.
      
      With this fix, 'perf probe' can probe it:
      
        # perf probe -D ksys_open:3
        p:probe/ksys_open _text+25707308
        p:probe/ksys_open_1 _text+25710596
        p:probe/ksys_open_2 _text+25711114
        p:probe/ksys_open_3 _text+25711343
        p:probe/ksys_open_4 _text+25714058
        p:probe/ksys_open_5 _text+2819653
        p:probe/ksys_open_6 _text+2819701
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157291300887.19771.14936015360963292236.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4ec7e16d
    • Masami Hiramatsu's avatar
      perf probe: Skip overlapped location on searching variables · da443aa6
      Masami Hiramatsu authored
      [ Upstream commit dee36a2a ]
      
      Since debuginfo__find_probes() callback function can be called with  the
      location which already passed, the callback function must filter out
      such overlapped locations.
      
      add_probe_trace_event() has already done it by commit 1a375ae7
      ("perf probe: Skip same probe address for a given line"), but
      add_available_vars() doesn't. Thus perf probe -v shows same address
      repeatedly as below:
      
        # perf probe -V vfs_read:18
        Available variables at vfs_read:18
                @<vfs_read+217>
                        char*   buf
                        loff_t* pos
                        ssize_t ret
                        struct file*    file
                @<vfs_read+217>
                        char*   buf
                        loff_t* pos
                        ssize_t ret
                        struct file*    file
                @<vfs_read+226>
                        char*   buf
                        loff_t* pos
                        ssize_t ret
                        struct file*    file
      
      With this fix, perf probe -V shows it correctly:
      
        # perf probe -V vfs_read:18
        Available variables at vfs_read:18
                @<vfs_read+217>
                        char*   buf
                        loff_t* pos
                        ssize_t ret
                        struct file*    file
                @<vfs_read+226>
                        char*   buf
                        loff_t* pos
                        ssize_t ret
                        struct file*    file
      
      Fixes: cf6eb489 ("perf probe: Show accessible local variables")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157241938927.32002.4026859017790562751.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      da443aa6
    • Masami Hiramatsu's avatar
      perf probe: Fix to probe a function which has no entry pc · 11c5a6ce
      Masami Hiramatsu authored
      [ Upstream commit 5d16dbcc ]
      
      Fix 'perf probe' to probe a function which has no entry pc or low pc but
      only has ranges attribute.
      
      probe_point_search_cb() uses dwarf_entrypc() to get the probe address,
      but that doesn't work for the function DIE which has only ranges
      attribute. Use die_entrypc() instead.
      
      Without this fix:
      
        # perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
        Probe point 'clear_tasks_mm_cpumask' not found.
          Error: Failed to add events.
      
      With this:
      
        # perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
        p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0
      
      Committer testing:
      
      Before:
      
        [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0
        Probe point 'clear_tasks_mm_cpumask' not found.
          Error: Failed to add events.
        [root@quaco ~]#
      
      After:
      
        [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0
        Added new event:
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
      
        [root@quaco ~]#
      
      Using it with 'perf trace':
      
        [root@quaco ~]# perf trace -e probe:clear_tasks_mm_cpumask
      
      Doesn't seem to be used in x86_64:
      
        $ find . -name "*.c" | xargs grep clear_tasks_mm_cpumask
        ./kernel/cpu.c: * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU
        ./kernel/cpu.c:void clear_tasks_mm_cpumask(int cpu)
        ./arch/xtensa/kernel/smp.c:	clear_tasks_mm_cpumask(cpu);
        ./arch/csky/kernel/smp.c:	clear_tasks_mm_cpumask(cpu);
        ./arch/sh/kernel/smp.c:	clear_tasks_mm_cpumask(cpu);
        ./arch/arm/kernel/smp.c:	clear_tasks_mm_cpumask(cpu);
        ./arch/powerpc/mm/nohash/mmu_context.c:	clear_tasks_mm_cpumask(cpu);
        $ find . -name "*.h" | xargs grep clear_tasks_mm_cpumask
        ./include/linux/cpu.h:void clear_tasks_mm_cpumask(int cpu);
        $ find . -name "*.S" | xargs grep clear_tasks_mm_cpumask
        $
      
      Fixes: e1ecbbc3 ("perf probe: Fix to handle optimized not-inlined functions")
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157199319438.8075.4695576954550638618.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      11c5a6ce
    • Masami Hiramatsu's avatar
      perf probe: Fix to show inlined function callsite without entry_pc · 86b5bd0a
      Masami Hiramatsu authored
      [ Upstream commit 18e21eb6 ]
      
      Fix 'perf probe --line' option to show inlined function callsite lines
      even if the function DIE has only ranges.
      
      Without this:
      
        # perf probe -L amd_put_event_constraints
        ...
            2  {
            3         if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
                              __amd_put_nb_event_constraints(cpuc, event);
            5  }
      
      With this patch:
      
        # perf probe -L amd_put_event_constraints
        ...
            2  {
            3         if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
            4                 __amd_put_nb_event_constraints(cpuc, event);
            5  }
      
      Committer testing:
      
      Before:
      
        [root@quaco ~]# perf probe -L amd_put_event_constraints
        <amd_put_event_constraints@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/arch/x86/events/amd/core.c:0>
              0  static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
                                                      struct perf_event *event)
              2  {
              3         if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
                                __amd_put_nb_event_constraints(cpuc, event);
              5  }
      
                 PMU_FORMAT_ATTR(event, "config:0-7,32-35");
                 PMU_FORMAT_ATTR(umask, "config:8-15"   );
      
        [root@quaco ~]#
      
      After:
      
        [root@quaco ~]# perf probe -L amd_put_event_constraints
        <amd_put_event_constraints@/usr/src/debug/kernel-5.2.fc30/linux-5.2.18-200.fc30.x86_64/arch/x86/events/amd/core.c:0>
              0  static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
                                                      struct perf_event *event)
              2  {
              3         if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
              4                 __amd_put_nb_event_constraints(cpuc, event);
              5  }
      
                 PMU_FORMAT_ATTR(event, "config:0-7,32-35");
                 PMU_FORMAT_ATTR(umask, "config:8-15"   );
      
        [root@quaco ~]# perf probe amd_put_event_constraints:4
        Added new event:
          probe:amd_put_event_constraints (on amd_put_event_constraints:4)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:amd_put_event_constraints -aR sleep 1
      
        [root@quaco ~]#
      
        [root@quaco ~]# perf probe -l
          probe:amd_put_event_constraints (on amd_put_event_constraints:4@arch/x86/events/amd/core.c)
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
        [root@quaco ~]#
      
      Using it:
      
        [root@quaco ~]# perf trace -e probe:*
        ^C[root@quaco ~]#
      
      Ok, Intel system here... :-)
      
      Fixes: 4cc9cec6 ("perf probe: Introduce lines walker interface")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157199322107.8075.12659099000567865708.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      86b5bd0a
    • Masami Hiramatsu's avatar
      perf probe: Fix to show ranges of variables in functions without entry_pc · 516288df
      Masami Hiramatsu authored
      [ Upstream commit af04dd2f ]
      
      Fix to show ranges of variables (--range and --vars option) in functions
      which DIE has only ranges but no entry_pc attribute.
      
      Without this fix:
      
        # perf probe --range -V clear_tasks_mm_cpumask
        Available variables at clear_tasks_mm_cpumask
        	@<clear_tasks_mm_cpumask+0>
        		(No matched variables)
      
      With this fix:
      
        # perf probe --range -V clear_tasks_mm_cpumask
        Available variables at clear_tasks_mm_cpumask
      	@<clear_tasks_mm_cpumask+0>
      		[VAL]	int	cpu	@<clear_tasks_mm_cpumask+[0-35,317-317,2052-2059]>
      
      Committer testing:
      
      Before:
      
        [root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
        Available variables at clear_tasks_mm_cpumask
                @<clear_tasks_mm_cpumask+0>
                        (No matched variables)
        [root@quaco ~]#
      
      After:
      
        [root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
        Available variables at clear_tasks_mm_cpumask
                @<clear_tasks_mm_cpumask+0>
                        [VAL]   int     cpu     @<clear_tasks_mm_cpumask+[0-23,23-105,105-106,106-106,1843-1850,1850-1862]>
        [root@quaco ~]#
      
      Using it:
      
        [root@quaco ~]# perf probe clear_tasks_mm_cpumask cpu
        Added new event:
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask with cpu)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1
      
        [root@quaco ~]# perf probe -l
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c with cpu)
        [root@quaco ~]#
        [root@quaco ~]# perf trace -e probe:*cpumask
        ^C[root@quaco ~]#
      
      Fixes: 349e8d26 ("perf probe: Add --range option to show a variable's location range")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157199323018.8075.8179744380479673672.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      516288df
    • Masami Hiramatsu's avatar
      perf probe: Fix to probe an inline function which has no entry pc · 104666b6
      Masami Hiramatsu authored
      [ Upstream commit eb6933b2 ]
      
      Fix perf probe to probe an inlne function which has no entry pc
      or low pc but only has ranges attribute.
      
      This seems very rare case, but I could find a few examples, as
      same as probe_point_search_cb(), use die_entrypc() to get the
      entry address in probe_point_inline_cb() too.
      
      Without this patch:
      
        # perf probe -D __amd_put_nb_event_constraints
        Failed to get entry address of __amd_put_nb_event_constraints.
        Probe point '__amd_put_nb_event_constraints' not found.
          Error: Failed to add events.
      
      With this patch:
      
        # perf probe -D __amd_put_nb_event_constraints
        p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43
      
      Committer testing:
      
      Before:
      
        [root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
        Failed to get entry address of __amd_put_nb_event_constraints.
        Probe point '__amd_put_nb_event_constraints' not found.
          Error: Failed to add events.
        [root@quaco ~]#
      
      After:
      
        [root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
        p:probe/__amd_put_nb_event_constraints _text+33789
        [root@quaco ~]#
      
      Fixes: 4ea42b18 ("perf: Add perf probe subcommand, a kprobe-event setup helper")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157199320336.8075.16189530425277588587.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      104666b6
    • Masami Hiramatsu's avatar
      perf probe: Walk function lines in lexical blocks · e4ae92b8
      Masami Hiramatsu authored
      [ Upstream commit acb6a704 ]
      
      Since some inlined functions are in lexical blocks of given function, we
      have to recursively walk through the DIE tree.  Without this fix,
      perf-probe -L can miss the inlined functions which is in a lexical block
      (like if (..) { func() } case.)
      
      However, even though, to walk the lines in a given function, we don't
      need to follow the children DIE of inlined functions because those do
      not have any lines in the specified function.
      
      We need to walk though whole trees only if we walk all lines in a given
      file, because an inlined function can include another inlined function
      in the same file.
      
      Fixes: b0e9cb28 ("perf probe: Fix to search nested inlined functions in CU")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157190836514.1859.15996864849678136353.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e4ae92b8
    • Masami Hiramatsu's avatar
      perf probe: Fix to list probe event with correct line number · 65333030
      Masami Hiramatsu authored
      [ Upstream commit 3895534d ]
      
      Since debuginfo__find_probe_point() uses dwarf_entrypc() for finding the
      entry address of the function on which a probe is, it will fail when the
      function DIE has only ranges attribute.
      
      To fix this issue, use die_entrypc() instead of dwarf_entrypc().
      
      Without this fix, perf probe -l shows incorrect offset:
      
        # perf probe -l
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579263632@work/linux/linux/kernel/cpu.c)
          probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask+18446744071579263752@work/linux/linux/kernel/cpu.c)
      
      With this:
      
        # perf probe -l
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@work/linux/linux/kernel/cpu.c)
          probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:21@work/linux/linux/kernel/cpu.c)
      
      Committer testing:
      
      Before:
      
        [root@quaco ~]# perf probe -l
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579765152@kernel/cpu.c)
        [root@quaco ~]#
      
      After:
      
        [root@quaco ~]# perf probe -l
          probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
        [root@quaco ~]#
      
      Fixes: 1d46ea2a ("perf probe: Fix listing incorrect line number with inline function")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157199321227.8075.14655572419136993015.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      65333030
    • Masami Hiramatsu's avatar
      perf probe: Fix to find range-only function instance · 54ea1fe2
      Masami Hiramatsu authored
      [ Upstream commit b77afa1f ]
      
      Fix die_is_func_instance() to find range-only function instance.
      
      In some case, a function instance can be made without any low PC or
      entry PC, but only with address ranges by optimization.  (e.g. cold text
      partially in "text.unlikely" section) To find such function instance, we
      have to check the range attribute too.
      
      Fixes: e1ecbbc3 ("perf probe: Fix to handle optimized not-inlined functions")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/157190835669.1859.8368628035930950596.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      54ea1fe2
    • Ping-Ke Shih's avatar
      rtlwifi: fix memory leak in rtl92c_set_fw_rsvdpagepkt() · 4ee618ad
      Ping-Ke Shih authored
      [ Upstream commit 5174f1e4 ]
      
      This leak was found by testing the EDIMAX EW-7612 on Raspberry Pi 3B+ with
      Linux 5.4-rc5 (multi_v7_defconfig + rtlwifi + kmemleak) and noticed a
      single memory leak during probe:
      
      unreferenced object 0xec13ee40 (size 176):
        comm "kworker/u8:1", pid 36, jiffies 4294939321 (age 5580.790s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<fc1bbb3e>] __netdev_alloc_skb+0x9c/0x164
          [<863dfa6e>] rtl92c_set_fw_rsvdpagepkt+0x254/0x340 [rtl8192c_common]
          [<9572be0d>] rtl92cu_set_hw_reg+0xf48/0xfa4 [rtl8192cu]
          [<116df4d8>] rtl_op_bss_info_changed+0x234/0x96c [rtlwifi]
          [<8933575f>] ieee80211_bss_info_change_notify+0xb8/0x264 [mac80211]
          [<d4061e86>] ieee80211_assoc_success+0x934/0x1798 [mac80211]
          [<e55adb56>] ieee80211_rx_mgmt_assoc_resp+0x174/0x314 [mac80211]
          [<5974629e>] ieee80211_sta_rx_queued_mgmt+0x3f4/0x7f0 [mac80211]
          [<d91091c6>] ieee80211_iface_work+0x208/0x318 [mac80211]
          [<ac5fcae4>] process_one_work+0x22c/0x564
          [<f5e6d3b6>] worker_thread+0x44/0x5d8
          [<82c7b073>] kthread+0x150/0x154
          [<b43e1b7d>] ret_from_fork+0x14/0x2c
          [<794dff30>] 0x0
      
      It is because 8192cu doesn't implement usb_cmd_send_packet(), and this
      patch just frees the skb within the function to resolve memleak problem
      by now. Since 8192cu doesn't turn on fwctrl_lps that needs to download
      command packet for firmware via the function, applying this patch doesn't
      affect driver behavior.
      Reported-by: default avatarStefan Wahren <wahrenst@gmx.net>
      Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4ee618ad
    • Takashi Iwai's avatar
      ALSA: timer: Limit max amount of slave instances · f68d9c56
      Takashi Iwai authored
      [ Upstream commit fdea53fe ]
      
      The fuzzer tries to open the timer instances as much as possible, and
      this may cause a system hiccup easily.  We've already introduced the
      cap for the max number of available instances for the h/w timers, and
      we should put such a limit also to the slave timers, too.
      
      This patch introduces the limit to the multiple opened slave timers.
      The upper limit is hard-coded to 1000 for now, which should suffice
      for any practical usages up to now.
      
      Link: https://lore.kernel.org/r/20191106154257.5853-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f68d9c56
    • Pan Bian's avatar
      spi: img-spfi: fix potential double release · 189fb903
      Pan Bian authored
      [ Upstream commit e9a8ba97 ]
      
      The channels spfi->tx_ch and spfi->rx_ch are not set to NULL after they
      are released. As a result, they will be released again, either on the
      error handling branch in the same function or in the corresponding
      remove function, i.e. img_spfi_remove(). This patch fixes the bug by
      setting the two members to NULL.
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Link: https://lore.kernel.org/r/1573007769-20131-1-git-send-email-bianpan2016@163.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      189fb903
    • Manish Chopra's avatar
      bnx2x: Fix PF-VF communication over multi-cos queues. · 89854f42
      Manish Chopra authored
      [ Upstream commit dc5a3d79 ]
      
      PF driver doesn't enable tx-switching for all cos queues/clients,
      which causes packets drop from PF to VF. Fix this by enabling
      tx-switching on all cos queues/clients.
      Signed-off-by: default avatarManish Chopra <manishc@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      89854f42
    • Luiz Augusto von Dentz's avatar
      Bluetooth: Fix advertising duplicated flags · 587af617
      Luiz Augusto von Dentz authored
      [ Upstream commit 6012b934 ]
      
      Instances may have flags set as part of its data in which case the code
      should not attempt to add it again otherwise it can cause duplication:
      
      < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 35
              Handle: 0x00
              Operation: Complete extended advertising data (0x03)
              Fragment preference: Minimize fragmentation (0x01)
              Data length: 0x06
              Flags: 0x04
                BR/EDR Not Supported
              Flags: 0x06
                LE General Discoverable Mode
                BR/EDR Not Supported
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      587af617
    • Geert Uytterhoeven's avatar
      pinctrl: sh-pfc: sh7734: Fix duplicate TCLK1_B · 37fdd90d
      Geert Uytterhoeven authored
      [ Upstream commit 884caada ]
      
      The definitions for bit field [19:18] of the Peripheral Function Select
      Register 3 were accidentally copied from bit field [20], leading to
      duplicates for the TCLK1_B function, and missing TCLK0, CAN_CLK_B, and
      ET0_ETXD4 functions.
      
      Fix this by adding the missing GPIO_FN_CAN_CLK_B and GPIO_FN_ET0_ETXD4
      enum values, and correcting the functions.
      Reported-by: default avatarBen Dooks <ben.dooks@codethink.co.uk>
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20191024131308.16659-1-geert+renesas@glider.beSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      37fdd90d
    • John Garry's avatar
      libata: Ensure ata_port probe has completed before detach · c7ba4745
      John Garry authored
      [ Upstream commit 130f4caf ]
      
      With CONFIG_DEBUG_TEST_DRIVER_REMOVE set, we may find the following WARN:
      
      [   23.452574] ------------[ cut here ]------------
      [   23.457190] WARNING: CPU: 59 PID: 1 at drivers/ata/libata-core.c:6676 ata_host_detach+0x15c/0x168
      [   23.466047] Modules linked in:
      [   23.469092] CPU: 59 PID: 1 Comm: swapper/0 Not tainted 5.4.0-rc1-00010-g5b83fd27752b-dirty #296
      [   23.477776] Hardware name: Huawei D06 /D06, BIOS Hisilicon D06 UEFI RC0 - V1.16.01 03/15/2019
      [   23.486286] pstate: a0c00009 (NzCv daif +PAN +UAO)
      [   23.491065] pc : ata_host_detach+0x15c/0x168
      [   23.495322] lr : ata_host_detach+0x88/0x168
      [   23.499491] sp : ffff800011cabb50
      [   23.502792] x29: ffff800011cabb50 x28: 0000000000000007
      [   23.508091] x27: ffff80001137f068 x26: ffff8000112c0c28
      [   23.513390] x25: 0000000000003848 x24: ffff0023ea185300
      [   23.518689] x23: 0000000000000001 x22: 00000000000014c0
      [   23.523987] x21: 0000000000013740 x20: ffff0023bdc20000
      [   23.529286] x19: 0000000000000000 x18: 0000000000000004
      [   23.534584] x17: 0000000000000001 x16: 00000000000000f0
      [   23.539883] x15: ffff0023eac13790 x14: ffff0023eb76c408
      [   23.545181] x13: 0000000000000000 x12: ffff0023eac13790
      [   23.550480] x11: ffff0023eb76c228 x10: 0000000000000000
      [   23.555779] x9 : ffff0023eac13798 x8 : 0000000040000000
      [   23.561077] x7 : 0000000000000002 x6 : 0000000000000001
      [   23.566376] x5 : 0000000000000002 x4 : 0000000000000000
      [   23.571674] x3 : ffff0023bf08a0bc x2 : 0000000000000000
      [   23.576972] x1 : 3099674201f72700 x0 : 0000000000400284
      [   23.582272] Call trace:
      [   23.584706]  ata_host_detach+0x15c/0x168
      [   23.588616]  ata_pci_remove_one+0x10/0x18
      [   23.592615]  ahci_remove_one+0x20/0x40
      [   23.596356]  pci_device_remove+0x3c/0xe0
      [   23.600267]  really_probe+0xdc/0x3e0
      [   23.603830]  driver_probe_device+0x58/0x100
      [   23.608000]  device_driver_attach+0x6c/0x90
      [   23.612169]  __driver_attach+0x84/0xc8
      [   23.615908]  bus_for_each_dev+0x74/0xc8
      [   23.619730]  driver_attach+0x20/0x28
      [   23.623292]  bus_add_driver+0x148/0x1f0
      [   23.627115]  driver_register+0x60/0x110
      [   23.630938]  __pci_register_driver+0x40/0x48
      [   23.635199]  ahci_pci_driver_init+0x20/0x28
      [   23.639372]  do_one_initcall+0x5c/0x1b0
      [   23.643199]  kernel_init_freeable+0x1a4/0x24c
      [   23.647546]  kernel_init+0x10/0x108
      [   23.651023]  ret_from_fork+0x10/0x18
      [   23.654590] ---[ end trace 634a14b675b71c13 ]---
      
      With KASAN also enabled, we may also get many use-after-free reports.
      
      The issue is that when CONFIG_DEBUG_TEST_DRIVER_REMOVE is set, we may
      attempt to detach the ata_port before it has been probed.
      
      This is because the ata_ports are async probed, meaning that there is no
      guarantee that the ata_port has probed prior to detach. When the ata_port
      does probe in this scenario, we get all sorts of issues as the detach may
      have already happened.
      
      Fix by ensuring synchronisation with async_synchronize_full(). We could
      alternatively use the cookie returned from the ata_port probe
      async_schedule() call, but that means managing the cookie, so more
      complicated.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c7ba4745
    • Yunfeng Ye's avatar
      arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() · 0ecb8a72
      Yunfeng Ye authored
      [ Upstream commit bfcef4ab ]
      
      In cases like suspend-to-disk and suspend-to-ram, a large number of CPU
      cores need to be shut down. At present, the CPU hotplug operation is
      serialised, and the CPU cores can only be shut down one by one. In this
      process, if PSCI affinity_info() does not return LEVEL_OFF quickly,
      cpu_psci_cpu_kill() needs to wait for 10ms. If hundreds of CPU cores
      need to be shut down, it will take a long time.
      
      Normally, there is no need to wait 10ms in cpu_psci_cpu_kill(). So
      change the wait interval from 10 ms to max 1 ms and use usleep_range()
      instead of msleep() for more accurate timer.
      
      In addition, reducing the time interval will increase the messages
      output, so remove the "Retry ..." message, instead, track time and
      output to the the sucessful message.
      Signed-off-by: default avatarYunfeng Ye <yeyunfeng@huawei.com>
      Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ecb8a72
    • Thomas Gleixner's avatar
      x86/ioapic: Prevent inconsistent state when moving an interrupt · b446869e
      Thomas Gleixner authored
      [ Upstream commit df439342 ]
      
      There is an issue with threaded interrupts which are marked ONESHOT
      and using the fasteoi handler:
      
        if (IS_ONESHOT())
          mask_irq();
        ....
        cond_unmask_eoi_irq()
          chip->irq_eoi();
            if (setaffinity_pending) {
               mask_ioapic();
               ...
      	 move_affinity();
      	 unmask_ioapic();
            }
      
      So if setaffinity is pending the interrupt will be moved and then
      unconditionally unmasked at the ioapic level, which is wrong in two
      aspects:
      
       1) It should be kept masked up to the point where the threaded handler
          finished.
      
       2) The physical chip state and the software masked state are inconsistent
      
      Guard both the mask and the unmask with a check for the software masked
      state. If the line is marked masked then the ioapic line is also masked, so
      both mask_ioapic() and unmask_ioapic() can be skipped safely.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sebastian Siewior <bigeasy@linutronix.de>
      Fixes: 3aa551c9 ("genirq: add threaded interrupt handler support")
      Link: https://lkml.kernel.org/r/20191017101938.321393687@linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b446869e
    • Chris Chiu's avatar
      rtl8xxxu: fix RTL8723BU connection failure issue after warm reboot · 21131a2d
      Chris Chiu authored
      [ Upstream commit 0eeb91ad ]
      
      The RTL8723BU has problems connecting to AP after each warm reboot.
      Sometimes it returns no scan result, and in most cases, it fails
      the authentication for unknown reason. However, it works totally
      fine after cold reboot.
      
      Compare the value of register SYS_CR and SYS_CLK_MAC_CLK_ENABLE
      for cold reboot and warm reboot, the registers imply that the MAC
      is already powered and thus some procedures are skipped during
      driver initialization. Double checked the vendor driver, it reads
      the SYS_CR and SYS_CLK_MAC_CLK_ENABLE also but doesn't skip any
      during initialization based on them. This commit only tells the
      RTL8723BU to do full initialization without checking MAC status.
      Signed-off-by: default avatarChris Chiu <chiu@endlessm.com>
      Signed-off-by: default avatarJes Sorensen <Jes.Sorensen@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      21131a2d
    • Kangjie Lu's avatar
      drm/gma500: fix memory disclosures due to uninitialized bytes · c3911873
      Kangjie Lu authored
      [ Upstream commit ec3b7b6e ]
      
      "clock" may be copied to "best_clock". Initializing best_clock
      is not sufficient. The fix initializes clock as well to avoid
      memory disclosures and informaiton leaks.
      Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191018044150.1899-1-kjlu@umn.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      c3911873
    • Benjamin Berg's avatar
      x86/mce: Lower throttling MCE messages' priority to warning · 5c57bd2f
      Benjamin Berg authored
      [ Upstream commit 9c3bafaa ]
      
      On modern CPUs it is quite normal that the temperature limits are
      reached and the CPU is throttled. In fact, often the thermal design is
      not sufficient to cool the CPU at full load and limits can quickly be
      reached when a burst in load happens. This will even happen with
      technologies like RAPL limitting the long term power consumption of
      the package.
      
      Also, these limits are "softer", as Srinivas explains:
      
      "CPU temperature doesn't have to hit max(TjMax) to get these warnings.
      OEMs ha[ve] an ability to program a threshold where a thermal interrupt
      can be generated. In some systems the offset is 20C+ (Read only value).
      
      In recent systems, there is another offset on top of it which can be
      programmed by OS, once some agent can adjust power limits dynamically.
      By default this is set to low by the firmware, which I guess the
      prime motivation of Benjamin to submit the patch."
      
      So these messages do not usually indicate a hardware issue (e.g.
      insufficient cooling). Log them as warnings to avoid confusion about
      their severity.
      
       [ bp: Massage commit mesage. ]
      Signed-off-by: default avatarBenjamin Berg <bberg@redhat.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Tested-by: default avatarChristian Kellner <ckellner@redhat.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-edac <linux-edac@vger.kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20191009155424.249277-1-bberg@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      5c57bd2f
    • Mattijs Korpershoek's avatar
      Bluetooth: hci_core: fix init for HCI_USER_CHANNEL · c4810efa
      Mattijs Korpershoek authored
      [ Upstream commit eb8c101e ]
      
      During the setup() stage, HCI device drivers expect the chip to
      acknowledge its setup() completion via vendor specific frames.
      
      If userspace opens() such HCI device in HCI_USER_CHANNEL [1] mode,
      the vendor specific frames are never tranmitted to the driver, as
      they are filtered in hci_rx_work().
      
      Allow HCI devices which operate in HCI_USER_CHANNEL mode to receive
      frames if the HCI device is is HCI_INIT state.
      
      [1] https://www.spinics.net/lists/linux-bluetooth/msg37345.html
      
      Fixes: 23500189 ("Bluetooth: Introduce new HCI socket channel for user operation")
      Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4810efa
    • Miquel Raynal's avatar
      iio: adc: max1027: Reset the device at probe time · 460ffb54
      Miquel Raynal authored
      [ Upstream commit db033831 ]
      
      All the registers are configured by the driver, let's reset the chip
      at probe time, avoiding any conflict with a possible earlier
      configuration.
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      460ffb54
    • Ingo Rohloff's avatar
      usb: usbfs: Suppress problematic bind and unbind uevents. · aaaf3afc
      Ingo Rohloff authored
      [ Upstream commit abb0b3d9 ]
      
      commit 1455cf8d ("driver core: emit uevents when device is bound
      to a driver") added bind and unbind uevents when a driver is bound or
      unbound to a physical device.
      
      For USB devices which are handled via the generic usbfs layer (via
      libusb for example), this is problematic:
      Each time a user space program calls
         ioctl(usb_fd, USBDEVFS_CLAIMINTERFACE, &usb_intf_nr);
      and then later
         ioctl(usb_fd, USBDEVFS_RELEASEINTERFACE, &usb_intf_nr);
      The kernel will now produce a bind or unbind event, which does not
      really contain any useful information.
      
      This allows a user space program to run a DoS attack against programs
      which listen to uevents (in particular systemd/eudev/upowerd):
      A malicious user space program just has to call in a tight loop
      
         ioctl(usb_fd, USBDEVFS_CLAIMINTERFACE, &usb_intf_nr);
         ioctl(usb_fd, USBDEVFS_RELEASEINTERFACE, &usb_intf_nr);
      
      With this loop the malicious user space program floods the kernel and
      all programs listening to uevents with tons of bind and unbind
      events.
      
      This patch suppresses uevents for ioctls USBDEVFS_CLAIMINTERFACE and
      USBDEVFS_RELEASEINTERFACE.
      Signed-off-by: default avatarIngo Rohloff <ingo.rohloff@lauterbach.com>
      Link: https://lore.kernel.org/r/20191011115518.2801-1-ingo.rohloff@lauterbach.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aaaf3afc
    • Jin Yao's avatar
      perf report: Add warning when libunwind not compiled in · 59b706ce
      Jin Yao authored
      [ Upstream commit 800d3f56 ]
      
      We received a user report that call-graph DWARF mode was enabled in
      'perf record' but 'perf report' didn't unwind the callstack correctly.
      The reason was, libunwind was not compiled in.
      
      We can use 'perf -vv' to check the compiled libraries but it would be
      valuable to report a warning to user directly (especially valuable for
      a perf newbie).
      
      The warning is:
      
      Warning:
      Please install libunwind development packages during the perf build.
      
      Both TUI and stdio are supported.
      Signed-off-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191011022122.26369-1-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      59b706ce
    • Leo Yan's avatar
      perf test: Report failure for mmap events · 62d86106
      Leo Yan authored
      [ Upstream commit 6add129c ]
      
      When fail to mmap events in task exit case, it misses to set 'err' to
      -1; thus the testing will not report failure for it.
      
      This patch sets 'err' to -1 when fails to mmap events, thus Perf tool
      can report correct result.
      
      Fixes: d723a550 ("perf test: Add test case for checking number of EXIT events")
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20191011091942.29841-1-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      62d86106
    • Sami Tolvanen's avatar
      x86/mm: Use the correct function type for native_set_fixmap() · beef7459
      Sami Tolvanen authored
      [ Upstream commit f53e2cd0 ]
      
      We call native_set_fixmap indirectly through the function pointer
      struct pv_mmu_ops::set_fixmap, which expects the first parameter to be
      'unsigned' instead of 'enum fixed_addresses'. This patch changes the
      function type for native_set_fixmap to match the pointer, which fixes
      indirect call mismatches with Control-Flow Integrity (CFI) checking.
      Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H . Peter Anvin <hpa@zytor.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190913211402.193018-1-samitolvanen@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      beef7459
    • Stephan Gerhold's avatar
      extcon: sm5502: Reset registers during initialization · 684db99e
      Stephan Gerhold authored
      [ Upstream commit 69426350 ]
      
      On some devices (e.g. Samsung Galaxy A5 (2015)), the bootloader
      seems to keep interrupts enabled for SM5502 when booting Linux.
      Changing the cable state (i.e. plugging in a cable) - until the driver
      is loaded - will therefore produce an interrupt that is never read.
      
      In this situation, the cable state will be stuck forever on the
      initial state because SM5502 stops sending interrupts.
      This can be avoided by clearing those pending interrupts after
      the driver has been loaded.
      
      One way to do this is to reset all registers to default state
      by writing to SM5502_REG_RESET. This ensures that we start from
      a clean state, with all interrupts disabled.
      Suggested-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
      Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      684db99e
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: Make sure YUYV is set as default format · f43df2a9
      Benoit Parrot authored
      [ Upstream commit e20b2480 ]
      
      v4l2-compliance fails with this message:
      
         fail: v4l2-test-formats.cpp(672): \
      	Video Capture Multiplanar: TRY_FMT(G_FMT) != G_FMT
         fail: v4l2-test-formats.cpp(672): \
      	Video Output Multiplanar: TRY_FMT(G_FMT) != G_FMT
      	...
         test VIDIOC_TRY_FMT: FAIL
      
      The default pixel format was setup as pointing to a specific offset in
      the vpe_formats table assuming it was pointing to the V4L2_PIX_FMT_YUYV
      entry. This became false after the addition on the NV21 format (see
      above commid-id)
      
      So instead of hard-coding an offset which might change over time we need
      to use a lookup helper instead so we know the default will always be what
      we intended.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Fixes: 40cc823f7005 ("media: ti-vpe: Add support for NV21 format")
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f43df2a9
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: fix a v4l2-compliance failure about frame sequence number · d389a33d
      Benoit Parrot authored
      [ Upstream commit 2444846c ]
      
      v4l2-compliance fails with this message:
      
         fail: v4l2-test-buffers.cpp(294): \
      	(int)g_sequence() < seq.last_seq + 1
         fail: v4l2-test-buffers.cpp(740): \
      	buf.check(m2m_q, last_m2m_seq)
         fail: v4l2-test-buffers.cpp(974): \
      	captureBufs(node, q, m2m_q, frame_count, true)
         test MMAP: FAIL
      
      The driver is failing to update the source frame sequence number in the
      vb2 buffer object. Only the destination frame sequence was being
      updated.
      
      This is only a reporting issue if the user space app actually cares
      about the frame sequence number. But it is fixed nonetheless.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d389a33d
    • Benoit Parrot's avatar
      media: ti-vpe: vpe: fix a v4l2-compliance warning about invalid pixel format · 8fabd302
      Benoit Parrot authored
      [ Upstream commit 06bec72b ]
      
      v4l2-compliance warns with this message:
      
         warn: v4l2-test-formats.cpp(717): \
       	TRY_FMT cannot handle an invalid pixelformat.
         warn: v4l2-test-formats.cpp(718): \
       	This may or may not be a problem. For more information see:
         warn: v4l2-test-formats.cpp(719): \
       	http://www.mail-archive.com/linux-media@vger.kernel.org/msg56550.html
      	...
         test VIDIOC_TRY_FMT: FAIL
      
      We need to make sure that the returns a valid pixel format in all
      instance. Based on the v4l2 framework convention drivers must return a
      valid pixel format when the requested pixel format is either invalid or
      not supported.
      Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
      Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8fabd302