1. 24 Apr, 2020 14 commits
    • YueHaibing's avatar
      misc: rtsx: set correct pcr_ops for rts522A · a3b12f19
      YueHaibing authored
      [ Upstream commit 10cea23b ]
      
      rts522a should use rts522a_pcr_ops, which is
      diffrent with rts5227 in phy/hw init setting.
      
      Fixes: ce6a5acc ("mfd: rtsx: Add support for rts522A")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200326032618.20472-1-yuehaibing@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a3b12f19
    • Josef Bacik's avatar
      btrfs: track reloc roots based on their commit root bytenr · ce216cff
      Josef Bacik authored
      [ Upstream commit ea287ab1 ]
      
      We always search the commit root of the extent tree for looking up back
      references, however we track the reloc roots based on their current
      bytenr.
      
      This is wrong, if we commit the transaction between relocating tree
      blocks we could end up in this code in build_backref_tree
      
        if (key.objectid == key.offset) {
      	  /*
      	   * Only root blocks of reloc trees use backref
      	   * pointing to itself.
      	   */
      	  root = find_reloc_root(rc, cur->bytenr);
      	  ASSERT(root);
      	  cur->root = root;
      	  break;
        }
      
      find_reloc_root() is looking based on the bytenr we had in the commit
      root, but if we've COWed this reloc root we will not find that bytenr,
      and we will trip over the ASSERT(root).
      
      Fix this by using the commit_root->start bytenr for indexing the commit
      root.  Then we change the __update_reloc_root() caller to be used when
      we switch the commit root for the reloc root during commit.
      
      This fixes the panic I was seeing when we started throttling relocation
      for delayed refs.
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce216cff
    • Josef Bacik's avatar
      btrfs: remove a BUG_ON() from merge_reloc_roots() · daa2bddf
      Josef Bacik authored
      [ Upstream commit 7b7b7431 ]
      
      This was pretty subtle, we default to reloc roots having 0 root refs, so
      if we crash in the middle of the relocation they can just be deleted.
      If we successfully complete the relocation operations we'll set our root
      refs to 1 in prepare_to_merge() and then go on to merge_reloc_roots().
      
      At prepare_to_merge() time if any of the reloc roots have a 0 reference
      still, we will remove that reloc root from our reloc root rb tree, and
      then clean it up later.
      
      However this only happens if we successfully start a transaction.  If
      we've aborted previously we will skip this step completely, and only
      have reloc roots with a reference count of 0, but were never properly
      removed from the reloc control's rb tree.
      
      This isn't a problem per-se, our references are held by the list the
      reloc roots are on, and by the original root the reloc root belongs to.
      If we end up in this situation all the reloc roots will be added to the
      dirty_reloc_list, and then properly dropped at that point.  The reloc
      control will be free'd and the rb tree is no longer used.
      
      There were two options when fixing this, one was to remove the BUG_ON(),
      the other was to make prepare_to_merge() handle the case where we
      couldn't start a trans handle.
      
      IMO this is the cleaner solution.  I started with handling the error in
      prepare_to_merge(), but it turned out super ugly.  And in the end this
      BUG_ON() simply doesn't matter, the cleanup was happening properly, we
      were just panicing because this BUG_ON() only matters in the success
      case.  So I've opted to just remove it and add a comment where it was.
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      daa2bddf
    • Boqun Feng's avatar
      locking/lockdep: Avoid recursion in lockdep_count_{for,back}ward_deps() · 7cdad70b
      Boqun Feng authored
      [ Upstream commit 25016bd7 ]
      
      Qian Cai reported a bug when PROVE_RCU_LIST=y, and read on /proc/lockdep
      triggered a warning:
      
        [ ] DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled)
        ...
        [ ] Call Trace:
        [ ]  lock_is_held_type+0x5d/0x150
        [ ]  ? rcu_lockdep_current_cpu_online+0x64/0x80
        [ ]  rcu_read_lock_any_held+0xac/0x100
        [ ]  ? rcu_read_lock_held+0xc0/0xc0
        [ ]  ? __slab_free+0x421/0x540
        [ ]  ? kasan_kmalloc+0x9/0x10
        [ ]  ? __kmalloc_node+0x1d7/0x320
        [ ]  ? kvmalloc_node+0x6f/0x80
        [ ]  __bfs+0x28a/0x3c0
        [ ]  ? class_equal+0x30/0x30
        [ ]  lockdep_count_forward_deps+0x11a/0x1a0
      
      The warning got triggered because lockdep_count_forward_deps() call
      __bfs() without current->lockdep_recursion being set, as a result
      a lockdep internal function (__bfs()) is checked by lockdep, which is
      unexpected, and the inconsistency between the irq-off state and the
      state traced by lockdep caused the warning.
      
      Apart from this warning, lockdep internal functions like __bfs() should
      always be protected by current->lockdep_recursion to avoid potential
      deadlocks and data inconsistency, therefore add the
      current->lockdep_recursion on-and-off section to protect __bfs() in both
      lockdep_count_forward_deps() and lockdep_count_backward_deps()
      Reported-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200312151258.128036-1-boqun.feng@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      7cdad70b
    • Arvind Sankar's avatar
      x86/boot: Use unsigned comparison for addresses · ee0ba8c3
      Arvind Sankar authored
      [ Upstream commit 81a34892 ]
      
      The load address is compared with LOAD_PHYSICAL_ADDR using a signed
      comparison currently (using jge instruction).
      
      When loading a 64-bit kernel using the new efi32_pe_entry() point added by:
      
        97aa2765 ("efi/x86: Add true mixed mode entry point into .compat section")
      
      using Qemu with -m 3072, the firmware actually loads us above 2Gb,
      resulting in a very early crash.
      
      Use the JAE instruction to perform a unsigned comparison instead, as physical
      addresses should be considered unsigned.
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20200301230436.2246909-6-nivedita@alum.mit.edu
      Link: https://lore.kernel.org/r/20200308080859.21568-14-ardb@kernel.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee0ba8c3
    • Bob Peterson's avatar
      gfs2: Don't demote a glock until its revokes are written · e0d199c1
      Bob Peterson authored
      [ Upstream commit df5db5f9 ]
      
      Before this patch, run_queue would demote glocks based on whether
      there are any more holders. But if the glock has pending revokes that
      haven't been written to the media, giving up the glock might end in
      file system corruption if the revokes never get written due to
      io errors, node crashes and fences, etc. In that case, another node
      will replay the metadata blocks associated with the glock, but
      because the revoke was never written, it could replay that block
      even though the glock had since been granted to another node who
      might have made changes.
      
      This patch changes the logic in run_queue so that it never demotes
      a glock until its count of pending revokes reaches zero.
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Reviewed-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e0d199c1
    • John Garry's avatar
      libata: Remove extra scsi_host_put() in ata_scsi_add_hosts() · 2e70b9a8
      John Garry authored
      [ Upstream commit 1d72f7ae ]
      
      If the call to scsi_add_host_with_dma() in ata_scsi_add_hosts() fails,
      then we may get use-after-free KASAN warns:
      
      ==================================================================
      BUG: KASAN: use-after-free in kobject_put+0x24/0x180
      Read of size 1 at addr ffff0026b8c80364 by task swapper/0/1
      CPU: 1 PID: 1 Comm: swapper/0 Tainted: G        W         5.6.0-rc3-00004-g5a71b206ea82-dirty #1765
      Hardware name: Huawei TaiShan 200 (Model 2280)/BC82AMDD, BIOS 2280-V2 CS V3.B160.01 02/24/2020
      Call trace:
      dump_backtrace+0x0/0x298
      show_stack+0x14/0x20
      dump_stack+0x118/0x190
      print_address_description.isra.9+0x6c/0x3b8
      __kasan_report+0x134/0x23c
      kasan_report+0xc/0x18
      __asan_load1+0x5c/0x68
      kobject_put+0x24/0x180
      put_device+0x10/0x20
      scsi_host_put+0x10/0x18
      ata_devres_release+0x74/0xb0
      release_nodes+0x2d0/0x470
      devres_release_all+0x50/0x78
      really_probe+0x2d4/0x560
      driver_probe_device+0x7c/0x148
      device_driver_attach+0x94/0xa0
      __driver_attach+0xa8/0x110
      bus_for_each_dev+0xe8/0x158
      driver_attach+0x30/0x40
      bus_add_driver+0x220/0x2e0
      driver_register+0xbc/0x1d0
      __pci_register_driver+0xbc/0xd0
      ahci_pci_driver_init+0x20/0x28
      do_one_initcall+0xf0/0x608
      kernel_init_freeable+0x31c/0x384
      kernel_init+0x10/0x118
      ret_from_fork+0x10/0x18
      
      Allocated by task 5:
      save_stack+0x28/0xc8
      __kasan_kmalloc.isra.8+0xbc/0xd8
      kasan_kmalloc+0xc/0x18
      __kmalloc+0x1a8/0x280
      scsi_host_alloc+0x44/0x678
      ata_scsi_add_hosts+0x74/0x268
      ata_host_register+0x228/0x488
      ahci_host_activate+0x1c4/0x2a8
      ahci_init_one+0xd18/0x1298
      local_pci_probe+0x74/0xf0
      work_for_cpu_fn+0x2c/0x48
      process_one_work+0x488/0xc08
      worker_thread+0x330/0x5d0
      kthread+0x1c8/0x1d0
      ret_from_fork+0x10/0x18
      
      Freed by task 5:
      save_stack+0x28/0xc8
      __kasan_slab_free+0x118/0x180
      kasan_slab_free+0x10/0x18
      slab_free_freelist_hook+0xa4/0x1a0
      kfree+0xd4/0x3a0
      scsi_host_dev_release+0x100/0x148
      device_release+0x7c/0xe0
      kobject_put+0xb0/0x180
      put_device+0x10/0x20
      scsi_host_put+0x10/0x18
      ata_scsi_add_hosts+0x210/0x268
      ata_host_register+0x228/0x488
      ahci_host_activate+0x1c4/0x2a8
      ahci_init_one+0xd18/0x1298
      local_pci_probe+0x74/0xf0
      work_for_cpu_fn+0x2c/0x48
      process_one_work+0x488/0xc08
      worker_thread+0x330/0x5d0
      kthread+0x1c8/0x1d0
      ret_from_fork+0x10/0x18
      
      There is also refcount issue, as well:
      WARNING: CPU: 1 PID: 1 at lib/refcount.c:28 refcount_warn_saturate+0xf8/0x170
      
      The issue is that we make an erroneous extra call to scsi_host_put()
      for that host:
      
      So in ahci_init_one()->ata_host_alloc_pinfo()->ata_host_alloc(), we setup
      a device release method - ata_devres_release() - which intends to release
      the SCSI hosts:
      
      static void ata_devres_release(struct device *gendev, void *res)
      {
      	...
      	for (i = 0; i < host->n_ports; i++) {
      		struct ata_port *ap = host->ports[i];
      
      		if (!ap)
      			continue;
      
      		if (ap->scsi_host)
      			scsi_host_put(ap->scsi_host);
      
      	}
      	...
      }
      
      However in the ata_scsi_add_hosts() error path, we also call
      scsi_host_put() for the SCSI hosts.
      
      Fix by removing the the scsi_host_put() calls in ata_scsi_add_hosts() and
      leave this to ata_devres_release().
      
      Fixes: f3187195 ("libata: separate out ata_host_alloc() and ata_host_register()")
      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>
      2e70b9a8
    • Andy Lutomirski's avatar
      selftests/x86/ptrace_syscall_32: Fix no-vDSO segfault · e9a6040f
      Andy Lutomirski authored
      [ Upstream commit 630b99ab ]
      
      If AT_SYSINFO is not present, don't try to call a NULL pointer.
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/faaf688265a7e1a5b944d6f8bc0f6368158306d3.1584052409.git.luto@kernel.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9a6040f
    • Michael Wang's avatar
      sched: Avoid scale real weight down to zero · c7539ebd
      Michael Wang authored
      [ Upstream commit 26cf5222 ]
      
      During our testing, we found a case that shares no longer
      working correctly, the cgroup topology is like:
      
        /sys/fs/cgroup/cpu/A		(shares=102400)
        /sys/fs/cgroup/cpu/A/B	(shares=2)
        /sys/fs/cgroup/cpu/A/B/C	(shares=1024)
      
        /sys/fs/cgroup/cpu/D		(shares=1024)
        /sys/fs/cgroup/cpu/D/E	(shares=1024)
        /sys/fs/cgroup/cpu/D/E/F	(shares=1024)
      
      The same benchmark is running in group C & F, no other tasks are
      running, the benchmark is capable to consumed all the CPUs.
      
      We suppose the group C will win more CPU resources since it could
      enjoy all the shares of group A, but it's F who wins much more.
      
      The reason is because we have group B with shares as 2, since
      A->cfs_rq.load.weight == B->se.load.weight == B->shares/nr_cpus,
      so A->cfs_rq.load.weight become very small.
      
      And in calc_group_shares() we calculate shares as:
      
        load = max(scale_load_down(cfs_rq->load.weight), cfs_rq->avg.load_avg);
        shares = (tg_shares * load) / tg_weight;
      
      Since the 'cfs_rq->load.weight' is too small, the load become 0
      after scale down, although 'tg_shares' is 102400, shares of the se
      which stand for group A on root cfs_rq become 2.
      
      While the se of D on root cfs_rq is far more bigger than 2, so it
      wins the battle.
      
      Thus when scale_load_down() scale real weight down to 0, it's no
      longer telling the real story, the caller will have the wrong
      information and the calculation will be buggy.
      
      This patch add check in scale_load_down(), so the real weight will
      be >= MIN_SHARES after scale, after applied the group C wins as
      expected.
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarMichael Wang <yun.wang@linux.alibaba.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Link: https://lkml.kernel.org/r/38e8e212-59a1-64b2-b247-b6d0b52d8dc1@linux.alibaba.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      c7539ebd
    • Sungbo Eo's avatar
      irqchip/versatile-fpga: Handle chained IRQs properly · 6b8147a1
      Sungbo Eo authored
      [ Upstream commit 486562da ]
      
      Enclose the chained handler with chained_irq_{enter,exit}(), so that the
      muxed interrupts get properly acked.
      
      This patch also fixes a reboot bug on OX820 SoC, where the jiffies timer
      interrupt is never acked. The kernel waits a clock tick forever in
      calibrate_delay_converge(), which leads to a boot hang.
      
      Fixes: c41b16f8 ("ARM: integrator/versatile: consolidate FPGA IRQ handling code")
      Signed-off-by: default avatarSungbo Eo <mans0n@gorani.run>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20200319023448.1479701-1-mans0n@gorani.runSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      6b8147a1
    • Alain Volmat's avatar
      i2c: st: fix missing struct parameter description · bdeeb6cb
      Alain Volmat authored
      [ Upstream commit f491c668 ]
      
      Fix a missing struct parameter description to allow
      warning free W=1 compilation.
      Signed-off-by: default avatarAlain Volmat <avolmat@me.com>
      Reviewed-by: default avatarPatrice Chotard <patrice.chotard@st.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bdeeb6cb
    • Xu Wang's avatar
      qlcnic: Fix bad kzalloc null test · f535c750
      Xu Wang authored
      [ Upstream commit bcaeb886 ]
      
      In qlcnic_83xx_get_reset_instruction_template, the variable
      of null test is bad, so correct it.
      Signed-off-by: default avatarXu Wang <vulab@iscas.ac.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f535c750
    • Zheng Wei's avatar
      net: vxge: fix wrong __VA_ARGS__ usage · 3c56ccde
      Zheng Wei authored
      [ Upstream commit b317538c ]
      
      printk in macro vxge_debug_ll uses __VA_ARGS__ without "##" prefix,
      it causes a build error when there is no variable
      arguments(e.g. only fmt is specified.).
      Signed-off-by: default avatarZheng Wei <wei.zheng@vivo.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c56ccde
    • Ondrej Jirman's avatar
      bus: sunxi-rsb: Return correct data when mixing 16-bit and 8-bit reads · b41174d9
      Ondrej Jirman authored
      [ Upstream commit a43ab30d ]
      
      When doing a 16-bit read that returns data in the MSB byte, the
      RSB_DATA register will keep the MSB byte unchanged when doing
      the following 8-bit read. sunxi_rsb_read() will then return
      a result that contains high byte from 16-bit read mixed with
      the 8-bit result.
      
      The consequence is that after this happens the PMIC's regmap will
      look like this: (0x33 is the high byte from the 16-bit read)
      
      % cat /sys/kernel/debug/regmap/sunxi-rsb-3a3/registers
      00: 33
      01: 33
      02: 33
      03: 33
      04: 33
      05: 33
      06: 33
      07: 33
      08: 33
      09: 33
      0a: 33
      0b: 33
      0c: 33
      0d: 33
      0e: 33
      [snip]
      
      Fix this by masking the result of the read with the correct mask
      based on the size of the read. There are no 16-bit users in the
      mainline kernel, so this doesn't need to get into the stable tree.
      Signed-off-by: default avatarOndrej Jirman <megous@megous.com>
      Acked-by: default avatarChen-Yu Tsai <wens@csie.org>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b41174d9
  2. 13 Apr, 2020 26 commits