Skip to content
  1. Dec 14, 2022
    • Jann Horn's avatar
      mm/khugepaged: take the right locks for page table retraction · d15cd6de
      Jann Horn authored
      commit 8d3c106e upstream.
      
      pagetable walks on address ranges mapped by VMAs can be done under the
      mmap lock, the lock of an anon_vma attached to the VMA, or the lock of the
      VMA's address_space.  Only one of these needs to be held, and it does not
      need to be held in exclusive mode.
      
      Under those circumstances, the rules for concurrent access to page table
      entries are:
      
       - Terminal page table entries (entries that don't point to another page
         table) can be arbitrarily changed under the page table lock, with the
         exception that they always need to be consistent for
         hardware page table walks and lockless_pages_from_mm().
         This includes that they can be changed into non-terminal entries.
       - Non-terminal page table entries (which point to another page table)
         can not be modified; readers are allowed to READ_ONCE() an entry, verify
         that it is non-terminal, and then assume that its value will stay as-is.
      
      Retracting a page table involves modifying a non-terminal entry, so
      page-table-level locks are insufficient to protect against concurrent page
      table traversal; it requires taking all the higher-level locks under which
      it is possible to start a page walk in the relevant range in exclusive
      mode.
      
      The collapse_huge_page() path for anonymous THP already follows this rule,
      but the shmem/file THP path was getting it wrong, making it possible for
      concurrent rmap-based operations to cause corruption.
      
      Link: https://lkml.kernel.org/r/20221129154730.2274278-1-jannh@google.com
      Link: https://lkml.kernel.org/r/20221128180252.1684965-1-jannh@google.com
      Link: https://lkml.kernel.org/r/20221125213714.4115729-1-jannh@google.com
      Fixes: 27e1f827
      
       ("khugepaged: enable collapse pmd for pte-mapped THP")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Reviewed-by: default avatarYang Shi <shy828301@gmail.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      [manual backport: this code was refactored from two copies into a common
      helper between 5.15 and 6.0]
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d15cd6de
    • Davide Tronchin's avatar
      net: usb: qmi_wwan: add u-blox 0x1342 composition · 26f084e5
      Davide Tronchin authored
      [ Upstream commit a487069e
      
       ]
      
      Add RmNet support for LARA-L6.
      
      LARA-L6 module can be configured (by AT interface) in three different
      USB modes:
      * Default mode (Vendor ID: 0x1546 Product ID: 0x1341) with 4 serial
      interfaces
      * RmNet mode (Vendor ID: 0x1546 Product ID: 0x1342) with 4 serial
      interfaces and 1 RmNet virtual network interface
      * CDC-ECM mode (Vendor ID: 0x1546 Product ID: 0x1343) with 4 serial
      interface and 1 CDC-ECM virtual network interface
      
      In RmNet mode LARA-L6 exposes the following interfaces:
      If 0: Diagnostic
      If 1: AT parser
      If 2: AT parser
      If 3: AT parset/alternative functions
      If 4: RMNET interface
      
      Signed-off-by: default avatarDavide Tronchin <davide.tronchin.94@gmail.com>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      26f084e5
    • Dominique Martinet's avatar
      9p/xen: check logical size for buffer size · 029a7f1c
      Dominique Martinet authored
      [ Upstream commit 391c18cf
      
       ]
      
      trans_xen did not check the data fits into the buffer before copying
      from the xen ring, but we probably should.
      Add a check that just skips the request and return an error to
      userspace if it did not fit
      
      Tested-by: default avatarStefano Stabellini <sstabellini@kernel.org>
      Reviewed-by: default avatarChristian Schoenebeck <linux_oss@crudebyte.com>
      Link: https://lkml.kernel.org/r/20221118135542.63400-1-asmadeus@codewreck.org
      Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      029a7f1c
    • Thinh Nguyen's avatar
      usb: dwc3: gadget: Disable GUSB2PHYCFG.SUSPHY for End Transfer · b3988328
      Thinh Nguyen authored
      [ Upstream commit 3aa07f72
      
       ]
      
      If there's a disconnection while operating in eSS, there may be a delay
      in VBUS drop response from the connector. In that case, the internal
      link state may drop to operate in usb2 speed while the controller thinks
      the VBUS is still high. The driver must make sure to disable
      GUSB2PHYCFG.SUSPHY when sending endpoint command while in usb2 speed.
      The End Transfer command may be called, and only that command needs to
      go through at this point. Let's keep it simple and unconditionally
      disable GUSB2PHYCFG.SUSPHY whenever we issue the command.
      
      This scenario is not seen in real hardware. In a rare case, our
      prototype type-c controller/interface may have a slow response
      triggerring this issue.
      
      Signed-off-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
      Link: https://lore.kernel.org/r/5651117207803c26e2f22ddf4e5ce9e865dcf7c7.1668045468.git.Thinh.Nguyen@synopsys.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b3988328
    • Tetsuo Handa's avatar
      fbcon: Use kzalloc() in fbcon_prepare_logo() · e70a5724
      Tetsuo Handa authored
      [ Upstream commit a6a00d7e
      
       ]
      
      A kernel built with syzbot's config file reported that
      
        scr_memcpyw(q, save, array3_size(logo_lines, new_cols, 2))
      
      causes uninitialized "save" to be copied.
      
        ----------
        [drm] Initialized vgem 1.0.0 20120112 for vgem on minor 0
        [drm] Initialized vkms 1.0.0 20180514 for vkms on minor 1
        Console: switching to colour frame buffer device 128x48
        =====================================================
        BUG: KMSAN: uninit-value in do_update_region+0x4b8/0xba0
         do_update_region+0x4b8/0xba0
         update_region+0x40d/0x840
         fbcon_switch+0x3364/0x35e0
         redraw_screen+0xae3/0x18a0
         do_bind_con_driver+0x1cb3/0x1df0
         do_take_over_console+0x11cb/0x13f0
         fbcon_fb_registered+0xacc/0xfd0
         register_framebuffer+0x1179/0x1320
         __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40
         drm_fbdev_client_hotplug+0xbea/0xda0
         drm_fbdev_generic_setup+0x65e/0x9d0
         vkms_init+0x9f3/0xc76
         (...snipped...)
      
        Uninit was stored to memory at:
         fbcon_prepare_logo+0x143b/0x1940
         fbcon_init+0x2c1b/0x31c0
         visual_init+0x3e7/0x820
         do_bind_con_driver+0x14a4/0x1df0
         do_take_over_console+0x11cb/0x13f0
         fbcon_fb_registered+0xacc/0xfd0
         register_framebuffer+0x1179/0x1320
         __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40
         drm_fbdev_client_hotplug+0xbea/0xda0
         drm_fbdev_generic_setup+0x65e/0x9d0
         vkms_init+0x9f3/0xc76
         (...snipped...)
      
        Uninit was created at:
         __kmem_cache_alloc_node+0xb69/0x1020
         __kmalloc+0x379/0x680
         fbcon_prepare_logo+0x704/0x1940
         fbcon_init+0x2c1b/0x31c0
         visual_init+0x3e7/0x820
         do_bind_con_driver+0x14a4/0x1df0
         do_take_over_console+0x11cb/0x13f0
         fbcon_fb_registered+0xacc/0xfd0
         register_framebuffer+0x1179/0x1320
         __drm_fb_helper_initial_config_and_unlock+0x23ad/0x2b40
         drm_fbdev_client_hotplug+0xbea/0xda0
         drm_fbdev_generic_setup+0x65e/0x9d0
         vkms_init+0x9f3/0xc76
         (...snipped...)
      
        CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rc4-00356-g8f2975c2bb4c #924
        Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
        ----------
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/cad03d25-0ea0-32c4-8173-fd1895314bce@I-love.SAKURA.ne.jp
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e70a5724
    • Andreas Kemnade's avatar
      regulator: twl6030: fix get status of twl6032 regulators · fd376859
      Andreas Kemnade authored
      [ Upstream commit 31a6297b
      
       ]
      
      Status is reported as always off in the 6032 case. Status
      reporting now matches the logic in the setters. Once of
      the differences to the 6030 is that there are no groups,
      therefore the state needs to be read out in the lower bits.
      
      Signed-off-by: default avatarAndreas Kemnade <andreas@kemnade.info>
      Link: https://lore.kernel.org/r/20221120221208.3093727-3-andreas@kemnade.info
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fd376859
    • Srinivasa Rao Mandadapu's avatar
      ASoC: soc-pcm: Add NULL check in BE reparenting · 9f74b9aa
      Srinivasa Rao Mandadapu authored
      [ Upstream commit db8f91d4
      
       ]
      
      Add NULL check in dpcm_be_reparent API, to handle
      kernel NULL pointer dereference error.
      The issue occurred in fuzzing test.
      
      Signed-off-by: default avatarSrinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
      Link: https://lore.kernel.org/r/1669098673-29703-1-git-send-email-quic_srivasam@quicinc.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9f74b9aa
    • Filipe Manana's avatar
      btrfs: send: avoid unaligned encoded writes when attempting to clone range · dae93f41
      Filipe Manana authored
      [ Upstream commit a11452a3
      
       ]
      
      When trying to see if we can clone a file range, there are cases where we
      end up sending two write operations in case the inode from the source root
      has an i_size that is not sector size aligned and the length from the
      current offset to its i_size is less than the remaining length we are
      trying to clone.
      
      Issuing two write operations when we could instead issue a single write
      operation is not incorrect. However it is not optimal, specially if the
      extents are compressed and the flag BTRFS_SEND_FLAG_COMPRESSED was passed
      to the send ioctl. In that case we can end up sending an encoded write
      with an offset that is not sector size aligned, which makes the receiver
      fallback to decompressing the data and writing it using regular buffered
      IO (so re-compressing the data in case the fs is mounted with compression
      enabled), because encoded writes fail with -EINVAL when an offset is not
      sector size aligned.
      
      The following example, which triggered a bug in the receiver code for the
      fallback logic of decompressing + regular buffer IO and is fixed by the
      patchset referred in a Link at the bottom of this changelog, is an example
      where we have the non-optimal behaviour due to an unaligned encoded write:
      
         $ cat test.sh
         #!/bin/bash
      
         DEV=/dev/sdj
         MNT=/mnt/sdj
      
         mkfs.btrfs -f $DEV > /dev/null
         mount -o compress $DEV $MNT
      
         # File foo has a size of 33K, not aligned to the sector size.
         xfs_io -f -c "pwrite -S 0xab 0 33K" $MNT/foo
      
         xfs_io -f -c "pwrite -S 0xcd 0 64K" $MNT/bar
      
         # Now clone the first 32K of file bar into foo at offset 0.
         xfs_io -c "reflink $MNT/bar 0 0 32K" $MNT/foo
      
         # Snapshot the default subvolume and create a full send stream (v2).
         btrfs subvolume snapshot -r $MNT $MNT/snap
      
         btrfs send --compressed-data -f /tmp/test.send $MNT/snap
      
         echo -e "\nFile bar in the original filesystem:"
         od -A d -t x1 $MNT/snap/bar
      
         umount $MNT
         mkfs.btrfs -f $DEV > /dev/null
         mount $DEV $MNT
      
         echo -e "\nReceiving stream in a new filesystem..."
         btrfs receive -f /tmp/test.send $MNT
      
         echo -e "\nFile bar in the new filesystem:"
         od -A d -t x1 $MNT/snap/bar
      
         umount $MNT
      
      Before this patch, the send stream included one regular write and one
      encoded write for file 'bar', with the later being not sector size aligned
      and causing the receiver to fallback to decompression + buffered writes.
      The output of the btrfs receive command in verbose mode (-vvv):
      
         (...)
         mkfile o258-7-0
         rename o258-7-0 -> bar
         utimes
         clone bar - source=foo source offset=0 offset=0 length=32768
         write bar - offset=32768 length=1024
         encoded_write bar - offset=33792, len=4096, unencoded_offset=33792, unencoded_file_len=31744, unencoded_len=65536, compression=1, encryption=0
         encoded_write bar - falling back to decompress and write due to errno 22 ("Invalid argument")
         (...)
      
      This patch avoids the regular write followed by an unaligned encoded write
      so that we end up sending a single encoded write that is aligned. So after
      this patch the stream content is (output of btrfs receive -vvv):
      
         (...)
         mkfile o258-7-0
         rename o258-7-0 -> bar
         utimes
         clone bar - source=foo source offset=0 offset=0 length=32768
         encoded_write bar - offset=32768, len=4096, unencoded_offset=32768, unencoded_file_len=32768, unencoded_len=65536, compression=1, encryption=0
         (...)
      
      So we get more optimal behaviour and avoid the silent data loss bug in
      versions of btrfs-progs affected by the bug referred by the Link tag
      below (btrfs-progs v5.19, v5.19.1, v6.0 and v6.0.1).
      
      Link: https://lore.kernel.org/linux-btrfs/cover.1668529099.git.fdmanana@suse.com/
      Reviewed-by: default avatarBoris Burkov <boris@bur.io>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dae93f41
    • Daniel Díaz's avatar
      selftests/net: Find nettest in current directory · f54e1edf
      Daniel Díaz authored
      [ Upstream commit bd5e1e42
      
       ]
      
      The `nettest` binary, built from `selftests/net/nettest.c`,
      was expected to be found in the path during test execution of
      `fcnal-test.sh` and `pmtu.sh`, leading to tests getting
      skipped when the binary is not installed in the system, as can
      be seen in these logs found in the wild [1]:
      
        # TEST: vti4: PMTU exceptions                                         [SKIP]
        [  350.600250] IPv6: ADDRCONF(NETDEV_CHANGE): veth_b: link becomes ready
        [  350.607421] IPv6: ADDRCONF(NETDEV_CHANGE): veth_a: link becomes ready
        # 'nettest' command not found; skipping tests
        #   xfrm6udp not supported
        # TEST: vti6: PMTU exceptions (ESP-in-UDP)                            [SKIP]
        [  351.605102] IPv6: ADDRCONF(NETDEV_CHANGE): veth_b: link becomes ready
        [  351.612243] IPv6: ADDRCONF(NETDEV_CHANGE): veth_a: link becomes ready
        # 'nettest' command not found; skipping tests
        #   xfrm4udp not supported
      
      The `unicast_extensions.sh` tests also rely on `nettest`, but
      it runs fine there because it looks for the binary in the
      current working directory [2]:
      
      The same mechanism that works for the Unicast extensions tests
      is here copied over to the PMTU and functional tests.
      
      [1] https://lkft.validation.linaro.org/scheduler/job/5839508#L6221
      [2] https://lkft.validation.linaro.org/scheduler/job/5839508#L7958
      
      Signed-off-by: default avatarDaniel Díaz <daniel.diaz@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f54e1edf
    • Kees Cook's avatar
      ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event · fccd4541
      Kees Cook authored
      [ Upstream commit 05530ef7
      
       ]
      
      With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
      indirect call targets are validated against the expected function
      pointer prototype to make sure the call target is valid to help mitigate
      ROP attacks. If they are not identical, there is a failure at run time,
      which manifests as either a kernel panic or thread getting killed.
      
      seq_copy_in_user() and seq_copy_in_kernel() did not have prototypes
      matching snd_seq_dump_func_t. Adjust this and remove the casts. There
      are not resulting binary output differences.
      
      This was found as a result of Clang's new -Wcast-function-type-strict
      flag, which is more sensitive than the simpler -Wcast-function-type,
      which only checks for type width mismatches.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/lkml/202211041527.HD8TLSE1-lkp@intel.com
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Takashi Iwai <tiwai@suse.com>
      Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
      Cc: alsa-devel@alsa-project.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221118232346.never.380-kees@kernel.org
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fccd4541
    • Konrad Dybcio's avatar
      regulator: slg51000: Wait after asserting CS pin · 542a563b
      Konrad Dybcio authored
      [ Upstream commit 0b24dfa5
      
       ]
      
      Sony's downstream driver [1], among some other changes, adds a
      seemingly random 10ms usleep_range, which turned out to be necessary
      for the hardware to function properly on at least Sony Xperia 1 IV.
      Without this, I2C transactions with the SLG51000 straight up fail.
      
      Relax (10-10ms -> 10-11ms) and add the aforementioned sleep to make
      sure the hardware has some time to wake up.
      
      (nagara-2.0.0-mlc/vendor/semc/hardware/camera-kernel-module/)
      [1] https://developer.sony.com/file/download/open-source-archive-for-64-0-m-4-29/
      
      Signed-off-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Link: https://lore.kernel.org/r/20221118131035.54874-1-konrad.dybcio@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      542a563b
    • GUO Zihua's avatar
      9p/fd: Use P9_HDRSZ for header size · 3d1b5fde
      GUO Zihua authored
      [ Upstream commit 6854fadb
      
       ]
      
      Cleanup hardcoded header sizes to use P9_HDRSZ instead of '7'
      
      Link: https://lkml.kernel.org/r/20221117091159.31533-4-guozihua@huawei.com
      Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
      Reviewed-by: default avatarChristian Schoenebeck <linux_oss@crudebyte.com>
      [Dominique: commit message adjusted to make sense after offset size
      adjustment got removed]
      Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d1b5fde
    • Shuming Fan's avatar
      ASoC: rt711-sdca: fix the latency time of clock stop prepare state machine transitions · fe2d44e8
      Shuming Fan authored
      [ Upstream commit c7d7d4e7
      
       ]
      
      Due to the hardware behavior, it takes some time for CBJ detection/impedance sensing/de-bounce.
      The ClockStop_NotFinished flag will be raised until these functions are completed.
      In ClockStopMode0 mode case, the SdW controller might check this flag from D3 to D0 when the
      jack detection interrupt happened.
      
      Signed-off-by: default avatarShuming Fan <shumingf@realtek.com>
      Link: https://lore.kernel.org/r/20221116090318.5017-1-shumingf@realtek.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fe2d44e8
    • Johan Jonker's avatar
      ARM: dts: rockchip: disable arm_global_timer on rk3066 and rk3188 · e945f3d8
      Johan Jonker authored
      [ Upstream commit da74858a
      
       ]
      
      The clock source and the sched_clock provided by the arm_global_timer
      on Rockchip rk3066a/rk3188 are quite unstable because their rates
      depend on the CPU frequency.
      
      Recent changes to the arm_global_timer driver makes it impossible to use.
      
      On the other side, the arm_global_timer has a higher rating than the
      ROCKCHIP_TIMER, it will be selected by default by the time framework
      while we want to use the stable Rockchip clock source.
      
      Keep the arm_global_timer disabled in order to have the
      DW_APB_TIMER (rk3066a) or ROCKCHIP_TIMER (rk3188) selected by default.
      
      Signed-off-by: default avatarJohan Jonker <jbx6244@gmail.com>
      Link: https://lore.kernel.org/r/f275ca8d-fd0a-26e5-b978-b7f3df815e0a@gmail.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e945f3d8
    • Zhichao Liu's avatar
      spi: mediatek: Fix DEVAPC Violation at KO Remove · c3b818c9
      Zhichao Liu authored
      [ Upstream commit 0d10e90c
      
       ]
      
      A DEVAPC violation occurs when removing the module
      due to accessing HW registers without base clock.
      To fix this bug, the correct method is:
      1. Call the runtime resume function to enable the
         clock;
      2. Operate the registers to reset the HW;
      3. Turn off the clocks and disable the device
         RPM mechanism.
      
      Signed-off-by: default avatarZhichao Liu <zhichao.liu@mediatek.com>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20221110072839.30961-1-zhichao.liu@mediatek.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c3b818c9
    • Chancel Liu's avatar
      ASoC: wm8962: Wait for updated value of WM8962_CLOCKING1 register · d9f0107b
      Chancel Liu authored
      [ Upstream commit 3ca507bf
      
       ]
      
      DSPCLK_DIV field in WM8962_CLOCKING1 register is used to generate
      correct frequency of LRCLK and BCLK. Sometimes the read-only value
      can't be updated timely after enabling SYSCLK. This results in wrong
      calculation values. Delay is introduced here to wait for newest value
      from register. The time of the delay should be at least 500~1000us
      according to test.
      
      Signed-off-by: default avatarChancel Liu <chancel.liu@nxp.com>
      Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20221109121354.123958-1-chancel.liu@nxp.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d9f0107b
    • Giulio Benetti's avatar
      ARM: 9266/1: mm: fix no-MMU ZERO_PAGE() implementation · 7ae02627
      Giulio Benetti authored
      [ Upstream commit 340a9828 ]
      
      Actually in no-MMU SoCs(i.e. i.MXRT) ZERO_PAGE(vaddr) expands to
      ```
      virt_to_page(0)
      ```
      that in order expands to:
      ```
      pfn_to_page(virt_to_pfn(0))
      ```
      and then virt_to_pfn(0) to:
      ```
              ((((unsigned long)(0) - PAGE_OFFSET) >> PAGE_SHIFT) +
               PHYS_PFN_OFFSET)
      ```
      where PAGE_OFFSET and PHYS_PFN_OFFSET are the DRAM offset(0x80000000) and
      PAGE_SHIFT is 12. This way we obtain 16MB(0x01000000) summed to the base of
      DRAM(0x80000000).
      When ZERO_PAGE(0) is then used, for example in bio_add_page(), the page
      gets an address that is out of DRAM bounds.
      So instead of using fake virtual page 0 let's allocate a dedicated
      zero_page during paging_init() and assign it to a global 'struct page *
      empty_zero_page' the same way mmu.c does and it's the same approach used
      in m68k with commit dc068f46
      
       as discussed here[0]. Then let's move
      ZERO_PAGE() definition to the top of pgtable.h to be in common between
      mmu.c and nommu.c.
      
      [0]: https://lore.kernel.org/linux-m68k/2a462b23-5b8e-bbf4-ec7d-778434a3b9d7@google.com/T/#m1266ceb63
      ad140743174d6b3070364d3c9a5179b
      
      Signed-off-by: default avatarGiulio Benetti <giulio.benetti@benettiengineering.com>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7ae02627
    • Tomislav Novak's avatar
      ARM: 9251/1: perf: Fix stacktraces for tracepoint events in THUMB2 kernels · d81c62e3
      Tomislav Novak authored
      [ Upstream commit 612695bc
      
       ]
      
      Store the frame address where arm_get_current_stackframe() looks for it
      (ARM_r7 instead of ARM_fp if CONFIG_THUMB2_KERNEL=y). Otherwise frame->fp
      gets set to 0, causing unwind_frame() to fail.
      
        # bpftrace -e 't:sched:sched_switch { @[kstack] = count(); exit(); }'
        Attaching 1 probe...
        @[
            __schedule+1059
        ]: 1
      
      A typical first unwind instruction is 0x97 (SP = R7), so after executing
      it SP ends up being 0 and -URC_FAILURE is returned.
      
        unwind_frame(pc = ac9da7d7 lr = 00000000 sp = c69bdda0 fp = 00000000)
        unwind_find_idx(ac9da7d7)
        unwind_exec_insn: insn = 00000097
        unwind_exec_insn: fp = 00000000 sp = 00000000 lr = 00000000 pc = 00000000
      
      With this patch:
      
        # bpftrace -e 't:sched:sched_switch { @[kstack] = count(); exit(); }'
        Attaching 1 probe...
        @[
            __schedule+1059
            __schedule+1059
            schedule+79
            schedule_hrtimeout_range_clock+163
            schedule_hrtimeout_range+17
            ep_poll+471
            SyS_epoll_wait+111
            sys_epoll_pwait+231
            __ret_fast_syscall+1
        ]: 1
      
      Link: https://lore.kernel.org/r/20220920230728.2617421-1-tnovak@fb.com/
      
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarTomislav Novak <tnovak@fb.com>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d81c62e3
    • Jann Horn's avatar
      fs: use acquire ordering in __fget_light() · 66717ad0
      Jann Horn authored
      [ Upstream commit 7ee47dcf
      
       ]
      
      We must prevent the CPU from reordering the files->count read with the
      FD table access like this, on architectures where read-read reordering is
      possible:
      
          files_lookup_fd_raw()
                                        close_fd()
                                        put_files_struct()
          atomic_read(&files->count)
      
      I would like to mark this for stable, but the stable rules explicitly say
      "no theoretical races", and given that the FD table pointer and
      files->count are explicitly stored in the same cacheline, this sort of
      reordering seems quite unlikely in practice...
      
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      66717ad0
    • Johan Jonker's avatar
      ARM: dts: rockchip: rk3188: fix lcdc1-rgb24 node name · 1222e236
      Johan Jonker authored
      [ Upstream commit 11871e20
      
       ]
      
      The lcdc1-rgb24 node name is out of line with the rest
      of the rk3188 lcdc1 node, so fix it.
      
      Signed-off-by: default avatarJohan Jonker <jbx6244@gmail.com>
      Link: https://lore.kernel.org/r/7b9c0a6f-626b-07e8-ae74-7e0f08b8d241@gmail.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1222e236
    • Johan Jonker's avatar
      arm64: dts: rockchip: fix ir-receiver node names · 996fb29b
      Johan Jonker authored
      [ Upstream commit de0d04b9
      
       ]
      
      Fix ir-receiver node names on Rockchip boards,
      so that they match with regex: '^ir(-receiver)?(@[a-f0-9]+)?$'
      
      Signed-off-by: default avatarJohan Jonker <jbx6244@gmail.com>
      Link: https://lore.kernel.org/r/e9764253-8ce8-150b-4820-41f03f845469@gmail.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      996fb29b
    • Johan Jonker's avatar
      ARM: dts: rockchip: fix ir-receiver node names · 752138ef
      Johan Jonker authored
      [ Upstream commit dd847fe3
      
       ]
      
      Fix ir-receiver node names on Rockchip boards,
      so that they match with regex: '^ir(-receiver)?(@[a-f0-9]+)?$'
      
      Signed-off-by: default avatarJohan Jonker <jbx6244@gmail.com>
      Link: https://lore.kernel.org/r/ea5af279-f44c-afea-023d-bb37f5a0d58d@gmail.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      752138ef
    • Sebastian Reichel's avatar
      arm: dts: rockchip: remove clock-frequency from rtc · 8045971e
      Sebastian Reichel authored
      [ Upstream commit 6122f3be
      
       ]
      
      'clock-frequency' is not part of the DT binding and not supported by the
      Linux driver.
      
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Link: https://lore.kernel.org/r/20221024165549.74574-5-sebastian.reichel@collabora.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8045971e
    • Sebastian Reichel's avatar
      arm: dts: rockchip: fix node name for hym8563 rtc · 5e9fb801
      Sebastian Reichel authored
      [ Upstream commit 17b57bea
      
       ]
      
      Fix the node name for hym8563 in all arm rockchip devicetrees.
      
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Link: https://lore.kernel.org/r/20221024165549.74574-4-sebastian.reichel@collabora.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5e9fb801
    • FUKAUMI Naoki's avatar
      arm64: dts: rockchip: keep I2S1 disabled for GPIO function on ROCK Pi 4 series · 2ed7137e
      FUKAUMI Naoki authored
      [ Upstream commit 849c19d1
      
       ]
      
      I2S1 pins are exposed on 40-pin header on Radxa ROCK Pi 4 series.
      their default function is GPIO, so I2S1 need to be disabled.
      
      Signed-off-by: default avatarFUKAUMI Naoki <naoki@radxa.com>
      Link: https://lore.kernel.org/r/20220924112812.1219-1-naoki@radxa.com
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ed7137e
    • Gaosheng Cui's avatar
      mmc: mtk-sd: Fix missing clk_disable_unprepare in msdc_of_clock_parse() · 5a1122e1
      Gaosheng Cui authored
      [ Upstream commit c61bfb1c ]
      
      The clk_disable_unprepare() should be called in the error handling
      of devm_clk_bulk_get_optional, fix it by replacing devm_clk_get_optional
      and clk_prepare_enable by devm_clk_get_optional_enabled.
      
      Fixes: f5eccd94
      
       ("mmc: mediatek: Add subsys clock control for MT8192 msdc")
      Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221125090141.3626747-1-cuigaosheng1@huawei.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5a1122e1
    • Uwe Kleine-König's avatar
      clk: Provide new devm_clk helpers for prepared and enabled clocks · 282f52c9
      Uwe Kleine-König authored
      [ Upstream commit 7ef9651e
      
       ]
      
      When a driver keeps a clock prepared (or enabled) during the whole
      lifetime of the driver, these helpers allow to simplify the drivers.
      
      Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Reviewed-by: default avatarAlexandru Ardelean <aardelean@deviqon.com>
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Link: https://lore.kernel.org/r/20220520075737.758761-4-u.kleine-koenig@pengutronix.de
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Stable-dep-of: c61bfb1c
      
       ("mmc: mtk-sd: Fix missing clk_disable_unprepare in msdc_of_clock_parse()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      282f52c9
    • Uwe Kleine-König's avatar
      clk: generalize devm_clk_get() a bit · eb94a7a2
      Uwe Kleine-König authored
      [ Upstream commit abae8e57
      
       ]
      
      Allow to add an exit hook to devm managed clocks. Also use
      clk_get_optional() in devm_clk_get_optional instead of open coding it.
      The generalisation will be used in the next commit to add some more
      devm_clk helpers.
      
      Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Reviewed-by: default avatarAlexandru Ardelean <aardelean@deviqon.com>
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Link: https://lore.kernel.org/r/20220520075737.758761-3-u.kleine-koenig@pengutronix.de
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Stable-dep-of: c61bfb1c
      
       ("mmc: mtk-sd: Fix missing clk_disable_unprepare in msdc_of_clock_parse()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb94a7a2
  2. Dec 08, 2022
    • Greg Kroah-Hartman's avatar
      Linux 5.15.82 · d9790301
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20221205190806.528972574@linuxfoundation.org
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarBagas Sanjaya <bagasdotme@gmail.com>
      Tested-by: default avatarRon Economos <re@w6rz.net>
      Link: https://lore.kernel.org/r/20221206124052.595650754@linuxfoundation.org
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Link: https://lore.kernel.org/r/20221206163439.841627689@linuxfoundation.org
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarAllen Pais <apais@linux.microsoft.com>
      Tested-by: default avatarRon Economos <re@w6rz.net>
      Tested-by: default avatarKelsey Steele <kelseysteele@linux.microsoft.com>
      Tested-by: default avatarBagas Sanjaya <bagasdotme@gmail.com>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarSudip Mukherjee <sudip.mukherjee@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v5.15.82
      d9790301
    • Linus Torvalds's avatar
      proc: proc_skip_spaces() shouldn't think it is working on C strings · 48642f94
      Linus Torvalds authored
      commit bce93322
      
       upstream.
      
      proc_skip_spaces() seems to think it is working on C strings, and ends
      up being just a wrapper around skip_spaces() with a really odd calling
      convention.
      
      Instead of basing it on skip_spaces(), it should have looked more like
      proc_skip_char(), which really is the exact same function (except it
      skips a particular character, rather than whitespace).  So use that as
      inspiration, odd coding and all.
      
      Now the calling convention actually makes sense and works for the
      intended purpose.
      
      Reported-and-tested-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      48642f94
    • Linus Torvalds's avatar
      proc: avoid integer type confusion in get_proc_long · 3eb9213f
      Linus Torvalds authored
      commit e6cfaf34
      
       upstream.
      
      proc_get_long() is passed a size_t, but then assigns it to an 'int'
      variable for the length.  Let's not do that, even if our IO paths are
      limited to MAX_RW_COUNT (exactly because of these kinds of type errors).
      
      So do the proper test in the rigth type.
      
      Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3eb9213f
    • Jann Horn's avatar
      ipc/sem: Fix dangling sem_array access in semtimedop race · 4a4073a2
      Jann Horn authored
      commit b52be557 upstream.
      
      When __do_semtimedop() goes to sleep because it has to wait for a
      semaphore value becoming zero or becoming bigger than some threshold, it
      links the on-stack sem_queue to the sem_array, then goes to sleep
      without holding a reference on the sem_array.
      
      When __do_semtimedop() comes back out of sleep, one of two things must
      happen:
      
       a) We prove that the on-stack sem_queue has been disconnected from the
          (possibly freed) sem_array, making it safe to return from the stack
          frame that the sem_queue exists in.
      
       b) We stabilize our reference to the sem_array, lock the sem_array, and
          detach the sem_queue from the sem_array ourselves.
      
      sem_array has RCU lifetime, so for case (b), the reference can be
      stabilized inside an RCU read-side critical section by locklessly
      checking whether the sem_queue is still connected to the sem_array.
      
      However, the current code does the lockless check on sem_queue before
      starting an RCU read-side critical section, so the result of the
      lockless check immediately becomes useless.
      
      Fix it by doing rcu_read_lock() before the lockless check.  Now RCU
      ensures that if we observe the object being on our queue, the object
      can't be freed until rcu_read_unlock().
      
      This bug is only hittable on kernel builds with full preemption support
      (either CONFIG_PREEMPT or PREEMPT_DYNAMIC with preempt=full).
      
      Fixes: 370b262c
      
       ("ipc/sem: avoid idr tree lookup for interrupted semop")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a4073a2
    • Zhang Xiaoxu's avatar
      Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send() · 53b9b120
      Zhang Xiaoxu authored
      commit 8c9a5993 upstream.
      
      There is a kmemleak when test the raydium_i2c_ts with bpf mock device:
      
        unreferenced object 0xffff88812d3675a0 (size 8):
          comm "python3", pid 349, jiffies 4294741067 (age 95.695s)
          hex dump (first 8 bytes):
            11 0e 10 c0 01 00 04 00                          ........
          backtrace:
            [<0000000068427125>] __kmalloc+0x46/0x1b0
            [<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
            [<000000006e631aee>] raydium_i2c_initialize.cold+0xbc/0x3e4 [raydium_i2c_ts]
            [<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
            [<00000000a310de16>] i2c_device_probe+0x651/0x680
            [<00000000f5a96bf3>] really_probe+0x17c/0x3f0
            [<00000000096ba499>] __driver_probe_device+0xe3/0x170
            [<00000000c5acb4d9>] driver_probe_device+0x49/0x120
            [<00000000264fe082>] __device_attach_driver+0xf7/0x150
            [<00000000f919423c>] bus_for_each_drv+0x114/0x180
            [<00000000e067feca>] __device_attach+0x1e5/0x2d0
            [<0000000054301fc2>] bus_probe_device+0x126/0x140
            [<00000000aad93b22>] device_add+0x810/0x1130
            [<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
            [<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
            [<00000000ffec4177>] of_i2c_notify+0x100/0x160
        unreferenced object 0xffff88812d3675c8 (size 8):
          comm "python3", pid 349, jiffies 4294741070 (age 95.692s)
          hex dump (first 8 bytes):
            22 00 36 2d 81 88 ff ff                          ".6-....
          backtrace:
            [<0000000068427125>] __kmalloc+0x46/0x1b0
            [<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
            [<000000001d5c9620>] raydium_i2c_initialize.cold+0x223/0x3e4 [raydium_i2c_ts]
            [<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
            [<00000000a310de16>] i2c_device_probe+0x651/0x680
            [<00000000f5a96bf3>] really_probe+0x17c/0x3f0
            [<00000000096ba499>] __driver_probe_device+0xe3/0x170
            [<00000000c5acb4d9>] driver_probe_device+0x49/0x120
            [<00000000264fe082>] __device_attach_driver+0xf7/0x150
            [<00000000f919423c>] bus_for_each_drv+0x114/0x180
            [<00000000e067feca>] __device_attach+0x1e5/0x2d0
            [<0000000054301fc2>] bus_probe_device+0x126/0x140
            [<00000000aad93b22>] device_add+0x810/0x1130
            [<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
            [<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
            [<00000000ffec4177>] of_i2c_notify+0x100/0x160
      
      After BANK_SWITCH command from i2c BUS, no matter success or error
      happened, the tx_buf should be freed.
      
      Fixes: 3b384bd6
      
       ("Input: raydium_ts_i2c - do not split tx transactions")
      Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
      Link: https://lore.kernel.org/r/20221202103412.2120169-1-zhangxiaoxu5@huawei.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53b9b120
    • Jan Dabros's avatar
      char: tpm: Protect tpm_pm_suspend with locks · 571b6bbb
      Jan Dabros authored
      commit 23393c64
      
       upstream.
      
      Currently tpm transactions are executed unconditionally in
      tpm_pm_suspend() function, which may lead to races with other tpm
      accessors in the system.
      
      Specifically, the hw_random tpm driver makes use of tpm_get_random(),
      and this function is called in a loop from a kthread, which means it's
      not frozen alongside userspace, and so can race with the work done
      during system suspend:
      
        tpm tpm0: tpm_transmit: tpm_recv: error -52
        tpm tpm0: invalid TPM_STS.x 0xff, dumping stack for forensics
        CPU: 0 PID: 1 Comm: init Not tainted 6.1.0-rc5+ #135
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-20220807_005459-localhost 04/01/2014
        Call Trace:
         tpm_tis_status.cold+0x19/0x20
         tpm_transmit+0x13b/0x390
         tpm_transmit_cmd+0x20/0x80
         tpm1_pm_suspend+0xa6/0x110
         tpm_pm_suspend+0x53/0x80
         __pnp_bus_suspend+0x35/0xe0
         __device_suspend+0x10f/0x350
      
      Fix this by calling tpm_try_get_ops(), which itself is a wrapper around
      tpm_chip_start(), but takes the appropriate mutex.
      
      Signed-off-by: default avatarJan Dabros <jsd@semihalf.com>
      Reported-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Tested-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Tested-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Link: https://lore.kernel.org/all/c5ba47ef-393f-1fba-30bd-1230d1b4b592@suse.cz/
      Cc: stable@vger.kernel.org
      Fixes: e891db1a
      
       ("tpm: turn on TPM on suspend for TPM 1.x")
      [Jason: reworked commit message, added metadata]
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      571b6bbb
    • Conor Dooley's avatar
      Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend" · f39891cf
      Conor Dooley authored
      [ Upstream commit d9f15a9d ]
      
      This reverts commit 232ccac1.
      
      On the subject of suspend, the RISC-V SBI spec states:
      
        This does not cover whether any given events actually reach the hart or
        not, just what the hart will do if it receives an event. On PolarFire
        SoC, and potentially other SiFive based implementations, events from the
        RISC-V timer do reach a hart during suspend. This is not the case for the
        implementation on the Allwinner D1 - there timer events are not received
        during suspend.
      
      To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
      timer driver - but this has broken both RCU stall detection and timers
      generally on PolarFire SoC and potentially other SiFive based
      implementations.
      
      If an AXI read to the PCIe controller on PolarFire SoC times out, the
      system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
      just locks up without RCU stalling:
      
      	io scheduler mq-deadline registered
      	io scheduler kyber registered
      	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
      	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
      	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: axi read request error
      	microchip-pcie 2000000000.pcie: axi read timeout
      	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
      	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
      	Freeing initrd memory: 7332K
      
      Similarly issues were reported with clock_nanosleep() - with a test app
      that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
      commit in place, the sleep times are rounded up to the next jiffy:
      
      == CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
      Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
      Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
      Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
      Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
      Samples: 521      Samples: 521      Samples: 521      Samples: 521
      
      Fortunately, the D1 has a second timer, which is "currently used in
      preference to the RISC-V/SBI timer driver" so a revert here does not
      hurt operation of D1 in its current form.
      
      Ultimately, a DeviceTree property (or node) will be added to encode the
      behaviour of the timers, but until then revert the addition of
      CLOCK_EVT_FEAT_C3STOP.
      
      Fixes: 232ccac1
      
       ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Acked-by: default avatarSamuel Holland <samuel@sholland.org>
      Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
      Link: https://github.com/riscv-non-isa/riscv-sbi-doc/issues/98/
      Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
      Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f39891cf
    • Vishal Verma's avatar
      ACPI: HMAT: Fix initiator registration for single-initiator systems · a759057a
      Vishal Verma authored
      [ Upstream commit 48d41809
      
       ]
      
      In a system with a single initiator node, and one or more memory-only
      'target' nodes, the memory-only node(s) would fail to register their
      initiator node correctly. i.e. in sysfs:
      
        # ls /sys/devices/system/node/node0/access0/targets/
        node0
      
      Where as the correct behavior should be:
      
        # ls /sys/devices/system/node/node0/access0/targets/
        node0 node1
      
      This happened because hmat_register_target_initiators() uses list_sort()
      to sort the initiator list, but the sort comparision function
      (initiator_cmp()) is overloaded to also set the node mask's bits.
      
      In a system with a single initiator, the list is singular, and list_sort
      elides the comparision helper call. Thus the node mask never gets set,
      and the subsequent search for the best initiator comes up empty.
      
      Add a new helper to consume the sorted initiator list, and generate the
      nodemask, decoupling it from the overloaded initiator_cmp() comparision
      callback. This prevents the singular list corner case naturally, and
      makes the code easier to follow as well.
      
      Cc: <stable@vger.kernel.org>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Liu Shixin <liushixin2@huawei.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Reported-by: default avatarChris Piper <chris.d.piper@intel.com>
      Signed-off-by: default avatarVishal Verma <vishal.l.verma@intel.com>
      Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-2-3712569be691@intel.com
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a759057a
    • Vishal Verma's avatar
      ACPI: HMAT: remove unnecessary variable initialization · da8a794d
      Vishal Verma authored
      [ Upstream commit 14f16d47
      
       ]
      
      In hmat_register_target_initiators(), the variable 'best' gets
      initialized in the outer per-locality-type for loop. The initialization
      just before setting up 'Access 1' targets was unnecessary. Remove it.
      
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Liu Shixin <liushixin2@huawei.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarVishal Verma <vishal.l.verma@intel.com>
      Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-1-3712569be691@intel.com
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Stable-dep-of: 48d41809
      
       ("ACPI: HMAT: Fix initiator registration for single-initiator systems")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      da8a794d
    • Andrew Lunn's avatar
      i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set · 2d16161a
      Andrew Lunn authored
      [ Upstream commit d36678f7 ]
      
      Recent changes to the DMA code has resulting in the IMX driver failing
      I2C transfers when the buffer has been vmalloc. Only perform DMA
      transfers if the message has the I2C_M_DMA_SAFE flag set, indicating
      the client is providing a buffer which is DMA safe.
      
      This is a minimal fix for stable. The I2C core provides helpers to
      allocate a bounce buffer. For a fuller fix the master should make use
      of these helpers.
      
      Fixes: 4544b9f2
      
       ("dma-mapping: Add vmap checks to dma_map_single()")
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Acked-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2d16161a
    • Yuan Can's avatar
      i2c: npcm7xx: Fix error handling in npcm_i2c_init() · 950a05cb
      Yuan Can authored
      [ Upstream commit 145900cf ]
      
      A problem about i2c-npcm7xx create debugfs failed is triggered with the
      following log given:
      
       [  173.827310] debugfs: Directory 'npcm_i2c' with parent '/' already present!
      
      The reason is that npcm_i2c_init() returns platform_driver_register()
      directly without checking its return value, if platform_driver_register()
      failed, it returns without destroy the newly created debugfs, resulting
      the debugfs of npcm_i2c can never be created later.
      
       npcm_i2c_init()
         debugfs_create_dir() # create debugfs directory
         platform_driver_register()
           driver_register()
             bus_add_driver()
               priv = kzalloc(...) # OOM happened
         # return without destroy debugfs directory
      
      Fix by removing debugfs when platform_driver_register() returns error.
      
      Fixes: 56a1485b
      
       ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
      Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
      Reviewed-by: default avatarTali Perry <tali.perry@nuvoton.com>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      950a05cb
    • Lukas Wunner's avatar
      serial: stm32: Deassert Transmit Enable on ->rs485_config() · db3f8da0
      Lukas Wunner authored
      [ Upstream commit adafbbf6 ]
      
      The STM32 USART can control RS-485 Transmit Enable in hardware.  Since
      commit 7df5081c ("serial: stm32: Add RS485 RTS GPIO control"),
      it can alternatively be controlled in software.  That was done to allow
      RS-485 even if the RTS pin is unavailable because it's pinmuxed to a
      different function.
      
      However the commit neglected to deassert Transmit Enable upon invocation
      of the ->rs485_config() callback.  Fix it.
      
      Avoid forward declarations by moving stm32_usart_tx_empty(),
      stm32_usart_rs485_rts_enable() and stm32_usart_rs485_rts_disable()
      further up in the driver.
      
      Fixes: 7df5081c
      
       ("serial: stm32: Add RS485 RTS GPIO control")
      Cc: stable@vger.kernel.org # v5.9+
      Cc: Marek Vasut <marex@denx.de>
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Link: https://lore.kernel.org/r/6059eab35dba394468335ef640df8b0050fd9dbd.1662886616.git.lukas@wunner.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      db3f8da0