Skip to content
  1. Jul 28, 2021
    • Mathias Nyman's avatar
      usb: hub: Disable USB 3 device initiated lpm if exit latency is too high · c7affd5b
      Mathias Nyman authored
      commit 1b7f56fb
      
       upstream.
      
      The device initiated link power management U1/U2 states should not be
      enabled in case the system exit latency plus one bus interval (125us) is
      greater than the shortest service interval of any periodic endpoint.
      
      This is the case for both U1 and U2 sytstem exit latencies and link states.
      
      See USB 3.2 section 9.4.9 "Set Feature" for more details
      
      Note, before this patch the host and device initiated U1/U2 lpm states
      were both enabled with lpm. After this patch it's possible to end up with
      only host inititated U1/U2 lpm in case the exit latencies won't allow
      device initiated lpm.
      
      If this case we still want to set the udev->usb3_lpm_ux_enabled flag so
      that sysfs users can see the link may go to U1/U2.
      
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210715150122.1995966-2-mathias.nyman@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7affd5b
    • Nicholas Piggin's avatar
      KVM: PPC: Book3S HV Nested: Sanitise H_ENTER_NESTED TM state · 1408e47a
      Nicholas Piggin authored
      commit d9c57d3e upstream.
      
      The H_ENTER_NESTED hypercall is handled by the L0, and it is a request
      by the L1 to switch the context of the vCPU over to that of its L2
      guest, and return with an interrupt indication. The L1 is responsible
      for switching some registers to guest context, and the L0 switches
      others (including all the hypervisor privileged state).
      
      If the L2 MSR has TM active, then the L1 is responsible for
      recheckpointing the L2 TM state. Then the L1 exits to L0 via the
      H_ENTER_NESTED hcall, and the L0 saves the TM state as part of the exit,
      and then it recheckpoints the TM state as part of the nested entry and
      finally HRFIDs into the L2 with TM active MSR. Not efficient, but about
      the simplest approach for something that's horrendously complicated.
      
      Problems arise if the L1 exits to the L0 with a TM state which does not
      match the L2 TM state being requested. For example if the L1 is
      transactional but the L2 MSR is non-transactional, or vice versa. The
      L0's HRFID can take a TM Bad Thing interrupt and crash.
      
      Fix this by disallowing H_ENTER_NESTED in TM[T] state entirely, and then
      ensuring that if the L1 is suspended then the L2 must have TM active,
      and if the L1 is not suspended then the L2 must not have TM active.
      
      Fixes: 360cae31
      
       ("KVM: PPC: Book3S HV: Nested guest entry via hypercall")
      Cc: stable@vger.kernel.org # v4.20+
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Acked-by: default avatarMichael Neuling <mikey@neuling.org>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1408e47a
    • Nicholas Piggin's avatar
      KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow · 35e114e6
      Nicholas Piggin authored
      commit f62f3c20 upstream.
      
      The kvmppc_rtas_hcall() sets the host rtas_args.rets pointer based on
      the rtas_args.nargs that was provided by the guest. That guest nargs
      value is not range checked, so the guest can cause the host rets pointer
      to be pointed outside the args array. The individual rtas function
      handlers check the nargs and nrets values to ensure they are correct,
      but if they are not, the handlers store a -3 (0xfffffffd) failure
      indication in rets[0] which corrupts host memory.
      
      Fix this by testing up front whether the guest supplied nargs and nret
      would exceed the array size, and fail the hcall directly without storing
      a failure indication to rets[0].
      
      Also expand on a comment about why we kill the guest and try not to
      return errors directly if we have a valid rets[0] pointer.
      
      Fixes: 8e591cb7
      
       ("KVM: PPC: Book3S: Add infrastructure to implement kernel-side RTAS calls")
      Cc: stable@vger.kernel.org # v3.10+
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35e114e6
    • David Jeffery's avatar
      usb: ehci: Prevent missed ehci interrupts with edge-triggered MSI · 3d98808e
      David Jeffery authored
      commit 0b605572 upstream.
      
      When MSI is used by the ehci-hcd driver, it can cause lost interrupts which
      results in EHCI only continuing to work due to a polling fallback. But the
      reliance of polling drastically reduces performance of any I/O through EHCI.
      
      Interrupts are lost as the EHCI interrupt handler does not safely handle
      edge-triggered interrupts. It fails to ensure all interrupt status bits are
      cleared, which works with level-triggered interrupts but not the
      edge-triggered interrupts typical from using MSI.
      
      To fix this problem, check if the driver may have raced with the hardware
      setting additional interrupt status bits and clear status until it is in a
      stable state.
      
      Fixes: 306c54d0
      
       ("usb: hcd: Try MSI interrupts on PCI devices")
      Tested-by: default avatarLaurence Oberman <loberman@redhat.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarDavid Jeffery <djeffery@redhat.com>
      Link: https://lore.kernel.org/r/20210715213744.GA44506@redhat
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d98808e
    • Mathias Nyman's avatar
      xhci: Fix lost USB 2 remote wake · 2c476bab
      Mathias Nyman authored
      commit 72f68bf5
      
       upstream.
      
      There's a small window where a USB 2 remote wake may be left unhandled
      due to a race between hub thread and xhci port event interrupt handler.
      
      When the resume event is detected in the xhci interrupt handler it kicks
      the hub timer, which should move the port from resume to U0 once resume
      has been signalled for long enough.
      
      To keep the hub "thread" running we set a bus_state->resuming_ports flag.
      This flag makes sure hub timer function kicks itself.
      
      checking this flag was not properly protected by the spinlock. Flag was
      copied to a local variable before lock was taken. The local variable was
      then checked later with spinlock held.
      
      If interrupt is handled right after copying the flag to the local variable
      we end up stopping the hub thread before it can handle the USB 2 resume.
      
      CPU0					CPU1
      (hub thread)				(xhci event handler)
      
      xhci_hub_status_data()
      status = bus_state->resuming_ports;
      					<Interrupt>
      					handle_port_status()
      					spin_lock()
      					bus_state->resuming_ports = 1
      					set_flag(HCD_FLAG_POLL_RH)
      					spin_unlock()
      spin_lock()
      if (!status)
        clear_flag(HCD_FLAG_POLL_RH)
      spin_unlock()
      
      Fix this by taking the lock a bit earlier so that it covers
      the resuming_ports flag copy in the hub thread
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20210715150651.1996099-2-mathias.nyman@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c476bab
    • Greg Thelen's avatar
      usb: xhci: avoid renesas_usb_fw.mem when it's unusable · 6c15cef9
      Greg Thelen authored
      commit 0665e387 upstream.
      
      Commit a66d21d7 ("usb: xhci: Add support for Renesas controller with
      memory") added renesas_usb_fw.mem firmware reference to xhci-pci.  Thus
      modinfo indicates xhci-pci.ko has "firmware: renesas_usb_fw.mem".  But
      the firmware is only actually used with CONFIG_USB_XHCI_PCI_RENESAS.  An
      unusable firmware reference can trigger safety checkers which look for
      drivers with unmet firmware dependencies.
      
      Avoid referring to renesas_usb_fw.mem in circumstances when it cannot be
      loaded (when CONFIG_USB_XHCI_PCI_RENESAS isn't set).
      
      Fixes: a66d21d7
      
       ("usb: xhci: Add support for Renesas controller with memory")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
      Link: https://lore.kernel.org/r/20210702071224.3673568-1-gthelen@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c15cef9
    • Moritz Fischer's avatar
      Revert "usb: renesas-xhci: Fix handling of unknown ROM state" · 62b022ed
      Moritz Fischer authored
      commit 44cf5360 upstream.
      
      This reverts commit d143825b
      
      .
      
      Justin reports some of his systems now fail as result of this commit:
      
       xhci_hcd 0000:04:00.0: Direct firmware load for renesas_usb_fw.mem failed with error -2
       xhci_hcd 0000:04:00.0: request_firmware failed: -2
       xhci_hcd: probe of 0000:04:00.0 failed with error -2
      
      The revert brings back the original issue the commit tried to solve but
      at least unbreaks existing systems relying on previous behavior.
      
      Cc: stable@vger.kernel.org
      Cc: Mathias Nyman <mathias.nyman@intel.com>
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: Justin Forbes <jmforbes@linuxtx.org>
      Reported-by: default avatarJustin Forbes <jmforbes@linuxtx.org>
      Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
      Fixes: d143825b
      
       ("usb: renesas-xhci: Fix handling of unknown ROM state")
      Link: https://lore.kernel.org/r/20210719070519.41114-1-mdf@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62b022ed
    • Takashi Iwai's avatar
      ALSA: pcm: Fix mmap capability check · 0def8cf0
      Takashi Iwai authored
      commit c4824ae7
      
       upstream.
      
      The hw_support_mmap() doesn't cover all memory allocation types and
      might use a wrong device pointer for checking the capability.
      Check the all memory allocation types more completely.
      
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210720092640.12338-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0def8cf0
    • Alan Young's avatar
      ALSA: pcm: Call substream ack() method upon compat mmap commit · 7ca1bb5b
      Alan Young authored
      commit 2e283256 upstream.
      
      If a 32-bit application is being used with a 64-bit kernel and is using
      the mmap mechanism to write data, then the SNDRV_PCM_IOCTL_SYNC_PTR
      ioctl results in calling snd_pcm_ioctl_sync_ptr_compat(). Make this use
      pcm_lib_apply_appl_ptr() so that the substream's ack() method, if
      defined, is called.
      
      The snd_pcm_sync_ptr() function, used in the 64-bit ioctl case, already
      uses snd_pcm_ioctl_sync_ptr_compat().
      
      Fixes: 9027c463
      
       ("ALSA: pcm: Call ack() whenever appl_ptr is updated")
      Signed-off-by: default avatarAlan Young <consult.awy@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/c441f18c-eb2a-3bdd-299a-696ccca2de9c@gmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ca1bb5b
    • Takashi Iwai's avatar
      ALSA: hdmi: Expose all pins on MSI MS-7C94 board · 7810cd82
      Takashi Iwai authored
      commit 33f735f1
      
       upstream.
      
      The BIOS on MSI Mortar B550m WiFi (MS-7C94) board with AMDGPU seems
      disabling the other pins than HDMI although it has more outputs
      including DP.
      
      This patch adds the board to the allow list for enabling all pins.
      
      Reported-by: default avatarDamjan Georgievski <gdamjan@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAEk1YH4Jd0a8vfZxORVu7qg+Zsc-K+pR187ezNq8QhJBPW4gpw@mail.gmail.com
      Link: https://lore.kernel.org/r/20210716135600.24176-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7810cd82
    • Hui Wang's avatar
      ALSA: hda/realtek: Fix pop noise and 2 Front Mic issues on a machine · 7b75c0f0
      Hui Wang authored
      commit e4efa826
      
       upstream.
      
      This is a Lenovo ThinkStation machine which uses the codec alc623.
      There are 2 issues on this machine, the 1st one is the pop noise in
      the lineout, the 2nd one is there are 2 Front Mics and pulseaudio
      can't handle them, After applying the fixup of
      ALC623_FIXUP_LENOVO_THINKSTATION_P340 to this machine, the 2 issues
      are fixed.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Link: https://lore.kernel.org/r/20210719030231.6870-1-hui.wang@canonical.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b75c0f0
    • Takashi Iwai's avatar
      ALSA: sb: Fix potential ABBA deadlock in CSP driver · ac8ea355
      Takashi Iwai authored
      commit 1c2b9519
      
       upstream.
      
      SB16 CSP driver may hit potentially a typical ABBA deadlock in two
      code paths:
      
       In snd_sb_csp_stop():
           spin_lock_irqsave(&p->chip->mixer_lock, flags);
           spin_lock(&p->chip->reg_lock);
      
       In snd_sb_csp_load():
           spin_lock_irqsave(&p->chip->reg_lock, flags);
           spin_lock(&p->chip->mixer_lock);
      
      Also the similar pattern is seen in snd_sb_csp_start().
      
      Although the practical impact is very small (those states aren't
      triggered in the same running state and this happens only on a real
      hardware, decades old ISA sound boards -- which must be very difficult
      to find nowadays), it's a real scenario and has to be fixed.
      
      This patch addresses those deadlocks by splitting the locks in
      snd_sb_csp_start() and snd_sb_csp_stop() for avoiding the nested
      locks.
      
      Reported-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/7b0fcdaf-cd4f-4728-2eae-48c151a92e10@gmail.com
      Link: https://lore.kernel.org/r/20210716132723.13216-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac8ea355
    • Alexander Tsoy's avatar
      ALSA: usb-audio: Add registration quirk for JBL Quantum headsets · ecdaa971
      Alexander Tsoy authored
      commit b0084afd
      
       upstream.
      
      These devices has two interfaces, but only the second interface
      contains the capture endpoint, thus quirk is required to delay the
      registration until the second interface appears.
      
      Tested-by: default avatarJakub Fišer <jakub@ufiseru.cz>
      Signed-off-by: default avatarAlexander Tsoy <alexander@tsoy.me>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210721235605.53741-1-alexander@tsoy.me
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecdaa971
    • Takashi Iwai's avatar
      ALSA: usb-audio: Add missing proc text entry for BESPOKEN type · 498129de
      Takashi Iwai authored
      commit 64752a95 upstream.
      
      Recently we've added a new usb_mixer element type, USB_MIXER_BESPOKEN,
      but it wasn't added in the table in snd_usb_mixer_dump_cval().  This
      is no big problem since each bespoken type should have its own dump
      method, but it still isn't disallowed to use the standard one, so we
      should cover it as well.  Along with it, define the table with the
      explicit array initializer for avoiding other pitfalls.
      
      Fixes: 785b6f29
      
       ("ALSA: usb-audio: scarlett2: Fix wrong resume call")
      Reported-by: default avatarPavel Machek <pavel@denx.de>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210714084836.1977-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      498129de
    • Alexander Egorenkov's avatar
      s390/boot: fix use of expolines in the DMA code · ca4c5e5c
      Alexander Egorenkov authored
      commit 463f36c7 upstream.
      
      The DMA code section of the decompressor must be compiled with expolines
      if Spectre V2 mitigation has been enabled for the decompressed kernel.
      This is required because although the decompressor's image contains
      the DMA code section, it is handed over to the decompressed kernel for use.
      
      Because the DMA code is already slow w/o expolines, use expolines always
      regardless whether the decompressed kernel is using them or not. This
      simplifies the DMA code by dropping the conditional compilation of
      expolines.
      
      Fixes: bf726301
      
       ("s390: use proper expoline sections for .dma code")
      Cc: <stable@vger.kernel.org> # 5.2
      Signed-off-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca4c5e5c
    • Vasily Gorbik's avatar
      s390/ftrace: fix ftrace_update_ftrace_func implementation · fde6627c
      Vasily Gorbik authored
      commit f8c26027 upstream.
      
      s390 enforces DYNAMIC_FTRACE if FUNCTION_TRACER is selected.
      At the same time implementation of ftrace_caller is not compliant with
      HAVE_DYNAMIC_FTRACE since it doesn't provide implementation of
      ftrace_update_ftrace_func() and calls ftrace_trace_function() directly.
      
      The subtle difference is that during ftrace code patching ftrace
      replaces function tracer via ftrace_update_ftrace_func() and activates
      it back afterwards. Unexpected direct calls to ftrace_trace_function()
      during ftrace code patching leads to nullptr-dereferences when tracing
      is activated for one of functions which are used during code patching.
      Those function currently are:
      copy_from_kernel_nofault()
      copy_from_kernel_nofault_allowed()
      preempt_count_sub() [with debug_defconfig]
      preempt_count_add() [with debug_defconfig]
      
      Corresponding KASAN report:
       BUG: KASAN: nullptr-dereference in function_trace_call+0x316/0x3b0
       Read of size 4 at addr 0000000000001e08 by task migration/0/15
      
       CPU: 0 PID: 15 Comm: migration/0 Tainted: G B 5.13.0-41423-g08316af3644d
       Hardware name: IBM 3906 M04 704 (LPAR)
       Stopper: multi_cpu_stop+0x0/0x3e0 <- stop_machine_cpuslocked+0x1e4/0x218
       Call Trace:
        [<0000000001f77caa>] show_stack+0x16a/0x1d0
        [<0000000001f8de42>] dump_stack+0x15a/0x1b0
        [<0000000001f81d56>] print_address_description.constprop.0+0x66/0x2e0
        [<000000000082b0ca>] kasan_report+0x152/0x1c0
        [<00000000004cfd8e>] function_trace_call+0x316/0x3b0
        [<0000000001fb7082>] ftrace_caller+0x7a/0x7e
        [<00000000006bb3e6>] copy_from_kernel_nofault_allowed+0x6/0x10
        [<00000000006bb42e>] copy_from_kernel_nofault+0x3e/0xd0
        [<000000000014605c>] ftrace_make_call+0xb4/0x1f8
        [<000000000047a1b4>] ftrace_replace_code+0x134/0x1d8
        [<000000000047a6e0>] ftrace_modify_all_code+0x120/0x1d0
        [<000000000047a7ec>] __ftrace_modify_code+0x5c/0x78
        [<000000000042395c>] multi_cpu_stop+0x224/0x3e0
        [<0000000000423212>] cpu_stopper_thread+0x33a/0x5a0
        [<0000000000243ff2>] smpboot_thread_fn+0x302/0x708
        [<00000000002329ea>] kthread+0x342/0x408
        [<00000000001066b2>] __ret_from_fork+0x92/0xf0
        [<0000000001fb57fa>] ret_from_fork+0xa/0x30
      
       The buggy address belongs to the page:
       page:(____ptrval____) refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1
       flags: 0x1ffff00000001000(reserved|node=0|zone=0|lastcpupid=0x1ffff)
       raw: 1ffff00000001000 0000040000000048 0000040000000048 0000000000000000
       raw: 0000000000000000 0000000000000000 ffffffff00000001 0000000000000000
       page dumped because: kasan: bad access detected
      
       Memory state around the buggy address:
        0000000000001d00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0000000000001d80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
       >0000000000001e00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
                             ^
        0000000000001e80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0000000000001f00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
       ==================================================================
      
      To fix that introduce ftrace_func callback to be called from
      ftrace_caller and update it in ftrace_update_ftrace_func().
      
      Fixes: 4cc9bed0
      
       ("[S390] cleanup ftrace backend functions")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fde6627c
    • Stephen Boyd's avatar
      mmc: core: Don't allocate IDA for OF aliases · 93af4d65
      Stephen Boyd authored
      commit 10252bae
      
       upstream.
      
      There's a chance that the IDA allocated in mmc_alloc_host() is not freed
      for some time because it's freed as part of a class' release function
      (see mmc_host_classdev_release() where the IDA is freed). If another
      thread is holding a reference to the class, then only once all balancing
      device_put() calls (in turn calling kobject_put()) have been made will
      the IDA be released and usable again.
      
      Normally this isn't a problem because the kobject is released before
      anything else that may want to use the same number tries to again, but
      with CONFIG_DEBUG_KOBJECT_RELEASE=y and OF aliases it becomes pretty
      easy to try to allocate an alias from the IDA twice while the first time
      it was allocated is still pending a call to ida_simple_remove(). It's
      also possible to trigger it by using CONFIG_DEBUG_KOBJECT_RELEASE and
      probe defering a driver at boot that calls mmc_alloc_host() before
      trying to get resources that may defer likes clks or regulators.
      
      Instead of allocating from the IDA in this scenario, let's just skip it
      if we know this is an OF alias. The number is already "claimed" and
      devices that aren't using OF aliases won't try to use the claimed
      numbers anyway (see mmc_first_nonreserved_index()). This should avoid
      any issues with mmc_alloc_host() returning failures from the
      ida_simple_get() in the case that we're using an OF alias.
      
      Cc: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
      Cc: Sujit Kautkar <sujitka@chromium.org>
      Reported-by: default avatarZubin Mithra <zsm@chromium.org>
      Fixes: fa2d0aa9
      
       ("mmc: core: Allow setting slot index via device tree alias")
      Signed-off-by: default avatarStephen Boyd <swboyd@chromium.org>
      Link: https://lore.kernel.org/r/20210623075002.1746924-3-swboyd@chromium.org
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93af4d65
    • Olivier Langlois's avatar
      io_uring: Fix race condition when sqp thread goes to sleep · 025b6262
      Olivier Langlois authored
      commit 99713501
      
       upstream.
      
      If an asynchronous completion happens before the task is preparing
      itself to wait and set its state to TASK_INTERRUPTIBLE, the completion
      will not wake up the sqp thread.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarOlivier Langlois <olivier@trillion01.com>
      Reviewed-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Link: https://lore.kernel.org/r/d1419dc32ec6a97b453bee34dc03fa6a02797142.1624473200.git.olivier@trillion01.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      025b6262
    • Linus Torvalds's avatar
      ACPI: fix NULL pointer dereference · ccf23a08
      Linus Torvalds authored
      commit fc68f42a upstream.
      
      Commit 71f64283
      
       ("ACPI: utils: Fix reference counting in
      for_each_acpi_dev_match()") started doing "acpi_dev_put()" on a pointer
      that was possibly NULL.  That fails miserably, because that helper
      inline function is not set up to handle that case.
      
      Just make acpi_dev_put() silently accept a NULL pointer, rather than
      calling down to put_device() with an invalid offset off that NULL
      pointer.
      
      Link: https://lore.kernel.org/lkml/a607c149-6bf6-0fd0-0e31-100378504da2@kernel.dk/
      Reported-and-tested-by: default avatarJens Axboe <axboe@kernel.dk>
      Tested-by: default avatarDaniel Scally <djrscally@gmail.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ccf23a08
    • Marcelo Henrique Cerri's avatar
      proc: Avoid mixing integer types in mem_rw() · 343b467a
      Marcelo Henrique Cerri authored
      [ Upstream commit d238692b
      
       ]
      
      Use size_t when capping the count argument received by mem_rw(). Since
      count is size_t, using min_t(int, ...) can lead to a negative value
      that will later be passed to access_remote_vm(), which can cause
      unexpected behavior.
      
      Since we are capping the value to at maximum PAGE_SIZE, the conversion
      from size_t to int when passing it to access_remote_vm() as "len"
      shouldn't be a problem.
      
      Link: https://lkml.kernel.org/r/20210512125215.3348316-1-marcelo.cerri@canonical.com
      Reviewed-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Signed-off-by: default avatarMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Souza Cascardo <cascardo@canonical.com>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: Michel Lespinasse <walken@google.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Lorenzo Stoakes <lstoakes@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      343b467a
    • Ronnie Sahlberg's avatar
      cifs: fix fallocate when trying to allocate a hole. · 11b40c8a
      Ronnie Sahlberg authored
      [ Upstream commit 488968a8 ]
      
      Remove the conditional checking for out_data_len and skipping the fallocate
      if it is 0. This is wrong will actually change any legitimate the fallocate
      where the entire region is unallocated into a no-op.
      
      Additionally, before allocating the range, if FALLOC_FL_KEEP_SIZE is set then
      we need to clamp the length of the fallocate region as to not extend the size of the file.
      
      Fixes: 966a3cb7
      
       ("cifs: improve fallocate emulation")
      Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      11b40c8a
    • Ronnie Sahlberg's avatar
      cifs: only write 64kb at a time when fallocating a small region of a file · a803678b
      Ronnie Sahlberg authored
      [ Upstream commit 2485bd75 ]
      
      We only allow sending single credit writes through the SMB2_write() synchronous
      api so split this into smaller chunks.
      
      Fixes: 966a3cb7
      
       ("cifs: improve fallocate emulation")
      
      Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Reported-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a803678b
    • Ioana Ciornei's avatar
      dpaa2-switch: seed the buffer pool after allocating the swp · ea826bd7
      Ioana Ciornei authored
      [ Upstream commit 7aaa0f31 ]
      
      Any interraction with the buffer pool (seeding a buffer, acquire one) is
      made through a software portal (SWP, a DPIO object).
      There are circumstances where the dpaa2-switch driver probes on a DPSW
      before any DPIO devices have been probed. In this case, seeding of the
      buffer pool will lead to a panic since no SWPs are initialized.
      
      To fix this, seed the buffer pool after making sure that the software
      portals have been probed and are ready to be used.
      
      Fixes: 0b1b7137
      
       ("staging: dpaa2-switch: handle Rx path on control interface")
      Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ea826bd7
    • Maxime Ripard's avatar
      drm/panel: raspberrypi-touchscreen: Prevent double-free · a0f2f2bf
      Maxime Ripard authored
      [ Upstream commit 7bbcb919 ]
      
      The mipi_dsi_device allocated by mipi_dsi_device_register_full() is
      already free'd on release.
      
      Fixes: 2f733d61
      
       ("drm/panel: Add support for the Raspberry Pi 7" Touchscreen.")
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210720134525.563936-9-maxime@cerno.tech
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0f2f2bf
    • Yajun Deng's avatar
      net: sched: cls_api: Fix the the wrong parameter · 6cd7bb12
      Yajun Deng authored
      [ Upstream commit 9d85a6f4 ]
      
      The 4th parameter in tc_chain_notify() should be flags rather than seq.
      Let's change it back correctly.
      
      Fixes: 32a4f5ec
      
       ("net: sched: introduce chain object to uapi")
      Signed-off-by: default avatarYajun Deng <yajun.deng@linux.dev>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6cd7bb12
    • Heinrich Schuchardt's avatar
      RISC-V: load initrd wherever it fits into memory · c95f925b
      Heinrich Schuchardt authored
      [ Upstream commit c79e89ec
      
       ]
      
      Requiring that initrd is loaded below RAM start + 256 MiB led to failure
      to boot SUSE Linux with GRUB on QEMU, cf.
      https://lists.gnu.org/archive/html/grub-devel/2021-06/msg00037.html
      
      Remove the constraint.
      
      Reported-by: default avatarAndreas Schwab <schwab@linux-m68k.org>
      Signed-off-by: default avatarHeinrich Schuchardt <xypron.glpk@gmx.de>
      Reviewed-by: default avatarAtish Patra <atish.patra@wdc.com>
      Acked-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Fixes: d7071743
      
       ("RISC-V: Add EFI stub support.")
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c95f925b
    • Vladimir Oltean's avatar
      net: dsa: sja1105: make VID 4095 a bridge VLAN too · 0bc32570
      Vladimir Oltean authored
      [ Upstream commit e40cba94 ]
      
      This simple series of commands:
      
      ip link add br0 type bridge vlan_filtering 1
      ip link set swp0 master br0
      
      fails on sja1105 with the following error:
      [   33.439103] sja1105 spi0.1: vlan-lookup-table needs to have at least the default untagged VLAN
      [   33.447710] sja1105 spi0.1: Invalid config, cannot upload
      Warning: sja1105: Failed to change VLAN Ethertype.
      
      For context, sja1105 has 3 operating modes:
      - SJA1105_VLAN_UNAWARE: the dsa_8021q_vlans are committed to hardware
      - SJA1105_VLAN_FILTERING_FULL: the bridge_vlans are committed to hardware
      - SJA1105_VLAN_FILTERING_BEST_EFFORT: both the dsa_8021q_vlans and the
        bridge_vlans are committed to hardware
      
      Swapping out a VLAN list and another in happens in
      sja1105_build_vlan_table(), which performs a delta update procedure.
      That function is called from a few places, notably from
      sja1105_vlan_filtering() which is called from the
      SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING handler.
      
      The above set of 2 commands fails when run on a kernel pre-commit
      8841f6e6 ("net: dsa: sja1105: make devlink property
      best_effort_vlan_filtering true by default"). So the priv->vlan_state
      transition that takes place is between VLAN-unaware and full VLAN
      filtering. So the dsa_8021q_vlans are swapped out and the bridge_vlans
      are swapped in.
      
      So why does it fail?
      
      Well, the bridge driver, through nbp_vlan_init(), first sets up the
      SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING attribute, and only then
      proceeds to call nbp_vlan_add for the default_pvid.
      
      So when we swap out the dsa_8021q_vlans and swap in the bridge_vlans in
      the SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING handler, there are no bridge
      VLANs (yet). So we have wiped the VLAN table clean, and the low-level
      static config checker complains of an invalid configuration. We _will_
      add the bridge VLANs using the dynamic config interface, albeit later,
      when nbp_vlan_add() calls us. So it is natural that it fails.
      
      So why did it ever work?
      
      Surprisingly, it looks like I only tested this configuration with 2
      things set up in a particular way:
      - a network manager that brings all ports up
      - a kernel with CONFIG_VLAN_8021Q=y
      
      It is widely known that commit ad1afb00 ("vlan_dev: VLAN 0 should be
      treated as "no vlan tag" (802.1p packet)") installs VID 0 to every net
      device that comes up. DSA treats these VLANs as bridge VLANs, and
      therefore, in my testing, the list of bridge_vlans was never empty.
      
      However, if CONFIG_VLAN_8021Q is not enabled, or the port is not up when
      it joins a VLAN-aware bridge, the bridge_vlans list will be temporarily
      empty, and the sja1105_static_config_reload() call from
      sja1105_vlan_filtering() will fail.
      
      To fix this, the simplest thing is to keep VID 4095, the one used for
      CPU-injected control packets since commit ed040abc ("net: dsa:
      sja1105: use 4095 as the private VLAN for untagged traffic"), in the
      list of bridge VLANs too, not just the list of tag_8021q VLANs. This
      ensures that the list of bridge VLANs will never be empty.
      
      Fixes: ec5ae610
      
       ("net: dsa: sja1105: save/restore VLANs using a delta commit method")
      Reported-by: default avatarRadu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0bc32570
    • Wei Wang's avatar
      tcp: disable TFO blackhole logic by default · ec7be4fd
      Wei Wang authored
      [ Upstream commit 213ad73d ]
      
      Multiple complaints have been raised from the TFO users on the internet
      stating that the TFO blackhole logic is too aggressive and gets falsely
      triggered too often.
      (e.g. https://blog.apnic.net/2021/07/05/tcp-fast-open-not-so-fast/)
      Considering that most middleboxes no longer drop TFO packets, we decide
      to disable the blackhole logic by setting
      /proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_set to 0 by default.
      
      Fixes: cf1ef3f0
      
       ("net/tcp_fastopen: Disable active side TFO in certain scenarios")
      Signed-off-by: default avatarWei Wang <weiwan@google.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarNeal Cardwell <ncardwell@google.com>
      Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ec7be4fd
    • Bin Meng's avatar
      riscv: Fix 32-bit RISC-V boot failure · ad9bfbe9
      Bin Meng authored
      [ Upstream commit d0e4dae7 ]
      
      Commit dd2d082b ("riscv: Cleanup setup_bootmem()") adjusted
      the calling sequence in setup_bootmem(), which invalidates the fix
      commit de043da0 ("RISC-V: Fix usage of memblock_enforce_memory_limit")
      did for 32-bit RISC-V unfortunately.
      
      So now 32-bit RISC-V does not boot again when testing booting kernel
      on QEMU 'virt' with '-m 2G', which was exactly what the original
      commit de043da0 ("RISC-V: Fix usage of memblock_enforce_memory_limit")
      tried to fix.
      
      Fixes: dd2d082b
      
       ("riscv: Cleanup setup_bootmem()")
      Signed-off-by: default avatarBin Meng <bmeng.cn@gmail.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad9bfbe9
    • Sukadev Bhattiprolu's avatar
      ibmvnic: Remove the proper scrq flush · fecd81c2
      Sukadev Bhattiprolu authored
      [ Upstream commit bb55362b ]
      
      Commit 65d6470d ("ibmvnic: clean pending indirect buffs during reset")
      intended to remove the call to ibmvnic_tx_scrq_flush() when the
      ->resetting flag is true and was tested that way. But during the final
      rebase to net-next, the hunk got applied to a block few lines below
      (which happened to have the same diff context) and the wrong call to
      ibmvnic_tx_scrq_flush() got removed.
      
      Fix that by removing the correct ibmvnic_tx_scrq_flush() and restoring
      the one that was incorrectly removed.
      
      Fixes: 65d6470d
      
       ("ibmvnic: clean pending indirect buffs during reset")
      Reported-by: default avatarDany Madden <drt@linux.ibm.com>
      Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fecd81c2
    • Vadim Fedorenko's avatar
      udp: check encap socket in __udp_lib_err · fee8c811
      Vadim Fedorenko authored
      [ Upstream commit 9bfce73c ]
      
      Commit d26796ae ("udp: check udp sock encap_type in __udp_lib_err")
      added checks for encapsulated sockets but it broke cases when there is
      no implementation of encap_err_lookup for encapsulation, i.e. ESP in
      UDP encapsulation. Fix it by calling encap_err_lookup only if socket
      implements this method otherwise treat it as legal socket.
      
      Fixes: d26796ae
      
       ("udp: check udp sock encap_type in __udp_lib_err")
      Signed-off-by: default avatarVadim Fedorenko <vfedorenko@novek.ru>
      Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fee8c811
    • Xin Long's avatar
      sctp: update active_key for asoc when old key is being replaced · c1de3764
      Xin Long authored
      [ Upstream commit 58acd100 ]
      
      syzbot reported a call trace:
      
        BUG: KASAN: use-after-free in sctp_auth_shkey_hold+0x22/0xa0 net/sctp/auth.c:112
        Call Trace:
         sctp_auth_shkey_hold+0x22/0xa0 net/sctp/auth.c:112
         sctp_set_owner_w net/sctp/socket.c:131 [inline]
         sctp_sendmsg_to_asoc+0x152e/0x2180 net/sctp/socket.c:1865
         sctp_sendmsg+0x103b/0x1d30 net/sctp/socket.c:2027
         inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:821
         sock_sendmsg_nosec net/socket.c:703 [inline]
         sock_sendmsg+0xcf/0x120 net/socket.c:723
      
      This is an use-after-free issue caused by not updating asoc->shkey after
      it was replaced in the key list asoc->endpoint_shared_keys, and the old
      key was freed.
      
      This patch is to fix by also updating active_key for asoc when old key is
      being replaced with a new one. Note that this issue doesn't exist in
      sctp_auth_del_key_id(), as it's not allowed to delete the active_key
      from the asoc.
      
      Fixes: 1b1e0bc9
      
       ("sctp: add refcnt support for sh_key")
      Reported-by: default avatar <syzbot+b774577370208727d12b@syzkaller.appspotmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c1de3764
    • Christoph Hellwig's avatar
      nvme: set the PRACT bit when using Write Zeroes with T10 PI · 65bd5af1
      Christoph Hellwig authored
      [ Upstream commit aaeb7bb0 ]
      
      When using Write Zeroes on a namespace that has protection
      information enabled they behavior without the PRACT bit
      counter-intuitive and will generally lead to validation failures
      when reading the written blocks.  Fix this by always setting the
      PRACT bit that generates matching PI data on the fly.
      
      Fixes: 6e02318e
      
       ("nvme: add support for the Write Zeroes command")
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      65bd5af1
    • Sayanta Pattanayak's avatar
      r8169: Avoid duplicate sysfs entry creation error · bc08be0e
      Sayanta Pattanayak authored
      [ Upstream commit e9a72f87 ]
      
      When registering the MDIO bus for a r8169 device, we use the PCI
      bus/device specifier as a (seemingly) unique device identifier.
      However the very same BDF number can be used on another PCI segment,
      which makes the driver fail probing:
      
      [ 27.544136] r8169 0002:07:00.0: enabling device (0000 -> 0003)
      [ 27.559734] sysfs: cannot create duplicate filename '/class/mdio_bus/r8169-700'
      ....
      [ 27.684858] libphy: mii_bus r8169-700 failed to register
      [ 27.695602] r8169: probe of 0002:07:00.0 failed with error -22
      
      Add the segment number to the device name to make it more unique.
      
      This fixes operation on ARM N1SDP boards, with two boards connected
      together to form an SMP system, and all on-board devices showing up
      twice, just on different PCI segments. A similar issue would occur on
      large systems with many PCI slots and multiple RTL8169 NICs.
      
      Fixes: f1e911d5
      
       ("r8169: add basic phylib support")
      Signed-off-by: default avatarSayanta Pattanayak <sayanta.pattanayak@arm.com>
      [Andre: expand commit message, use pci_domain_nr()]
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Acked-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bc08be0e
    • David Howells's avatar
      afs: Fix setting of writeback_index · 2131ea61
      David Howells authored
      [ Upstream commit 5a972474 ]
      
      Fix afs_writepages() to always set mapping->writeback_index to a page index
      and not a byte position[1].
      
      Fixes: 31143d5d
      
       ("AFS: implement basic file write support")
      Reported-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/CAB9dFdvHsLsw7CMnB+4cgciWDSqVjuij4mH3TaXnHQB8sz5rHw@mail.gmail.com/ [1]
      Link: https://lore.kernel.org/r/162610728339.3408253.4604750166391496546.stgit@warthog.procyon.org.uk/ # v2 (no v1)
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2131ea61
    • Tom Rix's avatar
      afs: check function return · 8dda575c
      Tom Rix authored
      [ Upstream commit afe69498 ]
      
      Static analysis reports this problem
      
      write.c:773:29: warning: Assigned value is garbage or undefined
        mapping->writeback_index = next;
                                 ^ ~~~~
      The call to afs_writepages_region() can return without setting
      next.  So check the function return before using next.
      
      Changes:
       ver #2:
         - Need to fix the range_cyclic case also[1].
      
      Fixes: e87b03f5
      
       ("afs: Prepare for use of THPs")
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/20210430155031.3287870-1-trix@redhat.com
      Link: https://lore.kernel.org/r/CAB9dFdvHsLsw7CMnB+4cgciWDSqVjuij4mH3TaXnHQB8sz5rHw@mail.gmail.com/ [1]
      Link: https://lore.kernel.org/r/162609464716.3133237.10354897554363093252.stgit@warthog.procyon.org.uk/ # v1
      Link: https://lore.kernel.org/r/162610727640.3408253.8687445613469681311.stgit@warthog.procyon.org.uk/ # v2
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8dda575c
    • David Howells's avatar
      afs: Fix tracepoint string placement with built-in AFS · 3d888aff
      David Howells authored
      [ Upstream commit 6c881ca0 ]
      
      To quote Alexey[1]:
      
          I was adding custom tracepoint to the kernel, grabbed full F34 kernel
          .config, disabled modules and booted whole shebang as VM kernel.
      
          Then did
      
      	perf record -a -e ...
      
          It crashed:
      
      	general protection fault, probably for non-canonical address 0x435f5346592e4243: 0000 [#1] SMP PTI
      	CPU: 1 PID: 842 Comm: cat Not tainted 5.12.6+ #26
      	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-1.fc33 04/01/2014
      	RIP: 0010:t_show+0x22/0xd0
      
          Then reproducer was narrowed to
      
      	# cat /sys/kernel/tracing/printk_formats
      
          Original F34 kernel with modules didn't crash.
      
          So I started to disable options and after disabling AFS everything
          started working again.
      
          The root cause is that AFS was placing char arrays content into a
          section full of _pointers_ to strings with predictable consequences.
      
          Non canonical address 435f5346592e4243 is "CB.YFS_" which came from
          CM_NAME macro.
      
          Steps to reproduce:
      
      	CONFIG_AFS=y
      	CONFIG_TRACING=y
      
      	# cat /sys/kernel/tracing/printk_formats
      
      Fix this by the following means:
      
       (1) Add enum->string translation tables in the event header with the AFS
           and YFS cache/callback manager operations listed by RPC operation ID.
      
       (2) Modify the afs_cb_call tracepoint to print the string from the
           translation table rather than using the string at the afs_call name
           pointer.
      
       (3) Switch translation table depending on the service we're being accessed
           as (AFS or YFS) in the tracepoint print clause.  Will this cause
           problems to userspace utilities?
      
           Note that the symbolic representation of the YFS service ID isn't
           available to this header, so I've put it in as a number.  I'm not sure
           if this is the best way to do this.
      
       (4) Remove the name wrangling (CM_NAME) macro and put the names directly
           into the afs_call_type structs in cmservice.c.
      
      Fixes: 8e8d7f13
      
       ("afs: Add some tracepoints")
      Reported-by: default avatarAlexey Dobriyan (SK hynix) <adobriyan@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      cc: Andrew Morton <akpm@linux-foundation.org>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/YLAXfvZ+rObEOdc%2F@localhost.localdomain/ [1]
      Link: https://lore.kernel.org/r/643721.1623754699@warthog.procyon.org.uk/
      Link: https://lore.kernel.org/r/162430903582.28961998
      
      .6098150063997983353.stgit@warthog.procyon.org.uk/ # v1
      Link: https://lore.kernel.org/r/162609463957.3133237.15916579353149746363.stgit@warthog.procyon.org.uk/ # v1 (repost)
      Link: https://lore.kernel.org/r/162610726860.3408253.445207609466288531.stgit@warthog.procyon.org.uk/ # v2
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d888aff
    • Vincent Palatin's avatar
      Revert "USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem" · 6bd6db23
      Vincent Palatin authored
      [ Upstream commit f3a1a937 ]
      
      This reverts commit 0bd86049
      
      .
      
      While the patch was working as stated,ie preventing the L850-GL LTE modem
      from crashing on some U3 wake-ups due to a race condition between the
      host wake-up and the modem-side wake-up, when using the MBIM interface,
      this would force disabling the USB runtime PM on the device.
      
      The increased power consumption is significant for LTE laptops,
      and given that with decently recent modem firmwares, when the modem hits
      the bug, it automatically recovers (ie it drops from the bus, but
      automatically re-enumerates after less than half a second, rather than being
      stuck until a power cycle as it was doing with ancient firmware), for
      most people, the trade-off now seems in favor of re-enabling it by
      default.
      
      For people with access to the platform code, the bug can also be worked-around
      successfully by changing the USB3 LFPM polling off-time for the XHCI
      controller in the BIOS code.
      
      Signed-off-by: default avatarVincent Palatin <vpalatin@chromium.org>
      Link: https://lore.kernel.org/r/20210721092516.2775971-1-vpalatin@chromium.org
      Fixes: 0bd86049
      
       ("USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem")
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6bd6db23
    • Zhihao Cheng's avatar
      nvme-pci: don't WARN_ON in nvme_reset_work if ctrl.state is not RESETTING · de3a8416
      Zhihao Cheng authored
      [ Upstream commit 7764656b ]
      
      Followling process:
      nvme_probe
        nvme_reset_ctrl
          nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING)
          queue_work(nvme_reset_wq, &ctrl->reset_work)
      
      -------------->	nvme_remove
      		  nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING)
      worker_thread
        process_one_work
          nvme_reset_work
          WARN_ON(dev->ctrl.state != NVME_CTRL_RESETTING)
      
      , which will trigger WARN_ON in nvme_reset_work():
      [  127.534298] WARNING: CPU: 0 PID: 139 at drivers/nvme/host/pci.c:2594
      [  127.536161] CPU: 0 PID: 139 Comm: kworker/u8:7 Not tainted 5.13.0
      [  127.552518] Call Trace:
      [  127.552840]  ? kvm_sched_clock_read+0x25/0x40
      [  127.553936]  ? native_send_call_func_single_ipi+0x1c/0x30
      [  127.555117]  ? send_call_function_single_ipi+0x9b/0x130
      [  127.556263]  ? __smp_call_single_queue+0x48/0x60
      [  127.557278]  ? ttwu_queue_wakelist+0xfa/0x1c0
      [  127.558231]  ? try_to_wake_up+0x265/0x9d0
      [  127.559120]  ? ext4_end_io_rsv_work+0x160/0x290
      [  127.560118]  process_one_work+0x28c/0x640
      [  127.561002]  worker_thread+0x39a/0x700
      [  127.561833]  ? rescuer_thread+0x580/0x580
      [  127.562714]  kthread+0x18c/0x1e0
      [  127.563444]  ? set_kthread_struct+0x70/0x70
      [  127.564347]  ret_from_fork+0x1f/0x30
      
      The preceding problem can be easily reproduced by executing following
      script (based on blktests suite):
      test() {
        pdev="$(_get_pci_dev_from_blkdev)"
        sysfs="/sys/bus/pci/devices/${pdev}"
        for ((i = 0; i < 10; i++)); do
          echo 1 > "$sysfs/remove"
          echo 1 > /sys/bus/pci/rescan
        done
      }
      
      Since the device ctrl could be updated as an non-RESETTING state by
      repeating probe/remove in userspace (which is a normal situation), we
      can replace stack dumping WARN_ON with a warnning message.
      
      Fixes: 82b057ca
      
       ("nvme-pci: fix multiple ctrl removal schedulin")
      Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      de3a8416
    • Faith Ekstrand's avatar
      drm/ttm: Force re-init if ttm_global_init() fails · a521c156
      Faith Ekstrand authored
      [ Upstream commit 235c3610
      
       ]
      
      If we have a failure, decrement the reference count so that the next
      call to ttm_global_init() will actually do something instead of assume
      everything is all set up.
      
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Fixes: 62b53b37
      
       ("drm/ttm: use a static ttm_bo_global instance")
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210720181357.2760720-5-jason@jlekstrand.net
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a521c156