Skip to content
  1. Feb 09, 2022
    • Ritesh Harjani's avatar
      ext4: fix error handling in ext4_restore_inline_data() · 627b44cf
      Ritesh Harjani authored
      commit 897026aa
      
       upstream.
      
      While running "./check -I 200 generic/475" it sometimes gives below
      kernel BUG(). Ideally we should not call ext4_write_inline_data() if
      ext4_create_inline_data() has failed.
      
      <log snip>
      [73131.453234] kernel BUG at fs/ext4/inline.c:223!
      
      <code snip>
       212 static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc,
       213                                    void *buffer, loff_t pos, unsigned int len)
       214 {
      <...>
       223         BUG_ON(!EXT4_I(inode)->i_inline_off);
       224         BUG_ON(pos + len > EXT4_I(inode)->i_inline_size);
      
      This patch handles the error and prints out a emergency msg saying potential
      data loss for the given inode (since we couldn't restore the original
      inline_data due to some previous error).
      
      [ 9571.070313] EXT4-fs (dm-0): error restoring inline_data for inode -- potential data loss! (inode 1703982, error -30)
      
      Reported-by: default avatarEric Whitney <enwlinux@gmail.com>
      Signed-off-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/9f4cd7dfd54fa58ff27270881823d94ddf78dd07.1642416995.git.riteshh@linux.ibm.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      627b44cf
    • Xin Yin's avatar
      ext4: modify the logic of ext4_mb_new_blocks_simple · 3ecbe2f8
      Xin Yin authored
      commit 31a074a0
      
       upstream.
      
      For now in ext4_mb_new_blocks_simple, if we found a block which
      should be excluded then will switch to next group, this may
      probably cause 'group' run out of range.
      
      Change to check next block in the same group when get a block should
      be excluded. Also change the search range to EXT4_CLUSTERS_PER_GROUP
      and add error checking.
      
      Signed-off-by: default avatarXin Yin <yinxin.x@bytedance.com>
      Reviewed-by: default avatarHarshad Shirwadkar <harshadshirwadkar@gmail.com>
      Link: https://lore.kernel.org/r/20220110035141.1980-3-yinxin.x@bytedance.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ecbe2f8
    • Xin Yin's avatar
      ext4: prevent used blocks from being allocated during fast commit replay · 33fb5931
      Xin Yin authored
      commit 599ea31d
      
       upstream.
      
      During fast commit replay procedure, we clear inode blocks bitmap in
      ext4_ext_clear_bb(), this may cause ext4_mb_new_blocks_simple() allocate
      blocks still in use.
      
      Make ext4_fc_record_regions() also record physical disk regions used by
      inodes during replay procedure. Then ext4_mb_new_blocks_simple() can
      excludes these blocks in use.
      
      Signed-off-by: default avatarXin Yin <yinxin.x@bytedance.com>
      Link: https://lore.kernel.org/r/20220110035141.1980-2-yinxin.x@bytedance.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33fb5931
    • Sergey Shtylyov's avatar
      EDAC/xgene: Fix deferred probing · 11dfe203
      Sergey Shtylyov authored
      commit dfd0dfb9 upstream.
      
      The driver overrides error codes returned by platform_get_irq_optional()
      to -EINVAL for some strange reason, so if it returns -EPROBE_DEFER, the
      driver will fail the probe permanently instead of the deferred probing.
      Switch to propagating the proper error codes to platform driver code
      upwards.
      
        [ bp: Massage commit message. ]
      
      Fixes: 0d442930
      
       ("EDAC: Add APM X-Gene SoC EDAC driver")
      Signed-off-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220124185503.6720-3-s.shtylyov@omp.ru
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11dfe203
    • Sergey Shtylyov's avatar
      EDAC/altera: Fix deferred probing · 9a258cb5
      Sergey Shtylyov authored
      commit 279eb857 upstream.
      
      The driver overrides the error codes returned by platform_get_irq() to
      -ENODEV for some strange reason, so if it returns -EPROBE_DEFER, the
      driver will fail the probe permanently instead of the deferred probing.
      Switch to propagating the proper error codes to platform driver code
      upwards.
      
        [ bp: Massage commit message. ]
      
      Fixes: 71bcada8
      
       ("edac: altera: Add Altera SDRAM EDAC support")
      Signed-off-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarDinh Nguyen <dinguyen@kernel.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220124185503.6720-2-s.shtylyov@omp.ru
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9a258cb5
    • Peter Zijlstra's avatar
      x86/perf: Default set FREEZE_ON_SMI for all · a90f9f3e
      Peter Zijlstra authored
      commit a01994f5
      
       upstream.
      
      Kyle reported that rr[0] has started to malfunction on Comet Lake and
      later CPUs due to EFI starting to make use of CPL3 [1] and the PMU
      event filtering not distinguishing between regular CPL3 and SMM CPL3.
      
      Since this is a privilege violation, default disable SMM visibility
      where possible.
      
      Administrators wanting to observe SMM cycles can easily change this
      using the sysfs attribute while regular users don't have access to
      this file.
      
      [0] https://rr-project.org/
      
      [1] See the Intel white paper "Trustworthy SMM on the Intel vPro Platform"
      at https://bugzilla.kernel.org/attachment.cgi?id=300300, particularly the
      end of page 5.
      
      Reported-by: default avatarKyle Huey <me@kylehuey.com>
      Suggested-by: default avatarAndrew Cooper <Andrew.Cooper3@citrix.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: stable@kernel.org
      Link: https://lkml.kernel.org/r/YfKChjX61OW4CkYm@hirez.programming.kicks-ass.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a90f9f3e
    • Tristan Hume's avatar
      perf/x86/intel/pt: Fix crash with stop filters in single-range mode · feffb6ae
      Tristan Hume authored
      commit 1d909345 upstream.
      
      Add a check for !buf->single before calling pt_buffer_region_size in a
      place where a missing check can cause a kernel crash.
      
      Fixes a bug introduced by commit 67063847 ("perf/x86/intel/pt:
      Opportunistically use single range output mode"), which added a
      support for PT single-range output mode. Since that commit if a PT
      stop filter range is hit while tracing, the kernel will crash because
      of a null pointer dereference in pt_handle_status due to calling
      pt_buffer_region_size without a ToPA configured.
      
      The commit which introduced single-range mode guarded almost all uses of
      the ToPA buffer variables with checks of the buf->single variable, but
      missed the case where tracing was stopped by the PT hardware, which
      happens when execution hits a configured stop filter.
      
      Tested that hitting a stop filter while PT recording successfully
      records a trace with this patch but crashes without this patch.
      
      Fixes: 67063847
      
       ("perf/x86/intel/pt: Opportunistically use single range output mode")
      Signed-off-by: default avatarTristan Hume <tristan@thume.ca>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@kernel.org
      Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      feffb6ae
    • Ian Rogers's avatar
      perf stat: Fix display of grouped aliased events · c5d62c82
      Ian Rogers authored
      [ Upstream commit b2b1aa73 ]
      
      An event may have a number of uncore aliases that when added to the
      evlist are consecutive.
      
      If there are multiple uncore events in a group then
      parse_events__set_leader_for_uncore_aliase will reorder the evlist so
      that events on the same PMU are adjacent.
      
      The collect_all_aliases function assumes that aliases are in blocks so
      that only the first counter is printed and all others are marked merged.
      
      The reordering for groups breaks the assumption and so all counts are
      printed.
      
      This change removes the assumption from collect_all_aliases
      that the events are in blocks and instead processes the entire evlist.
      
      Before:
      
        ```
        $ perf stat -e '{UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE,UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE},duration_time' -a -A -- sleep 1
      
         Performance counter stats for 'system wide':
      
        CPU0                  256,866      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 494,413      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      967      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,738      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,161      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,920      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,443      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  310,753      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,657      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,231      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,573      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  416,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 405,966      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,481      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,447      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  312,911      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 408,154      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,086      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,380      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  333,994      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,349      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,287      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,335      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  188,107      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 302,423      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      701      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,070      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  307,221      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 383,642      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,036      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,158      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  318,479      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 821,545      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,028      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,550      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  227,618      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 372,272      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      903      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  376,783      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 419,827      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,406      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,453      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  286,583      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 429,956      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      999      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,436      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  313,867      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 370,159      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,114      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 409,111      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,399      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,684      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,828      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 376,037      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,378      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,411      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  382,456      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 621,743      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,232      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,955      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,316      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 385,067      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,176      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,268      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  373,588      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 386,163      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,394      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,464      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  381,206      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 546,891      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,266      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,712      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  221,176      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 392,069      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      831      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,456      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  355,401      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 705,595      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,235      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,216      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  371,436      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 428,103      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,306      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,442      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  384,352      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 504,200      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,468      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,860      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  228,856      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 287,976      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      832      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,060      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  215,121      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 334,162      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      681      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,026      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,179      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 436,083      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,084      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,525      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  262,296      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 416,573      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      986      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,533      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  285,852      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 359,842      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,073      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,326      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  303,379      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 367,222      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,008      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,156      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  273,487      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 425,449      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                      932      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,367      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  297,596      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 414,793      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,140      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,601      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  342,365      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 360,422      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,291      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,342      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  327,196      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 580,858      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,122      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,014      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  296,564      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 452,817      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,087      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,694      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  375,002      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 389,393      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,478      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   1,540      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0                  365,213      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36                 594,685      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                    1,401      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                   2,222      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,749,060 ns   duration_time
      
               1.000749060 seconds time elapsed
        ```
      
      After:
      
        ```
         Performance counter stats for 'system wide':
      
        CPU0               20,547,434      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU36              45,202,862      UNC_CHA_TOR_OCCUPANCY.IA_MISS_DRD_REMOTE
        CPU0                   82,001      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU36                 159,688      UNC_CHA_TOR_INSERTS.IA_MISS_DRD_REMOTE
        CPU0            1,000,464,828 ns   duration_time
      
               1.000464828 seconds time elapsed
        ```
      
      Fixes: 3cdc5c2c
      
       ("perf parse-events: Handle uncore event aliases in small groups properly")
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Asaf Yaffe <asaf.yaffe@intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vineet Singh <vineet.singh@intel.com>
      Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220205010941.1065469-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c5d62c82
    • Marco Elver's avatar
      perf: Copy perf_event_attr::sig_data on modification · 8ee67e3c
      Marco Elver authored
      [ Upstream commit 3c25fc97 ]
      
      The intent has always been that perf_event_attr::sig_data should also be
      modifiable along with PERF_EVENT_IOC_MODIFY_ATTRIBUTES, because it is
      observable by user space if SIGTRAP on events is requested.
      
      Currently only PERF_TYPE_BREAKPOINT is modifiable, and explicitly copies
      relevant breakpoint-related attributes in hw_breakpoint_copy_attr().
      This misses copying perf_event_attr::sig_data.
      
      Since sig_data is not specific to PERF_TYPE_BREAKPOINT, introduce a
      helper to copy generic event-type-independent attributes on
      modification.
      
      Fixes: 97ba62b2
      
       ("perf: Add support for SIGTRAP on perf events")
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Link: https://lore.kernel.org/r/20220131103407.1971678-1-elver@google.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8ee67e3c
    • Mark Rutland's avatar
      kvm/arm64: rework guest entry logic · 5f780b14
      Mark Rutland authored
      [ Upstream commit 8cfe148a ]
      
      In kvm_arch_vcpu_ioctl_run() we enter an RCU extended quiescent state
      (EQS) by calling guest_enter_irqoff(), and unmasked IRQs prior to
      exiting the EQS by calling guest_exit(). As the IRQ entry code will not
      wake RCU in this case, we may run the core IRQ code and IRQ handler
      without RCU watching, leading to various potential problems.
      
      Additionally, we do not inform lockdep or tracing that interrupts will
      be enabled during guest execution, which caan lead to misleading traces
      and warnings that interrupts have been enabled for overly-long periods.
      
      This patch fixes these issues by using the new timing and context
      entry/exit helpers to ensure that interrupts are handled during guest
      vtime but with RCU watching, with a sequence:
      
      	guest_timing_enter_irqoff();
      
      	guest_state_enter_irqoff();
      	< run the vcpu >
      	guest_state_exit_irqoff();
      
      	< take any pending IRQs >
      
      	guest_timing_exit_irqoff();
      
      Since instrumentation may make use of RCU, we must also ensure that no
      instrumented code is run during the EQS. I've split out the critical
      section into a new kvm_arm_enter_exit_vcpu() helper which is marked
      noinstr.
      
      Fixes: 1b3d546d
      
       ("arm/arm64: KVM: Properly account for guest CPU time")
      Reported-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Cc: Alexandru Elisei <alexandru.elisei@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Frederic Weisbecker <frederic@kernel.org>
      Cc: James Morse <james.morse@arm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul E. McKenney <paulmck@kernel.org>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Message-Id: <20220201132926.3301912-3-mark.rutland@arm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f780b14
    • Mark Rutland's avatar
      kvm: add guest_state_{enter,exit}_irqoff() · bfa75fae
      Mark Rutland authored
      commit ef9989af upstream.
      
      When transitioning to/from guest mode, it is necessary to inform
      lockdep, tracing, and RCU in a specific order, similar to the
      requirements for transitions to/from user mode. Additionally, it is
      necessary to perform vtime accounting for a window around running the
      guest, with RCU enabled, such that timer interrupts taken from the guest
      can be accounted as guest time.
      
      Most architectures don't handle all the necessary pieces, and a have a
      number of common bugs, including unsafe usage of RCU during the window
      between guest_enter() and guest_exit().
      
      On x86, this was dealt with across commits:
      
        87fa7f3e ("x86/kvm: Move context tracking where it belongs")
        0642391e ("x86/kvm/vmx: Add hardirq tracing to guest enter/exit")
        9fc975e9 ("x86/kvm/svm: Add hardirq tracing on guest enter/exit")
        3ebccdf3 ("x86/kvm/vmx: Move guest enter/exit into .noinstr.text")
        135961e0 ("x86/kvm/svm: Move guest enter/exit into .noinstr.text")
        16045714 ("KVM: x86: Defer vtime accounting 'til after IRQ handling")
        bc908e09
      
       ("KVM: x86: Consolidate guest enter/exit logic to common helpers")
      
      ... but those fixes are specific to x86, and as the resulting logic
      (while correct) is split across generic helper functions and
      x86-specific helper functions, it is difficult to see that the
      entry/exit accounting is balanced.
      
      This patch adds generic helpers which architectures can use to handle
      guest entry/exit consistently and correctly. The guest_{enter,exit}()
      helpers are split into guest_timing_{enter,exit}() to perform vtime
      accounting, and guest_context_{enter,exit}() to perform the necessary
      context tracking and RCU management. The existing guest_{enter,exit}()
      heleprs are left as wrappers of these.
      
      Atop this, new guest_state_enter_irqoff() and guest_state_exit_irqoff()
      helpers are added to handle the ordering of lockdep, tracing, and RCU
      manageent. These are inteneded to mirror exit_to_user_mode() and
      enter_from_user_mode().
      
      Subsequent patches will migrate architectures over to the new helpers,
      following a sequence:
      
      	guest_timing_enter_irqoff();
      
      	guest_state_enter_irqoff();
      	< run the vcpu >
      	guest_state_exit_irqoff();
      
      	< take any pending IRQs >
      
      	guest_timing_exit_irqoff();
      
      This sequences handles all of the above correctly, and more clearly
      balances the entry and exit portions, making it easier to understand.
      
      The existing helpers are marked as deprecated, and will be removed once
      all architectures have been converted.
      
      There should be no functional change as a result of this patch.
      
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Message-Id: <20220201132926.3301912-2-mark.rutland@arm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfa75fae
    • Sergei Trofimovich's avatar
      objtool: Fix truncated string warning · f5b14654
      Sergei Trofimovich authored
      [ Upstream commit 82880283 ]
      
      On GCC 12, the build fails due to a possible truncated string:
      
          check.c: In function 'validate_call':
          check.c:2865:58: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
           2865 |                 snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
                |                                                          ^~
      
      In theory it's a valid bug:
      
          static char pvname[16];
          int idx;
          ...
          idx = (rel->addend / sizeof(void *));
          snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
      
      There are only 7 chars for %d while it could take up to 9, so the
      printed "pv_ops[%d]" string could get truncated.
      
      In reality the bug should never happen, because pv_ops only has ~80
      entries, so 7 chars for the integer is more than enough.  Still, it's
      worth fixing.  Bump the buffer size by 2 bytes to silence the warning.
      
      [ jpoimboe: changed size to 19; massaged changelog ]
      
      Fixes: db2b0c5d
      
       ("objtool: Support pv_opsindirect calls for noinstr")
      Reported-by: default avatarAdam Borowski <kilobyte@angband.pl>
      Reported-by: default avatarMartin Liška <mliska@suse.cz>
      Signed-off-by: default avatarSergei Trofimovich <slyich@gmail.com>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lore.kernel.org/r/20220120233748.2062559-1-slyich@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f5b14654
    • Riwen Lu's avatar
      rtc: cmos: Evaluate century appropriate · d0a96621
      Riwen Lu authored
      commit ff164ae3 upstream.
      
      There's limiting the year to 2069. When setting the rtc year to 2070,
      reading it returns 1970. Evaluate century starting from 19 to count the
      correct year.
      
      $ sudo date -s 20700106
      Mon 06 Jan 2070 12:00:00 AM CST
      $ sudo hwclock -w
      $ sudo hwclock -r
      1970-01-06 12:00:49.604968+08:00
      
      Fixes: 2a4daadd
      
       ("rtc: cmos: ignore bogus century byte")
      
      Signed-off-by: default avatarRiwen Lu <luriwen@kylinos.cn>
      Acked-by: default avatarEric Wong <e@80x24.org>
      Reviewed-by: default avatarMateusz Jończyk <mat.jonczyk@o2.pl>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn
      Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl> # preparation for stable
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0a96621
    • Sasha Neftin's avatar
      e1000e: Separate ADP board type from TGP · f96cdab3
      Sasha Neftin authored
      commit 68defd52
      
       upstream.
      
      We have the same LAN controller on different PCH's. Separate ADP board
      type from a TGP which will allow for specific fixes to be applied for
      ADP platforms.
      
      Suggested-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Suggested-by: default avatarDima Ruinskiy <dima.ruinskiy@intel.com>
      Signed-off-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarNechama Kraus <nechamax.kraus@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f96cdab3
    • Nathan Chancellor's avatar
      tools/resolve_btfids: Do not print any commands when building silently · fbc83aec
      Nathan Chancellor authored
      commit 7f3bdbc3 upstream.
      
      When building with 'make -s', there is some output from resolve_btfids:
      
      $ make -sj"$(nproc)" oldconfig prepare
        MKDIR     .../tools/bpf/resolve_btfids/libbpf/
        MKDIR     .../tools/bpf/resolve_btfids//libsubcmd
        LINK     resolve_btfids
      
      Silent mode means that no information should be emitted about what is
      currently being done. Use the $(silent) variable from Makefile.include
      to avoid defining the msg macro so that there is no information printed.
      
      Fixes: fbbb68de
      
       ("bpf: Add resolve_btfids tool to resolve BTF IDs in ELF object")
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20220201212503.731732-1-nathan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fbc83aec
    • Muhammad Usama Anjum's avatar
      selftests: futex: Use variable MAKE instead of make · e2242343
      Muhammad Usama Anjum authored
      commit b9199181 upstream.
      
      Recursive make commands should always use the variable MAKE, not the
      explicit command name ‘make’. This has benefits and removes the
      following warning when multiple jobs are used for the build:
      
      make[2]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
      
      Fixes: a8ba798b
      
       ("selftests: enable O and KBUILD_OUTPUT")
      Signed-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Reviewed-by: default avatarAndré Almeida <andrealmeid@collabora.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2242343
    • Muhammad Usama Anjum's avatar
      selftests/exec: Remove pipe from TEST_GEN_FILES · 191edea5
      Muhammad Usama Anjum authored
      commit 908a26e1 upstream.
      
      pipe named FIFO special file is being created in execveat.c to perform
      some tests. Makefile doesn't need to do anything with the pipe. When it
      isn't found, Makefile generates the following build error:
      
      make: *** No rule to make target
      '../tools/testing/selftests/exec/pipe', needed by 'all'.  Stop.
      
      pipe is created and removed during test run-time.
      
      Amended change log to add pipe remove info:
      Shuah Khan <skhan@linuxfoundation.org>
      
      Fixes: 61016db1
      
       ("selftests/exec: Verify execve of non-regular files fail")
      Signed-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      191edea5
    • Hou Tao's avatar
      bpf: Use VM_MAP instead of VM_ALLOC for ringbuf · d578933f
      Hou Tao authored
      commit b293dcc4 upstream.
      
      After commit 2fd3fb0be1d1 ("kasan, vmalloc: unpoison VM_ALLOC pages
      after mapping"), non-VM_ALLOC mappings will be marked as accessible
      in __get_vm_area_node() when KASAN is enabled. But now the flag for
      ringbuf area is VM_ALLOC, so KASAN will complain out-of-bound access
      after vmap() returns. Because the ringbuf area is created by mapping
      allocated pages, so use VM_MAP instead.
      
      After the change, info in /proc/vmallocinfo also changes from
        [start]-[end]   24576 ringbuf_map_alloc+0x171/0x290 vmalloc user
      to
        [start]-[end]   24576 ringbuf_map_alloc+0x171/0x290 vmap user
      
      Fixes: 457f4436
      
       ("bpf: Implement BPF ring buffer and verifier support for it")
      Reported-by: default avatar <syzbot+5ad567a418794b9b5983@syzkaller.appspotmail.com>
      Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20220202060158.6260-1-houtao1@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d578933f
    • Haiyue Wang's avatar
      gve: fix the wrong AdminQ buffer queue index check · 7d9c4701
      Haiyue Wang authored
      commit 1f84a945 upstream.
      
      The 'tail' and 'head' are 'unsigned int' type free-running count, when
      'head' is overflow, the 'int i (= tail) < u32 head' will be false:
      
      Only '- loop 0: idx = 63' result is shown, so it needs to use 'int' type
      to compare, it can handle the overflow correctly.
      
      typedef uint32_t u32;
      
      int main()
      {
              u32 tail, head;
              int stail, shead;
              int i, loop;
      
              tail = 0xffffffff;
              head = 0x00000000;
      
              for (i = tail, loop = 0; i < head; i++) {
                      unsigned int idx = i & 63;
      
                      printf("+ loop %d: idx = %u\n", loop++, idx);
              }
      
              stail = tail;
              shead = head;
              for (i = stail, loop = 0; i < shead; i++) {
                      unsigned int idx = i & 63;
      
                      printf("- loop %d: idx = %u\n", loop++, idx);
              }
      
              return 0;
      }
      
      Fixes: 5cdad90d
      
       ("gve: Batch AQ commands for creating and destroying queues.")
      Signed-off-by: default avatarHaiyue Wang <haiyue.wang@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d9c4701
    • Dai Ngo's avatar
      nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client. · 7e7e81aa
      Dai Ngo authored
      commit ab451ea9 upstream.
      
      From RFC 7530 Section 16.34.5:
      
      o  The server has not recorded an unconfirmed { v, x, c, *, * } and
         has recorded a confirmed { v, x, c, *, s }.  If the principals of
         the record and of SETCLIENTID_CONFIRM do not match, the server
         returns NFS4ERR_CLID_INUSE without removing any relevant leased
         client state, and without changing recorded callback and
         callback_ident values for client { x }.
      
      The current code intends to do what the spec describes above but
      it forgot to set 'old' to NULL resulting to the confirmed client
      to be expired.
      
      Fixes: 2b634821
      
       ("nfsd: fix clid_inuse on mount with security change")
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Reviewed-by: default avatarBruce Fields <bfields@fieldses.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e7e81aa
    • John Meneghini's avatar
      scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe · 2d24336c
      John Meneghini authored
      commit 936bd034 upstream.
      
      Running tests with a debug kernel shows that bnx2fc_recv_frame() is
      modifying the per_cpu lport stats counters in a non-mpsafe way.  Just boot
      a debug kernel and run the bnx2fc driver with the hardware enabled.
      
      [ 1391.699147] BUG: using smp_processor_id() in preemptible [00000000] code: bnx2fc_
      [ 1391.699160] caller is bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
      [ 1391.699174] CPU: 2 PID: 4355 Comm: bnx2fc_l2_threa Kdump: loaded Tainted: G    B
      [ 1391.699180] Hardware name: HP ProLiant DL120 G7, BIOS J01 07/01/2013
      [ 1391.699183] Call Trace:
      [ 1391.699188]  dump_stack_lvl+0x57/0x7d
      [ 1391.699198]  check_preemption_disabled+0xc8/0xd0
      [ 1391.699205]  bnx2fc_recv_frame+0xbf9/0x1760 [bnx2fc]
      [ 1391.699215]  ? do_raw_spin_trylock+0xb5/0x180
      [ 1391.699221]  ? bnx2fc_npiv_create_vports.isra.0+0x4e0/0x4e0 [bnx2fc]
      [ 1391.699229]  ? bnx2fc_l2_rcv_thread+0xb7/0x3a0 [bnx2fc]
      [ 1391.699240]  bnx2fc_l2_rcv_thread+0x1af/0x3a0 [bnx2fc]
      [ 1391.699250]  ? bnx2fc_ulp_init+0xc0/0xc0 [bnx2fc]
      [ 1391.699258]  kthread+0x364/0x420
      [ 1391.699263]  ? _raw_spin_unlock_irq+0x24/0x50
      [ 1391.699268]  ? set_kthread_struct+0x100/0x100
      [ 1391.699273]  ret_from_fork+0x22/0x30
      
      Restore the old get_cpu/put_cpu code with some modifications to reduce the
      size of the critical section.
      
      Link: https://lore.kernel.org/r/20220124145110.442335-1-jmeneghi@redhat.com
      Fixes: d576a5e8
      
       ("bnx2fc: Improve stats update mechanism")
      Tested-by: default avatarGuangwu Zhang <guazhang@redhat.com>
      Acked-by: default avatarSaurav Kashyap <skashyap@marvell.com>
      Signed-off-by: default avatarJohn Meneghini <jmeneghi@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d24336c
    • Tom Rix's avatar
      btrfs: fix use of uninitialized variable at rm device ioctl · 676c0f15
      Tom Rix authored
      commit 37b45995 upstream.
      
      Clang static analysis reports this problem
      ioctl.c:3333:8: warning: 3rd function call argument is an
        uninitialized value
          ret = exclop_start_or_cancel_reloc(fs_info,
      
      cancel is only set in one branch of an if-check and is always used.  So
      initialize to false.
      
      Fixes: 1a15eb72
      
       ("btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls")
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      676c0f15
    • Florian Fainelli's avatar
      pinctrl: bcm2835: Fix a few error paths · be064d88
      Florian Fainelli authored
      commit 5297c693 upstream.
      
      After commit 266423e6 ("pinctrl: bcm2835: Change init order for gpio
      hogs") a few error paths would not unwind properly the registration of
      gpio ranges. Correct that by assigning a single error label and goto it
      whenever we encounter a fatal error.
      
      Fixes: 266423e6
      
       ("pinctrl: bcm2835: Change init order for gpio hogs")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220127215033.267227-1-f.fainelli@gmail.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be064d88
    • Łukasz Bartosik's avatar
      pinctrl: intel: fix unexpected interrupt · 4519e6fc
      Łukasz Bartosik authored
      commit e986f0e6 upstream.
      
      ASUS Chromebook C223 with Celeron N3350 crashes sometimes during
      cold booot. Inspection of the kernel log showed that it gets into
      an inifite loop logging the following message:
      
      ->handle_irq():  000000009cdb51e8, handle_bad_irq+0x0/0x251
      ->irq_data.chip(): 000000005ec212a7, 0xffffa043009d8e7
      ->action(): 00000
         IRQ_NOPROBE set
      unexpected IRQ trap at vector 7c
      
      The issue happens during cold boot but only if cold boot happens
      at most several dozen seconds after Chromebook is powered off. For
      longer intervals between power off and power on (cold boot) the issue
      does not reproduce. The unexpected interrupt is sourced from INT3452
      GPIO pin which is used for SD card detect. Investigation relevealed
      that when the interval between power off and power on (cold boot)
      is less than several dozen seconds then values of INT3452 GPIO interrupt
      enable and interrupt pending registers survive power off and power
      on sequence and interrupt for SD card detect pin is enabled and pending
      during probe of SD controller which causes the unexpected IRQ message.
      "Intel Pentium and Celeron Processor N- and J- Series" volume 3 doc
      mentions that GPIO interrupt enable and status registers default
      value is 0x0.
      The fix clears INT3452 GPIO interrupt enabled and interrupt pending
      registers in its probe function.
      
      Fixes: 7981c001
      
       ("pinctrl: intel: Add Intel Sunrisepoint pin controller and GPIO support")
      Signed-off-by: default avatarŁukasz Bartosik <lb@semihalf.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4519e6fc
    • Andy Shevchenko's avatar
      pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line · d0e869bc
      Andy Shevchenko authored
      commit e12963c4 upstream.
      
      The commit af7e3eeb ("pinctrl: intel: Disable input and output buffer
      when switching to GPIO") hadn't taken into account an update of the IRQ
      flags scenario.
      
      When updating the IRQ flags on the preconfigured line the ->irq_set_type()
      is called again. In such case the sequential Rx buffer configuration
      changes may trigger a falling or rising edge interrupt that may lead,
      on some platforms, to an undesired event.
      
      This may happen because each of intel_gpio_set_gpio_mode() and
      __intel_gpio_set_direction() updates the pad configuration with a different
      value of the GPIORXDIS bit. Notable, that the intel_gpio_set_gpio_mode() is
      called only for the pads that are configured as an input. Due to this fact,
      integrate the logic of __intel_gpio_set_direction() call into the
      intel_gpio_set_gpio_mode() so that the Rx buffer won't be disabled and
      immediately re-enabled.
      
      Fixes: af7e3eeb
      
       ("pinctrl: intel: Disable input and output buffer when switching to GPIO")
      Reported-by: default avatarKane Chen <kane.chen@intel.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Tested-by: default avatarGrace Kao <grace.kao@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0e869bc
    • Andre Przywara's avatar
      pinctrl: sunxi: Fix H616 I2S3 pin data · 68b70ac6
      Andre Przywara authored
      commit 1fd6bb5b upstream.
      
      Two bugs have sneaked in the H616 pinctrl data:
      - PH9 uses the mux value of 0x3 twice (one should be 0x5 instead)
      - PH8 and PH9 use the "i2s3" function name twice in each pin
      
      For the double pin name we use the same trick we pulled for i2s0: append
      the pin function to the group name to designate the special function.
      
      Fixes: 25adc294
      
       ("pinctrl: sunxi: Add support for the Allwinner H616 pin controller")
      Reported-by: default avatarSASANO Takayoshi <uaa@mx5.nisiq.net>
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
      Reviewed-by: default avatarSamuel Holland <samuel@sholland.org>
      Link: https://lore.kernel.org/r/20220105172952.23347-1-andre.przywara@arm.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68b70ac6
    • Srinivas Kandagatla's avatar
      ASoC: qdsp6: q6apm-dai: only stop graphs that are started · 83775594
      Srinivas Kandagatla authored
      commit 8f2e5c65 upstream.
      
      Its possible that the sound card is just opened and closed without actually
      playing stream, ex: if the audio file itself is missing.
      
      Even in such cases we do call stop on graphs that are not yet started.
      DSP can throw errors in such cases, so add a check to see if the graph
      was started before stopping it.
      
      Fixes: 9b4fe0f1
      
       ("ASoC: qdsp6: audioreach: add q6apm-dai support")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20220126113549.8853-5-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      83775594
    • Srinivas Kandagatla's avatar
      ASoC: codecs: wcd938x: fix return value of mixer put function · 8a2812b4
      Srinivas Kandagatla authored
      commit bd2347fd upstream.
      
      wcd938x_ear_pa_put_gain, wcd938x_set_swr_port and  wcd938x_set_compander
      currently returns zero eventhough it changes the value.
      Fix this, so that change notifications are sent correctly.
      
      Fixes: e8ba1e05
      
       ("ASoC: codecs: wcd938x: add basic controls")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20220126113549.8853-4-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a2812b4
    • Srinivas Kandagatla's avatar
      ASoC: codecs: lpass-rx-macro: fix sidetone register offsets · 4bb0bd2e
      Srinivas Kandagatla authored
      commit fca041a3 upstream.
      
      For some reason we ended up with incorrect register offfset calcuations
      for sidetone. regmap clearly throw errors when accessing these incorrect
      registers as these do not belong to any read/write ranges.
      so fix them to point to correct register offsets.
      
      Fixes: f3ce6f3c
      
       ("ASoC: codecs: lpass-rx-macro: add iir widgets")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20220126113549.8853-3-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4bb0bd2e
    • Srinivas Kandagatla's avatar
      ASoC: codecs: wcd938x: fix incorrect used of portid · 9167f271
      Srinivas Kandagatla authored
      commit c5c1546a upstream.
      
      Mixer controls have the channel id in mixer->reg, which is not same
      as port id. port id should be derived from chan_info array.
      So fix this. Without this, its possible that we could corrupt
      struct wcd938x_sdw_priv by accessing port_map array out of range
      with channel id instead of port id.
      
      Fixes: e8ba1e05
      
       ("ASoC: codecs: wcd938x: add basic controls")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20220126113549.8853-2-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9167f271
    • Dan Carpenter's avatar
      ASoC: max9759: fix underflow in speaker_gain_control_put() · f114fd61
      Dan Carpenter authored
      commit 4c907bcd upstream.
      
      Check for negative values of "priv->gain" to prevent an out of bounds
      access.  The concern is that these might come from the user via:
        -> snd_ctl_elem_write_user()
          -> snd_ctl_elem_write()
            -> kctl->put()
      
      Fixes: fa8d9151
      
       ("ASoC: max9759: Add Amplifier Driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20220119123101.GA9509@kili
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f114fd61
    • 蒋家盛's avatar
      ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name · c6ede1d4
      蒋家盛 authored
      commit f7a6021a upstream.
      
      If the device does not exist, of_get_child_by_name() will return NULL
      pointer.
      And devm_snd_soc_register_component() does not check it.
      Also, I have noticed that cpcap_codec_driver has not been used yet.
      Therefore, it should be better to check it in order to avoid the future
      dereference of the NULL pointer.
      
      Fixes: f6cdf2d3
      
       ("ASoC: cpcap: new codec")
      Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
      Link: https://lore.kernel.org/r/20220111025048.524134-1-jiasheng@iscas.ac.cn
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6ede1d4
    • Robert Hancock's avatar
      ASoC: simple-card: fix probe failure on platform component · 6a2ae1bc
      Robert Hancock authored
      commit a64067f4 upstream.
      
      A previous change to simple-card resulted in asoc_simple_parse_dai
      attempting to retrieve the dai_name for platform components, which are
      unlikely to have a valid DAI name. This caused simple-card to fail to
      probe when using the xlnx_formatter_pcm as the platform component, since
      it does not register any DAI components.
      
      Since the dai_name is not used for platform components, just skip trying
      to retrieve it for those.
      
      Fixes: f107294c
      
       ("ASoC: simple-card: support snd_soc_dai_link_component style for cpu")
      Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
      Link: https://lore.kernel.org/r/20220107214711.1100162-6-robert.hancock@calian.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a2ae1bc
    • Robert Hancock's avatar
      ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes · aa610c4f
      Robert Hancock authored
      commit e958b588 upstream.
      
      This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make
      buffer bytes multiple of period bytes" by Devarsh Thakkar. The same
      issue exists in the mainline version of the driver. The original
      patch description is as follows:
      
      "The Xilinx Audio Formatter IP has a constraint on period
      bytes to be multiple of 64. This leads to driver changing
      the period size to suitable frames such that period bytes
      are multiple of 64.
      
      Now since period bytes and period size are updated but not
      the buffer bytes, this may make the buffer bytes unaligned
      and not multiple of period bytes.
      
      When this happens we hear popping noise as while DMA is being
      done the buffer bytes are not enough to complete DMA access
      for last period of frame within the application buffer boundary.
      
      To avoid this, align buffer bytes too as multiple of 64, and
      set another constraint to always enforce number of periods as
      integer. Now since, there is already a rule in alsa core
      to enforce Buffer size = Number of Periods * Period Size
      this automatically aligns buffer bytes as multiple of period
      bytes."
      
      Fixes: 6f6c3c36
      
       ("ASoC: xlnx: add pcm formatter platform driver")
      Cc: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
      Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
      Link: https://lore.kernel.org/r/20220107214711.1100162-2-robert.hancock@calian.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa610c4f
    • Miaoqian Lin's avatar
      ASoC: fsl: Add missing error handling in pcm030_fabric_probe · f5cfb8c5
      Miaoqian Lin authored
      commit fb25621d upstream.
      
      Add the missing platform_device_put() and platform_device_del()
      before return from pcm030_fabric_probe in the error handling case.
      
      Fixes: c912fa91
      
       ("ASoC: fsl: register the wm9712-codec")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220127131336.30214-1-linmq006@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f5cfb8c5
    • Peter Ujfalusi's avatar
      ASoC: rt5682: Fix deadlock on resume · a2b79c15
      Peter Ujfalusi authored
      commit 4045daf0 upstream.
      
      On resume from suspend the following chain of events can happen:
      A rt5682_resume() -> mod_delayed_work() for jack_detect_work
      B DAPM sequence starts ( DAPM is locked now)
      
      A1. rt5682_jack_detect_handler() scheduled
       - Takes both jdet_mutex and calibrate_mutex
       - Calls in to rt5682_headset_detect() which tries to take DAPM lock, it
         starts to wait for it as B path took it already.
      B1. DAPM sequence reaches the "HP Amp", rt5682_hp_event() tries to take
          the jdet_mutex, but it is locked in A1, so it waits.
      
      Deadlock.
      
      To solve the deadlock, drop the jdet_mutex, use the jack_detect_work to do
      the jack removal handling, move the dapm lock up one level to protect the
      most of the rt5682_jack_detect_handler(), but not the jack reporting as it
      might trigger a DAPM sequence.
      The rt5682_headset_detect() can be changed to static as well.
      
      Fixes: 8deb34a9
      
       ("ASoC: rt5682: fix the wrong jack type detected")
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
      Link: https://lore.kernel.org/r/20220126100325.16513-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2b79c15
    • Mario Limonciello's avatar
      drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled · bd741337
      Mario Limonciello authored
      commit e55a3aea upstream.
      
      dGPUs connected to Intel systems configured for suspend to idle
      will not have the power rails cut at suspend and resetting the GPU
      may lead to problematic behaviors.
      
      Fixes: e25443d2
      
       ("drm/amdgpu: add a dev_pm_ops prepare callback (v2)")
      Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1879
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd741337
    • Matthew Brost's avatar
      drm/i915: Lock timeline mutex directly in error path of eb_pin_timeline · 855f1528
      Matthew Brost authored
      commit 5ae13c30 upstream.
      
      Don't use the interruptable version of the timeline mutex lock in the
      error path of eb_pin_timeline as the cleanup must always happen.
      
      v2:
       (John Harrison)
        - Don't check for interrupt during mutex lock
      v3:
       (Tvrtko)
        - A comment explaining why lock helper isn't used
      
      Fixes: 544460c3
      
       ("drm/i915: Multi-BB execbuf")
      Signed-off-by: default avatarMatthew Brost <matthew.brost@intel.com>
      Reviewed-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
      Signed-off-by: default avatarJohn Harrison <John.C.Harrison@Intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220111163929.14017-1-matthew.brost@intel.com
      (cherry picked from commit cb935c46
      
      )
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      855f1528
    • Dan Carpenter's avatar
      drm/i915/overlay: Prevent divide by zero bugs in scaling · 76aad713
      Dan Carpenter authored
      commit 90a3d22f upstream.
      
      Smatch detected a divide by zero bug in check_overlay_scaling().
      
          drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling()
          error: potential divide by zero bug '/ rec->dst_height'.
          drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling()
          error: potential divide by zero bug '/ rec->dst_width'.
      
      Prevent this by ensuring that the dst height and width are non-zero.
      
      Fixes: 02e792fb
      
       ("drm/i915: implement drmmode overlay support v4")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@kili
      (cherry picked from commit cf5b64f7
      
      )
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      76aad713
    • Anitha Chrisanthus's avatar
      drm/kmb: Fix for build errors with Warray-bounds · cb64de55
      Anitha Chrisanthus authored
      commit 43f25179 upstream.
      
      This fixes the following build error
      
      drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
      drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
        165 |                 kmb->plane_status[plane_id].ctrl =
        LCD_CTRL_GL2_ENABLE;
        |                 ~~~~~~~~~~~~~~~~~^~~~~~~~~~
        In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
        drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
        61 |         struct layer_status  plane_status[KMB_MAX_PLANES];
        |                                         ^~~~~~~~~~~~
        drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array subscript 2 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
        162 |  kmb->plane_status[plane_id].ctrl =  LCD_CTRL_GL1_ENABLE;
        |                 ~~~~~~~~~~~~~~~~~^~~~~~~~~~
        In file included from
        drivers/gpu/drm/kmb/kmb_plane.c:17:
        drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
        61 |         struct layer_status  plane_status[KMB_MAX_PLANES];
        |
        ^~~~~~~~~~~~
      
      Fixes: 7f7b96a8
      
       ("drm/kmb: Add support for KeemBay Display")
      Signed-off-by: default avatarAnitha Chrisanthus <anitha.chrisanthus@intel.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220127194227.2213608-1-anitha.chrisanthus@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb64de55