commit 85b047c685fcb60f9d3538d3cf57dcd9cdda5bbc
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Nov 5 11:51:58 2020 +0100

    Linux 5.9.5
    
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Jeffrin Jose T <jeffrin@rajagiritech.edu.in>
    Link: https://lore.kernel.org/r/20201103203348.153465465@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b602720eaf0de597a116325b016cc739395c7899
Author: Damien Le Moal <damien.lemoal@wdc.com>
Date:   Thu Oct 29 20:05:00 2020 +0900

    null_blk: Fix locking in zoned mode
    
    commit aa1c09cb65e2ed17cb8e652bc7ec84e0af1229eb upstream.
    
    When the zoned mode is enabled in null_blk, Serializing read, write
    and zone management operations for each zone is necessary to protect
    device level information for managing zone resources (zone open and
    closed counters) as well as each zone condition and write pointer
    position. Commit 35bc10b2eafb ("null_blk: synchronization fix for
    zoned device") introduced a spinlock to implement this serialization.
    However, when memory backing is also enabled, GFP_NOIO memory
    allocations are executed under the spinlock, resulting in might_sleep()
    warnings. Furthermore, the zone_lock spinlock is locked/unlocked using
    spin_lock_irq/spin_unlock_irq, similarly to the memory backing code with
    the nullb->lock spinlock. This nested use of irq locks wrecks the irq
    enabled/disabled state.
    
    Fix all this by introducing a bitmap for per-zone lock, with locking
    implemented using wait_on_bit_lock_io() and clear_and_wake_up_bit().
    This locking mechanism allows keeping a zone locked while executing
    null_process_cmd(), serializing all operations to the zone while
    allowing to sleep during memory backing allocation with GFP_NOIO.
    Device level zone resource management information is protected using
    a spinlock which is not held while executing null_process_cmd();
    
    Fixes: 35bc10b2eafb ("null_blk: synchronization fix for zoned device")
    Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02d74bee80e0d2b1cf2fce8eb71ce8b06daf381f
Author: Damien Le Moal <damien.lemoal@wdc.com>
Date:   Thu Oct 29 20:04:59 2020 +0900

    null_blk: Fix zone reset all tracing
    
    commit f9c9104288da543cd64f186f9e2fba389f415630 upstream.
    
    In the cae of the REQ_OP_ZONE_RESET_ALL operation, the command sector is
    ignored and the operation is applied to all sequential zones. For these
    commands, tracing the effect of the command using the command sector to
    determine the target zone is thus incorrect.
    
    Fix null_zone_mgmt() zone condition tracing in the case of
    REQ_OP_ZONE_RESET_ALL to apply tracing to all sequential zones that are
    not already empty.
    
    Fixes: 766c3297d7e1 ("null_blk: add trace in null_blk_zoned.c")
    Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 167ebb193db90c6271dd79fc77d2d04fee19bf47
Author: Quanyang Wang <quanyang.wang@windriver.com>
Date:   Tue Sep 29 16:20:27 2020 +0800

    time/sched_clock: Mark sched_clock_read_begin/retry() as notrace
    
    commit 4cd2bb12981165f865d2b8ed92b446b52310ef74 upstream.
    
    Since sched_clock_read_begin() and sched_clock_read_retry() are called
    by notrace function sched_clock(), they shouldn't be traceable either,
    or else ftrace_graph_caller will run into a dead loop on the path
    as below (arm for instance):
    
      ftrace_graph_caller()
        prepare_ftrace_return()
          function_graph_enter()
            ftrace_push_return_trace()
              trace_clock_local()
                sched_clock()
                  sched_clock_read_begin/retry()
    
    Fixes: 1b86abc1c645 ("sched_clock: Expose struct clock_read_data")
    Signed-off-by: Quanyang Wang <quanyang.wang@windriver.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200929082027.16787-1-quanyang.wang@windriver.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3ac4fb8895e5061374b4fd9026d59e8cca53741e
Author: Zeng Tao <prime.zeng@hisilicon.com>
Date:   Tue Sep 1 17:30:13 2020 +0800

    time: Prevent undefined behaviour in timespec64_to_ns()
    
    commit cb47755725da7b90fecbb2aa82ac3b24a7adb89b upstream.
    
    UBSAN reports:
    
    Undefined behaviour in ./include/linux/time64.h:127:27
    signed integer overflow:
    17179869187 * 1000000000 cannot be represented in type 'long long int'
    Call Trace:
     timespec64_to_ns include/linux/time64.h:127 [inline]
     set_cpu_itimer+0x65c/0x880 kernel/time/itimer.c:180
     do_setitimer+0x8e/0x740 kernel/time/itimer.c:245
     __x64_sys_setitimer+0x14c/0x2c0 kernel/time/itimer.c:336
     do_syscall_64+0xa1/0x540 arch/x86/entry/common.c:295
    
    Commit bd40a175769d ("y2038: itimer: change implementation to timespec64")
    replaced the original conversion which handled time clamping correctly with
    timespec64_to_ns() which has no overflow protection.
    
    Fix it in timespec64_to_ns() as this is not necessarily limited to the
    usage in itimers.
    
    [ tglx: Added comment and adjusted the fixes tag ]
    
    Fixes: 361a3bf00582 ("time64: Add time64.h header and define struct timespec64")
    Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1598952616-6416-1-git-send-email-prime.zeng@hisilicon.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dd616e2ae016cf0f1b09be45f00932f579e38598
Author: Jing Xiangfeng <jingxiangfeng@huawei.com>
Date:   Mon Oct 26 15:06:37 2020 +0800

    vdpa/mlx5: Fix error return in map_direct_mr()
    
    commit 7ba08e81cb4aec9724ab7674a5de49e7a341062c upstream.
    
    Fix to return the variable "err" from the error handling case instead
    of "ret".
    
    Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code")
    Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
    Link: https://lore.kernel.org/r/20201026070637.164321-1-jingxiangfeng@huawei.com
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Acked-by: Eli Cohen <elic@nvidia.com>
    Cc: stable@vger.kernel.org
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 89c2fd0d313efe95a9330a6ad2aee930a6a8a075
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Fri Oct 23 15:08:53 2020 +0300

    vhost_vdpa: Return -EFAULT if copy_from_user() fails
    
    commit 7922460e33c81f41e0d2421417228b32e6fdbe94 upstream.
    
    The copy_to/from_user() functions return the number of bytes which we
    weren't able to copy but the ioctl should return -EFAULT if they fail.
    
    Fixes: a127c5bbb6a8 ("vhost-vdpa: fix backend feature ioctls")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Link: https://lore.kernel.org/r/20201023120853.GI282278@mwanda
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Cc: stable@vger.kernel.org
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 55124c2cd137e3543804523357552f58a65ceeca
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Thu Oct 29 12:12:46 2020 +0100

    cpufreq: schedutil: Always call driver if CPUFREQ_NEED_UPDATE_LIMITS is set
    
    commit d1e7c2996e988866e7ceceb4641a0886885b7889 upstream.
    
    Because sugov_update_next_freq() may skip a frequency update even if
    the need_freq_update flag has been set for the policy at hand, policy
    limits updates may not take effect as expected.
    
    For example, if the intel_pstate driver operates in the passive mode
    with HWP enabled, it needs to update the HWP min and max limits when
    the policy min and max limits change, respectively, but that may not
    happen if the target frequency does not change along with the limit
    at hand.  In particular, if the policy min is changed first, causing
    the target frequency to be adjusted to it, and the policy max limit
    is changed later to the same value, the HWP max limit will not be
    updated to follow it as expected, because the target frequency is
    still equal to the policy min limit and it will not change until
    that limit is updated.
    
    To address this issue, modify get_next_freq() to let the driver
    callback run if the CPUFREQ_NEED_UPDATE_LIMITS cpufreq driver flag
    is set regardless of whether or not the new frequency to set is
    equal to the previous one.
    
    Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled")
    Reported-by: Zhang Rui <rui.zhang@intel.com>
    Tested-by: Zhang Rui <rui.zhang@intel.com>
    Cc: 5.9+ <stable@vger.kernel.org> # 5.9+: 1c534352f47f cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS ...
    Cc: 5.9+ <stable@vger.kernel.org> # 5.9+: a62f68f5ca53 cpufreq: Introduce cpufreq_driver_test_flags()
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bc1fdacf9e838e53987b78e7db7e46b1fbeea97e
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Fri Oct 23 17:35:46 2020 +0200

    cpufreq: Introduce cpufreq_driver_test_flags()
    
    commit a62f68f5ca53ab61cba2f0a410d0add7a6d54a52 upstream.
    
    Add a helper function to test the flags of the cpufreq driver in use
    againt a given flags mask.
    
    In particular, this will be needed to test the
    CPUFREQ_NEED_UPDATE_LIMITS cpufreq driver flag in the schedutil
    governor.
    
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 48a0855e6c17d753c8d5a0c2605bdd77eef5d375
Author: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Date:   Fri Oct 16 16:56:30 2020 +0200

    staging: octeon: Drop on uncorrectable alignment or FCS error
    
    commit 49d28ebdf1e30d806410eefc7de0a7a1ca5d747c upstream.
    
    Currently in case of alignment or FCS error if the packet cannot be
    corrected it's still not dropped. Report the error properly and drop the
    packet while making the code around a little bit more readable.
    
    Fixes: 80ff0fd3ab64 ("Staging: Add octeon-ethernet driver files.")
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20201016145630.41852-1-alexander.sverdlin@nokia.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9f5bfc1d0ff3271583a81de850e2c3b9b1a65744
Author: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Date:   Fri Oct 16 12:18:57 2020 +0200

    staging: octeon: repair "fixed-link" support
    
    commit 179f5dc36b0a1aa31538d7d8823deb65c39847b3 upstream.
    
    The PHYs must be registered once in device probe function, not in device
    open callback because it's only possible to register them once.
    
    Fixes: a25e278020bf ("staging: octeon: support fixed-link phys")
    Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20201016101858.11374-1-alexander.sverdlin@nokia.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ec3a904e54ed4e84348814309bf451ed3100079e
Author: Ian Abbott <abbotti@mev.co.uk>
Date:   Wed Oct 21 13:21:42 2020 +0100

    staging: comedi: cb_pcidas: Allow 2-channel commands for AO subdevice
    
    commit 647a6002cb41d358d9ac5de101a8a6dc74748a59 upstream.
    
    The "cb_pcidas" driver supports asynchronous commands on the analog
    output (AO) subdevice for those boards that have an AO FIFO.  The code
    (in `cb_pcidas_ao_check_chanlist()` and `cb_pcidas_ao_cmd()`) to
    validate and set up the command supports output to a single channel or
    to two channels simultaneously (the boards have two AO channels).
    However, the code in `cb_pcidas_auto_attach()` that initializes the
    subdevices neglects to initialize the AO subdevice's `len_chanlist`
    member, leaving it set to 0, but the Comedi core will "correct" it to 1
    if the driver neglected to set it.  This limits commands to use a single
    channel (either channel 0 or 1), but the limit should be two channels.
    Set the AO subdevice's `len_chanlist` member to be the same value as the
    `n_chan` member, which will be 2.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
    Link: https://lore.kernel.org/r/20201021122142.81628-1-abbotti@mev.co.uk
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit de728ff77cfe09b948adcca085ad46f6fc2380a3
Author: Jing Xiangfeng <jingxiangfeng@huawei.com>
Date:   Mon Oct 12 21:24:04 2020 +0800

    staging: fieldbus: anybuss: jump to correct label in an error path
    
    commit 7e97e4cbf30026b49b0145c3bfe06087958382c5 upstream.
    
    In current code, controller_probe() misses to call ida_simple_remove()
    in an error path. Jump to correct label to fix it.
    
    Fixes: 17614978ed34 ("staging: fieldbus: anybus-s: support the Arcx anybus controller")
    Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
    Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20201012132404.113031-1-jingxiangfeng@huawei.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ffc1b64ca3a9fae0af5278a212a443cb25578122
Author: Zong Li <zong.li@sifive.com>
Date:   Wed Oct 21 15:38:39 2020 +0800

    stop_machine, rcu: Mark functions as notrace
    
    commit 4230e2deaa484b385aa01d598b2aea8e7f2660a6 upstream.
    
    Some architectures assume that the stopped CPUs don't make function calls
    to traceable functions when they are in the stopped state. See also commit
    cb9d7fd51d9f ("watchdog: Mark watchdog touch functions as notrace").
    
    Violating this assumption causes kernel crashes when switching tracer on
    RISC-V.
    
    Mark rcu_momentary_dyntick_idle() and stop_machine_yield() notrace to
    prevent this.
    
    Fixes: 4ecf0a43e729 ("processor: get rid of cpu_relax_yield")
    Fixes: 366237e7b083 ("stop_machine: Provide RCU quiescent state in multi_cpu_stop()")
    Signed-off-by: Zong Li <zong.li@sifive.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Atish Patra <atish.patra@wdc.com>
    Tested-by: Colin Ian King <colin.king@canonical.com>
    Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Acked-by: Paul E. McKenney <paulmck@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201021073839.43935-1-zong.li@sifive.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7e5bf05d27430f352d8d2a6a42beedb9462beda1
Author: Marc Zyngier <maz@kernel.org>
Date:   Thu Oct 29 17:24:09 2020 +0000

    KVM: arm64: Fix AArch32 handling of DBGD{CCINT,SCRext} and DBGVCR
    
    commit 4a1c2c7f63c52ccb11770b5ae25920a6b79d3548 upstream.
    
    The DBGD{CCINT,SCRext} and DBGVCR register entries in the cp14 array
    are missing their target register, resulting in all accesses being
    targetted at the guard sysreg (indexed by __INVALID_SYSREG__).
    
    Point the emulation code at the actual register entries.
    
    Fixes: bdfb4b389c8d ("arm64: KVM: add trap handlers for AArch32 debug registers")
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201029172409.2768336-1-maz@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 115a9b8c03038a9a108ca500c1f0ffe0fcb8b85a
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Oct 30 16:14:14 2020 +0100

    KVM: x86: Fix NULL dereference at kvm_msr_ignored_check()
    
    commit d383b3146d805a743658225c8973f5d38c6fedf4 upstream.
    
    The newly introduced kvm_msr_ignored_check() tries to print error or
    debug messages via vcpu_*() macros, but those may cause Oops when NULL
    vcpu is passed for KVM_GET_MSRS ioctl.
    
    Fix it by replacing the print calls with kvm_*() macros.
    
    (Note that this will leave vcpu argument completely unused in the
     function, but I didn't touch it to make the fix as small as
     possible.  A clean up may be applied later.)
    
    Fixes: 12bc2132b15e ("KVM: X86: Do the same ignore_msrs check for feature msrs")
    BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1178280
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Message-Id: <20201030151414.20165-1-tiwai@suse.de>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c570a8475e1b45d05e3cbfb77cdcd7960833162a
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Thu Oct 22 21:41:00 2020 +0300

    device property: Don't clear secondary pointer for shared primary firmware node
    
    commit 99aed9227073fb34ce2880cbc7063e04185a65e1 upstream.
    
    It appears that firmware nodes can be shared between devices. In such case
    when a (child) device is about to be deleted, its firmware node may be shared
    and ACPI_COMPANION_SET(..., NULL) call for it breaks the secondary link
    of the shared primary firmware node.
    
    In order to prevent that, check, if the device has a parent and parent's
    firmware node is shared with its child, and avoid crashing the link.
    
    Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
    Reported-by: Ferry Toth <fntoth@gmail.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Tested-by: Ferry Toth <fntoth@gmail.com>
    Cc: 5.9+ <stable@vger.kernel.org> # 5.9+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1c6d3708136bb7be6fa4d8c4b4637d2c1fad425c
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Thu Oct 22 21:40:59 2020 +0300

    device property: Keep secondary firmware node secondary by type
    
    commit d5dcce0c414fcbfe4c2037b66ac69ea5f9b3f75c upstream.
    
    Behind primary and secondary we understand the type of the nodes
    which might define their ordering. However, if primary node gone,
    we can't maintain the ordering by definition of the linked list.
    Thus, by ordering secondary node becomes first in the list.
    But in this case the meaning of it is still secondary (or auxiliary).
    The type of the node is maintained by the secondary pointer in it:
    
            secondary pointer               Meaning
            NULL or valid                   primary node
            ERR_PTR(-ENODEV)                secondary node
    
    So, if by some reason we do the following sequence of calls
    
            set_primary_fwnode(dev, NULL);
            set_primary_fwnode(dev, primary);
    
    we should preserve secondary node.
    
    This concept is supported by the description of set_primary_fwnode()
    along with implementation of set_secondary_fwnode(). Hence, fix
    the commit c15e1bdda436 to follow this as well.
    
    Fixes: c15e1bdda436 ("device property: Fix the secondary firmware node handling in set_primary_fwnode()")
    Cc: Ferry Toth <fntoth@gmail.com>
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Tested-by: Ferry Toth <fntoth@gmail.com>
    Cc: 5.9+ <stable@vger.kernel.org> # 5.9+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bedf37fc2b0931c12b08067edd21f9f95e787d07
Author: Suzuki K Poulose <suzuki.poulose@arm.com>
Date:   Thu Oct 29 10:45:58 2020 -0600

    coresight: cti: Initialize dynamic sysfs attributes
    
    commit 80624263fa289b3416f7ca309491f1b75e579477 upstream.
    
    With LOCKDEP enabled, CTI driver triggers the following splat due
    to uninitialized lock class for dynamically allocated attribute
    objects.
    
    [    5.372901] coresight etm0: CPU0: ETM v4.0 initialized
    [    5.376694] coresight etm1: CPU1: ETM v4.0 initialized
    [    5.380785] coresight etm2: CPU2: ETM v4.0 initialized
    [    5.385851] coresight etm3: CPU3: ETM v4.0 initialized
    [    5.389808] BUG: key ffff00000564a798 has not been registered!
    [    5.392456] ------------[ cut here ]------------
    [    5.398195] DEBUG_LOCKS_WARN_ON(1)
    [    5.398233] WARNING: CPU: 1 PID: 32 at kernel/locking/lockdep.c:4623 lockdep_init_map_waits+0x14c/0x260
    [    5.406149] Modules linked in:
    [    5.415411] CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.9.0-12034-gbbe85027ce80 #51
    [    5.418553] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
    [    5.426453] Workqueue: events amba_deferred_retry_func
    [    5.433299] pstate: 40000005 (nZcv daif -PAN -UAO -TCO BTYPE=--)
    [    5.438252] pc : lockdep_init_map_waits+0x14c/0x260
    [    5.444410] lr : lockdep_init_map_waits+0x14c/0x260
    [    5.449007] sp : ffff800012bbb720
    ...
    
    [    5.531561] Call trace:
    [    5.536847]  lockdep_init_map_waits+0x14c/0x260
    [    5.539027]  __kernfs_create_file+0xa8/0x1c8
    [    5.543539]  sysfs_add_file_mode_ns+0xd0/0x208
    [    5.548054]  internal_create_group+0x118/0x3c8
    [    5.552307]  internal_create_groups+0x58/0xb8
    [    5.556733]  sysfs_create_groups+0x2c/0x38
    [    5.561160]  device_add+0x2d8/0x768
    [    5.565148]  device_register+0x28/0x38
    [    5.568537]  coresight_register+0xf8/0x320
    [    5.572358]  cti_probe+0x1b0/0x3f0
    
    ...
    
    Fix this by initializing the attributes when they are allocated.
    
    Fixes: 3c5597e39812 ("coresight: cti: Add connection information to sysfs")
    Reported-by: Leo Yan <leo.yan@linaro.org>
    Tested-by: Leo Yan <leo.yan@linaro.org>
    Cc: Mike Leach <mike.leach@linaro.org>
    Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Link: https://lore.kernel.org/r/20201029164559.1268531-2-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0dc0cd2c6abc44af33cfeda1daf323bf20ef0de0
Author: Kanchan Joshi <joshi.k@samsung.com>
Date:   Mon Sep 28 15:25:49 2020 +0530

    null_blk: synchronization fix for zoned device
    
    commit 35bc10b2eafbb701064b94f283b77c54d3304842 upstream.
    
    Parallel write,read,zone-mgmt operations accessing/altering zone state
    and write-pointer may get into race. Avoid the situation by using a new
    spinlock for zoned device.
    Concurrent zone-appends (on a zone) returning same write-pointer issue
    is also avoided using this lock.
    
    Cc: stable@vger.kernel.org
    Fixes: e0489ed5daeb ("null_blk: Support REQ_OP_ZONE_APPEND")
    Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
    Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 48133352c5e678a31f3f974146e03f3ff4bde11d
Author: Pali Rohár <pali@kernel.org>
Date:   Mon Sep 7 13:27:17 2020 +0200

    arm64: dts: marvell: espressobin: Add ethernet switch aliases
    
    commit b64d814257b027e29a474bcd660f6372490138c7 upstream.
    
    Espressobin boards have 3 ethernet ports and some of them got assigned more
    then one MAC address. MAC addresses are stored in U-Boot environment.
    
    Since commit a2c7023f7075c ("net: dsa: read mac address from DT for slave
    device") kernel can use MAC addresses from DT for particular DSA port.
    
    Currently Espressobin DTS file contains alias just for ethernet0.
    
    This patch defines additional ethernet aliases in Espressobin DTS files, so
    bootloader can fill correct MAC address for DSA switch ports if more MAC
    addresses were specified.
    
    DT alias ethernet1 is used for wan port, DT aliases ethernet2 and ethernet3
    are used for lan ports for both Espressobin revisions (V5 and V7).
    
    Fixes: 5253cb8c00a6f ("arm64: dts: marvell: espressobin: add ethernet alias")
    Cc: <stable@vger.kernel.org> # a2c7023f7075c: dsa: read mac address
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Reviewed-by: Andre Heider <a.heider@gmail.com>
    Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 63632bd5dd31485450834948155be98703aaccb7
Author: Fangrui Song <maskray@google.com>
Date:   Thu Oct 29 11:19:51 2020 -0700

    arm64: Change .weak to SYM_FUNC_START_WEAK_PI for arch/arm64/lib/mem*.S
    
    commit ec9d78070de986ecf581ea204fd322af4d2477ec upstream.
    
    Commit 39d114ddc682 ("arm64: add KASAN support") added .weak directives to
    arch/arm64/lib/mem*.S instead of changing the existing SYM_FUNC_START_PI
    macros. This can lead to the assembly snippet `.weak memcpy ... .globl
    memcpy` which will produce a STB_WEAK memcpy with GNU as but STB_GLOBAL
    memcpy with LLVM's integrated assembler before LLVM 12. LLVM 12 (since
    https://reviews.llvm.org/D90108) will error on such an overridden symbol
    binding.
    
    Use the appropriate SYM_FUNC_START_WEAK_PI instead.
    
    Fixes: 39d114ddc682 ("arm64: add KASAN support")
    Reported-by: Sami Tolvanen <samitolvanen@google.com>
    Signed-off-by: Fangrui Song <maskray@google.com>
    Tested-by: Sami Tolvanen <samitolvanen@google.com>
    Tested-by: Nick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20201029181951.1866093-1-maskray@google.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8cad84ff21ea8105d891c09645a38b7d8ffe3c6b
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Tue Aug 4 21:26:49 2020 +0200

    ARM: s3c24xx: fix missing system reset
    
    commit f6d7cde84f6c5551586c8b9b68d70f8e6dc9a000 upstream.
    
    Commit f6361c6b3880 ("ARM: S3C24XX: remove separate restart code")
    removed usage of the watchdog reset platform code in favor of the
    Samsung SoC watchdog driver.  However the latter was not selected thus
    S3C24xx platforms lost reset abilities.
    
    Cc: <stable@vger.kernel.org>
    Fixes: f6361c6b3880 ("ARM: S3C24XX: remove separate restart code")
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b5ddb8d581bb7b030a57cfe53de50dad428af685
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Thu Sep 10 17:41:49 2020 +0200

    ARM: samsung: fix PM debug build with DEBUG_LL but !MMU
    
    commit 7be0d19c751b02db778ca95e3274d5ea7f31891c upstream.
    
    Selecting CONFIG_SAMSUNG_PM_DEBUG (depending on CONFIG_DEBUG_LL) but
    without CONFIG_MMU leads to build errors:
    
      arch/arm/plat-samsung/pm-debug.c: In function ‘s3c_pm_uart_base’:
      arch/arm/plat-samsung/pm-debug.c:57:2: error:
        implicit declaration of function ‘debug_ll_addr’ [-Werror=implicit-function-declaration]
    
    Fixes: 99b2fc2b8b40 ("ARM: SAMSUNG: Use debug_ll_addr() to get UART base address")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200910154150.3318-1-krzk@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d7121a31593c551f77a4b136346fd4802beb888a
Author: Joel Stanley <joel@jms.id.au>
Date:   Wed Aug 26 16:49:16 2020 +0930

    ARM: config: aspeed: Fix selection of media drivers
    
    commit 98c3f0a1b3ef83f6be6b212c970bee795e1a0467 upstream.
    
    In the 5.7 merge window the media kconfig was restructued. For most
    platforms these changes set CONFIG_MEDIA_SUPPORT_FILTER=y which keeps
    unwanted drivers disabled.
    
    The exception is if a config sets EMBEDDED or EXPERT (see b0cd4fb27665).
    In that case the filter is set to =n, causing a bunch of DVB tuner drivers
    (MEDIA_TUNER_*) to be accidentally enabled. This was noticed as it blew
    out the build time for the Aspeed defconfigs.
    
    Enabling the filter means the Aspeed config also needs to set
    CONFIG_MEDIA_PLATFORM_SUPPORT=y in order to have the CONFIG_VIDEO_ASPEED
    driver enabled.
    
    Fixes: 06b93644f4d1 ("media: Kconfig: add an option to filter in/out platform drivers")
    Fixes: b0cd4fb27665 ("media: Kconfig: on !EMBEDDED && !EXPERT, enable driver filtering")
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Cc: stable@vger.kernel.org
    CC: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8bb7513909ed1cedaf5a72aa9406858b56d25a1a
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:20 2020 +0200

    ARM: dts: s5pv210: fix pinctrl property of "vibrator-en" regulator in Aries
    
    commit 2c6658c607a3af2ed7bd41dc57a3dd31537d023e upstream.
    
    Fix typo in pinctrl property of "vibrator-en" fixed regulator in Aries
    family of boards.  The error caused lack of pin configuration for the
    GPIO used in vibrator.
    
    Fixes: 04568cb58a43 ("ARM: dts: s5pv210: Disable pull for vibrator enable GPIO on Aries boards")
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200907161141.31034-5-krzk@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d5c6c00d6e68afbc541ee907d8df2c035fe73833
Author: Joel Stanley <joel@jms.id.au>
Date:   Wed Aug 12 20:54:00 2020 +0930

    ARM: aspeed: g5: Do not set sirq polarity
    
    commit c82bf6e133d30e0f9172a20807814fa28aef0f67 upstream.
    
    A feature was added to the aspeed vuart driver to configure the vuart
    interrupt (sirq) polarity according to the LPC/eSPI strapping register.
    
    Systems that depend on a active low behaviour (sirq_polarity set to 0)
    such as OpenPower boxes also use LPC, so this relationship does not
    hold. Jeremy confirms that the s2600st which is strapped for eSPI also
    does not have this relationship.
    
    The property was added for a Tyan S7106 system which is not supported
    in the kernel tree. Should this or other systems wish to use this
    feature of the driver they should add it to the machine specific device
    tree.
    
    Fixes: c791fc76bc72 ("arm: dts: aspeed: Add vuart aspeed,sirq-polarity-sense...")
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Tested-by: Jeremy Kerr <jk@ozlabs.org>
    Reviewed-by: Jeremy Kerr <jk@ozlabs.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200812112400.2406734-1-joel@jms.id.au
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2ee94635b2b675239a22fab26eeecba521b567f9
Author: Frank Wunderlich <frank-w@public-files.de>
Date:   Mon Sep 7 09:05:17 2020 +0200

    arm: dts: mt7623: add missing pause for switchport
    
    commit 36f0a5fc5284838c544218666c63ee8cfa46a9c3 upstream.
    
    port6 of mt7530 switch (= cpu port 0) on bananapi-r2 misses pause option
    which causes rx drops on running iperf.
    
    Fixes: f4ff257cd160 ("arm: dts: mt7623: add support for Bananapi R2 (BPI-R2) board")
    Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200907070517.51715-1-linux@fw-web.de
    Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e25d2556c756d22b62149af8a357c85bce0d1f8a
Author: Helge Deller <deller@gmx.de>
Date:   Mon Oct 19 16:57:50 2020 +0200

    hil/parisc: Disable HIL driver when it gets stuck
    
    commit 879bc2d27904354b98ca295b6168718e045c4aa2 upstream.
    
    When starting a HP machine with HIL driver but without an HIL keyboard
    or HIL mouse attached, it may happen that data written to the HIL loop
    gets stuck (e.g. because the transaction queue is full).  Usually one
    will then have to reboot the machine because all you see is and endless
    output of:
     Transaction add failed: transaction already queued?
    
    In the higher layers hp_sdc_enqueue_transaction() is called to queued up
    a HIL packet. This function returns an error code, and this patch adds
    the necessary checks for this return code and disables the HIL driver if
    further packets can't be sent.
    
    Tested on a HP 730 and a HP 715/64 machine.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6657fd8e618e3d31c4338fe5ed807c9ac16b8395
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Mon Oct 26 09:12:10 2020 +0000

    cachefiles: Handle readpage error correctly
    
    commit 9480b4e75b7108ee68ecf5bc6b4bd68e8031c521 upstream.
    
    If ->readpage returns an error, it has already unlocked the page.
    
    Fixes: 5e929b33c393 ("CacheFiles: Handle truncate unlocking the page we're reading")
    Cc: stable@vger.kernel.org
    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 95be27d273f4896347d8d76e5bcefcde2e75025d
Author: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Date:   Fri Oct 9 15:08:31 2020 +0800

    arm64: berlin: Select DW_APB_TIMER_OF
    
    commit b0fc70ce1f028e14a37c186d9f7a55e51439b83a upstream.
    
    Berlin SoCs always contain some DW APB timers which can be used as an
    always-on broadcast timer.
    
    Link: https://lore.kernel.org/r/20201009150536.214181fb@xhacker.debian
    Cc: <stable@vger.kernel.org> # v3.14+
    Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8a071286dbe17c9aa690f6c7c2b8e5495cf82a30
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Oct 26 13:15:23 2020 -0700

    tty: make FONTX ioctl use the tty pointer they were actually passed
    
    commit 90bfdeef83f1d6c696039b6a917190dcbbad3220 upstream.
    
    Some of the font tty ioctl's always used the current foreground VC for
    their operations.  Don't do that then.
    
    This fixes a data race on fg_console.
    
    Side note: both Michael Ellerman and Jiri Slaby point out that all these
    ioctls are deprecated, and should probably have been removed long ago,
    and everything seems to be using the KDFONTOP ioctl instead.
    
    In fact, Michael points out that it looks like busybox's loadfont
    program seems to have switched over to using KDFONTOP exactly _because_
    of this bug (ahem.. 12 years ago ;-).
    
    Reported-by: Minh Yuan <yuanmingbuaa@gmail.com>
    Acked-by: Michael Ellerman <mpe@ellerman.id.au>
    Acked-by: Jiri Slaby <jirislaby@kernel.org>
    Cc: Greg KH <greg@kroah.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 561133aabab35c4304c20b6e712d5c5af0657660
Author: Likun Gao <Likun.Gao@amd.com>
Date:   Thu Oct 22 00:50:07 2020 +0800

    drm/amdgpu: correct the cu and rb info for sienna cichlid
    
    commit 687e79c0feb4243b141b1e9a20adba3c0ec66f7f upstream.
    
    Skip disabled sa to correct the cu_info and active_rbs for sienna cichlid.
    
    Signed-off-by: Likun Gao <Likun.Gao@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 5.9.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7d03d9b4df1a43baf81a6dc4329f8e23d10e2764
Author: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Date:   Fri Oct 16 10:50:44 2020 -0400

    drm/amd/psp: Fix sysfs: cannot create duplicate filename
    
    commit f1bcddffe46b349a82445a8d9efd5f5fcb72557f upstream.
    
    psp sysfs not cleaned up on driver unload for sienna_cichlid
    
    Fixes: ce87c98db428e7 ("drm/amdgpu: Include sienna_cichlid in USBC PD FW support.")
    Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 5.9.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6d85b48e063aab563ed1c3420e38325253891189
Author: Kevin Wang <kevin1.wang@amd.com>
Date:   Fri Oct 16 11:07:47 2020 +0800

    drm/amd/swsmu: add missing feature map for sienna_cichlid
    
    commit d48d7484d8dca1d4577fc53f1f826e68420d00eb upstream.
    
    it will cause smu sysfs node of "pp_features" show error.
    
    Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
    Reviewed-by: Likun Gao <Likun.Gao@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 5.9.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit eddae14564765c4231c25984f3b73af5758e8b5b
Author: Kenneth Feng <kenneth.feng@amd.com>
Date:   Wed Oct 21 16:15:47 2020 +0800

    drm/amd/pm: fix pp_dpm_fclk
    
    commit 392d256fa26d943fb0a019fea4be80382780d3b1 upstream.
    
    fclk value is missing in pp_dpm_fclk. add this to correctly show the current value.
    
    Signed-off-by: Kenneth Feng <kenneth.feng@amd.com>
    Reviewed-by: Likun Gao <Likun.Gao@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 5.9.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5489db9d093fdcea1af0d151a5b176855d62f22c
Author: Evan Quan <evan.quan@amd.com>
Date:   Wed Sep 2 16:10:10 2020 +0800

    drm/amd/pm: increase mclk switch threshold to 200 us
    
    commit 83da6eea3af669ee0b1f1bc05ffd6150af984994 upstream.
    
    To avoid underflow seen on Polaris10 with some 3440x1440
    144Hz displays. As the threshold of 190 us cuts too close
    to minVBlankTime of 192 us.
    
    Signed-off-by: Evan Quan <evan.quan@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 84493deabfd73f1d0200986ba9f4aab3d44b368b
Author: Alex Deucher <alexander.deucher@amd.com>
Date:   Mon Oct 26 17:30:28 2020 -0400

    drm/amdgpu/swsmu: drop smu i2c bus on navi1x
    
    commit 10105d0c9763f058f6a9a09f78397d5bf94dc94c upstream.
    
    Stop registering the SMU i2c bus on navi1x.  This leads to instability
    issues when userspace processes mess with the bus and also seems to
    cause display stability issues in some cases.
    
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1314
    Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1341
    Reviewed-by: Evan Quan <evan.quan@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 10f8db3c60d2a75eaf2624a4c6ddfff3fa68a29a
Author: Andrei Vagin <avagin@gmail.com>
Date:   Thu Oct 15 09:00:19 2020 -0700

    futex: Adjust absolute futex timeouts with per time namespace offset
    
    commit c2f7d08cccf4af2ce6992feaabb9e68e4ae0bff3 upstream.
    
    For all commands except FUTEX_WAIT, the timeout is interpreted as an
    absolute value. This absolute value is inside the task's time namespace and
    has to be converted to the host's time.
    
    Fixes: 5a590f35add9 ("posix-clocks: Wire up clock_gettime() with timens offsets")
    Reported-by: Hans van der Laan <j.h.vanderlaan@student.utwente.nl>
    Signed-off-by: Andrei Vagin <avagin@gmail.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20201015160020.293748-1-avagin@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b7bbf035c7d19b735ec709a02d7298bc77907037
Author: Alex Dewar <alex.dewar90@gmail.com>
Date:   Thu Aug 20 18:21:18 2020 +0100

    memory: brcmstb_dpfe: Fix memory leak
    
    commit 4da1edcf8f226d53c02c6b0e3077d581115b30d0 upstream.
    
    In brcmstb_dpfe_download_firmware(), memory is allocated to variable fw by
    firmware_request_nowarn(), but never released. Fix up to release fw on
    all return paths.
    
    Cc: <stable@vger.kernel.org>
    Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
    Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
    Acked-by: Markus Mayer <mmayer@broadcom.com>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/20200820172118.781324-1-alex.dewar90@gmail.com
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 38ae02bf311295db0e5a4c4fca8d4f0e78044c2e
Author: Thierry Reding <treding@nvidia.com>
Date:   Tue Sep 1 17:32:48 2020 +0200

    memory: tegra: Remove GPU from DRM IOMMU group
    
    commit ea90f66f2a8629dde07328df0b8314aae5e54a47 upstream.
    
    Commit 63a613fdb16c ("memory: tegra: Add gr2d and gr3d to DRM IOMMU
    group") added the GPU to the DRM IOMMU group, which doesn't make any
    sense. This causes problems when Nouveau tries to attach to the SMMU
    and causes it to fall back to using the DMA API.
    
    Remove the GPU from the DRM groups to restore the old behaviour. The
    GPU should always have its own IOMMU domain to make sure it can map
    buffers into contiguous chunks (for big page support) without getting
    in the way of mappings from the DRM group.
    
    Cc: <stable@vger.kernel.org>
    Fixes: 63a613fdb16c ("memory: tegra: Add gr2d and gr3d to DRM IOMMU group")
    Reported-by: Matias Zuniga <matias.nicolas.zc@gmail.com>
    Signed-off-by: Thierry Reding <treding@nvidia.com>
    Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
    Link: https://lore.kernel.org/r/20200901153248.1831263-1-thierry.reding@gmail.com
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 54ba7d5296b9d09ba7788ca412e2f988d726618d
Author: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Date:   Thu Oct 15 17:41:15 2020 +0800

    mmc: sdhci: Use Auto CMD Auto Select only when v4_mode is true
    
    commit b3e1ea16fb39fb6e1a1cf1dbdd6738531de3dc7d upstream.
    
    sdhci-of-dwcmshc meets an eMMC read performance regression with below
    command after commit 427b6514d095 ("mmc: sdhci: Add Auto CMD Auto
    Select support"):
    
    dd if=/dev/mmcblk0 of=/dev/null bs=8192 count=100000
    
    Before the commit, the above command gives 120MB/s
    After the commit, the above command gives 51.3 MB/s
    
    So it looks like sdhci-of-dwcmshc expects Version 4 Mode for Auto
    CMD Auto Select. Fix the performance degradation by ensuring v4_mode
    is true to use Auto CMD Auto Select.
    
    Fixes: 427b6514d095 ("mmc: sdhci: Add Auto CMD Auto Select support")
    Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201015174115.4cf2c19a@xhacker.debian
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f75a51933d12b9a0bbe5b682a9bc3ccf19ab8865
Author: Michael Walle <michael@walle.cc>
Date:   Fri Oct 23 00:23:37 2020 +0200

    mmc: sdhci-of-esdhc: set timeout to max before tuning
    
    commit 0add6e9b88d0632a25323aaf4987dbacb0e4ae64 upstream.
    
    On rare occations there is the following error:
    
      mmc0: Tuning timeout, falling back to fixed sampling clock
    
    There are SD cards which takes a significant longer time to reply to the
    first CMD19 command. The eSDHC takes the data timeout value into account
    during the tuning period. The SDHCI core doesn't explicitly set this
    timeout for the tuning procedure. Thus on the slow cards, there might be
    a spurious "Buffer Read Ready" interrupt, which in turn triggers a wrong
    sequence of events. In the end this will lead to an unsuccessful tuning
    procedure and to the above error.
    
    To workaround this, set the timeout to the maximum value (which is the
    best we can do) and the SDHCI core will take care of the proper timeout
    handling.
    
    Fixes: ba49cbd0936e ("mmc: sdhci-of-esdhc: add tuning support")
    Signed-off-by: Michael Walle <michael@walle.cc>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201022222337.19857-1-michael@walle.cc
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bbca4ddb9a766f98372bd3db496b84f3aca598a0
Author: Yangbo Lu <yangbo.lu@nxp.com>
Date:   Tue Oct 20 16:11:16 2020 +0800

    mmc: sdhci-of-esdhc: make sure delay chain locked for HS400
    
    commit 011fde48394b7dc8dfd6660d1013b26a00157b80 upstream.
    
    For eMMC HS400 mode initialization, the DLL reset is a required step
    if DLL is enabled to use previously, like in bootloader.
    This step has not been documented in reference manual, but the RM will
    be fixed sooner or later.
    
    This patch is to add the step of DLL reset, and make sure delay chain
    locked for HS400.
    
    Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Link: https://lore.kernel.org/r/20201020081116.20918-1-yangbo.lu@nxp.com
    Fixes: 54e08d9a95ca ("mmc: sdhci-of-esdhc: add hs400 mode support")
    Cc: stable@vger.kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 07e0606650822b9cd5cb997b1d70945c5eb439fa
Author: Dave Airlie <airlied@redhat.com>
Date:   Tue Oct 20 08:22:53 2020 +1000

    drm/ttm: fix eviction valuable range check.
    
    commit fea456d82c19d201c21313864105876deabe148b upstream.
    
    This was adding size to start, but pfn and start are in pages,
    so it should be using num_pages.
    
    Not sure this fixes anything in the real world, just noticed it
    during refactoring.
    
    Signed-off-by: Dave Airlie <airlied@redhat.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Cc: stable@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20201019222257.1684769-2-airlied@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cef20b45c9024fe43e9bc3a25f557d99f68d5d1a
Author: yangerkun <yangerkun@huawei.com>
Date:   Wed Oct 28 13:56:17 2020 +0800

    ext4: do not use extent after put_bh
    
    commit d7dce9e08595e80bf8039a81794809c66fe26431 upstream.
    
    ext4_ext_search_right() will read more extent blocks and call put_bh
    after we get the information we need.  However, ret_ex will break this
    and may cause use-after-free once pagecache has been freed.  Fix it by
    copying the extent structure if needed.
    
    Signed-off-by: yangerkun <yangerkun@huawei.com>
    Link: https://lore.kernel.org/r/20201028055617.2569255-1-yangerkun@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7bb9a23986895a373b7e1fcbfeeb9a1c954c4da3
Author: Ritesh Harjani <riteshh@linux.ibm.com>
Date:   Thu Oct 8 20:32:48 2020 +0530

    ext4: fix bs < ps issue reported with dioread_nolock mount opt
    
    commit d1e18b8824dd50cff255e6cecf515ea598eaf9f0 upstream.
    
    left shifting m_lblk by blkbits was causing value overflow and hence
    it was not able to convert unwritten to written extent.
    So, make sure we typecast it to loff_t before do left shift operation.
    Also in func ext4_convert_unwritten_io_end_vec(), make sure to initialize
    ret variable to avoid accidentally returning an uninitialized ret.
    
    This patch fixes the issue reported in ext4 for bs < ps with
    dioread_nolock mount option.
    
    Fixes: c8cc88163f40df39e50c ("ext4: Add support for blocksize < pagesize in dioread_nolock")
    Cc: stable@kernel.org
    Reported-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/af902b5db99e8b73980c795d84ad7bb417487e76.1602168865.git.riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5c2af83a89726af30644c2d7dd90df2ef993ae4a
Author: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Date:   Sun Sep 27 22:05:56 2020 -0400

    ext4: fix bdev write error check failed when mount fs with ro
    
    commit 9704a322ea67fdb05fc66cf431fdd01c2424bbd9 upstream.
    
    Consider a situation when a filesystem was uncleanly shutdown and the
    orphan list is not empty and a read-only mount is attempted. The orphan
    list cleanup during mount will fail with:
    
    ext4_check_bdev_write_error:193: comm mount: Error while async write back metadata
    
    This happens because sbi->s_bdev_wb_err is not initialized when mounting
    the filesystem in read only mode and so ext4_check_bdev_write_error()
    falsely triggers.
    
    Initialize sbi->s_bdev_wb_err unconditionally to avoid this problem.
    
    Fixes: bc71726c7257 ("ext4: abort the filesystem if failed to async write metadata buffer")
    Cc: stable@kernel.org
    Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20200928020556.710971-1-zhangxiaoxu5@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e500902cd5b88fd805d2c206bcce4f9782cc8cd4
Author: zhangyi (F) <yi.zhang@huawei.com>
Date:   Thu Sep 24 15:33:31 2020 +0800

    ext4: clear buffer verified flag if read meta block from disk
    
    commit d9befedaafcf3a111428baa7c45b02923eab2d87 upstream.
    
    The metadata buffer is no longer trusted after we read it from disk
    again because it is not uptodate for some reasons (e.g. failed to write
    back). Otherwise we may get below memory corruption problem in
    ext4_ext_split()->memset() if we read stale data from the newly
    allocated extent block on disk which has been failed to async write
    out but miss verify again since the verified bit has already been set
    on the buffer.
    
    [   29.774674] BUG: unable to handle kernel paging request at ffff88841949d000
    ...
    [   29.783317] Oops: 0002 [#2] SMP
    [   29.784219] R10: 00000000000f4240 R11: 0000000000002e28 R12: ffff88842fa1c800
    [   29.784627] CPU: 1 PID: 126 Comm: kworker/u4:3 Tainted: G      D W
    [   29.785546] R13: ffffffff9cddcc20 R14: ffffffff9cddd420 R15: ffff88842fa1c2f8
    [   29.786679] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),BIOS ?-20190727_0738364
    [   29.787588] FS:  0000000000000000(0000) GS:ffff88842fa00000(0000) knlGS:0000000000000000
    [   29.789288] Workqueue: writeback wb_workfn
    [   29.790319] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [   29.790321]  (flush-8:0)
    [   29.790844] CR2: 0000000000000008 CR3: 00000004234f2000 CR4: 00000000000006f0
    [   29.791924] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [   29.792839] RIP: 0010:__memset+0x24/0x30
    [   29.793739] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [   29.794256] Code: 90 90 90 90 90 90 0f 1f 44 00 00 49 89 f9 48 89 d1 83 e2 07 48 c1 e9 033
    [   29.795161] Kernel panic - not syncing: Fatal exception in interrupt
    ...
    [   29.808149] Call Trace:
    [   29.808475]  ext4_ext_insert_extent+0x102e/0x1be0
    [   29.809085]  ext4_ext_map_blocks+0xa89/0x1bb0
    [   29.809652]  ext4_map_blocks+0x290/0x8a0
    [   29.809085]  ext4_ext_map_blocks+0xa89/0x1bb0
    [   29.809652]  ext4_map_blocks+0x290/0x8a0
    [   29.810161]  ext4_writepages+0xc85/0x17c0
    ...
    
    Fix this by clearing buffer's verified bit if we read meta block from
    disk again.
    
    Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200924073337.861472-2-yi.zhang@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 357cc4c8a999573b2cc4d8e2fb22796056d0a082
Author: Luo Meng <luomeng12@huawei.com>
Date:   Tue Oct 20 09:36:31 2020 +0800

    ext4: fix invalid inode checksum
    
    commit 1322181170bb01bce3c228b82ae3d5c6b793164f upstream.
    
    During the stability test, there are some errors:
      ext4_lookup:1590: inode #6967: comm fsstress: iget: checksum invalid.
    
    If the inode->i_iblocks too big and doesn't set huge file flag, checksum
    will not be recalculated when update the inode information to it's buffer.
    If other inode marks the buffer dirty, then the inconsistent inode will
    be flushed to disk.
    
    Fix this problem by checking i_blocks in advance.
    
    Cc: stable@kernel.org
    Signed-off-by: Luo Meng <luomeng12@huawei.com>
    Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
    Link: https://lore.kernel.org/r/20201020013631.3796673-1-luomeng12@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56766806588f3f20afdd7172f1a661fa0c49fecb
Author: Ritesh Harjani <riteshh@linux.ibm.com>
Date:   Fri Sep 4 14:46:53 2020 +0530

    ext4: implement swap_activate aops using iomap
    
    commit 0e6895ba00b7be45f3ab0d2107dda3ef1245f5b4 upstream.
    
    After moving ext4's bmap to iomap interface, swapon functionality
    on files created using fallocate (which creates unwritten extents) are
    failing. This is since iomap_bmap interface returns 0 for unwritten
    extents and thus generic_swapfile_activate considers this as holes
    and hence bail out with below kernel msg :-
    
    [340.915835] swapon: swapfile has holes
    
    To fix this we need to implement ->swap_activate aops in ext4
    which will use ext4_iomap_report_ops. Since we only need to return
    the list of extents so ext4_iomap_report_ops should be enough.
    
    Cc: stable@kernel.org
    Reported-by: Yuxuan Shui <yshuiv7@gmail.com>
    Fixes: ac58e4fb03f ("ext4: move ext4 bmap to use iomap infrastructure")
    Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
    Link: https://lore.kernel.org/r/20200904091653.1014334-1-riteshh@linux.ibm.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9129151073eb09a20710387f0ed3e13fe3508c11
Author: Dinghao Liu <dinghao.liu@zju.edu.cn>
Date:   Sat Aug 29 10:54:02 2020 +0800

    ext4: fix error handling code in add_new_gdb
    
    commit c9e87161cc621cbdcfc472fa0b2d81c63780c8f5 upstream.
    
    When ext4_journal_get_write_access() fails, we should
    terminate the execution flow and release n_group_desc,
    iloc.bh, dind and gdb_bh.
    
    Cc: stable@kernel.org
    Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Link: https://lore.kernel.org/r/20200829025403.3139-1-dinghao.liu@zju.edu.cn
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5802528b2fc14e6cfd767f32c119b8897f6be1fe
Author: Eric Biggers <ebiggers@google.com>
Date:   Tue Sep 22 09:24:56 2020 -0700

    ext4: fix leaking sysfs kobject after failed mount
    
    commit cb8d53d2c97369029cc638c9274ac7be0a316c75 upstream.
    
    ext4_unregister_sysfs() only deletes the kobject.  The reference to it
    needs to be put separately, like ext4_put_super() does.
    
    This addresses the syzbot report
    "memory leak in kobject_set_name_vargs (3)"
    (https://syzkaller.appspot.com/bug?extid=9f864abad79fae7c17e1).
    
    Reported-by: syzbot+9f864abad79fae7c17e1@syzkaller.appspotmail.com
    Fixes: 72ba74508b28 ("ext4: release sysfs kobject when failing to enable quotas on mount")
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Link: https://lore.kernel.org/r/20200922162456.93657-1-ebiggers@kernel.org
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d43b468e0157c531bc89262c265f4b3fbf120562
Author: Stefano Garzarella <sgarzare@redhat.com>
Date:   Thu Oct 8 22:42:56 2020 +0200

    vringh: fix __vringh_iov() when riov and wiov are different
    
    commit 5745bcfbbf89b158416075374254d3c013488f21 upstream.
    
    If riov and wiov are both defined and they point to different
    objects, only riov is initialized. If the wiov is not initialized
    by the caller, the function fails returning -EINVAL and printing
    "Readable desc 0x... after writable" error message.
    
    This issue happens when descriptors have both readable and writable
    buffers (eg. virtio-blk devices has virtio_blk_outhdr in the readable
    buffer and status as last byte of writable buffer) and we call
    __vringh_iov() to get both type of buffers in two different iovecs.
    
    Let's replace the 'else if' clause with 'if' to initialize both
    riov and wiov if they are not NULL.
    
    As checkpatch pointed out, we also avoid crashing the kernel
    when riov and wiov are both NULL, replacing BUG() with WARN_ON()
    and returning -EINVAL.
    
    Fixes: f87d0fbb5798 ("vringh: host-side implementation of virtio rings.")
    Cc: stable@vger.kernel.org
    Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
    Link: https://lore.kernel.org/r/20201008204256.162292-1-sgarzare@redhat.com
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 96e3212fdca3da607c914dfb170b05cf35ff43e7
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Fri Oct 23 17:35:32 2020 +0200

    cpufreq: intel_pstate: Avoid missing HWP max updates in passive mode
    
    commit e0be38ed4ab413ddd492118cf146369b86ee0ab5 upstream.
    
    If the cpufreq policy max limit is changed when intel_pstate operates
    in the passive mode with HWP enabled and the "powersave" governor is
    used on top of it, the HWP max limit is not updated as appropriate.
    
    Namely, in the "powersave" governor case, the target P-state
    is always equal to the policy min limit, so if the latter does
    not change, intel_cpufreq_adjust_hwp() is not invoked to update
    the HWP Request MSR due to the "target_pstate != old_pstate" check
    in intel_cpufreq_update_pstate(), so the HWP max limit is not
    updated as a result.
    
    Also, if the CPUFREQ_NEED_UPDATE_LIMITS flag is not set for the
    driver and the target frequency does not change along with the
    policy max limit, the "target_freq == policy->cur" check in
    __cpufreq_driver_target() prevents the driver's ->target() callback
    from being invoked at all, so the HWP max limit is not updated.
    
    To prevent that occurring, set the CPUFREQ_NEED_UPDATE_LIMITS flag
    in the intel_cpufreq driver structure if HWP is enabled and modify
    intel_cpufreq_update_pstate() to do the "target_pstate != old_pstate"
    check only in the non-HWP case and let intel_cpufreq_adjust_hwp()
    always run in the HWP case (it will update HWP Request only if the
    cached value of the register is different from the new one including
    the limits, so if neither the target P-state value nor the max limit
    changes, the register write will still be avoided).
    
    Fixes: f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled")
    Reported-by: Zhang Rui <rui.zhang@intel.com>
    Cc: 5.9+ <stable@vger.kernel.org> # 5.9+: 1c534352f47f cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS ...
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
    Tested-by: Zhang Rui <rui.zhang@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit db6e432d0bcd9b3622681323a9588c66f1c5d01a
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Fri Oct 23 17:35:19 2020 +0200

    cpufreq: Introduce CPUFREQ_NEED_UPDATE_LIMITS driver flag
    
    commit 1c534352f47fd83eb08075ac2474f707e74bf7f7 upstream.
    
    Generally, a cpufreq driver may need to update some internal upper
    and lower frequency boundaries on policy max and min changes,
    respectively, but currently this does not work if the target
    frequency does not change along with the policy limit.
    
    Namely, if the target frequency does not change along with the
    policy min or max, the "target_freq == policy->cur" check in
    __cpufreq_driver_target() prevents driver callbacks from being
    invoked and they do not even have a chance to update the
    corresponding internal boundary.
    
    This particularly affects the "powersave" and "performance"
    governors that always set the target frequency to one of the
    policy limits and it never changes when the other limit is updated.
    
    To allow cpufreq the drivers needing to update internal frequency
    boundaries on policy limits changes to avoid this issue, introduce
    a new driver flag, CPUFREQ_NEED_UPDATE_LIMITS, that (when set) will
    neutralize the check mentioned above.
    
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 345b28cbf497d25018e89ec96c058f464d51a6f6
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Fri Oct 23 17:15:56 2020 +0200

    cpufreq: Avoid configuring old governors as default with intel_pstate
    
    commit db865272d9c4687520dc29f77e701a1b2669872f upstream.
    
    Commit 33aa46f252c7 ("cpufreq: intel_pstate: Use passive mode by
    default without HWP") was meant to cause intel_pstate to be used
    in the passive mode with the schedutil governor on top of it, but
    it missed the case in which either "ondemand" or "conservative"
    was selected as the default governor in the existing kernel config,
    in which case the previous old governor configuration would be used,
    causing the default legacy governor to be used on top of intel_pstate
    instead of schedutil.
    
    Address this by preventing "ondemand" and "conservative" from being
    configured as the default cpufreq governor in the case when schedutil
    is the default choice for the default governor setting.
    
    [Note that the default cpufreq governor can still be set via the
     kernel command line if need be and that choice is not limited,
     so if anyone really wants to use one of the legacy governors by
     default, it can be achieved this way.]
    
    Fixes: 33aa46f252c7 ("cpufreq: intel_pstate: Use passive mode by default without HWP")
    Reported-by: Julia Lawall <julia.lawall@inria.fr>
    Cc: 5.8+ <stable@vger.kernel.org> # 5.8+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2b583eff24a0ba8eaedb9bbc5ec3a2bee2b8e454
Author: Chen Yu <yu.c.chen@intel.com>
Date:   Sun Oct 25 00:29:53 2020 +0800

    intel_idle: Fix max_cstate for processor models without C-state tables
    
    commit 4e0ba5577dba686f96c1c10ef4166380667fdec7 upstream.
    
    Currently intel_idle driver gets the c-state information from ACPI
    _CST if the processor model is not recognized by it. However the
    c-state in _CST starts with index 1 which is different from the
    index in intel_idle driver's internal c-state table.
    
    While intel_idle_max_cstate_reached() was previously introduced to
    deal with intel_idle driver's internal c-state table, re-using
    this function directly on _CST is incorrect.
    
    Fix this by subtracting 1 from the index when checking max_cstate
    in the _CST case.
    
    For example, append intel_idle.max_cstate=1 in boot command line,
    Before the patch:
    grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name
    POLL
    After the patch:
    grep . /sys/devices/system/cpu/cpu0/cpuidle/state*/name
    /sys/devices/system/cpu/cpu0/cpuidle/state0/name:POLL
    /sys/devices/system/cpu/cpu0/cpuidle/state1/name:C1_ACPI
    
    Fixes: 18734958e9bf ("intel_idle: Use ACPI _CST for processor models without C-state tables")
    Reported-by: Pengfei Xu <pengfei.xu@intel.com>
    Cc: 5.6+ <stable@vger.kernel.org> # 5.6+
    Signed-off-by: Chen Yu <yu.c.chen@intel.com>
    [ rjw: Changelog edits ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0cf4848591a713e3325233282e30985b0bb237d2
Author: Mel Gorman <mgorman@techsingularity.net>
Date:   Fri Oct 16 17:28:32 2020 +0200

    intel_idle: Ignore _CST if control cannot be taken from the platform
    
    commit 75af76d0a34e048651a6af311781d7206b6964c7 upstream.
    
    e6d4f08a6776 ("intel_idle: Use ACPI _CST on server systems") avoids
    enabling c-states that have been disabled by the platform with the
    exception of C1E.
    
    Unfortunately, BIOS implementations are not always consistent in terms
    of how capabilities are advertised and control cannot always be handed
    over. If control cannot be handed over then intel_idle reports that "ACPI
    _CST not found or not usable" but does not clear acpi_state_table.count
    meaning the information is still partially used.
    
    This patch ignores ACPI information if CST control cannot be requested from
    the platform. This was only observed on a number of Haswell platforms that
    had identical CPUs but not identical BIOS versions.  While this problem
    may be rare overall, 24 separate test cases bisected to this specific
    commit across 4 separate test machines and is worth addressing. If the
    situation occurs, the kernel behaves as it did before commit e6d4f08a6776
    and uses any c-states that are discovered.
    
    The affected test cases were all ones that involved a small number of
    processes -- exec microbenchmark, pipe microbenchmark, git test suite,
    netperf, tbench with one client and system call microbenchmark. Each
    case benefits from being able to use turboboost which is prevented if the
    lower c-states are unavailable. This may mask real regressions specific
    to older hardware so it is worth addressing.
    
    C-state status before and after the patch
    
    5.9.0-vanilla            POLL     latency:0      disabled:0 default:enabled
    5.9.0-vanilla            C1       latency:2      disabled:0 default:enabled
    5.9.0-vanilla            C1E      latency:10     disabled:0 default:enabled
    5.9.0-vanilla            C3       latency:33     disabled:1 default:disabled
    5.9.0-vanilla            C6       latency:133    disabled:1 default:disabled
    5.9.0-ignore-cst-v1r1    POLL     latency:0      disabled:0 default:enabled
    5.9.0-ignore-cst-v1r1    C1       latency:2      disabled:0 default:enabled
    5.9.0-ignore-cst-v1r1    C1E      latency:10     disabled:0 default:enabled
    5.9.0-ignore-cst-v1r1    C3       latency:33     disabled:0 default:enabled
    5.9.0-ignore-cst-v1r1    C6       latency:133    disabled:0 default:enabled
    
    Patch enables C3/C6.
    
    Netperf UDP_STREAM
    
    netperf-udp
                                          5.5.0                  5.9.0
                                        vanilla        ignore-cst-v1r1
    Hmean     send-64         193.41 (   0.00%)      226.54 *  17.13%*
    Hmean     send-128        392.16 (   0.00%)      450.54 *  14.89%*
    Hmean     send-256        769.94 (   0.00%)      881.85 *  14.53%*
    Hmean     send-1024      2994.21 (   0.00%)     3468.95 *  15.85%*
    Hmean     send-2048      5725.60 (   0.00%)     6628.99 *  15.78%*
    Hmean     send-3312      8468.36 (   0.00%)    10288.02 *  21.49%*
    Hmean     send-4096     10135.46 (   0.00%)    12387.57 *  22.22%*
    Hmean     send-8192     17142.07 (   0.00%)    19748.11 *  15.20%*
    Hmean     send-16384    28539.71 (   0.00%)    30084.45 *   5.41%*
    
    Fixes: e6d4f08a6776 ("intel_idle: Use ACPI _CST on server systems")
    Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
    Cc: 5.6+ <stable@vger.kernel.org> # 5.6+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7c4df0c8776fc0a797ffe2f628eb46408e2105f2
Author: Qiujun Huang <hqjagain@gmail.com>
Date:   Mon Oct 19 22:22:42 2020 +0800

    ring-buffer: Return 0 on success from ring_buffer_resize()
    
    commit 0a1754b2a97efa644aa6e84d1db5b17c42251483 upstream.
    
    We don't need to check the new buffer size, and the return value
    had confused resize_buffer_duplicate_size().
    ...
            ret = ring_buffer_resize(trace_buf->buffer,
                    per_cpu_ptr(size_buf->data,cpu_id)->entries, cpu_id);
            if (ret == 0)
                    per_cpu_ptr(trace_buf->data, cpu_id)->entries =
                            per_cpu_ptr(size_buf->data, cpu_id)->entries;
    ...
    
    Link: https://lkml.kernel.org/r/20201019142242.11560-1-hqjagain@gmail.com
    
    Cc: stable@vger.kernel.org
    Fixes: d60da506cbeb3 ("tracing: Add a resize function to make one buffer equivalent to another buffer")
    Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 07a9b327933bf5419501e04285b89f3f3c4f9e55
Author: Ansuel Smith <ansuelsmth@gmail.com>
Date:   Tue Sep 1 14:49:54 2020 +0200

    PCI: qcom: Make sure PCIe is reset before init for rev 2.1.0
    
    commit d3d4d028afb785e52c55024d779089654f8302e7 upstream.
    
    Qsdk U-Boot can incorrectly leave the PCIe interface in an undefined
    state if bootm command is used instead of bootipq. This is caused by the
    not deinit of PCIe when bootm is called. Reset the PCIe before init
    anyway to fix this U-Boot bug.
    
    Link: https://lore.kernel.org/r/20200901124955.137-1-ansuelsmth@gmail.com
    Fixes: 82a823833f4e ("PCI: qcom: Add Qualcomm PCIe controller driver")
    Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Cc: stable@vger.kernel.org # v4.19+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5c404864f515a26dacc36791229278ef8cf7be82
Author: Artur Molchanov <arturmolchanov@gmail.com>
Date:   Mon Oct 12 01:00:45 2020 +0300

    net/sunrpc: Fix return value for sysctl sunrpc.transports
    
    commit c09f56b8f68d4d536bff518227aea323b835b2ce upstream.
    
    Fix returning value for sysctl sunrpc.transports.
    Return error code from sysctl proc_handler function proc_do_xprt instead of number of the written bytes.
    Otherwise sysctl returns random garbage for this key.
    
    Since v1:
    - Handle negative returned value from memory_read_from_buffer as an error
    
    Signed-off-by: Artur Molchanov <arturmolchanov@gmail.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29a41f7b632f280e65b844c0c485e1087a7de1f5
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Sun Oct 4 19:04:22 2020 +0100

    9P: Cast to loff_t before multiplying
    
    commit f5f7ab168b9a60e12a4b8f2bb6fcc91321dc23c1 upstream.
    
    On 32-bit systems, this multiplication will overflow for files larger
    than 4GB.
    
    Link: http://lkml.kernel.org/r/20201004180428.14494-2-willy@infradead.org
    Cc: stable@vger.kernel.org
    Fixes: fb89b45cdfdc ("9P: introduction of a new cache=mmap model.")
    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8ff240c07ed0607f8e28282dbb9ca5ae5e211a22
Author: Ilya Dryomov <idryomov@gmail.com>
Date:   Wed Oct 7 20:06:48 2020 +0200

    libceph: clear con->out_msg on Policy::stateful_server faults
    
    commit 28e1581c3b4ea5f98530064a103c6217bedeea73 upstream.
    
    con->out_msg must be cleared on Policy::stateful_server
    (!CEPH_MSG_CONNECT_LOSSY) faults.  Not doing so botches the
    reconnection attempt, because after writing the banner the
    messenger moves on to writing the data section of that message
    (either from where it got interrupted by the connection reset or
    from the beginning) instead of writing struct ceph_msg_connect.
    This results in a bizarre error message because the server
    sends CEPH_MSGR_TAG_BADPROTOVER but we think we wrote struct
    ceph_msg_connect:
    
      libceph: mds0 (1)172.21.15.45:6828 socket error on write
      ceph: mds0 reconnect start
      libceph: mds0 (1)172.21.15.45:6829 socket closed (con state OPEN)
      libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch, my 32 != server's 32
      libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch
    
    AFAICT this bug goes back to the dawn of the kernel client.
    The reason it survived for so long is that only MDS sessions
    are stateful and only two MDS messages have a data section:
    CEPH_MSG_CLIENT_RECONNECT (always, but reconnecting is rare)
    and CEPH_MSG_CLIENT_REQUEST (only when xattrs are involved).
    The connection has to get reset precisely when such message
    is being sent -- in this case it was the former.
    
    Cc: stable@vger.kernel.org
    Link: https://tracker.ceph.com/issues/47723
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 89b9cad46d8c2694e8fc73f1183bc5d66c1d75d8
Author: Matthew Wilcox (Oracle) <willy@infradead.org>
Date:   Sun Oct 4 19:04:24 2020 +0100

    ceph: promote to unsigned long long before shifting
    
    commit c403c3a2fbe24d4ed33e10cabad048583ebd4edf upstream.
    
    On 32-bit systems, this shift will overflow for files larger than 4GB.
    
    Cc: stable@vger.kernel.org
    Fixes: 61f68816211e ("ceph: check caps in filemap_fault and page_mkwrite")
    Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4052ea4a043425c9a50de269d5e9c77b6fc11fad
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Oct 23 09:46:54 2020 +0200

    drm/amd/display: Fix kernel panic by dal_gpio_open() error
    
    commit 920bb38c518408fa2600eaefa0af9e82cf48f166 upstream.
    
    Currently both error code paths handled in dal_gpio_open_ex() issues
    ASSERT_CRITICAL(), and this leads to a kernel panic unnecessarily if
    CONFIG_KGDB is enabled.  Since basically both are non-critical errors
    and can be recovered, drop those assert calls and use a safer one,
    BREAK_TO_DEBUGGER(), for allowing the debugging, instead.
    
    BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1177973
    Cc: <stable@vger.kernel.org>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c5e0a7386e1a53b2e62b2a168071e5cfb86732c6
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Oct 23 09:46:55 2020 +0200

    drm/amd/display: Don't invoke kgdb_breakpoint() unconditionally
    
    commit 8b7dc1fe1a5c1093551f6cd7dfbb941bd9081c2e upstream.
    
    ASSERT_CRITICAL() invokes kgdb_breakpoint() whenever either
    CONFIG_KGDB or CONFIG_HAVE_KGDB is set.  This, however, may lead to a
    kernel panic when no kdb stuff is attached, since the
    kgdb_breakpoint() call issues INT3.  It's nothing but a surprise for
    normal end-users.
    
    For avoiding the pitfall, make the kgdb_breakpoint() call only when
    CONFIG_DEBUG_KERNEL_DC is set.
    
    https://bugzilla.opensuse.org/show_bug.cgi?id=1177973
    Cc: <stable@vger.kernel.org>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3074346ddbd127e94261d563136b95992290ec50
Author: Christian König <christian.koenig@amd.com>
Date:   Mon Oct 12 13:09:36 2020 +0200

    drm/amdgpu: increase the reserved VM size to 2MB
    
    commit 55bb919be4e4973cd037a04f527ecc6686800437 upstream.
    
    Ideally this should be a multiple of the VM block size.
    2MB should at least fit for Vega/Navi.
    
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Reviewed-by: Madhav Chauhan <madhav.chauhan@amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c899ac36b2861a1a2e183bbffb100fcf6647a3eb
Author: Likun Gao <Likun.Gao@amd.com>
Date:   Wed Oct 14 14:05:18 2020 +0800

    drm/amdgpu: add function to program pbb mode for sienna cichlid
    
    commit 274c240c760ed4647ddae1f1b994e0dd3f71cbb1 upstream.
    
    Add function for sienna_cichlid to force PBB workload mode to zero by
    checking whether there have SE been harvested.
    
    Signed-off-by: Likun Gao <Likun.Gao@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 5.9.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1d0668756dbeaeee3420c9f902a12e5f031d1ac3
Author: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Date:   Wed Oct 14 13:12:30 2020 -0400

    drm/amd/display: Avoid MST manager resource leak.
    
    commit 5dff80bdce9e385af5716ed083f9e33e814484ab upstream.
    
    On connector destruction call drm_dp_mst_topology_mgr_destroy
    to release resources allocated in drm_dp_mst_topology_mgr_init.
    Do it only if MST manager was initilized before otherwsie a crash
    is seen on driver unload/device unplug.
    
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f2774533592118207795b92501694a45ff0437fb
Author: Jay Cornwall <jay.cornwall@amd.com>
Date:   Sat Oct 17 08:38:43 2020 -0500

    drm/amdkfd: Use same SQ prefetch setting as amdgpu
    
    commit d56b1980d7efe9ef08469e856fc0703d0cef65e4 upstream.
    
    0 causes instruction fetch stall at cache line boundary under some
    conditions on Navi10. A non-zero prefetch is the preferred default
    in any case.
    
    Fixes soft hang in Luxmark.
    
    Signed-off-by: Jay Cornwall <jay.cornwall@amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 58d6fa17fffb42b4f1a2b7c7c328f706394c6d82
Author: Evan Quan <evan.quan@amd.com>
Date:   Thu Oct 15 14:57:46 2020 +0800

    drm/amdgpu: correct the gpu reset handling for job != NULL case
    
    commit 207ac684792560acdb9e06f9d707ebf63c84b0e0 upstream.
    
    Current code wrongly treat all cases as job == NULL.
    
    Signed-off-by: Evan Quan <evan.quan@amd.com>
    Reviewed-and-tested-by: Jane Jian <Jane.Jian@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bacae0020733b15027f0cf90ddae524a476f9d59
Author: Likun Gao <Likun.Gao@amd.com>
Date:   Thu Oct 15 10:48:15 2020 +0800

    drm/amdgpu: update golden setting for sienna_cichlid
    
    commit 0d142232d9436acab3578ee995472f58adcbf201 upstream.
    
    Update golden setting for sienna_cichlid.
    
    Signed-off-by: Likun Gao <Likun.Gao@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 5.9.x
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 355d7432a84dc393c2f65646c0552f08bc8d5f7d
Author: Veerabadhran G <vegopala@amd.com>
Date:   Thu Oct 8 22:30:02 2020 +0530

    drm/amdgpu: vcn and jpeg ring synchronization
    
    commit 187561dd76531945126b15c9486fec7cfa5f0415 upstream.
    
    Synchronize the ring usage for vcn1 and jpeg1 to workaround a hardware bug.
    
    Signed-off-by: Veerabadhran Gopalakrishnan <veerabadhran.gopalakrishnan@amd.com>
    Acked-by: Christian König <christian.koenig@amd.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f77758e7cef156ff89ccd5e419e4bbc4ff09bece
Author: Wesley Chalmers <Wesley.Chalmers@amd.com>
Date:   Wed Sep 9 17:41:53 2020 -0400

    drm/amd/display: Increase timeout for DP Disable
    
    commit 37b7cb10f07c1174522faafc1d51c6591b1501d4 upstream.
    
    [WHY]
    When disabling DP video, the current REG_WAIT timeout
    of 50ms is too low for certain cases with very high
    VSYNC intervals.
    
    [HOW]
    Increase the timeout to 102ms, so that
    refresh rates as low as 10Hz can be handled properly.
    
    Signed-off-by: Wesley Chalmers <Wesley.Chalmers@amd.com>
    Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
    Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aa7c61b31680c93e86988ef23e266ab4d652827e
Author: David Galiffi <David.Galiffi@amd.com>
Date:   Thu Sep 3 19:20:36 2020 -0400

    drm/amd/display: Fix incorrect backlight register offset for DCN
    
    commit 651111be24aa4c8b62c10f6fff51d9ad82411249 upstream.
    
    [Why]
    Typo in backlight refactor introduced wrong register offset.
    
    [How]
    SR(BIOS_SCRATCH_2) to NBIO_SR(BIOS_SCRATCH_2).
    
    Signed-off-by: David Galiffi <David.Galiffi@amd.com>
    Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
    Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b8b9194fc802eaaef736cba5f08276fd2883ec79
Author: Madhav Chauhan <madhav.chauhan@amd.com>
Date:   Fri Oct 16 18:03:07 2020 +0530

    drm/amdgpu: don't map BO in reserved region
    
    commit c4aa8dff6091cc9536aeb255e544b0b4ba29faf4 upstream.
    
    2MB area is reserved at top inside VM.
    
    Suggested-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Madhav Chauhan <madhav.chauhan@amd.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ff2d398534a8dfd14b15e1e029be9d2b0d2c381f
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Sun Sep 20 23:12:38 2020 +0200

    i2c: imx: Fix external abort on interrupt in exit paths
    
    commit e50e4f0b85be308a01b830c5fbdffc657e1a6dd0 upstream.
    
    If interrupt comes late, during probe error path or device remove (could
    be triggered with CONFIG_DEBUG_SHIRQ), the interrupt handler
    i2c_imx_isr() will access registers with the clock being disabled.  This
    leads to external abort on non-linefetch on Toradex Colibri VF50 module
    (with Vybrid VF5xx):
    
        Unhandled fault: external abort on non-linefetch (0x1008) at 0x8882d003
        Internal error: : 1008 [#1] ARM
        Modules linked in:
        CPU: 0 PID: 1 Comm: swapper Not tainted 5.7.0 #607
        Hardware name: Freescale Vybrid VF5xx/VF6xx (Device Tree)
          (i2c_imx_isr) from [<8017009c>] (free_irq+0x25c/0x3b0)
          (free_irq) from [<805844ec>] (release_nodes+0x178/0x284)
          (release_nodes) from [<80580030>] (really_probe+0x10c/0x348)
          (really_probe) from [<80580380>] (driver_probe_device+0x60/0x170)
          (driver_probe_device) from [<80580630>] (device_driver_attach+0x58/0x60)
          (device_driver_attach) from [<805806bc>] (__driver_attach+0x84/0xc0)
          (__driver_attach) from [<8057e228>] (bus_for_each_dev+0x68/0xb4)
          (bus_for_each_dev) from [<8057f3ec>] (bus_add_driver+0x144/0x1ec)
          (bus_add_driver) from [<80581320>] (driver_register+0x78/0x110)
          (driver_register) from [<8010213c>] (do_one_initcall+0xa8/0x2f4)
          (do_one_initcall) from [<80c0100c>] (kernel_init_freeable+0x178/0x1dc)
          (kernel_init_freeable) from [<80807048>] (kernel_init+0x8/0x110)
          (kernel_init) from [<80100114>] (ret_from_fork+0x14/0x20)
    
    Additionally, the i2c_imx_isr() could wake up the wait queue
    (imx_i2c_struct->queue) before its initialization happens.
    
    The resource-managed framework should not be used for interrupt handling,
    because the resource will be released too late - after disabling clocks.
    The interrupt handler is not prepared for such case.
    
    Fixes: 1c4b6c3bcf30 ("i2c: imx: implement bus recovery")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 935def4d95958a6698891271a9e26340baadfb26
Author: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Date:   Mon Sep 14 17:45:48 2020 +0200

    rtc: rx8010: don't modify the global rtc ops
    
    commit d3b14296da69adb7825022f3224ac6137eb30abf upstream.
    
    The way the driver is implemented is buggy for the (admittedly unlikely)
    use case where there are two RTCs with one having an interrupt configured
    and the second not. This is caused by the fact that we use a global
    rtc_class_ops struct which we modify depending on whether the irq number
    is present or not.
    
    Fix it by using two const ops structs with and without alarm operations.
    While at it: not being able to request a configured interrupt is an error
    so don't ignore it and bail out of probe().
    
    Fixes: ed13d89b08e3 ("rtc: Add Epson RX8010SJ RTC driver")
    Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200914154601.32245-2-brgl@bgdev.pl
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a62e3b1e8cd15b9d8eae6f86684b7731c0d6c97c
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Sat Oct 17 16:13:37 2020 -0700

    ia64: fix build error with !COREDUMP
    
    commit 7404840d87557c4092bf0272bce5e0354c774bf9 upstream.
    
    Fix linkage error when CONFIG_BINFMT_ELF is selected but CONFIG_COREDUMP
    is not:
    
        ia64-linux-ld: arch/ia64/kernel/elfcore.o: in function `elf_core_write_extra_phdrs':
        elfcore.c:(.text+0x172): undefined reference to `dump_emit'
        ia64-linux-ld: arch/ia64/kernel/elfcore.o: in function `elf_core_write_extra_data':
        elfcore.c:(.text+0x2b2): undefined reference to `dump_emit'
    
    Fixes: 1fcccbac89f5 ("elf coredump: replace ELF_CORE_EXTRA_* macros by functions")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20200819064146.12529-1-krzk@kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9ff032d5ebb6cd2f87a752a50d9a35d90f4bcc6f
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Mon Jun 1 17:12:31 2020 +0800

    ubi: check kthread_should_stop() after the setting of task state
    
    commit d005f8c6588efcfbe88099b6edafc6f58c84a9c1 upstream.
    
    A detach hung is possible when a race occurs between the detach process
    and the ubi background thread. The following sequences outline the race:
    
      ubi thread: if (list_empty(&ubi->works)...
    
      ubi detach: set_bit(KTHREAD_SHOULD_STOP, &kthread->flags)
                  => by kthread_stop()
                  wake_up_process()
                  => ubi thread is still running, so 0 is returned
    
      ubi thread: set_current_state(TASK_INTERRUPTIBLE)
                  schedule()
                  => ubi thread will never be scheduled again
    
      ubi detach: wait_for_completion()
                  => hung task!
    
    To fix that, we need to check kthread_should_stop() after we set the
    task state, so the ubi thread will either see the stop bit and exit or
    the task state is reset to runnable such that it isn't scheduled out
    indefinitely.
    
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Cc: <stable@vger.kernel.org>
    Fixes: 801c135ce73d5df1ca ("UBI: Unsorted Block Images")
    Reported-by: syzbot+853639d0cb16c31c7a14@syzkaller.appspotmail.com
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 79337212b5ee0c8c4a3170fb2ed01ccd59830f0b
Author: Vineet Gupta <vgupta@synopsys.com>
Date:   Thu Oct 22 03:16:22 2020 -0700

    ARC: perf: redo the pct irq missing in device-tree handling
    
    commit 8c42a5c02bec6c7eccf08957be3c6c8fccf9790b upstream.
    
    commit feb92d7d3813456c11dce21 "(ARC: perf: don't bail setup if pct irq
    missing in device-tree)" introduced a silly brown-paper bag bug:
    The assignment and comparison in an if statement were not bracketed
    correctly leaving the order of evaluation undefined.
    
    |
    | if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) {
    |                           ^^^                         ^^^^
    
    And given such a chance, the compiler will bite you hard, fully entitled
    to generating this piece of beauty:
    
    |
    | # if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) {
    |
    | bl.d @platform_get_irq  <-- irq returned in r0
    |
    | setge r2, r0, 0       <-- r2 is bool 1 or 0 if irq >= 0 true/false
    | brlt.d r0, 0, @.L114
    |
    | st_s  r2,[sp]         <-- irq saved is bool 1 or 0, not actual return val
    | st    1,[r3,160]      # arc_pmu.18_29->irq <-- drops bool and assumes 1
    |
    | # return __request_percpu_irq(irq, handler, 0,
    |
    | bl.d @__request_percpu_irq;
    | mov_s r0,1       <-- drops even bool and assumes 1 which fails
    
    With the snafu fixed, everything is as expected.
    
    | bl.d @platform_get_irq        <-- returns irq in r0
    |
    | mov_s r2,r0
    | brlt.d r2, 0, @.L112
    |
    | st_s  r0,[sp]                 <-- irq isaved is actual return value above
    | st    r0,[r13,160]    #arc_pmu.18_27->irq
    |
    | bl.d @__request_percpu_irq    <-- r0 unchanged so actual irq returned
    | add r4,r4,r12 #, tmp363, __ptr
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e294c3f128bf49eb396a81295fe8c435a843d46d
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Sep 28 22:11:35 2020 +0200

    perf python scripting: Fix printable strings in python3 scripts
    
    commit 6fcd5ddc3b1467b3586972ef785d0d926ae4cdf4 upstream.
    
    Hagen reported broken strings in python3 tracepoint scripts:
    
      make PYTHON=python3
      perf record -e sched:sched_switch -a -- sleep 5
      perf script --gen-script py
      perf script -s ./perf-script.py
    
      [..]
      sched__sched_switch      7 563231.759525792        0 swapper   prev_comm=bytearray(b'swapper/7\x00\x00\x00\x00\x00\x00\x00'), prev_pid=0, prev_prio=120, prev_state=, next_comm=bytearray(b'mutex-thread-co\x00'),
    
    The problem is in the is_printable_array function that does not take the
    zero byte into account and claim such string as not printable, so the
    code will create byte array instead of string.
    
    Committer testing:
    
    After this fix:
    
    sched__sched_switch 3 484522.497072626  1158680 kworker/3:0-eve  prev_comm=kworker/3:0, prev_pid=1158680, prev_prio=120, prev_state=I, next_comm=swapper/3, next_pid=0, next_prio=120
    Sample: {addr=0, cpu=3, datasrc=84410401, datasrc_decode=N/A|SNP N/A|TLB N/A|LCK N/A, ip=18446744071841817196, period=1, phys_addr=0, pid=1158680, tid=1158680, time=484522497072626, transaction=0, values=[(0, 0)], weight=0}
    
    sched__sched_switch 4 484522.497085610  1225814 perf             prev_comm=perf, prev_pid=1225814, prev_prio=120, prev_state=, next_comm=migration/4, next_pid=30, next_prio=0
    Sample: {addr=0, cpu=4, datasrc=84410401, datasrc_decode=N/A|SNP N/A|TLB N/A|LCK N/A, ip=18446744071841817196, period=1, phys_addr=0, pid=1225814, tid=1225814, time=484522497085610, transaction=0, values=[(0, 0)], weight=0}
    
    Fixes: 249de6e07458 ("perf script python: Fix string vs byte array resolving")
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Tested-by: Hagen Paul Pfeifer <hagen@jauu.net>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Michael Petlan <mpetlan@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200928201135.3633850-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9aa1c59015b3b37acb99080210fdb5939e111772
Author: Kim Phillips <kim.phillips@amd.com>
Date:   Tue Sep 1 17:09:41 2020 -0500

    perf vendor events amd: Add L2 Prefetch events for zen1
    
    commit 60d804521ec4cd01217a96f33cd1bb29e295333d upstream.
    
    Later revisions of PPRs that post-date the original Family 17h events
    submission patch add these events.
    
    Specifically, they were not in this 2017 revision of the F17h PPR:
    
    Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors Rev 1.14 - April 15, 2017
    
    But e.g., are included in this 2019 version of the PPR:
    
    Processor Programming Reference (PPR) for AMD Family 17h Model 18h, Revision B1 Processors Rev. 3.14 - Sep 26, 2019
    
    Fixes: 98c07a8f74f8 ("perf vendor events amd: perf PMU events for AMD Family 17h")
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
    Signed-off-by: Kim Phillips <kim.phillips@amd.com>
    Reviewed-by: Ian Rogers <irogers@google.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Jin Yao <yao.jin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: John Garry <john.garry@huawei.com>
    Cc: Jon Grimm <jon.grimm@amd.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Martin Jambor <mjambor@suse.cz>
    Cc: Martin Liška <mliska@suse.cz>
    Cc: Michael Petlan <mpetlan@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Vijay Thakkar <vijaythakkar@me.com>
    Cc: William Cohen <wcohen@redhat.com>
    Cc: Yunfeng Ye <yeyunfeng@huawei.com>
    Link: http://lore.kernel.org/lkml/20200901220944.277505-1-kim.phillips@amd.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ce49ab59995470e0db30dcaee9217d66b97c05ed
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Tue Sep 29 20:45:31 2020 +0800

    ubifs: mount_ubifs: Release authentication resource in error handling path
    
    commit e2a05cc7f8229e150243cdae40f2af9021d67a4a upstream.
    
    Release the authentication related resource in some error handling
    branches in mount_ubifs().
    
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Cc: <stable@vger.kernel.org>  # 4.20+
    Fixes: d8a22773a12c6d7 ("ubifs: Enable authentication support")
    Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0d8021023a9ee091ad63cd23fea1818a238257d4
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Tue Sep 29 20:45:30 2020 +0800

    ubifs: Don't parse authentication mount options in remount process
    
    commit bb674a4d4de1032837fcbf860a63939e66f0b7ad upstream.
    
    There is no need to dump authentication options while remounting,
    because authentication initialization can only be doing once in
    the first mount process. Dumping authentication mount options in
    remount process may cause memory leak if UBIFS has already been
    mounted with old authentication mount options.
    
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Cc: <stable@vger.kernel.org>  # 4.20+
    Fixes: d8a22773a12c6d7 ("ubifs: Enable authentication support")
    Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 92b2d135b6bf87d76ecdacad86717882fa704908
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Tue Sep 29 20:45:29 2020 +0800

    ubifs: Fix a memleak after dumping authentication mount options
    
    commit 47f6d9ce45b03a40c34b668a9884754c58122b39 upstream.
    
    Fix a memory leak after dumping authentication mount options in error
    handling branch.
    
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Cc: <stable@vger.kernel.org>  # 4.20+
    Fixes: d8a22773a12c6d7 ("ubifs: Enable authentication support")
    Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 10185cbb57f93e2b231936c8b30095ffd25b51b6
Author: Richard Weinberger <richard@nod.at>
Date:   Mon Sep 28 20:58:59 2020 +0200

    ubifs: journal: Make sure to not dirty twice for auth nodes
    
    commit 78c7d49f55d8631b67c09f9bfbe8155211a9ea06 upstream.
    
    When removing the last reference of an inode the size of an auth node
    is already part of write_len. So we must not call ubifs_add_auth_dirt().
    Call it only when needed.
    
    Cc: <stable@vger.kernel.org>
    Cc: Sascha Hauer <s.hauer@pengutronix.de>
    Cc: Kristof Havasi <havasiefr@gmail.com>
    Fixes: 6a98bc4614de ("ubifs: Add authentication nodes to journal")
    Reported-and-tested-by: Kristof Havasi <havasiefr@gmail.com>
    Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ae623c57f2c9683f403ed7e069f5d2e3da604d4b
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Mon Jun 1 17:10:36 2020 +0800

    ubifs: xattr: Fix some potential memory leaks while iterating entries
    
    commit f2aae745b82c842221f4f233051f9ac641790959 upstream.
    
    Fix some potential memory leaks in error handling branches while
    iterating xattr entries. For example, function ubifs_tnc_remove_ino()
    forgets to free pxent if it exists. Similar problems also exist in
    ubifs_purge_xattrs(), ubifs_add_orphan() and ubifs_jnl_write_inode().
    
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Cc: <stable@vger.kernel.org>
    Fixes: 1e51764a3c2ac05a2 ("UBIFS: add new flash file system")
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1b50e507831ac11bc193b93de97129b26714e28a
Author: Zhihao Cheng <chengzhihao1@huawei.com>
Date:   Mon Jun 1 17:10:37 2020 +0800

    ubifs: dent: Fix some potential memory leaks while iterating entries
    
    commit 58f6e78a65f1fcbf732f60a7478ccc99873ff3ba upstream.
    
    Fix some potential memory leaks in error handling branches while
    iterating dent entries. For example, function dbg_check_dir()
    forgets to free pdent if it exists.
    
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Cc: <stable@vger.kernel.org>
    Fixes: 1e51764a3c2ac05a2 ("UBIFS: add new flash file system")
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 72307bf6e6ae4151f89bb9199a29b346ad4584f6
Author: Chuck Lever <chuck.lever@oracle.com>
Date:   Thu Oct 1 18:58:56 2020 -0400

    NFSD: Add missing NFSv2 .pc_func methods
    
    commit 6b3dccd48de8a4c650b01499a0b09d1e2279649e upstream.
    
    There's no protection in nfsd_dispatch() against a NULL .pc_func
    helpers. A malicious NFS client can trigger a crash by invoking the
    unused/unsupported NFSv2 ROOT or WRITECACHE procedures.
    
    The current NFSD dispatcher does not support returning a void reply
    to a non-NULL procedure, so the reply to both of these is wrong, for
    the moment.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 45cfdb4978ad02fdbb3f3bbbe7ff99faf3e0aade
Author: Olga Kornievskaia <kolga@netapp.com>
Date:   Fri Oct 16 09:25:45 2020 -0400

    NFSv4.2: support EXCHGID4_FLAG_SUPP_FENCE_OPS 4.2 EXCHANGE_ID flag
    
    commit 8c39076c276be0b31982e44654e2c2357473258a upstream.
    
    RFC 7862 introduced a new flag that either client or server is
    allowed to set: EXCHGID4_FLAG_SUPP_FENCE_OPS.
    
    Client needs to update its bitmask to allow for this flag value.
    
    v2: changed minor version argument to unsigned int
    
    Signed-off-by: Olga Kornievskaia <kolga@netapp.com>
    CC: <stable@vger.kernel.org>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1a42395b89962b88b15979a7eb3408ef91183e46
Author: Benjamin Coddington <bcodding@redhat.com>
Date:   Fri Sep 25 15:48:39 2020 -0400

    NFSv4: Wait for stateid updates after CLOSE/OPEN_DOWNGRADE
    
    commit b4868b44c5628995fdd8ef2e24dda73cef963a75 upstream.
    
    Since commit 0e0cb35b417f ("NFSv4: Handle NFS4ERR_OLD_STATEID in
    CLOSE/OPEN_DOWNGRADE") the following livelock may occur if a CLOSE races
    with the update of the nfs_state:
    
    Process 1           Process 2           Server
    =========           =========           ========
     OPEN file
                        OPEN file
                                            Reply OPEN (1)
                                            Reply OPEN (2)
     Update state (1)
     CLOSE file (1)
                                            Reply OLD_STATEID (1)
     CLOSE file (2)
                                            Reply CLOSE (-1)
                        Update state (2)
                        wait for state change
     OPEN file
                        wake
     CLOSE file
     OPEN file
                        wake
     CLOSE file
     ...
                        ...
    
    We can avoid this situation by not issuing an immediate retry with a bumped
    seqid when CLOSE/OPEN_DOWNGRADE receives NFS4ERR_OLD_STATEID.  Instead,
    take the same approach used by OPEN and wait at least 5 seconds for
    outstanding stateid updates to complete if we can detect that we're out of
    sequence.
    
    Note that after this change it is still possible (though unlikely) that
    CLOSE waits a full 5 seconds, bumps the seqid, and retries -- and that
    attempt races with another OPEN at the same time.  In order to avoid this
    race (which would result in the livelock), update
    nfs_need_update_open_stateid() to handle the case where:
     - the state is NFS_OPEN_STATE, and
     - the stateid doesn't match the current open stateid
    
    Finally, nfs_need_update_open_stateid() is modified to be idempotent and
    renamed to better suit the purpose of signaling that the stateid passed
    is the next stateid in sequence.
    
    Fixes: 0e0cb35b417f ("NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE")
    Cc: stable@vger.kernel.org # v5.4+
    Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e939ac2bcae4f466482b1fec577098b2fecc90f6
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Thu Oct 15 11:16:48 2020 -0500

    gfs2: Only access gl_delete for iopen glocks
    
    commit 2ffed5290b3bff7562d29fd06621be4705704242 upstream.
    
    Only initialize gl_delete for iopen glocks, but more importantly, only access
    it for iopen glocks in flush_delete_work: flush_delete_work is called for
    different types of glocks including rgrp glocks, and those use gl_vm which is
    in a union with gl_delete.  Without this fix, we'll end up clobbering gl_vm,
    which results in general memory corruption.
    
    Fixes: a0e3cc65fa29 ("gfs2: Turn gl_delete into a delayed work")
    Cc: stable@vger.kernel.org # v5.8+
    Signed-off-by: Bob Peterson <rpeterso@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5d1e4222e900f80e0e032ac6790bd1ff1e5397a9
Author: Andreas Gruenbacher <agruenba@redhat.com>
Date:   Fri Aug 28 23:44:36 2020 +0200

    gfs2: Make sure we don't miss any delayed withdraws
    
    commit 5a61ae1402f15276ee4e003e198aab816958ca69 upstream.
    
    Commit ca399c96e96e changes gfs2_log_flush to not withdraw the
    filesystem while holding the log flush lock, but it fails to check if
    the filesystem needs to be withdrawn once the log flush lock has been
    released.  Likewise, commit f05b86db314d depends on gfs2_log_flush to
    trigger for delayed withdraws.  Add that and clean up the code flow
    somewhat.
    
    In gfs2_put_super, add a check for delayed withdraws that have been
    missed to prevent these kinds of bugs in the future.
    
    Fixes: ca399c96e96e ("gfs2: flesh out delayed withdraw for gfs2_log_flush")
    Fixes: f05b86db314d ("gfs2: Prepare to withdraw as soon as an IO error occurs in log write")
    Cc: stable@vger.kernel.org # v5.7+: 462582b99b607: gfs2: add some much needed cleanup for log flushes that fail
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6ba303f180cbae03bd4db9b4b2b71fdb3cabb932
Author: Sibi Sankar <sibis@codeaurora.org>
Date:   Wed Sep 16 20:21:00 2020 +0530

    remoteproc: Fixup coredump debugfs disable request
    
    commit 1894622636745237f882bfab47925afc48e122e0 upstream.
    
    Fix the discrepancy observed between accepted input and read back value
    while disabling remoteproc coredump through the coredump debugfs entry.
    
    Fixes: 3afdc59e4390 ("remoteproc: Add coredump debugfs entry")
    Cc: stable@vger.kernel.org
    Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
    Link: https://lore.kernel.org/r/20200916145100.15872-1-sibis@codeaurora.org
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e3902c9ac8bb93d18eaa8d6bb9c3475305609d96
Author: Jens Axboe <axboe@kernel.dk>
Date:   Sun Oct 25 13:53:26 2020 -0600

    io_uring: use type appropriate io_kiocb handler for double poll
    
    commit c8b5e2600a2cfa1cdfbecf151afd67aee227381d upstream.
    
    io_poll_double_wake() is called for both request types - both pure poll
    requests, and internal polls. This means that we should be using the
    right handler based on the request type. Use the one that the original
    caller already assigned for the waitqueue handling, that will always
    match the correct type.
    
    Cc: stable@vger.kernel.org # v5.8+
    Reported-by: Pavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e8f3eef754a02c8095db0fe2835aa9707abf3fb1
Author: Naohiro Aota <naohiro.aota@wdc.com>
Date:   Wed Oct 28 16:25:36 2020 +0900

    block: advance iov_iter on bio_add_hw_page failure
    
    commit 4977d121bc9bc5138d4d48b85469123001859573 upstream.
    
    When the bio's size reaches max_append_sectors, bio_add_hw_page returns
    0 then __bio_iov_append_get_pages returns -EINVAL. This is an expected
    result of building a small enough bio not to be split in the IO path.
    However, iov_iter is not advanced in this case, causing the same pages
    are filled for the bio again and again.
    
    Fix the case by properly advancing the iov_iter for already processed
    pages.
    
    Fixes: 0512a75b98f8 ("block: Introduce REQ_OP_ZONE_APPEND")
    Cc: stable@vger.kernel.org # 5.8+
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd353d5aef6f31a0ce6b2d15a7af0d0d12737f93
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Mon Sep 7 13:42:10 2020 +0000

    powerpc/32: Fix vmap stack - Properly set r1 before activating MMU
    
    commit da7bb43ab9da39bcfed0d146ce94e1f0cbae4ca0 upstream.
    
    We need r1 to be properly set before activating MMU, otherwise any new
    exception taken while saving registers into the stack in exception
    prologs will use the user stack, which is wrong and will even lockup
    or crash when KUAP is selected.
    
    Do that by switching the meaning of r11 and r1 until we have saved r1
    to the stack: copy r1 into r11 and setup the new stack pointer in r1.
    To avoid complicating and impacting all generic and specific prolog
    code (and more), copy back r1 into r11 once r11 is save onto
    the stack.
    
    We could get rid of copying r1 back and forth at the cost of
    rewriting everything to use r1 instead of r11 all the way when
    CONFIG_VMAP_STACK is set, but the effort is probably not worth it.
    
    Fixes: 028474876f47 ("powerpc/32: prepare for CONFIG_VMAP_STACK")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/8f85e8752ac5af602db7237ef53d634f4f3d3892.1599486108.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3b234b4a6651ed6bdca94553aa0038fc7ded9271
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Mon Sep 7 13:42:09 2020 +0000

    powerpc/32: Fix vmap stack - Do not activate MMU before reading task struct
    
    commit c118c7303ad528be8ff2aea8cd1ee15452c763f0 upstream.
    
    We need r1 to be properly set before activating MMU, so
    reading task_struct->stack must be done with MMU off.
    
    This means we need an additional register to play with MSR
    bits while r11 now points to the stack. For that, move r10
    back to CR (As is already done for hash MMU) and use r10.
    
    We still don't have r1 correct yet when we activate MMU.
    It is done in following patch.
    
    Fixes: 028474876f47 ("powerpc/32: prepare for CONFIG_VMAP_STACK")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/a027d447022a006c9c4958ac734128e577a3c5c1.1599486108.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3786d32512e306a1002e27941aebf8e9c2fa5e59
Author: Michael Neuling <mikey@neuling.org>
Date:   Tue Oct 13 15:37:40 2020 +1100

    powerpc: Fix undetected data corruption with P9N DD2.1 VSX CI load emulation
    
    commit 1da4a0272c5469169f78cd76cf175ff984f52f06 upstream.
    
    __get_user_atomic_128_aligned() stores to kaddr using stvx which is a
    VMX store instruction, hence kaddr must be 16 byte aligned otherwise
    the store won't occur as expected.
    
    Unfortunately when we call __get_user_atomic_128_aligned() in
    p9_hmi_special_emu(), the buffer we pass as kaddr (ie. vbuf) isn't
    guaranteed to be 16B aligned. This means that the write to vbuf in
    __get_user_atomic_128_aligned() has the bottom bits of the address
    truncated. This results in other local variables being
    overwritten. Also vbuf will not contain the correct data which results
    in the userspace emulation being wrong and hence undetected user data
    corruption.
    
    In the past we've been mostly lucky as vbuf has ended up aligned but
    this is fragile and isn't always true. CONFIG_STACKPROTECTOR in
    particular can change the stack arrangement enough that our luck runs
    out.
    
    This issue only occurs on POWER9 Nimbus <= DD2.1 bare metal.
    
    The fix is to align vbuf to a 16 byte boundary.
    
    Fixes: 5080332c2c89 ("powerpc/64s: Add workaround for P9 vector CI load issue")
    Cc: stable@vger.kernel.org # v4.15+
    Signed-off-by: Michael Neuling <mikey@neuling.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20201013043741.743413-1-mikey@neuling.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e35aa57098dffa42126eac99c7a57ad6fe21af19
Author: Ganesh Goudar <ganeshgr@linux.ibm.com>
Date:   Fri Oct 9 12:10:04 2020 +0530

    powerpc/mce: Avoid nmi_enter/exit in real mode on pseries hash
    
    commit 8d0e2101274358d9b6b1f27232b40253ca48bab5 upstream.
    
    Use of nmi_enter/exit in real mode handler causes the kernel to panic
    and reboot on injecting SLB mutihit on pseries machine running in hash
    MMU mode, because these calls try to accesses memory outside RMO
    region in real mode handler where translation is disabled.
    
    Add check to not to use these calls on pseries machine running in hash
    MMU mode.
    
    Fixes: 116ac378bb3f ("powerpc/64s: machine check interrupt update NMI accounting")
    Cc: stable@vger.kernel.org # v5.8+
    Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20201009064005.19777-2-ganeshgr@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b77220b670fbb562bf32b4676a4ffa5e0a947d79
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Fri Sep 11 10:29:15 2020 +0000

    powerpc/powermac: Fix low_sleep_handler with KUAP and KUEP
    
    commit 2c637d2df4ee4830e9d3eb2bd5412250522ce96e upstream.
    
    low_sleep_handler() has an hardcoded restore of segment registers
    that doesn't take KUAP and KUEP into account.
    
    Use head_32's load_segment_registers() routine instead.
    
    Fixes: a68c31fc01ef ("powerpc/32s: Implement Kernel Userspace Access Protection")
    Fixes: 31ed2b13c48d ("powerpc/32s: Implement Kernel Userspace Execution Prevention.")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/21b05f7298c1b18f73e6e5b4cd5005aafa24b6da.1599820109.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0797686ac440241f360387ae80f649233ae8ad0d
Author: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Date:   Tue Oct 6 13:02:18 2020 +0530

    powerpc/powernv/elog: Fix race while processing OPAL error log event.
    
    commit aea948bb80b478ddc2448f7359d574387521a52d upstream.
    
    Every error log reported by OPAL is exported to userspace through a
    sysfs interface and notified using kobject_uevent(). The userspace
    daemon (opal_errd) then reads the error log and acknowledges the error
    log is saved safely to disk. Once acknowledged the kernel removes the
    respective sysfs file entry causing respective resources to be
    released including kobject.
    
    However it's possible the userspace daemon may already be scanning
    elog entries when a new sysfs elog entry is created by the kernel.
    User daemon may read this new entry and ack it even before kernel can
    notify userspace about it through kobject_uevent() call. If that
    happens then we have a potential race between
    elog_ack_store->kobject_put() and kobject_uevent which can lead to
    use-after-free of a kernfs object resulting in a kernel crash. eg:
    
      BUG: Unable to handle kernel data access on read at 0x6b6b6b6b6b6b6bfb
      Faulting instruction address: 0xc0000000008ff2a0
      Oops: Kernel access of bad area, sig: 11 [#1]
      LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV
      CPU: 27 PID: 805 Comm: irq/29-opal-elo Not tainted 5.9.0-rc2-gcc-8.2.0-00214-g6f56a67bcbb5-dirty #363
      ...
      NIP kobject_uevent_env+0xa0/0x910
      LR  elog_event+0x1f4/0x2d0
      Call Trace:
        0x5deadbeef0000122 (unreliable)
        elog_event+0x1f4/0x2d0
        irq_thread_fn+0x4c/0xc0
        irq_thread+0x1c0/0x2b0
        kthread+0x1c4/0x1d0
        ret_from_kernel_thread+0x5c/0x6c
    
    This patch fixes this race by protecting the sysfs file
    creation/notification by holding a reference count on kobject until we
    safely send kobject_uevent().
    
    The function create_elog_obj() returns the elog object which if used
    by caller function will end up in use-after-free problem again.
    However, the return value of create_elog_obj() function isn't being
    used today and there is no need as well. Hence change it to return
    void to make this fix complete.
    
    Fixes: 774fea1a38c6 ("powerpc/powernv: Read OPAL error log and export it through sysfs")
    Cc: stable@vger.kernel.org # v3.15+
    Reported-by: Oliver O'Halloran <oohall@gmail.com>
    Signed-off-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
    Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
    [mpe: Rework the logic to use a single return, reword comments, add oops]
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20201006122051.190176-1-mpe@ellerman.id.au
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2e6181523dbbb5574ade5ca00b82566b60289406
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Wed Oct 7 17:18:34 2020 +0530

    powerpc/memhotplug: Make lmb size 64bit
    
    commit 301d2ea6572386245c5d2d2dc85c3b5a737b85ac upstream.
    
    Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic")
    make sure different variables tracking lmb_size are updated to be 64 bit.
    
    This was found by code audit.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20201007114836.282468-3-aneesh.kumar@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9a5bd871d7bdfe81e131970cfcf5efe48030a0f4
Author: Joel Stanley <joel@jms.id.au>
Date:   Wed Sep 2 09:30:11 2020 +0930

    powerpc: Warn about use of smt_snooze_delay
    
    commit a02f6d42357acf6e5de6ffc728e6e77faf3ad217 upstream.
    
    It's not done anything for a long time. Save the percpu variable, and
    emit a warning to remind users to not expect it to do anything.
    
    This uses pr_warn_once instead of pr_warn_ratelimit as testing
    'ppc64_cpu --smt=off' on a 24 core / 4 SMT system showed the warning
    to be noisy, as the online/offline loop is slow.
    
    Fixes: 3fa8cad82b94 ("powerpc/pseries/cpuidle: smt-snooze-delay cleanup.")
    Cc: stable@vger.kernel.org # v3.14
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Acked-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200902000012.3440389-1-joel@jms.id.au
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e61aaa2c70169a10dcd3df5391b1bc1468f11cac
Author: Andrew Donnellan <ajd@linux.ibm.com>
Date:   Thu Aug 20 14:45:12 2020 +1000

    powerpc/rtas: Restrict RTAS requests from userspace
    
    commit bd59380c5ba4147dcbaad3e582b55ccfd120b764 upstream.
    
    A number of userspace utilities depend on making calls to RTAS to retrieve
    information and update various things.
    
    The existing API through which we expose RTAS to userspace exposes more
    RTAS functionality than we actually need, through the sys_rtas syscall,
    which allows root (or anyone with CAP_SYS_ADMIN) to make any RTAS call they
    want with arbitrary arguments.
    
    Many RTAS calls take the address of a buffer as an argument, and it's up to
    the caller to specify the physical address of the buffer as an argument. We
    allocate a buffer (the "RMO buffer") in the Real Memory Area that RTAS can
    access, and then expose the physical address and size of this buffer in
    /proc/powerpc/rtas/rmo_buffer. Userspace is expected to read this address,
    poke at the buffer using /dev/mem, and pass an address in the RMO buffer to
    the RTAS call.
    
    However, there's nothing stopping the caller from specifying whatever
    address they want in the RTAS call, and it's easy to construct a series of
    RTAS calls that can overwrite arbitrary bytes (even without /dev/mem
    access).
    
    Additionally, there are some RTAS calls that do potentially dangerous
    things and for which there are no legitimate userspace use cases.
    
    In the past, this would not have been a particularly big deal as it was
    assumed that root could modify all system state freely, but with Secure
    Boot and lockdown we need to care about this.
    
    We can't fundamentally change the ABI at this point, however we can address
    this by implementing a filter that checks RTAS calls against a list
    of permitted calls and forces the caller to use addresses within the RMO
    buffer.
    
    The list is based off the list of calls that are used by the librtas
    userspace library, and has been tested with a number of existing userspace
    RTAS utilities. For compatibility with any applications we are not aware of
    that require other calls, the filter can be turned off at build time.
    
    Cc: stable@vger.kernel.org
    Reported-by: Daniel Axtens <dja@axtens.net>
    Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200820044512.7543-1-ajd@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0c310c8bb3ea63dfe7bc3311160e5019a3876f69
Author: Sven Schnelle <svens@linux.ibm.com>
Date:   Tue Sep 15 08:53:50 2020 +0200

    s390/stp: add locking to sysfs functions
    
    commit b3bd02495cb339124f13135d51940cf48d83e5cb upstream.
    
    The sysfs function might race with stp_work_fn. To prevent that,
    add the required locking. Another issue is that the sysfs functions
    are checking the stp_online flag, but this flag just holds the user
    setting whether STP is enabled. Add a flag to clock_sync_flag whether
    stp_info holds valid data and use that instead.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
    Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5473e4891935c6b1cdb9ae3f012a00e39fe8c678
Author: Paul Cercueil <paul@crapouillou.net>
Date:   Sun Sep 6 21:29:21 2020 +0200

    MIPS: configs: lb60: Fix defconfig not selecting correct board
    
    commit 7487abbe85afd02c35c283315cefc5e19c28d40f upstream.
    
    Since INGENIC_GENERIC_BOARD was introduced, the JZ4740_QI_LB60 option
    is no longer the default, so the symbol has to be selected by the
    defconfig, otherwise the kernel built will be for a generic Ingenic
    board and won't have the Device Tree blob built-in.
    
    Cc: stable@vger.kernel.org # v5.7
    Fixes: 62249209a772 ("MIPS: ingenic: Default to a generic board")
    Signed-off-by: Paul Cercueil <paul@crapouillou.net>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 208eee40188d88c3e02538dfd9f15e364cd64d68
Author: Maciej W. Rozycki <macro@linux-mips.org>
Date:   Wed Oct 14 22:34:56 2020 +0100

    MIPS: DEC: Restore bootmem reservation for firmware working memory area
    
    commit cf3af0a4d3b62ab48e0b90180ea161d0f5d4953f upstream.
    
    Fix a crash on DEC platforms starting with:
    
    VFS: Mounted root (nfs filesystem) on device 0:11.
    Freeing unused PROM memory: 124k freed
    BUG: Bad page state in process swapper  pfn:00001
    page:(ptrval) refcount:0 mapcount:-128 mapping:00000000 index:0x1 pfn:0x1
    flags: 0x0()
    raw: 00000000 00000100 00000122 00000000 00000001 00000000 ffffff7f 00000000
    page dumped because: nonzero mapcount
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper Not tainted 5.9.0-00858-g865c50e1d279 #1
    Stack : 8065dc48 0000000b 8065d2b8 9bc27dcc 80645bfc 9bc259a4 806a1b97 80703124
            80710000 8064a900 00000001 80099574 806b116c 1000ec00 9bc27d88 806a6f30
            00000000 00000000 80645bfc 00000000 31232039 80706ba4 2e392e35 8039f348
            2d383538 00000070 0000000a 35363867 00000000 806c2830 80710000 806b0000
            80710000 8064a900 00000001 81000000 00000000 00000000 8035af2c 80700000
            ...
    Call Trace:
    [<8004bc5c>] show_stack+0x34/0x104
    [<8015675c>] bad_page+0xfc/0x128
    [<80157714>] free_pcppages_bulk+0x1f4/0x5dc
    [<801591cc>] free_unref_page+0xc0/0x130
    [<8015cb04>] free_reserved_area+0x144/0x1d8
    [<805abd78>] kernel_init+0x20/0x100
    [<80046070>] ret_from_kernel_thread+0x14/0x1c
    Disabling lock debugging due to kernel taint
    
    caused by an attempt to free bootmem space that as from
    commit b93ddc4f9156 ("mips: Reserve memory for the kernel image resources")
    has not been anymore reserved due to the removal of generic MIPS arch code
    that used to reserve all the memory from the beginning of RAM up to the
    kernel load address.
    
    This memory does need to be reserved on DEC platforms however as it is
    used by REX firmware as working area, as per the TURBOchannel firmware
    specification[1]:
    
    Table 2-2  REX Memory Regions
    -------------------------------------------------------------------------
            Starting        Ending
    Region  Address         Address         Use
    -------------------------------------------------------------------------
    0       0xa0000000      0xa000ffff      Restart block, exception vectors,
                                            REX stack and bss
    1       0xa0010000      0xa0017fff      Keyboard or tty drivers
    
    2       0xa0018000      0xa001f3ff 1)   CRT driver
    
    3       0xa0020000      0xa002ffff      boot, cnfg, init and t objects
    
    4       0xa0020000      0xa002ffff      64KB scratch space
    -------------------------------------------------------------------------
    1) Note that the last 3 Kbytes of region 2 are reserved for backward
    compatibility with previous system software.
    -------------------------------------------------------------------------
    
    (this table uses KSEG2 unmapped virtual addresses, which in the MIPS
    architecture are offset from physical addresses by a fixed value of
    0xa0000000 and therefore the regions referred do correspond to the
    beginning of the physical address space) and we call into the firmware
    on several occasions throughout the bootstrap process.  It is believed
    that pre-REX firmware used with non-TURBOchannel DEC platforms has the
    same requirements, as hinted by note #1 cited.
    
    Recreate the discarded reservation then, in DEC platform code, removing
    the crash.
    
    References:
    
    [1] "TURBOchannel Firmware Specification", On-line version,
        EK-TCAAD-FS-004, Digital Equipment Corporation, January 1993,
        Chapter 2 "System Module Firmware", p. 2-5
    
    Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
    Fixes: b93ddc4f9156 ("mips: Reserve memory for the kernel image resources")
    Cc: stable@vger.kernel.org # v5.2+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

commit 463fbe4f2bc20be5cfb3ac2ea5cd57052e9ca45e
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Tue Sep 15 14:27:38 2020 -0700

    rcu-tasks: Enclose task-list scan in rcu_read_lock()
    
    commit f747c7e15d7bc71a967a94ceda686cf2460b69e8 upstream.
    
    The rcu_tasks_trace_postgp() function uses for_each_process_thread()
    to scan the task list without the benefit of RCU read-side protection,
    which can result in use-after-free errors on task_struct structures.
    This error was missed because the TRACE01 rcutorture scenario enables
    lockdep, but also builds with CONFIG_PREEMPT_NONE=y.  In this situation,
    preemption is disabled everywhere, so lockdep thinks everywhere can
    be a legitimate RCU reader.  This commit therefore adds the needed
    rcu_read_lock() and rcu_read_unlock().
    
    Note that this bug can occur only after an RCU Tasks Trace CPU stall
    warning, which by default only happens after a grace period has extended
    for ten minutes (yes, not a typo, minutes).
    
    Fixes: 4593e772b502 ("rcu-tasks: Add stall warnings for RCU Tasks Trace")
    Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: <bpf@vger.kernel.org>
    Cc: <stable@vger.kernel.org> # 5.7.x
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19506c4e2022e283a2889f553c075e7221066db8
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Tue Sep 15 14:03:34 2020 -0700

    rcu-tasks: Fix low-probability task_struct leak
    
    commit 592031cc10858be4adb10f6c0f2608f6f21824aa upstream.
    
    When rcu_tasks_trace_postgp() function detects an RCU Tasks Trace
    CPU stall, it adds all tasks blocking the current grace period to
    a list, invoking get_task_struct() on each to prevent them from
    being freed while on the list.  It then traverses that list,
    printing stall-warning messages for each one that is still blocking
    the current grace period and removing it from the list.  The list
    removal invokes the matching put_task_struct().
    
    This of course means that in the admittedly unlikely event that some
    task executes its outermost rcu_read_unlock_trace() in the meantime, it
    won't be removed from the list and put_task_struct() won't be executing,
    resulting in a task_struct leak.  This commit therefore makes the list
    removal and put_task_struct() unconditional, stopping the leak.
    
    Note further that this bug can occur only after an RCU Tasks Trace CPU
    stall warning, which by default only happens after a grace period has
    extended for ten minutes (yes, not a typo, minutes).
    
    Fixes: 4593e772b502 ("rcu-tasks: Add stall warnings for RCU Tasks Trace")
    Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: <bpf@vger.kernel.org>
    Cc: <stable@vger.kernel.org> # 5.7.x
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 79036216e1bb74fc868976a305062953728a790a
Author: Paul E. McKenney <paulmck@kernel.org>
Date:   Mon Sep 14 15:44:37 2020 -0700

    rcu-tasks: Fix grace-period/unlock race in RCU Tasks Trace
    
    commit ba3a86e47232ad9f76160929f33ac9c64e4d0567 upstream.
    
    The more intense grace-period processing resulting from the 50x RCU
    Tasks Trace grace-period speedups exposed the following race condition:
    
    o       Task A running on CPU 0 executes rcu_read_lock_trace(),
            entering a read-side critical section.
    
    o       When Task A eventually invokes rcu_read_unlock_trace()
            to exit its read-side critical section, this function
            notes that the ->trc_reader_special.s flag is zero and
            and therefore invoke wil set ->trc_reader_nesting to zero
            using WRITE_ONCE().  But before that happens...
    
    o       The RCU Tasks Trace grace-period kthread running on some other
            CPU interrogates Task A, but this fails because this task is
            currently running.  This kthread therefore sends an IPI to CPU 0.
    
    o       CPU 0 receives the IPI, and thus invokes trc_read_check_handler().
            Because Task A has not yet cleared its ->trc_reader_nesting
            counter, this function sees that Task A is still within its
            read-side critical section.  This function therefore sets the
            ->trc_reader_nesting.b.need_qs flag, AKA the .need_qs flag.
    
            Except that Task A has already checked the .need_qs flag, which
            is part of the ->trc_reader_special.s flag.  The .need_qs flag
            therefore remains set until Task A's next rcu_read_unlock_trace().
    
    o       Task A now invokes synchronize_rcu_tasks_trace(), which cannot
            start a new grace period until the current grace period completes.
            And thus cannot return until after that time.
    
            But Task A's .need_qs flag is still set, which prevents the current
            grace period from completing.  And because Task A is blocked, it
            will never execute rcu_read_unlock_trace() until its call to
            synchronize_rcu_tasks_trace() returns.
    
            We are therefore deadlocked.
    
    This race is improbable, but 80 hours of rcutorture made it happen twice.
    The race was possible before the grace-period speedup, but roughly 50x
    less probable.  Several thousand hours of rcutorture would have been
    necessary to have a reasonable chance of making this happen before this
    50x speedup.
    
    This commit therefore eliminates this deadlock by setting
    ->trc_reader_nesting to a large negative number before checking the
    .need_qs and zeroing (or decrementing with respect to its initial
    value) ->trc_reader_nesting.  For its part, the IPI handler's
    trc_read_check_handler() function adds a check for negative values,
    deferring evaluation of the task in this case.  Taken together, these
    changes avoid this deadlock scenario.
    
    Fixes: 276c410448db ("rcu-tasks: Split ->trc_reader_need_end")
    Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: <bpf@vger.kernel.org>
    Cc: <stable@vger.kernel.org> # 5.7.x
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90ab55ddfa6b16279310e9a3a9c13ebde9286117
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Wed Oct 7 17:18:33 2020 +0530

    powerpc/drmem: Make lmb_size 64 bit
    
    commit ec72024e35dddb88a81e40071c87ceb18b5ee835 upstream.
    
    Similar to commit 89c140bbaeee ("pseries: Fix 64 bit logical memory block panic")
    make sure different variables tracking lmb_size are updated to be 64 bit.
    
    This was found by code audit.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Acked-by: Nathan Lynch <nathanl@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20201007114836.282468-2-aneesh.kumar@linux.ibm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bf4757c993eeacb36ba03e64555cbede46ab20d7
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Jul 22 16:50:41 2020 +0100

    iio:gyro:itg3200: Fix timestamp alignment and prevent data leak.
    
    commit 10ab7cfd5522f0041028556dac864a003e158556 upstream.
    
    One of a class of bugs pointed out by Lars in a recent review.
    iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
    to the size of the timestamp (8 bytes).  This is not guaranteed in
    this driver which uses a 16 byte array of smaller elements on the stack.
    This is fixed by using an explicit c structure. As there are no
    holes in the structure, there is no possiblity of data leakage
    in this case.
    
    The explicit alignment of ts is not strictly necessary but potentially
    makes the code slightly less fragile.  It also removes the possibility
    of this being cut and paste into another driver where the alignment
    isn't already true.
    
    Fixes: 36e0371e7764 ("iio:itg3200: Use iio_push_to_buffers_with_timestamp()")
    Reported-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200722155103.979802-6-jic23@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a42ca3b182ccb766666a0be1053921cba190e2de
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Jul 22 16:50:52 2020 +0100

    iio:imu:st_lsm6dsx Fix alignment and data leak issues
    
    commit c14edb4d0bdc53f969ea84c7f384472c28b1a9f8 upstream.
    
    One of a class of bugs pointed out by Lars in a recent review.
    iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
    to the size of the timestamp (8 bytes).  This is not guaranteed in
    this driver which uses an array of smaller elements on the stack.
    As Lars also noted this anti pattern can involve a leak of data to
    userspace and that indeed can happen here.  We close both issues by
    moving to an array of suitable structures in the iio_priv() data.
    
    This data is allocated with kzalloc so no data can leak apart from
    previous readings.
    
    For the tagged path the data is aligned by using __aligned(8) for
    the buffer on the stack.
    
    There has been a lot of churn in this driver, so likely backports
    may be needed for stable.
    
    Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver")
    Reported-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Cc: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200722155103.979802-17-jic23@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 221a429fb5078ff53baeda054c2bcc463b51ebb2
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Jul 22 16:51:01 2020 +0100

    iio:adc:ti-adc12138 Fix alignment issue with timestamp
    
    commit 293e809b2e8e608b65a949101aaf7c0bd1224247 upstream.
    
    One of a class of bugs pointed out by Lars in a recent review.
    iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
    to the size of the timestamp (8 bytes).  This is not guaranteed in
    this driver which uses an array of smaller elements on the stack.
    
    We move to a suitable structure in the iio_priv() data with alignment
    explicitly requested.  This data is allocated with kzalloc so no
    data can leak apart from previous readings. Note that previously
    no leak at all could occur, but previous readings should never
    be a problem.
    
    In this case the timestamp location depends on what other channels
    are enabled. As such we can't use a structure without misleading
    by suggesting only one possible timestamp location.
    
    Fixes: 50a6edb1b6e0 ("iio: adc: add ADC12130/ADC12132/ADC12138 ADC driver")
    Reported-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Cc: Akinobu Mita <akinobu.mita@gmail.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200722155103.979802-26-jic23@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b938a8ee2b6a2b52f84a65503c9c26fb19655a07
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Jul 22 16:51:00 2020 +0100

    iio:adc:ti-adc0832 Fix alignment issue with timestamp
    
    commit 39e91f3be4cba51c1560bcda3a343ed1f64dc916 upstream.
    
    One of a class of bugs pointed out by Lars in a recent review.
    iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
    to the size of the timestamp (8 bytes).  This is not guaranteed in
    this driver which uses an array of smaller elements on the stack.
    
    We fix this issues by moving to a suitable structure in the iio_priv()
    data with alignment explicitly requested.  This data is allocated
    with kzalloc so no data can leak apart from previous readings.
    Note that previously no data could leak 'including' previous readings
    but I don't think it is an issue to potentially leak them like
    this now does.
    
    In this case the postioning of the timestamp is depends on what
    other channels are enabled. As such we cannot use a structure to
    make the alignment explicit as it would be missleading by suggesting
    only one possible location for the timestamp.
    
    Fixes: 815bbc87462a ("iio: ti-adc0832: add triggered buffer support")
    Reported-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Cc: Akinobu Mita <akinobu.mita@gmail.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200722155103.979802-25-jic23@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dd58722bf5cf0a2420847240a50cf0584127121a
Author: Nuno Sá <nuno.sa@analog.com>
Date:   Fri Sep 25 11:10:45 2020 +0200

    iio: ad7292: Fix of_node refcounting
    
    commit b8a533f3c24b3b8f1fdbefc5ada6a7d5733d63e6 upstream.
    
    When returning or breaking early from a
    `for_each_available_child_of_node()` loop, we need to explicitly call
    `of_node_put()` on the child node to possibly release the node.
    
    Fixes: 506d2e317a0a0 ("iio: adc: Add driver support for AD7292")
    Signed-off-by: Nuno Sá <nuno.sa@analog.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200925091045.302-2-nuno.sa@analog.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e4a6eb72cbeafd73f35a117e75f9ad5b2a6d62fa
Author: Tobias Jordan <kernel@cdqe.de>
Date:   Sat Sep 26 18:19:46 2020 +0200

    iio: adc: gyroadc: fix leak of device node iterator
    
    commit da4410d4078ba4ead9d6f1027d6db77c5a74ecee upstream.
    
    Add missing of_node_put calls when exiting the for_each_child_of_node
    loop in rcar_gyroadc_parse_subdevs early.
    
    Also add goto-exception handling for the error paths in that loop.
    
    Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
    Signed-off-by: Tobias Jordan <kernel@cdqe.de>
    Link: https://lore.kernel.org/r/20200926161946.GA10240@agrajag.zerfleddert.de
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6c2142193a5f54b804c31e01d3cb0e2fcad430fe
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Jul 22 16:50:44 2020 +0100

    iio:light:si1145: Fix timestamp alignment and prevent data leak.
    
    commit 0456ecf34d466261970e0ff92b2b9c78a4908637 upstream.
    
    One of a class of bugs pointed out by Lars in a recent review.
    iio_push_to_buffers_with_timestamp assumes the buffer used is aligned
    to the size of the timestamp (8 bytes).  This is not guaranteed in
    this driver which uses a 24 byte array of smaller elements on the stack.
    As Lars also noted this anti pattern can involve a leak of data to
    userspace and that indeed can happen here.  We close both issues by
    moving to a suitable array in the iio_priv() data with alignment
    explicitly requested.  This data is allocated with kzalloc so no
    data can leak appart from previous readings.
    
    Depending on the enabled channels, the  location of the timestamp
    can be at various aligned offsets through the buffer.  As such we
    any use of a structure to enforce this alignment would incorrectly
    suggest a single location for the timestamp.  Comments adjusted to
    express this clearly in the code.
    
    Fixes: ac45e57f1590 ("iio: light: Add driver for Silabs si1132, si1141/2/3 and si1145/6/7 ambient light, uv index and proximity sensors")
    Reported-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200722155103.979802-9-jic23@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8602dad7e2294a575a9d1b38932b7641ac10f431
Author: Tom Rix <trix@redhat.com>
Date:   Sun Aug 9 10:55:51 2020 -0700

    iio:imu:st_lsm6dsx: check st_lsm6dsx_shub_read_output return
    
    commit f71e41e23e129640f620b65fc362a6da02580310 upstream.
    
    Potential error return is not checked.  This can lead to use
    of undefined data.
    
    Detected by clang static analysis.
    
    st_lsm6dsx_shub.c:540:8: warning: Assigned value is garbage or undefined
            *val = (s16)le16_to_cpu(*((__le16 *)data));
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
    Signed-off-by: Tom Rix <trix@redhat.com
    Cc: <Stable@vger.kernel.org>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Link: https://lore.kernel.org/r/20200809175551.6794-1-trix@redhat.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c955cccf8230c3326c044dacc8e8e46bfa9c64ed
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Jul 22 16:50:53 2020 +0100

    iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.
    
    commit 6b0cc5dce0725ae8f1a2883514da731c55eeb35e upstream.
    
    This case is a bit different to the rest of the series.  The driver
    was doing a regmap_bulk_read into a buffer that wasn't dma safe
    as it was on the stack with no guarantee of it being in a cacheline
    on it's own.   Fixing that also dealt with the data leak and
    alignment issues that Lars-Peter pointed out.
    
    Also removed some unaligned handling as we are now aligned.
    
    Fixes tag is for the dma safe buffer issue. Potentially we would
    need to backport timestamp alignment futher but that is a totally
    different patch.
    
    Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
    Reported-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
    Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
    Cc: <Stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20200722155103.979802-18-jic23@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fe6f7de1309ac9da504ce351f3e46496166db5e9
Author: Eugen Hristev <eugen.hristev@microchip.com>
Date:   Wed Sep 23 15:17:48 2020 +0300

    iio: adc: at91-sama5d2_adc: fix DMA conversion crash
    
    commit 1a198794451449113fa86994ed491d6986802c23 upstream.
    
    After the move of the postenable code to preenable, the DMA start was
    done before the DMA init, which is not correct.
    The DMA is initialized in set_watermark. Because of this, we need to call
    the DMA start functions in set_watermark, after the DMA init, instead of
    preenable hook, when the DMA is not properly setup yet.
    
    Fixes: f3c034f61775 ("iio: at91-sama5d2_adc: adjust iio_triggered_buffer_{predisable,postenable} positions")
    Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
    Link: https://lore.kernel.org/r/20200923121748.49384-1-eugen.hristev@microchip.com
    Cc: <Stable@vger.kernel.org>
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3990c508d64038634678d800c8b86e2c37b91762
Author: Nuno Sá <nuno.sa@analog.com>
Date:   Fri Sep 25 11:10:44 2020 +0200

    iio: ltc2983: Fix of_node refcounting
    
    commit b07c47bfab6f5c4c7182d23e854bbceaf7829c85 upstream.
    
    When returning or breaking early from a
    `for_each_available_child_of_node()` loop, we need to explicitly call
    `of_node_put()` on the child node to possibly release the node.
    
    Fixes: f110f3188e563 ("iio: temperature: Add support for LTC2983")
    Signed-off-by: Nuno Sá <nuno.sa@analog.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200925091045.302-1-nuno.sa@analog.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4655afcf0e3874af03afff8c8704b52350bdba47
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Tue Oct 27 22:49:22 2020 +0100

    drm/shme-helpers: Fix dma_buf_mmap forwarding bug
    
    commit f49a51bfdc8ea717c97ccd4cc98b7e6daaa5553a upstream.
    
    When we forward an mmap to the dma_buf exporter, they get to own
    everything. Unfortunately drm_gem_mmap_obj() overwrote
    vma->vm_private_data after the driver callback, wreaking the
    exporter complete. This was noticed because vb2_common_vm_close blew
    up on mali gpu with panfrost after commit 26d3ac3cb04d
    ("drm/shmem-helpers: Redirect mmap for imported dma-buf").
    
    Unfortunately drm_gem_mmap_obj also acquires a surplus reference that
    we need to drop in shmem helpers, which is a bit of a mislayer
    situation. Maybe the entire dma_buf_mmap forwarding should be pulled
    into core gem code.
    
    Note that the only two other drivers which forward mmap in their own
    code (etnaviv and exynos) get this somewhat right by overwriting the
    gem mmap code. But they seem to still have the leak. This might be a
    good excuse to move these drivers over to shmem helpers completely.
    
    Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
    Acked-by: Christian König <christian.koenig@amd.com>
    Cc: Christian König <christian.koenig@amd.com>
    Cc: Sumit Semwal <sumit.semwal@linaro.org>
    Cc: Lucas Stach <l.stach@pengutronix.de>
    Cc: Russell King <linux+etnaviv@armlinux.org.uk>
    Cc: Christian Gmeiner <christian.gmeiner@gmail.com>
    Cc: Inki Dae <inki.dae@samsung.com>
    Cc: Joonyoung Shim <jy0922.shim@samsung.com>
    Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
    Cc: Kyungmin Park <kyungmin.park@samsung.com>
    Fixes: 26d3ac3cb04d ("drm/shmem-helpers: Redirect mmap for imported dma-buf")
    Cc: Boris Brezillon <boris.brezillon@collabora.com>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Gerd Hoffmann <kraxel@redhat.com>
    Cc: Rob Herring <robh@kernel.org>
    Cc: dri-devel@lists.freedesktop.org
    Cc: linux-media@vger.kernel.org
    Cc: linaro-mm-sig@lists.linaro.org
    Cc: <stable@vger.kernel.org> # v5.9+
    Reported-and-tested-by: piotr.oniszczuk@gmail.com
    Cc: piotr.oniszczuk@gmail.com
    Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20201027214922.3566743-1-daniel.vetter@ffwll.ch
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 465094b411efd7b40a197b893767e5dee4fcb223
Author: Laurent Vivier <lvivier@redhat.com>
Date:   Tue Oct 27 18:59:14 2020 +0100

    vdpa_sim: Fix DMA mask
    
    commit 1eca16b231570c8ae57fb91fdfbc48eb52c6a93b upstream.
    
    Since commit f959dcd6ddfd
    ("dma-direct: Fix potential NULL pointer dereference")
    an error is reported when we load vdpa_sim and virtio-vdpa:
    
    [  129.351207] net eth0: Unexpected TXQ (0) queue failure: -12
    
    It seems that dma_mask is not initialized.
    
    This patch initializes dma_mask() and calls dma_set_mask_and_coherent()
    to fix the problem.
    
    Full log:
    
    [  128.548628] ------------[ cut here ]------------
    [  128.553268] WARNING: CPU: 23 PID: 1105 at kernel/dma/mapping.c:149 dma_map_page_attrs+0x14c/0x1d0
    [  128.562139] Modules linked in: virtio_net net_failover failover virtio_vdpa vdpa_sim vringh vhost_iotlb vdpa xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 nft_compat nft_counter nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink tun bridge stp llc iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi rfkill intel_rapl_msr intel_rapl_common isst_if_common sunrpc skx_edac nfit libnvdimm x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ipmi_ssif kvm mgag200 i2c_algo_bit irqbypass drm_kms_helper crct10dif_pclmul crc32_pclmul syscopyarea ghash_clmulni_intel iTCO_wdt sysfillrect iTCO_vendor_support sysimgblt rapl fb_sys_fops dcdbas intel_cstate drm acpi_ipmi ipmi_si mei_me dell_smbios intel_uncore ipmi_devintf mei i2c_i801 dell_wmi_descriptor wmi_bmof pcspkr lpc_ich i2c_smbus ipmi_msghandler acpi_power_meter ip_tables xfs libcrc32c sd_mod t10_pi sg ahci libahci libata megaraid_sas tg3 crc32c_intel wmi dm_mirror dm_region_hash dm_log
    [  128.562188]  dm_mod
    [  128.651334] CPU: 23 PID: 1105 Comm: NetworkManager Tainted: G S        I       5.10.0-rc1+ #59
    [  128.659939] Hardware name: Dell Inc. PowerEdge R440/04JN2K, BIOS 2.8.1 06/30/2020
    [  128.667419] RIP: 0010:dma_map_page_attrs+0x14c/0x1d0
    [  128.672384] Code: 1c 25 28 00 00 00 0f 85 97 00 00 00 48 83 c4 10 5b 5d 41 5c 41 5d c3 4c 89 da eb d7 48 89 f2 48 2b 50 18 48 89 d0 eb 8d 0f 0b <0f> 0b 48 c7 c0 ff ff ff ff eb c3 48 89 d9 48 8b 40 40 e8 2d a0 aa
    [  128.691131] RSP: 0018:ffffae0f0151f3c8 EFLAGS: 00010246
    [  128.696357] RAX: ffffffffc06b7400 RBX: 00000000000005fa RCX: 0000000000000000
    [  128.703488] RDX: 0000000000000040 RSI: ffffcee3c7861200 RDI: ffff9e2bc16cd000
    [  128.710620] RBP: 0000000000000000 R08: 0000000000000002 R09: 0000000000000000
    [  128.717754] R10: 0000000000000002 R11: 0000000000000000 R12: ffff9e472cb291f8
    [  128.724886] R13: ffff9e2bc14da780 R14: ffff9e472bc20000 R15: ffff9e2bc1b14940
    [  128.732020] FS:  00007f887bae23c0(0000) GS:ffff9e4ac01c0000(0000) knlGS:0000000000000000
    [  128.740105] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  128.745852] CR2: 0000562bc09de998 CR3: 00000003c156c006 CR4: 00000000007706e0
    [  128.752982] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [  128.760114] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [  128.767247] PKRU: 55555554
    [  128.769961] Call Trace:
    [  128.772418]  virtqueue_add+0x81e/0xb00
    [  128.776176]  virtqueue_add_inbuf_ctx+0x26/0x30
    [  128.780625]  try_fill_recv+0x3a2/0x6e0 [virtio_net]
    [  128.785509]  virtnet_open+0xf9/0x180 [virtio_net]
    [  128.790217]  __dev_open+0xe8/0x180
    [  128.793620]  __dev_change_flags+0x1a7/0x210
    [  128.797808]  dev_change_flags+0x21/0x60
    [  128.801646]  do_setlink+0x328/0x10e0
    [  128.805227]  ? __nla_validate_parse+0x121/0x180
    [  128.809757]  ? __nla_parse+0x21/0x30
    [  128.813338]  ? inet6_validate_link_af+0x5c/0xf0
    [  128.817871]  ? cpumask_next+0x17/0x20
    [  128.821535]  ? __snmp6_fill_stats64.isra.54+0x6b/0x110
    [  128.826676]  ? __nla_validate_parse+0x47/0x180
    [  128.831120]  __rtnl_newlink+0x541/0x8e0
    [  128.834962]  ? __nla_reserve+0x38/0x50
    [  128.838713]  ? security_sock_rcv_skb+0x2a/0x40
    [  128.843158]  ? netlink_deliver_tap+0x2c/0x1e0
    [  128.847518]  ? netlink_attachskb+0x1d8/0x220
    [  128.851793]  ? skb_queue_tail+0x1b/0x50
    [  128.855641]  ? fib6_clean_node+0x43/0x170
    [  128.859652]  ? _cond_resched+0x15/0x30
    [  128.863406]  ? kmem_cache_alloc_trace+0x3a3/0x420
    [  128.868110]  rtnl_newlink+0x43/0x60
    [  128.871602]  rtnetlink_rcv_msg+0x12c/0x380
    [  128.875701]  ? rtnl_calcit.isra.39+0x110/0x110
    [  128.880147]  netlink_rcv_skb+0x50/0x100
    [  128.883987]  netlink_unicast+0x1a5/0x280
    [  128.887913]  netlink_sendmsg+0x23d/0x470
    [  128.891839]  sock_sendmsg+0x5b/0x60
    [  128.895331]  ____sys_sendmsg+0x1ef/0x260
    [  128.899255]  ? copy_msghdr_from_user+0x5c/0x90
    [  128.903702]  ___sys_sendmsg+0x7c/0xc0
    [  128.907369]  ? dev_forward_change+0x130/0x130
    [  128.911731]  ? sysctl_head_finish.part.29+0x24/0x40
    [  128.916616]  ? new_sync_write+0x11f/0x1b0
    [  128.920628]  ? mntput_no_expire+0x47/0x240
    [  128.924727]  __sys_sendmsg+0x57/0xa0
    [  128.928309]  do_syscall_64+0x33/0x40
    [  128.931887]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [  128.936937] RIP: 0033:0x7f88792e3857
    [  128.940518] Code: c3 66 90 41 54 41 89 d4 55 48 89 f5 53 89 fb 48 83 ec 10 e8 0b ed ff ff 44 89 e2 48 89 ee 89 df 41 89 c0 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 48 89 44 24 08 e8 44 ed ff ff 48
    [  128.959263] RSP: 002b:00007ffdca60dea0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e
    [  128.966827] RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f88792e3857
    [  128.973960] RDX: 0000000000000000 RSI: 00007ffdca60def0 RDI: 000000000000000c
    [  128.981095] RBP: 00007ffdca60def0 R08: 0000000000000000 R09: 0000000000000000
    [  128.988224] R10: 0000000000000001 R11: 0000000000000293 R12: 0000000000000000
    [  128.995357] R13: 0000000000000000 R14: 00007ffdca60e0a8 R15: 00007ffdca60e09c
    [  129.002492] CPU: 23 PID: 1105 Comm: NetworkManager Tainted: G S        I       5.10.0-rc1+ #59
    [  129.011093] Hardware name: Dell Inc. PowerEdge R440/04JN2K, BIOS 2.8.1 06/30/2020
    [  129.018571] Call Trace:
    [  129.021027]  dump_stack+0x57/0x6a
    [  129.024346]  __warn.cold.14+0xe/0x3d
    [  129.027925]  ? dma_map_page_attrs+0x14c/0x1d0
    [  129.032283]  report_bug+0xbd/0xf0
    [  129.035602]  handle_bug+0x44/0x80
    [  129.038922]  exc_invalid_op+0x13/0x60
    [  129.042589]  asm_exc_invalid_op+0x12/0x20
    [  129.046602] RIP: 0010:dma_map_page_attrs+0x14c/0x1d0
    [  129.051566] Code: 1c 25 28 00 00 00 0f 85 97 00 00 00 48 83 c4 10 5b 5d 41 5c 41 5d c3 4c 89 da eb d7 48 89 f2 48 2b 50 18 48 89 d0 eb 8d 0f 0b <0f> 0b 48 c7 c0 ff ff ff ff eb c3 48 89 d9 48 8b 40 40 e8 2d a0 aa
    [  129.070311] RSP: 0018:ffffae0f0151f3c8 EFLAGS: 00010246
    [  129.075536] RAX: ffffffffc06b7400 RBX: 00000000000005fa RCX: 0000000000000000
    [  129.082669] RDX: 0000000000000040 RSI: ffffcee3c7861200 RDI: ffff9e2bc16cd000
    [  129.089803] RBP: 0000000000000000 R08: 0000000000000002 R09: 0000000000000000
    [  129.096936] R10: 0000000000000002 R11: 0000000000000000 R12: ffff9e472cb291f8
    [  129.104068] R13: ffff9e2bc14da780 R14: ffff9e472bc20000 R15: ffff9e2bc1b14940
    [  129.111200]  virtqueue_add+0x81e/0xb00
    [  129.114952]  virtqueue_add_inbuf_ctx+0x26/0x30
    [  129.119399]  try_fill_recv+0x3a2/0x6e0 [virtio_net]
    [  129.124280]  virtnet_open+0xf9/0x180 [virtio_net]
    [  129.128984]  __dev_open+0xe8/0x180
    [  129.132390]  __dev_change_flags+0x1a7/0x210
    [  129.136575]  dev_change_flags+0x21/0x60
    [  129.140415]  do_setlink+0x328/0x10e0
    [  129.143994]  ? __nla_validate_parse+0x121/0x180
    [  129.148528]  ? __nla_parse+0x21/0x30
    [  129.152107]  ? inet6_validate_link_af+0x5c/0xf0
    [  129.156639]  ? cpumask_next+0x17/0x20
    [  129.160306]  ? __snmp6_fill_stats64.isra.54+0x6b/0x110
    [  129.165443]  ? __nla_validate_parse+0x47/0x180
    [  129.169890]  __rtnl_newlink+0x541/0x8e0
    [  129.173731]  ? __nla_reserve+0x38/0x50
    [  129.177483]  ? security_sock_rcv_skb+0x2a/0x40
    [  129.181928]  ? netlink_deliver_tap+0x2c/0x1e0
    [  129.186286]  ? netlink_attachskb+0x1d8/0x220
    [  129.190560]  ? skb_queue_tail+0x1b/0x50
    [  129.194401]  ? fib6_clean_node+0x43/0x170
    [  129.198411]  ? _cond_resched+0x15/0x30
    [  129.202163]  ? kmem_cache_alloc_trace+0x3a3/0x420
    [  129.206869]  rtnl_newlink+0x43/0x60
    [  129.210361]  rtnetlink_rcv_msg+0x12c/0x380
    [  129.214462]  ? rtnl_calcit.isra.39+0x110/0x110
    [  129.218908]  netlink_rcv_skb+0x50/0x100
    [  129.222747]  netlink_unicast+0x1a5/0x280
    [  129.226672]  netlink_sendmsg+0x23d/0x470
    [  129.230599]  sock_sendmsg+0x5b/0x60
    [  129.234090]  ____sys_sendmsg+0x1ef/0x260
    [  129.238015]  ? copy_msghdr_from_user+0x5c/0x90
    [  129.242461]  ___sys_sendmsg+0x7c/0xc0
    [  129.246128]  ? dev_forward_change+0x130/0x130
    [  129.250487]  ? sysctl_head_finish.part.29+0x24/0x40
    [  129.255368]  ? new_sync_write+0x11f/0x1b0
    [  129.259381]  ? mntput_no_expire+0x47/0x240
    [  129.263478]  __sys_sendmsg+0x57/0xa0
    [  129.267058]  do_syscall_64+0x33/0x40
    [  129.270639]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [  129.275689] RIP: 0033:0x7f88792e3857
    [  129.279268] Code: c3 66 90 41 54 41 89 d4 55 48 89 f5 53 89 fb 48 83 ec 10 e8 0b ed ff ff 44 89 e2 48 89 ee 89 df 41 89 c0 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 48 89 44 24 08 e8 44 ed ff ff 48
    [  129.298015] RSP: 002b:00007ffdca60dea0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e
    [  129.305581] RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f88792e3857
    [  129.312712] RDX: 0000000000000000 RSI: 00007ffdca60def0 RDI: 000000000000000c
    [  129.319846] RBP: 00007ffdca60def0 R08: 0000000000000000 R09: 0000000000000000
    [  129.326978] R10: 0000000000000001 R11: 0000000000000293 R12: 0000000000000000
    [  129.334109] R13: 0000000000000000 R14: 00007ffdca60e0a8 R15: 00007ffdca60e09c
    [  129.341249] ---[ end trace c551e8028fbaf59d ]---
    [  129.351207] net eth0: Unexpected TXQ (0) queue failure: -12
    [  129.360445] net eth0: Unexpected TXQ (0) queue failure: -12
    [  129.824428] net eth0: Unexpected TXQ (0) queue failure: -12
    
    Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
    Signed-off-by: Laurent Vivier <lvivier@redhat.com>
    Link: https://lore.kernel.org/r/20201027175914.689278-1-lvivier@redhat.com
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Cc: stable@vger.kernel.org
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aaf32febcf6c36c0acd5d7a0ba01c5bde0e7dfea
Author: Paul Cercueil <paul@crapouillou.net>
Date:   Sun Oct 4 16:03:07 2020 +0200

    dmaengine: dma-jz4780: Fix race in jz4780_dma_tx_status
    
    commit baf6fd97b16ea8f981b8a8b04039596f32fc2972 upstream.
    
    The jz4780_dma_tx_status() function would check if a channel's cookie
    state was set to 'completed', and if not, it would enter the critical
    section. However, in that time frame, the jz4780_dma_chan_irq() function
    was able to set the cookie to 'completed', and clear the jzchan->vchan
    pointer, which was deferenced in the critical section of the first
    function.
    
    Fix this race by checking the channel's cookie state after entering the
    critical function and not before.
    
    Fixes: d894fc6046fe ("dmaengine: jz4780: add driver for the Ingenic JZ4780 DMA controller")
    Cc: stable@vger.kernel.org # v4.0
    Signed-off-by: Paul Cercueil <paul@crapouillou.net>
    Reported-by: Artur Rojek <contact@artur-rojek.eu>
    Tested-by: Artur Rojek <contact@artur-rojek.eu>
    Link: https://lore.kernel.org/r/20201004140307.885556-1-paul@crapouillou.net
    Signed-off-by: Vinod Koul <vkoul@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d4a5c29a9bef13c2003d0d200f27d04625ef1d22
Author: Jan Kara <jack@suse.cz>
Date:   Tue Sep 22 12:20:14 2020 +0200

    udf: Fix memory leak when mounting
    
    commit a7be300de800e755714c71103ae4a0d205e41e99 upstream.
    
    udf_process_sequence() allocates temporary array for processing
    partition descriptors on volume which it fails to free. Free the array
    when it is not needed anymore.
    
    Fixes: 7b78fd02fb19 ("udf: Fix handling of Partition Descriptors")
    CC: stable@vger.kernel.org
    Reported-by: syzbot+128f4dd6e796c98b3760@syzkaller.appspotmail.com
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8a2bb94635ae7a2cc5b9366914e429bbeac0830b
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Mon Aug 31 07:58:19 2020 +0000

    powerpc: Fix random segfault when freeing hugetlb range
    
    commit 542db12a9c42d1ce70c45091765e02f74c129f43 upstream.
    
    The following random segfault is observed from time to time with
    map_hugetlb selftest:
    
    root@localhost:~# ./map_hugetlb 1 19
    524288 kB hugepages
    Mapping 1 Mbytes
    Segmentation fault
    
    [   31.219972] map_hugetlb[365]: segfault (11) at 117 nip 77974f8c lr 779a6834 code 1 in ld-2.23.so[77966000+21000]
    [   31.220192] map_hugetlb[365]: code: 9421ffc0 480318d1 93410028 90010044 9361002c 93810030 93a10034 93c10038
    [   31.220307] map_hugetlb[365]: code: 93e1003c 93210024 8123007c 81430038 <80e90004> 814a0004 7f443a14 813a0004
    [   31.221911] BUG: Bad rss-counter state mm:(ptrval) type:MM_FILEPAGES val:33
    [   31.229362] BUG: Bad rss-counter state mm:(ptrval) type:MM_ANONPAGES val:5
    
    This fault is due to hugetlb_free_pgd_range() freeing page tables
    that are also used by regular pages.
    
    As explain in the comment at the beginning of
    hugetlb_free_pgd_range(), the verification done in free_pgd_range()
    on floor and ceiling is not done here, which means
    hugetlb_free_pte_range() can free outside the expected range.
    
    As the verification cannot be done in hugetlb_free_pgd_range(), it
    must be done in hugetlb_free_pte_range().
    
    Fixes: b250c8c08c79 ("powerpc/8xx: Manage 512k huge pages as standard pages.")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/f0cb2a5477cd87d1eaadb128042e20aeb2bc2859.1598860677.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9fbcfd89025628b02f4209bedeeef93e09687666
Author: Michael S. Tsirkin <mst@redhat.com>
Date:   Thu Oct 29 17:53:36 2020 -0400

    Revert "vhost-vdpa: fix page pinning leakage in error path"
    
    commit 5e1a3149eec8675c2767cc465903f5e4829de5b0 upstream.
    
    This reverts commit 7ed9e3d97c32d969caded2dfb6e67c1a2cc5a0b1.
    
    The patch creates a DoS risk since it can result in a high order memory
    allocation.
    
    Fixes: 7ed9e3d97c32d ("vhost-vdpa: fix page pinning leakage in error path")
    Cc: stable@vger.kernel.org
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit de3d7ff3ec852e455c5924f4c8b1f826496d6705
Author: Gaurav Kohli <gkohli@codeaurora.org>
Date:   Tue Oct 6 15:03:53 2020 +0530

    tracing: Fix race in trace_open and buffer resize call
    
    commit bbeb97464eefc65f506084fd9f18f21653e01137 upstream.
    
    Below race can come, if trace_open and resize of
    cpu buffer is running parallely on different cpus
    CPUX                                CPUY
                                        ring_buffer_resize
                                        atomic_read(&buffer->resize_disabled)
    tracing_open
    tracing_reset_online_cpus
    ring_buffer_reset_cpu
    rb_reset_cpu
                                        rb_update_pages
                                        remove/insert pages
    resetting pointer
    
    This race can cause data abort or some times infinte loop in
    rb_remove_pages and rb_insert_pages while checking pages
    for sanity.
    
    Take buffer lock to fix this.
    
    Link: https://lkml.kernel.org/r/1601976833-24377-1-git-send-email-gkohli@codeaurora.org
    
    Cc: stable@vger.kernel.org
    Fixes: b23d7a5f4a07a ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU")
    Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3ae49be1c207a0b9f9f599436da1f407d05cc242
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Fri Oct 23 04:34:29 2020 +0300

    tty: serial: fsl_lpuart: LS1021A has a FIFO size of 16 words, like LS1028A
    
    commit c97f2a6fb3dfbfbbc88edc8ea62ef2b944e18849 upstream.
    
    Prior to the commit that this one fixes, the FIFO size was derived from
    the read-only register LPUARTx_FIFO[TXFIFOSIZE] using the following
    formula:
    
    TX FIFO size = 2 ^ (LPUARTx_FIFO[TXFIFOSIZE] - 1)
    
    The documentation for LS1021A is a mess. Under chapter 26.1.3 LS1021A
    LPUART module special consideration, it mentions TXFIFO_SZ and RXFIFO_SZ
    being equal to 4, and in the register description for LPUARTx_FIFO, it
    shows the out-of-reset value of TXFIFOSIZE and RXFIFOSIZE fields as "011",
    even though these registers read as "101" in reality.
    
    And when LPUART on LS1021A was working, the "101" value did correspond
    to "16 datawords", by applying the formula above, even though the
    documentation is wrong again (!!!!) and says that "101" means 64 datawords
    (hint: it doesn't).
    
    So the "new" formula created by commit f77ebb241ce0 has all the premises
    of being wrong for LS1021A, because it relied only on false data and no
    actual experimentation.
    
    Interestingly, in commit c2f448cff22a ("tty: serial: fsl_lpuart: add
    LS1028A support"), Michael Walle applied a workaround to this by manually
    setting the FIFO widths for LS1028A. It looks like the same values are
    used by LS1021A as well, in fact.
    
    When the driver thinks that it has a deeper FIFO than it really has,
    getty (user space) output gets truncated.
    
    Many thanks to Michael for pointing out where to look.
    
    Fixes: f77ebb241ce0 ("tty: serial: fsl_lpuart: correct the FIFO depth size")
    Suggested-by: Michael Walle <michael@walle.cc>
    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20201023013429.3551026-1-vladimir.oltean@nxp.com
    Reviewed-by:Fugang Duan <fugang.duan@nxp.com>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit feda6c6f14e31fda1f89e4950c3f7be4fc4d579b
Author: Russell King <rmk+kernel@armlinux.org.uk>
Date:   Sun Oct 18 09:42:04 2020 +0100

    tty: serial: 21285: fix lockup on open
    
    commit 82776f6c75a90e1d2103e689b84a689de8f1aa02 upstream.
    
    Commit 293f89959483 ("tty: serial: 21285: stop using the unused[]
    variable from struct uart_port") introduced a bug which stops the
    transmit interrupt being disabled when there are no characters to
    transmit - disabling the transmit interrupt at the interrupt controller
    is the only way to stop an interrupt storm. If this interrupt is not
    disabled when there are no transmit characters, we end up with an
    interrupt storm which prevents the machine making forward progress.
    
    Fixes: 293f89959483 ("tty: serial: 21285: stop using the unused[] variable from struct uart_port")
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Cc: stable <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/E1kU4GS-0006lE-OO@rmk-PC.armlinux.org.uk
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 73258585034892190829062d72bd0400dd56118a
Author: Borislav Petkov <bp@suse.de>
Date:   Wed Oct 7 18:55:35 2020 +0200

    x86/mce: Allow for copy_mc_fragile symbol checksum to be generated
    
    commit b3149ffcdb31a8eb854cc442a389ae0b539bf28a upstream.
    
    Add asm/mce.h to asm/asm-prototypes.h so that that asm symbol's checksum
    can be generated in order to support CONFIG_MODVERSIONS with it and fix:
    
      WARNING: modpost: EXPORT symbol "copy_mc_fragile" [vmlinux] version \
              generation failed, symbol will not be versioned.
    
    For reference see:
    
      4efca4ed05cb ("kbuild: modversions for EXPORT_SYMBOL() for asm")
      334bb7738764 ("x86/kbuild: enable modversions for symbols exported from asm")
    
    Fixes: ec6347bb4339 ("x86, powerpc: Rename memcpy_mcsafe() to copy_mc_to_{user, kernel}()")
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lkml.kernel.org/r/20201007111447.GA23257@zn.tnic
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bcc91e0cf6cae0a0bf414162493207f61d3e82f1
Author: Jason Gerecke <jason.gerecke@wacom.com>
Date:   Wed Sep 23 13:14:56 2020 -0700

    HID: wacom: Avoid entering wacom_wac_pen_report for pad / battery
    
    commit d9216d753b2b1406b801243b12aaf00a5ce5b861 upstream.
    
    It has recently been reported that the "heartbeat" report from devices
    like the 2nd-gen Intuos Pro (PTH-460, PTH-660, PTH-860) or the 2nd-gen
    Bluetooth-enabled Intuos tablets (CTL-4100WL, CTL-6100WL) can cause the
    driver to send a spurious BTN_TOUCH=0 once per second in the middle of
    drawing. This can result in broken lines while drawing on Chrome OS.
    
    The source of the issue has been traced back to a change which modified
    the driver to only call `wacom_wac_pad_report()` once per report instead
    of once per collection. As part of this change, pad-handling code was
    removed from `wacom_wac_collection()` under the assumption that the
    `WACOM_PEN_FIELD` and `WACOM_TOUCH_FIELD` checks would not be satisfied
    when a pad or battery collection was being processed.
    
    To be clear, the macros `WACOM_PAD_FIELD` and `WACOM_PEN_FIELD` do not
    currently check exclusive conditions. In fact, most "pad" fields will
    also appear to be "pen" fields simply due to their presence inside of
    a Digitizer application collection. Because of this, the removal of
    the check from `wacom_wac_collection()` just causes pad / battery
    collections to instead trigger a call to `wacom_wac_pen_report()`
    instead. The pen report function in turn resets the tip switch state
    just prior to exiting, resulting in the observed BTN_TOUCH=0 symptom.
    
    To correct this, we restore a version of the `WACOM_PAD_FIELD` check
    in `wacom_wac_collection()` and return early. This effectively prevents
    pad / battery collections from being reported until the very end of the
    report as originally intended.
    
    Fixes: d4b8efeb46d9 ("HID: wacom: generic: Correct pad syncing")
    Cc: stable@vger.kernel.org # v4.17+
    Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
    Reviewed-by: Ping Cheng <ping.cheng@wacom.com>
    Tested-by: Ping Cheng <ping.cheng@wacom.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a9f0d28c0dd1a55c00e106e66b7ed4d984a71a0a
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Mon Oct 26 06:54:19 2020 +0100

    vt_ioctl: fix GIO_UNIMAP regression
    
    commit d54654790302ccaa72589380dce060d376ef8716 upstream.
    
    In commit 5ba127878722, we shuffled with the check of 'perm'. But my
    brain somehow inverted the condition in 'do_unimap_ioctl' (I thought
    it is ||, not &&), so GIO_UNIMAP stopped working completely.
    
    Move the 'perm' checks back to do_unimap_ioctl and do them right again.
    In fact, this reverts this part of code to the pre-5ba127878722 state.
    Except 'perm' is now a bool.
    
    Fixes: 5ba127878722 ("vt_ioctl: move perm checks level up")
    Cc: stable@vger.kernel.org
    Reported-by: Fabian Vogt <fvogt@suse.com>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20201026055419.30518-1-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c76b008823e5278046d805a652136e01d16ec138
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Mon Oct 19 10:55:17 2020 +0200

    vt: keyboard, extend func_buf_lock to readers
    
    commit 82e61c3909db51d91b9d3e2071557b6435018b80 upstream.
    
    Both read-side users of func_table/func_buf need locking. Without that,
    one can easily confuse the code by repeatedly setting altering strings
    like:
    while (1)
            for (a = 0; a < 2; a++) {
                    struct kbsentry kbs = {};
                    strcpy((char *)kbs.kb_string, a ? ".\n" : "88888\n");
                    ioctl(fd, KDSKBSENT, &kbs);
            }
    
    When that program runs, one can get unexpected output by holding F1
    (note the unxpected period on the last line):
    .
    88888
    .8888
    
    So protect all accesses to 'func_table' (and func_buf) by preexisting
    'func_buf_lock'.
    
    It is easy in 'k_fn' handler as 'puts_queue' is expected not to sleep.
    On the other hand, KDGKBSENT needs a local (atomic) copy of the string
    because copy_to_user can sleep. Use already allocated, but unused
    'kbs->kb_string' for that purpose.
    
    Note that the program above needs at least CAP_SYS_TTY_CONFIG.
    
    This depends on the previous patch and on the func_buf_lock lock added
    in commit 46ca3f735f34 (tty/vt: fix write/write race in ioctl(KDSKBSENT)
    handler) in 5.2.
    
    Likely fixes CVE-2020-25656.
    
    Cc: <stable@vger.kernel.org>
    Reported-by: Minh Yuan <yuanmingbuaa@gmail.com>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20201019085517.10176-2-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0d4ae5a219cc3f9afaf1b40ab51d47e2b94e904f
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Mon Oct 19 10:55:16 2020 +0200

    vt: keyboard, simplify vt_kdgkbsent
    
    commit 6ca03f90527e499dd5e32d6522909e2ad390896b upstream.
    
    Use 'strlen' of the string, add one for NUL terminator and simply do
    'copy_to_user' instead of the explicit 'for' loop. This makes the
    KDGKBSENT case more compact.
    
    The only thing we need to take care about is NULL 'func_table[i]'. Use
    an empty string in that case.
    
    The original check for overflow could never trigger as the func_buf
    strings are always shorter or equal to 'struct kbsentry's.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Link: https://lore.kernel.org/r/20201019085517.10176-1-jslaby@suse.cz
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b5b3a8bd8ac52462965133ed8279594753b4ec3f
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Oct 19 11:15:23 2020 +0100

    drm/i915: Force VT'd workarounds when running as a guest OS
    
    commit 8195400f7ea95399f721ad21f4d663a62c65036f upstream.
    
    If i915.ko is being used as a passthrough device, it does not know if
    the host is using intel_iommu. Mixing the iommu and gfx causes a few
    issues (such as scanout overfetch) which we need to workaround inside
    the driver, so if we detect we are running under a hypervisor, also
    assume the device access is being virtualised.
    
    Reported-by: Stefan Fritsch <sf@sfritsch.de>
    Suggested-by: Stefan Fritsch <sf@sfritsch.de>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
    Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Cc: Stefan Fritsch <sf@sfritsch.de>
    Cc: stable@vger.kernel.org
    Tested-by: Stefan Fritsch <sf@sfritsch.de>
    Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20201019101523.4145-1-chris@chris-wilson.co.uk
    (cherry picked from commit f566fdcd6cc49a9d5b5d782f56e3e7cb243f01b8)
    Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f75840d33795f1f85f0a3aff10f22f271dd232b7
Author: Bastien Nocera <hadess@hadess.net>
Date:   Thu Oct 22 09:55:21 2020 -0400

    USB: apple-mfi-fastcharge: don't probe unhandled devices
    
    commit 0cb686692fd200db12dcfb8231e793c1c98aec41 upstream.
    
    From: Bastien Nocera <hadess@hadess.net>
    
    Contrary to the comment above the id table, we didn't implement a match
    function. This meant that every single Apple device that was already
    plugged in to the computer would have its device driver reprobed
    when the apple-mfi-fastcharge driver was loaded, eg. the SD card reader
    could be reprobed when the apple-mfi-fastcharge after pivoting root
    during boot up and the module became available.
    
    Make sure that the driver probe isn't being run for unsupported
    devices by adding a match function that checks the product ID, in
    addition to the id_table checking the vendor ID.
    
    Link: https://bugzilla.redhat.com/show_bug.cgi?id=1878347
    Link: https://lore.kernel.org/linux-usb/CAE3RAxt0WhBEz8zkHrVO5RiyEOasayy1QUAjsv-pB0fAbY1GSw@mail.gmail.com/
    Fixes: 249fa8217b84 ("USB: Add driver to control USB fast charge for iOS devices")
    Cc: <stable@vger.kernel.org> # 5.8
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Alan Stern <stern@rowland.harvard.edu>
    [m.v.b: Add Link and Reported-by tags to the commit message]
    Reported-by: Pany <pany@fedoraproject.org>
    Tested-by: Pan (Pany) YUAN <pany@fedoraproject.org>
    Tested-by: Bastien Nocera <hadess@hadess.net>
    Signed-off-by: Bastien Nocera <hadess@hadess.net>
    Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
    Link: https://lore.kernel.org/r/20201022135521.375211-3-m.v.b@runbox.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 347e6870d9b05624bbaf558f951ca78759d25780
Author: Bastien Nocera <hadess@hadess.net>
Date:   Thu Oct 22 09:55:20 2020 -0400

    usbcore: Check both id_table and match() when both available
    
    commit 0942d59b0af46511d59dbf5bd69ec4a64d1a854c upstream.
    
    From: Bastien Nocera <hadess@hadess.net>
    
    When a USB device driver has both an id_table and a match() function, make
    sure to check both to find a match, first matching the id_table, then
    checking the match() function.
    
    This makes it possible to have module autoloading done through the
    id_table when devices are plugged in, before checking for further
    device eligibility in the match() function.
    
    Cc: <stable@vger.kernel.org> # 5.8
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Alan Stern <stern@rowland.harvard.edu>
    Co-developed-by: M. Vefa Bicakci <m.v.b@runbox.com>
    Tested-by: Bastien Nocera <hadess@hadess.net>
    Signed-off-by: Bastien Nocera <hadess@hadess.net>
    Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
    Tested-by: Pan (Pany) YUAN <pany@fedoraproject.org>
    Link: https://lore.kernel.org/r/20201022135521.375211-2-m.v.b@runbox.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c5f53cd315f81ef49003e95f312f870c5d0b0509
Author: Ran Wang <ran.wang_1@nxp.com>
Date:   Sat Oct 10 14:03:08 2020 +0800

    usb: host: fsl-mph-dr-of: check return of dma_set_mask()
    
    commit 3cd54a618834430a26a648d880dd83d740f2ae30 upstream.
    
    fsl_usb2_device_register() should stop init if dma_set_mask() return
    error.
    
    Fixes: cae058610465 ("drivers/usb/host: fsl: Set DMA_MASK of usb platform device")
    Reviewed-by: Peter Chen <peter.chen@nxp.com>
    Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
    Link: https://lore.kernel.org/r/20201010060308.33693-1-ran.wang_1@nxp.com
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 05b0086c69295a4a8cb2fa084535213165d5e66c
Author: Li Jun <jun.li@nxp.com>
Date:   Mon Oct 12 19:03:12 2020 +0800

    usb: typec: tcpm: reset hard_reset_count for any disconnect
    
    commit 2d9c6442a9c81f4f8dee678d0b3c183173ab1e2d upstream.
    
    Current tcpm_detach() only reset hard_reset_count if port->attached
    is true, this may cause this counter clear is missed if the CC
    disconnect event is generated after tcpm_port_reset() is done
    by other events, e.g. VBUS off comes first before CC disconect for
    a power sink, in that case the first tcpm_detach() will only clear
    port->attached flag but leave hard_reset_count there because
    tcpm_port_is_disconnected() is still false, then later tcpm_detach()
    by CC disconnect will directly return due to port->attached is cleared,
    finally this will result tcpm will not try hard reset or error recovery
    for later attach.
    
    ChiYuan reported this issue on his platform with below tcpm trace:
    After power sink session setup after hard reset 2 times, detach
    from the power source and then attach:
    [ 4848.046358] VBUS off
    [ 4848.046384] state change SNK_READY -> SNK_UNATTACHED
    [ 4848.050908] Setting voltage/current limit 0 mV 0 mA
    [ 4848.050936] polarity 0
    [ 4848.052593] Requesting mux state 0, usb-role 0, orientation 0
    [ 4848.053222] Start toggling
    [ 4848.086500] state change SNK_UNATTACHED -> TOGGLING
    [ 4848.089983] CC1: 0 -> 0, CC2: 3 -> 3 [state TOGGLING, polarity 0, connected]
    [ 4848.089993] state change TOGGLING -> SNK_ATTACH_WAIT
    [ 4848.090031] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @200 ms
    [ 4848.141162] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_ATTACH_WAIT, polarity 0, disconnected]
    [ 4848.141170] state change SNK_ATTACH_WAIT -> SNK_ATTACH_WAIT
    [ 4848.141184] pending state change SNK_ATTACH_WAIT -> SNK_UNATTACHED @20 ms
    [ 4848.163156] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [delayed 20 ms]
    [ 4848.163162] Start toggling
    [ 4848.216918] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected]
    [ 4848.216954] state change TOGGLING -> SNK_ATTACH_WAIT
    [ 4848.217080] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @200 ms
    [ 4848.231771] CC1: 0 -> 0, CC2: 3 -> 0 [state SNK_ATTACH_WAIT, polarity 0, disconnected]
    [ 4848.231800] state change SNK_ATTACH_WAIT -> SNK_ATTACH_WAIT
    [ 4848.231857] pending state change SNK_ATTACH_WAIT -> SNK_UNATTACHED @20 ms
    [ 4848.256022] state change SNK_ATTACH_WAIT -> SNK_UNATTACHED [delayed20 ms]
    [ 4848.256049] Start toggling
    [ 4848.871148] VBUS on
    [ 4848.885324] CC1: 0 -> 0, CC2: 0 -> 3 [state TOGGLING, polarity 0, connected]
    [ 4848.885372] state change TOGGLING -> SNK_ATTACH_WAIT
    [ 4848.885548] pending state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED @200 ms
    [ 4849.088240] state change SNK_ATTACH_WAIT -> SNK_DEBOUNCED [delayed200 ms]
    [ 4849.088284] state change SNK_DEBOUNCED -> SNK_ATTACHED
    [ 4849.088291] polarity 1
    [ 4849.088769] Requesting mux state 1, usb-role 2, orientation 2
    [ 4849.088895] state change SNK_ATTACHED -> SNK_STARTUP
    [ 4849.088907] state change SNK_STARTUP -> SNK_DISCOVERY
    [ 4849.088915] Setting voltage/current limit 5000 mV 0 mA
    [ 4849.088927] vbus=0 charge:=1
    [ 4849.090505] state change SNK_DISCOVERY -> SNK_WAIT_CAPABILITIES
    [ 4849.090828] pending state change SNK_WAIT_CAPABILITIES -> SNK_READY @240 ms
    [ 4849.335878] state change SNK_WAIT_CAPABILITIES -> SNK_READY [delayed240 ms]
    
    this patch fix this issue by clear hard_reset_count at any cases
    of cc disconnect, í.e. don't check port->attached flag.
    
    Fixes: 4b4e02c83167 ("typec: tcpm: Move out of staging")
    Cc: stable@vger.kernel.org
    Reported-and-tested-by: ChiYuan Huang <cy_huang@richtek.com>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Signed-off-by: Li Jun <jun.li@nxp.com>
    Link: https://lore.kernel.org/r/1602500592-3817-1-git-send-email-jun.li@nxp.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 88a559432e1f3f909941f0a3ec857465db24a784
Author: Jerome Brunet <jbrunet@baylibre.com>
Date:   Mon Oct 19 19:07:02 2020 +0200

    usb: cdc-acm: fix cooldown mechanism
    
    commit 38203b8385bf6283537162bde7d499f830964711 upstream.
    
    Commit a4e7279cd1d1 ("cdc-acm: introduce a cool down") is causing
    regression if there is some USB error, such as -EPROTO.
    
    This has been reported on some samples of the Odroid-N2 using the Combee II
    Zibgee USB dongle.
    
    > struct acm *acm = container_of(work, struct acm, work)
    
    is incorrect in case of a delayed work and causes warnings, usually from
    the workqueue:
    
    > WARNING: CPU: 0 PID: 0 at kernel/workqueue.c:1474 __queue_work+0x480/0x528.
    
    When this happens, USB eventually stops working completely after a while.
    Also the ACM_ERROR_DELAY bit is never set, so the cooldown mechanism
    previously introduced cannot be triggered and acm_submit_read_urb() is
    never called.
    
    This changes makes the cdc-acm driver use a single delayed work, fixing the
    pointer arithmetic in acm_softint() and set the ACM_ERROR_DELAY when the
    cooldown mechanism appear to be needed.
    
    Fixes: a4e7279cd1d1 ("cdc-acm: introduce a cool down")
    Cc: Oliver Neukum <oneukum@suse.com>
    Reported-by: Pascal Vizeli <pascal.vizeli@nabucasa.com>
    Acked-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
    Link: https://lore.kernel.org/r/20201019170702.150534-1-jbrunet@baylibre.com
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c4c67e1218fb774fdb09c0a010751dfb5d638493
Author: Pawel Laszczak <pawell@cadence.com>
Date:   Thu Oct 22 08:55:05 2020 +0800

    usb: cdns3: Fix on-chip memory overflow issue
    
    commit 52d3967704aea6cb316d419a33a5e1d56d33a3c1 upstream.
    
    Patch fixes issue caused setting On-chip memory overflow bit in usb_sts
    register. The issue occurred because EP_CFG register was set twice
    before USB_STS.CFGSTS was set. Every write operation on EP_CFG.BUFFERING
    causes that controller increases internal counter holding the number
    of reserved on-chip buffers. First time this register was updated in
    function cdns3_ep_config before delegating SET_CONFIGURATION request
    to class driver and again it was updated when class wanted to enable
    endpoint.  This patch fixes this issue by configuring endpoints
    enabled by class driver in cdns3_gadget_ep_enable and others just
    before status stage.
    
    Cc: stable@vger.kernel.org#v5.8+
    Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
    Reported-and-tested-by: Peter Chen <peter.chen@nxp.com>
    Signed-off-by: Pawel Laszczak <pawell@cadence.com>
    Signed-off-by: Peter Chen <peter.chen@nxp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9b69b26a3414e38d413c01b3cceb3ec8fc7b2b51
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Wed Sep 2 18:43:04 2020 -0700

    usb: dwc3: gadget: END_TRANSFER before CLEAR_STALL command
    
    commit d97c78a1908e59a1fdbcbece87cd0440b5d7a1f2 upstream.
    
    According the programming guide (for all DWC3 IPs), when the driver
    handles ClearFeature(halt) request, it should issue CLEAR_STALL command
    _after_ the END_TRANSFER command completes. The END_TRANSFER command may
    take some time to complete. So, delay the ClearFeature(halt) request
    control status stage and wait for END_TRANSFER command completion
    interrupt. Only after END_TRANSFER command completes that the driver
    may issue CLEAR_STALL command.
    
    Cc: stable@vger.kernel.org
    Fixes: cb11ea56f37a ("usb: dwc3: gadget: Properly handle ClearFeature(halt)")
    Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0991df61eaa47b7aca2ef0b1ed43d15567be1124
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Wed Sep 2 18:42:58 2020 -0700

    usb: dwc3: gadget: Resume pending requests after CLEAR_STALL
    
    commit c503672abe1348f10f5a54a662336358c6e1a297 upstream.
    
    The function driver may queue new requests right after halting the
    endpoint (i.e. queue new requests while the endpoint is stalled).
    There's no restriction preventing it from doing so. However, dwc3
    currently drops those requests after CLEAR_STALL. The driver should only
    drop started requests. Keep the pending requests in the pending list to
    resume and process them after the host issues ClearFeature(Halt) to the
    endpoint.
    
    Cc: stable@vger.kernel.org
    Fixes: cb11ea56f37a ("usb: dwc3: gadget: Properly handle ClearFeature(halt)")
    Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 47d52604b8e87bc05ca30933bd7c8b3adcccc2da
Author: Li Jun <jun.li@nxp.com>
Date:   Tue Jul 28 20:42:40 2020 +0800

    usb: dwc3: core: don't trigger runtime pm when remove driver
    
    commit 266d0493900ac5d6a21cdbe6b1624ed2da94d47a upstream.
    
    No need to trigger runtime pm in driver removal, otherwise if user
    disable auto suspend via sys file, runtime suspend may be entered,
    which will call dwc3_core_exit() again and there will be clock disable
    not balance warning:
    
    [ 2026.820154] xhci-hcd xhci-hcd.0.auto: remove, state 4
    [ 2026.825268] usb usb2: USB disconnect, device number 1
    [ 2026.831017] xhci-hcd xhci-hcd.0.auto: USB bus 2 deregistered
    [ 2026.836806] xhci-hcd xhci-hcd.0.auto: remove, state 4
    [ 2026.842029] usb usb1: USB disconnect, device number 1
    [ 2026.848029] xhci-hcd xhci-hcd.0.auto: USB bus 1 deregistered
    [ 2026.865889] ------------[ cut here ]------------
    [ 2026.870506] usb2_ctrl_root_clk already disabled
    [ 2026.875082] WARNING: CPU: 0 PID: 731 at drivers/clk/clk.c:958
    clk_core_disable+0xa0/0xa8
    [ 2026.883170] Modules linked in: dwc3(-) phy_fsl_imx8mq_usb [last
    unloaded: dwc3]
    [ 2026.890488] CPU: 0 PID: 731 Comm: rmmod Not tainted
    5.8.0-rc7-00280-g9d08cca-dirty #245
    [ 2026.898489] Hardware name: NXP i.MX8MQ EVK (DT)
    [ 2026.903020] pstate: 20000085 (nzCv daIf -PAN -UAO BTYPE=--)
    [ 2026.908594] pc : clk_core_disable+0xa0/0xa8
    [ 2026.912777] lr : clk_core_disable+0xa0/0xa8
    [ 2026.916958] sp : ffff8000121b39a0
    [ 2026.920271] x29: ffff8000121b39a0 x28: ffff0000b11f3700
    [ 2026.925583] x27: 0000000000000000 x26: ffff0000b539c700
    [ 2026.930895] x25: 000001d7e44e1232 x24: ffff0000b76fa800
    [ 2026.936208] x23: ffff0000b76fa6f8 x22: ffff800008d01040
    [ 2026.941520] x21: ffff0000b539ce00 x20: ffff0000b7105000
    [ 2026.946832] x19: ffff0000b7105000 x18: 0000000000000010
    [ 2026.952144] x17: 0000000000000001 x16: 0000000000000000
    [ 2026.957456] x15: ffff0000b11f3b70 x14: ffffffffffffffff
    [ 2026.962768] x13: ffff8000921b36f7 x12: ffff8000121b36ff
    [ 2026.968080] x11: ffff8000119e1000 x10: ffff800011bf26d0
    [ 2026.973392] x9 : 0000000000000000 x8 : ffff800011bf3000
    [ 2026.978704] x7 : ffff800010695d68 x6 : 0000000000000252
    [ 2026.984016] x5 : ffff0000bb9881f0 x4 : 0000000000000000
    [ 2026.989327] x3 : 0000000000000027 x2 : 0000000000000023
    [ 2026.994639] x1 : ac2fa471aa7cab00 x0 : 0000000000000000
    [ 2026.999951] Call trace:
    [ 2027.002401]  clk_core_disable+0xa0/0xa8
    [ 2027.006238]  clk_core_disable_lock+0x20/0x38
    [ 2027.010508]  clk_disable+0x1c/0x28
    [ 2027.013911]  clk_bulk_disable+0x34/0x50
    [ 2027.017758]  dwc3_core_exit+0xec/0x110 [dwc3]
    [ 2027.022122]  dwc3_suspend_common+0x84/0x188 [dwc3]
    [ 2027.026919]  dwc3_runtime_suspend+0x74/0x9c [dwc3]
    [ 2027.031712]  pm_generic_runtime_suspend+0x28/0x40
    [ 2027.036419]  genpd_runtime_suspend+0xa0/0x258
    [ 2027.040777]  __rpm_callback+0x88/0x140
    [ 2027.044526]  rpm_callback+0x20/0x80
    [ 2027.048015]  rpm_suspend+0xd0/0x418
    [ 2027.051503]  __pm_runtime_suspend+0x58/0xa0
    [ 2027.055693]  dwc3_runtime_idle+0x7c/0x90 [dwc3]
    [ 2027.060224]  __rpm_callback+0x88/0x140
    [ 2027.063973]  rpm_idle+0x78/0x150
    [ 2027.067201]  __pm_runtime_idle+0x58/0xa0
    [ 2027.071130]  dwc3_remove+0x64/0xc0 [dwc3]
    [ 2027.075140]  platform_drv_remove+0x28/0x48
    [ 2027.079239]  device_release_driver_internal+0xf4/0x1c0
    [ 2027.084377]  driver_detach+0x4c/0xd8
    [ 2027.087954]  bus_remove_driver+0x54/0xa8
    [ 2027.091877]  driver_unregister+0x2c/0x58
    [ 2027.095799]  platform_driver_unregister+0x10/0x18
    [ 2027.100509]  dwc3_driver_exit+0x14/0x1408 [dwc3]
    [ 2027.105129]  __arm64_sys_delete_module+0x178/0x218
    [ 2027.109922]  el0_svc_common.constprop.0+0x68/0x160
    [ 2027.114714]  do_el0_svc+0x20/0x80
    [ 2027.118031]  el0_sync_handler+0x88/0x190
    [ 2027.121953]  el0_sync+0x140/0x180
    [ 2027.125267] ---[ end trace 027f4f8189958f1f ]---
    [ 2027.129976] ------------[ cut here ]------------
    
    Fixes: fc8bb91bc83e ("usb: dwc3: implement runtime PM")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Li Jun <jun.li@nxp.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19544d59e0c3782270aa53d67499e1cf1bf23dbe
Author: Li Jun <jun.li@nxp.com>
Date:   Tue Jul 28 20:42:41 2020 +0800

    usb: dwc3: core: add phy cleanup for probe error handling
    
    commit 03c1fd622f72c7624c81b64fdba4a567ae5ee9cb upstream.
    
    Add the phy cleanup if dwc3 mode init fail, which is the missing part of
    de-init for dwc3 core init.
    
    Fixes: c499ff71ff2a ("usb: dwc3: core: re-factor init and exit paths")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Li Jun <jun.li@nxp.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d548d3914602a74875a98d731e4c87b54273a2fe
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Thu Sep 24 01:21:24 2020 -0700

    usb: dwc3: gadget: Reclaim extra TRBs after request completion
    
    commit 690e5c2dc29f8891fcfd30da67e0d5837c2c9df5 upstream.
    
    An SG request may be partially completed (due to no available TRBs).
    Don't reclaim extra TRBs and clear the needs_extra_trb flag until the
    request is fully completed. Otherwise, the driver will reclaim the wrong
    TRB.
    
    Cc: stable@vger.kernel.org
    Fixes: 1f512119a08c ("usb: dwc3: gadget: add remaining sg entries to ring")
    Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b8af1c91564798863b1f3d8f5fbf25966359c540
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Thu Sep 24 01:21:18 2020 -0700

    usb: dwc3: gadget: Check MPS of the request length
    
    commit ca3df3468eec87f6374662f7de425bc44c3810c1 upstream.
    
    When preparing for SG, not all the entries are prepared at once. When
    resume, don't use the remaining request length to calculate for MPS
    alignment. Use the entire request->length to do that.
    
    Cc: stable@vger.kernel.org
    Fixes: 5d187c0454ef ("usb: dwc3: gadget: Don't setup more than requested")
    Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8dca292e9aaa2275bbe261da95dcb1e52132e956
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Thu Sep 24 01:21:43 2020 -0700

    usb: dwc3: ep0: Fix ZLP for OUT ep0 requests
    
    commit 66706077dc89c66a4777a4c6298273816afb848c upstream.
    
    The current ZLP handling for ep0 requests is only for control IN
    requests. For OUT direction, DWC3 needs to check and setup for MPS
    alignment.
    
    Usually, control OUT requests can indicate its transfer size via the
    wLength field of the control message. So usb_request->zero is usually
    not needed for OUT direction. To handle ZLP OUT for control endpoint,
    make sure the TRB is MPS size.
    
    Cc: stable@vger.kernel.org
    Fixes: c7fcdeb2627c ("usb: dwc3: ep0: simplify EP0 state machine")
    Fixes: d6e5a549cc4d ("usb: dwc3: simplify ZLP handling")
    Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6865af367650a20f39723893064588180528721
Author: Raymond Tan <raymond.tan@intel.com>
Date:   Fri Aug 21 16:11:01 2020 +0300

    usb: dwc3: pci: Allow Elkhart Lake to utilize DSM method for PM functionality
    
    commit a609ce2a13360d639b384b6ca783b38c1247f2db upstream.
    
    Similar to some other IA platforms, Elkhart Lake too depends on the
    PMU register write to request transition of Dx power state.
    
    Thus, we add the PCI_DEVICE_ID_INTEL_EHLLP to the list of devices that
    shall execute the ACPI _DSM method during D0/D3 sequence.
    
    [heikki.krogerus@linux.intel.com: included Fixes tag]
    
    Fixes: dbb0569de852 ("usb: dwc3: pci: Add Support for Intel Elkhart Lake Devices")
    Cc: stable@vger.kernel.org
    Signed-off-by: Raymond Tan <raymond.tan@intel.com>
    Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d01c3b24199d2086e46df04278a73aa037239cc3
Author: Sandeep Singh <sandeep.singh@amd.com>
Date:   Wed Oct 28 22:31:23 2020 +0200

    usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
    
    commit 2a632815683d2d34df52b701a36fe5ac6654e719 upstream.
    
    On some platform of AMD, S3 fails with HCE and SRE errors. To fix this,
    need to disable a bit which is enable in sparse controller.
    
    Cc: stable@vger.kernel.org #v4.19+
    Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
    Signed-off-by: Sandeep Singh <sandeep.singh@amd.com>
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20201028203124.375344-3-mathias.nyman@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5fc99e04090a7feeda2052fa3d80e726d7da366f
Author: Josef Bacik <josef@toxicpanda.com>
Date:   Wed Oct 14 17:00:51 2020 -0400

    btrfs: drop the path before adding block group sysfs files
    
    commit 7837fa88704a66257404bb14144c9e4ab631a28a upstream.
    
    Dave reported a problem with my rwsem conversion patch where we got the
    following lockdep splat:
    
      ======================================================
      WARNING: possible circular locking dependency detected
      5.9.0-default+ #1297 Not tainted
      ------------------------------------------------------
      kswapd0/76 is trying to acquire lock:
      ffff9d5d25df2530 (&delayed_node->mutex){+.+.}-{3:3}, at: __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
    
      but task is already holding lock:
      ffffffffa40cbba0 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x5/0x30
    
      which lock already depends on the new lock.
    
      the existing dependency chain (in reverse order) is:
    
      -> #4 (fs_reclaim){+.+.}-{0:0}:
             __lock_acquire+0x582/0xac0
             lock_acquire+0xca/0x430
             fs_reclaim_acquire.part.0+0x25/0x30
             kmem_cache_alloc+0x30/0x9c0
             alloc_inode+0x81/0x90
             iget_locked+0xcd/0x1a0
             kernfs_get_inode+0x1b/0x130
             kernfs_get_tree+0x136/0x210
             sysfs_get_tree+0x1a/0x50
             vfs_get_tree+0x1d/0xb0
             path_mount+0x70f/0xa80
             do_mount+0x75/0x90
             __x64_sys_mount+0x8e/0xd0
             do_syscall_64+0x2d/0x70
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
      -> #3 (kernfs_mutex){+.+.}-{3:3}:
             __lock_acquire+0x582/0xac0
             lock_acquire+0xca/0x430
             __mutex_lock+0xa0/0xaf0
             kernfs_add_one+0x23/0x150
             kernfs_create_dir_ns+0x58/0x80
             sysfs_create_dir_ns+0x70/0xd0
             kobject_add_internal+0xbb/0x2d0
             kobject_add+0x7a/0xd0
             btrfs_sysfs_add_block_group_type+0x141/0x1d0 [btrfs]
             btrfs_read_block_groups+0x1f1/0x8c0 [btrfs]
             open_ctree+0x981/0x1108 [btrfs]
             btrfs_mount_root.cold+0xe/0xb0 [btrfs]
             legacy_get_tree+0x2d/0x60
             vfs_get_tree+0x1d/0xb0
             fc_mount+0xe/0x40
             vfs_kern_mount.part.0+0x71/0x90
             btrfs_mount+0x13b/0x3e0 [btrfs]
             legacy_get_tree+0x2d/0x60
             vfs_get_tree+0x1d/0xb0
             path_mount+0x70f/0xa80
             do_mount+0x75/0x90
             __x64_sys_mount+0x8e/0xd0
             do_syscall_64+0x2d/0x70
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
      -> #2 (btrfs-extent-00){++++}-{3:3}:
             __lock_acquire+0x582/0xac0
             lock_acquire+0xca/0x430
             down_read_nested+0x45/0x220
             __btrfs_tree_read_lock+0x35/0x1c0 [btrfs]
             __btrfs_read_lock_root_node+0x3a/0x50 [btrfs]
             btrfs_search_slot+0x6d4/0xfd0 [btrfs]
             check_committed_ref+0x69/0x200 [btrfs]
             btrfs_cross_ref_exist+0x65/0xb0 [btrfs]
             run_delalloc_nocow+0x446/0x9b0 [btrfs]
             btrfs_run_delalloc_range+0x61/0x6a0 [btrfs]
             writepage_delalloc+0xae/0x160 [btrfs]
             __extent_writepage+0x262/0x420 [btrfs]
             extent_write_cache_pages+0x2b6/0x510 [btrfs]
             extent_writepages+0x43/0x90 [btrfs]
             do_writepages+0x40/0xe0
             __writeback_single_inode+0x62/0x610
             writeback_sb_inodes+0x20f/0x500
             wb_writeback+0xef/0x4a0
             wb_do_writeback+0x49/0x2e0
             wb_workfn+0x81/0x340
             process_one_work+0x233/0x5d0
             worker_thread+0x50/0x3b0
             kthread+0x137/0x150
             ret_from_fork+0x1f/0x30
    
      -> #1 (btrfs-fs-00){++++}-{3:3}:
             __lock_acquire+0x582/0xac0
             lock_acquire+0xca/0x430
             down_read_nested+0x45/0x220
             __btrfs_tree_read_lock+0x35/0x1c0 [btrfs]
             __btrfs_read_lock_root_node+0x3a/0x50 [btrfs]
             btrfs_search_slot+0x6d4/0xfd0 [btrfs]
             btrfs_lookup_inode+0x3a/0xc0 [btrfs]
             __btrfs_update_delayed_inode+0x93/0x2c0 [btrfs]
             __btrfs_commit_inode_delayed_items+0x7de/0x850 [btrfs]
             __btrfs_run_delayed_items+0x8e/0x140 [btrfs]
             btrfs_commit_transaction+0x367/0xbc0 [btrfs]
             btrfs_mksubvol+0x2db/0x470 [btrfs]
             btrfs_mksnapshot+0x7b/0xb0 [btrfs]
             __btrfs_ioctl_snap_create+0x16f/0x1a0 [btrfs]
             btrfs_ioctl_snap_create_v2+0xb0/0xf0 [btrfs]
             btrfs_ioctl+0xd0b/0x2690 [btrfs]
             __x64_sys_ioctl+0x6f/0xa0
             do_syscall_64+0x2d/0x70
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
      -> #0 (&delayed_node->mutex){+.+.}-{3:3}:
             check_prev_add+0x91/0xc60
             validate_chain+0xa6e/0x2a20
             __lock_acquire+0x582/0xac0
             lock_acquire+0xca/0x430
             __mutex_lock+0xa0/0xaf0
             __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
             btrfs_evict_inode+0x3cc/0x560 [btrfs]
             evict+0xd6/0x1c0
             dispose_list+0x48/0x70
             prune_icache_sb+0x54/0x80
             super_cache_scan+0x121/0x1a0
             do_shrink_slab+0x16d/0x3b0
             shrink_slab+0xb1/0x2e0
             shrink_node+0x230/0x6a0
             balance_pgdat+0x325/0x750
             kswapd+0x206/0x4d0
             kthread+0x137/0x150
             ret_from_fork+0x1f/0x30
    
      other info that might help us debug this:
    
      Chain exists of:
        &delayed_node->mutex --> kernfs_mutex --> fs_reclaim
    
       Possible unsafe locking scenario:
    
             CPU0                    CPU1
             ----                    ----
        lock(fs_reclaim);
                                     lock(kernfs_mutex);
                                     lock(fs_reclaim);
        lock(&delayed_node->mutex);
    
       *** DEADLOCK ***
    
      3 locks held by kswapd0/76:
       #0: ffffffffa40cbba0 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x5/0x30
       #1: ffffffffa40b8b58 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab+0x54/0x2e0
       #2: ffff9d5d322390e8 (&type->s_umount_key#26){++++}-{3:3}, at: trylock_super+0x16/0x50
    
      stack backtrace:
      CPU: 2 PID: 76 Comm: kswapd0 Not tainted 5.9.0-default+ #1297
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014
      Call Trace:
       dump_stack+0x77/0x97
       check_noncircular+0xff/0x110
       ? save_trace+0x50/0x470
       check_prev_add+0x91/0xc60
       validate_chain+0xa6e/0x2a20
       ? save_trace+0x50/0x470
       __lock_acquire+0x582/0xac0
       lock_acquire+0xca/0x430
       ? __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
       __mutex_lock+0xa0/0xaf0
       ? __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
       ? __lock_acquire+0x582/0xac0
       ? __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
       ? btrfs_evict_inode+0x30b/0x560 [btrfs]
       ? __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
       __btrfs_release_delayed_node.part.0+0x3f/0x320 [btrfs]
       btrfs_evict_inode+0x3cc/0x560 [btrfs]
       evict+0xd6/0x1c0
       dispose_list+0x48/0x70
       prune_icache_sb+0x54/0x80
       super_cache_scan+0x121/0x1a0
       do_shrink_slab+0x16d/0x3b0
       shrink_slab+0xb1/0x2e0
       shrink_node+0x230/0x6a0
       balance_pgdat+0x325/0x750
       kswapd+0x206/0x4d0
       ? finish_wait+0x90/0x90
       ? balance_pgdat+0x750/0x750
       kthread+0x137/0x150
       ? kthread_mod_delayed_work+0xc0/0xc0
       ret_from_fork+0x1f/0x30
    
    This happens because we are still holding the path open when we start
    adding the sysfs files for the block groups, which creates a dependency
    on fs_reclaim via the tree lock.  Fix this by dropping the path before
    we start doing anything with sysfs.
    
    Reported-by: David Sterba <dsterba@suse.com>
    CC: stable@vger.kernel.org # 5.8+
    Reviewed-by: Anand Jain <anand.jain@oracle.com>
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Josef Bacik <josef@toxicpanda.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ce34a04a8ed379794f190d5e8bdc98591149513f
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Oct 12 11:55:24 2020 +0100

    btrfs: fix readahead hang and use-after-free after removing a device
    
    commit 66d204a16c94f24ad08290a7663ab67e7fc04e82 upstream.
    
    Very sporadically I had test case btrfs/069 from fstests hanging (for
    years, it is not a recent regression), with the following traces in
    dmesg/syslog:
    
      [162301.160628] BTRFS info (device sdc): dev_replace from /dev/sdd (devid 2) to /dev/sdg started
      [162301.181196] BTRFS info (device sdc): scrub: finished on devid 4 with status: 0
      [162301.287162] BTRFS info (device sdc): dev_replace from /dev/sdd (devid 2) to /dev/sdg finished
      [162513.513792] INFO: task btrfs-transacti:1356167 blocked for more than 120 seconds.
      [162513.514318]       Not tainted 5.9.0-rc6-btrfs-next-69 #1
      [162513.514522] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [162513.514747] task:btrfs-transacti state:D stack:    0 pid:1356167 ppid:     2 flags:0x00004000
      [162513.514751] Call Trace:
      [162513.514761]  __schedule+0x5ce/0xd00
      [162513.514765]  ? _raw_spin_unlock_irqrestore+0x3c/0x60
      [162513.514771]  schedule+0x46/0xf0
      [162513.514844]  wait_current_trans+0xde/0x140 [btrfs]
      [162513.514850]  ? finish_wait+0x90/0x90
      [162513.514864]  start_transaction+0x37c/0x5f0 [btrfs]
      [162513.514879]  transaction_kthread+0xa4/0x170 [btrfs]
      [162513.514891]  ? btrfs_cleanup_transaction+0x660/0x660 [btrfs]
      [162513.514894]  kthread+0x153/0x170
      [162513.514897]  ? kthread_stop+0x2c0/0x2c0
      [162513.514902]  ret_from_fork+0x22/0x30
      [162513.514916] INFO: task fsstress:1356184 blocked for more than 120 seconds.
      [162513.515192]       Not tainted 5.9.0-rc6-btrfs-next-69 #1
      [162513.515431] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [162513.515680] task:fsstress        state:D stack:    0 pid:1356184 ppid:1356177 flags:0x00004000
      [162513.515682] Call Trace:
      [162513.515688]  __schedule+0x5ce/0xd00
      [162513.515691]  ? _raw_spin_unlock_irqrestore+0x3c/0x60
      [162513.515697]  schedule+0x46/0xf0
      [162513.515712]  wait_current_trans+0xde/0x140 [btrfs]
      [162513.515716]  ? finish_wait+0x90/0x90
      [162513.515729]  start_transaction+0x37c/0x5f0 [btrfs]
      [162513.515743]  btrfs_attach_transaction_barrier+0x1f/0x50 [btrfs]
      [162513.515753]  btrfs_sync_fs+0x61/0x1c0 [btrfs]
      [162513.515758]  ? __ia32_sys_fdatasync+0x20/0x20
      [162513.515761]  iterate_supers+0x87/0xf0
      [162513.515765]  ksys_sync+0x60/0xb0
      [162513.515768]  __do_sys_sync+0xa/0x10
      [162513.515771]  do_syscall_64+0x33/0x80
      [162513.515774]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [162513.515781] RIP: 0033:0x7f5238f50bd7
      [162513.515782] Code: Bad RIP value.
      [162513.515784] RSP: 002b:00007fff67b978e8 EFLAGS: 00000206 ORIG_RAX: 00000000000000a2
      [162513.515786] RAX: ffffffffffffffda RBX: 000055b1fad2c560 RCX: 00007f5238f50bd7
      [162513.515788] RDX: 00000000ffffffff RSI: 000000000daf0e74 RDI: 000000000000003a
      [162513.515789] RBP: 0000000000000032 R08: 000000000000000a R09: 00007f5239019be0
      [162513.515791] R10: fffffffffffff24f R11: 0000000000000206 R12: 000000000000003a
      [162513.515792] R13: 00007fff67b97950 R14: 00007fff67b97906 R15: 000055b1fad1a340
      [162513.515804] INFO: task fsstress:1356185 blocked for more than 120 seconds.
      [162513.516064]       Not tainted 5.9.0-rc6-btrfs-next-69 #1
      [162513.516329] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [162513.516617] task:fsstress        state:D stack:    0 pid:1356185 ppid:1356177 flags:0x00000000
      [162513.516620] Call Trace:
      [162513.516625]  __schedule+0x5ce/0xd00
      [162513.516628]  ? _raw_spin_unlock_irqrestore+0x3c/0x60
      [162513.516634]  schedule+0x46/0xf0
      [162513.516647]  wait_current_trans+0xde/0x140 [btrfs]
      [162513.516650]  ? finish_wait+0x90/0x90
      [162513.516662]  start_transaction+0x4d7/0x5f0 [btrfs]
      [162513.516679]  btrfs_setxattr_trans+0x3c/0x100 [btrfs]
      [162513.516686]  __vfs_setxattr+0x66/0x80
      [162513.516691]  __vfs_setxattr_noperm+0x70/0x200
      [162513.516697]  vfs_setxattr+0x6b/0x120
      [162513.516703]  setxattr+0x125/0x240
      [162513.516709]  ? lock_acquire+0xb1/0x480
      [162513.516712]  ? mnt_want_write+0x20/0x50
      [162513.516721]  ? rcu_read_lock_any_held+0x8e/0xb0
      [162513.516723]  ? preempt_count_add+0x49/0xa0
      [162513.516725]  ? __sb_start_write+0x19b/0x290
      [162513.516727]  ? preempt_count_add+0x49/0xa0
      [162513.516732]  path_setxattr+0xba/0xd0
      [162513.516739]  __x64_sys_setxattr+0x27/0x30
      [162513.516741]  do_syscall_64+0x33/0x80
      [162513.516743]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [162513.516745] RIP: 0033:0x7f5238f56d5a
      [162513.516746] Code: Bad RIP value.
      [162513.516748] RSP: 002b:00007fff67b97868 EFLAGS: 00000202 ORIG_RAX: 00000000000000bc
      [162513.516750] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f5238f56d5a
      [162513.516751] RDX: 000055b1fbb0d5a0 RSI: 00007fff67b978a0 RDI: 000055b1fbb0d470
      [162513.516753] RBP: 000055b1fbb0d5a0 R08: 0000000000000001 R09: 00007fff67b97700
      [162513.516754] R10: 0000000000000004 R11: 0000000000000202 R12: 0000000000000004
      [162513.516756] R13: 0000000000000024 R14: 0000000000000001 R15: 00007fff67b978a0
      [162513.516767] INFO: task fsstress:1356196 blocked for more than 120 seconds.
      [162513.517064]       Not tainted 5.9.0-rc6-btrfs-next-69 #1
      [162513.517365] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [162513.517763] task:fsstress        state:D stack:    0 pid:1356196 ppid:1356177 flags:0x00004000
      [162513.517780] Call Trace:
      [162513.517786]  __schedule+0x5ce/0xd00
      [162513.517789]  ? _raw_spin_unlock_irqrestore+0x3c/0x60
      [162513.517796]  schedule+0x46/0xf0
      [162513.517810]  wait_current_trans+0xde/0x140 [btrfs]
      [162513.517814]  ? finish_wait+0x90/0x90
      [162513.517829]  start_transaction+0x37c/0x5f0 [btrfs]
      [162513.517845]  btrfs_attach_transaction_barrier+0x1f/0x50 [btrfs]
      [162513.517857]  btrfs_sync_fs+0x61/0x1c0 [btrfs]
      [162513.517862]  ? __ia32_sys_fdatasync+0x20/0x20
      [162513.517865]  iterate_supers+0x87/0xf0
      [162513.517869]  ksys_sync+0x60/0xb0
      [162513.517872]  __do_sys_sync+0xa/0x10
      [162513.517875]  do_syscall_64+0x33/0x80
      [162513.517878]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [162513.517881] RIP: 0033:0x7f5238f50bd7
      [162513.517883] Code: Bad RIP value.
      [162513.517885] RSP: 002b:00007fff67b978e8 EFLAGS: 00000206 ORIG_RAX: 00000000000000a2
      [162513.517887] RAX: ffffffffffffffda RBX: 000055b1fad2c560 RCX: 00007f5238f50bd7
      [162513.517889] RDX: 0000000000000000 RSI: 000000007660add2 RDI: 0000000000000053
      [162513.517891] RBP: 0000000000000032 R08: 0000000000000067 R09: 00007f5239019be0
      [162513.517893] R10: fffffffffffff24f R11: 0000000000000206 R12: 0000000000000053
      [162513.517895] R13: 00007fff67b97950 R14: 00007fff67b97906 R15: 000055b1fad1a340
      [162513.517908] INFO: task fsstress:1356197 blocked for more than 120 seconds.
      [162513.518298]       Not tainted 5.9.0-rc6-btrfs-next-69 #1
      [162513.518672] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [162513.519157] task:fsstress        state:D stack:    0 pid:1356197 ppid:1356177 flags:0x00000000
      [162513.519160] Call Trace:
      [162513.519165]  __schedule+0x5ce/0xd00
      [162513.519168]  ? _raw_spin_unlock_irqrestore+0x3c/0x60
      [162513.519174]  schedule+0x46/0xf0
      [162513.519190]  wait_current_trans+0xde/0x140 [btrfs]
      [162513.519193]  ? finish_wait+0x90/0x90
      [162513.519206]  start_transaction+0x4d7/0x5f0 [btrfs]
      [162513.519222]  btrfs_create+0x57/0x200 [btrfs]
      [162513.519230]  lookup_open+0x522/0x650
      [162513.519246]  path_openat+0x2b8/0xa50
      [162513.519270]  do_filp_open+0x91/0x100
      [162513.519275]  ? find_held_lock+0x32/0x90
      [162513.519280]  ? lock_acquired+0x33b/0x470
      [162513.519285]  ? do_raw_spin_unlock+0x4b/0xc0
      [162513.519287]  ? _raw_spin_unlock+0x29/0x40
      [162513.519295]  do_sys_openat2+0x20d/0x2d0
      [162513.519300]  do_sys_open+0x44/0x80
      [162513.519304]  do_syscall_64+0x33/0x80
      [162513.519307]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [162513.519309] RIP: 0033:0x7f5238f4a903
      [162513.519310] Code: Bad RIP value.
      [162513.519312] RSP: 002b:00007fff67b97758 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
      [162513.519314] RAX: ffffffffffffffda RBX: 00000000ffffffff RCX: 00007f5238f4a903
      [162513.519316] RDX: 0000000000000000 RSI: 00000000000001b6 RDI: 000055b1fbb0d470
      [162513.519317] RBP: 00007fff67b978c0 R08: 0000000000000001 R09: 0000000000000002
      [162513.519319] R10: 00007fff67b974f7 R11: 0000000000000246 R12: 0000000000000013
      [162513.519320] R13: 00000000000001b6 R14: 00007fff67b97906 R15: 000055b1fad1c620
      [162513.519332] INFO: task btrfs:1356211 blocked for more than 120 seconds.
      [162513.519727]       Not tainted 5.9.0-rc6-btrfs-next-69 #1
      [162513.520115] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [162513.520508] task:btrfs           state:D stack:    0 pid:1356211 ppid:1356178 flags:0x00004002
      [162513.520511] Call Trace:
      [162513.520516]  __schedule+0x5ce/0xd00
      [162513.520519]  ? _raw_spin_unlock_irqrestore+0x3c/0x60
      [162513.520525]  schedule+0x46/0xf0
      [162513.520544]  btrfs_scrub_pause+0x11f/0x180 [btrfs]
      [162513.520548]  ? finish_wait+0x90/0x90
      [162513.520562]  btrfs_commit_transaction+0x45a/0xc30 [btrfs]
      [162513.520574]  ? start_transaction+0xe0/0x5f0 [btrfs]
      [162513.520596]  btrfs_dev_replace_finishing+0x6d8/0x711 [btrfs]
      [162513.520619]  btrfs_dev_replace_by_ioctl.cold+0x1cc/0x1fd [btrfs]
      [162513.520639]  btrfs_ioctl+0x2a25/0x36f0 [btrfs]
      [162513.520643]  ? do_sigaction+0xf3/0x240
      [162513.520645]  ? find_held_lock+0x32/0x90
      [162513.520648]  ? do_sigaction+0xf3/0x240
      [162513.520651]  ? lock_acquired+0x33b/0x470
      [162513.520655]  ? _raw_spin_unlock_irq+0x24/0x50
      [162513.520657]  ? lockdep_hardirqs_on+0x7d/0x100
      [162513.520660]  ? _raw_spin_unlock_irq+0x35/0x50
      [162513.520662]  ? do_sigaction+0xf3/0x240
      [162513.520671]  ? __x64_sys_ioctl+0x83/0xb0
      [162513.520672]  __x64_sys_ioctl+0x83/0xb0
      [162513.520677]  do_syscall_64+0x33/0x80
      [162513.520679]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [162513.520681] RIP: 0033:0x7fc3cd307d87
      [162513.520682] Code: Bad RIP value.
      [162513.520684] RSP: 002b:00007ffe30a56bb8 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
      [162513.520686] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007fc3cd307d87
      [162513.520687] RDX: 00007ffe30a57a30 RSI: 00000000ca289435 RDI: 0000000000000003
      [162513.520689] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
      [162513.520690] R10: 0000000000000008 R11: 0000000000000202 R12: 0000000000000003
      [162513.520692] R13: 0000557323a212e0 R14: 00007ffe30a5a520 R15: 0000000000000001
      [162513.520703]
                      Showing all locks held in the system:
      [162513.520712] 1 lock held by khungtaskd/54:
      [162513.520713]  #0: ffffffffb40a91a0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x15/0x197
      [162513.520728] 1 lock held by in:imklog/596:
      [162513.520729]  #0: ffff8f3f0d781400 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x4d/0x60
      [162513.520782] 1 lock held by btrfs-transacti/1356167:
      [162513.520784]  #0: ffff8f3d810cc848 (&fs_info->transaction_kthread_mutex){+.+.}-{3:3}, at: transaction_kthread+0x4a/0x170 [btrfs]
      [162513.520798] 1 lock held by btrfs/1356190:
      [162513.520800]  #0: ffff8f3d57644470 (sb_writers#15){.+.+}-{0:0}, at: mnt_want_write_file+0x22/0x60
      [162513.520805] 1 lock held by fsstress/1356184:
      [162513.520806]  #0: ffff8f3d576440e8 (&type->s_umount_key#62){++++}-{3:3}, at: iterate_supers+0x6f/0xf0
      [162513.520811] 3 locks held by fsstress/1356185:
      [162513.520812]  #0: ffff8f3d57644470 (sb_writers#15){.+.+}-{0:0}, at: mnt_want_write+0x20/0x50
      [162513.520815]  #1: ffff8f3d80a650b8 (&type->i_mutex_dir_key#10){++++}-{3:3}, at: vfs_setxattr+0x50/0x120
      [162513.520820]  #2: ffff8f3d57644690 (sb_internal#2){.+.+}-{0:0}, at: start_transaction+0x40e/0x5f0 [btrfs]
      [162513.520833] 1 lock held by fsstress/1356196:
      [162513.520834]  #0: ffff8f3d576440e8 (&type->s_umount_key#62){++++}-{3:3}, at: iterate_supers+0x6f/0xf0
      [162513.520838] 3 locks held by fsstress/1356197:
      [162513.520839]  #0: ffff8f3d57644470 (sb_writers#15){.+.+}-{0:0}, at: mnt_want_write+0x20/0x50
      [162513.520843]  #1: ffff8f3d506465e8 (&type->i_mutex_dir_key#10){++++}-{3:3}, at: path_openat+0x2a7/0xa50
      [162513.520846]  #2: ffff8f3d57644690 (sb_internal#2){.+.+}-{0:0}, at: start_transaction+0x40e/0x5f0 [btrfs]
      [162513.520858] 2 locks held by btrfs/1356211:
      [162513.520859]  #0: ffff8f3d810cde30 (&fs_info->dev_replace.lock_finishing_cancel_unmount){+.+.}-{3:3}, at: btrfs_dev_replace_finishing+0x52/0x711 [btrfs]
      [162513.520877]  #1: ffff8f3d57644690 (sb_internal#2){.+.+}-{0:0}, at: start_transaction+0x40e/0x5f0 [btrfs]
    
    This was weird because the stack traces show that a transaction commit,
    triggered by a device replace operation, is blocking trying to pause any
    running scrubs but there are no stack traces of blocked tasks doing a
    scrub.
    
    After poking around with drgn, I noticed there was a scrub task that was
    constantly running and blocking for shorts periods of time:
    
      >>> t = find_task(prog, 1356190)
      >>> prog.stack_trace(t)
      #0  __schedule+0x5ce/0xcfc
      #1  schedule+0x46/0xe4
      #2  schedule_timeout+0x1df/0x475
      #3  btrfs_reada_wait+0xda/0x132
      #4  scrub_stripe+0x2a8/0x112f
      #5  scrub_chunk+0xcd/0x134
      #6  scrub_enumerate_chunks+0x29e/0x5ee
      #7  btrfs_scrub_dev+0x2d5/0x91b
      #8  btrfs_ioctl+0x7f5/0x36e7
      #9  __x64_sys_ioctl+0x83/0xb0
      #10 do_syscall_64+0x33/0x77
      #11 entry_SYSCALL_64+0x7c/0x156
    
    Which corresponds to:
    
    int btrfs_reada_wait(void *handle)
    {
        struct reada_control *rc = handle;
        struct btrfs_fs_info *fs_info = rc->fs_info;
    
        while (atomic_read(&rc->elems)) {
            if (!atomic_read(&fs_info->reada_works_cnt))
                reada_start_machine(fs_info);
            wait_event_timeout(rc->wait, atomic_read(&rc->elems) == 0,
                              (HZ + 9) / 10);
        }
    (...)
    
    So the counter "rc->elems" was set to 1 and never decreased to 0, causing
    the scrub task to loop forever in that function. Then I used the following
    script for drgn to check the readahead requests:
    
      $ cat dump_reada.py
      import sys
      import drgn
      from drgn import NULL, Object, cast, container_of, execscript, \
          reinterpret, sizeof
      from drgn.helpers.linux import *
    
      mnt_path = b"/home/fdmanana/btrfs-tests/scratch_1"
    
      mnt = None
      for mnt in for_each_mount(prog, dst = mnt_path):
          pass
    
      if mnt is None:
          sys.stderr.write(f'Error: mount point {mnt_path} not found\n')
          sys.exit(1)
    
      fs_info = cast('struct btrfs_fs_info *', mnt.mnt.mnt_sb.s_fs_info)
    
      def dump_re(re):
          nzones = re.nzones.value_()
          print(f're at {hex(re.value_())}')
          print(f'\t logical {re.logical.value_()}')
          print(f'\t refcnt {re.refcnt.value_()}')
          print(f'\t nzones {nzones}')
          for i in range(nzones):
              dev = re.zones[i].device
              name = dev.name.str.string_()
              print(f'\t\t dev id {dev.devid.value_()} name {name}')
          print()
    
      for _, e in radix_tree_for_each(fs_info.reada_tree):
          re = cast('struct reada_extent *', e)
          dump_re(re)
    
      $ drgn dump_reada.py
      re at 0xffff8f3da9d25ad8
              logical 38928384
              refcnt 1
              nzones 1
                     dev id 0 name b'/dev/sdd'
      $
    
    So there was one readahead extent with a single zone corresponding to the
    source device of that last device replace operation logged in dmesg/syslog.
    Also the ID of that zone's device was 0 which is a special value set in
    the source device of a device replace operation when the operation finishes
    (constant BTRFS_DEV_REPLACE_DEVID set at btrfs_dev_replace_finishing()),
    confirming again that device /dev/sdd was the source of a device replace
    operation.
    
    Normally there should be as many zones in the readahead extent as there are
    devices, and I wasn't expecting the extent to be in a block group with a
    'single' profile, so I went and confirmed with the following drgn script
    that there weren't any single profile block groups:
    
      $ cat dump_block_groups.py
      import sys
      import drgn
      from drgn import NULL, Object, cast, container_of, execscript, \
          reinterpret, sizeof
      from drgn.helpers.linux import *
    
      mnt_path = b"/home/fdmanana/btrfs-tests/scratch_1"
    
      mnt = None
      for mnt in for_each_mount(prog, dst = mnt_path):
          pass
    
      if mnt is None:
          sys.stderr.write(f'Error: mount point {mnt_path} not found\n')
          sys.exit(1)
    
      fs_info = cast('struct btrfs_fs_info *', mnt.mnt.mnt_sb.s_fs_info)
    
      BTRFS_BLOCK_GROUP_DATA = (1 << 0)
      BTRFS_BLOCK_GROUP_SYSTEM = (1 << 1)
      BTRFS_BLOCK_GROUP_METADATA = (1 << 2)
      BTRFS_BLOCK_GROUP_RAID0 = (1 << 3)
      BTRFS_BLOCK_GROUP_RAID1 = (1 << 4)
      BTRFS_BLOCK_GROUP_DUP = (1 << 5)
      BTRFS_BLOCK_GROUP_RAID10 = (1 << 6)
      BTRFS_BLOCK_GROUP_RAID5 = (1 << 7)
      BTRFS_BLOCK_GROUP_RAID6 = (1 << 8)
      BTRFS_BLOCK_GROUP_RAID1C3 = (1 << 9)
      BTRFS_BLOCK_GROUP_RAID1C4 = (1 << 10)
    
      def bg_flags_string(bg):
          flags = bg.flags.value_()
          ret = ''
          if flags & BTRFS_BLOCK_GROUP_DATA:
              ret = 'data'
          if flags & BTRFS_BLOCK_GROUP_METADATA:
              if len(ret) > 0:
                  ret += '|'
              ret += 'meta'
          if flags & BTRFS_BLOCK_GROUP_SYSTEM:
              if len(ret) > 0:
                  ret += '|'
              ret += 'system'
          if flags & BTRFS_BLOCK_GROUP_RAID0:
              ret += ' raid0'
          elif flags & BTRFS_BLOCK_GROUP_RAID1:
              ret += ' raid1'
          elif flags & BTRFS_BLOCK_GROUP_DUP:
              ret += ' dup'
          elif flags & BTRFS_BLOCK_GROUP_RAID10:
              ret += ' raid10'
          elif flags & BTRFS_BLOCK_GROUP_RAID5:
              ret += ' raid5'
          elif flags & BTRFS_BLOCK_GROUP_RAID6:
              ret += ' raid6'
          elif flags & BTRFS_BLOCK_GROUP_RAID1C3:
              ret += ' raid1c3'
          elif flags & BTRFS_BLOCK_GROUP_RAID1C4:
              ret += ' raid1c4'
          else:
              ret += ' single'
    
          return ret
    
      def dump_bg(bg):
          print()
          print(f'block group at {hex(bg.value_())}')
          print(f'\t start {bg.start.value_()} length {bg.length.value_()}')
          print(f'\t flags {bg.flags.value_()} - {bg_flags_string(bg)}')
    
      bg_root = fs_info.block_group_cache_tree.address_of_()
      for bg in rbtree_inorder_for_each_entry('struct btrfs_block_group', bg_root, 'cache_node'):
          dump_bg(bg)
    
      $ drgn dump_block_groups.py
    
      block group at 0xffff8f3d673b0400
             start 22020096 length 16777216
             flags 258 - system raid6
    
      block group at 0xffff8f3d53ddb400
             start 38797312 length 536870912
             flags 260 - meta raid6
    
      block group at 0xffff8f3d5f4d9c00
             start 575668224 length 2147483648
             flags 257 - data raid6
    
      block group at 0xffff8f3d08189000
             start 2723151872 length 67108864
             flags 258 - system raid6
    
      block group at 0xffff8f3db70ff000
             start 2790260736 length 1073741824
             flags 260 - meta raid6
    
      block group at 0xffff8f3d5f4dd800
             start 3864002560 length 67108864
             flags 258 - system raid6
    
      block group at 0xffff8f3d67037000
             start 3931111424 length 2147483648
             flags 257 - data raid6
      $
    
    So there were only 2 reasons left for having a readahead extent with a
    single zone: reada_find_zone(), called when creating a readahead extent,
    returned NULL either because we failed to find the corresponding block
    group or because a memory allocation failed. With some additional and
    custom tracing I figured out that on every further ocurrence of the
    problem the block group had just been deleted when we were looping to
    create the zones for the readahead extent (at reada_find_extent()), so we
    ended up with only one zone in the readahead extent, corresponding to a
    device that ends up getting replaced.
    
    So after figuring that out it became obvious why the hang happens:
    
    1) Task A starts a scrub on any device of the filesystem, except for
       device /dev/sdd;
    
    2) Task B starts a device replace with /dev/sdd as the source device;
    
    3) Task A calls btrfs_reada_add() from scrub_stripe() and it is currently
       starting to scrub a stripe from block group X. This call to
       btrfs_reada_add() is the one for the extent tree. When btrfs_reada_add()
       calls reada_add_block(), it passes the logical address of the extent
       tree's root node as its 'logical' argument - a value of 38928384;
    
    4) Task A then enters reada_find_extent(), called from reada_add_block().
       It finds there isn't any existing readahead extent for the logical
       address 38928384, so it proceeds to the path of creating a new one.
    
       It calls btrfs_map_block() to find out which stripes exist for the block
       group X. On the first iteration of the for loop that iterates over the
       stripes, it finds the stripe for device /dev/sdd, so it creates one
       zone for that device and adds it to the readahead extent. Before getting
       into the second iteration of the loop, the cleanup kthread deletes block
       group X because it was empty. So in the iterations for the remaining
       stripes it does not add more zones to the readahead extent, because the
       calls to reada_find_zone() returned NULL because they couldn't find
       block group X anymore.
    
       As a result the new readahead extent has a single zone, corresponding to
       the device /dev/sdd;
    
    4) Before task A returns to btrfs_reada_add() and queues the readahead job
       for the readahead work queue, task B finishes the device replace and at
       btrfs_dev_replace_finishing() swaps the device /dev/sdd with the new
       device /dev/sdg;
    
    5) Task A returns to reada_add_block(), which increments the counter
       "->elems" of the reada_control structure allocated at btrfs_reada_add().
    
       Then it returns back to btrfs_reada_add() and calls
       reada_start_machine(). This queues a job in the readahead work queue to
       run the function reada_start_machine_worker(), which calls
       __reada_start_machine().
    
       At __reada_start_machine() we take the device list mutex and for each
       device found in the current device list, we call
       reada_start_machine_dev() to start the readahead work. However at this
       point the device /dev/sdd was already freed and is not in the device
       list anymore.
    
       This means the corresponding readahead for the extent at 38928384 is
       never started, and therefore the "->elems" counter of the reada_control
       structure allocated at btrfs_reada_add() never goes down to 0, causing
       the call to btrfs_reada_wait(), done by the scrub task, to wait forever.
    
    Note that the readahead request can be made either after the device replace
    started or before it started, however in pratice it is very unlikely that a
    device replace is able to start after a readahead request is made and is
    able to complete before the readahead request completes - maybe only on a
    very small and nearly empty filesystem.
    
    This hang however is not the only problem we can have with readahead and
    device removals. When the readahead extent has other zones other than the
    one corresponding to the device that is being removed (either by a device
    replace or a device remove operation), we risk having a use-after-free on
    the device when dropping the last reference of the readahead extent.
    
    For example if we create a readahead extent with two zones, one for the
    device /dev/sdd and one for the device /dev/sde:
    
    1) Before the readahead worker starts, the device /dev/sdd is removed,
       and the corresponding btrfs_device structure is freed. However the
       readahead extent still has the zone pointing to the device structure;
    
    2) When the readahead worker starts, it only finds device /dev/sde in the
       current device list of the filesystem;
    
    3) It starts the readahead work, at reada_start_machine_dev(), using the
       device /dev/sde;
    
    4) Then when it finishes reading the extent from device /dev/sde, it calls
       __readahead_hook() which ends up dropping the last reference on the
       readahead extent through the last call to reada_extent_put();
    
    5) At reada_extent_put() it iterates over each zone of the readahead extent
       and attempts to delete an element from the device's 'reada_extents'
       radix tree, resulting in a use-after-free, as the device pointer of the
       zone for /dev/sdd is now stale. We can also access the device after
       dropping the last reference of a zone, through reada_zone_release(),
       also called by reada_extent_put().
    
    And a device remove suffers the same problem, however since it shrinks the
    device size down to zero before removing the device, it is very unlikely to
    still have readahead requests not completed by the time we free the device,
    the only possibility is if the device has a very little space allocated.
    
    While the hang problem is exclusive to scrub, since it is currently the
    only user of btrfs_reada_add() and btrfs_reada_wait(), the use-after-free
    problem affects any path that triggers readhead, which includes
    btree_readahead_hook() and __readahead_hook() (a readahead worker can
    trigger readahed for the children of a node) for example - any path that
    ends up calling reada_add_block() can trigger the use-after-free after a
    device is removed.
    
    So fix this by waiting for any readahead requests for a device to complete
    before removing a device, ensuring that while waiting for existing ones no
    new ones can be made.
    
    This problem has been around for a very long time - the readahead code was
    added in 2011, device remove exists since 2008 and device replace was
    introduced in 2013, hard to pick a specific commit for a git Fixes tag.
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dabb94d5791dc06cca82876ae8497006f27405d8
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Oct 12 11:55:23 2020 +0100

    btrfs: fix use-after-free on readahead extent after failure to create it
    
    commit 83bc1560e02e25c6439341352024ebe8488f4fbd upstream.
    
    If we fail to find suitable zones for a new readahead extent, we end up
    leaving a stale pointer in the global readahead extents radix tree
    (fs_info->reada_tree), which can trigger the following trace later on:
    
      [13367.696354] BUG: kernel NULL pointer dereference, address: 00000000000000b0
      [13367.696802] #PF: supervisor read access in kernel mode
      [13367.697249] #PF: error_code(0x0000) - not-present page
      [13367.697721] PGD 0 P4D 0
      [13367.698171] Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC PTI
      [13367.698632] CPU: 6 PID: 851214 Comm: btrfs Tainted: G        W         5.9.0-rc6-btrfs-next-69 #1
      [13367.699100] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      [13367.700069] RIP: 0010:__lock_acquire+0x20a/0x3970
      [13367.700562] Code: ff 1f 0f b7 c0 48 0f (...)
      [13367.701609] RSP: 0018:ffffb14448f57790 EFLAGS: 00010046
      [13367.702140] RAX: 0000000000000000 RBX: 29b935140c15e8cf RCX: 0000000000000000
      [13367.702698] RDX: 0000000000000002 RSI: ffffffffb3d66bd0 RDI: 0000000000000046
      [13367.703240] RBP: ffff8a52ba8ac040 R08: 00000c2866ad9288 R09: 0000000000000001
      [13367.703783] R10: 0000000000000001 R11: 00000000b66d9b53 R12: ffff8a52ba8ac9b0
      [13367.704330] R13: 0000000000000000 R14: ffff8a532b6333e8 R15: 0000000000000000
      [13367.704880] FS:  00007fe1df6b5700(0000) GS:ffff8a5376600000(0000) knlGS:0000000000000000
      [13367.705438] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [13367.705995] CR2: 00000000000000b0 CR3: 000000022cca8004 CR4: 00000000003706e0
      [13367.706565] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [13367.707127] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [13367.707686] Call Trace:
      [13367.708246]  ? ___slab_alloc+0x395/0x740
      [13367.708820]  ? reada_add_block+0xae/0xee0 [btrfs]
      [13367.709383]  lock_acquire+0xb1/0x480
      [13367.709955]  ? reada_add_block+0xe0/0xee0 [btrfs]
      [13367.710537]  ? reada_add_block+0xae/0xee0 [btrfs]
      [13367.711097]  ? rcu_read_lock_sched_held+0x5d/0x90
      [13367.711659]  ? kmem_cache_alloc_trace+0x8d2/0x990
      [13367.712221]  ? lock_acquired+0x33b/0x470
      [13367.712784]  _raw_spin_lock+0x34/0x80
      [13367.713356]  ? reada_add_block+0xe0/0xee0 [btrfs]
      [13367.713966]  reada_add_block+0xe0/0xee0 [btrfs]
      [13367.714529]  ? btrfs_root_node+0x15/0x1f0 [btrfs]
      [13367.715077]  btrfs_reada_add+0x117/0x170 [btrfs]
      [13367.715620]  scrub_stripe+0x21e/0x10d0 [btrfs]
      [13367.716141]  ? kvm_sched_clock_read+0x5/0x10
      [13367.716657]  ? __lock_acquire+0x41e/0x3970
      [13367.717184]  ? scrub_chunk+0x60/0x140 [btrfs]
      [13367.717697]  ? find_held_lock+0x32/0x90
      [13367.718254]  ? scrub_chunk+0x60/0x140 [btrfs]
      [13367.718773]  ? lock_acquired+0x33b/0x470
      [13367.719278]  ? scrub_chunk+0xcd/0x140 [btrfs]
      [13367.719786]  scrub_chunk+0xcd/0x140 [btrfs]
      [13367.720291]  scrub_enumerate_chunks+0x270/0x5c0 [btrfs]
      [13367.720787]  ? finish_wait+0x90/0x90
      [13367.721281]  btrfs_scrub_dev+0x1ee/0x620 [btrfs]
      [13367.721762]  ? rcu_read_lock_any_held+0x8e/0xb0
      [13367.722235]  ? preempt_count_add+0x49/0xa0
      [13367.722710]  ? __sb_start_write+0x19b/0x290
      [13367.723192]  btrfs_ioctl+0x7f5/0x36f0 [btrfs]
      [13367.723660]  ? __fget_files+0x101/0x1d0
      [13367.724118]  ? find_held_lock+0x32/0x90
      [13367.724559]  ? __fget_files+0x101/0x1d0
      [13367.724982]  ? __x64_sys_ioctl+0x83/0xb0
      [13367.725399]  __x64_sys_ioctl+0x83/0xb0
      [13367.725802]  do_syscall_64+0x33/0x80
      [13367.726188]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [13367.726574] RIP: 0033:0x7fe1df7add87
      [13367.726948] Code: 00 00 00 48 8b 05 09 91 (...)
      [13367.727763] RSP: 002b:00007fe1df6b4d48 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      [13367.728179] RAX: ffffffffffffffda RBX: 000055ce1fb596a0 RCX: 00007fe1df7add87
      [13367.728604] RDX: 000055ce1fb596a0 RSI: 00000000c400941b RDI: 0000000000000003
      [13367.729021] RBP: 0000000000000000 R08: 00007fe1df6b5700 R09: 0000000000000000
      [13367.729431] R10: 00007fe1df6b5700 R11: 0000000000000246 R12: 00007ffd922b07de
      [13367.729842] R13: 00007ffd922b07df R14: 00007fe1df6b4e40 R15: 0000000000802000
      [13367.730275] Modules linked in: btrfs blake2b_generic xor (...)
      [13367.732638] CR2: 00000000000000b0
      [13367.733166] ---[ end trace d298b6805556acd9 ]---
    
    What happens is the following:
    
    1) At reada_find_extent() we don't find any existing readahead extent for
       the metadata extent starting at logical address X;
    
    2) So we proceed to create a new one. We then call btrfs_map_block() to get
       information about which stripes contain extent X;
    
    3) After that we iterate over the stripes and create only one zone for the
       readahead extent - only one because reada_find_zone() returned NULL for
       all iterations except for one, either because a memory allocation failed
       or it couldn't find the block group of the extent (it may have just been
       deleted);
    
    4) We then add the new readahead extent to the readahead extents radix
       tree at fs_info->reada_tree;
    
    5) Then we iterate over each zone of the new readahead extent, and find
       that the device used for that zone no longer exists, because it was
       removed or it was the source device of a device replace operation.
       Since this left 'have_zone' set to 0, after finishing the loop we jump
       to the 'error' label, call kfree() on the new readahead extent and
       return without removing it from the radix tree at fs_info->reada_tree;
    
    6) Any future call to reada_find_extent() for the logical address X will
       find the stale pointer in the readahead extents radix tree, increment
       its reference counter, which can trigger the use-after-free right
       away or return it to the caller reada_add_block() that results in the
       use-after-free of the example trace above.
    
    So fix this by making sure we delete the readahead extent from the radix
    tree if we fail to setup zones for it (when 'have_zone = 0').
    
    Fixes: 319450211842ba ("btrfs: reada: bypass adding extent when all zone failed")
    CC: stable@vger.kernel.org # 4.9+
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33eb5b3cb2e616e543198ec5a7eb58b7b12846e4
Author: Daniel Xu <dxu@dxuuu.xyz>
Date:   Thu Oct 8 18:09:10 2020 -0700

    btrfs: tree-checker: validate number of chunk stripes and parity
    
    commit 85d07fbe09efd1c529ff3e025e2f0d2c6c96a1b7 upstream.
    
    If there's no parity and num_stripes < ncopies, a crafted image can
    trigger a division by zero in calc_stripe_length().
    
    The image was generated through fuzzing.
    
    CC: stable@vger.kernel.org # 5.4+
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209587
    Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0cb097f50d2e8c206938b138a5289b3eca623ac7
Author: Anand Jain <anand.jain@oracle.com>
Date:   Wed Sep 30 21:09:52 2020 +0800

    btrfs: skip devices without magic signature when mounting
    
    commit 96c2e067ed3e3e004580a643c76f58729206b829 upstream.
    
    Many things can happen after the device is scanned and before the device
    is mounted.  One such thing is losing the BTRFS_MAGIC on the device.
    If it happens we still won't free that device from the memory and cause
    the userland confusion.
    
    For example: As the BTRFS_IOC_DEV_INFO still carries the device path
    which does not have the BTRFS_MAGIC, 'btrfs fi show' still lists
    device which does not belong to the filesystem anymore:
    
      $ mkfs.btrfs -fq -draid1 -mraid1 /dev/sda /dev/sdb
      $ wipefs -a /dev/sdb
      # /dev/sdb does not contain magic signature
      $ mount -o degraded /dev/sda /btrfs
      $ btrfs fi show -m
      Label: none  uuid: 470ec6fb-646b-4464-b3cb-df1b26c527bd
              Total devices 2 FS bytes used 128.00KiB
              devid    1 size 3.00GiB used 571.19MiB path /dev/sda
              devid    2 size 3.00GiB used 571.19MiB path /dev/sdb
    
    We need to distinguish the missing signature and invalid superblock, so
    add a specific error code ENODATA for that. This also fixes failure of
    fstest btrfs/198.
    
    CC: stable@vger.kernel.org # 4.19+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Anand Jain <anand.jain@oracle.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fbf3b12a76a71c44ceaa81d4f0a441f4c6c7214c
Author: Josef Bacik <josef@toxicpanda.com>
Date:   Tue Sep 29 08:53:54 2020 -0400

    btrfs: cleanup cow block on error
    
    commit 572c83acdcdafeb04e70aa46be1fa539310be20c upstream.
    
    In fstest btrfs/064 a transaction abort in __btrfs_cow_block could lead
    to a system lockup. It gets stuck trying to write back inodes, and the
    write back thread was trying to lock an extent buffer:
    
      $ cat /proc/2143497/stack
      [<0>] __btrfs_tree_lock+0x108/0x250
      [<0>] lock_extent_buffer_for_io+0x35e/0x3a0
      [<0>] btree_write_cache_pages+0x15a/0x3b0
      [<0>] do_writepages+0x28/0xb0
      [<0>] __writeback_single_inode+0x54/0x5c0
      [<0>] writeback_sb_inodes+0x1e8/0x510
      [<0>] wb_writeback+0xcc/0x440
      [<0>] wb_workfn+0xd7/0x650
      [<0>] process_one_work+0x236/0x560
      [<0>] worker_thread+0x55/0x3c0
      [<0>] kthread+0x13a/0x150
      [<0>] ret_from_fork+0x1f/0x30
    
    This is because we got an error while COWing a block, specifically here
    
            if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) {
                    ret = btrfs_reloc_cow_block(trans, root, buf, cow);
                    if (ret) {
                            btrfs_abort_transaction(trans, ret);
                            return ret;
                    }
            }
    
      [16402.241552] BTRFS: Transaction aborted (error -2)
      [16402.242362] WARNING: CPU: 1 PID: 2563188 at fs/btrfs/ctree.c:1074 __btrfs_cow_block+0x376/0x540
      [16402.249469] CPU: 1 PID: 2563188 Comm: fsstress Not tainted 5.9.0-rc6+ #8
      [16402.249936] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
      [16402.250525] RIP: 0010:__btrfs_cow_block+0x376/0x540
      [16402.252417] RSP: 0018:ffff9cca40e578b0 EFLAGS: 00010282
      [16402.252787] RAX: 0000000000000025 RBX: 0000000000000002 RCX: ffff9132bbd19388
      [16402.253278] RDX: 00000000ffffffd8 RSI: 0000000000000027 RDI: ffff9132bbd19380
      [16402.254063] RBP: ffff9132b41a49c0 R08: 0000000000000000 R09: 0000000000000000
      [16402.254887] R10: 0000000000000000 R11: ffff91324758b080 R12: ffff91326ef17ce0
      [16402.255694] R13: ffff91325fc0f000 R14: ffff91326ef176b0 R15: ffff9132815e2000
      [16402.256321] FS:  00007f542c6d7b80(0000) GS:ffff9132bbd00000(0000) knlGS:0000000000000000
      [16402.256973] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [16402.257374] CR2: 00007f127b83f250 CR3: 0000000133480002 CR4: 0000000000370ee0
      [16402.257867] Call Trace:
      [16402.258072]  btrfs_cow_block+0x109/0x230
      [16402.258356]  btrfs_search_slot+0x530/0x9d0
      [16402.258655]  btrfs_lookup_file_extent+0x37/0x40
      [16402.259155]  __btrfs_drop_extents+0x13c/0xd60
      [16402.259628]  ? btrfs_block_rsv_migrate+0x4f/0xb0
      [16402.259949]  btrfs_replace_file_extents+0x190/0x820
      [16402.260873]  btrfs_clone+0x9ae/0xc00
      [16402.261139]  btrfs_extent_same_range+0x66/0x90
      [16402.261771]  btrfs_remap_file_range+0x353/0x3b1
      [16402.262333]  vfs_dedupe_file_range_one.part.0+0xd5/0x140
      [16402.262821]  vfs_dedupe_file_range+0x189/0x220
      [16402.263150]  do_vfs_ioctl+0x552/0x700
      [16402.263662]  __x64_sys_ioctl+0x62/0xb0
      [16402.264023]  do_syscall_64+0x33/0x40
      [16402.264364]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [16402.264862] RIP: 0033:0x7f542c7d15cb
      [16402.266901] RSP: 002b:00007ffd35944ea8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      [16402.267627] RAX: ffffffffffffffda RBX: 00000000009d1968 RCX: 00007f542c7d15cb
      [16402.268298] RDX: 00000000009d2490 RSI: 00000000c0189436 RDI: 0000000000000003
      [16402.268958] RBP: 00000000009d2520 R08: 0000000000000036 R09: 00000000009d2e64
      [16402.269726] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000002
      [16402.270659] R13: 000000000001f000 R14: 00000000009d1970 R15: 00000000009d2e80
      [16402.271498] irq event stamp: 0
      [16402.271846] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
      [16402.272497] hardirqs last disabled at (0): [<ffffffff910dbf59>] copy_process+0x6b9/0x1ba0
      [16402.273343] softirqs last  enabled at (0): [<ffffffff910dbf59>] copy_process+0x6b9/0x1ba0
      [16402.273905] softirqs last disabled at (0): [<0000000000000000>] 0x0
      [16402.274338] ---[ end trace 737874a5a41a8236 ]---
      [16402.274669] BTRFS: error (device dm-9) in __btrfs_cow_block:1074: errno=-2 No such entry
      [16402.276179] BTRFS info (device dm-9): forced readonly
      [16402.277046] BTRFS: error (device dm-9) in btrfs_replace_file_extents:2723: errno=-2 No such entry
      [16402.278744] BTRFS: error (device dm-9) in __btrfs_cow_block:1074: errno=-2 No such entry
      [16402.279968] BTRFS: error (device dm-9) in __btrfs_cow_block:1074: errno=-2 No such entry
      [16402.280582] BTRFS info (device dm-9): balance: ended with status: -30
    
    The problem here is that as soon as we allocate the new block it is
    locked and marked dirty in the btree inode.  This means that we could
    attempt to writeback this block and need to lock the extent buffer.
    However we're not unlocking it here and thus we deadlock.
    
    Fix this by unlocking the cow block if we have any errors inside of
    __btrfs_cow_block, and also free it so we do not leak it.
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: Josef Bacik <josef@toxicpanda.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9d63fb0503eb1f3ece29d975c38f2ed93fa9d5d8
Author: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Date:   Tue Sep 22 17:27:29 2020 +0900

    btrfs: reschedule when cloning lots of extents
    
    commit 6b613cc97f0ace77f92f7bc112b8f6ad3f52baf8 upstream.
    
    We have several occurrences of a soft lockup from fstest's generic/175
    testcase, which look more or less like this one:
    
      watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [xfs_io:10030]
      Kernel panic - not syncing: softlockup: hung tasks
      CPU: 0 PID: 10030 Comm: xfs_io Tainted: G             L    5.9.0-rc5+ #768
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4-rebuilt.opensuse.org 04/01/2014
      Call Trace:
       <IRQ>
       dump_stack+0x77/0xa0
       panic+0xfa/0x2cb
       watchdog_timer_fn.cold+0x85/0xa5
       ? lockup_detector_update_enable+0x50/0x50
       __hrtimer_run_queues+0x99/0x4c0
       ? recalibrate_cpu_khz+0x10/0x10
       hrtimer_run_queues+0x9f/0xb0
       update_process_times+0x28/0x80
       tick_handle_periodic+0x1b/0x60
       __sysvec_apic_timer_interrupt+0x76/0x210
       asm_call_on_stack+0x12/0x20
       </IRQ>
       sysvec_apic_timer_interrupt+0x7f/0x90
       asm_sysvec_apic_timer_interrupt+0x12/0x20
      RIP: 0010:btrfs_tree_unlock+0x91/0x1a0 [btrfs]
      RSP: 0018:ffffc90007123a58 EFLAGS: 00000282
      RAX: ffff8881cea2fbe0 RBX: ffff8881cea2fbe0 RCX: 0000000000000000
      RDX: ffff8881d23fd200 RSI: ffffffff82045220 RDI: ffff8881cea2fba0
      RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000032
      R10: 0000160000000000 R11: 0000000000001000 R12: 0000000000001000
      R13: ffff8882357fd5b0 R14: ffff88816fa76e70 R15: ffff8881cea2fad0
       ? btrfs_tree_unlock+0x15b/0x1a0 [btrfs]
       btrfs_release_path+0x67/0x80 [btrfs]
       btrfs_insert_replace_extent+0x177/0x2c0 [btrfs]
       btrfs_replace_file_extents+0x472/0x7c0 [btrfs]
       btrfs_clone+0x9ba/0xbd0 [btrfs]
       btrfs_clone_files.isra.0+0xeb/0x140 [btrfs]
       ? file_update_time+0xcd/0x120
       btrfs_remap_file_range+0x322/0x3b0 [btrfs]
       do_clone_file_range+0xb7/0x1e0
       vfs_clone_file_range+0x30/0xa0
       ioctl_file_clone+0x8a/0xc0
       do_vfs_ioctl+0x5b2/0x6f0
       __x64_sys_ioctl+0x37/0xa0
       do_syscall_64+0x33/0x40
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x7f87977fc247
      RSP: 002b:00007ffd51a2f6d8 EFLAGS: 00000206 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f87977fc247
      RDX: 00007ffd51a2f710 RSI: 000000004020940d RDI: 0000000000000003
      RBP: 0000000000000004 R08: 00007ffd51a79080 R09: 0000000000000000
      R10: 00005621f11352f2 R11: 0000000000000206 R12: 0000000000000000
      R13: 0000000000000000 R14: 00005621f128b958 R15: 0000000080000000
      Kernel Offset: disabled
      ---[ end Kernel panic - not syncing: softlockup: hung tasks ]---
    
    All of these lockup reports have the call chain btrfs_clone_files() ->
    btrfs_clone() in common. btrfs_clone_files() calls btrfs_clone() with
    both source and destination extents locked and loops over the source
    extent to create the clones.
    
    Conditionally reschedule in the btrfs_clone() loop, to give some time back
    to other processes.
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1700e87aaf64c32f8b113e31c82491c8af4ceec5
Author: Qu Wenruo <wqu@suse.com>
Date:   Tue Sep 22 10:37:01 2020 +0800

    btrfs: tree-checker: fix false alert caused by legacy btrfs root item
    
    commit 1465af12e254a68706e110846f59cf0f09683184 upstream.
    
    Commit 259ee7754b67 ("btrfs: tree-checker: Add ROOT_ITEM check")
    introduced btrfs root item size check, however btrfs root item has two
    versions, the legacy one which just ends before generation_v2 member, is
    smaller than current btrfs root item size.
    
    This caused btrfs kernel to reject valid but old tree root leaves.
    
    Fix this problem by also allowing legacy root item, since kernel can
    already handle them pretty well and upgrade to newer root item format
    when needed.
    
    Reported-by: Martin Steigerwald <martin@lichtvoll.de>
    Fixes: 259ee7754b67 ("btrfs: tree-checker: Add ROOT_ITEM check")
    CC: stable@vger.kernel.org # 5.4+
    Tested-By: Martin Steigerwald <martin@lichtvoll.de>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a3be5fff2295b607473efb3fd032dcfd2f6450cf
Author: Denis Efremov <efremov@linux.com>
Date:   Mon Sep 21 20:03:35 2020 +0300

    btrfs: use kvzalloc() to allocate clone_roots in btrfs_ioctl_send()
    
    commit 8eb2fd00153a3a96a19c62ac9c6d48c2efebe5e8 upstream.
    
    btrfs_ioctl_send() used open-coded kvzalloc implementation earlier.
    The code was accidentally replaced with kzalloc() call [1]. Restore
    the original code by using kvzalloc() to allocate sctx->clone_roots.
    
    [1] https://patchwork.kernel.org/patch/9757891/#20529627
    
    Fixes: 818e010bf9d0 ("btrfs: replace opencoded kvzalloc with the helper")
    CC: stable@vger.kernel.org # 4.14+
    Signed-off-by: Denis Efremov <efremov@linux.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4fdb5d05cbfc79cebae22ea651818c20de92c35a
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Sep 21 14:13:30 2020 +0100

    btrfs: send, recompute reference path after orphanization of a directory
    
    commit 9c2b4e0347067396ceb3ae929d6888c81d610259 upstream.
    
    During an incremental send, when an inode has multiple new references we
    might end up emitting rename operations for orphanizations that have a
    source path that is no longer valid due to a previous orphanization of
    some directory inode. This causes the receiver to fail since it tries
    to rename a path that does not exists.
    
    Example reproducer:
    
      $ cat reproducer.sh
      #!/bin/bash
    
      mkfs.btrfs -f /dev/sdi >/dev/null
      mount /dev/sdi /mnt/sdi
    
      touch /mnt/sdi/f1
      touch /mnt/sdi/f2
      mkdir /mnt/sdi/d1
      mkdir /mnt/sdi/d1/d2
    
      # Filesystem looks like:
      #
      # .                           (ino 256)
      # |----- f1                   (ino 257)
      # |----- f2                   (ino 258)
      # |----- d1/                  (ino 259)
      #        |----- d2/           (ino 260)
    
      btrfs subvolume snapshot -r /mnt/sdi /mnt/sdi/snap1
      btrfs send -f /tmp/snap1.send /mnt/sdi/snap1
    
      # Now do a series of changes such that:
      #
      # *) inode 258 has one new hardlink and the previous name changed
      #
      # *) both names conflict with the old names of two other inodes:
      #
      #    1) the new name "d1" conflicts with the old name of inode 259,
      #       under directory inode 256 (root)
      #
      #    2) the new name "d2" conflicts with the old name of inode 260
      #       under directory inode 259
      #
      # *) inodes 259 and 260 now have the old names of inode 258
      #
      # *) inode 257 is now located under inode 260 - an inode with a number
      #    smaller than the inode (258) for which we created a second hard
      #    link and swapped its names with inodes 259 and 260
      #
      ln /mnt/sdi/f2 /mnt/sdi/d1/f2_link
      mv /mnt/sdi/f1 /mnt/sdi/d1/d2/f1
    
      # Swap d1 and f2.
      mv /mnt/sdi/d1 /mnt/sdi/tmp
      mv /mnt/sdi/f2 /mnt/sdi/d1
      mv /mnt/sdi/tmp /mnt/sdi/f2
    
      # Swap d2 and f2_link
      mv /mnt/sdi/f2/d2 /mnt/sdi/tmp
      mv /mnt/sdi/f2/f2_link /mnt/sdi/f2/d2
      mv /mnt/sdi/tmp /mnt/sdi/f2/f2_link
    
      # Filesystem now looks like:
      #
      # .                                (ino 256)
      # |----- d1                        (ino 258)
      # |----- f2/                       (ino 259)
      #        |----- f2_link/           (ino 260)
      #        |       |----- f1         (ino 257)
      #        |
      #        |----- d2                 (ino 258)
    
      btrfs subvolume snapshot -r /mnt/sdi /mnt/sdi/snap2
      btrfs send -f /tmp/snap2.send -p /mnt/sdi/snap1 /mnt/sdi/snap2
    
      mkfs.btrfs -f /dev/sdj >/dev/null
      mount /dev/sdj /mnt/sdj
    
      btrfs receive -f /tmp/snap1.send /mnt/sdj
      btrfs receive -f /tmp/snap2.send /mnt/sdj
    
      umount /mnt/sdi
      umount /mnt/sdj
    
    When executed the receive of the incremental stream fails:
    
      $ ./reproducer.sh
      Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap1'
      At subvol /mnt/sdi/snap1
      Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap2'
      At subvol /mnt/sdi/snap2
      At subvol snap1
      At snapshot snap2
      ERROR: rename d1/d2 -> o260-6-0 failed: No such file or directory
    
    This happens because:
    
    1) When processing inode 257 we end up computing the name for inode 259
       because it is an ancestor in the send snapshot, and at that point it
       still has its old name, "d1", from the parent snapshot because inode
       259 was not yet processed. We then cache that name, which is valid
       until we start processing inode 259 (or set the progress to 260 after
       processing its references);
    
    2) Later we start processing inode 258 and collecting all its new
       references into the list sctx->new_refs. The first reference in the
       list happens to be the reference for name "d1" while the reference for
       name "d2" is next (the last element of the list).
       We compute the full path "d1/d2" for this second reference and store
       it in the reference (its ->full_path member). The path used for the
       new parent directory was "d1" and not "f2" because inode 259, the
       new parent, was not yet processed;
    
    3) When we start processing the new references at process_recorded_refs()
       we start with the first reference in the list, for the new name "d1".
       Because there is a conflicting inode that was not yet processed, which
       is directory inode 259, we orphanize it, renaming it from "d1" to
       "o259-6-0";
    
    4) Then we start processing the new reference for name "d2", and we
       realize it conflicts with the reference of inode 260 in the parent
       snapshot. So we issue an orphanization operation for inode 260 by
       emitting a rename operation with a destination path of "o260-6-0"
       and a source path of "d1/d2" - this source path is the value we
       stored in the reference earlier at step 2), corresponding to the
       ->full_path member of the reference, however that path is no longer
       valid due to the orphanization of the directory inode 259 in step 3).
       This makes the receiver fail since the path does not exists, it should
       have been "o259-6-0/d2".
    
    Fix this by recomputing the full path of a reference before emitting an
    orphanization if we previously orphanized any directory, since that
    directory could be a parent in the new path. This is a rare scenario so
    keeping it simple and not checking if that previously orphanized directory
    is in fact an ancestor of the inode we are trying to orphanize.
    
    A test case for fstests follows soon.
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a2b9ad4009ee253f3fa2576f46f26ca1c5f13bb4
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Sep 21 14:13:29 2020 +0100

    btrfs: send, orphanize first all conflicting inodes when processing references
    
    commit 98272bb77bf4cc20ed1ffca89832d713e70ebf09 upstream.
    
    When doing an incremental send it is possible that when processing the new
    references for an inode we end up issuing rename or link operations that
    have an invalid path, which contains the orphanized name of a directory
    before we actually orphanized it, causing the receiver to fail.
    
    The following reproducer triggers such scenario:
    
      $ cat reproducer.sh
      #!/bin/bash
    
      mkfs.btrfs -f /dev/sdi >/dev/null
      mount /dev/sdi /mnt/sdi
    
      touch /mnt/sdi/a
      touch /mnt/sdi/b
      mkdir /mnt/sdi/testdir
      # We want "a" to have a lower inode number then "testdir" (257 vs 259).
      mv /mnt/sdi/a /mnt/sdi/testdir/a
    
      # Filesystem looks like:
      #
      # .                           (ino 256)
      # |----- testdir/             (ino 259)
      # |          |----- a         (ino 257)
      # |
      # |----- b                    (ino 258)
    
      btrfs subvolume snapshot -r /mnt/sdi /mnt/sdi/snap1
      btrfs send -f /tmp/snap1.send /mnt/sdi/snap1
    
      # Now rename 259 to "testdir_2", then change the name of 257 to
      # "testdir" and make it a direct descendant of the root inode (256).
      # Also create a new link for inode 257 with the old name of inode 258.
      # By swapping the names and location of several inodes and create a
      # nasty dependency chain of rename and link operations.
      mv /mnt/sdi/testdir/a /mnt/sdi/a2
      touch /mnt/sdi/testdir/a
      mv /mnt/sdi/b /mnt/sdi/b2
      ln /mnt/sdi/a2 /mnt/sdi/b
      mv /mnt/sdi/testdir /mnt/sdi/testdir_2
      mv /mnt/sdi/a2 /mnt/sdi/testdir
    
      # Filesystem now looks like:
      #
      # .                            (ino 256)
      # |----- testdir_2/            (ino 259)
      # |          |----- a          (ino 260)
      # |
      # |----- testdir               (ino 257)
      # |----- b                     (ino 257)
      # |----- b2                    (ino 258)
    
      btrfs subvolume snapshot -r /mnt/sdi /mnt/sdi/snap2
      btrfs send -f /tmp/snap2.send -p /mnt/sdi/snap1 /mnt/sdi/snap2
    
      mkfs.btrfs -f /dev/sdj >/dev/null
      mount /dev/sdj /mnt/sdj
    
      btrfs receive -f /tmp/snap1.send /mnt/sdj
      btrfs receive -f /tmp/snap2.send /mnt/sdj
    
      umount /mnt/sdi
      umount /mnt/sdj
    
    When running the reproducer, the receive of the incremental send stream
    fails:
    
      $ ./reproducer.sh
      Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap1'
      At subvol /mnt/sdi/snap1
      Create a readonly snapshot of '/mnt/sdi' in '/mnt/sdi/snap2'
      At subvol /mnt/sdi/snap2
      At subvol snap1
      At snapshot snap2
      ERROR: link b -> o259-6-0/a failed: No such file or directory
    
    The problem happens because of the following:
    
    1) Before we start iterating the list of new references for inode 257,
       we generate its current path and store it at @valid_path, done at
       the very beginning of process_recorded_refs(). The generated path
       is "o259-6-0/a", containing the orphanized name for inode 259;
    
    2) Then we iterate over the list of new references, which has the
       references "b" and "testdir" in that specific order;
    
    3) We process reference "b" first, because it is in the list before
       reference "testdir". We then issue a link operation to create
       the new reference "b" using a target path corresponding to the
       content at @valid_path, which corresponds to "o259-6-0/a".
       However we haven't yet orphanized inode 259, its name is still
       "testdir", and not "o259-6-0". The orphanization of 259 did not
       happen yet because we will process the reference named "testdir"
       for inode 257 only in the next iteration of the loop that goes
       over the list of new references.
    
    Fix the issue by having a preliminar iteration over all the new references
    at process_recorded_refs(). This iteration is responsible only for doing
    the orphanization of other inodes that have and old reference that
    conflicts with one of the new references of the inode we are currently
    processing. The emission of rename and link operations happen now in the
    next iteration of the new references.
    
    A test case for fstests will follow soon.
    
    CC: stable@vger.kernel.org # 4.4+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3dfe2dd5e16f22ea5ddefa1c1abb2c5269d73568
Author: Filipe Manana <fdmanana@suse.com>
Date:   Mon Sep 14 15:27:50 2020 +0100

    btrfs: reschedule if necessary when logging directory items
    
    commit bb56f02f26fe23798edb1b2175707419b28c752a upstream.
    
    Logging directories with many entries can take a significant amount of
    time, and in some cases monopolize a cpu/core for a long time if the
    logging task doesn't happen to block often enough.
    
    Johannes and Lu Fengqi reported test case generic/041 triggering a soft
    lockup when the kernel has CONFIG_SOFTLOCKUP_DETECTOR=y. For this test
    case we log an inode with 3002 hard links, and because the test removed
    one hard link before fsyncing the file, the inode logging causes the
    parent directory do be logged as well, which has 6004 directory items to
    log (3002 BTRFS_DIR_ITEM_KEY items plus 3002 BTRFS_DIR_INDEX_KEY items),
    so it can take a significant amount of time and trigger the soft lockup.
    
    So just make tree-log.c:log_dir_items() reschedule when necessary,
    releasing the current search path before doing so and then resume from
    where it was before the reschedule.
    
    The stack trace produced when the soft lockup happens is the following:
    
    [10480.277653] watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [xfs_io:28172]
    [10480.279418] Modules linked in: dm_thin_pool dm_persistent_data (...)
    [10480.284915] irq event stamp: 29646366
    [10480.285987] hardirqs last  enabled at (29646365): [<ffffffff85249b66>] __slab_alloc.constprop.0+0x56/0x60
    [10480.288482] hardirqs last disabled at (29646366): [<ffffffff8579b00d>] irqentry_enter+0x1d/0x50
    [10480.290856] softirqs last  enabled at (4612): [<ffffffff85a00323>] __do_softirq+0x323/0x56c
    [10480.293615] softirqs last disabled at (4483): [<ffffffff85800dbf>] asm_call_on_stack+0xf/0x20
    [10480.296428] CPU: 2 PID: 28172 Comm: xfs_io Not tainted 5.9.0-rc4-default+ #1248
    [10480.298948] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba527-rebuilt.opensuse.org 04/01/2014
    [10480.302455] RIP: 0010:__slab_alloc.constprop.0+0x19/0x60
    [10480.304151] Code: 86 e8 31 75 21 00 66 66 2e 0f 1f 84 00 00 00 (...)
    [10480.309558] RSP: 0018:ffffadbe09397a58 EFLAGS: 00000282
    [10480.311179] RAX: ffff8a495ab92840 RBX: 0000000000000282 RCX: 0000000000000006
    [10480.313242] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff85249b66
    [10480.315260] RBP: ffff8a497d04b740 R08: 0000000000000001 R09: 0000000000000001
    [10480.317229] R10: ffff8a497d044800 R11: ffff8a495ab93c40 R12: 0000000000000000
    [10480.319169] R13: 0000000000000000 R14: 0000000000000c40 R15: ffffffffc01daf70
    [10480.321104] FS:  00007fa1dc5c0e40(0000) GS:ffff8a497da00000(0000) knlGS:0000000000000000
    [10480.323559] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [10480.325235] CR2: 00007fa1dc5befb8 CR3: 0000000004f8a006 CR4: 0000000000170ea0
    [10480.327259] Call Trace:
    [10480.328286]  ? overwrite_item+0x1f0/0x5a0 [btrfs]
    [10480.329784]  __kmalloc+0x831/0xa20
    [10480.331009]  ? btrfs_get_32+0xb0/0x1d0 [btrfs]
    [10480.332464]  overwrite_item+0x1f0/0x5a0 [btrfs]
    [10480.333948]  log_dir_items+0x2ee/0x570 [btrfs]
    [10480.335413]  log_directory_changes+0x82/0xd0 [btrfs]
    [10480.336926]  btrfs_log_inode+0xc9b/0xda0 [btrfs]
    [10480.338374]  ? init_once+0x20/0x20 [btrfs]
    [10480.339711]  btrfs_log_inode_parent+0x8d3/0xd10 [btrfs]
    [10480.341257]  ? dget_parent+0x97/0x2e0
    [10480.342480]  btrfs_log_dentry_safe+0x3a/0x50 [btrfs]
    [10480.343977]  btrfs_sync_file+0x24b/0x5e0 [btrfs]
    [10480.345381]  do_fsync+0x38/0x70
    [10480.346483]  __x64_sys_fsync+0x10/0x20
    [10480.347703]  do_syscall_64+0x2d/0x70
    [10480.348891]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [10480.350444] RIP: 0033:0x7fa1dc80970b
    [10480.351642] Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 (...)
    [10480.356952] RSP: 002b:00007fffb3d081d0 EFLAGS: 00000293 ORIG_RAX: 000000000000004a
    [10480.359458] RAX: ffffffffffffffda RBX: 0000562d93d45e40 RCX: 00007fa1dc80970b
    [10480.361426] RDX: 0000562d93d44ab0 RSI: 0000562d93d45e60 RDI: 0000000000000003
    [10480.363367] RBP: 0000000000000001 R08: 0000000000000000 R09: 00007fa1dc7b2a40
    [10480.365317] R10: 0000562d93d0e366 R11: 0000000000000293 R12: 0000000000000001
    [10480.367299] R13: 0000562d93d45290 R14: 0000562d93d45e40 R15: 0000562d93d45e60
    
    Link: https://lore.kernel.org/linux-btrfs/20180713090216.GC575@fnst.localdomain/
    Reported-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    CC: stable@vger.kernel.org # 4.4+
    Tested-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: Filipe Manana <fdmanana@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3872bf3031fa91c279d73273a89240a78a17a9d4
Author: Qu Wenruo <wqu@suse.com>
Date:   Tue Jul 28 09:42:49 2020 +0800

    btrfs: tracepoints: output proper root owner for trace_find_free_extent()
    
    commit 437490fed3b0c9ae21af8f70e0f338d34560842b upstream.
    
    The current trace event always output result like this:
    
     find_free_extent: root=2(EXTENT_TREE) len=16384 empty_size=0 flags=4(METADATA)
     find_free_extent: root=2(EXTENT_TREE) len=16384 empty_size=0 flags=4(METADATA)
     find_free_extent: root=2(EXTENT_TREE) len=8192 empty_size=0 flags=1(DATA)
     find_free_extent: root=2(EXTENT_TREE) len=8192 empty_size=0 flags=1(DATA)
     find_free_extent: root=2(EXTENT_TREE) len=4096 empty_size=0 flags=1(DATA)
     find_free_extent: root=2(EXTENT_TREE) len=4096 empty_size=0 flags=1(DATA)
    
    T's saying we're allocating data extent for EXTENT tree, which is not
    even possible.
    
    It's because we always use EXTENT tree as the owner for
    trace_find_free_extent() without using the @root from
    btrfs_reserve_extent().
    
    This patch will change the parameter to use proper @root for
    trace_find_free_extent():
    
    Now it looks much better:
    
     find_free_extent: root=5(FS_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
     find_free_extent: root=5(FS_TREE) len=8192 empty_size=0 flags=1(DATA)
     find_free_extent: root=5(FS_TREE) len=16384 empty_size=0 flags=1(DATA)
     find_free_extent: root=5(FS_TREE) len=4096 empty_size=0 flags=1(DATA)
     find_free_extent: root=5(FS_TREE) len=8192 empty_size=0 flags=1(DATA)
     find_free_extent: root=5(FS_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
     find_free_extent: root=7(CSUM_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
     find_free_extent: root=2(EXTENT_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
     find_free_extent: root=1(ROOT_TREE) len=16384 empty_size=0 flags=36(METADATA|DUP)
    
    Reported-by: Hans van Kranenburg <hans@knorrie.org>
    CC: stable@vger.kernel.org # 5.4+
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 304f3c04535b5b525e4d12a9f3a8de7ba685c2ce
Author: Josef Bacik <josef@toxicpanda.com>
Date:   Tue Sep 1 08:09:01 2020 -0400

    btrfs: sysfs: init devices outside of the chunk_mutex
    
    commit ca10845a56856fff4de3804c85e6424d0f6d0cde upstream.
    
    While running btrfs/061, btrfs/073, btrfs/078, or btrfs/178 we hit the
    following lockdep splat:
    
      ======================================================
      WARNING: possible circular locking dependency detected
      5.9.0-rc3+ #4 Not tainted
      ------------------------------------------------------
      kswapd0/100 is trying to acquire lock:
      ffff96ecc22ef4a0 (&delayed_node->mutex){+.+.}-{3:3}, at: __btrfs_release_delayed_node.part.0+0x3f/0x330
    
      but task is already holding lock:
      ffffffff8dd74700 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x5/0x30
    
      which lock already depends on the new lock.
    
      the existing dependency chain (in reverse order) is:
    
      -> #3 (fs_reclaim){+.+.}-{0:0}:
             fs_reclaim_acquire+0x65/0x80
             slab_pre_alloc_hook.constprop.0+0x20/0x200
             kmem_cache_alloc+0x37/0x270
             alloc_inode+0x82/0xb0
             iget_locked+0x10d/0x2c0
             kernfs_get_inode+0x1b/0x130
             kernfs_get_tree+0x136/0x240
             sysfs_get_tree+0x16/0x40
             vfs_get_tree+0x28/0xc0
             path_mount+0x434/0xc00
             __x64_sys_mount+0xe3/0x120
             do_syscall_64+0x33/0x40
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
      -> #2 (kernfs_mutex){+.+.}-{3:3}:
             __mutex_lock+0x7e/0x7e0
             kernfs_add_one+0x23/0x150
             kernfs_create_link+0x63/0xa0
             sysfs_do_create_link_sd+0x5e/0xd0
             btrfs_sysfs_add_devices_dir+0x81/0x130
             btrfs_init_new_device+0x67f/0x1250
             btrfs_ioctl+0x1ef/0x2e20
             __x64_sys_ioctl+0x83/0xb0
             do_syscall_64+0x33/0x40
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
      -> #1 (&fs_info->chunk_mutex){+.+.}-{3:3}:
             __mutex_lock+0x7e/0x7e0
             btrfs_chunk_alloc+0x125/0x3a0
             find_free_extent+0xdf6/0x1210
             btrfs_reserve_extent+0xb3/0x1b0
             btrfs_alloc_tree_block+0xb0/0x310
             alloc_tree_block_no_bg_flush+0x4a/0x60
             __btrfs_cow_block+0x11a/0x530
             btrfs_cow_block+0x104/0x220
             btrfs_search_slot+0x52e/0x9d0
             btrfs_insert_empty_items+0x64/0xb0
             btrfs_insert_delayed_items+0x90/0x4f0
             btrfs_commit_inode_delayed_items+0x93/0x140
             btrfs_log_inode+0x5de/0x2020
             btrfs_log_inode_parent+0x429/0xc90
             btrfs_log_new_name+0x95/0x9b
             btrfs_rename2+0xbb9/0x1800
             vfs_rename+0x64f/0x9f0
             do_renameat2+0x320/0x4e0
             __x64_sys_rename+0x1f/0x30
             do_syscall_64+0x33/0x40
             entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
      -> #0 (&delayed_node->mutex){+.+.}-{3:3}:
             __lock_acquire+0x119c/0x1fc0
             lock_acquire+0xa7/0x3d0
             __mutex_lock+0x7e/0x7e0
             __btrfs_release_delayed_node.part.0+0x3f/0x330
             btrfs_evict_inode+0x24c/0x500
             evict+0xcf/0x1f0
             dispose_list+0x48/0x70
             prune_icache_sb+0x44/0x50
             super_cache_scan+0x161/0x1e0
             do_shrink_slab+0x178/0x3c0
             shrink_slab+0x17c/0x290
             shrink_node+0x2b2/0x6d0
             balance_pgdat+0x30a/0x670
             kswapd+0x213/0x4c0
             kthread+0x138/0x160
             ret_from_fork+0x1f/0x30
    
      other info that might help us debug this:
    
      Chain exists of:
        &delayed_node->mutex --> kernfs_mutex --> fs_reclaim
    
       Possible unsafe locking scenario:
    
             CPU0                    CPU1
             ----                    ----
        lock(fs_reclaim);
                                     lock(kernfs_mutex);
                                     lock(fs_reclaim);
        lock(&delayed_node->mutex);
    
       *** DEADLOCK ***
    
      3 locks held by kswapd0/100:
       #0: ffffffff8dd74700 (fs_reclaim){+.+.}-{0:0}, at: __fs_reclaim_acquire+0x5/0x30
       #1: ffffffff8dd65c50 (shrinker_rwsem){++++}-{3:3}, at: shrink_slab+0x115/0x290
       #2: ffff96ed2ade30e0 (&type->s_umount_key#36){++++}-{3:3}, at: super_cache_scan+0x38/0x1e0
    
      stack backtrace:
      CPU: 0 PID: 100 Comm: kswapd0 Not tainted 5.9.0-rc3+ #4
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014
      Call Trace:
       dump_stack+0x8b/0xb8
       check_noncircular+0x12d/0x150
       __lock_acquire+0x119c/0x1fc0
       lock_acquire+0xa7/0x3d0
       ? __btrfs_release_delayed_node.part.0+0x3f/0x330
       __mutex_lock+0x7e/0x7e0
       ? __btrfs_release_delayed_node.part.0+0x3f/0x330
       ? __btrfs_release_delayed_node.part.0+0x3f/0x330
       ? lock_acquire+0xa7/0x3d0
       ? find_held_lock+0x2b/0x80
       __btrfs_release_delayed_node.part.0+0x3f/0x330
       btrfs_evict_inode+0x24c/0x500
       evict+0xcf/0x1f0
       dispose_list+0x48/0x70
       prune_icache_sb+0x44/0x50
       super_cache_scan+0x161/0x1e0
       do_shrink_slab+0x178/0x3c0
       shrink_slab+0x17c/0x290
       shrink_node+0x2b2/0x6d0
       balance_pgdat+0x30a/0x670
       kswapd+0x213/0x4c0
       ? _raw_spin_unlock_irqrestore+0x41/0x50
       ? add_wait_queue_exclusive+0x70/0x70
       ? balance_pgdat+0x670/0x670
       kthread+0x138/0x160
       ? kthread_create_worker_on_cpu+0x40/0x40
       ret_from_fork+0x1f/0x30
    
    This happens because we are holding the chunk_mutex at the time of
    adding in a new device.  However we only need to hold the
    device_list_mutex, as we're going to iterate over the fs_devices
    devices.  Move the sysfs init stuff outside of the chunk_mutex to get
    rid of this lockdep splat.
    
    CC: stable@vger.kernel.org # 4.4.x: f3cd2c58110dad14e: btrfs: sysfs, rename device_link add/remove functions
    CC: stable@vger.kernel.org # 4.4.x
    Reported-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Josef Bacik <josef@toxicpanda.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2978cb474745b2d93c263008d265e89985706094
Author: Qu Wenruo <wqu@suse.com>
Date:   Fri Jul 24 14:46:10 2020 +0800

    btrfs: qgroup: fix qgroup meta rsv leak for subvolume operations
    
    commit e85fde5162bf1b242cbd6daf7dba0f9b457d592b upstream.
    
    [BUG]
    When quota is enabled for TEST_DEV, generic/013 sometimes fails like this:
    
      generic/013 14s ... _check_dmesg: something found in dmesg (see xfstests-dev/results//generic/013.dmesg)
    
    And with the following metadata leak:
    
      BTRFS warning (device dm-3): qgroup 0/1370 has unreleased space, type 2 rsv 49152
      ------------[ cut here ]------------
      WARNING: CPU: 2 PID: 47912 at fs/btrfs/disk-io.c:4078 close_ctree+0x1dc/0x323 [btrfs]
      Call Trace:
       btrfs_put_super+0x15/0x17 [btrfs]
       generic_shutdown_super+0x72/0x110
       kill_anon_super+0x18/0x30
       btrfs_kill_super+0x17/0x30 [btrfs]
       deactivate_locked_super+0x3b/0xa0
       deactivate_super+0x40/0x50
       cleanup_mnt+0x135/0x190
       __cleanup_mnt+0x12/0x20
       task_work_run+0x64/0xb0
       __prepare_exit_to_usermode+0x1bc/0x1c0
       __syscall_return_slowpath+0x47/0x230
       do_syscall_64+0x64/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      ---[ end trace a6cfd45ba80e4e06 ]---
      BTRFS error (device dm-3): qgroup reserved space leaked
      BTRFS info (device dm-3): disk space caching is enabled
      BTRFS info (device dm-3): has skinny extents
    
    [CAUSE]
    The qgroup preallocated meta rsv operations of that offending root are:
    
      btrfs_delayed_inode_reserve_metadata: rsv_meta_prealloc root=1370 num_bytes=131072
      btrfs_delayed_inode_reserve_metadata: rsv_meta_prealloc root=1370 num_bytes=131072
      btrfs_subvolume_reserve_metadata: rsv_meta_prealloc root=1370 num_bytes=49152
      btrfs_delayed_inode_release_metadata: convert_meta_prealloc root=1370 num_bytes=-131072
      btrfs_delayed_inode_release_metadata: convert_meta_prealloc root=1370 num_bytes=-131072
    
    It's pretty obvious that, we reserve qgroup meta rsv in
    btrfs_subvolume_reserve_metadata(), but doesn't have corresponding
    release/convert calls in btrfs_subvolume_release_metadata().
    
    This leads to the leakage.
    
    [FIX]
    To fix this bug, we should follow what we're doing in
    btrfs_delalloc_reserve_metadata(), where we reserve qgroup space, and
    add it to block_rsv->qgroup_rsv_reserved.
    
    And free the qgroup reserved metadata space when releasing the
    block_rsv.
    
    To do this, we need to change the btrfs_subvolume_release_metadata() to
    accept btrfs_root, and record the qgroup_to_release number, and call
    btrfs_qgroup_convert_reserved_meta() for it.
    
    Fixes: 733e03a0b26a ("btrfs: qgroup: Split meta rsv type into meta_prealloc and meta_pertrans")
    CC: stable@vger.kernel.org # 4.19+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4190caf5a679feeba08e4fa81adfaa878b0aba95
Author: Anand Jain <anand.jain@oracle.com>
Date:   Thu Sep 3 21:30:12 2020 +0800

    btrfs: improve device scanning messages
    
    commit 79dae17d8d44b2d15779e332180080af45df5352 upstream.
    
    Systems booting without the initramfs seems to scan an unusual kind
    of device path (/dev/root). And at a later time, the device is updated
    to the correct path. We generally print the process name and PID of the
    process scanning the device but we don't capture the same information if
    the device path is rescanned with a different pathname.
    
    The current message is too long, so drop the unnecessary UUID and add
    process name and PID.
    
    While at this also update the duplicate device warning to include the
    process name and PID so the messages are consistent
    
    CC: stable@vger.kernel.org # 4.19+
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=89721
    Signed-off-by: Anand Jain <anand.jain@oracle.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 27e786834cc47ecb89b2f22a694262f99e6cbe2e
Author: Qu Wenruo <wqu@suse.com>
Date:   Fri Jul 24 14:46:09 2020 +0800

    btrfs: qgroup: fix wrong qgroup metadata reserve for delayed inode
    
    commit b4c5d8fdfff3e2b6c4fa4a5043e8946dff500f8c upstream.
    
    For delayed inode facility, qgroup metadata is reserved for it, and
    later freed.
    
    However we're freeing more bytes than we reserved.
    In btrfs_delayed_inode_reserve_metadata():
    
            num_bytes = btrfs_calc_metadata_size(fs_info, 1);
            ...
                    ret = btrfs_qgroup_reserve_meta_prealloc(root,
                                    fs_info->nodesize, true);
                    ...
                    if (!ret) {
                            node->bytes_reserved = num_bytes;
    
    But in btrfs_delayed_inode_release_metadata():
    
            if (qgroup_free)
                    btrfs_qgroup_free_meta_prealloc(node->root,
                                    node->bytes_reserved);
            else
                    btrfs_qgroup_convert_reserved_meta(node->root,
                                    node->bytes_reserved);
    
    This means, we're always releasing more qgroup metadata rsv than we have
    reserved.
    
    This won't trigger selftest warning, as btrfs qgroup metadata rsv has
    extra protection against cases like quota enabled half-way.
    
    But we still need to fix this problem any way.
    
    This patch will use the same num_bytes for qgroup metadata rsv so we
    could handle it correctly.
    
    Fixes: f218ea6c4792 ("btrfs: delayed-inode: Remove wrong qgroup meta reservation calls")
    CC: stable@vger.kernel.org # 4.19+
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90e8bbe6218a875a5bad5964452deedbbba98b2c
Author: Xiang Chen <chenxiang66@hisilicon.com>
Date:   Tue Sep 22 21:11:06 2020 +0800

    PM: runtime: Remove link state checks in rpm_get/put_supplier()
    
    commit d12544fb2aa9944b180c35914031a8384ab082c1 upstream.
    
    To support runtime PM for hisi SAS driver (the driver is in directory
    drivers/scsi/hisi_sas), we add device link between scsi_device->sdev_gendev
    (consumer device) and hisi_hba->dev(supplier device) with flags
    DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE.
    
    After runtime suspended consumers and supplier, unload the dirver which
    causes a hung.
    
    We found that it called function device_release_driver_internal() to
    release the supplier device (hisi_hba->dev), as the device link was
    busy, it set the device link state to DL_STATE_SUPPLIER_UNBIND, and
    then it called device_release_driver_internal() to release the consumer
    device (scsi_device->sdev_gendev).
    
    Then it would try to call pm_runtime_get_sync() to resume the consumer
    device, but because consumer-supplier relation existed, it would try
    to resume the supplier first, but as the link state was already
    DL_STATE_SUPPLIER_UNBIND, so it skipped resuming the supplier and only
    resumed the consumer which hanged (it sends IOs to resume scsi_device
    while the SAS controller is suspended).
    
    Simple flow is as follows:
    
    device_release_driver_internal -> (supplier device)
        if device_links_busy ->
            device_links_unbind_consumers ->
                ...
                WRITE_ONCE(link->status, DL_STATE_SUPPLIER_UNBIND)
                device_release_driver_internal (consumer device)
        pm_runtime_get_sync -> (consumer device)
            ...
            __rpm_callback ->
                rpm_get_suppliers ->
                    if link->state == DL_STATE_SUPPLIER_UNBIND -> skip the action of resuming the supplier
                    ...
        pm_runtime_clean_up_links
        ...
    
    Correct suspend/resume ordering between a supplier device and its consumer
    devices (resume the supplier device before resuming consumer devices, and
    suspend consumer devices before suspending the supplier device) should be
    guaranteed by runtime PM, but the state checks in rpm_get_supplier() and
    rpm_put_supplier() break this rule, so remove them.
    
    Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
    [ rjw: Subject and changelog edits ]
    Cc: All applicable <stable@vger.kernel.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 931d55334a46434af4656d6d61491c080739e6de
Author: Quinn Tran <qutran@marvell.com>
Date:   Tue Sep 29 03:21:50 2020 -0700

    scsi: qla2xxx: Fix crash on session cleanup with unload
    
    commit 50457dab670f396557e60c07f086358460876353 upstream.
    
    On unload, session cleanup prematurely gave the signal for driver unload
    path to advance.
    
    Link: https://lore.kernel.org/r/20200929102152.32278-6-njavali@marvell.com
    Fixes: 726b85487067 ("qla2xxx: Add framework for async fabric discovery")
    Cc: stable@vger.kernel.org
    Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
    Signed-off-by: Quinn Tran <qutran@marvell.com>
    Signed-off-by: Nilesh Javali <njavali@marvell.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f4f250c7e7ec7f8ac4588eeeb3aef2739bbe6dbf
Author: Arun Easi <aeasi@marvell.com>
Date:   Tue Sep 29 03:21:49 2020 -0700

    scsi: qla2xxx: Fix reset of MPI firmware
    
    commit 3e6efab865ac943f4ec43913eb665695737112b0 upstream.
    
    Normally, the MPI firmware is reset when an MPI dump is collected.  If an
    unsaved MPI dump exists in the driver, though, an alternate mechanism is
    used. This mechanism, which was not fully correct, is not recommended and
    instead an MPI dump template walk is suggested to perform the MPI reset.
    
    To allow for the MPI dump template walk, extra space is reserved in the MPI
    dump buffer which gets used only when there is already an MPI dump in
    place.
    
    Link: https://lore.kernel.org/r/20200929102152.32278-5-njavali@marvell.com
    Fixes: cbb01c2f2f63 ("scsi: qla2xxx: Fix MPI failure AEN (8200) handling")
    Cc: stable@vger.kernel.org
    Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
    Signed-off-by: Arun Easi <aeasi@marvell.com>
    Signed-off-by: Nilesh Javali <njavali@marvell.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 26474cdeb96eaf2cf3b9ae00e93b0bc634ff1f7c
Author: Arun Easi <aeasi@marvell.com>
Date:   Tue Sep 29 03:21:48 2020 -0700

    scsi: qla2xxx: Fix MPI reset needed message
    
    commit 7a6cdbd5e87515ebf6231b762ad903c7cff87b9c upstream.
    
    When printing the message:
    
      "MPI Heartbeat stop. MPI reset is not needed.."
    
    ..the wrong register was checked leading to always printing that MPI reset
    is not needed, even when it is needed. Fix the MPI reset message.
    
    Link: https://lore.kernel.org/r/20200929102152.32278-4-njavali@marvell.com
    Fixes: cbb01c2f2f63 ("scsi: qla2xxx: Fix MPI failure AEN (8200) handling")
    Cc: stable@vger.kernel.org
    Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
    Signed-off-by: Arun Easi <aeasi@marvell.com>
    Signed-off-by: Nilesh Javali <njavali@marvell.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f242539e2944835b72a84aa2d421f66dc6543c2b
Author: Helge Deller <deller@gmx.de>
Date:   Thu Oct 22 11:00:05 2020 +0200

    scsi: mptfusion: Fix null pointer dereferences in mptscsih_remove()
    
    commit 2f4843b172c2c0360ee7792ad98025fae7baefde upstream.
    
    The mptscsih_remove() function triggers a kernel oops if the Scsi_Host
    pointer (ioc->sh) is NULL, as can be seen in this syslog:
    
     ioc0: LSI53C1030 B2: Capabilities={Initiator,Target}
     Begin: Waiting for root file system ...
     scsi host2: error handler thread failed to spawn, error = -4
     mptspi: ioc0: WARNING - Unable to register controller with SCSI subsystem
     Backtrace:
      [<000000001045b7cc>] mptspi_probe+0x248/0x3d0 [mptspi]
      [<0000000040946470>] pci_device_probe+0x1ac/0x2d8
      [<0000000040add668>] really_probe+0x1bc/0x988
      [<0000000040ade704>] driver_probe_device+0x160/0x218
      [<0000000040adee24>] device_driver_attach+0x160/0x188
      [<0000000040adef90>] __driver_attach+0x144/0x320
      [<0000000040ad7c78>] bus_for_each_dev+0xd4/0x158
      [<0000000040adc138>] driver_attach+0x4c/0x80
      [<0000000040adb3ec>] bus_add_driver+0x3e0/0x498
      [<0000000040ae0130>] driver_register+0xf4/0x298
      [<00000000409450c4>] __pci_register_driver+0x78/0xa8
      [<000000000007d248>] mptspi_init+0x18c/0x1c4 [mptspi]
    
    This patch adds the necessary NULL-pointer checks.  Successfully tested on
    a HP C8000 parisc workstation with buggy SCSI drives.
    
    Link: https://lore.kernel.org/r/20201022090005.GA9000@ls3530.fritz.box
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e1043d8b6f5fb8938981d4c1256b4ee068df1538
Author: Kees Cook <keescook@chromium.org>
Date:   Fri Oct 2 10:38:13 2020 -0700

    fs/kernel_read_file: Remove FIRMWARE_PREALLOC_BUFFER enum
    
    commit c307459b9d1fcb8bbf3ea5a4162979532322ef77 upstream.
    
    FIRMWARE_PREALLOC_BUFFER is a "how", not a "what", and confuses the LSMs
    that are interested in filtering between types of things. The "how"
    should be an internal detail made uninteresting to the LSMs.
    
    Fixes: a098ecd2fa7d ("firmware: support loading into a pre-allocated buffer")
    Fixes: fd90bc559bfb ("ima: based on policy verify firmware signatures (pre-allocated buffer)")
    Fixes: 4f0496d8ffa3 ("ima: based on policy warn about loading firmware (pre-allocated buffer)")
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    Acked-by: Scott Branden <scott.branden@broadcom.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201002173828.2099543-2-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7a5b7644d441e1e137d25bb2b14c5ab20fd88895
Author: Martin Fuzzey <martin.fuzzey@flowbird.group>
Date:   Wed Sep 30 10:36:46 2020 +0200

    w1: mxc_w1: Fix timeout resolution problem leading to bus error
    
    commit c9723750a699c3bd465493ac2be8992b72ccb105 upstream.
    
    On my platform (i.MX53) bus access sometimes fails with
            w1_search: max_slave_count 64 reached, will continue next search.
    
    The reason is the use of jiffies to implement a 200us timeout in
    mxc_w1_ds2_touch_bit().
    On some platforms the jiffies timer resolution is insufficient for this.
    
    Fix by replacing jiffies by ktime_get().
    
    For consistency apply the same change to the other use of jiffies in
    mxc_w1_ds2_reset_bus().
    
    Fixes: f80b2581a706 ("w1: mxc_w1: Optimize mxc_w1_ds2_touch_bit()")
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group>
    Link: https://lore.kernel.org/r/1601455030-6607-1-git-send-email-martin.fuzzey@flowbird.group
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0c399a6a772cb7e7c19806da3be21cb8780700a1
Author: Jens Axboe <axboe@kernel.dk>
Date:   Thu Oct 15 10:13:07 2020 -0600

    io-wq: assign NUMA node locality if appropriate
    
    commit a8b595b22d31f83b715511f59012f152a269d83b upstream.
    
    There was an assumption that kthread_create_on_node() would properly set
    NUMA affinities in terms of CPUs allowed, but it doesn't. Make sure we
    do this when creating an io-wq context on NUMA.
    
    Cc: stable@vger.kernel.org
    Stefan Metzmacher <metze@samba.org>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ebabf9be905756986361f47b5a2600f6ef5e7826
Author: Wei Huang <wei.huang2@amd.com>
Date:   Sun Oct 18 22:57:41 2020 -0500

    acpi-cpufreq: Honor _PSD table setting on new AMD CPUs
    
    commit 5368512abe08a28525d9b24abbfc2a72493e8dba upstream.
    
    acpi-cpufreq has a old quirk that overrides the _PSD table supplied by
    BIOS on AMD CPUs. However the _PSD table of new AMD CPUs (Family 19h+)
    now accurately reports the P-state dependency of CPU cores. Hence this
    quirk needs to be fixed in order to support new CPUs' frequency control.
    
    Fixes: acd316248205 ("acpi-cpufreq: Add quirk to disable _PSD usage on all AMD CPUs")
    Signed-off-by: Wei Huang <wei.huang2@amd.com>
    [ rjw: Subject edit ]
    Cc: 3.10+ <stable@vger.kernel.org> # 3.10+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 658433100603c5f01dd50b1636e2c74891d100a8
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Mon Oct 5 19:13:46 2020 +0200

    ACPI: EC: PM: Drop ec_no_wakeup check from acpi_ec_dispatch_gpe()
    
    commit e0e9ce390d7bc6a705653d4a8aa4ea92c9a65e53 upstream.
    
    It turns out that in some cases there are EC events to flush in
    acpi_ec_dispatch_gpe() even though the ec_no_wakeup kernel parameter
    is set and the EC GPE is disabled while sleeping, so drop the
    ec_no_wakeup check that prevents those events from being processed
    from acpi_ec_dispatch_gpe().
    
    Reported-by: Todd Brandt <todd.e.brandt@linux.intel.com>
    Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f1ab870b7522a64da732e997345ef83c2488f1a1
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Mon Oct 5 19:13:15 2020 +0200

    ACPI: EC: PM: Flush EC work unconditionally after wakeup
    
    commit 5e92442bb4121562231e6daf8a2d1306cb5f8805 upstream.
    
    Commit 607b9df63057 ("ACPI: EC: PM: Avoid flushing EC work when EC
    GPE is inactive") has been reported to cause some power button wakeup
    events to be missed on some systems, so modify acpi_ec_dispatch_gpe()
    to call acpi_ec_flush_work() unconditionally to effectively reverse
    the changes made by that commit.
    
    Also note that the problem which prompted commit 607b9df63057 is not
    reproducible any more on the affected machine.
    
    Fixes: 607b9df63057 ("ACPI: EC: PM: Avoid flushing EC work when EC GPE is inactive")
    Reported-by: Raymond Tan <raymond.tan@intel.com>
    Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c56d455ab60be27ab6b75ebcb95350f8c483b88b
Author: Lukas Wunner <lukas@wunner.de>
Date:   Fri Oct 2 07:10:12 2020 +0200

    PCI/ACPI: Whitelist hotplug ports for D3 if power managed by ACPI
    
    commit c6e331312ebfb52b7186e5d82d517d68b4d2f2d8 upstream.
    
    Recent laptops with dual AMD GPUs fail to suspend the discrete GPU, thus
    causing lockups on system sleep and high power consumption at runtime.
    The discrete GPU would normally be suspended to D3cold by turning off
    ACPI _PR3 Power Resources of the Root Port above the GPU.
    
    However on affected systems, the Root Port is hotplug-capable and
    pci_bridge_d3_possible() only allows hotplug ports to go to D3 if they
    belong to a Thunderbolt device or if the Root Port possesses a
    "HotPlugSupportInD3" ACPI property.  Neither is the case on affected
    laptops.  The reason for whitelisting only specific, known to work
    hotplug ports for D3 is that there have been reports of SkyLake Xeon-SP
    systems raising Hardware Error NMIs upon suspending their hotplug ports:
    https://lore.kernel.org/linux-pci/20170503180426.GA4058@otc-nc-03/
    
    But if a hotplug port is power manageable by ACPI (as can be detected
    through presence of Power Resources and corresponding _PS0 and _PS3
    methods) then it ought to be safe to suspend it to D3.  To this end,
    amend acpi_pci_bridge_d3() to whitelist such ports for D3.
    
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1222
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1252
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1304
    Reported-and-tested-by: Arthur Borsboom <arthurborsboom@gmail.com>
    Reported-and-tested-by: matoro <matoro@airmail.cc>
    Reported-by: Aaron Zakhrov <aaron.zakhrov@gmail.com>
    Reported-by: Michal Rostecki <mrostecki@suse.com>
    Reported-by: Shai Coleman <git@shaicoleman.com>
    Signed-off-by: Lukas Wunner <lukas@wunner.de>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: 5.4+ <stable@vger.kernel.org> # 5.4+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 62bf715007b9e7911dd0d74ac3ff01a7bbb22ff7
Author: Jamie Iles <jamie@nuviainc.com>
Date:   Mon Oct 12 14:04:46 2020 +0100

    ACPI: debug: don't allow debugging when ACPI is disabled
    
    commit 0fada277147ffc6d694aa32162f51198d4f10d94 upstream.
    
    If ACPI is disabled then loading the acpi_dbg module will result in the
    following splat when lock debugging is enabled.
    
      DEBUG_LOCKS_WARN_ON(lock->magic != lock)
      WARNING: CPU: 0 PID: 1 at kernel/locking/mutex.c:938 __mutex_lock+0xa10/0x1290
      Kernel panic - not syncing: panic_on_warn set ...
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc8+ #103
      Hardware name: linux,dummy-virt (DT)
      Call trace:
       dump_backtrace+0x0/0x4d8
       show_stack+0x34/0x48
       dump_stack+0x174/0x1f8
       panic+0x360/0x7a0
       __warn+0x244/0x2ec
       report_bug+0x240/0x398
       bug_handler+0x50/0xc0
       call_break_hook+0x160/0x1d8
       brk_handler+0x30/0xc0
       do_debug_exception+0x184/0x340
       el1_dbg+0x48/0xb0
       el1_sync_handler+0x170/0x1c8
       el1_sync+0x80/0x100
       __mutex_lock+0xa10/0x1290
       mutex_lock_nested+0x6c/0xc0
       acpi_register_debugger+0x40/0x88
       acpi_aml_init+0xc4/0x114
       do_one_initcall+0x24c/0xb10
       kernel_init_freeable+0x690/0x728
       kernel_init+0x20/0x1e8
       ret_from_fork+0x10/0x18
    
    This is because acpi_debugger.lock has not been initialized as
    acpi_debugger_init() is not called when ACPI is disabled.  Fail module
    loading to avoid this and any subsequent problems that might arise by
    trying to debug AML when ACPI is disabled.
    
    Fixes: 8cfb0cdf07e2 ("ACPI / debugger: Add IO interface to access debugger functionalities")
    Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
    Signed-off-by: Jamie Iles <jamie@nuviainc.com>
    Cc: 4.10+ <stable@vger.kernel.org> # 4.10+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ebf5e9972a47dcbefbc7b03e0d24b966b05d1477
Author: Alex Hung <alex.hung@canonical.com>
Date:   Sun Sep 13 16:34:03 2020 -0600

    ACPI: video: use ACPI backlight for HP 635 Notebook
    
    commit b226faab4e7890bbbccdf794e8b94276414f9058 upstream.
    
    The default backlight interface is AMD's radeon_bl0 which does not
    work on this system, so use the ACPI backlight interface on it
    instead.
    
    BugLink: https://bugs.launchpad.net/bugs/1894667
    Cc: All applicable <stable@vger.kernel.org>
    Signed-off-by: Alex Hung <alex.hung@canonical.com>
    [ rjw: Changelog edits ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f7a79afb7a5dd4b7653c2dc3634707d41ec4565e
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sun Sep 27 22:50:42 2020 +0100

    ACPI / extlog: Check for RDMSR failure
    
    commit 7cecb47f55e00282f972a1e0b09136c8cd938221 upstream.
    
    extlog_init() uses rdmsrl() to read an MSR, which on older CPUs
    provokes a error message at boot:
    
        unchecked MSR access error: RDMSR from 0x179 at rIP: 0xcd047307 (native_read_msr+0x7/0x40)
    
    Use rdmsrl_safe() instead, and return -ENODEV if it fails.
    
    Reported-by: jim@photojim.ca
    References: https://bugs.debian.org/971058
    Cc: All applicable <stable@vger.kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 57c75814e30f63df683b521ec6dc205da9dfcca1
Author: dmitry.torokhov@gmail.com <dmitry.torokhov@gmail.com>
Date:   Sun Oct 4 22:11:25 2020 -0700

    ACPI: button: fix handling lid state changes when input device closed
    
    commit 21988a8e51479ceffe7b0568b170effabb708dfe upstream.
    
    The original intent of 84d3f6b76447 was to delay evaluating lid state until
    all drivers have been loaded, with input device being opened from userspace
    serving as a signal for this condition. Let's ensure that state updates
    happen even if userspace closed (or in the future inhibited) input device.
    
    Note that if we go through suspend/resume cycle we assume the system has
    been fully initialized even if LID input device has not been opened yet.
    
    This has a side-effect of fixing access to input->users outside of
    input->mutex protections by the way of eliminating said accesses and using
    driver private flag.
    
    Fixes: 84d3f6b76447 ("ACPI / button: Delay acpi_lid_initialize_state() until first user space open")
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Cc: 4.15+ <stable@vger.kernel.org> # 4.15+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 42c2d31f68a3da620eb2a1a157645caa83821d83
Author: Ashish Sangwan <ashishsangwan2@gmail.com>
Date:   Mon Oct 5 02:22:43 2020 -0700

    NFS: fix nfs_path in case of a rename retry
    
    commit 247db73560bc3e5aef6db50c443c3c0db115bc93 upstream.
    
    We are generating incorrect path in case of rename retry because
    we are restarting from wrong dentry. We should restart from the
    dentry which was received in the call to nfs_path.
    
    CC: stable@vger.kernel.org
    Signed-off-by: Ashish Sangwan <ashishsangwan2@gmail.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3b224e0d43223bca7673d2a25c6861bb1b862297
Author: Hanjun Guo <guohanjun@huawei.com>
Date:   Fri Sep 18 17:13:28 2020 +0800

    ACPI: configfs: Add missing config_item_put() to fix refcount leak
    
    commit 9a2e849fb6de471b82d19989a7944d3b7671793c upstream.
    
    config_item_put() should be called in the drop_item callback, to
    decrement refcount for the config item.
    
    Fixes: 772bf1e2878ec ("ACPI: configfs: Unload SSDT on configfs entry removal")
    Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
    [ rjw: Subject edit ]
    Cc: 4.13+ <stable@vger.kernel.org> # 4.13+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 36ed9e604215f58cec0381ca5fcc6da05f2d87ca
Author: Jan Kara <jack@suse.cz>
Date:   Fri Sep 4 10:58:51 2020 +0200

    fs: Don't invalidate page buffers in block_write_full_page()
    
    commit 6dbf7bb555981fb5faf7b691e8f6169fc2b2e63b upstream.
    
    If block_write_full_page() is called for a page that is beyond current
    inode size, it will truncate page buffers for the page and return 0.
    This logic has been added in 2.5.62 in commit 81eb69062588 ("fix ext3
    BUG due to race with truncate") in history.git tree to fix a problem
    with ext3 in data=ordered mode. This particular problem doesn't exist
    anymore because ext3 is long gone and ext4 handles ordered data
    differently. Also normally buffers are invalidated by truncate code and
    there's no need to specially handle this in ->writepage() code.
    
    This invalidation of page buffers in block_write_full_page() is causing
    issues to filesystems (e.g. ext4 or ocfs2) when block device is shrunk
    under filesystem's hands and metadata buffers get discarded while being
    tracked by the journalling layer. Although it is obviously "not
    supported" it can cause kernel crashes like:
    
    [ 7986.689400] BUG: unable to handle kernel NULL pointer dereference at
    +0000000000000008
    [ 7986.697197] PGD 0 P4D 0
    [ 7986.699724] Oops: 0002 [#1] SMP PTI
    [ 7986.703200] CPU: 4 PID: 203778 Comm: jbd2/dm-3-8 Kdump: loaded Tainted: G
    +O     --------- -  - 4.18.0-147.5.0.5.h126.eulerosv2r9.x86_64 #1
    [ 7986.716438] Hardware name: Huawei RH2288H V3/BC11HGSA0, BIOS 1.57 08/11/2015
    [ 7986.723462] RIP: 0010:jbd2_journal_grab_journal_head+0x1b/0x40 [jbd2]
    ...
    [ 7986.810150] Call Trace:
    [ 7986.812595]  __jbd2_journal_insert_checkpoint+0x23/0x70 [jbd2]
    [ 7986.818408]  jbd2_journal_commit_transaction+0x155f/0x1b60 [jbd2]
    [ 7986.836467]  kjournald2+0xbd/0x270 [jbd2]
    
    which is not great. The crash happens because bh->b_private is suddently
    NULL although BH_JBD flag is still set (this is because
    block_invalidatepage() cleared BH_Mapped flag and subsequent bh lookup
    found buffer without BH_Mapped set, called init_page_buffers() which has
    rewritten bh->b_private). So just remove the invalidation in
    block_write_full_page().
    
    Note that the buffer cache invalidation when block device changes size
    is already careful to avoid similar problems by using
    invalidate_mapping_pages() which skips busy buffers so it was only this
    odd block_write_full_page() behavior that could tear down bdev buffers
    under filesystem's hands.
    
    Reported-by: Ye Bin <yebin10@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    CC: stable@vger.kernel.org
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bdacedeb2f4d55aca27ff9e69dcad8f8d19328e0
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Tue Jul 28 13:22:08 2020 +0200

    media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
    
    commit 93df48d37c3f03886d84831992926333e7810640 upstream.
    
    uvc_ctrl_add_info() calls uvc_ctrl_get_flags() which will override
    the fixed-up flags set by uvc_ctrl_fixup_xu_info().
    
    uvc_ctrl_init_xu_ctrl() already calls uvc_ctrl_get_flags() before
    calling uvc_ctrl_add_info(), so the uvc_ctrl_get_flags() call in
    uvc_ctrl_add_info() is not necessary for xu ctrls.
    
    This commit moves the uvc_ctrl_get_flags() call for normal controls
    from uvc_ctrl_add_info() to uvc_ctrl_init_ctrl(), so that we no longer
    call uvc_ctrl_get_flags() twice for xu controls and so that we no longer
    override the fixed-up flags set by uvc_ctrl_fixup_xu_info().
    
    This fixes the xu motor controls not working properly on a Logitech
    046d:08cc, and presumably also on the other Logitech models which have
    a quirk for this in the uvc_ctrl_fixup_xu_info() function.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bc8a557e7f1dd71bdba49fee64a68d4682b9e1fd
Author: Steve Foreman <foremans@google.com>
Date:   Fri Oct 2 16:35:38 2020 +0000

    hwmon: (pmbus/max34440) Fix OC fault limits
    
    commit 2b52278150c49559a472f2d6dd66f6f3b405378e upstream.
    
    The max34* family have the IOUT_OC_WARN_LIMIT and IOUT_OC_CRIT_LIMIT
    registers swapped.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Steve Foreman <foremans@google.com>
    [groeck: Updated subject, use C comment style, tab after defines]
    [groeck: Added missing break; statements (by alexandru.ardelean@analog.com)]
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9767f1d6eabcf4f339ddb2fc49f2d44b68a1d91d
Author: Marek Behún <marek.behun@nic.cz>
Date:   Fri Sep 18 00:32:58 2020 +0200

    leds: bcm6328, bcm6358: use devres LED registering function
    
    commit ff5c89d44453e7ad99502b04bf798a3fc32c758b upstream.
    
    These two drivers do not provide remove method and use devres for
    allocation of other resources, yet they use led_classdev_register
    instead of the devres variant, devm_led_classdev_register.
    
    Fix this.
    
    Signed-off-by: Marek Behún <marek.behun@nic.cz>
    Cc: Álvaro Fernández Rojas <noltari@gmail.com>
    Cc: Kevin Cernekee <cernekee@gmail.com>
    Cc: Jaedon Shin <jaedon.shin@gmail.com>
    Signed-off-by: Pavel Machek <pavel@ucw.cz>
    Cc: stable@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3a38676b199daca9ffe16e8b514a258c82f374a5
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Aug 17 09:00:00 2020 +0200

    extcon: ptn5150: Fix usage of atomic GPIO with sleeping GPIO chips
    
    commit 6aaad58c872db062f7ea2761421ca748bd0931cc upstream.
    
    The driver uses atomic version of gpiod_set_value() without any real
    reason.  It is called in a workqueue under mutex so it could sleep
    there.  Changing it to "can_sleep" flavor allows to use the driver with
    all GPIO chips.
    
    Fixes: 4ed754de2d66 ("extcon: Add support for ptn5150 extcon driver")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Reviewed-by: Vijai Kumar K <vijaikumar.kanagarajan@gmail.com>
    Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b31eb1d1bf62568a3ac17426d34553a99b970deb
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Tue Sep 1 17:27:03 2020 +0200

    spi: sprd: Release DMA channel also on probe deferral
    
    commit 687a2e76186dcfa42f22c14b655c3fb159839e79 upstream.
    
    If dma_request_chan() for TX channel fails with EPROBE_DEFER, the RX
    channel would not be released and on next re-probe it would be requested
    second time.
    
    Fixes: 386119bc7be9 ("spi: sprd: spi: sprd: Add DMA mode support")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Acked-by: Chunyan Zhang <zhang.lyra@gmail.com>
    Link: https://lore.kernel.org/r/20200901152713.18629-1-krzk@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f3a8fc35eef9b15c17c3f22272488c5445d328ee
Author: Chuanhong Guo <gch981213@gmail.com>
Date:   Tue Sep 22 19:49:02 2020 +0800

    spi: spi-mtk-nor: fix timeout calculation overflow
    
    commit 4cafaddedb5fbef9531202ee547784409fd0de33 upstream.
    
    CLK_TO_US macro is used to calculate potential transfer time for various
    timeout handling. However it overflows on transfer bigger than 512 bytes
    because it first did (len * 8 * 1000000).
    This controller typically operates at 45MHz. This patch did 2 things:
    1. calculate clock / 1000000 first
    2. add a 4M transfer size cap so that the final timeout in DMA reading
       doesn't overflow
    
    Fixes: 881d1ee9fe81f ("spi: add support for mediatek spi-nor controller")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
    Link: https://lore.kernel.org/r/20200922114905.2942859-1-gch981213@gmail.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit efecc0e9e2a1d23985b16b6f533bcf2e45e544b0
Author: Kim Phillips <kim.phillips@amd.com>
Date:   Tue Sep 8 16:47:38 2020 -0500

    perf/x86/amd/ibs: Fix raw sample data accumulation
    
    commit 36e1be8ada994d509538b3b1d0af8b63c351e729 upstream.
    
    Neither IbsBrTarget nor OPDATA4 are populated in IBS Fetch mode.
    Don't accumulate them into raw sample user data in that case.
    
    Also, in Fetch mode, add saving the IBS Fetch Control Extended MSR.
    
    Technically, there is an ABI change here with respect to the IBS raw
    sample data format, but I don't see any perf driver version information
    being included in perf.data file headers, but, existing users can detect
    whether the size of the sample record has reduced by 8 bytes to
    determine whether the IBS driver has this fix.
    
    Fixes: 904cb3677f3a ("perf/x86/amd/ibs: Update IBS MSRs and feature definitions")
    Reported-by: Stephane Eranian <stephane.eranian@google.com>
    Signed-off-by: Kim Phillips <kim.phillips@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20200908214740.18097-6-kim.phillips@amd.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9afe993184dcf751b5cf57a2142b8dde9c305115
Author: Kim Phillips <kim.phillips@amd.com>
Date:   Tue Sep 8 16:47:37 2020 -0500

    perf/x86/amd/ibs: Don't include randomized bits in get_ibs_op_count()
    
    commit 680d69635005ba0e58fe3f4c52fc162b8fc743b0 upstream.
    
    get_ibs_op_count() adds hardware's current count (IbsOpCurCnt) bits
    to its count regardless of hardware's valid status.
    
    According to the PPR for AMD Family 17h Model 31h B0 55803 Rev 0.54,
    if the counter rolls over, valid status is set, and the lower 7 bits
    of IbsOpCurCnt are randomized by hardware.
    
    Don't include those bits in the driver's event count.
    
    Fixes: 8b1e13638d46 ("perf/x86-ibs: Fix usage of IBS op current count")
    Signed-off-by: Kim Phillips <kim.phillips@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c21983394c9b116f5c20439e04be21a713bf38cd
Author: Kim Phillips <kim.phillips@amd.com>
Date:   Tue Sep 8 16:47:34 2020 -0500

    perf/amd/uncore: Set all slices and threads to restore perf stat -a behaviour
    
    commit c8fe99d0701fec9fb849ec880a86bc5592530496 upstream.
    
    Commit 2f217d58a8a0 ("perf/x86/amd/uncore: Set the thread mask for
    F17h L3 PMCs") inadvertently changed the uncore driver's behaviour
    wrt perf tool invocations with or without a CPU list, specified with
    -C / --cpu=.
    
    Change the behaviour of the driver to assume the former all-cpu (-a)
    case, which is the more commonly desired default.  This fixes
    '-a -A' invocations without explicit cpu lists (-C) to not count
    L3 events only on behalf of the first thread of the first core
    in the L3 domain.
    
    BEFORE:
    
    Activity performed by the first thread of the last core (CPU#43) in
    CPU#40's L3 domain is not reported by CPU#40:
    
    sudo perf stat -a -A -e l3_request_g1.caching_l3_cache_accesses taskset -c 43 perf bench mem memcpy -s 32mb -l 100 -f default
    ...
    CPU36                 21,835      l3_request_g1.caching_l3_cache_accesses
    CPU40                 87,066      l3_request_g1.caching_l3_cache_accesses
    CPU44                 17,360      l3_request_g1.caching_l3_cache_accesses
    ...
    
    AFTER:
    
    The L3 domain activity is now reported by CPU#40:
    
    sudo perf stat -a -A -e l3_request_g1.caching_l3_cache_accesses taskset -c 43 perf bench mem memcpy -s 32mb -l 100 -f default
    ...
    CPU36                354,891      l3_request_g1.caching_l3_cache_accesses
    CPU40              1,780,870      l3_request_g1.caching_l3_cache_accesses
    CPU44                315,062      l3_request_g1.caching_l3_cache_accesses
    ...
    
    Fixes: 2f217d58a8a0 ("perf/x86/amd/uncore: Set the thread mask for F17h L3 PMCs")
    Signed-off-by: Kim Phillips <kim.phillips@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20200908214740.18097-2-kim.phillips@amd.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 595d78c5438bdcbda8dbf85465a0014c55afb2ae
Author: Kim Phillips <kim.phillips@amd.com>
Date:   Tue Sep 8 16:47:35 2020 -0500

    perf/x86/amd: Fix sampling Large Increment per Cycle events
    
    commit 26e52558ead4b39c0e0fe7bf08f82f5a9777a412 upstream.
    
    Commit 5738891229a2 ("perf/x86/amd: Add support for Large Increment
    per Cycle Events") mistakenly zeroes the upper 16 bits of the count
    in set_period().  That's fine for counting with perf stat, but not
    sampling with perf record when only Large Increment events are being
    sampled.  To enable sampling, we sign extend the upper 16 bits of the
    merged counter pair as described in the Family 17h PPRs:
    
    "Software wanting to preload a value to a merged counter pair writes the
    high-order 16-bit value to the low-order 16 bits of the odd counter and
    then writes the low-order 48-bit value to the even counter. Reading the
    even counter of the merged counter pair returns the full 64-bit value."
    
    Fixes: 5738891229a2 ("perf/x86/amd: Add support for Large Increment per Cycle Events")
    Signed-off-by: Kim Phillips <kim.phillips@amd.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=206537
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fc42da3d03186031b690b7fe8b1ab6bc1e98f342
Author: Kan Liang <kan.liang@linux.intel.com>
Date:   Mon Sep 28 06:47:26 2020 -0700

    perf/x86/intel: Fix Ice Lake event constraint table
    
    commit 010cb00265f150bf82b23c02ad1fb87ce5c781e1 upstream.
    
    An error occues when sampling non-PEBS INST_RETIRED.PREC_DIST(0x01c0)
    event.
    
      perf record -e cpu/event=0xc0,umask=0x01/ -- sleep 1
      Error:
      The sys_perf_event_open() syscall returned with 22 (Invalid argument)
      for event (cpu/event=0xc0,umask=0x01/).
      /bin/dmesg | grep -i perf may provide additional information.
    
    The idxmsk64 of the event is set to 0. The event never be successfully
    scheduled.
    
    The event should be limit to the fixed counter 0.
    
    Fixes: 6017608936c1 ("perf/x86/intel: Add Icelake support")
    Reported-by: Yi, Ammy <ammy.yi@intel.com>
    Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/20200928134726.13090-1-kan.liang@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 13651b944e6601f4c21b6bf0bfc5e3e20a992bf6
Author: Andy Lutomirski <luto@kernel.org>
Date:   Wed Aug 26 10:00:46 2020 -0700

    selftests/x86/fsgsbase: Test PTRACE_PEEKUSER for GSBASE with invalid LDT GS
    
    commit 1b9abd1755ad947d7c9913e92e7837b533124c90 upstream.
    
    This tests commit:
    
      8ab49526b53d ("x86/fsgsbase/64: Fix NULL deref in 86_fsgsbase_read_task")
    
    Unpatched kernels will OOPS.
    
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/c618ae86d1f757e01b1a8e79869f553cb88acf9a.1598461151.git.luto@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9e00a4f447a53a0b90de1fc22ffbefe3126e2559
Author: Jann Horn <jannh@google.com>
Date:   Mon Oct 5 03:44:01 2020 +0200

    seccomp: Make duplicate listener detection non-racy
    
    commit dfe719fef03d752f1682fa8aeddf30ba501c8555 upstream.
    
    Currently, init_listener() tries to prevent adding a filter with
    SECCOMP_FILTER_FLAG_NEW_LISTENER if one of the existing filters already
    has a listener. However, this check happens without holding any lock that
    would prevent another thread from concurrently installing a new filter
    (potentially with a listener) on top of the ones we already have.
    
    Theoretically, this is also a data race: The plain load from
    current->seccomp.filter can race with concurrent writes to the same
    location.
    
    Fix it by moving the check into the region that holds the siglock to guard
    against concurrent TSYNC.
    
    (The "Fixes" tag points to the commit that introduced the theoretical
    data race; concurrent installation of another filter with TSYNC only
    became possible later, in commit 51891498f2da ("seccomp: allow TSYNC and
    USER_NOTIF together").)
    
    Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
    Reviewed-by: Tycho Andersen <tycho@tycho.pizza>
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20201005014401.490175-1-jannh@google.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a4b13128d33ea8bdb9b1f2f6dbf1d934f72121ac
Author: Bharata B Rao <bharata@linux.ibm.com>
Date:   Tue Oct 13 16:53:09 2020 -0700

    mm: memcg/slab: uncharge during kmem_cache_free_bulk()
    
    commit d1b2cf6cb84a9bd0de6f151512648dd1af82f80f upstream.
    
    Object cgroup charging is done for all the objects during allocation, but
    during freeing, uncharging ends up happening for only one object in the
    case of bulk allocation/freeing.
    
    Fix this by having a separate call to uncharge all the objects from
    kmem_cache_free_bulk() and by modifying memcg_slab_free_hook() to take
    care of bulk uncharging.
    
    Fixes: 964d4bd370d5 ("mm: memcg/slab: save obj_cgroup for non-root slab objects"
    Signed-off-by: Bharata B Rao <bharata@linux.ibm.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Acked-by: Roman Gushchin <guro@fb.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Shakeel Butt <shakeelb@google.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lkml.kernel.org/r/20201009060423.390479-1-bharata@linux.ibm.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d1c891a108597508809733f70736bc51606e2891
Author: Raul E Rangel <rrangel@chromium.org>
Date:   Mon Sep 28 15:59:20 2020 -0600

    mmc: sdhci-acpi: AMDI0040: Set SDHCI_QUIRK2_PRESET_VALUE_BROKEN
    
    commit f23cc3ba491af77395cea3f9d51204398729f26b upstream.
    
    This change fixes HS400 tuning for devices with invalid presets.
    
    SDHCI presets are not currently used for eMMC HS/HS200/HS400, but are
    used for DDR52. The HS400 retuning sequence is:
    
        HS400->DDR52->HS->HS200->Perform Tuning->HS->HS400
    
    This means that when HS400 tuning happens, we transition through DDR52
    for a very brief period. This causes presets to be enabled
    unintentionally and stay enabled when transitioning back to HS200 or
    HS400. Some firmware has invalid presets, so we end up with driver
    strengths that can cause I/O problems.
    
    Fixes: 34597a3f60b1 ("mmc: sdhci-acpi: Add support for ACPI HID of AMD Controller with HS400")
    Signed-off-by: Raul E Rangel <rrangel@chromium.org>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200928154718.1.Icc21d4b2f354e83e26e57e270dc952f5fe0b0a40@changeid
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 136b0b3e34f896b935a4213509b904783097e81a
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Tue Aug 18 13:45:08 2020 +0300

    mmc: sdhci: Add LTR support for some Intel BYT based controllers
    
    commit 46f4a69ec8ed6ab9f6a6172afe50df792c8bc1b6 upstream.
    
    Some Intel BYT based host controllers support the setting of latency
    tolerance.  Accordingly, implement the PM QoS ->set_latency_tolerance()
    callback.  The raw register values are also exposed via debugfs.
    
    Intel EHL controllers require this support.
    
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Fixes: cb3a7d4a0aec4e ("mmc: sdhci-pci: Add support for Intel EHL")
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20200818104508.7149-1-adrian.hunter@intel.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56d652b882d03d79ef65bc4c4972640205e5b723
Author: Song Liu <songliubraving@fb.com>
Date:   Mon Oct 5 09:35:21 2020 -0700

    md/raid5: fix oops during stripe resizing
    
    commit b44c018cdf748b96b676ba09fdbc5b34fc443ada upstream.
    
    KoWei reported crash during raid5 reshape:
    
    [ 1032.252932] Oops: 0002 [#1] SMP PTI
    [...]
    [ 1032.252943] RIP: 0010:memcpy_erms+0x6/0x10
    [...]
    [ 1032.252947] RSP: 0018:ffffba1ac0c03b78 EFLAGS: 00010286
    [ 1032.252949] RAX: 0000784ac0000000 RBX: ffff91bec3d09740 RCX: 0000000000001000
    [ 1032.252951] RDX: 0000000000001000 RSI: ffff91be6781c000 RDI: 0000784ac0000000
    [ 1032.252953] RBP: ffffba1ac0c03bd8 R08: 0000000000001000 R09: ffffba1ac0c03bf8
    [ 1032.252954] R10: 0000000000000000 R11: 0000000000000000 R12: ffffba1ac0c03bf8
    [ 1032.252955] R13: 0000000000001000 R14: 0000000000000000 R15: 0000000000000000
    [ 1032.252958] FS:  0000000000000000(0000) GS:ffff91becf500000(0000) knlGS:0000000000000000
    [ 1032.252959] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 1032.252961] CR2: 0000784ac0000000 CR3: 000000031780a002 CR4: 00000000001606e0
    [ 1032.252962] Call Trace:
    [ 1032.252969]  ? async_memcpy+0x179/0x1000 [async_memcpy]
    [ 1032.252977]  ? raid5_release_stripe+0x8e/0x110 [raid456]
    [ 1032.252982]  handle_stripe_expansion+0x15a/0x1f0 [raid456]
    [ 1032.252988]  handle_stripe+0x592/0x1270 [raid456]
    [ 1032.252993]  handle_active_stripes.isra.0+0x3cb/0x5a0 [raid456]
    [ 1032.252999]  raid5d+0x35c/0x550 [raid456]
    [ 1032.253002]  ? schedule+0x42/0xb0
    [ 1032.253006]  ? schedule_timeout+0x10e/0x160
    [ 1032.253011]  md_thread+0x97/0x160
    [ 1032.253015]  ? wait_woken+0x80/0x80
    [ 1032.253019]  kthread+0x104/0x140
    [ 1032.253022]  ? md_start_sync+0x60/0x60
    [ 1032.253024]  ? kthread_park+0x90/0x90
    [ 1032.253027]  ret_from_fork+0x35/0x40
    
    This is because cache_size_mutex was unlocked too early in resize_stripes,
    which races with grow_one_stripe() that grow_one_stripe() allocates a
    stripe with wrong pool_size.
    
    Fix this issue by unlocking cache_size_mutex after updating pool_size.
    
    Cc: <stable@vger.kernel.org> # v4.4+
    Reported-by: KoWei Sung <winders@amazon.com>
    Signed-off-by: Song Liu <songliubraving@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit deb81bab8707a62503186776d4130f93331107e9
Author: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Date:   Thu Oct 8 05:19:09 2020 +0200

    md: fix the checking of wrong work queue
    
    commit cf0b9b4821a2955f8a23813ef8f422208ced9bd7 upstream.
    
    It should check md_rdev_misc_wq instead of md_misc_wq.
    
    Fixes: cc1ffe61c026 ("md: add new workqueue for delete rdev")
    Cc: <stable@vger.kernel.org> # v5.8+
    Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
    Signed-off-by: Song Liu <songliubraving@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit be4e2dcd85f639f4e61c873d37e2de040d67409c
Author: Huacai Chen <chenhc@lemote.com>
Date:   Fri Sep 11 18:26:18 2020 +0800

    irqchip/loongson-htvec: Fix initial interrupt clearing
    
    commit 1d1e5630de78f7253ac24b92cee6427c3ff04d56 upstream.
    
    In htvec_reset() only the first group of initial interrupts is cleared.
    This sometimes causes spurious interrupts, so let's clear all groups.
    
    While at it, fix the nearby comment that to match the reality of what
    the driver does.
    
    Fixes: 818e915fbac518e8c78e1877 ("irqchip: Add Loongson HyperTransport Vector support")
    Signed-off-by: Huacai Chen <chenhc@lemote.com>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/1599819978-13999-2-git-send-email-chenhc@lemote.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ccd11d1dcd66c7d1b3d404bd537f55edc5223cc5
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Fri Aug 21 12:42:47 2020 -0700

    vmlinux.lds.h: Add PGO and AutoFDO input sections
    
    commit eff8728fe69880d3f7983bec3fb6cea4c306261f upstream.
    
    Basically, consider .text.{hot|unlikely|unknown}.* part of .text, too.
    
    When compiling with profiling information (collected via PGO
    instrumentations or AutoFDO sampling), Clang will separate code into
    .text.hot, .text.unlikely, or .text.unknown sections based on profiling
    information. After D79600 (clang-11), these sections will have a
    trailing `.` suffix, ie.  .text.hot., .text.unlikely., .text.unknown..
    
    When using -ffunction-sections together with profiling infomation,
    either explicitly (FGKASLR) or implicitly (LTO), code may be placed in
    sections following the convention:
    .text.hot.<foo>, .text.unlikely.<bar>, .text.unknown.<baz>
    where <foo>, <bar>, and <baz> are functions.  (This produces one section
    per function; we generally try to merge these all back via linker script
    so that we don't have 50k sections).
    
    For the above cases, we need to teach our linker scripts that such
    sections might exist and that we'd explicitly like them grouped
    together, otherwise we can wind up with code outside of the
    _stext/_etext boundaries that might not be mapped properly for some
    architectures, resulting in boot failures.
    
    If the linker script is not told about possible input sections, then
    where the section is placed as output is a heuristic-laiden mess that's
    non-portable between linkers (ie. BFD and LLD), and has resulted in many
    hard to debug bugs.  Kees Cook is working on cleaning this up by adding
    --orphan-handling=warn linker flag used in ARCH=powerpc to additional
    architectures. In the case of linker scripts, borrowing from the Zen of
    Python: explicit is better than implicit.
    
    Also, ld.bfd's internal linker script considers .text.hot AND
    .text.hot.* to be part of .text, as well as .text.unlikely and
    .text.unlikely.*. I didn't see support for .text.unknown.*, and didn't
    see Clang producing such code in our kernel builds, but I see code in
    LLVM that can produce such section names if profiling information is
    missing. That may point to a larger issue with generating or collecting
    profiles, but I would much rather be safe and explicit than have to
    debug yet another issue related to orphan section placement.
    
    Reported-by: Jian Cai <jiancai@google.com>
    Suggested-by: Fāng-ruì Sòng <maskray@google.com>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Tested-by: Luis Lozano <llozano@google.com>
    Tested-by: Manoj Gupta <manojgupta@google.com>
    Acked-by: Kees Cook <keescook@chromium.org>
    Cc: linux-arch@vger.kernel.org
    Cc: stable@vger.kernel.org
    Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=add44f8d5c5c05e08b11e033127a744d61c26aee
    Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1de778ed23ce7492c523d5850c6c6dbb34152655
    Link: https://reviews.llvm.org/D79600
    Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1084760
    Link: https://lore.kernel.org/r/20200821194310.3089815-7-keescook@chromium.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    
    Debugged-by: Luis Lozano <llozano@google.com>

commit 4b235c02bb8675d1889cd572f130341907eccd3c
Author: Chao Leng <lengchao@huawei.com>
Date:   Mon Oct 12 16:10:40 2020 +0800

    nvme-rdma: fix crash when connect rejected
    
    [ Upstream commit 43efdb8e870ee0f58633fd579aa5b5185bf5d39e ]
    
    A crash can happened when a connect is rejected.   The host establishes
    the connection after received ConnectReply, and then continues to send
    the fabrics Connect command.  If the controller does not receive the
    ReadyToUse capsule, host may receive a ConnectReject reply.
    
    Call nvme_rdma_destroy_queue_ib after the host received the
    RDMA_CM_EVENT_REJECTED event.  Then when the fabrics Connect command
    times out, nvme_rdma_timeout calls nvme_rdma_complete_rq to fail the
    request.  A crash happenes due to use after free in
    nvme_rdma_complete_rq.
    
    nvme_rdma_destroy_queue_ib is redundant when handling the
    RDMA_CM_EVENT_REJECTED event as nvme_rdma_destroy_queue_ib is already
    called in connection failure handler.
    
    Signed-off-by: Chao Leng <lengchao@huawei.com>
    Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 182f7c778ed03d4226947bc5f9dd2a451d426786
Author: Douglas Gilbert <dgilbert@interlog.com>
Date:   Thu Oct 15 14:57:35 2020 -0400

    sgl_alloc_order: fix memory leak
    
    [ Upstream commit b2a182a40278bc5849730e66bca01a762188ed86 ]
    
    sgl_alloc_order() can fail when 'length' is large on a memory
    constrained system. When order > 0 it will potentially be
    making several multi-page allocations with the later ones more
    likely to fail than the earlier one. So it is important that
    sgl_alloc_order() frees up any pages it has obtained before
    returning NULL. In the case when order > 0 it calls the wrong
    free page function and leaks. In testing the leak was
    sufficient to bring down my 8 GiB laptop with OOM.
    
    Reviewed-by: Bart Van Assche <bvanassche@acm.org>
    Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 14df8724aeeef338172e2a2d6efadc989921ca0f
Author: Xiubo Li <xiubli@redhat.com>
Date:   Tue Oct 13 22:45:14 2020 -0400

    nbd: make the config put is called before the notifying the waiter
    
    [ Upstream commit 87aac3a80af5cbad93e63250e8a1e19095ba0d30 ]
    
    There has one race case for ceph's rbd-nbd tool. When do mapping
    it may fail with EBUSY from ioctl(nbd, NBD_DO_IT), but actually
    the nbd device has already unmaped.
    
    It dues to if just after the wake_up(), the recv_work() is scheduled
    out and defers calling the nbd_config_put(), though the map process
    has exited the "nbd->recv_task" is not cleared.
    
    Signed-off-by: Xiubo Li <xiubli@redhat.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 902c3e281094e829f4eac12c495f78a67b41fc8b
Author: Konrad Dybcio <konradybcio@gmail.com>
Date:   Fri Aug 14 17:47:49 2020 +0200

    arm64: dts: qcom: kitakami: Temporarily disable SDHCI1
    
    [ Upstream commit e884fb6cc89dce1debeae33704edd7735a3d6d9c ]
    
    There is an issue with Kitakami eMMCs dying when a quirk
    isn't addressed. Until that happens, disable it.
    
    Signed-off-by: Konrad Dybcio <konradybcio@gmail.com>
    Link: https://lore.kernel.org/r/20200814154749.257837-1-konradybcio@gmail.com
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 82e815165ba0b7138022f95e8b22d15faceb0bd5
Author: Sudeep Holla <sudeep.holla@arm.com>
Date:   Mon Sep 7 12:00:04 2020 +0100

    firmware: arm_scmi: Move scmi bus init and exit calls into the driver
    
    [ Upstream commit 5a2f0a0bdf201e2183904b6217f9c74774c961a8 ]
    
    In preparation to enable building scmi as a single module, let us move
    the scmi bus {de-,}initialisation call into the driver.
    
    The main reason for this is to keep it simple instead of maintaining
    it as separate modules and dealing with all possible initcall races
    and deferred probe handling. We can move it as separate modules if
    needed in future.
    
    Link: https://lore.kernel.org/r/20200907195046.56615-3-sudeep.holla@arm.com
    Tested-by: Cristian Marussi <cristian.marussi@arm.com>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bf27c9bf73592062c0e3e8ced509212dbbcd2672
Author: Grygorii Strashko <grygorii.strashko@ti.com>
Date:   Fri Sep 11 21:30:23 2020 -0700

    bindings: soc: ti: soc: ringacc: remove ti,dma-ring-reset-quirk
    
    [ Upstream commit aee123f48f387ea62002cddb46c7cb04c96628df ]
    
    Remove "ti,dma-ring-reset-quirk" DT property as proper w/a handling is
    implemented now in Ringacc driver using SoC info.
    
    Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
    Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7b5875e410674c0db374a81888a61c3a8755844d
Author: Grygorii Strashko <grygorii.strashko@ti.com>
Date:   Fri Sep 11 21:29:56 2020 -0700

    soc: ti: k3: ringacc: add am65x sr2.0 support
    
    [ Upstream commit 95e7be062aea6d2e09116cd4d28957d310c04781 ]
    
    The AM65x SR2.0 Ringacc has fixed errata i2023 "RINGACC, UDMA: RINGACC and
    UDMA Ring State Interoperability Issue after Channel Teardown". This errata
    also fixed for J271E SoC.
    
    Use SOC bus data for K3 SoC identification and enable i2023 errate w/a only
    for the AM65x SR1.0. This also makes obsolete "ti,dma-ring-reset-quirk" DT
    property.
    
    Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
    Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit cd491cf605a538ed559b90c27c0808b151013b7d
Author: Stephen Boyd <swboyd@chromium.org>
Date:   Fri Jul 24 14:17:11 2020 -0700

    soc: qcom: rpmh-rsc: Sleep waiting for tcs slots to be free
    
    [ Upstream commit 2bc20f3c8487bd5bc4dd9ad2c06d2ba05fd4e838 ]
    
    The busy loop in rpmh_rsc_send_data() is written with the assumption
    that the udelay will be preempted by the tcs_tx_done() irq handler when
    the TCS slots are all full. This doesn't hold true when the calling
    thread is an irqthread and the tcs_tx_done() irq is also an irqthread.
    That's because kernel irqthreads are SCHED_FIFO and thus need to
    voluntarily give up priority by calling into the scheduler so that other
    threads can run.
    
    I see RCU stalls when I boot with irqthreads on the kernel commandline
    because the modem remoteproc driver is trying to send an rpmh async
    message from an irqthread that needs to give up the CPU for the rpmh
    irqthread to run and clear out tcs slots.
    
     rcu: INFO: rcu_preempt self-detected stall on CPU
     rcu:     0-....: (1 GPs behind) idle=402/1/0x4000000000000002 softirq=2108/2109 fqs=4920
      (t=21016 jiffies g=2933 q=590)
     Task dump for CPU 0:
     irq/11-smp2p    R  running task        0   148      2 0x00000028
     Call trace:
      dump_backtrace+0x0/0x154
      show_stack+0x20/0x2c
      sched_show_task+0xfc/0x108
      dump_cpu_task+0x44/0x50
      rcu_dump_cpu_stacks+0xa4/0xf8
      rcu_sched_clock_irq+0x7dc/0xaa8
      update_process_times+0x30/0x54
      tick_sched_handle+0x50/0x64
      tick_sched_timer+0x4c/0x8c
      __hrtimer_run_queues+0x21c/0x36c
      hrtimer_interrupt+0xf0/0x22c
      arch_timer_handler_phys+0x40/0x50
      handle_percpu_devid_irq+0x114/0x25c
      __handle_domain_irq+0x84/0xc4
      gic_handle_irq+0xd0/0x178
      el1_irq+0xbc/0x180
      save_return_addr+0x18/0x28
      return_address+0x54/0x88
      preempt_count_sub+0x40/0x88
      _raw_spin_unlock_irqrestore+0x4c/0x6c
      ___ratelimit+0xd0/0x128
      rpmh_rsc_send_data+0x24c/0x378
      __rpmh_write+0x1b0/0x208
      rpmh_write_async+0x90/0xbc
      rpmhpd_send_corner+0x60/0x8c
      rpmhpd_aggregate_corner+0x8c/0x124
      rpmhpd_set_performance_state+0x8c/0xbc
      _genpd_set_performance_state+0xdc/0x1b8
      dev_pm_genpd_set_performance_state+0xb8/0xf8
      q6v5_pds_disable+0x34/0x60 [qcom_q6v5_mss]
      qcom_msa_handover+0x38/0x44 [qcom_q6v5_mss]
      q6v5_handover_interrupt+0x24/0x3c [qcom_q6v5]
      handle_nested_irq+0xd0/0x138
      qcom_smp2p_intr+0x188/0x200
      irq_thread_fn+0x2c/0x70
      irq_thread+0xfc/0x14c
      kthread+0x11c/0x12c
      ret_from_fork+0x10/0x18
    
    This busy loop naturally lends itself to using a wait queue so that each
    thread that tries to send a message will sleep waiting on the waitqueue
    and only be woken up when a free slot is available. This should make
    things more predictable too because the scheduler will be able to sleep
    tasks that are waiting on a free tcs instead of the busy loop we
    currently have today.
    
    Reviewed-by: Maulik Shah <mkshah@codeaurora.org>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
    Cc: Douglas Anderson <dianders@chromium.org>
    Cc: Maulik Shah <mkshah@codeaurora.org>
    Cc: Lina Iyer <ilina@codeaurora.org>
    Signed-off-by: Stephen Boyd <swboyd@chromium.org>
    Link: https://lore.kernel.org/r/20200724211711.810009-1-sboyd@kernel.org
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 98db1e524b13715026c53d0e372ca5939589268b
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:40 2020 +0200

    ARM: dts: s5pv210: align SPI GPIO node name with dtschema in Aries
    
    [ Upstream commit 1ed7f6d0bab2f1794f1eb4ed032e90575552fd21 ]
    
    The device tree schema expects SPI controller to be named "spi",
    otherwise dtbs_check complain with a warning like:
    
      spi-gpio-0: $nodename:0: 'spi-gpio-0' does not match '^spi(@.*|-[0-9a-f])*$'
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Tested-by: Jonathan Bakker <xc-racer2@live.ca>
    Link: https://lore.kernel.org/r/20200907161141.31034-25-krzk@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8f5c4165297ddc3e99534f7c72345af15da05563
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:27 2020 +0200

    ARM: dts: s5pv210: add RTC 32 KHz clock in Aries family
    
    [ Upstream commit 086c4498b0cc87fdb09188f3da7056e898814948 ]
    
    The S3C RTC requires 32768 Hz clock as input which is provided by PMIC.
    However there is no such clock provider but rather a regulator driver
    which registers the clock as a regulator.  This is an old driver which
    will not be updated so add a workaround - a fixed-clock to fill missing
    clock phandle reference in S3C RTC.
    
    This fixes dtbs_check warnings:
    
      rtc@e2800000: clocks: [[2, 145]] is too short
      rtc@e2800000: clock-names: ['rtc'] is too short
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Tested-by: Jonathan Bakker <xc-racer2@live.ca>
    Link: https://lore.kernel.org/r/20200907161141.31034-12-krzk@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6df47b841103aeaddd01d23c4f1f10baf15f193d
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:24 2020 +0200

    ARM: dts: s5pv210: remove dedicated 'audio-subsystem' node
    
    [ Upstream commit 6c17a2974abf68a58517f75741b15c4aba42b4b8 ]
    
    The 'audio-subsystem' node is an artificial creation, not representing
    real hardware.  The hardware is described by its nodes - AUDSS clock
    controller and I2S0.
    
    Remove the 'audio-subsystem' node along with its undocumented compatible
    to fix dtbs_check warnings like:
    
      audio-subsystem: $nodename:0: 'audio-subsystem' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$'
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Tested-by: Jonathan Bakker <xc-racer2@live.ca>
    Link: https://lore.kernel.org/r/20200907161141.31034-9-krzk@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9bf3c93dadeca93515b4e49aaf35aeb7f55a2291
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:23 2020 +0200

    ARM: dts: s5pv210: move PMU node out of clock controller
    
    [ Upstream commit bb98fff84ad1ea321823759edaba573a16fa02bd ]
    
    The Power Management Unit (PMU) is a separate device which has little
    common with clock controller.  Moving it to one level up (from clock
    controller child to SoC) allows to remove fake simple-bus compatible and
    dtbs_check warnings like:
    
      clock-controller@e0100000: $nodename:0:
        'clock-controller@e0100000' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$'
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Tested-by: Jonathan Bakker <xc-racer2@live.ca>
    Link: https://lore.kernel.org/r/20200907161141.31034-8-krzk@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 76ad6a9be3c0ea3d5d72aef259244e4c73e89742
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:22 2020 +0200

    ARM: dts: s5pv210: move fixed clocks under root node
    
    [ Upstream commit d38cae370e5f2094cbc38db3082b8e9509ae52ce ]
    
    The fixed clocks are kept under dedicated 'external-clocks' node, thus a
    fake 'reg' was added.  This is not correct with dtschema as fixed-clock
    binding does not have a 'reg' property.  Moving fixed clocks out of
    'soc' to root node fixes multiple dtbs_check warnings:
    
      external-clocks: $nodename:0: 'external-clocks' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$'
      external-clocks: #size-cells:0:0: 0 is not one of [1, 2]
      external-clocks: oscillator@0:reg:0: [0] is too short
      external-clocks: oscillator@1:reg:0: [1] is too short
      external-clocks: 'ranges' is a required property
      oscillator@0: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Tested-by: Jonathan Bakker <xc-racer2@live.ca>
    Link: https://lore.kernel.org/r/20200907161141.31034-7-krzk@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 79703e5ae4d38724b267658b027a2347e5821274
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Mon Sep 7 18:11:21 2020 +0200

    ARM: dts: s5pv210: remove DMA controller bus node name to fix dtschema warnings
    
    [ Upstream commit ea4e792f3c8931fffec4d700cf6197d84e9f35a6 ]
    
    There is no need to keep DMA controller nodes under AMBA bus node.
    Remove the "amba" node to fix dtschema warnings like:
    
      amba: $nodename:0: 'amba' does not match '^([a-z][a-z0-9\\-]+-bus|bus|soc|axi|ahb|apb)(@[0-9a-f]+)?$'
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Tested-by: Jonathan Bakker <xc-racer2@live.ca>
    Link: https://lore.kernel.org/r/20200907161141.31034-6-krzk@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9723770cde43293a27efc884a6b76f124dac41f5
Author: Jonathan Bakker <xc-racer2@live.ca>
Date:   Tue Sep 1 17:38:58 2020 -0700

    ARM: dts: s5pv210: Enable audio on Aries boards
    
    [ Upstream commit cd972fe90008adf49de0790250c1275480ac5cdc ]
    
    Both the Galaxy S and the Fascinate4G have a WM8994 codec, but they
    differ slightly in their jack detection and micbias configuration.
    
    Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fb4139a7955c11bf5bf85fddc5f624f0ac732f4e
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Aug 26 14:37:59 2020 +0300

    memory: emif: Remove bogus debugfs error handling
    
    [ Upstream commit fd22781648080cc400772b3c68aa6b059d2d5420 ]
    
    Callers are generally not supposed to check the return values from
    debugfs functions.  Debugfs functions never return NULL so this error
    handling will never trigger.  (Historically debugfs functions used to
    return a mix of NULL and error pointers but it was eventually deemed too
    complicated for something which wasn't intended to be used in normal
    situations).
    
    Delete all the error handling.
    
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
    Link: https://lore.kernel.org/r/20200826113759.GF393664@mwanda
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 792a818350bdd3d25be9af066a41a81f1829d035
Author: Tony Lindgren <tony@atomide.com>
Date:   Tue Mar 10 14:02:48 2020 -0700

    ARM: dts: omap4: Fix sgx clock rate for 4430
    
    [ Upstream commit 19d3e9a0bdd57b90175f30390edeb06851f5f9f3 ]
    
    We currently have a different clock rate for droid4 compared to the
    stock v3.0.8 based Android Linux kernel:
    
    # cat /sys/kernel/debug/clk/dpll_*_m7x2_ck/clk_rate
    266666667
    307200000
    # cat /sys/kernel/debug/clk/l3_gfx_cm:clk:0000:0/clk_rate
    307200000
    
    Let's fix this by configuring sgx to use 153.6 MHz instead of 307.2 MHz.
    Looks like also at least duover needs this change to avoid hangs, so
    let's apply it for all 4430.
    
    This helps a bit with thermal issues that seem to be related to memory
    corruption when using sgx. It seems that other driver related issues
    still remain though.
    
    Cc: Arthur Demchenkov <spinal.by@gmail.com>
    Cc: Merlijn Wajer <merlijn@wizzup.org>
    Cc: Sebastian Reichel <sre@kernel.org>
    Signed-off-by: Tony Lindgren <tony@atomide.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 88572b07da0fbaea256d191d46fd5515e07f637b
Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Date:   Fri Jul 17 21:33:21 2020 +0900

    arm64: dts: renesas: ulcb: add full-pwr-cycle-in-suspend into eMMC nodes
    
    [ Upstream commit 992d7a8b88c83c05664b649fc54501ce58e19132 ]
    
    Add full-pwr-cycle-in-suspend property to do a graceful shutdown of
    the eMMC device in system suspend.
    
    Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Link: https://lore.kernel.org/r/1594989201-24228-1-git-send-email-yoshihiro.shimoda.uh@renesas.com
    Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9e9f33d227d6f17e239e3c26b59730a11fb2be8f
Author: Ronnie Sahlberg <lsahlber@redhat.com>
Date:   Fri Oct 9 09:32:56 2020 +1000

    cifs: handle -EINTR in cifs_setattr
    
    [ Upstream commit c6cc4c5a72505a0ecefc9b413f16bec512f38078 ]
    
    RHBZ: 1848178
    
    Some calls that set attributes, like utimensat(), are not supposed to return
    -EINTR and thus do not have handlers for this in glibc which causes us
    to leak -EINTR to the applications which are also unprepared to handle it.
    
    For example tar will break if utimensat() return -EINTR and abort unpacking
    the archive. Other applications may break too.
    
    To handle this we add checks, and retry, for -EINTR in cifs_setattr()
    
    Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fa6d7a5853f93efb088aba36af12cb1944156411
Author: Rohith Surabattula <rohiths@microsoft.com>
Date:   Fri Sep 18 05:37:28 2020 +0000

    Handle STATUS_IO_TIMEOUT gracefully
    
    [ Upstream commit 8e670f77c4a55013db6d23b962f9bf6673a5e7b6 ]
    
    Currently STATUS_IO_TIMEOUT is not treated as retriable error.
    It is currently mapped to ETIMEDOUT and returned to userspace
    for most system calls. STATUS_IO_TIMEOUT is returned by server
    in case of unavailability or throttling errors.
    
    This patch will map the STATUS_IO_TIMEOUT to EAGAIN, so that it
    can be retried. Also, added a check to drop the connection to
    not overload the server in case of ongoing unavailability.
    
    Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
    Reviewed-by: Aurelien Aptel <aaptel@suse.com>
    Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 22a700bca3c852ca382d8c9720fd372fdfbda6c6
Author: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Date:   Wed Oct 14 22:01:09 2020 +0530

    gfs2: add validation checks for size of superblock
    
    [ Upstream commit 0ddc5154b24c96f20e94d653b0a814438de6032b ]
    
    In gfs2_check_sb(), no validation checks are performed with regards to
    the size of the superblock.
    syzkaller detected a slab-out-of-bounds bug that was primarily caused
    because the block size for a superblock was set to zero.
    A valid size for a superblock is a power of 2 between 512 and PAGE_SIZE.
    Performing validation checks and ensuring that the size of the superblock
    is valid fixes this bug.
    
    Reported-by: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com
    Tested-by: syzbot+af90d47a37376844e731@syzkaller.appspotmail.com
    Suggested-by: Andrew Price <anprice@redhat.com>
    Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
    [Minor code reordering.]
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 00f6058e6802892251163337fdcaedf4f62f854c
Author: Jamie Iles <jamie@nuviainc.com>
Date:   Mon Oct 12 14:13:09 2020 +0100

    gfs2: use-after-free in sysfs deregistration
    
    [ Upstream commit c2a04b02c060c4858762edce4674d5cba3e5a96f ]
    
    syzkaller found the following splat with CONFIG_DEBUG_KOBJECT_RELEASE=y:
    
      Read of size 1 at addr ffff000028e896b8 by task kworker/1:2/228
    
      CPU: 1 PID: 228 Comm: kworker/1:2 Tainted: G S                5.9.0-rc8+ #101
      Hardware name: linux,dummy-virt (DT)
      Workqueue: events kobject_delayed_cleanup
      Call trace:
       dump_backtrace+0x0/0x4d8
       show_stack+0x34/0x48
       dump_stack+0x174/0x1f8
       print_address_description.constprop.0+0x5c/0x550
       kasan_report+0x13c/0x1c0
       __asan_report_load1_noabort+0x34/0x60
       memcmp+0xd0/0xd8
       gfs2_uevent+0xc4/0x188
       kobject_uevent_env+0x54c/0x1240
       kobject_uevent+0x2c/0x40
       __kobject_del+0x190/0x1d8
       kobject_delayed_cleanup+0x2bc/0x3b8
       process_one_work+0x96c/0x18c0
       worker_thread+0x3f0/0xc30
       kthread+0x390/0x498
       ret_from_fork+0x10/0x18
    
      Allocated by task 1110:
       kasan_save_stack+0x28/0x58
       __kasan_kmalloc.isra.0+0xc8/0xe8
       kasan_kmalloc+0x10/0x20
       kmem_cache_alloc_trace+0x1d8/0x2f0
       alloc_super+0x64/0x8c0
       sget_fc+0x110/0x620
       get_tree_bdev+0x190/0x648
       gfs2_get_tree+0x50/0x228
       vfs_get_tree+0x84/0x2e8
       path_mount+0x1134/0x1da8
       do_mount+0x124/0x138
       __arm64_sys_mount+0x164/0x238
       el0_svc_common.constprop.0+0x15c/0x598
       do_el0_svc+0x60/0x150
       el0_svc+0x34/0xb0
       el0_sync_handler+0xc8/0x5b4
       el0_sync+0x15c/0x180
    
      Freed by task 228:
       kasan_save_stack+0x28/0x58
       kasan_set_track+0x28/0x40
       kasan_set_free_info+0x24/0x48
       __kasan_slab_free+0x118/0x190
       kasan_slab_free+0x14/0x20
       slab_free_freelist_hook+0x6c/0x210
       kfree+0x13c/0x460
    
    Use the same pattern as f2fs + ext4 where the kobject destruction must
    complete before allowing the FS itself to be freed.  This means that we
    need an explicit free_sbd in the callers.
    
    Cc: Bob Peterson <rpeterso@redhat.com>
    Cc: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Jamie Iles <jamie@nuviainc.com>
    [Also go to fail_free when init_names fails.]
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e15c2f93775bc04e01320b6e37a2d217053eeef0
Author: Andrew Price <anprice@redhat.com>
Date:   Wed Oct 7 12:30:58 2020 +0100

    gfs2: Fix NULL pointer dereference in gfs2_rgrp_dump
    
    [ Upstream commit 0e539ca1bbbe85a86549c97a30a765ada4a09df9 ]
    
    When an rindex entry is found to be corrupt, compute_bitstructs() calls
    gfs2_consist_rgrpd() which calls gfs2_rgrp_dump() like this:
    
        gfs2_rgrp_dump(NULL, rgd->rd_gl, fs_id_buf);
    
    gfs2_rgrp_dump then dereferences the gl without checking it and we get
    
        BUG: KASAN: null-ptr-deref in gfs2_rgrp_dump+0x28/0x280
    
    because there's no rgrp glock involved while reading the rindex on mount.
    
    Fix this by changing gfs2_rgrp_dump to take an rgrp argument.
    
    Reported-by: syzbot+43fa87986bdd31df9de6@syzkaller.appspotmail.com
    Signed-off-by: Andrew Price <anprice@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f8401526aab2827731be8703c0b28f02ffe7805e
Author: Bob Peterson <rpeterso@redhat.com>
Date:   Wed Sep 16 11:06:23 2020 -0500

    gfs2: call truncate_inode_pages_final for address space glocks
    
    [ Upstream commit ee1e2c773e4f4ce2213f9d77cc703b669ca6fa3f ]
    
    Before this patch, we were not calling truncate_inode_pages_final for the
    address space for glocks, which left the possibility of a leak. We now
    take care of the problem instead of complaining, and we do it during
    glock tear-down..
    
    Signed-off-by: Bob Peterson <rpeterso@redhat.com>
    Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3aade0647187d73e36a8483d9575267ef2f45317
Author: Christoph Hellwig <hch@lst.de>
Date:   Mon Oct 5 10:41:28 2020 +0200

    scsi: core: Clean up allocation and freeing of sgtables
    
    [ Upstream commit 7007e9dd56767a95de0947b3f7599bcc2f21687f ]
    
    Rename scsi_init_io() to scsi_alloc_sgtables(), and ensure callers call
    scsi_free_sgtables() to cleanup failures close to scsi_init_io() instead of
    leaking it down the generic I/O submission path.
    
    Link: https://lore.kernel.org/r/20201005084130.143273-9-hch@lst.de
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3ed6ba0bb3f38ebb5a0d3e4edbfd6950cdb8e473
Author: Fabiano Rosas <farosas@linux.ibm.com>
Date:   Fri Sep 11 01:16:07 2020 -0300

    KVM: PPC: Book3S HV: Do not allocate HPT for a nested guest
    
    [ Upstream commit 05e6295dc7de859c9d56334805485c4d20bebf25 ]
    
    The current nested KVM code does not support HPT guests. This is
    informed/enforced in some ways:
    
    - Hosts < P9 will not be able to enable the nested HV feature;
    
    - The nested hypervisor MMU capabilities will not contain
      KVM_CAP_PPC_MMU_HASH_V3;
    
    - QEMU reflects the MMU capabilities in the
      'ibm,arch-vec-5-platform-support' device-tree property;
    
    - The nested guest, at 'prom_parse_mmu_model' ignores the
      'disable_radix' kernel command line option if HPT is not supported;
    
    - The KVM_PPC_CONFIGURE_V3_MMU ioctl will fail if trying to use HPT.
    
    There is, however, still a way to start a HPT guest by using
    max-compat-cpu=power8 at the QEMU machine options. This leads to the
    guest being set to use hash after QEMU calls the KVM_PPC_ALLOCATE_HTAB
    ioctl.
    
    With the guest set to hash, the nested hypervisor goes through the
    entry path that has no knowledge of nesting (kvmppc_run_vcpu) and
    crashes when it tries to execute an hypervisor-privileged (mtspr
    HDEC) instruction at __kvmppc_vcore_entry:
    
    root@L1:~ $ qemu-system-ppc64 -machine pseries,max-cpu-compat=power8 ...
    
    <snip>
    [  538.543303] CPU: 83 PID: 25185 Comm: CPU 0/KVM Not tainted 5.9.0-rc4 #1
    [  538.543355] NIP:  c00800000753f388 LR: c00800000753f368 CTR: c0000000001e5ec0
    [  538.543417] REGS: c0000013e91e33b0 TRAP: 0700   Not tainted  (5.9.0-rc4)
    [  538.543470] MSR:  8000000002843033 <SF,VEC,VSX,FP,ME,IR,DR,RI,LE>  CR: 22422882  XER: 20040000
    [  538.543546] CFAR: c00800000753f4b0 IRQMASK: 3
                   GPR00: c0080000075397a0 c0000013e91e3640 c00800000755e600 0000000080000000
                   GPR04: 0000000000000000 c0000013eab19800 c000001394de0000 00000043a054db72
                   GPR08: 00000000003b1652 0000000000000000 0000000000000000 c0080000075502e0
                   GPR12: c0000000001e5ec0 c0000007ffa74200 c0000013eab19800 0000000000000008
                   GPR16: 0000000000000000 c00000139676c6c0 c000000001d23948 c0000013e91e38b8
                   GPR20: 0000000000000053 0000000000000000 0000000000000001 0000000000000000
                   GPR24: 0000000000000001 0000000000000001 0000000000000000 0000000000000001
                   GPR28: 0000000000000001 0000000000000053 c0000013eab19800 0000000000000001
    [  538.544067] NIP [c00800000753f388] __kvmppc_vcore_entry+0x90/0x104 [kvm_hv]
    [  538.544121] LR [c00800000753f368] __kvmppc_vcore_entry+0x70/0x104 [kvm_hv]
    [  538.544173] Call Trace:
    [  538.544196] [c0000013e91e3640] [c0000013e91e3680] 0xc0000013e91e3680 (unreliable)
    [  538.544260] [c0000013e91e3820] [c0080000075397a0] kvmppc_run_core+0xbc8/0x19d0 [kvm_hv]
    [  538.544325] [c0000013e91e39e0] [c00800000753d99c] kvmppc_vcpu_run_hv+0x404/0xc00 [kvm_hv]
    [  538.544394] [c0000013e91e3ad0] [c0080000072da4fc] kvmppc_vcpu_run+0x34/0x48 [kvm]
    [  538.544472] [c0000013e91e3af0] [c0080000072d61b8] kvm_arch_vcpu_ioctl_run+0x310/0x420 [kvm]
    [  538.544539] [c0000013e91e3b80] [c0080000072c7450] kvm_vcpu_ioctl+0x298/0x778 [kvm]
    [  538.544605] [c0000013e91e3ce0] [c0000000004b8c2c] sys_ioctl+0x1dc/0xc90
    [  538.544662] [c0000013e91e3dc0] [c00000000002f9a4] system_call_exception+0xe4/0x1c0
    [  538.544726] [c0000013e91e3e20] [c00000000000d140] system_call_common+0xf0/0x27c
    [  538.544787] Instruction dump:
    [  538.544821] f86d1098 60000000 60000000 48000099 e8ad0fe8 e8c500a0 e9264140 75290002
    [  538.544886] 7d1602a6 7cec42a6 40820008 7d0807b4 <7d164ba6> 7d083a14 f90d10a0 480104fd
    [  538.544953] ---[ end trace 74423e2b948c2e0c ]---
    
    This patch makes the KVM_PPC_ALLOCATE_HTAB ioctl fail when running in
    the nested hypervisor, causing QEMU to abort.
    
    Reported-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
    Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
    Reviewed-by: Greg Kurz <groug@kaod.org>
    Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
    Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4fcc5185231016ee94ced47e0961198ab6bbe849
Author: Jan Kara <jack@suse.cz>
Date:   Thu Oct 15 13:03:30 2020 +0200

    ext4: Detect already used quota file early
    
    [ Upstream commit e0770e91424f694b461141cbc99adf6b23006b60 ]
    
    When we try to use file already used as a quota file again (for the same
    or different quota type), strange things can happen. At the very least
    lockdep annotations may be wrong but also inode flags may be wrongly set
    / reset. When the file is used for two quota types at once we can even
    corrupt the file and likely crash the kernel. Catch all these cases by
    checking whether passed file is already used as quota file and bail
    early in that case.
    
    This fixes occasional generic/219 failure due to lockdep complaint.
    
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Reported-by: Ritesh Harjani <riteshh@linux.ibm.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20201015110330.28716-1-jack@suse.cz
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 693a6e258f1a4018c8415b55d703e819bd69c125
Author: changfengnan <fengnanchang@foxmail.com>
Date:   Mon Oct 12 18:49:00 2020 +0200

    jbd2: avoid transaction reuse after reformatting
    
    [ Upstream commit fc750a3b44bdccb9fb96d6abbc48a9b8e480ce7b ]
    
    When ext4 is formatted with lazy_journal_init=1 and transactions from
    the previous filesystem are still on disk, it is possible that they are
    considered during a recovery after a crash. Because the checksum seed
    has changed, the CRC check will fail, and the journal recovery fails
    with checksum error although the journal is otherwise perfectly valid.
    Fix the problem by checking commit block time stamps to determine
    whether the data in the journal block is just stale or whether it is
    indeed corrupt.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Signed-off-by: Fengnan Chang <changfengnan@hikvision.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Link: https://lore.kernel.org/r/20201012164900.20197-1-jack@suse.cz
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d9371ef33695b2a71ba3594872fa51af87e18f8c
Author: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Date:   Fri Aug 7 16:59:02 2020 +0530

    drivers: watchdog: rdc321x_wdt: Fix race condition bugs
    
    [ Upstream commit 4b2e7f99cdd314263c9d172bc17193b8b6bba463 ]
    
    In rdc321x_wdt_probe(), rdc321x_wdt_device.queue is initialized
    after misc_register(), hence if ioctl is called before its
    initialization which can call rdc321x_wdt_start() function,
    it will see an uninitialized value of rdc321x_wdt_device.queue,
    hence initialize it before misc_register().
    Also, rdc321x_wdt_device.default_ticks is accessed in reset()
    function called from write callback, thus initialize it before
    misc_register().
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/20200807112902.28764-1-madhuparnabhowmik10@gmail.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a33ce4dc05b38763d508d8697fb4982cdc394223
Author: Yan, Zheng <zyan@redhat.com>
Date:   Tue Aug 11 15:23:03 2020 +0800

    ceph: encode inodes' parent/d_name in cap reconnect message
    
    [ Upstream commit a33f6432b3a63a4909dbbb0967f7c9df8ff2de91 ]
    
    Since nautilus, MDS tracks dirfrags whose child inodes have caps in open
    file table. When MDS recovers, it prefetches all of these dirfrags. This
    avoids using backtrace to load inodes. But dirfrags prefetch may load
    lots of useless inodes into cache, and make MDS run out of memory.
    
    Recent MDS adds an option that disables dirfrags prefetch. When dirfrags
    prefetch is disabled. Recovering MDS only prefetches corresponding dir
    inodes. Including inodes' parent/d_name in cap reconnect message can
    help MDS to load inodes into its cache.
    
    Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 07f5e25b99f918cc31505a473918de5bd1db989f
Author: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Date:   Mon Oct 12 09:54:04 2020 +0530

    net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid
    
    [ Upstream commit 7ca1db21ef8e0e6725b4d25deed1ca196f7efb28 ]
    
    In p9_fd_create_unix, checking is performed to see if the addr (passed
    as an argument) is NULL or not.
    However, no check is performed to see if addr is a valid address, i.e.,
    it doesn't entirely consist of only 0's.
    The initialization of sun_server.sun_path to be equal to this faulty
    addr value leads to an uninitialized variable, as detected by KMSAN.
    Checking for this (faulty addr) and returning a negative error number
    appropriately, resolves this issue.
    
    Link: http://lkml.kernel.org/r/20201012042404.2508-1-anant.thazhemadam@gmail.com
    Reported-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
    Tested-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
    Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
    Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4c595834bcb2aa41b5ca36d10b9a8a66ff66762a
Author: J. Bruce Fields <bfields@redhat.com>
Date:   Fri Sep 25 10:09:58 2020 -0400

    nfsd4: remove check_conflicting_opens warning
    
    [ Upstream commit 50747dd5e47bde3b7d7f839c84d0d3b554090497 ]
    
    There are actually rare races where this is possible (e.g. if a new open
    intervenes between the read of i_writecount and the fi_fds).
    
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 902bd6fc2444321d31e1fd4037927a0221a10e2f
Author: Hou Tao <houtao1@huawei.com>
Date:   Fri Aug 28 15:02:55 2020 +0800

    nfsd: rename delegation related tracepoints to make them less confusing
    
    [ Upstream commit 3caf91757ced158e6c4a44d8b105bd7b3e1767d8 ]
    
    Now when a read delegation is given, two delegation related traces
    will be printed:
    
        nfsd_deleg_open: client 5f45b854:e6058001 stateid 00000030:00000001
        nfsd_deleg_none: client 5f45b854:e6058001 stateid 0000002f:00000001
    
    Although the intention is to let developers know two stateid are
    returned, the traces are confusing about whether or not a read delegation
    is handled out. So renaming trace_nfsd_deleg_none() to trace_nfsd_open()
    and trace_nfsd_deleg_open() to trace_nfsd_deleg_read() to make
    the intension clearer.
    
    The patched traces will be:
    
        nfsd_deleg_read: client 5f48a967:b55b21cd stateid 00000003:00000001
        nfsd_open: client 5f48a967:b55b21cd stateid 00000002:00000001
    
    Suggested-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 27ff4af0e61dd601050a3dd0b530e0079d26b0b7
Author: Tero Kristo <t-kristo@ti.com>
Date:   Mon Sep 7 11:25:59 2020 +0300

    clk: ti: clockdomain: fix static checker warning
    
    [ Upstream commit b7a7943fe291b983b104bcbd2f16e8e896f56590 ]
    
    Fix a memory leak induced by not calling clk_put after doing of_clk_get.
    
    Reported-by: Dan Murphy <dmurphy@ti.com>
    Signed-off-by: Tero Kristo <t-kristo@ti.com>
    Link: https://lore.kernel.org/r/20200907082600.454-3-t-kristo@ti.com
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3a516ce86583c34d00d5904cd2a34cf5e03ebd28
Author: Tuan Phan <tuanphan@os.amperecomputing.com>
Date:   Thu Aug 6 14:57:34 2020 -0700

    PCI/ACPI: Add Ampere Altra SOC MCFG quirk
    
    [ Upstream commit 877c1a5f79c6984bbe3f2924234c08e2f4f1acd5 ]
    
    Ampere Altra SOC supports only 32-bit ECAM reads.  Add an MCFG quirk for
    the platform.
    
    Link: https://lore.kernel.org/r/1596751055-12316-1-git-send-email-tuanphan@os.amperecomputing.com
    Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4abb271249bf3de128e7602d2ed0d84acf4bc648
Author: Chris Lew <clew@codeaurora.org>
Date:   Wed Jun 24 22:15:18 2020 +0530

    rpmsg: glink: Use complete_all for open states
    
    [ Upstream commit 4fcdaf6e28d11e2f3820d54dd23cd12a47ddd44e ]
    
    The open_req and open_ack completion variables are the state variables
    to represet a remote channel as open. Use complete_all so there are no
    races with waiters and using completion_done.
    
    Signed-off-by: Chris Lew <clew@codeaurora.org>
    Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
    Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
    Link: https://lore.kernel.org/r/1593017121-7953-2-git-send-email-deesin@codeaurora.org
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0682461455dc98a01f389fd10ab67577d08aff08
Author: Michael Chan <michael.chan@broadcom.com>
Date:   Mon Oct 12 05:10:51 2020 -0400

    bnxt_en: Log unknown link speed appropriately.
    
    [ Upstream commit 8eddb3e7ce124dd6375d3664f1aae13873318b0f ]
    
    If the VF virtual link is set to always enabled, the speed may be
    unknown when the physical link is down.  The driver currently logs
    the link speed as 4294967295 Mbps which is SPEED_UNKNOWN.  Modify
    the link up log message as "speed unknown" which makes more sense.
    
    Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
    Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
    Signed-off-by: Michael Chan <michael.chan@broadcom.com>
    Link: https://lore.kernel.org/r/1602493854-29283-7-git-send-email-michael.chan@broadcom.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit cb2c620f509bb17b3dcc16c5e8ee67e3645709ff
Author: Chao Yu <chao@kernel.org>
Date:   Fri Oct 9 10:40:48 2020 +0800

    f2fs: fix to set SBI_NEED_FSCK flag for inconsistent inode
    
    [ Upstream commit d662fad143c0470ad7f46ea7b02da539f613d7d7 ]
    
    If compressed inode has inconsistent fields on i_compress_algorithm,
    i_compr_blocks and i_log_cluster_size, we missed to set SBI_NEED_FSCK
    to notice fsck to repair the inode, fix it.
    
    Signed-off-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 029d664c6b9a34338d8843e5abe1754b80156e35
Author: Zhao Heming <heming.zhao@suse.com>
Date:   Tue Oct 6 00:00:24 2020 +0800

    md/bitmap: md_bitmap_get_counter returns wrong blocks
    
    [ Upstream commit d837f7277f56e70d82b3a4a037d744854e62f387 ]
    
    md_bitmap_get_counter() has code:
    
    ```
        if (bitmap->bp[page].hijacked ||
            bitmap->bp[page].map == NULL)
            csize = ((sector_t)1) << (bitmap->chunkshift +
                          PAGE_COUNTER_SHIFT - 1);
    ```
    
    The minus 1 is wrong, this branch should report 2048 bits of space.
    With "-1" action, this only report 1024 bit of space.
    
    This bug code returns wrong blocks, but it doesn't inflence bitmap logic:
    1. Most callers focus this function return value (the counter of offset),
       not the parameter blocks.
    2. The bug is only triggered when hijacked is true or map is NULL.
       the hijacked true condition is very rare.
       the "map == null" only true when array is creating or resizing.
    3. Even the caller gets wrong blocks, current code makes caller just to
       call md_bitmap_get_counter() one more time.
    
    Signed-off-by: Zhao Heming <heming.zhao@suse.com>
    Signed-off-by: Song Liu <songliubraving@fb.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1290a420fc5b6cb909468a5a72b1b2d641904957
Author: Anand Jain <anand.jain@oracle.com>
Date:   Sat Sep 5 01:34:22 2020 +0800

    btrfs: fix replace of seed device
    
    [ Upstream commit c6a5d954950c5031444173ad2195efc163afcac9 ]
    
    If you replace a seed device in a sprouted fs, it appears to have
    successfully replaced the seed device, but if you look closely, it
    didn't.  Here is an example.
    
      $ mkfs.btrfs /dev/sda
      $ btrfstune -S1 /dev/sda
      $ mount /dev/sda /btrfs
      $ btrfs device add /dev/sdb /btrfs
      $ umount /btrfs
      $ btrfs device scan --forget
      $ mount -o device=/dev/sda /dev/sdb /btrfs
      $ btrfs replace start -f /dev/sda /dev/sdc /btrfs
      $ echo $?
      0
    
      BTRFS info (device sdb): dev_replace from /dev/sda (devid 1) to /dev/sdc started
      BTRFS info (device sdb): dev_replace from /dev/sda (devid 1) to /dev/sdc finished
    
      $ btrfs fi show
      Label: none  uuid: ab2c88b7-be81-4a7e-9849-c3666e7f9f4f
              Total devices 2 FS bytes used 256.00KiB
              devid    1 size 3.00GiB used 520.00MiB path /dev/sdc
              devid    2 size 3.00GiB used 896.00MiB path /dev/sdb
    
      Label: none  uuid: 10bd3202-0415-43af-96a8-d5409f310a7e
              Total devices 1 FS bytes used 128.00KiB
              devid    1 size 3.00GiB used 536.00MiB path /dev/sda
    
    So as per the replace start command and kernel log replace was successful.
    Now let's try to clean mount.
    
      $ umount /btrfs
      $ btrfs device scan --forget
    
      $ mount -o device=/dev/sdc /dev/sdb /btrfs
      mount: /btrfs: wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper program, or other error.
    
      [  636.157517] BTRFS error (device sdc): failed to read chunk tree: -2
      [  636.180177] BTRFS error (device sdc): open_ctree failed
    
    That's because per dev items it is still looking for the original seed
    device.
    
     $ btrfs inspect-internal dump-tree -d /dev/sdb
    
            item 0 key (DEV_ITEMS DEV_ITEM 1) itemoff 16185 itemsize 98
                    devid 1 total_bytes 3221225472 bytes_used 545259520
                    io_align 4096 io_width 4096 sector_size 4096 type 0
                    generation 6 start_offset 0 dev_group 0
                    seek_speed 0 bandwidth 0
                    uuid 59368f50-9af2-4b17-91da-8a783cc418d4  <--- seed uuid
                    fsid 10bd3202-0415-43af-96a8-d5409f310a7e  <--- seed fsid
            item 1 key (DEV_ITEMS DEV_ITEM 2) itemoff 16087 itemsize 98
                    devid 2 total_bytes 3221225472 bytes_used 939524096
                    io_align 4096 io_width 4096 sector_size 4096 type 0
                    generation 0 start_offset 0 dev_group 0
                    seek_speed 0 bandwidth 0
                    uuid 56a0a6bc-4630-4998-8daf-3c3030c4256a  <- sprout uuid
                    fsid ab2c88b7-be81-4a7e-9849-c3666e7f9f4f <- sprout fsid
    
    But the replaced target has the following uuid+fsid in its superblock
    which doesn't match with the expected uuid+fsid in its devitem.
    
      $ btrfs in dump-super /dev/sdc | egrep '^generation|dev_item.uuid|dev_item.fsid|devid'
      generation    20
      dev_item.uuid 59368f50-9af2-4b17-91da-8a783cc418d4
      dev_item.fsid ab2c88b7-be81-4a7e-9849-c3666e7f9f4f [match]
      dev_item.devid        1
    
    So if you provide the original seed device the mount shall be
    successful.  Which so long happening in the test case btrfs/163.
    
      $ btrfs device scan --forget
      $ mount -o device=/dev/sda /dev/sdb /btrfs
    
    Fix in this patch:
    If a seed is not sprouted then there is no replacement of it, because of
    its read-only filesystem with a read-only device. Similarly, in the case
    of a sprouted filesystem, the seed device is still read only. So, mark
    it as you can't replace a seed device, you can only add a new device and
    then delete the seed device. If replace is attempted then returns
    -EINVAL.
    
    Signed-off-by: Anand Jain <anand.jain@oracle.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bd7827bb17df02745ab8d0bb923e95649848621e
Author: Gabriel Krisman Bertazi <krisman@collabora.com>
Date:   Tue Oct 6 15:41:25 2020 -0400

    block: Consider only dispatched requests for inflight statistic
    
    [ Upstream commit a926c7afffcc0f2e35e6acbccb16921bacf34617 ]
    
    According to Documentation/block/stat.rst, inflight should not include
    I/O requests that are in the queue but not yet dispatched to the device,
    but blk-mq identifies as inflight any request that has a tag allocated,
    which, for queues without elevator, happens at request allocation time
    and before it is queued in the ctx (default case in blk_mq_submit_bio).
    
    In addition, current behavior is different for queues with elevator from
    queues without it, since for the former the driver tag is allocated at
    dispatch time.  A more precise approach would be to only consider
    requests with state MQ_RQ_IN_FLIGHT.
    
    This effectively reverts commit 6131837b1de6 ("blk-mq: count allocated
    but not started requests in iostats inflight") to consolidate blk-mq
    behavior with itself (elevator case) and with original documentation,
    but it differs from the behavior used by the legacy path.
    
    This version differs from v1 by using blk_mq_rq_state to access the
    state attribute.  Avoid using blk_mq_request_started, which was
    suggested, since we don't want to include MQ_RQ_COMPLETE.
    
    Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
    Cc: Omar Sandoval <osandov@fb.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a9364c07add8ec751716ca63f5781f42b2c67ae4
Author: Zhen Lei <thunder.leizhen@huawei.com>
Date:   Thu Sep 24 15:17:54 2020 +0800

    ARC: [dts] fix the errors detected by dtbs_check
    
    [ Upstream commit 05b1be68c4d6d76970025e6139bfd735c2256ee5 ]
    
    xxx/arc/boot/dts/axs101.dt.yaml: dw-apb-ictl@e0012000: $nodename:0: \
    'dw-apb-ictl@e0012000' does not match '^interrupt-controller(@[0-9a-f,]+)*$'
     From schema: xxx/interrupt-controller/snps,dw-apb-ictl.yaml
    
    The node name of the interrupt controller must start with
    "interrupt-controller" instead of "dw-apb-ictl".
    
    Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
    Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e3db2d9af1ce3b8431eea381a45513f4dc6b7f0c
Author: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Date:   Wed Sep 30 13:57:54 2020 -0400

    drm/amd/display: Avoid set zero in the requested clk
    
    [ Upstream commit 2f8be0e516803cc3fd87c1671247896571a5a8fb ]
    
    [Why]
    Sometimes CRTCs can be disabled due to display unplugging or temporarily
    transition in the userspace; in these circumstances, DCE tries to set
    the minimum clock threshold. When we have this situation, the function
    bw_calcs is invoked with number_of_displays set to zero, making DCE set
    dispclk_khz and sclk_khz to zero. For these reasons, we have seen some
    ATOM bios errors that look like:
    
    [drm:atom_op_jump [amdgpu]] *ERROR* atombios stuck in loop for more than
    5secs aborting
    [drm:amdgpu_atom_execute_table_locked [amdgpu]] *ERROR* atombios stuck
    executing EA8A (len 761, WS 0, PS 0) @ 0xEABA
    
    [How]
    This error happens due to an attempt to optimize the bandwidth using the
    sclk, and the dispclk clock set to zero. Technically we handle this in
    the function dce112_set_clock, but we are not considering the case that
    this value is set to zero. This commit fixes this issue by ensuring that
    we never set a minimum value below the minimum clock threshold.
    
    Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
    Acked-by: Eryk Brol <eryk.brol@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4c28fd24b41171ec9c78a9d4e3663acb88873251
Author: Fangzhi Zuo <Jerry.Zuo@amd.com>
Date:   Mon Sep 21 17:52:43 2020 -0400

    drm/amd/display: HDMI remote sink need mode validation for Linux
    
    [ Upstream commit 95d620adb48f7728e67d82f56f756e8d451cf8d2 ]
    
    [Why]
    Currently mode validation is bypassed if remote sink exists. That
    leads to mode set issue when a BW bottle neck exists in the link path,
    e.g., a DP-to-HDMI converter that only supports HDMI 1.4.
    
    Any invalid mode passed to Linux user space will cause the modeset
    failure due to limitation of Linux user space implementation.
    
    [How]
    Mode validation is skipped only if in edid override. For real remote
    sink, clock limit check should be done for HDMI remote sink.
    
    Have HDMI related remote sink going through mode validation to
    elimiate modes which pixel clock exceeds BW limitation.
    
    Signed-off-by: Fangzhi Zuo <Jerry.Zuo@amd.com>
    Reviewed-by: Hersen Wu <hersenxs.wu@amd.com>
    Acked-by: Eryk Brol <eryk.brol@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit be43038ae544bf734e7664ab222690fb3877bd34
Author: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Date:   Fri Sep 4 14:09:58 2020 +0800

    power: supply: test_power: add missing newlines when printing parameters by sysfs
    
    [ Upstream commit c07fa6c1631333f02750cf59f22b615d768b4d8f ]
    
    When I cat some module parameters by sysfs, it displays as follows.
    It's better to add a newline for easy reading.
    
    root@syzkaller:~# cd /sys/module/test_power/parameters/
    root@syzkaller:/sys/module/test_power/parameters# cat ac_online
    onroot@syzkaller:/sys/module/test_power/parameters# cat battery_present
    trueroot@syzkaller:/sys/module/test_power/parameters# cat battery_health
    goodroot@syzkaller:/sys/module/test_power/parameters# cat battery_status
    dischargingroot@syzkaller:/sys/module/test_power/parameters# cat battery_technology
    LIONroot@syzkaller:/sys/module/test_power/parameters# cat usb_online
    onroot@syzkaller:/sys/module/test_power/parameters#
    
    Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a5c925f9c262f61f5a2b2865690912310c1a40b1
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Wed Sep 30 22:05:45 2020 +0800

    ACPI: HMAT: Fix handling of changes from ACPI 6.2 to ACPI 6.3
    
    [ Upstream commit 2c5b9bde95c96942f2873cea6ef383c02800e4a8 ]
    
    In ACPI 6.3, the Memory Proximity Domain Attributes Structure
    changed substantially.  One of those changes was that the flag
    for "Memory Proximity Domain field is valid" was deprecated.
    
    This was because the field "Proximity Domain for the Memory"
    became a required field and hence having a validity flag makes
    no sense.
    
    So the correct logic is to always assume the field is there.
    Current code assumes it never is.
    
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 55743cd6507c6b73928d43fad390bca98c70a7e8
Author: Diana Craciun <diana.craciun@oss.nxp.com>
Date:   Tue Sep 29 11:54:38 2020 +0300

    bus/fsl_mc: Do not rely on caller to provide non NULL mc_io
    
    [ Upstream commit 5026cf605143e764e1785bbf9158559d17f8d260 ]
    
    Before destroying the mc_io, check first that it was
    allocated.
    
    Reviewed-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
    Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
    Signed-off-by: Diana Craciun <diana.craciun@oss.nxp.com>
    Link: https://lore.kernel.org/r/20200929085441.17448-11-diana.craciun@oss.nxp.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5a4494029af98fcd345e209043a026b414821906
Author: Bhaumik Bhatt <bbhatt@codeaurora.org>
Date:   Tue Sep 29 23:22:02 2020 +0530

    bus: mhi: core: Abort suspends due to outgoing pending packets
    
    [ Upstream commit 515847c557dd33167be86cb429fc0674a331bc88 ]
    
    Add the missing check to abort suspends if a client driver has pending
    outgoing packets to send to the device. This allows better utilization
    of the MHI bus wherein clients on the host are not left waiting for
    longer suspend or resume cycles to finish for data transfers.
    
    Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
    Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    Link: https://lore.kernel.org/r/20200929175218.8178-4-manivannan.sadhasivam@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5e2e8f395f2e007caa50234de9373f813dcdc851
Author: Li Jun <jun.li@nxp.com>
Date:   Sun Jul 26 11:17:39 2020 +0800

    usb: dwc3: core: do not queue work if dr_mode is not USB_DR_MODE_OTG
    
    [ Upstream commit dc336b19e82d0454ea60270cd18fbb4749e162f6 ]
    
    Do not try to queue a drd work if dr_mode is not USB_DR_MODE_OTG
    because the work is not inited, this may be triggered by user try
    to change mode file of debugfs on a single role port, which will
    cause below kernel dump:
    [   60.115529] ------------[ cut here ]------------
    [   60.120166] WARNING: CPU: 1 PID: 627 at kernel/workqueue.c:1473
    __queue_work+0x46c/0x520
    [   60.128254] Modules linked in:
    [   60.131313] CPU: 1 PID: 627 Comm: sh Not tainted
    5.7.0-rc4-00022-g914a586-dirty #135
    [   60.139054] Hardware name: NXP i.MX8MQ EVK (DT)
    [   60.143585] pstate: a0000085 (NzCv daIf -PAN -UAO)
    [   60.148376] pc : __queue_work+0x46c/0x520
    [   60.152385] lr : __queue_work+0x314/0x520
    [   60.156393] sp : ffff8000124ebc40
    [   60.159705] x29: ffff8000124ebc40 x28: ffff800011808018
    [   60.165018] x27: ffff800011819ef8 x26: ffff800011d39980
    [   60.170331] x25: ffff800011808018 x24: 0000000000000100
    [   60.175643] x23: 0000000000000013 x22: 0000000000000001
    [   60.180955] x21: ffff0000b7c08e00 x20: ffff0000b6c31080
    [   60.186267] x19: ffff0000bb99bc00 x18: 0000000000000000
    [   60.191579] x17: 0000000000000000 x16: 0000000000000000
    [   60.196891] x15: 0000000000000000 x14: 0000000000000000
    [   60.202202] x13: 0000000000000000 x12: 0000000000000000
    [   60.207515] x11: 0000000000000000 x10: 0000000000000040
    [   60.212827] x9 : ffff800011d55460 x8 : ffff800011d55458
    [   60.218138] x7 : ffff0000b7800028 x6 : 0000000000000000
    [   60.223450] x5 : ffff0000b7800000 x4 : 0000000000000000
    [   60.228762] x3 : ffff0000bb997cc0 x2 : 0000000000000001
    [   60.234074] x1 : 0000000000000000 x0 : ffff0000b6c31088
    [   60.239386] Call trace:
    [   60.241834]  __queue_work+0x46c/0x520
    [   60.245496]  queue_work_on+0x6c/0x90
    [   60.249075]  dwc3_set_mode+0x48/0x58
    [   60.252651]  dwc3_mode_write+0xf8/0x150
    [   60.256489]  full_proxy_write+0x5c/0xa8
    [   60.260327]  __vfs_write+0x18/0x40
    [   60.263729]  vfs_write+0xdc/0x1c8
    [   60.267045]  ksys_write+0x68/0xf0
    [   60.270360]  __arm64_sys_write+0x18/0x20
    [   60.274286]  el0_svc_common.constprop.0+0x68/0x160
    [   60.279077]  do_el0_svc+0x20/0x80
    [   60.282394]  el0_sync_handler+0x10c/0x178
    [   60.286403]  el0_sync+0x140/0x180
    [   60.289716] ---[ end trace 70b155582e2b7988 ]---
    
    Signed-off-by: Li Jun <jun.li@nxp.com>
    Signed-off-by: Felipe Balbi <balbi@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8491cd0cbbb55b9834062ee5d1a11644db9571a8
Author: Xie He <xie.he.0141@gmail.com>
Date:   Mon Sep 28 05:56:43 2020 -0700

    drivers/net/wan/hdlc_fr: Correctly handle special skb->protocol values
    
    [ Upstream commit 8306266c1d51aac9aa7aa907fe99032a58c6382c ]
    
    The fr_hard_header function is used to prepend the header to skbs before
    transmission. It is used in 3 situations:
    1) When a control packet is generated internally in this driver;
    2) When a user sends an skb on an Ethernet-emulating PVC device;
    3) When a user sends an skb on a normal PVC device.
    
    These 3 situations need to be handled differently by fr_hard_header.
    Different headers should be prepended to the skb in different situations.
    
    Currently fr_hard_header distinguishes these 3 situations using
    skb->protocol. For situation 1 and 2, a special skb->protocol value
    will be assigned before calling fr_hard_header, so that it can recognize
    these 2 situations. All skb->protocol values other than these special ones
    are treated by fr_hard_header as situation 3.
    
    However, it is possible that in situation 3, the user sends an skb with
    one of the special skb->protocol values. In this case, fr_hard_header
    would incorrectly treat it as situation 1 or 2.
    
    This patch tries to solve this issue by using skb->dev instead of
    skb->protocol to distinguish between these 3 situations. For situation
    1, skb->dev would be NULL; for situation 2, skb->dev->type would be
    ARPHRD_ETHER; and for situation 3, skb->dev->type would be ARPHRD_DLCI.
    
    This way fr_hard_header would be able to distinguish these 3 situations
    correctly regardless what skb->protocol value the user tries to use in
    situation 3.
    
    Cc: Krzysztof Halasa <khc@pm.waw.pl>
    Signed-off-by: Xie He <xie.he.0141@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 56e567fd5d7f56f104a6c6aab17a2af2ae43259d
Author: Wen Gong <wgong@codeaurora.org>
Date:   Tue Sep 29 20:15:34 2020 +0300

    ath11k: change to disable softirqs for ath11k_regd_update to solve deadlock
    
    [ Upstream commit df648808c6b9989555e247530d8ca0ad0094b361 ]
    
    After base_lock which occupy by ath11k_regd_update, the softirq run for
    WMI_REG_CHAN_LIST_CC_EVENTID maybe arrived and it also need to accuire
    the spin lock, then deadlock happend, change to disable softirqis to solve it.
    
    [  235.576990] ================================
    [  235.576991] WARNING: inconsistent lock state
    [  235.576993] 5.9.0-rc5-wt-ath+ #196 Not tainted
    [  235.576994] --------------------------------
    [  235.576995] inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
    [  235.576997] kworker/u16:1/98 [HC0[0]:SC0[0]:HE1:SE1] takes:
    [  235.576998] ffff9655f75cad98 (&ab->base_lock){+.?.}-{2:2}, at: ath11k_regd_update+0x28/0x1d0 [ath11k]
    [  235.577009] {IN-SOFTIRQ-W} state was registered at:
    [  235.577013]   __lock_acquire+0x219/0x6e0
    [  235.577015]   lock_acquire+0xb6/0x270
    [  235.577018]   _raw_spin_lock+0x2c/0x70
    [  235.577023]   ath11k_reg_chan_list_event.isra.0+0x10d/0x1e0 [ath11k]
    [  235.577028]   ath11k_wmi_tlv_op_rx+0x3c3/0x560 [ath11k]
    [  235.577033]   ath11k_htc_rx_completion_handler+0x207/0x370 [ath11k]
    [  235.577039]   ath11k_ce_recv_process_cb+0x15e/0x1e0 [ath11k]
    [  235.577041]   ath11k_pci_ce_tasklet+0x10/0x30 [ath11k_pci]
    [  235.577043]   tasklet_action_common.constprop.0+0xd4/0xf0
    [  235.577045]   __do_softirq+0xc9/0x482
    [  235.577046]   asm_call_on_stack+0x12/0x20
    [  235.577048]   do_softirq_own_stack+0x49/0x60
    [  235.577049]   irq_exit_rcu+0x9a/0xd0
    [  235.577050]   common_interrupt+0xa1/0x190
    [  235.577052]   asm_common_interrupt+0x1e/0x40
    [  235.577053]   cpu_idle_poll.isra.0+0x2e/0x60
    [  235.577055]   do_idle+0x5f/0xe0
    [  235.577056]   cpu_startup_entry+0x14/0x20
    [  235.577058]   start_kernel+0x443/0x464
    [  235.577060]   secondary_startup_64+0xa4/0xb0
    [  235.577061] irq event stamp: 432035
    [  235.577063] hardirqs last  enabled at (432035): [<ffffffff968d12b4>] _raw_spin_unlock_irqrestore+0x34/0x40
    [  235.577064] hardirqs last disabled at (432034): [<ffffffff968d10d3>] _raw_spin_lock_irqsave+0x63/0x80
    [  235.577066] softirqs last  enabled at (431998): [<ffffffff967115c1>] inet6_fill_ifla6_attrs+0x3f1/0x430
    [  235.577067] softirqs last disabled at (431996): [<ffffffff9671159f>] inet6_fill_ifla6_attrs+0x3cf/0x430
    [  235.577068]
    [  235.577068] other info that might help us debug this:
    [  235.577069]  Possible unsafe locking scenario:
    [  235.577069]
    [  235.577070]        CPU0
    [  235.577070]        ----
    [  235.577071]   lock(&ab->base_lock);
    [  235.577072]   <Interrupt>
    [  235.577073]     lock(&ab->base_lock);
    [  235.577074]
    [  235.577074]  *** DEADLOCK ***
    [  235.577074]
    [  235.577075] 3 locks held by kworker/u16:1/98:
    [  235.577076]  #0: ffff9655f75b1d48 ((wq_completion)ath11k_qmi_driver_event){+.+.}-{0:0}, at: process_one_work+0x1d3/0x5d0
    [  235.577079]  #1: ffffa33cc02f3e70 ((work_completion)(&ab->qmi.event_work)){+.+.}-{0:0}, at: process_one_work+0x1d3/0x5d0
    [  235.577081]  #2: ffff9655f75cad50 (&ab->core_lock){+.+.}-{3:3}, at: ath11k_core_qmi_firmware_ready.part.0+0x4e/0x160 [ath11k]
    [  235.577087]
    [  235.577087] stack backtrace:
    [  235.577088] CPU: 3 PID: 98 Comm: kworker/u16:1 Not tainted 5.9.0-rc5-wt-ath+ #196
    [  235.577089] Hardware name: Intel(R) Client Systems NUC8i7HVK/NUC8i7HVB, BIOS HNKBLi70.86A.0049.2018.0801.1601 08/01/2018
    [  235.577095] Workqueue: ath11k_qmi_driver_event ath11k_qmi_driver_event_work [ath11k]
    [  235.577096] Call Trace:
    [  235.577100]  dump_stack+0x77/0xa0
    [  235.577102]  mark_lock_irq.cold+0x15/0x3c
    [  235.577104]  mark_lock+0x1d7/0x540
    [  235.577105]  mark_usage+0xc7/0x140
    [  235.577107]  __lock_acquire+0x219/0x6e0
    [  235.577108]  ? sched_clock_cpu+0xc/0xb0
    [  235.577110]  lock_acquire+0xb6/0x270
    [  235.577116]  ? ath11k_regd_update+0x28/0x1d0 [ath11k]
    [  235.577118]  ? atomic_notifier_chain_register+0x2d/0x40
    [  235.577120]  _raw_spin_lock+0x2c/0x70
    [  235.577125]  ? ath11k_regd_update+0x28/0x1d0 [ath11k]
    [  235.577130]  ath11k_regd_update+0x28/0x1d0 [ath11k]
    [  235.577136]  __ath11k_mac_register+0x3fb/0x480 [ath11k]
    [  235.577141]  ath11k_mac_register+0x119/0x180 [ath11k]
    [  235.577146]  ath11k_core_pdev_create+0x17/0xe0 [ath11k]
    [  235.577150]  ath11k_core_qmi_firmware_ready.part.0+0x65/0x160 [ath11k]
    [  235.577155]  ath11k_qmi_driver_event_work+0x1c5/0x230 [ath11k]
    [  235.577158]  process_one_work+0x265/0x5d0
    [  235.577160]  worker_thread+0x49/0x300
    [  235.577161]  ? process_one_work+0x5d0/0x5d0
    [  235.577163]  kthread+0x135/0x150
    [  235.577164]  ? kthread_create_worker_on_cpu+0x60/0x60
    [  235.577166]  ret_from_fork+0x22/0x30
    
    Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
    
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/1601399736-3210-7-git-send-email-kvalo@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ea310e6c9947277f624aa5bd4e5b9dca629d5548
Author: Carl Huang <cjhuang@codeaurora.org>
Date:   Wed Sep 30 13:51:12 2020 +0300

    ath11k: fix warning caused by lockdep_assert_held
    
    [ Upstream commit 2f588660e34a982377109872757f1b99d7748d21 ]
    
    Fix warning caused by lockdep_assert_held when CONFIG_LOCKDEP is enabled.
    
    [  271.940647] WARNING: CPU: 6 PID: 0 at drivers/net/wireless/ath/ath11k/hal.c:818 ath11k_hal_srng_access_begin+0x31/0x40 [ath11k]
    [  271.940655] Modules linked in: qrtr_mhi qrtr ns ath11k_pci mhi ath11k qmi_helpers nvme nvme_core
    [  271.940675] CPU: 6 PID: 0 Comm: swapper/6 Kdump: loaded Tainted: G        W         5.9.0-rc5-kalle-bringup-wt-ath+ #4
    [  271.940682] Hardware name: Dell Inc. Inspiron 7590/08717F, BIOS 1.3.0 07/22/2019
    [  271.940698] RIP: 0010:ath11k_hal_srng_access_begin+0x31/0x40 [ath11k]
    [  271.940708] Code: 48 89 f3 85 c0 75 11 48 8b 83 a8 00 00 00 8b 00 89 83 b0 00 00 00 5b c3 48 8d 7e 58 be ff ff ff ff e8 53 24 ec fa 85 c0 75 dd <0f> 0b eb d9 90 66 2e 0f 1f 84 00 00 00 00 00 55 53 48 89 f3 8b 35
    [  271.940718] RSP: 0018:ffffbdf0c0230df8 EFLAGS: 00010246
    [  271.940727] RAX: 0000000000000000 RBX: ffffa12b34e67680 RCX: ffffa12b57a0d800
    [  271.940735] RDX: 0000000000000000 RSI: 00000000ffffffff RDI: ffffa12b34e676d8
    [  271.940742] RBP: ffffa12b34e60000 R08: 0000000000000001 R09: 0000000000000001
    [  271.940753] R10: 0000000000000001 R11: 0000000000000046 R12: 0000000000000000
    [  271.940763] R13: ffffa12b34e60000 R14: ffffa12b34e60000 R15: 0000000000000000
    [  271.940774] FS:  0000000000000000(0000) GS:ffffa12b5a400000(0000) knlGS:0000000000000000
    [  271.940788] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  271.940798] CR2: 00007f8bef282008 CR3: 00000001f4224004 CR4: 00000000003706e0
    [  271.940805] Call Trace:
    [  271.940813]  <IRQ>
    [  271.940835]  ath11k_dp_tx_completion_handler+0x9e/0x950 [ath11k]
    [  271.940847]  ? lock_acquire+0xba/0x3b0
    [  271.940876]  ath11k_dp_service_srng+0x5a/0x2e0 [ath11k]
    [  271.940893]  ath11k_pci_ext_grp_napi_poll+0x1e/0x80 [ath11k_pci]
    [  271.940908]  net_rx_action+0x283/0x4f0
    [  271.940931]  __do_softirq+0xcb/0x499
    [  271.940950]  asm_call_on_stack+0x12/0x20
    [  271.940963]  </IRQ>
    [  271.940979]  do_softirq_own_stack+0x4d/0x60
    [  271.940991]  irq_exit_rcu+0xb0/0xc0
    [  271.941001]  common_interrupt+0xce/0x190
    [  271.941014]  asm_common_interrupt+0x1e/0x40
    [  271.941026] RIP: 0010:cpuidle_enter_state+0x115/0x500
    
    Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
    
    Signed-off-by: Carl Huang <cjhuang@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/1601463073-12106-5-git-send-email-kvalo@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 753e764add0344f2959b054d9a2556212ec54e8a
Author: Wen Gong <wgong@codeaurora.org>
Date:   Tue Sep 29 20:15:35 2020 +0300

    ath11k: Use GFP_ATOMIC instead of GFP_KERNEL in ath11k_dp_htt_get_ppdu_desc
    
    [ Upstream commit 6a8be1baa9116a038cb4f6158cc10134387ca0d0 ]
    
    With SLUB DEBUG CONFIG below crash is seen as kmem_cache_alloc
    is being called in non-atomic context.
    
    To fix this issue, use GFP_ATOMIC instead of GFP_KERNEL kzalloc.
    
    [  357.217088] BUG: sleeping function called from invalid context at mm/slab.h:498
    [  357.217091] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/0
    [  357.217092] INFO: lockdep is turned off.
    [  357.217095] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W         5.9.0-rc5-wt-ath+ #196
    [  357.217096] Hardware name: Intel(R) Client Systems NUC8i7HVK/NUC8i7HVB, BIOS HNKBLi70.86A.0049.2018.0801.1601 08/01/2018
    [  357.217097] Call Trace:
    [  357.217098]  <IRQ>
    [  357.217107]  ? ath11k_dp_htt_get_ppdu_desc+0xa9/0x170 [ath11k]
    [  357.217110]  dump_stack+0x77/0xa0
    [  357.217113]  ___might_sleep.cold+0xa6/0xb6
    [  357.217116]  kmem_cache_alloc_trace+0x1f2/0x270
    [  357.217122]  ath11k_dp_htt_get_ppdu_desc+0xa9/0x170 [ath11k]
    [  357.217129]  ath11k_htt_pull_ppdu_stats.isra.0+0x96/0x270 [ath11k]
    [  357.217135]  ath11k_dp_htt_htc_t2h_msg_handler+0xe7/0x1d0 [ath11k]
    [  357.217137]  ? trace_hardirqs_on+0x1c/0x100
    [  357.217143]  ath11k_htc_rx_completion_handler+0x207/0x370 [ath11k]
    [  357.217149]  ath11k_ce_recv_process_cb+0x15e/0x1e0 [ath11k]
    [  357.217151]  ? handle_irq_event+0x70/0xa8
    [  357.217154]  ath11k_pci_ce_tasklet+0x10/0x30 [ath11k_pci]
    [  357.217157]  tasklet_action_common.constprop.0+0xd4/0xf0
    [  357.217160]  __do_softirq+0xc9/0x482
    [  357.217162]  asm_call_on_stack+0x12/0x20
    [  357.217163]  </IRQ>
    [  357.217166]  do_softirq_own_stack+0x49/0x60
    [  357.217167]  irq_exit_rcu+0x9a/0xd0
    [  357.217169]  common_interrupt+0xa1/0x190
    [  357.217171]  asm_common_interrupt+0x1e/0x40
    [  357.217173] RIP: 0010:cpu_idle_poll.isra.0+0x2e/0x60
    [  357.217175] Code: 8b 35 26 27 74 69 e8 11 c8 3d ff e8 bc fa 42 ff e8 e7 9f 4a ff fb 65 48 8b 1c 25 80 90 01 00 48 8b 03 a8 08 74 0b eb 1c f3 90 <48> 8b 03 a8 08 75 13 8b 0
    [  357.217177] RSP: 0018:ffffffff97403ee0 EFLAGS: 00000202
    [  357.217178] RAX: 0000000000000001 RBX: ffffffff9742b8c0 RCX: 0000000000b890ca
    [  357.217180] RDX: 0000000000b890ca RSI: 0000000000000001 RDI: ffffffff968d0c49
    [  357.217181] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001
    [  357.217182] R10: ffffffff9742b8c0 R11: 0000000000000046 R12: 0000000000000000
    [  357.217183] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000066fdf520
    [  357.217186]  ? cpu_idle_poll.isra.0+0x19/0x60
    [  357.217189]  do_idle+0x5f/0xe0
    [  357.217191]  cpu_startup_entry+0x14/0x20
    [  357.217193]  start_kernel+0x443/0x464
    [  357.217196]  secondary_startup_64+0xa4/0xb0
    
    Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1
    
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/1601399736-3210-8-git-send-email-kvalo@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8b725915481f945dd145a7e40ba8ac042b2e300f
Author: Wright Feng <wright.feng@cypress.com>
Date:   Mon Sep 28 00:49:22 2020 -0500

    brcmfmac: Fix warning message after dongle setup failed
    
    [ Upstream commit 6aa5a83a7ed8036c1388a811eb8bdfa77b21f19c ]
    
    Brcmfmac showed warning message in fweh.c when checking the size of event
    queue which is not initialized. Therefore, we only cancel the worker and
    reset event handler only when it is initialized.
    
    [  145.505899] brcmfmac 0000:02:00.0: brcmf_pcie_setup: Dongle setup
    [  145.929970] ------------[ cut here ]------------
    [  145.929994] WARNING: CPU: 0 PID: 288 at drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c:312
    brcmf_fweh_detach+0xbc/0xd0 [brcmfmac]
    ...
    [  145.930029] Call Trace:
    [  145.930036]  brcmf_detach+0x77/0x100 [brcmfmac]
    [  145.930043]  brcmf_pcie_remove+0x79/0x130 [brcmfmac]
    [  145.930046]  pci_device_remove+0x39/0xc0
    [  145.930048]  device_release_driver_internal+0x141/0x200
    [  145.930049]  device_release_driver+0x12/0x20
    [  145.930054]  brcmf_pcie_setup+0x101/0x3c0 [brcmfmac]
    [  145.930060]  brcmf_fw_request_done+0x11d/0x1f0 [brcmfmac]
    [  145.930062]  ? lock_timer_base+0x7d/0xa0
    [  145.930063]  ? internal_add_timer+0x1f/0xa0
    [  145.930064]  ? add_timer+0x11a/0x1d0
    [  145.930066]  ? __kmalloc_track_caller+0x18c/0x230
    [  145.930068]  ? kstrdup_const+0x23/0x30
    [  145.930069]  ? add_dr+0x46/0x80
    [  145.930070]  ? devres_add+0x3f/0x50
    [  145.930072]  ? usermodehelper_read_unlock+0x15/0x20
    [  145.930073]  ? _request_firmware+0x288/0xa20
    [  145.930075]  request_firmware_work_func+0x36/0x60
    [  145.930077]  process_one_work+0x144/0x360
    [  145.930078]  worker_thread+0x4d/0x3c0
    [  145.930079]  kthread+0x112/0x150
    [  145.930080]  ? rescuer_thread+0x340/0x340
    [  145.930081]  ? kthread_park+0x60/0x60
    [  145.930083]  ret_from_fork+0x25/0x30
    
    Signed-off-by: Wright Feng <wright.feng@cypress.com>
    Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/20200928054922.44580-3-wright.feng@cypress.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8354df5716de60d76f603a0f97a359632e868e2f
Author: Stanislaw Kardach <skardach@marvell.com>
Date:   Tue Sep 29 11:28:14 2020 +0200

    octeontx2-af: fix LD CUSTOM LTYPE aliasing
    
    [ Upstream commit 450f0b978870c384dd81d1176088536555f3170e ]
    
    Since LD contains LTYPE definitions tweaked toward efficient
    NIX_AF_RX_FLOW_KEY_ALG(0..31)_FIELD(0..4) usage, the original location
    of NPC_LT_LD_CUSTOM0/1 was aliased with MPLS_IN_* definitions.
    Moving custom frame to value 6 and 7 removes the aliasing at the cost of
    custom frames being also considered when TCP/UDP RSS algo is configured.
    
    However since the goal of CUSTOM frames is to classify them to a
    separate set of RQs, this cost is acceptable.
    
    Signed-off-by: Stanislaw Kardach <skardach@marvell.com>
    Acked-by: Sunil Goutham <sgoutham@marvell.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a7e0f23a7e568298f1bc63308601e98c20167066
Author: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Date:   Tue Aug 18 22:24:25 2020 +0800

    ACPI: Add out of bounds and numa_off protections to pxm_to_node()
    
    [ Upstream commit 8a3decac087aa897df5af04358c2089e52e70ac4 ]
    
    The function should check the validity of the pxm value before using
    it to index the pxm_to_node_map[] array.
    
    Whilst hardening this code may be good in general, the main intent
    here is to enable following patches that use this function to replace
    acpi_map_pxm_to_node() for non SRAT usecases which should return
    NO_NUMA_NODE for PXM entries not matching with those in SRAT.
    
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
    Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d7918968fead037bafb9bac3ff3b733e18dc61f8
Author: Gao Xiang <hsiangkao@redhat.com>
Date:   Tue Sep 22 09:41:06 2020 -0700

    xfs: avoid LR buffer overrun due to crafted h_len
    
    [ Upstream commit f692d09e9c8fd0f5557c2e87f796a16dd95222b8 ]
    
    Currently, crafted h_len has been blocked for the log
    header of the tail block in commit a70f9fe52daa ("xfs:
    detect and handle invalid iclog size set by mkfs").
    
    However, each log record could still have crafted h_len
    and cause log record buffer overrun. So let's check
    h_len vs buffer size for each log record as well.
    
    Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
    Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Brian Foster <bfoster@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7bd6f89a09d4d6c687ad04175fa8c8af7cfee111
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Mon Sep 21 09:15:08 2020 -0700

    xfs: don't free rt blocks when we're doing a REMAP bunmapi call
    
    [ Upstream commit 8df0fa39bdd86ca81a8d706a6ed9d33cc65ca625 ]
    
    When callers pass XFS_BMAPI_REMAP into xfs_bunmapi, they want the extent
    to be unmapped from the given file fork without the extent being freed.
    We do this for non-rt files, but we forgot to do this for realtime
    files.  So far this isn't a big deal since nobody makes a bunmapi call
    to a rt file with the REMAP flag set, but don't leave a logic bomb.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 66b70f6b0f44b7df1d42a2029e1fd25460c820dd
Author: farah kassabri <fkassabri@habana.ai>
Date:   Tue Aug 4 09:41:32 2020 +0300

    habanalabs: remove security from ARB_MST_QUIET register
    
    [ Upstream commit acd330c141b4c49f468f00719ebc944656061eac ]
    
    Allow user application to write to this register in order
    to be able to configure the quiet period of the QMAN between grants.
    
    Signed-off-by: farah kassabri <fkassabri@habana.ai>
    Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
    Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a00e6c37f32541ae38578d3d411dff273013610c
Author: Joakim Zhang <qiangqing.zhang@nxp.com>
Date:   Tue Dec 10 09:00:13 2019 +0000

    can: flexcan: disable clocks during stop mode
    
    [ Upstream commit 02f71c6605e1f8259c07f16178330db766189a74 ]
    
    Disable clocks while CAN core is in stop mode.
    
    Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
    Tested-by: Sean Nyekjaer <sean@geanix.com>
    Link: https://lore.kernel.org/r/20191210085721.9853-2-qiangqing.zhang@nxp.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e2095095a930d7bf9594db239152c0863a903e0c
Author: Zhengyuan Liu <liuzhengyuan@tj.kylinos.cn>
Date:   Mon Sep 21 10:39:36 2020 +0800

    arm64/mm: return cpu_all_mask when node is NUMA_NO_NODE
    
    [ Upstream commit a194c5f2d2b3a05428805146afcabe5140b5d378 ]
    
    The @node passed to cpumask_of_node() can be NUMA_NO_NODE, in that
    case it will trigger the following WARN_ON(node >= nr_node_ids) due to
    mismatched data types of @node and @nr_node_ids. Actually we should
    return cpu_all_mask just like most other architectures do if passed
    NUMA_NO_NODE.
    
    Also add a similar check to the inline cpumask_of_node() in numa.h.
    
    Signed-off-by: Zhengyuan Liu <liuzhengyuan@tj.kylinos.cn>
    Reviewed-by: Gavin Shan <gshan@redhat.com>
    Link: https://lore.kernel.org/r/20200921023936.21846-1-liuzhengyuan@tj.kylinos.cn
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9fa33ebd64a9e02b4614d533f2c42aa7676071d9
Author: Dmitry Osipenko <digetx@gmail.com>
Date:   Thu Jul 9 20:35:32 2020 +0300

    cpuidle: tegra: Correctly handle result of arm_cpuidle_simple_enter()
    
    [ Upstream commit 1170433e6611402b869c583fa1fbfd85106ff066 ]
    
    The enter() callback of CPUIDLE drivers returns index of the entered idle
    state on success or a negative value on failure. The negative value could
    any negative value, i.e. it doesn't necessarily needs to be a error code.
    That's because CPUIDLE core only cares about the fact of failure and not
    about the reason of the enter() failure.
    
    Like every other enter() callback, the arm_cpuidle_simple_enter() returns
    the entered idle-index on success. Unlike some of other drivers, it never
    fails. It happened that TEGRA_C1=index=err=0 in the code of cpuidle-tegra
    driver, and thus, there is no problem for the cpuidle-tegra driver created
    by the typo in the code which assumes that the arm_cpuidle_simple_enter()
    returns a error code.
    
    The arm_cpuidle_simple_enter() also may return a -ENODEV error if CPU_IDLE
    is disabled in a kernel's config, but all CPUIDLE drivers are disabled if
    CPU_IDLE is disabled, including the cpuidle-tegra driver. So we can't ever
    see the error code from arm_cpuidle_simple_enter() today.
    
    Of course the code may get some changes in the future and then the
    typo may transform into a real bug, so let's correct the typo! The
    tegra_cpuidle_state_enter() is now changed to make it return the entered
    idle-index on success and negative error code on fail, which puts it on
    par with the arm_cpuidle_simple_enter(), making code consistent in regards
    to the error handling.
    
    This patch fixes a minor typo in the code, it doesn't fix any bugs.
    
    Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
    Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0740ee012c3e343d441cda980e4a0991abee93c6
Author: Chuck Lever <chuck.lever@oracle.com>
Date:   Wed Jul 8 16:09:53 2020 -0400

    SUNRPC: Mitigate cond_resched() in xprt_transmit()
    
    [ Upstream commit 6f9f17287e78e5049931af2037b15b26d134a32a ]
    
    The original purpose of this expensive call is to prevent a long
    queue of requests from blocking other work.
    
    The cond_resched() call is unnecessary after just a single send
    operation.
    
    For longer queues, instead of invoking the kernel scheduler, simply
    release the transport send lock and return to the RPC scheduler.
    
    Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8101c05f96be04c2d079fb07964ef05461775aa7
Author: Peter Chen <peter.chen@nxp.com>
Date:   Fri Sep 18 16:17:49 2020 +0300

    usb: xhci: omit duplicate actions when suspending a runtime suspended host.
    
    [ Upstream commit 18a367e8947d72dd91b6fc401e88a2952c6363f7 ]
    
    If the xhci-plat.c is the platform driver, after the runtime pm is
    enabled, the xhci_suspend is called if nothing is connected on
    the port. When the system goes to suspend, it will call xhci_suspend again
    if USB wakeup is enabled.
    
    Since the runtime suspend wakeup setting is not always the same as
    system suspend wakeup setting, eg, at runtime suspend we always need
    wakeup if the controller is in low power mode; but at system suspend,
    we may not need wakeup. So, we move the judgement after changing
    wakeup setting.
    
    [commit message rewording -Mathias]
    
    Reviewed-by: Jun Li <jun.li@nxp.com>
    Signed-off-by: Peter Chen <peter.chen@nxp.com>
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Link: https://lore.kernel.org/r/20200918131752.16488-8-mathias.nyman@linux.intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d980c86bec856001d23f04442020ba9822d1289d
Author: Felix Fietkau <nbd@nbd.name>
Date:   Tue Sep 8 14:36:49 2020 +0200

    mac80211: add missing queue/hash initialization to 802.3 xmit
    
    [ Upstream commit 5f8d69eaab1915df97f4f2aca89ea16abdd092d5 ]
    
    Fixes AQL for encap-offloaded tx
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20200908123702.88454-2-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b0cd0b466a97b518630d7e26371a7a6d89cb9c13
Author: Luben Tuikov <luben.tuikov@amd.com>
Date:   Wed Sep 16 13:03:50 2020 -0400

    drm/amdgpu: No sysfs, not an error condition
    
    [ Upstream commit 5aea5327ea2ddf544cbeff096f45fc2319b0714e ]
    
    Not being able to create amdgpu sysfs attributes
    is not a fatal error warranting not to continue
    to try to bring up the display. Thus, if we get
    an error trying to create amdgpu sysfs attrs,
    report it and continue on to try to bring up
    a display.
    
    Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
    Acked-by: Slava Abramov <slava.abramov@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fc5382d70826c92e90d9efa90a4c671efe15f268
Author: Linu Cherian <lcherian@marvell.com>
Date:   Wed Sep 16 13:17:35 2020 -0600

    coresight: Make sysfs functional on topologies with per core sink
    
    [ Upstream commit 6d578258b955fc8888e1bbd9a8fefe7b10065a84 ]
    
    Coresight driver assumes sink is common across all the ETMs,
    and tries to build a path between ETM and the first enabled
    sink found using bus based search. This breaks sysFS usage
    on implementations that has multiple per core sinks in
    enabled state.
    
    To fix this, coresight_get_enabled_sink API is updated to
    do a connection based search starting from the given source,
    instead of bus based search.
    With sink selection using sysfs depecrated for perf interface,
    provision for reset is removed as well in this API.
    
    Signed-off-by: Linu Cherian <lcherian@marvell.com>
    [Fixed indentation problem and removed obsolete comment]
    Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Link: https://lore.kernel.org/r/20200916191737.4001561-15-mathieu.poirier@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1737a0bd8f5ecdd2774f31fe41c7454c355e09c1
Author: Lang Dai <lang.dai@intel.com>
Date:   Mon Sep 14 11:26:41 2020 +0800

    uio: free uio id after uio file node is freed
    
    [ Upstream commit 8fd0e2a6df262539eaa28b0a2364cca10d1dc662 ]
    
    uio_register_device() do two things.
    1) get an uio id from a global pool, e.g. the id is <A>
    2) create file nodes like /sys/class/uio/uio<A>
    
    uio_unregister_device() do two things.
    1) free the uio id <A> and return it to the global pool
    2) free the file node /sys/class/uio/uio<A>
    
    There is a situation is that one worker is calling uio_unregister_device(),
    and another worker is calling uio_register_device().
    If the two workers are X and Y, they go as below sequence,
    1) X free the uio id <AAA>
    2) Y get an uio id <AAA>
    3) Y create file node /sys/class/uio/uio<AAA>
    4) X free the file note /sys/class/uio/uio<AAA>
    Then it will failed at the 3rd step and cause the phenomenon we saw as it
    is creating a duplicated file node.
    
    Failure reports as follows:
    sysfs: cannot create duplicate filename '/class/uio/uio10'
    Call Trace:
       sysfs_do_create_link_sd.isra.2+0x9e/0xb0
       sysfs_create_link+0x25/0x40
       device_add+0x2c4/0x640
       __uio_register_device+0x1c5/0x576 [uio]
       adf_uio_init_bundle_dev+0x231/0x280 [intel_qat]
       adf_uio_register+0x1c0/0x340 [intel_qat]
       adf_dev_start+0x202/0x370 [intel_qat]
       adf_dev_start_async+0x40/0xa0 [intel_qat]
       process_one_work+0x14d/0x410
       worker_thread+0x4b/0x460
       kthread+0x105/0x140
     ? process_one_work+0x410/0x410
     ? kthread_bind+0x40/0x40
     ret_from_fork+0x1f/0x40
     Code: 85 c0 48 89 c3 74 12 b9 00 10 00 00 48 89 c2 31 f6 4c 89 ef
     e8 ec c4 ff ff 4c 89 e2 48 89 de 48 c7 c7 e8 b4 ee b4 e8 6a d4 d7
     ff <0f> 0b 48 89 df e8 20 fa f3 ff 5b 41 5c 41 5d 5d c3 66 0f 1f 84
    ---[ end trace a7531c1ed5269e84 ]---
     c6xxvf b002:00:00.0: Failed to register UIO devices
     c6xxvf b002:00:00.0: Failed to register UIO devices
    
    Signed-off-by: Lang Dai <lang.dai@intel.com>
    
    Link: https://lore.kernel.org/r/1600054002-17722-1-git-send-email-lang.dai@intel.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 818b65a0dc507ac6d8e929056fce375674cd04b2
Author: Oliver Neukum <oneukum@suse.com>
Date:   Thu Sep 17 13:26:00 2020 +0200

    USB: adutux: fix debugging
    
    [ Upstream commit c56150c1bc8da5524831b1dac2eec3c67b89f587 ]
    
    Handling for removal of the controller was missing at one place.
    Add it.
    
    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Link: https://lore.kernel.org/r/20200917112600.26508-1-oneukum@suse.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f43e2b942540b8d7cf68d9191d49104ce205397e
Author: Alain Volmat <avolmat@me.com>
Date:   Mon Aug 31 08:10:11 2020 +0200

    cpufreq: sti-cpufreq: add stih418 support
    
    [ Upstream commit 01a163c52039e9426c7d3d3ab16ca261ad622597 ]
    
    The STiH418 can be controlled the same way as STiH407 &
    STiH410 regarding cpufreq.
    
    Signed-off-by: Alain Volmat <avolmat@me.com>
    Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 68f513d3e7e8743d6deb1c58f672b4badfd5653b
Author: Zong Li <zong.li@sifive.com>
Date:   Mon Aug 31 15:33:49 2020 +0800

    riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO
    
    [ Upstream commit b5fca7c55f9fbab5ad732c3bce00f31af6ba5cfa ]
    
    AT_VECTOR_SIZE_ARCH should be defined with the maximum number of
    NEW_AUX_ENT entries that ARCH_DLINFO can contain, but it wasn't defined
    for RISC-V at all even though ARCH_DLINFO will contain one NEW_AUX_ENT
    for the VDSO address.
    
    Signed-off-by: Zong Li <zong.li@sifive.com>
    Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
    Reviewed-by: Pekka Enberg <penberg@kernel.org>
    Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5a328deb5bf78730ef6c6ffde14efaca90d93f66
Author: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Date:   Thu Aug 20 14:26:07 2020 -0400

    drm/amd/display: Check clock table return
    
    [ Upstream commit 4b4f21ff7f5d11bb77e169b306dcbc5b216f5db5 ]
    
    During the load processes for Renoir, our display code needs to retrieve
    the SMU clock and voltage table, however, this operation can fail which
    means that we have to check this scenario. Currently, we are not
    handling this case properly and as a result, we have seen the following
    dmesg log during the boot:
    
    RIP: 0010:rn_clk_mgr_construct+0x129/0x3d0 [amdgpu]
    ...
    Call Trace:
     dc_clk_mgr_create+0x16a/0x1b0 [amdgpu]
     dc_create+0x231/0x760 [amdgpu]
    
    This commit fixes this issue by checking the return status retrieved
    from the clock table before try to populate any bandwidth.
    
    Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0018d0254fe621ad3ce225a0b847f28033565d84
Author: Magnus Karlsson <magnus.karlsson@intel.com>
Date:   Thu Sep 10 10:31:05 2020 +0200

    samples/bpf: Fix possible deadlock in xdpsock
    
    [ Upstream commit 5a2a0dd88f0f267ac5953acd81050ae43a82201f ]
    
    Fix a possible deadlock in the l2fwd application in xdpsock that can
    occur when there is no space in the Tx ring. There are two ways to get
    the kernel to consume entries in the Tx ring: calling sendto() to make
    it send packets and freeing entries from the completion ring, as the
    kernel will not send a packet if there is no space for it to add a
    completion entry in the completion ring. The Tx loop in l2fwd only
    used to call sendto(). This patches adds cleaning the completion ring
    in that loop.
    
    Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Link: https://lore.kernel.org/bpf/1599726666-8431-3-git-send-email-magnus.karlsson@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4c210f8a0907d85687a9732f67f54e19d51847d9
Author: Stephen Smalley <stephen.smalley.work@gmail.com>
Date:   Thu Sep 10 10:28:05 2020 -0400

    selinux: access policycaps with READ_ONCE/WRITE_ONCE
    
    [ Upstream commit e8ba53d0023a76ba0f50e6ee3e6288c5442f9d33 ]
    
    Use READ_ONCE/WRITE_ONCE for all accesses to the
    selinux_state.policycaps booleans to prevent compiler
    mischief.
    
    Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4388cebc2e785383b3e50330c6afe5a0355b0d6c
Author: Yonghong Song <yhs@fb.com>
Date:   Thu Sep 10 13:27:18 2020 -0700

    selftests/bpf: Define string const as global for test_sysctl_prog.c
    
    [ Upstream commit 6e057fc15a2da4ee03eb1fa6889cf687e690106e ]
    
    When tweaking llvm optimizations, I found that selftest build failed
    with the following error:
      libbpf: elf: skipping unrecognized data section(6) .rodata.str1.1
      libbpf: prog 'sysctl_tcp_mem': bad map relo against '.L__const.is_tcp_mem.tcp_mem_name'
              in section '.rodata.str1.1'
      Error: failed to open BPF object file: Relocation failed
      make: *** [/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h] Error 255
      make: *** Deleting file `/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h'
    
    The local string constant "tcp_mem_name" is put into '.rodata.str1.1' section
    which libbpf cannot handle. Using untweaked upstream llvm, "tcp_mem_name"
    is completely inlined after loop unrolling.
    
    Commit 7fb5eefd7639 ("selftests/bpf: Fix test_sysctl_loop{1, 2}
    failure due to clang change") solved a similar problem by defining
    the string const as a global. Let us do the same here
    for test_sysctl_prog.c so it can weather future potential llvm changes.
    
    Signed-off-by: Yonghong Song <yhs@fb.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Acked-by: Andrii Nakryiko <andriin@fb.com>
    Link: https://lore.kernel.org/bpf/20200910202718.956042-1-yhs@fb.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d8e784352dc1e14182e01c16d612b48cc7024b95
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Thu Sep 10 18:12:16 2020 +0200

    nfc: s3fwrn5: Add missing CRYPTO_HASH dependency
    
    [ Upstream commit 4aa62c62d4c41d71b2bda5ed01b78961829ee93c ]
    
    The driver uses crypto hash functions so it needs to select CRYPTO_HASH.
    This fixes build errors:
    
      arc-linux-ld: drivers/nfc/s3fwrn5/firmware.o: in function `s3fwrn5_fw_download':
      firmware.c:(.text+0x152): undefined reference to `crypto_alloc_shash'
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 96d06ba94da7762eb6f3f321a06ca8d7b6bfbe6f
Author: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Date:   Fri Aug 7 10:35:30 2020 +0200

    media: uvcvideo: Fix dereference of out-of-bound list iterator
    
    [ Upstream commit f875bcc375c738bf2f599ff2e1c5b918dbd07c45 ]
    
    Fixes the following coccinelle report:
    
    drivers/media/usb/uvc/uvc_ctrl.c:1860:5-11:
    ERROR: invalid reference to the index variable of the iterator on line 1854
    
    by adding a boolean variable to check if the loop has found the
    
    Found using - Coccinelle (http://coccinelle.lip6.fr)
    
    [Replace cursor variable with bool found]
    
    Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 26a1c2d3e9d49eaa45c49b08e76da3e110063514
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Tue Apr 28 13:09:35 2020 +0200

    drm: panfrost: fix common struct sg_table related issues
    
    [ Upstream commit 34a4e66faf8b22c8409cbd46839ba5e488b1e6a9 ]
    
    The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
    returns the number of the created entries in the DMA address space.
    However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
    dma_unmap_sg must be called with the original number of the entries
    passed to the dma_map_sg().
    
    struct sg_table is a common structure used for describing a non-contiguous
    memory buffer, used commonly in the DRM and graphics subsystems. It
    consists of a scatterlist with memory pages and DMA addresses (sgl entry),
    as well as the number of scatterlist entries: CPU pages (orig_nents entry)
    and DMA mapped pages (nents entry).
    
    It turned out that it was a common mistake to misuse nents and orig_nents
    entries, calling DMA-mapping functions with a wrong number of entries or
    ignoring the number of mapped entries returned by the dma_map_sg()
    function.
    
    To avoid such issues, lets use a common dma-mapping wrappers operating
    directly on the struct sg_table objects and use scatterlist page
    iterators where possible. This, almost always, hides references to the
    nents and orig_nents entries, making the code robust, easier to follow
    and copy/paste safe.
    
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Reviewed-by: Steven Price <steven.price@arm.com>
    Reviewed-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e65ea28f61b4009b8ca658d105934c25b150f089
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Tue Apr 28 13:09:11 2020 +0200

    drm: lima: fix common struct sg_table related issues
    
    [ Upstream commit c3d9c17f486d5c54940487dc31a54ebfdeeb371a ]
    
    The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
    returns the number of the created entries in the DMA address space.
    However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
    dma_unmap_sg must be called with the original number of the entries
    passed to the dma_map_sg().
    
    struct sg_table is a common structure used for describing a non-contiguous
    memory buffer, used commonly in the DRM and graphics subsystems. It
    consists of a scatterlist with memory pages and DMA addresses (sgl entry),
    as well as the number of scatterlist entries: CPU pages (orig_nents entry)
    and DMA mapped pages (nents entry).
    
    It turned out that it was a common mistake to misuse nents and orig_nents
    entries, calling DMA-mapping functions with a wrong number of entries or
    ignoring the number of mapped entries returned by the dma_map_sg()
    function.
    
    To avoid such issues, lets use a common dma-mapping wrappers operating
    directly on the struct sg_table objects and use scatterlist page
    iterators where possible. This, almost always, hides references to the
    nents and orig_nents entries, making the code robust, easier to follow
    and copy/paste safe.
    
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Reviewed-by: Qiang Yu <yuq825@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1e454c7519b3c419ea2b6b5820e41be927e6b167
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Fri May 8 16:07:13 2020 +0200

    xen: gntdev: fix common struct sg_table related issues
    
    [ Upstream commit d1749eb1ab85e04e58c29e58900e3abebbdd6e82 ]
    
    The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
    returns the number of the created entries in the DMA address space.
    However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
    dma_unmap_sg must be called with the original number of the entries
    passed to the dma_map_sg().
    
    struct sg_table is a common structure used for describing a non-contiguous
    memory buffer, used commonly in the DRM and graphics subsystems. It
    consists of a scatterlist with memory pages and DMA addresses (sgl entry),
    as well as the number of scatterlist entries: CPU pages (orig_nents entry)
    and DMA mapped pages (nents entry).
    
    It turned out that it was a common mistake to misuse nents and orig_nents
    entries, calling DMA-mapping functions with a wrong number of entries or
    ignoring the number of mapped entries returned by the dma_map_sg()
    function.
    
    To avoid such issues, lets use a common dma-mapping wrappers operating
    directly on the struct sg_table objects and use scatterlist page
    iterators where possible. This, almost always, hides references to the
    nents and orig_nents entries, making the code robust, easier to follow
    and copy/paste safe.
    
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Acked-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 27d9825cc65f2136de87863c2938d9c218bf118e
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Tue Apr 28 13:08:41 2020 +0200

    drm: exynos: fix common struct sg_table related issues
    
    [ Upstream commit 84404614167b829f7b58189cd24b6c0c74897171 ]
    
    The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
    returns the number of the created entries in the DMA address space.
    However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
    dma_unmap_sg must be called with the original number of the entries
    passed to the dma_map_sg().
    
    struct sg_table is a common structure used for describing a non-contiguous
    memory buffer, used commonly in the DRM and graphics subsystems. It
    consists of a scatterlist with memory pages and DMA addresses (sgl entry),
    as well as the number of scatterlist entries: CPU pages (orig_nents entry)
    and DMA mapped pages (nents entry).
    
    It turned out that it was a common mistake to misuse nents and orig_nents
    entries, calling DMA-mapping functions with a wrong number of entries or
    ignoring the number of mapped entries returned by the dma_map_sg()
    function.
    
    To avoid such issues, lets use a common dma-mapping wrappers operating
    directly on the struct sg_table objects and use scatterlist page
    iterators where possible. This, almost always, hides references to the
    nents and orig_nents entries, making the code robust, easier to follow
    and copy/paste safe.
    
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
    Acked-by : Inki Dae <inki.dae@samsung.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 74187a81d873da4e672f608230fc92582deb0cd3
Author: Yonghong Song <yhs@fb.com>
Date:   Tue Sep 8 10:57:02 2020 -0700

    bpf: Permit map_ptr arithmetic with opcode add and offset 0
    
    [ Upstream commit 7c6967326267bd5c0dded0a99541357d70dd11ac ]
    
    Commit 41c48f3a98231 ("bpf: Support access
    to bpf map fields") added support to access map fields
    with CORE support. For example,
    
                struct bpf_map {
                        __u32 max_entries;
                } __attribute__((preserve_access_index));
    
                struct bpf_array {
                        struct bpf_map map;
                        __u32 elem_size;
                } __attribute__((preserve_access_index));
    
                struct {
                        __uint(type, BPF_MAP_TYPE_ARRAY);
                        __uint(max_entries, 4);
                        __type(key, __u32);
                        __type(value, __u32);
                } m_array SEC(".maps");
    
                SEC("cgroup_skb/egress")
                int cg_skb(void *ctx)
                {
                        struct bpf_array *array = (struct bpf_array *)&m_array;
    
                        /* .. array->map.max_entries .. */
                }
    
    In kernel, bpf_htab has similar structure,
    
                struct bpf_htab {
                        struct bpf_map map;
                        ...
                }
    
    In the above cg_skb(), to access array->map.max_entries, with CORE, the clang will
    generate two builtin's.
                base = &m_array;
                /* access array.map */
                map_addr = __builtin_preserve_struct_access_info(base, 0, 0);
                /* access array.map.max_entries */
                max_entries_addr = __builtin_preserve_struct_access_info(map_addr, 0, 0);
                max_entries = *max_entries_addr;
    
    In the current llvm, if two builtin's are in the same function or
    in the same function after inlining, the compiler is smart enough to chain
    them together and generates like below:
                base = &m_array;
                max_entries = *(base + reloc_offset); /* reloc_offset = 0 in this case */
    and we are fine.
    
    But if we force no inlining for one of functions in test_map_ptr() selftest, e.g.,
    check_default(), the above two __builtin_preserve_* will be in two different
    functions. In this case, we will have code like:
       func check_hash():
                reloc_offset_map = 0;
                base = &m_array;
                map_base = base + reloc_offset_map;
                check_default(map_base, ...)
       func check_default(map_base, ...):
                max_entries = *(map_base + reloc_offset_max_entries);
    
    In kernel, map_ptr (CONST_PTR_TO_MAP) does not allow any arithmetic.
    The above "map_base = base + reloc_offset_map" will trigger a verifier failure.
      ; VERIFY(check_default(&hash->map, map));
      0: (18) r7 = 0xffffb4fe8018a004
      2: (b4) w1 = 110
      3: (63) *(u32 *)(r7 +0) = r1
       R1_w=invP110 R7_w=map_value(id=0,off=4,ks=4,vs=8,imm=0) R10=fp0
      ; VERIFY_TYPE(BPF_MAP_TYPE_HASH, check_hash);
      4: (18) r1 = 0xffffb4fe8018a000
      6: (b4) w2 = 1
      7: (63) *(u32 *)(r1 +0) = r2
       R1_w=map_value(id=0,off=0,ks=4,vs=8,imm=0) R2_w=invP1 R7_w=map_value(id=0,off=4,ks=4,vs=8,imm=0) R10=fp0
      8: (b7) r2 = 0
      9: (18) r8 = 0xffff90bcb500c000
      11: (18) r1 = 0xffff90bcb500c000
      13: (0f) r1 += r2
      R1 pointer arithmetic on map_ptr prohibited
    
    To fix the issue, let us permit map_ptr + 0 arithmetic which will
    result in exactly the same map_ptr.
    
    Signed-off-by: Yonghong Song <yhs@fb.com>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Acked-by: Andrii Nakryiko <andriin@fb.com>
    Link: https://lore.kernel.org/bpf/20200908175702.2463625-1-yhs@fb.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8ec3f414377b2e16bfdaced73b478a3e1313d28f
Author: Douglas Anderson <dianders@chromium.org>
Date:   Tue Jun 30 15:14:38 2020 -0700

    kgdb: Make "kgdbcon" work properly with "kgdb_earlycon"
    
    [ Upstream commit b18b099e04f450cdc77bec72acefcde7042bd1f3 ]
    
    On my system the kernel processes the "kgdb_earlycon" parameter before
    the "kgdbcon" parameter.  When we setup "kgdb_earlycon" we'll end up
    in kgdb_register_callbacks() and "kgdb_use_con" won't have been set
    yet so we'll never get around to starting "kgdbcon".  Let's remedy
    this by detecting that the IO module was already registered when
    setting "kgdb_use_con" and registering the console then.
    
    As part of this, to avoid pre-declaring things, move the handling of
    the "kgdbcon" further down in the file.
    
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Link: https://lore.kernel.org/r/20200630151422.1.I4aa062751ff5e281f5116655c976dff545c09a46@changeid
    Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 828a1847b119b97c0376a8cc52fe34102617d59b
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Wed Aug 19 11:57:19 2020 +1000

    selftests/powerpc: Make using_hash_mmu() work on Cell & PowerMac
    
    [ Upstream commit 34c103342be3f9397e656da7c5cc86e97b91f514 ]
    
    These platforms don't show the MMU in /proc/cpuinfo, but they always
    use hash, so teach using_hash_mmu() that.
    
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200819015727.1977134-1-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit aa718a71091409d85bee367bc52620d4aa8391be
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sat Aug 29 22:01:09 2020 +0900

    ia64: kprobes: Use generic kretprobe trampoline handler
    
    [ Upstream commit e792ff804f49720ce003b3e4c618b5d996256a18 ]
    
    Use the generic kretprobe trampoline handler. Don't use
    framepointer verification.
    
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/159870606883.1229682.12331813108378725668.stgit@devnote2
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bd12a494701d0ea3b463e47b6c8bfe6b6157179d
Author: John Ogness <john.ogness@linutronix.de>
Date:   Wed Aug 12 09:37:22 2020 +0206

    printk: reduce LOG_BUF_SHIFT range for H8300
    
    [ Upstream commit 550c10d28d21bd82a8bb48debbb27e6ed53262f6 ]
    
    The .bss section for the h8300 is relatively small. A value of
    CONFIG_LOG_BUF_SHIFT that is larger than 19 will create a static
    printk ringbuffer that is too large. Limit the range appropriately
    for the H8300.
    
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: John Ogness <john.ogness@linutronix.de>
    Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Petr Mladek <pmladek@suse.com>
    Link: https://lore.kernel.org/r/20200812073122.25412-1-john.ogness@linutronix.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e5ac60e9807c00eab5662a8fd73694ed30910d9b
Author: Valentin Schneider <valentin.schneider@arm.com>
Date:   Sat Aug 29 14:00:16 2020 +0100

    arm64: topology: Stop using MPIDR for topology information
    
    [ Upstream commit 3102bc0e6ac752cc5df896acb557d779af4d82a1 ]
    
    In the absence of ACPI or DT topology data, we fallback to haphazardly
    decoding *something* out of MPIDR. Sadly, the contents of that register are
    mostly unusable due to the implementation leniancy and things like Aff0
    having to be capped to 15 (despite being encoded on 8 bits).
    
    Consider a simple system with a single package of 32 cores, all under the
    same LLC. We ought to be shoving them in the same core_sibling mask, but
    MPIDR is going to look like:
    
      | CPU  | 0 | ... | 15 | 16 | ... | 31 |
      |------+---+-----+----+----+-----+----+
      | Aff0 | 0 | ... | 15 |  0 | ... | 15 |
      | Aff1 | 0 | ... |  0 |  1 | ... |  1 |
      | Aff2 | 0 | ... |  0 |  0 | ... |  0 |
    
    Which will eventually yield
    
      core_sibling(0-15)  == 0-15
      core_sibling(16-31) == 16-31
    
    NUMA woes
    =========
    
    If we try to play games with this and set up NUMA boundaries within those
    groups of 16 cores via e.g. QEMU:
    
      # Node0: 0-9; Node1: 10-19
      $ qemu-system-aarch64 <blah> \
        -smp 20 -numa node,cpus=0-9,nodeid=0 -numa node,cpus=10-19,nodeid=1
    
    The scheduler's MC domain (all CPUs with same LLC) is going to be built via
    
      arch_topology.c::cpu_coregroup_mask()
    
    In there we try to figure out a sensible mask out of the topology
    information we have. In short, here we'll pick the smallest of NUMA or
    core sibling mask.
    
      node_mask(CPU9)    == 0-9
      core_sibling(CPU9) == 0-15
    
    MC mask for CPU9 will thus be 0-9, not a problem.
    
      node_mask(CPU10)    == 10-19
      core_sibling(CPU10) == 0-15
    
    MC mask for CPU10 will thus be 10-19, not a problem.
    
      node_mask(CPU16)    == 10-19
      core_sibling(CPU16) == 16-19
    
    MC mask for CPU16 will thus be 16-19... Uh oh. CPUs 16-19 are in two
    different unique MC spans, and the scheduler has no idea what to make of
    that. That triggers the WARN_ON() added by commit
    
      ccf74128d66c ("sched/topology: Assert non-NUMA topology masks don't (partially) overlap")
    
    Fixing MPIDR-derived topology
    =============================
    
    We could try to come up with some cleverer scheme to figure out which of
    the available masks to pick, but really if one of those masks resulted from
    MPIDR then it should be discarded because it's bound to be bogus.
    
    I was hoping to give MPIDR a chance for SMT, to figure out which threads are
    in the same core using Aff1-3 as core ID, but Sudeep and Robin pointed out
    to me that there are systems out there where *all* cores have non-zero
    values in their higher affinity fields (e.g. RK3288 has "5" in all of its
    cores' MPIDR.Aff1), which would expose a bogus core ID to userspace.
    
    Stop using MPIDR for topology information. When no other source of topology
    information is available, mark each CPU as its own core and its NUMA node
    as its LLC domain.
    
    Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
    Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
    Link: https://lore.kernel.org/r/20200829130016.26106-1-valentin.schneider@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9dc81e0a8bdf8964230d581ac1875228979533e6
Author: Dmitry Osipenko <digetx@gmail.com>
Date:   Sun Aug 30 22:14:37 2020 +0300

    brcmfmac: increase F2 watermark for BCM4329
    
    [ Upstream commit 317da69d10b0247c4042354eb90c75b81620ce9d ]
    
    This patch fixes SDHCI CRC errors during of RX throughput testing on
    BCM4329 chip if SDIO BUS is clocked above 25MHz. In particular the
    checksum problem is observed on NVIDIA Tegra20 SoCs. The good watermark
    value is borrowed from downstream BCMDHD driver and it's matching to the
    value that is already used for the BCM4339 chip, hence let's re-use it
    for BCM4329.
    
    Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
    Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/20200830191439.10017-2-digetx@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d84978ad61367d269befe972790d898fba7ed594
Author: Antonio Borneo <antonio.borneo@st.com>
Date:   Wed Jul 1 21:42:34 2020 +0200

    drm/bridge/synopsys: dsi: add support for non-continuous HS clock
    
    [ Upstream commit c6d94e37bdbb6dfe7e581e937a915ab58399b8a5 ]
    
    Current code enables the HS clock when video mode is started or to
    send out a HS command, and disables the HS clock to send out a LP
    command. This is not what DSI spec specify.
    
    Enable HS clock either in command and in video mode.
    Set automatic HS clock management for panels and devices that
    support non-continuous HS clock.
    
    Signed-off-by: Antonio Borneo <antonio.borneo@st.com>
    Tested-by: Philippe Cornu <philippe.cornu@st.com>
    Reviewed-by: Philippe Cornu <philippe.cornu@st.com>
    Acked-by: Neil Armstrong <narmstrong@baylibre.com>
    Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200701194234.18123-1-yannick.fertre@st.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d8a4ba7bfedf79e9759794f1961551b0fd6cbd74
Author: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Date:   Sat Aug 22 11:45:28 2020 +0530

    mmc: via-sdmmc: Fix data race bug
    
    [ Upstream commit 87d7ad089b318b4f319bf57f1daa64eb6d1d10ad ]
    
    via_save_pcictrlreg() should be called with host->lock held
    as it writes to pm_pcictrl_reg, otherwise there can be a race
    condition between via_sd_suspend() and via_sdc_card_detect().
    The same pattern is used in the function via_reset_pcictrl()
    as well, where via_save_pcictrlreg() is called with host->lock
    held.
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
    Link: https://lore.kernel.org/r/20200822061528.7035-1-madhuparnabhowmik10@gmail.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 337f7744396a374ff2faffe5abf39585926ac821
Author: Hans Verkuil <hverkuil@xs4all.nl>
Date:   Fri Jul 3 11:20:32 2020 +0200

    media: imx274: fix frame interval handling
    
    [ Upstream commit 49b20d981d723fae5a93843c617af2b2c23611ec ]
    
    1) the numerator and/or denominator might be 0, in that case
       fall back to the default frame interval. This is per the spec
       and this caused a v4l2-compliance failure.
    
    2) the updated frame interval wasn't returned in the s_frame_interval
       subdev op.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Reviewed-by: Luca Ceresoli <luca@lucaceresoli.net>
    Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9df9101643b497bd3fbeaf14ada0b429ff332c3d
Author: Sidong Yang <realwakka@gmail.com>
Date:   Fri Aug 28 12:45:53 2020 +0000

    drm/vkms: avoid warning in vkms_get_vblank_timestamp
    
    [ Upstream commit 05ca530268a9d0ab3547e7b288635e35990a77c4 ]
    
    This patch avoid the warning in vkms_get_vblank_timestamp when vblanks
    aren't enabled. When running igt test kms_cursor_crc just after vkms
    module, the warning raised like below. Initial value of vblank time is
    zero and hrtimer.node.expires is also zero if vblank aren't enabled
    before. vkms module isn't real hardware but just virtual hardware
    module. so vkms can't generate a resonable timestamp when hrtimer is
    off. it's best to grab the current time.
    
    [106444.464503] [IGT] kms_cursor_crc: starting subtest pipe-A-cursor-size-change
    [106444.471475] WARNING: CPU: 0 PID: 10109 at
    vkms_get_vblank_timestamp+0x42/0x50 [vkms]
    [106444.471511] CPU: 0 PID: 10109 Comm: kms_cursor_crc Tainted: G        W  OE
    5.9.0-rc1+ #6
    [106444.471514] RIP: 0010:vkms_get_vblank_timestamp+0x42/0x50 [vkms]
    [106444.471528] Call Trace:
    [106444.471551]  drm_get_last_vbltimestamp+0xb9/0xd0 [drm]
    [106444.471566]  drm_reset_vblank_timestamp+0x63/0xe0 [drm]
    [106444.471579]  drm_crtc_vblank_on+0x85/0x150 [drm]
    [106444.471582]  vkms_crtc_atomic_enable+0xe/0x10 [vkms]
    [106444.471592]  drm_atomic_helper_commit_modeset_enables+0x1db/0x230
    [drm_kms_helper]
    [106444.471594]  vkms_atomic_commit_tail+0x38/0xc0 [vkms]
    [106444.471601]  commit_tail+0x97/0x130 [drm_kms_helper]
    [106444.471608]  drm_atomic_helper_commit+0x117/0x140 [drm_kms_helper]
    [106444.471622]  drm_atomic_commit+0x4a/0x50 [drm]
    [106444.471629]  drm_atomic_helper_set_config+0x63/0xb0 [drm_kms_helper]
    [106444.471642]  drm_mode_setcrtc+0x1d9/0x7b0 [drm]
    [106444.471654]  ? drm_mode_getcrtc+0x1a0/0x1a0 [drm]
    [106444.471666]  drm_ioctl_kernel+0xb6/0x100 [drm]
    [106444.471677]  drm_ioctl+0x3ad/0x470 [drm]
    [106444.471688]  ? drm_mode_getcrtc+0x1a0/0x1a0 [drm]
    [106444.471692]  ? tomoyo_file_ioctl+0x19/0x20
    [106444.471694]  __x64_sys_ioctl+0x96/0xd0
    [106444.471697]  do_syscall_64+0x37/0x80
    [106444.471699]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
    Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
    Cc: Melissa Wen <melissa.srw@gmail.com>
    
    Signed-off-by: Sidong Yang <realwakka@gmail.com>
    Reviewed-by: Melissa Wen <melissa.srw@gmail.com>
    Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200828124553.2178-1-realwakka@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2e9db787af83a7daede0085fb71cb752ce2a8dfa
Author: Tom Rix <trix@redhat.com>
Date:   Mon Aug 10 21:25:18 2020 +0200

    media: tw5864: check status of tw5864_frameinterval_get
    
    [ Upstream commit 780d815dcc9b34d93ae69385a8465c38d423ff0f ]
    
    clang static analysis reports this problem
    
    tw5864-video.c:773:32: warning: The left expression of the compound
      assignment is an uninitialized value.
      The computed value will also be garbage
            fintv->stepwise.max.numerator *= std_max_fps;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    
    stepwise.max is set with frameinterval, which comes from
    
            ret = tw5864_frameinterval_get(input, &frameinterval);
            fintv->stepwise.step = frameinterval;
            fintv->stepwise.min = frameinterval;
            fintv->stepwise.max = frameinterval;
            fintv->stepwise.max.numerator *= std_max_fps;
    
    When tw5864_frameinterval_get() fails, frameinterval is not
    set. So check the status and fix another similar problem.
    
    Signed-off-by: Tom Rix <trix@redhat.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 48be293e10d2b0ab3b20ec34017c7f54854abb5d
Author: Badhri Jagan Sridharan <badhri@google.com>
Date:   Mon Aug 17 11:38:27 2020 -0700

    usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart
    
    [ Upstream commit 6bbe2a90a0bb4af8dd99c3565e907fe9b5e7fd88 ]
    
    The patch addresses the compliance test failures while running
    TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 of the "Deterministic PD
    Compliance MOI" test plan published in https://www.usb.org/usbc.
    For a product to be Type-C compliant, it's expected that these tests
    are run on usb.org certified Type-C compliance tester as mentioned in
    https://www.usb.org/usbc.
    
    The purpose of the tests TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 is to
    verify the PR_SWAP response of the device. While doing so, the test
    asserts that Source Capabilities message is NOT received from the test
    device within tSwapSourceStart min (20 ms) from the time the last bit
    of GoodCRC corresponding to the RS_RDY message sent by the UUT was
    sent. If it does then the test fails.
    
    This is in line with the requirements from the USB Power Delivery
    Specification Revision 3.0, Version 1.2:
    "6.6.8.1 SwapSourceStartTimer
    The SwapSourceStartTimer Shall be used by the new Source, after a
    Power Role Swap or Fast Role Swap, to ensure that it does not send
    Source_Capabilities Message before the new Sink is ready to receive
    the
    Source_Capabilities Message. The new Source Shall Not send the
    Source_Capabilities Message earlier than tSwapSourceStart after the
    last bit of the EOP of GoodCRC Message sent in response to the PS_RDY
    Message sent by the new Source indicating that its power supply is
    ready."
    
    The patch makes sure that TCPM does not send the Source_Capabilities
    Message within tSwapSourceStart(20ms) by transitioning into
    SRC_STARTUP only after  tSwapSourceStart(20ms).
    
    Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
    Reviewed-by: Guenter Roeck <linux@roeck-us.net>
    Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
    Link: https://lore.kernel.org/r/20200817183828.1895015-1-badhri@google.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit deb8aeef2e5973abb95535bc37fd590bfba6e3d6
Author: Xia Jiang <xia.jiang@mediatek.com>
Date:   Fri Aug 14 09:11:35 2020 +0200

    media: platform: Improve queue set up flow for bug fixing
    
    [ Upstream commit 5095a6413a0cf896ab468009b6142cb0fe617e66 ]
    
    Add checking created buffer size follow in mtk_jpeg_queue_setup().
    
    Reviewed-by: Tomasz Figa <tfiga@chromium.org>
    Signed-off-by: Xia Jiang <xia.jiang@mediatek.com>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3d45a186561dbc859640e729c4f45d2f87eba68b
Author: Jérôme Pouiller <jerome.pouiller@silabs.com>
Date:   Tue Aug 25 10:58:24 2020 +0200

    staging: wfx: fix potential use before init
    
    [ Upstream commit ce3653a8d3db096aa163fc80239d8ec1305c81fa ]
    
    The trace below can appear:
    
        [83613.832200] INFO: trying to register non-static key.
        [83613.837248] the code is fine but needs lockdep annotation.
        [83613.842808] turning off the locking correctness validator.
        [83613.848375] CPU: 3 PID: 141 Comm: kworker/3:2H Tainted: G           O      5.6.13-silabs15 #2
        [83613.857019] Hardware name: BCM2835
        [83613.860605] Workqueue: events_highpri bh_work [wfx]
        [83613.865552] Backtrace:
        [83613.868041] [<c010f2cc>] (dump_backtrace) from [<c010f7b8>] (show_stack+0x20/0x24)
        [83613.881463] [<c010f798>] (show_stack) from [<c0d82138>] (dump_stack+0xe8/0x114)
        [83613.888882] [<c0d82050>] (dump_stack) from [<c01a02ec>] (register_lock_class+0x748/0x768)
        [83613.905035] [<c019fba4>] (register_lock_class) from [<c019da04>] (__lock_acquire+0x88/0x13dc)
        [83613.924192] [<c019d97c>] (__lock_acquire) from [<c019f6a4>] (lock_acquire+0xe8/0x274)
        [83613.942644] [<c019f5bc>] (lock_acquire) from [<c0daa5dc>] (_raw_spin_lock_irqsave+0x58/0x6c)
        [83613.961714] [<c0daa584>] (_raw_spin_lock_irqsave) from [<c0ab3248>] (skb_dequeue+0x24/0x78)
        [83613.974967] [<c0ab3224>] (skb_dequeue) from [<bf330db0>] (wfx_tx_queues_get+0x96c/0x1294 [wfx])
        [83613.989728] [<bf330444>] (wfx_tx_queues_get [wfx]) from [<bf320454>] (bh_work+0x454/0x26d8 [wfx])
        [83614.009337] [<bf320000>] (bh_work [wfx]) from [<c014c920>] (process_one_work+0x23c/0x7ec)
        [83614.028141] [<c014c6e4>] (process_one_work) from [<c014cf1c>] (worker_thread+0x4c/0x55c)
        [83614.046861] [<c014ced0>] (worker_thread) from [<c0154c04>] (kthread+0x138/0x168)
        [83614.064876] [<c0154acc>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)
        [83614.072200] Exception stack(0xecad3fb0 to 0xecad3ff8)
        [83614.077323] 3fa0:                                     00000000 00000000 00000000 00000000
        [83614.085620] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
        [83614.093914] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
    
    Indeed, the code of wfx_add_interface() shows that the interface is
    enabled to early. So, the spinlock associated with some skb_queue may
    not yet initialized when wfx_tx_queues_get() is called.
    
    Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
    Link: https://lore.kernel.org/r/20200825085828.399505-8-Jerome.Pouiller@silabs.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f25af2fba567120e98010c0b13e9d86204afae12
Author: Marek Szyprowski <m.szyprowski@samsung.com>
Date:   Wed Aug 26 08:33:12 2020 +0200

    misc: fastrpc: fix common struct sg_table related issues
    
    [ Upstream commit 7cd7edb89437457ec36ffdbb970cc314d00c4aba ]
    
    The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function
    returns the number of the created entries in the DMA address space.
    However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and
    dma_unmap_sg must be called with the original number of the entries
    passed to the dma_map_sg().
    
    struct sg_table is a common structure used for describing a non-contiguous
    memory buffer, used commonly in the DRM and graphics subsystems. It
    consists of a scatterlist with memory pages and DMA addresses (sgl entry),
    as well as the number of scatterlist entries: CPU pages (orig_nents entry)
    and DMA mapped pages (nents entry).
    
    It turned out that it was a common mistake to misuse nents and orig_nents
    entries, calling DMA-mapping functions with a wrong number of entries or
    ignoring the number of mapped entries returned by the dma_map_sg()
    function.
    
    To avoid such issues, lets use a common dma-mapping wrappers operating
    directly on the struct sg_table objects and use scatterlist page
    iterators where possible. This, almost always, hides references to the
    nents and orig_nents entries, making the code robust, easier to follow
    and copy/paste safe.
    
    Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
    Link: https://lore.kernel.org/r/20200826063316.23486-29-m.szyprowski@samsung.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7c9edabec5f9910163d802c12b3e12362c68309b
Author: Akshu Agrawal <akshu.agrawal@amd.com>
Date:   Thu Aug 27 00:24:20 2020 +0530

    ASoC: AMD: Clean kernel log from deferred probe error messages
    
    [ Upstream commit f7660445c8e7fda91e8b944128554249d886b1d4 ]
    
    While the driver waits for DAIs to be probed and retries probing,
    have the error messages at debug level instead of error.
    
    Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
    Link: https://lore.kernel.org/r/20200826185454.5545-1-akshu.agrawal@amd.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0d6d22fb209fb071fb43234969fed2a81a6447bb
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Thu Aug 20 12:47:16 2020 +0200

    media: videodev2.h: RGB BT2020 and HSV are always full range
    
    [ Upstream commit b305dfe2e93434b12d438434461b709641f62af4 ]
    
    The default RGB quantization range for BT.2020 is full range (just as for
    all the other RGB pixel encodings), not limited range.
    
    Update the V4L2_MAP_QUANTIZATION_DEFAULT macro and documentation
    accordingly.
    
    Also mention that HSV is always full range and cannot be limited range.
    
    When RGB BT2020 was introduced in V4L2 it was not clear whether it should
    be limited or full range, but full range is the right (and consistent)
    choice.
    
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7edf069b6624b59b2d3cb46f78f515d6dc18a41e
Author: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Date:   Wed Aug 26 10:15:22 2020 +0200

    drm/bridge_connector: Set default status connected for eDP connectors
    
    [ Upstream commit c5589b39549d1875bb506da473bf4580c959db8c ]
    
    In an eDP application, HPD is not required and on most bridge chips
    useless. If HPD is not used, we need to set initial status as connected,
    otherwise the connector created by the drm_bridge_connector API remains
    in an unknown state.
    
    Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Acked-by: Sam Ravnborg <sam@ravnborg.org>
    Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
    Reviewed-by: Bilal Wasim <bwasim.lkml@gmail.com>
    Tested-by: Bilal Wasim <bwasim.lkml@gmail.com>
    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200826081526.674866-2-enric.balletbo@collabora.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d3e8ba30b2b23fdf0f346fd232fdab621c51e87d
Author: Andy Lutomirski <luto@kernel.org>
Date:   Wed Aug 26 10:00:45 2020 -0700

    selftests/x86/fsgsbase: Reap a forgotten child
    
    [ Upstream commit ab2dd173330a3f07142e68cd65682205036cd00f ]
    
    The ptrace() test forgot to reap its child.  Reap it.
    
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/e7700a503f30e79ab35a63103938a19893dbeff2.1598461151.git.luto@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 43836fdc9e318a11233cf19c5ee7ffb04e8e5d8f
Author: Rander Wang <rander.wang@intel.com>
Date:   Tue Aug 25 16:50:35 2020 -0700

    ASoC: SOF: fix a runtime pm issue in SOF when HDMI codec doesn't work
    
    [ Upstream commit 6c63c954e1c52f1262f986f36d95f557c6f8fa94 ]
    
    When hda_codec_probe() doesn't initialize audio component, we disable
    the codec and keep going. However,the resources are not released. The
    child_count of SOF device is increased in snd_hdac_ext_bus_device_init
    but is not decrease in error case, so SOF can't get suspended.
    
    snd_hdac_ext_bus_device_exit will be invoked in HDA framework if it
    gets a error. Now copy this behavior to release resources and decrease
    SOF device child_count to release SOF device.
    
    Signed-off-by: Rander Wang <rander.wang@intel.com>
    Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
    Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
    Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
    Link: https://lore.kernel.org/r/20200825235040.1586478-3-ranjani.sridharan@linux.intel.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit dc689cd5732e5122cb04171c15a1cb37731f6d30
Author: Nadezda Lutovinova <lutovinova@ispras.ru>
Date:   Wed Aug 19 17:37:56 2020 +0300

    drm/brige/megachips: Add checking if ge_b850v3_lvds_init() is working correctly
    
    [ Upstream commit f688a345f0d7a6df4dd2aeca8e4f3c05e123a0ee ]
    
    If ge_b850v3_lvds_init() does not allocate memory for ge_b850v3_lvds_ptr,
    then a null pointer dereference is accessed.
    
    The patch adds checking of the return value of ge_b850v3_lvds_init().
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Signed-off-by: Nadezda Lutovinova <lutovinova@ispras.ru>
    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200819143756.30626-1-lutovinova@ispras.ru
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c1918dd9f20cb5449d172e0ab43f6bdd16a46ac0
Author: Luben Tuikov <luben.tuikov@amd.com>
Date:   Tue Aug 11 19:59:58 2020 -0400

    drm/scheduler: Scheduler priority fixes (v2)
    
    [ Upstream commit e2d732fdb7a9e421720a644580cd6a9400f97f60 ]
    
    Remove DRM_SCHED_PRIORITY_LOW, as it was used
    in only one place.
    
    Rename and separate by a line
    DRM_SCHED_PRIORITY_MAX to DRM_SCHED_PRIORITY_COUNT
    as it represents a (total) count of said
    priorities and it is used as such in loops
    throughout the code. (0-based indexing is the
    the count number.)
    
    Remove redundant word HIGH in priority names,
    and rename *KERNEL* to *HIGH*, as it really
    means that, high.
    
    v2: Add back KERNEL and remove SW and HW,
        in lieu of a single HIGH between NORMAL and KERNEL.
    
    Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e2578ebb1a5f3ed191dd6c1e99d493785310e44a
Author: Sathishkumar Muruganandam <murugana@codeaurora.org>
Date:   Fri Aug 14 13:46:11 2020 +0530

    ath10k: fix VHT NSS calculation when STBC is enabled
    
    [ Upstream commit 99f41b8e43b8b4b31262adb8ac3e69088fff1289 ]
    
    When STBC is enabled, NSTS_SU value need to be accounted for VHT NSS
    calculation for SU case.
    
    Without this fix, 1SS + STBC enabled case was reported wrongly as 2SS
    in radiotap header on monitor mode capture.
    
    Tested-on: QCA9984 10.4-3.10-00047
    
    Signed-off-by: Sathishkumar Muruganandam <murugana@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/1597392971-3897-1-git-send-email-murugana@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 663992ddcd943fcb28f4230cfc530b5d4f7dad5d
Author: Wen Gong <wgong@codeaurora.org>
Date:   Fri Aug 14 18:17:08 2020 +0300

    ath10k: start recovery process when payload length exceeds max htc length for sdio
    
    [ Upstream commit 2fd3c8f34d08af0a6236085f9961866ad92ef9ec ]
    
    When simulate random transfer fail for sdio write and read, it happened
    "payload length exceeds max htc length" and recovery later sometimes.
    
    Test steps:
    1. Add config and update kernel:
    CONFIG_FAIL_MMC_REQUEST=y
    CONFIG_FAULT_INJECTION=y
    CONFIG_FAULT_INJECTION_DEBUG_FS=y
    
    2. Run simulate fail:
    cd /sys/kernel/debug/mmc1/fail_mmc_request
    echo 10 > probability
    echo 10 > times # repeat until hitting issues
    
    3. It happened payload length exceeds max htc length.
    [  199.935506] ath10k_sdio mmc1:0001:1: payload length 57005 exceeds max htc length: 4088
    ....
    [  264.990191] ath10k_sdio mmc1:0001:1: payload length 57005 exceeds max htc length: 4088
    
    4. after some time, such as 60 seconds, it start recovery which triggered
    by wmi command timeout for periodic scan.
    [  269.229232] ieee80211 phy0: Hardware restart was requested
    [  269.734693] ath10k_sdio mmc1:0001:1: device successfully recovered
    
    The simulate fail of sdio is not a real sdio transter fail, it only
    set an error status in mmc_should_fail_request after the transfer end,
    actually the transfer is success, then sdio_io_rw_ext_helper will
    return error status and stop transfer the left data. For example,
    the really RX len is 286 bytes, then it will split to 2 blocks in
    sdio_io_rw_ext_helper, one is 256 bytes, left is 30 bytes, if the
    first 256 bytes get an error status by mmc_should_fail_request,then
    the left 30 bytes will not read in this RX operation. Then when the
    next RX arrive, the left 30 bytes will be considered as the header
    of the read, the top 4 bytes of the 30 bytes will be considered as
    lookaheads, but actually the 4 bytes is not the lookaheads, so the len
    from this lookaheads is not correct, it exceeds max htc length 4088
    sometimes. When happened exceeds, the buffer chain is not matched between
    firmware and ath10k, then it need to start recovery ASAP. Recently then
    recovery will be started by wmi command timeout, but it will be long time
    later, for example, it is 60+ seconds later from the periodic scan, if
    it does not have periodic scan, it will be longer.
    
    Start recovery when it happened "payload length exceeds max htc length"
    will be reasonable.
    
    This patch only effect sdio chips.
    
    Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029.
    
    Signed-off-by: Wen Gong <wgong@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/20200108031957.22308-3-wgong@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d1c9ddc7bc69d0673ec1848e5813d52b9beff7e9
Author: Tom Rix <trix@redhat.com>
Date:   Mon Jul 20 12:18:45 2020 -0700

    video: fbdev: pvr2fb: initialize variables
    
    [ Upstream commit 8e1ba47c60bcd325fdd097cd76054639155e5d2e ]
    
    clang static analysis reports this repesentative error
    
    pvr2fb.c:1049:2: warning: 1st function call argument
      is an uninitialized value [core.CallAndMessage]
            if (*cable_arg)
            ^~~~~~~~~~~~~~~
    
    Problem is that cable_arg depends on the input loop to
    set the cable_arg[0].  If it does not, then some random
    value from the stack is used.
    
    A similar problem exists for output_arg.
    
    So initialize cable_arg and output_arg.
    
    Signed-off-by: Tom Rix <trix@redhat.com>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200720191845.20115-1-trix@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9745a32e15ed325dc26ff5a3afb8f0afbae91d95
Author: Guchun Chen <guchun.chen@amd.com>
Date:   Wed Jul 22 10:37:01 2020 +0800

    drm/amdgpu: restore ras flags when user resets eeprom(v2)
    
    [ Upstream commit bf0b91b78f002faa1be1902a75eeb0797f9fbcf3 ]
    
    RAS flags needs to be cleaned as well when user requires
    one clean eeprom.
    
    v2: RAS flags shall be restored after eeprom reset succeeds.
    
    Signed-off-by: Guchun Chen <guchun.chen@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f12784e5a7c859a3eacaa7a8415416fbdf56a24a
Author: Thomas Zimmermann <tzimmermann@suse.de>
Date:   Thu Jul 30 15:51:59 2020 +0200

    drm/ast: Separate DRM driver from PCI code
    
    [ Upstream commit d50ace1e72f05708cc5dbc89b9bbb9873f150092 ]
    
    Putting the DRM driver to the top of the file and the PCI code to the
    bottom makes ast_drv.c more readable. While at it, the patch prefixes
    file-scope variables with ast_.
    
    Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
    Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Acked-by: Sam Ravnborg <sam@ravnborg.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-3-tzimmermann@suse.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ad9d55dc8db1bc596b3b17bb651121ab3306d40d
Author: Arvind Sankar <nivedita@alum.mit.edu>
Date:   Mon Jul 27 19:07:57 2020 -0400

    x86/kaslr: Initialize mem_limit to the real maximum address
    
    [ Upstream commit 451286940d95778e83fa7f97006316d995b4c4a8 ]
    
    On 64-bit, the kernel must be placed below MAXMEM (64TiB with 4-level
    paging or 4PiB with 5-level paging). This is currently not enforced by
    KASLR, which thus implicitly relies on physical memory being limited to
    less than 64TiB.
    
    On 32-bit, the limit is KERNEL_IMAGE_SIZE (512MiB). This is enforced by
    special checks in __process_mem_region().
    
    Initialize mem_limit to the maximum (depending on architecture), instead
    of ULLONG_MAX, and make sure the command-line arguments can only
    decrease it. This makes the enforcement explicit on 64-bit, and
    eliminates the 32-bit specific checks to keep the kernel below 512M.
    
    Check upfront to make sure the minimum address is below the limit before
    doing any work.
    
    Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Kees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20200727230801.3468620-5-nivedita@alum.mit.edu
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3fc85e7c84d5be212e07a972a62536209638a667
Author: Venkateswara Naralasetty <vnaralas@codeaurora.org>
Date:   Mon Jun 15 20:29:01 2020 +0300

    ath10k: fix retry packets update in station dump
    
    [ Upstream commit 67b927f9820847d30e97510b2f00cd142b9559b6 ]
    
    When tx status enabled, retry count is updated from tx completion status.
    which is not working as expected due to firmware limitation where
    firmware can not provide per MSDU rate statistics from tx completion
    status. Due to this tx retry count is always 0 in station dump.
    
    Fix this issue by updating the retry packet count from per peer
    statistics. This patch will not break on SDIO devices since, this retry
    count is already updating from peer statistics for SDIO devices.
    
    Tested-on: QCA9984 PCI 10.4-3.6-00104
    Tested-on: QCA9882 PCI 10.2.4-1.0-00047
    
    Signed-off-by: Venkateswara Naralasetty <vnaralas@codeaurora.org>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Link: https://lore.kernel.org/r/1591856446-26977-1-git-send-email-vnaralas@codeaurora.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2178d10f68ea156466fbaaaa000b4b80e12dd30e
Author: Pavel Begunkov <asml.silence@gmail.com>
Date:   Tue Oct 13 09:43:56 2020 +0100

    io_uring: don't set COMP_LOCKED if won't put
    
    [ Upstream commit 368c5481ae7c6a9719c40984faea35480d9f4872 ]
    
    __io_kill_linked_timeout() sets REQ_F_COMP_LOCKED for a linked timeout
    even if it can't cancel it, e.g. it's already running. It not only races
    with io_link_timeout_fn() for ->flags field, but also leaves the flag
    set and so io_link_timeout_fn() may find it and decide that it holds the
    lock. Hopefully, the second problem is potential.
    
    Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f8462e2671b17b61d71fc70ca72d81dbbb67ad96
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Wed Oct 7 13:55:16 2020 -0700

    xfs: fix realtime bitmap/summary file truncation when growing rt volume
    
    [ Upstream commit f4c32e87de7d66074d5612567c5eac7325024428 ]
    
    The realtime bitmap and summary files are regular files that are hidden
    away from the directory tree.  Since they're regular files, inode
    inactivation will try to purge what it thinks are speculative
    preallocations beyond the incore size of the file.  Unfortunately,
    xfs_growfs_rt forgets to update the incore size when it resizes the
    inodes, with the result that inactivating the rt inodes at unmount time
    will cause their contents to be truncated.
    
    Fix this by updating the incore size when we change the ondisk size as
    part of updating the superblock.  Note that we don't do this when we're
    allocating blocks to the rt inodes because we actually want those blocks
    to get purged if the growfs fails.
    
    This fixes corruption complaints from the online rtsummary checker when
    running xfs/233.  Since that test requires rmap, one can also trigger
    this by growing an rt volume, cycling the mount, and creating rt files.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit be23eff8efb09ce93bd4f3d0769c941bad589f73
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Fri Sep 25 17:39:51 2020 -0700

    xfs: change the order in which child and parent defer ops are finished
    
    [ Upstream commit 27dada070d59c28a441f1907d2cec891b17dcb26 ]
    
    The defer ops code has been finishing items in the wrong order -- if a
    top level defer op creates items A and B, and finishing item A creates
    more defer ops A1 and A2, we'll put the new items on the end of the
    chain and process them in the order A B A1 A2.  This is kind of weird,
    since it's convenient for programmers to be able to think of A and B as
    an ordered sequence where all the sub-tasks for A must finish before we
    move on to B, e.g. A A1 A2 D.
    
    Right now, our log intent items are not so complex that this matters,
    but this will become important for the atomic extent swapping patchset.
    In order to maintain correct reference counting of extents, we have to
    unmap and remap extents in that order, and we want to complete that work
    before moving on to the next range that the user wants to swap.  This
    patch fixes defer ops to satsify that requirement.
    
    The primary symptom of the incorrect order was noticed in an early
    performance analysis of the atomic extent swap code.  An astonishingly
    large number of deferred work items accumulated when userspace requested
    an atomic update of two very fragmented files.  The cause of this was
    traced to the same ordering bug in the inner loop of
    xfs_defer_finish_noroll.
    
    If the ->finish_item method of a deferred operation queues new deferred
    operations, those new deferred ops are appended to the tail of the
    pending work list.  To illustrate, say that a caller creates a
    transaction t0 with four deferred operations D0-D3.  The first thing
    defer ops does is roll the transaction to t1, leaving us with:
    
    t1: D0(t0), D1(t0), D2(t0), D3(t0)
    
    Let's say that finishing each of D0-D3 will create two new deferred ops.
    After finish D0 and roll, we'll have the following chain:
    
    t2: D1(t0), D2(t0), D3(t0), d4(t1), d5(t1)
    
    d4 and d5 were logged to t1.  Notice that while we're about to start
    work on D1, we haven't actually completed all the work implied by D0
    being finished.  So far we've been careful (or lucky) to structure the
    dfops callers such that D1 doesn't depend on d4 or d5 being finished,
    but this is a potential logic bomb.
    
    There's a second problem lurking.  Let's see what happens as we finish
    D1-D3:
    
    t3: D2(t0), D3(t0), d4(t1), d5(t1), d6(t2), d7(t2)
    t4: D3(t0), d4(t1), d5(t1), d6(t2), d7(t2), d8(t3), d9(t3)
    t5: d4(t1), d5(t1), d6(t2), d7(t2), d8(t3), d9(t3), d10(t4), d11(t4)
    
    Let's say that d4-d11 are simple work items that don't queue any other
    operations, which means that we can complete each d4 and roll to t6:
    
    t6: d5(t1), d6(t2), d7(t2), d8(t3), d9(t3), d10(t4), d11(t4)
    t7: d6(t2), d7(t2), d8(t3), d9(t3), d10(t4), d11(t4)
    ...
    t11: d10(t4), d11(t4)
    t12: d11(t4)
    <done>
    
    When we try to roll to transaction #12, we're holding defer op d11,
    which we logged way back in t4.  This means that the tail of the log is
    pinned at t4.  If the log is very small or there are a lot of other
    threads updating metadata, this means that we might have wrapped the log
    and cannot get roll to t11 because there isn't enough space left before
    we'd run into t4.
    
    Let's shift back to the original failure.  I mentioned before that I
    discovered this flaw while developing the atomic file update code.  In
    that scenario, we have a defer op (D0) that finds a range of file blocks
    to remap, creates a handful of new defer ops to do that, and then asks
    to be continued with however much work remains.
    
    So, D0 is the original swapext deferred op.  The first thing defer ops
    does is rolls to t1:
    
    t1: D0(t0)
    
    We try to finish D0, logging d1 and d2 in the process, but can't get all
    the work done.  We log a done item and a new intent item for the work
    that D0 still has to do, and roll to t2:
    
    t2: D0'(t1), d1(t1), d2(t1)
    
    We roll and try to finish D0', but still can't get all the work done, so
    we log a done item and a new intent item for it, requeue D0 a second
    time, and roll to t3:
    
    t3: D0''(t2), d1(t1), d2(t1), d3(t2), d4(t2)
    
    If it takes 48 more rolls to complete D0, then we'll finally dispense
    with D0 in t50:
    
    t50: D<fifty primes>(t49), d1(t1), ..., d102(t50)
    
    We then try to roll again to get a chain like this:
    
    t51: d1(t1), d2(t1), ..., d101(t50), d102(t50)
    ...
    t152: d102(t50)
    <done>
    
    Notice that in rolling to transaction #51, we're holding on to a log
    intent item for d1 that was logged in transaction #1.  This means that
    the tail of the log is pinned at t1.  If the log is very small or there
    are a lot of other threads updating metadata, this means that we might
    have wrapped the log and cannot roll to t51 because there isn't enough
    space left before we'd run into t1.  This is of course problem #2 again.
    
    But notice the third problem with this scenario: we have 102 defer ops
    tied to this transaction!  Each of these items are backed by pinned
    kernel memory, which means that we risk OOM if the chains get too long.
    
    Yikes.  Problem #1 is a subtle logic bomb that could hit someone in the
    future; problem #2 applies (rarely) to the current upstream, and problem
    #3 applies to work under development.
    
    This is not how incremental deferred operations were supposed to work.
    The dfops design of logging in the same transaction an intent-done item
    and a new intent item for the work remaining was to make it so that we
    only have to juggle enough deferred work items to finish that one small
    piece of work.  Deferred log item recovery will find that first
    unfinished work item and restart it, no matter how many other intent
    items might follow it in the log.  Therefore, it's ok to put the new
    intents at the start of the dfops chain.
    
    For the first example, the chains look like this:
    
    t2: d4(t1), d5(t1), D1(t0), D2(t0), D3(t0)
    t3: d5(t1), D1(t0), D2(t0), D3(t0)
    ...
    t9: d9(t7), D3(t0)
    t10: D3(t0)
    t11: d10(t10), d11(t10)
    t12: d11(t10)
    
    For the second example, the chains look like this:
    
    t1: D0(t0)
    t2: d1(t1), d2(t1), D0'(t1)
    t3: d2(t1), D0'(t1)
    t4: D0'(t1)
    t5: d1(t4), d2(t4), D0''(t4)
    ...
    t148: D0<50 primes>(t147)
    t149: d101(t148), d102(t148)
    t150: d102(t148)
    <done>
    
    This actually sucks more for pinning the log tail (we try to roll to t10
    while holding an intent item that was logged in t1) but we've solved
    problem #1.  We've also reduced the maximum chain length from:
    
        sum(all the new items) + nr_original_items
    
    to:
    
        max(new items that each original item creates) + nr_original_items
    
    This solves problem #3 by sharply reducing the number of defer ops that
    can be attached to a transaction at any given time.  The change makes
    the problem of log tail pinning worse, but is improvement we need to
    solve problem #2.  Actually solving #2, however, is left to the next
    patch.
    
    Note that a subsequent analysis of some hard-to-trigger reflink and COW
    livelocks on extremely fragmented filesystems (or systems running a lot
    of IO threads) showed the same symptoms -- uncomfortably large numbers
    of incore deferred work items and occasional stalls in the transaction
    grant code while waiting for log reservations.  I think this patch and
    the next one will also solve these problems.
    
    As originally written, the code used list_splice_tail_init instead of
    list_splice_init, so change that, and leave a short comment explaining
    our actions.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Reviewed-by: Brian Foster <bfoster@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 730c9df7b73bd6450e2eec509b7c1589fefe1266
Author: Krzysztof Kozlowski <krzk@kernel.org>
Date:   Sat Sep 19 16:04:14 2020 +0200

    power: supply: bq27xxx: report "not charging" on all types
    
    [ Upstream commit 7bf738ba110722b63e9dc8af760d3fb2aef25593 ]
    
    Commit 6f24ff97e323 ("power: supply: bq27xxx_battery: Add the
    BQ27Z561 Battery monitor") and commit d74534c27775 ("power:
    bq27xxx_battery: Add support for additional bq27xxx family devices")
    added support for new device types by copying most of the code and
    adding necessary quirks.
    
    However they did not copy the code in bq27xxx_battery_status()
    responsible for returning POWER_SUPPLY_STATUS_NOT_CHARGING.
    
    Unify the bq27xxx_battery_status() so for all types when charger is
    supplied, it will return "not charging" status.
    
    Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
    Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 77dbbcde014ac482952f26fdfee538ab43fdd0c1
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Mon Sep 21 09:15:09 2020 -0700

    xfs: log new intent items created as part of finishing recovered intent items
    
    [ Upstream commit 93293bcbde93567efaf4e6bcd58cad270e1fcbf5 ]
    
    During a code inspection, I found a serious bug in the log intent item
    recovery code when an intent item cannot complete all the work and
    decides to requeue itself to get that done.  When this happens, the
    item recovery creates a new incore deferred op representing the
    remaining work and attaches it to the transaction that it allocated.  At
    the end of _item_recover, it moves the entire chain of deferred ops to
    the dummy parent_tp that xlog_recover_process_intents passed to it, but
    fail to log a new intent item for the remaining work before committing
    the transaction for the single unit of work.
    
    xlog_finish_defer_ops logs those new intent items once recovery has
    finished dealing with the intent items that it recovered, but this isn't
    sufficient.  If the log is forced to disk after a recovered log item
    decides to requeue itself and the system goes down before we call
    xlog_finish_defer_ops, the second log recovery will never see the new
    intent item and therefore has no idea that there was more work to do.
    It will finish recovery leaving the filesystem in a corrupted state.
    
    The same logic applies to /any/ deferred ops added during intent item
    recovery, not just the one handling the remaining work.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bbf30f490b960d3993195797afc407c6db85b2bc
Author: Chandan Babu R <chandanrlinux@gmail.com>
Date:   Thu Sep 17 11:12:08 2020 -0700

    xfs: Set xfs_buf's b_ops member when zeroing bitmap/summary files
    
    [ Upstream commit c54e14d155f5fdbac73a8cd4bd2678cb252149dc ]
    
    In xfs_growfs_rt(), we enlarge bitmap and summary files by allocating
    new blocks for both files. For each of the new blocks allocated, we
    allocate an xfs_buf, zero the payload, log the contents and commit the
    transaction. Hence these buffers will eventually find themselves
    appended to list at xfs_ail->ail_buf_list.
    
    Later, xfs_growfs_rt() loops across all of the new blocks belonging to
    the bitmap inode to set the bitmap values to 1. In doing so, it
    allocates a new transaction and invokes the following sequence of
    functions,
      - xfs_rtfree_range()
        - xfs_rtmodify_range()
          - xfs_rtbuf_get()
            We pass '&xfs_rtbuf_ops' as the ops pointer to xfs_trans_read_buf().
            - xfs_trans_read_buf()
              We find the xfs_buf of interest in per-ag hash table, invoke
              xfs_buf_reverify() which ends up assigning '&xfs_rtbuf_ops' to
              xfs_buf->b_ops.
    
    On the other hand, if xfs_growfs_rt_alloc() had allocated a few blocks
    for the bitmap inode and returned with an error, all the xfs_bufs
    corresponding to the new bitmap blocks that have been allocated would
    continue to be on xfs_ail->ail_buf_list list without ever having a
    non-NULL value assigned to their b_ops members. An AIL flush operation
    would then trigger the following warning message to be printed on the
    console,
    
      XFS (loop0): _xfs_buf_ioapply: no buf ops on daddr 0x58 len 8
      00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      CPU: 3 PID: 449 Comm: xfsaild/loop0 Not tainted 5.8.0-rc4-chandan-00038-g4d8c2b9de9ab-dirty #37
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      Call Trace:
       dump_stack+0x57/0x70
       _xfs_buf_ioapply+0x37c/0x3b0
       ? xfs_rw_bdev+0x1e0/0x1e0
       ? xfs_buf_delwri_submit_buffers+0xd4/0x210
       __xfs_buf_submit+0x6d/0x1f0
       xfs_buf_delwri_submit_buffers+0xd4/0x210
       xfsaild+0x2c8/0x9e0
       ? __switch_to_asm+0x42/0x70
       ? xfs_trans_ail_cursor_first+0x80/0x80
       kthread+0xfe/0x140
       ? kthread_park+0x90/0x90
       ret_from_fork+0x22/0x30
    
    This message indicates that the xfs_buf had its b_ops member set to
    NULL.
    
    This commit fixes the issue by assigning "&xfs_rtbuf_ops" to b_ops
    member of each of the xfs_bufs logged by xfs_growfs_rt_alloc().
    
    Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
    Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 735d83e70b16a076babfa1a6bfa589c363098a8d
Author: Chandan Babu R <chandanrlinux@gmail.com>
Date:   Tue Sep 15 20:50:42 2020 -0700

    xfs: Set xfs_buf type flag when growing summary/bitmap files
    
    [ Upstream commit 72cc95132a93293dcd0b6f68353f4741591c9aeb ]
    
    The following sequence of commands,
    
      mkfs.xfs -f -m reflink=0 -r rtdev=/dev/loop1,size=10M /dev/loop0
      mount -o rtdev=/dev/loop1 /dev/loop0 /mnt
      xfs_growfs  /mnt
    
    ... causes the following call trace to be printed on the console,
    
    XFS: Assertion failed: (bip->bli_flags & XFS_BLI_STALE) || (xfs_blft_from_flags(&bip->__bli_format) > XFS_BLFT_UNKNOWN_BUF && xfs_blft_from_flags(&bip->__bli_format) < XFS_BLFT_MAX_BUF), file: fs/xfs/xfs_buf_item.c, line: 331
    Call Trace:
     xfs_buf_item_format+0x632/0x680
     ? kmem_alloc_large+0x29/0x90
     ? kmem_alloc+0x70/0x120
     ? xfs_log_commit_cil+0x132/0x940
     xfs_log_commit_cil+0x26f/0x940
     ? xfs_buf_item_init+0x1ad/0x240
     ? xfs_growfs_rt_alloc+0x1fc/0x280
     __xfs_trans_commit+0xac/0x370
     xfs_growfs_rt_alloc+0x1fc/0x280
     xfs_growfs_rt+0x1a0/0x5e0
     xfs_file_ioctl+0x3fd/0xc70
     ? selinux_file_ioctl+0x174/0x220
     ksys_ioctl+0x87/0xc0
     __x64_sys_ioctl+0x16/0x20
     do_syscall_64+0x3e/0x70
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    This occurs because the buffer being formatted has the value of
    XFS_BLFT_UNKNOWN_BUF assigned to the 'type' subfield of
    bip->bli_formats->blf_flags.
    
    This commit fixes the issue by assigning one of XFS_BLFT_RTSUMMARY_BUF
    and XFS_BLFT_RTBITMAP_BUF to the 'type' subfield of
    bip->bli_formats->blf_flags before committing the corresponding
    transaction.
    
    Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 91b7766bc2a4a0ddc8c7ed9ca7045590c793e168
Author: Dave Wysochanski <dwysocha@redhat.com>
Date:   Tue Aug 4 12:11:47 2020 -0400

    NFS4: Fix oops when copy_file_range is attempted with NFS4.0 source
    
    [ Upstream commit d8a6ad913c286d4763ae20b14c02fe6f39d7cd9f ]
    
    The following oops is seen during xfstest/565 when the 'test'
    (source of the copy) is NFS4.0 and 'scratch' (destination) is NFS4.2
    [   59.692458] run fstests generic/565 at 2020-08-01 05:50:35
    [   60.613588] BUG: kernel NULL pointer dereference, address: 0000000000000008
    [   60.624970] #PF: supervisor read access in kernel mode
    [   60.627671] #PF: error_code(0x0000) - not-present page
    [   60.630347] PGD 0 P4D 0
    [   60.631853] Oops: 0000 [#1] SMP PTI
    [   60.634086] CPU: 6 PID: 2828 Comm: xfs_io Kdump: loaded Not tainted 5.8.0-rc3 #1
    [   60.637676] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
    [   60.639901] RIP: 0010:nfs4_check_serverowner_major_id+0x5/0x30 [nfsv4]
    [   60.642719] Code: 89 ff e8 3e b3 b8 e1 e9 71 fe ff ff 41 bc da d8 ff ff e9 c3 fe ff ff e8 e9 9d 08 e2 66 0f 1f 84 00 00 00 00 00 66 66 66 66 90 <8b> 57 08 31 c0 3b 56 08 75 12 48 83 c6 0c 48 83 c7 0c e8 c4 97 bb
    [   60.652629] RSP: 0018:ffffc265417f7e10 EFLAGS: 00010287
    [   60.655379] RAX: ffffa0664b066400 RBX: 0000000000000000 RCX: 0000000000000001
    [   60.658754] RDX: ffffa066725fb000 RSI: ffffa066725fd000 RDI: 0000000000000000
    [   60.662292] RBP: 0000000000020000 R08: 0000000000020000 R09: 0000000000000000
    [   60.666189] R10: 0000000000000003 R11: 0000000000000000 R12: ffffa06648258d00
    [   60.669914] R13: 0000000000000000 R14: 0000000000000000 R15: ffffa06648258100
    [   60.673645] FS:  00007faa9fb35800(0000) GS:ffffa06677d80000(0000) knlGS:0000000000000000
    [   60.677698] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [   60.680773] CR2: 0000000000000008 CR3: 0000000203f14000 CR4: 00000000000406e0
    [   60.684476] Call Trace:
    [   60.685809]  nfs4_copy_file_range+0xfc/0x230 [nfsv4]
    [   60.688704]  vfs_copy_file_range+0x2ee/0x310
    [   60.691104]  __x64_sys_copy_file_range+0xd6/0x210
    [   60.693527]  do_syscall_64+0x4d/0x90
    [   60.695512]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
    [   60.698006] RIP: 0033:0x7faa9febc1bd
    
    Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
    Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c0997e1540e61e43dd09949114f74c5043154634
Author: Douglas Anderson <dianders@chromium.org>
Date:   Thu Aug 6 23:24:35 2020 +0100

    ARM: 8997/2: hw_breakpoint: Handle inexact watchpoint addresses
    
    [ Upstream commit 22c9e58299e5f18274788ce54c03d4fb761e3c5d ]
    
    This is commit fdfeff0f9e3d ("arm64: hw_breakpoint: Handle inexact
    watchpoint addresses") but ported to arm32, which has the same
    problem.
    
    This problem was found by Android CTS tests, notably the
    "watchpoint_imprecise" test [1].  I tested locally against a copycat
    (simplified) version of the test though.
    
    [1] https://android.googlesource.com/platform/bionic/+/master/tests/sys_ptrace_test.cpp
    
    Link: https://lkml.kernel.org/r/20191019111216.1.I82eae759ca6dc28a245b043f485ca490e3015321@changeid
    
    Signed-off-by: Douglas Anderson <dianders@chromium.org>
    Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
    Acked-by: Will Deacon <will@kernel.org>
    Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f6a41f7a0a23644011a59e47c9aceb9014c9a735
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Tue Aug 25 17:55:35 2020 +1000

    powerpc/64s: handle ISA v3.1 local copy-paste context switches
    
    [ Upstream commit dc462267d2d7aacffc3c1d99b02d7a7c59db7c66 ]
    
    The ISA v3.1 the copy-paste facility has a new memory move functionality
    which allows the copy buffer to be pasted to domestic memory (RAM) as
    opposed to foreign memory (accelerator).
    
    This means the POWER9 trick of avoiding the cp_abort on context switch if
    the process had not mapped foreign memory does not work on POWER10. Do the
    cp_abort unconditionally there.
    
    KVM must also cp_abort on guest exit to prevent copy buffer state leaking
    between contexts.
    
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Acked-by: Paul Mackerras <paulus@ozlabs.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200825075535.224536-1-npiggin@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d2297a29bc7c0b0b8f741b8c0aa7ae996f09ba62
Author: David Howells <dhowells@redhat.com>
Date:   Thu Oct 15 09:02:25 2020 +0100

    afs: Don't assert on unpurgeable server records
    
    [ Upstream commit 7530d3eb3dcf1a30750e8e7f1f88b782b96b72b8 ]
    
    Don't give an assertion failure on unpurgeable afs_server records - which
    kills the thread - but rather emit a trace line when we are purging a
    record (which only happens during network namespace removal or rmmod) and
    print a notice of the problem.
    
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6b67737f2dde60fbad8ddac37c8653e3c3bf0855
Author: Jaegeuk Kim <jaegeuk@kernel.org>
Date:   Fri Oct 2 14:17:35 2020 -0700

    f2fs: handle errors of f2fs_get_meta_page_nofail
    
    [ Upstream commit 86f33603f8c51537265ff7ac0320638fd2cbdb1b ]
    
    First problem is we hit BUG_ON() in f2fs_get_sum_page given EIO on
    f2fs_get_meta_page_nofail().
    
    Quick fix was not to give any error with infinite loop, but syzbot caught
    a case where it goes to that loop from fuzzed image. In turned out we abused
    f2fs_get_meta_page_nofail() like in the below call stack.
    
    - f2fs_fill_super
     - f2fs_build_segment_manager
      - build_sit_entries
       - get_current_sit_page
    
    INFO: task syz-executor178:6870 can't die for more than 143 seconds.
    task:syz-executor178 state:R
     stack:26960 pid: 6870 ppid:  6869 flags:0x00004006
    Call Trace:
    
    Showing all locks held in the system:
    1 lock held by khungtaskd/1179:
     #0: ffffffff8a554da0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260 kernel/locking/lockdep.c:6242
    1 lock held by systemd-journal/3920:
    1 lock held by in:imklog/6769:
     #0: ffff88809eebc130 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xe9/0x100 fs/file.c:930
    1 lock held by syz-executor178/6870:
     #0: ffff8880925120e0 (&type->s_umount_key#47/1){+.+.}-{3:3}, at: alloc_super+0x201/0xaf0 fs/super.c:229
    
    Actually, we didn't have to use _nofail in this case, since we could return
    error to mount(2) already with the error handler.
    
    As a result, this patch tries to 1) remove _nofail callers as much as possible,
    2) deal with error case in last remaining caller, f2fs_get_sum_page().
    
    Reported-by: syzbot+ee250ac8137be41d7b13@syzkaller.appspotmail.com
    Reviewed-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit dba295d6a3fbd86041a91410fc5a897288773a30
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Jun 4 13:23:17 2020 +0200

    um: change sigio_spinlock to a mutex
    
    [ Upstream commit f2d05059e15af3f70502074f4e3a504530af504a ]
    
    Lockdep complains at boot:
    
    =============================
    [ BUG: Invalid wait context ]
    5.7.0-05093-g46d91ecd597b #98 Not tainted
    -----------------------------
    swapper/1 is trying to lock:
    0000000060931b98 (&desc[i].request_mutex){+.+.}-{3:3}, at: __setup_irq+0x11d/0x623
    other info that might help us debug this:
    context-{4:4}
    1 lock held by swapper/1:
     #0: 000000006074fed8 (sigio_spinlock){+.+.}-{2:2}, at: sigio_lock+0x1a/0x1c
    stack backtrace:
    CPU: 0 PID: 1 Comm: swapper Not tainted 5.7.0-05093-g46d91ecd597b #98
    Stack:
     7fa4fab0 6028dfd1 0000002a 6008bea5
     7fa50700 7fa50040 7fa4fac0 6028e016
     7fa4fb50 6007f6da 60959c18 00000000
    Call Trace:
     [<60023a0e>] show_stack+0x13b/0x155
     [<6028e016>] dump_stack+0x2a/0x2c
     [<6007f6da>] __lock_acquire+0x515/0x15f2
     [<6007eb50>] lock_acquire+0x245/0x273
     [<6050d9f1>] __mutex_lock+0xbd/0x325
     [<6050dc76>] mutex_lock_nested+0x1d/0x1f
     [<6008e27e>] __setup_irq+0x11d/0x623
     [<6008e8ed>] request_threaded_irq+0x169/0x1a6
     [<60021eb0>] um_request_irq+0x1ee/0x24b
     [<600234ee>] write_sigio_irq+0x3b/0x76
     [<600383ca>] sigio_broken+0x146/0x2e4
     [<60020bd8>] do_one_initcall+0xde/0x281
    
    Because we hold sigio_spinlock and then get into requesting
    an interrupt with a mutex.
    
    Change the spinlock to a mutex to avoid that.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1ce1948602722d5b402d2f3c336d8372b252000d
Author: Harald Freudenberger <freude@linux.ibm.com>
Date:   Tue Aug 4 09:27:47 2020 +0200

    s390/ap/zcrypt: revisit ap and zcrypt error handling
    
    [ Upstream commit e0332629e33d1926c93348d918aaaf451ef9a16b ]
    
    Revisit the ap queue error handling: Based on discussions and
    evaluatios with the firmware folk here is now a rework of the response
    code handling for all the AP instructions. The idea is to distinguish
    between failures because of some kind of invalid request where a retry
    does not make any sense and a failure where another attempt to send
    the very same request may succeed. The first case is handled by
    returning EINVAL to the userspace application. The second case results
    in retries within the zcrypt API controlled by a per message retry
    counter.
    
    Revisit the zcrpyt error handling: Similar here, based on discussions
    with the firmware people here comes a rework of the handling of all
    the reply codes.  Main point here is that there are only very few
    cases left, where a zcrypt device queue is switched to offline. It
    should never be the case that an AP reply message is 'unknown' to the
    device driver as it indicates a total mismatch between device driver
    and crypto card firmware. In all other cases, the code distinguishes
    between failure because of invalid message (see above - EINVAL) or
    failures of the infrastructure (see above - EAGAIN).
    
    Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 09c8c3f9c91d6b3c666756c6d0e787e82318c901
Author: Chao Yu <chao@kernel.org>
Date:   Fri Sep 18 11:03:49 2020 +0800

    f2fs: compress: fix to disallow enabling compress on non-empty file
    
    [ Upstream commit 519a5a2f37b850f4eb86674a10d143088670a390 ]
    
    Compressed inode and normal inode has different layout, so we should
    disallow enabling compress on non-empty file to avoid race condition
    during inode .i_addr array parsing and updating.
    
    Signed-off-by: Chao Yu <yuchao0@huawei.com>
    [Jaegeuk Kim: Fix missing condition]
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0d41bd04b4825327e950e3f6ff059254f6fbae31
Author: Vasily Gorbik <gor@linux.ibm.com>
Date:   Thu Sep 24 19:07:04 2020 +0200

    s390/startup: avoid save_area_sync overflow
    
    [ Upstream commit 2835c2ea95d50625108e47a459e1a47f6be836ce ]
    
    Currently we overflow save_area_sync and write over
    save_area_async. Although this is not a real problem make
    startup_pgm_check_handler consistent with late pgm check handler and
    store [%r0,%r7] directly into gpregs_save_area.
    
    Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
    Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit eb8ce8c51f95f880746f712cf6022bb0137f5eee
Author: Chao Yu <chao@kernel.org>
Date:   Tue Sep 29 09:23:12 2020 +0800

    f2fs: fix to check segment boundary during SIT page readahead
    
    [ Upstream commit 6a257471fa42c8c9c04a875cd3a2a22db148e0f0 ]
    
    As syzbot reported:
    
    kernel BUG at fs/f2fs/segment.h:657!
    invalid opcode: 0000 [#1] PREEMPT SMP KASAN
    CPU: 1 PID: 16220 Comm: syz-executor.0 Not tainted 5.9.0-rc5-syzkaller #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    RIP: 0010:f2fs_ra_meta_pages+0xa51/0xdc0 fs/f2fs/segment.h:657
    Call Trace:
     build_sit_entries fs/f2fs/segment.c:4195 [inline]
     f2fs_build_segment_manager+0x4b8a/0xa3c0 fs/f2fs/segment.c:4779
     f2fs_fill_super+0x377d/0x6b80 fs/f2fs/super.c:3633
     mount_bdev+0x32e/0x3f0 fs/super.c:1417
     legacy_get_tree+0x105/0x220 fs/fs_context.c:592
     vfs_get_tree+0x89/0x2f0 fs/super.c:1547
     do_new_mount fs/namespace.c:2875 [inline]
     path_mount+0x1387/0x2070 fs/namespace.c:3192
     do_mount fs/namespace.c:3205 [inline]
     __do_sys_mount fs/namespace.c:3413 [inline]
     __se_sys_mount fs/namespace.c:3390 [inline]
     __x64_sys_mount+0x27f/0x300 fs/namespace.c:3390
     do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    @blkno in f2fs_ra_meta_pages could exceed max segment count, causing panic
    in following sanity check in current_sit_addr(), add check condition to
    avoid this issue.
    
    Reported-by: syzbot+3698081bcf0bb2d12174@syzkaller.appspotmail.com
    Signed-off-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit cc7038332a313e0aeafebf96acec20b2194f2f96
Author: Chao Yu <chao@kernel.org>
Date:   Tue Sep 29 09:22:50 2020 +0800

    f2fs: fix uninit-value in f2fs_lookup
    
    [ Upstream commit 6d7ab88a98c1b7a47c228f8ffb4f44d631eaf284 ]
    
    As syzbot reported:
    
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x21c/0x280 lib/dump_stack.c:118
     kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:122
     __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:219
     f2fs_lookup+0xe05/0x1a80 fs/f2fs/namei.c:503
     lookup_open fs/namei.c:3082 [inline]
     open_last_lookups fs/namei.c:3177 [inline]
     path_openat+0x2729/0x6a90 fs/namei.c:3365
     do_filp_open+0x2b8/0x710 fs/namei.c:3395
     do_sys_openat2+0xa88/0x1140 fs/open.c:1168
     do_sys_open fs/open.c:1184 [inline]
     __do_compat_sys_openat fs/open.c:1242 [inline]
     __se_compat_sys_openat+0x2a4/0x310 fs/open.c:1240
     __ia32_compat_sys_openat+0x56/0x70 fs/open.c:1240
     do_syscall_32_irqs_on arch/x86/entry/common.c:80 [inline]
     __do_fast_syscall_32+0x129/0x180 arch/x86/entry/common.c:139
     do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:162
     do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:205
     entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
    
    In f2fs_lookup(), @res_page could be used before being initialized,
    because in __f2fs_find_entry(), once F2FS_I(dir)->i_current_depth was
    been fuzzed to zero, then @res_page will never be initialized, causing
    this kmsan warning, relocating @res_page initialization place to fix
    this bug.
    
    Reported-by: syzbot+0eac6f0bbd558fd866d7@syzkaller.appspotmail.com
    Signed-off-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 01dcc51b7f77cce261035b97bde81f88c252bfb7
Author: Chao Yu <chao@kernel.org>
Date:   Mon Sep 21 20:53:13 2020 +0800

    f2fs: do sanity check on zoned block device path
    
    [ Upstream commit 07eb1d699452de04e9d389ff17fb8fc9e975d7bf ]
    
    sbi->devs would be initialized only if image enables multiple device
    feature or blkzoned feature, if blkzoned feature flag was set by fuzz
    in non-blkzoned device, we will suffer below panic:
    
    get_zone_idx fs/f2fs/segment.c:4892 [inline]
    f2fs_usable_zone_blks_in_seg fs/f2fs/segment.c:4943 [inline]
    f2fs_usable_blks_in_seg+0x39b/0xa00 fs/f2fs/segment.c:4999
    Call Trace:
     check_block_count+0x69/0x4e0 fs/f2fs/segment.h:704
     build_sit_entries fs/f2fs/segment.c:4403 [inline]
     f2fs_build_segment_manager+0x51da/0xa370 fs/f2fs/segment.c:5100
     f2fs_fill_super+0x3880/0x6ff0 fs/f2fs/super.c:3684
     mount_bdev+0x32e/0x3f0 fs/super.c:1417
     legacy_get_tree+0x105/0x220 fs/fs_context.c:592
     vfs_get_tree+0x89/0x2f0 fs/super.c:1547
     do_new_mount fs/namespace.c:2896 [inline]
     path_mount+0x12ae/0x1e70 fs/namespace.c:3216
     do_mount fs/namespace.c:3229 [inline]
     __do_sys_mount fs/namespace.c:3437 [inline]
     __se_sys_mount fs/namespace.c:3414 [inline]
     __x64_sys_mount+0x27f/0x300 fs/namespace.c:3414
     do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
    
    Add sanity check to inconsistency on factors: blkzoned flag, device
    path and device character to avoid above panic.
    
    Signed-off-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5042a546b6f256f46b4bb415edf0a5d5de770908
Author: Zhang Qilong <zhangqilong3@huawei.com>
Date:   Mon Sep 21 20:45:44 2020 +0800

    f2fs: add trace exit in exception path
    
    [ Upstream commit 9b66482282888d02832b7d90239e1cdb18e4b431 ]
    
    Missing the trace exit in f2fs_sync_dirty_inodes
    
    Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
    Reviewed-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 51fcce5a4ec7050acbcb616c95a71ea0357e34d0
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Mon Sep 14 14:52:18 2020 +1000

    sparc64: remove mm_cpumask clearing to fix kthread_use_mm race
    
    [ Upstream commit bafb056ce27940c9994ea905336aa8f27b4f7275 ]
    
    The de facto (and apparently uncommented) standard for using an mm had,
    thanks to this code in sparc if nothing else, been that you must have a
    reference on mm_users *and that reference must have been obtained with
    mmget()*, i.e., from a thread with a reference to mm_users that had used
    the mm.
    
    The introduction of mmget_not_zero() in commit d2005e3f41d4
    ("userfaultfd: don't pin the user memory in userfaultfd_file_create()")
    allowed mm_count holders to aoperate on user mappings asynchronously
    from the actual threads using the mm, but they were not to load those
    mappings into their TLB (i.e., walking vmas and page tables is okay,
    kthread_use_mm() is not).
    
    io_uring 2b188cc1bb857 ("Add io_uring IO interface") added code which
    does a kthread_use_mm() from a mmget_not_zero() refcount.
    
    The problem with this is code which previously assumed mm == current->mm
    and mm->mm_users == 1 implies the mm will remain single-threaded at
    least until this thread creates another mm_users reference, has now
    broken.
    
    arch/sparc/kernel/smp_64.c:
    
        if (atomic_read(&mm->mm_users) == 1) {
            cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
            goto local_flush_and_out;
        }
    
    vs fs/io_uring.c
    
        if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL) ||
                     !mmget_not_zero(ctx->sqo_mm)))
            return -EFAULT;
        kthread_use_mm(ctx->sqo_mm);
    
    mmget_not_zero() could come in right after the mm_users == 1 test, then
    kthread_use_mm() which sets its CPU in the mm_cpumask. That update could
    be lost if cpumask_copy() occurs afterward.
    
    I propose we fix this by allowing mmget_not_zero() to be a first-class
    reference, and not have this obscure undocumented and unchecked
    restriction.
    
    The basic fix for sparc64 is to remove its mm_cpumask clearing code. The
    optimisation could be effectively restored by sending IPIs to mm_cpumask
    members and having them remove themselves from mm_cpumask. This is more
    tricky so I leave it as an exercise for someone with a sparc64 SMP.
    powerpc has a (currently similarly broken) example.
    
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Acked-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200914045219.3736466-4-npiggin@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e3783eb86c89ca941cd6e383e0be79e2c60a2389
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Mon Sep 14 14:52:17 2020 +1000

    powerpc: select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
    
    [ Upstream commit 66acd46080bd9e5ad2be4b0eb1d498d5145d058e ]
    
    powerpc uses IPIs in some situations to switch a kernel thread away
    from a lazy tlb mm, which is subject to the TLB flushing race
    described in the changelog introducing ARCH_WANT_IRQS_OFF_ACTIVATE_MM.
    
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200914045219.3736466-3-npiggin@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5311d47879a826e34642f51cb73538e3c334d681
Author: Nicholas Piggin <npiggin@gmail.com>
Date:   Mon Sep 14 14:52:16 2020 +1000

    mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race
    
    [ Upstream commit d53c3dfb23c45f7d4f910c3a3ca84bf0a99c6143 ]
    
    Reading and modifying current->mm and current->active_mm and switching
    mm should be done with irqs off, to prevent races seeing an intermediate
    state.
    
    This is similar to commit 38cf307c1f20 ("mm: fix kthread_use_mm() vs TLB
    invalidate"). At exec-time when the new mm is activated, the old one
    should usually be single-threaded and no longer used, unless something
    else is holding an mm_users reference (which may be possible).
    
    Absent other mm_users, there is also a race with preemption and lazy tlb
    switching. Consider the kernel_execve case where the current thread is
    using a lazy tlb active mm:
    
      call_usermodehelper()
        kernel_execve()
          old_mm = current->mm;
          active_mm = current->active_mm;
          *** preempt *** -------------------->  schedule()
                                                   prev->active_mm = NULL;
                                                   mmdrop(prev active_mm);
                                                 ...
                          <--------------------  schedule()
          current->mm = mm;
          current->active_mm = mm;
          if (!old_mm)
              mmdrop(active_mm);
    
    If we switch back to the kernel thread from a different mm, there is a
    double free of the old active_mm, and a missing free of the new one.
    
    Closing this race only requires interrupts to be disabled while ->mm
    and ->active_mm are being switched, but the TLB problem requires also
    holding interrupts off over activate_mm. Unfortunately not all archs
    can do that yet, e.g., arm defers the switch if irqs are disabled and
    expects finish_arch_post_lock_switch() to be called to complete the
    flush; um takes a blocking lock in activate_mm().
    
    So as a first step, disable interrupts across the mm/active_mm updates
    to close the lazy tlb preempt race, and provide an arch option to
    extend that to activate_mm which allows architectures doing IPI based
    TLB shootdowns to close the second race.
    
    This is a bit ugly, but in the interest of fixing the bug and backporting
    before all architectures are converted this is a compromise.
    
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200914045219.3736466-2-npiggin@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6e7c31e49e6dd7bd163d918ce3d4faea73e54e62
Author: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Date:   Wed Sep 2 09:59:40 2020 +0530

    powerpc/watchpoint/ptrace: Fix SETHWDEBUG when CONFIG_HAVE_HW_BREAKPOINT=N
    
    [ Upstream commit 9b6b7c680cc20971444d9f836e49fc98848bcd0a ]
    
    When kernel is compiled with CONFIG_HAVE_HW_BREAKPOINT=N, user can
    still create watchpoint using PPC_PTRACE_SETHWDEBUG, with limited
    functionalities. But, such watchpoints are never firing because of
    the missing privilege settings. Fix that.
    
    It's safe to set HW_BRK_TYPE_PRIV_ALL because we don't really leak
    any kernel address in signal info. Setting HW_BRK_TYPE_PRIV_ALL will
    also help to find scenarios when kernel accesses user memory.
    
    Reported-by: Pedro Miraglia Franco de Carvalho <pedromfc@linux.ibm.com>
    Suggested-by: Pedro Miraglia Franco de Carvalho <pedromfc@linux.ibm.com>
    Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200902042945.129369-4-ravi.bangoria@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6dac3326c5769d6cd9ebeddde63d6d063cc608a7
Author: Chao Yu <chao@kernel.org>
Date:   Wed Sep 2 15:01:52 2020 +0800

    f2fs: allocate proper size memory for zstd decompress
    
    [ Upstream commit 0e2b7385cb59e566520cfd0a04b4b53bc9461e98 ]
    
    As 5kft <5kft@5kft.org> reported:
    
     kworker/u9:3: page allocation failure: order:9, mode:0x40c40(GFP_NOFS|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0
     CPU: 3 PID: 8168 Comm: kworker/u9:3 Tainted: G         C        5.8.3-sunxi #trunk
     Hardware name: Allwinner sun8i Family
     Workqueue: f2fs_post_read_wq f2fs_post_read_work
     [<c010d6d5>] (unwind_backtrace) from [<c0109a55>] (show_stack+0x11/0x14)
     [<c0109a55>] (show_stack) from [<c056d489>] (dump_stack+0x75/0x84)
     [<c056d489>] (dump_stack) from [<c0243b53>] (warn_alloc+0xa3/0x104)
     [<c0243b53>] (warn_alloc) from [<c024473b>] (__alloc_pages_nodemask+0xb87/0xc40)
     [<c024473b>] (__alloc_pages_nodemask) from [<c02267c5>] (kmalloc_order+0x19/0x38)
     [<c02267c5>] (kmalloc_order) from [<c02267fd>] (kmalloc_order_trace+0x19/0x90)
     [<c02267fd>] (kmalloc_order_trace) from [<c047c665>] (zstd_init_decompress_ctx+0x21/0x88)
     [<c047c665>] (zstd_init_decompress_ctx) from [<c047e9cf>] (f2fs_decompress_pages+0x97/0x228)
     [<c047e9cf>] (f2fs_decompress_pages) from [<c045d0ab>] (__read_end_io+0xfb/0x130)
     [<c045d0ab>] (__read_end_io) from [<c045d141>] (f2fs_post_read_work+0x61/0x84)
     [<c045d141>] (f2fs_post_read_work) from [<c0130b2f>] (process_one_work+0x15f/0x3b0)
     [<c0130b2f>] (process_one_work) from [<c0130e7b>] (worker_thread+0xfb/0x3e0)
     [<c0130e7b>] (worker_thread) from [<c0135c3b>] (kthread+0xeb/0x10c)
     [<c0135c3b>] (kthread) from [<c0100159>]
    
    zstd may allocate large size memory for {,de}compression, it may cause
    file copy failure on low-end device which has very few memory.
    
    For decompression, let's just allocate proper size memory based on current
    file's cluster size instead of max cluster size.
    
    Reported-by: 5kft <5kft@5kft.org>
    Signed-off-by: Chao Yu <yuchao0@huawei.com>
    Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 44c1c8c227b7d9cd560bb6575870aa146daae969
Author: Jason Gunthorpe <jgg@ziepe.ca>
Date:   Wed Sep 2 11:17:08 2020 +0300

    RDMA/core: Change how failing destroy is handled during uobj abort
    
    [ Upstream commit f553246f7f794675da1794ae7ee07d1f35e561ae ]
    
    Currently it triggers a WARN_ON and then goes ahead and destroys the
    uobject anyhow, leaking any driver memory.
    
    The only place that leaks driver memory should be during FD close() in
    uverbs_destroy_ufile_hw().
    
    Drivers are only allowed to fail destroy uobjects if they guarantee
    destroy will eventually succeed. uverbs_destroy_ufile_hw() provides the
    loop to give the driver that chance.
    
    Link: https://lore.kernel.org/r/20200902081708.746631-1-leon@kernel.org
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d4ddc5ade2994a4df7e725c5214e36e4ea540f53
Author: Oliver O'Halloran <oohall@gmail.com>
Date:   Tue Aug 4 10:54:05 2020 +1000

    powerpc/powernv/smp: Fix spurious DBG() warning
    
    [ Upstream commit f6bac19cf65c5be21d14a0c9684c8f560f2096dd ]
    
    When building with W=1 we get the following warning:
    
     arch/powerpc/platforms/powernv/smp.c: In function ‘pnv_smp_cpu_kill_self’:
     arch/powerpc/platforms/powernv/smp.c:276:16: error: suggest braces around
            empty body in an ‘if’ statement [-Werror=empty-body]
       276 |      cpu, srr1);
           |                ^
     cc1: all warnings being treated as errors
    
    The full context is this block:
    
     if (srr1 && !generic_check_cpu_restart(cpu))
            DBG("CPU%d Unexpected exit while offline srr1=%lx!\n",
                            cpu, srr1);
    
    When building with DEBUG undefined DBG() expands to nothing and GCC emits
    the warning due to the lack of braces around an empty statement.
    
    Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
    Reviewed-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200804005410.146094-2-oohall@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3ae2f2b9b7a0cc8066235a128ec3aa57cfca1111
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Fri Jul 31 17:04:59 2020 +0530

    powerpc/vmemmap: Fix memory leak with vmemmap list allocation failures.
    
    [ Upstream commit ccaea15296f9773abd43aaa17ee4b88848e4a505 ]
    
    If we fail to allocate vmemmap list, we don't keep track of allocated
    vmemmap block buf. Hence on section deactivate we skip vmemmap block
    buf free. This results in memory leak.
    
    Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20200731113500.248306-1-aneesh.kumar@linux.ibm.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7120a843a356ddae6222b6a78aa1cc4309f2f88e
Author: Mateusz Nosek <mateusznosek0@gmail.com>
Date:   Sun Sep 27 02:08:58 2020 +0200

    futex: Fix incorrect should_fail_futex() handling
    
    [ Upstream commit 921c7ebd1337d1a46783d7e15a850e12aed2eaa0 ]
    
    If should_futex_fail() returns true in futex_wake_pi(), then the 'ret'
    variable is set to -EFAULT and then immediately overwritten. So the failure
    injection is non-functional.
    
    Fix it by actually leaving the function and returning -EFAULT.
    
    The Fixes tag is kinda blury because the initial commit which introduced
    failure injection was already sloppy, but the below mentioned commit broke
    it completely.
    
    [ tglx: Massaged changelog ]
    
    Fixes: 6b4f4bc9cb22 ("locking/futex: Allow low-level atomic operations to return -EAGAIN")
    Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20200927000858.24219-1-mateusznosek0@gmail.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4da20d6e80a0559f972060c8791a6640ccb4760e
Author: Tang Bin <tangbin@cmss.chinamobile.com>
Date:   Mon Oct 26 17:06:57 2020 +0800

    usb: host: ehci-tegra: Fix error handling in tegra_ehci_probe()
    
    [ Upstream commit 32d174d2d5eb318c34ff36771adefabdf227c186 ]
    
    If the function platform_get_irq() failed, the negative value
    returned will not be detected here. So fix error handling in
    tegra_ehci_probe().
    
    Fixes: 79ad3b5add4a ("usb: host: Add EHCI driver for NVIDIA Tegra SoCs")
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Acked-by: Thierry Reding <treding@nvidia.com>
    Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
    Link: https://lore.kernel.org/r/20201026090657.49988-1-tangbin@cmss.chinamobile.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4028b426991952a2cc0f93fa23ae55a7c9292868
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Thu Oct 22 12:23:02 2020 +0200

    lockdep: Fix preemption WARN for spurious IRQ-enable
    
    [ Upstream commit f8e48a3dca060e80f672d398d181db1298fbc86c ]
    
    It is valid (albeit uncommon) to call local_irq_enable() without first
    having called local_irq_disable(). In this case we enter
    lockdep_hardirqs_on*() with IRQs enabled and trip a preemption warning
    for using __this_cpu_read().
    
    Use this_cpu_read() instead to avoid the warning.
    
    Fixes: 4d004099a6 ("lockdep: Fix lockdep recursion")
    Reported-by: syzbot+53f8ce8bbc07924b6417@syzkaller.appspotmail.com
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 95580381ec06cd08b1ed44e6c770da16f5b3ee7b
Author: Georgi Djakov <georgi.djakov@linaro.org>
Date:   Mon Oct 12 22:40:34 2020 +0300

    interconnect: qcom: sdm845: Enable keepalive for the MM1 BCM
    
    [ Upstream commit 5be1805dc3961ce0465bcb0beab85fe8580af08d ]
    
    After enabling interconnect scaling for display on the db845c board,
    in certain configurations the board hangs, while the following errors
    are observed on the console:
    
      Error sending AMC RPMH requests (-110)
      qcom_rpmh TCS Busy, retrying RPMH message send: addr=0x50000
      qcom_rpmh TCS Busy, retrying RPMH message send: addr=0x50000
      qcom_rpmh TCS Busy, retrying RPMH message send: addr=0x50000
      ...
    
    In this specific case, the above is related to one of the sequencers
    being stuck, while client drivers are returning from probe and trying
    to disable the currently unused clock and interconnect resources.
    Generally we want to keep the multimedia NoC enabled like the rest of
    the NoCs, so let's set the keepalive flag on it too.
    
    Fixes: aae57773fbe0 ("interconnect: qcom: sdm845: Split qnodes into their respective NoCs")
    Reported-by: Amit Pundir <amit.pundir@linaro.org>
    Reviewed-by: Mike Tipton <mdtipton@codeaurora.org>
    Tested-by: John Stultz <john.stultz@linaro.org>
    Link: https://lore.kernel.org/r/20201012194034.26944-1-georgi.djakov@linaro.org
    Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 636c6eee590fe6b56e03cb117647203802a8a65a
Author: Laurent Vivier <lvivier@redhat.com>
Date:   Thu Oct 29 13:20:49 2020 +0100

    vdpasim: fix MAC address configuration
    
    [ Upstream commit 4a6a42db53aae049a8a64d4b273761bc80c46ebf ]
    
    vdpa_sim generates a ramdom MAC address but it is never used by upper
    layers because the VIRTIO_NET_F_MAC bit is not set in the features list.
    
    Because of that, virtio-net always regenerates a random MAC address each
    time it is loaded whereas the address should only change on vdpa_sim
    load/unload.
    
    Fix that by adding VIRTIO_NET_F_MAC in the features list of vdpa_sim.
    
    Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
    Cc: jasowang@redhat.com
    Signed-off-by: Laurent Vivier <lvivier@redhat.com>
    Link: https://lore.kernel.org/r/20201029122050.776445-2-lvivier@redhat.com
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5ecf1c68aaeb9014312cb39bebac2ad63489e96b
Author: David Howells <dhowells@redhat.com>
Date:   Wed Oct 28 12:08:39 2020 +0000

    afs: Fix dirty-region encoding on ppc32 with 64K pages
    
    [ Upstream commit 2d9900f26ad61e63a34f239bc76c80d2f8a6ff41 ]
    
    The dirty region bounds stored in page->private on an afs page are 15 bits
    on a 32-bit box and can, at most, represent a range of up to 32K within a
    32K page with a resolution of 1 byte.  This is a problem for powerpc32 with
    64K pages enabled.
    
    Further, transparent huge pages may get up to 2M, which will be a problem
    for the afs filesystem on all 32-bit arches in the future.
    
    Fix this by decreasing the resolution.  For the moment, a 64K page will
    have a resolution determined from PAGE_SIZE.  In the future, the page will
    need to be passed in to the helper functions so that the page size can be
    assessed and the resolution determined dynamically.
    
    Note that this might not be the ideal way to handle this, since it may
    allow some leakage of undirtied zero bytes to the server's copy in the case
    of a 3rd-party conflict.  Fixing that would require a separately allocated
    record and is a more complicated fix.
    
    Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit db43215c102f1339b4de74bd080536ce5e6b2dc1
Author: David Howells <dhowells@redhat.com>
Date:   Thu Oct 22 14:08:23 2020 +0100

    afs: Fix afs_invalidatepage to adjust the dirty region
    
    [ Upstream commit f86726a69dec5df6ba051baf9265584419478b64 ]
    
    Fix afs_invalidatepage() to adjust the dirty region recorded in
    page->private when truncating a page.  If the dirty region is entirely
    removed, then the private data is cleared and the page dirty state is
    cleared.
    
    Without this, if the page is truncated and then expanded again by truncate,
    zeros from the expanded, but no-longer dirty region may get written back to
    the server if the page gets laundered due to a conflicting 3rd-party write.
    
    It mustn't, however, shorten the dirty region of the page if that page is
    still mmapped and has been marked dirty by afs_page_mkwrite(), so a flag is
    stored in page->private to record this.
    
    Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2ecc9510833c66cad87a1eceff2708055fd4532e
Author: David Howells <dhowells@redhat.com>
Date:   Mon Oct 26 13:57:44 2020 +0000

    afs: Alter dirty range encoding in page->private
    
    [ Upstream commit 65dd2d6072d393a3aa14ded8afa9a12f27d9c8ad ]
    
    Currently, page->private on an afs page is used to store the range of
    dirtied data within the page, where the range includes the lower bound, but
    excludes the upper bound (e.g. 0-1 is a range covering a single byte).
    
    This, however, requires a superfluous bit for the last-byte bound so that
    on a 4KiB page, it can say 0-4096 to indicate the whole page, the idea
    being that having both numbers the same would indicate an empty range.
    This is unnecessary as the PG_private bit is clear if it's an empty range
    (as is PG_dirty).
    
    Alter the way the dirty range is encoded in page->private such that the
    upper bound is reduced by 1 (e.g. 0-0 is then specified the same single
    byte range mentioned above).
    
    Applying this to both bounds frees up two bits, one of which can be used in
    a future commit.
    
    This allows the afs filesystem to be compiled on ppc32 with 64K pages;
    without this, the following warnings are seen:
    
    ../fs/afs/internal.h: In function 'afs_page_dirty_to':
    ../fs/afs/internal.h:881:15: warning: right shift count >= width of type [-Wshift-count-overflow]
      881 |  return (priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK;
          |               ^~
    ../fs/afs/internal.h: In function 'afs_page_dirty':
    ../fs/afs/internal.h:886:28: warning: left shift count >= width of type [-Wshift-count-overflow]
      886 |  return ((unsigned long)to << __AFS_PAGE_PRIV_SHIFT) | from;
          |                            ^~
    
    Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ad08180bdfe563d4cf20c78a5f0db42e1e8765a8
Author: David Howells <dhowells@redhat.com>
Date:   Mon Oct 26 13:22:47 2020 +0000

    afs: Wrap page->private manipulations in inline functions
    
    [ Upstream commit 185f0c7073bd5c78f86265f703f5daf1306ab5a7 ]
    
    The afs filesystem uses page->private to store the dirty range within a
    page such that in the event of a conflicting 3rd-party write to the server,
    we write back just the bits that got changed locally.
    
    However, there are a couple of problems with this:
    
     (1) I need a bit to note if the page might be mapped so that partial
         invalidation doesn't shrink the range.
    
     (2) There aren't necessarily sufficient bits to store the entire range of
         data altered (say it's a 32-bit system with 64KiB pages or transparent
         huge pages are in use).
    
    So wrap the accesses in inline functions so that future commits can change
    how this works.
    
    Also move them out of the tracing header into the in-directory header.
    There's not really any need for them to be in the tracing header.
    
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d82995e7b6684c1e8f34f4c92b9a9df377c82e75
Author: David Howells <dhowells@redhat.com>
Date:   Mon Oct 26 14:05:33 2020 +0000

    afs: Fix where page->private is set during write
    
    [ Upstream commit f792e3ac82fe2c6c863e93187eb7ddfccab68fa7 ]
    
    In afs, page->private is set to indicate the dirty region of a page.  This
    is done in afs_write_begin(), but that can't take account of whether the
    copy into the page actually worked.
    
    Fix this by moving the change of page->private into afs_write_end().
    
    Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a88bbf94e24438bbdacc78c8a1caedd955d7707c
Author: David Howells <dhowells@redhat.com>
Date:   Thu Oct 22 14:03:03 2020 +0100

    afs: Fix page leak on afs_write_begin() failure
    
    [ Upstream commit 21db2cdc667f744691a407105b7712bc18d74023 ]
    
    Fix the leak of the target page in afs_write_begin() when it fails.
    
    Fixes: 15b4650e55e0 ("afs: convert to new aops")
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Nick Piggin <npiggin@gmail.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 67375bd879437b5d60e0984f87e093d524a4749f
Author: David Howells <dhowells@redhat.com>
Date:   Wed Oct 21 13:22:19 2020 +0100

    afs: Fix to take ref on page when PG_private is set
    
    [ Upstream commit fa04a40b169fcee615afbae97f71a09332993f64 ]
    
    Fix afs to take a ref on a page when it sets PG_private on it and to drop
    the ref when removing the flag.
    
    Note that in afs_write_begin(), a lot of the time, PG_private is already
    set on a page to which we're going to add some data.  In such a case, we
    leave the bit set and mustn't increment the page count.
    
    As suggested by Matthew Wilcox, use attach/detach_page_private() where
    possible.
    
    Fixes: 31143d5d515e ("AFS: implement basic file write support")
    Reported-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 765c116aff4bbf003711f8bf2ecdbc50b0298940
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Tue Oct 27 08:32:06 2020 +0100

    arm64: efi: increase EFI PE/COFF header padding to 64 KB
    
    [ Upstream commit a2d50c1c77aa879af24f9f67b33186737b3d4885 ]
    
    Commit 76085aff29f5 ("efi/libstub/arm64: align PE/COFF sections to segment
    alignment") increased the PE/COFF section alignment to match the minimum
    segment alignment of the kernel image, which ensures that the kernel does
    not need to be moved around in memory by the EFI stub if it was built as
    relocatable.
    
    However, the first PE/COFF section starts at _stext, which is only 4 KB
    aligned, and so the section layout is inconsistent. Existing EFI loaders
    seem to care little about this, but it is better to clean this up.
    
    So let's pad the header to 64 KB to match the PE/COFF section alignment.
    
    Fixes: 76085aff29f5 ("efi/libstub/arm64: align PE/COFF sections to segment alignment")
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Link: https://lore.kernel.org/r/20201027073209.2897-2-ardb@kernel.org
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e6bec26805ebc17cb39e7dcfa6e3bc5b8e36ba57
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Fri May 8 07:28:19 2020 +0200

    ata: sata_nv: Fix retrieving of active qcs
    
    [ Upstream commit 8e4c309f9f33b76c09daa02b796ef87918eee494 ]
    
    ata_qc_complete_multiple() has to be called with the tags physically
    active, that is the hw tag is at bit 0. ap->qc_active has the same tag
    at bit ATA_TAG_INTERNAL instead, so call ata_qc_get_active() to fix that
    up. This is done in the vein of 8385d756e114 ("libata: Fix retrieving of
    active qcs").
    
    Fixes: 28361c403683 ("libata: add extra internal command")
    Tested-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0d587af1b8855b6b4100e45a58f876bc6024e85a
Author: Alok Prasad <palok@marvell.com>
Date:   Wed Oct 21 11:50:08 2020 +0000

    RDMA/qedr: Fix memory leak in iWARP CM
    
    [ Upstream commit a2267f8a52eea9096861affd463f691be0f0e8c9 ]
    
    Fixes memory leak in iWARP CM
    
    Fixes: e411e0587e0d ("RDMA/qedr: Add iWARP connection management functions")
    Link: https://lore.kernel.org/r/20201021115008.28138-1-palok@marvell.com
    Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
    Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
    Signed-off-by: Alok Prasad <palok@marvell.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2c2b887165b1b9571a351a35585b89244cebfa5a
Author: David Howells <dhowells@redhat.com>
Date:   Thu Oct 22 14:40:31 2020 +0100

    afs: Fix afs_launder_page to not clear PG_writeback
    
    [ Upstream commit d383e346f97d6bb0d654bb3d63c44ab106d92d29 ]
    
    Fix afs_launder_page() to not clear PG_writeback on the page it is
    laundering as the flag isn't set in this case.
    
    Fixes: 4343d00872e1 ("afs: Get rid of the afs_writeback record")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e167e9cf4db7c975679c42bd855bd27fa4622632
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Mon Aug 24 11:58:12 2020 +0300

    afs: Fix a use after free in afs_xattr_get_acl()
    
    [ Upstream commit 248c944e2159de4868bef558feea40214aaf8464 ]
    
    The "op" pointer is freed earlier when we call afs_put_operation().
    
    Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 620e69608db535a4cc892a49a70c26322d355fdd
Author: Sasha Levin <sashal@kernel.org>
Date:   Sun Nov 1 12:35:33 2020 -0500

    tracing, synthetic events: Replace buggy strcat() with seq_buf operations
    
    [ Upstream commit 761a8c58db6bc884994b28cd6d9707b467d680c1 ]
    
    There was a memory corruption bug happening while running the synthetic
    event selftests:
    
     kmemleak: Cannot insert 0xffff8c196fa2afe5 into the object search tree (overlaps existing)
     CPU: 5 PID: 6866 Comm: ftracetest Tainted: G        W         5.9.0-rc5-test+ #577
     Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
     Call Trace:
      dump_stack+0x8d/0xc0
      create_object.cold+0x3b/0x60
      slab_post_alloc_hook+0x57/0x510
      ? tracing_map_init+0x178/0x340
      __kmalloc+0x1b1/0x390
      tracing_map_init+0x178/0x340
      event_hist_trigger_func+0x523/0xa40
      trigger_process_regex+0xc5/0x110
      event_trigger_write+0x71/0xd0
      vfs_write+0xca/0x210
      ksys_write+0x70/0xf0
      do_syscall_64+0x33/0x40
      entry_SYSCALL_64_after_hwframe+0x44/0xa9
     RIP: 0033:0x7fef0a63a487
     Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
     RSP: 002b:00007fff76f18398 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
     RAX: ffffffffffffffda RBX: 0000000000000039 RCX: 00007fef0a63a487
     RDX: 0000000000000039 RSI: 000055eb3b26d690 RDI: 0000000000000001
     RBP: 000055eb3b26d690 R08: 000000000000000a R09: 0000000000000038
     R10: 000055eb3b2cdb80 R11: 0000000000000246 R12: 0000000000000039
     R13: 00007fef0a70b500 R14: 0000000000000039 R15: 00007fef0a70b700
     kmemleak: Kernel memory leak detector disabled
     kmemleak: Object 0xffff8c196fa2afe0 (size 8):
     kmemleak:   comm "ftracetest", pid 6866, jiffies 4295082531
     kmemleak:   min_count = 1
     kmemleak:   count = 0
     kmemleak:   flags = 0x1
     kmemleak:   checksum = 0
     kmemleak:   backtrace:
          __kmalloc+0x1b1/0x390
          tracing_map_init+0x1be/0x340
          event_hist_trigger_func+0x523/0xa40
          trigger_process_regex+0xc5/0x110
          event_trigger_write+0x71/0xd0
          vfs_write+0xca/0x210
          ksys_write+0x70/0xf0
          do_syscall_64+0x33/0x40
          entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    The cause came down to a use of strcat() that was adding an string that was
    shorten, but the strcat() did not take that into account.
    
    strcat() is extremely dangerous as it does not care how big the buffer is.
    Replace it with seq_buf operations that prevent the buffer from being
    overwritten if what is being written is bigger than the buffer.
    
    Fixes: 10819e25799a ("tracing: Handle synthetic event array field type checking correctly")
    Reviewed-by: Tom Zanussi <zanussi@kernel.org>
    Tested-by: Tom Zanussi <zanussi@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit acdb3422ee7e854c6a6e81af025d284299ea4c38
Author: Amit Cohen <amcohen@nvidia.com>
Date:   Sat Oct 24 16:37:33 2020 +0300

    mlxsw: core: Fix use-after-free in mlxsw_emad_trans_finish()
    
    [ Upstream commit 0daf2bf5a2dcf33d446b76360908f109816e2e21 ]
    
    Each EMAD transaction stores the skb used to issue the EMAD request
    ('trans->tx_skb') so that the request could be retried in case of a
    timeout. The skb can be freed when a corresponding response is received
    or as part of the retry logic (e.g., failed retransmit, exceeded maximum
    number of retries).
    
    The two tasks (i.e., response processing and retransmits) are
    synchronized by the atomic 'trans->active' field which ensures that
    responses to inactive transactions are ignored.
    
    In case of a failed retransmit the transaction is finished and all of
    its resources are freed. However, the current code does not mark it as
    inactive. Syzkaller was able to hit a race condition in which a
    concurrent response is processed while the transaction's resources are
    being freed, resulting in a use-after-free [1].
    
    Fix the issue by making sure to mark the transaction as inactive after a
    failed retransmit and free its resources only if a concurrent task did
    not already do that.
    
    [1]
    BUG: KASAN: use-after-free in consume_skb+0x30/0x370
    net/core/skbuff.c:833
    Read of size 4 at addr ffff88804f570494 by task syz-executor.0/1004
    
    CPU: 0 PID: 1004 Comm: syz-executor.0 Not tainted 5.8.0-rc7+ #68
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
    rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0xf6/0x16e lib/dump_stack.c:118
     print_address_description.constprop.0+0x1c/0x250
    mm/kasan/report.c:383
     __kasan_report mm/kasan/report.c:513 [inline]
     kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
     check_memory_region_inline mm/kasan/generic.c:186 [inline]
     check_memory_region+0x14e/0x1b0 mm/kasan/generic.c:192
     instrument_atomic_read include/linux/instrumented.h:56 [inline]
     atomic_read include/asm-generic/atomic-instrumented.h:27 [inline]
     refcount_read include/linux/refcount.h:147 [inline]
     skb_unref include/linux/skbuff.h:1044 [inline]
     consume_skb+0x30/0x370 net/core/skbuff.c:833
     mlxsw_emad_trans_finish+0x64/0x1c0 drivers/net/ethernet/mellanox/mlxsw/core.c:592
     mlxsw_emad_process_response drivers/net/ethernet/mellanox/mlxsw/core.c:651 [inline]
     mlxsw_emad_rx_listener_func+0x5c9/0xac0 drivers/net/ethernet/mellanox/mlxsw/core.c:672
     mlxsw_core_skb_receive+0x4df/0x770 drivers/net/ethernet/mellanox/mlxsw/core.c:2063
     mlxsw_pci_cqe_rdq_handle drivers/net/ethernet/mellanox/mlxsw/pci.c:595 [inline]
     mlxsw_pci_cq_tasklet+0x12a6/0x2520 drivers/net/ethernet/mellanox/mlxsw/pci.c:651
     tasklet_action_common.isra.0+0x13f/0x3e0 kernel/softirq.c:550
     __do_softirq+0x223/0x964 kernel/softirq.c:292
     asm_call_on_stack+0x12/0x20 arch/x86/entry/entry_64.S:711
    
    Allocated by task 1006:
     save_stack+0x1b/0x40 mm/kasan/common.c:48
     set_track mm/kasan/common.c:56 [inline]
     __kasan_kmalloc mm/kasan/common.c:494 [inline]
     __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:467
     slab_post_alloc_hook mm/slab.h:586 [inline]
     slab_alloc_node mm/slub.c:2824 [inline]
     slab_alloc mm/slub.c:2832 [inline]
     kmem_cache_alloc+0xcd/0x2e0 mm/slub.c:2837
     __build_skb+0x21/0x60 net/core/skbuff.c:311
     __netdev_alloc_skb+0x1e2/0x360 net/core/skbuff.c:464
     netdev_alloc_skb include/linux/skbuff.h:2810 [inline]
     mlxsw_emad_alloc drivers/net/ethernet/mellanox/mlxsw/core.c:756 [inline]
     mlxsw_emad_reg_access drivers/net/ethernet/mellanox/mlxsw/core.c:787 [inline]
     mlxsw_core_reg_access_emad+0x1ab/0x1420 drivers/net/ethernet/mellanox/mlxsw/core.c:1817
     mlxsw_reg_trans_query+0x39/0x50 drivers/net/ethernet/mellanox/mlxsw/core.c:1831
     mlxsw_sp_sb_pm_occ_clear drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c:260 [inline]
     mlxsw_sp_sb_occ_max_clear+0xbff/0x10a0 drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c:1365
     mlxsw_devlink_sb_occ_max_clear+0x76/0xb0 drivers/net/ethernet/mellanox/mlxsw/core.c:1037
     devlink_nl_cmd_sb_occ_max_clear_doit+0x1ec/0x280 net/core/devlink.c:1765
     genl_family_rcv_msg_doit net/netlink/genetlink.c:669 [inline]
     genl_family_rcv_msg net/netlink/genetlink.c:714 [inline]
     genl_rcv_msg+0x617/0x980 net/netlink/genetlink.c:731
     netlink_rcv_skb+0x152/0x440 net/netlink/af_netlink.c:2470
     genl_rcv+0x24/0x40 net/netlink/genetlink.c:742
     netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
     netlink_unicast+0x53a/0x750 net/netlink/af_netlink.c:1330
     netlink_sendmsg+0x850/0xd90 net/netlink/af_netlink.c:1919
     sock_sendmsg_nosec net/socket.c:651 [inline]
     sock_sendmsg+0x150/0x190 net/socket.c:671
     ____sys_sendmsg+0x6d8/0x840 net/socket.c:2359
     ___sys_sendmsg+0xff/0x170 net/socket.c:2413
     __sys_sendmsg+0xe5/0x1b0 net/socket.c:2446
     do_syscall_64+0x56/0xa0 arch/x86/entry/common.c:384
     entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    Freed by task 73:
     save_stack+0x1b/0x40 mm/kasan/common.c:48
     set_track mm/kasan/common.c:56 [inline]
     kasan_set_free_info mm/kasan/common.c:316 [inline]
     __kasan_slab_free+0x12c/0x170 mm/kasan/common.c:455
     slab_free_hook mm/slub.c:1474 [inline]
     slab_free_freelist_hook mm/slub.c:1507 [inline]
     slab_free mm/slub.c:3072 [inline]
     kmem_cache_free+0xbe/0x380 mm/slub.c:3088
     kfree_skbmem net/core/skbuff.c:622 [inline]
     kfree_skbmem+0xef/0x1b0 net/core/skbuff.c:616
     __kfree_skb net/core/skbuff.c:679 [inline]
     consume_skb net/core/skbuff.c:837 [inline]
     consume_skb+0xe1/0x370 net/core/skbuff.c:831
     mlxsw_emad_trans_finish+0x64/0x1c0 drivers/net/ethernet/mellanox/mlxsw/core.c:592
     mlxsw_emad_transmit_retry.isra.0+0x9d/0xc0 drivers/net/ethernet/mellanox/mlxsw/core.c:613
     mlxsw_emad_trans_timeout_work+0x43/0x50 drivers/net/ethernet/mellanox/mlxsw/core.c:625
     process_one_work+0xa3e/0x17a0 kernel/workqueue.c:2269
     worker_thread+0x9e/0x1050 kernel/workqueue.c:2415
     kthread+0x355/0x470 kernel/kthread.c:291
     ret_from_fork+0x22/0x30 arch/x86/entry/entry_64.S:293
    
    The buggy address belongs to the object at ffff88804f5703c0
     which belongs to the cache skbuff_head_cache of size 224
    The buggy address is located 212 bytes inside of
     224-byte region [ffff88804f5703c0, ffff88804f5704a0)
    The buggy address belongs to the page:
    page:ffffea00013d5c00 refcount:1 mapcount:0 mapping:0000000000000000
    index:0x0
    flags: 0x100000000000200(slab)
    raw: 0100000000000200 dead000000000100 dead000000000122 ffff88806c625400
    raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
    page dumped because: kasan: bad access detected
    
    Memory state around the buggy address:
     ffff88804f570380: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
     ffff88804f570400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    >ffff88804f570480: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
                             ^
     ffff88804f570500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffff88804f570580: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
    
    Fixes: caf7297e7ab5f ("mlxsw: core: Introduce support for asynchronous EMAD register access")
    Signed-off-by: Amit Cohen <amcohen@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 161b8996d0c3c5a5c8d5e219ac585c222eed2e8d
Author: Parav Pandit <parav@nvidia.com>
Date:   Mon Oct 26 15:43:59 2020 +0200

    RDMA/mlx5: Fix devlink deadlock on net namespace deletion
    
    [ Upstream commit fbdd0049d98d44914fc57d4b91f867f4996c787b ]
    
    When a mlx5 core devlink instance is reloaded in different net namespace,
    its associated IB device is deleted and recreated.
    
    Example sequence is:
    $ ip netns add foo
    $ devlink dev reload pci/0000:00:08.0 netns foo
    $ ip netns del foo
    
    mlx5 IB device needs to attach and detach the netdevice to it through the
    netdev notifier chain during load and unload sequence.  A below call graph
    of the unload flow.
    
    cleanup_net()
       down_read(&pernet_ops_rwsem); <- first sem acquired
         ops_pre_exit_list()
           pre_exit()
             devlink_pernet_pre_exit()
               devlink_reload()
                 mlx5_devlink_reload_down()
                   mlx5_unload_one()
                   [...]
                     mlx5_ib_remove()
                       mlx5_ib_unbind_slave_port()
                         mlx5_remove_netdev_notifier()
                           unregister_netdevice_notifier()
                             down_write(&pernet_ops_rwsem);<- recurrsive lock
    
    Hence, when net namespace is deleted, mlx5 reload results in deadlock.
    
    When deadlock occurs, devlink mutex is also held. This not only deadlocks
    the mlx5 device under reload, but all the processes which attempt to
    access unrelated devlink devices are deadlocked.
    
    Hence, fix this by mlx5 ib driver to register for per net netdev notifier
    instead of global one, which operats on the net namespace without holding
    the pernet_ops_rwsem.
    
    Fixes: 4383cfcc65e7 ("net/mlx5: Add devlink reload")
    Link: https://lore.kernel.org/r/20201026134359.23150-1-parav@nvidia.com
    Signed-off-by: Parav Pandit <parav@nvidia.com>
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f17225eb0907bc27020f62098cb196813b5fea49
Author: Sasha Levin <sashal@kernel.org>
Date:   Sun Nov 1 12:30:42 2020 -0500

    ionic: no rx flush in deinit
    
    [ Upstream commit 43ecf7b46f2688fd37909801aee264f288b3917b ]
    
    Kmemleak pointed out to us that ionic_rx_flush() is sending
    skbs into napi_gro_XXX with a disabled napi context, and these
    end up getting lost and leaked.  We can safely remove the flush.
    
    Fixes: 0f3154e6bcb3 ("ionic: Add Tx and Rx handling")
    Signed-off-by: Shannon Nelson <snelson@pensando.io>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e7d0b164729b1c376b3dc60aed6eec18580da783
Author: Juergen Gross <jgross@suse.com>
Date:   Fri Oct 9 16:42:25 2020 +0200

    x86/alternative: Don't call text_poke() in lazy TLB mode
    
    [ Upstream commit abee7c494d8c41bb388839bccc47e06247f0d7de ]
    
    When running in lazy TLB mode the currently active page tables might
    be the ones of a previous process, e.g. when running a kernel thread.
    
    This can be problematic in case kernel code is being modified via
    text_poke() in a kernel thread, and on another processor exit_mmap()
    is active for the process which was running on the first cpu before
    the kernel thread.
    
    As text_poke() is using a temporary address space and the former
    address space (obtained via cpu_tlbstate.loaded_mm) is restored
    afterwards, there is a race possible in case the cpu on which
    exit_mmap() is running wants to make sure there are no stale
    references to that address space on any cpu active (this e.g. is
    required when running as a Xen PV guest, where this problem has been
    observed and analyzed).
    
    In order to avoid that, drop off TLB lazy mode before switching to the
    temporary address space.
    
    Fixes: cefa929c034eb5d ("x86/mm: Introduce temporary mm structs")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Link: https://lkml.kernel.org/r/20201009144225.12019-1-jgross@suse.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e0bab5e1504bd42afa029fd0dc25e5d3de9a9661
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Tue Oct 13 19:17:37 2020 -0700

    firmware: arm_scmi: Fix duplicate workqueue name
    
    [ Upstream commit b9ceca6be43233845be70792be9b5ab315d2e010 ]
    
    When more than a single SCMI device are present in the system, the
    creation of the notification workqueue with the WQ_SYSFS flag will lead
    to the following sysfs duplicate node warning:
    
     sysfs: cannot create duplicate filename '/devices/virtual/workqueue/scmi_notify'
     CPU: 0 PID: 20 Comm: kworker/0:1 Not tainted 5.9.0-gdf4dd84a3f7d #29
     Hardware name: Broadcom STB (Flattened Device Tree)
     Workqueue: events deferred_probe_work_func
     Backtrace:
       show_stack + 0x20/0x24
       dump_stack + 0xbc/0xe0
       sysfs_warn_dup + 0x70/0x80
       sysfs_create_dir_ns + 0x15c/0x1a4
       kobject_add_internal + 0x140/0x4d0
       kobject_add + 0xc8/0x138
       device_add + 0x1dc/0xc20
       device_register + 0x24/0x28
       workqueue_sysfs_register + 0xe4/0x1f0
       alloc_workqueue + 0x448/0x6ac
       scmi_notification_init + 0x78/0x1dc
       scmi_probe + 0x268/0x4fc
       platform_drv_probe + 0x70/0xc8
       really_probe + 0x184/0x728
       driver_probe_device + 0xa4/0x278
       __device_attach_driver + 0xe8/0x148
       bus_for_each_drv + 0x108/0x158
       __device_attach + 0x190/0x234
       device_initial_probe + 0x1c/0x20
       bus_probe_device + 0xdc/0xec
       deferred_probe_work_func + 0xd4/0x11c
       process_one_work + 0x420/0x8f0
       worker_thread + 0x4fc/0x91c
       kthread + 0x21c/0x22c
       ret_from_fork + 0x14/0x20
     kobject_add_internal failed for scmi_notify with -EEXIST, don't try to
            register things with the same name in the same directory.
     arm-scmi brcm_scmi@1: SCMI Notifications - Initialization Failed.
     arm-scmi brcm_scmi@1: SCMI Notifications NOT available.
     arm-scmi brcm_scmi@1: SCMI Protocol v1.0 'brcm-scmi:' Firmware version 0x1
    
    Fix this by using dev_name(handle->dev) which guarantees that the name is
    unique and this also helps correlate which notification workqueue corresponds
    to which SCMI device instance.
    
    Link: https://lore.kernel.org/r/20201014021737.287340-1-f.fainelli@gmail.com
    Fixes: bd31b249692e ("firmware: arm_scmi: Add notification dispatch and delivery")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    [sudeep.holla: trimmed backtrace to remove all unwanted hexcodes and timestamps]
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 8db07e440b6d3f55ff9df640dfbe4b9a8728ed8f
Author: Cristian Marussi <cristian.marussi@arm.com>
Date:   Tue Oct 13 14:31:09 2020 +0100

    firmware: arm_scmi: Fix locking in notifications
    
    [ Upstream commit c7821c2d9c0dda0adf2bcf88e79b02a19a430be4 ]
    
    When a protocol registers its events, the notification core takes care
    to rescan the hashtable of pending event handlers and activate all the
    possibly existent handlers referring to any of the events that are just
    registered by the new protocol. When a pending handler becomes active
    the core requests and enables the corresponding events in the SCMI
    firmware.
    
    If, for whatever reason, the enable fails, such invalid event handler
    must be finally removed and freed. Let us ensure to use the
    scmi_put_active_handler() helper which handles properly the needed
    additional locking.
    
    Failing to properly acquire all the needed mutexes exposes a race that
    leads to the following splat being observed:
    
     WARNING: CPU: 0 PID: 388 at lib/refcount.c:28 refcount_warn_saturate+0xf8/0x148
     Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development
            Platform, BIOS EDK II Jun 30 2020
     pstate: 40000005 (nZcv daif -PAN -UAO BTYPE=--)
     pc : refcount_warn_saturate+0xf8/0x148
     lr : refcount_warn_saturate+0xf8/0x148
     Call trace:
      refcount_warn_saturate+0xf8/0x148
      scmi_put_handler_unlocked.isra.10+0x204/0x208
      scmi_put_handler+0x50/0xa0
      scmi_unregister_notifier+0x1bc/0x240
      scmi_notify_tester_remove+0x4c/0x68 [dummy_scmi_consumer]
      scmi_dev_remove+0x54/0x68
      device_release_driver_internal+0x114/0x1e8
      driver_detach+0x58/0xe8
      bus_remove_driver+0x88/0xe0
      driver_unregister+0x38/0x68
      scmi_driver_unregister+0x1c/0x28
      scmi_drv_exit+0x1c/0xae0 [dummy_scmi_consumer]
      __arm64_sys_delete_module+0x1a4/0x268
      el0_svc_common.constprop.3+0x94/0x178
      do_el0_svc+0x2c/0x98
      el0_sync_handler+0x148/0x1a8
      el0_sync+0x158/0x180
    
    Link: https://lore.kernel.org/r/20201013133109.49821-1-cristian.marussi@arm.com
    Fixes: e7c215f358a35 ("firmware: arm_scmi: Add notification callbacks-registration")
    Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c2214a35d609224d4df2039ebaf0ca239978b398
Author: Jiri Slaby <jirislaby@kernel.org>
Date:   Wed Oct 14 07:30:51 2020 +0200

    x86/unwind/orc: Fix inactive tasks with stack pointer in %sp on GCC 10 compiled kernels
    
    [ Upstream commit f2ac57a4c49d40409c21c82d23b5706df9b438af ]
    
    GCC 10 optimizes the scheduler code differently than its predecessors.
    
    When CONFIG_DEBUG_SECTION_MISMATCH=y, the Makefile forces GCC not
    to inline some functions (-fno-inline-functions-called-once). Before GCC
    10, "no-inlined" __schedule() starts with the usual prologue:
    
      push %bp
      mov %sp, %bp
    
    So the ORC unwinder simply picks stack pointer from %bp and
    unwinds from __schedule() just perfectly:
    
      $ cat /proc/1/stack
      [<0>] ep_poll+0x3e9/0x450
      [<0>] do_epoll_wait+0xaa/0xc0
      [<0>] __x64_sys_epoll_wait+0x1a/0x20
      [<0>] do_syscall_64+0x33/0x40
      [<0>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
    
    But now, with GCC 10, there is no %bp prologue in __schedule():
    
      $ cat /proc/1/stack
      <nothing>
    
    The ORC entry of the point in __schedule() is:
    
      sp:sp+88 bp:last_sp-48 type:call end:0
    
    In this case, nobody subtracts sizeof "struct inactive_task_frame" in
    __unwind_start(). The struct is put on the stack by __switch_to_asm() and
    only then __switch_to_asm() stores %sp to task->thread.sp. But we start
    unwinding from a point in __schedule() (stored in frame->ret_addr by
    'call') and not in __switch_to_asm().
    
    So for these example values in __unwind_start():
    
      sp=ffff94b50001fdc8 bp=ffff8e1f41d29340 ip=__schedule+0x1f0
    
    The stack is:
    
      ffff94b50001fdc8: ffff8e1f41578000 # struct inactive_task_frame
      ffff94b50001fdd0: 0000000000000000
      ffff94b50001fdd8: ffff8e1f41d29340
      ffff94b50001fde0: ffff8e1f41611d40 # ...
      ffff94b50001fde8: ffffffff93c41920 # bx
      ffff94b50001fdf0: ffff8e1f41d29340 # bp
      ffff94b50001fdf8: ffffffff9376cad0 # ret_addr (and end of the struct)
    
    0xffffffff9376cad0 is __schedule+0x1f0 (after the call to
    __switch_to_asm).  Now follow those 88 bytes from the ORC entry (sp+88).
    The entry is correct, __schedule() really pushes 48 bytes (8*7) + 32 bytes
    via subq to store some local values (like 4U below). So to unwind, look
    at the offset 88-sizeof(long) = 0x50 from here:
    
      ffff94b50001fe00: ffff8e1f41578618
      ffff94b50001fe08: 00000cc000000255
      ffff94b50001fe10: 0000000500000004
      ffff94b50001fe18: 7793fab6956b2d00 # NOTE (see below)
      ffff94b50001fe20: ffff8e1f41578000
      ffff94b50001fe28: ffff8e1f41578000
      ffff94b50001fe30: ffff8e1f41578000
      ffff94b50001fe38: ffff8e1f41578000
      ffff94b50001fe40: ffff94b50001fed8
      ffff94b50001fe48: ffff8e1f41577ff0
      ffff94b50001fe50: ffffffff9376cf12
    
    Here                ^^^^^^^^^^^^^^^^ is the correct ret addr from
    __schedule(). It translates to schedule+0x42 (insn after a call to
    __schedule()).
    
    BUT, unwind_next_frame() tries to take the address starting from
    0xffff94b50001fdc8. That is exactly from thread.sp+88-sizeof(long) =
    0xffff94b50001fdc8+88-8 = 0xffff94b50001fe18, which is garbage marked as
    NOTE above. So this quits the unwinding as 7793fab6956b2d00 is obviously
    not a kernel address.
    
    There was a fix to skip 'struct inactive_task_frame' in
    unwind_get_return_address_ptr in the following commit:
    
      187b96db5ca7 ("x86/unwind/orc: Fix unwind_get_return_address_ptr() for inactive tasks")
    
    But we need to skip the struct already in the unwinder proper. So
    subtract the size (increase the stack pointer) of the structure in
    __unwind_start() directly. This allows for removal of the code added by
    commit 187b96db5ca7 completely, as the address is now at
    '(unsigned long *)state->sp - 1', the same as in the generic case.
    
    [ mingo: Cleaned up the changelog a bit, for better readability. ]
    
    Fixes: ee9f8fce9964 ("x86/unwind: Add the ORC unwinder")
    Bug: https://bugzilla.suse.com/show_bug.cgi?id=1176907
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/20201014053051.24199-1-jslaby@suse.cz
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0a9466f36cde35638d3473bb8fb967b0124180c2
Author: Sudeep Holla <sudeep.holla@arm.com>
Date:   Mon Oct 12 14:26:24 2020 +0100

    firmware: arm_scmi: Add missing Rx size re-initialisation
    
    [ Upstream commit 9724722fde8f9bbd2b87340f00b9300c9284001e ]
    
    Few commands provide the list of description partially and require
    to be called consecutively until all the descriptors are fetched
    completely. In such cases, we don't release the buffers and reuse
    them for consecutive transmits.
    
    However, currently we don't reset the Rx size which will be set as
    per the response for the last transmit. This may result in incorrect
    response size being interpretted as the firmware may repond with size
    greater than the one set but we read only upto the size set by previous
    response.
    
    Let us reset the receive buffer size to max possible in such cases as
    we don't know the exact size of the response.
    
    Link:  https://lore.kernel.org/r/20201012141746.32575-1-sudeep.holla@arm.com
    Fixes: b6f20ff8bd94 ("firmware: arm_scmi: add common infrastructure and support for base protocol")
    Reported-by: Etienne Carriere <etienne.carriere@linaro.org>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 137064b3eb740898c9cb515b1bf25073739a10d2
Author: Sumit Garg <sumit.garg@linaro.org>
Date:   Thu Sep 17 19:10:22 2020 +0530

    tee: client UUID: Skip REE kernel login method as well
    
    [ Upstream commit 722939528a37aa0cb22d441e2045c0cf53e78fb0 ]
    
    Since the addition of session's client UUID generation via commit [1],
    login via REE kernel method was disallowed. So fix that via passing
    nill UUID in case of TEE_IOCTL_LOGIN_REE_KERNEL method as well.
    
    Fixes: e33bcbab16d1 ("tee: add support for session's client UUID generation") [1]
    Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
    Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3a2b9c8da21bc27b24e01e8d486240a76811bd02
Author: Etienne Carriere <etienne.carriere@linaro.org>
Date:   Thu Oct 8 16:37:21 2020 +0200

    firmware: arm_scmi: Expand SMC/HVC message pool to more than one
    
    [ Upstream commit 7adb2c8aaaa6a387af7140e57004beba2c04a4c6 ]
    
    SMC/HVC can transmit only one message at the time as the shared memory
    needs to be protected and the calls are synchronous.
    
    However, in order to allow multiple threads to send SCMI messages
    simultaneously, we need a larger poll of memory.
    
    Let us just use value of 20 to keep it in sync mailbox transport
    implementation. Any other value must work perfectly.
    
    Link: https://lore.kernel.org/r/20201008143722.21888-4-etienne.carriere@linaro.org
    Fixes: 1dc6558062da ("firmware: arm_scmi: Add smc/hvc transport")
    Cc: Peng Fan <peng.fan@nxp.com>
    Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
    [sudeep.holla: reworded the commit message to indicate the practicality]
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 99efe4a3232ce5cb91c194cfd06a429f7bd810dc
Author: Etienne Carriere <etienne.carriere@linaro.org>
Date:   Thu Oct 8 16:37:22 2020 +0200

    firmware: arm_scmi: Fix ARCH_COLD_RESET
    
    [ Upstream commit 45b9e04d5ba0b043783dfe2b19bb728e712cb32e ]
    
    The defination for ARCH_COLD_RESET is wrong. Let us fix it according to
    the SCMI specification.
    
    Link: https://lore.kernel.org/r/20201008143722.21888-5-etienne.carriere@linaro.org
    Fixes: 95a15d80aa0d ("firmware: arm_scmi: Add RESET protocol in SCMI v2.0")
    Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9572c78fbf7bcf274384552031138209eb8c5964
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 14 14:01:02 2020 +0200

    xen/events: block rogue events for some time
    
    commit 5f7f77400ab5b357b5fdb7122c3442239672186c upstream.
    
    In order to avoid high dom0 load due to rogue guests sending events at
    high frequency, block those events in case there was no action needed
    in dom0 to handle the events.
    
    This is done by adding a per-event counter, which set to zero in case
    an EOI without the XEN_EOI_FLAG_SPURIOUS is received from a backend
    driver, and incremented when this flag has been set. In case the
    counter is 2 or higher delay the EOI by 1 << (cnt - 2) jiffies, but
    not more than 1 second.
    
    In order not to waste memory shorten the per-event refcnt to two bytes
    (it should normally never exceed a value of 2). Add an overflow check
    to evtchn_get() to make sure the 2 bytes really won't overflow.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d985af1ca3d0e07c3167c712a0288450aa14a002
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:30 2020 +0200

    xen/events: defer eoi in case of excessive number of events
    
    commit e99502f76271d6bc4e374fe368c50c67a1fd3070 upstream.
    
    In case rogue guests are sending events at high frequency it might
    happen that xen_evtchn_do_upcall() won't stop processing events in
    dom0. As this is done in irq handling a crash might be the result.
    
    In order to avoid that, delay further inter-domain events after some
    time in xen_evtchn_do_upcall() by forcing eoi processing into a
    worker on the same cpu, thus inhibiting new events coming in.
    
    The time after which eoi processing is to be delayed is configurable
    via a new module parameter "event_loop_timeout" which specifies the
    maximum event loop time in jiffies (default: 2, the value was chosen
    after some tests showing that a value of 2 was the lowest with an
    only slight drop of dom0 network throughput while multiple guests
    performed an event storm).
    
    How long eoi processing will be delayed can be specified via another
    parameter "event_eoi_delay" (again in jiffies, default 10, again the
    value was chosen after testing with different delay values).
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a942cd654112e7e14301404521cb83a4e2f951c2
Author: Juergen Gross <jgross@suse.com>
Date:   Sun Sep 13 14:23:02 2020 +0200

    xen/events: use a common cpu hotplug hook for event channels
    
    commit 7beb290caa2adb0a399e735a1e175db9aae0523a upstream.
    
    Today only fifo event channels have a cpu hotplug callback. In order
    to prepare for more percpu (de)init work move that callback into
    events_base.c and add percpu_init() and percpu_deinit() hooks to
    struct evtchn_ops.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 573b878eed1305a2006361db763ce00504e781f1
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:29 2020 +0200

    xen/events: switch user event channels to lateeoi model
    
    commit c44b849cee8c3ac587da3b0980e01f77500d158c upstream.
    
    Instead of disabling the irq when an event is received and enabling
    it again when handled by the user process use the lateeoi model.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Tested-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4d7e5f611b8e427a5d143170a0c5aa072a4503ca
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:29 2020 +0200

    xen/pciback: use lateeoi irq binding
    
    commit c2711441bc961b37bba0615dd7135857d189035f upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving pcifront use the lateeoi irq
    binding for pciback and unmask the event channel only just before
    leaving the event handling function.
    
    Restructure the handling to support that scheme. Basically an event can
    come in for two reasons: either a normal request for a pciback action,
    which is handled in a worker, or in case the guest has finished an AER
    request which was requested by pciback.
    
    When an AER request is issued to the guest and a normal pciback action
    is currently active issue an EOI early in order to be able to receive
    another event when the AER request has been finished by the guest.
    
    Let the worker processing the normal requests run until no further
    request is pending, instead of starting a new worker ion that case.
    Issue the EOI only just before leaving the worker.
    
    This scheme allows to drop calling the generic function
    xen_pcibk_test_and_schedule_op() after processing of any request as
    the handling of both request types is now separated more cleanly.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 751ce9ffc994c467bf8ed4c4b94d668c1829ca3a
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:28 2020 +0200

    xen/pvcallsback: use lateeoi irq binding
    
    commit c8d647a326f06a39a8e5f0f1af946eacfa1835f8 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving pvcallsfront use the lateeoi
    irq binding for pvcallsback and unmask the event channel only after
    handling all write requests, which are the ones coming in via an irq.
    
    This requires modifying the logic a little bit to not require an event
    for each write request, but to keep the ioworker running until no
    further data is found on the ring page to be processed.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d9a71a4153aedc045a9c0fe818f248895875570f
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:28 2020 +0200

    xen/scsiback: use lateeoi irq binding
    
    commit 86991b6e7ea6c613b7692f65106076943449b6b7 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving scsifront use the lateeoi
    irq binding for scsiback and unmask the event channel only just before
    leaving the event handling function.
    
    In case of a ring protocol error don't issue an EOI in order to avoid
    the possibility to use that for producing an event storm. This at once
    will result in no further call of scsiback_irq_fn(), so the ring_error
    struct member can be dropped and scsiback_do_cmd_fn() can signal the
    protocol error via a negative return value.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 23ba4f63296083481d975aeafead92c740ef04ad
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:28 2020 +0200

    xen/netback: use lateeoi irq binding
    
    commit 23025393dbeb3b8b3b60ebfa724cdae384992e27 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving netfront use the lateeoi
    irq binding for netback and unmask the event channel only just before
    going to sleep waiting for new events.
    
    Make sure not to issue an EOI when none is pending by introducing an
    eoi_pending element to struct xenvif_queue.
    
    When no request has been consumed set the spurious flag when sending
    the EOI for an interrupt.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e8ae8e67ebc4c7581fcd31e2c92fb9ab7abf2303
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:27 2020 +0200

    xen/blkback: use lateeoi irq binding
    
    commit 01263a1fabe30b4d542f34c7e2364a22587ddaf2 upstream.
    
    In order to reduce the chance for the system becoming unresponsive due
    to event storms triggered by a misbehaving blkfront use the lateeoi
    irq binding for blkback and unmask the event channel only after
    processing all pending requests.
    
    As the thread processing requests is used to do purging work in regular
    intervals an EOI may be sent only after having received an event. If
    there was no pending I/O request flag the EOI as spurious.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c4f9ce89fc6e05abee7f8bc0db1a29bdec4eb7ad
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:27 2020 +0200

    xen/events: add a new "late EOI" evtchn framework
    
    commit 54c9de89895e0a36047fcc4ae754ea5b8655fb9d upstream.
    
    In order to avoid tight event channel related IRQ loops add a new
    framework of "late EOI" handling: the IRQ the event channel is bound
    to will be masked until the event has been handled and the related
    driver is capable to handle another event. The driver is responsible
    for unmasking the event channel via the new function xen_irq_lateeoi().
    
    This is similar to binding an event channel to a threaded IRQ, but
    without having to structure the driver accordingly.
    
    In order to support a future special handling in case a rogue guest
    is sending lots of unsolicited events, add a flag to xen_irq_lateeoi()
    which can be set by the caller to indicate the event was a spurious
    one.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ea23e8f3e1b74395e7e33eea2c3ac8e2dd338be7
Author: Juergen Gross <jgross@suse.com>
Date:   Tue Oct 20 06:52:55 2020 +0200

    xen/events: fix race in evtchn_fifo_unmask()
    
    commit f01337197419b7e8a492e83089552b77d3b5fb90 upstream.
    
    Unmasking a fifo event channel can result in unmasking it twice, once
    directly in the kernel and once via a hypercall in case the event was
    pending.
    
    Fix that by doing the local unmask only if the event is not pending.
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit efdaf1d3683c106b609d1170f640bdeccdbdcf63
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:27 2020 +0200

    xen/events: add a proper barrier to 2-level uevent unmasking
    
    commit 4d3fe31bd993ef504350989786858aefdb877daa upstream.
    
    A follow-up patch will require certain write to happen before an event
    channel is unmasked.
    
    While the memory barrier is not strictly necessary for all the callers,
    the main one will need it. In order to avoid an extra memory barrier
    when using fifo event channels, mandate evtchn_unmask() to provide
    write ordering.
    
    The 2-level event handling unmask operation is missing an appropriate
    barrier, so add it. Fifo event channels are fine in this regard due to
    using sync_cmpxchg().
    
    This is part of XSA-332.
    
    Cc: stable@vger.kernel.org
    Suggested-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6b7343607ffe88bd8a336d4a546dcf8ec383c456
Author: Juergen Gross <jgross@suse.com>
Date:   Mon Sep 7 15:47:27 2020 +0200

    xen/events: avoid removing an event channel while handling it
    
    commit 073d0552ead5bfc7a3a9c01de590e924f11b5dd2 upstream.
    
    Today it can happen that an event channel is being removed from the
    system while the event handling loop is active. This can lead to a
    race resulting in crashes or WARN() splats when trying to access the
    irq_info structure related to the event channel.
    
    Fix this problem by using a rwlock taken as reader in the event
    handling loop and as writer when deallocating the irq_info structure.
    
    As the observed problem was a NULL dereference in evtchn_from_irq()
    make this function more robust against races by testing the irq_info
    pointer to be not NULL before dereferencing it.
    
    And finally make all accesses to evtchn_to_irq[row][col] atomic ones
    in order to avoid seeing partial updates of an array element in irq
    handling. Note that irq handling can be entered only for event channels
    which have been valid before, so any not populated row isn't a problem
    in this regard, as rows are only ever added and never removed.
    
    This is XSA-331.
    
    Cc: stable@vger.kernel.org
    Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reported-by: Jinoh Kang <luke1337@theori.io>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Wei Liu <wl@xen.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>