Skip to content
  1. Dec 14, 2023
    • Konstantin Aladyshev's avatar
      usb: gadget: f_hid: fix report descriptor allocation · d9828961
      Konstantin Aladyshev authored
      commit 61890dc2 upstream.
      
      The commit 89ff3dfa ("usb: gadget: f_hid: fix f_hidg lifetime vs
      cdev") has introduced a bug that leads to hid device corruption after
      the replug operation.
      Reverse device managed memory allocation for the report descriptor
      to fix the issue.
      
      Tested:
      This change was tested on the AMD EthanolX CRB server with the BMC
      based on the OpenBMC distribution. The BMC provides KVM functionality
      via the USB gadget device:
      - before: KVM page refresh results in a broken USB device,
      - after: KVM page refresh works without any issues.
      
      Fixes: 89ff3dfa
      
       ("usb: gadget: f_hid: fix f_hidg lifetime vs cdev")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKonstantin Aladyshev <aladyshev22@gmail.com>
      Link: https://lore.kernel.org/r/20231206080744.253-2-aladyshev22@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9828961
    • JP Kobryn's avatar
      kprobes: consistent rcu api usage for kretprobe holder · 95a4c959
      JP Kobryn authored
      commit d839a656 upstream.
      
      It seems that the pointer-to-kretprobe "rp" within the kretprobe_holder is
      RCU-managed, based on the (non-rethook) implementation of get_kretprobe().
      The thought behind this patch is to make use of the RCU API where possible
      when accessing this pointer so that the needed barriers are always in place
      and to self-document the code.
      
      The __rcu annotation to "rp" allows for sparse RCU checking. Plain writes
      done to the "rp" pointer are changed to make use of the RCU macro for
      assignment. For the single read, the implementation of get_kretprobe()
      is simplified by making use of an RCU macro which accomplishes the same,
      but note that the log warning text will be more generic.
      
      I did find that there is a difference in assembly generated between the
      usage of the RCU macros vs without. For example, on arm64, when using
      rcu_assign_pointer(), the corresponding store instruction is a
      store-release (STLR) which has an implicit barrier. When normal assignment
      is done, a regular store (STR) is found. In the macro case, this seems to
      be a result of rcu_assign_pointer() using smp_store_release() when the
      value to write is not NULL.
      
      Link: https://lore.kernel.org/all/20231122132058.3359-1-inwardvessel@gmail.com/
      
      Fixes: d741bf41
      
       ("kprobes: Remove kretprobe hash")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJP Kobryn <inwardvessel@gmail.com>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95a4c959
    • Srinivas Kandagatla's avatar
      ASoC: ops: add correct range check for limiting volume · 395e52b7
      Srinivas Kandagatla authored
      commit fb9ad244
      
       upstream.
      
      Volume can have ranges that start with negative values, ex: -84dB to
      +40dB. Apply correct range check in snd_soc_limit_volume before setting
      the platform_max. Without this patch, for example setting a 0dB limit on
      a volume range of -84dB to +40dB would fail.
      
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Tested-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reviewed-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20231204124736.132185-2-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      395e52b7
    • Boerge Struempfel's avatar
      gpiolib: sysfs: Fix error handling on failed export · 6df51c52
      Boerge Struempfel authored
      [ Upstream commit 95dd1e34 ]
      
      If gpio_set_transitory() fails, we should free the GPIO again. Most
      notably, the flag FLAG_REQUESTED has previously been set in
      gpiod_request_commit(), and should be reset on failure.
      
      To my knowledge, this does not affect any current users, since the
      gpio_set_transitory() mainly returns 0 and -ENOTSUPP, which is converted
      to 0. However the gpio_set_transitory() function calles the .set_config()
      function of the corresponding GPIO chip and there are some GPIO drivers in
      which some (unlikely) branches return other values like -EPROBE_DEFER,
      and -EINVAL. In these cases, the above mentioned FLAG_REQUESTED would not
      be reset, which results in the pin being blocked until the next reboot.
      
      Fixes: e10f72bf
      
       ("gpio: gpiolib: Generalise state persistence beyond sleep")
      Signed-off-by: default avatarBoerge Struempfel <boerge.struempfel@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6df51c52
    • Ashwin Dayanand Kamat's avatar
      x86/sev: Fix kernel crash due to late update to read-only ghcb_version · 73bbca12
      Ashwin Dayanand Kamat authored
      [ Upstream commit 27d25348 ]
      
      A write-access violation page fault kernel crash was observed while running
      cpuhotplug LTP testcases on SEV-ES enabled systems. The crash was
      observed during hotplug, after the CPU was offlined and the process
      was migrated to different CPU. setup_ghcb() is called again which
      tries to update ghcb_version in sev_es_negotiate_protocol(). Ideally this
      is a read_only variable which is initialised during booting.
      
      Trying to write it results in a pagefault:
      
        BUG: unable to handle page fault for address: ffffffffba556e70
        #PF: supervisor write access in kernel mode
        #PF: error_code(0x0003) - permissions violation
        [ ...]
        Call Trace:
         <TASK>
         ? __die_body.cold+0x1a/0x1f
         ? __die+0x2a/0x35
         ? page_fault_oops+0x10c/0x270
         ? setup_ghcb+0x71/0x100
         ? __x86_return_thunk+0x5/0x6
         ? search_exception_tables+0x60/0x70
         ? __x86_return_thunk+0x5/0x6
         ? fixup_exception+0x27/0x320
         ? kernelmode_fixup_or_oops+0xa2/0x120
         ? __bad_area_nosemaphore+0x16a/0x1b0
         ? kernel_exc_vmm_communication+0x60/0xb0
         ? bad_area_nosemaphore+0x16/0x20
         ? do_kern_addr_fault+0x7a/0x90
         ? exc_page_fault+0xbd/0x160
         ? asm_exc_page_fault+0x27/0x30
         ? setup_ghcb+0x71/0x100
         ? setup_ghcb+0xe/0x100
         cpu_init_exception_handling+0x1b9/0x1f0
      
      The fix is to call sev_es_negotiate_protocol() only in the BSP boot phase,
      and it only needs to be done once in any case.
      
      [ mingo: Refined the changelog. ]
      
      Fixes: 95d33bfa
      
       ("x86/sev: Register GHCB memory when SEV-SNP is active")
      Suggested-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Co-developed-by: default avatarBo Gan <bo.gan@broadcom.com>
      Signed-off-by: default avatarBo Gan <bo.gan@broadcom.com>
      Signed-off-by: default avatarAshwin Dayanand Kamat <ashwin.kamat@broadcom.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
      Link: https://lore.kernel.org/r/1701254429-18250-1-git-send-email-kashwindayan@vmware.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      73bbca12
    • Peter Zijlstra's avatar
      perf: Fix perf_event_validate_size() · cfe9295d
      Peter Zijlstra authored
      [ Upstream commit 382c27f4 ]
      
      Budimir noted that perf_event_validate_size() only checks the size of
      the newly added event, even though the sizes of all existing events
      can also change due to not all events having the same read_format.
      
      When we attach the new event, perf_group_attach(), we do re-compute
      the size for all events.
      
      Fixes: a723968c
      
       ("perf: Fix u16 overflows")
      Reported-by: default avatarBudimir Markovic <markovicbudimir@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cfe9295d
    • Jiadong Zhu's avatar
      drm/amdgpu: disable MCBP by default · c66c4794
      Jiadong Zhu authored
      [ Upstream commit d6a57588 ]
      
      Disable MCBP(mid command buffer preemption) by default as old Mesa
      hangs with it. We shall not enable the feature that breaks old usermode
      driver.
      
      Fixes: 50a7c876
      
       ("drm/amdgpu: enable mcbp by default on gfx9")
      Signed-off-by: default avatarJiadong Zhu <Jiadong.Zhu@amd.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c66c4794
    • Hsin-Yi Wang's avatar
      arm64: dts: mt8183: kukui: Fix underscores in node names · 3798c665
      Hsin-Yi Wang authored
      [ Upstream commit 8980c301 ]
      
      Replace underscores with hyphens in pinctrl node names both for consistency
      and to adhere to the bindings.
      
      Cc: stable@vger.kernel.org
      Fixes: cd894e27 ("arm64: dts: mt8183: Add krane-sku176 board")
      Fixes: 1652dbf7 ("arm64: dts: mt8183: add scp node")
      Fixes: 27eaf34d
      
       ("arm64: dts: mt8183: config dsi node")
      Signed-off-by: default avatarHsin-Yi Wang <hsinyi@chromium.org>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20231026191343.3345279-2-hsinyi@chromium.org
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3798c665
    • Krzysztof Kozlowski's avatar
      arm64: dts: mediatek: add missing space before { · b6c47d91
      Krzysztof Kozlowski authored
      [ Upstream commit a9c740c5
      
       ]
      
      Add missing whitespace between node name/label and opening {.
      
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20230705150006.293690-2-krzysztof.kozlowski@linaro.org
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Stable-dep-of: 8980c301
      
       ("arm64: dts: mt8183: kukui: Fix underscores in node names")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b6c47d91
    • Helge Deller's avatar
      parisc: Fix asm operand number out of range build error in bug table · 5bdd0ced
      Helge Deller authored
      [ Upstream commit 48763575
      
       ]
      
      Build is broken if CONFIG_DEBUG_BUGVERBOSE=n.
      Fix it be using the correct asm operand number.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Reported-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Fixes: fe76a134
      
       ("parisc: Use natural CPU alignment for bug_table")
      Cc: stable@vger.kernel.org   # v6.0+
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5bdd0ced
    • Helge Deller's avatar
      parisc: Reduce size of the bug_table on 64-bit kernel by half · 16496064
      Helge Deller authored
      [ Upstream commit 43266838
      
       ]
      
      Enable GENERIC_BUG_RELATIVE_POINTERS which will store 32-bit relative
      offsets to the bug address and the source file name instead of 64-bit
      absolute addresses. This effectively reduces the size of the
      bug_table[] array by half on 64-bit kernels.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Stable-dep-of: 48763575
      
       ("parisc: Fix asm operand number out of range build error in bug table")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      16496064
    • Hengqi Chen's avatar
      LoongArch: BPF: Don't sign extend function return value · 4b117370
      Hengqi Chen authored
      [ Upstream commit 5d47ec2e ]
      
      The `cls_redirect` test triggers a kernel panic like:
      
        # ./test_progs -t cls_redirect
        Can't find bpf_testmod.ko kernel module: -2
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        [   30.938489] CPU 3 Unable to handle kernel paging request at virtual address fffffffffd814de0, era == ffff800002009fb8, ra == ffff800002009f9c
        [   30.939331] Oops[#1]:
        [   30.939513] CPU: 3 PID: 1260 Comm: test_progs Not tainted 6.7.0-rc2-loong-devel-g2f56bb0d2327 #35 a896aca3f4164f09cc346f89f2e09832e07be5f6
        [   30.939732] Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 2/2/2022
        [   30.939901] pc ffff800002009fb8 ra ffff800002009f9c tp 9000000104da4000 sp 9000000104da7ab0
        [   30.940038] a0 fffffffffd814de0 a1 9000000104da7a68 a2 0000000000000000 a3 9000000104da7c10
        [   30.940183] a4 9000000104da7c14 a5 0000000000000002 a6 0000000000000021 a7 00005555904d7f90
        [   30.940321] t0 0000000000000110 t1 0000000000000000 t2 fffffffffd814de0 t3 0004c4b400000000
        [   30.940456] t4 ffffffffffffffff t5 00000000c3f63600 t6 0000000000000000 t7 0000000000000000
        [   30.940590] t8 000000000006d803 u0 0000000000000020 s9 9000000104da7b10 s0 900000010504c200
        [   30.940727] s1 fffffffffd814de0 s2 900000010504c200 s3 9000000104da7c10 s4 9000000104da7ad0
        [   30.940866] s5 0000000000000000 s6 90000000030e65bc s7 9000000104da7b44 s8 90000000044f6fc0
        [   30.941015]    ra: ffff800002009f9c bpf_prog_846803e5ae81417f_cls_redirect+0xa0/0x590
        [   30.941535]   ERA: ffff800002009fb8 bpf_prog_846803e5ae81417f_cls_redirect+0xbc/0x590
        [   30.941696]  CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
        [   30.942224]  PRMD: 00000004 (PPLV0 +PIE -PWE)
        [   30.942330]  EUEN: 00000003 (+FPE +SXE -ASXE -BTE)
        [   30.942453]  ECFG: 00071c1c (LIE=2-4,10-12 VS=7)
        [   30.942612] ESTAT: 00010000 [PIL] (IS= ECode=1 EsubCode=0)
        [   30.942764]  BADV: fffffffffd814de0
        [   30.942854]  PRID: 0014c010 (Loongson-64bit, Loongson-3A5000)
        [   30.942974] Modules linked in:
        [   30.943078] Process test_progs (pid: 1260, threadinfo=00000000ce303226, task=000000007d10bb76)
        [   30.943306] Stack : 900000010a064000 90000000044f6fc0 9000000104da7b48 0000000000000000
        [   30.943495]         0000000000000000 9000000104da7c14 9000000104da7c10 900000010504c200
        [   30.943626]         0000000000000001 ffff80001b88c000 9000000104da7b70 90000000030e6668
        [   30.943785]         0000000000000000 9000000104da7b58 ffff80001b88c048 9000000003d05000
        [   30.943936]         900000000303ac88 0000000000000000 0000000000000000 9000000104da7b70
        [   30.944091]         0000000000000000 0000000000000001 0000000731eeab00 0000000000000000
        [   30.944245]         ffff80001b88c000 0000000000000000 0000000000000000 54b99959429f83b8
        [   30.944402]         ffff80001b88c000 90000000044f6fc0 9000000101d70000 ffff80001b88c000
        [   30.944538]         000000000000005a 900000010504c200 900000010a064000 900000010a067000
        [   30.944697]         9000000104da7d88 0000000000000000 9000000003d05000 90000000030e794c
        [   30.944852]         ...
        [   30.944924] Call Trace:
        [   30.945120] [<ffff800002009fb8>] bpf_prog_846803e5ae81417f_cls_redirect+0xbc/0x590
        [   30.945650] [<90000000030e6668>] bpf_test_run+0x1ec/0x2f8
        [   30.945958] [<90000000030e794c>] bpf_prog_test_run_skb+0x31c/0x684
        [   30.946065] [<90000000026d4f68>] __sys_bpf+0x678/0x2724
        [   30.946159] [<90000000026d7288>] sys_bpf+0x20/0x2c
        [   30.946253] [<90000000032dd224>] do_syscall+0x7c/0x94
        [   30.946343] [<9000000002541c5c>] handle_syscall+0xbc/0x158
        [   30.946492]
        [   30.946549] Code: 0015030e  5c0009c0  5001d000 <28c00304> 02c00484  29c00304  00150009  2a42d2e4  0280200d
        [   30.946793]
        [   30.946971] ---[ end trace 0000000000000000 ]---
        [   32.093225] Kernel panic - not syncing: Fatal exception in interrupt
        [   32.093526] Kernel relocated by 0x2320000
        [   32.093630]  .text @ 0x9000000002520000
        [   32.093725]  .data @ 0x9000000003400000
        [   32.093792]  .bss  @ 0x9000000004413200
        [   34.971998] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
      
      This is because we signed-extend function return values. When subprog
      mode is enabled, we have:
      
        cls_redirect()
          -> get_global_metrics() returns pcpu ptr 0xfffffefffc00b480
      
      The pointer returned is later signed-extended to 0xfffffffffc00b480 at
      `BPF_JMP | BPF_EXIT`. During BPF prog run, this triggers unhandled page
      fault and a kernel panic.
      
      Drop the unnecessary signed-extension on return values like other
      architectures do.
      
      With this change, we have:
      
        # ./test_progs -t cls_redirect
        Can't find bpf_testmod.ko kernel module: -2
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        #51/1    cls_redirect/cls_redirect_inlined:OK
        #51/2    cls_redirect/IPv4 TCP accept unknown (no hops, flags: SYN):OK
        #51/3    cls_redirect/IPv6 TCP accept unknown (no hops, flags: SYN):OK
        #51/4    cls_redirect/IPv4 TCP accept unknown (no hops, flags: ACK):OK
        #51/5    cls_redirect/IPv6 TCP accept unknown (no hops, flags: ACK):OK
        #51/6    cls_redirect/IPv4 TCP forward unknown (one hop, flags: ACK):OK
        #51/7    cls_redirect/IPv6 TCP forward unknown (one hop, flags: ACK):OK
        #51/8    cls_redirect/IPv4 TCP accept known (one hop, flags: ACK):OK
        #51/9    cls_redirect/IPv6 TCP accept known (one hop, flags: ACK):OK
        #51/10   cls_redirect/IPv4 UDP accept unknown (no hops, flags: none):OK
        #51/11   cls_redirect/IPv6 UDP accept unknown (no hops, flags: none):OK
        #51/12   cls_redirect/IPv4 UDP forward unknown (one hop, flags: none):OK
        #51/13   cls_redirect/IPv6 UDP forward unknown (one hop, flags: none):OK
        #51/14   cls_redirect/IPv4 UDP accept known (one hop, flags: none):OK
        #51/15   cls_redirect/IPv6 UDP accept known (one hop, flags: none):OK
        #51/16   cls_redirect/cls_redirect_subprogs:OK
        #51/17   cls_redirect/IPv4 TCP accept unknown (no hops, flags: SYN):OK
        #51/18   cls_redirect/IPv6 TCP accept unknown (no hops, flags: SYN):OK
        #51/19   cls_redirect/IPv4 TCP accept unknown (no hops, flags: ACK):OK
        #51/20   cls_redirect/IPv6 TCP accept unknown (no hops, flags: ACK):OK
        #51/21   cls_redirect/IPv4 TCP forward unknown (one hop, flags: ACK):OK
        #51/22   cls_redirect/IPv6 TCP forward unknown (one hop, flags: ACK):OK
        #51/23   cls_redirect/IPv4 TCP accept known (one hop, flags: ACK):OK
        #51/24   cls_redirect/IPv6 TCP accept known (one hop, flags: ACK):OK
        #51/25   cls_redirect/IPv4 UDP accept unknown (no hops, flags: none):OK
        #51/26   cls_redirect/IPv6 UDP accept unknown (no hops, flags: none):OK
        #51/27   cls_redirect/IPv4 UDP forward unknown (one hop, flags: none):OK
        #51/28   cls_redirect/IPv6 UDP forward unknown (one hop, flags: none):OK
        #51/29   cls_redirect/IPv4 UDP accept known (one hop, flags: none):OK
        #51/30   cls_redirect/IPv6 UDP accept known (one hop, flags: none):OK
        #51/31   cls_redirect/cls_redirect_dynptr:OK
        #51/32   cls_redirect/IPv4 TCP accept unknown (no hops, flags: SYN):OK
        #51/33   cls_redirect/IPv6 TCP accept unknown (no hops, flags: SYN):OK
        #51/34   cls_redirect/IPv4 TCP accept unknown (no hops, flags: ACK):OK
        #51/35   cls_redirect/IPv6 TCP accept unknown (no hops, flags: ACK):OK
        #51/36   cls_redirect/IPv4 TCP forward unknown (one hop, flags: ACK):OK
        #51/37   cls_redirect/IPv6 TCP forward unknown (one hop, flags: ACK):OK
        #51/38   cls_redirect/IPv4 TCP accept known (one hop, flags: ACK):OK
        #51/39   cls_redirect/IPv6 TCP accept known (one hop, flags: ACK):OK
        #51/40   cls_redirect/IPv4 UDP accept unknown (no hops, flags: none):OK
        #51/41   cls_redirect/IPv6 UDP accept unknown (no hops, flags: none):OK
        #51/42   cls_redirect/IPv4 UDP forward unknown (one hop, flags: none):OK
        #51/43   cls_redirect/IPv6 UDP forward unknown (one hop, flags: none):OK
        #51/44   cls_redirect/IPv4 UDP accept known (one hop, flags: none):OK
        #51/45   cls_redirect/IPv6 UDP accept known (one hop, flags: none):OK
        #51      cls_redirect:OK
        Summary: 1/45 PASSED, 0 SKIPPED, 0 FAILED
      
      Fixes: 5dc61552
      
       ("LoongArch: Add BPF JIT support")
      Signed-off-by: default avatarHengqi Chen <hengqi.chen@gmail.com>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4b117370
    • Hengqi Chen's avatar
      LoongArch: BPF: Don't sign extend memory load operand · 3275410b
      Hengqi Chen authored
      [ Upstream commit fe575755 ]
      
      The `cgrp_local_storage` test triggers a kernel panic like:
      
        # ./test_progs -t cgrp_local_storage
        Can't find bpf_testmod.ko kernel module: -2
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        [  550.930632] CPU 1 Unable to handle kernel paging request at virtual address 0000000000000080, era == ffff80000200be34, ra == ffff80000200be00
        [  550.931781] Oops[#1]:
        [  550.931966] CPU: 1 PID: 1303 Comm: test_progs Not tainted 6.7.0-rc2-loong-devel-g2f56bb0d2327 #35 a896aca3f4164f09cc346f89f2e09832e07be5f6
        [  550.932215] Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 2/2/2022
        [  550.932403] pc ffff80000200be34 ra ffff80000200be00 tp 9000000108350000 sp 9000000108353dc0
        [  550.932545] a0 0000000000000000 a1 0000000000000517 a2 0000000000000118 a3 00007ffffbb15558
        [  550.932682] a4 00007ffffbb15620 a5 90000001004e7700 a6 0000000000000021 a7 0000000000000118
        [  550.932824] t0 ffff80000200bdc0 t1 0000000000000517 t2 0000000000000517 t3 00007ffff1c06ee0
        [  550.932961] t4 0000555578ae04d0 t5 fffffffffffffff8 t6 0000000000000004 t7 0000000000000020
        [  550.933097] t8 0000000000000040 u0 00000000000007b8 s9 9000000108353e00 s0 90000001004e7700
        [  550.933241] s1 9000000004005000 s2 0000000000000001 s3 0000000000000000 s4 0000555555eb2ec8
        [  550.933379] s5 00007ffffbb15bb8 s6 00007ffff1dafd60 s7 000055555663f610 s8 00007ffff1db0050
        [  550.933520]    ra: ffff80000200be00 bpf_prog_98f1b9e767be2a84_on_enter+0x40/0x200
        [  550.933911]   ERA: ffff80000200be34 bpf_prog_98f1b9e767be2a84_on_enter+0x74/0x200
        [  550.934105]  CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
        [  550.934596]  PRMD: 00000004 (PPLV0 +PIE -PWE)
        [  550.934712]  EUEN: 00000003 (+FPE +SXE -ASXE -BTE)
        [  550.934836]  ECFG: 00071c1c (LIE=2-4,10-12 VS=7)
        [  550.934976] ESTAT: 00010000 [PIL] (IS= ECode=1 EsubCode=0)
        [  550.935097]  BADV: 0000000000000080
        [  550.935181]  PRID: 0014c010 (Loongson-64bit, Loongson-3A5000)
        [  550.935291] Modules linked in:
        [  550.935391] Process test_progs (pid: 1303, threadinfo=000000006c3b1c41, task=0000000061f84a55)
        [  550.935643] Stack : 00007ffffbb15bb8 0000555555eb2ec8 0000000000000000 0000000000000001
        [  550.935844]         9000000004005000 ffff80001b864000 00007ffffbb15450 90000000029aa034
        [  550.935990]         0000000000000000 9000000108353ec0 0000000000000118 d07d9dfb09721a09
        [  550.936175]         0000000000000001 0000000000000000 9000000108353ec0 0000000000000118
        [  550.936314]         9000000101d46ad0 900000000290abf0 000055555663f610 0000000000000000
        [  550.936479]         0000000000000003 9000000108353ec0 00007ffffbb15450 90000000029d7288
        [  550.936635]         00007ffff1dafd60 000055555663f610 0000000000000000 0000000000000003
        [  550.936779]         9000000108353ec0 90000000035dd1f0 00007ffff1dafd58 9000000002841c5c
        [  550.936939]         0000000000000119 0000555555eea5a8 00007ffff1d78780 00007ffffbb153e0
        [  550.937083]         ffffffffffffffda 00007ffffbb15518 0000000000000040 00007ffffbb15558
        [  550.937224]         ...
        [  550.937299] Call Trace:
        [  550.937521] [<ffff80000200be34>] bpf_prog_98f1b9e767be2a84_on_enter+0x74/0x200
        [  550.937910] [<90000000029aa034>] bpf_trace_run2+0x90/0x154
        [  550.938105] [<900000000290abf0>] syscall_trace_enter.isra.0+0x1cc/0x200
        [  550.938224] [<90000000035dd1f0>] do_syscall+0x48/0x94
        [  550.938319] [<9000000002841c5c>] handle_syscall+0xbc/0x158
        [  550.938477]
        [  550.938607] Code: 580009ae  50016000  262402e4 <28c20085> 14092084  03a00084  16000024  03240084  00150006
        [  550.938851]
        [  550.939021] ---[ end trace 0000000000000000 ]---
      
      Further investigation shows that this panic is triggered by memory
      load operations:
      
        ptr = bpf_cgrp_storage_get(&map_a, task->cgroups->dfl_cgrp, 0,
                                   BPF_LOCAL_STORAGE_GET_F_CREATE);
      
      The expression `task->cgroups->dfl_cgrp` involves two memory load.
      Since the field offset fits in imm12 or imm14, we use ldd or ldptrd
      instructions. But both instructions have the side effect that it will
      signed-extended the imm operand. Finally, we got the wrong addresses
      and panics is inevitable.
      
      Use a generic ldxd instruction to avoid this kind of issues.
      
      With this change, we have:
      
        # ./test_progs -t cgrp_local_storage
        Can't find bpf_testmod.ko kernel module: -2
        WARNING! Selftests relying on bpf_testmod.ko will be skipped.
        test_cgrp_local_storage:PASS:join_cgroup /cgrp_local_storage 0 nsec
        #48/1    cgrp_local_storage/tp_btf:OK
        test_attach_cgroup:PASS:skel_open 0 nsec
        test_attach_cgroup:PASS:prog_attach 0 nsec
        test_attach_cgroup:PASS:prog_attach 0 nsec
        libbpf: prog 'update_cookie_tracing': failed to attach: ERROR: strerror_r(-524)=22
        test_attach_cgroup:FAIL:prog_attach unexpected error: -524
        #48/2    cgrp_local_storage/attach_cgroup:FAIL
        test_recursion:PASS:skel_open_and_load 0 nsec
        libbpf: prog 'on_lookup': failed to attach: ERROR: strerror_r(-524)=22
        libbpf: prog 'on_lookup': failed to auto-attach: -524
        test_recursion:FAIL:skel_attach unexpected error: -524 (errno 524)
        #48/3    cgrp_local_storage/recursion:FAIL
        #48/4    cgrp_local_storage/negative:OK
        #48/5    cgrp_local_storage/cgroup_iter_sleepable:OK
        test_yes_rcu_lock:PASS:skel_open 0 nsec
        test_yes_rcu_lock:PASS:skel_load 0 nsec
        libbpf: prog 'yes_rcu_lock': failed to attach: ERROR: strerror_r(-524)=22
        libbpf: prog 'yes_rcu_lock': failed to auto-attach: -524
        test_yes_rcu_lock:FAIL:skel_attach unexpected error: -524 (errno 524)
        #48/6    cgrp_local_storage/yes_rcu_lock:FAIL
        #48/7    cgrp_local_storage/no_rcu_lock:OK
        #48      cgrp_local_storage:FAIL
      
        All error logs:
        test_cgrp_local_storage:PASS:join_cgroup /cgrp_local_storage 0 nsec
        test_attach_cgroup:PASS:skel_open 0 nsec
        test_attach_cgroup:PASS:prog_attach 0 nsec
        test_attach_cgroup:PASS:prog_attach 0 nsec
        libbpf: prog 'update_cookie_tracing': failed to attach: ERROR: strerror_r(-524)=22
        test_attach_cgroup:FAIL:prog_attach unexpected error: -524
        #48/2    cgrp_local_storage/attach_cgroup:FAIL
        test_recursion:PASS:skel_open_and_load 0 nsec
        libbpf: prog 'on_lookup': failed to attach: ERROR: strerror_r(-524)=22
        libbpf: prog 'on_lookup': failed to auto-attach: -524
        test_recursion:FAIL:skel_attach unexpected error: -524 (errno 524)
        #48/3    cgrp_local_storage/recursion:FAIL
        test_yes_rcu_lock:PASS:skel_open 0 nsec
        test_yes_rcu_lock:PASS:skel_load 0 nsec
        libbpf: prog 'yes_rcu_lock': failed to attach: ERROR: strerror_r(-524)=22
        libbpf: prog 'yes_rcu_lock': failed to auto-attach: -524
        test_yes_rcu_lock:FAIL:skel_attach unexpected error: -524 (errno 524)
        #48/6    cgrp_local_storage/yes_rcu_lock:FAIL
        #48      cgrp_local_storage:FAIL
        Summary: 0/4 PASSED, 0 SKIPPED, 1 FAILED
      
      No panics any more (The test still failed because lack of BPF trampoline
      which I am actively working on).
      
      Fixes: 5dc61552
      
       ("LoongArch: Add BPF JIT support")
      Signed-off-by: default avatarHengqi Chen <hengqi.chen@gmail.com>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3275410b
    • Ilkka Koskinen's avatar
      perf vendor events arm64: AmpereOne: Add missing DefaultMetricgroupName fields · 0fdd1b88
      Ilkka Koskinen authored
      [ Upstream commit 90fe70d4 ]
      
      AmpereOne metrics were missing DefaultMetricgroupName from metrics with
      "Default" in group name resulting perf to segfault. Add the missing
      field to address the issue.
      
      Fixes: 59faeaf8
      
       ("perf vendor events arm64: Fix for AmpereOne metrics")
      Signed-off-by: default avatarIlkka Koskinen <ilkka@os.amperecomputing.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20231201021550.1109196-2-ilkka@os.amperecomputing.com
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0fdd1b88
    • Su Hui's avatar
      misc: mei: client.c: fix problem of return '-EOVERFLOW' in mei_cl_write · f78fff46
      Su Hui authored
      [ Upstream commit ee623602 ]
      
      Clang static analyzer complains that value stored to 'rets' is never
      read.Let 'buf_len = -EOVERFLOW' to make sure we can return '-EOVERFLOW'.
      
      Fixes: 8c8d964c
      
       ("mei: move hbuf_depth from the mei device to the hw modules")
      Signed-off-by: default avatarSu Hui <suhui@nfschina.com>
      Link: https://lore.kernel.org/r/20231120095523.178385-2-suhui@nfschina.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f78fff46
    • Su Hui's avatar
      misc: mei: client.c: return negative error code in mei_cl_write · e2365ead
      Su Hui authored
      [ Upstream commit 8f06aee8 ]
      
      mei_msg_hdr_init() return negative error code, rets should be
      'PTR_ERR(mei_hdr)' rather than '-PTR_ERR(mei_hdr)'.
      
      Fixes: 0cd7c01a
      
       ("mei: add support for mei extended header.")
      Signed-off-by: default avatarSu Hui <suhui@nfschina.com>
      Link: https://lore.kernel.org/r/20231120095523.178385-1-suhui@nfschina.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e2365ead
    • Junhao He's avatar
      coresight: ultrasoc-smb: Fix uninitialized before use buf_hw_base · c541d0ed
      Junhao He authored
      [ Upstream commit 862c135b ]
      
      In smb_reset_buffer, the sdb->buf_hw_base variable is uninitialized
      before use, which initializes it in smb_init_data_buffer. And the SMB
      regiester are set in smb_config_inport.
      So move the call after smb_config_inport.
      
      Fixes: 06f5c292
      
       ("drivers/coresight: Add UltraSoc System Memory Buffer driver")
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/20231114133346.30489-4-hejunhao3@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c541d0ed
    • Junhao He's avatar
      coresight: ultrasoc-smb: Config SMB buffer before register sink · ab5091e1
      Junhao He authored
      [ Upstream commit 830a7f54 ]
      
      The SMB dirver register the enable/disable sysfs interface in function
      smb_register_sink(), however the buffer depends on the following
      configuration to work well. So it'll be possible for user to access an
      unreset one.
      
      Move the config buffer operation to before register_sink().
      Ignore the return value, if smb_config_inport() fails. That will
      cause the hardwares disable trace path to fail, should not affect
      SMB driver remove. So we make smb_remove() return success,
      
      Fixes: 06f5c292
      
       ("drivers/coresight: Add UltraSoc System Memory Buffer driver")
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/20231114133346.30489-3-hejunhao3@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab5091e1
    • Junhao He's avatar
      coresight: ultrasoc-smb: Fix sleep while close preempt in enable_smb · ace850bd
      Junhao He authored
      [ Upstream commit b8411287 ]
      
      When we to enable the SMB by perf, the perf sched will call perf_ctx_lock()
      to close system preempt in event_function_call(). But SMB::enable_smb() use
      mutex to lock the critical section, which may sleep.
      
       BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
       in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 153023, name: perf
       preempt_count: 2, expected: 0
       RCU nest depth: 0, expected: 0
       INFO: lockdep is turned off.
       irq event stamp: 0
       hardirqs last  enabled at (0): [<0000000000000000>] 0x0
       hardirqs last disabled at (0): [<ffffa2983f5c5f40>] copy_process+0xae8/0x2b48
       softirqs last  enabled at (0): [<ffffa2983f5c5f40>] copy_process+0xae8/0x2b48
       softirqs last disabled at (0): [<0000000000000000>] 0x0
       CPU: 2 PID: 153023 Comm: perf Kdump: loaded Tainted: G   W  O   6.5.0-rc4+ #1
      
       Call trace:
       ...
        __mutex_lock+0xbc/0xa70
        mutex_lock_nested+0x34/0x48
        smb_update_buffer+0x58/0x360 [ultrasoc_smb]
        etm_event_stop+0x204/0x2d8 [coresight]
        etm_event_del+0x1c/0x30 [coresight]
        event_sched_out+0x17c/0x3b8
        group_sched_out.part.0+0x5c/0x208
        __perf_event_disable+0x15c/0x210
        event_function+0xe0/0x230
        remote_function+0xb4/0xe8
        generic_exec_single+0x160/0x268
        smp_call_function_single+0x20c/0x2a0
        event_function_call+0x20c/0x220
        _perf_event_disable+0x5c/0x90
        perf_event_for_each_child+0x58/0xc0
        _perf_ioctl+0x34c/0x1250
        perf_ioctl+0x64/0x98
       ...
      
      Use spinlock to replace mutex to control driver data access to one at a
      time. The function copy_to_user() may sleep, it cannot be in a spinlock
      context, so we can't simply replace it in smb_read(). But we can ensure
      that only one user gets the SMB device fd by smb_open(), so remove the
      locks from smb_read() and buffer synchronization is guaranteed by the user.
      
      Fixes: 06f5c292
      
       ("drivers/coresight: Add UltraSoc System Memory Buffer driver")
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/20231114133346.30489-2-hejunhao3@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ace850bd
    • Junhao He's avatar
      hwtracing: hisi_ptt: Add dummy callback pmu::read() · 359d3fbc
      Junhao He authored
      [ Upstream commit 55e0a2fb ]
      
      When start trace with perf option "-C $cpu" and immediately stop it
      with SIGTERM or others, the perf core will invoke pmu::read() while
      the driver doesn't implement it. Add a dummy pmu::read() to avoid
      any issues.
      
      Fixes: ff0de066
      
       ("hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device")
      Signed-off-by: default avatarJunhao He <hejunhao3@huawei.com>
      Signed-off-by: default avatarYicong Yang <yangyicong@hisilicon.com>
      Acked-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/20231010084731.30450-6-yangyicong@huawei.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      359d3fbc
    • James Clark's avatar
      coresight: Fix crash when Perf and sysfs modes are used concurrently · 2f6b1527
      James Clark authored
      [ Upstream commit 287e82cf ]
      
      Partially revert the change in commit 61486528
      
       ("coresight: Enable
      and disable helper devices adjacent to the path") which changed the bare
      call from source_ops(csdev)->enable() to coresight_enable_source() for
      Perf sessions. It was missed that coresight_enable_source() is
      specifically for the sysfs interface, rather than being a generic call.
      This interferes with the sysfs reference counting to cause the following
      crash:
      
        $ perf record -e cs_etm/@tmc_etr0/ -C 0 &
        $ echo 1 > /sys/bus/coresight/devices/tmc_etr0/enable_sink
        $ echo 1 > /sys/bus/coresight/devices/etm0/enable_source
        $ echo 0 > /sys/bus/coresight/devices/etm0/enable_source
      
        Unable to handle kernel NULL pointer dereference at virtual
        address 00000000000001d0
        Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
        ...
        Call trace:
         etm4_disable+0x54/0x150 [coresight_etm4x]
         coresight_disable_source+0x6c/0x98 [coresight]
         coresight_disable+0x74/0x1c0 [coresight]
         enable_source_store+0x88/0xa0 [coresight]
         dev_attr_store+0x20/0x40
         sysfs_kf_write+0x4c/0x68
         kernfs_fop_write_iter+0x120/0x1b8
         vfs_write+0x2dc/0x3b0
         ksys_write+0x70/0x108
         __arm64_sys_write+0x24/0x38
         invoke_syscall+0x50/0x128
         el0_svc_common.constprop.0+0x104/0x130
         do_el0_svc+0x40/0xb8
         el0_svc+0x2c/0xb8
         el0t_64_sync_handler+0xc0/0xc8
         el0t_64_sync+0x1a4/0x1a8
        Code: d53cd042 91002000 b9402a81 b8626800 (f940ead5)
        ---[ end trace 0000000000000000 ]---
      
      This commit linked below also fixes the issue, but has unlocked updates
      to the mode which could potentially race. So until we come up with a
      more complete solution that takes all locking and interaction between
      both modes into account, just revert back to the old behavior for Perf.
      
      Reported-by: default avatarJunhao He <hejunhao3@huawei.com>
      Closes: https://lore.kernel.org/linux-arm-kernel/20230921132904.60996-1-hejunhao3@huawei.com/
      Fixes: 61486528
      
       ("coresight: Enable and disable helper devices adjacent to the path")
      Tested-by: default avatarJunhao He <hejunhao3@huawei.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/20231006131452.646721-1-james.clark@arm.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2f6b1527
    • Uwe Kleine-König's avatar
      coresight: etm4x: Remove bogous __exit annotation for some functions · 1b5d156c
      Uwe Kleine-König authored
      [ Upstream commit 348ddab8 ]
      
      etm4_platform_driver (which lives in ".data" contains a reference to
      etm4_remove_platform_dev(). So the latter must not be marked with __exit
      which results in the function being discarded for a build with
      CONFIG_CORESIGHT_SOURCE_ETM4X=y which in turn makes the remove pointer
      contain invalid data.
      
      etm4x_amba_driver referencing etm4_remove_amba() has the same issue.
      
      Drop the __exit annotations for the two affected functions and a third
      one that is called by the other two.
      
      For reasons I don't understand this isn't catched by building with
      CONFIG_DEBUG_SECTION_MISMATCH=y.
      
      Fixes: c23bc382 ("coresight: etm4x: Refactor probing routine")
      Fixes: 5214b563
      
       ("coresight: etm4x: Add support for sysreg only devices")
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/all/20230929081540.yija47lsj35xtj4v@pengutronix.de/
      Link: https://lore.kernel.org/r/20230929081637.2377335-1-u.kleine-koenig@pengutronix.de
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b5d156c
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: mt8186: Change gpu speedbin nvmem cell name · b9cc1708
      AngeloGioacchino Del Regno authored
      commit 59fa1e51 upstream.
      
      MT8186's GPU speedbin value must be interpreted, or the value will not
      be meaningful.
      Use the correct "gpu-speedbin" nvmem cell name for the GPU speedbin to
      allow triggering the cell info fixup handler, hence feeding the right
      speedbin number to the users.
      
      Cc: stable@vger.kernel.org
      Fixes: 263d2fd0
      
       ("arm64: dts: mediatek: mt8186: Add GPU speed bin NVMEM cells")
      Reviewed-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Link: https://lore.kernel.org/r/20231005151150.355536-1-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9cc1708
    • Eugen Hristev's avatar
      arm64: dts: mediatek: mt8186: fix clock names for power domains · b6eccbcb
      Eugen Hristev authored
      commit 9adf7580 upstream.
      
      Clocks for each power domain are split into big categories: pd clocks
      and subsys clocks.
      According to the binding, all clocks which have a dash '-' in their name
      are treated as subsys clocks, and must be placed at the end of the list.
      The other clocks which are pd clocks must come first.
      Fixed the naming and the placing of all clocks in the power domains.
      For the avoidance of doubt, prefixed all subsys clocks with the 'subsys'
      prefix. The binding does not enforce strict clock names, the driver
      uses them in bulk, only making a difference for pd clocks vs subsys clocks.
      
      The above problem appears to be trivial, however, it leads to incorrect
      power up and power down sequence of the power domains, because some
      clocks will be mistakenly taken for subsys clocks and viceversa.
      One consequence is the fact that if the DIS power domain goes power down
      and power back up during the boot process, when it comes back up, there
      are still transactions left on the bus which makes the display inoperable.
      
      Some of the clocks for the DIS power domain were wrongly using '_' instead
      of '-', which again made these clocks being treated as pd clocks instead of
      subsys clocks.
      
      Cc: stable@vger.kernel.org
      Fixes: d9e43c1e
      
       ("arm64: dts: mt8186: Add power domains controller")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@collabora.com>
      Tested-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Tested-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Reviewed-by: default avatarAlexandre Mergnat <amergnat@baylibre.com>
      Link: https://lore.kernel.org/r/20231005103041.352478-1-eugen.hristev@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6eccbcb
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: mt8183-evb: Fix unit_address_vs_reg warning on ntc · 2e465268
      AngeloGioacchino Del Regno authored
      commit 9dea1c72 upstream.
      
      The NTC is defined as ntc@0 but it doesn't need any address at all.
      Fix the unit_address_vs_reg warning by dropping the unit address: since
      the node name has to be generic also fully rename it from ntc@0 to
      thermal-sensor.
      
      Cc: stable@vger.kernel.org
      Fixes: ff9ea5c6
      
       ("arm64: dts: mediatek: mt8183-evb: Add node for thermistor")
      Link: https://lore.kernel.org/r/20231025093816.44327-7-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e465268
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: mt8183: Move thermal-zones to the root node · bfff27fb
      AngeloGioacchino Del Regno authored
      commit 5a60d634 upstream.
      
      The thermal zones are not a soc bus device: move it to the root
      node to solve simple_bus_reg warnings.
      
      Cc: stable@vger.kernel.org
      Fixes: b325ce39
      
       ("arm64: dts: mt8183: add thermal zone node")
      Link: https://lore.kernel.org/r/20231025093816.44327-9-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfff27fb
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: mt8183: Fix unit address for scp reserved memory · d97373c3
      AngeloGioacchino Del Regno authored
      commit 19cba9a6 upstream.
      
      The reserved memory for scp had node name "scp_mem_region" and also
      without unit-address: change the name to "memory@(address)".
      This fixes a unit_address_vs_reg warning.
      
      Cc: stable@vger.kernel.org
      Fixes: 1652dbf7
      
       ("arm64: dts: mt8183: add scp node")
      Link: https://lore.kernel.org/r/20231025093816.44327-6-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d97373c3
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: mt8195: Fix PM suspend/resume with venc clocks · 9c4ae480
      AngeloGioacchino Del Regno authored
      commit 61b94d54 upstream.
      
      Before suspending the LARBs we're making sure that any operation is
      done: this never happens because we are unexpectedly unclocking the
      LARB20 before executing the suspend handler for the MediaTek Smart
      Multimedia Interface (SMI) and the cause of this is incorrect clocks
      on this LARB.
      
      Fix this issue by changing the Local Arbiter 20 (used by the video
      encoder secondary core) apb clock to CLK_VENC_CORE1_VENC;
      furthermore, in order to make sure that both the PM resume and video
      encoder operation is stable, add the CLK_VENC(_CORE1)_LARB clock to
      the VENC (main core) and VENC_CORE1 power domains, as this IP cannot
      communicate with the rest of the system (the AP) without local
      arbiter clocks being operational.
      
      Cc: stable@vger.kernel.org
      Fixes: 3b5838d1 ("arm64: dts: mt8195: Add iommu and smi nodes")
      Fixes: 2b515194
      
       ("arm64: dts: mt8195: Add power domains controller")
      Reviewed-by: default avatarAlexandre Mergnat <amergnat@baylibre.com>
      Link: https://lore.kernel.org/r/20230706095841.109315-1-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c4ae480
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: mt8173-evb: Fix regulator-fixed node names · 12530266
      AngeloGioacchino Del Regno authored
      commit 24165c5d upstream.
      
      Fix a unit_address_vs_reg warning for the USB VBUS fixed regulators
      by renaming the regulator nodes from regulator@{0,1} to regulator-usb-p0
      and regulator-usb-p1.
      
      Cc: stable@vger.kernel.org
      Fixes: c0891284
      
       ("arm64: dts: mediatek: add USB3 DRD driver")
      Link: https://lore.kernel.org/r/20231025093816.44327-8-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12530266
    • AngeloGioacchino Del Regno's avatar
      arm64: dts: mediatek: cherry: Fix interrupt cells for MT6360 on I2C7 · ac9a2f55
      AngeloGioacchino Del Regno authored
      commit 5943b8f7 upstream.
      
      Change interrupt cells to 2 to suppress interrupts_property warning.
      
      Cc: stable@vger.kernel.org
      Fixes: 0de0fe95
      
       ("arm64: dts: mediatek: cherry: Enable MT6360 sub-pmic on I2C7")
      Link: https://lore.kernel.org/r/20231127132026.165027-1-angelogioacchino.delregno@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac9a2f55
    • Eugen Hristev's avatar
      arm64: dts: mediatek: mt8183-kukui-jacuzzi: fix dsi unnecessary cells properties · d7646d79
      Eugen Hristev authored
      commit 74543b30 upstream.
      
      dtbs_check throws a warning at the dsi node:
      Warning (avoid_unnecessary_addr_size): /soc/dsi@14014000: unnecessary #address-cells/#size-cells without "ranges" or child "reg" property
      
      Other DTS have a panel child node with a reg, so the parent dtsi
      must have the address-cells and size-cells, however this specific DT
      has the panel removed, but not the cells, hence the warning above.
      
      If panel is deleted then the cells must also be deleted since they are
      tied together, as the child node in this DT does not have a reg.
      
      Cc: stable@vger.kernel.org
      Fixes: cabc71b0
      
       ("arm64: dts: mt8183: Add kukui-jacuzzi-damu board")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@collabora.com>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20230814071053.5459-1-eugen.hristev@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7646d79
    • Eugen Hristev's avatar
      arm64: dts: mediatek: mt7622: fix memory node warning check · 6a6df679
      Eugen Hristev authored
      commit 8e6ecbfd upstream.
      
      dtbs_check throws a warning at the memory node:
      Warning (unit_address_vs_reg): /memory: node has a reg or ranges property, but no unit name
      
      fix by adding the address into the node name.
      
      Cc: stable@vger.kernel.org
      Fixes: 0b6286dd
      
       ("arm64: dts: mt7622: add bananapi BPI-R64 board")
      Signed-off-by: default avatarEugen Hristev <eugen.hristev@collabora.com>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20230814065042.4973-1-eugen.hristev@collabora.com
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a6df679
    • Eric Woudstra's avatar
      arm64: dts: mt7986: fix emmc hs400 mode without uboot initialization · 90dc20c8
      Eric Woudstra authored
      commit 8dfe51c3 upstream.
      
      Eric reports errors on emmc with hs400 mode when booting linux on bpi-r3
      without uboot [1]. Booting with uboot does not show this because clocks
      seem to be initialized by uboot.
      
      Fix this by adding assigned-clocks and assigned-clock-parents like it's
      done in uboot [2].
      
      [1] https://forum.banana-pi.org/t/bpi-r3-kernel-fails-setting-emmc-clock-to-416m-depends-on-u-boot/15170
      [2] https://github.com/u-boot/u-boot/blob/master/arch/arm/dts/mt7986.dtsi#L287
      
      Cc: stable@vger.kernel.org
      Fixes: 513b49d1
      
       ("arm64: dts: mt7986: add mmc related device nodes")
      Signed-off-by: default avatarEric Woudstra <ericwouds@gmail.com>
      Signed-off-by: default avatarFrank Wunderlich <frank-w@public-files.de>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20231025170832.78727-2-linux@fw-web.de
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      90dc20c8
    • Frank Wunderlich's avatar
      arm64: dts: mt7986: define 3W max power to both SFP on BPI-R3 · 287b1c41
      Frank Wunderlich authored
      commit 6413cbc1 upstream.
      
      All SFP power supplies are connected to the system VDD33 which is 3v3/8A.
      Set 3A per SFP slot to allow SFPs work which need more power than the
      default 1W.
      
      Cc: stable@vger.kernel.org
      Fixes: 8e01fb15
      
       ("arm64: dts: mt7986: add Bananapi R3")
      Signed-off-by: default avatarFrank Wunderlich <frank-w@public-files.de>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20231025170832.78727-3-linux@fw-web.de
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      287b1c41
    • Frank Wunderlich's avatar
      arm64: dts: mt7986: change cooling trips · 5012eb02
      Frank Wunderlich authored
      commit 1fcda8ce upstream.
      
      Add Critical and hot trips for emergency system shutdown and limiting
      system load.
      
      Change passive trip to active to make sure fan is activated on the
      lowest trip.
      
      Cc: stable@vger.kernel.org
      Fixes: 1f5be051 ("arm64: dts: mt7986: add thermal-zones")
      Fixes: c26f779a
      
       ("arm64: dts: mt7986: add pwm-fan and cooling-maps to BPI-R3 dts")
      Suggested-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarFrank Wunderlich <frank-w@public-files.de>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20231025170832.78727-4-linux@fw-web.de
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5012eb02
    • Ville Syrjälä's avatar
      drm/i915: Skip some timing checks on BXT/GLK DSI transcoders · 8e1e489c
      Ville Syrjälä authored
      commit 20c2dbff upstream.
      
      Apparently some BXT/GLK systems have DSI panels whose timings
      don't agree with the normal cpu transcoder hblank>=32 limitation.
      This is perhaps fine as there are no specific hblank/etc. limits
      listed for the BXT/GLK DSI transcoders.
      
      Move those checks out from the global intel_mode_valid() into
      into connector specific .mode_valid() hooks, skipping BXT/GLK
      DSI connectors. We'll leave the basic [hv]display/[hv]total
      checks in intel_mode_valid() as those seem like sensible upper
      limits regardless of the transcoder used.
      
      Cc: stable@vger.kernel.org
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/9720
      Fixes: 8f4b1068
      
       ("drm/i915: Check some transcoder timing minimum limits")
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20231127145028.4899-1-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit e0ef2daa
      
      )
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e1e489c
    • Ville Syrjälä's avatar
      drm/i915/mst: Reject modes that require the bigjoiner · a0396af3
      Ville Syrjälä authored
      commit dd7eb65c upstream.
      
      We have no bigjoiner support in the MST code, so .mode_valid()
      pretending otherwise is just going to result black screens for
      users. Reject any mode that needs the joiner.
      
      Cc: stable@vger.kernel.org
      Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
      Fixes: d51f25eb
      
       ("drm/i915: Add DSC support to MST path")
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20231127145028.4899-3-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit 9c058492
      
      )
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a0396af3
    • Ville Syrjälä's avatar
      drm/i915/mst: Fix .mode_valid_ctx() return values · 654748c6
      Ville Syrjälä authored
      commit 7cf82b25 upstream.
      
      .mode_valid_ctx() returns an errno, not the mode status. Fix
      the code to do the right thing.
      
      Cc: stable@vger.kernel.org
      Cc: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
      Fixes: d51f25eb
      
       ("drm/i915: Add DSC support to MST path")
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20231127145028.4899-2-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit c1799032
      
      )
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      654748c6
    • Thomas Zimmermann's avatar
      drm/atomic-helpers: Invoke end_fb_access while owning plane state · 02650b3b
      Thomas Zimmermann authored
      commit e0f04e41
      
       upstream.
      
      Invoke drm_plane_helper_funcs.end_fb_access before
      drm_atomic_helper_commit_hw_done(). The latter function hands over
      ownership of the plane state to the following commit, which might
      free it. Releasing resources in end_fb_access then operates on undefined
      state. This bug has been observed with non-blocking commits when they
      are being queued up quickly.
      
      Here is an example stack trace from the bug report. The plane state has
      been free'd already, so the pages for drm_gem_fb_vunmap() are gone.
      
      Unable to handle kernel paging request at virtual address 0000000100000049
      [...]
       drm_gem_fb_vunmap+0x18/0x74
       drm_gem_end_shadow_fb_access+0x1c/0x2c
       drm_atomic_helper_cleanup_planes+0x58/0xd8
       drm_atomic_helper_commit_tail+0x90/0xa0
       commit_tail+0x15c/0x188
       commit_work+0x14/0x20
      
      Fix this by running end_fb_access immediately after updating all planes
      in drm_atomic_helper_commit_planes(). The existing clean-up helper
      drm_atomic_helper_cleanup_planes() now only handles cleanup_fb.
      
      For aborted commits, roll back from drm_atomic_helper_prepare_planes()
      in the new helper drm_atomic_helper_unprepare_planes(). This case is
      different from regular cleanup, as we have to release the new state;
      regular cleanup releases the old state. The new helper also invokes
      cleanup_fb for all planes.
      
      The changes mostly involve DRM's atomic helpers. Only two drivers, i915
      and nouveau, implement their own commit function. Update them to invoke
      drm_atomic_helper_unprepare_planes(). Drivers with custom commit_tail
      function do not require changes.
      
      v4:
      	* fix documentation (kernel test robot)
      v3:
      	* add drm_atomic_helper_unprepare_planes() for rolling back
      	* use correct state for end_fb_access
      v2:
      	* fix test in drm_atomic_helper_cleanup_planes()
      
      Reported-by: default avatarAlyssa Ross <hi@alyssa.is>
      Closes: https://lore.kernel.org/dri-devel/87leazm0ya.fsf@alyssa.is/
      Suggested-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Fixes: 94d879ea
      
       ("drm/atomic-helper: Add {begin,end}_fb_access to plane helpers")
      Tested-by: default avatarAlyssa Ross <hi@alyssa.is>
      Reviewed-by: default avatarAlyssa Ross <hi@alyssa.is>
      Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Cc: <stable@vger.kernel.org> # v6.2+
      Link: https://patchwork.freedesktop.org/patch/msgid/20231204083247.22006-1-tzimmermann@suse.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02650b3b
    • David Jeffery's avatar
      md/raid6: use valid sector values to determine if an I/O should wait on the reshape · 4ce431c2
      David Jeffery authored
      commit c467e97f upstream.
      
      During a reshape or a RAID6 array such as expanding by adding an additional
      disk, I/Os to the region of the array which have not yet been reshaped can
      stall indefinitely. This is from errors in the stripe_ahead_of_reshape
      function causing md to think the I/O is to a region in the actively
      undergoing the reshape.
      
      stripe_ahead_of_reshape fails to account for the q disk having a sector
      value of 0. By not excluding the q disk from the for loop, raid6 will always
      generate a min_sector value of 0, causing a return value which stalls.
      
      The function's max_sector calculation also uses min() when it should use
      max(), causing the max_sector value to always be 0. During a backwards
      rebuild this can cause the opposite problem where it allows I/O to advance
      when it should wait.
      
      Fixing these errors will allow safe I/O to advance in a timely manner and
      delay only I/O which is unsafe due to stripes in the middle of undergoing
      the reshape.
      
      Fixes: 486f6055
      
       ("md/raid5: Check all disks in a stripe_head for reshape progress")
      Cc: stable@vger.kernel.org # v6.0+
      Signed-off-by: default avatarDavid Jeffery <djeffery@redhat.com>
      Tested-by: default avatarLaurence Oberman <loberman@redhat.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Link: https://lore.kernel.org/r/20231128181233.6187-1-djeffery@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ce431c2