Skip to content
  1. Jan 18, 2023
    • Ammar Faizi's avatar
      tools/nolibc: x86-64: Use `mov $60,%eax` instead of `mov $60,%rax` · 487386a4
      Ammar Faizi authored
      [ Upstream commit 7bdc0e7a
      
       ]
      
      Note that mov to 32-bit register will zero extend to 64-bit register.
      Thus `mov $60,%eax` has the same effect with `mov $60,%rax`. Use the
      shorter opcode to achieve the same thing.
      ```
        b8 3c 00 00 00       	mov    $60,%eax (5 bytes) [1]
        48 c7 c0 3c 00 00 00 	mov    $60,%rax (7 bytes) [2]
      ```
      Currently, we use [2]. Change it to [1] for shorter code.
      
      Signed-off-by: default avatarAmmar Faizi <ammar.faizi@students.amikom.ac.id>
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Stable-dep-of: 184177c3
      
       ("tools/nolibc: restore mips branch ordering in the _start block")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      487386a4
    • Ammar Faizi's avatar
      tools/nolibc: x86: Remove `r8`, `r9` and `r10` from the clobber list · 27af4f22
      Ammar Faizi authored
      [ Upstream commit bf916669
      
       ]
      
      Linux x86-64 syscall only clobbers rax, rcx and r11 (and "memory").
      
        - rax for the return value.
        - rcx to save the return address.
        - r11 to save the rflags.
      
      Other registers are preserved.
      
      Having r8, r9 and r10 in the syscall clobber list is harmless, but this
      results in a missed-optimization.
      
      As the syscall doesn't clobber r8-r10, GCC should be allowed to reuse
      their value after the syscall returns to userspace. But since they are
      in the clobber list, GCC will always miss this opportunity.
      
      Remove them from the x86-64 syscall clobber list to help GCC generate
      better code and fix the comment.
      
      See also the x86-64 ABI, section A.2 AMD64 Linux Kernel Conventions,
      A.2.1 Calling Conventions [1].
      
      Extra note:
      Some people may think it does not really give a benefit to remove r8,
      r9 and r10 from the syscall clobber list because the impression of
      syscall is a C function call, and function call always clobbers those 3.
      
      However, that is not the case for nolibc.h, because we have a potential
      to inline the "syscall" instruction (which its opcode is "0f 05") to the
      user functions.
      
      All syscalls in the nolibc.h are written as a static function with inline
      ASM and are likely always inline if we use optimization flag, so this is
      a profit not to have r8, r9 and r10 in the clobber list.
      
      Here is the example where this matters.
      
      Consider the following C code:
      ```
        #include "tools/include/nolibc/nolibc.h"
        #define read_abc(a, b, c) __asm__ volatile("nop"::"r"(a),"r"(b),"r"(c))
      
        int main(void)
        {
        	int a = 0xaa;
        	int b = 0xbb;
        	int c = 0xcc;
      
        	read_abc(a, b, c);
        	write(1, "test\n", 5);
        	read_abc(a, b, c);
      
        	return 0;
        }
      ```
      
      Compile with:
          gcc -Os test.c -o test -nostdlib
      
      With r8, r9, r10 in the clobber list, GCC generates this:
      
      0000000000001000 <main>:
          1000:	f3 0f 1e fa          	endbr64
          1004:	41 54                	push   %r12
          1006:	41 bc cc 00 00 00    	mov    $0xcc,%r12d
          100c:	55                   	push   %rbp
          100d:	bd bb 00 00 00       	mov    $0xbb,%ebp
          1012:	53                   	push   %rbx
          1013:	bb aa 00 00 00       	mov    $0xaa,%ebx
          1018:	90                   	nop
          1019:	b8 01 00 00 00       	mov    $0x1,%eax
          101e:	bf 01 00 00 00       	mov    $0x1,%edi
          1023:	ba 05 00 00 00       	mov    $0x5,%edx
          1028:	48 8d 35 d1 0f 00 00 	lea    0xfd1(%rip),%rsi
          102f:	0f 05                	syscall
          1031:	90                   	nop
          1032:	31 c0                	xor    %eax,%eax
          1034:	5b                   	pop    %rbx
          1035:	5d                   	pop    %rbp
          1036:	41 5c                	pop    %r12
          1038:	c3                   	ret
      
      GCC thinks that syscall will clobber r8, r9, r10. So it spills 0xaa,
      0xbb and 0xcc to callee saved registers (r12, rbp and rbx). This is
      clearly extra memory access and extra stack size for preserving them.
      
      But syscall does not actually clobber them, so this is a missed
      optimization.
      
      Now without r8, r9, r10 in the clobber list, GCC generates better code:
      
      0000000000001000 <main>:
          1000:	f3 0f 1e fa          	endbr64
          1004:	41 b8 aa 00 00 00    	mov    $0xaa,%r8d
          100a:	41 b9 bb 00 00 00    	mov    $0xbb,%r9d
          1010:	41 ba cc 00 00 00    	mov    $0xcc,%r10d
          1016:	90                   	nop
          1017:	b8 01 00 00 00       	mov    $0x1,%eax
          101c:	bf 01 00 00 00       	mov    $0x1,%edi
          1021:	ba 05 00 00 00       	mov    $0x5,%edx
          1026:	48 8d 35 d3 0f 00 00 	lea    0xfd3(%rip),%rsi
          102d:	0f 05                	syscall
          102f:	90                   	nop
          1030:	31 c0                	xor    %eax,%eax
          1032:	c3                   	ret
      
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: x86@kernel.org
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
      Signed-off-by: default avatarAmmar Faizi <ammar.faizi@students.amikom.ac.id>
      Link: https://gitlab.com/x86-psABIs/x86-64-ABI/-/wikis/x86-64-psABI [1]
      Link: https://lore.kernel.org/lkml/20211011040344.437264-1-ammar.faizi@students.amikom.ac.id/
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Stable-dep-of: 184177c3
      
       ("tools/nolibc: restore mips branch ordering in the _start block")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27af4f22
    • Mirsad Goran Todorovac's avatar
      af_unix: selftest: Fix the size of the parameter to connect() · a60b2419
      Mirsad Goran Todorovac authored
      [ Upstream commit 7d6ceeb1
      
       ]
      
      Adjust size parameter in connect() to match the type of the parameter, to
      fix "No such file or directory" error in selftests/net/af_unix/
      test_oob_unix.c:127.
      
      The existing code happens to work provided that the autogenerated pathname
      is shorter than sizeof (struct sockaddr), which is why it hasn't been
      noticed earlier.
      
      Visible from the trace excerpt:
      
      bind(3, {sa_family=AF_UNIX, sun_path="unix_oob_453059"}, 110) = 0
      clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa6a6577a10) = 453060
      [pid <child>] connect(6, {sa_family=AF_UNIX, sun_path="unix_oob_45305"}, 16) = -1 ENOENT (No such file or directory)
      
      BUG: The filename is trimmed to sizeof (struct sockaddr).
      
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
      Cc: Florian Westphal <fw@strlen.de>
      Reviewed-by: default avatarFlorian Westphal <fw@strlen.de>
      Fixes: 314001f0
      
       ("af_unix: Add OOB support")
      Signed-off-by: default avatarMirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a60b2419
    • Minsuk Kang's avatar
      nfc: pn533: Wait for out_urb's completion in pn533_usb_send_frame() · 39ae73e5
      Minsuk Kang authored
      [ Upstream commit 9dab880d ]
      
      Fix a use-after-free that occurs in hcd when in_urb sent from
      pn533_usb_send_frame() is completed earlier than out_urb. Its callback
      frees the skb data in pn533_send_async_complete() that is used as a
      transfer buffer of out_urb. Wait before sending in_urb until the
      callback of out_urb is called. To modify the callback of out_urb alone,
      separate the complete function of out_urb and ack_urb.
      
      Found by a modified version of syzkaller.
      
      BUG: KASAN: use-after-free in dummy_timer
      Call Trace:
       memcpy (mm/kasan/shadow.c:65)
       dummy_perform_transfer (drivers/usb/gadget/udc/dummy_hcd.c:1352)
       transfer (drivers/usb/gadget/udc/dummy_hcd.c:1453)
       dummy_timer (drivers/usb/gadget/udc/dummy_hcd.c:1972)
       arch_static_branch (arch/x86/include/asm/jump_label.h:27)
       static_key_false (include/linux/jump_label.h:207)
       timer_expire_exit (include/trace/events/timer.h:127)
       call_timer_fn (kernel/time/timer.c:1475)
       expire_timers (kernel/time/timer.c:1519)
       __run_timers (kernel/time/timer.c:1790)
       run_timer_softirq (kernel/time/timer.c:1803)
      
      Fixes: c46ee386
      
       ("NFC: pn533: add NXP pn533 nfc device driver")
      Signed-off-by: default avatarMinsuk Kang <linuxlovemin@yonsei.ac.kr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      39ae73e5
    • Roger Pau Monne's avatar
      hvc/xen: lock console list traversal · f6003784
      Roger Pau Monne authored
      [ Upstream commit c0dccad8 ]
      
      The currently lockless access to the xen console list in
      vtermno_to_xencons() is incorrect, as additions and removals from the
      list can happen anytime, and as such the traversal of the list to get
      the private console data for a given termno needs to happen with the
      lock held.  Note users that modify the list already do so with the
      lock taken.
      
      Adjust current lock takers to use the _irq{save,restore} helpers,
      since the context in which vtermno_to_xencons() is called can have
      interrupts disabled.  Use the _irq{save,restore} set of helpers to
      switch the current callers to disable interrupts in the locked region.
      I haven't checked if existing users could instead use the _irq
      variant, as I think it's safer to use _irq{save,restore} upfront.
      
      While there switch from using list_for_each_entry_safe to
      list_for_each_entry: the current entry cursor won't be removed as
      part of the code in the loop body, so using the _safe variant is
      pointless.
      
      Fixes: 02e19f9c
      
       ('hvc_xen: implement multiconsole support')
      Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
      Link: https://lore.kernel.org/r/20221130163611.14686-1-roger.pau@citrix.com
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f6003784
    • Angela Czubak's avatar
      octeontx2-af: Fix LMAC config in cgx_lmac_rx_tx_enable · 79c58b74
      Angela Czubak authored
      [ Upstream commit b4e9b876 ]
      
      PF netdev can request AF to enable or disable reception and transmission
      on assigned CGX::LMAC. The current code instead of disabling or enabling
      'reception and transmission' also disables/enable the LMAC. This patch
      fixes this issue.
      
      Fixes: 1435f66a
      
       ("octeontx2-af: CGX Rx/Tx enable/disable mbox handlers")
      Signed-off-by: default avatarAngela Czubak <aczubak@marvell.com>
      Signed-off-by: default avatarHariprasad Kelam <hkelam@marvell.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Link: https://lore.kernel.org/r/20230105160107.17638-1-hkelam@marvell.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      79c58b74
    • Tung Nguyen's avatar
      tipc: fix unexpected link reset due to discovery messages · 303d0628
      Tung Nguyen authored
      [ Upstream commit c244c092 ]
      
      This unexpected behavior is observed:
      
      node 1                    | node 2
      ------                    | ------
      link is established       | link is established
      reboot                    | link is reset
      up                        | send discovery message
      receive discovery message |
      link is established       | link is established
      send discovery message    |
                                | receive discovery message
                                | link is reset (unexpected)
                                | send reset message
      link is reset             |
      
      It is due to delayed re-discovery as described in function
      tipc_node_check_dest(): "this link endpoint has already reset
      and re-established contact with the peer, before receiving a
      discovery message from that node."
      
      However, commit 598411d7 has changed the condition for calling
      tipc_node_link_down() which was the acceptance of new media address.
      
      This commit fixes this by restoring the old and correct behavior.
      
      Fixes: 598411d7
      
       ("tipc: make resetting of links non-atomic")
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarTung Nguyen <tung.q.nguyen@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      303d0628
    • Takashi Iwai's avatar
      ALSA: usb-audio: Relax hw constraints for implicit fb sync · e79d0f97
      Takashi Iwai authored
      [ Upstream commit d463ac1a ]
      
      The fix commit the commit e4ea77f8 ("ALSA: usb-audio: Always apply
      the hw constraints for implicit fb sync") tried to address the bug
      where an incorrect PCM parameter is chosen when two (implicit fb)
      streams are set up at the same time.  This change had, however, some
      side effect: once when the sync endpoint is chosen and set up, this
      restriction is applied at the next hw params unless it's freed via hw
      free explicitly.
      
      This patch is a workaround for the problem by relaxing the hw
      constraints a bit for the implicit fb sync.  We still keep applying
      the hw constraints for implicit fb sync, but only when the matching
      sync EP is being used by other streams.
      
      Fixes: e4ea77f8
      
       ("ALSA: usb-audio: Always apply the hw constraints for implicit fb sync")
      Reported-by: default avatarRuud van Asseldonk <ruud@veniogames.com>
      Link: https://lore.kernel.org/r/4e509aea-e563-e592-e652-ba44af6733fe@veniogames.com
      Link: https://lore.kernel.org/r/20230102170759.29610-3-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e79d0f97
    • Takashi Iwai's avatar
      ALSA: usb-audio: Make sure to stop endpoints before closing EPs · c9557906
      Takashi Iwai authored
      [ Upstream commit 0599313e ]
      
      At the PCM hw params, we may re-configure the endpoints and it's done
      by a temporary EP close followed by re-open.  A potential problem
      there is that the EP might be already running internally at the PCM
      prepare stage; it's seen typically in the playback stream with the
      implicit feedback sync.  As this stream start isn't tracked by the
      core PCM layer, we'd need to stop it explicitly, and that's the
      missing piece.
      
      This patch adds the stop_endpoints() call at snd_usb_hw_params() to
      assure the stream stop before closing the EPs.
      
      Fixes: bf6313a0
      
       ("ALSA: usb-audio: Refactor endpoint management")
      Link: https://lore.kernel.org/r/4e509aea-e563-e592-e652-ba44af6733fe@veniogames.com
      Link: https://lore.kernel.org/r/20230102170759.29610-2-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c9557906
    • Emanuele Ghidoli's avatar
      ASoC: wm8904: fix wrong outputs volume after power reactivation · 83e75810
      Emanuele Ghidoli authored
      [ Upstream commit 472a6309 ]
      
      Restore volume after charge pump and PGA activation to ensure
      that volume settings are correctly applied when re-enabling codec
      from SND_SOC_BIAS_OFF state.
      CLASS_W, CHARGE_PUMP and POWER_MANAGEMENT_2 register configuration
      affect how the volume register are applied and must be configured first.
      
      Fixes: a91eb199
      
       ("ASoC: Initial WM8904 CODEC driver")
      Link: https://lore.kernel.org/all/c7864c35-738c-a867-a6a6-ddf9f98df7e7@gmail.com/
      Signed-off-by: default avatarEmanuele Ghidoli <emanuele.ghidoli@toradex.com>
      Signed-off-by: default avatarFrancesco Dolcini <francesco.dolcini@toradex.com>
      Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20221223080247.7258-1-francesco@dolcini.it
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      83e75810
    • Peter Wang's avatar
      scsi: ufs: core: WLUN suspend SSU/enter hibern8 fail recovery · 7c26d218
      Peter Wang authored
      [ Upstream commit 1a5665fc ]
      
      When SSU/enter hibern8 fail in WLUN suspend flow, trigger the error handler
      and return busy to break the suspend.  Otherwise the consumer will get
      stuck in runtime suspend status.
      
      Fixes: b294ff3e
      
       ("scsi: ufs: core: Enable power management for wlun")
      Signed-off-by: default avatarPeter Wang <peter.wang@mediatek.com>
      Link: https://lore.kernel.org/r/20221208072520.26210-1-peter.wang@mediatek.com
      Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7c26d218
    • Bart Van Assche's avatar
      scsi: ufs: Stop using the clock scaling lock in the error handler · 513fdf0b
      Bart Van Assche authored
      [ Upstream commit 5675c381
      
       ]
      
      Instead of locking and unlocking the clock scaling lock, surround the
      command queueing code with an RCU reader lock and call synchronize_rcu().
      This patch prepares for removal of the clock scaling lock.
      
      Link: https://lore.kernel.org/r/20211203231950.193369-16-bvanassche@acm.org
      Tested-by: default avatarBean Huo <beanhuo@micron.com>
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Stable-dep-of: 1a5665fc
      
       ("scsi: ufs: core: WLUN suspend SSU/enter hibern8 fail recovery")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      513fdf0b
    • Shin'ichiro Kawasaki's avatar
      scsi: mpi3mr: Refer CONFIG_SCSI_MPI3MR in Makefile · 13259b60
      Shin'ichiro Kawasaki authored
      [ Upstream commit f0a43ba6 ]
      
      When Kconfig item CONFIG_SCSI_MPI3MR was introduced for mpi3mr driver, the
      Makefile of the driver was not modified to refer the Kconfig item.
      
      As a result, mpi3mr.ko is built regardless of the Kconfig item value y or
      m. Also, if 'make localmodconfig' can not find the Kconfig item in the
      Makefile, then it does not generate CONFIG_SCSI_MPI3MR=m even when
      mpi3mr.ko is loaded on the system.
      
      Refer to the Kconfig item to avoid the issues.
      
      Fixes: c4f7ac64
      
       ("scsi: mpi3mr: Add mpi30 Rev-R headers and Kconfig")
      Signed-off-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Link: https://lore.kernel.org/r/20221207023659.2411785-1-shinichiro.kawasaki@wdc.com
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Acked-by: default avatarSathya Prakash Veerichetty <sathya.prakash@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      13259b60
    • Ricardo Ribalda's avatar
      regulator: da9211: Use irq handler when ready · 470f6a91
      Ricardo Ribalda authored
      [ Upstream commit 02228f6a
      
       ]
      
      If the system does not come from reset (like when it is kexec()), the
      regulator might have an IRQ waiting for us.
      
      If we enable the IRQ handler before its structures are ready, we crash.
      
      This patch fixes:
      
      [    1.141839] Unable to handle kernel read from unreadable memory at virtual address 0000000000000078
      [    1.316096] Call trace:
      [    1.316101]  blocking_notifier_call_chain+0x20/0xa8
      [    1.322757] cpu cpu0: dummy supplies not allowed for exclusive requests
      [    1.327823]  regulator_notifier_call_chain+0x1c/0x2c
      [    1.327825]  da9211_irq_handler+0x68/0xf8
      [    1.327829]  irq_thread+0x11c/0x234
      [    1.327833]  kthread+0x13c/0x154
      
      Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
      Reviewed-by: default avatarAdam Ward <DLG-Adam.Ward.opensource@dm.renesas.com>
      Link: https://lore.kernel.org/r/20221124-da9211-v2-0-1779e3c5d491@chromium.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      470f6a91
    • Peter Newman's avatar
      x86/resctrl: Fix task CLOSID/RMID update race · 24107ad4
      Peter Newman authored
      commit fe1f0714 upstream.
      
      When the user moves a running task to a new rdtgroup using the task's
      file interface or by deleting its rdtgroup, the resulting change in
      CLOSID/RMID must be immediately propagated to the PQR_ASSOC MSR on the
      task(s) CPUs.
      
      x86 allows reordering loads with prior stores, so if the task starts
      running between a task_curr() check that the CPU hoisted before the
      stores in the CLOSID/RMID update then it can start running with the old
      CLOSID/RMID until it is switched again because __rdtgroup_move_task()
      failed to determine that it needs to be interrupted to obtain the new
      CLOSID/RMID.
      
      Refer to the diagram below:
      
      CPU 0                                   CPU 1
      -----                                   -----
      __rdtgroup_move_task():
        curr <- t1->cpu->rq->curr
                                              __schedule():
                                                rq->curr <- t1
                                              resctrl_sched_in():
                                                t1->{closid,rmid} -> {1,1}
        t1->{closid,rmid} <- {2,2}
        if (curr == t1) // false
         IPI(t1->cpu)
      
      A similar race impacts rdt_move_group_tasks(), which updates tasks in a
      deleted rdtgroup.
      
      In both cases, use smp_mb() to order the task_struct::{closid,rmid}
      stores before the loads in task_curr().  In particular, in the
      rdt_move_group_tasks() case, simply execute an smp_mb() on every
      iteration with a matching task.
      
      It is possible to use a single smp_mb() in rdt_move_group_tasks(), but
      this would require two passes and a means of remembering which
      task_structs were updated in the first loop. However, benchmarking
      results below showed too little performance impact in the simple
      approach to justify implementing the two-pass approach.
      
      Times below were collected using `perf stat` to measure the time to
      remove a group containing a 1600-task, parallel workload.
      
      CPU: Intel(R) Xeon(R) Platinum P-8136 CPU @ 2.00GHz (112 threads)
      
        # mkdir /sys/fs/resctrl/test
        # echo $$ > /sys/fs/resctrl/test/tasks
        # perf bench sched messaging -g 40 -l 100000
      
      task-clock time ranges collected using:
      
        # perf stat rmdir /sys/fs/resctrl/test
      
      Baseline:                     1.54 - 1.60 ms
      smp_mb() every matching task: 1.57 - 1.67 ms
      
        [ bp: Massage commit message. ]
      
      Fixes: ae28d1aa ("x86/resctrl: Use an IPI instead of task_work_add() to update PQR_ASSOC MSR")
      Fixes: 0efc89be
      
       ("x86/intel_rdt: Update task closid immediately on CPU in rmdir and unmount")
      Signed-off-by: default avatarPeter Newman <peternewman@google.com>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
      Reviewed-by: default avatarBabu Moger <babu.moger@amd.com>
      Cc: <stable@kernel.org>
      Link: https://lore.kernel.org/r/20221220161123.432120-1-peternewman@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24107ad4
    • Eliav Farber's avatar
      EDAC/device: Fix period calculation in edac_device_reset_delay_period() · cd3da505
      Eliav Farber authored
      commit e8407743 upstream.
      
      Fix period calculation in case user sets a value of 1000.  The input of
      round_jiffies_relative() should be in jiffies and not in milli-seconds.
      
        [ bp: Use the same code pattern as in edac_device_workq_setup() for
          clarity. ]
      
      Fixes: c4cf3b45
      
       ("EDAC: Rework workqueue handling")
      Signed-off-by: default avatarEliav Farber <farbere@amazon.com>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Cc: <stable@kernel.org>
      Link: https://lore.kernel.org/r/20221020124458.22153-1-farbere@amazon.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd3da505
    • Peter Zijlstra's avatar
      x86/boot: Avoid using Intel mnemonics in AT&T syntax asm · ab0d02c5
      Peter Zijlstra authored
      commit 7c6dd961 upstream.
      
      With 'GNU assembler (GNU Binutils for Debian) 2.39.90.20221231' the
      build now reports:
      
        arch/x86/realmode/rm/../../boot/bioscall.S: Assembler messages:
        arch/x86/realmode/rm/../../boot/bioscall.S:35: Warning: found `movsd'; assuming `movsl' was meant
        arch/x86/realmode/rm/../../boot/bioscall.S:70: Warning: found `movsd'; assuming `movsl' was meant
      
        arch/x86/boot/bioscall.S: Assembler messages:
        arch/x86/boot/bioscall.S:35: Warning: found `movsd'; assuming `movsl' was meant
        arch/x86/boot/bioscall.S:70: Warning: found `movsd'; assuming `movsl' was meant
      
      Which is due to:
      
        PR gas/29525
      
        Note that with the dropped CMPSD and MOVSD Intel Syntax string insn
        templates taking operands, mixed IsString/non-IsString template groups
        (with memory operands) cannot occur anymore. With that
        maybe_adjust_templates() becomes unnecessary (and is hence being
        removed).
      
      More details: https://sourceware.org/bugzilla/show_bug.cgi?id=29525
      
      Borislav Petkov further explains:
      
        " the particular problem here is is that the 'd' suffix is
          "conflicting" in the sense that you can have SSE mnemonics like movsD %xmm...
          and the same thing also for string ops (which is the case here) so apparently
          the agreement in binutils land is to use the always accepted suffixes 'l' or 'q'
          and phase out 'd' slowly... "
      
      Fixes: 7a734e7d
      
       ("x86, setup: "glove box" BIOS calls -- infrastructure")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Link: https://lore.kernel.org/r/Y71I3Ex2pvIxMpsP@hirez.programming.kicks-ass.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab0d02c5
    • Kajol Jain's avatar
      powerpc/imc-pmu: Fix use of mutex in IRQs disabled section · a90d339f
      Kajol Jain authored
      commit 76d588dd upstream.
      
      Current imc-pmu code triggers a WARNING with CONFIG_DEBUG_ATOMIC_SLEEP
      and CONFIG_PROVE_LOCKING enabled, while running a thread_imc event.
      
      Command to trigger the warning:
        # perf stat -e thread_imc/CPM_CS_FROM_L4_MEM_X_DPTEG/ sleep 5
      
         Performance counter stats for 'sleep 5':
      
                         0      thread_imc/CPM_CS_FROM_L4_MEM_X_DPTEG/
      
               5.002117947 seconds time elapsed
      
               0.000131000 seconds user
               0.001063000 seconds sys
      
      Below is snippet of the warning in dmesg:
      
        BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
        in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 2869, name: perf-exec
        preempt_count: 2, expected: 0
        4 locks held by perf-exec/2869:
         #0: c00000004325c540 (&sig->cred_guard_mutex){+.+.}-{3:3}, at: bprm_execve+0x64/0xa90
         #1: c00000004325c5d8 (&sig->exec_update_lock){++++}-{3:3}, at: begin_new_exec+0x460/0xef0
         #2: c0000003fa99d4e0 (&cpuctx_lock){-...}-{2:2}, at: perf_event_exec+0x290/0x510
         #3: c000000017ab8418 (&ctx->lock){....}-{2:2}, at: perf_event_exec+0x29c/0x510
        irq event stamp: 4806
        hardirqs last  enabled at (4805): [<c000000000f65b94>] _raw_spin_unlock_irqrestore+0x94/0xd0
        hardirqs last disabled at (4806): [<c0000000003fae44>] perf_event_exec+0x394/0x510
        softirqs last  enabled at (0): [<c00000000013c404>] copy_process+0xc34/0x1ff0
        softirqs last disabled at (0): [<0000000000000000>] 0x0
        CPU: 36 PID: 2869 Comm: perf-exec Not tainted 6.2.0-rc2-00011-g1247637727f2 #61
        Hardware name: 8375-42A POWER9 0x4e1202 opal:v7.0-16-g9b85f7d961 PowerNV
        Call Trace:
          dump_stack_lvl+0x98/0xe0 (unreliable)
          __might_resched+0x2f8/0x310
          __mutex_lock+0x6c/0x13f0
          thread_imc_event_add+0xf4/0x1b0
          event_sched_in+0xe0/0x210
          merge_sched_in+0x1f0/0x600
          visit_groups_merge.isra.92.constprop.166+0x2bc/0x6c0
          ctx_flexible_sched_in+0xcc/0x140
          ctx_sched_in+0x20c/0x2a0
          ctx_resched+0x104/0x1c0
          perf_event_exec+0x340/0x510
          begin_new_exec+0x730/0xef0
          load_elf_binary+0x3f8/0x1e10
        ...
        do not call blocking ops when !TASK_RUNNING; state=2001 set at [<00000000fd63e7cf>] do_nanosleep+0x60/0x1a0
        WARNING: CPU: 36 PID: 2869 at kernel/sched/core.c:9912 __might_sleep+0x9c/0xb0
        CPU: 36 PID: 2869 Comm: sleep Tainted: G        W          6.2.0-rc2-00011-g1247637727f2 #61
        Hardware name: 8375-42A POWER9 0x4e1202 opal:v7.0-16-g9b85f7d961 PowerNV
        NIP:  c000000000194a1c LR: c000000000194a18 CTR: c000000000a78670
        REGS: c00000004d2134e0 TRAP: 0700   Tainted: G        W           (6.2.0-rc2-00011-g1247637727f2)
        MSR:  9000000000021033 <SF,HV,ME,IR,DR,RI,LE>  CR: 48002824  XER: 00000000
        CFAR: c00000000013fb64 IRQMASK: 1
      
      The above warning triggered because the current imc-pmu code uses mutex
      lock in interrupt disabled sections. The function mutex_lock()
      internally calls __might_resched(), which will check if IRQs are
      disabled and in case IRQs are disabled, it will trigger the warning.
      
      Fix the issue by changing the mutex lock to spinlock.
      
      Fixes: 8f95faaa
      
       ("powerpc/powernv: Detect and create IMC device")
      Reported-by: default avatarMichael Petlan <mpetlan@redhat.com>
      Reported-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      [mpe: Fix comments, trim oops in change log, add reported-by tags]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20230106065157.182648-1-kjain@linux.ibm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a90d339f
    • Gavrilov Ilia's avatar
      netfilter: ipset: Fix overflow before widen in the bitmap_ip_create() function. · 511cf17b
      Gavrilov Ilia authored
      commit 9ea4b476 upstream.
      
      When first_ip is 0, last_ip is 0xFFFFFFFF, and netmask is 31, the value of
      an arithmetic expression 2 << (netmask - mask_bits - 1) is subject
      to overflow due to a failure casting operands to a larger data type
      before performing the arithmetic.
      
      Note that it's harmless since the value will be checked at the next step.
      
      Found by InfoTeCS on behalf of Linux Verification Center
      (linuxtesting.org) with SVACE.
      
      Fixes: b9fed748
      
       ("netfilter: ipset: Check and reject crazy /0 input parameters")
      Signed-off-by: default avatarIlia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      511cf17b
    • Waiman Long's avatar
      sched/core: Fix use-after-free bug in dup_user_cpus_ptr() · b22faa21
      Waiman Long authored
      commit 87ca4f9e upstream.
      
      Since commit 07ec77a1 ("sched: Allow task CPU affinity to be
      restricted on asymmetric systems"), the setting and clearing of
      user_cpus_ptr are done under pi_lock for arm64 architecture. However,
      dup_user_cpus_ptr() accesses user_cpus_ptr without any lock
      protection. Since sched_setaffinity() can be invoked from another
      process, the process being modified may be undergoing fork() at
      the same time.  When racing with the clearing of user_cpus_ptr in
      __set_cpus_allowed_ptr_locked(), it can lead to user-after-free and
      possibly double-free in arm64 kernel.
      
      Commit 8f9ea86f ("sched: Always preserve the user requested
      cpumask") fixes this problem as user_cpus_ptr, once set, will never
      be cleared in a task's lifetime. However, this bug was re-introduced
      in commit 851a723e ("sched: Always clear user_cpus_ptr in
      do_set_cpus_allowed()") which allows the clearing of user_cpus_ptr in
      do_set_cpus_allowed(). This time, it will affect all arches.
      
      Fix this bug by always clearing the user_cpus_ptr of the newly
      cloned/forked task before the copying process starts and check the
      user_cpus_ptr state of the source task under pi_lock.
      
      Note to stable, this patch won't be applicable to stable releases.
      Just copy the new dup_user_cpus_ptr() function over.
      
      Fixes: 07ec77a1 ("sched: Allow task CPU affinity to be restricted on asymmetric systems")
      Fixes: 851a723e
      
       ("sched: Always clear user_cpus_ptr in do_set_cpus_allowed()")
      Reported-by: default avatarDavid Wang 王标 <wangbiao3@xiaomi.com>
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221231041120.440785-2-longman@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b22faa21
    • Christophe JAILLET's avatar
      iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe() · d766ccad
      Christophe JAILLET authored
      commit 142e821f upstream.
      
      A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not released in
      the error handling path of mtk_iommu_v1_probe().
      
      Add the corresponding clk_disable_unprepare(), as already done in the
      remove function.
      
      Fixes: b17336c5
      
       ("iommu/mediatek: add support for mtk iommu generation one HW")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarYong Wu <yong.wu@mediatek.com>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Reviewed-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
      Link: https://lore.kernel.org/r/593e7b7d97c6e064b29716b091a9d4fd122241fb.1671473163.git.christophe.jaillet@wanadoo.fr
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d766ccad
    • Yunfei Wang's avatar
      iommu/iova: Fix alloc iova overflows issue · c929a230
      Yunfei Wang authored
      commit dcdb3ba7
      
       upstream.
      
      In __alloc_and_insert_iova_range, there is an issue that retry_pfn
      overflows. The value of iovad->anchor.pfn_hi is ~0UL, then when
      iovad->cached_node is iovad->anchor, curr_iova->pfn_hi + 1 will
      overflow. As a result, if the retry logic is executed, low_pfn is
      updated to 0, and then new_pfn < low_pfn returns false to make the
      allocation successful.
      
      This issue occurs in the following two situations:
      1. The first iova size exceeds the domain size. When initializing
      iova domain, iovad->cached_node is assigned as iovad->anchor. For
      example, the iova domain size is 10M, start_pfn is 0x1_F000_0000,
      and the iova size allocated for the first time is 11M. The
      following is the log information, new->pfn_lo is smaller than
      iovad->cached_node.
      
      Example log as follows:
      [  223.798112][T1705487] sh: [name:iova&]__alloc_and_insert_iova_range
      start_pfn:0x1f0000,retry_pfn:0x0,size:0xb00,limit_pfn:0x1f0a00
      [  223.799590][T1705487] sh: [name:iova&]__alloc_and_insert_iova_range
      success start_pfn:0x1f0000,new->pfn_lo:0x1efe00,new->pfn_hi:0x1f08ff
      
      2. The node with the largest iova->pfn_lo value in the iova domain
      is deleted, iovad->cached_node will be updated to iovad->anchor,
      and then the alloc iova size exceeds the maximum iova size that can
      be allocated in the domain.
      
      After judging that retry_pfn is less than limit_pfn, call retry_pfn+1
      to fix the overflow issue.
      
      Signed-off-by: default avatarjianjiao zeng <jianjiao.zeng@mediatek.com>
      Signed-off-by: default avatarYunfei Wang <yf.wang@mediatek.com>
      Cc: <stable@vger.kernel.org> # 5.15.*
      Fixes: 4e89dce7
      
       ("iommu/iova: Retry from last rb tree node if iova search fails")
      Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Link: https://lore.kernel.org/r/20230111063801.25107-1-yf.wang@mediatek.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c929a230
    • Ferry Toth's avatar
      usb: ulpi: defer ulpi_register on ulpi_read_id timeout · 4b51aa26
      Ferry Toth authored
      [ Upstream commit 8a7b31d5 ]
      
      Since commit 0f010171 ("usb: dwc3: Don't switch OTG -> peripheral
      if extcon is present") Dual Role support on Intel Merrifield platform
      broke due to rearranging the call to dwc3_get_extcon().
      
      It appears to be caused by ulpi_read_id() on the first test write failing
      with -ETIMEDOUT. Currently ulpi_read_id() expects to discover the phy via
      DT when the test write fails and returns 0 in that case, even if DT does not
      provide the phy. As a result usb probe completes without phy.
      
      Make ulpi_read_id() return -ETIMEDOUT to its user if the first test write
      fails. The user should then handle it appropriately. A follow up patch
      will make dwc3_core_init() set -EPROBE_DEFER in this case and bail out.
      
      Fixes: ef6a7bcf
      
       ("usb: ulpi: Support device discovery via DT")
      Cc: stable@vger.kernel.org
      Acked-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarFerry Toth <ftoth@exalondelft.nl>
      Link: https://lore.kernel.org/r/20221205201527.13525-2-ftoth@exalondelft.nl
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4b51aa26
    • Qiang Yu's avatar
      bus: mhi: host: Fix race between channel preparation and M0 event · 9a8bf443
      Qiang Yu authored
      [ Upstream commit 869a9990 ]
      
      There is a race condition where mhi_prepare_channel() updates the
      read and write pointers as the base address and in parallel, if
      an M0 transition occurs, the tasklet goes ahead and rings
      doorbells for all channels with a delta in TRE rings assuming
      they are already enabled. This causes a null pointer access. Fix
      it by adding a channel enabled check before ringing channel
      doorbells.
      
      Cc: stable@vger.kernel.org # 5.19
      Fixes: a6e2e352
      
       "bus: mhi: core: Add support for PM state transitions"
      Signed-off-by: default avatarQiang Yu <quic_qianyu@quicinc.com>
      Reviewed-by: default avatarManivannan Sadhasivam <mani@kernel.org>
      Link: https://lore.kernel.org/r/1665889532-13634-1-git-send-email-quic_qianyu@quicinc.com
      [mani: CCed stable list]
      Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9a8bf443
    • Herbert Xu's avatar
      ipv6: raw: Deduct extension header length in rawv6_push_pending_frames · 456e3794
      Herbert Xu authored
      commit cb3e9864
      
       upstream.
      
      The total cork length created by ip6_append_data includes extension
      headers, so we must exclude them when comparing them against the
      IPV6_CHECKSUM offset which does not include extension headers.
      
      Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Fixes: 357b40a1
      
       ("[IPV6]: IPV6_CHECKSUM socket option can corrupt kernel memory")
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      456e3794
    • Yang Yingliang's avatar
      ixgbe: fix pci device refcount leak · 4c93422a
      Yang Yingliang authored
      commit b93fb440 upstream.
      
      As the comment of pci_get_domain_bus_and_slot() says, it
      returns a PCI device with refcount incremented, when finish
      using it, the caller must decrement the reference count by
      calling pci_dev_put().
      
      In ixgbe_get_first_secondary_devfn() and ixgbe_x550em_a_has_mii(),
      pci_dev_put() is called to avoid leak.
      
      Fixes: 8fa10ef0
      
       ("ixgbe: register a mdiobus")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c93422a
    • Hans de Goede's avatar
      platform/x86: sony-laptop: Don't turn off 0x153 keyboard backlight during probe · e97da5d9
      Hans de Goede authored
      commit ad75bd85 upstream.
      
      The 0x153 version of the kbd backlight control SNC handle has no separate
      address to probe if the backlight is there.
      
      This turns the probe call into a set keyboard backlight call with a value
      of 0 turning off the keyboard backlight.
      
      Skip probing when there is no separate probe address to avoid this.
      
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=1583752
      Fixes: 800f2017
      
       ("Keyboard backlight control for some Vaio Fit models")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarMattia Dongili <malattia@linux.it>
      Link: https://lore.kernel.org/r/20221213122943.11123-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e97da5d9
    • Konrad Dybcio's avatar
      dt-bindings: msm/dsi: Don't require vcca-supply on 14nm PHY · f3b1e04d
      Konrad Dybcio authored
      commit a2117773
      
       upstream.
      
      On some SoCs (hello SM6115) vcca-supply is not wired to any smd-rpm
      or rpmh regulator, but instead powered by the VDD_MX line, which is
      voted for in the DSI ctrl node.
      
      Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Fixes: 8fc939e7
      
       ("dt-bindings: msm: dsi: add yaml schemas for DSI PHY bindings")
      Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Patchwork: https://patchwork.freedesktop.org/patch/513555/
      Link: https://lore.kernel.org/r/20221130135807.45028-1-konrad.dybcio@linaro.org
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3b1e04d
    • Konrad Dybcio's avatar
      dt-bindings: msm/dsi: Don't require vdds-supply on 10nm PHY · 52a5f596
      Konrad Dybcio authored
      commit ef11cb7a
      
       upstream.
      
      On some SoCs (hello SM6350) vdds-supply is not wired to any smd-rpm
      or rpmh regulator, but instead powered by the VDD_MX/mx.lvl line,
      which is voted for in the DSI ctrl node.
      
      Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Fixes: 8fc939e7
      
       ("dt-bindings: msm: dsi: add yaml schemas for DSI PHY bindings")
      Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Patchwork: https://patchwork.freedesktop.org/patch/511889/
      Link: https://lore.kernel.org/r/20221116163218.42449-1-konrad.dybcio@linaro.org
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52a5f596
    • Kuogee Hsieh's avatar
      drm/msm/dp: do not complete dp_aux_cmd_fifo_tx() if irq is not for aux transfer · 984ad875
      Kuogee Hsieh authored
      commit 1cba0d15 upstream.
      
      There are 3 possible interrupt sources are handled by DP controller,
      HPDstatus, Controller state changes and Aux read/write transaction.
      At every irq, DP controller have to check isr status of every interrupt
      sources and service the interrupt if its isr status bits shows interrupts
      are pending. There is potential race condition may happen at current aux
      isr handler implementation since it is always complete dp_aux_cmd_fifo_tx()
      even irq is not for aux read or write transaction. This may cause aux read
      transaction return premature if host aux data read is in the middle of
      waiting for sink to complete transferring data to host while irq happen.
      This will cause host's receiving buffer contains unexpected data. This
      patch fixes this problem by checking aux isr and return immediately at
      aux isr handler if there are no any isr status bits set.
      
      Current there is a bug report regrading eDP edid corruption happen during
      system booting up. After lengthy debugging to found that VIDEO_READY
      interrupt was continuously firing during system booting up which cause
      dp_aux_isr() to complete dp_aux_cmd_fifo_tx() prematurely to retrieve data
      from aux hardware buffer which is not yet contains complete data transfer
      from sink. This cause edid corruption.
      
      Follows are the signature at kernel logs when problem happen,
      EDID has corrupt header
      panel-simple-dp-aux aux-aea0000.edp: Couldn't identify panel via EDID
      
      Changes in v2:
      -- do complete if (ret == IRQ_HANDLED) ay dp-aux_isr()
      -- add more commit text
      
      Changes in v3:
      -- add Stephen suggested
      -- dp_aux_isr() return IRQ_XXX back to caller
      -- dp_ctrl_isr() return IRQ_XXX back to caller
      
      Changes in v4:
      -- split into two patches
      
      Changes in v5:
      -- delete empty line between tags
      
      Changes in v6:
      -- remove extra "that" and fixed line more than 75 char at commit text
      
      Fixes: c943b494
      
       ("drm/msm/dp: add displayPort driver support")
      Signed-off-by: default avatarKuogee Hsieh <quic_khsieh@quicinc.com>
      Tested-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/516121/
      Link: https://lore.kernel.org/r/1672193785-11003-2-git-send-email-quic_khsieh@quicinc.com
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      984ad875
    • Hans de Goede's avatar
      platform/x86: ideapad-laptop: Add Legion 5 15ARH05 DMI id to set_fn_lock_led_list[] · 92ae8366
      Hans de Goede authored
      commit f4b7f8fe upstream.
      
      The Lenovo Legion 5 15ARH05 needs ideapad-laptop to call SALS_FNLOCK_ON /
      SALS_FNLOCK_OFF on Fn-lock state change to get the LED in the Fn key to
      correctly reflect the Fn-lock state.
      
      Add a DMI match for the Legion 5 15ARH05 to the set_fn_lock_led_list[]
      table for this.
      
      Fixes: 81a5603a
      
       ("platform/x86: ideapad-laptop: Fix interrupt storm on fn-lock toggle on some Yoga laptops")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20221215154357.123876-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      92ae8366
    • Bryan O'Donoghue's avatar
      dt-bindings: msm: dsi-phy-28nm: Add missing qcom, dsi-phy-regulator-ldo-mode · e38b5f81
      Bryan O'Donoghue authored
      commit be79f805 upstream.
      
      Add in missing qcom,dsi-phy-regulator-ldo-mode to the 28nm DSI PHY.
      When converting from .txt to .yaml we missed this one.
      
      Fixes: 4dbe55c9
      
       ("dt-bindings: msm: dsi: add yaml schemas for DSI bindings")
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/516205/
      Link: https://lore.kernel.org/r/20221229124438.504770-2-bryan.odonoghue@linaro.org
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e38b5f81
    • Bryan O'Donoghue's avatar
      dt-bindings: msm: dsi-controller-main: Fix description of core clock · bb32ab40
      Bryan O'Donoghue authored
      commit 654ffe4b upstream.
      
      There's a typo in describing the core clock as an 'escape' clock. The
      accurate description is 'core'.
      
      Fixes: 4dbe55c9
      
       ("dt-bindings: msm: dsi: add yaml schemas for DSI bindings")
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/515938/
      Link: https://lore.kernel.org/r/20221223021025.1646636-4-bryan.odonoghue@linaro.org
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb32ab40
    • Bryan O'Donoghue's avatar
      dt-bindings: msm: dsi-controller-main: Fix power-domain constraint · 3fb8d10b
      Bryan O'Donoghue authored
      commit a6f03393 upstream.
      
      power-domain is required for the sc7180 dispcc GDSC but not every qcom SoC
      has a similar dependency for example the apq8064.
      
      Most Qcom SoC's using mdss-dsi-ctrl seem to have the ability to
      power-collapse the MDP without collapsing DSI.
      
      For example the qcom vendor kernel commit for apq8084, msm8226, msm8916,
      msm8974.
      
      https://review.carbonrom.org/plugins/gitiles/CarbonROM/android_kernel_oneplus_msm8994/+/7b5c011a770daa2811778937ed646237a28a8694
      
      "ARM: dts: msm: add mdss gdsc supply to dsi controller device
      
       It is possible for the DSI controller to be active when MDP is
       power collapsed. DSI controller needs to have it's own vote for
       mdss gdsc to ensure that gdsc remains on in such cases."
      
      This however doesn't appear to be the case for the apq8064 so we shouldn't
      be marking power-domain as required in yaml checks.
      
      Fixes: 4dbe55c9
      
       ("dt-bindings: msm: dsi: add yaml schemas for DSI bindings")
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/515958/
      Link: https://lore.kernel.org/r/20221223021025.1646636-3-bryan.odonoghue@linaro.org
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fb8d10b
    • Konrad Dybcio's avatar
      drm/msm/adreno: Make adreno quirks not overwrite each other · dc5b651c
      Konrad Dybcio authored
      commit 13ef096e upstream.
      
      So far the adreno quirks have all been assigned with an OR operator,
      which is problematic, because they were assigned consecutive integer
      values, which makes checking them with an AND operator kind of no bueno..
      
      Switch to using BIT(n) so that only the quirks that the programmer chose
      are taken into account when evaluating info->quirks & ADRENO_QUIRK_...
      
      Fixes: 370063ee
      
       ("drm/msm/adreno: Add A540 support")
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarMarijn Suijten <marijn.suijten@somainline.org>
      Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
      Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Reviewed-by: default avatarAkhil P Oommen <quic_akhilpo@quicinc.com>
      Patchwork: https://patchwork.freedesktop.org/patch/516456/
      Link: https://lore.kernel.org/r/20230102100201.77286-1-konrad.dybcio@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dc5b651c
    • Bryan O'Donoghue's avatar
      dt-bindings: msm: dsi-controller-main: Fix operating-points-v2 constraint · 757d665e
      Bryan O'Donoghue authored
      commit cdf64343 upstream.
      
      The existing msm8916.dtsi does not depend on nor require operating points.
      
      Fixes: 4dbe55c9
      
       ("dt-bindings: msm: dsi: add yaml schemas for DSI bindings")
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Acked-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/515940/
      Link: https://lore.kernel.org/r/20221223021025.1646636-2-bryan.odonoghue@linaro.org
      Signed-off-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      757d665e
    • Hans de Goede's avatar
      platform/x86: dell-privacy: Fix SW_CAMERA_LENS_COVER reporting · c90cf47d
      Hans de Goede authored
      commit 1af7fef0 upstream.
      
      Use KE_VSW instead of KE_SW for the SW_CAMERA_LENS_COVER key_entry
      and get the value of the switch from the status field when handling
      SW_CAMERA_LENS_COVER events, instead of always reporting 0.
      
      Also correctly set the initial SW_CAMERA_LENS_COVER value.
      
      Fixes: 8af9fa37
      
       ("platform/x86: dell-privacy: Add support for Dell hardware privacy")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20221221220724.119594-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c90cf47d
    • Maximilian Luz's avatar
      platform/surface: aggregator: Ignore command messages not intended for us · 25b5f693
      Maximilian Luz authored
      commit ae0fa0a3 upstream.
      
      It is possible that we (the host/kernel driver) receive command messages
      that are not intended for us. Ignore those for now.
      
      The whole story is a bit more complicated: It is possible to enable
      debug output on SAM, which is sent via SSH command messages. By default
      this output is sent to a debug connector, with its own target ID
      (TID=0x03). It is possible to override the target of the debug output
      and set it to the host/kernel driver. This, however, does not change the
      original target ID of the message. Meaning, we receive messages with
      TID=0x03 (debug) but expect to only receive messages with TID=0x00
      (host).
      
      The problem is that the different target ID also comes with a different
      scope of request IDs. In particular, these do not follow the standard
      event rules (i.e. do not fall into a set of small reserved values).
      Therefore, current message handling interprets them as responses to
      pending requests and tries to match them up via the request ID. However,
      these debug output messages are not in fact responses, and therefore
      this will at best fail to find the request and at worst pass on the
      wrong data as response for a request.
      
      Therefore ignore any command messages not intended for us (host) for
      now. We can implement support for the debug messages once we have a
      better understanding of them.
      
      Note that this may also provide a bit more stability and avoid some
      driver confusion in case any other targets want to talk to us in the
      future, since we don't yet know what to do with those as well. A warning
      for the dropped messages should suffice for now and also give us a
      chance of discovering new targets if they come along without any
      potential for bugs/instabilities.
      
      Fixes: c167b9c7
      
       ("platform/surface: Add Surface Aggregator subsystem")
      Signed-off-by: default avatarMaximilian Luz <luzmaximilian@gmail.com>
      Link: https://lore.kernel.org/r/20221202223327.690880-2-luzmaximilian@gmail.com
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25b5f693
    • Hans de Goede's avatar
      platform/x86: dell-privacy: Only register SW_CAMERA_LENS_COVER if present · ee7b8ce2
      Hans de Goede authored
      commit 6dc485f9 upstream.
      
      Unlike keys where userspace only reacts to keypresses, userspace may act
      on switches in both (0 and 1) of their positions.
      
      For example if a SW_TABLET_MODE switch is registered then GNOME will not
      automatically show the onscreen keyboard when a text field gets focus on
      touchscreen devices when SW_TABLET_MODE reports 0 and when SW_TABLET_MODE
      reports 1 libinput will block (filter out) builtin keyboard and touchpad
      events.
      
      So to avoid unwanted side-effects EV_SW type inputs should only be
      registered if they are actually present, only register SW_CAMERA_LENS_COVER
      if it is actually there.
      
      Fixes: 8af9fa37
      
       ("platform/x86: dell-privacy: Add support for Dell hardware privacy")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20221221220724.119594-2-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee7b8ce2
    • Volker Lendecke's avatar
      cifs: Fix uninitialized memory read for smb311 posix symlink create · e0072068
      Volker Lendecke authored
      commit a152d05a upstream.
      
      If smb311 posix is enabled, we send the intended mode for file
      creation in the posix create context. Instead of using what's there on
      the stack, create the mfsymlink file with 0644.
      
      Fixes: ce558b0e
      
       ("smb3: Add posix create context for smb3.11 posix mounts")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarVolker Lendecke <vl@samba.org>
      Reviewed-by: default avatarTom Talpey <tom@talpey.com>
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0072068