From b7eb4289b7410f3984692d47a36c364b6658e7a0 Mon Sep 17 00:00:00 2001
From: Sukecz <222629366+Sukecz@users.noreply.github.com>
Date: Fri, 23 Oct 2026 11:10:29 +0200
Subject: [PATCH] Publish Platina Linux source base for Xiaomi Mi 8 Lite
---
.gitattributes | 2 +
.github/workflows/check.yml | 20 +
.gitignore | 29 +
CHANGELOG.md | 18 +
CONTRIBUTING.md | 24 +
LICENSE | 339 +
LICENSES/BSD-2-Clause | 24 +
LICENSES/GPL-3.0 | 674 +
LICENSES/MIT | 21 +
Makefile | 28 +
NOTICE | 56 +
README.md | 128 +
docs/BUILDING.md | 108 +
docs/DISPLAY.md | 88 +
docs/HARDWARE.md | 19 +
docs/INSTALLATION.md | 145 +
docs/LICENSING.md | 58 +
.../candidate/device-xiaomi-platina/APKBUILD | 59 +
.../device-xiaomi-platina.post-install | 13 +
.../device-xiaomi-platina/deviceinfo | 36 +
.../disable-suspend.start | 11 +
.../device-xiaomi-platina/gpu-firmware.files | 6 +
.../device-xiaomi-platina/kernel-cmdline.conf | 4 +
.../device-xiaomi-platina/modules-initfs | 14 +
.../device-xiaomi-platina/platina-avahi.conf | 16 +
.../platina-networkmanager.conf | 12 +
.../platina-usb-network.start | 5 +
.../platina-usb.nmconnection | 18 +
.../firmware-xiaomi-platina/APKBUILD | 47 +
.../firmware-xiaomi-platina/gen-board-2.py | 36 +
.../0001-platina-enable-display.patch | 192 +
.../0002-panel-simple-td4320.patch | 57 +
.../0004-synaptics-tcm-driver.patch | 735 +
.../0006-platina-battery.patch | 46 +
.../0007-platina-wifi.patch | 45 +
.../0010-ath10k-wcn3990-no-psmode.patch | 88 +
.../0011-ath10k-wcn3990-chanlist-qcacld.patch | 69 +
...12-ath10k-wcn3990-scan-trailing-tlvs.patch | 60 +
...014-ath10k-wcn3990-no-scan-chan-stat.patch | 40 +
.../0015-clk-qcom-sdm660-cpu-osm-driver.patch | 904 +
...arm64-dts-sdm660-platina-osm-cpufreq.patch | 101 +
.../0017-clk-qcom-sdm660-cprh-driver.patch | 352 +
.../0018-platina-audio.patch | 122 +
.../0020-tfa9894-codec.patch | 323 +
.../0021-platina-speaker.patch | 47 +
.../0022-platina-bluetooth.patch | 46 +
.../0024-platina-sec-mi2s-pinctrl.patch | 30 +
.../0025-platina-vibrator.patch | 17 +
.../0026-platina-7.2-wifi-debug.patch | 56 +
.../0027-platina-7.2-audio-machine.patch | 44 +
...0028-platina-touch-regulator-cleanup.patch | 33 +
...29-sdm660-mdp-clock-safe-rate-change.patch | 11 +
.../0030-platina-tianma-panel.patch | 329 +
.../linux-postmarketos-qcom-sdm660/APKBUILD | 155 +
.../config-postmarketos-qcom-sdm660.aarch64 | 8109 ++
.../stable-7.2.10-11.patch | 12005 ++
.../stable-7.2.11-12.patch | 790 +
.../stable-7.2.3-4.patch | 28233 +++++
.../stable-7.2.4-5.patch | 20100 ++++
.../stable-7.2.5-6.patch | 99331 ++++++++++++++++
.../stable-7.2.6-7.patch | 36204 ++++++
.../stable-7.2.7-8.patch | 24521 ++++
.../stable-7.2.8-9.patch | 19942 ++++
.../stable-7.2.9-10.patch | 18102 +++
project/branding/platina-linux-logo.png | Bin 0 -> 630696 bytes
project/branding/provenance.json | 7 +
project/display/platina-panel-dcs.c | 92 +
project/display/tianma-reference.json | 10 +
project/release.json | 7 +
project/sources.lock.json | 29 +
scripts/Audit-Server-Image.sh | 42 +
scripts/Harden-Server-Image.sh | 65 +
scripts/audit-candidate-artifacts.py | 95 +
scripts/build-candidate-images.py | 149 +
scripts/check-public-tree.py | 38 +
scripts/linux-runtime-check.sh | 39 +
scripts/phone-display-session.py | 83 +
scripts/phone-display.py | 166 +
scripts/phone-headless.start | 27 +
scripts/phone-splash.py | 145 +
scripts/platina-release.py | 104 +
scripts/pmbootstrap | 4 +
scripts/prepare-display-frame.py | 44 +
scripts/prepare-firmware.py | 70 +
scripts/project | 5 +
scripts/project.py | 373 +
scripts/scope-initramfs-modules.py | 168 +
tests/test_display_candidate.py | 47 +
tests/test_display_control.py | 91 +
tests/test_display_session.py | 47 +
tests/test_firmware_packaging.py | 53 +
tests/test_initramfs.py | 74 +
tests/test_public_boundary.py | 65 +
tests/test_splash.py | 97 +
tests/test_workflow.py | 177 +
95 files changed, 275710 insertions(+)
create mode 100644 .gitattributes
create mode 100644 .github/workflows/check.yml
create mode 100644 .gitignore
create mode 100644 CHANGELOG.md
create mode 100644 CONTRIBUTING.md
create mode 100644 LICENSE
create mode 100644 LICENSES/BSD-2-Clause
create mode 100644 LICENSES/GPL-3.0
create mode 100644 LICENSES/MIT
create mode 100644 Makefile
create mode 100644 NOTICE
create mode 100644 README.md
create mode 100644 docs/BUILDING.md
create mode 100644 docs/DISPLAY.md
create mode 100644 docs/HARDWARE.md
create mode 100644 docs/INSTALLATION.md
create mode 100644 docs/LICENSING.md
create mode 100644 ports/candidate/device-xiaomi-platina/APKBUILD
create mode 100644 ports/candidate/device-xiaomi-platina/device-xiaomi-platina.post-install
create mode 100644 ports/candidate/device-xiaomi-platina/deviceinfo
create mode 100644 ports/candidate/device-xiaomi-platina/disable-suspend.start
create mode 100644 ports/candidate/device-xiaomi-platina/gpu-firmware.files
create mode 100644 ports/candidate/device-xiaomi-platina/kernel-cmdline.conf
create mode 100644 ports/candidate/device-xiaomi-platina/modules-initfs
create mode 100644 ports/candidate/device-xiaomi-platina/platina-avahi.conf
create mode 100644 ports/candidate/device-xiaomi-platina/platina-networkmanager.conf
create mode 100644 ports/candidate/device-xiaomi-platina/platina-usb-network.start
create mode 100644 ports/candidate/device-xiaomi-platina/platina-usb.nmconnection
create mode 100644 ports/candidate/firmware-xiaomi-platina/APKBUILD
create mode 100644 ports/candidate/firmware-xiaomi-platina/gen-board-2.py
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0001-platina-enable-display.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0002-panel-simple-td4320.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0004-synaptics-tcm-driver.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0006-platina-battery.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0007-platina-wifi.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0010-ath10k-wcn3990-no-psmode.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0011-ath10k-wcn3990-chanlist-qcacld.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0012-ath10k-wcn3990-scan-trailing-tlvs.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0014-ath10k-wcn3990-no-scan-chan-stat.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0015-clk-qcom-sdm660-cpu-osm-driver.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0016-arm64-dts-sdm660-platina-osm-cpufreq.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0017-clk-qcom-sdm660-cprh-driver.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0018-platina-audio.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0020-tfa9894-codec.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0021-platina-speaker.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0022-platina-bluetooth.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0024-platina-sec-mi2s-pinctrl.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0025-platina-vibrator.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0026-platina-7.2-wifi-debug.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0027-platina-7.2-audio-machine.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0028-platina-touch-regulator-cleanup.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0029-sdm660-mdp-clock-safe-rate-change.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/0030-platina-tianma-panel.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/APKBUILD
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/config-postmarketos-qcom-sdm660.aarch64
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.10-11.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.11-12.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.3-4.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.4-5.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.5-6.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.6-7.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.7-8.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.8-9.patch
create mode 100644 ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.9-10.patch
create mode 100644 project/branding/platina-linux-logo.png
create mode 100644 project/branding/provenance.json
create mode 100644 project/display/platina-panel-dcs.c
create mode 100644 project/display/tianma-reference.json
create mode 100644 project/release.json
create mode 100644 project/sources.lock.json
create mode 100755 scripts/Audit-Server-Image.sh
create mode 100755 scripts/Harden-Server-Image.sh
create mode 100644 scripts/audit-candidate-artifacts.py
create mode 100644 scripts/build-candidate-images.py
create mode 100755 scripts/check-public-tree.py
create mode 100755 scripts/linux-runtime-check.sh
create mode 100755 scripts/phone-display-session.py
create mode 100755 scripts/phone-display.py
create mode 100755 scripts/phone-headless.start
create mode 100755 scripts/phone-splash.py
create mode 100755 scripts/platina-release.py
create mode 100755 scripts/pmbootstrap
create mode 100755 scripts/prepare-display-frame.py
create mode 100755 scripts/prepare-firmware.py
create mode 100755 scripts/project
create mode 100755 scripts/project.py
create mode 100644 scripts/scope-initramfs-modules.py
create mode 100644 tests/test_display_candidate.py
create mode 100644 tests/test_display_control.py
create mode 100644 tests/test_display_session.py
create mode 100644 tests/test_firmware_packaging.py
create mode 100644 tests/test_initramfs.py
create mode 100644 tests/test_public_boundary.py
create mode 100644 tests/test_splash.py
create mode 100644 tests/test_workflow.py
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..82ac521
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+* text=auto eol=lf
+*.patch -text -whitespace
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 0000000..0d06fd6
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,20 @@
+name: Offline project checks
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+permissions:
+ contents: read
+concurrency:
+ group: check-${{ github.ref }}
+ cancel-in-progress: true
+jobs:
+ check:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+ with:
+ persist-credentials: false
+ - name: Validate sources and run offline tests
+ run: make check
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..421f946
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,29 @@
+# Private inputs and generated outputs stay local.
+/config/
+/backups/
+/artifacts/
+/work/
+/sources/
+/tools/
+/logs/
+/reports/
+/archive/
+**/AGENTS.md
+**/AGENTS.*
+**/*private*
+**/*secret*
+*.txt
+*.key
+*.pem
+*.env
+.env*
+*.img
+*.apk
+*.elf
+*.bin
+*.zip
+*.tar.gz
+*.nmconnection
+!ports/**/platina-usb.nmconnection
+**/__pycache__/
+*.py[cod]
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..dc554a7
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,18 @@
+# Changelog
+
+## Unreleased — integrated display candidate
+
+- Kernel 7.2.12-r1 adds the Platina Tianma NT36672A panel to the normal driver and device tree.
+- Full kernel and module build passed; the existing-installation boot candidate passed offline checks.
+- Added display on/off/brightness/status, timed images and host-side image preparation.
+- Panel activation, repeated power cycles and power use still require physical testing.
+
+## 0.1.1 — verified integration
+
+- Boot into headless postmarketOS from eMMC with SSH over Wi-Fi or USB networking.
+- Key-only SSH, disabled root/password login, NetworkManager reconnect and OpenRC autostart.
+- Corrected initramfs module indexes and verified normal restarts.
+- Displayed the Platina logo for seven seconds using an explicitly loaded temporary LCD helper.
+- Automatic logo and backlight shutdown were physically confirmed on a Tianma Mi 8 Lite.
+
+The integration version is separate from the kernel and distribution versions.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..1d734c2
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,24 @@
+# Contributing
+
+Start with the [feature status](README.md#feature-status), [build guide](docs/BUILDING.md)
+and [hardware notes](docs/HARDWARE.md). Keep changes small and include the affected
+phone model, panel variant, kernel version and the result you actually tested.
+
+Edit recipes in `ports/candidate/`, update the matching SHA512 entries and package
+revision, and keep `project/sources.lock.json` consistent. Do not edit generated
+checkout files as the only source of a change. Run `make check` before submitting.
+For hardware changes, distinguish a successful build from a real phone test.
+
+Use 🟢 for physically verified functionality, 🟠 for partial support or work awaiting
+hardware testing, and 🔴 for known non-working or unsupported functionality. Update
+the README status table and date when evidence changes. Never promote a driver to
+working simply because it exists in the kernel configuration.
+
+Submit device logs after removing credentials, device identifiers, public keys,
+local addresses and personal paths. Never commit firmware blobs, phone backups,
+private configuration, generated images or agent instructions.
+
+Original contributions are GPL-2.0-only unless a file states another applicable
+license. Preserve third-party copyrights, SPDX identifiers and license notices;
+see [licensing](docs/LICENSING.md). A pull request does not authorize flashing
+someone else's device or changing their network.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..886ce4f
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,339 @@
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/LICENSES/BSD-2-Clause b/LICENSES/BSD-2-Clause
new file mode 100644
index 0000000..4c3a62e
--- /dev/null
+++ b/LICENSES/BSD-2-Clause
@@ -0,0 +1,24 @@
+
+Copyright (c) . All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSES/GPL-3.0 b/LICENSES/GPL-3.0
new file mode 100644
index 0000000..9cecc1d
--- /dev/null
+++ b/LICENSES/GPL-3.0
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/LICENSES/MIT b/LICENSES/MIT
new file mode 100644
index 0000000..fa818a3
--- /dev/null
+++ b/LICENSES/MIT
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright holders are identified in NOTICE and the original source files.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..47edff5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+.PHONY: help check test doctor prepare sync kernel images verify audit version splash
+PROFILE ?= candidate
+OUTPUT ?= candidate-$(shell date +%Y%m%d-%H%M%S)
+help:
+ @./scripts/project --help
+check:
+ @./scripts/project check
+ @python3 scripts/check-public-tree.py
+test:
+ @python3 -m unittest discover -s tests -v
+doctor:
+ @./scripts/project doctor
+prepare:
+ @./scripts/project prepare --profile "$(PROFILE)"
+sync:
+ @./scripts/project sync --profile "$(PROFILE)"
+kernel:
+ @./scripts/project kernel --profile "$(PROFILE)"
+images:
+ @./scripts/project images --output "$(OUTPUT)"
+verify:
+ @./scripts/project verify "$(DIR)"
+audit:
+ @./scripts/project audit "$(DIR)"
+version:
+ @./scripts/platina-release.py show
+splash:
+ @./scripts/platina-release.py build
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..3279328
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,56 @@
+Platina Linux — Xiaomi Mi 8 Lite / platina
+
+Original Platina integration code, documentation and artwork:
+Copyright (C) 2026 Sukecz and Platina contributors.
+Licensed GPL-2.0-only unless a file or the following notice specifies otherwise.
+The original Platina logo is supplied under the same project license; the name
+and logo do not imply endorsement by Xiaomi, Qualcomm, Alpine or postmarketOS.
+
+This repository contains an aggregate of independently licensed components.
+The top-level license does not relicense third-party source or firmware.
+
+Linux / SDM660 kernel changes and configuration
+- Linux contributors and the authors identified in patch headers/source files.
+- https://github.com/sdm660-mainline/linux
+- GPL-2.0-only for the kernel as a whole. Preserve per-file SPDX notices, including
+ GPL-2.0-or-later and compatible dual-license options where present.
+- Linux stable incremental patches originate from kernel.org.
+
+Community Xiaomi Mi 8 Lite port
+- Cesar Tamayo / macosmojave2-alt and credited patch authors.
+- https://github.com/macosmojave2-alt/postmarket-mi8lite-platina
+- Device package data declares MIT; kernel additions declare the applicable GPL
+ licenses. Original maintainer names, copyrights and patch notices are retained.
+- No assumption is made that the community repository has one blanket license.
+- Its firmware board-index helper is not redistributed: the public helper and
+ firmware packaging recipe were written for this repository.
+
+postmarketOS packaging / pmaports
+- postmarketOS contributors; package maintainers remain credited in APKBUILD.
+- https://gitlab.postmarketos.org/postmarketOS/pmaports
+- Packaging material inherited from pmaports retains GPLv3, subject to
+ explicit per-file/package-data notices. The kernel APKBUILD's license field
+ describes the resulting kernel package, not a relicensing of its build recipe.
+- GPLv3 packaging and GPLv2 kernel patches are independent works in an aggregate.
+
+Tianma panel reference
+- Xiaomi / The Linux Foundation / authors of MiCode platina-o-oss.
+- https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/0bb2780bccb9c7e05f0edf5db8860e779179b5f9
+- GPL-2.0-only downstream panel data, with variant values recorded from matching
+ stock panel data. Exact reference hashes are in tianma-reference.json.
+
+External dependencies
+- pmbootstrap (GPLv3), the full kernel and distro packages are fetched
+ from pinned upstream sources during preparation/build. Their original notices
+ and distribution obligations remain applicable; their source trees are not
+ vendored here. Python/Pillow and other host tools keep their own licenses.
+
+Firmware
+- No GPU, Wi-Fi, modem or calibration binaries are included.
+- The firmware APK's license=proprietary describes user-supplied firmware payloads.
+ It does not restrict the GPL-2.0-only recipe/helper source written here.
+- No redistribution permission for those payloads is granted by this repository.
+
+License texts: LICENSE (GPLv2), LICENSES/GPL-3.0, LICENSES/MIT and
+LICENSES/BSD-2-Clause. Upstream copyright and license notices take precedence
+for inherited material. See docs/LICENSING.md for scope and source links.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7559e08
--- /dev/null
+++ b/README.md
@@ -0,0 +1,128 @@
+
+
+
+
+# Platina Linux for Xiaomi Mi 8 Lite
+
+Turn a **Xiaomi Mi 8 Lite (platina, M1808D2TG, Qualcomm Snapdragon 660 / SDM660)**
+into a small **headless Linux server** with Wi-Fi, USB networking and SSH.
+Platina Linux is a device integration built on **postmarketOS and Alpine Linux**,
+using the SDM660 mainline-oriented kernel port. It boots Linux directly from eMMC;
+this is not Android, a container inside Android, or a desktop phone OS.
+
+[](https://github.com/Sukecz/platina-linux/actions/workflows/check.yml)
+[](LICENSE)
+[](docs/HARDWARE.md)
+
+**Verified integration: 0.1.1** · **Kernel: 7.2.12-sdm660** · **Development / early hardware testing**
+
+[Installation](docs/INSTALLATION.md) · [Build from source](docs/BUILDING.md)
+· [Display development](docs/DISPLAY.md) · [Changelog](CHANGELOG.md) · [Licensing](docs/LICENSING.md)
+
+## What it does
+
+- **Real Linux on the phone:** an ARM64 Alpine userspace, package manager and OpenRC services.
+- **Remote administration:** key-only OpenSSH over Wi-Fi or the USB network gadget,
+ with root login and SSH password login disabled.
+- **Reconnect automatically:** NetworkManager restores the configured Wi-Fi connection;
+ USB networking provides a separate local administration path.
+- **Headless by default:** keep the backlight dark while running background services.
+- **Battery and charger operation:** use Wi-Fi while running on the battery or a separate charger.
+- **A useful display foundation:** the existing logo works with a temporary helper;
+ the integrated Tianma driver and commands for brightness, power and custom images
+ are prepared for their next hardware test.
+- **Repeatable development:** pinned source revisions, versioned recipes, checksum
+ verification, offline tests and separate build/export/audit steps.
+
+The goal is a practical always-on server. **Long-term 24/7 stability and sustained
+power balance have not yet been qualified.** Existing phone components keep their
+own support limits; this project does not claim full smartphone functionality.
+
+## Feature status
+
+**Last reviewed: 2026-10-23.** Status describes tests on the maintainer's Mi 8 Lite,
+not a guarantee for every device or panel variant.
+
+🟢 **Verified** · 🟠 **Partial / prepared / awaiting hardware testing** · 🔴 **Not working / unsupported**
+
+| Feature | Status | What has been verified |
+|---|:---:|---|
+| Linux boot from internal eMMC | 🟢 | Installed system, normal startup and repeated restarts |
+| ARM64 userspace and OpenRC | 🟢 | postmarketOS v26.06 / Alpine; services start after boot |
+| SSH over Wi-Fi | 🟢 | Direct LAN login with an administrator key |
+| SSH over USB networking | 🟢 | USB gadget administration on a Linux host |
+| SSH authentication hardening | 🟢 | Password and root SSH login disabled; administrator uses sudo |
+| Wi-Fi reconnect | 🟢 | Reconnect after radio recovery; network configuration persists |
+| USB network recovery | 🟢 | Software disconnect/reconnect and address recovery |
+| mDNS hostname | 🟢 | `platina.local` on a compatible local network |
+| eMMC / ext4 storage | 🟢 | Read/write root filesystem and offline image checks |
+| Battery operation | 🟢 | Wi-Fi administration with data USB physically disconnected |
+| Separate charger operation | 🟢 | Operation and charging confirmed with a suitable charger/cable |
+| Battery / thermal telemetry | 🟢 | Battery information and CPU, GPU and battery temperature readings |
+| Short boot logo | 🟢 | Logo and subsequent backlight shutdown physically confirmed in 0.1.1 |
+| Integrated Tianma NT36672A panel driver | 🟠 | Kernel 7.2.12-r1 built; boot/module candidate audited offline, not yet boot-tested |
+| Display power, brightness and custom images | 🟠 | Control tools and image conversion tested offline; panel power cycles await hardware test |
+| Beszel monitoring | 🟠 | Native monitoring tested separately; optional custom hub/power-chart integration is outside this source base |
+| VPN access from outside the home network | 🟠 | A LAN jump-host route was tested; a real off-site client test is pending |
+| Continuous 48–72-hour uptime | 🟠 | Qualification is pending; shorter successful tests are not a soak test |
+| Sustained charging / wall power use | 🟠 | Short charger tests passed; long-term balance and wall-meter measurements are pending |
+| CPU frequency scaling | 🟠 | Port/platform limitation; no supported full scaling claim |
+| Audio, Bluetooth, camera and SD card | 🟠 | Not functionally qualified by this project |
+| Touchscreen on the tested device | 🔴 | Controller initialization fails; headless administration is unaffected |
+| Mobile calls / mobile data | 🔴 | Outside the supported headless-server feature set |
+| Android apps / Android services | 🔴 | This system replaces the running Android environment |
+| Other Xiaomi Mi 8 models / other phones | 🔴 | This port targets **Mi 8 Lite / platina only** |
+
+The checked-in candidate sources are **kernel 7.2.12-r1 + device 5-r31**. They include
+the new display work; **they are not the same as the physically verified 0.1.1
+installation**. The public firmware recipe is 2-r5, with a newly written packaging
+helper; proprietary firmware payloads are supplied locally by each builder.
+No prebuilt installation images or binary firmware are published here.
+
+## Hardware
+
+**Tested:** Xiaomi Mi 8 Lite, model **M1808D2TG**, codename **platina**, Snapdragon 660,
+4 GB RAM / 64 GB eMMC, **Tianma NT36672A 1080 × 2280 LCD**.
+Other RAM/storage variants and BOE panel variants are not qualified. Check the
+codename and actual panel before using the display candidate. The Mi 8, Mi 8 SE,
+Mi 8 Pro and Mi 8 Lite are different devices.
+
+## Getting started
+
+You need an unlocked bootloader, a Linux build host, your own SSH public key,
+matching stock firmware inputs and a recovery plan. **Initial installation erases
+Android user data.** Follow the [installation guide](docs/INSTALLATION.md), including
+its backup, device identification and RAM-test stages before a permanent flash.
+
+```sh
+git clone https://github.com/Sukecz/platina-linux.git
+cd platina-linux
+make doctor
+make check
+```
+
+The public tree contains the current port recipes, build and audit tools,
+display sources, regression tests and documentation. Configuration, firmware,
+phone backups and generated images remain local.
+
+## Updating this project
+
+The table above is maintained alongside code changes. A successful compilation
+means **built**, an offline audit means **audited**, and a physical phone test means
+**hardware verified**. These states are recorded separately.
+
+Platina's integration version lives in `project/release.json`; it is independent
+of the Linux and Alpine version numbers. The integrated display candidate will
+become a new integration version only after installation and hardware validation.
+
+## Credits and license
+
+Built on [postmarketOS](https://postmarketos.org/), [Alpine Linux](https://alpinelinux.org/),
+[SDM660 mainline](https://github.com/sdm660-mainline/linux) and the
+[community Mi 8 Lite port](https://github.com/macosmojave2-alt/postmarket-mi8lite-platina).
+The panel sequence is based on Xiaomi's published kernel sources and matching
+stock panel data. Original authors and source notices are retained.
+
+**Original Platina contributions: GPL-2.0-only.** Third-party code retains its
+own licenses; firmware remains proprietary and is not included. See
+[LICENSE](LICENSE), [NOTICE](NOTICE) and the [licensing notes](docs/LICENSING.md).
diff --git a/docs/BUILDING.md b/docs/BUILDING.md
new file mode 100644
index 0000000..0b2f9f9
--- /dev/null
+++ b/docs/BUILDING.md
@@ -0,0 +1,108 @@
+# Building Platina Linux
+
+This is a source-only development port. The candidate kernel builds, but the new
+integrated Tianma display still needs its first successful physical boot test.
+An image built here is a candidate, not a ready-made stable release.
+
+## Build host
+
+Use Linux, Python 3.11+, Git, Make, a POSIX shell and sudo. The build creates
+pmbootstrap chroots and needs Internet access, substantial disk space and time.
+It uses two jobs at nice level 10. No host services or phones are restarted.
+
+On Debian/Ubuntu, typical host tools are:
+
+```sh
+sudo apt install git python3 make sudo openssh-client e2fsprogs util-linux kmod mtools fastboot
+# Optional: only needed for make splash / custom image conversion.
+sudo apt install python3-pil fonts-dejavu-core
+```
+
+`make doctor` reports missing core tools without installing them. Kernel compilers
+and package dependencies are installed inside the build chroots by pmbootstrap.
+Python's standard library is enough for the basic offline test suite; image
+conversion uses Pillow on the build host.
+
+## Personal build inputs
+
+```sh
+mkdir -p config
+cp /PATH/TO/YOUR/ADMINISTRATOR-KEY.pub config/admin-builder.pub
+```
+
+Use a dedicated key if appropriate. Only its **public** half enters the image.
+The user account is `server`, with passwordless sudo for administration. Password
+and root SSH login are disabled. Keep the private key outside this repository.
+
+Firmware is not distributed here. From a legally obtained matching stock ROM,
+extract `images/NON-HLOS.bin` without running any ROM scripts, and obtain the
+matching `a512_zap.elf` GPU firmware from your own vendor firmware. The pinned
+reference is the Mi 8 Lite global stock firmware V12.0.3.0.QDTMIXM; other inputs
+are rejected if their hashes differ.
+
+The recipe expects three local inputs: `a512_zap.elf`,
+`firmware-xiaomi-platina-bdwlan.tar.gz` and `firmware-xiaomi-platina-modem.tar.gz`.
+The helper reads the FAT firmware image with mtools, creates deterministic
+archives and checks all three against the recipe before writing them:
+
+```sh
+python3 scripts/prepare-firmware.py \
+ --modem-image /PATH/TO/NON-HLOS.bin \
+ --gpu-firmware /PATH/TO/a512_zap.elf
+```
+
+The output is `config/firmware/`, which is ignored by Git. Missing matching
+firmware is a build prerequisite; this repository does not silently substitute
+another phone's calibration, modem firmware or administrator key.
+
+## Prepare and compile
+
+```sh
+make check
+./scripts/project prepare --profile candidate --fetch
+make kernel PROFILE=candidate
+make images OUTPUT=candidate-local
+make verify DIR=artifacts/candidate-local
+make audit DIR=artifacts/candidate-local
+```
+
+Preparation pins pmbootstrap, pmaports and its channel table from
+`project/sources.lock.json`. It creates a new managed checkout and refuses to
+overwrite one. After changing a versioned recipe, run `make sync` before rebuilding.
+Checksum checks parse APKBUILD as text rather than executing its shell on the host.
+
+The image contains the public key and proprietary firmware you provided. It is
+therefore **your local installation image**, not automatically a public artifact.
+The builder stops pmbootstrap mounts before copying/hashing filesystem images.
+Source revisions are pinned, but external Alpine repositories/toolchain packages
+are not fully frozen; bit-for-bit reproducible full builds are not promised.
+
+## Scope initramfs module indexes
+
+The mkinitfs version used by this port can copy full-rootfs module indexes into
+an initramfs containing only some modules. Before booting or flashing, regenerate
+indexes for the modules that are actually included:
+
+```sh
+python3 scripts/scope-initramfs-modules.py artifacts/candidate-local/boot.img \
+ --release 7.2.12-sdm660 --output artifacts/candidate-local-scoped
+make verify DIR=artifacts/candidate-local-scoped
+```
+
+Use **candidate-local-scoped/boot.img** with **candidate-local/xiaomi-platina.img**.
+The scoping tool preserves the kernel, DTB and rootfs command line; it does not
+create a second root filesystem and does not flash anything.
+
+Exported files include boot.img, xiaomi-platina.img, initramfs, kernel and DTB.
+Keep the manifest and corresponding APKs for your own rollback records.
+
+## Optional display assets
+
+```sh
+make splash
+python3 scripts/prepare-display-frame.py your-image.png --output artifacts/custom-frame
+```
+
+The original logo is preserved; the integration version is added during rendering.
+These commands create local bundles. `make images` does not yet install the
+versioned splash bundle automatically; see [display setup](DISPLAY.md).
diff --git a/docs/DISPLAY.md b/docs/DISPLAY.md
new file mode 100644
index 0000000..d2d7985
--- /dev/null
+++ b/docs/DISPLAY.md
@@ -0,0 +1,88 @@
+# Platina display support
+
+The tested Mi 8 Lite has a **Tianma NT36672A 1080 × 2280** panel. Display support
+has two separate states:
+
+| State | Status |
+|---|---|
+| Integration 0.1.1 logo with a temporary LCD power/wake helper | 🟢 Physically verified, including automatic start and subsequent backlight shutdown |
+| Integrated driver / DT in kernel 7.2.12-r1 | 🟠 Compiled and audited offline; physical boot and power cycles pending |
+
+The candidate is in `ports/candidate/linux-postmarketos-qcom-sdm660/0030-platina-tianma-panel.patch`.
+It adds the panel-specific command sequence, correct regulator names, reset timing,
+DT binding and initialization-error cleanup to the NT36672A driver. The stock
+command sequence is recorded in `project/display/tianma-reference.json` and
+compared by offline tests. This is not a verified BOE TD4320 configuration.
+
+## Optional controller setup
+
+After testing a successful boot with the integrated driver, install the renderer
+and controller on **your phone**. The files listed below are source files from
+this repository; transfer them using your own authenticated SSH connection.
+
+```sh
+# On the phone, from the directory to which you transferred these scripts:
+sudo install -m755 phone-splash.py /usr/local/sbin/platina-splash
+sudo install -m755 phone-display.py /usr/local/sbin/platina-display
+```
+
+For the logo, run `make splash` on the build host. Transfer its three runtime files
+`release.json`, `version` and `frame.bgrx.gz` from `artifacts/platina-linux-0.1.1/`
+into a new phone directory `/usr/local/share/platina/releases/0.1.1/`, then create
+`/usr/local/share/platina/current` pointing to `releases/0.1.1`. If updating an
+existing setup, back up its assets/hook first and use a new versioned directory.
+The phone renderer uses Python's standard library, without Pillow or a desktop.
+
+```sh
+sudo platina-display status
+sudo platina-display on --brightness 25
+sudo platina-display brightness --brightness 10
+sudo platina-display off
+sudo platina-display show --seconds 7
+sudo platina-display show --directory /PATH/TO/CUSTOM-FRAME --seconds 60
+```
+
+`status` only reads sysfs. Changes require root and the actual bound Tianma driver;
+the tool refuses the old panel-simple driver or a simultaneously loaded temporary
+DCS helper. `on` keeps the current framebuffer visible until `off` is requested;
+it may show the console. `show` is bounded to one hour and turns the panel off on
+completion, ordinary error, SIGTERM or Ctrl-C. Display operations share the splash
+lock. An external SIGKILL cannot run Python cleanup.
+
+`off` requests `FB_BLANK_POWERDOWN` through DRM after clearing the backlight.
+A brightness value of zero alone is not proof that the LCD rails are powered off.
+Regulator counts and actual repeated wake behavior must be checked on the device.
+
+Prepare another image on the build host:
+
+```sh
+python3 scripts/prepare-display-frame.py picture.png --output artifacts/custom-frame
+```
+
+The converter preserves aspect ratio, adds black padding and produces a preview,
+BGRX framebuffer data and a checksum manifest. Transfer the generated frame bundle
+separately; this command does not contact the phone.
+
+## Boot logo
+
+The optional `phone-headless.start` hook starts the logo in the background for
+seven seconds, with a timeout and cleanup. On the integrated panel it selects the
+new controller. On the old boot it selects the temporary session only when that
+kernel-specific module was explicitly installed. Do not install the old helper
+blindly, or auto-load it alongside the integrated driver.
+
+Only install the hook after manual rendering and powerdown have worked. The
+current clean-image builder keeps the backlight dark and does not automatically
+install a generated splash bundle. SSH must remain independent of splash success.
+
+## Hardware acceptance
+
+Confirm the picture physically, test several brightness values and at least ten
+off/on cycles, inspect DRM/DCS/kernel errors and compare regulator state before
+and after. Verify normal reboot, logo timeout, SSH and temperature/charging.
+Measured power savings are a separate result; they have not been established.
+
+Do not live-unbind/rebind the MSM DRM stack: a previous attempt caused an Oops.
+For future dashboards the same frame format can carry status screens. Animations
+or interactive UIs can later use standard DRM/KMS or a Wayland client after the
+panel lifecycle works reliably. Touchscreen support remains a separate porting task.
diff --git a/docs/HARDWARE.md b/docs/HARDWARE.md
new file mode 100644
index 0000000..4ddf6f9
--- /dev/null
+++ b/docs/HARDWARE.md
@@ -0,0 +1,19 @@
+# Xiaomi Mi 8 Lite / platina hardware
+
+The target is **Xiaomi Mi 8 Lite**, codename **platina**, Qualcomm **Snapdragon 660
+(SDM660)**, ARM64. Maintainer tests used model **M1808D2TG**, 4 GB RAM and 64 GB eMMC.
+Verify your own device; its marketing name alone does not identify the board.
+
+The tested LCD is **Tianma NT36672A**, 1080 × 2280. The original community port
+selected a BOE TD4320 descriptor. Those panels are not interchangeable merely
+because their resolution matches. The current source candidate changes the DT
+to the tested Tianma variant. BOE devices require their own configuration and test.
+
+The device package uses USB network gadget mode and NetworkManager. Charging
+behavior depends on the cable, host port and charger. Test the chosen supply
+under the intended load; a visible charge indicator is not a sustained power test.
+The phone has to stay awake for this headless-server use case.
+
+Before repurposing an older phone, inspect its battery and check its storage
+health. Keep a recovery route through the unlocked bootloader and Fastboot.
+See the [feature matrix](../README.md#feature-status) for actual support status.
diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md
new file mode 100644
index 0000000..44d019b
--- /dev/null
+++ b/docs/INSTALLATION.md
@@ -0,0 +1,145 @@
+# Install Linux on Xiaomi Mi 8 Lite (platina)
+
+**Development port.** The maintainer's existing installation boots and provides
+SSH, but the checked-in integrated Tianma display candidate has not yet passed
+its physical boot/power-cycle test. There is no supported prebuilt installer.
+Build your own images using [BUILDING.md](BUILDING.md).
+
+These steps are for a **fresh installation** on **Mi 8 Lite / platina**.
+Flashing `userdata` destroys Android apps and personal data. For an existing Linux
+installation, do not follow the userdata step: keep its filesystem UUID and use
+a separately prepared boot/module update with a current backup.
+
+## 1. Prepare recovery and identify the device
+
+- Back up your Android data, the original boot/vbmeta images and the phone-specific
+ partitions needed for recovery, using a method you have actually verified.
+ Fastboot is not a universal partition-backup tool.
+- Retain the matching stock ROM and a working host-side Fastboot recovery path.
+ Backups may contain identity/calibration data; keep them private.
+- Unlock the bootloader through Xiaomi's supported process before installing Linux.
+ Unlocking itself can erase data. This project supplies no bootloader bypass.
+- Check the **platina** codename and **Tianma NT36672A** panel variant.
+ See [hardware](HARDWARE.md). Do not use the Tianma candidate on an unverified BOE unit.
+- Use reliable USB power and a charged, healthy battery. Keep physical access
+ throughout the first boot and recovery test.
+
+Enter Fastboot with **Volume Down + Power** from power-off. With only the intended
+phone attached, inspect it before any write:
+
+```sh
+fastboot devices
+fastboot getvar product
+fastboot oem device-info
+fastboot getvar partition-size:boot
+fastboot getvar partition-size:userdata
+```
+
+Confirm product `platina`, unlocked status and sufficient partition sizes.
+The tested Fastboot boot-image limit was `0x3ffc000` bytes. Recheck your device;
+a full raw backup of a partition can exceed the maximum accepted image length.
+
+General device/mode information is also in the
+[postmarketOS Mi 8 Lite wiki](https://wiki.postmarketos.org/wiki/Xiaomi_Mi_8_Lite_(xiaomi-platina)).
+That page may describe a different kernel/port; use this repository's feature
+matrix for this integration's support status.
+
+## 2. Build and verify your own image pair
+
+Follow BUILDING.md through the offline audit and module-index scoping stages.
+The examples below assume these files exist:
+
+```sh
+ROOTFS=artifacts/candidate-local/xiaomi-platina.img
+BOOT=artifacts/candidate-local-scoped/boot.img
+make verify DIR=artifacts/candidate-local
+make verify DIR=artifacts/candidate-local-scoped
+```
+
+The boot command line must refer to the UUID of that root filesystem. Do not mix
+a newly generated clean rootfs with a boot prepared for another installation.
+All exported modules must match the kernel. Archive your build manifest and APKs.
+
+## 3. Fresh rootfs, vbmeta and RAM boot
+
+**The following commands write to the phone. Run them only after completing the
+backup, identification and offline checks.** A RAM boot avoids a permanent kernel
+write, but it does not undo a preceding userdata or vbmeta write.
+
+```sh
+# Permanently replaces Android user data with your local Linux root filesystem.
+fastboot -S 128M flash userdata "$ROOTFS"
+# Generates and flashes AVB metadata with verification disabled for this port.
+./scripts/pmbootstrap flasher flash_vbmeta
+# Test the new kernel/initramfs in RAM before writing the boot partition.
+fastboot boot "$BOOT"
+```
+
+Stop on any error. Do not flash GPT, bootloader, recovery, persist or modem identity
+partitions. Leave the bootloader unlocked. The Fastboot `OKAY` message alone
+proves neither that Linux booted nor that the display works.
+
+If USB transfer hangs, investigate the host/cable/Fastboot transport before retrying.
+Do not replace a failed RAM test with a blind permanent flash. Never unbind/rebind
+MSM DRM on a live system as a substitute for booting the correct device tree.
+
+## 4. Establish SSH and Wi-Fi
+
+The phone's USB gadget address is **172.16.42.1/24**, user **server**. Configure the
+host side of the identified USB network interface for **172.16.42.2/24**, without
+replacing the host's normal default route. Some desktops do not automatically
+choose that address. Use your Linux host's normal network manager and configure
+only the interface belonging to this phone.
+
+Verify the phone's SSH host key through a trusted local console or a verified
+recovery session before recording it in known_hosts. `ssh-keyscan` by itself does
+not authenticate the device. Keep strict host-key checking enabled.
+
+```sh
+ssh -i /PATH/TO/YOUR/PRIVATE-KEY -o StrictHostKeyChecking=yes server@172.16.42.1
+```
+
+The phone's dedicated administrator has passwordless sudo; password and root SSH
+login are disabled. Add your Wi-Fi profile interactively on the phone, so the
+passphrase does not become a repository file or shell argument:
+
+```sh
+sudo nmcli --ask device wifi connect YOUR_WIFI_SSID
+ip -brief address show wlan0
+```
+
+Use its DHCP address, or `platina.local` where mDNS works. Test a second SSH
+session over Wi-Fi before unplugging USB. USB administration does not by itself
+provide Internet access: the host must explicitly share a connection if needed.
+No router, firewall, forwarding or VPN changes are made by the build tools.
+
+## 5. Validate, then install the boot image
+
+Verify `uname -r`, the root filesystem, OpenRC services, SSH, Wi-Fi reconnect,
+charging/temperature and kernel logs. For the new display candidate, require a
+visible correct picture and repeated on/off tests; see [DISPLAY.md](DISPLAY.md).
+Retain your stock boot and a way to return to Fastboot throughout.
+
+When the RAM boot is successful, return physically to Fastboot and install the
+**same tested** boot image:
+
+```sh
+fastboot flash boot "$BOOT"
+fastboot reboot
+```
+
+Confirm a normal eMMC boot and automatic service startup, then test a separate
+charger with Wi-Fi. Test long-term stability and charging under the intended
+workload before relying on it as a 24/7 server.
+
+## Recovery and future updates
+
+On a failed candidate, return to Fastboot and restore the verified boot image for
+the matching installation and module tree. A stock Android boot alone does not
+restore Android userdata that has already been replaced. Follow your stock-ROM
+recovery procedure if reverting the whole installation.
+
+For later kernel updates, preserve rootfs UUID, pair kernel/modules/initramfs,
+back up the active module tree and configuration, and check any package hooks
+before installation. Do not automatically install a new kernel from a rolling
+repository. Build, offline audit, RAM test and permanent flash are separate steps.
diff --git a/docs/LICENSING.md b/docs/LICENSING.md
new file mode 100644
index 0000000..93973e5
--- /dev/null
+++ b/docs/LICENSING.md
@@ -0,0 +1,58 @@
+# Licensing
+
+## Decision
+
+**GPL-2.0-only** is the license for original Platina integration contributions,
+including original scripts, tests, documentation and the supplied logo, unless
+an individual file specifies otherwise. See [LICENSE](../LICENSE) and [NOTICE](../NOTICE).
+
+The main reason is practical: this is a Linux kernel/device port, and its kernel
+patches should remain usable under Linux's GPLv2 terms. This does not mean that
+all software running on the phone has to use GPLv2.
+
+| Option considered | Fit for this project |
+|---|---|
+| MIT | Good for permissive standalone tools; would not remove inherited kernel/copyleft requirements |
+| Apache-2.0 | Explicit patent terms, but not compatible with GPL-2.0-only kernel combinations |
+| GPL-3.0-only | Useful for many projects; cannot simply replace Linux's GPL-2.0-only terms |
+| **GPL-2.0-only** | **Chosen for original integration work and kernel changes; matches the kernel's licensing baseline** |
+
+Sources: [Linux kernel licensing rules](https://docs.kernel.org/process/license-rules.html),
+[GNU license compatibility](https://www.gnu.org/licenses/license-list.html), and
+[Apache's GPL compatibility explanation](https://apache.org/licenses/GPL-compatibility.html).
+
+## Third-party material keeps its license
+
+This source repository is an aggregate, not a claim that all included components
+are one GPLv2 program. Existing copyrights and SPDX notices are retained.
+
+- **Kernel patches/configuration:** kernel GPLv2 terms and relevant per-file SPDX
+ identifiers. Some files allow later GPL versions or have compatible dual licenses.
+- **Inherited pmaports packaging:** GPLv3 where the upstream packaging
+ license applies. The package's `license=` field describes its installed payload;
+ it is not by itself a license grant for every packaging script.
+- **Device data:** MIT as declared by the community device package, with original
+ author/maintainer attribution retained. Applicable kernel DT notices still apply.
+- **Public firmware recipe and board-index helper:** newly written GPL-2.0-only
+ source. The public firmware revision is 2-r5 to distinguish this packaging change.
+- **Firmware binaries:** proprietary and absent from this Git repository. Each
+ builder supplies matching inputs locally and must respect their own usage rights.
+- **External toolchains/packages:** retain their own licenses; the source repository
+ does not vendor the full distro or claim ownership of those projects.
+
+The upstream community repository has no blanket top-level LICENSE at the time
+of this review. We therefore preserve its explicit kernel/device notices and do
+not redistribute its firmware helper under an invented blanket license.
+Full attribution and license texts are in NOTICE and LICENSES/.
+
+## Source publication versus image publication
+
+This initial public repository contains source and the project logo. It does not
+publish APKs, prebuilt disk/boot images, stock ROMs or device calibration backups.
+Building a local image does not automatically grant permission to redistribute
+its proprietary firmware, nor make a personalized SSH key/configuration public.
+
+Any future binary release requires a separate component/source and firmware-rights
+review. A GPL-covered kernel binary must be accompanied by the corresponding
+source and notices under the applicable license terms. Existing third-party
+rights are preserved; the repository's project license cannot replace them.
diff --git a/ports/candidate/device-xiaomi-platina/APKBUILD b/ports/candidate/device-xiaomi-platina/APKBUILD
new file mode 100644
index 0000000..3fe04c0
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/APKBUILD
@@ -0,0 +1,59 @@
+# Local experimental headless adaptation; see project docs/SOURCE-AUDIT.md.
+maintainer="Platina local project "
+pkgname=device-xiaomi-platina
+pkgdesc="Xiaomi Mi 8 Lite - experimental headless server"
+pkgver=5
+pkgrel=31
+url="https://github.com/macosmojave2-alt/postmarket-mi8lite-platina"
+license="MIT"
+arch="aarch64"
+options="!check !archcheck"
+depends="
+ firmware-qcom-adreno-a530
+ firmware-xiaomi-platina
+ linux-firmware-qca
+ linux-postmarketos-qcom-sdm660
+ mkbootimg
+ msm-firmware-loader
+ postmarketos-base
+ chrony-openrc
+ pam-rundir
+ avahi
+ avahi-openrc
+ networkmanager-openrc
+ networkmanager-cli
+ networkmanager-wifi
+ wireless-regdb
+ dbus-openrc
+ postmarketos-usb-moded-openrc
+ postmarketos-usb-moded-default-profile-developer
+ tzdata
+ soc-qcom-sdm660
+ soc-qcom-sdm660-rproc
+"
+makedepends="devicepkg-dev"
+install="$pkgname.post-install"
+source="deviceinfo kernel-cmdline.conf modules-initfs disable-suspend.start gpu-firmware.files platina-networkmanager.conf platina-usb.nmconnection platina-usb-network.start platina-avahi.conf"
+build() {
+ devicepkg_build $startdir $pkgname
+}
+package() {
+ devicepkg_package $startdir $pkgname
+ install -Dm755 "$srcdir/disable-suspend.start" "$pkgdir/etc/local.d/disable-suspend.start"
+ install -Dm644 "$srcdir/gpu-firmware.files" "$pkgdir/usr/share/mkinitfs/files/00-platina-gpu-firmware.files"
+ install -Dm644 "$srcdir/platina-networkmanager.conf" "$pkgdir/etc/NetworkManager/conf.d/30-platina-wifi.conf"
+ install -Dm600 "$srcdir/platina-usb.nmconnection" "$pkgdir/etc/NetworkManager/system-connections/platina-usb.nmconnection"
+ install -Dm755 "$srcdir/platina-usb-network.start" "$pkgdir/etc/local.d/platina-usb-network.start"
+ install -Dm644 "$srcdir/platina-avahi.conf" "$pkgdir/usr/share/platina/avahi-daemon.conf"
+}
+sha512sums="
+c692b8c5935011955892071ab52b468c17ef186f21a5c2c7927453b2ae2ab8e80bb9d433c96a4e309a1bcec644c86adb9f0781c3fa02a39979d5880af464fb3d deviceinfo
+3221917497d75c8ee6c151f2ed01a4dfdd3fe4e6a691b693b963bfb57fda9e1b482c50b77efa55a6dc4145ba08e9685e23482ddd488128983d79924f677f4eeb kernel-cmdline.conf
+3901ca92054e15136091e5111feb5a33ca4fb7544020b9df421974409cab0d04989054c209215cb5e4a58da3ac142ebd47049fa75eb922ca6630e6b8297e0bad modules-initfs
+53d9813f7537bc7d6f2ff7a623ed36c6f1243f3b66bbbc1ac2ebd55897a638e7867e447bea3b0353500d6b1a9a0142e18c1a708f3ff968f8970beedc1175279a disable-suspend.start
+afc76d9275689bfa47065a14a2f9b0322576d5c269fa46663f4dab5b7299707450f4bbd7e0e6ea926b6afc7b73642dd33bed449d7c0999de53f48d2300d75f8c gpu-firmware.files
+29dacca516ae2a0aea7e1c523131e120a13dca330af7f52b210971cf3613fe8a9267fd100499df8cf64478228f383c69f915092930468e2b3fb95271aa3512c2 platina-networkmanager.conf
+dd56237bcc3e6c3219310dca6358b8f2269e40534f2670b0fdef27d5db3dad7d7742a24b24b6478a5e12689c60ab9353abf1713e5af237c07d4617e15c47da12 platina-usb.nmconnection
+82272323ff6feb710f32ff34787cd85ccc189c6a8e77bed0de4dd0855f997939b1fd5952c6ab416be59e77a9f5b96bad67417737ae4361af9365d85f46ea29cc platina-usb-network.start
+c620fb012b2b24ab25929952af2289caaaea6ac96a080b34b48e640c1d39c5662e1cd77bd26f89a864c127e514401243a41d6b7e53c8004c35cec045949f527f platina-avahi.conf
+"
diff --git a/ports/candidate/device-xiaomi-platina/device-xiaomi-platina.post-install b/ports/candidate/device-xiaomi-platina/device-xiaomi-platina.post-install
new file mode 100644
index 0000000..309b44f
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/device-xiaomi-platina.post-install
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+if [ -f /usr/share/platina/avahi-daemon.conf ]; then
+ mkdir -p /etc/avahi
+ cp /usr/share/platina/avahi-daemon.conf /etc/avahi/avahi-daemon.conf
+ chmod 644 /etc/avahi/avahi-daemon.conf
+fi
+# Headless/OpenRC image: enable network and time services without the UI meta package.
+if command -v rc-update >/dev/null 2>&1; then
+ for service in local networkmanager usb-moded chronyd avahi-daemon; do
+ rc-update add "$service" default
+ done
+fi
diff --git a/ports/candidate/device-xiaomi-platina/deviceinfo b/ports/candidate/device-xiaomi-platina/deviceinfo
new file mode 100644
index 0000000..40b4ebe
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/deviceinfo
@@ -0,0 +1,36 @@
+# Reference:
+# Please use double quotes only. You can source this file in shell
+# scripts.
+
+deviceinfo_format_version="0"
+deviceinfo_name="Xiaomi Mi 8 Lite"
+deviceinfo_manufacturer="Xiaomi"
+deviceinfo_codename="xiaomi-platina"
+deviceinfo_year="2018"
+deviceinfo_dtb="qcom/sdm660-xiaomi-platina"
+deviceinfo_append_dtb="true"
+deviceinfo_arch="aarch64"
+deviceinfo_drm="true"
+
+# Device related
+deviceinfo_chassis="handset"
+deviceinfo_external_storage="true"
+deviceinfo_screen_width="1080"
+deviceinfo_screen_height="2280"
+
+# Bootloader related
+deviceinfo_flash_method="fastboot"
+deviceinfo_flash_fastboot_partition_vbmeta="vbmeta"
+deviceinfo_generate_bootimg="true"
+deviceinfo_flash_sparse="true"
+deviceinfo_flash_pagesize="4096"
+deviceinfo_flash_offset_base="0x00000000"
+deviceinfo_flash_offset_kernel="0x00008000"
+deviceinfo_flash_offset_ramdisk="0x01000000"
+deviceinfo_flash_offset_second="0x00f00000"
+deviceinfo_flash_offset_tags="0x00000100"
+
+# Xiaomi Communications Co., Ltd.
+deviceinfo_usb_idVendor="0x2717"
+# Mi/Redmi series (RNDIS)
+deviceinfo_usb_idProduct="0xff80"
diff --git a/ports/candidate/device-xiaomi-platina/disable-suspend.start b/ports/candidate/device-xiaomi-platina/disable-suspend.start
new file mode 100644
index 0000000..80cdc57
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/disable-suspend.start
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Mi 8 Lite (platina): evita que el sistema entre en suspend y tumbe el USB/SSH.
+# Se ejecuta en cada arranque (local.d de OpenRC).
+if [ -w /sys/power/state ]; then
+ chmod 000 /sys/power/state 2>/dev/null
+fi
+# Desactivar autosuspend de todos los dispositivos USB por si acaso.
+for f in /sys/bus/usb/devices/*/power/control; do
+ [ -w "$f" ] && echo on > "$f" 2>/dev/null
+done
+exit 0
diff --git a/ports/candidate/device-xiaomi-platina/gpu-firmware.files b/ports/candidate/device-xiaomi-platina/gpu-firmware.files
new file mode 100644
index 0000000..7c3b0c3
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/gpu-firmware.files
@@ -0,0 +1,6 @@
+/lib/firmware/qcom/a530_pm4.fw
+/lib/firmware/qcom/a530_pfp.fw
+/lib/firmware/qcom/a530v3_gpmu.fw2
+/lib/firmware/postmarketos/a512_zap.mbn
+/lib/firmware/regulatory.db
+/lib/firmware/regulatory.db.p7s
diff --git a/ports/candidate/device-xiaomi-platina/kernel-cmdline.conf b/ports/candidate/device-xiaomi-platina/kernel-cmdline.conf
new file mode 100644
index 0000000..84d4a98
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/kernel-cmdline.conf
@@ -0,0 +1,4 @@
+msm.prefer_mdp5=false
+pd_ignore_unused
+clk_ignore_unused
+usbcore.autosuspend=-1
diff --git a/ports/candidate/device-xiaomi-platina/modules-initfs b/ports/candidate/device-xiaomi-platina/modules-initfs
new file mode 100644
index 0000000..e2b9baa
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/modules-initfs
@@ -0,0 +1,14 @@
+msm
+pmi8998_fg
+qcom_smbx
+qcom-spmi-rradc
+qcom_pil_info
+ath10k_core
+snd_soc_core
+qcom_vadc_common
+snd_soc_qcom_common
+btqca
+qcom_q6v5
+qcom_common
+snd_soc_qcom_sdw
+btrtl
diff --git a/ports/candidate/device-xiaomi-platina/platina-avahi.conf b/ports/candidate/device-xiaomi-platina/platina-avahi.conf
new file mode 100644
index 0000000..ab48b8e
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/platina-avahi.conf
@@ -0,0 +1,16 @@
+[server]
+host-name=platina
+domain-name=local
+use-ipv4=yes
+use-ipv6=no
+allow-interfaces=wlan0
+
+[wide-area]
+enable-wide-area=no
+
+[publish]
+publish-hinfo=no
+publish-workstation=no
+
+[reflector]
+enable-reflector=no
diff --git a/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf b/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf
new file mode 100644
index 0000000..46243ce
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf
@@ -0,0 +1,12 @@
+[main]
+# USB routing uses static DNS. Do not replace it when Wi-Fi is disconnected.
+dns=none
+
+[device-platina-wifi]
+match-device=interface-name:wlan0
+managed=1
+wifi.scan-rand-mac-address=no
+
+[device-platina-usb]
+match-device=interface-name:usb0
+managed=1
diff --git a/ports/candidate/device-xiaomi-platina/platina-usb-network.start b/ports/candidate/device-xiaomi-platina/platina-usb-network.start
new file mode 100644
index 0000000..56511fb
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/platina-usb-network.start
@@ -0,0 +1,5 @@
+#!/bin/sh
+# NetworkManager autoconnect also handles USB appearing after boot or reconnect.
+# Do not block boot when the cable is absent.
+nmcli --wait 0 connection up platina-usb >/dev/null 2>&1 || true
+exit 0
diff --git a/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection b/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection
new file mode 100644
index 0000000..66de955
--- /dev/null
+++ b/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection
@@ -0,0 +1,18 @@
+[connection]
+id=platina-usb
+uuid=e6cc4c76-9736-4bd4-b92f-37d89bcd8348
+type=ethernet
+interface-name=usb0
+autoconnect=true
+autoconnect-retries=0
+
+[ethernet]
+
+[ipv4]
+method=manual
+address1=172.16.42.1/24,172.16.42.2
+route-metric=100
+ignore-auto-dns=true
+
+[ipv6]
+method=disabled
diff --git a/ports/candidate/firmware-xiaomi-platina/APKBUILD b/ports/candidate/firmware-xiaomi-platina/APKBUILD
new file mode 100644
index 0000000..f13e5d3
--- /dev/null
+++ b/ports/candidate/firmware-xiaomi-platina/APKBUILD
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) 2026 Sukecz
+# This recipe is open source; the firmware it packages remains proprietary.
+maintainer="Sukecz <222629366+Sukecz@users.noreply.github.com>"
+pkgname=firmware-xiaomi-platina
+pkgver=2
+pkgrel=5
+pkgdesc="User-supplied Xiaomi Mi 8 Lite GPU, Wi-Fi and modem firmware"
+url="https://github.com/Sukecz/platina-linux"
+arch="aarch64"
+license="proprietary"
+options="!strip !check !archcheck !spdx !tracedeps pmb:cross-native"
+makedepends="qca-swiss-army-knife python3"
+source="
+ a512_zap.elf
+ gen-board-2.py
+ firmware-xiaomi-platina-bdwlan.tar.gz
+ firmware-xiaomi-platina-modem.tar.gz
+"
+builddir="$srcdir"
+
+build() {
+ ath10k-fwencoder --create \
+ --features=wowlan,no-nwifi-decap-4addr-padding,allows-mesh-bcast,mgmt-tx-by-ref,non-bmi,single-chan-info-per-channel \
+ --set-wmi-op-version=tlv --set-htt-op-version=tlv --set-fw-api=5
+ python3 "$srcdir/gen-board-2.py" "$srcdir/bdwlan" "$srcdir/bdwlan/board-2.json"
+ cd "$srcdir/bdwlan"
+ ath10k-bdencoder -c board-2.json -o "$srcdir/board-2.bin"
+}
+
+package() {
+ local wifi="$pkgdir/lib/firmware/ath10k/WCN3990/hw1.0"
+ local platform="$pkgdir/lib/firmware/postmarketos"
+ install -Dm644 "$srcdir/firmware-5.bin" "$wifi/firmware-5.bin"
+ install -Dm644 "$srcdir/board-2.bin" "$wifi/board-2.bin"
+ install -Dm644 "$srcdir/bdwlan/wlanmdsp.mbn" "$platform/wlanmdsp.mbn"
+ install -Dm644 "$srcdir/a512_zap.elf" "$platform/a512_zap.mbn"
+ install -dm755 "$platform"
+ install -m644 "$srcdir/modem/mba.mbn" "$srcdir/modem/modem.mdt" \
+ "$srcdir"/modem/modem.b* "$platform/"
+}
+sha512sums="
+44e003d5d75265fed5192d2dc384cf9b6867b5c2008cca1a50c8fc77f4b918df37d5f7c6bc63d0e9e9e4908eaf9c5250347e1edf08231c79eae0366942de70db a512_zap.elf
+6c27a45c8322743ef231da3560a43cbd83fc7bf339af133a3ec2a082ab55d63e0c945652caae4f934307536d919a18fa2a91e5a4daa3698125ec9260ce81f70c gen-board-2.py
+61d1dd7e3273b3327e0217e1c9fe418034e1c2c65b18c0e1ba71978799eb159723cc71407a236a3ac3185e1948a45d3d346983a47504abb211d28c8c6e249f69 firmware-xiaomi-platina-bdwlan.tar.gz
+2402fe62d1350e61d53d9f928c17ba0f6a7e4b76552946327067b01194945982935601812693e9567748fc7c8b67ef90b4ad49fee16533038e89acc9f26cc506 firmware-xiaomi-platina-modem.tar.gz
+"
diff --git a/ports/candidate/firmware-xiaomi-platina/gen-board-2.py b/ports/candidate/firmware-xiaomi-platina/gen-board-2.py
new file mode 100644
index 0000000..fba1e24
--- /dev/null
+++ b/ports/candidate/firmware-xiaomi-platina/gen-board-2.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) 2026 Sukecz
+"""Index a user's local Qualcomm board files for ath10k-bdencoder."""
+import argparse
+import json
+from pathlib import Path
+import re
+
+
+def index(directory):
+ entries = []
+ for path in sorted(directory.glob('bdwlan.*')):
+ if not path.is_file():
+ continue
+ suffix = path.suffix[1:]
+ aliases = ['bus=snoc']
+ if suffix == 'bin':
+ aliases.extend('bus=snoc,qmi-board-id=' + value for value in ('ff', '0'))
+ else:
+ value = suffix[1:] if re.fullmatch('b[0-9a-fA-F]{2}', suffix) else suffix
+ if not re.fullmatch('[0-9a-fA-F]+', value):
+ continue
+ aliases = ['bus=snoc,qmi-board-id=' + value]
+ entries.append({'names': aliases, 'data': path.name})
+ if not entries:
+ raise ValueError('No valid bdwlan files in the input directory')
+ return entries
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('directory', type=Path)
+ parser.add_argument('output', type=Path)
+ args = parser.parse_args()
+ args.output.write_text(json.dumps(index(args.directory), indent=2))
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0001-platina-enable-display.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0001-platina-enable-display.patch
new file mode 100644
index 0000000..cb82d23
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0001-platina-enable-display.patch
@@ -0,0 +1,192 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660-xiaomi-platina: enable display + synaptics TCM touch
+
+Enable the display pipeline + BOE TD4320 panel (1080x2280) via panel-simple,
+WLED (2 strings), model the LCDB VSP/VSN as fixed regulators, and enable the
+Synaptics TouchComm (TCM) touchscreen, brought up independently of the panel so
+it does not disturb the shared TDDI rails.
+
+Also drop the platina removed_region@85800000 and cdsp-region@94e00000 reserved
+memory nodes that overlap nodes already defined in sdm630.dtsi / are unreferenced.
+
+Signed-off-by: pmOS Mi8Lite
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -63,16 +63,6 @@
+ no-map;
+ };
+
+- cdsp-region@94e00000 {
+- reg = <0x00 0x94e00000 0x00 0x600000>;
+- no-map;
+- };
+-
+- removed_region@85800000 {
+- reg = <0x00 0x85800000 0x00 0x3700000>;
+- no-map;
+- };
+-
+ framebuffer_memory@9d400000 {
+ reg = <0x0 0x9d400000 0x0 (1080 * 2280 * 4)>;
+ no-map;
+@@ -89,6 +79,31 @@
+ regulator-boot-on;
+ };
+
++ /*
++ * The panel positive/negative supplies (VSP/VSN, +/-5.4V) are
++ * generated by the PM660L LCDB block, for which there is no mainline
++ * driver yet (see sdm660-mainline issue #125). The bootloader leaves
++ * LCDB enabled at boot; model VSP/VSN as fixed always-on regulators so
++ * the panel can probe and uses the voltages the bootloader set up.
++ */
++ panel_vsp: panel-vsp-regulator {
++ compatible = "regulator-fixed";
++ regulator-name = "panel_vsp";
++ regulator-min-microvolt = <5400000>;
++ regulator-max-microvolt = <5400000>;
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
++ panel_vsn: panel-vsn-regulator {
++ compatible = "regulator-fixed";
++ regulator-name = "panel_vsn";
++ regulator-min-microvolt = <5400000>;
++ regulator-max-microvolt = <5400000>;
++ regulator-always-on;
++ regulator-boot-on;
++ };
++
+ cam_avdd_front_vreg: cam-avdd-front-vreg {
+ compatible = "regulator-fixed";
+ regulator-name = "cam-avdd-front-vreg";
+@@ -236,7 +251,12 @@
+ };
+
+ &adreno_gpu {
+- status = "disabled";
++ status = "okay";
++};
++
++&adreno_gpu_zap {
++ firmware-name = "a512_zap.mbn";
++ memory-region = <&zap_shader_region>;
+ };
+
+ &blsp_i2c2 {
+@@ -252,14 +272,28 @@
+ &blsp_i2c4 {
+ status = "okay";
+
+- touchscreen@1 {
+- compatible = "novatek,nt36672a-ts";
+- reg = <0x1>;
+- iovcc-supply = <&vreg_l11a_1p8>;
++ /*
++ * Synaptics TouchComm (TCM) touchscreen. This unit has the Synaptics
++ * variant (the stock kernel dmesg shows the Novatek and Focaltech
++ * probes failing and the Synaptics controller at 4-0020 being present).
++ * It speaks the TCM command/report protocol (not RMI4), driven by the
++ * synaptics-tcm-i2c driver. It is integrated with the TD4320 TDDI
++ * panel, so it follows the panel power state via panel=<&panel>.
++ * vdd is the digital 1.8V rail; vbus is the panel analog rail (LCDB,
++ * kept on by the bootloader). reset tlmm66, IRQ tlmm67.
++ */
++ touchscreen@20 {
++ compatible = "syna,tcm-i2c";
++ reg = <0x20>;
++
++ vdd-supply = <&vreg_l11a_1p8>;
++
++
+ pinctrl-0 = <&ts_int_active &ts_rst_n>;
+ pinctrl-names = "default";
+ interrupts-extended = <&tlmm 67 IRQ_TYPE_EDGE_FALLING>;
+ reset-gpios = <&tlmm 66 GPIO_ACTIVE_LOW>;
++
+ touchscreen-size-x = <1080>;
+ touchscreen-size-y = <2280>;
+ };
+@@ -270,11 +304,11 @@
+ };
+
+ &gpucc {
+- status = "disabled";
++ status = "okay";
+ };
+
+ &mmcc {
+- status = "disabled";
++ status = "okay";
+ };
+
+ &pm660_gpios {
+@@ -789,3 +823,67 @@
+ dr_mode = "peripheral";
+ extcon = <&extcon_usb>;
+ };
++
++&mdss {
++ status = "okay";
++};
++
++&mdss_dsi0 {
++ status = "okay";
++
++ #address-cells = <1>;
++ #size-cells = <0>;
++
++ vdd-supply = <&vreg_l1b_0p925>;
++ vdda-supply = <&vreg_l1a_1p225>;
++
++ panel: panel@0 {
++ compatible = "xiaomi,platina-td4320", "boe,td4320";
++ reg = <0>;
++
++ iovcc-supply = <&vreg_l11a_1p8>;
++ vsp-supply = <&panel_vsp>;
++ vsn-supply = <&panel_vsn>;
++
++ reset-gpios = <&tlmm 53 GPIO_ACTIVE_LOW>;
++
++ backlight = <&pm660l_wled>;
++
++ pinctrl-names = "default";
++ pinctrl-0 = <&panel_reset_n &mdp_vsync_n>;
++
++ port {
++ panel_in: endpoint {
++ remote-endpoint = <&mdss_dsi0_out>;
++ };
++ };
++ };
++};
++
++&mdss_dsi0_out {
++ data-lanes = <0 1 2 3>;
++ remote-endpoint = <&panel_in>;
++};
++
++&mdss_dsi0_phy {
++ vcca-supply = <&vreg_l1b_0p925>;
++ status = "okay";
++};
++
++&mmss_smmu {
++ status = "okay";
++};
++
++&pm660l_wled {
++ qcom,switching-freq = <800>;
++ qcom,current-limit-microamp = <20000>;
++ qcom,num-strings = <2>;
++
++ status = "okay";
++};
++
++/* Audio DAI links are wired up in 0018-platina-audio (internal sndcard);
++ * q6asm-dai provides the MultiMedia frontends, so enable it. */
++&q6asmdai {
++ status = "okay";
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0002-panel-simple-td4320.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0002-panel-simple-td4320.patch
new file mode 100644
index 0000000..7cba785
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0002-panel-simple-td4320.patch
@@ -0,0 +1,57 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] drm/panel: simple: add BOE TD4320 (Xiaomi Mi 8 Lite platina)
+
+Per the postmarketOS mainlining FAQ: when the device shows the boot splash with
+mainline (platina does), the panel is already initialized by the bootloader, so
+the simple-panel driver (no command init) should work. Add the BOE TD4320
+1080x2280 panel to panel-simple with video mode + HSE, instead of sending the
+downstream command sequence which left the panel showing stripes then black.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/drivers/gpu/drm/panel/b/drivers/gpu/drm/panel/panel-simple.c 2026-06-18 15:17:49.929505993 -0500
++++ b/drivers/gpu/drm/panel/panel-simple.c 2026-06-18 15:17:24.484507501 -0500
+@@ -5777,8 +5777,43 @@
+ .lanes = 4,
+ };
+
++static const struct drm_display_mode boe_td4320_mode = {
++ .clock = (1080 + 92 + 20 + 112) * (2280 + 12 + 4 + 60) * 60 / 1000,
++ .hdisplay = 1080,
++ .hsync_start = 1080 + 92,
++ .hsync_end = 1080 + 92 + 20,
++ .htotal = 1080 + 92 + 20 + 112,
++ .vdisplay = 2280,
++ .vsync_start = 2280 + 12,
++ .vsync_end = 2280 + 12 + 4,
++ .vtotal = 2280 + 12 + 4 + 60,
++ .width_mm = 68,
++ .height_mm = 144,
++ .type = DRM_MODE_TYPE_DRIVER,
++};
++
++static const struct panel_desc_dsi boe_td4320 = {
++ .desc = {
++ .modes = &boe_td4320_mode,
++ .num_modes = 1,
++ .bpc = 8,
++ .size = {
++ .width = 68,
++ .height = 144,
++ },
++ .connector_type = DRM_MODE_CONNECTOR_DSI,
++ },
++ .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_HSE |
++ MIPI_DSI_CLOCK_NON_CONTINUOUS,
++ .format = MIPI_DSI_FMT_RGB888,
++ .lanes = 4,
++};
++
+ static const struct of_device_id dsi_of_match[] = {
+ {
++ .compatible = "boe,td4320",
++ .data = &boe_td4320
++ }, {
+ .compatible = "auo,b080uan01",
+ .data = &auo_b080uan01
+ }, {
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0004-synaptics-tcm-driver.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0004-synaptics-tcm-driver.patch
new file mode 100644
index 0000000..f2c15d1
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0004-synaptics-tcm-driver.patch
@@ -0,0 +1,735 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] input: touchscreen: add Synaptics TouchComm (TCM) I2C driver
+
+Mainline driver for Synaptics TouchComm (TCM) touch controllers (e.g. the Synaptics
+variant of the BOE TD4320 TDDI panel on the Xiaomi Mi 8 Lite). TCM uses a command/report
+message protocol over I2C and is not RMI4-compatible. The driver only enables the shared
+vdd rail (never disables it), retries the identify/app-info handshake, parses the variable
+touch report config for multitouch type B and reports BTN_TOUCH for single-touch clients.
+
+Signed-off-by: pmOS Mi8Lite
+--- /dev/null
++++ b/drivers/input/touchscreen/synaptics-tcm-i2c.c
+@@ -0,0 +1,691 @@
++// SPDX-License-Identifier: GPL-2.0-or-later
++/*
++ * Synaptics TouchComm (TCM) I2C touchscreen driver.
++ *
++ * Minimal mainline driver for Synaptics TCM (TouchComm v1) touch controllers
++ * such as the one integrated with the BOE TD4320 TDDI panel on the Xiaomi
++ * Mi 8 Lite (platina). These controllers use a command/report message protocol
++ * over I2C and are NOT compatible with the RMI4 register interface.
++ *
++ * The controller runs application firmware from its own storage (it reports
++ * MODE_APPLICATION right after reset), so no host firmware download is needed.
++ *
++ * Protocol and touch report parsing are based on the downstream
++ * drivers/input/touchscreen/synaptics_tcm vendor driver.
++ *
++ * Copyright (c) 2026 pmOS Mi8Lite
++ */
++
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++
++/* TCM message framing */
++#define TCM_MESSAGE_MARKER 0xa5
++#define TCM_MESSAGE_PADDING 0x5a
++#define TCM_HEADER_SIZE 4
++#define TCM_RD_BUF 256
++
++/* Commands (host -> device) */
++#define TCM_CMD_IDENTIFY 0x02
++#define TCM_CMD_RESET 0x04
++#define TCM_CMD_ENABLE_REPORT 0x05
++#define TCM_CMD_DISABLE_REPORT 0x06
++#define TCM_CMD_GET_APP_INFO 0x20
++#define TCM_CMD_GET_TOUCH_REPORT_CONFIG 0x25
++
++/* Status codes (device -> host, in response message header code field) */
++#define TCM_STATUS_OK 0x01
++#define TCM_STATUS_CONTINUED_READ 0x03
++
++/* Report codes (async, device -> host) */
++#define TCM_REPORT_IDENTIFY 0x10
++#define TCM_REPORT_TOUCH 0x11
++
++/* Touch report config opcodes (describe the touch report bitstream layout) */
++enum tcm_touch_report_code {
++ TOUCH_END = 0,
++ TOUCH_FOREACH_ACTIVE_OBJECT,
++ TOUCH_FOREACH_OBJECT,
++ TOUCH_FOREACH_END,
++ TOUCH_PAD_TO_NEXT_BYTE,
++ TOUCH_TIMESTAMP,
++ TOUCH_OBJECT_N_INDEX,
++ TOUCH_OBJECT_N_CLASSIFICATION,
++ TOUCH_OBJECT_N_X_POSITION,
++ TOUCH_OBJECT_N_Y_POSITION,
++ TOUCH_OBJECT_N_Z,
++ TOUCH_OBJECT_N_X_WIDTH,
++ TOUCH_OBJECT_N_Y_WIDTH,
++ TOUCH_OBJECT_N_TX_POSITION_TIXELS,
++ TOUCH_OBJECT_N_RX_POSITION_TIXELS,
++ TOUCH_0D_BUTTONS_STATE,
++ TOUCH_GESTURE_DOUBLE_TAP,
++ TOUCH_FRAME_RATE,
++ TOUCH_POWER_IM,
++ TOUCH_CID_IM,
++ TOUCH_RAIL_IM,
++ TOUCH_CID_VARIANCE_IM,
++ TOUCH_NSM_FREQUENCY,
++ TOUCH_NSM_STATE,
++ TOUCH_NUM_OF_ACTIVE_OBJECTS,
++ TOUCH_NUM_OF_CPU_CYCLES_USED_SINCE_LAST_FRAME,
++};
++
++/* object classification (status) values */
++#define TCM_OBJECT_NONE 0
++#define TCM_OBJECT_FINGER 1
++#define TCM_OBJECT_GLOVED_FINGER 2
++
++#define TCM_MAX_OBJECTS 10
++#define TCM_CONFIG_SIZE 256
++
++struct syna_tcm {
++ struct i2c_client *client;
++ struct input_dev *input;
++ struct touchscreen_properties prop;
++ struct gpio_desc *reset_gpio;
++ struct regulator *vdd;
++ bool powered;
++
++ struct drm_panel_follower panel_follower;
++ bool is_panel_follower;
++ bool enabled;
++
++ unsigned int max_x;
++ unsigned int max_y;
++ unsigned int max_objects;
++
++ u8 config[TCM_CONFIG_SIZE];
++ unsigned int config_len;
++
++ u8 rxbuf[TCM_RD_BUF];
++};
++
++/* ---- low level I2C message I/O ---- */
++
++/*
++ * Read a whole TCM message in a single I2C read. The controller pads any
++ * bytes beyond the message with TCM_MESSAGE_PADDING (0x5a), so reading a
++ * fixed oversized buffer is safe. On success *code/*payload_len describe the
++ * message and the payload starts at buf[TCM_HEADER_SIZE].
++ */
++static int syna_read_message(struct syna_tcm *ts, u8 *code,
++ unsigned int *payload_len)
++{
++ struct i2c_client *client = ts->client;
++ struct i2c_msg msg = {
++ .addr = client->addr,
++ .flags = I2C_M_RD,
++ .len = TCM_RD_BUF,
++ .buf = ts->rxbuf,
++ };
++ int ret;
++
++ ret = i2c_transfer(client->adapter, &msg, 1);
++ if (ret != 1)
++ return ret < 0 ? ret : -EIO;
++
++ if (ts->rxbuf[0] != TCM_MESSAGE_MARKER)
++ return -EIO;
++
++ *code = ts->rxbuf[1];
++ *payload_len = get_unaligned_le16(&ts->rxbuf[2]);
++ if (*payload_len + TCM_HEADER_SIZE > TCM_RD_BUF)
++ *payload_len = TCM_RD_BUF - TCM_HEADER_SIZE;
++
++ return 0;
++}
++
++/* Write a command with optional payload. */
++static int syna_write_command(struct syna_tcm *ts, u8 cmd,
++ const u8 *payload, u16 len)
++{
++ struct i2c_client *client = ts->client;
++ u8 buf[8];
++ struct i2c_msg msg = {
++ .addr = client->addr,
++ .flags = 0,
++ .buf = buf,
++ };
++ int ret;
++
++ if (len + 3 > sizeof(buf))
++ return -EINVAL;
++
++ buf[0] = cmd;
++ put_unaligned_le16(len, &buf[1]);
++ if (len)
++ memcpy(&buf[3], payload, len);
++ msg.len = 3 + len;
++
++ ret = i2c_transfer(client->adapter, &msg, 1);
++ return ret == 1 ? 0 : (ret < 0 ? ret : -EIO);
++}
++
++/*
++ * Send a command and wait (polling) for its response. Used during probe when
++ * the IRQ is not requested yet. Any async reports received while waiting are
++ * skipped. The response payload (if any) is copied into resp.
++ */
++static int syna_command(struct syna_tcm *ts, u8 cmd, const u8 *payload, u16 len,
++ u8 *resp, unsigned int resp_size, unsigned int *resp_len)
++{
++ unsigned int plen;
++ u8 code;
++ int ret, tries;
++
++ ret = syna_write_command(ts, cmd, payload, len);
++ if (ret)
++ return ret;
++
++ /* wait for the response message, skipping async reports */
++ for (tries = 0; tries < 50; tries++) {
++ usleep_range(2000, 3000);
++
++ ret = syna_read_message(ts, &code, &plen);
++ if (ret)
++ continue;
++
++ /* async reports have code >= REPORT_IDENTIFY; skip them */
++ if (code >= TCM_REPORT_IDENTIFY)
++ continue;
++
++ if (code != TCM_STATUS_OK)
++ return -EIO;
++
++ if (resp && resp_size) {
++ plen = min(plen, resp_size);
++ memcpy(resp, &ts->rxbuf[TCM_HEADER_SIZE], plen);
++ if (resp_len)
++ *resp_len = plen;
++ }
++ return 0;
++ }
++
++ return -ETIMEDOUT;
++}
++
++/* ---- touch report parsing ---- */
++
++/* Extract `bits` bits from the payload bitstream at `offset`. */
++static u32 syna_get_bits(const u8 *data, unsigned int data_len,
++ unsigned int offset, unsigned int bits)
++{
++ u32 output = 0;
++ unsigned int remaining = bits;
++ unsigned int got = 0;
++
++ if (bits == 0 || bits > 32)
++ return 0;
++ if (offset + bits > data_len * 8)
++ return 0;
++
++ while (remaining) {
++ unsigned int byte_off = offset / 8;
++ unsigned int bit_off = offset % 8;
++ unsigned int avail = 8 - bit_off;
++ unsigned int take = min(avail, remaining);
++ u32 mask = 0xff >> (8 - take);
++ u32 val = (data[byte_off] >> bit_off) & mask;
++
++ output |= val << got;
++ got += take;
++ offset += take;
++ remaining -= take;
++ }
++
++ return output;
++}
++
++struct syna_object {
++ unsigned int status;
++ unsigned int x;
++ unsigned int y;
++};
++
++/*
++ * Parse a touch report payload according to the touch report config and emit
++ * MT type-B events. Mirrors the downstream config walker.
++ */
++static void syna_parse_touch(struct syna_tcm *ts, const u8 *data,
++ unsigned int data_len)
++{
++ struct syna_object objs[TCM_MAX_OBJECTS] = {};
++ const u8 *cfg = ts->config;
++ unsigned int cfg_len = ts->config_len;
++ unsigned int offset = 0; /* bit offset in payload */
++ unsigned int idx = 0; /* index into config */
++ unsigned int obj = 0;
++ unsigned int active_objects = 0;
++ unsigned int num_active = 0;
++ bool have_num_active = false;
++ bool active_only = false;
++ unsigned int foreach_idx = 0;
++ unsigned int objects_done = 0;
++ int active_count = 0;
++ int i;
++
++ while (idx < cfg_len) {
++ u8 code = cfg[idx++];
++ unsigned int bits;
++
++ switch (code) {
++ case TOUCH_END:
++ goto report;
++ case TOUCH_FOREACH_ACTIVE_OBJECT:
++ foreach_idx = idx;
++ active_only = true;
++ obj = 0;
++ objects_done = 0;
++ break;
++ case TOUCH_FOREACH_OBJECT:
++ foreach_idx = idx;
++ active_only = false;
++ obj = 0;
++ objects_done = 0;
++ break;
++ case TOUCH_FOREACH_END:
++ objects_done++;
++ /*
++ * The report packs only the objects it actually carries,
++ * back to back. Loop over the per-object config again
++ * only while the report still has data left (and we have
++ * not hit the object / active-object limit). Without this
++ * bound, iterating past the data would read zeroes and a
++ * TOUCH_OBJECT_N_INDEX field would clobber object 0.
++ */
++ if (objects_done < ts->max_objects &&
++ offset < data_len * 8 &&
++ (!have_num_active || objects_done < num_active)) {
++ idx = foreach_idx;
++ obj++;
++ }
++ break;
++ case TOUCH_PAD_TO_NEXT_BYTE:
++ offset = ALIGN(offset, 8);
++ break;
++ case TOUCH_TIMESTAMP:
++ bits = cfg[idx++];
++ offset += bits;
++ break;
++ case TOUCH_OBJECT_N_INDEX:
++ bits = cfg[idx++];
++ obj = syna_get_bits(data, data_len, offset, bits);
++ offset += bits;
++ break;
++ case TOUCH_OBJECT_N_CLASSIFICATION:
++ bits = cfg[idx++];
++ if (obj < TCM_MAX_OBJECTS)
++ objs[obj].status =
++ syna_get_bits(data, data_len, offset, bits);
++ offset += bits;
++ break;
++ case TOUCH_OBJECT_N_X_POSITION:
++ bits = cfg[idx++];
++ if (obj < TCM_MAX_OBJECTS)
++ objs[obj].x =
++ syna_get_bits(data, data_len, offset, bits);
++ offset += bits;
++ break;
++ case TOUCH_OBJECT_N_Y_POSITION:
++ bits = cfg[idx++];
++ if (obj < TCM_MAX_OBJECTS)
++ objs[obj].y =
++ syna_get_bits(data, data_len, offset, bits);
++ offset += bits;
++ break;
++ case TOUCH_NUM_OF_ACTIVE_OBJECTS:
++ bits = cfg[idx++];
++ num_active = syna_get_bits(data, data_len, offset, bits);
++ have_num_active = true;
++ if (num_active > ts->max_objects)
++ num_active = ts->max_objects;
++ active_objects = num_active;
++ offset += bits;
++ break;
++ /* fields we read past but don't use */
++ case TOUCH_OBJECT_N_Z:
++ case TOUCH_OBJECT_N_X_WIDTH:
++ case TOUCH_OBJECT_N_Y_WIDTH:
++ case TOUCH_OBJECT_N_TX_POSITION_TIXELS:
++ case TOUCH_OBJECT_N_RX_POSITION_TIXELS:
++ case TOUCH_0D_BUTTONS_STATE:
++ case TOUCH_GESTURE_DOUBLE_TAP:
++ case TOUCH_FRAME_RATE:
++ case TOUCH_POWER_IM:
++ case TOUCH_CID_IM:
++ case TOUCH_RAIL_IM:
++ case TOUCH_CID_VARIANCE_IM:
++ case TOUCH_NSM_FREQUENCY:
++ case TOUCH_NSM_STATE:
++ case TOUCH_NUM_OF_CPU_CYCLES_USED_SINCE_LAST_FRAME:
++ bits = cfg[idx++];
++ offset += bits;
++ break;
++ default:
++ /* unknown opcode followed by a bit count */
++ bits = cfg[idx++];
++ offset += bits;
++ break;
++ }
++ }
++
++report:
++ (void)active_objects;
++ for (i = 0; i < ts->max_objects && i < TCM_MAX_OBJECTS; i++) {
++ bool active = objs[i].status == TCM_OBJECT_FINGER ||
++ objs[i].status == TCM_OBJECT_GLOVED_FINGER;
++
++ input_mt_slot(ts->input, i);
++ input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, active);
++ if (active) {
++ active_count++;
++ touchscreen_report_pos(ts->input, &ts->prop,
++ objs[i].x, objs[i].y, true);
++ }
++ }
++ /* single-touch emulation for clients that rely on BTN_TOUCH */
++ input_report_key(ts->input, BTN_TOUCH, active_count > 0);
++ input_mt_sync_frame(ts->input);
++ input_sync(ts->input);
++}
++
++/* ---- IRQ ---- */
++
++static irqreturn_t syna_irq(int irq, void *dev_id)
++{
++ struct syna_tcm *ts = dev_id;
++ unsigned int plen;
++ u8 code;
++
++ if (syna_read_message(ts, &code, &plen))
++ return IRQ_HANDLED;
++
++ if (code == TCM_REPORT_TOUCH)
++ syna_parse_touch(ts, &ts->rxbuf[TCM_HEADER_SIZE], plen);
++
++ return IRQ_HANDLED;
++}
++
++/* ---- power / reset ---- */
++
++static int syna_power_on(struct syna_tcm *ts)
++{
++ int ret;
++
++ /*
++ * Enable our digital rail. This rail (and the analog LCDB rail) is
++ * shared with the TDDI panel, so we only ever turn it ON and never
++ * disable it: powering it down would kill the panel. The analog supply
++ * is left to the bootloader/panel (always on), we do not manage it.
++ */
++ if (!ts->powered) {
++ ret = regulator_enable(ts->vdd);
++ if (ret)
++ return ret;
++ ts->powered = true;
++ }
++
++ /* the bootloader leaves the panel/touch rails on; give it a moment */
++ msleep(20);
++
++ if (ts->reset_gpio) {
++ gpiod_set_value_cansleep(ts->reset_gpio, 1);
++ usleep_range(1000, 2000);
++ gpiod_set_value_cansleep(ts->reset_gpio, 0);
++ /* controller needs ~200ms to boot into application firmware */
++ msleep(200);
++ }
++
++ return 0;
++}
++
++/*
++ * We deliberately never power the controller down: its rails are shared with
++ * the always-on TDDI panel. The most we do on stop is assert the touch-only
++ * reset GPIO (tlmm66), which does not affect the panel.
++ */
++static void syna_power_off(struct syna_tcm *ts)
++{
++ if (ts->reset_gpio)
++ gpiod_set_value_cansleep(ts->reset_gpio, 1);
++}
++
++/* ---- controller setup (query info + config, enable reports) ---- */
++
++static int syna_setup(struct syna_tcm *ts)
++{
++ struct device *dev = &ts->client->dev;
++ u8 app_info[64];
++ unsigned int len;
++ u8 code, rep;
++ unsigned int plen;
++ int ret, tries, attempt;
++
++ /*
++ * The controller may not answer immediately after an independent probe
++ * (the shared TDDI rails take time to settle). Retry the identify +
++ * app-info handshake for a few seconds before giving up.
++ */
++ for (attempt = 0; ; attempt++) {
++ /* drain the identify report the controller sends after reset */
++ for (tries = 0; tries < 20; tries++) {
++ usleep_range(2000, 3000);
++ if (!syna_read_message(ts, &code, &plen) &&
++ code == TCM_REPORT_IDENTIFY)
++ break;
++ }
++
++ ret = syna_command(ts, TCM_CMD_GET_APP_INFO, NULL, 0,
++ app_info, sizeof(app_info), &len);
++ if (!ret && len >= 38)
++ break;
++
++ if (attempt >= 20)
++ return dev_err_probe(dev, ret ? ret : -EIO,
++ "controller not responding (app info)\n");
++ msleep(100);
++ }
++
++ /* app_info layout (struct syna_tcm_app_info): max_x/max_y/max_objects
++ * are 16-bit LE at offsets 32/34/36 (after the 16-byte
++ * customer_config_id at offset 16).
++ */
++ ts->max_x = get_unaligned_le16(&app_info[32]);
++ ts->max_y = get_unaligned_le16(&app_info[34]);
++ ts->max_objects = get_unaligned_le16(&app_info[36]);
++
++ if (!ts->max_x || !ts->max_y ||
++ ts->max_objects == 0 || ts->max_objects > TCM_MAX_OBJECTS) {
++ dev_warn(dev, "implausible app info x=%u y=%u obj=%u, using defaults\n",
++ ts->max_x, ts->max_y, ts->max_objects);
++ ts->max_x = 1080;
++ ts->max_y = 2280;
++ ts->max_objects = TCM_MAX_OBJECTS;
++ }
++
++ ret = syna_command(ts, TCM_CMD_GET_TOUCH_REPORT_CONFIG, NULL, 0,
++ ts->config, sizeof(ts->config), &ts->config_len);
++ if (ret)
++ return dev_err_probe(dev, ret, "failed to get report config\n");
++
++ /* enable touch reports */
++ rep = TCM_REPORT_TOUCH;
++ ret = syna_command(ts, TCM_CMD_ENABLE_REPORT, &rep, 1, NULL, 0, NULL);
++ if (ret)
++ return dev_err_probe(dev, ret, "failed to enable touch report\n");
++
++ dev_info(dev, "Synaptics TCM touch %ux%u, %u objects\n",
++ ts->max_x, ts->max_y, ts->max_objects);
++ return 0;
++}
++
++static int syna_start(struct syna_tcm *ts)
++{
++ int ret;
++
++ ret = syna_power_on(ts);
++ if (ret)
++ return ret;
++
++ ret = syna_setup(ts);
++ if (ret) {
++ syna_power_off(ts);
++ return ret;
++ }
++
++ enable_irq(ts->client->irq);
++ ts->enabled = true;
++ return 0;
++}
++
++static void syna_stop(struct syna_tcm *ts)
++{
++ disable_irq(ts->client->irq);
++ ts->enabled = false;
++ syna_power_off(ts);
++}
++
++/* ---- drm panel follower (power-sync with the TDDI panel) ---- */
++
++static int syna_panel_prepared(struct drm_panel_follower *follower)
++{
++ struct syna_tcm *ts = container_of(follower, struct syna_tcm,
++ panel_follower);
++
++ return syna_start(ts);
++}
++
++static int syna_panel_unpreparing(struct drm_panel_follower *follower)
++{
++ struct syna_tcm *ts = container_of(follower, struct syna_tcm,
++ panel_follower);
++
++ if (ts->enabled)
++ syna_stop(ts);
++ return 0;
++}
++
++static const struct drm_panel_follower_funcs syna_follower_funcs = {
++ .panel_prepared = syna_panel_prepared,
++ .panel_unpreparing = syna_panel_unpreparing,
++};
++
++/* ---- probe ---- */
++
++static int syna_probe(struct i2c_client *client)
++{
++ struct device *dev = &client->dev;
++ struct syna_tcm *ts;
++ int ret;
++
++ ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
++ if (!ts)
++ return -ENOMEM;
++
++ ts->client = client;
++ i2c_set_clientdata(client, ts);
++
++ /*
++ * Only the digital rail is managed here. The analog supply is the panel
++ * LCDB rail, left on by the bootloader; we must not touch it. The vdd
++ * rail is shared with the panel iovcc, so we only turn it on (never off).
++ */
++ ts->vdd = devm_regulator_get(dev, "vdd");
++ if (IS_ERR(ts->vdd))
++ return dev_err_probe(dev, PTR_ERR(ts->vdd),
++ "failed to get vdd regulator\n");
++
++ ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
++ if (IS_ERR(ts->reset_gpio))
++ return dev_err_probe(dev, PTR_ERR(ts->reset_gpio),
++ "failed to get reset gpio\n");
++
++ /* default geometry; refined from app info in syna_setup() */
++ ts->max_x = 1080;
++ ts->max_y = 2280;
++ ts->max_objects = TCM_MAX_OBJECTS;
++
++ ts->input = devm_input_allocate_device(dev);
++ if (!ts->input)
++ return -ENOMEM;
++
++ ts->input->name = "Synaptics TCM Touchscreen";
++ ts->input->id.bustype = BUS_I2C;
++
++ input_set_capability(ts->input, EV_KEY, BTN_TOUCH);
++ input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0);
++ input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0);
++ touchscreen_parse_properties(ts->input, true, &ts->prop);
++
++ ret = input_mt_init_slots(ts->input, TCM_MAX_OBJECTS,
++ INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
++ if (ret)
++ return dev_err_probe(dev, ret, "failed to init MT slots\n");
++
++ ret = devm_request_threaded_irq(dev, client->irq, NULL, syna_irq,
++ IRQF_ONESHOT | IRQF_NO_AUTOEN,
++ "synaptics-tcm", ts);
++ if (ret)
++ return dev_err_probe(dev, ret, "failed to request irq\n");
++
++ /* register input before the controller can raise IRQs */
++ ret = input_register_device(ts->input);
++ if (ret)
++ return dev_err_probe(dev, ret, "failed to register input\n");
++
++ /*
++ * If the touch node references the panel (panel = <&panel>), follow the
++ * panel's power state so we power on in sync with the TDDI display.
++ * Otherwise bring the controller up immediately.
++ */
++ if (drm_is_panel_follower(dev)) {
++ ts->is_panel_follower = true;
++ ts->panel_follower.funcs = &syna_follower_funcs;
++ ret = devm_drm_panel_add_follower(dev, &ts->panel_follower);
++ if (ret)
++ return dev_err_probe(dev, ret,
++ "failed to add panel follower\n");
++ } else {
++ ret = syna_start(ts);
++ if (ret)
++ return ret;
++ }
++
++ return 0;
++}
++
++static const struct of_device_id syna_of_match[] = {
++ { .compatible = "syna,tcm-i2c" },
++ { }
++};
++MODULE_DEVICE_TABLE(of, syna_of_match);
++
++static const struct i2c_device_id syna_id[] = {
++ { "synaptics-tcm-i2c" },
++ { }
++};
++MODULE_DEVICE_TABLE(i2c, syna_id);
++
++static struct i2c_driver syna_driver = {
++ .driver = {
++ .name = "synaptics-tcm-i2c",
++ .of_match_table = syna_of_match,
++ },
++ .probe = syna_probe,
++ .id_table = syna_id,
++};
++module_i2c_driver(syna_driver);
++
++MODULE_DESCRIPTION("Synaptics TouchComm (TCM) I2C touchscreen driver");
++MODULE_AUTHOR("pmOS Mi8Lite ");
++MODULE_LICENSE("GPL");
+--- a/drivers/input/touchscreen/Kconfig
++++ b/drivers/input/touchscreen/Kconfig
+@@ -1309,6 +1309,18 @@
+ To compile this driver as a module, choose M here: the
+ module will be called surface3_spi.
+
++config TOUCHSCREEN_SYNAPTICS_TCM
++ tristate "Synaptics TouchComm (TCM) I2C touchscreen"
++ depends on I2C
++ help
++ Say Y here if you have a Synaptics TouchComm (TCM) touch controller,
++ such as the one integrated with the BOE TD4320 TDDI panel on the
++ Xiaomi Mi 8 Lite (platina). These controllers use a command/report
++ message protocol and are not compatible with RMI4.
++
++ To compile this driver as a module, choose M here: the module will be
++ called synaptics-tcm-i2c.
++
+ config TOUCHSCREEN_SX8654
+ tristate "Semtech SX8654 touchscreen"
+ depends on I2C
+--- a/drivers/input/touchscreen/Makefile
++++ b/drivers/input/touchscreen/Makefile
+@@ -109,6 +109,7 @@
+ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o
+ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o
+ obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o
++obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM) += synaptics-tcm-i2c.o
+ obj-$(CONFIG_TOUCHSCREEN_SX8654) += sx8654.o
+ obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
+ obj-$(CONFIG_TOUCHSCREEN_ZET6223) += zet6223.o
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0006-platina-battery.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0006-platina-battery.patch
new file mode 100644
index 0000000..7f5fa98
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0006-platina-battery.patch
@@ -0,0 +1,46 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660-xiaomi-platina: enable battery + charger
+
+Enable battery monitoring on the Xiaomi Mi 8 Lite: the PM660 charger
+(qcom,pm660-charger), the PMI8998-style fuel gauge (qcom,pmi8998-fg) and
+the round-robin ADC (qcom,pm660-rradc) it depends on. Model the 3350 mAh
+cell as a simple-battery, matching what Xiaomi Redmi Note 7 (lavender)
+does on the same SDM660 + PM660 PMIC.
+
+This populates /sys/class/power_supply so charge percentage and power
+management work.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -887,3 +887,29 @@
+ &q6asmdai {
+ status = "okay";
+ };
++
++/ {
++ battery: battery {
++ compatible = "simple-battery";
++ charge-full-design-microamp-hours = <3350000>;
++ voltage-min-design-microvolt = <3400000>;
++ voltage-max-design-microvolt = <4400000>;
++ };
++};
++
++&pm660_charger {
++ monitored-battery = <&battery>;
++
++ status = "okay";
++};
++
++&pm660_fg {
++ monitored-battery = <&battery>;
++ power-supplies = <&pm660_charger>;
++
++ status = "okay";
++};
++
++&pm660_rradc {
++ status = "okay";
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0007-platina-wifi.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0007-platina-wifi.patch
new file mode 100644
index 0000000..bcbf482
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0007-platina-wifi.patch
@@ -0,0 +1,45 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660-xiaomi-platina: enable modem + WCN3990 WiFi (direct supplies)
+
+Enable the modem (MSS) remoteproc and the WCN3990 WiFi.
+
+Power the WLAN block with the four rails the stock Android DT of this
+exact device uses (icnss node in the live-extracted DT):
+ vdd-cx-mx -> LDO A5 (0.848 V)
+ vdd-1.8-xo -> LDO A9
+ vdd-1.3-rfa-> LDO A6
+ vdd-3.3-ch0-> LDO A19
+There is no ch1 rail (the chip reports num_rf_chains = 1, single chain)
+and Android drives the rails directly - there is no wcn3990-pmu power
+sequencer on this board. This mirrors sdm660-xiaomi-lavender, where WiFi
+scan/connect is known to work with the same SoC and firmware generation
+(WLAN.HL.1.0.1). A previous revision of this patch modeled a wcn3990-pmu
+node with a vddio rail, which does not match the platina hardware; with
+it the WLAN firmware crashed (err_qdi.c EX:wlan_process) as soon as a
+scan was started.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -913,3 +913,20 @@
+ &pm660_rradc {
+ status = "okay";
+ };
++
++&remoteproc_mss {
++ firmware-name = "postmarketos/mba.mbn", "postmarketos/modem.mdt";
++
++ status = "okay";
++};
++
++&wifi {
++ vdd-0.8-cx-mx-supply = <&vreg_l5a_0p848>;
++ vdd-1.8-xo-supply = <&vreg_l9a_1p8>;
++ vdd-1.3-rfa-supply = <&vreg_l6a_1p3>;
++ vdd-3.3-ch0-supply = <&vreg_l19a_3p3>;
++
++ qcom,calibration-variant = "xiaomi_platina";
++
++ status = "okay";
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0010-ath10k-wcn3990-no-psmode.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0010-ath10k-wcn3990-no-psmode.patch
new file mode 100644
index 0000000..f2cbe6e
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0010-ath10k-wcn3990-no-psmode.patch
@@ -0,0 +1,88 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] ath10k: work around WCN3990/SDM660 firmware crashes (psmode, group key, 5GHz scan)
+
+The WCN3990 WLAN firmware on SDM660 (WLAN.HL.1.0.1.c6, runs as a
+protection domain inside the modem Q6) fatally crashes
+(err_qdi.c EX:wlan_process, always PC=b00c75b8) as soon as it receives
+the WMI set_psmode command, which mac80211/ath10k send unconditionally
+during STA vif bring-up and around scans. Any scan (active or passive,
+any band) kills the firmware and only a full reboot recovers it.
+
+Port the workarounds that were verified on this device (Xiaomi Mi 8
+Lite, platina) on the 6.17-based tree:
+
+ 1. never send set_psmode on WCN3990 (skip ath10k_mac_vif_setup_ps),
+ 2. never advertise SUPPORTS_PS/SUPPORTS_DYNAMIC_PS on WCN3990 so
+ mac80211 does not trigger PS transitions,
+ 3. force passive scan on 5GHz (firmware does not tune the radio on
+ active 5GHz scans; rx_clear_count is identical across channels),
+ 4. don't install a junk group key on DISABLE_KEY on WCN3990 (crashes
+ the firmware on disconnect - same class of bug).
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/drivers/net/wireless/ath/ath10k/mac.c
++++ b/drivers/net/wireless/ath/ath10k/mac.c
+@@ -290,9 +290,12 @@
+ key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
+
+ if (cmd == DISABLE_KEY) {
+- if (flags & WMI_KEY_GROUP) {
++ if ((flags & WMI_KEY_GROUP) && !QCA_REV_WCN3990(ar)) {
+ /* Not all hardware handles group-key deletion operation
+ * correctly. Replace the key with a junk value to invalidate it.
++ * On WCN3990 (WLAN.HL.1.0.1 firmware in the SDM660 modem)
++ * installing a junk group key crashes the firmware, so take
++ * the plain-disable path there.
+ */
+ get_random_bytes(key->key, key->keylen);
+ } else {
+@@ -1959,6 +1962,16 @@
+
+ lockdep_assert_held(&arvif->ar->conf_mutex);
+
++ /*
++ * The WCN3990 WLAN firmware on the SDM660 (running inside the modem
++ * Q6) crashes with EX:wlan_process PC=b00c75b8 as soon as it receives
++ * the WMI set_psmode command. This command is otherwise sent
++ * unconditionally during STA vif bring-up / scan. Skip it entirely on
++ * WCN3990 so the firmware stays alive and scan/connect can proceed.
++ */
++ if (QCA_REV_WCN3990(ar))
++ return 0;
++
+ if (arvif->vif->type != NL80211_IFTYPE_STATION)
+ return 0;
+
+@@ -3450,6 +3463,14 @@
+ passive = channel->flags & IEEE80211_CHAN_NO_IR;
+ ch->passive = passive;
+
++ /* Force passive scan on 5GHz to work around WCN3990
++ * firmware bug where active scan doesn't tune the
++ * radio on 5GHz non-DFS channels. The radio reports
++ * identical rx_clear_count across channels.
++ */
++ if (QCA_REV_WCN3990(ar) && band == NL80211_BAND_5GHZ)
++ ch->passive = true;
++
+ /* the firmware is ignoring the "radar" flag of the
+ * channel and is scanning actively using Probe Requests
+ * on "Radar detection"/DFS channels which are not
+@@ -10072,7 +10093,15 @@
+
+ ieee80211_hw_set(ar->hw, SIGNAL_DBM);
+
+- if (!test_bit(ATH10K_FW_FEATURE_NO_PS,
++ /*
++ * The WCN3990 WLAN firmware (WLAN.HL.1.0.1.c6) running inside the modem
++ * on the SDM660 crashes (EX:wlan_process, PC=b00c75b8) the moment it
++ * receives the WMI set_psmode command that mac80211 triggers when power
++ * save is advertised. Do not advertise PS for WCN3990 so mac80211 never
++ * sends set_psmode; this keeps the device operational (scan/connect).
++ */
++ if (!QCA_REV_WCN3990(ar) &&
++ !test_bit(ATH10K_FW_FEATURE_NO_PS,
+ ar->running_fw->fw_file.fw_features)) {
+ ieee80211_hw_set(ar->hw, SUPPORTS_PS);
+ ieee80211_hw_set(ar->hw, SUPPORTS_DYNAMIC_PS);
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0011-ath10k-wcn3990-chanlist-qcacld.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0011-ath10k-wcn3990-chanlist-qcacld.patch
new file mode 100644
index 0000000..bb454db
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0011-ath10k-wcn3990-chanlist-qcacld.patch
@@ -0,0 +1,69 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] ath10k: WCN3990/SDM660: encode scan channel list like qcacld
+
+The WLAN.HL.1.0.1 firmware running in the SDM660 modem fatally asserts
+(err_qdi.c EX:wlan_process) on the first channel tune of any scan,
+active or passive, on any band. Verified on Xiaomi Mi 8 Lite (platina)
+to be independent of: board data file used (all 18 device calibrations),
+regdomain in the board data (0x809c and unlocked 0x0), firmware build
+(c6-00023 and c6-00027), modem build (-00076 and -00087), regulators
+(all rails verified on at runtime) and the RF reference clock (on).
+
+What does differ is the WMI_SCAN_CHAN_LIST payload. qcacld (the stock
+Android driver, which scans fine on the same device/firmware) sends per
+channel only the regulatory power, in plain dBm, leaving max_power,
+max_tx_power, antenna_max and reg_class_id at zero, and does not allow
+VHT on 2.4GHz. Mainline ath10k sends max_power/reg_power/max_tx_power
+as doubled half-dBm values (e.g. 40 for 20dBm) while the firmware's WMI
+headers document max_tx_power as "1 dBm units"; the firmware's TPC
+lookup against the per-device board data then fails at tune time.
+
+Mirror the qcacld encoding on WCN3990.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/drivers/net/wireless/ath/ath10k/mac.c
++++ b/drivers/net/wireless/ath/ath10k/mac.c
+@@ -3449,7 +3449,11 @@
+ ch->allow_ht = true;
+
+ /* FIXME: when should we really allow VHT? */
+- ch->allow_vht = true;
++ if (QCA_REV_WCN3990(ar))
++ /* qcacld only allows VHT on 5GHz; mirror it */
++ ch->allow_vht = channel->band == NL80211_BAND_5GHZ;
++ else
++ ch->allow_vht = true;
+
+ ch->allow_ibss =
+ !(channel->flags & IEEE80211_CHAN_NO_IR);
+@@ -3481,9 +3485,26 @@
+ ch->freq = channel->center_freq;
+ ch->band_center_freq1 = channel->center_freq;
+ ch->min_power = 0;
+- ch->max_power = channel->max_power * 2;
+- ch->max_reg_power = channel->max_reg_power * 2;
+- ch->max_antenna_gain = channel->max_antenna_gain;
++ if (QCA_REV_WCN3990(ar)) {
++ /* The WLAN.HL.1.0.1 firmware on the SDM660
++ * modem takes these fields the way qcacld
++ * sends them: only the regulatory power, in
++ * plain dBm (max_tx_power is documented as
++ * "1 dBm units" in the WMI headers). The
++ * doubled half-dBm values below make the TPC
++ * lookup against the per-device board data
++ * fail and the firmware fatally asserts on
++ * the first channel tune of any scan
++ * (err_qdi.c EX:wlan_process).
++ */
++ ch->max_power = 0;
++ ch->max_reg_power = channel->max_reg_power;
++ ch->max_antenna_gain = 0;
++ } else {
++ ch->max_power = channel->max_power * 2;
++ ch->max_reg_power = channel->max_reg_power * 2;
++ ch->max_antenna_gain = channel->max_antenna_gain;
++ }
+ ch->reg_class_id = 0; /* FIXME */
+
+ /* FIXME: why use only legacy modes, why not any
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0012-ath10k-wcn3990-scan-trailing-tlvs.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0012-ath10k-wcn3990-scan-trailing-tlvs.patch
new file mode 100644
index 0000000..e446a64
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0012-ath10k-wcn3990-scan-trailing-tlvs.patch
@@ -0,0 +1,60 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] ath10k: wmi-tlv: append the trailing scan TLVs qcacld sends
+
+The WLAN.HL.1.0.1.c6 firmware of the WCN3990 on SDM660 fatally asserts
+(err_qdi.c EX:wlan_process, RT:2072) as soon as the scan state machine
+processes the first channel of any scan (active or passive, any band).
+Verified on Xiaomi Mi 8 Lite (platina) to be independent of board data,
+regdomain, firmware/modem build, regulators, RF clock, power values in
+the channel list, and PS mode.
+
+qcacld - the driver this firmware was developed against, and which scans
+fine on the same device - always appends two more TLVs to
+WMI_START_SCAN_CMDID after the IE array: the probe request vendor OUI
+whitelist (ARRAY_STRUC) and the per-channel phy mode list (ARRAY_BYTE),
+both zero-length in a normal scan ("Add ZERO legth phy mode TLV" in
+wmi_unified_tlv.c). Mainline stops after the IE array. Append the two
+trailing zero-length TLVs to match qcacld's wire format.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+@@ -1995,7 +1995,9 @@
+ sizeof(*tlv) + chan_len +
+ sizeof(*tlv) + ssid_len +
+ sizeof(*tlv) + bssid_len +
+- sizeof(*tlv) + ie_len;
++ sizeof(*tlv) + ie_len +
++ sizeof(*tlv) + /* zero-length vendor OUI array */
++ sizeof(*tlv); /* zero-length phy mode list */
+
+ skb = ath10k_wmi_alloc_skb(ar, len);
+ if (!skb)
+@@ -2065,6 +2067,26 @@
+ ptr += sizeof(*tlv);
+ ptr += ie_len;
+
++ /* The WMI-TLV firmware of the WCN3990 on SDM660 (WLAN.HL.1.0.1.c6)
++ * expects the two trailing arrays qcacld always appends to
++ * WMI_START_SCAN_CMDID, even when they are empty: the probe request
++ * vendor OUI whitelist and the per-channel phy mode list. Without
++ * them the firmware accepts the command but fatally asserts
++ * (err_qdi.c EX:wlan_process) as soon as the scan state machine
++ * processes the first channel. Append both as zero-length TLVs,
++ * exactly like qcacld does for a normal (non wide-band, no
++ * whitelist) scan.
++ */
++ tlv = ptr;
++ tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
++ tlv->len = __cpu_to_le16(0);
++ ptr += sizeof(*tlv);
++
++ tlv = ptr;
++ tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
++ tlv->len = __cpu_to_le16(0);
++ ptr += sizeof(*tlv);
++
+ ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start scan\n");
+ return skb;
+ }
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0014-ath10k-wcn3990-no-scan-chan-stat.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0014-ath10k-wcn3990-no-scan-chan-stat.patch
new file mode 100644
index 0000000..79409a0
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0014-ath10k-wcn3990-no-scan-chan-stat.patch
@@ -0,0 +1,40 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] ath10k: don't request scan channel stats on WCN3990
+
+The WLAN.HL.1.0.1.c6 firmware of the WCN3990 on SDM660 (Xiaomi Mi 8
+Lite, platina) fatally asserts (err_qdi.c EX:wlan_process, RT:2072,
+a fixed ~87ms after tuning to every scan channel) whenever the scan is
+requested with WMI_SCAN_CHAN_STAT_EVENT. Bisected at runtime with WMI
+flag knobs after eliminating board data, regdomain, channel powers,
+trailing TLVs, firmware/modem builds, PS mode, band crossing and
+regulators/clocks: clearing this single bit turns every scan from a
+guaranteed firmware crash into a reliable full scan of both bands
+(30 BSS found in testing). Reading the MAC cycle counters for the
+channel stats appears to hit a dead hardware block on this platform.
+
+Don't set the flag on WCN3990. Only channel survey data is lost.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/drivers/net/wireless/ath/ath10k/wmi.c
++++ b/drivers/net/wireless/ath/ath10k/wmi.c
+@@ -7096,7 +7096,18 @@
+ | WMI_SCAN_EVENT_FOREIGN_CHANNEL
+ | WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT
+ | WMI_SCAN_EVENT_DEQUEUED;
+- arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
++ /* On the WCN3990 of the SDM660 (WLAN.HL.1.0.1.c6 firmware running
++ * inside the modem, Xiaomi Mi 8 Lite) requesting channel stats makes
++ * the WLAN firmware fatally assert (err_qdi.c EX:wlan_process,
++ * RT:2072) a fixed ~87ms after tuning to every scan channel - active
++ * or passive, any band, any board data. Reading the MAC cycle
++ * counters for the stats appears to hit a dead hardware block on
++ * this platform (rx_clear_count was already known to read frozen).
++ * Bisected at runtime via WMI flag knobs: clearing this single flag
++ * makes scans complete reliably. Only channel survey data is lost.
++ */
++ if (!QCA_REV_WCN3990(ar))
++ arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
+ arg->n_bssids = 1;
+ arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
+ }
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0015-clk-qcom-sdm660-cpu-osm-driver.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0015-clk-qcom-sdm660-cpu-osm-driver.patch
new file mode 100644
index 0000000..199ee03
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0015-clk-qcom-sdm660-cpu-osm-driver.patch
@@ -0,0 +1,904 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] clk: qcom: add SDM660 CPU (OSM) clock driver
+
+CPU frequency scaling driver for SDM660. Programs the OSM (LUT, cycle
+counters, boost/DCVS FSMs, PLL/RCGR config, APM, ITM handoff, sequencer
+microcode, mem-acc/APM voltage, cluster PLLs) then enables it; cpufreq-dt
+scales via the cpu OPP tables. The cluster PLL reconfig parks the mux on
+GPLL0 first to avoid hanging the (little) cluster that runs from it.
+
+Signed-off-by: pmOS Mi8Lite
+---
+diff --git a/drivers/clk/qcom/clk-cpu-sdm660.c b/drivers/clk/qcom/clk-cpu-sdm660.c
+new file mode 100644
+index 0000000..d89c18c
+--- /dev/null
++++ b/drivers/clk/qcom/clk-cpu-sdm660.c
+@@ -0,0 +1,855 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * SDM660 CPU (OSM) clock driver for mainline Linux.
++ *
++ * The SDM660 scales its two Kryo-260 CPU clusters with the OSM (Operating
++ * State Manager) hardware, like the SDM845 - but unlike the SDM845 the
++ * SDM660 bootloader does NOT program the OSM: it leaves ENABLE=0 and the
++ * frequency/voltage LUT empty and runs the cores from a fixed bypass source
++ * (this is why mainline has no cpufreq on SDM660). On Android the secure
++ * world (TrustZone) programs the OSM sequencer/config; on mainline there is
++ * no TZ doing that, so this driver does the full "secure_init" setup itself:
++ *
++ * per cluster: program the freq/voltage LUT from the DT speedbin tables,
++ * program the PLL/RCGR config words and the APM voltage switch;
++ * once: program the ITM handoff and load the OSM sequencer microcode;
++ * then: enable the OSM. From then on cpufreq only writes a LUT index
++ * into DCVS_PERF_STATE_DESIRED and the OSM drives PLL, mux and
++ * voltage on its own.
++ *
++ * No ACD, LLM, trace or FSM optimisations (all optional on SDM660), open-loop
++ * voltages (no CPR3). Reverse-engineered and reduced from the LineageOS
++ * clk-cpu-osm-660 driver.
++ *
++ * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
++ */
++
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++
++/* OSM register offsets (relative to each cluster's OSM base) */
++#define ENABLE_REG 0x1004
++#define SPM_CC_CTRL 0x1028
++#define SEQ_MEM_ADDR 0x500
++#define SEQ_CFG_BR_ADDR 0x170
++#define INDEX_REG 0x1150
++#define FREQ_REG 0x1154
++#define VOLT_REG 0x1158
++#define OVERRIDE_REG 0x115c
++#define SPARE_REG 0x1164
++#define OSM_REG_SIZE 32
++#define OSM_TABLE_SIZE 40
++#define DCVS_PERF_STATE_DESIRED_REG 0x1f10
++#define SEQ_REG(n) (0x300 + (n) * 4)
++
++/* Voltage word: bits[21:16] = virtual corner, bits[11:0] = open-loop mV */
++#define OSM_VC_MASK GENMASK(21, 16)
++#define OSM_OLV_MASK GENMASK(11, 0)
++
++/* PLL / RCGR config words programmed into the OSM sequencer registers */
++#define PLL_MIN_LVAL 43
++#define PLL_POST_DIV1 0x1f
++#define PLL_POST_DIV2 0x11f
++#define GPLL_SEL 0x400
++#define PLL_EARLY_SEL 0x500
++#define PLL_MAIN_SEL 0x300
++#define RCG_UPDATE 0x3
++#define RCG_UPDATE_SUCCESS 0x2
++
++/* APM (Array Power Mux) switch words */
++#define APM_MX_MODE 0
++#define APM_APC_MODE BIT(1)
++#define APM_MODE_SWITCH_MASK (FIELD_PREP(GENMASK(4, 2), 7) | \
++ FIELD_PREP(GENMASK(1, 0), 3))
++#define APM_MX_MODE_VAL 0
++#define APM_APC_MODE_VAL 0x3
++
++/* ITM handoff */
++#define ITM_CL0_DISABLE_CL1_ENABLED 0x2
++#define ITM_CL0_ENABLED_CL1_DISABLE 0x1
++
++/* Cluster PLL (relative to each cluster's PLL base) */
++#define PLL_MODE 0x0
++#define PLL_L_VAL 0x4
++#define PLL_USER_CTRL 0xc
++#define PLL_CONFIG_CTL_LO 0x10
++#define PLL_WAIT_LOCK_TIME_US 10
++#define PLL_SETUP_L_VAL 0x20
++#define PLL_SETUP_USER_CTRL 0x01000008
++#define PLL_SETUP_CONFIG_CTL 0x20004aa8
++
++/* DCVS boost/safe FSMs (relative to OSM base) */
++#define PDN_FSM_CTRL_REG 0x1070
++#define CC_BOOST_EN_MASK BIT(0)
++#define CC_BOOST_TIMER_REG0 0x1074
++#define CC_BOOST_TIMER_REG1 0x1078
++#define CC_BOOST_TIMER_REG2 0x107c
++#define DCVS_BOOST_EN_MASK BIT(2)
++#define DCVS_BOOST_TIMER_REG0 0x1084
++#define DCVS_BOOST_TIMER_REG1 0x1088
++#define DCVS_BOOST_TIMER_REG2 0x108c
++#define PS_BOOST_EN_MASK BIT(1)
++#define PS_BOOST_TIMER_REG0 0x1094
++#define PS_BOOST_TIMER_REG1 0x1098
++#define PS_BOOST_TIMER_REG2 0x109c
++#define BOOST_PROG_SYNC_DELAY_REG 0x10a0
++#define OSM_PLL_SW_OVERRIDE_EN 0x10c0
++#define PLL_SW_OVERRIDE_DROOP_EN BIT(0)
++#define PLL_WAIT_LOCK_TIME_NS 10000
++#define SAFE_FREQ_WAIT_NS 5000
++#define DEXT_DECREMENT_WAIT_NS 1000
++
++/* Cycle counter */
++#define OSM_CYCLE_COUNTER_CTRL_REG 0x1f00
++#define OSM_CYCLE_COUNTER_USE_XO_EDGE BIT(8)
++
++/* clocks (Hz) */
++#define OSM_CLK_RATE 200000000
++#define XO_CLK_RATE 19200000
++
++#define OSM_CORE_TABLE_SIZE 0x2000
++#define NUM_CLUSTERS 2
++
++/* nsec -> OSM clock cycles (osm_clk_rate * nsec / 1e9) */
++static inline u32 osm_count_ns(u64 nsec)
++{
++ u64 t = (u64)OSM_CLK_RATE * nsec;
++
++ do_div(t, 1000000000);
++ return t;
++}
++
++/*
++ * OSM sequencer microcode. This is the "program" the OSM executes to perform
++ * the PLL/mux/voltage transitions; without it ENABLE=1 does nothing. Verbatim
++ * from the downstream clk-cpu-osm-660 (identical for pwrcl and perfcl).
++ */
++static const u32 seq_instr[] = {
++ 0xc2005000, 0x2c9e3b21, 0xc0ab2cdc, 0xc2882525, 0x359dc491, 0x700a500b,
++ 0x5001aefc, 0xaefd7000, 0x390938c8, 0xcb44c833, 0xce56cd54, 0x341336e0,
++ 0xa4baadba, 0xb480a493, 0x10004000, 0x70005001, 0x1000500c, 0xc792c5a1,
++ 0x501625e1, 0x3da335a2, 0x50170006, 0x50150006, 0x1000c633, 0x1000acb3,
++ 0xc422acb4, 0xaefc1000, 0x700a500b, 0x70005001, 0x5010aefd, 0x5012700b,
++ 0xad41700c, 0x84e5adb9, 0xb3808566, 0x239b0003, 0x856484e3, 0xb9800007,
++ 0x2bad0003, 0xac3aa20b, 0x0003181b, 0x0003bb40, 0xa30d239b, 0x500c181b,
++ 0x5011500f, 0x181b3413, 0x853984b9, 0x0003bd80, 0xa0012ba4, 0x72050803,
++ 0x500e1000, 0x500c1000, 0x1c011c0a, 0x3b181c06, 0x1c073b43, 0x1c061000,
++ 0x1c073983, 0x1c02500c, 0x10001c0a, 0x70015002, 0x81031000, 0x70025003,
++ 0x70035004, 0x3b441000, 0x81553985, 0x70025003, 0x50054003, 0xa1467009,
++ 0x0003b1c0, 0x4005238b, 0x835a1000, 0x855c84db, 0x1000a51f, 0x84de835d,
++ 0xa52c855c, 0x50061000, 0x39cd3a4c, 0x3ad03a8f, 0x10004006, 0x70065007,
++ 0xa00f2c12, 0x08034007, 0xaefc7205, 0xaefd700d, 0xa9641000, 0x40071c1a,
++ 0x700daefc, 0x1000aefd, 0x70065007, 0x50101c16, 0x40075012, 0x700daefc,
++ 0x2411aefd, 0xa8211000, 0x0803a00f, 0x500c7005, 0x1c1591e0, 0x500f5014,
++ 0x10005011, 0x500c2bd4, 0x0803a00f, 0x10007205, 0xa00fa9d1, 0x0803a821,
++ 0xa9d07005, 0x91e0500c, 0x500f1c15, 0x10005011, 0x1c162bce, 0x50125010,
++ 0xa022a82a, 0x70050803, 0x1c1591df, 0x5011500f, 0x5014500c, 0x0803a00f,
++ 0x10007205, 0x501391a4, 0x22172217, 0x70075008, 0xa9634008, 0x1c1a0006,
++ 0x70085009, 0x10004009, 0x00008ed9, 0x3e05c8dd, 0x1c033604, 0xabaf1000,
++ 0x856284e1, 0x0003bb80, 0x1000239f, 0x0803a037, 0x10007205, 0x8dc61000,
++ 0x38a71c2a, 0x1c2a8dc4, 0x100038a6, 0x1c2a8dc5, 0x8dc73867, 0x38681c2a,
++ 0x8c491000, 0x8d4b8cca, 0x10001c00, 0x8ccd8c4c, 0x1c008d4e, 0x8c4f1000,
++ 0x8d518cd0, 0x10001c00, 0xa759a79a, 0x1000a718, 0xbf80af9b, 0x00001000,
++};
++
++static const u32 seq_br_instr[] = {
++ 0x00000248, 0x0000020e, 0x0000021c, 0x000000f6, 0x00000112, 0x0000011c,
++ 0x000000e4, 0x000000ea, 0x000000c6, 0x000000d6, 0x00000126, 0x00000108,
++ 0x00000184, 0x000001a8, 0x000001b0, 0x00000134, 0x00000158, 0x0000016e,
++ 0x0000014a, 0x000000c2, 0x00000190, 0x000001d2, 0x000001cc, 0x000001d4,
++ 0x000001e8, 0x00000000, 0x000001f6, 0x00000032, 0x00000066, 0x000000b0,
++ 0x000000a6, 0x000001fc, 0x0000003c, 0x00000044, 0x0000005c, 0x00000060,
++ 0x00000204, 0x00000030, 0x0000022a, 0x00000234, 0x0000023e, 0x00000000,
++ 0x00000250, 0x00000000, 0x00000000, 0x0000009a, 0x0000020c,
++};
++
++struct osm_entry {
++ u32 freq_data;
++ u32 override_data;
++ u32 spare_data;
++ u32 virtual_corner; /* 0-based */
++ u32 open_loop_volt; /* mV */
++ unsigned long frequency;
++};
++
++struct sdm660_osm_clk {
++ struct clk_hw hw;
++ void __iomem *base; /* this cluster's OSM base (read) */
++ phys_addr_t phys; /* this cluster's OSM base (phys, for SCM) */
++ void __iomem *pll_base; /* this cluster's HFPLL base */
++ void __iomem *rcgr_base; /* this cluster's APCS RCGR mux */
++ /* per-cluster config addresses (physical values fed to the OSM) */
++ u32 l_val_base;
++ u32 apcs_pll_user_ctl;
++ u32 apcs_cfg_rcgr;
++ u32 apcs_cmd_rcgr;
++ u32 apcs_itm_present;
++ u32 apm_mode_ctl;
++ u32 apm_ctrl_status;
++ u32 itm_handoff; /* ITM_CL0_* value for this cluster */
++ struct osm_entry table[OSM_TABLE_SIZE];
++ int num_entries;
++};
++
++#define to_osm_clk(_hw) container_of(_hw, struct sdm660_osm_clk, hw)
++
++/*
++ * The OSM register block has two write-protection domains on this SoC,
++ * confirmed live via /dev/mem: control/LUT registers at offset >= 0x1000
++ * (ENABLE, the freq/volt LUT, the boost/DCVS FSMs, DCVS_PERF_STATE_DESIRED)
++ * accept ordinary non-secure writes, but the whole sequencer region below
++ * that - the branch table at 0x170 and the SEQ_MEM microcode / SEQ_REG
++ * parameter area at 0x300-0x5ff - is XPU-protected: a plain writel from the
++ * kernel is silently dropped, leaving the sequencer empty so the OSM enables
++ * but never transitions. Those writes must go through the secure world, which
++ * is exactly what the downstream driver does (scm_io_write) - the TrustZone on
++ * this device implements SCM_IO_WRITE (the OSM is programmed this way under
++ * Android). So route < 0x1000 through qcom_scm_io_writel and the rest direct.
++ */
++#define OSM_SECURE_LIMIT 0x1000
++
++static void osm_w(struct sdm660_osm_clk *c, u32 val, u32 off)
++{
++ /*
++ * r54 diagnostic: previously off < OSM_SECURE_LIMIT was routed through
++ * qcom_scm_io_writel, which is a silent no-op on this SoC (SCM readback
++ * returned 0). Write everything directly to test whether a plain kernel
++ * writel to the sequencer region actually lands (checked via SCM
++ * readback in probe: reg21 should read back PLL_MIN_LVAL if it does).
++ */
++ writel_relaxed(val, c->base + off);
++}
++
++static inline u32 osm_r(struct sdm660_osm_clk *c, u32 off)
++{
++ return readl_relaxed(c->base + off);
++}
++
++/* --- clk_ops: with the OSM running, set_rate is a single index vote --- */
++
++static int osm_search(struct sdm660_osm_clk *c, unsigned long rate)
++{
++ int i;
++
++ for (i = 0; i < c->num_entries; i++)
++ if (c->table[i].frequency == rate)
++ return i;
++ return -EINVAL;
++}
++
++static int sdm660_osm_set_rate(struct clk_hw *hw, unsigned long rate,
++ unsigned long parent_rate)
++{
++ struct sdm660_osm_clk *c = to_osm_clk(hw);
++ int index = osm_search(c, rate);
++
++ if (index < 0)
++ return index;
++ osm_w(c, index, DCVS_PERF_STATE_DESIRED_REG);
++ wmb(); /* ensure the vote reaches the OSM */
++ return 0;
++}
++
++static unsigned long sdm660_osm_recalc_rate(struct clk_hw *hw,
++ unsigned long parent_rate)
++{
++ struct sdm660_osm_clk *c = to_osm_clk(hw);
++ u32 index = osm_r(c, DCVS_PERF_STATE_DESIRED_REG);
++
++ if (index >= c->num_entries)
++ index = c->num_entries - 1;
++ return c->table[index].frequency;
++}
++
++static int sdm660_osm_determine_rate(struct clk_hw *hw,
++ struct clk_rate_request *req)
++{
++ struct sdm660_osm_clk *c = to_osm_clk(hw);
++ unsigned long best = c->table[0].frequency;
++ int i;
++
++ for (i = 0; i < c->num_entries; i++)
++ if (c->table[i].frequency <= req->rate &&
++ c->table[i].frequency > best)
++ best = c->table[i].frequency;
++ req->rate = best;
++ return 0;
++}
++
++static const struct clk_ops sdm660_osm_ops = {
++ .set_rate = sdm660_osm_set_rate,
++ .recalc_rate = sdm660_osm_recalc_rate,
++ .determine_rate = sdm660_osm_determine_rate,
++};
++
++/* --- one-time OSM programming --- */
++
++static void osm_setup_lut(struct sdm660_osm_clk *c)
++{
++ int i;
++
++ for (i = 0; i < OSM_TABLE_SIZE; i++) {
++ u32 freq = 0, volt = 0, override = 0, spare = 0;
++ u32 off = i * OSM_REG_SIZE;
++
++ if (i < c->num_entries) {
++ freq = c->table[i].freq_data;
++ volt = FIELD_PREP(OSM_VC_MASK, c->table[i].virtual_corner) |
++ FIELD_PREP(OSM_OLV_MASK, c->table[i].open_loop_volt);
++ override = c->table[i].override_data;
++ spare = c->table[i].spare_data;
++ }
++ osm_w(c, i, INDEX_REG + off);
++ osm_w(c, freq, FREQ_REG + off);
++ osm_w(c, volt, VOLT_REG + off);
++ osm_w(c, override, OVERRIDE_REG + off);
++ osm_w(c, spare, SPARE_REG + off);
++ }
++ wmb();
++}
++
++static void osm_program_apm(struct sdm660_osm_clk *c)
++{
++ osm_w(c, c->apm_mode_ctl, SEQ_REG(2));
++ osm_w(c, c->apm_ctrl_status, SEQ_REG(3));
++ osm_w(c, APM_MX_MODE, SEQ_REG(77));
++ osm_w(c, APM_MX_MODE_VAL, SEQ_REG(78));
++ osm_w(c, APM_MODE_SWITCH_MASK, SEQ_REG(79));
++ osm_w(c, APM_APC_MODE, SEQ_REG(80));
++ osm_w(c, APM_APC_MODE_VAL, SEQ_REG(81));
++}
++
++/* program the PLL/RCGR config + APM the OSM sequencer needs (secure_init) */
++static void osm_program_config(struct sdm660_osm_clk *c)
++{
++ osm_w(c, FIELD_PREP(GENMASK(23, 16), 0xf), SPM_CC_CTRL);
++ osm_w(c, c->l_val_base, SEQ_REG(0));
++ osm_w(c, PLL_MIN_LVAL, SEQ_REG(21));
++ osm_w(c, c->apcs_pll_user_ctl, SEQ_REG(18));
++ osm_w(c, PLL_POST_DIV2, SEQ_REG(19));
++ osm_w(c, PLL_POST_DIV1, SEQ_REG(29));
++
++ osm_program_apm(c);
++
++ osm_w(c, c->apcs_cfg_rcgr, SEQ_REG(16));
++ osm_w(c, c->apcs_cmd_rcgr, SEQ_REG(33));
++ osm_w(c, RCG_UPDATE, SEQ_REG(34));
++ osm_w(c, GPLL_SEL, SEQ_REG(17));
++ osm_w(c, PLL_EARLY_SEL, SEQ_REG(82));
++ osm_w(c, PLL_MAIN_SEL, SEQ_REG(83));
++ osm_w(c, RCG_UPDATE_SUCCESS, SEQ_REG(84));
++ osm_w(c, RCG_UPDATE, SEQ_REG(85));
++ wmb();
++}
++
++/*
++ * MEM ACC + APM voltage-crossover sequencer setup. The sequencer consults
++ * these while ramping voltage during a DCVS transition; without them it stalls
++ * after switching the RCGR to the safe source (seen live: RCGR moves but the
++ * PLL never ramps). Because this driver runs every corner at the max CPR
++ * ceiling (see osm_get_lut) the APM always stays on APCC, so the threshold
++ * corner is 0 and the crossover never actually triggers.
++ */
++#define MEM_ACC_APM_READ_MASK 0xff
++#define APM_THRESHOLD_VC 0
++#define APM_CROSSOVER_VC 3
++#define OSM_SEQ_MINUS_ONE 0xff
++
++static void osm_program_mem_acc(struct sdm660_osm_clk *c)
++{
++ osm_w(c, 1, SEQ_REG(51));
++ osm_w(c, 2, SEQ_REG(52));
++ osm_w(c, 3, SEQ_REG(53));
++ osm_w(c, 4, SEQ_REG(54));
++ osm_w(c, MEM_ACC_APM_READ_MASK, SEQ_REG(59));
++ osm_w(c, 0, SEQ_REG(55));
++ osm_w(c, 1, SEQ_REG(56));
++ osm_w(c, 0, SEQ_REG(57));
++ osm_w(c, 1, SEQ_REG(58));
++ osm_w(c, c->phys + SEQ_REG(28), SEQ_REG(49));
++ wmb();
++}
++
++static void osm_program_apm_vc(struct sdm660_osm_clk *c)
++{
++ osm_w(c, APM_THRESHOLD_VC, SEQ_REG(1));
++ osm_w(c, APM_CROSSOVER_VC, SEQ_REG(72));
++ osm_w(c, c->phys + SEQ_REG(1), SEQ_REG(8));
++ osm_w(c, APM_THRESHOLD_VC, SEQ_REG(15));
++ osm_w(c, OSM_SEQ_MINUS_ONE, SEQ_REG(31));
++ osm_w(c, 0x3b | (APM_THRESHOLD_VC << 6), SEQ_REG(73));
++ osm_w(c, 0x39 | (APM_THRESHOLD_VC << 6), SEQ_REG(76));
++ wmb();
++}
++
++static void osm_program_handoff(struct sdm660_osm_clk *c)
++{
++ osm_w(c, c->apcs_itm_present, SEQ_REG(37));
++ osm_w(c, 0, SEQ_REG(38));
++ osm_w(c, c->itm_handoff, SEQ_REG(39));
++ wmb();
++}
++
++static void osm_load_sequencer(struct sdm660_osm_clk *c)
++{
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(seq_instr); i++)
++ osm_w(c, seq_instr[i], SEQ_MEM_ADDR + i * 4);
++ for (i = 0; i < ARRAY_SIZE(seq_br_instr); i++)
++ osm_w(c, seq_br_instr[i], SEQ_CFG_BR_ADDR + i * 4);
++ wmb();
++}
++
++/* OSM-to-XO cycle counter, needed by the boost/DCVS FSMs for their timers */
++static void osm_setup_cycle_counters(struct sdm660_osm_clk *c)
++{
++ u32 ratio = OSM_CLK_RATE / XO_CLK_RATE;
++ u32 val = BIT(0) | FIELD_PREP(GENMASK(5, 1), ratio - 1) |
++ OSM_CYCLE_COUNTER_USE_XO_EDGE;
++
++ osm_w(c, val, OSM_CYCLE_COUNTER_CTRL_REG);
++ wmb();
++}
++
++/*
++ * Program the boost (frequency up) and safe/DCVS (frequency down) FSMs. These
++ * are what actually carry out a DCVS request: without them the OSM latches the
++ * desired index but never drives the PLL/mux. boost + safe + PS are enabled
++ * (the wfx/pc/droop FSMs are power-collapse/di-dt droop refinements, optional).
++ */
++static void osm_setup_fsms(struct sdm660_osm_clk *c)
++{
++ u32 val;
++
++ /* boost FSM (ramp up) */
++ val = osm_r(c, PDN_FSM_CTRL_REG) | CC_BOOST_EN_MASK;
++ osm_w(c, val, PDN_FSM_CTRL_REG);
++
++ val = osm_r(c, CC_BOOST_TIMER_REG0);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ val |= FIELD_PREP(GENMASK(31, 16), osm_count_ns(SAFE_FREQ_WAIT_NS));
++ osm_w(c, val, CC_BOOST_TIMER_REG0);
++
++ val = osm_r(c, CC_BOOST_TIMER_REG1);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ val |= FIELD_PREP(GENMASK(31, 16), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ osm_w(c, val, CC_BOOST_TIMER_REG1);
++
++ val = osm_r(c, CC_BOOST_TIMER_REG2);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(DEXT_DECREMENT_WAIT_NS));
++ osm_w(c, val, CC_BOOST_TIMER_REG2);
++
++ /* safe / DCVS boost FSM (ramp down) */
++ val = osm_r(c, PDN_FSM_CTRL_REG) | DCVS_BOOST_EN_MASK;
++ osm_w(c, val, PDN_FSM_CTRL_REG);
++
++ val = osm_r(c, DCVS_BOOST_TIMER_REG0);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ val |= FIELD_PREP(GENMASK(31, 16), osm_count_ns(SAFE_FREQ_WAIT_NS));
++ osm_w(c, val, DCVS_BOOST_TIMER_REG0);
++
++ val = osm_r(c, DCVS_BOOST_TIMER_REG1);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ val |= FIELD_PREP(GENMASK(31, 16), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ osm_w(c, val, DCVS_BOOST_TIMER_REG1);
++
++ val = osm_r(c, DCVS_BOOST_TIMER_REG2);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(DEXT_DECREMENT_WAIT_NS));
++ osm_w(c, val, DCVS_BOOST_TIMER_REG2);
++
++ /*
++ * PS (perf-state) FSM. r56: the working downstream enables this too and
++ * it is the FSM that carries out a perf-state (DCVS_PERF_STATE_DESIRED)
++ * transition - without it the OSM latched the desired index but never
++ * drove the PLL/mux (the r49..r55 symptom).
++ */
++ val = osm_r(c, PDN_FSM_CTRL_REG) | PS_BOOST_EN_MASK;
++ osm_w(c, val, PDN_FSM_CTRL_REG);
++
++ val = osm_r(c, PS_BOOST_TIMER_REG0);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ val |= FIELD_PREP(GENMASK(31, 16), osm_count_ns(SAFE_FREQ_WAIT_NS));
++ osm_w(c, val, PS_BOOST_TIMER_REG0);
++
++ val = osm_r(c, PS_BOOST_TIMER_REG1);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ val |= FIELD_PREP(GENMASK(31, 16), osm_count_ns(PLL_WAIT_LOCK_TIME_NS));
++ osm_w(c, val, PS_BOOST_TIMER_REG1);
++
++ val = osm_r(c, PS_BOOST_TIMER_REG2);
++ val |= FIELD_PREP(GENMASK(15, 0), osm_count_ns(DEXT_DECREMENT_WAIT_NS));
++ osm_w(c, val, PS_BOOST_TIMER_REG2);
++
++ osm_w(c, 0x5, BOOST_PROG_SYNC_DELAY_REG);
++
++ val = osm_r(c, OSM_PLL_SW_OVERRIDE_EN) | PLL_SW_OVERRIDE_DROOP_EN;
++ osm_w(c, val, OSM_PLL_SW_OVERRIDE_EN);
++ wmb();
++}
++
++/* APCS RCGR mux: cmd at +0x0, cfg at +0x4; SRC_SEL is cfg[10:8] */
++#define RCGR_CMD 0x0
++#define RCGR_CFG 0x4
++#define RCGR_UPDATE_BIT BIT(0)
++#define RCGR_SRC_MASK GENMASK(10, 8)
++#define RCGR_SRC_GPLL0 4 /* GPLL0 (safe bypass) */
++
++static void rcgr_do_update(struct sdm660_osm_clk *c)
++{
++ int i;
++
++ writel_relaxed(readl_relaxed(c->rcgr_base + RCGR_CMD) | RCGR_UPDATE_BIT,
++ c->rcgr_base + RCGR_CMD);
++ for (i = 0; i < 200; i++) {
++ if (!(readl_relaxed(c->rcgr_base + RCGR_CMD) & RCGR_UPDATE_BIT))
++ break;
++ udelay(1);
++ }
++}
++
++/*
++ * Reconfigure the cluster HFPLL so the OSM can drive it. Reconfiguring means
++ * briefly powering the PLL down (MODE=0), which hangs the cluster if it is
++ * currently clocked from that PLL - and the little cluster (which runs the
++ * kernel) is. So first switch the cluster's RCGR mux to GPLL0, reconfigure the
++ * PLL, then switch it back. Verified live: without the bypass this hangs.
++ */
++static void __maybe_unused osm_setup_cluster_pll(struct sdm660_osm_clk *c)
++{
++ u32 cfg = readl_relaxed(c->rcgr_base + RCGR_CFG);
++
++ /* park the cluster on GPLL0 */
++ writel_relaxed((cfg & ~RCGR_SRC_MASK) |
++ FIELD_PREP(RCGR_SRC_MASK, RCGR_SRC_GPLL0),
++ c->rcgr_base + RCGR_CFG);
++ rcgr_do_update(c);
++ udelay(1);
++
++ writel_relaxed(0x0, c->pll_base + PLL_MODE);
++ writel_relaxed(PLL_SETUP_L_VAL, c->pll_base + PLL_L_VAL);
++ writel_relaxed(PLL_SETUP_USER_CTRL, c->pll_base + PLL_USER_CTRL);
++ writel_relaxed(PLL_SETUP_CONFIG_CTL, c->pll_base + PLL_CONFIG_CTL_LO);
++ writel_relaxed(0x2, c->pll_base + PLL_MODE);
++ wmb();
++ udelay(PLL_WAIT_LOCK_TIME_US);
++ writel_relaxed(0x6, c->pll_base + PLL_MODE);
++ wmb();
++ usleep_range(50, 75);
++ writel_relaxed(0x7, c->pll_base + PLL_MODE);
++ wmb();
++
++ /* restore the original mux selection */
++ writel_relaxed(cfg, c->rcgr_base + RCGR_CFG);
++ rcgr_do_update(c);
++}
++
++static void __maybe_unused osm_enable(struct sdm660_osm_clk *c)
++{
++ udelay(5);
++ osm_w(c, 1, ENABLE_REG);
++ wmb();
++ udelay(5);
++}
++
++/* --- device tree LUT parsing --- */
++
++static int osm_get_lut(struct device *dev, struct sdm660_osm_clk *c,
++ const char *prop, const u32 *ceil_uv, int ceil_cnt)
++{
++ struct device_node *np = dev->of_node;
++ int len, rows, i, j;
++ u32 vmax = 0;
++
++ len = of_property_count_u32_elems(np, prop);
++ if (len < 0)
++ return dev_err_probe(dev, len, "missing %s\n", prop);
++ rows = len / 5;
++ if (rows > OSM_TABLE_SIZE)
++ rows = OSM_TABLE_SIZE;
++
++ /*
++ * First cut: run every corner at the highest CPR ceiling. The
++ * per-corner virtual-corner -> voltage mapping goes through the CPR3
++ * fuse/fmax tables which this driver does not model; using the max
++ * ceiling for all entries over-volts the low frequencies (wastes a
++ * little power) but guarantees no frequency is ever under-volted.
++ * Proper per-corner open-loop scaling is a later optimisation.
++ */
++ for (j = 0; j < ceil_cnt; j++)
++ if (ceil_uv[j] > vmax)
++ vmax = ceil_uv[j];
++
++ for (i = 0; i < rows; i++) {
++ u32 cell[5];
++
++ for (j = 0; j < 5; j++)
++ of_property_read_u32_index(np, prop, i * 5 + j, &cell[j]);
++ /* [0]freq [1]freq_data [2]override [3]virtual_corner(1-based) [4]spare */
++ c->table[i].frequency = cell[0];
++ c->table[i].freq_data = cell[1];
++ c->table[i].override_data = cell[2];
++ c->table[i].virtual_corner = cell[3] - 1;
++ c->table[i].spare_data = cell[4];
++ c->table[i].open_loop_volt = vmax / 1000;
++ }
++ c->num_entries = rows;
++ return 0;
++}
++
++static struct clk_hw *osm_hws[NUM_CLUSTERS];
++
++static struct clk_hw *osm_of_get(struct of_phandle_args *args, void *data)
++{
++ unsigned int idx = args->args[0];
++
++ return idx < NUM_CLUSTERS ? osm_hws[idx] : ERR_PTR(-EINVAL);
++}
++
++struct cluster_cfg {
++ const char *name;
++ const char *lut_prop;
++ const char *ceil_prop;
++ u32 base_off;
++ u32 pll_phys;
++ u32 l_val_base, pll_user_ctl, cfg_rcgr, cmd_rcgr, itm_present;
++ u32 apm_mode_ctl, apm_ctrl_status, itm_handoff;
++};
++
++/* physical addresses come from the SDM660 APCS layout (fixed for this SoC) */
++static const struct cluster_cfg cluster_cfgs[NUM_CLUSTERS] = {
++ { /* cluster 0: power (little) cpu0-3 */
++ .name = "pwrcl_clk", .base_off = 0,
++ .lut_prop = "qcom,pwrcl-speedbin0-v0",
++ .ceil_prop = "qcom,pwrcl-voltage-ceiling",
++ .pll_phys = 0x17916000,
++ .l_val_base = 0x17916004, .pll_user_ctl = 0x1791600c,
++ .cfg_rcgr = 0x17911054, .cmd_rcgr = 0x17911050,
++ .itm_present = 0x179d143c,
++ .apm_mode_ctl = 0x179d0004, .apm_ctrl_status = 0x179d000c,
++ .itm_handoff = ITM_CL0_DISABLE_CL1_ENABLED,
++ },
++ { /* cluster 1: performance (big) cpu4-7 */
++ .name = "perfcl_clk", .base_off = OSM_CORE_TABLE_SIZE,
++ .lut_prop = "qcom,perfcl-speedbin1-v0",
++ .ceil_prop = "qcom,perfcl-voltage-ceiling",
++ .pll_phys = 0x17816000,
++ .l_val_base = 0x17816004, .pll_user_ctl = 0x1781600c,
++ .cfg_rcgr = 0x17811054, .cmd_rcgr = 0x17811050,
++ .itm_present = 0x179d143c,
++ .apm_mode_ctl = 0x179d0010, .apm_ctrl_status = 0x179d0018,
++ .itm_handoff = ITM_CL0_ENABLED_CL1_DISABLE,
++ },
++};
++
++static int sdm660_osm_probe(struct platform_device *pdev)
++{
++ struct device *dev = &pdev->dev;
++ struct sdm660_osm_clk *cl[NUM_CLUSTERS];
++ void __iomem *osm_base;
++ struct resource *osm_res;
++ struct clk *aux;
++ int i, ret;
++
++ /*
++ * The sequencer setup writes go through the secure monitor
++ * (qcom_scm_io_writel). This clock controller can probe before the SCM
++ * firmware driver is up, in which case those writes would be dropped and
++ * the OSM would enable with an empty sequencer - so defer until SCM is
++ * available.
++ */
++ if (!qcom_scm_is_available())
++ return dev_err_probe(dev, -EPROBE_DEFER, "waiting for qcom_scm\n");
++
++ /* GPLL0/aux feeds the OSM sequencer clock; keep it on */
++ aux = devm_clk_get_enabled(dev, "aux");
++ if (IS_ERR(aux))
++ return dev_err_probe(dev, PTR_ERR(aux), "no aux clock\n");
++
++ osm_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "osm");
++ osm_base = devm_ioremap_resource(dev, osm_res);
++ if (IS_ERR(osm_base))
++ return PTR_ERR(osm_base);
++
++ for (i = 0; i < NUM_CLUSTERS; i++) {
++ const struct cluster_cfg *cfg = &cluster_cfgs[i];
++ u32 ceil[8];
++ int ceil_cnt;
++
++ cl[i] = devm_kzalloc(dev, sizeof(*cl[i]), GFP_KERNEL);
++ if (!cl[i])
++ return -ENOMEM;
++
++ cl[i]->base = osm_base + cfg->base_off;
++ cl[i]->phys = osm_res->start + cfg->base_off;
++ cl[i]->pll_base = devm_ioremap(dev, cfg->pll_phys, 0x100);
++ if (!cl[i]->pll_base)
++ return -ENOMEM;
++ cl[i]->rcgr_base = devm_ioremap(dev, cfg->cmd_rcgr, 0x10);
++ if (!cl[i]->rcgr_base)
++ return -ENOMEM;
++ cl[i]->l_val_base = cfg->l_val_base;
++ cl[i]->apcs_pll_user_ctl = cfg->pll_user_ctl;
++ cl[i]->apcs_cfg_rcgr = cfg->cfg_rcgr;
++ cl[i]->apcs_cmd_rcgr = cfg->cmd_rcgr;
++ cl[i]->apcs_itm_present = cfg->itm_present;
++ cl[i]->apm_mode_ctl = cfg->apm_mode_ctl;
++ cl[i]->apm_ctrl_status = cfg->apm_ctrl_status;
++ cl[i]->itm_handoff = cfg->itm_handoff;
++
++ ceil_cnt = of_property_read_variable_u32_array(dev->of_node,
++ cfg->ceil_prop, ceil, 1, ARRAY_SIZE(ceil));
++ if (ceil_cnt < 0)
++ ceil_cnt = 0;
++
++ ret = osm_get_lut(dev, cl[i], cfg->lut_prop, ceil, ceil_cnt);
++ if (ret)
++ return ret;
++
++ /* order mirrors the downstream probe (secure_init path) */
++ osm_setup_cycle_counters(cl[i]);
++ osm_setup_lut(cl[i]);
++ osm_setup_fsms(cl[i]);
++ osm_program_config(cl[i]);
++ }
++
++ /* handoff, sequencer microcode and voltage setup (both clusters) */
++ for (i = 0; i < NUM_CLUSTERS; i++) {
++ osm_program_handoff(cl[i]);
++ osm_load_sequencer(cl[i]);
++ osm_program_mem_acc(cl[i]);
++ osm_program_apm_vc(cl[i]);
++ }
++
++ /* prepare the cluster PLLs, enable the OSM and register the clocks */
++ for (i = 0; i < NUM_CLUSTERS; i++) {
++ struct clk_init_data init = {
++ .name = cluster_cfgs[i].name,
++ .ops = &sdm660_osm_ops,
++ };
++
++ /*
++ * r57: OSM enable DISABLED. Exhaustive testing (r49-r56, with
++ * the freq/voltage LUT + FSMs + CPRh all verified byte-correct
++ * against a working downstream device) proved the OSM latches
++ * the perf-state vote (DCVS_PERF_STATE_DESIRED) but never drives
++ * the PLL/mux: the transition needs the sequencer config in the
++ * OSM's <0x1000 region, which is XPU-protected and established
++ * only by the Android secure-boot flow, not reproducible from a
++ * mainline boot. Leaving the OSM disabled keeps the driver inert
++ * (everything is programmed but nothing enabled) and the boot
++ * stable; the CPUs run at the bootloader-set fixed rate. Flip the
++ * two calls below back on to reproduce the experiment.
++ */
++ if (0) {
++ osm_setup_cluster_pll(cl[i]);
++ osm_enable(cl[i]);
++ }
++ cl[i]->hw.init = &init;
++ ret = devm_clk_hw_register(dev, &cl[i]->hw);
++ if (ret)
++ return ret;
++ osm_hws[i] = &cl[i]->hw;
++ }
++
++ /*
++ * r54 decisive test. Since r50 every build wrote the sequencer through
++ * qcom_scm_io_writel (proven a silent no-op in r51); the "plain kernel
++ * writel + read back through the secure monitor" combination was NEVER
++ * tried, so whether a kernel writel to the < 0x1000 region lands is still
++ * genuinely open. VERSION_REG (0x0) is a fixed non-zero HW id in the same
++ * XPU domain and acts as a control: if its SCM read is non-zero, SCM reads
++ * of this region are NOT masked and reg21 is trustworthy - reg21 ==
++ * PLL_MIN_LVAL then means the plain writel LANDED (sequencer loadable,
++ * re-enable the OSM in r55). If SCMver reads 0 as well, SCM reads are
++ * masked and every past "seq0=0" datum (the "sequencer empty" evidence)
++ * was unsound and the sequencer may in fact be programmed.
++ */
++ for (i = 0; i < NUM_CLUSTERS; i++) {
++ u32 scm_seq0 = 0, scm_reg21 = 0, scm_ver = 0;
++ u32 hlos_ver = osm_r(cl[i], 0x0);
++ int r0, r2, rv;
++
++ rv = qcom_scm_io_readl(cl[i]->phys + 0x0, &scm_ver);
++ r0 = qcom_scm_io_readl(cl[i]->phys + SEQ_MEM_ADDR, &scm_seq0);
++ r2 = qcom_scm_io_readl(cl[i]->phys + SEQ_REG(21), &scm_reg21);
++
++ dev_info(dev,
++ "%s: enable=%#x desired=%u | VER hlos=%#x scm(%d)=%#x | SCM(%d/%d) seq0=%#x reg21=%#x(exp %d)\n",
++ cluster_cfgs[i].name,
++ osm_r(cl[i], ENABLE_REG),
++ osm_r(cl[i], DCVS_PERF_STATE_DESIRED_REG),
++ hlos_ver, rv, scm_ver,
++ r0, r2, scm_seq0, scm_reg21, PLL_MIN_LVAL);
++ }
++
++ return devm_of_clk_add_hw_provider(dev, osm_of_get, NULL);
++}
++
++static const struct of_device_id sdm660_osm_match[] = {
++ { .compatible = "qcom,sdm660-osm" },
++ {}
++};
++MODULE_DEVICE_TABLE(of, sdm660_osm_match);
++
++static struct platform_driver sdm660_osm_driver = {
++ .probe = sdm660_osm_probe,
++ .driver = {
++ .name = "sdm660-osm-cpu",
++ .of_match_table = sdm660_osm_match,
++ },
++};
++module_platform_driver(sdm660_osm_driver);
++
++/*
++ * Boot-stage diagnostic. On this SoC the OSM sequencer is meant to be
++ * programmed by the secure world before Linux (secure_init=false model), so it
++ * should already contain microcode when Linux starts. Sample it before this
++ * driver's probe (fs_initcall) and after it (late_initcall): if the pre-probe
++ * read shows the first microcode word (0xc2005000) but the post-probe read
++ * shows 0, this driver's probe is clearing the firmware-programmed sequencer.
++ */
++static void osm_dbg_dump(const char *stage)
++{
++ void __iomem *b = ioremap(0x179c0000, 0x3000);
++ u32 en = 0, hp = 0, hb = 0, sp = 0, sb = 0;
++ int rs = -1;
++
++ if (b) {
++ en = readl_relaxed(b + ENABLE_REG);
++ hp = readl_relaxed(b + SEQ_MEM_ADDR);
++ hb = readl_relaxed(b + OSM_CORE_TABLE_SIZE + SEQ_MEM_ADDR);
++ iounmap(b);
++ }
++ if (qcom_scm_is_available()) {
++ rs = qcom_scm_io_readl(0x179c0000 + SEQ_MEM_ADDR, &sp);
++ qcom_scm_io_readl(0x179c2000 + SEQ_MEM_ADDR, &sb);
++ }
++ pr_info("sdm660-osm DBG[%s]: pwrcl ENABLE=%#x | readl seq0 pwrcl=%#x perfcl=%#x | SCM(ret %d) pwrcl=%#x perfcl=%#x\n",
++ stage, en, hp, hb, rs, sp, sb);
++}
++
++static int __init osm_dbg_fs(void)
++{
++ osm_dbg_dump("fs/pre-probe");
++ return 0;
++}
++fs_initcall(osm_dbg_fs);
++
++static int __init osm_dbg_late(void)
++{
++ osm_dbg_dump("late/post-probe");
++ return 0;
++}
++late_initcall(osm_dbg_late);
++
++MODULE_DESCRIPTION("Qualcomm SDM660 CPU (OSM) clock driver");
++MODULE_LICENSE("GPL");
+diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
+index a284ba0..9e8d43d 100644
+--- a/drivers/clk/qcom/Kconfig
++++ b/drivers/clk/qcom/Kconfig
+@@ -871,6 +871,15 @@ config SDM_GCC_660
+ Say Y if you want to use peripheral devices such as UART, SPI,
+ i2C, USB, UFS, SDDC, PCIe, etc.
+
++config SDM660_CPU_CLK
++ tristate "SDM660 CPU (OSM) Clock Controller"
++ depends on ARM64 || COMPILE_TEST
++ help
++ Support for the Operating State Manager (OSM) that drives the two
++ Kryo-260 CPU clusters on SDM660. Unlike SDM845 the bootloader does
++ not program the OSM, so this driver loads the frequency/voltage
++ tables and the sequencer microcode itself, enabling cpufreq.
++
+ config SDM_MMCC_660
+ tristate "SDM660 Multimedia Clock Controller"
+ depends on ARM64 || COMPILE_TEST
+diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
+index 0ac8a90..e7d1ff2 100644
+--- a/drivers/clk/qcom/Makefile
++++ b/drivers/clk/qcom/Makefile
+@@ -121,6 +121,7 @@ obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o
+ obj-$(CONFIG_SDM_GCC_660) += gcc-sdm660.o
+ obj-$(CONFIG_SDM_MMCC_660) += mmcc-sdm660.o
+ obj-$(CONFIG_SDM_GPUCC_660) += gpucc-sdm660.o
++obj-$(CONFIG_SDM660_CPU_CLK) += clk-cpu-sdm660.o
+ obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
+ obj-$(CONFIG_SDM_GPUCC_845) += gpucc-sdm845.o
+ obj-$(CONFIG_SDM_LPASSCC_845) += lpasscc-sdm845.o
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0016-arm64-dts-sdm660-platina-osm-cpufreq.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0016-arm64-dts-sdm660-platina-osm-cpufreq.patch
new file mode 100644
index 0000000..eca464a
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0016-arm64-dts-sdm660-platina-osm-cpufreq.patch
@@ -0,0 +1,101 @@
+From: Platina local project
+Subject: [PATCH] Rebase platina OSM nodes after preceding display/battery patches
+
+Keep upstream OSM data unchanged; the original patch incorrectly expected
+the USB block to be at EOF although patch 0001 appends display nodes there.
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -15,6 +15,7 @@
+ #include
+ #include
+ #include
++#include
+
+ / {
+ model = "Xiaomi Mi 8 Lite";
+@@ -930,3 +931,84 @@
+
+ status = "okay";
+ };
++
++/*
++ * CPU frequency scaling via the OSM (clk-cpu-sdm660 driver). First-cut OPPs
++ * stay within each rail's boot-time voltage corner (little <= 1382 MHz,
++ * big <= 1113 MHz), so nothing is under-volted; raise once the OSM voltage
++ * path is confirmed to move VDD_APCC.
++ */
++&{/} {
++ cpu_osm: clock-controller@179c0000 {
++ compatible = "qcom,sdm660-osm";
++ reg = <0x0 0x179c0000 0x0 0x4000>;
++ reg-names = "osm";
++ clocks = <&gcc HMSS_GPLL0_CLK_SRC>;
++ clock-names = "aux";
++ #clock-cells = <1>;
++
++ /* r56: exact LUT from LineageOS /proc/device-tree (speed bin 1). */
++ qcom,pwrcl-speedbin0-v0 =
++ < 300000000 0x0004000f 0x01200020 0x1 1 >,
++ < 633600000 0x05040021 0x03200020 0x1 2 >,
++ < 902400000 0x0404002f 0x04260026 0x1 3 >,
++ < 1113600000 0x0404003a 0x052e002e 0x2 4 >,
++ < 1401600000 0x04040049 0x073a003a 0x2 5 >,
++ < 1536000000 0x04040050 0x08400040 0x2 6 >,
++ < 1747200000 0x0404005b 0x09480048 0x2 7 >,
++ < 1843200000 0x04040060 0x094c004c 0x3 8 >;
++
++ qcom,perfcl-speedbin1-v0 =
++ < 300000000 0x0004000f 0x01200020 0x1 1 >,
++ < 1113600000 0x0404003a 0x052e002e 0x1 2 >,
++ < 1401600000 0x04040049 0x073a003a 0x2 3 >,
++ < 1747200000 0x0404005b 0x09480048 0x2 4 >,
++ < 1958400000 0x04040066 0x0a510051 0x2 5 >,
++ < 2150400000 0x04040070 0x0b590059 0x2 6 >,
++ < 2208000000 0x04040073 0x0b5c005c 0x3 7 >;
++
++ qcom,pwrcl-voltage-ceiling =
++ < 724000 724000 724000 788000 868000
++ 1068000 1068000 1068000 >;
++ qcom,perfcl-voltage-ceiling =
++ < 724000 724000 788000 868000 988000 988000 1068000 >;
++ };
++
++ /* CPRh: puts the CPU voltage rails in HW closed-loop for the OSM. */
++ cprh_cpu: cpr@179c8000 {
++ compatible = "qcom,sdm660-cprh";
++ clocks = <&gcc GCC_HMSS_RBCPR_CLK>;
++ clock-names = "core_clk";
++ };
++
++ /*
++ * r56: OPP freqs match the real LUT points exactly and stay <= NOM
++ * corner (little <= 1113.6, big <= 1401.6) so the NOM-clamped CPRh never
++ * under-volts. Raise once transitions are confirmed and CPRh TURBO added.
++ */
++ cpu0_opp_table: opp-table-cpu0 {
++ compatible = "operating-points-v2";
++ opp-shared;
++ opp-300000000 { opp-hz = /bits/ 64 <300000000>; };
++ opp-633600000 { opp-hz = /bits/ 64 <633600000>; };
++ opp-902400000 { opp-hz = /bits/ 64 <902400000>; };
++ opp-1113600000 { opp-hz = /bits/ 64 <1113600000>; };
++ };
++
++ cpu4_opp_table: opp-table-cpu4 {
++ compatible = "operating-points-v2";
++ opp-shared;
++ opp-300000000 { opp-hz = /bits/ 64 <300000000>; };
++ opp-1113600000 { opp-hz = /bits/ 64 <1113600000>; };
++ opp-1401600000 { opp-hz = /bits/ 64 <1401600000>; };
++ };
++};
++
++&cpu0 { clocks = <&cpu_osm 0>; operating-points-v2 = <&cpu0_opp_table>; };
++&cpu1 { clocks = <&cpu_osm 0>; operating-points-v2 = <&cpu0_opp_table>; };
++&cpu2 { clocks = <&cpu_osm 0>; operating-points-v2 = <&cpu0_opp_table>; };
++&cpu3 { clocks = <&cpu_osm 0>; operating-points-v2 = <&cpu0_opp_table>; };
++&cpu4 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
++&cpu5 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
++&cpu6 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
++&cpu7 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0017-clk-qcom-sdm660-cprh-driver.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0017-clk-qcom-sdm660-cprh-driver.patch
new file mode 100644
index 0000000..f9c84fb
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0017-clk-qcom-sdm660-cprh-driver.patch
@@ -0,0 +1,352 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] clk: qcom: add SDM660 CPRh CPU voltage bring-up driver
+
+Programs the CPRh (CPR hardened) controllers into full HW closed-loop so the
+OSM can perform its voltage handshake and raise CPU frequency. Conservative
+first cut: all corners clamped at/below the NOM fuse point (no over-volt).
+
+Signed-off-by: pmOS Mi8Lite
+---
+diff --git a/drivers/clk/qcom/clk-cprh-sdm660.c b/drivers/clk/qcom/clk-cprh-sdm660.c
+new file mode 100644
+index 0000000..1111111
+--- /dev/null
++++ b/drivers/clk/qcom/clk-cprh-sdm660.c
+@@ -0,0 +1,310 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * SDM660 CPRh (CPR hardened) minimal bring-up for mainline Linux.
++ *
++ * The SDM660 CPU clusters get their supply voltage from the CPRh hardware in
++ * "full HW closed-loop" mode. The OSM (cpufreq) cannot raise CPU frequency
++ * until the CPRh is programmed and running, because each OSM frequency
++ * transition performs a voltage handshake with the CPRh. Mainline has no CPRh
++ * driver for SDM660, which is why cpufreq is missing.
++ *
++ * This is a distilled port of the downstream cpr3-regulator + cprh-kbss
++ * drivers, reduced to the one-time hardware setup needed for full HW
++ * closed-loop operation. It uses per-device "golden" fuse-derived values
++ * captured from the downstream kernel (see cprh-golden-platina.md) so it does
++ * not re-implement the fuse read / interpolation math.
++ *
++ * WARNING: this programs the CPU voltage rail. Wrong values can under-volt
++ * (hang) or over-volt (hardware damage). The values below are the fuse-derived
++ * open-loop voltages + CPR target quotients read out of this exact device.
++ *
++ * Status: complete for a conservative first bring-up, UNTESTED on hardware.
++ * The full HW closed-loop init sequence is implemented; all corners are clamped
++ * at/below the NOM fuse point so the worst case is under-volt, never over-volt
++ * (see the corner tables). To use it:
++ * 1. add a DT node:
++ * cprh: cpr@179c8000 {
++ * compatible = "qcom,sdm660-cprh";
++ * reg = <0 0x179c8000 0 0x4000>, <0 0x179c4000 0 0x4000>;
++ * clocks = <&gcc GCC_HMSS_RBCPR_CLK>;
++ * clock-names = "core_clk";
++ * };
++ * (this driver ioremaps the two controller bases from hard-coded phys for
++ * now; a cleaner version would take them from reg.)
++ * 2. cap the OSM OPP table to <= NOM (<=1401 MHz pwrcl / the perfcl NOM freq)
++ * so the OSM never signals a corner above the clamped voltages.
++ * 3. verify the OSM<->CPRh corner index (0- vs 1-based) before extending the
++ * corner table upward or removing the clamp.
++ * Later work: real per-frequency interpolation of corners 1/6/7, TURBO corners
++ * with the APM switch above 872 mV, sensor-ownership programming, and exposing
++ * the controllers as proper regulators.
++ */
++
++#include
++#include
++#include
++#include
++#include
++#include
++
++/* --- CPRh controller register offsets (from cpr_ctrl base) --- */
++#define CPR3_REG_CPR_CTL 0x4
++#define CPR3_CPR_CTL_LOOP_EN BIT(0)
++#define CPR3_REG_CPR_STEP_QUOT 0x14
++#define CPR3_REG_GCNT(ro) (0xA0 + 0x4 * (ro))
++#define CPR3_REG_THRESH(thr) (0x808 + 0x440 * (thr))
++#define CPR3_REG_RO_MASK(thr) (0x80C + 0x440 * (thr))
++#define CPR3_RO_MASK_ALL GENMASK(15, 0) /* CPR3_RO_COUNT=16 */
++#define CPR4_REG_MARGIN_ADJ_CTL 0x7F8
++#define CPR4_MARGIN_ADJ_CTL_HW_CL_EN BIT(4)
++#define CPR3_REG_CPR_TIMER_MID_CONT 0x3004
++#define CPRH_REG_CORNER(n) (0x3A00 + 0x4 * (n))
++#define CPRH_REG_CTL 0x3AA0
++#define CPRH_CTL_OSM_ENABLED BIT(0) /* OSM<->CPR interface enable */
++
++/* CPR_CTL fields */
++#define CPR_CTL_IDLE_CLOCKS_SHIFT 1
++#define CPR_CTL_COUNT_MODE_SHIFT 6
++#define CPR_CTL_COUNT_REPEAT_SHIFT 9
++
++/* THRESH fields (per thread) */
++#define THRESH_CONS_DOWN_SHIFT 0
++#define THRESH_CONS_UP_SHIFT 4
++#define THRESH_DOWN_THRESH_SHIFT 8
++#define THRESH_UP_THRESH_SHIFT 13
++
++/* CPRH corner word fields */
++#define CORNER_INIT_VOLT_SHIFT 0
++#define CORNER_FLOOR_VOLT_SHIFT 8
++#define CORNER_QUOT_DELTA_SHIFT 16
++#define CORNER_RO_SEL_SHIFT 25
++
++/* CPRH_REG_CTL fields */
++#define CTL_BASE_VOLTAGE_SHIFT 1
++#define CTL_VOLTAGE_MULTIPLIER_SHIFT 25
++
++/* thread THRESH config (apc0/apc1 thread@0): cons_up0 cons_down2 up2 down2 */
++#define THRESH_CONS_UP 0
++#define THRESH_CONS_DOWN 2
++#define THRESH_UP_THRESHOLD 2
++#define THRESH_DOWN_THRESHOLD 2
++
++/* constants from cprh-kbss / DT */
++#define CPR_CLOCK_RATE 19200000 /* RBCPR core clk */
++#define SENSOR_TIME_NS 1000
++#define LOOP_TIME_NS 5000000
++#define IDLE_CLOCKS 15
++#define COUNT_MODE 0 /* all at once */
++#define COUNT_REPEAT 14
++#define STEP_QUOT_INIT_MIN 12
++#define STEP_QUOT_INIT_MAX 14
++#define VOLTAGE_BASE_UV 400000
++#define VOLTAGE_STEP_UV 4000
++#define DELTA_QUOT_STEP_FACTOR 4
++#define RO_SEL 7
++
++/*
++ * Full 8-corner tables (platina, speed bin 1). The controllers have 8 corners,
++ * one per OSM frequency; the corner the OSM signals indexes CPRH_REG_CORNER(n).
++ *
++ * Values are the fuse-derived golden open-loop voltages + CPR target quotients
++ * captured from the downstream kernel (see cprh-golden-platina.md), with floors
++ * from qcom,cpr-voltage-floor. corner-fmax-map places the fuse points at the
++ * corners marked below; corners between/around them would normally be linearly
++ * interpolated by frequency.
++ *
++ * SAFETY-FIRST first cut: instead of interpolating (and instead of relying on
++ * the exact 0-/1-based OSM<->CPRh corner index, which we cannot validate live),
++ * every corner is clamped at or below the NOM fuse point (<=758 mV pwrcl /
++ * <=788 mV perfcl, all well under the 872 mV APM threshold). Consequence: if
++ * the OSM ever requests a high corner, or if the index is off by one, the worst
++ * case is a mild UNDER-volt (recoverable hang) - never an over-volt. The OSM
++ * OPP table must be capped to <=NOM to match; higher corners are a later step
++ * once real interpolation + index verification are done.
++ */
++struct cprh_corner {
++ u32 open_loop_uv;
++ u32 floor_uv;
++ u32 target_quot; /* RO7 */
++};
++
++struct cprh_ctrl_cfg {
++ const char *name;
++ u32 phys; /* cpr_ctrl base */
++ const struct cprh_corner *corners;
++ int corner_count;
++};
++
++/* pwrcl / little: fmax-map <2 3 4 5 8> = LowSVS SVS SVSPLUS NOM TURBO_L1 */
++static const struct cprh_corner apc0_corners[8] = {
++ { 614000, 588000, 336 }, /* c0 OSM1 LowSVS */
++ { 614000, 588000, 336 }, /* c1 OSM2 LowSVS */
++ { 644000, 588000, 390 }, /* c2 OSM3 SVS */
++ { 688000, 596000, 461 }, /* c3 OSM4 SVSPLUS */
++ { 758000, 652000, 586 }, /* c4 OSM5 NOM */
++ { 758000, 652000, 586 }, /* c5 clamp NOM */
++ { 758000, 652000, 586 }, /* c6 clamp NOM */
++ { 758000, 652000, 586 }, /* c7 clamp NOM */
++};
++
++/* perfcl / big: fmax-map <2 3 4 6 7> = SVS SVSPLUS NOM TURBO TURBO_L2 */
++static const struct cprh_corner apc1_corners[8] = {
++ { 684000, 588000, 575 }, /* c0 OSM1 SVS */
++ { 684000, 588000, 575 }, /* c1 OSM2 SVS */
++ { 718000, 596000, 642 }, /* c2 OSM3 SVSPLUS */
++ { 788000, 652000, 794 }, /* c3 OSM4 NOM */
++ { 788000, 652000, 794 }, /* c4 clamp NOM */
++ { 788000, 652000, 794 }, /* c5 clamp NOM */
++ { 788000, 652000, 794 }, /* c6 clamp NOM */
++ { 788000, 652000, 794 }, /* c7 clamp NOM */
++};
++
++static const struct cprh_ctrl_cfg ctrl_cfgs[] = {
++ { "apc0", 0x179c8000, apc0_corners, ARRAY_SIZE(apc0_corners) },
++ { "apc1", 0x179c4000, apc1_corners, ARRAY_SIZE(apc1_corners) },
++};
++
++#define DIV_RUP(a, b) (((a) + (b) - 1) / (b))
++
++static u32 corner_word(const struct cprh_corner *c, u32 base_quot)
++{
++ u32 iv = DIV_RUP(c->open_loop_uv - VOLTAGE_BASE_UV, VOLTAGE_STEP_UV);
++ u32 fv = DIV_RUP(c->floor_uv - VOLTAGE_BASE_UV, VOLTAGE_STEP_UV);
++ u32 dq = c->target_quot ?
++ DIV_RUP(c->target_quot - base_quot, DELTA_QUOT_STEP_FACTOR) : 0;
++
++ return ((iv & 0xff) << CORNER_INIT_VOLT_SHIFT) |
++ ((fv & 0xff) << CORNER_FLOOR_VOLT_SHIFT) |
++ ((dq & 0x1ff) << CORNER_QUOT_DELTA_SHIFT) |
++ ((RO_SEL & 0xf) << CORNER_RO_SEL_SHIFT);
++}
++
++static u32 calc_gcnt(void)
++{
++ u64 t = (u64)CPR_CLOCK_RATE * SENSOR_TIME_NS;
++
++ return DIV_RUP(t, 1000000000ULL) - 1;
++}
++
++static void cprh_program(void __iomem *base, const struct cprh_ctrl_cfg *cfg)
++{
++ u32 base_quot = U32_MAX, gcnt, val;
++ u64 tmp;
++ int i;
++
++ for (i = 0; i < cfg->corner_count; i++)
++ base_quot = min(base_quot, cfg->corners[i].target_quot);
++
++ /* GCNT for the RO in use */
++ gcnt = calc_gcnt();
++ writel_relaxed(gcnt, base + CPR3_REG_GCNT(RO_SEL));
++
++ /* loop-delay timer (HW closed-loop) */
++ tmp = (u64)CPR_CLOCK_RATE * LOOP_TIME_NS;
++ do_div(tmp, 1000000000ULL);
++ writel_relaxed((u32)tmp, base + CPR3_REG_CPR_TIMER_MID_CONT);
++
++ /* CPR sensor control (loop_en left off until the very end) */
++ val = (IDLE_CLOCKS << CPR_CTL_IDLE_CLOCKS_SHIFT) |
++ (COUNT_MODE << CPR_CTL_COUNT_MODE_SHIFT) |
++ (COUNT_REPEAT << CPR_CTL_COUNT_REPEAT_SHIFT);
++ writel_relaxed(val, base + CPR3_REG_CPR_CTL);
++
++ /* default step quotients */
++ val = (STEP_QUOT_INIT_MIN & 0x3f) | ((STEP_QUOT_INIT_MAX & 0x3f) << 6);
++ writel_relaxed(val, base + CPR3_REG_CPR_STEP_QUOT);
++
++ /* per-thread init: THRESH, then mask all ROs initially */
++ val = (THRESH_CONS_DOWN << THRESH_CONS_DOWN_SHIFT) |
++ (THRESH_CONS_UP << THRESH_CONS_UP_SHIFT) |
++ (THRESH_DOWN_THRESHOLD << THRESH_DOWN_THRESH_SHIFT) |
++ (THRESH_UP_THRESHOLD << THRESH_UP_THRESH_SHIFT);
++ writel_relaxed(val, base + CPR3_REG_THRESH(0));
++ writel_relaxed(CPR3_RO_MASK_ALL, base + CPR3_REG_RO_MASK(0));
++
++ /* corner table */
++ for (i = 0; i < cfg->corner_count; i++)
++ writel_relaxed(corner_word(&cfg->corners[i], base_quot),
++ base + CPRH_REG_CORNER(i));
++
++ /* unmask the RO actually used (set bit = masked, so clear RO_SEL) */
++ writel_relaxed(CPR3_RO_MASK_ALL & ~BIT(RO_SEL),
++ base + CPR3_REG_RO_MASK(0));
++
++ /*
++ * CPRH control: base voltage + step multiplier + OSM interface enable.
++ * OSM_ENABLED is what lets the OSM perform its voltage handshake with
++ * the CPRh - without it the OSM cannot change frequency. init_mode /
++ * mode_switch_delay are left at reset (0); only used with a configured
++ * corner-switch-delay, which platina does not set.
++ */
++ val = (DIV_RUP(VOLTAGE_BASE_UV, VOLTAGE_STEP_UV) << CTL_BASE_VOLTAGE_SHIFT) |
++ (DIV_RUP(VOLTAGE_STEP_UV, 1000) << CTL_VOLTAGE_MULTIPLIER_SHIFT) |
++ CPRH_CTL_OSM_ENABLED;
++ writel_relaxed(val, base + CPRH_REG_CTL);
++ wmb();
++
++ /* enable full HW closed-loop (CPRH type: MARGIN_ADJ_CTL bit4) */
++ val = readl_relaxed(base + CPR4_REG_MARGIN_ADJ_CTL);
++ val |= CPR4_MARGIN_ADJ_CTL_HW_CL_EN;
++ writel_relaxed(val, base + CPR4_REG_MARGIN_ADJ_CTL);
++ wmb();
++
++ /* finally, enable the CPR loop */
++ val = readl_relaxed(base + CPR3_REG_CPR_CTL) | CPR3_CPR_CTL_LOOP_EN;
++ writel_relaxed(val, base + CPR3_REG_CPR_CTL);
++ wmb();
++}
++
++static int sdm660_cprh_probe(struct platform_device *pdev)
++{
++ struct device *dev = &pdev->dev;
++ struct clk *core, *bus, *iface;
++ int i, ret;
++
++ /* CPRh needs core (RBCPR 19.2MHz) + bus + iface clocks on */
++ core = devm_clk_get(dev, "core_clk");
++ if (IS_ERR(core))
++ return dev_err_probe(dev, PTR_ERR(core), "no core_clk\n");
++ clk_set_rate(core, CPR_CLOCK_RATE);
++ ret = clk_prepare_enable(core);
++ if (ret)
++ return ret;
++
++ bus = devm_clk_get_optional(dev, "bus_clk");
++ if (!IS_ERR_OR_NULL(bus))
++ clk_prepare_enable(bus);
++ iface = devm_clk_get_optional(dev, "iface_clk");
++ if (!IS_ERR_OR_NULL(iface))
++ clk_prepare_enable(iface);
++
++ for (i = 0; i < ARRAY_SIZE(ctrl_cfgs); i++) {
++ void __iomem *base = devm_ioremap(dev, ctrl_cfgs[i].phys, 0x4000);
++
++ if (!base)
++ return -ENOMEM;
++ cprh_program(base, &ctrl_cfgs[i]);
++ dev_info(dev, "%s CPRh programmed (%d corners, closed-loop on)\n",
++ ctrl_cfgs[i].name, ctrl_cfgs[i].corner_count);
++ }
++
++ return 0;
++}
++
++static const struct of_device_id sdm660_cprh_match[] = {
++ { .compatible = "qcom,sdm660-cprh" },
++ {}
++};
++MODULE_DEVICE_TABLE(of, sdm660_cprh_match);
++
++static struct platform_driver sdm660_cprh_driver = {
++ .probe = sdm660_cprh_probe,
++ .driver = {
++ .name = "sdm660-cprh",
++ .of_match_table = sdm660_cprh_match,
++ },
++};
++module_platform_driver(sdm660_cprh_driver);
++
++MODULE_DESCRIPTION("Qualcomm SDM660 CPRh minimal closed-loop bring-up");
++MODULE_LICENSE("GPL");
+diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
+--- a/drivers/clk/qcom/Kconfig
++++ b/drivers/clk/qcom/Kconfig
+@@ -880,6 +880,14 @@ config SDM660_CPU_CLK
+ not program the OSM, so this driver loads the frequency/voltage
+ tables and the sequencer microcode itself, enabling cpufreq.
+
++config SDM660_CPRH
++ tristate "SDM660 CPRh CPU voltage bring-up"
++ depends on ARM64 || COMPILE_TEST
++ help
++ Programs the CPRh (CPR hardened) controllers into HW closed-loop so
++ the OSM can raise CPU voltage/frequency. Required for cpufreq on the
++ SDM660 CPU clusters.
++
+ config SDM_MMCC_660
+ tristate "SDM660 Multimedia Clock Controller"
+ depends on ARM64 || COMPILE_TEST
+diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
+--- a/drivers/clk/qcom/Makefile
++++ b/drivers/clk/qcom/Makefile
+@@ -124,4 +124,5 @@ obj-$(CONFIG_SDM_GPUCC_660) += gpucc-sdm660.o
+ obj-$(CONFIG_SDM660_CPU_CLK) += clk-cpu-sdm660.o
+ obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
++obj-$(CONFIG_SDM660_CPRH) += clk-cprh-sdm660.o
+ obj-$(CONFIG_SDM_GPUCC_845) += gpucc-sdm845.o
+ obj-$(CONFIG_SDM_LPASSCC_845) += lpasscc-sdm845.o
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0018-platina-audio.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0018-platina-audio.patch
new file mode 100644
index 0000000..a687fbd
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0018-platina-audio.patch
@@ -0,0 +1,122 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660: enable internal audio on platina
+
+Wire up the SDM660 internal sound card on the Xiaomi Mi 8 Lite: the PM660L
+analog codec + LPASS digital codec driven by the Q6/ADSP (headphones out +
+internal mic), including the q6asm/q6afe DAI children the frontends/backends
+need. Mirrors sdm660-xiaomi-lavender-common.dtsi.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -15,6 +15,8 @@
+ #include
+ #include
+ #include
++#include
++#include
+ #include
+
+ / {
+@@ -1012,3 +1014,100 @@
+ &cpu5 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
+ &cpu6 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
+ &cpu7 { clocks = <&cpu_osm 1>; operating-points-v2 = <&cpu4_opp_table>; };
++
++/*
++ * Audio: SDM660 internal sound card (headphones + mic via the PM660L analog
++ * codec + LPASS digital codec, driven by the Q6/ADSP). Mirrors the working
++ * sdm660-xiaomi-lavender-common.dtsi wiring; speaker (NXP TFA98xx) is separate.
++ */
++&q6afedai {
++ dai@81 {
++ reg = ;
++ qcom,sd-lines = <0 1>;
++ };
++
++ dai@88 {
++ reg = ;
++ qcom,sd-lines = <0 1>;
++ };
++};
++
++&q6asmdai {
++ dai@0 {
++ reg = <0>;
++ };
++
++ dai@1 {
++ reg = <1>;
++ };
++};
++
++&lpass_codec {
++ status = "okay";
++};
++
++&pm660l_codec {
++ vdd-cdc-io-supply = <&vreg_s4a_2p04>;
++ vdd-cdc-tx-rx-cx-supply = <&vreg_s4a_2p04>;
++ vdd-micbias-supply = <&vreg_l7b_3p125>;
++
++ qcom,micbias-lvl = <2600>;
++ qcom,micbias1-ext-cap;
++
++ status = "okay";
++};
++
++&sound {
++ compatible = "qcom,sdm660-internal-sndcard";
++ model = "Xiaomi Mi 8 Lite";
++
++ pinctrl-0 = <&cdc_pdm_default>, <&cdc_dmic_default>;
++ pinctrl-names = "default";
++
++ audio-routing = "PDM_RX1", "Digital PDM_RX1",
++ "PDM_RX2", "Digital PDM_RX2",
++ "PDM_RX3", "Digital PDM_RX3",
++ "Digital LPASS_PDM_TX", "PDM_TX",
++ "AMIC1", "MIC BIAS External1",
++ "AMIC2", "MIC BIAS External2";
++
++ mm1-dai-link {
++ link-name = "MultiMedia1";
++ cpu {
++ sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>;
++ };
++ };
++
++ mm2-dai-link {
++ link-name = "MultiMedia2";
++ cpu {
++ sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA2>;
++ };
++ };
++
++ int0-mi2s-dai-link {
++ link-name = "Internal MI2S Playback";
++ cpu {
++ sound-dai = <&q6afedai INT0_MI2S_RX>;
++ };
++ platform {
++ sound-dai = <&q6routing>;
++ };
++ codec {
++ sound-dai = <&pm660l_codec 0>, <&lpass_codec 0>;
++ };
++ };
++
++ int3-mi2s-dai-link {
++ link-name = "Internal MI2S Capture";
++ cpu {
++ sound-dai = <&q6afedai INT3_MI2S_TX>;
++ };
++ platform {
++ sound-dai = <&q6routing>;
++ };
++ codec {
++ sound-dai = <&pm660l_codec 1>, <&lpass_codec 1>;
++ };
++ };
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0020-tfa9894-codec.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0020-tfa9894-codec.patch
new file mode 100644
index 0000000..5f2b0e2
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0020-tfa9894-codec.patch
@@ -0,0 +1,323 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] ASoC: codecs: add NXP TFA9894 direct-mode driver
+
+Minimal ASoC driver for the TFA9894 smart speaker amp on the Xiaomi Mi 8 Lite.
+Direct mode (I2S/TDM straight to the speaker, no CoolFlux DSP/container),
+verified live to pass audio. Register config RE'd from the vendor driver and
+captured from a working device.
+
+Signed-off-by: pmOS Mi8Lite
+---
+diff --git a/sound/soc/codecs/tfa9894.c b/sound/soc/codecs/tfa9894.c
+new file mode 100644
+--- /dev/null
++++ b/sound/soc/codecs/tfa9894.c
+@@ -0,0 +1,273 @@
++// SPDX-License-Identifier: GPL-2.0-only
++/*
++ * tfa9894.c - minimal ASoC driver for the NXP/Goodix TFA9894 smart speaker amp
++ *
++ * The TFA9894 is a "smart" mono Class-D amp with an on-chip CoolFlux DSP that
++ * Android drives with a proprietary firmware "container" (speaker model, boost,
++ * excursion protection). This driver deliberately does NOT use the DSP: it puts
++ * the amp in DIRECT mode (AMPINSEL = TDM), which is what the vendor driver does
++ * for the raw audio path, so I2S/TDM audio reaches the speaker without loading
++ * any firmware. Without the DSP there is no excursion/thermal protection, so
++ * keep the volume conservative.
++ *
++ * The register map and the per-revision "optimal settings" were reverse
++ * engineered from the vendor tfa98xx driver (tfa_init.c: tfa9894_specific) and
++ * verified against the chip on a Xiaomi Mi 8 Lite (revid 0x1a94, read live over
++ * i2c: reg 0x03 low byte = 0x94).
++ */
++
++#include
++#include
++#include
++#include
++#include
++#include
++#include
++
++/* registers (8-bit address, 16-bit big-endian values) */
++#define TFA9894_SYS_CTRL0 0x00
++#define SYS_CTRL0_PWDN BIT(0) /* power down */
++#define SYS_CTRL0_I2CR BIT(1) /* I2C reset (auto-clear) */
++#define SYS_CTRL0_CFE BIT(2) /* enable CoolFlux DSP */
++#define SYS_CTRL0_AMPE BIT(3) /* enable amplifier */
++#define SYS_CTRL0_DCA BIT(4) /* enable DCDC boost */
++#define SYS_CTRL0_SBSL BIT(5) /* DSP configured */
++#define SYS_CTRL0_AMPC BIT(6) /* amplifier controlled by DSP */
++#define TFA9894_SYS_CTRL1 0x01
++#define SYS_CTRL1_AMPINSEL GENMASK(1, 0) /* 0 = TDM direct to amp */
++#define SYS_CTRL1_MANSCONF BIT(2) /* device I2C settings configured */
++#define TFA9894_AUDIO_CTRL 0x02
++#define AUDIO_CTRL_AUDFS GENMASK(3, 0) /* audio sample rate */
++#define TFA9894_REVISION 0x03
++#define TFA9894_HIDE_KEY 0x0f
++#define TFA9894_TDM_CFG0 0x20
++#define TDM_CFG0_TDME BIT(0) /* enable TDM interface */
++#define TDM_CFG0_TDMSPKE BIT(1) /* audio channel to sink0 (speaker) */
++#define TFA9894_TDM_SLOT 0x23
++#define TDM_SLOT_TDMSPKS GENMASK(3, 0) /* TDM slot for sink0 */
++#define TFA9894_KEY2 0xa0
++#define TFA9894_MTP_KEY 0xfb
++
++#define TFA9894_REV_ID 0x94 /* low byte of reg 0x03 */
++
++/*
++ * Cold-start register configuration for revid 0x1a94. This is the vendor
++ * "optimal settings" (RE'd from tfa9894_specific()) PLUS the clock/analog/TDM
++ * and speaker-protection registers captured live over i2c from a working
++ * Xiaomi Mi 8 Lite while audio was playing. In DIRECT mode (AMPINSEL = TDM,
++ * no DSP) these i2c registers are all the chip needs - the CoolFlux DSP RAM
++ * is not used. Verified live: flipping a fully-initialised chip to AMPINSEL=0
++ * kept audio playing, so this hardware path works without firmware.
++ * reg 0x00/0x01 (power + input mux) are handled in probe()/DAPM, not here.
++ */
++static const struct reg_sequence tfa9894_init_1a94[] = {
++ { 0x00, 0xa211 }, /* direct mode: no DSP (AMPC/CFE=0), boost on, amp off */
++ { 0x01, 0x15d4 }, /* AMPINSEL=0 (TDM straight to amp), MANSCONF=1 */
++ { 0x02, 0x52c8 }, /* audio ctrl (AUDFS overwritten per-rate) */
++ { 0x10, 0x785e }, /* system/clock control */
++ { 0x11, 0x0006 },
++ { 0x12, 0x004f },
++ { 0x14, 0x0d49 }, /* PLL / analog */
++ { 0x15, 0x029a },
++ { 0x16, 0x0028 },
++ { 0x17, 0x0118 },
++ { 0x20, 0x0747 }, /* TDM interface config */
++ { 0x21, 0x8110 },
++ { 0x22, 0x3c0f },
++ { 0x23, 0x0410 }, /* speaker sink on slot 0 */
++ { 0x24, 0x0410 },
++ { 0x52, 0xbe17 }, /* analog / current-sense / protection */
++ { 0x53, 0x0dbe },
++ { 0x54, 0x00e0 },
++ { 0x55, 0x07ff },
++ { 0x56, 0x05c3 },
++ { 0x57, 0x0344 },
++ { 0x58, 0x0081 },
++ { 0x59, 0x0a9a },
++ { 0x5a, 0x1040 },
++ { 0x5b, 0x0a82 },
++ { 0x5c, 0x00b0 },
++ { 0x5d, 0x0790 },
++ { 0x5e, 0x0005 },
++ { 0x5f, 0x002a },
++ { 0x61, 0x0032 },
++ { 0x71, 0x00cf },
++ { 0x72, 0x34a9 },
++ { 0x73, 0x38c8 },
++ { 0x76, 0x0067 },
++ { 0x81, 0x5799 },
++ { 0x82, 0x0104 },
++ { 0x83, 0x0003 },
++ { 0x88, 0x0004 },
++ { 0x89, 0x0022 },
++ { 0x8a, 0x1470 },
++};
++
++struct tfa9894 {
++ struct regmap *regmap;
++};
++
++static bool tfa9894_volatile_reg(struct device *dev, unsigned int reg)
++{
++ switch (reg) {
++ case TFA9894_SYS_CTRL0: /* status bits auto-update */
++ case TFA9894_REVISION:
++ case TFA9894_MTP_KEY:
++ return true;
++ default:
++ return false;
++ }
++}
++
++static const struct regmap_config tfa9894_regmap = {
++ .reg_bits = 8,
++ .val_bits = 16,
++ .max_register = 0xff,
++ .volatile_reg = tfa9894_volatile_reg,
++ .cache_type = REGCACHE_NONE,
++};
++
++/* map an ALSA rate to the AUDFS field value (matches vendor table) */
++static int tfa9894_audfs(unsigned int rate)
++{
++ switch (rate) {
++ case 8000: return 0;
++ case 11025: return 1;
++ case 12000: return 2;
++ case 16000: return 3;
++ case 22050: return 4;
++ case 24000: return 5;
++ case 32000: return 6;
++ case 44100: return 7;
++ case 48000: return 8;
++ default: return -EINVAL;
++ }
++}
++
++static int tfa9894_hw_params(struct snd_pcm_substream *substream,
++ struct snd_pcm_hw_params *params,
++ struct snd_soc_dai *dai)
++{
++ struct snd_soc_component *comp = dai->component;
++ int fs = tfa9894_audfs(params_rate(params));
++
++ if (fs < 0) {
++ dev_err(comp->dev, "unsupported rate %u\n", params_rate(params));
++ return fs;
++ }
++
++ return snd_soc_component_update_bits(comp, TFA9894_AUDIO_CTRL,
++ AUDIO_CTRL_AUDFS,
++ FIELD_PREP(AUDIO_CTRL_AUDFS, fs));
++}
++
++static const struct snd_soc_dai_ops tfa9894_dai_ops = {
++ .hw_params = tfa9894_hw_params,
++};
++
++static struct snd_soc_dai_driver tfa9894_dai = {
++ .name = "tfa9894-hifi",
++ .playback = {
++ .stream_name = "HiFi Playback",
++ .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
++ .rates = SNDRV_PCM_RATE_8000_48000,
++ .rate_min = 8000,
++ .rate_max = 48000,
++ .channels_min = 1,
++ .channels_max = 2,
++ },
++ .ops = &tfa9894_dai_ops,
++};
++
++/*
++ * DAPM: the "OUT" -> AMPE -> POWER chain enables the amp when the stream runs.
++ * POWER clears PWDN (invert), AMPE sets the amp-enable bit; DCA (boost) rides
++ * along with AMPE via the supply. AMPC is left 0 so the amp follows AMPE
++ * directly instead of waiting for the (unused) DSP.
++ */
++static const struct snd_soc_dapm_widget tfa9894_widgets[] = {
++ SND_SOC_DAPM_AIF_IN("AIF IN", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
++ SND_SOC_DAPM_SUPPLY("POWER", TFA9894_SYS_CTRL0, 0 /* PWDN */, 1, NULL, 0),
++ SND_SOC_DAPM_OUT_DRV("AMPE", TFA9894_SYS_CTRL0, 3 /* AMPE */, 0, NULL, 0),
++ SND_SOC_DAPM_OUTPUT("OUT"),
++};
++
++static const struct snd_soc_dapm_route tfa9894_routes[] = {
++ { "AMPE", NULL, "AIF IN" },
++ { "AMPE", NULL, "POWER" },
++ { "OUT", NULL, "AMPE" },
++};
++
++static int tfa9894_probe(struct snd_soc_component *comp)
++{
++ struct tfa9894 *tfa = snd_soc_component_get_drvdata(comp);
++ unsigned int rev, key;
++ int ret;
++
++ ret = regmap_read(tfa->regmap, TFA9894_REVISION, &rev);
++ if (ret)
++ return ret;
++ if ((rev & 0xff) != TFA9894_REV_ID)
++ dev_warn(comp->dev, "unexpected revid %#x (want low byte %#x)\n",
++ rev, TFA9894_REV_ID);
++
++ /* unlock protected registers (vendor tfa9894_specific sequence) */
++ regmap_write(tfa->regmap, TFA9894_HIDE_KEY, 0x5a6b);
++ regmap_read(tfa->regmap, TFA9894_MTP_KEY, &key);
++ regmap_write(tfa->regmap, TFA9894_KEY2, (key ^ 0x005a) & 0xffff);
++
++ /*
++ * Apply the full cold-start config (direct/TDM mode, no DSP). After
++ * this the chip is configured with the amp powered down; the DAPM
++ * "POWER"/"AMPE" widgets clear PWDN and enable the amplifier when a
++ * stream starts. TDM interface + speaker sink are set in the sequence.
++ */
++ return regmap_multi_reg_write(tfa->regmap, tfa9894_init_1a94,
++ ARRAY_SIZE(tfa9894_init_1a94));
++}
++
++static const struct snd_soc_component_driver tfa9894_component = {
++ .probe = tfa9894_probe,
++ .dapm_widgets = tfa9894_widgets,
++ .num_dapm_widgets = ARRAY_SIZE(tfa9894_widgets),
++ .dapm_routes = tfa9894_routes,
++ .num_dapm_routes = ARRAY_SIZE(tfa9894_routes),
++ .idle_bias_on = 1,
++ .endianness = 1,
++};
++
++static int tfa9894_i2c_probe(struct i2c_client *i2c)
++{
++ struct tfa9894 *tfa;
++
++ tfa = devm_kzalloc(&i2c->dev, sizeof(*tfa), GFP_KERNEL);
++ if (!tfa)
++ return -ENOMEM;
++
++ tfa->regmap = devm_regmap_init_i2c(i2c, &tfa9894_regmap);
++ if (IS_ERR(tfa->regmap))
++ return PTR_ERR(tfa->regmap);
++
++ i2c_set_clientdata(i2c, tfa);
++
++ return devm_snd_soc_register_component(&i2c->dev, &tfa9894_component,
++ &tfa9894_dai, 1);
++}
++
++static const struct of_device_id tfa9894_of_match[] = {
++ { .compatible = "nxp,tfa9894" },
++ { }
++};
++MODULE_DEVICE_TABLE(of, tfa9894_of_match);
++
++static struct i2c_driver tfa9894_i2c_driver = {
++ .driver = {
++ .name = "tfa9894",
++ .of_match_table = tfa9894_of_match,
++ },
++ .probe = tfa9894_i2c_probe,
++};
++module_i2c_driver(tfa9894_i2c_driver);
++
++MODULE_DESCRIPTION("ASoC NXP TFA9894 direct-mode driver");
++MODULE_LICENSE("GPL");
+--- a/sound/soc/codecs/Kconfig
++++ b/sound/soc/codecs/Kconfig
+@@ -2209,6 +2209,14 @@
+ Note that the driver currently bypasses the built-in "CoolFlux DSP"
+ and does not support (hardware) volume control.
+
++config SND_SOC_TFA9894
++ tristate "NXP/Goodix TFA9894 speaker amplifier (direct mode)"
++ depends on I2C
++ select REGMAP_I2C
++ help
++ Enable support for the NXP/Goodix TFA9894 smart speaker amplifier in
++ direct (DSP-bypass) mode, routing I2S/TDM straight to the speaker.
++
+ config SND_SOC_TLV320ADC3XXX
+ tristate "Texas Instruments TLV320ADC3001/3101 audio ADC"
+ depends on I2C
+--- a/sound/soc/codecs/Makefile
++++ b/sound/soc/codecs/Makefile
+@@ -324,6 +324,7 @@
+ snd-soc-tas2783-sdw-y := tas2783-sdw.o
+ snd-soc-tfa9879-y := tfa9879.o
+ snd-soc-tfa989x-y := tfa989x.o
++snd-soc-tfa9894-y := tfa9894.o
+ snd-soc-tlv320adc3xxx-y := tlv320adc3xxx.o
+ snd-soc-tlv320aic23-y := tlv320aic23.o
+ snd-soc-tlv320aic23-i2c-y := tlv320aic23-i2c.o
+@@ -758,6 +759,7 @@
+ obj-$(CONFIG_SND_SOC_TAS2770) += snd-soc-tas2770.o
+ obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o
+ obj-$(CONFIG_SND_SOC_TFA989X) += snd-soc-tfa989x.o
++obj-$(CONFIG_SND_SOC_TFA9894) += snd-soc-tfa9894.o
+ obj-$(CONFIG_SND_SOC_TLV320ADC3XXX) += snd-soc-tlv320adc3xxx.o
+ obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o
+ obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0021-platina-speaker.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0021-platina-speaker.patch
new file mode 100644
index 0000000..51dd55b
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0021-platina-speaker.patch
@@ -0,0 +1,47 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660: wire TFA9894 speaker on platina
+
+Add the TFA9894 speaker amp on blsp_i2c2 and a Secondary MI2S DAI link so the
+Q6/ADSP feeds it, giving speaker output on the Xiaomi Mi 8 Lite.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -1111,3 +1111,36 @@
+ };
+ };
+ };
++
++/* Speaker: NXP TFA9894 smart amp on blsp_i2c2, fed by Secondary MI2S from the
++ * Q6/ADSP. Driven in direct (DSP-bypass) mode by the tfa9894 driver. */
++&blsp_i2c2 {
++ tfa9894: audio-codec@34 {
++ compatible = "nxp,tfa9894";
++ reg = <0x34>;
++ #sound-dai-cells = <0>;
++ sound-name-prefix = "Speaker";
++ };
++};
++
++&q6afedai {
++ dai@18 {
++ reg = ;
++ qcom,sd-lines = <0>;
++ };
++};
++
++&sound {
++ sec-mi2s-dai-link {
++ link-name = "Secondary MI2S Playback";
++ cpu {
++ sound-dai = <&q6afedai SECONDARY_MI2S_RX>;
++ };
++ platform {
++ sound-dai = <&q6routing>;
++ };
++ codec {
++ sound-dai = <&tfa9894>;
++ };
++ };
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0022-platina-bluetooth.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0022-platina-bluetooth.patch
new file mode 100644
index 0000000..6c11324
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0022-platina-bluetooth.patch
@@ -0,0 +1,46 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660-xiaomi-platina: enable WCN3990 Bluetooth
+
+Enable the WCN3990 Bluetooth (hci_qca serdev on the BLSP2 UART1 4-wire
+port). It is the same combo die as the already-working WiFi; the four
+VDD rails are shared with &wifi and ref-counted by the regulator core.
+This mirrors the known-working sdm660-xiaomi-lavender BT config, and
+adds the serial1 alias lavender uses for the BT UART.
+
+Split out of the old 0022-platina-bt-vibrator so BT and the vibrator can
+be validated (and, if needed, bisected) independently on the device.
+
+Signed-off-by: pmOS Mi8Lite
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts 2026-07-15 15:35:10.645379298 -0500
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts 2026-07-15 15:35:10.670546665 -0500
+@@ -26,6 +26,7 @@
+
+ aliases {
+ serial0 = &blsp1_uart2;
++ serial1 = &blsp2_uart1; /* Bluetooth UART */
+ };
+
+ chosen {
+@@ -1159,3 +1160,22 @@
+ &sound {
+ pinctrl-0 = <&cdc_pdm_default>, <&cdc_dmic_default>, <&sec_mi2s_default>;
+ };
++
++/*
++ * Bluetooth: WCN3990 combo chip (shares the die with the WiFi) on the
++ * BLSP2 UART1 4-wire port via hci_qca. The four VDD rails are the same
++ * ones the WiFi (&wifi) votes for the shared chip; the regulator core
++ * ref-counts them. Mirrors the known-working sdm660-xiaomi-lavender BT.
++ */
++&blsp2_uart1 {
++ status = "okay";
++
++ bluetooth {
++ compatible = "qcom,wcn3990-bt";
++ vddxo-supply = <&vreg_l9a_1p8>;
++ vddrf-supply = <&vreg_l6a_1p3>;
++ vddch0-supply = <&vreg_l19a_3p3>;
++ vddio-supply = <&vreg_l13a_1p8>;
++ max-speed = <3200000>;
++ };
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0024-platina-sec-mi2s-pinctrl.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0024-platina-sec-mi2s-pinctrl.patch
new file mode 100644
index 0000000..78da558
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0024-platina-sec-mi2s-pinctrl.patch
@@ -0,0 +1,30 @@
+From: pmOS Mi8Lite
+Subject: [PATCH] arm64: dts: qcom: sdm660: mux Secondary MI2S pins on platina
+
+The TFA9894 speaker is fed by Secondary MI2S; without muxing gpio24-27 to the
+sec_mi2s function the amp receives no bit clock and stays silent. Add the pin
+state and apply it via the sound card.
+
+Signed-off-by: pmOS Mi8Lite
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -1144,3 +1144,18 @@
+ };
+ };
+ };
++
++/* Secondary MI2S pins (SCK/WS/SD) to the TFA9894 speaker amp. Without this the
++ * amp gets no bit clock (NOCLK) and stays silent. */
++&tlmm {
++ sec_mi2s_default: sec-mi2s-default-state {
++ pins = "gpio24", "gpio25", "gpio26", "gpio27";
++ function = "sec_mi2s";
++ drive-strength = <8>;
++ bias-disable;
++ };
++};
++
++&sound {
++ pinctrl-0 = <&cdc_pdm_default>, <&cdc_dmic_default>, <&sec_mi2s_default>;
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0025-platina-vibrator.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0025-platina-vibrator.patch
new file mode 100644
index 0000000..d591147
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0025-platina-vibrator.patch
@@ -0,0 +1,17 @@
+From: Platina local project
+Subject: [PATCH] Rebase unchanged PM660 haptics node after Bluetooth
+
+The previous Bluetooth patch appends nodes after the original sound context.
+Keep the haptics setting unchanged and append it after those nodes.
+---
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -1179,3 +1179,8 @@
+ max-speed = <3200000>;
+ };
+ };
++
++/* Vibrator: PM660 SPMI haptics (LRA). Proven on jasmine/whyred/lavender. */
++&pm660_haptics {
++ status = "okay";
++};
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0026-platina-7.2-wifi-debug.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0026-platina-7.2-wifi-debug.patch
new file mode 100644
index 0000000..3006db7
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0026-platina-7.2-wifi-debug.patch
@@ -0,0 +1,56 @@
+--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+@@ -16,6 +16,30 @@
+ #include "testmode.h"
+ #include "txrx.h"
+ #include
++
++/* Debug knobs (Xiaomi platina, WLAN.HL.1.0.1.c6 scan crash bring-up):
++ * let the WMI scan command be altered at runtime through
++ * /sys/module/ath10k_core/parameters/ so firmware behavior can be
++ * bisected without rebuilding. Defaults keep mainline behavior.
++ * scan_flags_clr/set operate on scan_ctrl_flags AFTER the TLV
++ * FILTER_PROBE_REQ inversion: PASSIVE=0x1 BCAST_PROBE=0x2 CCK=0x4
++ * OFDM=0x8 CHAN_STAT=0x10 FILTER_PROBE=0x20 CONT_ON_ERR=0x80.
++ */
++static unsigned int ath10k_tlv_scan_flags_clr;
++module_param_named(scan_flags_clr, ath10k_tlv_scan_flags_clr, uint, 0644);
++MODULE_PARM_DESC(scan_flags_clr, "bits to clear in WMI scan_ctrl_flags");
++static unsigned int ath10k_tlv_scan_flags_set;
++module_param_named(scan_flags_set, ath10k_tlv_scan_flags_set, uint, 0644);
++MODULE_PARM_DESC(scan_flags_set, "bits to set in WMI scan_ctrl_flags");
++static unsigned int ath10k_tlv_scan_dwell_active;
++module_param_named(scan_dwell_active, ath10k_tlv_scan_dwell_active, uint, 0644);
++MODULE_PARM_DESC(scan_dwell_active, "override active dwell time ms (0=default)");
++static unsigned int ath10k_tlv_scan_dwell_passive;
++module_param_named(scan_dwell_passive, ath10k_tlv_scan_dwell_passive, uint, 0644);
++MODULE_PARM_DESC(scan_dwell_passive, "override passive dwell time ms (0=default)");
++static unsigned int ath10k_tlv_scan_num_probes = 3;
++module_param_named(scan_num_probes, ath10k_tlv_scan_num_probes, uint, 0644);
++MODULE_PARM_DESC(scan_num_probes, "num_probes in WMI start scan (default 3)");
+
+ /***************/
+ /* TLV helpers */
+@@ -2019,7 +2043,7 @@
+ cmd->num_ssids = __cpu_to_le32(arg->n_ssids);
+ cmd->num_bssids = __cpu_to_le32(arg->n_bssids);
+ cmd->ie_len = __cpu_to_le32(arg->ie_len);
+- cmd->num_probes = __cpu_to_le32(3);
++ cmd->num_probes = __cpu_to_le32(ath10k_tlv_scan_num_probes);
+ ether_addr_copy(cmd->mac_addr.addr, arg->mac_addr.addr);
+ ether_addr_copy(cmd->mac_mask.addr, arg->mac_mask.addr);
+
+@@ -2027,6 +2051,13 @@
+ * e.g. WMI-TLV inverts the logic behind the following flag.
+ */
+ cmd->common.scan_ctrl_flags ^= __cpu_to_le32(WMI_SCAN_FILTER_PROBE_REQ);
++
++ cmd->common.scan_ctrl_flags &= __cpu_to_le32(~ath10k_tlv_scan_flags_clr);
++ cmd->common.scan_ctrl_flags |= __cpu_to_le32(ath10k_tlv_scan_flags_set);
++ if (ath10k_tlv_scan_dwell_active)
++ cmd->common.dwell_time_active = __cpu_to_le32(ath10k_tlv_scan_dwell_active);
++ if (ath10k_tlv_scan_dwell_passive)
++ cmd->common.dwell_time_passive = __cpu_to_le32(ath10k_tlv_scan_dwell_passive);
+
+ ptr += sizeof(*tlv);
+ ptr += sizeof(*cmd);
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0027-platina-7.2-audio-machine.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0027-platina-7.2-audio-machine.patch
new file mode 100644
index 0000000..a9c4b0c
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0027-platina-7.2-audio-machine.patch
@@ -0,0 +1,44 @@
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -1023,12 +1023,12 @@
+ */
+ &q6afedai {
+ dai@81 {
+- reg = ;
++ reg = ;
+ qcom,sd-lines = <0 1>;
+ };
+
+ dai@88 {
+- reg = ;
++ reg = ;
+ qcom,sd-lines = <0 1>;
+ };
+ };
+@@ -1059,7 +1059,7 @@
+ };
+
+ &sound {
+- compatible = "qcom,sdm660-internal-sndcard";
++ compatible = "qcom,sdm660-sndcard";
+ model = "Xiaomi Mi 8 Lite";
+
+ pinctrl-0 = <&cdc_pdm_default>, <&cdc_dmic_default>;
+@@ -1089,7 +1089,7 @@
+ int0-mi2s-dai-link {
+ link-name = "Internal MI2S Playback";
+ cpu {
+- sound-dai = <&q6afedai INT0_MI2S_RX>;
++ sound-dai = <&q6afedai LPI_MI2S_RX_0>;
+ };
+ platform {
+ sound-dai = <&q6routing>;
+@@ -1102,7 +1102,7 @@
+ int3-mi2s-dai-link {
+ link-name = "Internal MI2S Capture";
+ cpu {
+- sound-dai = <&q6afedai INT3_MI2S_TX>;
++ sound-dai = <&q6afedai LPI_MI2S_TX_3>;
+ };
+ platform {
+ sound-dai = <&q6routing>;
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0028-platina-touch-regulator-cleanup.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0028-platina-touch-regulator-cleanup.patch
new file mode 100644
index 0000000..e549ec2
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0028-platina-touch-regulator-cleanup.patch
@@ -0,0 +1,33 @@
+--- a/drivers/input/touchscreen/synaptics-tcm-i2c.c
++++ b/drivers/input/touchscreen/synaptics-tcm-i2c.c
+@@ -582,6 +582,19 @@
+
+ /* ---- probe ---- */
+
++static void syna_release_regulator(void *data)
++{
++ struct syna_tcm *ts = data;
++
++ /* Balance this consumer's enable on probe failure or driver removal.
++ * Normal panel stop still leaves the shared rail enabled.
++ */
++ if (ts->powered) {
++ regulator_disable(ts->vdd);
++ ts->powered = false;
++ }
++}
++
+ static int syna_probe(struct i2c_client *client)
+ {
+ struct device *dev = &client->dev;
+@@ -604,6 +617,10 @@
+ if (IS_ERR(ts->vdd))
+ return dev_err_probe(dev, PTR_ERR(ts->vdd),
+ "failed to get vdd regulator\n");
++
++ ret = devm_add_action_or_reset(dev, syna_release_regulator, ts);
++ if (ret)
++ return ret;
+
+ ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(ts->reset_gpio))
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0029-sdm660-mdp-clock-safe-rate-change.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0029-sdm660-mdp-clock-safe-rate-change.patch
new file mode 100644
index 0000000..d2d34a6
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0029-sdm660-mdp-clock-safe-rate-change.patch
@@ -0,0 +1,11 @@
+--- a/drivers/clk/qcom/mmcc-sdm660.c
++++ b/drivers/clk/qcom/mmcc-sdm660.c
+@@ -970,7 +970,7 @@
+ .name = "mdp_clk_src",
+ .parent_data = mmcc_xo_mmpll0_mmpll5_mmpll7_gpll0_gpll0_div,
+ .num_parents = ARRAY_SIZE(mmcc_xo_mmpll0_mmpll5_mmpll7_gpll0_gpll0_div),
+- .ops = &clk_rcg2_ops,
++ .ops = &clk_rcg2_shared_no_init_park_ops,
+ },
+ };
+
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/0030-platina-tianma-panel.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/0030-platina-tianma-panel.patch
new file mode 100644
index 0000000..6ceb333
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/0030-platina-tianma-panel.patch
@@ -0,0 +1,329 @@
+From: Platina local project
+Subject: [PATCH] drm/panel: integrate Platina Tianma NT36672A power and init
+
+Hardware candidate; full boot and repeated power cycles await physical testing.
+Stock evidence: project/display/tianma-reference.json.
+
+--- a/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
++++ b/drivers/gpu/drm/panel/panel-novatek-nt36672a.c
+@@ -50,6 +50,7 @@
+ unsigned long mode_flags;
+ enum mipi_dsi_pixel_format format;
+ unsigned int lanes;
++ bool reset_pulse;
+
+ void (*send_init_cmds)(struct mipi_dsi_multi_context *dsi_ctx);
+ void (*send_deinit_cmds)(struct mipi_dsi_multi_context *dsi_ctx);
+@@ -117,6 +118,17 @@
+ ret = regulator_bulk_enable(ARRAY_SIZE(pinfo->supplies), pinfo->supplies);
+ if (ret < 0)
+ return ret;
++
++ if (pinfo->desc->reset_pulse) {
++ /* Platina downstream: physical high 1ms, low 1ms, high 10ms. */
++ gpiod_set_value(pinfo->reset_gpio, 0);
++ usleep_range(1000, 2000);
++ gpiod_set_value(pinfo->reset_gpio, 1);
++ usleep_range(1000, 2000);
++ gpiod_set_value(pinfo->reset_gpio, 0);
++ msleep(10);
++ return 0;
++ }
+
+ /*
+ * As per downstream kernel, Reset sequence of Tianma FHD panel requires the panel to
+@@ -138,13 +150,15 @@
+ struct mipi_dsi_multi_context dsi_ctx = { .dsi = pinfo->link };
+
+ dsi_ctx.accum_err = nt36672a_panel_power_on(pinfo);
++ if (dsi_ctx.accum_err < 0)
++ return dsi_ctx.accum_err;
+
+ /* send init cmds */
+ if (pinfo->desc->send_init_cmds)
+ pinfo->desc->send_init_cmds(&dsi_ctx);
+
+ if (dsi_ctx.accum_err < 0)
+- gpiod_set_value(pinfo->reset_gpio, 0);
++ nt36672a_panel_power_off(panel);
+
+ return dsi_ctx.accum_err;
+ }
+@@ -912,7 +926,9 @@
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "failed to get regulators\n");
+
+- pinfo->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
++ pinfo->reset_gpio = devm_gpiod_get(dev, "reset",
++ pinfo->desc->reset_pulse ?
++ GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
+ if (IS_ERR(pinfo->reset_gpio))
+ return dev_err_probe(dev, PTR_ERR(pinfo->reset_gpio),
+ "failed to get reset gpio from DT\n");
+@@ -974,7 +990,235 @@
+ drm_panel_remove(&pinfo->base);
+ }
+
++/* Xiaomi platina Tianma variant; use its own stock sequence and timings.
++ * Reference: MiCode platina-o-oss, dsi-panel-tianma-fhd-nt36672a-video.dtsi
++ * (GPL-2.0-only), with CABC/ESD values from the retained original stock boot.
++ * Do not use the same-resolution tulip or bootloader-only BOE descriptor.
++ */
++static void platina_tianma_init_cmds(struct mipi_dsi_multi_context *dsi_ctx)
++{
++ dsi_ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x22);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfb, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x00, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x01, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x02, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x03, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x04, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x05, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x06, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x07, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x08, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x09, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x0a, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x0b, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x0c, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x0d, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x0e, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x0f, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x10, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x11, 0x50);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x12, 0x60);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x13, 0x70);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x14, 0x58);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x15, 0x68);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x16, 0x78);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x17, 0x77);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x18, 0x3e);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x19, 0x36);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x1a, 0x30);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x1b, 0x28);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x1c, 0x25);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x1d, 0x23);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x1e, 0x26);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x1f, 0x2a);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x20, 0x30);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x21, 0x36);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x22, 0x3c);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x23, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x24, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x25, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x26, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x27, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x28, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x53, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x54, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x55, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x56, 0x76);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x58, 0xc8);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x59, 0xca);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5a, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5b, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5c, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5d, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5e, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5f, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x60, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x61, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x62, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x63, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x64, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x65, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x66, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x67, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x68, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x69, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x6a, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x6b, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x6c, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x6d, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x6e, 0x48);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x6f, 0xc8);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x70, 0x03);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x71, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x72, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x73, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x74, 0x06);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x75, 0x0c);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x76, 0x03);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x77, 0x09);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x78, 0x0f);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x79, 0x68);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x7a, 0x8b);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x7c, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x7d, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x7e, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x7f, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x80, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x81, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x83, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x84, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x85, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x86, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x87, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x88, 0x40);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x89, 0x83);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x8a, 0x86);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb7, 0x76);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb8, 0x76);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x23);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfb, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x00, 0x60);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x07, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x08, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x09, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x11, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x12, 0x80);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x15, 0x6d);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x16, 0x0b);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x29, 0x0a);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x30, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x31, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x32, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x33, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x34, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x35, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x36, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x37, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x38, 0xfc);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x39, 0xf9);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x3a, 0xf5);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x3b, 0xf1);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x3d, 0xee);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x3f, 0xeb);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x40, 0xe9);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x41, 0xe5);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x2a, 0x13);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x45, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x46, 0xf5);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x47, 0xea);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x48, 0xdf);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x49, 0xd5);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x4a, 0xca);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x4b, 0xc0);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x4c, 0xb6);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x4d, 0xac);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x4e, 0xa2);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x4f, 0x98);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x50, 0x8e);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x51, 0x84);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x52, 0x7a);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x53, 0x70);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x54, 0x66);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x2b, 0x0e);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x58, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x59, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5a, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5b, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5c, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5d, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5e, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x5f, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x60, 0xf6);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x61, 0xec);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x62, 0xe3);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x63, 0xd9);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x64, 0xd0);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x65, 0xc7);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x66, 0xbd);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x67, 0xb3);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x01, 0x84);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x06, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x05, 0x2d);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x04, 0x05);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x25);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfb, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x05, 0x04);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x10);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfb, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x35, 0x00);
++ mipi_dsi_generic_write_seq_multi(dsi_ctx, 0x51, 0x07, 0xff);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x53, 0x24);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x55, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x29);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x11);
++ mipi_dsi_msleep(dsi_ctx, 70);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x24);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfb, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xc3, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xc4, 0x54);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xc2, 0x8e);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x10);
++}
++
++static void platina_tianma_deinit_cmds(struct mipi_dsi_multi_context *dsi_ctx)
++{
++ /* Stock disables ESD before display-off/sleep; these are sent by unprepare. */
++ dsi_ctx->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x24);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfb, 0x01);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xc3, 0x00);
++ mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xff, 0x10);
++}
++
++static const struct drm_display_mode platina_tianma_mode = {
++ .clock = (1080 + 92 + 20 + 140) * (2280 + 16 + 2 + 10) * 60 / 1000,
++ .hdisplay = 1080,
++ .hsync_start = 1080 + 92,
++ .hsync_end = 1080 + 92 + 20,
++ .htotal = 1080 + 92 + 20 + 140,
++ .vdisplay = 2280,
++ .vsync_start = 2280 + 16,
++ .vsync_end = 2280 + 16 + 2,
++ .vtotal = 2280 + 16 + 2 + 10,
++ .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
++};
++
++static const struct nt36672a_panel_desc platina_tianma_panel_desc = {
++ .display_mode = &platina_tianma_mode,
++ .width_mm = 68,
++ .height_mm = 144,
++ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
++ MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_LPM,
++ .format = MIPI_DSI_FMT_RGB888,
++ .lanes = 4,
++ .reset_pulse = true,
++ .send_init_cmds = platina_tianma_init_cmds,
++ .send_deinit_cmds = platina_tianma_deinit_cmds,
++};
++
+ static const struct of_device_id panel_nt36672a_match[] = {
++ { .compatible = "xiaomi,platina-tianma-nt36672a", .data = &platina_tianma_panel_desc },
+ { .compatible = "shenchao,fhdplus-video", .data = &shenchao_lavender_panel_desc },
+ { .compatible = "tianma,fhd-video", .data = &tianma_fhd_video_panel_desc },
+ { .compatible = "tianma,tl060fvxs16-00", .data = &tianma_jasmine_panel_desc },
+--- a/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
++++ b/arch/arm64/boot/dts/qcom/sdm660-xiaomi-platina.dts
+@@ -842,12 +842,12 @@
+ vdda-supply = <&vreg_l1a_1p225>;
+
+ panel: panel@0 {
+- compatible = "xiaomi,platina-td4320", "boe,td4320";
++ compatible = "xiaomi,platina-tianma-nt36672a", "novatek,nt36672a";
+ reg = <0>;
+
+- iovcc-supply = <&vreg_l11a_1p8>;
+- vsp-supply = <&panel_vsp>;
+- vsn-supply = <&panel_vsn>;
++ vddio-supply = <&vreg_l11a_1p8>;
++ vddpos-supply = <&panel_vsp>;
++ vddneg-supply = <&panel_vsn>;
+
+ reset-gpios = <&tlmm 53 GPIO_ACTIVE_LOW>;
+
+--- a/Documentation/devicetree/bindings/display/panel/novatek,nt36672a.yaml
++++ b/Documentation/devicetree/bindings/display/panel/novatek,nt36672a.yaml
+@@ -23,7 +23,8 @@
+ items:
+ - enum:
+ - shenchao,fhdplus-video
+- - tianma,fhd-video
++ - xiaomi,platina-tianma-nt36672a
++ - tianma,fhd-video
+ - tianma,tl060fvxs16-00
+ - tianma,tl063fvmca01-00
+ - tianma,tl063fvmc43-02
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/APKBUILD b/ports/candidate/linux-postmarketos-qcom-sdm660/APKBUILD
new file mode 100644
index 0000000..f328511
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/APKBUILD
@@ -0,0 +1,155 @@
+# Kernel config based on: arch/arm64/configs/sdm660_defconfig
+maintainer="Alexey Minnekhanov "
+_flavor="postmarketos-qcom-sdm660"
+pkgname=linux-$_flavor
+pkgver=7.2.12
+pkgrel=1
+pkgdesc="Close to mainline linux kernel for Qualcomm Snapdragon 660 SoC"
+arch="aarch64"
+url="https://kernel.org/"
+license="GPL-2.0-only"
+options="!strip !check !tracedeps
+ pmb:cross-native
+ pmb:kconfigcheck-community
+ "
+makedepends="
+ bison
+ clang
+ findutils
+ flex
+ lld
+ llvm
+ openssl-dev
+ perl
+ postmarketos-installkernel
+ python3
+ zstd
+ pahole
+ linux-headers
+ elfutils-dev
+ "
+
+_commit="dd1ed52c8ceef4f16715118ed0252fe75adbe71d"
+
+source="
+ linux-$_commit.tar.gz::https://codeload.github.com/sdm660-mainline/linux/tar.gz/$_commit
+ config-$_flavor.aarch64
+ 0001-platina-enable-display.patch
+ 0002-panel-simple-td4320.patch
+ 0004-synaptics-tcm-driver.patch
+ 0006-platina-battery.patch
+ 0007-platina-wifi.patch
+ 0010-ath10k-wcn3990-no-psmode.patch
+ 0011-ath10k-wcn3990-chanlist-qcacld.patch
+ 0012-ath10k-wcn3990-scan-trailing-tlvs.patch
+ 0014-ath10k-wcn3990-no-scan-chan-stat.patch
+ 0015-clk-qcom-sdm660-cpu-osm-driver.patch
+ 0016-arm64-dts-sdm660-platina-osm-cpufreq.patch
+ 0017-clk-qcom-sdm660-cprh-driver.patch
+ 0018-platina-audio.patch
+ 0020-tfa9894-codec.patch
+ 0021-platina-speaker.patch
+ 0024-platina-sec-mi2s-pinctrl.patch
+ 0022-platina-bluetooth.patch
+ 0025-platina-vibrator.patch
+ 0026-platina-7.2-wifi-debug.patch
+ 0027-platina-7.2-audio-machine.patch
+ 0028-platina-touch-regulator-cleanup.patch
+ 0029-sdm660-mdp-clock-safe-rate-change.patch
+ 0030-platina-tianma-panel.patch
+ stable-7.2.3-4.patch
+ stable-7.2.4-5.patch
+ stable-7.2.5-6.patch
+ stable-7.2.6-7.patch
+ stable-7.2.7-8.patch
+ stable-7.2.8-9.patch
+ stable-7.2.9-10.patch
+ stable-7.2.10-11.patch
+ stable-7.2.11-12.patch
+"
+
+_carch="arm64"
+
+# for some reason, the directory inside .tar.gz does not match tag name: leading
+# "v" is missing, so we can't use $_tag here
+builddir="$srcdir/linux-$_commit"
+
+prepare() {
+ default_prepare
+ cp -v "$srcdir/config-$_flavor.$CARCH" "$builddir"/.config
+}
+
+build() {
+ unset LDFLAGS
+
+ make ARCH="$_carch" LLVM=1 \
+ KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor" all Image.gz
+}
+
+package() {
+ mkdir -p "$pkgdir"/boot
+
+ make modules_install dtbs_install \
+ ARCH="$_carch" \
+ LLVM=1 \
+ INSTALL_PATH="$pkgdir"/boot \
+ INSTALL_MOD_PATH="$pkgdir"/usr \
+ INSTALL_MOD_STRIP=1 \
+ INSTALL_DTBS_PATH="$pkgdir/boot/dtbs-tmp"
+
+ install -D "$builddir/arch/arm64/boot/vmlinuz.efi" \
+ "$pkgdir/boot/vmlinuz.efi"
+
+ install -D "$builddir/arch/arm64/boot/Image.gz" \
+ "$pkgdir/boot/vmlinuz"
+
+ # Reduce package size, install only qcom SDM630/636/660 dtbs.
+ # This reduces .apk size from ~46 Mb to ~30 Mb.
+ mkdir -p "$pkgdir"/boot/dtbs/qcom
+ cp -r "$pkgdir"/boot/dtbs-tmp/qcom/sda660* "$pkgdir"/boot/dtbs/qcom
+ cp -r "$pkgdir"/boot/dtbs-tmp/qcom/sdm630* "$pkgdir"/boot/dtbs/qcom
+ cp -r "$pkgdir"/boot/dtbs-tmp/qcom/sdm636* "$pkgdir"/boot/dtbs/qcom
+ cp -r "$pkgdir"/boot/dtbs-tmp/qcom/sdm660* "$pkgdir"/boot/dtbs/qcom
+ rm -r "$pkgdir"/boot/dtbs-tmp
+
+ rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source
+
+ install -D "$builddir/include/config/kernel.release" \
+ "$pkgdir/usr/share/kernel/$_flavor/kernel.release"
+}
+sha512sums="
+b56636f4d7429e971a70c1b7237fda4d5795fbe422c01f6fc6038220c2e831bf4479bd411b5e04e4db45de4fb8ec15a9e0e312b6479e2067709062af3dfd6997 linux-dd1ed52c8ceef4f16715118ed0252fe75adbe71d.tar.gz
+2a21ce86163c1f33d2fc8bf1d84823c4c6221f67abdcb32e7a11f27325eb5dc7ffc968bc56d15b469aa5aa4b8381ba077e6abe018bd69a69049124e331228304 config-postmarketos-qcom-sdm660.aarch64
+0ed47ad2e1cf773a49ab542b4f6ccc2baf61a4186e51cda8f70bacce6c30c687305f8c7f327cdd9b3919358ca18eaac28c7c9b82bfec73e5fe492663afdec825 0001-platina-enable-display.patch
+83b9efa9b1a46499d1936f9e3f90b832458ace687a5ad3892ae1787a09997491efb9cc1bb0db44007adda97900ae2e3ce1b7dafa28ecb4cd84a95ade8667f05b 0002-panel-simple-td4320.patch
+2ff1034abfbaf3c5bf56233b46a6c5a066015a982d4e55e5fd34c5d908d145305c7a99fd7731057b8fd5b9afc3e595b60856f6e0a0af921cfbff068eb744757b 0004-synaptics-tcm-driver.patch
+727180fca4f9846de890f73cc8636e3a1eccb8a05b0ad60613407e967857b377356c8380d2fa27b453cf4bc63b71d8be45b09b0039396794ba16259dcc9d5901 0006-platina-battery.patch
+c7d469c265fcae3280a008a3114cd516bb0a90dfe25ad5357bd09ba48175bf79ce589c661fec71ff83e48887d90b9b1e987a04ad5de03130e9e1212f0f470966 0007-platina-wifi.patch
+f7a8b7272ccb70b6a3a0049006ec608960fd876bf43ebf2c5880c92d1e55e7953a31dff37a2b219756f39e5baac4e8d6beee1407094fd07e812d513e9cd8397c 0010-ath10k-wcn3990-no-psmode.patch
+e8a8b9382cdb3543b9ed73d309bfc37d41be96852b92ba46beed78b880186e71e3d73a151acb9893f8f13764e9265bf5a50865b2c2329feeb064039b70721091 0011-ath10k-wcn3990-chanlist-qcacld.patch
+a60a9faec11342f4ac0388b612edbbbe132269d2fd68bbbd2709fa0af068f1c9d27b57d5ebf0c6fc99792609eee0d715572ec160e41698bf0ae11a5c5cab7cf1 0012-ath10k-wcn3990-scan-trailing-tlvs.patch
+ae81f328100b9a6f756c68f5fcda2618ea866349c2ce291703f5f817b42d3a0954c772ed6f063d8132f522837e3eaa2978c61564cd19536f4442eb381e636680 0014-ath10k-wcn3990-no-scan-chan-stat.patch
+f8a47c452ec42a4c9278bd7e40e83ecea1d18c6eb76099e8e5526788275e2afac24bc2b415c22e1e41a3fda14ce07dc968e3e7e95b91122226a1fb098b027305 0015-clk-qcom-sdm660-cpu-osm-driver.patch
+36aef2306a6bb302e69891bf6619cfdfa81bc2e09cd2e4a2a15371f39af5755cf1045e061a1561d7375d8cfd8659dd2d81cab0296c62d90f7b256894fa28ea14 0016-arm64-dts-sdm660-platina-osm-cpufreq.patch
+71cd673724dda58e0af4c50d428d3739114eb32640da84823c84ffb8342ab1106f361cc5c780d58827bbc854285f06acdce17ffa486d3a4d14b786c1c415e318 0017-clk-qcom-sdm660-cprh-driver.patch
+110ad7640090163637a29fa61d5901b7424a2516be9f3131094fbecdb0ce69d705b3584a49ce27ae1d7c3319eefac974912e78fa65ede2baadd4135f724fc20b 0018-platina-audio.patch
+49e5d4ffac1120cade440bc5df28995686a074699b36874e52cf49c33cf2b3e74012c819cd1d0040738af153bf3273635702c9b8a955f1984b2cc6bd541e85de 0020-tfa9894-codec.patch
+93d75da385d8b8fd93bfc038a182ddecab8dd1367a7b0c937c3a73160699749c78154454d957cb740d16d6ad1b2afa72ab453581138f78ec4e884787c3997fac 0021-platina-speaker.patch
+af6e09b560c497300e57b5b74ce5e8f59740091045a9dcd0dc8299018d9ff88b958c6476a5c1fc00060d649118e34011bd5481261aa52f1b56d1d522618bbf76 0024-platina-sec-mi2s-pinctrl.patch
+ae97edcc2302b088a3d83539139199e9f5a19c3a11f66a3512b979b93673755f300b6458f7ddfaaa769b9f735e9d99f7abcbca37951e6cb767a6239e245cdf8b 0022-platina-bluetooth.patch
+73eb732191f8ea7ce41a0810b390f407e525a4cecf317e7ead8ce42b1b7fd0b249c37619b0164e1c9241dbe53a605f7d6681ce589dc506a36f1a40b891db328d 0025-platina-vibrator.patch
+1bb9b6f31c3e8c5847bd41dd5e2ad1971842bde316d027bd5a5f262febc53566a1542027d8ee726a83947f2b9a5f6e0c76bee138771cdef3368601d99fd071b9 0026-platina-7.2-wifi-debug.patch
+81bb48b72a639df602deb7447dcb7c28e56daa14e5d86b76a49f8ac7b2cea10f8c38cabdeee61448408097ac765596539245fec9e3f3f3379fe7451438f8108f 0027-platina-7.2-audio-machine.patch
+c04261993d81ae94ae8f6e86df93e6e37390fd8b7746f8d54eaf957e818cdf92691fdeb8b9a5adae220fcd199189aea268c837b6482e13a70a9de9aeaafaacc5 0028-platina-touch-regulator-cleanup.patch
+07f552abed2177d7c0a4fd731692c934d54f8ad4d117ecad3e1eab4ceedd546b07c6fc01c693dae65a09fc1581b987db4bb7f3cdffa4488b20919a32a1790621 0029-sdm660-mdp-clock-safe-rate-change.patch
+e845d83a8bb8e7bb7cc59bb309b78b920460f4d31b9c962e00119321e3f01a65bfcc2cc3185d609a0b99a73c9deed5d705d58afdf06d8dac2e409ad15f821d68 0030-platina-tianma-panel.patch
+1a7f9cf2443c0f059ac64a78dddee77fca584288edeea943aa45db05fb5e3b7b2930dab595f6c0911671bf5517bd64550a65b097f47d5179cc7454ec90db56cd stable-7.2.3-4.patch
+303d4a717c67d5dbb5d17c37882b3ef1b6b44b3cf9b17723a611efe1f028019d5ef53c0e3595ed79f5468a46ede2d640171b9dd97ce2dd99b487d0406ef79f16 stable-7.2.4-5.patch
+b09a94d0eb3c0382ad8998843019ea0d52ae5a89ad7ba54072b21eeea2c7ee602c57a32a0d9b99a2c5ae1f581dadc4d4395096e905b54678affc18125d9b8cba stable-7.2.5-6.patch
+4b527cf54dd581408cbb44ace82ea975baa656cf12c9cd35356ce6c4e05901c27d498c3b3a956f84dcf5f5ac436da39cb37cd535353f024c7877e315f455062e stable-7.2.6-7.patch
+526e8061f3906876bcd9db2f7c82a31c438c2d2c56701208041edb932bd66473ff8f221b22af24b687f14e85852dbbb1d8058cdc63f29ca30f14bb1590216733 stable-7.2.7-8.patch
+e34cc3b376501b8db887eeb79950adb84906641062ef0e60a9bdbedb3b43e956dd5c56f1967df8ad274454c3d9df03867c37dcf62cdb5d80a9a59eddfa831776 stable-7.2.8-9.patch
+be7770c858be5b7b559b959fc6f50ca6d94a7f518ee67c8e675e01ab583fc043c10cbeb6971079a13394a981f8153906839cdf409fef6f4279709ecc93495eff stable-7.2.9-10.patch
+d2449e4c02bf11835d20bd9c841a3b0db78ba14ebe2effaec04d98db63ea4dc41a552d23db8ae72e10d2675d1b20570f06a250c790dc773f95f0be4a14c706e9 stable-7.2.10-11.patch
+eb3b89ac99648776f193ee3c9d96d257f7d2e6ba5200a526e63c97e7dc4982e4b2985f15481aa4314dc54ca5f0bafb395b4f4fc375ed4fba2b8d9ca23124cd31 stable-7.2.11-12.patch
+"
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/config-postmarketos-qcom-sdm660.aarch64 b/ports/candidate/linux-postmarketos-qcom-sdm660/config-postmarketos-qcom-sdm660.aarch64
new file mode 100644
index 0000000..145ae47
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/config-postmarketos-qcom-sdm660.aarch64
@@ -0,0 +1,8109 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# Linux/arm64 7.2.12 Kernel Configuration
+#
+CONFIG_CC_VERSION_TEXT="Alpine clang version 22.1.3"
+CONFIG_GCC_VERSION=0
+CONFIG_CC_IS_CLANG=y
+CONFIG_CLANG_VERSION=220103
+CONFIG_AS_IS_LLVM=y
+CONFIG_AS_VERSION=220103
+CONFIG_LD_VERSION=0
+CONFIG_LD_IS_LLD=y
+CONFIG_LLD_VERSION=220103
+CONFIG_RUSTC_VERSION=0
+CONFIG_RUSTC_LLVM_VERSION=0
+CONFIG_RUSTC_LLVM_MAJOR_VERSION=0
+CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
+CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
+CONFIG_TOOLS_SUPPORT_RELR=y
+CONFIG_CC_HAS_ASM_INLINE=y
+CONFIG_CC_HAS_ASSUME=y
+CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
+CONFIG_CC_HAS_COUNTED_BY=y
+CONFIG_CC_HAS_COUNTED_BY_PTR=y
+CONFIG_CC_HAS_ALLOC_TOKEN=y
+CONFIG_CC_HAS_MULTIDIMENSIONAL_NONSTRING=y
+CONFIG_CC_OPT_INLINE_MEMSET="-mllvm -max-store-memset=4294967294"
+CONFIG_LD_CAN_USE_KEEP_IN_OVERLAY=y
+CONFIG_PAHOLE_VERSION=130
+CONFIG_IRQ_WORK=y
+CONFIG_BUILDTIME_TABLE_SORT=y
+CONFIG_THREAD_INFO_IN_TASK=y
+
+#
+# General setup
+#
+CONFIG_INIT_ENV_ARG_LIMIT=32
+# CONFIG_COMPILE_TEST is not set
+# CONFIG_WERROR is not set
+CONFIG_LOCALVERSION="-sdm660"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_BUILD_SALT=""
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_ZSTD=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_ZSTD is not set
+CONFIG_DEFAULT_INIT=""
+CONFIG_DEFAULT_HOSTNAME="(none)"
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+# CONFIG_WATCH_QUEUE is not set
+CONFIG_CROSS_MEMORY_ATTACH=y
+CONFIG_AUDIT=y
+CONFIG_HAVE_ARCH_AUDITSYSCALL=y
+CONFIG_AUDITSYSCALL=y
+
+#
+# IRQ subsystem
+#
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_IRQ_SHOW=y
+CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
+CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK=y
+CONFIG_GENERIC_IRQ_MIGRATION=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_IRQ_DOMAIN=y
+CONFIG_IRQ_DOMAIN_HIERARCHY=y
+CONFIG_IRQ_FASTEOI_HIERARCHY_HANDLERS=y
+CONFIG_GENERIC_IRQ_IPI=y
+CONFIG_GENERIC_MSI_IRQ=y
+CONFIG_IRQ_MSI_IOMMU=y
+CONFIG_GENERIC_IRQ_STAT_SNAPSHOT=y
+CONFIG_IRQ_FORCED_THREADING=y
+CONFIG_SPARSE_IRQ=y
+# CONFIG_GENERIC_IRQ_DEBUGFS is not set
+CONFIG_GENERIC_IRQ_KEXEC_CLEAR_VM_FORWARD=y
+# end of IRQ subsystem
+
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_ARCH_HAS_TICK_BROADCAST=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_HAVE_POSIX_CPU_TIMERS_TASK_WORK=y
+CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y
+CONFIG_CONTEXT_TRACKING=y
+CONFIG_CONTEXT_TRACKING_IDLE=y
+
+#
+# Timers subsystem
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ_COMMON=y
+# CONFIG_HZ_PERIODIC is not set
+CONFIG_NO_HZ_IDLE=y
+# CONFIG_NO_HZ_FULL is not set
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_POSIX_AUX_CLOCKS=y
+# end of Timers subsystem
+
+CONFIG_BPF=y
+CONFIG_HAVE_EBPF_JIT=y
+CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y
+
+#
+# BPF subsystem
+#
+CONFIG_BPF_SYSCALL=y
+CONFIG_BPF_JIT=y
+# CONFIG_BPF_JIT_ALWAYS_ON is not set
+CONFIG_BPF_JIT_DEFAULT_ON=y
+CONFIG_BPF_UNPRIV_DEFAULT_OFF=y
+# CONFIG_BPF_PRELOAD is not set
+CONFIG_BPF_LSM=y
+# end of BPF subsystem
+
+CONFIG_PREEMPT_BUILD=y
+CONFIG_ARCH_HAS_PREEMPT_LAZY=y
+CONFIG_PREEMPT=y
+# CONFIG_PREEMPT_LAZY is not set
+CONFIG_PREEMPT_COUNT=y
+CONFIG_PREEMPTION=y
+# CONFIG_PREEMPT_DYNAMIC is not set
+# CONFIG_SCHED_CLASS_EXT is not set
+
+#
+# CPU/Task time and stats accounting
+#
+CONFIG_TICK_CPU_ACCOUNTING=y
+# CONFIG_VIRT_CPU_ACCOUNTING_GEN is not set
+CONFIG_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_SCHED_AVG_IRQ=y
+CONFIG_SCHED_HW_PRESSURE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_PSI=y
+# CONFIG_PSI_DEFAULT_DISABLED is not set
+# end of CPU/Task time and stats accounting
+
+CONFIG_CPU_ISOLATION=y
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+CONFIG_PREEMPT_RCU=y
+# CONFIG_RCU_EXPERT is not set
+CONFIG_TREE_SRCU=y
+CONFIG_TASKS_RCU_GENERIC=y
+CONFIG_NEED_TASKS_RCU=y
+CONFIG_TASKS_RCU=y
+CONFIG_TASKS_RUDE_RCU=y
+CONFIG_TASKS_TRACE_RCU=y
+CONFIG_RCU_STALL_COMMON=y
+CONFIG_RCU_NEED_SEGCBLIST=y
+# end of RCU Subsystem
+
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+# CONFIG_IKHEADERS is not set
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
+# CONFIG_PRINTK_INDEX is not set
+CONFIG_GENERIC_SCHED_CLOCK=y
+
+#
+# Scheduler features
+#
+CONFIG_UCLAMP_TASK=y
+CONFIG_UCLAMP_BUCKETS_COUNT=5
+# end of Scheduler features
+
+CONFIG_ARCH_SUPPORTS_NUMA_BALANCING=y
+CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH=y
+CONFIG_CC_HAS_INT128=y
+CONFIG_CC_IMPLICIT_FALLTHROUGH="-Wimplicit-fallthrough"
+CONFIG_CC_MS_EXTENSIONS="-fms-extensions"
+CONFIG_GCC10_NO_ARRAY_BOUNDS=y
+CONFIG_GCC_NO_STRINGOP_OVERFLOW=y
+CONFIG_ARCH_SUPPORTS_INT128=y
+CONFIG_SCHED_CACHE=y
+CONFIG_SLAB_OBJ_EXT=y
+CONFIG_CGROUPS=y
+CONFIG_PAGE_COUNTER=y
+# CONFIG_CGROUP_FAVOR_DYNMODS is not set
+CONFIG_MEMCG=y
+# CONFIG_MEMCG_V1 is not set
+CONFIG_BLK_CGROUP=y
+CONFIG_CGROUP_WRITEBACK=y
+CONFIG_CGROUP_SCHED=y
+CONFIG_GROUP_SCHED_WEIGHT=y
+CONFIG_GROUP_SCHED_BANDWIDTH=y
+CONFIG_FAIR_GROUP_SCHED=y
+CONFIG_CFS_BANDWIDTH=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_SCHED_MM_CID=y
+CONFIG_UCLAMP_TASK_GROUP=y
+CONFIG_CGROUP_PIDS=y
+# CONFIG_CGROUP_RDMA is not set
+CONFIG_CGROUP_DMEM=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_HUGETLB=y
+CONFIG_CPUSETS=y
+# CONFIG_CPUSETS_V1 is not set
+CONFIG_CGROUP_DEVICE=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_CGROUP_PERF=y
+CONFIG_CGROUP_BPF=y
+CONFIG_CGROUP_MISC=y
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_SOCK_CGROUP_DATA=y
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_TIME_NS=y
+CONFIG_TIME_NS_VDSO=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_NET_NS=y
+CONFIG_CHECKPOINT_RESTORE=y
+CONFIG_SCHED_AUTOGROUP=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+CONFIG_RD_BZIP2=y
+CONFIG_RD_LZMA=y
+CONFIG_RD_XZ=y
+CONFIG_RD_LZO=y
+CONFIG_RD_LZ4=y
+CONFIG_RD_ZSTD=y
+# CONFIG_BOOT_CONFIG is not set
+CONFIG_CMDLINE_LOG_WRAP_IDEAL_LEN=1021
+CONFIG_INITRAMFS_PRESERVE_MTIME=y
+CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_LD_ORPHAN_WARN=y
+CONFIG_LD_ORPHAN_WARN_LEVEL="warn"
+CONFIG_SYSCTL=y
+CONFIG_HAVE_UID16=y
+CONFIG_SYSCTL_EXCEPTION_TRACE=y
+CONFIG_SYSFS_SYSCALL=y
+# CONFIG_EXPERT is not set
+CONFIG_UID16=y
+CONFIG_MULTIUSER=y
+CONFIG_FHANDLE=y
+CONFIG_POSIX_TIMERS=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_FUTEX=y
+CONFIG_FUTEX_PI=y
+CONFIG_FUTEX_PRIVATE_HASH=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+CONFIG_IO_URING=y
+CONFIG_ADVISE_SYSCALLS=y
+CONFIG_MEMBARRIER=y
+CONFIG_KCMP=y
+CONFIG_RSEQ=y
+CONFIG_CACHESTAT_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_SELFTEST is not set
+CONFIG_KALLSYMS_ALL=y
+CONFIG_ARCH_HAS_MEMBARRIER_SYNC_CORE=y
+CONFIG_ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS=y
+CONFIG_HAVE_PERF_EVENTS=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_PERF_EVENTS=y
+# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
+# end of Kernel Performance Events And Counters
+
+CONFIG_SYSTEM_DATA_VERIFICATION=y
+CONFIG_PROFILING=y
+CONFIG_TRACEPOINTS=y
+
+#
+# Kexec and crash features
+#
+CONFIG_CRASH_RESERVE=y
+CONFIG_VMCORE_INFO=y
+CONFIG_KEXEC_CORE=y
+CONFIG_KEXEC=y
+# CONFIG_KEXEC_FILE is not set
+CONFIG_CRASH_DUMP=y
+# end of Kexec and crash features
+
+#
+# Live Update and Kexec HandOver
+#
+# CONFIG_KEXEC_HANDOVER is not set
+# end of Live Update and Kexec HandOver
+# end of General setup
+
+CONFIG_ARM64=y
+CONFIG_RUSTC_SUPPORTS_ARM64=y
+CONFIG_CLANG_SUPPORTS_DYNAMIC_FTRACE_WITH_ARGS=y
+CONFIG_64BIT=y
+CONFIG_MMU=y
+CONFIG_ARM64_CONT_PTE_SHIFT=4
+CONFIG_ARM64_CONT_PMD_SHIFT=4
+CONFIG_ARCH_MMAP_RND_BITS_MIN=18
+CONFIG_ARCH_MMAP_RND_BITS_MAX=33
+CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MIN=11
+CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX=16
+CONFIG_NO_IOPORT_MAP=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_SMP=y
+CONFIG_KERNEL_MODE_NEON=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_PGTABLE_LEVELS=4
+CONFIG_ARCH_SUPPORTS_UPROBES=y
+CONFIG_ARCH_PROC_KCORE_TEXT=y
+CONFIG_BUILTIN_RETURN_ADDRESS_STRIPS_PAC=y
+
+#
+# Platform selection
+#
+# CONFIG_ARCH_ACTIONS is not set
+# CONFIG_ARCH_AIROHA is not set
+# CONFIG_ARCH_SUNXI is not set
+# CONFIG_ARCH_ALPINE is not set
+# CONFIG_ARCH_APPLE is not set
+# CONFIG_ARCH_ASPEED is not set
+# CONFIG_ARCH_AXIADO is not set
+# CONFIG_ARCH_BCM is not set
+# CONFIG_ARCH_BERLIN is not set
+# CONFIG_ARCH_BITMAIN is not set
+# CONFIG_ARCH_BLAIZE is not set
+# CONFIG_ARCH_BST is not set
+# CONFIG_ARCH_CIX is not set
+# CONFIG_ARCH_EXYNOS is not set
+# CONFIG_ARCH_K3 is not set
+# CONFIG_ARCH_LG1K is not set
+# CONFIG_ARCH_HISI is not set
+# CONFIG_ARCH_KEEMBAY is not set
+# CONFIG_ARCH_MEDIATEK is not set
+# CONFIG_ARCH_MESON is not set
+# CONFIG_ARCH_MICROCHIP is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_MVEBU is not set
+# CONFIG_ARCH_NXP is not set
+# CONFIG_ARCH_MA35 is not set
+# CONFIG_ARCH_NPCM is not set
+# CONFIG_ARCH_PENSANDO is not set
+CONFIG_ARCH_QCOM=y
+# CONFIG_ARCH_REALTEK is not set
+# CONFIG_ARCH_RENESAS is not set
+# CONFIG_ARCH_ROCKCHIP is not set
+# CONFIG_ARCH_SEATTLE is not set
+# CONFIG_ARCH_INTEL_SOCFPGA is not set
+# CONFIG_ARCH_SOPHGO is not set
+# CONFIG_ARCH_STM32 is not set
+# CONFIG_ARCH_SYNQUACER is not set
+# CONFIG_ARCH_TEGRA is not set
+# CONFIG_ARCH_SPRD is not set
+# CONFIG_ARCH_THUNDER is not set
+# CONFIG_ARCH_THUNDER2 is not set
+# CONFIG_ARCH_UNIPHIER is not set
+# CONFIG_ARCH_VEXPRESS is not set
+# CONFIG_ARCH_VISCONTI is not set
+# CONFIG_ARCH_XGENE is not set
+# CONFIG_ARCH_ZYNQMP is not set
+# end of Platform selection
+
+#
+# Kernel Features
+#
+
+#
+# ARM errata workarounds via the alternatives framework
+#
+CONFIG_AMPERE_ERRATUM_AC03_CPU_38=y
+CONFIG_AMPERE_ERRATUM_AC04_CPU_23=y
+CONFIG_ARM64_WORKAROUND_CLEAN_CACHE=y
+CONFIG_ARM64_ERRATUM_826319=y
+CONFIG_ARM64_ERRATUM_827319=y
+CONFIG_ARM64_ERRATUM_824069=y
+CONFIG_ARM64_ERRATUM_819472=y
+CONFIG_ARM64_ERRATUM_832075=y
+CONFIG_ARM64_ERRATUM_1742098=y
+CONFIG_ARM64_ERRATUM_845719=y
+CONFIG_ARM64_ERRATUM_843419=y
+CONFIG_ARM64_ERRATUM_1024718=y
+CONFIG_ARM64_ERRATUM_1418040=y
+CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT=y
+CONFIG_ARM64_ERRATUM_1165522=y
+CONFIG_ARM64_ERRATUM_1319367=y
+CONFIG_ARM64_ERRATUM_1530923=y
+CONFIG_ARM64_WORKAROUND_REPEAT_TLBI=y
+CONFIG_ARM64_ERRATUM_2441007=y
+CONFIG_ARM64_ERRATUM_1286807=y
+CONFIG_ARM64_ERRATUM_1463225=y
+CONFIG_ARM64_ERRATUM_1542419=y
+CONFIG_ARM64_ERRATUM_1508412=y
+CONFIG_ARM64_ERRATUM_2051678=y
+# CONFIG_ARM64_ERRATUM_2077057 is not set
+CONFIG_ARM64_ERRATUM_2658417=y
+CONFIG_ARM64_WORKAROUND_TSB_FLUSH_FAILURE=y
+CONFIG_ARM64_ERRATUM_2054223=y
+CONFIG_ARM64_ERRATUM_2067961=y
+CONFIG_ARM64_ERRATUM_2441009=y
+CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT=y
+CONFIG_ARM64_ERRATUM_2457168=y
+CONFIG_ARM64_ERRATUM_2645198=y
+CONFIG_ARM64_ERRATUM_3821522=y
+CONFIG_ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD=y
+CONFIG_ARM64_ERRATUM_2966298=y
+CONFIG_ARM64_ERRATUM_3117295=y
+CONFIG_ARM64_ERRATUM_3194386=y
+CONFIG_ARM64_ERRATUM_4311569=y
+CONFIG_ARM64_ERRATUM_4193714=y
+CONFIG_ARM64_ERRATUM_4118414=y
+CONFIG_CAVIUM_ERRATUM_22375=y
+CONFIG_CAVIUM_ERRATUM_23154=y
+CONFIG_CAVIUM_ERRATUM_27456=y
+CONFIG_CAVIUM_ERRATUM_30115=y
+CONFIG_CAVIUM_TX2_ERRATUM_219=y
+CONFIG_FUJITSU_ERRATUM_010001=y
+CONFIG_HISILICON_ERRATUM_161600802=y
+CONFIG_HISILICON_ERRATUM_162100801=y
+CONFIG_HISILICON_ERRATUM_162100125=y
+CONFIG_QCOM_FALKOR_ERRATUM_1003=y
+CONFIG_QCOM_FALKOR_ERRATUM_1009=y
+CONFIG_QCOM_QDF2400_ERRATUM_0065=y
+CONFIG_QCOM_FALKOR_ERRATUM_E1041=y
+CONFIG_ARM64_WORKAROUND_DISABLE_CNP=y
+CONFIG_NVIDIA_CARMEL_CNP_ERRATUM=y
+CONFIG_ROCKCHIP_ERRATUM_3568002=y
+CONFIG_ROCKCHIP_ERRATUM_3588001=y
+CONFIG_SOCIONEXT_SYNQUACER_PREITS=y
+# end of ARM errata workarounds via the alternatives framework
+
+CONFIG_ARM64_4K_PAGES=y
+# CONFIG_ARM64_16K_PAGES is not set
+# CONFIG_ARM64_64K_PAGES is not set
+# CONFIG_ARM64_VA_BITS_39 is not set
+CONFIG_ARM64_VA_BITS_48=y
+# CONFIG_ARM64_VA_BITS_52 is not set
+CONFIG_ARM64_VA_BITS=48
+CONFIG_ARM64_PA_BITS_48=y
+CONFIG_ARM64_PA_BITS=48
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_NR_CPUS=8
+CONFIG_HOTPLUG_CPU=y
+# CONFIG_NUMA is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_HW_PERF_EVENTS=y
+CONFIG_CC_HAVE_SHADOW_CALL_STACK=y
+# CONFIG_PARAVIRT is not set
+# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set
+CONFIG_ARCH_SUPPORTS_KEXEC=y
+CONFIG_ARCH_SUPPORTS_KEXEC_FILE=y
+CONFIG_ARCH_SUPPORTS_KEXEC_SIG=y
+CONFIG_ARCH_SUPPORTS_KEXEC_IMAGE_VERIFY_SIG=y
+CONFIG_ARCH_DEFAULT_KEXEC_IMAGE_VERIFY_SIG=y
+CONFIG_ARCH_SUPPORTS_KEXEC_HANDOVER=y
+CONFIG_ARCH_SUPPORTS_CRASH_DUMP=y
+CONFIG_ARCH_DEFAULT_CRASH_DUMP=y
+CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION=y
+CONFIG_TRANS_TABLE=y
+# CONFIG_XEN is not set
+CONFIG_ARCH_FORCE_MAX_ORDER=10
+CONFIG_UNMAP_KERNEL_AT_EL0=y
+CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY=y
+# CONFIG_ARM64_SW_TTBR0_PAN is not set
+CONFIG_ARM64_TAGGED_ADDR_ABI=y
+CONFIG_COMPAT=y
+CONFIG_KUSER_HELPERS=y
+CONFIG_COMPAT_VDSO=y
+CONFIG_THUMB2_COMPAT_VDSO=y
+CONFIG_COMPAT_ALIGNMENT_FIXUPS=y
+# CONFIG_ARMV8_DEPRECATED is not set
+
+#
+# ARMv8.1 architectural features
+#
+CONFIG_ARM64_HW_AFDBM=y
+# end of ARMv8.1 architectural features
+
+#
+# ARMv8.2 architectural features
+#
+# CONFIG_ARM64_PMEM is not set
+CONFIG_ARM64_RAS_EXTN=y
+CONFIG_ARM64_CNP=y
+# end of ARMv8.2 architectural features
+
+#
+# ARMv8.3 architectural features
+#
+CONFIG_ARM64_PTR_AUTH=y
+CONFIG_ARM64_PTR_AUTH_KERNEL=y
+CONFIG_CC_HAS_BRANCH_PROT_PAC_RET=y
+CONFIG_AS_HAS_CFI_NEGATE_RA_STATE=y
+# end of ARMv8.3 architectural features
+
+#
+# ARMv8.4 architectural features
+#
+CONFIG_ARM64_AMU_EXTN=y
+CONFIG_ARM64_TLB_RANGE=y
+# CONFIG_ARM64_MPAM is not set
+# end of ARMv8.4 architectural features
+
+#
+# ARMv8.5 architectural features
+#
+CONFIG_AS_HAS_ARMV8_5=y
+CONFIG_ARM64_BTI=y
+CONFIG_CC_HAS_BRANCH_PROT_PAC_RET_BTI=y
+CONFIG_ARM64_E0PD=y
+CONFIG_ARM64_AS_HAS_MTE=y
+CONFIG_ARM64_MTE=y
+# end of ARMv8.5 architectural features
+
+#
+# ARMv8.7 architectural features
+#
+CONFIG_ARM64_EPAN=y
+# end of ARMv8.7 architectural features
+
+CONFIG_AS_HAS_MOPS=y
+
+#
+# ARMv8.9 architectural features
+#
+CONFIG_ARM64_POE=y
+CONFIG_ARCH_PKEY_BITS=3
+CONFIG_ARM64_HAFT=y
+# end of ARMv8.9 architectural features
+
+#
+# ARMv9.4 architectural features
+#
+CONFIG_ARM64_GCS=y
+# end of ARMv9.4 architectural features
+
+CONFIG_AS_HAS_LSUI=y
+
+#
+# ARMv9.6 architectural features
+#
+CONFIG_ARM64_LSUI=y
+# end of ARMv9.6 architectural features
+
+CONFIG_ARM64_SVE=y
+CONFIG_AS_HAS_SME=y
+CONFIG_ARM64_SME=y
+# CONFIG_ARM64_PSEUDO_NMI is not set
+CONFIG_RELOCATABLE=y
+CONFIG_RANDOMIZE_BASE=y
+CONFIG_RANDOMIZE_MODULE_REGION_FULL=y
+CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y
+CONFIG_STACKPROTECTOR_PER_TASK=y
+# CONFIG_UNWIND_PATCH_PAC_INTO_SCS is not set
+CONFIG_ARM64_CONTPTE=y
+# end of Kernel Features
+
+#
+# Boot options
+#
+CONFIG_CMDLINE=""
+CONFIG_CMDLINE_DROP_DANGEROUS_ANDROID_OPTIONS=y
+CONFIG_EFI_STUB=y
+CONFIG_EFI=y
+# CONFIG_COMPRESSED_INSTALL is not set
+CONFIG_DMI=y
+# end of Boot options
+
+#
+# Power management options
+#
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATE_CALLBACKS=y
+CONFIG_HIBERNATION=y
+CONFIG_HIBERNATION_SNAPSHOT_DEV=y
+CONFIG_HIBERNATION_COMP_LZO=y
+# CONFIG_HIBERNATION_COMP_LZ4 is not set
+CONFIG_HIBERNATION_DEF_COMP="lzo"
+CONFIG_PM_STD_PARTITION=""
+CONFIG_PM_SLEEP=y
+CONFIG_PM_SLEEP_SMP=y
+# CONFIG_PM_AUTOSLEEP is not set
+# CONFIG_PM_USERSPACE_AUTOSLEEP is not set
+# CONFIG_PM_WAKELOCKS is not set
+# CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP is not set
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_CLK=y
+CONFIG_PM_GENERIC_DOMAINS=y
+CONFIG_WQ_POWER_EFFICIENT_DEFAULT=y
+CONFIG_PM_GENERIC_DOMAINS_SLEEP=y
+CONFIG_PM_GENERIC_DOMAINS_OF=y
+CONFIG_CPU_PM=y
+# CONFIG_ENERGY_MODEL is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_HIBERNATION_HEADER=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# end of Power management options
+
+#
+# CPU Power Management
+#
+
+#
+# CPU Idle
+#
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_MULTIPLE_DRIVERS=y
+# CONFIG_CPU_IDLE_GOV_LADDER is not set
+CONFIG_CPU_IDLE_GOV_MENU=y
+# CONFIG_CPU_IDLE_GOV_TEO is not set
+CONFIG_DT_IDLE_STATES=y
+CONFIG_DT_IDLE_GENPD=y
+
+#
+# ARM CPU Idle Drivers
+#
+CONFIG_ARM_PSCI_CPUIDLE=y
+CONFIG_ARM_PSCI_CPUIDLE_DOMAIN=y
+# end of ARM CPU Idle Drivers
+# end of CPU Idle
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_GOV_ATTR_SET=y
+CONFIG_CPU_FREQ_GOV_COMMON=y
+CONFIG_CPU_FREQ_STAT=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
+
+#
+# CPU frequency scaling drivers
+#
+CONFIG_CPUFREQ_DT=y
+# CONFIG_CPUFREQ_VIRT is not set
+CONFIG_CPUFREQ_DT_PLATDEV=y
+CONFIG_ARM_QCOM_CPUFREQ_NVMEM=m
+CONFIG_ARM_QCOM_CPUFREQ_HW=m
+# end of CPU Frequency scaling
+# end of CPU Power Management
+
+CONFIG_ARCH_SUPPORTS_ACPI=y
+# CONFIG_ACPI is not set
+# CONFIG_VIRTUALIZATION is not set
+CONFIG_HAVE_LIVEPATCH=y
+# CONFIG_LIVEPATCH is not set
+CONFIG_CPU_MITIGATIONS=y
+
+#
+# General architecture-dependent options
+#
+CONFIG_ARCH_HAS_SUBPAGE_FAULTS=y
+CONFIG_HOTPLUG_SMT=y
+CONFIG_ARCH_SUPPORTS_SCHED_SMT=y
+CONFIG_ARCH_SUPPORTS_SCHED_CLUSTER=y
+CONFIG_ARCH_SUPPORTS_SCHED_MC=y
+# CONFIG_SCHED_SMT is not set
+# CONFIG_SCHED_CLUSTER is not set
+CONFIG_SCHED_MC=y
+CONFIG_HOTPLUG_CORE_SYNC=y
+CONFIG_HOTPLUG_CORE_SYNC_DEAD=y
+CONFIG_GENERIC_IRQ_ENTRY=y
+CONFIG_KPROBES=y
+CONFIG_JUMP_LABEL=y
+# CONFIG_STATIC_KEYS_SELFTEST is not set
+# CONFIG_STATIC_CALL_SELFTEST is not set
+CONFIG_UPROBES=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_KRETPROBES=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_FUNCTION_ERROR_INJECTION=y
+CONFIG_HAVE_NMI=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_DMA_CONTIGUOUS=y
+CONFIG_GENERIC_SMP_IDLE_THREAD=y
+CONFIG_GENERIC_IDLE_POLL_SETUP=y
+CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
+CONFIG_ARCH_HAS_KEEPINITRD=y
+CONFIG_ARCH_HAS_SET_MEMORY=y
+CONFIG_ARCH_HAS_SET_DIRECT_MAP=y
+CONFIG_HAVE_ARCH_THREAD_STRUCT_WHITELIST=y
+CONFIG_ARCH_WANTS_NO_INSTR=y
+CONFIG_HAVE_ASM_MODVERSIONS=y
+CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
+CONFIG_HAVE_RSEQ=y
+CONFIG_HAVE_RUST=y
+CONFIG_HAVE_FUNCTION_ARG_ACCESS_API=y
+CONFIG_HAVE_HW_BREAKPOINT=y
+CONFIG_HAVE_PERF_REGS=y
+CONFIG_HAVE_PERF_USER_STACK_DUMP=y
+CONFIG_HAVE_ARCH_JUMP_LABEL=y
+CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE=y
+CONFIG_MMU_GATHER_TABLE_FREE=y
+CONFIG_MMU_GATHER_RCU_TABLE_FREE=y
+CONFIG_MMU_LAZY_TLB_REFCOUNT=y
+CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG=y
+CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS=y
+CONFIG_HAVE_ALIGNED_STRUCT_PAGE=y
+CONFIG_HAVE_CMPXCHG_LOCAL=y
+CONFIG_HAVE_CMPXCHG_DOUBLE=y
+CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION=y
+CONFIG_HAVE_ARCH_SECCOMP=y
+CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
+CONFIG_SECCOMP=y
+CONFIG_SECCOMP_FILTER=y
+# CONFIG_SECCOMP_CACHE_DEBUG is not set
+CONFIG_HAVE_ARCH_KSTACK_ERASE=y
+CONFIG_HAVE_STACKPROTECTOR=y
+CONFIG_STACKPROTECTOR=y
+CONFIG_STACKPROTECTOR_STRONG=y
+CONFIG_ARCH_SUPPORTS_SHADOW_CALL_STACK=y
+CONFIG_SHADOW_CALL_STACK=y
+CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
+CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN=y
+CONFIG_HAS_LTO_CLANG=y
+CONFIG_LTO_NONE=y
+# CONFIG_LTO_CLANG_FULL is not set
+# CONFIG_LTO_CLANG_THIN is not set
+# CONFIG_LTO_CLANG_THIN_DIST is not set
+# CONFIG_AUTOFDO_CLANG is not set
+# CONFIG_PROPELLER_CLANG is not set
+CONFIG_ARCH_SUPPORTS_CFI=y
+CONFIG_CFI=y
+CONFIG_CFI_ICALL_NORMALIZE_INTEGERS=y
+CONFIG_HAVE_CFI_ICALL_NORMALIZE_INTEGERS=y
+CONFIG_HAVE_CFI_ICALL_NORMALIZE_INTEGERS_RUSTC=y
+# CONFIG_CFI_PERMISSIVE is not set
+CONFIG_HAVE_CONTEXT_TRACKING_USER=y
+CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
+CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
+CONFIG_HAVE_MOVE_PUD=y
+CONFIG_HAVE_MOVE_PMD=y
+CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
+CONFIG_HAVE_ARCH_HUGE_VMAP=y
+CONFIG_HAVE_ARCH_HUGE_VMALLOC=y
+CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
+CONFIG_ARCH_WANT_PMD_MKWRITE=y
+CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
+CONFIG_MODULES_USE_ELF_RELA=y
+CONFIG_ARCH_WANTS_EXECMEM_LATE=y
+CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK=y
+CONFIG_SOFTIRQ_ON_OWN_STACK=y
+CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
+CONFIG_HAVE_ARCH_MMAP_RND_BITS=y
+CONFIG_ARCH_MMAP_RND_BITS=18
+CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS=y
+CONFIG_ARCH_MMAP_RND_COMPAT_BITS=11
+CONFIG_HAVE_PAGE_SIZE_4KB=y
+CONFIG_PAGE_SIZE_4KB=y
+CONFIG_PAGE_SIZE_LESS_THAN_64KB=y
+CONFIG_PAGE_SIZE_LESS_THAN_256KB=y
+CONFIG_PAGE_SHIFT=12
+CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT=y
+CONFIG_HAVE_RELIABLE_STACKTRACE=y
+CONFIG_CLONE_BACKWARDS=y
+CONFIG_OLD_SIGSUSPEND3=y
+CONFIG_COMPAT_OLD_SIGACTION=y
+CONFIG_COMPAT_32BIT_TIME=y
+CONFIG_ARCH_SUPPORTS_RT=y
+CONFIG_HAVE_ARCH_VMAP_STACK=y
+CONFIG_VMAP_STACK=y
+CONFIG_HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET=y
+CONFIG_RANDOMIZE_KSTACK_OFFSET=y
+# CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT is not set
+CONFIG_ARCH_HAS_STRICT_KERNEL_RWX=y
+CONFIG_STRICT_KERNEL_RWX=y
+CONFIG_ARCH_HAS_STRICT_MODULE_RWX=y
+CONFIG_STRICT_MODULE_RWX=y
+CONFIG_HAVE_ARCH_COMPILER_H=y
+CONFIG_HAVE_ARCH_PREL32_RELOCATIONS=y
+CONFIG_ARCH_USE_MEMREMAP_PROT=y
+# CONFIG_LOCK_EVENT_COUNTS is not set
+CONFIG_ARCH_HAS_RELR=y
+CONFIG_RELR=y
+CONFIG_ARCH_HAS_MEM_ENCRYPT=y
+CONFIG_ARCH_HAS_CC_PLATFORM=y
+CONFIG_HAVE_STATIC_CALL=y
+CONFIG_HAVE_PREEMPT_DYNAMIC=y
+CONFIG_HAVE_PREEMPT_DYNAMIC_KEY=y
+CONFIG_ARCH_WANT_LD_ORPHAN_WARN=y
+CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
+CONFIG_ARCH_SUPPORTS_PAGE_TABLE_CHECK=y
+CONFIG_ARCH_HAVE_TRACE_MMIO_ACCESS=y
+CONFIG_ARCH_HAS_HW_PTE_YOUNG=y
+CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG=y
+CONFIG_ARCH_HAS_KERNEL_FPU_SUPPORT=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
+# end of GCOV-based kernel profiling
+
+CONFIG_HAVE_GCC_PLUGINS=y
+CONFIG_FUNCTION_ALIGNMENT_4B=y
+CONFIG_FUNCTION_ALIGNMENT=4
+CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT=y
+CONFIG_HAVE_ARCH_GET_SECUREBOOT=y
+# end of General architecture-dependent options
+
+CONFIG_RT_MUTEXES=y
+CONFIG_MODULES=y
+CONFIG_MODULE_DEBUG=y
+# CONFIG_MODULE_STATS is not set
+# CONFIG_MODULE_DEBUG_AUTOLOAD_DUPS is not set
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODULE_UNLOAD_TAINT_TRACKING is not set
+# CONFIG_MODVERSIONS is not set
+CONFIG_MODULE_SRCVERSION_ALL=y
+# CONFIG_MODULE_SIG is not set
+CONFIG_MODULE_COMPRESS=y
+# CONFIG_MODULE_COMPRESS_GZIP is not set
+# CONFIG_MODULE_COMPRESS_XZ is not set
+CONFIG_MODULE_COMPRESS_ZSTD=y
+CONFIG_MODULE_COMPRESS_ALL=y
+CONFIG_MODULE_DECOMPRESS=y
+# CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is not set
+CONFIG_MODPROBE_PATH="/sbin/modprobe"
+# CONFIG_TRIM_UNUSED_KSYMS is not set
+CONFIG_MODULES_TREE_LOOKUP=y
+CONFIG_BLOCK=y
+CONFIG_BLOCK_LEGACY_AUTOLOAD=y
+CONFIG_BLK_CGROUP_RWSTAT=y
+CONFIG_BLK_CGROUP_PUNT_BIO=y
+CONFIG_BLK_DEV_BSG_COMMON=y
+# CONFIG_BLK_DEV_BSGLIB is not set
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_BLK_DEV_WRITE_MOUNTED=y
+# CONFIG_BLK_DEV_ZONED is not set
+CONFIG_BLK_DEV_THROTTLING=y
+# CONFIG_BLK_WBT is not set
+# CONFIG_BLK_CGROUP_IOLATENCY is not set
+# CONFIG_BLK_CGROUP_IOCOST is not set
+# CONFIG_BLK_CGROUP_IOPRIO is not set
+CONFIG_BLK_DEBUG_FS=y
+# CONFIG_BLK_SED_OPAL is not set
+# CONFIG_BLK_INLINE_ENCRYPTION is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_EFI_PARTITION=y
+# end of Partition Types
+
+CONFIG_BLK_PM=y
+CONFIG_BLOCK_HOLDER_DEPRECATED=y
+CONFIG_BLK_MQ_STACKING=y
+# CONFIG_BLK_ERROR_INJECTION is not set
+
+#
+# IO Schedulers
+#
+CONFIG_MQ_IOSCHED_DEADLINE=y
+CONFIG_MQ_IOSCHED_KYBER=y
+# CONFIG_IOSCHED_BFQ is not set
+# end of IO Schedulers
+
+CONFIG_PADATA=y
+CONFIG_ASN1=y
+CONFIG_UNINLINE_SPIN_UNLOCK=y
+CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
+CONFIG_MUTEX_SPIN_ON_OWNER=y
+CONFIG_RWSEM_SPIN_ON_OWNER=y
+CONFIG_LOCK_SPIN_ON_OWNER=y
+CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y
+CONFIG_QUEUED_SPINLOCKS=y
+CONFIG_ARCH_USE_QUEUED_RWLOCKS=y
+CONFIG_QUEUED_RWLOCKS=y
+CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE=y
+CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y
+CONFIG_FREEZER=y
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_COMPAT_BINFMT_ELF=y
+CONFIG_ARCH_BINFMT_ELF_STATE=y
+CONFIG_ARCH_BINFMT_ELF_EXTRA_PHDRS=y
+CONFIG_ARCH_HAVE_ELF_PROT=y
+CONFIG_ARCH_USE_GNU_PROPERTY=y
+CONFIG_ELFCORE=y
+CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
+CONFIG_BINFMT_SCRIPT=y
+CONFIG_BINFMT_MISC=m
+CONFIG_COREDUMP=y
+# end of Executable file formats
+
+#
+# Memory Management options
+#
+CONFIG_SWAP=y
+# CONFIG_ZSWAP is not set
+CONFIG_ZSMALLOC=y
+
+#
+# Zsmalloc allocator options
+#
+
+#
+# Zsmalloc is a common backend allocator for zswap & zram
+#
+# CONFIG_ZSMALLOC_STAT is not set
+CONFIG_ZSMALLOC_CHAIN_SIZE=8
+# end of Zsmalloc allocator options
+
+#
+# Slab allocator options
+#
+CONFIG_SLUB=y
+CONFIG_KVFREE_RCU_BATCHED=y
+CONFIG_SLAB_MERGE_DEFAULT=y
+# CONFIG_SLAB_FREELIST_RANDOM is not set
+# CONFIG_SLAB_FREELIST_HARDENED is not set
+CONFIG_SLAB_BUCKETS=y
+# CONFIG_SLUB_STATS is not set
+# CONFIG_KMALLOC_PARTITION_CACHES is not set
+# end of Slab allocator options
+
+# CONFIG_SHUFFLE_PAGE_ALLOCATOR is not set
+# CONFIG_COMPAT_BRK is not set
+CONFIG_SPARSEMEM=y
+CONFIG_SPARSEMEM_EXTREME=y
+CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
+CONFIG_SPARSEMEM_VMEMMAP=y
+CONFIG_HAVE_GUP_FAST=y
+CONFIG_ARCH_KEEP_MEMBLOCK=y
+CONFIG_MEMORY_ISOLATION=y
+CONFIG_EXCLUSIVE_SYSTEM_RAM=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+# CONFIG_MEMORY_HOTPLUG is not set
+CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE=y
+CONFIG_SPLIT_PTE_PTLOCKS=y
+CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK=y
+CONFIG_SPLIT_PMD_PTLOCKS=y
+CONFIG_COMPACTION=y
+CONFIG_COMPACT_UNEVICTABLE_DEFAULT=1
+# CONFIG_PAGE_REPORTING is not set
+CONFIG_MIGRATION=y
+CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION=y
+CONFIG_ARCH_ENABLE_THP_MIGRATION=y
+CONFIG_CONTIG_ALLOC=y
+CONFIG_PCP_BATCH_SCALE_MAX=5
+CONFIG_PHYS_ADDR_T_64BIT=y
+CONFIG_KSM=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y
+CONFIG_MEMORY_FAILURE=y
+# CONFIG_HWPOISON_INJECT is not set
+CONFIG_ARCH_WANTS_THP_SWAP=y
+# CONFIG_PERSISTENT_HUGE_ZERO_FOLIO is not set
+CONFIG_MM_ID=y
+CONFIG_TRANSPARENT_HUGEPAGE=y
+CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y
+# CONFIG_TRANSPARENT_HUGEPAGE_MADVISE is not set
+# CONFIG_TRANSPARENT_HUGEPAGE_NEVER is not set
+CONFIG_TRANSPARENT_HUGEPAGE_SHMEM_HUGE_NEVER=y
+# CONFIG_TRANSPARENT_HUGEPAGE_SHMEM_HUGE_ALWAYS is not set
+# CONFIG_TRANSPARENT_HUGEPAGE_SHMEM_HUGE_WITHIN_SIZE is not set
+# CONFIG_TRANSPARENT_HUGEPAGE_SHMEM_HUGE_ADVISE is not set
+CONFIG_TRANSPARENT_HUGEPAGE_TMPFS_HUGE_NEVER=y
+# CONFIG_TRANSPARENT_HUGEPAGE_TMPFS_HUGE_ALWAYS is not set
+# CONFIG_TRANSPARENT_HUGEPAGE_TMPFS_HUGE_WITHIN_SIZE is not set
+# CONFIG_TRANSPARENT_HUGEPAGE_TMPFS_HUGE_ADVISE is not set
+CONFIG_THP_SWAP=y
+# CONFIG_NO_PAGE_MAPCOUNT is not set
+CONFIG_PAGE_MAPCOUNT=y
+CONFIG_PGTABLE_HAS_HUGE_LEAVES=y
+CONFIG_HAVE_GIGANTIC_FOLIOS=y
+CONFIG_ARCH_SUPPORTS_HUGE_PFNMAP=y
+CONFIG_ARCH_SUPPORTS_PMD_PFNMAP=y
+CONFIG_CMA=y
+# CONFIG_CMA_DEBUGFS is not set
+# CONFIG_CMA_SYSFS is not set
+CONFIG_CMA_AREAS=7
+CONFIG_PAGE_BLOCK_MAX_ORDER=10
+CONFIG_GENERIC_EARLY_IOREMAP=y
+# CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set
+# CONFIG_IDLE_PAGE_TRACKING is not set
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_ARCH_HAS_CURRENT_STACK_POINTER=y
+CONFIG_ZONE_DMA=y
+CONFIG_ZONE_DMA32=y
+CONFIG_ARCH_USES_HIGH_VMA_FLAGS=y
+CONFIG_ARCH_HAS_PKEYS=y
+CONFIG_ARCH_USES_PG_ARCH_2=y
+CONFIG_ARCH_USES_PG_ARCH_3=y
+CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_PERCPU_STATS is not set
+# CONFIG_GUP_TEST is not set
+# CONFIG_DMAPOOL_TEST is not set
+CONFIG_ARCH_HAS_PTE_SPECIAL=y
+CONFIG_MEMFD_CREATE=y
+CONFIG_SECRETMEM=y
+# CONFIG_ANON_VMA_NAME is not set
+# CONFIG_USERFAULTFD is not set
+CONFIG_LRU_GEN=y
+CONFIG_LRU_GEN_ENABLED=y
+# CONFIG_LRU_GEN_STATS is not set
+CONFIG_LRU_GEN_WALKS_MMU=y
+CONFIG_ARCH_SUPPORTS_PER_VMA_LOCK=y
+CONFIG_PER_VMA_LOCK=y
+CONFIG_LOCK_MM_AND_FIND_VMA=y
+CONFIG_EXECMEM=y
+CONFIG_ARCH_HAS_USER_SHADOW_STACK=y
+CONFIG_PT_RECLAIM=y
+CONFIG_ARCH_HAS_LAZY_MMU_MODE=y
+
+#
+# Data Access Monitoring
+#
+# CONFIG_DAMON is not set
+# end of Data Access Monitoring
+# end of Memory Management options
+
+CONFIG_NET=y
+CONFIG_NET_INGRESS=y
+CONFIG_NET_EGRESS=y
+CONFIG_NET_XGRESS=y
+CONFIG_SKB_EXTENSIONS=y
+CONFIG_NET_DEVMEM=y
+CONFIG_NET_CRC32C=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_DIAG is not set
+# CONFIG_INET_PSP is not set
+CONFIG_UNIX=y
+CONFIG_AF_UNIX_OOB=y
+# CONFIG_UNIX_DIAG is not set
+# CONFIG_TLS is not set
+# CONFIG_XFRM_USER is not set
+# CONFIG_NET_KEY is not set
+# CONFIG_DIBS is not set
+# CONFIG_XDP_SOCKETS is not set
+CONFIG_NET_HANDSHAKE=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+# CONFIG_IP_FIB_TRIE_STATS is not set
+CONFIG_IP_MULTIPLE_TABLES=y
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE_DEMUX is not set
+CONFIG_NET_IP_TUNNEL=m
+# CONFIG_IP_MROUTE is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_NET_IPVTI is not set
+CONFIG_NET_UDP_TUNNEL=m
+# CONFIG_NET_FOU is not set
+# CONFIG_NET_FOU_IP_TUNNELS is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+CONFIG_INET_TABLE_PERTURB_ORDER=16
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_INET_UDP_DIAG is not set
+# CONFIG_INET_RAW_DIAG is not set
+# CONFIG_INET_DIAG_DESTROY is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_AO is not set
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+# CONFIG_INET6_AH is not set
+# CONFIG_INET6_ESP is not set
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_IPV6_MIP6 is not set
+# CONFIG_IPV6_ILA is not set
+# CONFIG_IPV6_VTI is not set
+CONFIG_IPV6_SIT=m
+# CONFIG_IPV6_SIT_6RD is not set
+CONFIG_IPV6_NDISC_NODETYPE=y
+# CONFIG_IPV6_TUNNEL is not set
+CONFIG_IPV6_MULTIPLE_TABLES=y
+# CONFIG_IPV6_SUBTREES is not set
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_IPV6_SEG6_LWTUNNEL is not set
+# CONFIG_IPV6_SEG6_HMAC is not set
+# CONFIG_IPV6_RPL_LWTUNNEL is not set
+# CONFIG_IPV6_IOAM6_LWTUNNEL is not set
+# CONFIG_NETLABEL is not set
+# CONFIG_MPTCP is not set
+# CONFIG_NETWORK_SECMARK is not set
+CONFIG_NET_PTP_CLASSIFY=y
+# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=m
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_INGRESS=y
+CONFIG_NETFILTER_EGRESS=y
+CONFIG_NETFILTER_NETLINK=y
+CONFIG_NETFILTER_FAMILY_BRIDGE=y
+CONFIG_NETFILTER_BPF_LINK=y
+# CONFIG_NETFILTER_NETLINK_HOOK is not set
+# CONFIG_NETFILTER_NETLINK_ACCT is not set
+# CONFIG_NETFILTER_NETLINK_QUEUE is not set
+# CONFIG_NETFILTER_NETLINK_LOG is not set
+# CONFIG_NETFILTER_NETLINK_OSF is not set
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_LOG_SYSLOG=m
+CONFIG_NF_CONNTRACK_MARK=y
+# CONFIG_NF_CONNTRACK_ZONES is not set
+# CONFIG_NF_CONNTRACK_PROCFS is not set
+CONFIG_NF_CONNTRACK_EVENTS=y
+# CONFIG_NF_CONNTRACK_TIMEOUT is not set
+# CONFIG_NF_CONNTRACK_TIMESTAMP is not set
+# CONFIG_NF_CONNTRACK_LABELS is not set
+CONFIG_NF_CT_PROTO_SCTP=y
+# CONFIG_NF_CONNTRACK_AMANDA is not set
+# CONFIG_NF_CONNTRACK_FTP is not set
+# CONFIG_NF_CONNTRACK_H323 is not set
+# CONFIG_NF_CONNTRACK_IRC is not set
+# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
+# CONFIG_NF_CONNTRACK_SNMP is not set
+# CONFIG_NF_CONNTRACK_PPTP is not set
+# CONFIG_NF_CONNTRACK_SANE is not set
+# CONFIG_NF_CONNTRACK_SIP is not set
+# CONFIG_NF_CONNTRACK_TFTP is not set
+# CONFIG_NF_CT_NETLINK is not set
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_REDIRECT=y
+CONFIG_NF_NAT_MASQUERADE=y
+CONFIG_NF_TABLES=m
+CONFIG_NF_TABLES_INET=y
+# CONFIG_NF_TABLES_NETDEV is not set
+# CONFIG_NFT_NUMGEN is not set
+CONFIG_NFT_CT=m
+# CONFIG_NFT_EXTHDR_DCCP is not set
+# CONFIG_NFT_CONNLIMIT is not set
+CONFIG_NFT_LOG=m
+CONFIG_NFT_LIMIT=m
+CONFIG_NFT_MASQ=m
+# CONFIG_NFT_REDIR is not set
+CONFIG_NFT_NAT=m
+# CONFIG_NFT_TUNNEL is not set
+# CONFIG_NFT_QUOTA is not set
+CONFIG_NFT_REJECT=m
+CONFIG_NFT_REJECT_INET=m
+CONFIG_NFT_COMPAT=m
+# CONFIG_NFT_HASH is not set
+CONFIG_NFT_FIB=m
+CONFIG_NFT_FIB_INET=m
+# CONFIG_NFT_SOCKET is not set
+# CONFIG_NFT_OSF is not set
+# CONFIG_NFT_TPROXY is not set
+# CONFIG_NFT_SYNPROXY is not set
+# CONFIG_NF_FLOW_TABLE is not set
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XTABLES_COMPAT=y
+CONFIG_NETFILTER_XTABLES_LEGACY=y
+
+#
+# Xtables combined modules
+#
+CONFIG_NETFILTER_XT_MARK=m
+# CONFIG_NETFILTER_XT_CONNMARK is not set
+
+#
+# Xtables targets
+#
+# CONFIG_NETFILTER_XT_TARGET_AUDIT is not set
+CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
+# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set
+# CONFIG_NETFILTER_XT_TARGET_CONNMARK is not set
+# CONFIG_NETFILTER_XT_TARGET_CT is not set
+# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
+# CONFIG_NETFILTER_XT_TARGET_HL is not set
+# CONFIG_NETFILTER_XT_TARGET_HMARK is not set
+# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set
+# CONFIG_NETFILTER_XT_TARGET_LED is not set
+CONFIG_NETFILTER_XT_TARGET_LOG=m
+# CONFIG_NETFILTER_XT_TARGET_MARK is not set
+CONFIG_NETFILTER_XT_NAT=m
+# CONFIG_NETFILTER_XT_TARGET_NETMAP is not set
+# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
+# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
+# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
+# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
+CONFIG_NETFILTER_XT_TARGET_REDIRECT=m
+CONFIG_NETFILTER_XT_TARGET_MASQUERADE=m
+# CONFIG_NETFILTER_XT_TARGET_TEE is not set
+# CONFIG_NETFILTER_XT_TARGET_TPROXY is not set
+# CONFIG_NETFILTER_XT_TARGET_TRACE is not set
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
+
+#
+# Xtables matches
+#
+CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=m
+# CONFIG_NETFILTER_XT_MATCH_BPF is not set
+# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set
+# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+# CONFIG_NETFILTER_XT_MATCH_CONNBYTES is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNLABEL is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_CONNMARK is not set
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+# CONFIG_NETFILTER_XT_MATCH_CPU is not set
+# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
+# CONFIG_NETFILTER_XT_MATCH_DEVGROUP is not set
+# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
+# CONFIG_NETFILTER_XT_MATCH_ECN is not set
+# CONFIG_NETFILTER_XT_MATCH_ESP is not set
+# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
+# CONFIG_NETFILTER_XT_MATCH_HL is not set
+# CONFIG_NETFILTER_XT_MATCH_IPCOMP is not set
+# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set
+CONFIG_NETFILTER_XT_MATCH_IPVS=m
+# CONFIG_NETFILTER_XT_MATCH_L2TP is not set
+# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
+# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_MAC is not set
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+# CONFIG_NETFILTER_XT_MATCH_NFACCT is not set
+# CONFIG_NETFILTER_XT_MATCH_OSF is not set
+# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
+# CONFIG_NETFILTER_XT_MATCH_PHYSDEV is not set
+# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
+# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
+# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
+# CONFIG_NETFILTER_XT_MATCH_REALM is not set
+# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
+# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
+# CONFIG_NETFILTER_XT_MATCH_SOCKET is not set
+# CONFIG_NETFILTER_XT_MATCH_STATE is not set
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+# CONFIG_NETFILTER_XT_MATCH_STRING is not set
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+# CONFIG_NETFILTER_XT_MATCH_TIME is not set
+# CONFIG_NETFILTER_XT_MATCH_U32 is not set
+# end of Core Netfilter Configuration
+
+# CONFIG_IP_SET is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_IPV6 is not set
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+# CONFIG_IP_VS_PROTO_ESP is not set
+# CONFIG_IP_VS_PROTO_AH is not set
+# CONFIG_IP_VS_PROTO_SCTP is not set
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+# CONFIG_IP_VS_WRR is not set
+# CONFIG_IP_VS_LC is not set
+# CONFIG_IP_VS_WLC is not set
+# CONFIG_IP_VS_FO is not set
+# CONFIG_IP_VS_OVF is not set
+# CONFIG_IP_VS_LBLC is not set
+# CONFIG_IP_VS_LBLCR is not set
+# CONFIG_IP_VS_DH is not set
+# CONFIG_IP_VS_SH is not set
+# CONFIG_IP_VS_MH is not set
+# CONFIG_IP_VS_SED is not set
+# CONFIG_IP_VS_NQ is not set
+# CONFIG_IP_VS_TWOS is not set
+
+#
+# IPVS SH scheduler
+#
+CONFIG_IP_VS_SH_TAB_BITS=8
+
+#
+# IPVS MH scheduler
+#
+CONFIG_IP_VS_MH_TAB_INDEX=12
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_NFCT=y
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_DEFRAG_IPV4=m
+CONFIG_IP_NF_IPTABLES_LEGACY=m
+# CONFIG_NF_SOCKET_IPV4 is not set
+# CONFIG_NF_TPROXY_IPV4 is not set
+CONFIG_NF_TABLES_IPV4=y
+CONFIG_NFT_REJECT_IPV4=m
+CONFIG_NFT_DUP_IPV4=m
+CONFIG_NFT_FIB_IPV4=m
+# CONFIG_NF_TABLES_ARP is not set
+CONFIG_NF_DUP_IPV4=m
+# CONFIG_NF_LOG_ARP is not set
+CONFIG_NF_LOG_IPV4=m
+CONFIG_NF_REJECT_IPV4=m
+CONFIG_IP_NF_IPTABLES=m
+# CONFIG_IP_NF_MATCH_AH is not set
+# CONFIG_IP_NF_MATCH_ECN is not set
+# CONFIG_IP_NF_MATCH_RPFILTER is not set
+# CONFIG_IP_NF_MATCH_TTL is not set
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+# CONFIG_IP_NF_TARGET_SYNPROXY is not set
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+# CONFIG_IP_NF_TARGET_NETMAP is not set
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_MANGLE=m
+# CONFIG_IP_NF_TARGET_ECN is not set
+# CONFIG_IP_NF_TARGET_TTL is not set
+CONFIG_IP_NF_RAW=m
+# CONFIG_IP_NF_SECURITY is not set
+# CONFIG_IP_NF_ARPTABLES is not set
+# CONFIG_IP_NF_ARPFILTER is not set
+# end of IP: Netfilter Configuration
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_IP6_NF_IPTABLES_LEGACY=m
+# CONFIG_NF_SOCKET_IPV6 is not set
+# CONFIG_NF_TPROXY_IPV6 is not set
+CONFIG_NF_TABLES_IPV6=y
+CONFIG_NFT_REJECT_IPV6=m
+CONFIG_NFT_DUP_IPV6=m
+CONFIG_NFT_FIB_IPV6=m
+CONFIG_NF_DUP_IPV6=m
+CONFIG_NF_REJECT_IPV6=m
+CONFIG_NF_LOG_IPV6=m
+CONFIG_IP6_NF_IPTABLES=m
+# CONFIG_IP6_NF_MATCH_AH is not set
+# CONFIG_IP6_NF_MATCH_EUI64 is not set
+# CONFIG_IP6_NF_MATCH_FRAG is not set
+# CONFIG_IP6_NF_MATCH_OPTS is not set
+# CONFIG_IP6_NF_MATCH_HL is not set
+# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set
+# CONFIG_IP6_NF_MATCH_MH is not set
+# CONFIG_IP6_NF_MATCH_RPFILTER is not set
+# CONFIG_IP6_NF_MATCH_RT is not set
+# CONFIG_IP6_NF_MATCH_SRH is not set
+# CONFIG_IP6_NF_TARGET_HL is not set
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+# CONFIG_IP6_NF_TARGET_SYNPROXY is not set
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_RAW=m
+# CONFIG_IP6_NF_SECURITY is not set
+CONFIG_IP6_NF_NAT=m
+CONFIG_IP6_NF_TARGET_MASQUERADE=m
+# CONFIG_IP6_NF_TARGET_NPT is not set
+# end of IPv6: Netfilter Configuration
+
+CONFIG_NF_DEFRAG_IPV6=m
+# CONFIG_NF_TABLES_BRIDGE is not set
+# CONFIG_NF_CONNTRACK_BRIDGE is not set
+# CONFIG_BRIDGE_NF_EBTABLES_LEGACY is not set
+# CONFIG_BRIDGE_NF_EBTABLES is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_L2TP is not set
+CONFIG_STP=m
+CONFIG_GARP=m
+CONFIG_MRP=m
+CONFIG_BRIDGE=m
+CONFIG_BRIDGE_IGMP_SNOOPING=y
+CONFIG_BRIDGE_VLAN_FILTERING=y
+# CONFIG_BRIDGE_MRP is not set
+# CONFIG_BRIDGE_CFM is not set
+# CONFIG_NET_DSA is not set
+CONFIG_VLAN_8021Q=m
+CONFIG_VLAN_8021Q_GVRP=y
+CONFIG_VLAN_8021Q_MVRP=y
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_PHONET is not set
+# CONFIG_6LOWPAN is not set
+# CONFIG_IEEE802154 is not set
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+# CONFIG_NET_SCH_HTB is not set
+# CONFIG_NET_SCH_HFSC is not set
+# CONFIG_NET_SCH_PRIO is not set
+# CONFIG_NET_SCH_MULTIQ is not set
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFB is not set
+# CONFIG_NET_SCH_SFQ is not set
+# CONFIG_NET_SCH_TEQL is not set
+# CONFIG_NET_SCH_TBF is not set
+# CONFIG_NET_SCH_CBS is not set
+# CONFIG_NET_SCH_ETF is not set
+# CONFIG_NET_SCH_TAPRIO is not set
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_NETEM is not set
+# CONFIG_NET_SCH_DRR is not set
+# CONFIG_NET_SCH_MQPRIO is not set
+# CONFIG_NET_SCH_SKBPRIO is not set
+# CONFIG_NET_SCH_CHOKE is not set
+# CONFIG_NET_SCH_QFQ is not set
+# CONFIG_NET_SCH_CODEL is not set
+# CONFIG_NET_SCH_FQ_CODEL is not set
+# CONFIG_NET_SCH_CAKE is not set
+# CONFIG_NET_SCH_FQ is not set
+# CONFIG_NET_SCH_HHF is not set
+# CONFIG_NET_SCH_PIE is not set
+# CONFIG_NET_SCH_PLUG is not set
+# CONFIG_NET_SCH_ETS is not set
+# CONFIG_NET_SCH_BPF is not set
+CONFIG_NET_SCH_DUALPI2=m
+# CONFIG_NET_SCH_DEFAULT is not set
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+# CONFIG_NET_CLS_BASIC is not set
+# CONFIG_NET_CLS_ROUTE4 is not set
+# CONFIG_NET_CLS_FW is not set
+# CONFIG_NET_CLS_U32 is not set
+# CONFIG_NET_CLS_FLOW is not set
+CONFIG_NET_CLS_CGROUP=m
+# CONFIG_NET_CLS_BPF is not set
+# CONFIG_NET_CLS_FLOWER is not set
+# CONFIG_NET_CLS_MATCHALL is not set
+# CONFIG_NET_EMATCH is not set
+# CONFIG_NET_CLS_ACT is not set
+CONFIG_NET_SCH_FIFO=y
+# CONFIG_DCB is not set
+CONFIG_DNS_RESOLVER=m
+# CONFIG_BATMAN_ADV is not set
+# CONFIG_OPENVSWITCH is not set
+# CONFIG_VSOCKETS is not set
+# CONFIG_NETLINK_DIAG is not set
+# CONFIG_MPLS is not set
+# CONFIG_NET_NSH is not set
+# CONFIG_HSR is not set
+# CONFIG_NET_SWITCHDEV is not set
+CONFIG_NET_L3_MASTER_DEV=y
+CONFIG_QRTR=m
+CONFIG_QRTR_SMD=m
+CONFIG_QRTR_TUN=m
+# CONFIG_NET_NCSI is not set
+CONFIG_PCPU_DEV_REFCNT=y
+CONFIG_MAX_SKB_FRAGS=17
+CONFIG_RPS=y
+CONFIG_RFS_ACCEL=y
+CONFIG_SOCK_RX_QUEUE_MAPPING=y
+CONFIG_XPS=y
+CONFIG_CGROUP_NET_PRIO=y
+CONFIG_CGROUP_NET_CLASSID=y
+CONFIG_NET_RX_BUSY_POLL=y
+CONFIG_BQL=y
+# CONFIG_BPF_STREAM_PARSER is not set
+CONFIG_NET_FLOW_LIMIT=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_DROP_MONITOR is not set
+# end of Network testing
+# end of Networking options
+
+# CONFIG_CAN is not set
+CONFIG_BT=m
+CONFIG_BT_BREDR=y
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_HIDP=m
+CONFIG_BT_LE=y
+CONFIG_BT_LE_L2CAP_ECRED=y
+CONFIG_BT_LEDS=y
+CONFIG_BT_MSFTEXT=y
+CONFIG_BT_AOSPEXT=y
+CONFIG_BT_DEBUGFS=y
+# CONFIG_BT_SELFTEST is not set
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_INTEL=m
+CONFIG_BT_BCM=m
+CONFIG_BT_RTL=m
+CONFIG_BT_QCA=m
+CONFIG_BT_HCIBTUSB=m
+# CONFIG_BT_HCIBTUSB_AUTOSUSPEND is not set
+CONFIG_BT_HCIBTUSB_POLL_SYNC=y
+CONFIG_BT_HCIBTUSB_BCM=y
+# CONFIG_BT_HCIBTUSB_MTK is not set
+CONFIG_BT_HCIBTUSB_RTL=y
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_SERDEV=y
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_NOKIA=m
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_ATH3K=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIUART_3WIRE=y
+CONFIG_BT_HCIUART_INTEL=y
+CONFIG_BT_HCIUART_BCM=y
+CONFIG_BT_HCIUART_RTL=y
+CONFIG_BT_HCIUART_QCA=y
+# CONFIG_BT_HCIUART_AG6XX is not set
+# CONFIG_BT_HCIUART_MRVL is not set
+# CONFIG_BT_HCIUART_AML is not set
+# CONFIG_BT_HCIBCM203X is not set
+# CONFIG_BT_HCIBPA10X is not set
+# CONFIG_BT_HCIBFUSB is not set
+# CONFIG_BT_HCIVHCI is not set
+# CONFIG_BT_MRVL is not set
+CONFIG_BT_ATH3K=m
+# CONFIG_BT_MTKSDIO is not set
+# CONFIG_BT_MTKUART is not set
+CONFIG_BT_QCOMSMD=m
+# CONFIG_BT_VIRTIO is not set
+# CONFIG_BT_NXPUART is not set
+# end of Bluetooth device drivers
+
+# CONFIG_AF_RXRPC is not set
+# CONFIG_AF_KCM is not set
+CONFIG_STREAM_PARSER=y
+# CONFIG_MCTP is not set
+CONFIG_FIB_RULES=y
+CONFIG_WIRELESS=y
+CONFIG_CFG80211=m
+# CONFIG_NL80211_TESTMODE is not set
+# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
+CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=y
+CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=y
+CONFIG_CFG80211_DEFAULT_PS=y
+# CONFIG_CFG80211_DEBUGFS is not set
+CONFIG_CFG80211_CRDA_SUPPORT=y
+# CONFIG_CFG80211_WEXT is not set
+CONFIG_MAC80211=m
+CONFIG_MAC80211_HAS_RC=y
+CONFIG_MAC80211_RC_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
+# CONFIG_MAC80211_MESH is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_MESSAGE_TRACING is not set
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_MAC80211_STA_HASH_MAX_SIZE=0
+CONFIG_RFKILL=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_RFKILL_INPUT=y
+# CONFIG_RFKILL_GPIO is not set
+# CONFIG_NET_9P is not set
+# CONFIG_CEPH_LIB is not set
+CONFIG_NFC=m
+# CONFIG_NFC_DIGITAL is not set
+CONFIG_NFC_NCI=m
+# CONFIG_NFC_NCI_SPI is not set
+# CONFIG_NFC_NCI_UART is not set
+# CONFIG_NFC_HCI is not set
+
+#
+# Near Field Communication (NFC) devices
+#
+# CONFIG_NFC_VIRTUAL_NCI is not set
+# CONFIG_NFC_FDP is not set
+# CONFIG_NFC_PN533_USB is not set
+# CONFIG_NFC_PN533_I2C is not set
+# CONFIG_NFC_PN532_UART is not set
+# CONFIG_NFC_MRVL_USB is not set
+# CONFIG_NFC_ST_NCI_I2C is not set
+# CONFIG_NFC_ST_NCI_SPI is not set
+# CONFIG_NFC_NXP_NCI is not set
+CONFIG_NFC_S3FWRN5=m
+CONFIG_NFC_S3FWRN5_I2C=m
+# CONFIG_NFC_S3FWRN82_UART is not set
+# end of Near Field Communication (NFC) devices
+
+# CONFIG_PSAMPLE is not set
+# CONFIG_NET_IFE is not set
+# CONFIG_LWTUNNEL is not set
+CONFIG_DST_CACHE=y
+CONFIG_GRO_CELLS=y
+CONFIG_NET_SELFTESTS=m
+CONFIG_NET_SOCK_MSG=y
+CONFIG_PAGE_POOL=y
+# CONFIG_PAGE_POOL_STATS is not set
+CONFIG_FAILOVER=m
+CONFIG_ETHTOOL_NETLINK=y
+
+#
+# Device Drivers
+#
+CONFIG_ARM_AMBA=y
+CONFIG_HAVE_PCI=y
+CONFIG_GENERIC_PCI_IOMAP=y
+# CONFIG_PCI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Generic Driver Options
+#
+CONFIG_AUXILIARY_BUS=y
+CONFIG_UEVENT_HELPER=y
+CONFIG_UEVENT_HELPER_PATH=""
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+# CONFIG_DEVTMPFS_SAFE is not set
+CONFIG_DRIVER_DEFERRED_PROBE_TIMEOUT=10
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+
+#
+# Firmware loader
+#
+CONFIG_FW_LOADER=y
+CONFIG_FW_LOADER_DEBUG=y
+CONFIG_FW_LOADER_PAGED_BUF=y
+CONFIG_FW_LOADER_SYSFS=y
+CONFIG_EXTRA_FIRMWARE=""
+CONFIG_FW_LOADER_USER_HELPER=y
+# CONFIG_FW_LOADER_USER_HELPER_FALLBACK is not set
+CONFIG_FW_LOADER_COMPRESS=y
+CONFIG_FW_LOADER_COMPRESS_XZ=y
+CONFIG_FW_LOADER_COMPRESS_ZSTD=y
+CONFIG_FW_CACHE=y
+# CONFIG_FW_UPLOAD is not set
+# end of Firmware loader
+
+CONFIG_WANT_DEV_COREDUMP=y
+CONFIG_ALLOW_DEV_COREDUMP=y
+CONFIG_DEV_COREDUMP=y
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_DEBUG_TEST_DRIVER_REMOVE is not set
+# CONFIG_TEST_ASYNC_DRIVER_PROBE is not set
+CONFIG_GENERIC_CPU_DEVICES=y
+CONFIG_GENERIC_CPU_AUTOPROBE=y
+CONFIG_GENERIC_CPU_VULNERABILITIES=y
+CONFIG_SOC_BUS=y
+CONFIG_REGMAP=y
+CONFIG_REGMAP_I2C=y
+CONFIG_REGMAP_SPI=m
+CONFIG_REGMAP_SPMI=y
+CONFIG_REGMAP_MMIO=y
+CONFIG_REGMAP_IRQ=y
+CONFIG_DMA_SHARED_BUFFER=y
+# CONFIG_DMA_FENCE_TRACE is not set
+CONFIG_GENERIC_ARCH_TOPOLOGY=y
+# CONFIG_FW_DEVLINK_SYNC_STATE_TIMEOUT is not set
+# end of Generic Driver Options
+
+#
+# Bus devices
+#
+# CONFIG_MOXTET is not set
+# CONFIG_QCOM_EBI2 is not set
+CONFIG_QCOM_SSC_BLOCK_BUS=y
+# CONFIG_VEXPRESS_CONFIG is not set
+# CONFIG_MHI_BUS is not set
+# CONFIG_MHI_BUS_EP is not set
+# end of Bus devices
+
+# CONFIG_CACHEMAINT_FOR_HOTPLUG is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+
+#
+# Firmware Drivers
+#
+
+#
+# ARM System Control and Management Interface Protocol
+#
+# CONFIG_ARM_SCMI_PROTOCOL is not set
+# end of ARM System Control and Management Interface Protocol
+
+# CONFIG_ARM_SCPI_PROTOCOL is not set
+# CONFIG_ARM_SDE_INTERFACE is not set
+CONFIG_DMIID=y
+# CONFIG_DMI_SYSFS is not set
+CONFIG_SYSFB=y
+# CONFIG_SYSFB_SIMPLEFB is not set
+# CONFIG_ARM_FFA_TRANSPORT is not set
+# CONFIG_GOOGLE_FIRMWARE is not set
+
+#
+# EFI (Extensible Firmware Interface) Support
+#
+CONFIG_EFI_ESRT=y
+CONFIG_EFI_VARS_PSTORE=y
+# CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE is not set
+CONFIG_EFI_PARAMS_FROM_FDT=y
+CONFIG_EFI_RUNTIME_WRAPPERS=y
+CONFIG_EFI_GENERIC_STUB=y
+CONFIG_EFI_ZBOOT=y
+CONFIG_EFI_ARMSTUB_DTB_LOADER=y
+# CONFIG_EFI_BOOTLOADER_CONTROL is not set
+# CONFIG_EFI_CAPSULE_LOADER is not set
+# CONFIG_EFI_TEST is not set
+# CONFIG_RESET_ATTACK_MITIGATION is not set
+# CONFIG_EFI_DISABLE_PCI_DMA is not set
+CONFIG_EFI_EARLYCON=y
+# CONFIG_EFI_DISABLE_RUNTIME is not set
+# CONFIG_EFI_COCO_SECRET is not set
+CONFIG_OVMF_DEBUG_LOG=y
+CONFIG_EFI_SBAT_FILE=""
+# end of EFI (Extensible Firmware Interface) Support
+
+CONFIG_ARM_PSCI_FW=y
+# CONFIG_ARM_PSCI_CHECKER is not set
+
+#
+# Qualcomm firmware drivers
+#
+CONFIG_QCOM_SCM=y
+CONFIG_QCOM_TZMEM=y
+CONFIG_QCOM_TZMEM_MODE_GENERIC=y
+# CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE is not set
+CONFIG_QCOM_QSEECOM=y
+# CONFIG_QCOM_QSEECOM_UEFISECAPP is not set
+# end of Qualcomm firmware drivers
+
+CONFIG_HAVE_ARM_SMCCC=y
+CONFIG_HAVE_ARM_SMCCC_DISCOVERY=y
+CONFIG_ARM_SMCCC_SOC_ID=y
+
+#
+# Tegra firmware driver
+#
+# end of Tegra firmware driver
+# end of Firmware Drivers
+
+CONFIG_FWCTL=y
+CONFIG_GNSS=y
+# CONFIG_GNSS_MTK_SERIAL is not set
+# CONFIG_GNSS_SIRF_SERIAL is not set
+# CONFIG_GNSS_UBX_SERIAL is not set
+# CONFIG_GNSS_USB is not set
+# CONFIG_MTD is not set
+CONFIG_DTC=y
+CONFIG_OF=y
+# CONFIG_OF_UNITTEST is not set
+CONFIG_OF_FLATTREE=y
+CONFIG_OF_EARLY_FLATTREE=y
+CONFIG_OF_KOBJ=y
+CONFIG_OF_DYNAMIC=y
+CONFIG_OF_ADDRESS=y
+CONFIG_OF_IRQ=y
+CONFIG_OF_RESERVED_MEM=y
+CONFIG_OF_RESOLVE=y
+CONFIG_OF_OVERLAY=y
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_NULL_BLK is not set
+CONFIG_ZRAM=y
+CONFIG_ZRAM_BACKEND_LZ4=y
+CONFIG_ZRAM_BACKEND_LZ4HC=y
+CONFIG_ZRAM_BACKEND_ZSTD=y
+CONFIG_ZRAM_BACKEND_DEFLATE=y
+CONFIG_ZRAM_BACKEND_842=y
+CONFIG_ZRAM_BACKEND_LZO=y
+# CONFIG_ZRAM_DEF_COMP_LZORLE is not set
+# CONFIG_ZRAM_DEF_COMP_LZO is not set
+# CONFIG_ZRAM_DEF_COMP_LZ4 is not set
+# CONFIG_ZRAM_DEF_COMP_LZ4HC is not set
+CONFIG_ZRAM_DEF_COMP_ZSTD=y
+# CONFIG_ZRAM_DEF_COMP_DEFLATE is not set
+# CONFIG_ZRAM_DEF_COMP_842 is not set
+CONFIG_ZRAM_DEF_COMP="zstd"
+CONFIG_ZRAM_WRITEBACK=y
+CONFIG_ZRAM_TRACK_ENTRY_ACTIME=y
+CONFIG_ZRAM_MEMORY_TRACKING=y
+# CONFIG_ZRAM_MULTI_COMP is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
+# CONFIG_BLK_DEV_DRBD is not set
+CONFIG_BLK_DEV_NBD=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_ATA_OVER_ETH is not set
+CONFIG_VIRTIO_BLK=m
+# CONFIG_BLK_DEV_RBD is not set
+CONFIG_BLK_DEV_UBLK=m
+CONFIG_BLKDEV_UBLK_LEGACY_OPCODES=y
+
+#
+# NVME Support
+#
+# CONFIG_NVME_FC is not set
+# CONFIG_NVME_TCP is not set
+# CONFIG_NVME_TARGET is not set
+# end of NVME Support
+
+#
+# Misc devices
+#
+# CONFIG_AD525X_DPOT is not set
+# CONFIG_DUMMY_IRQ is not set
+# CONFIG_RPMB is not set
+# CONFIG_TI_FPC202 is not set
+# CONFIG_ICS932S401 is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_HI6421V600_IRQ is not set
+CONFIG_QCOM_COINCELL=m
+CONFIG_QCOM_FASTRPC=m
+# CONFIG_APDS9802ALS is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_ISL29020 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_SENSORS_BH1770 is not set
+# CONFIG_HMC6352 is not set
+# CONFIG_DS1682 is not set
+# CONFIG_LATTICE_ECP3_CONFIG is not set
+# CONFIG_SRAM is not set
+# CONFIG_XILINX_SDFEC is not set
+# CONFIG_HISI_HIKEY_USB is not set
+# CONFIG_OPEN_DICE is not set
+CONFIG_NTSYNC=m
+# CONFIG_VCPU_STALL_DETECTOR is not set
+# CONFIG_NSM is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_EEPROM_93XX46 is not set
+# CONFIG_EEPROM_IDT_89HPESX is not set
+# CONFIG_EEPROM_EE1004 is not set
+# CONFIG_EEPROM_M24LR is not set
+# end of EEPROM support
+
+# CONFIG_SENSORS_LIS3_SPI is not set
+# CONFIG_SENSORS_LIS3_I2C is not set
+# CONFIG_ALTERA_STAPL is not set
+# CONFIG_MISC_RTSX_USB is not set
+# CONFIG_UACCE is not set
+# CONFIG_PVPANIC is not set
+# CONFIG_AMD_SBRMI_I2C is not set
+# end of Misc devices
+
+#
+# SCSI device support
+#
+CONFIG_SCSI_MOD=y
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI_COMMON=y
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_PROC_FS is not set
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+CONFIG_BLK_DEV_BSG=y
+# CONFIG_CHR_DEV_SCH is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# end of SCSI Transports
+
+CONFIG_SCSI_LOWLEVEL=y
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_ISCSI_BOOT_SYSFS is not set
+# CONFIG_SCSI_DEBUG is not set
+# CONFIG_SCSI_VIRTIO is not set
+# CONFIG_SCSI_DH is not set
+# end of SCSI device support
+
+# CONFIG_ATA is not set
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_BITMAP=y
+# CONFIG_MD_LLBITMAP is not set
+CONFIG_MD_AUTODETECT=y
+CONFIG_MD_BITMAP_FILE=y
+CONFIG_MD_LINEAR=y
+CONFIG_MD_RAID0=y
+CONFIG_MD_RAID1=y
+CONFIG_MD_RAID10=y
+CONFIG_MD_RAID456=y
+# CONFIG_BCACHE is not set
+CONFIG_BLK_DEV_DM_BUILTIN=y
+CONFIG_BLK_DEV_DM=y
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_BUFIO=m
+# CONFIG_DM_DEBUG_BLOCK_MANAGER_LOCKING is not set
+CONFIG_DM_BIO_PRISON=m
+CONFIG_DM_PERSISTENT_DATA=m
+# CONFIG_DM_UNSTRIPED is not set
+CONFIG_DM_CRYPT=y
+# CONFIG_DM_SNAPSHOT is not set
+CONFIG_DM_THIN_PROVISIONING=m
+# CONFIG_DM_CACHE is not set
+# CONFIG_DM_WRITECACHE is not set
+# CONFIG_DM_EBS is not set
+# CONFIG_DM_ERA is not set
+# CONFIG_DM_CLONE is not set
+# CONFIG_DM_MIRROR is not set
+CONFIG_DM_RAID=m
+# CONFIG_DM_ZERO is not set
+# CONFIG_DM_MULTIPATH is not set
+# CONFIG_DM_DELAY is not set
+# CONFIG_DM_DUST is not set
+# CONFIG_DM_INIT is not set
+# CONFIG_DM_UEVENT is not set
+# CONFIG_DM_FLAKEY is not set
+CONFIG_DM_VERITY=m
+# CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG is not set
+# CONFIG_DM_VERITY_FEC is not set
+# CONFIG_DM_SWITCH is not set
+# CONFIG_DM_LOG_WRITES is not set
+CONFIG_DM_INTEGRITY=m
+CONFIG_DM_AUDIT=y
+# CONFIG_DM_VDO is not set
+# CONFIG_TARGET_CORE is not set
+CONFIG_NETDEVICES=y
+CONFIG_MII=m
+CONFIG_NET_CORE=y
+CONFIG_BONDING=m
+CONFIG_DUMMY=m
+CONFIG_WIREGUARD=m
+# CONFIG_WIREGUARD_DEBUG is not set
+CONFIG_OVPN=m
+# CONFIG_EQUALIZER is not set
+# CONFIG_NET_TEAM is not set
+CONFIG_MACVLAN=m
+CONFIG_MACVTAP=m
+CONFIG_IPVLAN_L3S=y
+CONFIG_IPVLAN=m
+# CONFIG_IPVTAP is not set
+CONFIG_VXLAN=m
+# CONFIG_GENEVE is not set
+# CONFIG_BAREUDP is not set
+# CONFIG_GTP is not set
+# CONFIG_PFCP is not set
+# CONFIG_AMT is not set
+# CONFIG_MACSEC is not set
+# CONFIG_NETCONSOLE is not set
+CONFIG_TUN=m
+CONFIG_TAP=m
+# CONFIG_TUN_VNET_CROSS_LE is not set
+CONFIG_VETH=m
+CONFIG_VIRTIO_NET=m
+CONFIG_NLMON=m
+# CONFIG_NETKIT is not set
+# CONFIG_NET_VRF is not set
+CONFIG_ETHERNET=y
+# CONFIG_NET_VENDOR_ALACRITECH is not set
+CONFIG_NET_VENDOR_ALIBABA=y
+# CONFIG_ALTERA_TSE is not set
+# CONFIG_NET_VENDOR_AMAZON is not set
+# CONFIG_NET_VENDOR_AMD is not set
+# CONFIG_NET_VENDOR_AQUANTIA is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_VENDOR_ASIX is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CADENCE is not set
+# CONFIG_NET_VENDOR_CAVIUM is not set
+# CONFIG_NET_VENDOR_CORTINA is not set
+# CONFIG_NET_VENDOR_DAVICOM is not set
+# CONFIG_NET_VENDOR_ENGLEDER is not set
+# CONFIG_NET_VENDOR_EZCHIP is not set
+# CONFIG_NET_VENDOR_FUNGIBLE is not set
+# CONFIG_NET_VENDOR_GOOGLE is not set
+# CONFIG_NET_VENDOR_HISILICON is not set
+# CONFIG_NET_VENDOR_HUAWEI is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_ADI is not set
+# CONFIG_NET_VENDOR_LITEX is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MELLANOX is not set
+# CONFIG_NET_VENDOR_META is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_MICROSEMI is not set
+# CONFIG_NET_VENDOR_MICROSOFT is not set
+CONFIG_NET_VENDOR_MUCSE=y
+# CONFIG_NET_VENDOR_NI is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_ETHOC is not set
+# CONFIG_NET_VENDOR_PENSANDO is not set
+CONFIG_NET_VENDOR_QUALCOMM=y
+# CONFIG_QCA7000_SPI is not set
+# CONFIG_QCA7000_UART is not set
+# CONFIG_QCOM_EMAC is not set
+# CONFIG_QCOM_PPE is not set
+CONFIG_RMNET=m
+# CONFIG_NET_VENDOR_RENESAS is not set
+# CONFIG_NET_VENDOR_ROCKER is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SOLARFLARE is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_SOCIONEXT is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_SYNOPSYS is not set
+# CONFIG_NET_VENDOR_VERTEXCOM is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WANGXUN is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+# CONFIG_NET_VENDOR_XILINX is not set
+CONFIG_QCOM_IPA=m
+CONFIG_PHYLINK=m
+CONFIG_PHYLIB=m
+CONFIG_SWPHY=y
+# CONFIG_LED_TRIGGER_PHY is not set
+CONFIG_PHYLIB_LEDS=y
+CONFIG_FIXED_PHY=m
+# CONFIG_SFP is not set
+
+#
+# MII PHY device drivers
+#
+# CONFIG_AS21XXX_PHY is not set
+# CONFIG_AIR_AN8801_PHY is not set
+# CONFIG_AIR_EN8811H_PHY is not set
+# CONFIG_AMD_PHY is not set
+# CONFIG_ADIN_PHY is not set
+# CONFIG_ADIN1100_PHY is not set
+# CONFIG_AQUANTIA_PHY is not set
+CONFIG_AX88796B_PHY=m
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_BCM54140_PHY is not set
+# CONFIG_BCM7XXX_PHY is not set
+# CONFIG_BCM84881_PHY is not set
+# CONFIG_BCM87XX_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_CORTINA_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_INTEL_XWAY_PHY is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_MARVELL_10G_PHY is not set
+# CONFIG_MARVELL_88Q2XXX_PHY is not set
+# CONFIG_MARVELL_88X2222_PHY is not set
+# CONFIG_MAXLINEAR_GPHY is not set
+# CONFIG_MAXLINEAR_86110_PHY is not set
+# CONFIG_MEDIATEK_GE_PHY is not set
+# CONFIG_MICREL_PHY is not set
+# CONFIG_MICROCHIP_T1S_PHY is not set
+CONFIG_MICROCHIP_PHY=m
+# CONFIG_MICROCHIP_T1_PHY is not set
+# CONFIG_MICROSEMI_PHY is not set
+# CONFIG_MOTORCOMM_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_NXP_CBTX_PHY is not set
+# CONFIG_NXP_C45_TJA11XX_PHY is not set
+# CONFIG_NXP_TJA11XX_PHY is not set
+# CONFIG_NCN26000_PHY is not set
+# CONFIG_AT803X_PHY is not set
+# CONFIG_QCA83XX_PHY is not set
+# CONFIG_QCA808X_PHY is not set
+# CONFIG_QCA807X_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_RENESAS_PHY is not set
+# CONFIG_ROCKCHIP_PHY is not set
+CONFIG_SMSC_PHY=m
+# CONFIG_STE10XP is not set
+# CONFIG_TERANETICS_PHY is not set
+# CONFIG_DP83822_PHY is not set
+# CONFIG_DP83TC811_PHY is not set
+# CONFIG_DP83848_PHY is not set
+# CONFIG_DP83867_PHY is not set
+# CONFIG_DP83869_PHY is not set
+# CONFIG_DP83TD510_PHY is not set
+# CONFIG_DP83TG720_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_XILINX_GMII2RGMII is not set
+# CONFIG_PSE_CONTROLLER is not set
+CONFIG_FWNODE_MDIO=m
+CONFIG_OF_MDIO=m
+# CONFIG_MDIO_BITBANG is not set
+# CONFIG_MDIO_BCM_UNIMAC is not set
+# CONFIG_MDIO_HISI_FEMAC is not set
+# CONFIG_MDIO_MVUSB is not set
+# CONFIG_MDIO_MSCC_MIIM is not set
+# CONFIG_MDIO_OCTEON is not set
+# CONFIG_MDIO_IPQ4019 is not set
+# CONFIG_MDIO_IPQ8064 is not set
+
+#
+# MDIO Multiplexers
+#
+# CONFIG_MDIO_BUS_MUX_GPIO is not set
+# CONFIG_MDIO_BUS_MUX_MULTIPLEXER is not set
+# CONFIG_MDIO_BUS_MUX_MMIOREG is not set
+
+#
+# PCS device drivers
+#
+# CONFIG_PCS_XPCS is not set
+# end of PCS device drivers
+
+CONFIG_PPP=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_FILTER=y
+# CONFIG_PPP_MPPE is not set
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPPOX=m
+CONFIG_PPPOE=m
+# CONFIG_PPPOE_HASH_BITS_1 is not set
+# CONFIG_PPPOE_HASH_BITS_2 is not set
+CONFIG_PPPOE_HASH_BITS_4=y
+# CONFIG_PPPOE_HASH_BITS_8 is not set
+CONFIG_PPPOE_HASH_BITS=4
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+# CONFIG_SLIP is not set
+CONFIG_SLHC=m
+CONFIG_USB_NET_DRIVERS=y
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_RTL8152=m
+CONFIG_USB_LAN78XX=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_AX88179_178A=m
+CONFIG_USB_NET_CDCETHER=m
+# CONFIG_USB_NET_CDC_EEM is not set
+CONFIG_USB_NET_CDC_NCM=m
+CONFIG_USB_NET_HUAWEI_CDC_NCM=m
+CONFIG_USB_NET_CDC_MBIM=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_SR9700=m
+CONFIG_USB_NET_SR9800=m
+CONFIG_USB_NET_SMSC75XX=m
+CONFIG_USB_NET_SMSC95XX=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET_ENABLE=m
+CONFIG_USB_NET_CDC_SUBSET=m
+# CONFIG_USB_ALI_M5632 is not set
+# CONFIG_USB_AN2720 is not set
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+# CONFIG_USB_EPSON2888 is not set
+# CONFIG_USB_KC2190 is not set
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_NET_CX82310_ETH=m
+CONFIG_USB_NET_KALMIA=m
+CONFIG_USB_NET_QMI_WWAN=m
+CONFIG_USB_HSO=m
+CONFIG_USB_NET_INT51X1=m
+CONFIG_USB_IPHETH=m
+CONFIG_USB_SIERRA_NET=m
+CONFIG_USB_VL600=m
+CONFIG_USB_NET_CH9200=m
+CONFIG_USB_NET_AQC111=m
+CONFIG_USB_RTL8153_ECM=m
+CONFIG_WLAN=y
+# CONFIG_WLAN_VENDOR_ADMTEK is not set
+CONFIG_ATH_COMMON=m
+CONFIG_WLAN_VENDOR_ATH=y
+# CONFIG_ATH_DEBUG is not set
+# CONFIG_ATH9K is not set
+# CONFIG_ATH9K_HTC is not set
+# CONFIG_CARL9170 is not set
+# CONFIG_ATH6KL is not set
+# CONFIG_AR5523 is not set
+CONFIG_ATH10K=m
+CONFIG_ATH10K_CE=y
+# CONFIG_ATH10K_SDIO is not set
+# CONFIG_ATH10K_USB is not set
+CONFIG_ATH10K_SNOC=m
+CONFIG_ATH10K_DEBUG=y
+CONFIG_ATH10K_DEBUGFS=y
+CONFIG_ATH10K_LEDS=y
+CONFIG_ATH10K_SPECTRAL=y
+# CONFIG_ATH10K_TRACING is not set
+# CONFIG_WCN36XX is not set
+# CONFIG_ATH11K is not set
+# CONFIG_WLAN_VENDOR_ATMEL is not set
+# CONFIG_WLAN_VENDOR_BROADCOM is not set
+# CONFIG_WLAN_VENDOR_INTEL is not set
+# CONFIG_WLAN_VENDOR_INTERSIL is not set
+# CONFIG_WLAN_VENDOR_MARVELL is not set
+# CONFIG_WLAN_VENDOR_MEDIATEK is not set
+# CONFIG_WLAN_VENDOR_MICROCHIP is not set
+# CONFIG_WLAN_VENDOR_PURELIFI is not set
+# CONFIG_WLAN_VENDOR_RALINK is not set
+# CONFIG_WLAN_VENDOR_REALTEK is not set
+# CONFIG_WLAN_VENDOR_RSI is not set
+# CONFIG_WLAN_VENDOR_SILABS is not set
+# CONFIG_WLAN_VENDOR_ST is not set
+# CONFIG_WLAN_VENDOR_TI is not set
+# CONFIG_WLAN_VENDOR_ZYDAS is not set
+# CONFIG_WLAN_VENDOR_QUANTENNA is not set
+# CONFIG_MAC80211_HWSIM is not set
+# CONFIG_VIRT_WIFI is not set
+# CONFIG_WAN is not set
+
+#
+# Wireless WAN
+#
+# CONFIG_WWAN is not set
+# end of Wireless WAN
+
+# CONFIG_NETDEVSIM is not set
+CONFIG_NET_FAILOVER=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_LEDS=y
+CONFIG_INPUT_FF_MEMLESS=y
+# CONFIG_INPUT_SPARSEKMAP is not set
+CONFIG_INPUT_MATRIXKMAP=m
+CONFIG_INPUT_VIVALDIFMAP=m
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADC is not set
+# CONFIG_KEYBOARD_ADP5588 is not set
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_QT1050 is not set
+# CONFIG_KEYBOARD_QT1070 is not set
+# CONFIG_KEYBOARD_QT2160 is not set
+# CONFIG_KEYBOARD_DLINK_DIR685 is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_GPIO=y
+CONFIG_KEYBOARD_GPIO_POLLED=y
+# CONFIG_KEYBOARD_TCA8418 is not set
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_CHARLIEPLEX is not set
+# CONFIG_KEYBOARD_LM8323 is not set
+# CONFIG_KEYBOARD_LM8333 is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
+# CONFIG_KEYBOARD_MPR121 is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_PINEPHONE is not set
+# CONFIG_KEYBOARD_SAMSUNG is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+CONFIG_KEYBOARD_STMPE=m
+# CONFIG_KEYBOARD_OMAP4 is not set
+# CONFIG_KEYBOARD_TM2_TOUCHKEY is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_CAP11XX is not set
+# CONFIG_KEYBOARD_BCM is not set
+# CONFIG_KEYBOARD_CYPRESS_SF is not set
+CONFIG_INPUT_MOUSE=y
+# CONFIG_MOUSE_PS2 is not set
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_APPLETOUCH is not set
+# CONFIG_MOUSE_BCM5974 is not set
+# CONFIG_MOUSE_CYAPA is not set
+# CONFIG_MOUSE_ELAN_I2C is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_MOUSE_GPIO is not set
+CONFIG_MOUSE_SYNAPTICS_I2C=m
+CONFIG_MOUSE_SYNAPTICS_USB=m
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADC is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+# CONFIG_JOYSTICK_TWIDJOY is not set
+# CONFIG_JOYSTICK_ZHENHUA is not set
+# CONFIG_JOYSTICK_AS5011 is not set
+# CONFIG_JOYSTICK_JOYDUMP is not set
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+# CONFIG_JOYSTICK_PSXPAD_SPI is not set
+# CONFIG_JOYSTICK_PXRC is not set
+# CONFIG_JOYSTICK_QWIIC is not set
+# CONFIG_JOYSTICK_FSIA6B is not set
+# CONFIG_JOYSTICK_SENSEHAT is not set
+# CONFIG_JOYSTICK_SEESAW is not set
+CONFIG_INPUT_TABLET=y
+# CONFIG_TABLET_USB_ACECAD is not set
+# CONFIG_TABLET_USB_AIPTEK is not set
+# CONFIG_TABLET_USB_HANWANG is not set
+# CONFIG_TABLET_USB_KBTAB is not set
+# CONFIG_TABLET_USB_PEGASUS is not set
+# CONFIG_TABLET_SERIAL_WACOM4 is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_ADC is not set
+# CONFIG_TOUCHSCREEN_AR1021_I2C is not set
+# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set
+# CONFIG_TOUCHSCREEN_AUO_PIXCIR is not set
+# CONFIG_TOUCHSCREEN_BU21013 is not set
+# CONFIG_TOUCHSCREEN_BU21029 is not set
+# CONFIG_TOUCHSCREEN_CHIPONE_ICN8318 is not set
+# CONFIG_TOUCHSCREEN_CY8CTMA140 is not set
+# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set
+# CONFIG_TOUCHSCREEN_CYTTSP_CORE is not set
+# CONFIG_TOUCHSCREEN_CYTTSP5 is not set
+# CONFIG_TOUCHSCREEN_DYNAPRO is not set
+# CONFIG_TOUCHSCREEN_HAMPSHIRE is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
+# CONFIG_TOUCHSCREEN_EGALAX is not set
+# CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set
+# CONFIG_TOUCHSCREEN_EXC3000 is not set
+# CONFIG_TOUCHSCREEN_FUJITSU is not set
+CONFIG_TOUCHSCREEN_GOODIX=m
+# CONFIG_TOUCHSCREEN_GOODIX_BERLIN_I2C is not set
+# CONFIG_TOUCHSCREEN_GOODIX_BERLIN_SPI is not set
+# CONFIG_TOUCHSCREEN_HIDEEP is not set
+# CONFIG_TOUCHSCREEN_HIMAX_HX852X is not set
+# CONFIG_TOUCHSCREEN_HYCON_HY46XX is not set
+# CONFIG_TOUCHSCREEN_HYNITRON_CSTXXX is not set
+# CONFIG_TOUCHSCREEN_HYNITRON_CST816X is not set
+# CONFIG_TOUCHSCREEN_ILI210X is not set
+# CONFIG_TOUCHSCREEN_ILITEK is not set
+# CONFIG_TOUCHSCREEN_S6SY761 is not set
+# CONFIG_TOUCHSCREEN_GUNZE is not set
+# CONFIG_TOUCHSCREEN_EKTF2127 is not set
+# CONFIG_TOUCHSCREEN_ELAN is not set
+# CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_WACOM_I2C is not set
+# CONFIG_TOUCHSCREEN_WACOM_W9000 is not set
+# CONFIG_TOUCHSCREEN_MAX11801 is not set
+# CONFIG_TOUCHSCREEN_MMS114 is not set
+# CONFIG_TOUCHSCREEN_MELFAS_MIP4 is not set
+# CONFIG_TOUCHSCREEN_MSG2638 is not set
+# CONFIG_TOUCHSCREEN_MTOUCH is not set
+CONFIG_TOUCHSCREEN_NOVATEK_NVT_TS=m
+# CONFIG_TOUCHSCREEN_IMAGIS is not set
+# CONFIG_TOUCHSCREEN_IMX6UL_TSC is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
+# CONFIG_TOUCHSCREEN_PENMOUNT is not set
+CONFIG_TOUCHSCREEN_EDT_FT5X06=m
+# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
+# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
+# CONFIG_TOUCHSCREEN_PIXCIR is not set
+# CONFIG_TOUCHSCREEN_WDT87XX_I2C is not set
+# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC_SERIO is not set
+# CONFIG_TOUCHSCREEN_TSC2004 is not set
+# CONFIG_TOUCHSCREEN_TSC2005 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_RM_TS is not set
+# CONFIG_TOUCHSCREEN_SILEAD is not set
+# CONFIG_TOUCHSCREEN_SIS_I2C is not set
+# CONFIG_TOUCHSCREEN_ST1232 is not set
+# CONFIG_TOUCHSCREEN_STMFTS is not set
+# CONFIG_TOUCHSCREEN_STMPE is not set
+# CONFIG_TOUCHSCREEN_SURFACE3_SPI is not set
+CONFIG_TOUCHSCREEN_SYNAPTICS_TCM=y
+# CONFIG_TOUCHSCREEN_SX8654 is not set
+# CONFIG_TOUCHSCREEN_TPS6507X is not set
+# CONFIG_TOUCHSCREEN_ZET6223 is not set
+# CONFIG_TOUCHSCREEN_ZFORCE is not set
+# CONFIG_TOUCHSCREEN_COLIBRI_VF50 is not set
+# CONFIG_TOUCHSCREEN_ROHM_BU21023 is not set
+# CONFIG_TOUCHSCREEN_IQS5XX is not set
+# CONFIG_TOUCHSCREEN_IQS7211 is not set
+# CONFIG_TOUCHSCREEN_ZINITIX is not set
+# CONFIG_TOUCHSCREEN_HIMAX_HX83112B is not set
+CONFIG_INPUT_MISC=y
+# CONFIG_INPUT_AD714X is not set
+# CONFIG_INPUT_ATMEL_CAPTOUCH is not set
+# CONFIG_INPUT_AW86927 is not set
+# CONFIG_INPUT_BMA150 is not set
+# CONFIG_INPUT_E3X0_BUTTON is not set
+CONFIG_INPUT_PM8941_PWRKEY=y
+CONFIG_INPUT_PM8XXX_VIBRATOR=y
+CONFIG_INPUT_QCOM_SPMI_HAPTICS=m
+# CONFIG_INPUT_MMA8450 is not set
+# CONFIG_INPUT_GPIO_BEEPER is not set
+# CONFIG_INPUT_GPIO_DECODER is not set
+# CONFIG_INPUT_GPIO_VIBRA is not set
+# CONFIG_INPUT_ATI_REMOTE2 is not set
+# CONFIG_INPUT_KEYSPAN_REMOTE is not set
+# CONFIG_INPUT_KXTJ9 is not set
+# CONFIG_INPUT_POWERMATE is not set
+# CONFIG_INPUT_YEALINK is not set
+# CONFIG_INPUT_CM109 is not set
+# CONFIG_INPUT_REGULATOR_HAPTIC is not set
+CONFIG_INPUT_UINPUT=y
+# CONFIG_INPUT_PCF8574 is not set
+# CONFIG_INPUT_PWM_BEEPER is not set
+# CONFIG_INPUT_PWM_VIBRA is not set
+# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
+# CONFIG_INPUT_DA7280_HAPTICS is not set
+# CONFIG_INPUT_ADXL34X is not set
+# CONFIG_INPUT_IBM_PANEL is not set
+# CONFIG_INPUT_IMS_PCU is not set
+# CONFIG_INPUT_IQS269A is not set
+# CONFIG_INPUT_IQS626A is not set
+# CONFIG_INPUT_IQS7222 is not set
+# CONFIG_INPUT_CMA3000 is not set
+# CONFIG_INPUT_DRV260X_HAPTICS is not set
+# CONFIG_INPUT_DRV2665_HAPTICS is not set
+# CONFIG_INPUT_DRV2667_HAPTICS is not set
+CONFIG_RMI4_CORE=y
+CONFIG_RMI4_I2C=y
+CONFIG_RMI4_SPI=m
+CONFIG_RMI4_SMB=m
+CONFIG_RMI4_F03=y
+CONFIG_RMI4_F03_SERIO=y
+CONFIG_RMI4_2D_SENSOR=y
+CONFIG_RMI4_F11=y
+CONFIG_RMI4_F12=y
+# CONFIG_RMI4_F1A is not set
+# CONFIG_RMI4_F21 is not set
+CONFIG_RMI4_F30=y
+# CONFIG_RMI4_F34 is not set
+CONFIG_RMI4_F3A=y
+# CONFIG_RMI4_F55 is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_AMBAKMI is not set
+# CONFIG_SERIO_LIBPS2 is not set
+# CONFIG_SERIO_RAW is not set
+# CONFIG_SERIO_ALTERA_PS2 is not set
+# CONFIG_SERIO_PS2MULT is not set
+# CONFIG_SERIO_ARC_PS2 is not set
+# CONFIG_SERIO_APBPS2 is not set
+# CONFIG_SERIO_GPIO_PS2 is not set
+# CONFIG_USERIO is not set
+# CONFIG_GAMEPORT is not set
+# end of Hardware I/O ports
+# end of Input device support
+
+#
+# Character devices
+#
+CONFIG_TTY=y
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_VT_CONSOLE_SLEEP=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=16
+# CONFIG_LEGACY_TIOCSTI is not set
+CONFIG_LDISC_AUTOLOAD=y
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_EARLYCON=y
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_AMBA_PL010 is not set
+# CONFIG_SERIAL_AMBA_PL011 is not set
+# CONFIG_SERIAL_EARLYCON_SEMIHOST is not set
+# CONFIG_SERIAL_MAX3100 is not set
+# CONFIG_SERIAL_MAX310X is not set
+# CONFIG_SERIAL_UARTLITE is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_MSM=y
+CONFIG_SERIAL_MSM_CONSOLE=y
+# CONFIG_SERIAL_QCOM_GENI is not set
+# CONFIG_SERIAL_SIFIVE is not set
+# CONFIG_SERIAL_SCCNXP is not set
+# CONFIG_SERIAL_SC16IS7XX is not set
+# CONFIG_SERIAL_ALTERA_JTAGUART is not set
+# CONFIG_SERIAL_ALTERA_UART is not set
+# CONFIG_SERIAL_XILINX_PS_UART is not set
+# CONFIG_SERIAL_ARC is not set
+# CONFIG_SERIAL_FSL_LPUART is not set
+# CONFIG_SERIAL_FSL_LINFLEXUART is not set
+# CONFIG_SERIAL_CONEXANT_DIGICOLOR is not set
+# CONFIG_SERIAL_SPRD is not set
+# end of Serial drivers
+
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_N_GSM is not set
+CONFIG_NULL_TTY=y
+# CONFIG_HVC_DCC is not set
+CONFIG_RPMSG_TTY=m
+CONFIG_SERIAL_DEV_BUS=y
+CONFIG_SERIAL_DEV_CTRL_TTYPORT=y
+# CONFIG_VIRTIO_CONSOLE is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_SSIF_IPMI_BMC is not set
+# CONFIG_IPMB_DEVICE_INTERFACE is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_HW_RANDOM_TIMERIOMEM is not set
+# CONFIG_HW_RANDOM_BA431 is not set
+# CONFIG_HW_RANDOM_VIRTIO is not set
+# CONFIG_HW_RANDOM_CCTRNG is not set
+# CONFIG_HW_RANDOM_XIPHERA is not set
+CONFIG_HW_RANDOM_ARM_SMCCC_TRNG=m
+CONFIG_DEVMEM=y
+CONFIG_DEVPORT=y
+# CONFIG_TCG_TPM is not set
+# CONFIG_XILLYBUS is not set
+# CONFIG_XILLYUSB is not set
+# end of Character devices
+
+#
+# I2C support
+#
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_MUX=y
+
+#
+# Multiplexer I2C Chip support
+#
+# CONFIG_I2C_ARB_GPIO_CHALLENGE is not set
+# CONFIG_I2C_MUX_GPIO is not set
+# CONFIG_I2C_MUX_GPMUX is not set
+# CONFIG_I2C_MUX_LTC4306 is not set
+# CONFIG_I2C_MUX_PCA9541 is not set
+# CONFIG_I2C_MUX_PCA954x is not set
+# CONFIG_I2C_MUX_PINCTRL is not set
+# CONFIG_I2C_MUX_REG is not set
+# CONFIG_I2C_DEMUX_PINCTRL is not set
+# CONFIG_I2C_MUX_MLXCPLD is not set
+# end of Multiplexer I2C Chip support
+
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=y
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_CADENCE is not set
+# CONFIG_I2C_CBUS_GPIO is not set
+# CONFIG_I2C_DESIGNWARE_CORE is not set
+# CONFIG_I2C_EMEV2 is not set
+CONFIG_I2C_GPIO=y
+# CONFIG_I2C_GPIO_FAULT_INJECTOR is not set
+# CONFIG_I2C_HISI is not set
+# CONFIG_I2C_NOMADIK is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_QCOM_CCI is not set
+# CONFIG_I2C_QCOM_GENI is not set
+CONFIG_I2C_QUP=y
+# CONFIG_I2C_RK3X is not set
+# CONFIG_I2C_SIMTEC is not set
+# CONFIG_I2C_XILINX is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_DIOLAN_U2C is not set
+# CONFIG_I2C_CP2615 is not set
+# CONFIG_I2C_ROBOTFUZZ_OSIF is not set
+# CONFIG_I2C_TAOS_EVM is not set
+# CONFIG_I2C_TINY_USB is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_VIRTIO is not set
+# end of I2C Hardware Bus support
+
+# CONFIG_I2C_STUB is not set
+CONFIG_I2C_SLAVE=y
+# CONFIG_I2C_SLAVE_EEPROM is not set
+# CONFIG_I2C_SLAVE_TESTUNIT is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# end of I2C support
+
+# CONFIG_I3C is not set
+CONFIG_I3C_OR_I2C=y
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+CONFIG_SPI_MEM=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_ALTERA is not set
+# CONFIG_SPI_AXI_SPI_ENGINE is not set
+CONFIG_SPI_BITBANG=m
+# CONFIG_SPI_CADENCE is not set
+# CONFIG_SPI_CADENCE_QUADSPI is not set
+# CONFIG_SPI_CADENCE_XSPI is not set
+# CONFIG_SPI_CH341 is not set
+# CONFIG_SPI_DESIGNWARE is not set
+# CONFIG_SPI_GPIO is not set
+# CONFIG_SPI_FSL_SPI is not set
+# CONFIG_SPI_MICROCHIP_CORE_QSPI is not set
+# CONFIG_SPI_MICROCHIP_CORE_SPI is not set
+# CONFIG_SPI_OC_TINY is not set
+# CONFIG_SPI_PL022 is not set
+# CONFIG_SPI_QCOM_QSPI is not set
+CONFIG_SPI_QUP=y
+# CONFIG_SPI_QCOM_GENI is not set
+# CONFIG_SPI_SC18IS602 is not set
+# CONFIG_SPI_SIFIVE is not set
+# CONFIG_SPI_SN_F_OSPI is not set
+# CONFIG_SPI_MXIC is not set
+# CONFIG_SPI_VIRTIO is not set
+# CONFIG_SPI_XCOMM is not set
+# CONFIG_SPI_XILINX is not set
+# CONFIG_SPI_ZYNQMP_GQSPI is not set
+
+#
+# SPI Multiplexer support
+#
+# CONFIG_SPI_MUX is not set
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=m
+# CONFIG_SPI_LOOPBACK_TEST is not set
+# CONFIG_SPI_TLE62X0 is not set
+# CONFIG_SPI_SLAVE is not set
+CONFIG_SPI_DYNAMIC=y
+CONFIG_SPMI=y
+# CONFIG_SPMI_HISI3670 is not set
+CONFIG_SPMI_MSM_PMIC_ARB=y
+# CONFIG_HSI is not set
+CONFIG_PPS=y
+# CONFIG_PPS_DEBUG is not set
+
+#
+# PPS clients support
+#
+# CONFIG_PPS_CLIENT_KTIMER is not set
+# CONFIG_PPS_CLIENT_LDISC is not set
+# CONFIG_PPS_CLIENT_GPIO is not set
+CONFIG_PPS_GENERATOR=m
+# CONFIG_PPS_GENERATOR_DUMMY is not set
+
+#
+# PTP clock support
+#
+CONFIG_PTP_1588_CLOCK=y
+CONFIG_PTP_1588_CLOCK_OPTIONAL=y
+
+#
+# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks.
+#
+CONFIG_PTP_1588_CLOCK_KVM=y
+CONFIG_PTP_1588_CLOCK_VMCLOCK=y
+# CONFIG_PTP_1588_CLOCK_IDT82P33 is not set
+# CONFIG_PTP_1588_CLOCK_IDTCM is not set
+# CONFIG_PTP_1588_CLOCK_FC3W is not set
+# CONFIG_PTP_1588_CLOCK_MOCK is not set
+# end of PTP clock support
+
+#
+# DPLL device support
+#
+# CONFIG_ZL3073X_I2C is not set
+# CONFIG_ZL3073X_SPI is not set
+# end of DPLL device support
+
+CONFIG_PINCTRL=y
+CONFIG_GENERIC_PINCTRL_GROUPS=y
+CONFIG_PINMUX=y
+CONFIG_GENERIC_PINMUX_FUNCTIONS=y
+CONFIG_PINCONF=y
+CONFIG_GENERIC_PINCONF=y
+# CONFIG_DEBUG_PINCTRL is not set
+# CONFIG_PINCTRL_AW9523 is not set
+# CONFIG_PINCTRL_CY8C95X0 is not set
+# CONFIG_PINCTRL_GENERIC_MUX is not set
+# CONFIG_PINCTRL_MCP23S08 is not set
+# CONFIG_PINCTRL_MICROCHIP_SGPIO is not set
+# CONFIG_PINCTRL_OCELOT is not set
+CONFIG_PINCTRL_SINGLE=y
+# CONFIG_PINCTRL_STMFX is not set
+# CONFIG_PINCTRL_SX150X is not set
+CONFIG_PINCTRL_MSM=y
+CONFIG_PINCTRL_ELIZA=y
+# CONFIG_PINCTRL_GLYMUR is not set
+CONFIG_PINCTRL_HAWI=y
+# CONFIG_PINCTRL_IPQ5018 is not set
+CONFIG_PINCTRL_IPQ5210=y
+# CONFIG_PINCTRL_IPQ5332 is not set
+# CONFIG_PINCTRL_IPQ5424 is not set
+# CONFIG_PINCTRL_IPQ8074 is not set
+# CONFIG_PINCTRL_IPQ6018 is not set
+# CONFIG_PINCTRL_IPQ9574 is not set
+CONFIG_PINCTRL_IPQ9650=y
+# CONFIG_PINCTRL_KAANAPALI is not set
+# CONFIG_PINCTRL_MDM9607 is not set
+# CONFIG_PINCTRL_MSM8916 is not set
+# CONFIG_PINCTRL_MSM8917 is not set
+# CONFIG_PINCTRL_MSM8953 is not set
+# CONFIG_PINCTRL_MSM8976 is not set
+# CONFIG_PINCTRL_MSM8994 is not set
+# CONFIG_PINCTRL_MSM8996 is not set
+# CONFIG_PINCTRL_MSM8998 is not set
+CONFIG_PINCTRL_NORD=y
+# CONFIG_PINCTRL_QCM2290 is not set
+# CONFIG_PINCTRL_QCS404 is not set
+# CONFIG_PINCTRL_QCS615 is not set
+# CONFIG_PINCTRL_QCS8300 is not set
+# CONFIG_PINCTRL_QDU1000 is not set
+# CONFIG_PINCTRL_SA8775P is not set
+# CONFIG_PINCTRL_SAR2130P is not set
+# CONFIG_PINCTRL_SC7180 is not set
+# CONFIG_PINCTRL_SC7280 is not set
+# CONFIG_PINCTRL_SC8180X is not set
+# CONFIG_PINCTRL_SC8280XP is not set
+CONFIG_PINCTRL_SDM660=y
+# CONFIG_PINCTRL_SDM670 is not set
+# CONFIG_PINCTRL_SDM845 is not set
+# CONFIG_PINCTRL_SDX75 is not set
+CONFIG_PINCTRL_SHIKRA=y
+# CONFIG_PINCTRL_SM4450 is not set
+# CONFIG_PINCTRL_SM6115 is not set
+# CONFIG_PINCTRL_SM6125 is not set
+# CONFIG_PINCTRL_SM6350 is not set
+# CONFIG_PINCTRL_SM6375 is not set
+# CONFIG_PINCTRL_SM7150 is not set
+# CONFIG_PINCTRL_MILOS is not set
+# CONFIG_PINCTRL_SM8150 is not set
+# CONFIG_PINCTRL_SM8250 is not set
+# CONFIG_PINCTRL_SM8350 is not set
+# CONFIG_PINCTRL_SM8450 is not set
+# CONFIG_PINCTRL_SM8550 is not set
+# CONFIG_PINCTRL_SM8650 is not set
+# CONFIG_PINCTRL_SM8750 is not set
+# CONFIG_PINCTRL_X1E80100 is not set
+CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
+CONFIG_PINCTRL_QCOM_SSBI_PMIC=y
+CONFIG_PINCTRL_LPASS_LPI=y
+# CONFIG_PINCTRL_MILOS_LPASS_LPI is not set
+# CONFIG_PINCTRL_SC7280_LPASS_LPI is not set
+CONFIG_PINCTRL_SDM660_LPASS_LPI=m
+# CONFIG_PINCTRL_SM4250_LPASS_LPI is not set
+# CONFIG_PINCTRL_SDM670_LPASS_LPI is not set
+# CONFIG_PINCTRL_SM6115_LPASS_LPI is not set
+# CONFIG_PINCTRL_SM6350_LPASS_LPI is not set
+# CONFIG_PINCTRL_SM8250_LPASS_LPI is not set
+# CONFIG_PINCTRL_SM8450_LPASS_LPI is not set
+# CONFIG_PINCTRL_SC8280XP_LPASS_LPI is not set
+# CONFIG_PINCTRL_SM8550_LPASS_LPI is not set
+# CONFIG_PINCTRL_SM8650_LPASS_LPI is not set
+
+#
+# Renesas pinctrl drivers
+#
+# end of Renesas pinctrl drivers
+
+CONFIG_GPIOLIB_LEGACY=y
+CONFIG_HAVE_SHARED_GPIOS=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIOLIB_FASTPATH_LIMIT=512
+CONFIG_OF_GPIO=y
+CONFIG_GPIOLIB_IRQCHIP=y
+CONFIG_GPIO_SHARED=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_CDEV=y
+CONFIG_GPIO_CDEV_V1=y
+
+#
+# Memory mapped GPIO drivers
+#
+# CONFIG_GPIO_74XX_MMIO is not set
+# CONFIG_GPIO_ALTERA is not set
+# CONFIG_GPIO_BY_PINCTRL is not set
+# CONFIG_GPIO_CADENCE is not set
+# CONFIG_GPIO_DWAPB is not set
+# CONFIG_GPIO_FTGPIO010 is not set
+# CONFIG_GPIO_GENERIC_PLATFORM is not set
+# CONFIG_GPIO_GRGPIO is not set
+# CONFIG_GPIO_HISI is not set
+# CONFIG_GPIO_HLWD is not set
+# CONFIG_GPIO_LOGICVC is not set
+# CONFIG_GPIO_MB86S7X is not set
+# CONFIG_GPIO_PL061 is not set
+# CONFIG_GPIO_POLARFIRE_SOC is not set
+# CONFIG_GPIO_SIFIVE is not set
+# CONFIG_GPIO_SYSCON is not set
+# CONFIG_GPIO_WAVESHARE_DSI_TOUCH is not set
+# CONFIG_GPIO_XGENE is not set
+# CONFIG_GPIO_XILINX is not set
+# CONFIG_GPIO_AMD_FCH is not set
+# end of Memory mapped GPIO drivers
+
+#
+# I2C GPIO expanders
+#
+# CONFIG_GPIO_ADNP is not set
+# CONFIG_GPIO_FXL6408 is not set
+# CONFIG_GPIO_DS4520 is not set
+# CONFIG_GPIO_GW_PLD is not set
+# CONFIG_GPIO_MAX7300 is not set
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCA9570 is not set
+# CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_TPIC2810 is not set
+# end of I2C GPIO expanders
+
+#
+# MFD GPIO expanders
+#
+# CONFIG_GPIO_STMPE is not set
+# end of MFD GPIO expanders
+
+#
+# Auxiliary Bus GPIO drivers
+#
+# end of Auxiliary Bus GPIO drivers
+
+#
+# SPI GPIO expanders
+#
+# CONFIG_GPIO_74X164 is not set
+# CONFIG_GPIO_MAX3191X is not set
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MC33880 is not set
+# CONFIG_GPIO_PISOSR is not set
+# CONFIG_GPIO_XRA1403 is not set
+# end of SPI GPIO expanders
+
+#
+# USB GPIO expanders
+#
+# CONFIG_GPIO_MPSSE is not set
+# end of USB GPIO expanders
+
+#
+# Virtual GPIO drivers
+#
+# CONFIG_GPIO_AGGREGATOR is not set
+# CONFIG_GPIO_LATCH is not set
+# CONFIG_GPIO_LINE_MUX is not set
+# CONFIG_GPIO_MOCKUP is not set
+# CONFIG_GPIO_VIRTIO is not set
+# CONFIG_GPIO_SIM is not set
+CONFIG_GPIO_SHARED_PROXY=m
+# end of Virtual GPIO drivers
+
+#
+# GPIO Debugging utilities
+#
+# CONFIG_GPIO_VIRTUSER is not set
+# end of GPIO Debugging utilities
+
+# CONFIG_W1 is not set
+CONFIG_POWER_RESET=y
+# CONFIG_POWER_RESET_GPIO is not set
+# CONFIG_POWER_RESET_GPIO_RESTART is not set
+CONFIG_POWER_RESET_MSM=y
+CONFIG_POWER_RESET_QCOM_PON=y
+# CONFIG_POWER_RESET_LTC2952 is not set
+# CONFIG_POWER_RESET_REGULATOR is not set
+# CONFIG_POWER_RESET_RESTART is not set
+# CONFIG_POWER_RESET_XGENE is not set
+# CONFIG_POWER_RESET_SYSCON is not set
+# CONFIG_POWER_RESET_SYSCON_POWEROFF is not set
+CONFIG_REBOOT_MODE=y
+CONFIG_SYSCON_REBOOT_MODE=y
+CONFIG_NVMEM_REBOOT_MODE=y
+# CONFIG_POWER_RESET_QEMU_VIRT_CTRL is not set
+CONFIG_POWER_SEQUENCING=y
+CONFIG_POWER_SEQUENCING_QCOM_WCN=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+CONFIG_POWER_SUPPLY_HWMON=y
+# CONFIG_GENERIC_ADC_BATTERY is not set
+# CONFIG_IP5XXX_POWER is not set
+# CONFIG_TEST_POWER is not set
+# CONFIG_CHARGER_ADP5061 is not set
+# CONFIG_BATTERY_CHAGALL is not set
+# CONFIG_BATTERY_CW2015 is not set
+# CONFIG_BATTERY_DS2780 is not set
+# CONFIG_BATTERY_DS2781 is not set
+# CONFIG_BATTERY_DS2782 is not set
+CONFIG_BATTERY_QCOM_BATTMGR=m
+# CONFIG_BATTERY_SAMSUNG_SDI is not set
+# CONFIG_BATTERY_S2MU005 is not set
+# CONFIG_BATTERY_SBS is not set
+# CONFIG_CHARGER_SBS is not set
+# CONFIG_MANAGER_SBS is not set
+# CONFIG_BATTERY_BQ27XXX is not set
+# CONFIG_BATTERY_MAX17040 is not set
+# CONFIG_BATTERY_MAX17042 is not set
+# CONFIG_BATTERY_MAX1720X is not set
+# CONFIG_CHARGER_ISP1704 is not set
+# CONFIG_CHARGER_MAX8903 is not set
+# CONFIG_CHARGER_LP8727 is not set
+# CONFIG_CHARGER_GPIO is not set
+# CONFIG_CHARGER_MANAGER is not set
+# CONFIG_CHARGER_LT3651 is not set
+# CONFIG_CHARGER_LTC4162L is not set
+# CONFIG_CHARGER_DETECTOR_MAX14656 is not set
+# CONFIG_CHARGER_MAX77976 is not set
+# CONFIG_CHARGER_MAX8971 is not set
+CONFIG_CHARGER_QCOM_SMBB=m
+# CONFIG_BATTERY_PM8916_BMS_VM is not set
+# CONFIG_CHARGER_PM8916_LBC is not set
+CONFIG_BATTERY_PMI8998_FG=m
+# CONFIG_CHARGER_BQ2415X is not set
+# CONFIG_CHARGER_BQ24190 is not set
+# CONFIG_CHARGER_BQ24257 is not set
+# CONFIG_CHARGER_BQ24735 is not set
+# CONFIG_CHARGER_BQ2515X is not set
+# CONFIG_CHARGER_BQ25890 is not set
+# CONFIG_CHARGER_BQ25980 is not set
+# CONFIG_CHARGER_BQ256XX is not set
+# CONFIG_CHARGER_SMB347 is not set
+# CONFIG_BATTERY_GAUGE_LTC2941 is not set
+# CONFIG_BATTERY_GOLDFISH is not set
+CONFIG_BATTERY_RT5033=m
+# CONFIG_CHARGER_RT9455 is not set
+# CONFIG_CHARGER_RT9467 is not set
+# CONFIG_CHARGER_RT9471 is not set
+# CONFIG_CHARGER_RT9756 is not set
+# CONFIG_CHARGER_UCS1002 is not set
+# CONFIG_CHARGER_BD99954 is not set
+# CONFIG_BATTERY_UG3105 is not set
+# CONFIG_BATTERY_CHARGER_SURFACE_RT is not set
+CONFIG_CHARGER_QCOM_SMB2=m
+# CONFIG_FUEL_GAUGE_MM8013 is not set
+CONFIG_HWMON=y
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Native drivers
+#
+# CONFIG_SENSORS_AD7314 is not set
+# CONFIG_SENSORS_AD7414 is not set
+# CONFIG_SENSORS_AD7418 is not set
+# CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1029 is not set
+# CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ADM1177 is not set
+# CONFIG_SENSORS_ADM9240 is not set
+# CONFIG_SENSORS_ADT7310 is not set
+# CONFIG_SENSORS_ADT7410 is not set
+# CONFIG_SENSORS_ADT7411 is not set
+# CONFIG_SENSORS_ADT7462 is not set
+# CONFIG_SENSORS_ADT7470 is not set
+# CONFIG_SENSORS_ADT7475 is not set
+# CONFIG_SENSORS_AHT10 is not set
+# CONFIG_SENSORS_AQUACOMPUTER_D5NEXT is not set
+# CONFIG_SENSORS_AS370 is not set
+# CONFIG_SENSORS_ASC7621 is not set
+# CONFIG_SENSORS_ASUS_ROG_RYUJIN is not set
+# CONFIG_SENSORS_AXI_FAN_CONTROL is not set
+# CONFIG_SENSORS_ARCTIC_FAN_CONTROLLER is not set
+# CONFIG_SENSORS_ATXP1 is not set
+# CONFIG_SENSORS_CHIPCAP2 is not set
+# CONFIG_SENSORS_CORSAIR_CPRO is not set
+# CONFIG_SENSORS_CORSAIR_PSU is not set
+# CONFIG_SENSORS_DS620 is not set
+# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_F71882FG is not set
+# CONFIG_SENSORS_F75375S is not set
+# CONFIG_SENSORS_FTSTEUTATES is not set
+# CONFIG_SENSORS_GIGABYTE_WATERFORCE is not set
+# CONFIG_SENSORS_GL518SM is not set
+# CONFIG_SENSORS_GL520SM is not set
+# CONFIG_SENSORS_G760A is not set
+# CONFIG_SENSORS_G762 is not set
+# CONFIG_SENSORS_GPIO_FAN is not set
+# CONFIG_SENSORS_HIH6130 is not set
+# CONFIG_SENSORS_HS3001 is not set
+# CONFIG_SENSORS_HTU31 is not set
+# CONFIG_SENSORS_IIO_HWMON is not set
+# CONFIG_SENSORS_ISL28022 is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_JC42 is not set
+# CONFIG_SENSORS_POWERZ is not set
+# CONFIG_SENSORS_POWR1220 is not set
+# CONFIG_SENSORS_LINEAGE is not set
+# CONFIG_SENSORS_LTC2945 is not set
+# CONFIG_SENSORS_LTC2947_I2C is not set
+# CONFIG_SENSORS_LTC2947_SPI is not set
+# CONFIG_SENSORS_LTC2990 is not set
+# CONFIG_SENSORS_LTC2991 is not set
+# CONFIG_SENSORS_LTC2992 is not set
+# CONFIG_SENSORS_LTC4151 is not set
+# CONFIG_SENSORS_LTC4215 is not set
+# CONFIG_SENSORS_LTC4222 is not set
+# CONFIG_SENSORS_LTC4245 is not set
+# CONFIG_SENSORS_LTC4260 is not set
+# CONFIG_SENSORS_LTC4261 is not set
+# CONFIG_SENSORS_LTC4282 is not set
+# CONFIG_SENSORS_LTC4283 is not set
+# CONFIG_SENSORS_MAX1111 is not set
+# CONFIG_SENSORS_MAX127 is not set
+# CONFIG_SENSORS_MAX16065 is not set
+# CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_MAX1668 is not set
+# CONFIG_SENSORS_MAX197 is not set
+# CONFIG_SENSORS_MAX31722 is not set
+# CONFIG_SENSORS_MAX31730 is not set
+# CONFIG_SENSORS_MAX31760 is not set
+# CONFIG_MAX31827 is not set
+# CONFIG_SENSORS_MAX6620 is not set
+# CONFIG_SENSORS_MAX6621 is not set
+# CONFIG_SENSORS_MAX6639 is not set
+# CONFIG_SENSORS_MAX6650 is not set
+# CONFIG_SENSORS_MAX6697 is not set
+# CONFIG_SENSORS_MAX31790 is not set
+# CONFIG_SENSORS_MC34VR500 is not set
+# CONFIG_SENSORS_MCP3021 is not set
+# CONFIG_SENSORS_MCP9982 is not set
+# CONFIG_SENSORS_TC654 is not set
+# CONFIG_SENSORS_TPS23861 is not set
+# CONFIG_SENSORS_MR75203 is not set
+# CONFIG_SENSORS_ADCXX is not set
+# CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM70 is not set
+# CONFIG_SENSORS_LM73 is not set
+# CONFIG_SENSORS_LM75 is not set
+# CONFIG_SENSORS_LM77 is not set
+# CONFIG_SENSORS_LM78 is not set
+# CONFIG_SENSORS_LM80 is not set
+# CONFIG_SENSORS_LM83 is not set
+# CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM87 is not set
+# CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_LM92 is not set
+# CONFIG_SENSORS_LM93 is not set
+# CONFIG_SENSORS_LM95234 is not set
+# CONFIG_SENSORS_LM95241 is not set
+# CONFIG_SENSORS_LM95245 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_NTC_THERMISTOR is not set
+# CONFIG_SENSORS_NCT6683 is not set
+# CONFIG_SENSORS_NCT6775 is not set
+# CONFIG_SENSORS_NCT6775_I2C is not set
+# CONFIG_SENSORS_NCT7363 is not set
+# CONFIG_SENSORS_NCT7802 is not set
+# CONFIG_SENSORS_NCT7904 is not set
+# CONFIG_SENSORS_NPCM7XX is not set
+# CONFIG_SENSORS_NZXT_KRAKEN2 is not set
+# CONFIG_SENSORS_NZXT_KRAKEN3 is not set
+# CONFIG_SENSORS_NZXT_SMART2 is not set
+# CONFIG_SENSORS_OCC_P8_I2C is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_PMBUS is not set
+# CONFIG_SENSORS_PT5161L is not set
+# CONFIG_SENSORS_PWM_FAN is not set
+# CONFIG_SENSORS_SBTSI is not set
+# CONFIG_SENSORS_SHT15 is not set
+# CONFIG_SENSORS_SHT21 is not set
+# CONFIG_SENSORS_SHT3x is not set
+# CONFIG_SENSORS_SHT4x is not set
+# CONFIG_SENSORS_SHTC1 is not set
+# CONFIG_SENSORS_DME1737 is not set
+# CONFIG_SENSORS_EMC1403 is not set
+# CONFIG_SENSORS_EMC1812 is not set
+# CONFIG_SENSORS_EMC2103 is not set
+# CONFIG_SENSORS_EMC2305 is not set
+# CONFIG_SENSORS_EMC6W201 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47M192 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_SCH5627 is not set
+# CONFIG_SENSORS_SCH5636 is not set
+# CONFIG_SENSORS_STTS751 is not set
+# CONFIG_SENSORS_ADC128D818 is not set
+# CONFIG_SENSORS_ADS7828 is not set
+# CONFIG_SENSORS_ADS7871 is not set
+# CONFIG_SENSORS_AMC6821 is not set
+# CONFIG_SENSORS_INA209 is not set
+# CONFIG_SENSORS_INA2XX is not set
+# CONFIG_SENSORS_INA238 is not set
+# CONFIG_SENSORS_INA3221 is not set
+# CONFIG_SENSORS_SPD5118 is not set
+# CONFIG_SENSORS_TC74 is not set
+# CONFIG_SENSORS_THMC50 is not set
+# CONFIG_SENSORS_TMP102 is not set
+# CONFIG_SENSORS_TMP103 is not set
+# CONFIG_SENSORS_TMP108 is not set
+# CONFIG_SENSORS_TMP401 is not set
+# CONFIG_SENSORS_TMP421 is not set
+# CONFIG_SENSORS_TMP464 is not set
+# CONFIG_SENSORS_TMP513 is not set
+# CONFIG_SENSORS_TSC1641 is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_SENSORS_W83773G is not set
+# CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83791D is not set
+# CONFIG_SENSORS_W83792D is not set
+# CONFIG_SENSORS_W83793 is not set
+# CONFIG_SENSORS_W83795 is not set
+# CONFIG_SENSORS_W83L785TS is not set
+# CONFIG_SENSORS_W83L786NG is not set
+# CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
+CONFIG_THERMAL=y
+# CONFIG_THERMAL_NETLINK is not set
+# CONFIG_THERMAL_STATISTICS is not set
+# CONFIG_THERMAL_DEBUGFS is not set
+# CONFIG_THERMAL_CORE_TESTING is not set
+CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
+CONFIG_THERMAL_HWMON=y
+CONFIG_THERMAL_OF=y
+CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
+# CONFIG_THERMAL_DEFAULT_GOV_FAIR_SHARE is not set
+# CONFIG_THERMAL_DEFAULT_GOV_USER_SPACE is not set
+# CONFIG_THERMAL_DEFAULT_GOV_BANG_BANG is not set
+CONFIG_THERMAL_GOV_FAIR_SHARE=y
+CONFIG_THERMAL_GOV_STEP_WISE=y
+CONFIG_THERMAL_GOV_BANG_BANG=y
+CONFIG_THERMAL_GOV_USER_SPACE=y
+CONFIG_CPU_THERMAL=y
+CONFIG_CPU_FREQ_THERMAL=y
+CONFIG_DEVFREQ_THERMAL=y
+CONFIG_THERMAL_EMULATION=y
+# CONFIG_THERMAL_MMIO is not set
+CONFIG_GENERIC_ADC_THERMAL=m
+
+#
+# Qualcomm thermal drivers
+#
+CONFIG_QCOM_TSENS=y
+CONFIG_QCOM_SPMI_ADC_TM5=m
+CONFIG_QCOM_SPMI_TEMP_ALARM=m
+CONFIG_QCOM_LMH=m
+# end of Qualcomm thermal drivers
+
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_CORE=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y
+CONFIG_WATCHDOG_OPEN_TIMEOUT=0
+# CONFIG_WATCHDOG_SYSFS is not set
+# CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT is not set
+
+#
+# Watchdog Pretimeout Governors
+#
+# CONFIG_WATCHDOG_PRETIMEOUT_GOV is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+# CONFIG_GPIO_WATCHDOG is not set
+# CONFIG_XILINX_WATCHDOG is not set
+# CONFIG_XILINX_WINDOW_WATCHDOG is not set
+# CONFIG_ZIIRAVE_WATCHDOG is not set
+# CONFIG_ARM_SP805_WATCHDOG is not set
+# CONFIG_ARM_SBSA_WATCHDOG is not set
+# CONFIG_CADENCE_WATCHDOG is not set
+# CONFIG_DW_WATCHDOG is not set
+# CONFIG_MAX63XX_WATCHDOG is not set
+CONFIG_QCOM_WDT=m
+# CONFIG_ARM_SMC_WATCHDOG is not set
+# CONFIG_PM8916_WATCHDOG is not set
+# CONFIG_MEN_A21_WDT is not set
+
+#
+# USB-based Watchdog Cards
+#
+# CONFIG_USBPCWATCHDOG is not set
+# CONFIG_GUNYAH_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+# CONFIG_SSB is not set
+CONFIG_BCMA_POSSIBLE=y
+# CONFIG_BCMA is not set
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_CORE=y
+# CONFIG_MFD_ADP5585 is not set
+# CONFIG_MFD_ACT8945A is not set
+# CONFIG_MFD_AS3711 is not set
+# CONFIG_MFD_SMPRO is not set
+# CONFIG_MFD_AS3722 is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_AAT2870_CORE is not set
+# CONFIG_MFD_ATMEL_FLEXCOM is not set
+# CONFIG_MFD_ATMEL_HLCDC is not set
+# CONFIG_MFD_BCM590XX is not set
+# CONFIG_MFD_BD9571MWV is not set
+# CONFIG_MFD_AXP20X_I2C is not set
+# CONFIG_MFD_CS40L50_I2C is not set
+# CONFIG_MFD_CS40L50_SPI is not set
+# CONFIG_MFD_CS42L43_I2C is not set
+# CONFIG_MFD_CS42L43_SDW is not set
+# CONFIG_MFD_LOCHNAGAR is not set
+# CONFIG_MFD_MADERA is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_MFD_DA9052_SPI is not set
+# CONFIG_MFD_DA9052_I2C is not set
+# CONFIG_MFD_DA9055 is not set
+# CONFIG_MFD_DA9062 is not set
+# CONFIG_MFD_DA9063 is not set
+# CONFIG_MFD_DA9150 is not set
+# CONFIG_MFD_DLN2 is not set
+# CONFIG_MFD_GATEWORKS_GSC is not set
+# CONFIG_MFD_MC13XXX_SPI is not set
+# CONFIG_MFD_MC13XXX_I2C is not set
+# CONFIG_MFD_MP2629 is not set
+# CONFIG_MFD_PF1550 is not set
+# CONFIG_MFD_HI6421_PMIC is not set
+# CONFIG_MFD_HI6421_SPMI is not set
+# CONFIG_MFD_IQS62X is not set
+# CONFIG_MFD_KEMPLD is not set
+# CONFIG_MFD_88PM800 is not set
+# CONFIG_MFD_88PM805 is not set
+# CONFIG_MFD_88PM860X is not set
+# CONFIG_MFD_88PM886_PMIC is not set
+# CONFIG_MFD_MAX5970 is not set
+# CONFIG_MFD_MAX14577 is not set
+# CONFIG_MFD_MAX77541 is not set
+# CONFIG_MFD_MAX77620 is not set
+# CONFIG_MFD_MAX77650 is not set
+# CONFIG_MFD_MAX77686 is not set
+# CONFIG_MFD_MAX77693 is not set
+# CONFIG_MFD_MAX77705 is not set
+# CONFIG_MFD_MAX77714 is not set
+# CONFIG_MFD_MAX77759 is not set
+# CONFIG_MFD_MAX77843 is not set
+# CONFIG_MFD_MAX8907 is not set
+# CONFIG_MFD_MAX8925 is not set
+# CONFIG_MFD_MAX8997 is not set
+# CONFIG_MFD_MAX8998 is not set
+# CONFIG_MFD_MT6360 is not set
+# CONFIG_MFD_MT6370 is not set
+# CONFIG_MFD_MT6397 is not set
+# CONFIG_MFD_MENF21BMC is not set
+# CONFIG_MFD_NCT6694 is not set
+# CONFIG_MFD_OCELOT is not set
+# CONFIG_MFD_CPCAP is not set
+# CONFIG_MFD_VIPERBOARD is not set
+# CONFIG_MFD_NTXEC is not set
+# CONFIG_MFD_RETU is not set
+CONFIG_MFD_QCOM_RPM=y
+CONFIG_MFD_SPMI_PMIC=y
+# CONFIG_MFD_SY7636A is not set
+# CONFIG_MFD_RT4831 is not set
+# CONFIG_MFD_RT5033 is not set
+# CONFIG_MFD_RT5120 is not set
+# CONFIG_MFD_RC5T583 is not set
+# CONFIG_MFD_RK8XX_I2C is not set
+# CONFIG_MFD_RK8XX_SPI is not set
+# CONFIG_MFD_RN5T618 is not set
+# CONFIG_MFD_SEC_I2C is not set
+# CONFIG_MFD_SI476X_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_MFD_SKY81452 is not set
+CONFIG_MFD_STMPE=y
+
+#
+# STMicroelectronics STMPE Interface Drivers
+#
+CONFIG_STMPE_I2C=y
+# CONFIG_STMPE_SPI is not set
+# end of STMicroelectronics STMPE Interface Drivers
+
+CONFIG_MFD_SYSCON=y
+# CONFIG_MFD_LP3943 is not set
+# CONFIG_MFD_LP8788 is not set
+# CONFIG_MFD_TI_LMU is not set
+# CONFIG_MFD_BQ257XX is not set
+# CONFIG_MFD_PALMAS is not set
+# CONFIG_TPS6105X is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TPS6507X is not set
+# CONFIG_MFD_TPS65086 is not set
+# CONFIG_MFD_TPS65090 is not set
+# CONFIG_MFD_TPS65217 is not set
+# CONFIG_MFD_TI_LP873X is not set
+# CONFIG_MFD_TI_LP87565 is not set
+# CONFIG_MFD_TPS65218 is not set
+# CONFIG_MFD_TPS65219 is not set
+# CONFIG_MFD_TPS6586X is not set
+# CONFIG_MFD_TPS65910 is not set
+# CONFIG_MFD_TPS65912_I2C is not set
+# CONFIG_MFD_TPS65912_SPI is not set
+# CONFIG_MFD_TPS6594_I2C is not set
+# CONFIG_MFD_TPS6594_SPI is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_TWL6040_CORE is not set
+# CONFIG_MFD_LM3533 is not set
+# CONFIG_MFD_TC3589X is not set
+# CONFIG_MFD_TQMX86 is not set
+# CONFIG_MFD_ARIZONA_I2C is not set
+# CONFIG_MFD_ARIZONA_SPI is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X_I2C is not set
+# CONFIG_MFD_WM831X_SPI is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_WM8994 is not set
+# CONFIG_MFD_ROHM_BD718XX is not set
+# CONFIG_MFD_ROHM_BD71828 is not set
+# CONFIG_MFD_ROHM_BD957XMUF is not set
+# CONFIG_MFD_ROHM_BD96801 is not set
+# CONFIG_MFD_STPMIC1 is not set
+# CONFIG_MFD_STMFX is not set
+# CONFIG_MFD_WCD934X is not set
+# CONFIG_MFD_ATC260X_I2C is not set
+# CONFIG_MFD_QCOM_PM8008 is not set
+# CONFIG_RAVE_SP_CORE is not set
+# CONFIG_MFD_INTEL_M10_BMC_SPI is not set
+# CONFIG_MFD_QNAP_MCU is not set
+# CONFIG_MFD_RSMU_I2C is not set
+# CONFIG_MFD_RSMU_SPI is not set
+# CONFIG_MFD_MAX7360 is not set
+# end of Multifunction device drivers
+
+CONFIG_REGULATOR=y
+# CONFIG_REGULATOR_DEBUG is not set
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
+# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set
+CONFIG_REGULATOR_NETLINK_EVENTS=y
+# CONFIG_REGULATOR_88PG86X is not set
+# CONFIG_REGULATOR_ACT8865 is not set
+# CONFIG_REGULATOR_AD5398 is not set
+# CONFIG_REGULATOR_ADP5055 is not set
+# CONFIG_REGULATOR_AW37503 is not set
+# CONFIG_REGULATOR_DA9121 is not set
+# CONFIG_REGULATOR_DA9210 is not set
+# CONFIG_REGULATOR_DA9211 is not set
+# CONFIG_REGULATOR_FAN53555 is not set
+# CONFIG_REGULATOR_FAN53880 is not set
+# CONFIG_REGULATOR_GPIO is not set
+# CONFIG_REGULATOR_ISL9305 is not set
+# CONFIG_REGULATOR_ISL6271A is not set
+# CONFIG_REGULATOR_FP9931 is not set
+# CONFIG_REGULATOR_LP3971 is not set
+# CONFIG_REGULATOR_LP3972 is not set
+# CONFIG_REGULATOR_LP872X is not set
+# CONFIG_REGULATOR_LP8755 is not set
+# CONFIG_REGULATOR_LTC3589 is not set
+# CONFIG_REGULATOR_LTC3676 is not set
+# CONFIG_REGULATOR_MAX1586 is not set
+# CONFIG_REGULATOR_MAX77503 is not set
+# CONFIG_REGULATOR_MAX77675 is not set
+# CONFIG_REGULATOR_MAX77857 is not set
+# CONFIG_REGULATOR_MAX8649 is not set
+# CONFIG_REGULATOR_MAX8660 is not set
+# CONFIG_REGULATOR_MAX8893 is not set
+# CONFIG_REGULATOR_MAX8952 is not set
+# CONFIG_REGULATOR_MAX8973 is not set
+# CONFIG_REGULATOR_MAX20086 is not set
+# CONFIG_REGULATOR_MAX20411 is not set
+# CONFIG_REGULATOR_MAX77826 is not set
+# CONFIG_REGULATOR_MAX77838 is not set
+# CONFIG_REGULATOR_MCP16502 is not set
+# CONFIG_REGULATOR_MP5416 is not set
+# CONFIG_REGULATOR_MP8859 is not set
+# CONFIG_REGULATOR_MP886X is not set
+# CONFIG_REGULATOR_MPQ7920 is not set
+# CONFIG_REGULATOR_MT6311 is not set
+# CONFIG_REGULATOR_MT6315 is not set
+# CONFIG_REGULATOR_MT6316 is not set
+# CONFIG_REGULATOR_MT6363 is not set
+# CONFIG_REGULATOR_PCA9450 is not set
+# CONFIG_REGULATOR_PF9453 is not set
+# CONFIG_REGULATOR_PF0900 is not set
+# CONFIG_REGULATOR_PF530X is not set
+# CONFIG_REGULATOR_PF8X00 is not set
+# CONFIG_REGULATOR_PFUZE100 is not set
+# CONFIG_REGULATOR_PV88060 is not set
+# CONFIG_REGULATOR_PV88080 is not set
+# CONFIG_REGULATOR_PV88090 is not set
+CONFIG_REGULATOR_PWM=y
+CONFIG_REGULATOR_QCOM_REFGEN=m
+# CONFIG_REGULATOR_QCOM_RPM is not set
+CONFIG_REGULATOR_QCOM_RPMH=y
+CONFIG_REGULATOR_QCOM_SMD_RPM=y
+CONFIG_REGULATOR_QCOM_SPMI=y
+CONFIG_REGULATOR_QCOM_USB_VBUS=y
+# CONFIG_REGULATOR_RAA215300 is not set
+# CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY is not set
+# CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_V2 is not set
+# CONFIG_REGULATOR_RT4801 is not set
+# CONFIG_REGULATOR_RT4803 is not set
+# CONFIG_REGULATOR_RT5133 is not set
+# CONFIG_REGULATOR_RT5190A is not set
+# CONFIG_REGULATOR_RT5739 is not set
+# CONFIG_REGULATOR_RT5759 is not set
+# CONFIG_REGULATOR_RT6160 is not set
+# CONFIG_REGULATOR_RT6190 is not set
+# CONFIG_REGULATOR_RT6245 is not set
+# CONFIG_REGULATOR_RT8092 is not set
+# CONFIG_REGULATOR_RTQ2134 is not set
+# CONFIG_REGULATOR_RTMV20 is not set
+# CONFIG_REGULATOR_RTQ6752 is not set
+# CONFIG_REGULATOR_RTQ2208 is not set
+# CONFIG_REGULATOR_SGM3804 is not set
+# CONFIG_REGULATOR_SLG51000 is not set
+# CONFIG_REGULATOR_SY8106A is not set
+# CONFIG_REGULATOR_SY8824X is not set
+# CONFIG_REGULATOR_SY8827N is not set
+# CONFIG_REGULATOR_TPS51632 is not set
+# CONFIG_REGULATOR_TPS62360 is not set
+# CONFIG_REGULATOR_TPS6286X is not set
+# CONFIG_REGULATOR_TPS6287X is not set
+# CONFIG_REGULATOR_TPS65023 is not set
+# CONFIG_REGULATOR_TPS6507X is not set
+# CONFIG_REGULATOR_TPS65132 is not set
+# CONFIG_REGULATOR_TPS65185 is not set
+# CONFIG_REGULATOR_TPS6524X is not set
+# CONFIG_REGULATOR_VCTRL is not set
+# CONFIG_REGULATOR_VQMMC_IPQ4019 is not set
+CONFIG_REGULATOR_QCOM_LABIBB=m
+# CONFIG_RC_CORE is not set
+CONFIG_CEC_CORE=m
+
+#
+# CEC support
+#
+# CONFIG_MEDIA_CEC_SUPPORT is not set
+# end of CEC support
+
+CONFIG_MEDIA_SUPPORT=m
+CONFIG_MEDIA_SUPPORT_FILTER=y
+CONFIG_MEDIA_SUBDRV_AUTOSELECT=y
+
+#
+# Media device types
+#
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+# CONFIG_MEDIA_ANALOG_TV_SUPPORT is not set
+# CONFIG_MEDIA_DIGITAL_TV_SUPPORT is not set
+# CONFIG_MEDIA_RADIO_SUPPORT is not set
+# CONFIG_MEDIA_SDR_SUPPORT is not set
+CONFIG_MEDIA_PLATFORM_SUPPORT=y
+# CONFIG_MEDIA_TEST_SUPPORT is not set
+# end of Media device types
+
+CONFIG_VIDEO_DEV=m
+CONFIG_MEDIA_CONTROLLER=y
+
+#
+# Video4Linux options
+#
+CONFIG_VIDEO_V4L2_I2C=y
+CONFIG_VIDEO_V4L2_SUBDEV_API=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
+CONFIG_V4L2_MEM2MEM_DEV=m
+# CONFIG_V4L2_FLASH_LED_CLASS is not set
+CONFIG_V4L2_FWNODE=m
+CONFIG_V4L2_ASYNC=m
+# end of Video4Linux options
+
+#
+# Media controller options
+#
+# end of Media controller options
+
+#
+# Media drivers
+#
+
+#
+# Drivers filtered as selected at 'Filter media drivers'
+#
+
+#
+# Media drivers
+#
+# CONFIG_MEDIA_USB_SUPPORT is not set
+CONFIG_MEDIA_PLATFORM_DRIVERS=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_V4L_MEM2MEM_DRIVERS=y
+# CONFIG_VIDEO_MEM2MEM_DEINTERLACE is not set
+# CONFIG_VIDEO_MUX is not set
+
+#
+# Allegro DVT media platform drivers
+#
+
+#
+# Amlogic media platform drivers
+#
+
+#
+# Amphion drivers
+#
+
+#
+# ARM media platform drivers
+#
+
+#
+# Aspeed media platform drivers
+#
+
+#
+# Atmel media platform drivers
+#
+
+#
+# Cadence media platform drivers
+#
+# CONFIG_VIDEO_CADENCE_CSI2RX is not set
+# CONFIG_VIDEO_CADENCE_CSI2TX is not set
+
+#
+# Chips&Media media platform drivers
+#
+
+#
+# Intel media platform drivers
+#
+
+#
+# Marvell media platform drivers
+#
+
+#
+# Mediatek media platform drivers
+#
+
+#
+# Microchip Technology, Inc. media platform drivers
+#
+
+#
+# Nuvoton media platform drivers
+#
+
+#
+# NVidia media platform drivers
+#
+
+#
+# NXP media platform drivers
+#
+
+#
+# Qualcomm media platform drivers
+#
+CONFIG_VIDEO_QCOM_CAMSS=m
+# CONFIG_VIDEO_QCOM_IRIS is not set
+CONFIG_VIDEO_QCOM_VENUS=m
+
+#
+# Raspberry Pi media platform drivers
+#
+# CONFIG_VIDEO_RP1_CFE is not set
+
+#
+# Renesas media platform drivers
+#
+
+#
+# Rockchip media platform drivers
+#
+
+#
+# Samsung media platform drivers
+#
+
+#
+# STMicroelectronics media platform drivers
+#
+
+#
+# Sunxi media platform drivers
+#
+
+#
+# Texas Instruments drivers
+#
+
+#
+# Verisilicon media platform drivers
+#
+
+#
+# VIA media platform drivers
+#
+
+#
+# Xilinx media platform drivers
+#
+# CONFIG_VIDEO_XILINX is not set
+CONFIG_UVC_COMMON=m
+CONFIG_VIDEOBUF2_CORE=m
+CONFIG_VIDEOBUF2_V4L2=m
+CONFIG_VIDEOBUF2_MEMOPS=m
+CONFIG_VIDEOBUF2_DMA_CONTIG=m
+CONFIG_VIDEOBUF2_VMALLOC=m
+CONFIG_VIDEOBUF2_DMA_SG=m
+# end of Media drivers
+
+CONFIG_MEDIA_HIDE_ANCILLARY_SUBDRV=y
+
+#
+# Media ancillary drivers
+#
+CONFIG_VIDEO_CAMERA_SENSOR=y
+# CONFIG_VIDEO_ALVIUM_CSI2 is not set
+# CONFIG_VIDEO_AR0521 is not set
+# CONFIG_VIDEO_GC0308 is not set
+# CONFIG_VIDEO_GC0310 is not set
+# CONFIG_VIDEO_GC05A2 is not set
+# CONFIG_VIDEO_GC08A3 is not set
+# CONFIG_VIDEO_GC2145 is not set
+# CONFIG_VIDEO_HI556 is not set
+# CONFIG_VIDEO_HI846 is not set
+# CONFIG_VIDEO_HI847 is not set
+# CONFIG_VIDEO_IMX111 is not set
+# CONFIG_VIDEO_IMX208 is not set
+# CONFIG_VIDEO_IMX214 is not set
+# CONFIG_VIDEO_IMX219 is not set
+# CONFIG_VIDEO_IMX258 is not set
+# CONFIG_VIDEO_IMX274 is not set
+# CONFIG_VIDEO_IMX283 is not set
+# CONFIG_VIDEO_IMX290 is not set
+# CONFIG_VIDEO_IMX296 is not set
+# CONFIG_VIDEO_IMX319 is not set
+# CONFIG_VIDEO_IMX334 is not set
+# CONFIG_VIDEO_IMX335 is not set
+# CONFIG_VIDEO_IMX355 is not set
+# CONFIG_VIDEO_IMX412 is not set
+# CONFIG_VIDEO_IMX415 is not set
+# CONFIG_VIDEO_MT9M001 is not set
+# CONFIG_VIDEO_MT9M111 is not set
+# CONFIG_VIDEO_MT9M114 is not set
+# CONFIG_VIDEO_MT9P031 is not set
+# CONFIG_VIDEO_MT9T112 is not set
+# CONFIG_VIDEO_MT9V011 is not set
+# CONFIG_VIDEO_MT9V032 is not set
+# CONFIG_VIDEO_MT9V111 is not set
+# CONFIG_VIDEO_OG01A1B is not set
+# CONFIG_VIDEO_OG0VE1B is not set
+# CONFIG_VIDEO_OS05B10 is not set
+# CONFIG_VIDEO_OV01A10 is not set
+# CONFIG_VIDEO_OV02A10 is not set
+# CONFIG_VIDEO_OV02E10 is not set
+# CONFIG_VIDEO_OV02C10 is not set
+# CONFIG_VIDEO_OV08D10 is not set
+# CONFIG_VIDEO_OV08X40 is not set
+# CONFIG_VIDEO_OV13858 is not set
+# CONFIG_VIDEO_OV13B10 is not set
+# CONFIG_VIDEO_OV2640 is not set
+# CONFIG_VIDEO_OV2659 is not set
+# CONFIG_VIDEO_OV2680 is not set
+# CONFIG_VIDEO_OV2685 is not set
+# CONFIG_VIDEO_OV2732 is not set
+# CONFIG_VIDEO_OV2735 is not set
+# CONFIG_VIDEO_OV4689 is not set
+# CONFIG_VIDEO_OV5640 is not set
+# CONFIG_VIDEO_OV5645 is not set
+# CONFIG_VIDEO_OV5647 is not set
+# CONFIG_VIDEO_OV5648 is not set
+# CONFIG_VIDEO_OV5670 is not set
+# CONFIG_VIDEO_OV5675 is not set
+# CONFIG_VIDEO_OV5693 is not set
+# CONFIG_VIDEO_OV5695 is not set
+# CONFIG_VIDEO_OV6211 is not set
+# CONFIG_VIDEO_OV64A40 is not set
+# CONFIG_VIDEO_OV7251 is not set
+# CONFIG_VIDEO_OV7640 is not set
+# CONFIG_VIDEO_OV7670 is not set
+# CONFIG_VIDEO_OV772X is not set
+# CONFIG_VIDEO_OV7740 is not set
+# CONFIG_VIDEO_OV8856 is not set
+# CONFIG_VIDEO_OV8858 is not set
+# CONFIG_VIDEO_OV8865 is not set
+# CONFIG_VIDEO_OV9282 is not set
+# CONFIG_VIDEO_OV9640 is not set
+# CONFIG_VIDEO_OV9650 is not set
+# CONFIG_VIDEO_RDACM20 is not set
+# CONFIG_VIDEO_RDACM21 is not set
+# CONFIG_VIDEO_RJ54N1 is not set
+# CONFIG_VIDEO_S5C73M3 is not set
+# CONFIG_VIDEO_S5K3M5 is not set
+# CONFIG_VIDEO_S5K5BAF is not set
+# CONFIG_VIDEO_S5K6A3 is not set
+# CONFIG_VIDEO_S5KJN1 is not set
+# CONFIG_VIDEO_VD55G1 is not set
+# CONFIG_VIDEO_VD56G3 is not set
+# CONFIG_VIDEO_VGXY61 is not set
+# CONFIG_VIDEO_CCS is not set
+# CONFIG_VIDEO_ET8EK8 is not set
+
+#
+# Camera ISPs
+#
+# CONFIG_VIDEO_THP7312 is not set
+# end of Camera ISPs
+
+CONFIG_VIDEO_CAMERA_LENS=y
+# CONFIG_VIDEO_AD5820 is not set
+# CONFIG_VIDEO_AK7375 is not set
+# CONFIG_VIDEO_DW9714 is not set
+# CONFIG_VIDEO_DW9719 is not set
+# CONFIG_VIDEO_DW9768 is not set
+# CONFIG_VIDEO_DW9807_VCM is not set
+
+#
+# Flash devices
+#
+# CONFIG_VIDEO_ADP1653 is not set
+# CONFIG_VIDEO_LM3560 is not set
+# CONFIG_VIDEO_LM3646 is not set
+# end of Flash devices
+
+#
+# audio, video and radio I2C drivers auto-selected by 'Autoselect ancillary drivers'
+#
+
+#
+# Video and audio decoders
+#
+
+#
+# Video serializers and deserializers
+#
+# CONFIG_VIDEO_DS90UB913 is not set
+# CONFIG_VIDEO_DS90UB953 is not set
+# CONFIG_VIDEO_DS90UB960 is not set
+# CONFIG_VIDEO_MAX96714 is not set
+# CONFIG_VIDEO_MAX96717 is not set
+# end of Video serializers and deserializers
+
+#
+# SPI I2C drivers auto-selected by 'Autoselect ancillary drivers'
+#
+
+#
+# Media SPI Adapters
+#
+# CONFIG_VIDEO_GS1662 is not set
+# end of Media SPI Adapters
+# end of Media ancillary drivers
+
+#
+# Graphics support
+#
+CONFIG_APERTURE_HELPERS=y
+CONFIG_SCREEN_INFO=y
+CONFIG_VIDEO=y
+# CONFIG_AUXDISPLAY is not set
+CONFIG_DRM=y
+
+#
+# DRM debugging options
+#
+# CONFIG_DRM_DEBUG_MM is not set
+# end of DRM debugging options
+
+CONFIG_DRM_MIPI_DSI=y
+CONFIG_DRM_KMS_HELPER=y
+CONFIG_DRM_DRAW=y
+CONFIG_DRM_PANIC=y
+CONFIG_DRM_PANIC_FOREGROUND_COLOR=0xffffff
+CONFIG_DRM_PANIC_BACKGROUND_COLOR=0x000000
+# CONFIG_DRM_PANIC_DEBUG is not set
+CONFIG_DRM_PANIC_SCREEN="kmsg"
+# CONFIG_DRM_RAS is not set
+CONFIG_DRM_CLIENT=y
+CONFIG_DRM_CLIENT_LIB=y
+CONFIG_DRM_CLIENT_SELECTION=y
+CONFIG_DRM_CLIENT_SETUP=y
+
+#
+# Supported DRM clients
+#
+CONFIG_DRM_FBDEV_EMULATION=y
+CONFIG_DRM_FBDEV_OVERALLOC=200
+# CONFIG_DRM_CLIENT_LOG is not set
+CONFIG_DRM_CLIENT_DEFAULT_FBDEV=y
+CONFIG_DRM_CLIENT_DEFAULT="fbdev"
+# end of Supported DRM clients
+
+# CONFIG_DRM_LOAD_EDID_FIRMWARE is not set
+CONFIG_DRM_DISPLAY_DP_AUX_BUS=m
+CONFIG_DRM_DISPLAY_HELPER=m
+CONFIG_DRM_BRIDGE_CONNECTOR=y
+# CONFIG_DRM_DISPLAY_DP_AUX_CEC is not set
+# CONFIG_DRM_DISPLAY_DP_AUX_CHARDEV is not set
+CONFIG_DRM_DISPLAY_DP_HELPER=y
+CONFIG_DRM_DISPLAY_DSC_HELPER=y
+CONFIG_DRM_DISPLAY_HDMI_AUDIO_HELPER=y
+CONFIG_DRM_DISPLAY_HDMI_CEC_HELPER=y
+CONFIG_DRM_DISPLAY_HDMI_HELPER=y
+CONFIG_DRM_DISPLAY_HDMI_STATE_HELPER=y
+CONFIG_DRM_EXEC=m
+CONFIG_DRM_GPUVM=m
+CONFIG_DRM_GEM_SHMEM_HELPER=y
+CONFIG_DRM_SCHED=m
+
+#
+# ARM devices
+#
+# CONFIG_DRM_HDLCD is not set
+# CONFIG_DRM_MALI_DISPLAY is not set
+# CONFIG_DRM_KOMEDA is not set
+# end of ARM devices
+
+CONFIG_DRM_BRIDGE=y
+CONFIG_DRM_PANEL_BRIDGE=y
+CONFIG_DRM_AUX_BRIDGE=y
+CONFIG_DRM_AUX_HPD_BRIDGE=m
+
+#
+# Display Interface Bridges
+#
+# CONFIG_DRM_CHIPONE_ICN6211 is not set
+# CONFIG_DRM_CHRONTEL_CH7033 is not set
+# CONFIG_DRM_DISPLAY_CONNECTOR is not set
+# CONFIG_DRM_I2C_NXP_TDA998X is not set
+# CONFIG_DRM_ITE_IT6263 is not set
+# CONFIG_DRM_ITE_IT6505 is not set
+# CONFIG_DRM_LONTIUM_LT8912B is not set
+# CONFIG_DRM_LONTIUM_LT9211 is not set
+# CONFIG_DRM_LONTIUM_LT9611 is not set
+# CONFIG_DRM_LONTIUM_LT9611UXC is not set
+# CONFIG_DRM_LONTIUM_LT8713SX is not set
+# CONFIG_DRM_ITE_IT66121 is not set
+# CONFIG_DRM_LVDS_CODEC is not set
+# CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW is not set
+# CONFIG_DRM_NWL_MIPI_DSI is not set
+# CONFIG_DRM_NXP_PTN3460 is not set
+# CONFIG_DRM_PARADE_PS8622 is not set
+# CONFIG_DRM_PARADE_PS8640 is not set
+# CONFIG_DRM_SAMSUNG_DSIM is not set
+# CONFIG_DRM_SIL_SII8620 is not set
+# CONFIG_DRM_SII902X is not set
+# CONFIG_DRM_SII9234 is not set
+# CONFIG_DRM_SIMPLE_BRIDGE is not set
+# CONFIG_DRM_SOLOMON_SSD2825 is not set
+# CONFIG_DRM_THINE_THC63LVD1024 is not set
+# CONFIG_DRM_TOSHIBA_TC358762 is not set
+# CONFIG_DRM_TOSHIBA_TC358764 is not set
+# CONFIG_DRM_TOSHIBA_TC358767 is not set
+# CONFIG_DRM_TOSHIBA_TC358768 is not set
+# CONFIG_DRM_TOSHIBA_TC358775 is not set
+# CONFIG_DRM_TI_DLPC3433 is not set
+# CONFIG_DRM_TI_TDP158 is not set
+# CONFIG_DRM_TI_TFP410 is not set
+# CONFIG_DRM_TI_SN65DSI83 is not set
+# CONFIG_DRM_TI_SN65DSI86 is not set
+# CONFIG_DRM_TI_TPD12S015 is not set
+# CONFIG_DRM_WAVESHARE_BRIDGE is not set
+# CONFIG_DRM_ANALOGIX_ANX6345 is not set
+# CONFIG_DRM_ANALOGIX_ANX78XX is not set
+# CONFIG_DRM_ANALOGIX_ANX7625 is not set
+# CONFIG_DRM_I2C_ADV7511 is not set
+# CONFIG_DRM_CDNS_DSI is not set
+# CONFIG_DRM_CDNS_MHDP8546 is not set
+# end of Display Interface Bridges
+
+# CONFIG_DRM_ETNAVIV is not set
+CONFIG_DRM_GUD=m
+# CONFIG_DRM_HISI_KIRIN is not set
+# CONFIG_DRM_POWERVR is not set
+# CONFIG_DRM_LIMA is not set
+# CONFIG_DRM_LOGICVC is not set
+CONFIG_DRM_MSM=m
+CONFIG_DRM_MSM_GPU_STATE=y
+CONFIG_DRM_MSM_KMS=y
+CONFIG_DRM_MSM_KMS_FBDEV=y
+CONFIG_DRM_MSM_MDSS=y
+# CONFIG_DRM_MSM_MDP4 is not set
+CONFIG_DRM_MSM_MDP5=y
+CONFIG_DRM_MSM_DPU=y
+CONFIG_DRM_MSM_DP=y
+CONFIG_DRM_MSM_DSI=y
+CONFIG_DRM_MSM_DSI_28NM_PHY=y
+CONFIG_DRM_MSM_DSI_20NM_PHY=y
+CONFIG_DRM_MSM_DSI_28NM_8960_PHY=y
+CONFIG_DRM_MSM_DSI_14NM_PHY=y
+CONFIG_DRM_MSM_DSI_10NM_PHY=y
+CONFIG_DRM_MSM_DSI_7NM_PHY=y
+# CONFIG_DRM_MSM_HDMI is not set
+CONFIG_DRM_PANEL=y
+
+#
+# Display Panels
+#
+# CONFIG_DRM_PANEL_ABT_Y030XX067A is not set
+# CONFIG_DRM_PANEL_ARM_VERSATILE is not set
+# CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596 is not set
+# CONFIG_DRM_PANEL_AUO_A030JTN01 is not set
+# CONFIG_DRM_PANEL_BOE_BF060Y8M_AJ0 is not set
+CONFIG_DRM_PANEL_BOE_BV045FHM_L00=m
+# CONFIG_DRM_PANEL_BOE_HIMAX8279D is not set
+# CONFIG_DRM_PANEL_BOE_TD4320 is not set
+# CONFIG_DRM_PANEL_BOE_TH101MB31UIG002_28A is not set
+# CONFIG_DRM_PANEL_BOE_TV101WUM_NL6 is not set
+# CONFIG_DRM_PANEL_BOE_TV101WUM_LL2 is not set
+# CONFIG_DRM_PANEL_CHIPWEALTH_CH13726A is not set
+# CONFIG_DRM_PANEL_EBBG_FT8719 is not set
+# CONFIG_DRM_PANEL_ELIDA_KD35T133 is not set
+CONFIG_DRM_PANEL_FT8716U=m
+# CONFIG_DRM_PANEL_FEIXIN_K101_IM2BA02 is not set
+# CONFIG_DRM_PANEL_FEIYANG_FY07024DI26A30D is not set
+# CONFIG_DRM_PANEL_FOCALTECH_OTA7290B is not set
+CONFIG_DRM_PANEL_DSI_CM=y
+# CONFIG_DRM_PANEL_LVDS is not set
+# CONFIG_DRM_PANEL_HIMAX_HX8279 is not set
+# CONFIG_DRM_PANEL_HIMAX_HX83102 is not set
+# CONFIG_DRM_PANEL_HIMAX_HX83112A is not set
+# CONFIG_DRM_PANEL_HIMAX_HX83112B is not set
+# CONFIG_DRM_PANEL_HIMAX_HX83121A is not set
+# CONFIG_DRM_PANEL_HIMAX_HX8394 is not set
+# CONFIG_DRM_PANEL_HYDIS_HV101HD1 is not set
+# CONFIG_DRM_PANEL_ILITEK_IL9322 is not set
+# CONFIG_DRM_PANEL_ILITEK_ILI9341 is not set
+# CONFIG_DRM_PANEL_ILITEK_ILI9805 is not set
+# CONFIG_DRM_PANEL_ILITEK_ILI9806E_DSI is not set
+# CONFIG_DRM_PANEL_ILITEK_ILI9806E_SPI is not set
+# CONFIG_DRM_PANEL_ILITEK_ILI9881C is not set
+# CONFIG_DRM_PANEL_ILITEK_ILI9882T is not set
+# CONFIG_DRM_PANEL_INNOLUX_EJ030NA is not set
+# CONFIG_DRM_PANEL_INNOLUX_P079ZCA is not set
+# CONFIG_DRM_PANEL_JADARD_JD9365DA_H3 is not set
+# CONFIG_DRM_PANEL_JDI_LPM102A188A is not set
+# CONFIG_DRM_PANEL_JDI_LT070ME05000 is not set
+# CONFIG_DRM_PANEL_JDI_R63452 is not set
+# CONFIG_DRM_PANEL_KHADAS_TS050 is not set
+# CONFIG_DRM_PANEL_KINGDISPLAY_KD097D04 is not set
+# CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W is not set
+# CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829 is not set
+# CONFIG_DRM_PANEL_LINCOLNTECH_LCD197 is not set
+# CONFIG_DRM_PANEL_LG_LB035Q02 is not set
+# CONFIG_DRM_PANEL_LG_LD070WX3 is not set
+# CONFIG_DRM_PANEL_LG_LG4573 is not set
+# CONFIG_DRM_PANEL_LG_SW43408 is not set
+# CONFIG_DRM_PANEL_LXD_M9189A is not set
+# CONFIG_DRM_PANEL_MAGNACHIP_D53E6EA8966 is not set
+# CONFIG_DRM_PANEL_MANTIX_MLAF057WE51 is not set
+# CONFIG_DRM_PANEL_MOTOROLA_MOT is not set
+# CONFIG_DRM_PANEL_NEC_NL8048HL11 is not set
+# CONFIG_DRM_PANEL_NEWVISION_NV3051D is not set
+# CONFIG_DRM_PANEL_NEWVISION_NV3052C is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT35510 is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT35532 is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT35560 is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT35950 is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT36523 is not set
+CONFIG_DRM_PANEL_NOVATEK_NT36672A=m
+# CONFIG_DRM_PANEL_NOVATEK_NT36672E is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT37700F is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT37801 is not set
+# CONFIG_DRM_PANEL_NOVATEK_NT39016 is not set
+CONFIG_DRM_PANEL_NOVATEK_NT51021=m
+# CONFIG_DRM_PANEL_OLIMEX_LCD_OLINUXINO is not set
+# CONFIG_DRM_PANEL_ORISETECH_OTA5601A is not set
+# CONFIG_DRM_PANEL_ORISETECH_OTM8009A is not set
+# CONFIG_DRM_PANEL_OSD_OSD101T2587_53TS is not set
+# CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00 is not set
+# CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN is not set
+# CONFIG_DRM_PANEL_RAYDIUM_RM67191 is not set
+# CONFIG_DRM_PANEL_RAYDIUM_RM67200 is not set
+# CONFIG_DRM_PANEL_RAYDIUM_RM68200 is not set
+# CONFIG_DRM_PANEL_RAYDIUM_RM692E5 is not set
+# CONFIG_DRM_PANEL_RAYDIUM_RM69380 is not set
+# CONFIG_DRM_PANEL_RENESAS_R61307 is not set
+# CONFIG_DRM_PANEL_RENESAS_R69328 is not set
+# CONFIG_DRM_PANEL_RONBO_RB070D30 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_AMS581VF01 is not set
+CONFIG_DRM_PANEL_SAMSUNG_AMS601NT12=m
+# CONFIG_DRM_PANEL_SAMSUNG_AMS639RQ08 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS427AP24 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E88A0_AMS452EF01 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_ATNA33XC20 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_DB7430 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_LD9040 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_LTL106HL02 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E3FA7 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6D16D0 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6D27A1 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6D7AA0 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E3FC2X01 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E3HA2 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E3HA8 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E63M0 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E8AA5X01_AMS561RA01 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_S6E8FC0 is not set
+# CONFIG_DRM_PANEL_SAMSUNG_SOFEF00 is not set
+# CONFIG_DRM_PANEL_SEIKO_43WVF1G is not set
+# CONFIG_DRM_PANEL_SHARP_LQ079L1SX01 is not set
+# CONFIG_DRM_PANEL_SHARP_LQ101R1SX01 is not set
+# CONFIG_DRM_PANEL_SHARP_LS037V7DW01 is not set
+# CONFIG_DRM_PANEL_SHARP_LS043T1LE01 is not set
+# CONFIG_DRM_PANEL_SHARP_LS060T1SX01 is not set
+# CONFIG_DRM_PANEL_SITRONIX_ST7701 is not set
+# CONFIG_DRM_PANEL_SITRONIX_ST7703 is not set
+# CONFIG_DRM_PANEL_SITRONIX_ST7789V is not set
+# CONFIG_DRM_PANEL_SONY_ACX565AKM is not set
+# CONFIG_DRM_PANEL_SONY_TD4353_JDI is not set
+# CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521 is not set
+# CONFIG_DRM_PANEL_STARTEK_KD070FHFID015 is not set
+# CONFIG_DRM_PANEL_EDP is not set
+CONFIG_DRM_PANEL_SIMPLE=y
+# CONFIG_DRM_PANEL_SUMMIT is not set
+# CONFIG_DRM_PANEL_SYNAPTICS_R63353 is not set
+# CONFIG_DRM_PANEL_SYNAPTICS_TDDI is not set
+CONFIG_DRM_PANEL_SYNAPTICS_TD4310=m
+# CONFIG_DRM_PANEL_TDO_TL070WSH30 is not set
+CONFIG_DRM_PANEL_TIANMA_TD4310=m
+# CONFIG_DRM_PANEL_TPO_TD028TTEC1 is not set
+# CONFIG_DRM_PANEL_TPO_TD043MTEA1 is not set
+# CONFIG_DRM_PANEL_TPO_TPG110 is not set
+# CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA is not set
+CONFIG_DRM_PANEL_TRULY_TD4322=m
+# CONFIG_DRM_PANEL_VISIONOX_G2647FB105 is not set
+# CONFIG_DRM_PANEL_VISIONOX_R66451 is not set
+# CONFIG_DRM_PANEL_VISIONOX_RM69299 is not set
+# CONFIG_DRM_PANEL_VISIONOX_RM692E5 is not set
+# CONFIG_DRM_PANEL_VISIONOX_VTDR6130 is not set
+# CONFIG_DRM_PANEL_WIDECHIPS_WS2401 is not set
+# CONFIG_DRM_PANEL_XINPENG_XPP055C272 is not set
+# end of Display Panels
+
+# CONFIG_DRM_PANFROST is not set
+# CONFIG_DRM_PANTHOR is not set
+# CONFIG_DRM_PL111 is not set
+# CONFIG_DRM_ST7571 is not set
+# CONFIG_DRM_ST7586 is not set
+# CONFIG_DRM_ST7735R is not set
+# CONFIG_DRM_ST7920 is not set
+# CONFIG_DRM_SSD130X is not set
+
+#
+# Drivers for system framebuffers
+#
+CONFIG_DRM_SYSFB_HELPER=y
+CONFIG_DRM_EFIDRM=m
+CONFIG_DRM_SIMPLEDRM=y
+# end of Drivers for system framebuffers
+
+# CONFIG_DRM_TIDSS is not set
+# CONFIG_DRM_ARCPGU is not set
+# CONFIG_DRM_GM12U320 is not set
+# CONFIG_DRM_PANEL_MIPI_DBI is not set
+# CONFIG_DRM_PIXPAPER is not set
+# CONFIG_TINYDRM_HX8357D is not set
+# CONFIG_TINYDRM_ILI9163 is not set
+# CONFIG_TINYDRM_ILI9225 is not set
+# CONFIG_TINYDRM_ILI9341 is not set
+# CONFIG_TINYDRM_ILI9486 is not set
+# CONFIG_TINYDRM_MI0283QT is not set
+# CONFIG_TINYDRM_REPAPER is not set
+# CONFIG_TINYDRM_SHARP_MEMORY is not set
+CONFIG_DRM_UDL=m
+# CONFIG_DRM_VGEM is not set
+# CONFIG_DRM_VIRTIO_GPU is not set
+# CONFIG_DRM_VKMS is not set
+CONFIG_DRM_PANEL_ORIENTATION_QUIRKS=y
+
+#
+# Frame buffer Devices
+#
+CONFIG_FB=y
+# CONFIG_FB_UVESA is not set
+# CONFIG_FB_EFI is not set
+# CONFIG_FB_OPENCORES is not set
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_SMSCUFX is not set
+# CONFIG_FB_UDL is not set
+# CONFIG_FB_IBM_GXT4500 is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_SSD1307 is not set
+CONFIG_FB_CORE=y
+CONFIG_FB_NOTIFY=y
+CONFIG_FB_DEVICE=y
+CONFIG_FB_SYS_FILLRECT=y
+CONFIG_FB_SYS_COPYAREA=y
+CONFIG_FB_SYS_IMAGEBLIT=y
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+CONFIG_FB_SYSMEM_FOPS=y
+CONFIG_FB_DEFERRED_IO=y
+CONFIG_FB_SYSMEM_HELPERS=y
+CONFIG_FB_SYSMEM_HELPERS_DEFERRED=y
+# CONFIG_FB_TILEBLITTING is not set
+# end of Frame buffer Devices
+
+#
+# Backlight & LCD device support
+#
+CONFIG_LCD_CLASS_DEVICE=m
+# CONFIG_LCD_L4F00242T03 is not set
+# CONFIG_LCD_LMS283GF05 is not set
+# CONFIG_LCD_LTV350QV is not set
+# CONFIG_LCD_ILI922X is not set
+# CONFIG_LCD_ILI9320 is not set
+# CONFIG_LCD_TDO24M is not set
+# CONFIG_LCD_VGG2432A4 is not set
+# CONFIG_LCD_PLATFORM is not set
+# CONFIG_LCD_AMS369FG06 is not set
+# CONFIG_LCD_LMS501KF03 is not set
+# CONFIG_LCD_HX8357 is not set
+# CONFIG_LCD_OTM3225A is not set
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+# CONFIG_BACKLIGHT_AW99706 is not set
+# CONFIG_BACKLIGHT_KTD253 is not set
+# CONFIG_BACKLIGHT_KTD2801 is not set
+# CONFIG_BACKLIGHT_KTZ8866 is not set
+CONFIG_BACKLIGHT_PWM=y
+# CONFIG_BACKLIGHT_MAX25014 is not set
+CONFIG_BACKLIGHT_QCOM_WLED=y
+# CONFIG_BACKLIGHT_ADP8860 is not set
+# CONFIG_BACKLIGHT_ADP8870 is not set
+# CONFIG_BACKLIGHT_LM3509 is not set
+# CONFIG_BACKLIGHT_LM3630A is not set
+# CONFIG_BACKLIGHT_LM3639 is not set
+CONFIG_BACKLIGHT_LP855X=y
+# CONFIG_BACKLIGHT_MP3309C is not set
+# CONFIG_BACKLIGHT_GPIO is not set
+# CONFIG_BACKLIGHT_LV5207LP is not set
+# CONFIG_BACKLIGHT_BD6107 is not set
+# CONFIG_BACKLIGHT_ARCXCNN is not set
+# CONFIG_BACKLIGHT_LED is not set
+# end of Backlight & LCD device support
+
+CONFIG_VIDEOMODE_HELPERS=y
+CONFIG_HDMI=y
+# CONFIG_FIRMWARE_EDID is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_DUMMY_CONSOLE_COLUMNS=80
+CONFIG_DUMMY_CONSOLE_ROWS=25
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION is not set
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y
+# end of Console display driver support
+
+CONFIG_LOGO=y
+CONFIG_LOGO_LINUX_MONO=y
+CONFIG_LOGO_LINUX_MONO_FILE="drivers/video/logo/logo_linux_mono.pbm"
+CONFIG_LOGO_LINUX_VGA16=y
+CONFIG_LOGO_LINUX_VGA16_FILE="drivers/video/logo/logo_linux_vga16.ppm"
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_LOGO_LINUX_CLUT224_FILE="drivers/video/logo/logo_linux_clut224.ppm"
+CONFIG_TRACE_GPU_MEM=y
+# end of Graphics support
+
+CONFIG_DRM_ACCEL=y
+# CONFIG_DRM_ACCEL_ARM_ETHOSU is not set
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_PCM_ELD=y
+CONFIG_SND_PCM_IEC958=y
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_UMP=m
+CONFIG_SND_UMP_LEGACY_RAWMIDI=y
+CONFIG_SND_COMPRESS_OFFLOAD=m
+CONFIG_SND_JACK=y
+CONFIG_SND_JACK_INPUT_DEV=y
+# CONFIG_SND_OSSEMUL is not set
+CONFIG_SND_PCM_TIMER=y
+# CONFIG_SND_HRTIMER is not set
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_MAX_CARDS=32
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_PROC_FS=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_CTL_FAST_LOOKUP=y
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_CTL_INPUT_VALIDATION is not set
+CONFIG_SND_UTIMER=y
+# CONFIG_SND_SEQUENCER is not set
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_DUMMY is not set
+# CONFIG_SND_ALOOP is not set
+# CONFIG_SND_PCMTEST is not set
+# CONFIG_SND_MTPAV is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+# CONFIG_SND_SERIAL_GENERIC is not set
+# CONFIG_SND_MPU401 is not set
+
+#
+# HD-Audio
+#
+# end of HD-Audio
+
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_AUDIO_MIDI_V2=y
+CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER=y
+# CONFIG_SND_USB_UA101 is not set
+# CONFIG_SND_USB_CAIAQ is not set
+# CONFIG_SND_USB_6FIRE is not set
+# CONFIG_SND_USB_HIFACE is not set
+# CONFIG_SND_BCD2000 is not set
+CONFIG_SND_USB_AUDIO_QMI=m
+# CONFIG_SND_USB_POD is not set
+# CONFIG_SND_USB_PODHD is not set
+# CONFIG_SND_USB_TONEPORT is not set
+# CONFIG_SND_USB_VARIAX is not set
+CONFIG_SND_SOC=m
+CONFIG_SND_SOC_COMPRESS=y
+CONFIG_SND_SOC_TOPOLOGY=y
+CONFIG_SND_SOC_USB=m
+
+#
+# Analog Devices
+#
+# CONFIG_SND_SOC_ADI_AXI_I2S is not set
+# CONFIG_SND_SOC_ADI_AXI_SPDIF is not set
+# end of Analog Devices
+
+#
+# AMD
+#
+# CONFIG_SND_SOC_AMD_ACP is not set
+# CONFIG_SND_AMD_ACP_CONFIG is not set
+# end of AMD
+
+#
+# Apple
+#
+# end of Apple
+
+#
+# Atmel
+#
+# CONFIG_SND_SOC_MIKROE_PROTO is not set
+# end of Atmel
+
+#
+# Au1x
+#
+# end of Au1x
+
+#
+# Broadcom
+#
+# CONFIG_SND_BCM63XX_I2S_WHISTLER is not set
+# end of Broadcom
+
+#
+# Cirrus Logic
+#
+# end of Cirrus Logic
+
+#
+# DesignWare
+#
+# CONFIG_SND_DESIGNWARE_I2S is not set
+# end of DesignWare
+
+#
+# Freescale
+#
+
+#
+# Common SoC Audio options for Freescale CPUs:
+#
+# CONFIG_SND_SOC_FSL_ASRC is not set
+# CONFIG_SND_SOC_FSL_SAI is not set
+# CONFIG_SND_SOC_FSL_AUDMIX is not set
+# CONFIG_SND_SOC_FSL_SSI is not set
+# CONFIG_SND_SOC_FSL_SPDIF is not set
+# CONFIG_SND_SOC_FSL_ESAI is not set
+# CONFIG_SND_SOC_FSL_MICFIL is not set
+# CONFIG_SND_SOC_FSL_XCVR is not set
+# CONFIG_SND_SOC_FSL_RPMSG is not set
+# CONFIG_SND_SOC_IMX_AUDMUX is not set
+# end of Freescale
+
+#
+# Google
+#
+# CONFIG_SND_SOC_CHV3_I2S is not set
+# end of Google
+
+#
+# Hisilicon
+#
+# CONFIG_SND_I2S_HI6210_I2S is not set
+# end of Hisilicon
+
+#
+# JZ4740
+#
+# end of JZ4740
+
+#
+# Kirkwood
+#
+# end of Kirkwood
+
+#
+# Loongson
+#
+# end of Loongson
+
+#
+# Intel
+#
+# end of Intel
+
+#
+# Mediatek
+#
+# CONFIG_SND_SOC_MTK_BTCVSD is not set
+# end of Mediatek
+
+#
+# PXA
+#
+# end of PXA
+
+CONFIG_SND_SOC_QCOM=m
+CONFIG_SND_SOC_LPASS_CPU=m
+CONFIG_SND_SOC_LPASS_PLATFORM=m
+CONFIG_SND_SOC_LPASS_APQ8016=m
+# CONFIG_SND_SOC_STORM is not set
+CONFIG_SND_SOC_APQ8016_SBC=m
+CONFIG_SND_SOC_QCOM_COMMON=m
+CONFIG_SND_SOC_QCOM_SDW=m
+CONFIG_SND_SOC_QDSP6_COMMON=m
+CONFIG_SND_SOC_QDSP6_CORE=m
+CONFIG_SND_SOC_QDSP6_AFE=m
+CONFIG_SND_SOC_QDSP6_AFE_DAI=m
+CONFIG_SND_SOC_QDSP6_AFE_CLOCKS=m
+CONFIG_SND_SOC_QDSP6_ADM=m
+CONFIG_SND_SOC_QDSP6_ROUTING=m
+CONFIG_SND_SOC_QDSP6_ASM=m
+CONFIG_SND_SOC_QDSP6_ASM_DAI=m
+CONFIG_SND_SOC_QDSP6_APM_DAI=m
+CONFIG_SND_SOC_QDSP6_APM_LPASS_DAI=m
+CONFIG_SND_SOC_QDSP6_APM=m
+CONFIG_SND_SOC_QDSP6_PRM_LPASS_CLOCKS=m
+CONFIG_SND_SOC_QDSP6_PRM=m
+CONFIG_SND_SOC_QCOM_OFFLOAD_UTILS=m
+CONFIG_SND_SOC_QDSP6_USB=m
+CONFIG_SND_SOC_QDSP6=m
+# CONFIG_SND_SOC_MSM8996 is not set
+# CONFIG_SND_SOC_SDM845 is not set
+CONFIG_SND_SOC_SM8250=m
+# CONFIG_SND_SOC_SC8280XP is not set
+# CONFIG_SND_SOC_SC7180 is not set
+# CONFIG_SND_SOC_SC7280 is not set
+# CONFIG_SND_SOC_X1E80100 is not set
+
+#
+# SoundWire (SDCA)
+#
+CONFIG_SND_SOC_SDCA_OPTIONAL=m
+# end of SoundWire (SDCA)
+
+#
+# ST SPEAr
+#
+# end of ST SPEAr
+
+#
+# Spreadtrum
+#
+# end of Spreadtrum
+
+#
+# STMicroelectronics STM32
+#
+# end of STMicroelectronics STM32
+
+#
+# Tegra
+#
+# end of Tegra
+
+#
+# Xilinx
+#
+# CONFIG_SND_SOC_XILINX_I2S is not set
+# CONFIG_SND_SOC_XILINX_AUDIO_FORMATTER is not set
+# CONFIG_SND_SOC_XILINX_SPDIF is not set
+# end of Xilinx
+
+#
+# Xtensa
+#
+# CONFIG_SND_SOC_XTFPGA_I2S is not set
+# end of Xtensa
+
+# CONFIG_SND_SOC_SOF_TOPLEVEL is not set
+CONFIG_SND_SOC_I2C_AND_SPI=m
+
+#
+# CODEC drivers
+#
+# CONFIG_SND_SOC_AC97_CODEC is not set
+# CONFIG_SND_SOC_ADAU1372_I2C is not set
+# CONFIG_SND_SOC_ADAU1372_SPI is not set
+# CONFIG_SND_SOC_ADAU1373 is not set
+# CONFIG_SND_SOC_ADAU1701 is not set
+# CONFIG_SND_SOC_ADAU1761_I2C is not set
+# CONFIG_SND_SOC_ADAU1761_SPI is not set
+# CONFIG_SND_SOC_ADAU7002 is not set
+# CONFIG_SND_SOC_ADAU7118_HW is not set
+# CONFIG_SND_SOC_ADAU7118_I2C is not set
+# CONFIG_SND_SOC_AK4104 is not set
+# CONFIG_SND_SOC_AK4118 is not set
+# CONFIG_SND_SOC_AK4375 is not set
+# CONFIG_SND_SOC_AK4458 is not set
+# CONFIG_SND_SOC_AK4554 is not set
+# CONFIG_SND_SOC_AK4613 is not set
+# CONFIG_SND_SOC_AK4619 is not set
+# CONFIG_SND_SOC_AK4642 is not set
+# CONFIG_SND_SOC_AK5386 is not set
+# CONFIG_SND_SOC_AK5558 is not set
+# CONFIG_SND_SOC_ALC5623 is not set
+# CONFIG_SND_SOC_AUDIO_IIO_AUX is not set
+# CONFIG_SND_SOC_AW8738 is not set
+# CONFIG_SND_SOC_AW88395 is not set
+# CONFIG_SND_SOC_AW88166 is not set
+# CONFIG_SND_SOC_AW88261 is not set
+# CONFIG_SND_SOC_AW88081 is not set
+# CONFIG_SND_SOC_AW87390 is not set
+# CONFIG_SND_SOC_AW88399 is not set
+# CONFIG_SND_SOC_BD28623 is not set
+# CONFIG_SND_SOC_BT_SCO is not set
+# CONFIG_SND_SOC_CHV3_CODEC is not set
+# CONFIG_SND_SOC_CS35L32 is not set
+# CONFIG_SND_SOC_CS35L33 is not set
+# CONFIG_SND_SOC_CS35L34 is not set
+# CONFIG_SND_SOC_CS35L35 is not set
+# CONFIG_SND_SOC_CS35L36 is not set
+# CONFIG_SND_SOC_CS35L41_SPI is not set
+# CONFIG_SND_SOC_CS35L41_I2C is not set
+# CONFIG_SND_SOC_CS35L45_SPI is not set
+# CONFIG_SND_SOC_CS35L45_I2C is not set
+# CONFIG_SND_SOC_CS35L56_I2C is not set
+# CONFIG_SND_SOC_CS35L56_SPI is not set
+# CONFIG_SND_SOC_CS35L56_SDW is not set
+# CONFIG_SND_SOC_CS42L42 is not set
+# CONFIG_SND_SOC_CS42L42_SDW is not set
+# CONFIG_SND_SOC_CS42L51_I2C is not set
+# CONFIG_SND_SOC_CS42L52 is not set
+# CONFIG_SND_SOC_CS42L56 is not set
+# CONFIG_SND_SOC_CS42L73 is not set
+# CONFIG_SND_SOC_CS42L83 is not set
+# CONFIG_SND_SOC_CS42L84 is not set
+# CONFIG_SND_SOC_CS4234 is not set
+# CONFIG_SND_SOC_CS4265 is not set
+# CONFIG_SND_SOC_CS4270 is not set
+# CONFIG_SND_SOC_CS4271_I2C is not set
+# CONFIG_SND_SOC_CS4271_SPI is not set
+# CONFIG_SND_SOC_CS42XX8_SPI is not set
+# CONFIG_SND_SOC_CS42XX8_I2C is not set
+# CONFIG_SND_SOC_CS43130 is not set
+# CONFIG_SND_SOC_CS4341 is not set
+# CONFIG_SND_SOC_CS4349 is not set
+# CONFIG_SND_SOC_CS48L32 is not set
+# CONFIG_SND_SOC_CS53L30 is not set
+# CONFIG_SND_SOC_CS530X_I2C is not set
+# CONFIG_SND_SOC_CS530X_SPI is not set
+# CONFIG_SND_SOC_CX2072X is not set
+# CONFIG_SND_SOC_DA7213 is not set
+# CONFIG_SND_SOC_DMIC is not set
+CONFIG_SND_SOC_HDMI_CODEC=m
+# CONFIG_SND_SOC_ES7134 is not set
+# CONFIG_SND_SOC_ES7241 is not set
+# CONFIG_SND_SOC_ES8311 is not set
+# CONFIG_SND_SOC_ES8316 is not set
+# CONFIG_SND_SOC_ES8323 is not set
+# CONFIG_SND_SOC_ES8326 is not set
+# CONFIG_SND_SOC_ES8328_I2C is not set
+# CONFIG_SND_SOC_ES8328_SPI is not set
+# CONFIG_SND_SOC_ES8375 is not set
+# CONFIG_SND_SOC_ES8389 is not set
+# CONFIG_SND_SOC_FS210X is not set
+# CONFIG_SND_SOC_GTM601 is not set
+# CONFIG_SND_SOC_HDA is not set
+# CONFIG_SND_SOC_ICS43432 is not set
+# CONFIG_SND_SOC_IDT821034 is not set
+# CONFIG_SND_SOC_MAX98088 is not set
+# CONFIG_SND_SOC_MAX98090 is not set
+# CONFIG_SND_SOC_MAX98357A is not set
+# CONFIG_SND_SOC_MAX98504 is not set
+# CONFIG_SND_SOC_MAX9867 is not set
+# CONFIG_SND_SOC_MAX98927 is not set
+# CONFIG_SND_SOC_MAX98520 is not set
+# CONFIG_SND_SOC_MAX98363 is not set
+# CONFIG_SND_SOC_MAX98373_I2C is not set
+# CONFIG_SND_SOC_MAX98373_SDW is not set
+# CONFIG_SND_SOC_MAX98388 is not set
+# CONFIG_SND_SOC_MAX98390 is not set
+# CONFIG_SND_SOC_MAX98396 is not set
+# CONFIG_SND_SOC_MAX9860 is not set
+CONFIG_SND_SOC_MSM8916_WCD_ANALOG=m
+CONFIG_SND_SOC_MSM8916_WCD_DIGITAL=m
+# CONFIG_SND_SOC_PCM1681 is not set
+# CONFIG_SND_SOC_PCM1754 is not set
+# CONFIG_SND_SOC_PCM1789_I2C is not set
+# CONFIG_SND_SOC_PCM179X_I2C is not set
+# CONFIG_SND_SOC_PCM179X_SPI is not set
+# CONFIG_SND_SOC_PCM186X_I2C is not set
+# CONFIG_SND_SOC_PCM186X_SPI is not set
+# CONFIG_SND_SOC_PCM3060_I2C is not set
+# CONFIG_SND_SOC_PCM3060_SPI is not set
+# CONFIG_SND_SOC_PCM3168A_I2C is not set
+# CONFIG_SND_SOC_PCM3168A_SPI is not set
+# CONFIG_SND_SOC_PCM5102A is not set
+# CONFIG_SND_SOC_PCM512x_I2C is not set
+# CONFIG_SND_SOC_PCM512x_SPI is not set
+# CONFIG_SND_SOC_PCM6240 is not set
+# CONFIG_SND_SOC_PEB2466 is not set
+# CONFIG_SND_SOC_PM4125_SDW is not set
+# CONFIG_SND_SOC_RT1017_SDCA_SDW is not set
+# CONFIG_SND_SOC_RT1308_SDW is not set
+# CONFIG_SND_SOC_RT1316_SDW is not set
+# CONFIG_SND_SOC_RT1318_SDW is not set
+# CONFIG_SND_SOC_RT1320_SDW is not set
+# CONFIG_SND_SOC_RT5575 is not set
+# CONFIG_SND_SOC_RT5616 is not set
+# CONFIG_SND_SOC_RT5631 is not set
+# CONFIG_SND_SOC_RT5640 is not set
+# CONFIG_SND_SOC_RT5645 is not set
+# CONFIG_SND_SOC_RT5659 is not set
+# CONFIG_SND_SOC_RT5682_SDW is not set
+# CONFIG_SND_SOC_RT700_SDW is not set
+# CONFIG_SND_SOC_RT711_SDW is not set
+# CONFIG_SND_SOC_RT711_SDCA_SDW is not set
+# CONFIG_SND_SOC_RT712_SDCA_SDW is not set
+# CONFIG_SND_SOC_RT712_SDCA_DMIC_SDW is not set
+# CONFIG_SND_SOC_RT721_SDCA_SDW is not set
+# CONFIG_SND_SOC_RT722_SDCA_SDW is not set
+# CONFIG_SND_SOC_RT715_SDW is not set
+# CONFIG_SND_SOC_RT715_SDCA_SDW is not set
+# CONFIG_SND_SOC_RT9120 is not set
+# CONFIG_SND_SOC_RT9123 is not set
+# CONFIG_SND_SOC_RT9123P is not set
+# CONFIG_SND_SOC_RTQ9124 is not set
+# CONFIG_SND_SOC_RTQ9128 is not set
+# CONFIG_SND_SOC_SGTL5000 is not set
+# CONFIG_SND_SOC_SIMPLE_AMPLIFIER is not set
+# CONFIG_SND_SOC_SIMPLE_MUX is not set
+# CONFIG_SND_SOC_SMA1303 is not set
+# CONFIG_SND_SOC_SMA1307 is not set
+# CONFIG_SND_SOC_SPDIF is not set
+# CONFIG_SND_SOC_SRC4XXX_I2C is not set
+# CONFIG_SND_SOC_SSM2305 is not set
+# CONFIG_SND_SOC_SSM2518 is not set
+# CONFIG_SND_SOC_SSM2602_SPI is not set
+# CONFIG_SND_SOC_SSM2602_I2C is not set
+# CONFIG_SND_SOC_SSM3515 is not set
+# CONFIG_SND_SOC_SSM4567 is not set
+# CONFIG_SND_SOC_STA32X is not set
+# CONFIG_SND_SOC_STA350 is not set
+# CONFIG_SND_SOC_STI_SAS is not set
+# CONFIG_SND_SOC_TAS2552 is not set
+# CONFIG_SND_SOC_TAS2557 is not set
+# CONFIG_SND_SOC_TAS2562 is not set
+# CONFIG_SND_SOC_TAS2764 is not set
+# CONFIG_SND_SOC_TAS2770 is not set
+# CONFIG_SND_SOC_TAS2780 is not set
+# CONFIG_SND_SOC_TAS2781_I2C is not set
+# CONFIG_SND_SOC_TAS5086 is not set
+# CONFIG_SND_SOC_TAS571X is not set
+# CONFIG_SND_SOC_TAS5720 is not set
+# CONFIG_SND_SOC_TAS5805M is not set
+# CONFIG_SND_SOC_TAS6424 is not set
+# CONFIG_SND_SOC_TAS675X is not set
+# CONFIG_SND_SOC_TDA7419 is not set
+# CONFIG_SND_SOC_TFA9879 is not set
+# CONFIG_SND_SOC_TFA989X is not set
+CONFIG_SND_SOC_TFA9894=m
+# CONFIG_SND_SOC_TLV320ADC3XXX is not set
+# CONFIG_SND_SOC_TLV320AIC23_I2C is not set
+# CONFIG_SND_SOC_TLV320AIC23_SPI is not set
+# CONFIG_SND_SOC_TLV320AIC31XX is not set
+# CONFIG_SND_SOC_TLV320AIC32X4_I2C is not set
+# CONFIG_SND_SOC_TLV320AIC32X4_SPI is not set
+# CONFIG_SND_SOC_TLV320AIC3X_I2C is not set
+# CONFIG_SND_SOC_TLV320AIC3X_SPI is not set
+# CONFIG_SND_SOC_TLV320ADCX140 is not set
+# CONFIG_SND_SOC_TS3A227E is not set
+# CONFIG_SND_SOC_TSCS42XX is not set
+# CONFIG_SND_SOC_TSCS454 is not set
+# CONFIG_SND_SOC_UDA1334 is not set
+# CONFIG_SND_SOC_UDA1342 is not set
+# CONFIG_SND_SOC_UDA1380 is not set
+# CONFIG_SND_SOC_WCD9335 is not set
+# CONFIG_SND_SOC_WCD937X_SDW is not set
+# CONFIG_SND_SOC_WCD938X_SDW is not set
+# CONFIG_SND_SOC_WCD939X_SDW is not set
+# CONFIG_SND_SOC_WM8510 is not set
+# CONFIG_SND_SOC_WM8523 is not set
+# CONFIG_SND_SOC_WM8524 is not set
+# CONFIG_SND_SOC_WM8580 is not set
+# CONFIG_SND_SOC_WM8711 is not set
+# CONFIG_SND_SOC_WM8728 is not set
+# CONFIG_SND_SOC_WM8731_I2C is not set
+# CONFIG_SND_SOC_WM8731_SPI is not set
+# CONFIG_SND_SOC_WM8737 is not set
+# CONFIG_SND_SOC_WM8741 is not set
+# CONFIG_SND_SOC_WM8750 is not set
+# CONFIG_SND_SOC_WM8753 is not set
+# CONFIG_SND_SOC_WM8770 is not set
+# CONFIG_SND_SOC_WM8776 is not set
+# CONFIG_SND_SOC_WM8782 is not set
+# CONFIG_SND_SOC_WM8804_I2C is not set
+# CONFIG_SND_SOC_WM8804_SPI is not set
+# CONFIG_SND_SOC_WM8903 is not set
+# CONFIG_SND_SOC_WM8904 is not set
+# CONFIG_SND_SOC_WM8940 is not set
+# CONFIG_SND_SOC_WM8960 is not set
+# CONFIG_SND_SOC_WM8961 is not set
+# CONFIG_SND_SOC_WM8962 is not set
+# CONFIG_SND_SOC_WM8974 is not set
+# CONFIG_SND_SOC_WM8978 is not set
+# CONFIG_SND_SOC_WM8985 is not set
+# CONFIG_SND_SOC_WSA881X is not set
+# CONFIG_SND_SOC_WSA883X is not set
+# CONFIG_SND_SOC_WSA884X is not set
+# CONFIG_SND_SOC_ZL38060 is not set
+# CONFIG_SND_SOC_MAX9759 is not set
+# CONFIG_SND_SOC_MT6351 is not set
+# CONFIG_SND_SOC_MT6357 is not set
+# CONFIG_SND_SOC_MT6358 is not set
+# CONFIG_SND_SOC_MT6660 is not set
+# CONFIG_SND_SOC_NAU8315 is not set
+# CONFIG_SND_SOC_NAU8325 is not set
+# CONFIG_SND_SOC_NAU8540 is not set
+# CONFIG_SND_SOC_NAU8810 is not set
+# CONFIG_SND_SOC_NAU8821 is not set
+# CONFIG_SND_SOC_NAU8822 is not set
+# CONFIG_SND_SOC_NAU8824 is not set
+# CONFIG_SND_SOC_NTP8918 is not set
+# CONFIG_SND_SOC_NTP8835 is not set
+# CONFIG_SND_SOC_TPA6130A2 is not set
+# CONFIG_SND_SOC_LPASS_WSA_MACRO is not set
+# CONFIG_SND_SOC_LPASS_VA_MACRO is not set
+# CONFIG_SND_SOC_LPASS_RX_MACRO is not set
+# CONFIG_SND_SOC_LPASS_TX_MACRO is not set
+# end of CODEC drivers
+
+#
+# Generic drivers
+#
+# CONFIG_SND_SIMPLE_CARD is not set
+# CONFIG_SND_AUDIO_GRAPH_CARD is not set
+# CONFIG_SND_AUDIO_GRAPH_CARD2 is not set
+# CONFIG_SND_TEST_COMPONENT is not set
+# end of Generic drivers
+
+# CONFIG_SND_VIRTIO is not set
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+CONFIG_HID_BATTERY_STRENGTH=y
+CONFIG_HIDRAW=y
+CONFIG_UHID=m
+CONFIG_HID_GENERIC=m
+# CONFIG_HID_HAPTIC is not set
+
+#
+# Special HID drivers
+#
+CONFIG_HID_A4TECH=m
+CONFIG_HID_ACCUTOUCH=m
+CONFIG_HID_ACRUX=m
+CONFIG_HID_ACRUX_FF=y
+CONFIG_HID_APPLE=m
+CONFIG_HID_APPLEIR=m
+# CONFIG_HID_ASUS is not set
+CONFIG_HID_AUREAL=m
+CONFIG_HID_BELKIN=m
+CONFIG_HID_BETOP_FF=m
+CONFIG_HID_BIGBEN_FF=m
+CONFIG_HID_CHERRY=m
+CONFIG_HID_CHICONY=m
+CONFIG_HID_CORSAIR=m
+CONFIG_HID_COUGAR=m
+CONFIG_HID_MACALLY=m
+CONFIG_HID_PRODIKEYS=m
+CONFIG_HID_CMEDIA=m
+CONFIG_HID_CP2112=m
+CONFIG_HID_CREATIVE_SB0540=m
+CONFIG_HID_CYPRESS=m
+CONFIG_HID_DRAGONRISE=m
+CONFIG_DRAGONRISE_FF=y
+CONFIG_HID_EMS_FF=m
+CONFIG_HID_ELAN=m
+CONFIG_HID_ELECOM=m
+CONFIG_HID_ELO=m
+CONFIG_HID_EVISION=m
+CONFIG_HID_EZKEY=m
+CONFIG_HID_FT260=m
+CONFIG_HID_GEMBIRD=m
+CONFIG_HID_GFRM=m
+CONFIG_HID_GLORIOUS=m
+CONFIG_HID_HOLTEK=m
+CONFIG_HOLTEK_FF=y
+CONFIG_HID_VIVALDI_COMMON=m
+CONFIG_HID_GOODIX_SPI=m
+CONFIG_HID_GOOGLE_STADIA_FF=m
+CONFIG_HID_VIVALDI=m
+CONFIG_HID_GT683R=m
+CONFIG_HID_KEYTOUCH=m
+CONFIG_HID_KYE=m
+# CONFIG_HID_KYSONA is not set
+CONFIG_HID_UCLOGIC=m
+CONFIG_HID_WALTOP=m
+CONFIG_HID_VIEWSONIC=m
+# CONFIG_HID_VRC2 is not set
+CONFIG_HID_XIAOMI=m
+CONFIG_HID_GYRATION=m
+CONFIG_HID_ICADE=m
+CONFIG_HID_ITE=m
+CONFIG_HID_JABRA=m
+CONFIG_HID_TWINHAN=m
+CONFIG_HID_KENSINGTON=m
+CONFIG_HID_LCPOWER=m
+CONFIG_HID_LED=m
+# CONFIG_HID_LENOVO is not set
+# CONFIG_HID_LENOVO_GO is not set
+# CONFIG_HID_LENOVO_GO_S is not set
+CONFIG_HID_LETSKETCH=m
+CONFIG_HID_LOGITECH=m
+CONFIG_HID_LOGITECH_DJ=m
+CONFIG_HID_LOGITECH_HIDPP=m
+# CONFIG_LOGITECH_FF is not set
+# CONFIG_LOGIRUMBLEPAD2_FF is not set
+# CONFIG_LOGIG940_FF is not set
+# CONFIG_LOGIWHEELS_FF is not set
+CONFIG_HID_MAGICMOUSE=m
+CONFIG_HID_MALTRON=m
+CONFIG_HID_MAYFLASH=m
+CONFIG_HID_MEGAWORLD_FF=m
+# CONFIG_HID_RAKK is not set
+CONFIG_HID_REDRAGON=y
+CONFIG_HID_MICROSOFT=m
+CONFIG_HID_MONTEREY=m
+CONFIG_HID_MULTITOUCH=m
+CONFIG_HID_NINTENDO=m
+CONFIG_NINTENDO_FF=y
+CONFIG_HID_NTI=m
+CONFIG_HID_NTRIG=m
+CONFIG_HID_NVIDIA_SHIELD=m
+CONFIG_NVIDIA_SHIELD_FF=y
+CONFIG_HID_ORTEK=m
+# CONFIG_HID_OXP is not set
+CONFIG_HID_PANTHERLORD=m
+CONFIG_PANTHERLORD_FF=y
+CONFIG_HID_PENMOUNT=m
+CONFIG_HID_PETALYNX=m
+CONFIG_HID_PICOLCD=m
+CONFIG_HID_PICOLCD_FB=y
+CONFIG_HID_PICOLCD_BACKLIGHT=y
+CONFIG_HID_PICOLCD_LCD=y
+CONFIG_HID_PICOLCD_LEDS=y
+CONFIG_HID_PLANTRONICS=m
+CONFIG_HID_PLAYSTATION=m
+# CONFIG_PLAYSTATION_FF is not set
+CONFIG_HID_PXRC=m
+# CONFIG_HID_RAPOO is not set
+CONFIG_HID_RAZER=m
+CONFIG_HID_PRIMAX=m
+CONFIG_HID_RETRODE=m
+CONFIG_HID_ROCCAT=m
+CONFIG_HID_SAITEK=m
+CONFIG_HID_SAMSUNG=m
+CONFIG_HID_SEMITEK=m
+CONFIG_HID_SIGMAMICRO=m
+CONFIG_HID_SONY=m
+CONFIG_SONY_FF=y
+CONFIG_HID_SPEEDLINK=m
+CONFIG_HID_STEAM=m
+CONFIG_STEAM_FF=y
+CONFIG_HID_STEELSERIES=m
+CONFIG_HID_SUNPLUS=m
+CONFIG_HID_RMI=m
+CONFIG_HID_GREENASIA=m
+CONFIG_GREENASIA_FF=y
+CONFIG_HID_SMARTJOYPLUS=m
+CONFIG_SMARTJOYPLUS_FF=y
+CONFIG_HID_TIVO=m
+CONFIG_HID_TOPSEED=m
+CONFIG_HID_TOPRE=m
+CONFIG_HID_THINGM=m
+CONFIG_HID_THRUSTMASTER=m
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_HID_UDRAW_PS3=m
+CONFIG_HID_U2FZERO=m
+# CONFIG_HID_UNIVERSAL_PIDFF is not set
+CONFIG_HID_WACOM=m
+CONFIG_HID_WIIMOTE=m
+CONFIG_HID_WINWING=m
+CONFIG_HID_XINMO=m
+CONFIG_HID_ZEROPLUS=m
+CONFIG_ZEROPLUS_FF=y
+CONFIG_HID_ZYDACRON=m
+CONFIG_HID_SENSOR_HUB=m
+CONFIG_HID_SENSOR_CUSTOM_SENSOR=m
+CONFIG_HID_ALPS=m
+# CONFIG_HID_MCP2200 is not set
+CONFIG_HID_MCP2221=m
+# CONFIG_HID_HUAWEI is not set
+# end of Special HID drivers
+
+#
+# HID-BPF support
+#
+# end of HID-BPF support
+
+CONFIG_I2C_HID=y
+CONFIG_I2C_HID_OF=m
+# CONFIG_I2C_HID_OF_ELAN is not set
+CONFIG_I2C_HID_OF_GOODIX=m
+CONFIG_I2C_HID_CORE=m
+
+#
+# USB HID support
+#
+CONFIG_USB_HID=y
+CONFIG_HID_PID=y
+CONFIG_USB_HIDDEV=y
+# end of USB HID support
+
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_COMMON=y
+CONFIG_USB_LED_TRIG=y
+CONFIG_USB_ULPI_BUS=y
+CONFIG_USB_CONN_GPIO=m
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEFAULT_PERSIST=y
+# CONFIG_USB_FEW_INIT_RETRIES is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_OTG=y
+# CONFIG_USB_OTG_PRODUCTLIST is not set
+# CONFIG_USB_OTG_DISABLE_EXTERNAL_HUB is not set
+CONFIG_USB_OTG_FSM=m
+# CONFIG_USB_LEDS_TRIGGER_USBPORT is not set
+CONFIG_USB_AUTOSUSPEND_DELAY=2
+CONFIG_USB_DEFAULT_AUTHORIZATION_MODE=1
+CONFIG_USB_MON=m
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+CONFIG_USB_XHCI_HCD=y
+# CONFIG_USB_XHCI_DBGCAP is not set
+CONFIG_USB_XHCI_PLATFORM=y
+CONFIG_USB_XHCI_SIDEBAND=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+# CONFIG_USB_EHCI_FSL is not set
+CONFIG_USB_EHCI_HCD_PLATFORM=y
+# CONFIG_USB_OXU210HP_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_MAX3421_HCD is not set
+# CONFIG_USB_OHCI_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
+# CONFIG_USB_HCD_TEST_MODE is not set
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+CONFIG_USB_WDM=m
+# CONFIG_USB_TMC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; see USB_STORAGE Help for more info
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_REALTEK is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_ONETOUCH is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
+# CONFIG_USB_STORAGE_ENE_UB6250 is not set
+CONFIG_USB_UAS=m
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+CONFIG_USBIP_CORE=m
+CONFIG_USBIP_VHCI_HCD=m
+CONFIG_USBIP_VHCI_HC_PORTS=8
+CONFIG_USBIP_VHCI_NR_HCS=1
+CONFIG_USBIP_HOST=m
+# CONFIG_USBIP_VUDC is not set
+# CONFIG_USBIP_DEBUG is not set
+
+#
+# USB dual-mode controller drivers
+#
+# CONFIG_USB_CDNS_SUPPORT is not set
+# CONFIG_USB_MUSB_HDRC is not set
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_ULPI=y
+# CONFIG_USB_DWC3_HOST is not set
+# CONFIG_USB_DWC3_GADGET is not set
+CONFIG_USB_DWC3_DUAL_ROLE=y
+
+#
+# Platform Glue Driver Support
+#
+CONFIG_USB_DWC3_OF_SIMPLE=y
+CONFIG_USB_DWC3_QCOM=y
+CONFIG_USB_DWC3_GENERIC_PLAT=m
+# CONFIG_USB_DWC3_GOOGLE is not set
+# CONFIG_USB_DWC2 is not set
+CONFIG_USB_CHIPIDEA=y
+CONFIG_USB_CHIPIDEA_UDC=y
+CONFIG_USB_CHIPIDEA_HOST=y
+CONFIG_USB_CHIPIDEA_MSM=y
+CONFIG_USB_CHIPIDEA_NPCM=y
+CONFIG_USB_CHIPIDEA_IMX=y
+CONFIG_USB_CHIPIDEA_GENERIC=y
+CONFIG_USB_CHIPIDEA_TEGRA=y
+# CONFIG_USB_ISP1760 is not set
+
+#
+# USB port drivers
+#
+CONFIG_USB_SERIAL=m
+# CONFIG_USB_SERIAL_GENERIC is not set
+CONFIG_USB_SERIAL_SIMPLE=m
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+# CONFIG_USB_SERIAL_ARK3116 is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_CH341 is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+CONFIG_USB_SERIAL_CP210X=m
+# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_F81232 is not set
+# CONFIG_USB_SERIAL_F8153X is not set
+# CONFIG_USB_SERIAL_GARMIN is not set
+# CONFIG_USB_SERIAL_IPW is not set
+# CONFIG_USB_SERIAL_IUU is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_METRO is not set
+# CONFIG_USB_SERIAL_MOS7720 is not set
+# CONFIG_USB_SERIAL_MOS7840 is not set
+# CONFIG_USB_SERIAL_MXUPORT is not set
+# CONFIG_USB_SERIAL_NAVMAN is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_OTI6858 is not set
+# CONFIG_USB_SERIAL_QCAUX is not set
+# CONFIG_USB_SERIAL_QUALCOMM is not set
+# CONFIG_USB_SERIAL_SPCP8X5 is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
+# CONFIG_USB_SERIAL_SYMBOL is not set
+# CONFIG_USB_SERIAL_TI is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_OPTION is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+# CONFIG_USB_SERIAL_OPTICON is not set
+# CONFIG_USB_SERIAL_XSENS_MT is not set
+# CONFIG_USB_SERIAL_WISHBONE is not set
+# CONFIG_USB_SERIAL_SSU100 is not set
+# CONFIG_USB_SERIAL_QT2 is not set
+# CONFIG_USB_SERIAL_UPD78F0730 is not set
+# CONFIG_USB_SERIAL_XR is not set
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_SEVSEG is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+CONFIG_USB_QCOM_EUD=m
+# CONFIG_APPLE_MFI_FASTCHARGE is not set
+# CONFIG_USB_SISUSBVGA is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_EHSET_TEST_FIXTURE is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_YUREX is not set
+# CONFIG_USB_EZUSB_FX2 is not set
+# CONFIG_USB_HUB_USB251XB is not set
+# CONFIG_USB_HSIC_USB3503 is not set
+# CONFIG_USB_HSIC_USB4604 is not set
+# CONFIG_USB_LINK_LAYER_TEST is not set
+# CONFIG_USB_CHAOSKEY is not set
+# CONFIG_USB_ONBOARD_DEV is not set
+
+#
+# USB Physical Layer drivers
+#
+CONFIG_USB_PHY=y
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_USB_ISP1301 is not set
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
+# end of USB Physical Layer drivers
+
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG is not set
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
+CONFIG_U_SERIAL_CONSOLE=y
+
+#
+# USB Peripheral Controller
+#
+# CONFIG_USB_GR_UDC is not set
+# CONFIG_USB_R8A66597 is not set
+# CONFIG_USB_PXA27X is not set
+# CONFIG_USB_SNP_UDC_PLAT is not set
+# CONFIG_USB_M66592 is not set
+# CONFIG_USB_BDC_UDC is not set
+# CONFIG_USB_GADGET_XILINX is not set
+# CONFIG_USB_MAX3420_UDC is not set
+# CONFIG_USB_DUMMY_HCD is not set
+# end of USB Peripheral Controller
+
+CONFIG_USB_LIBCOMPOSITE=m
+CONFIG_USB_F_ACM=m
+CONFIG_USB_U_SERIAL=m
+CONFIG_USB_U_ETHER=m
+CONFIG_USB_U_AUDIO=m
+CONFIG_USB_F_SERIAL=m
+CONFIG_USB_F_OBEX=m
+CONFIG_USB_F_NCM=m
+CONFIG_USB_F_ECM=m
+CONFIG_USB_F_EEM=m
+CONFIG_USB_F_SUBSET=m
+CONFIG_USB_F_RNDIS=m
+CONFIG_USB_F_MASS_STORAGE=m
+CONFIG_USB_F_FS=m
+CONFIG_USB_F_UAC1=m
+CONFIG_USB_F_UAC2=m
+CONFIG_USB_F_UVC=m
+CONFIG_USB_F_MIDI=m
+CONFIG_USB_F_MIDI2=m
+CONFIG_USB_F_HID=m
+CONFIG_USB_F_PRINTER=m
+CONFIG_USB_CONFIGFS=m
+CONFIG_USB_CONFIGFS_SERIAL=y
+CONFIG_USB_CONFIGFS_ACM=y
+CONFIG_USB_CONFIGFS_OBEX=y
+CONFIG_USB_CONFIGFS_NCM=y
+CONFIG_USB_CONFIGFS_ECM=y
+CONFIG_USB_CONFIGFS_ECM_SUBSET=y
+CONFIG_USB_CONFIGFS_RNDIS=y
+CONFIG_USB_CONFIGFS_EEM=y
+CONFIG_USB_CONFIGFS_MASS_STORAGE=y
+# CONFIG_USB_CONFIGFS_F_LB_SS is not set
+CONFIG_USB_CONFIGFS_F_FS=y
+CONFIG_USB_CONFIGFS_F_UAC1=y
+# CONFIG_USB_CONFIGFS_F_UAC1_LEGACY is not set
+CONFIG_USB_CONFIGFS_F_UAC2=y
+CONFIG_USB_CONFIGFS_F_MIDI=y
+CONFIG_USB_CONFIGFS_F_MIDI2=y
+CONFIG_USB_CONFIGFS_F_HID=y
+CONFIG_USB_CONFIGFS_F_UVC=y
+CONFIG_USB_CONFIGFS_F_PRINTER=y
+
+#
+# USB Gadget precomposed configurations
+#
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_ETH is not set
+# CONFIG_USB_G_NCM is not set
+# CONFIG_USB_GADGETFS is not set
+# CONFIG_USB_FUNCTIONFS is not set
+# CONFIG_USB_MASS_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
+# CONFIG_USB_G_ACM_MS is not set
+# CONFIG_USB_G_MULTI is not set
+# CONFIG_USB_G_HID is not set
+# CONFIG_USB_G_DBGP is not set
+# CONFIG_USB_G_WEBCAM is not set
+# CONFIG_USB_RAW_GADGET is not set
+# end of USB Gadget precomposed configurations
+
+CONFIG_TYPEC=y
+# CONFIG_TYPEC_TCPM is not set
+CONFIG_TYPEC_UCSI=y
+# CONFIG_UCSI_CCG is not set
+# CONFIG_UCSI_STM32G0 is not set
+CONFIG_UCSI_PMIC_GLINK=m
+# CONFIG_TYPEC_TPS6598X is not set
+# CONFIG_TYPEC_ANX7411 is not set
+# CONFIG_TYPEC_RT1719 is not set
+# CONFIG_TYPEC_HD3SS3220 is not set
+# CONFIG_TYPEC_STUSB160X is not set
+# CONFIG_TYPEC_WUSB3801 is not set
+
+#
+# USB Type-C Multiplexer/DeMultiplexer Switch support
+#
+# CONFIG_TYPEC_MUX_FSA4480 is not set
+# CONFIG_TYPEC_MUX_GPIO_SBU is not set
+# CONFIG_TYPEC_MUX_PI3USB30532 is not set
+# CONFIG_TYPEC_MUX_IT5205 is not set
+# CONFIG_TYPEC_MUX_NB7VPQ904M is not set
+# CONFIG_TYPEC_MUX_PS883X is not set
+# CONFIG_TYPEC_MUX_PTN36502 is not set
+# CONFIG_TYPEC_MUX_TUSB1046 is not set
+# CONFIG_TYPEC_MUX_WCD939X_USBSS is not set
+# end of USB Type-C Multiplexer/DeMultiplexer Switch support
+
+#
+# USB Type-C Alternate Mode drivers
+#
+# CONFIG_TYPEC_DP_ALTMODE is not set
+# CONFIG_TYPEC_TBT_ALTMODE is not set
+# end of USB Type-C Alternate Mode drivers
+
+CONFIG_USB_ROLE_SWITCH=y
+CONFIG_MMC=y
+CONFIG_PWRSEQ_EMMC=y
+CONFIG_PWRSEQ_SIMPLE=y
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_MINORS=32
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_ARMMMCI is not set
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_IO_ACCESSORS=y
+CONFIG_MMC_SDHCI_PLTFM=y
+# CONFIG_MMC_SDHCI_OF_ARASAN is not set
+# CONFIG_MMC_SDHCI_OF_AT91 is not set
+# CONFIG_MMC_SDHCI_OF_DWCMSHC is not set
+# CONFIG_MMC_SDHCI_CADENCE is not set
+# CONFIG_MMC_SDHCI_F_SDH30 is not set
+# CONFIG_MMC_SDHCI_MILBEAUT is not set
+CONFIG_MMC_SDHCI_MSM=y
+# CONFIG_MMC_SPI is not set
+# CONFIG_MMC_DW is not set
+# CONFIG_MMC_VUB300 is not set
+# CONFIG_MMC_USHC is not set
+# CONFIG_MMC_USDHI6ROL0 is not set
+CONFIG_MMC_CQHCI=y
+# CONFIG_MMC_HSQ is not set
+# CONFIG_MMC_MTK is not set
+# CONFIG_MMC_SDHCI_XENON is not set
+# CONFIG_SCSI_UFSHCD is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_CLASS_FLASH=m
+CONFIG_LEDS_CLASS_MULTICOLOR=m
+# CONFIG_LEDS_BRIGHTNESS_HW_CHANGED is not set
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_AN30259A is not set
+# CONFIG_LEDS_OSRAM_AMS_AS3668 is not set
+# CONFIG_LEDS_AW200XX is not set
+# CONFIG_LEDS_AW2013 is not set
+# CONFIG_LEDS_BCM6328 is not set
+# CONFIG_LEDS_BCM6358 is not set
+# CONFIG_LEDS_CR0014114 is not set
+# CONFIG_LEDS_EL15203000 is not set
+# CONFIG_LEDS_LM3530 is not set
+# CONFIG_LEDS_LM3532 is not set
+# CONFIG_LEDS_LM3642 is not set
+# CONFIG_LEDS_LM3692X is not set
+# CONFIG_LEDS_PCA9532 is not set
+# CONFIG_LEDS_GPIO is not set
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_LP3952 is not set
+# CONFIG_LEDS_LP50XX is not set
+# CONFIG_LEDS_LP55XX_COMMON is not set
+# CONFIG_LEDS_LP8860 is not set
+# CONFIG_LEDS_LP8864 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_PCA963X is not set
+# CONFIG_LEDS_PCA995X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_PWM is not set
+# CONFIG_LEDS_REGULATOR is not set
+# CONFIG_LEDS_BD2606MVV is not set
+# CONFIG_LEDS_BD2802 is not set
+# CONFIG_LEDS_LT3593 is not set
+# CONFIG_LEDS_TCA6507 is not set
+# CONFIG_LEDS_TLC591XX is not set
+# CONFIG_LEDS_LM355x is not set
+# CONFIG_LEDS_IS31FL319X is not set
+# CONFIG_LEDS_IS31FL32XX is not set
+
+#
+# LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)
+#
+# CONFIG_LEDS_BLINKM is not set
+# CONFIG_LEDS_SYSCON is not set
+# CONFIG_LEDS_MLXREG is not set
+# CONFIG_LEDS_USER is not set
+# CONFIG_LEDS_SPI_BYTE is not set
+# CONFIG_LEDS_LM3697 is not set
+# CONFIG_LEDS_ST1202 is not set
+
+#
+# Flash and Torch LED drivers
+#
+# CONFIG_LEDS_AAT1290 is not set
+# CONFIG_LEDS_AS3645A is not set
+# CONFIG_LEDS_KTD2692 is not set
+# CONFIG_LEDS_LM3601X is not set
+# CONFIG_LEDS_QCOM_FLASH is not set
+# CONFIG_LEDS_RT4505 is not set
+# CONFIG_LEDS_RT8515 is not set
+# CONFIG_LEDS_SGM3140 is not set
+# CONFIG_LEDS_SY7802 is not set
+# CONFIG_LEDS_TPS6131X is not set
+
+#
+# RGB LED drivers
+#
+# CONFIG_LEDS_GROUP_MULTICOLOR is not set
+# CONFIG_LEDS_KTD202X is not set
+# CONFIG_LEDS_LP5812 is not set
+# CONFIG_LEDS_LP5860_CORE is not set
+# CONFIG_LEDS_LP5860_SPI is not set
+# CONFIG_LEDS_NCP5623 is not set
+# CONFIG_LEDS_PWM_MULTICOLOR is not set
+CONFIG_LEDS_QCOM_LPG=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=y
+# CONFIG_LEDS_TRIGGER_ONESHOT is not set
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+CONFIG_LEDS_TRIGGER_CPU=y
+# CONFIG_LEDS_TRIGGER_ACTIVITY is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_LEDS_TRIGGER_TRANSIENT is not set
+# CONFIG_LEDS_TRIGGER_CAMERA is not set
+CONFIG_LEDS_TRIGGER_PANIC=y
+# CONFIG_LEDS_TRIGGER_NETDEV is not set
+CONFIG_LEDS_TRIGGER_PATTERN=m
+# CONFIG_LEDS_TRIGGER_TTY is not set
+# CONFIG_LEDS_TRIGGER_INPUT_EVENTS is not set
+
+#
+# Simatic LED drivers
+#
+CONFIG_ACCESSIBILITY=y
+CONFIG_A11Y_BRAILLE_CONSOLE=y
+
+#
+# Speakup console speech
+#
+CONFIG_SPEAKUP=m
+CONFIG_SPEAKUP_SYNTH_ACNTSA=m
+CONFIG_SPEAKUP_SYNTH_APOLLO=m
+CONFIG_SPEAKUP_SYNTH_AUDPTR=m
+CONFIG_SPEAKUP_SYNTH_BNS=m
+CONFIG_SPEAKUP_SYNTH_DECTLK=m
+CONFIG_SPEAKUP_SYNTH_DECEXT=m
+CONFIG_SPEAKUP_SYNTH_LTLK=m
+CONFIG_SPEAKUP_SYNTH_SOFT=m
+CONFIG_SPEAKUP_SYNTH_SPKOUT=m
+CONFIG_SPEAKUP_SYNTH_TXPRT=m
+# CONFIG_SPEAKUP_SYNTH_DUMMY is not set
+# end of Speakup console speech
+
+# CONFIG_INFINIBAND is not set
+CONFIG_EDAC_SUPPORT=y
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+CONFIG_RTC_SYSTOHC=y
+CONFIG_RTC_SYSTOHC_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+CONFIG_RTC_NVMEM=y
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_ABB5ZES3 is not set
+# CONFIG_RTC_DRV_ABEOZ9 is not set
+# CONFIG_RTC_DRV_ABX80X is not set
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_HYM8563 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_MAX31335 is not set
+# CONFIG_RTC_DRV_NCT3018Y is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_ISL12022 is not set
+# CONFIG_RTC_DRV_ISL12026 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8523 is not set
+# CONFIG_RTC_DRV_PCF85363 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_BQ32K is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8010 is not set
+# CONFIG_RTC_DRV_RX8111 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+# CONFIG_RTC_DRV_EM3027 is not set
+# CONFIG_RTC_DRV_RV3028 is not set
+# CONFIG_RTC_DRV_RV3032 is not set
+# CONFIG_RTC_DRV_RV8803 is not set
+# CONFIG_RTC_DRV_SD2405AL is not set
+# CONFIG_RTC_DRV_SD3078 is not set
+
+#
+# SPI RTC drivers
+#
+# CONFIG_RTC_DRV_M41T93 is not set
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1302 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1343 is not set
+# CONFIG_RTC_DRV_DS1347 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
+# CONFIG_RTC_DRV_MAX6916 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RX4581 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
+# CONFIG_RTC_DRV_MCP795 is not set
+CONFIG_RTC_I2C_AND_SPI=y
+
+#
+# SPI and I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS3232 is not set
+# CONFIG_RTC_DRV_PCF2127 is not set
+# CONFIG_RTC_DRV_PCF85063 is not set
+# CONFIG_RTC_DRV_RV3029C2 is not set
+# CONFIG_RTC_DRV_RX6110 is not set
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1685_FAMILY is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_DS2404 is not set
+# CONFIG_RTC_DRV_EFI is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_MSM6242 is not set
+# CONFIG_RTC_DRV_RP5C01 is not set
+# CONFIG_RTC_DRV_ZYNQMP is not set
+
+#
+# on-CPU RTC drivers
+#
+# CONFIG_RTC_DRV_PL030 is not set
+# CONFIG_RTC_DRV_PL031 is not set
+# CONFIG_RTC_DRV_CADENCE is not set
+# CONFIG_RTC_DRV_FTRTC010 is not set
+CONFIG_RTC_DRV_PM8XXX=y
+# CONFIG_RTC_DRV_R7301 is not set
+# CONFIG_RTC_DRV_GOLDFISH is not set
+
+#
+# HID Sensor RTC drivers
+#
+CONFIG_RTC_DRV_HID_SENSOR_TIME=m
+CONFIG_DMADEVICES=y
+# CONFIG_DMADEVICES_DEBUG is not set
+
+#
+# DMA Devices
+#
+CONFIG_DMA_ENGINE=y
+CONFIG_DMA_VIRTUAL_CHANNELS=y
+CONFIG_DMA_OF=y
+# CONFIG_ALTERA_MSGDMA is not set
+# CONFIG_AMBA_PL08X is not set
+# CONFIG_ARM_DMA350 is not set
+# CONFIG_BCM_SBA_RAID is not set
+# CONFIG_DW_AXI_DMAC is not set
+# CONFIG_FSL_EDMA is not set
+# CONFIG_FSL_QDMA is not set
+# CONFIG_INTEL_IDMA64 is not set
+# CONFIG_MV_XOR_V2 is not set
+# CONFIG_PL330_DMA is not set
+# CONFIG_XILINX_DMA is not set
+# CONFIG_XILINX_XDMA is not set
+# CONFIG_XILINX_ZYNQMP_DMA is not set
+# CONFIG_XILINX_ZYNQMP_DPDMA is not set
+# CONFIG_AMD_QDMA is not set
+CONFIG_QCOM_BAM_DMA=y
+CONFIG_QCOM_GPI_DMA=y
+# CONFIG_QCOM_HIDMA_MGMT is not set
+# CONFIG_QCOM_HIDMA is not set
+# CONFIG_DW_DMAC is not set
+# CONFIG_SF_PDMA is not set
+
+#
+# DMA Clients
+#
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+
+#
+# DMABUF options
+#
+CONFIG_SYNC_FILE=y
+# CONFIG_SW_SYNC is not set
+CONFIG_UDMABUF=y
+# CONFIG_DMABUF_DEBUG is not set
+# CONFIG_DMABUF_HEAPS is not set
+# end of DMABUF options
+
+# CONFIG_UIO is not set
+# CONFIG_VFIO is not set
+# CONFIG_VIRT_DRIVERS is not set
+CONFIG_VIRTIO_ANCHOR=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_MENU=y
+# CONFIG_VIRTIO_BALLOON is not set
+# CONFIG_VIRTIO_INPUT is not set
+# CONFIG_VIRTIO_MMIO is not set
+# CONFIG_VIRTIO_DEBUG is not set
+# CONFIG_VIRTIO_RTC is not set
+# CONFIG_VDPA is not set
+CONFIG_VHOST_MENU=y
+# CONFIG_VHOST_NET is not set
+# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set
+CONFIG_VHOST_ENABLE_FORK_OWNER_CONTROL=y
+
+#
+# Microsoft Hyper-V guest support
+#
+# CONFIG_HYPERV is not set
+# end of Microsoft Hyper-V guest support
+
+# CONFIG_GREYBUS is not set
+# CONFIG_COMEDI is not set
+# CONFIG_GPIB is not set
+# CONFIG_STAGING is not set
+# CONFIG_GOLDFISH is not set
+# CONFIG_CHROME_PLATFORMS is not set
+# CONFIG_MELLANOX_PLATFORM is not set
+# CONFIG_SURFACE_PLATFORMS is not set
+CONFIG_ARM64_PLATFORM_DEVICES=y
+# CONFIG_EC_ACER_ASPIRE1 is not set
+# CONFIG_EC_HUAWEI_GAOKUN is not set
+# CONFIG_EC_LENOVO_YOGA_C630 is not set
+# CONFIG_EC_LENOVO_THINKPAD_T14S is not set
+# CONFIG_EC_QCOM_HAMOA is not set
+CONFIG_HAVE_CLK=y
+CONFIG_HAVE_CLK_PREPARE=y
+CONFIG_COMMON_CLK=y
+
+#
+# Clock driver for ARM Reference designs
+#
+# CONFIG_CLK_ICST is not set
+# CONFIG_CLK_SP810 is not set
+# end of Clock driver for ARM Reference designs
+
+# CONFIG_LMK04832 is not set
+# CONFIG_COMMON_CLK_MAX9485 is not set
+# CONFIG_COMMON_CLK_SI5341 is not set
+# CONFIG_COMMON_CLK_SI5351 is not set
+# CONFIG_COMMON_CLK_SI514 is not set
+# CONFIG_COMMON_CLK_SI544 is not set
+# CONFIG_COMMON_CLK_SI570 is not set
+# CONFIG_COMMON_CLK_CDCE706 is not set
+# CONFIG_COMMON_CLK_CDCE925 is not set
+# CONFIG_COMMON_CLK_CS2000_CP is not set
+# CONFIG_COMMON_CLK_AXI_CLKGEN is not set
+# CONFIG_COMMON_CLK_XGENE is not set
+# CONFIG_COMMON_CLK_PWM is not set
+# CONFIG_COMMON_CLK_RS9_PCIE is not set
+# CONFIG_COMMON_CLK_SI521XX is not set
+# CONFIG_COMMON_CLK_VC3 is not set
+# CONFIG_COMMON_CLK_VC5 is not set
+# CONFIG_COMMON_CLK_VC7 is not set
+# CONFIG_COMMON_CLK_FIXED_MMIO is not set
+CONFIG_QCOM_GDSC=y
+CONFIG_COMMON_CLK_QCOM=y
+# CONFIG_CLK_ELIZA_DISPCC is not set
+# CONFIG_CLK_ELIZA_GCC is not set
+# CONFIG_CLK_ELIZA_TCSRCC is not set
+# CONFIG_CLK_GLYMUR_DISPCC is not set
+# CONFIG_CLK_GLYMUR_GCC is not set
+# CONFIG_CLK_GLYMUR_GPUCC is not set
+# CONFIG_CLK_GLYMUR_TCSRCC is not set
+# CONFIG_CLK_GLYMUR_VIDEOCC is not set
+# CONFIG_CLK_KAANAPALI_CAMCC is not set
+# CONFIG_CLK_KAANAPALI_DISPCC is not set
+# CONFIG_CLK_KAANAPALI_GCC is not set
+# CONFIG_CLK_KAANAPALI_GPUCC is not set
+# CONFIG_CLK_KAANAPALI_TCSRCC is not set
+# CONFIG_CLK_KAANAPALI_VIDEOCC is not set
+# CONFIG_CLK_NORD_GCC is not set
+# CONFIG_CLK_X1E80100_CAMCC is not set
+# CONFIG_CLK_X1E80100_DISPCC is not set
+CONFIG_CLK_X1E80100_GCC=m
+# CONFIG_CLK_X1E80100_GPUCC is not set
+# CONFIG_CLK_X1E80100_TCSRCC is not set
+CONFIG_CLK_X1P42100_CAMCC=m
+# CONFIG_CLK_X1P42100_GPUCC is not set
+CONFIG_CLK_X1P42100_VIDEOCC=m
+# CONFIG_CLK_QCM2290_GPUCC is not set
+# CONFIG_QCOM_A53PLL is not set
+# CONFIG_QCOM_A7PLL is not set
+# CONFIG_QCOM_CLK_APCS_MSM8916 is not set
+# CONFIG_QCOM_CLK_APCC_MSM8996 is not set
+# CONFIG_QCOM_CLK_RPM is not set
+CONFIG_QCOM_CLK_SMD_RPM=y
+CONFIG_QCOM_CLK_RPMH=y
+# CONFIG_CLK_HAWI_GCC is not set
+# CONFIG_CLK_HAWI_TCSRCC is not set
+# CONFIG_IPQ_APSS_PLL is not set
+# CONFIG_IPQ_APSS_5424 is not set
+# CONFIG_IPQ_APSS_6018 is not set
+# CONFIG_IPQ_CMN_PLL is not set
+# CONFIG_IPQ_GCC_4019 is not set
+# CONFIG_IPQ_GCC_5018 is not set
+# CONFIG_IPQ_GCC_5210 is not set
+# CONFIG_IPQ_GCC_5332 is not set
+# CONFIG_IPQ_GCC_5424 is not set
+# CONFIG_IPQ_GCC_6018 is not set
+# CONFIG_IPQ_GCC_8074 is not set
+# CONFIG_IPQ_GCC_9574 is not set
+CONFIG_IPQ_GCC_9650=y
+# CONFIG_IPQ_NSSCC_QCA8K is not set
+# CONFIG_MSM_GCC_8916 is not set
+# CONFIG_MSM_GCC_8917 is not set
+# CONFIG_MSM_GCC_8939 is not set
+# CONFIG_MSM_GCC_8953 is not set
+# CONFIG_MSM_GCC_8976 is not set
+# CONFIG_MSM_MMCC_8994 is not set
+# CONFIG_MSM_GCC_8994 is not set
+# CONFIG_MSM_GCC_8996 is not set
+# CONFIG_MSM_MMCC_8996 is not set
+# CONFIG_MSM_GCC_8998 is not set
+# CONFIG_MSM_GPUCC_8998 is not set
+# CONFIG_MSM_MMCC_8998 is not set
+# CONFIG_QCM_GCC_2290 is not set
+# CONFIG_QCM_DISPCC_2290 is not set
+# CONFIG_QCS_DISPCC_615 is not set
+# CONFIG_QCS_CAMCC_615 is not set
+# CONFIG_QCS_GCC_404 is not set
+# CONFIG_CLK_NORD_TCSRCC is not set
+# CONFIG_SA_CAMCC_8775P is not set
+# CONFIG_QCS_GCC_8300 is not set
+# CONFIG_QCS_GCC_615 is not set
+# CONFIG_QCS_GPUCC_615 is not set
+# CONFIG_QCS_VIDEOCC_615 is not set
+# CONFIG_SC_CAMCC_7180 is not set
+# CONFIG_SC_CAMCC_7280 is not set
+# CONFIG_SC_CAMCC_8180X is not set
+# CONFIG_SC_CAMCC_8280XP is not set
+# CONFIG_SA_DISPCC_8775P is not set
+# CONFIG_SC_DISPCC_7180 is not set
+# CONFIG_SC_DISPCC_7280 is not set
+# CONFIG_SC_DISPCC_8280XP is not set
+# CONFIG_SA_GCC_8775P is not set
+# CONFIG_SA_GPUCC_8775P is not set
+# CONFIG_SAR_GCC_2130P is not set
+# CONFIG_SAR_GPUCC_2130P is not set
+# CONFIG_SC_GCC_7180 is not set
+# CONFIG_SC_GCC_7280 is not set
+# CONFIG_SC_GCC_8180X is not set
+# CONFIG_SC_GCC_8280XP is not set
+# CONFIG_SC_GPUCC_7180 is not set
+# CONFIG_SC_GPUCC_7280 is not set
+# CONFIG_SC_GPUCC_8280XP is not set
+# CONFIG_SC_LPASSCC_7280 is not set
+# CONFIG_SC_LPASSCC_8280XP is not set
+# CONFIG_SC_LPASS_CORECC_7180 is not set
+# CONFIG_SC_LPASS_CORECC_7280 is not set
+# CONFIG_SC_VIDEOCC_7180 is not set
+# CONFIG_SC_VIDEOCC_7280 is not set
+# CONFIG_SDM_CAMCC_845 is not set
+CONFIG_SDM_GCC_660=y
+CONFIG_SDM660_CPU_CLK=y
+CONFIG_SDM660_CPRH=y
+CONFIG_SDM_MMCC_660=y
+CONFIG_SDM_GPUCC_660=y
+# CONFIG_QCS_TURING_404 is not set
+# CONFIG_QCS_Q6SSTOP_404 is not set
+# CONFIG_QDU_GCC_1000 is not set
+# CONFIG_QDU_ECPRICC_1000 is not set
+# CONFIG_SDM_GCC_845 is not set
+# CONFIG_SDM_GPUCC_845 is not set
+# CONFIG_SDM_VIDEOCC_845 is not set
+# CONFIG_SDM_DISPCC_845 is not set
+# CONFIG_SDM_LPASSCC_845 is not set
+# CONFIG_SDX_GCC_75 is not set
+# CONFIG_SM_CAMCC_4450 is not set
+# CONFIG_SM_CAMCC_6350 is not set
+# CONFIG_SM_CAMCC_7150 is not set
+# CONFIG_SM_CAMCC_MILOS is not set
+# CONFIG_SM_CAMCC_8150 is not set
+# CONFIG_SM_CAMCC_8250 is not set
+# CONFIG_SM_CAMCC_8450 is not set
+# CONFIG_SM_CAMCC_8550 is not set
+# CONFIG_SM_CAMCC_8650 is not set
+# CONFIG_SM_CAMCC_8750 is not set
+# CONFIG_SM_GCC_4450 is not set
+# CONFIG_SM_GCC_6115 is not set
+# CONFIG_SM_GCC_6125 is not set
+# CONFIG_SM_GCC_6350 is not set
+# CONFIG_SM_GCC_6375 is not set
+# CONFIG_SM_GCC_7150 is not set
+# CONFIG_SM_GCC_MILOS is not set
+# CONFIG_SM_GCC_8150 is not set
+# CONFIG_SM_GCC_8250 is not set
+# CONFIG_SM_GCC_8350 is not set
+# CONFIG_SM_GCC_8450 is not set
+# CONFIG_SM_GCC_8550 is not set
+# CONFIG_SM_GCC_8650 is not set
+# CONFIG_SM_GCC_8750 is not set
+# CONFIG_SM_GPUCC_4450 is not set
+# CONFIG_SM_GPUCC_6115 is not set
+# CONFIG_SM_GPUCC_6125 is not set
+# CONFIG_SM_GPUCC_6375 is not set
+# CONFIG_SM_GPUCC_6350 is not set
+# CONFIG_SM_GPUCC_MILOS is not set
+# CONFIG_SM_GPUCC_8150 is not set
+# CONFIG_SM_GPUCC_8250 is not set
+# CONFIG_SM_GPUCC_8350 is not set
+# CONFIG_SM_GPUCC_8450 is not set
+# CONFIG_SM_GPUCC_8550 is not set
+# CONFIG_SM_GPUCC_8650 is not set
+# CONFIG_SM_GPUCC_8750 is not set
+# CONFIG_SM_LPASSCC_6115 is not set
+# CONFIG_SM_TCSRCC_8550 is not set
+# CONFIG_SM_TCSRCC_8650 is not set
+# CONFIG_SM_TCSRCC_8750 is not set
+# CONFIG_SA_VIDEOCC_8775P is not set
+# CONFIG_SM_VIDEOCC_6350 is not set
+# CONFIG_SM_VIDEOCC_7150 is not set
+# CONFIG_SM_VIDEOCC_MILOS is not set
+# CONFIG_SM_VIDEOCC_8150 is not set
+# CONFIG_SM_VIDEOCC_8250 is not set
+# CONFIG_SM_VIDEOCC_8550 is not set
+# CONFIG_SM_VIDEOCC_8750 is not set
+# CONFIG_SPMI_PMIC_CLKDIV is not set
+# CONFIG_QCOM_HFPLL is not set
+# CONFIG_KPSS_XCC is not set
+# CONFIG_CLK_GFM_LPASS_SM8250 is not set
+# CONFIG_SM_VIDEOCC_8450 is not set
+# CONFIG_XILINX_VCU is not set
+# CONFIG_COMMON_CLK_XLNX_CLKWZRD is not set
+CONFIG_HWSPINLOCK=y
+CONFIG_HWSPINLOCK_QCOM=y
+
+#
+# Clock Source drivers
+#
+CONFIG_TIMER_OF=y
+CONFIG_TIMER_PROBE=y
+CONFIG_ARM_ARCH_TIMER=y
+CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
+CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND=y
+CONFIG_FSL_ERRATUM_A008585=y
+CONFIG_HISILICON_ERRATUM_161010101=y
+CONFIG_ARM64_ERRATUM_858921=y
+# CONFIG_ARM_TIMER_SP804 is not set
+# end of Clock Source drivers
+
+CONFIG_MAILBOX=y
+# CONFIG_ARM_MHU is not set
+# CONFIG_ARM_MHU_V2 is not set
+# CONFIG_ARM_MHU_V3 is not set
+# CONFIG_PLATFORM_MHU is not set
+# CONFIG_PL320_MBOX is not set
+# CONFIG_ALTERA_MBOX is not set
+# CONFIG_MAILBOX_TEST is not set
+CONFIG_QCOM_APCS_IPC=y
+# CONFIG_QCOM_CPUCP_MBOX is not set
+CONFIG_QCOM_IPCC=m
+CONFIG_IOMMU_IOVA=y
+CONFIG_IOMMU_API=y
+CONFIG_IOMMU_SUPPORT=y
+
+#
+# Generic IOMMU Pagetable Support
+#
+CONFIG_IOMMU_IO_PGTABLE=y
+CONFIG_IOMMU_IO_PGTABLE_LPAE=y
+CONFIG_IOMMU_IO_PGTABLE_ARMV7S=y
+# CONFIG_IOMMU_IO_PGTABLE_ARMV7S_SELFTEST is not set
+# CONFIG_IOMMU_IO_PGTABLE_DART is not set
+# end of Generic IOMMU Pagetable Support
+
+CONFIG_IOMMU_DEBUGFS=y
+CONFIG_IOMMU_DEFAULT_DMA_STRICT=y
+# CONFIG_IOMMU_DEFAULT_DMA_LAZY is not set
+# CONFIG_IOMMU_DEFAULT_PASSTHROUGH is not set
+CONFIG_OF_IOMMU=y
+CONFIG_IOMMU_DMA=y
+CONFIG_ARM_SMMU=y
+# CONFIG_ARM_SMMU_LEGACY_DT_BINDINGS is not set
+CONFIG_ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT=y
+CONFIG_ARM_SMMU_MMU_500_CPRE_ERRATA=y
+CONFIG_ARM_SMMU_QCOM=y
+# CONFIG_ARM_SMMU_QCOM_DEBUG is not set
+CONFIG_ARM_SMMU_V3=y
+# CONFIG_ARM_SMMU_V3_SVA is not set
+# CONFIG_TEGRA241_CMDQV is not set
+CONFIG_QCOM_IOMMU=y
+# CONFIG_IOMMUFD is not set
+# CONFIG_VIRTIO_IOMMU is not set
+
+#
+# Remoteproc drivers
+#
+CONFIG_REMOTEPROC=y
+# CONFIG_REMOTEPROC_CDEV is not set
+CONFIG_QCOM_PIL_INFO=m
+CONFIG_QCOM_RPROC_COMMON=m
+CONFIG_QCOM_Q6V5_COMMON=m
+# CONFIG_QCOM_Q6V5_ADSP is not set
+CONFIG_QCOM_Q6V5_MSS=m
+CONFIG_QCOM_Q6V5_PAS=m
+CONFIG_QCOM_Q6V5_WCSS=m
+CONFIG_QCOM_SYSMON=m
+CONFIG_QCOM_WCNSS_PIL=m
+# end of Remoteproc drivers
+
+#
+# Rpmsg drivers
+#
+CONFIG_RPMSG=y
+CONFIG_RPMSG_CHAR=y
+CONFIG_RPMSG_CTRL=y
+CONFIG_RPMSG_NS=y
+CONFIG_RPMSG_QCOM_GLINK=y
+CONFIG_RPMSG_QCOM_GLINK_RPM=y
+CONFIG_RPMSG_QCOM_GLINK_SMEM=y
+CONFIG_RPMSG_QCOM_SMD=y
+# CONFIG_RPMSG_VIRTIO is not set
+# end of Rpmsg drivers
+
+CONFIG_SOUNDWIRE=m
+
+#
+# SoundWire Devices
+#
+CONFIG_SOUNDWIRE_QCOM=m
+
+#
+# SOC (System On Chip) specific Drivers
+#
+
+#
+# Amlogic SoC drivers
+#
+# end of Amlogic SoC drivers
+
+#
+# Broadcom SoC drivers
+#
+# end of Broadcom SoC drivers
+
+#
+# NXP/Freescale QorIQ SoC drivers
+#
+# CONFIG_QUICC_ENGINE is not set
+# CONFIG_FSL_RCPM is not set
+# end of NXP/Freescale QorIQ SoC drivers
+
+#
+# fujitsu SoC drivers
+#
+# end of fujitsu SoC drivers
+
+#
+# i.MX SoC drivers
+#
+# end of i.MX SoC drivers
+
+#
+# Enable LiteX SoC Builder specific drivers
+#
+# CONFIG_LITEX_SOC_CONTROLLER is not set
+# end of Enable LiteX SoC Builder specific drivers
+
+# CONFIG_WPCM450_SOC is not set
+
+#
+# Qualcomm SoC drivers
+#
+CONFIG_QCOM_AOSS_QMP=m
+CONFIG_QCOM_COMMAND_DB=y
+CONFIG_QCOM_GENI_SE=m
+CONFIG_QCOM_GSBI=m
+CONFIG_QCOM_LLCC=m
+CONFIG_QCOM_MDT_LOADER=m
+CONFIG_QCOM_OCMEM=m
+CONFIG_QCOM_PD_MAPPER=m
+CONFIG_QCOM_PDR_HELPERS=m
+CONFIG_QCOM_PDR_MSG=m
+# CONFIG_QCOM_PMIC_PDCHARGER_ULOG is not set
+CONFIG_QCOM_PMIC_GLINK=m
+CONFIG_QCOM_QMI_HELPERS=m
+CONFIG_QCOM_RAMP_CTRL=m
+CONFIG_QCOM_RMTFS_MEM=m
+CONFIG_QCOM_RPM_MASTER_STATS=m
+CONFIG_QCOM_RPMH=y
+CONFIG_QCOM_SNS_REG=m
+CONFIG_QCOM_SMEM=y
+CONFIG_QCOM_SMD_RPM=y
+CONFIG_QCOM_SMEM_STATE=y
+CONFIG_QCOM_SMP2P=y
+CONFIG_QCOM_SMSM=y
+CONFIG_QCOM_SOCINFO=y
+CONFIG_QCOM_SPM=m
+CONFIG_QCOM_STATS=m
+CONFIG_QCOM_WCNSS_CTRL=m
+CONFIG_QCOM_APR=m
+CONFIG_QCOM_ICC_BWMON=m
+# CONFIG_QCOM_PBS is not set
+# end of Qualcomm SoC drivers
+
+CONFIG_QCOM_UBWC_CONFIG=m
+# CONFIG_SOC_TI is not set
+
+#
+# Xilinx SoC drivers
+#
+# end of Xilinx SoC drivers
+# end of SOC (System On Chip) specific Drivers
+
+#
+# PM Domains
+#
+
+#
+# Amlogic PM Domains
+#
+# end of Amlogic PM Domains
+
+#
+# Broadcom PM Domains
+#
+# end of Broadcom PM Domains
+
+#
+# i.MX PM Domains
+#
+# end of i.MX PM Domains
+
+#
+# Qualcomm PM Domains
+#
+CONFIG_QCOM_CPR=m
+CONFIG_QCOM_RPMHPD=y
+CONFIG_QCOM_RPMPD=y
+# end of Qualcomm PM Domains
+# end of PM Domains
+
+CONFIG_PM_DEVFREQ=y
+
+#
+# DEVFREQ Governors
+#
+CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
+CONFIG_DEVFREQ_GOV_PERFORMANCE=y
+CONFIG_DEVFREQ_GOV_POWERSAVE=y
+CONFIG_DEVFREQ_GOV_USERSPACE=y
+CONFIG_DEVFREQ_GOV_PASSIVE=y
+
+#
+# DEVFREQ Drivers
+#
+# CONFIG_PM_DEVFREQ_EVENT is not set
+CONFIG_EXTCON=y
+
+#
+# Extcon Device Drivers
+#
+# CONFIG_EXTCON_ADC_JACK is not set
+# CONFIG_EXTCON_FSA9480 is not set
+CONFIG_EXTCON_GPIO=y
+# CONFIG_EXTCON_LC824206XA is not set
+# CONFIG_EXTCON_MAX3355 is not set
+# CONFIG_EXTCON_MAX14526 is not set
+# CONFIG_EXTCON_PTN5150 is not set
+# CONFIG_EXTCON_QCOM_SPMI_MISC is not set
+# CONFIG_EXTCON_RT8973A is not set
+CONFIG_EXTCON_SM5502=y
+CONFIG_EXTCON_USB_GPIO=y
+# CONFIG_EXTCON_USBC_TUSB320 is not set
+CONFIG_MEMORY=y
+# CONFIG_ARM_PL172_MPMC is not set
+CONFIG_IIO=y
+CONFIG_IIO_BUFFER=y
+CONFIG_IIO_BUFFER_CB=m
+CONFIG_IIO_BUFFER_DMA=m
+CONFIG_IIO_BUFFER_DMAENGINE=m
+CONFIG_IIO_BUFFER_HW_CONSUMER=m
+CONFIG_IIO_KFIFO_BUF=m
+CONFIG_IIO_TRIGGERED_BUFFER=m
+# CONFIG_IIO_CONFIGFS is not set
+CONFIG_IIO_TRIGGER=y
+CONFIG_IIO_CONSUMERS_PER_TRIGGER=2
+# CONFIG_IIO_SW_DEVICE is not set
+# CONFIG_IIO_SW_TRIGGER is not set
+# CONFIG_IIO_TRIGGERED_EVENT is not set
+
+#
+# Accelerometers
+#
+# CONFIG_ADIS16201 is not set
+# CONFIG_ADIS16209 is not set
+# CONFIG_ADXL313_I2C is not set
+# CONFIG_ADXL313_SPI is not set
+# CONFIG_ADXL345_I2C is not set
+# CONFIG_ADXL345_SPI is not set
+# CONFIG_ADXL355_I2C is not set
+# CONFIG_ADXL355_SPI is not set
+# CONFIG_ADXL367_SPI is not set
+# CONFIG_ADXL367_I2C is not set
+# CONFIG_ADXL372_SPI is not set
+# CONFIG_ADXL372_I2C is not set
+# CONFIG_ADXL380_SPI is not set
+# CONFIG_ADXL380_I2C is not set
+# CONFIG_BMA180 is not set
+# CONFIG_BMA220 is not set
+# CONFIG_BMA400 is not set
+CONFIG_BMC150_ACCEL=m
+CONFIG_BMC150_ACCEL_I2C=m
+CONFIG_BMC150_ACCEL_SPI=m
+# CONFIG_BMI088_ACCEL is not set
+# CONFIG_DA280 is not set
+# CONFIG_DA311 is not set
+# CONFIG_DMARD06 is not set
+# CONFIG_DMARD09 is not set
+# CONFIG_DMARD10 is not set
+# CONFIG_FXLS8962AF_I2C is not set
+# CONFIG_FXLS8962AF_SPI is not set
+CONFIG_HID_SENSOR_ACCEL_3D=m
+CONFIG_IIO_QCOM_SMGR_ACCEL=m
+# CONFIG_IIO_ST_ACCEL_3AXIS is not set
+# CONFIG_IIO_KX022A_SPI is not set
+# CONFIG_IIO_KX022A_I2C is not set
+# CONFIG_KXSD9 is not set
+# CONFIG_KXCJK1013 is not set
+# CONFIG_MC3230 is not set
+# CONFIG_MMA7455_I2C is not set
+# CONFIG_MMA7455_SPI is not set
+# CONFIG_MMA7660 is not set
+# CONFIG_MMA8452 is not set
+# CONFIG_MMA9551 is not set
+# CONFIG_MMA9553 is not set
+# CONFIG_MSA311 is not set
+# CONFIG_MXC4005 is not set
+# CONFIG_MXC6255 is not set
+# CONFIG_SCA3000 is not set
+# CONFIG_SCA3300 is not set
+# CONFIG_STK8312 is not set
+# CONFIG_STK8BA50 is not set
+# end of Accelerometers
+
+#
+# Analog to digital converters
+#
+# CONFIG_AD4000 is not set
+# CONFIG_AD4030 is not set
+# CONFIG_AD4080 is not set
+# CONFIG_AD4130 is not set
+# CONFIG_AD4134 is not set
+# CONFIG_AD4170_4 is not set
+# CONFIG_AD4691 is not set
+# CONFIG_AD4695 is not set
+# CONFIG_AD4851 is not set
+# CONFIG_AD7091R5 is not set
+# CONFIG_AD7091R8 is not set
+# CONFIG_AD7124 is not set
+# CONFIG_AD7173 is not set
+# CONFIG_AD7191 is not set
+# CONFIG_AD7192 is not set
+# CONFIG_AD7266 is not set
+# CONFIG_AD7280 is not set
+# CONFIG_AD7291 is not set
+# CONFIG_AD7292 is not set
+# CONFIG_AD7298 is not set
+# CONFIG_AD7380 is not set
+# CONFIG_AD7476 is not set
+# CONFIG_AD7606_IFACE_PARALLEL is not set
+# CONFIG_AD7606_IFACE_SPI is not set
+# CONFIG_AD7625 is not set
+# CONFIG_AD7766 is not set
+# CONFIG_AD7768_1 is not set
+# CONFIG_AD7779 is not set
+# CONFIG_AD7780 is not set
+# CONFIG_AD7791 is not set
+# CONFIG_AD7793 is not set
+# CONFIG_AD7887 is not set
+# CONFIG_AD7923 is not set
+# CONFIG_AD7944 is not set
+# CONFIG_AD7949 is not set
+# CONFIG_AD799X is not set
+# CONFIG_AD9467 is not set
+# CONFIG_ADE9000 is not set
+# CONFIG_CC10001_ADC is not set
+# CONFIG_ENVELOPE_DETECTOR is not set
+# CONFIG_GEHC_PMC_ADC is not set
+# CONFIG_HI8435 is not set
+# CONFIG_HX711 is not set
+# CONFIG_INA2XX_ADC is not set
+# CONFIG_LTC2309 is not set
+# CONFIG_LTC2471 is not set
+# CONFIG_LTC2485 is not set
+# CONFIG_LTC2496 is not set
+# CONFIG_LTC2497 is not set
+# CONFIG_MAX1027 is not set
+# CONFIG_MAX11100 is not set
+# CONFIG_MAX1118 is not set
+# CONFIG_MAX11205 is not set
+# CONFIG_MAX11410 is not set
+# CONFIG_MAX1241 is not set
+# CONFIG_MAX1363 is not set
+# CONFIG_MAX14001 is not set
+# CONFIG_MAX34408 is not set
+# CONFIG_MAX9611 is not set
+# CONFIG_MCP320X is not set
+# CONFIG_MCP3422 is not set
+# CONFIG_MCP3564 is not set
+# CONFIG_MCP3911 is not set
+# CONFIG_NAU7802 is not set
+# CONFIG_NCT7201 is not set
+# CONFIG_PAC1921 is not set
+# CONFIG_PAC1934 is not set
+CONFIG_QCOM_VADC_COMMON=m
+CONFIG_QCOM_SPMI_RRADC=m
+CONFIG_QCOM_SPMI_IADC=m
+CONFIG_QCOM_SPMI_VADC=m
+CONFIG_QCOM_SPMI_ADC5=m
+# CONFIG_QCOM_SPMI_ADC5_GEN3 is not set
+# CONFIG_ROHM_BD79112 is not set
+# CONFIG_ROHM_BD79124 is not set
+# CONFIG_RICHTEK_RTQ6056 is not set
+# CONFIG_SD_ADC_MODULATOR is not set
+# CONFIG_STMPE_ADC is not set
+# CONFIG_TI_ADC081C is not set
+# CONFIG_TI_ADC0832 is not set
+# CONFIG_TI_ADC084S021 is not set
+# CONFIG_TI_ADC108S102 is not set
+# CONFIG_TI_ADC12138 is not set
+# CONFIG_TI_ADC128S052 is not set
+# CONFIG_TI_ADC161S626 is not set
+# CONFIG_TI_ADS1015 is not set
+# CONFIG_TI_ADS1018 is not set
+# CONFIG_TI_ADS1100 is not set
+# CONFIG_TI_ADS1119 is not set
+# CONFIG_TI_ADS124S08 is not set
+# CONFIG_TI_ADS1298 is not set
+# CONFIG_TI_ADS131E08 is not set
+# CONFIG_TI_ADS131M02 is not set
+# CONFIG_TI_ADS7138 is not set
+# CONFIG_TI_ADS7924 is not set
+# CONFIG_TI_ADS7950 is not set
+# CONFIG_TI_ADS8344 is not set
+# CONFIG_TI_ADS8688 is not set
+# CONFIG_TI_LMP92064 is not set
+# CONFIG_TI_TLC4541 is not set
+# CONFIG_TI_TSC2046 is not set
+# CONFIG_VF610_ADC is not set
+# CONFIG_XILINX_XADC is not set
+# end of Analog to digital converters
+
+#
+# Analog to digital and digital to analog converters
+#
+# CONFIG_AD74115 is not set
+# CONFIG_AD74413R is not set
+# end of Analog to digital and digital to analog converters
+
+#
+# Analog Front Ends
+#
+# CONFIG_IIO_RESCALE is not set
+# end of Analog Front Ends
+
+#
+# Amplifiers
+#
+# CONFIG_AD8366 is not set
+# CONFIG_ADA4250 is not set
+# CONFIG_ADL8113 is not set
+# CONFIG_HMC425 is not set
+# end of Amplifiers
+
+#
+# Capacitance to digital converters
+#
+# CONFIG_AD7150 is not set
+# CONFIG_AD7746 is not set
+# end of Capacitance to digital converters
+
+#
+# Chemical Sensors
+#
+# CONFIG_AOSONG_AGS02MA is not set
+# CONFIG_ATLAS_PH_SENSOR is not set
+# CONFIG_ATLAS_EZO_SENSOR is not set
+# CONFIG_BME680 is not set
+# CONFIG_CCS811 is not set
+# CONFIG_ENS160 is not set
+# CONFIG_IAQCORE is not set
+# CONFIG_MHZ19B is not set
+# CONFIG_PMS7003 is not set
+# CONFIG_SCD30_CORE is not set
+# CONFIG_SCD4X is not set
+# CONFIG_SEN0322 is not set
+# CONFIG_SENSIRION_SGP30 is not set
+# CONFIG_SENSIRION_SGP40 is not set
+# CONFIG_SPS30_I2C is not set
+# CONFIG_SPS30_SERIAL is not set
+# CONFIG_SENSEAIR_SUNRISE_CO2 is not set
+# CONFIG_VZ89X is not set
+# end of Chemical Sensors
+
+#
+# Hid Sensor IIO Common
+#
+CONFIG_HID_SENSOR_IIO_COMMON=m
+CONFIG_HID_SENSOR_IIO_TRIGGER=m
+# end of Hid Sensor IIO Common
+
+#
+# IIO SCMI Sensors
+#
+# end of IIO SCMI Sensors
+
+CONFIG_IIO_QCOM_SMGR=m
+
+#
+# SSP Sensor Common
+#
+# CONFIG_IIO_SSP_SENSORHUB is not set
+# end of SSP Sensor Common
+
+#
+# Digital to analog converters
+#
+# CONFIG_AD3530R is not set
+# CONFIG_AD3552R_HS is not set
+# CONFIG_AD3552R is not set
+# CONFIG_AD5064 is not set
+# CONFIG_AD5360 is not set
+# CONFIG_AD5380 is not set
+# CONFIG_AD5421 is not set
+# CONFIG_AD5446_SPI is not set
+# CONFIG_AD5446_I2C is not set
+# CONFIG_AD5449 is not set
+# CONFIG_AD5592R is not set
+# CONFIG_AD5593R is not set
+# CONFIG_AD5504 is not set
+# CONFIG_AD5624R_SPI is not set
+# CONFIG_AD5706R is not set
+# CONFIG_AD9739A is not set
+# CONFIG_LTC2688 is not set
+# CONFIG_AD5686_SPI is not set
+# CONFIG_AD5696_I2C is not set
+# CONFIG_AD5755 is not set
+# CONFIG_AD5758 is not set
+# CONFIG_AD5761 is not set
+# CONFIG_AD5764 is not set
+# CONFIG_AD5766 is not set
+# CONFIG_AD5770R is not set
+# CONFIG_AD5791 is not set
+# CONFIG_AD7293 is not set
+# CONFIG_AD7303 is not set
+# CONFIG_AD8460 is not set
+# CONFIG_AD8801 is not set
+# CONFIG_BD79703 is not set
+# CONFIG_DPOT_DAC is not set
+# CONFIG_DS4424 is not set
+# CONFIG_LTC1660 is not set
+# CONFIG_LTC2632 is not set
+# CONFIG_LTC2664 is not set
+# CONFIG_M62332 is not set
+# CONFIG_MAX517 is not set
+# CONFIG_MAX22007 is not set
+# CONFIG_MAX5522 is not set
+# CONFIG_MAX5821 is not set
+# CONFIG_MCP4725 is not set
+# CONFIG_MCP4728 is not set
+# CONFIG_MCP47FEB02 is not set
+# CONFIG_MCP4821 is not set
+# CONFIG_MCP4922 is not set
+# CONFIG_TI_DAC082S085 is not set
+# CONFIG_TI_DAC5571 is not set
+# CONFIG_TI_DAC7311 is not set
+# CONFIG_TI_DAC7612 is not set
+# CONFIG_VF610_DAC is not set
+# end of Digital to analog converters
+
+#
+# IIO dummy driver
+#
+# end of IIO dummy driver
+
+#
+# Filters
+#
+# CONFIG_ADMV8818 is not set
+# end of Filters
+
+#
+# Frequency Synthesizers DDS/PLL
+#
+
+#
+# Clock Generator/Distribution
+#
+# CONFIG_AD9523 is not set
+# end of Clock Generator/Distribution
+
+#
+# Phase-Locked Loop (PLL) frequency synthesizers
+#
+# CONFIG_ADF4350 is not set
+# CONFIG_ADF4371 is not set
+# CONFIG_ADF4377 is not set
+# CONFIG_ADMFM2000 is not set
+# CONFIG_ADMV1013 is not set
+# CONFIG_ADMV1014 is not set
+# CONFIG_ADMV4420 is not set
+# CONFIG_ADRF6780 is not set
+# end of Phase-Locked Loop (PLL) frequency synthesizers
+# end of Frequency Synthesizers DDS/PLL
+
+#
+# Digital gyroscope sensors
+#
+# CONFIG_ADIS16080 is not set
+# CONFIG_ADIS16130 is not set
+# CONFIG_ADIS16136 is not set
+# CONFIG_ADIS16260 is not set
+# CONFIG_ADXRS290 is not set
+# CONFIG_ADXRS450 is not set
+CONFIG_BMG160=m
+CONFIG_BMG160_I2C=m
+CONFIG_BMG160_SPI=m
+# CONFIG_FXAS21002C is not set
+CONFIG_HID_SENSOR_GYRO_3D=m
+# CONFIG_MPU3050_I2C is not set
+# CONFIG_IIO_ST_GYRO_3AXIS is not set
+CONFIG_IIO_QCOM_SMGR_GYRO=m
+# CONFIG_ITG3200 is not set
+# end of Digital gyroscope sensors
+
+#
+# Health Sensors
+#
+
+#
+# Heart Rate Monitors
+#
+# CONFIG_AFE4403 is not set
+# CONFIG_AFE4404 is not set
+# CONFIG_MAX30100 is not set
+# CONFIG_MAX30102 is not set
+# end of Heart Rate Monitors
+# end of Health Sensors
+
+#
+# Humidity sensors
+#
+# CONFIG_AM2315 is not set
+# CONFIG_DHT11 is not set
+# CONFIG_ENS210 is not set
+# CONFIG_HDC100X is not set
+# CONFIG_HDC2010 is not set
+# CONFIG_HDC3020 is not set
+CONFIG_HID_SENSOR_HUMIDITY=m
+# CONFIG_HTS221 is not set
+# CONFIG_HTU21 is not set
+# CONFIG_SI7005 is not set
+# CONFIG_SI7020 is not set
+# end of Humidity sensors
+
+#
+# Inertial measurement units
+#
+# CONFIG_ADIS16400 is not set
+# CONFIG_ADIS16460 is not set
+# CONFIG_ADIS16475 is not set
+# CONFIG_ADIS16480 is not set
+# CONFIG_ADIS16550 is not set
+# CONFIG_BMI160_I2C is not set
+# CONFIG_BMI160_SPI is not set
+# CONFIG_BMI270_I2C is not set
+# CONFIG_BMI270_SPI is not set
+# CONFIG_BMI323_I2C is not set
+# CONFIG_BMI323_SPI is not set
+# CONFIG_BOSCH_BNO055_SERIAL is not set
+# CONFIG_BOSCH_BNO055_I2C is not set
+# CONFIG_FXOS8700_I2C is not set
+# CONFIG_FXOS8700_SPI is not set
+# CONFIG_KMX61 is not set
+# CONFIG_INV_ICM42600_I2C is not set
+# CONFIG_INV_ICM42600_SPI is not set
+# CONFIG_INV_ICM45600_I2C is not set
+# CONFIG_INV_ICM45600_SPI is not set
+# CONFIG_INV_MPU6050_I2C is not set
+# CONFIG_INV_MPU6050_SPI is not set
+# CONFIG_SMI240 is not set
+# CONFIG_SMI330_I2C is not set
+# CONFIG_SMI330_SPI is not set
+# CONFIG_IIO_ST_LSM6DSX is not set
+# CONFIG_IIO_ST_LSM9DS0 is not set
+# end of Inertial measurement units
+
+#
+# Light sensors
+#
+# CONFIG_ADJD_S311 is not set
+# CONFIG_ADUX1020 is not set
+# CONFIG_AL3000A is not set
+# CONFIG_AL3010 is not set
+# CONFIG_AL3320A is not set
+# CONFIG_APDS9160 is not set
+# CONFIG_APDS9300 is not set
+# CONFIG_APDS9306 is not set
+# CONFIG_APDS9960 is not set
+# CONFIG_APDS9999 is not set
+# CONFIG_AS73211 is not set
+# CONFIG_BH1745 is not set
+# CONFIG_BH1750 is not set
+# CONFIG_BH1780 is not set
+# CONFIG_CM32181 is not set
+# CONFIG_CM3232 is not set
+# CONFIG_CM3323 is not set
+# CONFIG_CM3605 is not set
+# CONFIG_CM36651 is not set
+# CONFIG_GP2AP002 is not set
+# CONFIG_GP2AP020A00F is not set
+# CONFIG_SENSORS_ISL29018 is not set
+# CONFIG_SENSORS_ISL29028 is not set
+# CONFIG_ISL29125 is not set
+# CONFIG_ISL76682 is not set
+CONFIG_HID_SENSOR_ALS=m
+CONFIG_HID_SENSOR_PROX=m
+# CONFIG_JSA1212 is not set
+# CONFIG_ROHM_BU27034 is not set
+# CONFIG_RPR0521 is not set
+# CONFIG_LTR390 is not set
+CONFIG_LTR501=m
+# CONFIG_LTRF216A is not set
+# CONFIG_LV0104CS is not set
+# CONFIG_MAX44000 is not set
+# CONFIG_MAX44009 is not set
+# CONFIG_NOA1305 is not set
+# CONFIG_OPT3001 is not set
+# CONFIG_OPT4001 is not set
+# CONFIG_OPT4060 is not set
+# CONFIG_PA12203001 is not set
+# CONFIG_SI1133 is not set
+# CONFIG_SI1145 is not set
+# CONFIG_STK3310 is not set
+# CONFIG_ST_UVIS25 is not set
+# CONFIG_TCS3414 is not set
+# CONFIG_TCS3472 is not set
+# CONFIG_SENSORS_TSL2563 is not set
+# CONFIG_TSL2583 is not set
+# CONFIG_TSL2591 is not set
+# CONFIG_TSL2772 is not set
+# CONFIG_TSL4531 is not set
+# CONFIG_US5182D is not set
+# CONFIG_VCNL4000 is not set
+# CONFIG_VCNL4035 is not set
+# CONFIG_VEML3235 is not set
+# CONFIG_VEML3328 is not set
+# CONFIG_VEML6030 is not set
+# CONFIG_VEML6040 is not set
+# CONFIG_VEML6046X00 is not set
+# CONFIG_VEML6070 is not set
+# CONFIG_VEML6075 is not set
+# CONFIG_VL6180 is not set
+# CONFIG_ZOPT2201 is not set
+# end of Light sensors
+
+#
+# Magnetometer sensors
+#
+# CONFIG_AF8133J is not set
+# CONFIG_AK8974 is not set
+# CONFIG_AK8975 is not set
+# CONFIG_AK09911 is not set
+# CONFIG_ALS31300 is not set
+CONFIG_BMC150_MAGN=m
+CONFIG_BMC150_MAGN_I2C=m
+# CONFIG_BMC150_MAGN_SPI is not set
+# CONFIG_MAG3110 is not set
+CONFIG_HID_SENSOR_MAGNETOMETER_3D=m
+# CONFIG_MMC35240 is not set
+# CONFIG_MMC5633 is not set
+# CONFIG_MMC5983 is not set
+CONFIG_IIO_QCOM_SMGR_MAG=m
+# CONFIG_IIO_ST_MAGN_3AXIS is not set
+# CONFIG_INFINEON_TLV493D is not set
+# CONFIG_SENSORS_HMC5843_I2C is not set
+# CONFIG_SENSORS_HMC5843_SPI is not set
+# CONFIG_SENSORS_RM3100_I2C is not set
+# CONFIG_SENSORS_RM3100_SPI is not set
+# CONFIG_SI7210 is not set
+# CONFIG_TI_TMAG5273 is not set
+# CONFIG_YAMAHA_YAS530 is not set
+# end of Magnetometer sensors
+
+#
+# Multiplexers
+#
+# CONFIG_IIO_MUX is not set
+# end of Multiplexers
+
+#
+# Inclinometer sensors
+#
+CONFIG_HID_SENSOR_INCLINOMETER_3D=m
+CONFIG_HID_SENSOR_DEVICE_ROTATION=m
+# end of Inclinometer sensors
+
+#
+# Triggers - standalone
+#
+CONFIG_IIO_SYSFS_TRIGGER=m
+# end of Triggers - standalone
+
+#
+# Linear and angular position sensors
+#
+CONFIG_HID_SENSOR_CUSTOM_INTEL_HINGE=m
+# end of Linear and angular position sensors
+
+#
+# Digital potentiometers
+#
+# CONFIG_AD5110 is not set
+# CONFIG_AD5272 is not set
+# CONFIG_DS1803 is not set
+# CONFIG_MAX5432 is not set
+# CONFIG_MAX5481 is not set
+# CONFIG_MAX5487 is not set
+# CONFIG_MCP4018 is not set
+# CONFIG_MCP4131 is not set
+# CONFIG_MCP4531 is not set
+# CONFIG_MCP41010 is not set
+# CONFIG_TPL0102 is not set
+# CONFIG_X9250 is not set
+# end of Digital potentiometers
+
+#
+# Digital potentiostats
+#
+# CONFIG_LMP91000 is not set
+# end of Digital potentiostats
+
+#
+# Pressure sensors
+#
+# CONFIG_ABP060MG is not set
+# CONFIG_ABP2030PA_I2C is not set
+# CONFIG_ABP2030PA_SPI is not set
+# CONFIG_ROHM_BM1390 is not set
+# CONFIG_BMP280 is not set
+CONFIG_IIO_QCOM_SMGR_PRESSURE=m
+# CONFIG_DLHL60D is not set
+# CONFIG_DPS310 is not set
+CONFIG_HID_SENSOR_PRESS=m
+# CONFIG_HP03 is not set
+# CONFIG_HSC030PA is not set
+# CONFIG_ICP10100 is not set
+# CONFIG_MPL115_I2C is not set
+# CONFIG_MPL115_SPI is not set
+# CONFIG_MPL3115 is not set
+# CONFIG_MPRLS0025PA_I2C is not set
+# CONFIG_MPRLS0025PA_SPI is not set
+# CONFIG_MS5611 is not set
+# CONFIG_MS5637 is not set
+# CONFIG_SDP500 is not set
+# CONFIG_IIO_ST_PRESS is not set
+# CONFIG_T5403 is not set
+# CONFIG_HP206C is not set
+# CONFIG_ZPA2326 is not set
+# CONFIG_ADP810 is not set
+# end of Pressure sensors
+
+#
+# Lightning sensors
+#
+# CONFIG_AS3935 is not set
+# end of Lightning sensors
+
+#
+# Proximity and distance sensors
+#
+# CONFIG_D3323AA is not set
+# CONFIG_HX9023S is not set
+CONFIG_IIO_QCOM_SMGR_PROX=m
+# CONFIG_IRSD200 is not set
+# CONFIG_ISL29501 is not set
+# CONFIG_LIDAR_LITE_V2 is not set
+# CONFIG_MB1232 is not set
+# CONFIG_PING is not set
+# CONFIG_RFD77402 is not set
+# CONFIG_SRF04 is not set
+# CONFIG_SX9310 is not set
+# CONFIG_SX9324 is not set
+# CONFIG_SX9360 is not set
+# CONFIG_SX9500 is not set
+# CONFIG_SRF08 is not set
+# CONFIG_VCNL3020 is not set
+# CONFIG_VL53L0X_I2C is not set
+# CONFIG_VL53L1X_I2C is not set
+# CONFIG_AW96103 is not set
+# end of Proximity and distance sensors
+
+#
+# Resolver to digital converters
+#
+# CONFIG_AD2S90 is not set
+# CONFIG_AD2S1200 is not set
+# CONFIG_AD2S1210 is not set
+# end of Resolver to digital converters
+
+#
+# Temperature sensors
+#
+# CONFIG_LTC2983 is not set
+# CONFIG_MAXIM_THERMOCOUPLE is not set
+CONFIG_HID_SENSOR_TEMP=m
+# CONFIG_MLX90614 is not set
+# CONFIG_MLX90632 is not set
+# CONFIG_MLX90635 is not set
+# CONFIG_TMP006 is not set
+# CONFIG_TMP007 is not set
+# CONFIG_TMP117 is not set
+# CONFIG_TSYS01 is not set
+# CONFIG_TSYS02D is not set
+# CONFIG_MAX30208 is not set
+# CONFIG_MAX31856 is not set
+# CONFIG_MAX31865 is not set
+# CONFIG_MCP9600 is not set
+# end of Temperature sensors
+
+CONFIG_PWM=y
+# CONFIG_PWM_DEBUG is not set
+# CONFIG_PWM_PROVIDE_GPIO is not set
+# CONFIG_PWM_ARGON_FAN_HAT is not set
+# CONFIG_PWM_ATMEL_TCB is not set
+CONFIG_PWM_CLK=m
+# CONFIG_PWM_FSL_FTM is not set
+CONFIG_PWM_GPIO=m
+# CONFIG_PWM_IPQ is not set
+# CONFIG_PWM_MC33XS2410 is not set
+# CONFIG_PWM_PCA9685 is not set
+# CONFIG_PWM_STMPE is not set
+# CONFIG_PWM_XILINX is not set
+
+#
+# IRQ chip support
+#
+CONFIG_IRQCHIP=y
+CONFIG_ARM_GIC=y
+CONFIG_ARM_GIC_MAX_NR=1
+CONFIG_ARM_GIC_V3=y
+CONFIG_ARM_GIC_ITS_PARENT=y
+CONFIG_ARM_GIC_V3_ITS=y
+CONFIG_ARM_GIC_V5=y
+CONFIG_IRQ_MSI_LIB=y
+# CONFIG_AL_FIC is not set
+# CONFIG_XILINX_INTC is not set
+# CONFIG_QCOM_PDC is not set
+# CONFIG_QCOM_MPM is not set
+# end of IRQ chip support
+
+# CONFIG_IPACK_BUS is not set
+CONFIG_RESET_CONTROLLER=y
+CONFIG_RESET_GPIO=y
+# CONFIG_RESET_QCOM_AOSS is not set
+# CONFIG_RESET_QCOM_PDC is not set
+# CONFIG_RESET_TI_SYSCON is not set
+# CONFIG_RESET_TI_TPS380X is not set
+
+#
+# PHY Subsystem
+#
+CONFIG_GENERIC_PHY=y
+# CONFIG_PHY_CAN_TRANSCEIVER is not set
+# CONFIG_PHY_GOOGLE_USB is not set
+# CONFIG_PHY_NXP_PTN3222 is not set
+# CONFIG_PHY_NXP_TJA1145 is not set
+CONFIG_PHY_SNPS_EUSB2=m
+
+#
+# PHY drivers for Broadcom platforms
+#
+# CONFIG_BCM_KONA_USB2_PHY is not set
+# end of PHY drivers for Broadcom platforms
+
+# CONFIG_PHY_CADENCE_TORRENT is not set
+# CONFIG_PHY_CADENCE_DPHY is not set
+# CONFIG_PHY_CADENCE_DPHY_RX is not set
+# CONFIG_PHY_CADENCE_SIERRA is not set
+# CONFIG_PHY_CADENCE_SALVO is not set
+# CONFIG_PHY_PXA_28NM_HSIC is not set
+# CONFIG_PHY_PXA_28NM_USB2 is not set
+# CONFIG_PHY_CPCAP_USB is not set
+# CONFIG_PHY_MAPPHONE_MDM6600 is not set
+# CONFIG_PHY_OCELOT_SERDES is not set
+# CONFIG_PHY_QCOM_APQ8064_SATA is not set
+# CONFIG_PHY_QCOM_EDP is not set
+# CONFIG_PHY_QCOM_IPQ4019_USB is not set
+# CONFIG_PHY_QCOM_IPQ806X_SATA is not set
+# CONFIG_PHY_QCOM_PCIE2 is not set
+CONFIG_PHY_QCOM_QMP=y
+CONFIG_PHY_QCOM_QMP_COMBO=y
+CONFIG_PHY_QCOM_QMP_UFS=y
+CONFIG_PHY_QCOM_QMP_USB=y
+# CONFIG_PHY_QCOM_QMP_USB_LEGACY is not set
+CONFIG_PHY_QCOM_QUSB2=y
+CONFIG_PHY_QCOM_EUSB2_REPEATER=y
+CONFIG_PHY_QCOM_M31_USB=m
+# CONFIG_PHY_QCOM_UNIPHY_PCIE_28LP is not set
+CONFIG_PHY_QCOM_M31_EUSB=m
+CONFIG_PHY_QCOM_USB_HS=y
+# CONFIG_PHY_QCOM_USB_SNPS_FEMTO_V2 is not set
+# CONFIG_PHY_QCOM_USB_HSIC is not set
+# CONFIG_PHY_QCOM_USB_HS_28NM is not set
+# CONFIG_PHY_QCOM_USB_SS is not set
+# CONFIG_PHY_QCOM_IPQ806X_USB is not set
+# CONFIG_PHY_QCOM_SGMII_ETH is not set
+# CONFIG_PHY_TI_DS125DF111 is not set
+# CONFIG_PHY_TUSB1210 is not set
+# end of PHY Subsystem
+
+# CONFIG_POWERCAP is not set
+# CONFIG_MCB is not set
+
+#
+# Performance monitor support
+#
+# CONFIG_ARM_CCI_PMU is not set
+# CONFIG_ARM_CCN is not set
+# CONFIG_ARM_CMN is not set
+# CONFIG_ARM_NI is not set
+CONFIG_ARM_PMU=y
+# CONFIG_ARM_SMMU_V3_PMU is not set
+CONFIG_ARM_PMUV3=y
+# CONFIG_ARM_DSU_PMU is not set
+# CONFIG_ARM_SPE_PMU is not set
+CONFIG_ARM64_BRBE=y
+# CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU is not set
+# end of Performance monitor support
+
+# CONFIG_RAS is not set
+
+#
+# Android
+#
+CONFIG_ANDROID_BINDER_IPC=y
+# CONFIG_ANDROID_BINDERFS is not set
+CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"
+# end of Android
+
+# CONFIG_LIBNVDIMM is not set
+# CONFIG_DAX is not set
+CONFIG_NVMEM=y
+CONFIG_NVMEM_SYSFS=y
+CONFIG_NVMEM_LAYOUTS=y
+
+#
+# Layout Types
+#
+# CONFIG_NVMEM_LAYOUT_SL28_VPD is not set
+# CONFIG_NVMEM_LAYOUT_ONIE_TLV is not set
+# CONFIG_NVMEM_LAYOUT_U_BOOT_ENV is not set
+# end of Layout Types
+
+CONFIG_NVMEM_QCOM_QFPROM=y
+CONFIG_NVMEM_QCOM_SEC_QFPROM=m
+# CONFIG_NVMEM_RMEM is not set
+# CONFIG_NVMEM_SPMI_SDAM is not set
+
+#
+# HW tracing support
+#
+# CONFIG_STM is not set
+# CONFIG_INTEL_TH is not set
+# end of HW tracing support
+
+# CONFIG_FPGA is not set
+# CONFIG_FSI is not set
+# CONFIG_TEE is not set
+# CONFIG_MUX_CORE is not set
+CONFIG_PM_OPP=y
+# CONFIG_SIOX is not set
+CONFIG_SLIMBUS=m
+CONFIG_SLIM_QCOM_NGD_CTRL=m
+CONFIG_INTERCONNECT=y
+CONFIG_INTERCONNECT_QCOM=y
+# CONFIG_INTERCONNECT_QCOM_ELIZA is not set
+# CONFIG_INTERCONNECT_QCOM_GLYMUR is not set
+# CONFIG_INTERCONNECT_QCOM_HAWI is not set
+# CONFIG_INTERCONNECT_QCOM_KAANAPALI is not set
+# CONFIG_INTERCONNECT_QCOM_MSM8916 is not set
+# CONFIG_INTERCONNECT_QCOM_MSM8937 is not set
+# CONFIG_INTERCONNECT_QCOM_MSM8939 is not set
+# CONFIG_INTERCONNECT_QCOM_MSM8953 is not set
+# CONFIG_INTERCONNECT_QCOM_MSM8976 is not set
+# CONFIG_INTERCONNECT_QCOM_MSM8996 is not set
+# CONFIG_INTERCONNECT_QCOM_NORD is not set
+# CONFIG_INTERCONNECT_QCOM_OSM_L3 is not set
+# CONFIG_INTERCONNECT_QCOM_QCM2290 is not set
+# CONFIG_INTERCONNECT_QCOM_QCS404 is not set
+# CONFIG_INTERCONNECT_QCOM_QCS615 is not set
+# CONFIG_INTERCONNECT_QCOM_QCS8300 is not set
+# CONFIG_INTERCONNECT_QCOM_QDU1000 is not set
+CONFIG_INTERCONNECT_QCOM_RPMH_POSSIBLE=y
+# CONFIG_INTERCONNECT_QCOM_SA8775P is not set
+# CONFIG_INTERCONNECT_QCOM_SAR2130P is not set
+# CONFIG_INTERCONNECT_QCOM_SC7180 is not set
+# CONFIG_INTERCONNECT_QCOM_SC7280 is not set
+# CONFIG_INTERCONNECT_QCOM_SC8180X is not set
+# CONFIG_INTERCONNECT_QCOM_SC8280XP is not set
+CONFIG_INTERCONNECT_QCOM_SDM660=y
+# CONFIG_INTERCONNECT_QCOM_SDM670 is not set
+# CONFIG_INTERCONNECT_QCOM_SDM845 is not set
+# CONFIG_INTERCONNECT_QCOM_SDX75 is not set
+# CONFIG_INTERCONNECT_QCOM_SHIKRA is not set
+# CONFIG_INTERCONNECT_QCOM_SM6115 is not set
+# CONFIG_INTERCONNECT_QCOM_SM6350 is not set
+# CONFIG_INTERCONNECT_QCOM_SM7150 is not set
+# CONFIG_INTERCONNECT_QCOM_MILOS is not set
+# CONFIG_INTERCONNECT_QCOM_SM8150 is not set
+# CONFIG_INTERCONNECT_QCOM_SM8250 is not set
+# CONFIG_INTERCONNECT_QCOM_SM8350 is not set
+# CONFIG_INTERCONNECT_QCOM_SM8450 is not set
+# CONFIG_INTERCONNECT_QCOM_SM8550 is not set
+# CONFIG_INTERCONNECT_QCOM_SM8650 is not set
+# CONFIG_INTERCONNECT_QCOM_SM8750 is not set
+# CONFIG_INTERCONNECT_QCOM_X1E80100 is not set
+CONFIG_INTERCONNECT_QCOM_SMD_RPM=y
+CONFIG_INTERCONNECT_CLK=y
+# CONFIG_COUNTER is not set
+# CONFIG_MOST is not set
+# CONFIG_PECI is not set
+# CONFIG_HTE is not set
+# CONFIG_CDX_BUS is not set
+# end of Device Drivers
+
+#
+# File systems
+#
+CONFIG_DCACHE_WORD_ACCESS=y
+# CONFIG_VALIDATE_FS_PARSER is not set
+CONFIG_FS_IOMAP=y
+CONFIG_FS_STACK=y
+CONFIG_BUFFER_HEAD=y
+CONFIG_LEGACY_DIRECT_IO=y
+# CONFIG_EXT2_FS is not set
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_USE_FOR_EXT2=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+# CONFIG_EXT4_DEBUG is not set
+CONFIG_JBD2=y
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_JFS_FS is not set
+CONFIG_XFS_FS=y
+CONFIG_XFS_SUPPORT_V4=y
+CONFIG_XFS_SUPPORT_ASCII_CI=y
+# CONFIG_XFS_QUOTA is not set
+CONFIG_XFS_POSIX_ACL=y
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_ONLINE_SCRUB is not set
+# CONFIG_XFS_WARN is not set
+# CONFIG_XFS_DEBUG is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+CONFIG_BTRFS_FS=y
+CONFIG_BTRFS_FS_POSIX_ACL=y
+# CONFIG_BTRFS_FS_RUN_SANITY_TESTS is not set
+# CONFIG_BTRFS_DEBUG is not set
+# CONFIG_BTRFS_ASSERT is not set
+# CONFIG_BTRFS_EXPERIMENTAL is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_F2FS_FS=y
+CONFIG_F2FS_STAT_FS=y
+CONFIG_F2FS_FS_XATTR=y
+CONFIG_F2FS_FS_POSIX_ACL=y
+# CONFIG_F2FS_FS_SECURITY is not set
+# CONFIG_F2FS_CHECK_FS is not set
+# CONFIG_F2FS_FAULT_INJECTION is not set
+# CONFIG_F2FS_FS_COMPRESSION is not set
+CONFIG_F2FS_IOSTAT=y
+# CONFIG_F2FS_UNFAIR_RWSEM is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_EXPORTFS=y
+CONFIG_EXPORTFS_BLOCK_OPS=y
+CONFIG_FILE_LOCKING=y
+# CONFIG_FS_ENCRYPTION is not set
+# CONFIG_FS_VERITY is not set
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_FANOTIFY=y
+CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
+CONFIG_QUOTA=y
+# CONFIG_QUOTA_NETLINK_INTERFACE is not set
+# CONFIG_QUOTA_DEBUG is not set
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=y
+CONFIG_FUSE_FS=m
+CONFIG_CUSE=m
+# CONFIG_VIRTIO_FS is not set
+CONFIG_FUSE_PASSTHROUGH=y
+CONFIG_FUSE_IO_URING=y
+CONFIG_OVERLAY_FS=m
+# CONFIG_OVERLAY_FS_REDIRECT_DIR is not set
+CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW=y
+# CONFIG_OVERLAY_FS_INDEX is not set
+# CONFIG_OVERLAY_FS_XINO_AUTO is not set
+# CONFIG_OVERLAY_FS_METACOPY is not set
+# CONFIG_OVERLAY_FS_DEBUG is not set
+
+#
+# Caches
+#
+CONFIG_NETFS_SUPPORT=m
+# CONFIG_NETFS_STATS is not set
+# CONFIG_NETFS_DEBUG is not set
+CONFIG_FSCACHE=y
+# CONFIG_FSCACHE_STATS is not set
+CONFIG_CACHEFILES=m
+# CONFIG_CACHEFILES_DEBUG is not set
+# CONFIG_CACHEFILES_ERROR_INJECTION is not set
+# CONFIG_CACHEFILES_ONDEMAND is not set
+# end of Caches
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+CONFIG_UDF_FS=m
+# end of CD-ROM/DVD Filesystems
+
+#
+# DOS/FAT/EXFAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_FAT_DEFAULT_UTF8=y
+CONFIG_EXFAT_FS=y
+CONFIG_EXFAT_DEFAULT_IOCHARSET="utf8"
+# CONFIG_NTFS_FS is not set
+CONFIG_NTFS3_FS=m
+# CONFIG_NTFS3_64BIT_CLUSTER is not set
+# CONFIG_NTFS3_LZX_XPRESS is not set
+# CONFIG_NTFS3_FS_POSIX_ACL is not set
+# end of DOS/FAT/EXFAT/NT Filesystems
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_PROC_VMCORE=y
+# CONFIG_PROC_VMCORE_DEVICE_DUMP is not set
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_PROC_CHILDREN=y
+CONFIG_KERNFS=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_TMPFS_XATTR=y
+# CONFIG_TMPFS_INODE64 is not set
+# CONFIG_TMPFS_QUOTA is not set
+CONFIG_ARCH_SUPPORTS_HUGETLBFS=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING=y
+CONFIG_ARCH_HAS_GIGANTIC_PAGE=y
+CONFIG_CONFIGFS_FS=y
+CONFIG_EFIVAR_FS=m
+# end of Pseudo filesystems
+
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ORANGEFS_FS is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_ECRYPT_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_FILE_CACHE=y
+# CONFIG_SQUASHFS_FILE_DIRECT is not set
+CONFIG_SQUASHFS_DECOMP_SINGLE=y
+# CONFIG_SQUASHFS_CHOICE_DECOMP_BY_MOUNT is not set
+CONFIG_SQUASHFS_COMPILE_DECOMP_SINGLE=y
+# CONFIG_SQUASHFS_COMPILE_DECOMP_MULTI is not set
+# CONFIG_SQUASHFS_COMPILE_DECOMP_MULTI_PERCPU is not set
+CONFIG_SQUASHFS_XATTR=y
+# CONFIG_SQUASHFS_COMP_CACHE_FULL is not set
+CONFIG_SQUASHFS_ZLIB=y
+# CONFIG_SQUASHFS_LZ4 is not set
+# CONFIG_SQUASHFS_LZO is not set
+CONFIG_SQUASHFS_XZ=y
+CONFIG_SQUASHFS_ZSTD=y
+# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX6FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_PSTORE=y
+CONFIG_PSTORE_DEFAULT_KMSG_BYTES=10240
+CONFIG_PSTORE_COMPRESS=y
+CONFIG_PSTORE_CONSOLE=y
+CONFIG_PSTORE_PMSG=y
+# CONFIG_PSTORE_FTRACE is not set
+CONFIG_PSTORE_RAM=y
+# CONFIG_PSTORE_BLK is not set
+# CONFIG_UFS_FS is not set
+CONFIG_EROFS_FS=m
+# CONFIG_EROFS_FS_DEBUG is not set
+CONFIG_EROFS_FS_XATTR=y
+CONFIG_EROFS_FS_POSIX_ACL=y
+CONFIG_EROFS_FS_SECURITY=y
+CONFIG_EROFS_FS_BACKED_BY_FILE=y
+CONFIG_EROFS_FS_ZIP=y
+CONFIG_EROFS_FS_ZIP_LZMA=y
+CONFIG_EROFS_FS_ZIP_LZMA_DEFAULT_MAX_STREAMS=8
+CONFIG_EROFS_FS_ZIP_DEFLATE=y
+CONFIG_EROFS_FS_ZIP_ZSTD=y
+# CONFIG_EROFS_FS_ZIP_ACCEL is not set
+# CONFIG_EROFS_FS_PCPU_KTHREAD is not set
+# CONFIG_EROFS_FS_PAGE_CACHE_SHARE is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+# CONFIG_NFS_V2 is not set
+CONFIG_NFS_V3=m
+# CONFIG_NFS_V3_ACL is not set
+CONFIG_NFS_V4=m
+# CONFIG_NFS_SWAP is not set
+CONFIG_NFS_V4_0=y
+CONFIG_NFS_V4_2=y
+CONFIG_PNFS_FILE_LAYOUT=m
+CONFIG_PNFS_BLOCK=m
+CONFIG_PNFS_FLEXFILE_LAYOUT=m
+CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN="kernel.org"
+# CONFIG_NFS_V4_1_MIGRATION is not set
+CONFIG_NFS_V4_SECURITY_LABEL=y
+CONFIG_NFS_FSCACHE=y
+# CONFIG_NFS_USE_LEGACY_DNS is not set
+CONFIG_NFS_USE_KERNEL_DNS=y
+CONFIG_NFS_DISABLE_UDP_SUPPORT=y
+CONFIG_NFS_V4_2_READ_PLUS=y
+CONFIG_NFSD=m
+# CONFIG_NFSD_V2 is not set
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_PNFS=y
+CONFIG_NFSD_BLOCKLAYOUT=y
+CONFIG_NFSD_SCSILAYOUT=y
+# CONFIG_NFSD_FLEXFILELAYOUT is not set
+CONFIG_NFSD_V4_2_INTER_SSC=y
+# CONFIG_NFSD_V4_SECURITY_LABEL is not set
+# CONFIG_NFSD_LEGACY_CLIENT_TRACKING is not set
+# CONFIG_NFSD_V4_POSIX_ACLS is not set
+CONFIG_GRACE_PERIOD=m
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_NFS_COMMON_LOCALIO_SUPPORT=m
+CONFIG_NFS_LOCALIO=y
+CONFIG_NFS_V4_2_SSC_HELPER=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC_BACKCHANNEL=y
+CONFIG_RPCSEC_GSS_KRB5=m
+# CONFIG_SUNRPC_DEBUG is not set
+# CONFIG_CEPH_FS is not set
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS2=y
+CONFIG_CIFS_ALLOW_INSECURE_LEGACY=y
+# CONFIG_CIFS_UPCALL is not set
+# CONFIG_CIFS_XATTR is not set
+CONFIG_CIFS_DEBUG=y
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_DEBUG_DUMP_KEYS is not set
+# CONFIG_CIFS_DFS_UPCALL is not set
+# CONFIG_CIFS_SWN_UPCALL is not set
+# CONFIG_CIFS_FSCACHE is not set
+# CONFIG_CIFS_COMPRESSION is not set
+# CONFIG_SMB_SERVER is not set
+CONFIG_SMBFS=m
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_MAC_ROMAN is not set
+# CONFIG_NLS_MAC_CELTIC is not set
+# CONFIG_NLS_MAC_CENTEURO is not set
+# CONFIG_NLS_MAC_CROATIAN is not set
+# CONFIG_NLS_MAC_CYRILLIC is not set
+# CONFIG_NLS_MAC_GAELIC is not set
+# CONFIG_NLS_MAC_GREEK is not set
+# CONFIG_NLS_MAC_ICELAND is not set
+# CONFIG_NLS_MAC_INUIT is not set
+# CONFIG_NLS_MAC_ROMANIAN is not set
+# CONFIG_NLS_MAC_TURKISH is not set
+CONFIG_NLS_UTF8=y
+CONFIG_NLS_UCS2_UTILS=m
+# CONFIG_DLM is not set
+CONFIG_UNICODE=y
+CONFIG_IO_WQ=y
+# end of File systems
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+# CONFIG_KEYS_REQUEST_CACHE is not set
+# CONFIG_PERSISTENT_KEYRINGS is not set
+# CONFIG_BIG_KEYS is not set
+# CONFIG_TRUSTED_KEYS is not set
+# CONFIG_ENCRYPTED_KEYS is not set
+CONFIG_KEY_DH_OPERATIONS=y
+CONFIG_SECURITY_DMESG_RESTRICT=y
+CONFIG_PROC_MEM_ALWAYS_FORCE=y
+# CONFIG_PROC_MEM_FORCE_PTRACE is not set
+# CONFIG_PROC_MEM_NO_FORCE is not set
+CONFIG_SECURITY=y
+CONFIG_HAS_SECURITY_AUDIT=y
+CONFIG_SECURITYFS=y
+# CONFIG_SECURITY_NETWORK is not set
+CONFIG_SECURITY_PATH=y
+# CONFIG_STATIC_USERMODEHELPER is not set
+# CONFIG_SECURITY_SMACK is not set
+# CONFIG_SECURITY_TOMOYO is not set
+# CONFIG_SECURITY_APPARMOR is not set
+# CONFIG_SECURITY_LOADPIN is not set
+CONFIG_SECURITY_YAMA=y
+# CONFIG_SECURITY_SAFESETID is not set
+# CONFIG_SECURITY_LOCKDOWN_LSM is not set
+# CONFIG_SECURITY_LANDLOCK is not set
+# CONFIG_SECURITY_IPE is not set
+CONFIG_INTEGRITY=y
+# CONFIG_INTEGRITY_SIGNATURE is not set
+CONFIG_INTEGRITY_AUDIT=y
+# CONFIG_IMA is not set
+# CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT is not set
+# CONFIG_EVM is not set
+CONFIG_DEFAULT_SECURITY_DAC=y
+CONFIG_LSM="lockdown,yama,loadpin,safesetid,integrity"
+
+#
+# Kernel hardening options
+#
+
+#
+# Memory initialization
+#
+CONFIG_CC_HAS_AUTO_VAR_INIT_PATTERN=y
+CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_BARE=y
+CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO=y
+# CONFIG_INIT_STACK_NONE is not set
+# CONFIG_INIT_STACK_ALL_PATTERN is not set
+CONFIG_INIT_STACK_ALL_ZERO=y
+CONFIG_CC_HAS_SANCOV_STACK_DEPTH_CALLBACK=y
+# CONFIG_KSTACK_ERASE is not set
+# CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set
+# CONFIG_INIT_ON_FREE_DEFAULT_ON is not set
+CONFIG_CC_HAS_ZERO_CALL_USED_REGS=y
+# CONFIG_ZERO_CALL_USED_REGS is not set
+# end of Memory initialization
+
+#
+# Bounds checking
+#
+# CONFIG_FORTIFY_SOURCE is not set
+# CONFIG_HARDENED_USERCOPY is not set
+# end of Bounds checking
+
+#
+# Hardening of kernel data structures
+#
+# CONFIG_LIST_HARDENED is not set
+# CONFIG_BUG_ON_DATA_CORRUPTION is not set
+# end of Hardening of kernel data structures
+
+CONFIG_CC_HAS_RANDSTRUCT=y
+CONFIG_RANDSTRUCT_NONE=y
+# CONFIG_RANDSTRUCT_FULL is not set
+# end of Kernel hardening options
+# end of Security options
+
+CONFIG_ASYNC_CORE=y
+CONFIG_ASYNC_MEMCPY=y
+CONFIG_ASYNC_XOR=y
+CONFIG_ASYNC_PQ=y
+CONFIG_ASYNC_RAID6_RECOV=y
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_SIG=y
+CONFIG_CRYPTO_SIG2=y
+CONFIG_CRYPTO_SKCIPHER=y
+CONFIG_CRYPTO_SKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_AKCIPHER2=y
+CONFIG_CRYPTO_AKCIPHER=y
+CONFIG_CRYPTO_KPP2=y
+CONFIG_CRYPTO_KPP=y
+CONFIG_CRYPTO_ACOMP2=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_USER is not set
+CONFIG_CRYPTO_NULL=y
+# CONFIG_CRYPTO_PCRYPT is not set
+CONFIG_CRYPTO_CRYPTD=y
+CONFIG_CRYPTO_AUTHENC=y
+CONFIG_CRYPTO_KRB5ENC=m
+# CONFIG_CRYPTO_BENCHMARK is not set
+# end of Crypto core or helper
+
+#
+# Public-key cryptography
+#
+CONFIG_CRYPTO_RSA=y
+CONFIG_CRYPTO_DH=y
+# CONFIG_CRYPTO_DH_RFC7919_GROUPS is not set
+CONFIG_CRYPTO_ECC=m
+CONFIG_CRYPTO_ECDH=m
+# CONFIG_CRYPTO_ECDSA is not set
+# CONFIG_CRYPTO_ECRDSA is not set
+# CONFIG_CRYPTO_MLDSA is not set
+# end of Public-key cryptography
+
+#
+# Block ciphers
+#
+CONFIG_CRYPTO_AES=y
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARIA is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+CONFIG_CRYPTO_CAMELLIA=m
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=m
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+CONFIG_CRYPTO_SM4=m
+# CONFIG_CRYPTO_SM4_GENERIC is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+# end of Block ciphers
+
+#
+# Length-preserving ciphers and modes
+#
+# CONFIG_CRYPTO_ADIANTUM is not set
+# CONFIG_CRYPTO_ARC4 is not set
+CONFIG_CRYPTO_CHACHA20=m
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=y
+# CONFIG_CRYPTO_HCTR2 is not set
+# CONFIG_CRYPTO_LRW is not set
+CONFIG_CRYPTO_XTS=y
+# end of Length-preserving ciphers and modes
+
+#
+# AEAD (authenticated encryption with associated data) ciphers
+#
+# CONFIG_CRYPTO_AEGIS128 is not set
+CONFIG_CRYPTO_CHACHA20POLY1305=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_GCM=m
+# CONFIG_CRYPTO_SEQIV is not set
+# CONFIG_CRYPTO_ECHAINIV is not set
+CONFIG_CRYPTO_ESSIV=y
+# end of AEAD (authenticated encryption with associated data) ciphers
+
+#
+# Hashes, digests, and MACs
+#
+CONFIG_CRYPTO_BLAKE2B=y
+CONFIG_CRYPTO_CMAC=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_RMD160 is not set
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=y
+CONFIG_CRYPTO_SHA512=y
+CONFIG_CRYPTO_SHA3=y
+# CONFIG_CRYPTO_SM3 is not set
+# CONFIG_CRYPTO_STREEBOG is not set
+# CONFIG_CRYPTO_WP512 is not set
+# CONFIG_CRYPTO_XCBC is not set
+CONFIG_CRYPTO_XXHASH=y
+# end of Hashes, digests, and MACs
+
+#
+# CRCs (cyclic redundancy checks)
+#
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_CRC32=y
+# end of CRCs (cyclic redundancy checks)
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+CONFIG_CRYPTO_LZO=y
+# CONFIG_CRYPTO_842 is not set
+CONFIG_CRYPTO_LZ4=y
+# CONFIG_CRYPTO_LZ4HC is not set
+CONFIG_CRYPTO_ZSTD=y
+# end of Compression
+
+#
+# Random number generation
+#
+CONFIG_CRYPTO_DRBG=y
+CONFIG_CRYPTO_JITTERENTROPY=y
+CONFIG_CRYPTO_JITTERENTROPY_MEMORY_BLOCKS=64
+CONFIG_CRYPTO_JITTERENTROPY_MEMORY_BLOCKSIZE=32
+CONFIG_CRYPTO_JITTERENTROPY_OSR=1
+CONFIG_CRYPTO_KDF800108_CTR=y
+# end of Random number generation
+
+#
+# Userspace interface (deprecated)
+#
+CONFIG_CRYPTO_USER_API=m
+CONFIG_CRYPTO_USER_API_HASH=m
+CONFIG_CRYPTO_USER_API_SKCIPHER=m
+CONFIG_CRYPTO_USER_API_RNG=m
+# CONFIG_CRYPTO_USER_API_RNG_CAVP is not set
+CONFIG_CRYPTO_USER_API_AEAD=m
+CONFIG_CRYPTO_USER_API_ENABLE_OBSOLETE=y
+# end of Userspace interface (deprecated)
+
+#
+# Accelerated Cryptographic Algorithms for CPU (arm64)
+#
+CONFIG_CRYPTO_GHASH_ARM64_CE=y
+CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
+CONFIG_CRYPTO_AES_ARM64_NEON_BLK=m
+CONFIG_CRYPTO_AES_ARM64_BS=m
+CONFIG_CRYPTO_SM4_ARM64_CE=m
+# CONFIG_CRYPTO_SM4_ARM64_CE_BLK is not set
+# CONFIG_CRYPTO_SM4_ARM64_NEON_BLK is not set
+CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
+# CONFIG_CRYPTO_SM4_ARM64_CE_CCM is not set
+# CONFIG_CRYPTO_SM4_ARM64_CE_GCM is not set
+# end of Accelerated Cryptographic Algorithms for CPU (arm64)
+
+CONFIG_CRYPTO_HW=y
+# CONFIG_CRYPTO_DEV_ATMEL_ECC is not set
+# CONFIG_CRYPTO_DEV_ATMEL_SHA204A is not set
+# CONFIG_CRYPTO_DEV_CCP is not set
+CONFIG_CRYPTO_DEV_QCE=m
+CONFIG_CRYPTO_DEV_QCE_SKCIPHER=y
+CONFIG_CRYPTO_DEV_QCE_SHA=y
+CONFIG_CRYPTO_DEV_QCE_AEAD=y
+CONFIG_CRYPTO_DEV_QCE_ENABLE_ALL=y
+# CONFIG_CRYPTO_DEV_QCE_ENABLE_SKCIPHER is not set
+# CONFIG_CRYPTO_DEV_QCE_ENABLE_SHA is not set
+# CONFIG_CRYPTO_DEV_QCE_ENABLE_AEAD is not set
+CONFIG_CRYPTO_DEV_QCE_SW_MAX_LEN=512
+CONFIG_CRYPTO_DEV_QCOM_RNG=m
+# CONFIG_CRYPTO_DEV_VIRTIO is not set
+# CONFIG_CRYPTO_DEV_SAFEXCEL is not set
+# CONFIG_CRYPTO_DEV_CCREE is not set
+# CONFIG_CRYPTO_DEV_HISI_SEC is not set
+# CONFIG_CRYPTO_DEV_AMLOGIC_GXL is not set
+CONFIG_ASYMMETRIC_KEY_TYPE=y
+CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
+CONFIG_X509_CERTIFICATE_PARSER=y
+CONFIG_PKCS8_PRIVATE_KEY_PARSER=m
+CONFIG_PKCS7_MESSAGE_PARSER=y
+# CONFIG_PKCS7_TEST_KEY is not set
+# CONFIG_SIGNED_PE_FILE_VERIFICATION is not set
+# CONFIG_FIPS_SIGNATURE_SELFTEST is not set
+
+#
+# Certificates for signature checking
+#
+CONFIG_SYSTEM_TRUSTED_KEYRING=y
+CONFIG_SYSTEM_TRUSTED_KEYS=""
+# CONFIG_SYSTEM_EXTRA_CERTIFICATE is not set
+# CONFIG_SECONDARY_TRUSTED_KEYRING is not set
+# CONFIG_SYSTEM_BLACKLIST_KEYRING is not set
+CONFIG_OPENSSL_SUPPORTS_ML_DSA=y
+# end of Certificates for signature checking
+
+CONFIG_CRYPTO_KRB5=m
+# CONFIG_CRYPTO_KRB5_SELFTESTS is not set
+CONFIG_BINARY_PRINTF=y
+
+#
+# Library routines
+#
+CONFIG_LINEAR_RANGES=y
+# CONFIG_PACKING is not set
+CONFIG_BITREVERSE=y
+CONFIG_HAVE_ARCH_BITREVERSE=y
+CONFIG_GENERIC_STRNCPY_FROM_USER=y
+CONFIG_GENERIC_STRNLEN_USER=y
+CONFIG_GENERIC_NET_UTILS=y
+# CONFIG_CORDIC is not set
+# CONFIG_PRIME_NUMBERS is not set
+CONFIG_RATIONAL=y
+CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
+CONFIG_ARCH_HAS_FAST_MULTIPLIER=y
+CONFIG_ARCH_USE_SYM_ANNOTATIONS=y
+# CONFIG_INDIRECT_PIO is not set
+# CONFIG_TRACE_MMIO_ACCESS is not set
+CONFIG_CRC16=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC_T10DIF=y
+CONFIG_CRC_T10DIF_ARCH=y
+CONFIG_CRC32=y
+CONFIG_CRC32_ARCH=y
+CONFIG_CRC64=y
+CONFIG_CRC64_ARCH=y
+CONFIG_CRC_OPTIMIZATIONS=y
+CONFIG_CRYPTO_HASH_INFO=y
+CONFIG_CRYPTO_LIB_UTILS=y
+CONFIG_CRYPTO_LIB_AES=y
+CONFIG_CRYPTO_LIB_AES_ARCH=y
+CONFIG_CRYPTO_LIB_AES_CBC_MACS=y
+CONFIG_CRYPTO_LIB_ARC4=m
+CONFIG_CRYPTO_LIB_GF128MUL=y
+CONFIG_CRYPTO_LIB_BLAKE2B=y
+CONFIG_CRYPTO_LIB_CHACHA=m
+CONFIG_CRYPTO_LIB_CHACHA_ARCH=y
+CONFIG_CRYPTO_LIB_CURVE25519=m
+CONFIG_CRYPTO_LIB_CURVE25519_GENERIC=y
+CONFIG_CRYPTO_LIB_DES=m
+CONFIG_CRYPTO_LIB_GF128HASH=m
+CONFIG_CRYPTO_LIB_GF128HASH_ARCH=y
+CONFIG_CRYPTO_LIB_MD5=y
+CONFIG_CRYPTO_LIB_POLY1305=m
+CONFIG_CRYPTO_LIB_POLY1305_ARCH=y
+CONFIG_CRYPTO_LIB_POLY1305_RSIZE=9
+CONFIG_CRYPTO_LIB_CHACHA20POLY1305=m
+CONFIG_CRYPTO_LIB_SHA1=y
+CONFIG_CRYPTO_LIB_SHA1_ARCH=y
+CONFIG_CRYPTO_LIB_SHA256=y
+CONFIG_CRYPTO_LIB_SHA256_ARCH=y
+CONFIG_CRYPTO_LIB_SHA512=y
+CONFIG_CRYPTO_LIB_SHA512_ARCH=y
+CONFIG_CRYPTO_LIB_SHA3=y
+CONFIG_CRYPTO_LIB_SHA3_ARCH=y
+CONFIG_XOR_BLOCKS=y
+CONFIG_XOR_BLOCKS_ARCH=y
+CONFIG_RAID6_PQ=y
+CONFIG_RAID6_PQ_ARCH=y
+CONFIG_RAID6_PQ_BENCHMARK=y
+CONFIG_XXHASH=y
+CONFIG_AUDIT_GENERIC=y
+CONFIG_AUDIT_ARCH_COMPAT_GENERIC=y
+CONFIG_AUDIT_COMPAT_GENERIC=y
+# CONFIG_RANDOM32_SELFTEST is not set
+CONFIG_842_COMPRESS=y
+CONFIG_842_DECOMPRESS=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_LZ4_COMPRESS=y
+CONFIG_LZ4HC_COMPRESS=y
+CONFIG_LZ4_DECOMPRESS=y
+CONFIG_ZSTD_COMMON=y
+CONFIG_ZSTD_COMPRESS=y
+CONFIG_ZSTD_DECOMPRESS=y
+CONFIG_XZ_DEC=y
+CONFIG_XZ_DEC_X86=y
+CONFIG_XZ_DEC_POWERPC=y
+CONFIG_XZ_DEC_ARM=y
+CONFIG_XZ_DEC_ARMTHUMB=y
+CONFIG_XZ_DEC_ARM64=y
+CONFIG_XZ_DEC_SPARC=y
+CONFIG_XZ_DEC_RISCV=y
+CONFIG_XZ_DEC_MICROLZMA=y
+CONFIG_XZ_DEC_BCJ=y
+# CONFIG_XZ_DEC_TEST is not set
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_DECOMPRESS_BZIP2=y
+CONFIG_DECOMPRESS_LZMA=y
+CONFIG_DECOMPRESS_XZ=y
+CONFIG_DECOMPRESS_LZO=y
+CONFIG_DECOMPRESS_LZ4=y
+CONFIG_DECOMPRESS_ZSTD=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=y
+CONFIG_REED_SOLOMON_ENC8=y
+CONFIG_REED_SOLOMON_DEC8=y
+CONFIG_INTERVAL_TREE=y
+CONFIG_XARRAY_MULTI=y
+CONFIG_ASSOCIATIVE_ARRAY=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_DMA_OPS_HELPERS=y
+CONFIG_NEED_SG_DMA_FLAGS=y
+CONFIG_NEED_SG_DMA_LENGTH=y
+CONFIG_NEED_DMA_MAP_STATE=y
+CONFIG_ARCH_DMA_ADDR_T_64BIT=y
+CONFIG_DMA_DECLARE_COHERENT=y
+CONFIG_ARCH_HAS_SETUP_DMA_OPS=y
+CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE=y
+CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU=y
+CONFIG_ARCH_HAS_DMA_PREP_COHERENT=y
+CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED=y
+CONFIG_ARCH_HAS_BATCHED_DMA_SYNC=y
+CONFIG_SWIOTLB=y
+# CONFIG_SWIOTLB_DYNAMIC is not set
+CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC=y
+CONFIG_DMA_NEED_SYNC=y
+# CONFIG_DMA_RESTRICTED_POOL is not set
+CONFIG_DMA_NONCOHERENT_MMAP=y
+CONFIG_DMA_COHERENT_POOL=y
+CONFIG_DMA_DIRECT_REMAP=y
+CONFIG_DMA_CMA=y
+
+#
+# Default contiguous memory area size:
+#
+CONFIG_CMA_SIZE_MBYTES=32
+CONFIG_CMA_SIZE_SEL_MBYTES=y
+# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set
+# CONFIG_CMA_SIZE_SEL_MIN is not set
+# CONFIG_CMA_SIZE_SEL_MAX is not set
+CONFIG_CMA_ALIGNMENT=8
+# CONFIG_DMA_API_DEBUG is not set
+# CONFIG_DMA_MAP_BENCHMARK is not set
+CONFIG_SGL_ALLOC=y
+CONFIG_CPU_RMAP=y
+CONFIG_DQL=y
+CONFIG_GLOB=y
+CONFIG_NLATTR=y
+CONFIG_CLZ_TAB=y
+# CONFIG_IRQ_POLL is not set
+CONFIG_MPILIB=y
+CONFIG_DIMLIB=y
+CONFIG_LIBFDT=y
+CONFIG_OID_REGISTRY=y
+CONFIG_UCS2_STRING=y
+CONFIG_HAVE_GENERIC_VDSO=y
+CONFIG_GENERIC_GETTIMEOFDAY=y
+CONFIG_VDSO_GETRANDOM=y
+CONFIG_FONT_SUPPORT=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_SG_POOL=y
+CONFIG_ARCH_HAS_CPU_CACHE_INVALIDATE_MEMREGION=y
+CONFIG_GENERIC_CPU_CACHE_MAINTENANCE=y
+CONFIG_ARCH_STACKWALK=y
+CONFIG_STACKDEPOT=y
+CONFIG_STACKDEPOT_MAX_FRAMES=64
+CONFIG_SBITMAP=y
+# CONFIG_LWQ_TEST is not set
+# end of Library routines
+
+CONFIG_GENERIC_IOREMAP=y
+CONFIG_GENERIC_LIB_DEVMEM_IS_ALLOWED=y
+CONFIG_UNION_FIND=y
+
+#
+# Kernel hacking
+#
+
+#
+# printk and dmesg options
+#
+CONFIG_PRINTK_TIME=y
+# CONFIG_PRINTK_CALLER is not set
+# CONFIG_STACKTRACE_BUILD_ID is not set
+CONFIG_CONSOLE_LOGLEVEL_DEFAULT=7
+CONFIG_CONSOLE_LOGLEVEL_QUIET=4
+CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4
+# CONFIG_BOOT_PRINTK_DELAY is not set
+CONFIG_DYNAMIC_DEBUG=y
+CONFIG_DYNAMIC_DEBUG_CORE=y
+CONFIG_SYMBOLIC_ERRNAME=y
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE_DETAILED is not set
+# end of printk and dmesg options
+
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DEBUG_MISC=y
+
+#
+# Compile-time checks and compiler options
+#
+CONFIG_DEBUG_INFO=y
+CONFIG_AS_HAS_NON_CONST_ULEB128=y
+# CONFIG_DEBUG_INFO_NONE is not set
+# CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT is not set
+# CONFIG_DEBUG_INFO_DWARF4 is not set
+CONFIG_DEBUG_INFO_DWARF5=y
+# CONFIG_DEBUG_INFO_REDUCED is not set
+CONFIG_DEBUG_INFO_COMPRESSED_NONE=y
+# CONFIG_DEBUG_INFO_COMPRESSED_ZLIB is not set
+# CONFIG_DEBUG_INFO_COMPRESSED_ZSTD is not set
+# CONFIG_DEBUG_INFO_SPLIT is not set
+CONFIG_DEBUG_INFO_BTF=y
+CONFIG_PAHOLE_HAS_BTF_TAG=y
+CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y
+CONFIG_DEBUG_INFO_BTF_MODULES=y
+# CONFIG_MODULE_ALLOW_BTF_MISMATCH is not set
+# CONFIG_GDB_SCRIPTS is not set
+CONFIG_FRAME_WARN=2048
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_HEADERS_INSTALL is not set
+CONFIG_SECTION_MISMATCH_WARN_ONLY=y
+CONFIG_ARCH_WANT_FRAME_POINTERS=y
+CONFIG_FRAME_POINTER=y
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# end of Compile-time checks and compiler options
+
+#
+# Generic Kernel Debugging Instruments
+#
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1
+CONFIG_MAGIC_SYSRQ_SERIAL=y
+CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE=""
+CONFIG_DEBUG_FS=y
+CONFIG_DEBUG_FS_ALLOW_ALL=y
+# CONFIG_DEBUG_FS_ALLOW_NONE is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+CONFIG_ARCH_HAS_UBSAN=y
+# CONFIG_UBSAN is not set
+CONFIG_HAVE_KCSAN_COMPILER=y
+# end of Generic Kernel Debugging Instruments
+
+#
+# Networking Debugging
+#
+# CONFIG_NET_DEV_REFCNT_TRACKER is not set
+# CONFIG_NET_NS_REFCNT_TRACKER is not set
+# CONFIG_DEBUG_NET is not set
+# CONFIG_DEBUG_NET_SMALL_RTNL is not set
+# end of Networking Debugging
+
+#
+# Memory Debugging
+#
+# CONFIG_PAGE_EXTENSION is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_SLUB_DEBUG=y
+# CONFIG_SLUB_DEBUG_ON is not set
+# CONFIG_PAGE_OWNER is not set
+# CONFIG_PAGE_TABLE_CHECK is not set
+# CONFIG_PAGE_POISONING is not set
+# CONFIG_DEBUG_PAGE_REF is not set
+# CONFIG_DEBUG_RODATA_TEST is not set
+CONFIG_ARCH_HAS_DEBUG_WX=y
+# CONFIG_DEBUG_WX is not set
+CONFIG_ARCH_HAS_PTDUMP=y
+# CONFIG_PTDUMP_DEBUGFS is not set
+CONFIG_HAVE_DEBUG_KMEMLEAK=y
+# CONFIG_DEBUG_KMEMLEAK is not set
+# CONFIG_PER_VMA_LOCK_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_SHRINKER_DEBUG is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_SCHED_STACK_END_CHECK is not set
+CONFIG_ARCH_HAS_DEBUG_VM_PGTABLE=y
+# CONFIG_DEBUG_VFS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_VM_PGTABLE is not set
+CONFIG_ARCH_HAS_DEBUG_VIRTUAL=y
+# CONFIG_DEBUG_VIRTUAL is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_PER_CPU_MAPS is not set
+# CONFIG_MEM_ALLOC_PROFILING is not set
+CONFIG_HAVE_ARCH_KASAN=y
+CONFIG_HAVE_ARCH_KASAN_SW_TAGS=y
+CONFIG_HAVE_ARCH_KASAN_HW_TAGS=y
+CONFIG_HAVE_ARCH_KASAN_VMALLOC=y
+CONFIG_CC_HAS_KASAN_GENERIC=y
+CONFIG_CC_HAS_KASAN_SW_TAGS=y
+CONFIG_CC_HAS_WORKING_NOSANITIZE_ADDRESS=y
+# CONFIG_KASAN is not set
+CONFIG_HAVE_ARCH_KFENCE=y
+# CONFIG_KFENCE is not set
+# end of Memory Debugging
+
+# CONFIG_DEBUG_SHIRQ is not set
+
+#
+# Debug Oops, Lockups and Hangs
+#
+# CONFIG_PANIC_ON_OOPS is not set
+CONFIG_PANIC_TIMEOUT=-1
+CONFIG_LOCKUP_DETECTOR=y
+CONFIG_SOFTLOCKUP_DETECTOR=y
+CONFIG_SOFTLOCKUP_DETECTOR_INTR_STORM=y
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=0
+CONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=y
+CONFIG_HARDLOCKUP_DETECTOR=y
+# CONFIG_HARDLOCKUP_DETECTOR_PERF is not set
+CONFIG_HARDLOCKUP_DETECTOR_BUDDY=y
+# CONFIG_HARDLOCKUP_DETECTOR_ARCH is not set
+CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER=y
+# CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is not set
+# CONFIG_DETECT_HUNG_TASK is not set
+# CONFIG_WQ_WATCHDOG is not set
+# CONFIG_WQ_CPU_INTENSIVE_REPORT is not set
+# CONFIG_TEST_LOCKUP is not set
+# end of Debug Oops, Lockups and Hangs
+
+#
+# Scheduler Debugging
+#
+CONFIG_SCHED_INFO=y
+# CONFIG_SCHEDSTATS is not set
+# end of Scheduler Debugging
+
+# CONFIG_DEBUG_PREEMPT is not set
+# CONFIG_DEBUG_ATOMIC is not set
+
+#
+# Lock Debugging (spinlocks, mutexes, etc...)
+#
+CONFIG_LOCK_DEBUGGING_SUPPORT=y
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_DEBUG_ATOMIC_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_LOCK_TORTURE_TEST is not set
+# CONFIG_WW_MUTEX_SELFTEST is not set
+# CONFIG_SCF_TORTURE_TEST is not set
+# CONFIG_CSD_LOCK_WAIT_DEBUG is not set
+# end of Lock Debugging (spinlocks, mutexes, etc...)
+
+# CONFIG_DEBUG_IRQFLAGS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+
+#
+# Debug kernel data structures
+#
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_PLIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_MAPLE_TREE is not set
+# end of Debug kernel data structures
+
+#
+# RCU Debugging
+#
+# CONFIG_RCU_SCALE_TEST is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_REF_SCALE_TEST is not set
+CONFIG_RCU_CPU_STALL_TIMEOUT=21
+CONFIG_RCU_EXP_CPU_STALL_TIMEOUT=0
+# CONFIG_RCU_CPU_STALL_CPUTIME is not set
+# CONFIG_RCU_TRACE is not set
+# CONFIG_RCU_EQS_DEBUG is not set
+# end of RCU Debugging
+
+# CONFIG_DEBUG_WQ_FORCE_RR_CPU is not set
+# CONFIG_CPU_HOTPLUG_STATE_CONTROL is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_DEBUG_CGROUP_REF is not set
+CONFIG_USER_STACKTRACE_SUPPORT=y
+CONFIG_NOP_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_FREGS=y
+CONFIG_HAVE_FTRACE_GRAPH_FUNC=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_EXTRA_IPI_TRACEPOINTS=y
+CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS=y
+CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
+CONFIG_HAVE_C_RECORDMCOUNT=y
+CONFIG_HAVE_BUILDTIME_MCOUNT_SORT=y
+CONFIG_BUILDTIME_MCOUNT_SORT=y
+CONFIG_TRACE_CLOCK=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_TRACING=y
+CONFIG_GENERIC_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_TRACEFS_AUTOMOUNT_DEPRECATED is not set
+# CONFIG_BOOTTIME_TRACING is not set
+CONFIG_FUNCTION_TRACER=y
+CONFIG_FUNCTION_GRAPH_TRACER=y
+CONFIG_FUNCTION_GRAPH_RETVAL=y
+# CONFIG_FUNCTION_GRAPH_RETADDR is not set
+CONFIG_FUNCTION_TRACE_ARGS=y
+CONFIG_DYNAMIC_FTRACE=y
+CONFIG_DYNAMIC_FTRACE_WITH_ARGS=y
+# CONFIG_FUNCTION_SELF_TRACING is not set
+# CONFIG_FPROBE is not set
+# CONFIG_FUNCTION_PROFILER is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_PREEMPT_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_HWLAT_TRACER is not set
+# CONFIG_OSNOISE_TRACER is not set
+# CONFIG_TIMERLAT_TRACER is not set
+# CONFIG_FTRACE_SYSCALLS is not set
+# CONFIG_TRACER_SNAPSHOT is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+CONFIG_PROBE_EVENTS_BTF_ARGS=y
+CONFIG_KPROBE_EVENTS=y
+# CONFIG_KPROBE_EVENTS_ON_NOTRACE is not set
+CONFIG_UPROBE_EVENTS=y
+CONFIG_EPROBE_EVENTS=y
+CONFIG_BPF_EVENTS=y
+CONFIG_DYNAMIC_EVENTS=y
+CONFIG_PROBE_EVENTS=y
+CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY=y
+# CONFIG_SYNTH_EVENTS is not set
+# CONFIG_USER_EVENTS is not set
+# CONFIG_HIST_TRIGGERS is not set
+# CONFIG_TRACE_EVENT_INJECT is not set
+# CONFIG_TRACEPOINT_BENCHMARK is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_TRACE_EVAL_MAP_FILE is not set
+# CONFIG_FTRACE_RECORD_RECURSION is not set
+# CONFIG_FTRACE_VALIDATE_RCU_IS_WATCHING is not set
+# CONFIG_FTRACE_STARTUP_TEST is not set
+# CONFIG_FTRACE_SORT_STARTUP_TEST is not set
+# CONFIG_RING_BUFFER_STARTUP_TEST is not set
+# CONFIG_RING_BUFFER_VALIDATE_TIME_DELTAS is not set
+# CONFIG_RING_BUFFER_PERSISTENT_INJECT is not set
+# CONFIG_PREEMPTIRQ_DELAY_TEST is not set
+# CONFIG_KPROBE_EVENT_GEN_TEST is not set
+# CONFIG_RV is not set
+# CONFIG_TRACE_REMOTE_TEST is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_SAMPLE_FTRACE_DIRECT=y
+CONFIG_HAVE_SAMPLE_FTRACE_DIRECT_MULTI=y
+CONFIG_STRICT_DEVMEM=y
+# CONFIG_IO_STRICT_DEVMEM is not set
+
+#
+# arm64 Debugging
+#
+# CONFIG_PID_IN_CONTEXTIDR is not set
+# CONFIG_DEBUG_EFI is not set
+# CONFIG_ARM64_RELOC_TEST is not set
+# CONFIG_CORESIGHT is not set
+# end of arm64 Debugging
+
+#
+# Kernel Testing and Coverage
+#
+# CONFIG_KUNIT is not set
+# CONFIG_NOTIFIER_ERROR_INJECTION is not set
+# CONFIG_FUNCTION_ERROR_INJECTION is not set
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_ARCH_HAS_KCOV=y
+# CONFIG_KCOV is not set
+CONFIG_RUNTIME_TESTING_MENU=y
+# CONFIG_TEST_DHRY is not set
+# CONFIG_LKDTM is not set
+# CONFIG_TEST_DIV64 is not set
+# CONFIG_TEST_MULDIV64 is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_TEST_REF_TRACKER is not set
+# CONFIG_RBTREE_TEST is not set
+# CONFIG_REED_SOLOMON_TEST is not set
+# CONFIG_INTERVAL_TREE_TEST is not set
+# CONFIG_PERCPU_TEST is not set
+# CONFIG_ATOMIC64_SELFTEST is not set
+# CONFIG_ASYNC_RAID6_TEST is not set
+# CONFIG_TEST_HEXDUMP is not set
+# CONFIG_TEST_KSTRTOX is not set
+# CONFIG_TEST_BITMAP is not set
+# CONFIG_TEST_XARRAY is not set
+# CONFIG_TEST_MAPLE_TREE is not set
+# CONFIG_TEST_RHASHTABLE is not set
+# CONFIG_TEST_IDA is not set
+# CONFIG_TEST_LKM is not set
+# CONFIG_TEST_BITOPS is not set
+# CONFIG_TEST_VMALLOC is not set
+# CONFIG_TEST_WORKQUEUE is not set
+# CONFIG_TEST_BPF is not set
+# CONFIG_FIND_BIT_BENCHMARK is not set
+# CONFIG_TEST_FIRMWARE is not set
+# CONFIG_TEST_SYSCTL is not set
+# CONFIG_TEST_UDELAY is not set
+# CONFIG_TEST_STATIC_KEYS is not set
+# CONFIG_TEST_DYNAMIC_DEBUG is not set
+# CONFIG_TEST_KMOD is not set
+# CONFIG_TEST_KALLSYMS is not set
+# CONFIG_TEST_MEMCAT_P is not set
+# CONFIG_TEST_MEMINIT is not set
+# CONFIG_TEST_FREE_PAGES is not set
+# CONFIG_TEST_FPU is not set
+# CONFIG_TEST_OBJPOOL is not set
+CONFIG_ARCH_USE_MEMTEST=y
+# CONFIG_MEMTEST is not set
+# end of Kernel Testing and Coverage
+
+#
+# Rust hacking
+#
+# end of Rust hacking
+# end of Kernel hacking
+
+CONFIG_IO_URING_ZCRX=y
+CONFIG_IO_URING_BPF=y
+CONFIG_IO_URING_BPF_OPS=y
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.10-11.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.10-11.patch
new file mode 100644
index 0000000..a59775e
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.10-11.patch
@@ -0,0 +1,12005 @@
+diff --git a/Documentation/networking/strparser.rst b/Documentation/networking/strparser.rst
+index 372106b61e6512..d0804c88ad0a04 100644
+--- a/Documentation/networking/strparser.rst
++++ b/Documentation/networking/strparser.rst
+@@ -77,7 +77,7 @@ Functions
+
+ strp_done is called to release any resources held by the stream
+ parser instance. This must be called after the stream processor
+- has been stopped.
++ has been stopped. The socket lock must not be held.
+
+ ::
+
+diff --git a/Makefile b/Makefile
+index be413b167b2443..4b60c83ab75c17 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0
+ VERSION = 7
+ PATCHLEVEL = 2
+-SUBLEVEL = 10
++SUBLEVEL = 11
+ EXTRAVERSION =
+ NAME = Baby Opossum Posse
+
+diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+index 1d73abffa6b72b..6ead557a8cf19f 100644
+--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
++++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+@@ -1783,7 +1783,7 @@
+ };
+
+ dspi2_miso_mosi_pins: iic5-spi3-pins {
+- pinctrl-single,bits = <0x3 (0x2 << 9) (0x7 << 9)>;
++ pinctrl-single,bits = <0x0 (0x3 << 9) (0x7 << 9)>;
+ };
+
+ i2c5_pins: iic6-i2c-pins {
+@@ -1803,7 +1803,7 @@
+ };
+
+ gpio1_31_28_pins: xspi1-data74-gpio-pins {
+- pinctrl-single,bits = <0x0 0x1 (0x7 << 15)>;
++ pinctrl-single,bits = <0x0 (0x1 << 15) (0x7 << 15)>;
+ };
+
+ fspi_data30_pins: xspi1-data30-pins {
+@@ -1811,7 +1811,7 @@
+ };
+
+ gpio1_27_24_pins: xspi1-data30-gpio-pins {
+- pinctrl-single,bits = <0x0 0x1 (0x7 << 18)>;
++ pinctrl-single,bits = <0x0 (0x1 << 18) (0x7 << 18)>;
+ };
+
+ fspi_dqs_sck_cs10_pins: xspi1-base-pins {
+@@ -1819,7 +1819,7 @@
+ };
+
+ gpio1_23_20_pins: xspi1-base-gpio-pins {
+- pinctrl-single,bits = <0x0 0x1 (0x7 << 21)>;
++ pinctrl-single,bits = <0x0 (0x1 << 21) (0x7 << 21)>;
+ };
+
+ esdhc0_cmd_data30_clk_vsel_pins: sdhc1-base-sdhc-vsel-pins {
+@@ -1868,12 +1868,19 @@
+ };
+
+ /* RCWSR14 */
++ /*
++ * IIC1_PMUX is a single bit at RCWSR14[10], but bit-per-mux
++ * uses the mask for the field to clear before applying the
++ * value.
++ * So bits 11 and 12, which are reserved, are written as 0
++ * on every mux switch, it is harmless.
++ */
+ i2c0_pins: iic1-i2c-pins {
+- pinctrl-single,bits = <0x8 0x0 (0x1 << 10)>;
++ pinctrl-single,bits = <0x8 0x0 (0x7 << 10)>;
+ };
+
+ gpio0_3_2_pins: iic1-gpio-pins {
+- pinctrl-single,bits = <0x8 (0x1 << 10) (0x1 << 10)>;
++ pinctrl-single,bits = <0x8 (0x1 << 10) (0x7 << 10)>;
+ };
+ };
+
+diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
+index 87560d8b254e67..1da277baacf78c 100644
+--- a/arch/arm64/include/asm/el2_setup.h
++++ b/arch/arm64/include/asm/el2_setup.h
+@@ -421,8 +421,9 @@
+ mov x2, xzr
+ mrs x1, id_aa64dfr0_el1
+ ubfx x1, x1, #ID_AA64DFR0_EL1_PMUVer_SHIFT, #4
+- cmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9
+- b.lt .Lskip_pmuv3p9_\@
++ cmp x1, #ID_AA64DFR0_EL1_PMUVer_IMP_DEF
++ ccmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9, #8, ne
++ b.lt .Lskip_pmuv3p9_\@ // Skip if < PMUv3p9 or IMP_DEF
+
+ orr x0, x0, #HDFGRTR2_EL2_nPMICNTR_EL0
+ orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0
+diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
+index d2690c3ec52885..ea66339435bf0b 100644
+--- a/arch/arm64/kernel/Makefile
++++ b/arch/arm64/kernel/Makefile
+@@ -25,6 +25,9 @@ KASAN_SANITIZE_stacktrace.o := n
+ KCOV_INSTRUMENT_entry-common.o := n
+ KCOV_INSTRUMENT_idle.o := n
+
++# Softirq stack switching can run outside interrupt context.
++KCOV_INSTRUMENT_irq.o := n
++
+ # Object file lists.
+ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \
+ entry-common.o process.o ptrace.o \
+diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
+index f7028caaeae06e..e5166df510bb64 100644
+--- a/arch/riscv/Kconfig
++++ b/arch/riscv/Kconfig
+@@ -450,9 +450,10 @@ config SMP
+ config NR_CPUS
+ int "Maximum number of CPUs (2-512)"
+ depends on SMP
+- range 2 512 if !RISCV_SBI_V01
+- range 2 32 if RISCV_SBI_V01 && 32BIT
++ range 2 512 if !RISCV_SBI_V01 && 64BIT
++ range 2 128 if !RISCV_SBI_V01 && 32BIT
+ range 2 64 if RISCV_SBI_V01 && 64BIT
++ range 2 32 if RISCV_SBI_V01 && 32BIT
+ default "32" if 32BIT
+ default "64" if RISCV_SBI_V01 && 64BIT
+ default "256" if !RISCV_SBI_V01 && 64BIT
+diff --git a/arch/riscv/Kconfig.errata b/arch/riscv/Kconfig.errata
+index 3c945d086c7d02..6121ba83cfa6b6 100644
+--- a/arch/riscv/Kconfig.errata
++++ b/arch/riscv/Kconfig.errata
+@@ -146,6 +146,7 @@ config ERRATA_THEAD_PMU
+ config ERRATA_THEAD_GHOSTWRITE
+ bool "Apply T-Head Ghostwrite errata"
+ depends on ERRATA_THEAD && RISCV_ISA_XTHEADVECTOR
++ select RISCV_ALTERNATIVE_EARLY
+ default y
+ help
+ The T-Head C9xx cores have a vulnerability in the xtheadvector
+diff --git a/arch/riscv/include/asm/futex.h b/arch/riscv/include/asm/futex.h
+index 90c86b115e008a..6f3bc9bdb85e39 100644
+--- a/arch/riscv/include/asm/futex.h
++++ b/arch/riscv/include/asm/futex.h
+@@ -40,6 +40,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
+
+ if (!access_ok(uaddr, sizeof(u32)))
+ return -EFAULT;
++ uaddr = untagged_addr(uaddr);
+
+ switch (op) {
+ case FUTEX_OP_SET:
+@@ -82,6 +83,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
+
+ if (!access_ok(uaddr, sizeof(u32)))
+ return -EFAULT;
++ uaddr = untagged_addr(uaddr);
+
+ __enable_user_access();
+ __asm__ __volatile__ (
+diff --git a/arch/riscv/include/asm/scs.h b/arch/riscv/include/asm/scs.h
+index 023a412fe38d37..49e40eef4ed7b2 100644
+--- a/arch/riscv/include/asm/scs.h
++++ b/arch/riscv/include/asm/scs.h
+@@ -4,6 +4,7 @@
+
+ #ifdef __ASSEMBLER__
+ #include
++#include
+
+ #ifdef CONFIG_SHADOW_CALL_STACK
+
+@@ -22,9 +23,17 @@
+ REG_L gp, TASK_TI_SCS_SP(tp)
+ .endm
+
+-/* Load task_scs_sp(current) to gp, but only if tp has changed. */
+-.macro scs_load_current_if_task_changed prev
+- beq \prev, tp, _skip_scs
++/*
++ * Load task_scs_sp(current) to gp, but only when the trap came from U-mode.
++ * The source privilege level is taken from the saved sstatus.SPP bit (written
++ * by hardware on trap entry), not by comparing tp. tp is a user-writable
++ * register, so gating the shadow call stack reload on it let a user task that
++ * set tp == ¤t skip the reload and run the kernel with an attacker
++ * controlled gp (the shadow call stack pointer).
++ */
++.macro scs_load_current_if_from_user status, tmp
++ andi \tmp, \status, SR_SPP
++ bnez \tmp, _skip_scs
+ scs_load_current
+ _skip_scs:
+ .endm
+@@ -42,7 +51,7 @@ _skip_scs:
+ .endm
+ .macro scs_load_current
+ .endm
+-.macro scs_load_current_if_task_changed prev
++.macro scs_load_current_if_from_user status, tmp
+ .endm
+ .macro scs_save_current
+ .endm
+diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
+index 00cb9c0982b1ae..8d736e826d84d2 100644
+--- a/arch/riscv/include/asm/vector.h
++++ b/arch/riscv/include/asm/vector.h
+@@ -132,8 +132,8 @@ static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest)
+ "csrr %0, " __stringify(CSR_VSTART) "\n\t"
+ "csrr %1, " __stringify(CSR_VTYPE) "\n\t"
+ "csrr %2, " __stringify(CSR_VL) "\n\t"
+- : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl),
+- "=r" (dest->vcsr) : :);
++ : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl)
++ : :);
+
+ if (has_xtheadvector()) {
+ unsigned long status;
+@@ -225,7 +225,7 @@ static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to,
+ "add %1, %1, %0\n\t"
+ "vse8.v v24, (%1)\n\t"
+ ".option pop\n\t"
+- : "=&r" (vl) : "r" (datap) : "memory");
++ : "=&r" (vl), "+r" (datap) : : "memory");
+ }
+ riscv_v_disable();
+ }
+@@ -261,7 +261,7 @@ static inline void __riscv_v_vstate_restore(struct __riscv_v_ext_state *restore_
+ "add %1, %1, %0\n\t"
+ "vle8.v v24, (%1)\n\t"
+ ".option pop\n\t"
+- : "=&r" (vl) : "r" (datap) : "memory");
++ : "=&r" (vl), "+r" (datap) : : "memory");
+ }
+ __vstate_csr_restore(restore_from);
+ riscv_v_disable();
+diff --git a/arch/riscv/include/uapi/asm/vendor/mips.h b/arch/riscv/include/uapi/asm/vendor/mips.h
+index e65ab268b26551..a31c23afe74fb2 100644
+--- a/arch/riscv/include/uapi/asm/vendor/mips.h
++++ b/arch/riscv/include/uapi/asm/vendor/mips.h
+@@ -1,3 +1,5 @@
+ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+-#define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL BIT(0)
++#include
++
++#define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL _BITULL(0)
+diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
+index d799c4e56f8049..61b7a77166971d 100644
+--- a/arch/riscv/kernel/entry.S
++++ b/arch/riscv/kernel/entry.S
+@@ -208,7 +208,7 @@ SYM_CODE_START(handle_exception)
+ load_global_pointer
+
+ /* Load the kernel shadow call stack pointer if coming from userspace */
+- scs_load_current_if_task_changed s5
++ scs_load_current_if_from_user s1, s5
+
+ #ifdef CONFIG_RISCV_ISA_V_PREEMPTIVE
+ move a0, sp
+diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
+index 16b243376f3621..1e8f1ac5a755f9 100644
+--- a/arch/riscv/kernel/patch.c
++++ b/arch/riscv/kernel/patch.c
+@@ -46,7 +46,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
+
+ if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr)) {
+ phys = __pa_symbol(addr);
+- } else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) {
++ } else if (IS_ENABLED(CONFIG_EXECMEM)) {
+ struct page *page = vmalloc_to_page(addr);
+
+ BUG_ON(!page);
+diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c
+index f336a183667eb8..a0055743d3ba50 100644
+--- a/arch/riscv/kernel/ptrace.c
++++ b/arch/riscv/kernel/ptrace.c
+@@ -230,6 +230,7 @@ static int riscv_vr_set(struct task_struct *target,
+ return -ENODATA;
+
+ /* Copy rest of the vstate except datap */
++ memset(&ptrace_vstate, 0, sizeof(ptrace_vstate));
+ ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ptrace_vstate, 0,
+ sizeof(struct __riscv_v_regset_state));
+ if (unlikely(ret))
+@@ -299,6 +300,9 @@ static int riscv_cfi_get(struct task_struct *target,
+ struct user_cfi_state user_cfi;
+ struct pt_regs *regs;
+
++ if (!is_user_lpad_enabled() && !is_user_shstk_enabled())
++ return -EINVAL;
++
+ memset(&user_cfi, 0, sizeof(user_cfi));
+ regs = task_pt_regs(target);
+
+@@ -337,8 +341,12 @@ static int riscv_cfi_set(struct task_struct *target,
+ struct user_cfi_state user_cfi;
+ struct pt_regs *regs;
+
++ if (!is_user_lpad_enabled() && !is_user_shstk_enabled())
++ return -EINVAL;
++
+ regs = task_pt_regs(target);
+
++ memset(&user_cfi, 0, sizeof(user_cfi));
+ ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &user_cfi, 0, -1);
+ if (ret)
+ return ret;
+diff --git a/arch/riscv/lib/strnlen.S b/arch/riscv/lib/strnlen.S
+index a8911605c24801..5b3bbf0a30987a 100644
+--- a/arch/riscv/lib/strnlen.S
++++ b/arch/riscv/lib/strnlen.S
+@@ -87,9 +87,25 @@ strnlen_zbb:
+ * Aligned boundary. Use the address of the last valid byte
+ * (s + count - 1) to avoid loading a word past the count
+ * boundary in the loop below. count == 0 is handled above.
++ *
++ * Saturate the boundary when s + count would wrap around (very
++ * large counts, e.g. SIZE_MAX passed by FORTIFY strcat/strlcat
++ * with a destination whose size is unknown at compile time).
++ * Without this, the wrapped boundary lands before s and the
++ * pre-loop guard below always exits, returning a truncated
++ * length.
++ *
++ * Clamping the increment to ~s (== SIZE_MAX - s) keeps the
++ * computation branchless and wrap-free:
++ *
++ * s + min(count - 1, ~s) == saturating_add(s, count - 1)
++ *
++ * Saturating makes the scan equivalent to strlen().
+ */
+- add t4, a0, a1
+- addi t4, t4, -1
++ addi t4, a1, -1 /* count - 1 */
++ not t1, a0 /* SIZE_MAX - s */
++ minu t4, t4, t1 /* clamp, so s + t4 can never wrap */
++ add t4, a0, t4 /* saturated s + count - 1 */
+ andi t4, t4, -SZREG
+
+ /* Get the first word. */
+diff --git a/arch/riscv/mm/extable.c b/arch/riscv/mm/extable.c
+index dd1530af3ef15b..e252eba55edece 100644
+--- a/arch/riscv/mm/extable.c
++++ b/arch/riscv/mm/extable.c
+@@ -68,8 +68,8 @@ ex_handler_load_unaligned_zeropad(const struct exception_table_entry *ex,
+
+ addr = regs_get_gpr(regs, reg_addr * sizeof(unsigned long));
+
+- offset = addr & 0x7UL;
+- addr &= ~0x7UL;
++ offset = addr & (sizeof(data) - 1);
++ addr &= ~(sizeof(data) - 1);
+
+ data = *(unsigned long *)addr >> (offset * 8);
+
+diff --git a/arch/um/drivers/vector_transports.c b/arch/um/drivers/vector_transports.c
+index ddd127ee96785d..e1fb2a76fdff59 100644
+--- a/arch/um/drivers/vector_transports.c
++++ b/arch/um/drivers/vector_transports.c
+@@ -209,6 +209,7 @@ static int raw_verify_header(
+ if ((vheader->flags & VIRTIO_NET_HDR_F_DATA_VALID) > 0)
+ return 1;
+
++ skb_set_network_header(skb, ETH_HLEN);
+ virtio_net_hdr_to_skb(skb, vheader, virtio_legacy_is_little_endian());
+ return 0;
+ }
+diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
+index 1b4a48bff18f75..caca69a4e6d5a4 100644
+--- a/arch/x86/include/asm/cpufeatures.h
++++ b/arch/x86/include/asm/cpufeatures.h
+@@ -465,6 +465,8 @@
+ #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* No Nested Data Breakpoints */
+ #define X86_FEATURE_WRMSR_XX_BASE_NS (20*32+ 1) /* WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing */
+ #define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* LFENCE always serializing / synchronizes RDTSC */
++
++#define X86_FEATURE_TLBSYNC_SFW_NO (20*32+ 4) /* TLBI Erratum #1718 fixed in microcode */
+ #define X86_FEATURE_VERW_CLEAR (20*32+ 5) /* The memory form of VERW mitigates TSA */
+ #define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* Null Selector Clears Base */
+
+@@ -575,4 +577,5 @@
+ #define X86_BUG_TSA X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */
+ #define X86_BUG_VMSCAPE X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */
+ #define X86_BUG_SEAMRET_INVD_VMCS X86_BUG( 1*32+11) /* "seamret_invd_vmcs" SEAMRET from P-SEAMLDR clears the current VMCS */
++#define X86_BUG_TLBI X86_BUG( 1*32+12) /* "tlbi" AMD TLBI Erratum #1718 */
+ #endif /* _ASM_X86_CPUFEATURES_H */
+diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
+index 866ea78ba156ae..eba925c85f522b 100644
+--- a/arch/x86/include/asm/tlb.h
++++ b/arch/x86/include/asm/tlb.h
+@@ -110,6 +110,12 @@ static inline void __tlbsync(void)
+
+ /* TLBSYNC: supported in binutils >= 0.36. */
+ asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory");
++
++ if (!static_cpu_has_bug(X86_BUG_TLBI))
++ return;
++
++ /* TLBSYNC: supported in binutils >= 0.36. */
++ asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory");
+ }
+ #else
+ /* Some compilers (I'm looking at you clang!) simply can't do DCE */
+diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
+index d61df70d6875ef..89e3280475a9d9 100644
+--- a/arch/x86/kernel/cpu/amd.c
++++ b/arch/x86/kernel/cpu/amd.c
+@@ -1047,6 +1047,10 @@ static void init_amd_zen5(struct cpuinfo_x86 *c)
+ msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+ pr_emerg_once("RDSEED32 is broken. Disabling the corresponding CPUID bit.\n");
+ }
++
++ if (cpu_has(c, X86_FEATURE_INVLPGB) &&
++ !cpu_has(c, X86_FEATURE_TLBSYNC_SFW_NO))
++ set_cpu_bug(c, X86_BUG_TLBI);
+ }
+
+ static void init_amd(struct cpuinfo_x86 *c)
+diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs
+index c10148e9069f3b..8f7aa867ce68bc 100644
+--- a/drivers/android/binder/node.rs
++++ b/drivers/android/binder/node.rs
+@@ -49,9 +49,9 @@ pub(crate) struct CouldNotDeliverCriticalIncrement;
+ /// about to drop the weak reference, then the strong increment could be processed after the
+ /// other thread has already exited, which would be too late.
+ ///
+-/// Note that trying to create a `ListArc` to the node can succeed even if `has_normal_push` is
++/// Note that trying to create a `ListArc` to the node can succeed even if `has_pushed_node` is
+ /// set. This is because another thread might just have popped the node from a todo list, but not
+-/// yet called `do_work`. However, if `has_normal_push` is false, then creating a `ListArc` should
++/// yet called `do_work`. However, if `has_pushed_node` is false, then creating a `ListArc` should
+ /// always succeed.
+ ///
+ /// Like the other fields in `NodeInner`, the delivery state is protected by the process lock.
+@@ -733,7 +733,21 @@ impl DeliverToRead for Node {
+ self.do_work_locked(writer, owner_inner)
+ }
+
+- fn cancel(self: DArc) {}
++ fn cancel(self: DArc) {
++ let _drop_outside_lock;
++ let mut owner_inner = self.owner.inner.lock();
++
++ // We only do something on BINDER_THREAD_EXIT, not process exit.
++ if owner_inner.is_dead {
++ return;
++ }
++
++ // If BINDER_THREAD_EXIT is invoked on a thread with a pending node refcount update, we
++ // should move ourselves to ensure the refcount update is still delivered.
++ if let Some(node) = ListArc::try_from_arc_borrow(self.as_arc_borrow()) {
++ _drop_outside_lock = owner_inner.push_work(node);
++ }
++ }
+
+ fn should_sync_wakeup(&self) -> bool {
+ false
+diff --git a/drivers/android/binder/node/wrapper.rs b/drivers/android/binder/node/wrapper.rs
+index 43294c05050292..aeda07ff7218bc 100644
+--- a/drivers/android/binder/node/wrapper.rs
++++ b/drivers/android/binder/node/wrapper.rs
+@@ -57,7 +57,39 @@ impl DeliverToRead for NodeWrapper {
+ node.do_work_locked(writer, owner_inner)
+ }
+
+- fn cancel(self: DArc) {}
++ fn cancel(self: DArc) {
++ let _drop_outside_lock;
++ let node = &self.node;
++ let mut owner_inner = node.owner.inner.lock();
++
++ // We only do something on BINDER_THREAD_EXIT, not process exit.
++ if owner_inner.is_dead {
++ return;
++ }
++
++ // We transfer the responsibility of the node refcount update to the scheduled Node because
++ // NodeWrapper has no way to re-create the ListArc.
++ let inner = node.inner.access_mut(&mut owner_inner);
++
++ let ds = &mut inner.delivery_state;
++ assert!(ds.has_pushed_wrapper);
++ assert!(ds.has_strong_zero2one);
++ ds.has_pushed_wrapper = false;
++
++ // We are changing the state to one where the Node is the strong zero2one update instead of
++ // the wrapper.
++ ds.has_weak_zero2one = false;
++
++ if !ds.has_pushed_node {
++ if let Some(node2) = ListArc::try_from_arc_borrow(node.as_arc_borrow()) {
++ ds.has_pushed_node = true;
++ _drop_outside_lock = owner_inner.push_work(node2);
++ } else {
++ // This can't actually happen.
++ ds.has_strong_zero2one = false;
++ }
++ }
++ }
+
+ fn should_sync_wakeup(&self) -> bool {
+ false
+diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
+index 3559485b503495..d06062abca9cef 100644
+--- a/drivers/ata/libata-scsi.c
++++ b/drivers/ata/libata-scsi.c
+@@ -3026,10 +3026,15 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
+ if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
+ qc->dev->sdev->locked = 0;
+
+- if (cmd->result)
+- ata_scsi_qc_done(qc, false, 0);
+- else
+- ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION);
++ /*
++ * Report CHECK CONDITION unless the command was terminated
++ * with a host byte set. Only set the status byte, so that the
++ * SCSI midlayer internal byte, which scsi_check_sense() may
++ * have set from the sense data, is preserved.
++ */
++ if (get_host_byte(cmd) == DID_OK)
++ set_status_byte(cmd, SAM_STAT_CHECK_CONDITION);
++ ata_scsi_qc_done(qc, false, 0);
+ goto schedule_deferred;
+ }
+
+diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
+index 1333fae05ac5dd..a011f3e518a551 100644
+--- a/drivers/block/zloop.c
++++ b/drivers/block/zloop.c
+@@ -799,6 +799,27 @@ static void zloop_cmd_workfn(struct work_struct *work)
+ current->flags = orig_flags;
+ }
+
++static void zloop_fill_zero_rq(struct request *rq, unsigned int zero_from)
++{
++ struct req_iterator iter;
++ struct bio_vec bv;
++ unsigned int pos = 0;
++ unsigned int end, off;
++
++ rq_for_each_segment(bv, rq, iter) {
++ end = pos + bv.bv_len;
++ if (end > zero_from) {
++ if (pos < zero_from)
++ off = zero_from - pos;
++ else
++ off = 0;
++ memzero_page(bv.bv_page, bv.bv_offset + off,
++ bv.bv_len - off);
++ }
++ pos = end;
++ }
++}
++
+ static void zloop_complete_rq(struct request *rq)
+ {
+ struct zloop_cmd *cmd = blk_mq_rq_to_pdu(rq);
+@@ -813,13 +834,9 @@ static void zloop_complete_rq(struct request *rq)
+ pr_err("Zone %u: failed read sector %llu, %llu sectors\n",
+ zone_no, cmd->sector, cmd->nr_sectors);
+
+- if (cmd->ret >= 0 && cmd->ret != blk_rq_bytes(rq)) {
+- /* short read */
+- struct bio *bio;
+-
+- __rq_for_each_bio(bio, rq)
+- zero_fill_bio(bio);
+- }
++ /* Short read. Zero out the unread tail beyond cmd->ret. */
++ if (cmd->ret >= 0 && cmd->ret != blk_rq_bytes(rq))
++ zloop_fill_zero_rq(rq, cmd->ret);
+ break;
+ case REQ_OP_WRITE:
+ case REQ_OP_ZONE_APPEND:
+diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
+index fdc1fd2586b9ec..ed4ba2e469ac79 100644
+--- a/drivers/bluetooth/btintel_pcie.c
++++ b/drivers/bluetooth/btintel_pcie.c
+@@ -401,7 +401,7 @@ static int btintel_pcie_send_sync(struct btintel_pcie_data *data,
+
+ tfd_index = data->ia.tr_hia[BTINTEL_PCIE_TXQ_NUM];
+
+- if (tfd_index > txq->count)
++ if (tfd_index >= txq->count)
+ return -ERANGE;
+
+ if (skb->len > BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN) {
+@@ -1715,7 +1715,7 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id)
+ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
+ {
+ int err;
+- int num_irqs, i;
++ int num_irqs, i, j;
+
+ for (i = 0; i < BTINTEL_PCIE_MSIX_VEC_MAX; i++)
+ data->msix_entries[i].entry = i;
+@@ -1744,6 +1744,10 @@ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data)
+ KBUILD_MODNAME,
+ msix_entry);
+ if (err) {
++ for (j = 0; j < i; j++)
++ devm_free_irq(&data->pdev->dev,
++ data->msix_entries[j].vector,
++ &data->msix_entries[j]);
+ pci_free_irq_vectors(data->pdev);
+ data->alloc_vecs = 0;
+ return err;
+@@ -1815,6 +1819,13 @@ static int btintel_pcie_config_pcie(struct pci_dev *pdev,
+ if (IS_ERR(data->base_addr))
+ return PTR_ERR(data->base_addr);
+
++ /* Do shared hardware reset to ensure a clean start before
++ * configuring interrupts.
++ */
++ err = btintel_pcie_reset_bt(data);
++ if (err)
++ return err;
++
+ err = btintel_pcie_setup_irq(data);
+ if (err)
+ return err;
+@@ -3003,7 +3014,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev)
+ struct msix_entry *msix_entry;
+
+ msix_entry = &data->msix_entries[i];
+- free_irq(msix_entry->vector, msix_entry);
++ devm_free_irq(&pdev->dev, msix_entry->vector, msix_entry);
+ }
+
+ pci_free_irq_vectors(pdev);
+diff --git a/drivers/clk/qcom/gcc-eliza.c b/drivers/clk/qcom/gcc-eliza.c
+index 3e26c7a1e5b546..fe18942a59ac45 100644
+--- a/drivers/clk/qcom/gcc-eliza.c
++++ b/drivers/clk/qcom/gcc-eliza.c
+@@ -3010,8 +3010,6 @@ static const u32 gcc_eliza_critical_cbcrs[] = {
+ 0x26034, /* GCC_CAMERA_XO_CLK */
+ 0x27004, /* GCC_DISP_AHB_CLK */
+ 0x71004, /* GCC_GPU_CFG_AHB_CLK */
+- 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */
+- 0x52010, /* GCC_PCIE_RSCC_XO_CLK */
+ 0x32004, /* GCC_VIDEO_AHB_CLK */
+ 0x32038, /* GCC_VIDEO_XO_CLK */
+ };
+@@ -3045,6 +3043,10 @@ static const struct regmap_config gcc_eliza_regmap_config = {
+
+ static void clk_eliza_regs_configure(struct device *dev, struct regmap *regmap)
+ {
++ /* Keep clocks always enabled */
++ regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */
++ regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */
++
+ /* FORCE_MEM_CORE_ON for ufs phy ice core and gcc ufs phy axi clocks */
+ qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true);
+ qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_axi_clk, true);
+diff --git a/drivers/clk/qcom/gcc-kaanapali.c b/drivers/clk/qcom/gcc-kaanapali.c
+index 842c1a70c69168..5bcbcd17865774 100644
+--- a/drivers/clk/qcom/gcc-kaanapali.c
++++ b/drivers/clk/qcom/gcc-kaanapali.c
+@@ -3464,8 +3464,6 @@ static const u32 gcc_kaanapali_critical_cbcrs[] = {
+ 0x9f004, /* GCC_EVA_AHB_CLK */
+ 0x9f024, /* GCC_EVA_XO_CLK */
+ 0x71004, /* GCC_GPU_CFG_AHB_CLK */
+- 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */
+- 0x52010, /* GCC_PCIE_RSCC_XO_CLK */
+ 0x32004, /* GCC_VIDEO_AHB_CLK */
+ 0x32040, /* GCC_VIDEO_XO_CLK */
+ };
+@@ -3480,6 +3478,10 @@ static const struct regmap_config gcc_kaanapali_regmap_config = {
+
+ static void clk_kaanapali_regs_configure(struct device *dev, struct regmap *regmap)
+ {
++ /* Keep clocks always enabled */
++ regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */
++ regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */
++
+ /* FORCE_MEM_CORE_ON for ufs phy ice core clocks */
+ qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true);
+ }
+diff --git a/drivers/clk/qcom/gpucc-glymur.c b/drivers/clk/qcom/gpucc-glymur.c
+index 001b2454786a0c..cac51de20b2950 100644
+--- a/drivers/clk/qcom/gpucc-glymur.c
++++ b/drivers/clk/qcom/gpucc-glymur.c
+@@ -510,7 +510,7 @@ static struct gdsc gpu_cc_cx_gdsc = {
+ .name = "gpu_cc_cx_gdsc",
+ },
+ .pwrsts = PWRSTS_OFF_ON,
+- .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE,
++ .flags = RETAIN_FF_ENABLE | VOTABLE,
+ };
+
+ static struct clk_regmap *gpu_cc_glymur_clocks[] = {
+diff --git a/drivers/clk/qcom/gpucc-kaanapali.c b/drivers/clk/qcom/gpucc-kaanapali.c
+index ae5563e516f677..f75f2caa2205c4 100644
+--- a/drivers/clk/qcom/gpucc-kaanapali.c
++++ b/drivers/clk/qcom/gpucc-kaanapali.c
+@@ -380,7 +380,7 @@ static struct gdsc gpu_cc_cx_gdsc = {
+ .name = "gpu_cc_cx_gdsc",
+ },
+ .pwrsts = PWRSTS_OFF_ON,
+- .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE,
++ .flags = RETAIN_FF_ENABLE | VOTABLE,
+ };
+
+ static struct clk_regmap *gpu_cc_kaanapali_clocks[] = {
+diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
+index 475235c402e888..0c0d11c7292598 100644
+--- a/drivers/edac/amd64_edac.c
++++ b/drivers/edac/amd64_edac.c
+@@ -2796,13 +2796,13 @@ static inline void decode_bus_error(int node_id, struct mce *m)
+ * the instance_id. For example, instance_id=0xYXXXXX where Y is the channel
+ * number.
+ *
+- * For DRAM ECC errors, the Chip Select number is given in bits [2:0] of
++ * For DRAM ECC errors, the Chip Select number is given in bits [1:0] of
+ * the MCA_SYND[ErrorInformation] field.
+ */
+ static void umc_get_err_info(struct mce *m, struct err_info *err)
+ {
+ err->channel = (m->ipid & GENMASK(31, 0)) >> 20;
+- err->csrow = m->synd & 0x7;
++ err->csrow = m->synd & 0x3;
+ }
+
+ static void decode_umc_error(int node_id, struct mce *m)
+diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
+index 9053662f18177f..f629cc526f3ee7 100644
+--- a/drivers/gpio/gpio-exar.c
++++ b/drivers/gpio/gpio-exar.c
+@@ -199,6 +199,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
+ index = ida_alloc(&ida_index, GFP_KERNEL);
+ if (index < 0)
+ return index;
++ exar_gpio->index = index;
+
+ ret = devm_add_action_or_reset(dev, exar_devm_ida_free, exar_gpio);
+ if (ret)
+@@ -214,7 +215,6 @@ static int gpio_exar_probe(struct platform_device *pdev)
+ exar_gpio->gpio_chip.set = exar_set_value;
+ exar_gpio->gpio_chip.base = -1;
+ exar_gpio->gpio_chip.ngpio = ngpios;
+- exar_gpio->index = index;
+ exar_gpio->first_pin = first_pin;
+
+ ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio);
+diff --git a/drivers/gpio/gpio-mpsse.c b/drivers/gpio/gpio-mpsse.c
+index a859deab2bca80..5ce822c0ddcf49 100644
+--- a/drivers/gpio/gpio-mpsse.c
++++ b/drivers/gpio/gpio-mpsse.c
+@@ -10,6 +10,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+
+@@ -24,6 +25,7 @@ struct mpsse_priv {
+ raw_spinlock_t irq_spin; /* protects worker list */
+ atomic_t irq_type[16]; /* pin -> edge detection type */
+ atomic_t irq_enabled;
++ atomic_t dying; /* no new workers after disconnect */
+ int id;
+
+ u8 gpio_outputs[2]; /* Output states for GPIOs [L, H] */
+@@ -46,6 +48,7 @@ struct mpsse_worker {
+ atomic_t cancelled;
+ struct list_head list; /* linked list */
+ struct list_head destroy; /* teardown linked list */
++ struct rcu_head rcu; /* deferred free for dying path */
+ };
+
+ struct bulk_desc {
+@@ -525,10 +528,24 @@ static void gpio_mpsse_irq_enable(struct irq_data *irqd)
+ worker->priv = priv;
+ INIT_LIST_HEAD(&worker->list);
+ INIT_WORK(&worker->work, gpio_mpsse_poll);
+- schedule_work(&worker->work);
+
+- scoped_guard(raw_spinlock_irqsave, &priv->irq_spin)
++ scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) {
++ if (atomic_read(&priv->dying)) {
++ /*
++ * Cannot kfree() here: this callback
++ * runs with the IRQ descriptor's raw
++ * spinlock held and kfree() may sleep
++ * on PREEMPT_RT. The worker is not
++ * yet published, so the deferred free
++ * is unobservable.
++ */
++ kfree_rcu(worker, rcu);
++ return;
++ }
++
+ list_add(&worker->list, &priv->workers);
++ schedule_work(&worker->work);
++ }
+ }
+ }
+
+@@ -704,6 +721,9 @@ static void gpio_mpsse_disconnect(struct usb_interface *intf)
+ {
+ struct mpsse_priv *priv = usb_get_intfdata(intf);
+
++ scoped_guard(raw_spinlock_irqsave, &priv->irq_spin)
++ atomic_set(&priv->dying, 1);
++
+ /*
+ * Lock prevents double-free of worker from here and the teardown
+ * step at the beginning of gpio_mpsse_poll
+diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
+index 532205175827a0..9406ce85f93308 100644
+--- a/drivers/gpio/gpio-xilinx.c
++++ b/drivers/gpio/gpio-xilinx.c
+@@ -271,14 +271,7 @@ static void xgpio_save_regs(struct xgpio_instance *chip)
+
+ static int xgpio_request(struct gpio_chip *chip, unsigned int offset)
+ {
+- int ret;
+-
+- ret = pm_runtime_get_sync(chip->parent);
+- /*
+- * If the device is already active pm_runtime_get() will return 1 on
+- * success, but gpio_request still needs to return 0.
+- */
+- return ret < 0 ? ret : 0;
++ return pm_runtime_resume_and_get(chip->parent);
+ }
+
+ static void xgpio_free(struct gpio_chip *chip, unsigned int offset)
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+index 4b29e7eee61053..299baecb83ebda 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+@@ -597,14 +597,18 @@ int amdgpu_amdkfd_get_dmabuf_info(struct amdgpu_device *adev, int dma_buf_fd,
+ /* first get metadata_size by buffer = NULL */
+ r = amdgpu_bo_get_metadata(bo, NULL, 0,
+ metadata_size, NULL);
++ if (r)
++ goto out_put;
+
+ /* user buf_size is bigger than bo metadata_size
+ * allocate a buf at kernel space and copy */
+ if (*metadata_size <= buffer_size) {
+ *metadata_buffer = kzalloc(*metadata_size, GFP_KERNEL);
+
+- if (!*metadata_buffer)
+- return -ENOMEM;
++ if (!*metadata_buffer) {
++ r = -ENOMEM;
++ goto out_put;
++ }
+
+ r = amdgpu_bo_get_metadata(bo, *metadata_buffer, *metadata_size,
+ NULL, &metadata_flags);
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+index 4536d46b7f21b5..40b34770414b78 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+@@ -120,6 +120,20 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f,
+
+ *pos &= (1UL << 22) - 1;
+
++ if (size > PAGE_SIZE)
++ return -EINVAL;
++
++ /*
++ * Access the user buffer only while none of the locks below are held:
++ * a fault takes mmap_lock, and grbm_idx_mutex and srbm_mutex nest
++ * inside it.
++ */
++ u32 *data __free(kfree) = kmalloc(size, GFP_KERNEL);
++ if (!data)
++ return -ENOMEM;
++ if (!read && copy_from_user(data, buf, size))
++ return -EFAULT;
++
+ r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
+ if (r < 0) {
+ pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+@@ -151,28 +165,16 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f,
+ mutex_lock(&adev->pm.mutex);
+
+ while (size) {
+- uint32_t value;
+-
+- if (read) {
+- value = RREG32(*pos >> 2);
+- r = put_user(value, (uint32_t *)buf);
+- } else {
+- r = get_user(value, (uint32_t *)buf);
+- if (!r)
+- amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, value, 0);
+- }
+- if (r) {
+- result = r;
+- goto end;
+- }
++ if (read)
++ data[result >> 2] = RREG32(*pos >> 2);
++ else
++ amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, data[result >> 2], 0);
+
+ result += 4;
+- buf += 4;
+ *pos += 4;
+ size -= 4;
+ }
+
+-end:
+ if (use_bank) {
+ amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, 0);
+ mutex_unlock(&adev->grbm_idx_mutex);
+@@ -187,6 +189,10 @@ end:
+ pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+
+ amdgpu_virt_disable_access_debugfs(adev);
++
++ if (read && copy_to_user(buf, data, result))
++ return -EFAULT;
++
+ return result;
+ }
+
+@@ -237,11 +243,24 @@ static ssize_t amdgpu_debugfs_regs2_op(struct file *f, char __user *buf, u32 off
+ struct amdgpu_device *adev = rd->adev;
+ ssize_t result = 0;
+ int r;
+- uint32_t value;
+
+ if (size & 0x3 || offset & 0x3)
+ return -EINVAL;
+
++ if (size > PAGE_SIZE)
++ return -EINVAL;
++
++ /*
++ * Access the user buffer only while none of the locks below are held:
++ * a fault takes mmap_lock, and grbm_idx_mutex and srbm_mutex nest
++ * inside it.
++ */
++ u32 *data __free(kfree) = kmalloc(size, GFP_KERNEL);
++ if (!data)
++ return -ENOMEM;
++ if (write_en && copy_from_user(data, buf, size))
++ return -EFAULT;
++
+ r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
+ if (r < 0) {
+ pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+@@ -280,24 +299,16 @@ static ssize_t amdgpu_debugfs_regs2_op(struct file *f, char __user *buf, u32 off
+ mutex_lock(&adev->pm.mutex);
+
+ while (size) {
+- if (!write_en) {
+- value = RREG32(offset >> 2);
+- r = put_user(value, (uint32_t *)buf);
+- } else {
+- r = get_user(value, (uint32_t *)buf);
+- if (!r)
+- amdgpu_mm_wreg_mmio_rlc(adev, offset >> 2, value, rd->id.xcc_id);
+- }
+- if (r) {
+- result = r;
+- goto end;
+- }
++ if (!write_en)
++ data[result >> 2] = RREG32(offset >> 2);
++ else
++ amdgpu_mm_wreg_mmio_rlc(adev, offset >> 2, data[result >> 2],
++ rd->id.xcc_id);
+ offset += 4;
+ size -= 4;
+ result += 4;
+- buf += 4;
+ }
+-end:
++
+ if (rd->id.use_grbm) {
+ amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, rd->id.xcc_id);
+ mutex_unlock(&adev->grbm_idx_mutex);
+@@ -316,6 +327,10 @@ end:
+ pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+
+ amdgpu_virt_disable_access_debugfs(adev);
++
++ if (!write_en && copy_to_user(buf, data, result))
++ return -EFAULT;
++
+ return result;
+ }
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+index 5d6149ba7ab78e..8fb3ebe4c2990d 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+@@ -1089,20 +1089,17 @@ void amdgpu_gmc_init_vga_resv_regions(struct amdgpu_device *adev)
+ case CHIP_RENOIR:
+ adev->mman.keep_stolen_vga_memory = true;
+ break;
+- case CHIP_POLARIS10:
+- case CHIP_POLARIS11:
+- case CHIP_POLARIS12:
+- /* MacBookPros with switchable graphics put VRAM at 0 when
+- * the iGPU is enabled which results in cursor issues if
+- * the cursor ends up at 0. Reserve vram at 0 in that case.
+- */
+- if (adev->gmc.vram_start == 0)
+- adev->mman.keep_stolen_vga_memory = true;
+- break;
+ default:
+ adev->mman.keep_stolen_vga_memory = false;
+ break;
+ }
++ /* MacBookPros with switchable graphics put VRAM at 0 when
++ * the iGPU is enabled which results in cursor issues if
++ * the cursor ends up at 0. Reserve vram at 0 in that case.
++ */
++ if ((adev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) &&
++ (adev->gmc.vram_start == 0))
++ adev->mman.keep_stolen_vga_memory = true;
+
+ if (amdgpu_sriov_vf(adev) ||
+ !amdgpu_device_has_display_hardware(adev)) {
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+index 8bb9c198ddec13..872cce1115a915 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+@@ -30,6 +30,7 @@
+ #include
+ #include
+ #include
++#include
+ #include "amdgpu_uvd.h"
+ #include "amdgpu_vce.h"
+ #include "atom.h"
+@@ -1631,6 +1632,9 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc)
+ DRM_ERROR("Invalid crtc %u\n", pipe);
+ return -EINVAL;
+ }
++ if (!down_read_trylock(&adev->reset_domain->sem))
++ return drm_crtc_vblank_count(crtc);
++
+
+ /* The hw increments its frame counter at start of vsync, not at start
+ * of vblank, as is required by DRM core vblank counter handling.
+@@ -1676,6 +1680,7 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc)
+ DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n");
+ }
+
++ up_read(&adev->reset_domain->sem);
+ return count;
+ }
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+index 655429c4035181..0c3fa2d60555a9 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
+@@ -439,6 +439,7 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
+ u64 doorbell_index;
+ struct drm_gem_object *gobj;
+ struct amdgpu_userq_obj *db_obj = db_info->db_obj;
++ struct amdgpu_bo *abo;
+ int r, db_size;
+
+ gobj = drm_gem_object_lookup(filp, db_info->doorbell_handle);
+@@ -447,7 +448,17 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
+ return -EINVAL;
+ }
+
+- db_obj->obj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
++ /*
++ * Pinning a regular BO into the doorbell domain would discard its
++ * contents, possibly those of a buffer shared by another client.
++ */
++ abo = gem_to_amdgpu_bo(gobj);
++ if (!(abo->preferred_domains & AMDGPU_GEM_DOMAIN_DOORBELL)) {
++ drm_gem_object_put(gobj);
++ return -EINVAL;
++ }
++
++ db_obj->obj = amdgpu_bo_ref(abo);
+ drm_gem_object_put(gobj);
+
+ r = amdgpu_bo_reserve(db_obj->obj, true);
+diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+index 4e44a581a78a21..e4bd6e5509b529 100644
+--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
++++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+@@ -304,8 +304,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
+
+ compute_mqd = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size);
+ if (IS_ERR(compute_mqd)) {
+- DRM_ERROR("Failed to read user MQD\n");
+- r = -ENOMEM;
++ r = PTR_ERR(compute_mqd);
+ goto free_mqd;
+ }
+
+@@ -349,8 +348,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
+
+ mqd_gfx_v11 = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size);
+ if (IS_ERR(mqd_gfx_v11)) {
+- DRM_ERROR("Failed to read user MQD\n");
+- r = -ENOMEM;
++ r = PTR_ERR(mqd_gfx_v11);
+ goto free_mqd;
+ }
+
+@@ -394,8 +392,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue,
+
+ mqd_sdma_v11 = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size);
+ if (IS_ERR(mqd_sdma_v11)) {
+- DRM_ERROR("Failed to read sdma user MQD\n");
+- r = -ENOMEM;
++ r = PTR_ERR(mqd_sdma_v11);
+ goto free_mqd;
+ }
+
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+index 487cf746c45045..ed934425907906 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+@@ -599,12 +599,32 @@ static int allocate_doorbell(struct qcm_process_device *qpd,
+ * we need the physical sdma engine id in order to get the
+ * correct doorbell offset.
+ */
+- uint32_t valid_id = idx_offset[qpd->dqm->dev->node_id *
+- get_num_all_sdma_engines(qpd->dqm) +
+- q->properties.sdma_engine_id]
+- + (q->properties.sdma_queue_id & 1)
+- * KFD_QUEUE_DOORBELL_MIRROR_OFFSET
+- + (q->properties.sdma_queue_id >> 1);
++ u32 engine_base = idx_offset[dev->node_id *
++ get_num_all_sdma_engines(qpd->dqm) +
++ q->properties.sdma_engine_id];
++ u32 valid_id;
++
++ /*
++ * With the aqua_vanjaram doorbell layout, a shader doorbell
++ * write whose 32-byte block starts in the previous engine's
++ * range rings that engine instead. Engine ranges are 10
++ * indices apart (sdma_doorbell_range = 20 dwords, halved for
++ * 8-byte doorbells, in aqua_vanjaram_doorbell_index_init()),
++ * which puts odd engines 2 indices into a shared block.
++ * Aligning costs at most 2 indices, and 8 queues per engine use
++ * only 4 of the 10, so the aligned base stays in range. The
++ * 512-index mirror offset keeps the alignment.
++ */
++ if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 3) ||
++ KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 4) ||
++ KFD_GC_VERSION(dev) == IP_VERSION(9, 5, 0))
++ engine_base = ALIGN(engine_base,
++ KFD_SDMA_SHADER_DOORBELL_GRANULARITY);
++
++ valid_id = engine_base +
++ (q->properties.sdma_queue_id & 1) *
++ KFD_QUEUE_DOORBELL_MIRROR_OFFSET +
++ (q->properties.sdma_queue_id >> 1);
+
+ if (restore_id && *restore_id != valid_id)
+ return -EINVAL;
+diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+index 4d65f94da4d818..993d98374253ba 100644
+--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
++++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+@@ -132,6 +132,13 @@
+ */
+ #define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512
+
++/*
++ * On GC 9.4.3, 9.4.4 and 9.5.0, doorbell writes issued from shaders are
++ * routed to an SDMA engine at 32-byte granularity, i.e. 4 indices with the
++ * 8-byte SDMA doorbells used on SOC15.
++ */
++#define KFD_SDMA_SHADER_DOORBELL_GRANULARITY 4
++
+ /**
+ * enum kfd_ioctl_flags - KFD ioctl flags
+ * Various flags that can be set in &amdkfd_ioctl_desc.flags to control how
+diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+index 4ee7db8a6a2267..b92d129962b2a8 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+@@ -7260,10 +7260,15 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode,
+ const struct drm_display_mode *native_mode,
+ bool scale_enabled)
+ {
++ /* Inserted modes copy the native sync; a sink mode with equal totals may not */
+ if (scale_enabled || (
+ native_mode->clock == drm_mode->clock &&
+ native_mode->htotal == drm_mode->htotal &&
+- native_mode->vtotal == drm_mode->vtotal)) {
++ native_mode->vtotal == drm_mode->vtotal &&
++ native_mode->hsync_start == drm_mode->hsync_start &&
++ native_mode->hsync_end == drm_mode->hsync_end &&
++ native_mode->vsync_start == drm_mode->vsync_start &&
++ native_mode->vsync_end == drm_mode->vsync_end)) {
+ if (native_mode->crtc_clock)
+ copy_crtc_timing_for_drm_display_mode(native_mode, drm_mode);
+ } else {
+@@ -10397,6 +10402,13 @@ static void amdgpu_dm_enable_self_refresh(struct amdgpu_display_manager *dm,
+ struct amdgpu_dm_connector *aconn =
+ (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context;
+
++ if (!acrtc_state->base.async_flip) {
++ amdgpu_dm_psr_set_event(dm, acrtc_state->stream, false,
++ psr_event_immediate_flip, false);
++ amdgpu_dm_replay_set_event(dm, acrtc_state->stream, false,
++ replay_event_immediate_flip, false);
++ }
++
+ /* Decrement skip count when SR is enabled and we're doing fast updates. */
+ if (acrtc_state->update_type == UPDATE_TYPE_FAST &&
+ (psr->psr_feature_enabled || pr->replay_feature_enabled)) {
+@@ -10810,6 +10822,18 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
+ spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags);
+ }
+ mutex_lock(&dm->dc_lock);
++ /*
++ * Tearing (immediate) flips cannot work with panel self-refresh
++ * features. The event is cleared by
++ * amdgpu_dm_enable_self_refresh() once async flips stop.
++ */
++ if (immediate_flip) {
++ dc_exit_ips_for_hw_access(dm->dc);
++ amdgpu_dm_psr_set_event(dm, acrtc_state->stream, true,
++ psr_event_immediate_flip, true);
++ amdgpu_dm_replay_set_event(dm, acrtc_state->stream, true,
++ replay_event_immediate_flip, true);
++ }
+ update_planes_and_stream_adapter(dm->dc,
+ acrtc_state->update_type,
+ planes_count,
+diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+index cfd76c54f652bd..1d69ecae10a478 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+@@ -110,25 +110,7 @@ void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state
+
+ if (plane_state->pixel_blend_mode == DRM_MODE_BLEND_PREMULTI ||
+ plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) {
+- static const uint32_t alpha_formats[] = {
+- DRM_FORMAT_ARGB8888,
+- DRM_FORMAT_RGBA8888,
+- DRM_FORMAT_ABGR8888,
+- DRM_FORMAT_ARGB2101010,
+- DRM_FORMAT_ABGR2101010,
+- DRM_FORMAT_ARGB16161616,
+- DRM_FORMAT_ABGR16161616,
+- DRM_FORMAT_ARGB16161616F,
+- };
+- uint32_t format = plane_state->fb->format->format;
+- unsigned int i;
+-
+- for (i = 0; i < ARRAY_SIZE(alpha_formats); ++i) {
+- if (format == alpha_formats[i]) {
+- *per_pixel_alpha = true;
+- break;
+- }
+- }
++ *per_pixel_alpha = plane_state->fb->format->has_alpha;
+
+ if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE)
+ *pre_multiplied_alpha = false;
+diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+index d4577663a1f0ef..aa36b79d0f6c42 100644
+--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
++++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+@@ -189,13 +189,12 @@ static int aspeed_gfx_load(struct drm_device *drm)
+ }
+ reset_control_deassert(priv->rst);
+
+- priv->clk = devm_clk_get(drm->dev, NULL);
++ priv->clk = devm_clk_get_enabled(drm->dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ dev_err(&pdev->dev,
+- "missing or invalid clk device tree entry");
++ "failed to get and enable clock\n");
+ return PTR_ERR(priv->clk);
+ }
+- clk_prepare_enable(priv->clk);
+
+ /* Sanitize control registers */
+ writel(0, priv->base + CRT_CTRL1);
+diff --git a/drivers/gpu/drm/bridge/th1520-dw-hdmi.c b/drivers/gpu/drm/bridge/th1520-dw-hdmi.c
+index cbea8b14cd4b0f..2fa7f2d46b3dcd 100644
+--- a/drivers/gpu/drm/bridge/th1520-dw-hdmi.c
++++ b/drivers/gpu/drm/bridge/th1520-dw-hdmi.c
+@@ -135,8 +135,8 @@ static int th1520_dw_hdmi_probe(struct platform_device *pdev)
+ plat_data->priv_data = hdmi;
+
+ hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data);
+- if (IS_ERR(hdmi))
+- return PTR_ERR(hdmi);
++ if (IS_ERR(hdmi->dw_hdmi))
++ return PTR_ERR(hdmi->dw_hdmi);
+
+ platform_set_drvdata(pdev, hdmi);
+
+@@ -145,9 +145,9 @@ static int th1520_dw_hdmi_probe(struct platform_device *pdev)
+
+ static void th1520_dw_hdmi_remove(struct platform_device *pdev)
+ {
+- struct dw_hdmi *hdmi = platform_get_drvdata(pdev);
++ struct th1520_hdmi *hdmi = platform_get_drvdata(pdev);
+
+- dw_hdmi_remove(hdmi);
++ dw_hdmi_remove(hdmi->dw_hdmi);
+ }
+
+ static const struct of_device_id th1520_dw_hdmi_of_table[] = {
+diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
+index e623ccb4c1d8ab..488fd123a01adb 100644
+--- a/drivers/gpu/drm/display/drm_dp_helper.c
++++ b/drivers/gpu/drm/display/drm_dp_helper.c
+@@ -4634,7 +4634,9 @@ static int dp_aux_backlight_update_status(struct backlight_device *bd)
+
+ if (!backlight_is_blank(bd)) {
+ if (!bl->enabled) {
+- drm_edp_backlight_enable(bl->aux, &bl->info, brightness);
++ ret = drm_edp_backlight_enable(bl->aux, &bl->info, brightness);
++ if (ret)
++ return ret;
+ bl->enabled = true;
+ return 0;
+ }
+diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
+index 687b36eea0c703..9124cbe1ff8895 100644
+--- a/drivers/gpu/drm/drm_bridge.c
++++ b/drivers/gpu/drm/drm_bridge.c
+@@ -414,8 +414,10 @@ void drm_bridge_add(struct drm_bridge *bridge)
+ * in bridge_lingering_list. Remove it or bridge_lingering_list will be
+ * corrupted when adding this bridge to bridge_list below.
+ */
++ mutex_lock(&bridge_lock);
+ if (!list_empty(&bridge->list))
+ list_del_init(&bridge->list);
++ mutex_unlock(&bridge_lock);
+
+ mutex_init(&bridge->hpd_mutex);
+
+@@ -556,8 +558,10 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
+ if (!bridge->container)
+ DRM_WARN("DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()\n");
+
+- if (list_empty(&bridge->list))
+- DRM_WARN("Missing drm_bridge_add() before attach\n");
++ scoped_guard(mutex, &bridge_lock) {
++ if (list_empty(&bridge->list))
++ DRM_WARN("Missing drm_bridge_add() before attach\n");
++ }
+
+ drm_bridge_get(bridge);
+
+diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
+index 80ca785bdb262f..3dfa64dc310969 100644
+--- a/drivers/gpu/drm/drm_fb_helper.c
++++ b/drivers/gpu/drm/drm_fb_helper.c
+@@ -1724,10 +1724,10 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
+
+ ret = drm_fb_helper_single_fb_probe(fb_helper);
+ if (ret < 0) {
+- if (ret == -EAGAIN) {
+- fb_helper->deferred_setup = true;
++ /* modesets are probed but fb_helper->fb isn't; defer restore too */
++ fb_helper->deferred_setup = true;
++ if (ret == -EAGAIN)
+ ret = 0;
+- }
+ mutex_unlock(&fb_helper->lock);
+
+ goto err_drm_fb_helper_release_info;
+diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
+index aa7792966287bf..5aa5ac2f37274a 100644
+--- a/drivers/gpu/drm/gud/gud_pipe.c
++++ b/drivers/gpu/drm/gud/gud_pipe.c
+@@ -507,6 +507,7 @@ int gud_plane_atomic_check(struct drm_plane *plane,
+ for_each_new_connector_in_state(state, connector, connector_state, i) {
+ if (connector_state->crtc)
+ break;
++ connector_state = NULL;
+ }
+
+ /*
+diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+index 1f303d4eaa4d4f..d5aadced7da0cf 100644
+--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
++++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+@@ -1766,6 +1766,7 @@ static int eb_reinit_userptr(struct i915_execbuffer *eb)
+
+ static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb)
+ {
++ const unsigned int count = eb->buffer_count;
+ bool have_copy = false;
+ struct eb_vma *ev;
+ int err = 0;
+@@ -1868,7 +1869,6 @@ err:
+
+ out:
+ if (have_copy) {
+- const unsigned int count = eb->buffer_count;
+ unsigned int i;
+
+ for (i = 0; i < count; i++) {
+diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c b/drivers/gpu/drm/i915/gt/intel_rps.c
+index a33b19c04737a7..0f9b4f1dd3cb6d 100644
+--- a/drivers/gpu/drm/i915/gt/intel_rps.c
++++ b/drivers/gpu/drm/i915/gt/intel_rps.c
+@@ -1904,7 +1904,8 @@ static void rps_work(struct work_struct *work)
+
+ out:
+ spin_lock_irq(gt->irq_lock);
+- gen6_gt_pm_unmask_irq(gt, rps->pm_events);
++ if (intel_rps_is_active(rps))
++ gen6_gt_pm_unmask_irq(gt, rps->pm_events);
+ spin_unlock_irq(gt->irq_lock);
+ }
+
+diff --git a/drivers/gpu/drm/imagination/pvr_mmu.c b/drivers/gpu/drm/imagination/pvr_mmu.c
+index 62eae7fcd5a26a..67e73d7d5d0e97 100644
+--- a/drivers/gpu/drm/imagination/pvr_mmu.c
++++ b/drivers/gpu/drm/imagination/pvr_mmu.c
+@@ -2337,7 +2337,7 @@ void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx)
+ * @ctx: MMU context associated with owning VM context.
+ * @sgt: Scatter gather table containing pages pinned for use by this context.
+ * @device_addr: Virtual device address at the start of the requested mapping.
+- * @sgt_offset: Start offset of the requested device-virtual memory mapping.
++ * @sgt_offset: Offset into @sgt of the start of the requested mapping.
+ * @size: Size in bytes of the requested device-virtual memory mapping. For an
+ * unmapping, this should be zero so that no page tables are allocated.
+ *
+@@ -2350,7 +2350,6 @@ struct pvr_mmu_op_context *
+ pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt,
+ u64 device_addr, u64 sgt_offset, u64 size)
+ {
+- u64 start_addr = device_addr + sgt_offset;
+ int err;
+
+ struct pvr_mmu_op_context *op_ctx = kzalloc_obj(*op_ctx);
+@@ -2365,18 +2364,18 @@ pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt,
+
+ if (size) {
+ /*
+- * The number of page table objects we need to prealloc is
+- * indicated by the mapping size, start address and the sizes
+- * of the areas mapped per PT or PD. The range calculation is
+- * identical to that for the index into a table for a device
+- * address, so we reuse those functions here.
++ * The page tables needed are set by the device-virtual range
++ * being mapped: one level 1 table per 1GiB region and one
++ * level 0 table per 2MiB region the range touches. Tables that
++ * already exist are not consumed, so this is an upper bound.
+ */
+- const u32 l1_start_idx = pvr_page_table_l2_idx(start_addr);
+- const u32 l1_end_idx = pvr_page_table_l2_idx(start_addr + size);
+- const u32 l1_count = l1_end_idx - l1_start_idx + 1;
+- const u32 l0_start_idx = pvr_page_table_l1_idx(start_addr);
+- const u32 l0_end_idx = pvr_page_table_l1_idx(start_addr + size);
+- const u32 l0_count = l0_end_idx - l0_start_idx + 1;
++ const u64 last_addr = device_addr + size - 1;
++ const u64 l1_count =
++ (last_addr >> ROGUE_MMUCTRL_VADDR_PC_INDEX_SHIFT) -
++ (device_addr >> ROGUE_MMUCTRL_VADDR_PC_INDEX_SHIFT) + 1;
++ const u64 l0_count =
++ (last_addr >> ROGUE_MMUCTRL_VADDR_PD_INDEX_SHIFT) -
++ (device_addr >> ROGUE_MMUCTRL_VADDR_PD_INDEX_SHIFT) + 1;
+
+ /*
+ * Alloc and push page table entries until we have enough of
+diff --git a/drivers/gpu/drm/imagination/pvr_vm.c b/drivers/gpu/drm/imagination/pvr_vm.c
+index 55cc999f3708b6..cbdd15ed74fdbb 100644
+--- a/drivers/gpu/drm/imagination/pvr_vm.c
++++ b/drivers/gpu/drm/imagination/pvr_vm.c
+@@ -418,6 +418,8 @@ pvr_vm_gpuva_unmap(struct drm_gpuva_op *op, void *op_ctx)
+ static int
+ pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx)
+ {
++ /* The split parts belong to the object of the mapping being split. */
++ struct drm_gpuvm_bo *vm_bo = op->remap.unmap->va->vm_bo;
+ struct pvr_vm_bind_op *ctx = op_ctx;
+ u64 va_start = 0, va_range = 0;
+ int err;
+@@ -433,14 +435,12 @@ pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx)
+ drm_gpuva_remap(&ctx->prev_va->base, &ctx->next_va->base, &op->remap);
+
+ if (op->remap.prev) {
+- pvr_gem_object_get(gem_to_pvr_gem(ctx->prev_va->base.gem.obj));
+- drm_gpuva_link(&ctx->prev_va->base, ctx->gpuvm_bo);
++ drm_gpuva_link(&ctx->prev_va->base, vm_bo);
+ ctx->prev_va = NULL;
+ }
+
+ if (op->remap.next) {
+- pvr_gem_object_get(gem_to_pvr_gem(ctx->next_va->base.gem.obj));
+- drm_gpuva_link(&ctx->next_va->base, ctx->gpuvm_bo);
++ drm_gpuva_link(&ctx->next_va->base, vm_bo);
+ ctx->next_va = NULL;
+ }
+
+diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
+index 369ee06434bbdd..765b895619e8be 100644
+--- a/drivers/gpu/drm/panthor/panthor_sched.c
++++ b/drivers/gpu/drm/panthor/panthor_sched.c
+@@ -3675,6 +3675,9 @@ int panthor_group_create(struct panthor_file *pfile,
+ hweight64(group_args->tiler_core_mask) < group_args->max_tiler_cores)
+ return -EINVAL;
+
++ if (group_args->queues.count > sched->cs_slot_count)
++ return -EINVAL;
++
+ group = kzalloc_obj(*group);
+ if (!group)
+ return -ENOMEM;
+diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
+index 49ea2ed0996b4c..7b8b3364000fce 100644
+--- a/drivers/gpu/drm/vc4/vc4_bo.c
++++ b/drivers/gpu/drm/vc4/vc4_bo.c
+@@ -204,7 +204,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev,
+ struct list_head *new_list;
+ uint32_t i;
+
+- new_list = kmalloc_objs(struct list_head, new_size);
++ new_list = kvmalloc_objs(struct list_head, new_size);
+ if (!new_list)
+ return NULL;
+
+@@ -224,7 +224,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev,
+ for (i = vc4->bo_cache.size_list_size; i < new_size; i++)
+ INIT_LIST_HEAD(&new_list[i]);
+
+- kfree(vc4->bo_cache.size_list);
++ kvfree(vc4->bo_cache.size_list);
+ vc4->bo_cache.size_list = new_list;
+ vc4->bo_cache.size_list_size = new_size;
+ }
+@@ -1052,6 +1052,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)
+ cancel_work_sync(&vc4->bo_cache.time_work);
+
+ vc4_bo_cache_purge(dev);
++ kvfree(vc4->bo_cache.size_list);
+
+ for (i = 0; i < vc4->num_labels; i++) {
+ if (vc4->bo_labels[i].num_allocated) {
+diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
+index 616caf9d9915b9..7b64e1ed02d4c8 100644
+--- a/drivers/gpu/drm/vc4/vc4_drv.c
++++ b/drivers/gpu/drm/vc4/vc4_drv.c
+@@ -360,8 +360,11 @@ static int vc4_drm_bind(struct device *dev)
+ }
+
+ ret = aperture_remove_all_conflicting_devices(driver->name);
+- if (ret)
++ if (ret) {
++ if (firmware)
++ rpi_firmware_put(firmware);
+ goto err;
++ }
+
+ if (firmware) {
+ ret = rpi_firmware_property(firmware,
+diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
+index 0f5958c1e6b601..b0e82c2dc1bae7 100644
+--- a/drivers/gpu/drm/vc4/vc4_drv.h
++++ b/drivers/gpu/drm/vc4/vc4_drv.h
+@@ -1051,7 +1051,7 @@ void vc4_plane_async_set_fb(struct drm_plane *plane,
+ /* vc4_v3d.c */
+ extern struct platform_driver vc4_v3d_driver;
+ extern const struct of_device_id vc4_v3d_dt_match[];
+-int vc4_v3d_get_bin_slot(struct vc4_dev *vc4);
++int vc4_v3d_get_bin_slot(struct vc4_dev *vc4, long timeout);
+ int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used);
+ void vc4_v3d_bin_bo_put(struct vc4_dev *vc4);
+ int vc4_v3d_pm_get(struct vc4_dev *vc4);
+diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
+index e231c906709c1b..6ee4bd77d4331a 100644
+--- a/drivers/gpu/drm/vc4/vc4_gem.c
++++ b/drivers/gpu/drm/vc4/vc4_gem.c
+@@ -877,11 +877,17 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
+ drm_gem_object_put(&bo->base.base);
+ }
+
+- /* Free up the allocation of any bin slots we used. */
++ /* Free up the allocation of any bin slots we used. Jobs that ran to
++ * completion had their slots released in vc4_irq_finish_render_job().
++ * Only jobs that never completed still have slots to be released here.
++ */
+ spin_lock_irqsave(&vc4->job_lock, irqflags);
+ vc4->bin_alloc_used &= ~exec->bin_slots;
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+
++ /* Let anyone waiting on the binner pool retry. */
++ wake_up_all(&vc4->job_wait_queue);
++
+ /* Release the reference on the binner BO if needed. */
+ if (exec->bin_bo_used)
+ vc4_v3d_bin_bo_put(vc4);
+diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
+index 7877d493d80e62..dc10d3a4d90f20 100644
+--- a/drivers/gpu/drm/vc4/vc4_irq.c
++++ b/drivers/gpu/drm/vc4/vc4_irq.c
+@@ -74,7 +74,7 @@ vc4_overflow_mem_work(struct work_struct *work)
+
+ bo = vc4->bin_bo;
+
+- bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
++ bin_bo_slot = vc4_v3d_get_bin_slot(vc4, msecs_to_jiffies(500));
+ if (bin_bo_slot < 0) {
+ drm_err(&vc4->base, "Couldn't allocate binner overflow mem\n");
+ goto complete;
+@@ -165,6 +165,10 @@ vc4_irq_finish_render_job(struct drm_device *dev)
+ trace_vc4_rcl_end_irq(dev, exec->seqno);
+
+ vc4->finished_seqno++;
++
++ vc4->bin_alloc_used &= ~exec->bin_slots;
++ exec->bin_slots = 0;
++
+ list_move_tail(&exec->head, &vc4->job_done_list);
+
+ nextbin = vc4_first_bin_job(vc4);
+@@ -276,7 +280,7 @@ vc4_irq_disable(struct drm_device *dev)
+ V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS);
+
+ /* Finish any interrupt handler still in flight. */
+- synchronize_irq(vc4->irq);
++ disable_irq(vc4->irq);
+
+ cancel_work_sync(&vc4->overflow_mem_work);
+ }
+@@ -284,7 +288,6 @@ vc4_irq_disable(struct drm_device *dev)
+ int vc4_irq_install(struct drm_device *dev, int irq)
+ {
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
+- int ret;
+
+ if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
+ return -ENODEV;
+@@ -298,19 +301,8 @@ int vc4_irq_install(struct drm_device *dev, int irq)
+ init_waitqueue_head(&vc4->job_wait_queue);
+ INIT_WORK(&vc4->overflow_mem_work, vc4_overflow_mem_work);
+
+- /* Clear any pending interrupts someone might have left around
+- * for us.
+- */
+- V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS);
+-
+- ret = devm_request_irq(dev->dev, irq, vc4_irq, 0,
+- dev_name(dev->dev), dev);
+- if (ret)
+- return ret;
+-
+- vc4_irq_enable(dev);
+-
+- return 0;
++ return devm_request_irq(dev->dev, irq, vc4_irq, IRQF_NO_AUTOEN,
++ dev_name(dev->dev), dev);
+ }
+
+ void vc4_irq_uninstall(struct drm_device *dev)
+diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
+index f32410420d3e4d..6844e8f3948cf8 100644
+--- a/drivers/gpu/drm/vc4/vc4_v3d.c
++++ b/drivers/gpu/drm/vc4/vc4_v3d.c
+@@ -9,6 +9,7 @@
+ #include
+ #include
+ #include
++#include
+
+ #include
+
+@@ -172,46 +173,42 @@ static void vc4_v3d_init_hw(struct drm_device *dev)
+ V3D_WRITE(V3D_VPMBASE, 0);
+ }
+
+-int vc4_v3d_get_bin_slot(struct vc4_dev *vc4)
++static int bin_slot_try_alloc(struct vc4_dev *vc4)
+ {
+- struct drm_device *dev = &vc4->base;
+- unsigned long irqflags;
+ int slot;
+- uint64_t seqno = 0;
+- struct vc4_exec_info *exec;
+
+- if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
+- return -ENODEV;
++ guard(spinlock_irqsave)(&vc4->job_lock);
+
+-try_again:
+- spin_lock_irqsave(&vc4->job_lock, irqflags);
+ slot = ffs(~vc4->bin_alloc_used);
+ if (slot != 0) {
+ /* Switch from ffs() bit index to a 0-based index. */
+ slot--;
+ vc4->bin_alloc_used |= BIT(slot);
+- spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+- return slot;
++ } else {
++ slot = -ENOMEM;
+ }
+
+- /* Couldn't find an open slot. Wait for render to complete
+- * and try again.
+- */
+- exec = vc4_last_render_job(vc4);
+- if (exec)
+- seqno = exec->seqno;
+- spin_unlock_irqrestore(&vc4->job_lock, irqflags);
++ return slot;
++}
+
+- if (seqno) {
+- int ret = vc4_wait_for_seqno(dev, seqno, ~0ull, true);
++int vc4_v3d_get_bin_slot(struct vc4_dev *vc4, long timeout)
++{
++ int slot;
++ long ret;
+
+- if (ret == 0)
+- goto try_again;
++ if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
++ return -ENODEV;
+
++ /* If the pool is full, wait for a job to release its slots. */
++ ret = wait_event_interruptible_timeout(vc4->job_wait_queue,
++ (slot = bin_slot_try_alloc(vc4)) >= 0,
++ timeout);
++ if (ret < 0)
+ return ret;
+- }
++ if (ret == 0)
++ return -ENOMEM;
+
+- return -ENOMEM;
++ return slot;
+ }
+
+ /*
+@@ -396,6 +393,7 @@ static int vc4_v3d_runtime_resume(struct device *dev)
+ vc4_v3d_init_hw(&vc4->base);
+
+ vc4_irq_enable(&vc4->base);
++ enable_irq(vc4->irq);
+
+ return 0;
+ }
+@@ -452,6 +450,12 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
+ return ret;
+ vc4->irq = ret;
+
++ ret = vc4_irq_install(drm, vc4->irq);
++ if (ret) {
++ drm_err(drm, "Failed to install IRQ handler\n");
++ return ret;
++ }
++
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+@@ -473,12 +477,6 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
+ V3D_WRITE(V3D_BPOA, 0);
+ V3D_WRITE(V3D_BPOS, 0);
+
+- ret = vc4_irq_install(drm, vc4->irq);
+- if (ret) {
+- drm_err(drm, "Failed to install IRQ handler\n");
+- goto err_put_runtime_pm;
+- }
+-
+ pm_runtime_use_autosuspend(dev);
+ pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */
+ pm_runtime_put_autosuspend(dev);
+@@ -497,8 +495,15 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master,
+ struct drm_device *drm = data;
+ struct vc4_dev *vc4 = to_vc4_dev(drm);
+
++ /* A straggler vc4_reset() re-enables the interrupt. */
++ timer_shutdown_sync(&vc4->hangcheck.timer);
++ cancel_work_sync(&vc4->hangcheck.reset_work);
++
+ vc4_irq_uninstall(drm);
+
++ /* Flush rather than cancel, so queued completions release their jobs. */
++ flush_work(&vc4->job_done_work);
++
+ /* Disable the binner's overflow memory address, so the next
+ * driver probe (if any) doesn't try to reuse our old
+ * allocation.
+diff --git a/drivers/gpu/drm/vc4/vc4_validate.c b/drivers/gpu/drm/vc4/vc4_validate.c
+index d2a65c968b1f90..565227657b43b4 100644
+--- a/drivers/gpu/drm/vc4/vc4_validate.c
++++ b/drivers/gpu/drm/vc4/vc4_validate.c
+@@ -402,7 +402,7 @@ validate_tile_binning_config(VALIDATE_ARGS)
+ return -EINVAL;
+ }
+
+- bin_slot = vc4_v3d_get_bin_slot(vc4);
++ bin_slot = vc4_v3d_get_bin_slot(vc4, MAX_SCHEDULE_TIMEOUT);
+ if (bin_slot < 0) {
+ if (bin_slot != -EINTR && bin_slot != -ERESTARTSYS) {
+ drm_err(dev, "Failed to allocate binner memory: %d\n",
+diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+index d1e7df50019030..5a69606a0593bc 100644
+--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+@@ -324,6 +324,7 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
+ unsigned long kmap_num;
+ SVGA3dCopyBox *box;
+ u32 box_count;
++ u64 src_extent;
+ void *virtual;
+ bool is_iomem;
+ struct vmw_dma_cmd {
+@@ -335,6 +336,8 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
+ vmw_surface_get_desc(VMW_CURSOR_SNOOP_FORMAT);
+ const u32 image_pitch = VMW_CURSOR_SNOOP_WIDTH * desc->pitchBytesPerBlock;
+
++ BUILD_BUG_ON(sizeof(*srf->snooper.image) != desc->pitchBytesPerBlock);
++
+ cmd = container_of(header, struct vmw_dma_cmd, header);
+
+ /* No snooper installed, nothing to copy */
+@@ -372,8 +375,19 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
+ return;
+ }
+
++ if (box->w == 0 || box->h == 0)
++ return;
++
++ src_extent = (u64)(box->h - 1) * cmd->dma.guest.pitch +
++ (u64)box->w * desc->pitchBytesPerBlock;
++ if (src_extent > bo->base.size) {
++ DRM_ERROR("Cursor snoop source of %llu bytes exceeds the %zu byte buffer\n",
++ src_extent, bo->base.size);
++ return;
++ }
++
+ kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT;
+- kmap_num = (VMW_CURSOR_SNOOP_HEIGHT * image_pitch) >> PAGE_SHIFT;
++ kmap_num = PFN_UP(src_extent);
+
+ ret = ttm_bo_reserve(bo, true, false, NULL);
+ if (unlikely(ret != 0)) {
+@@ -387,14 +401,16 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
+
+ virtual = ttm_kmap_obj_virtual(&map, &is_iomem);
+
+- if (box->w == VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) {
++ if (box->w == VMW_CURSOR_SNOOP_WIDTH &&
++ box->h == VMW_CURSOR_SNOOP_HEIGHT &&
++ cmd->dma.guest.pitch == image_pitch) {
+ memcpy(srf->snooper.image, virtual,
+ VMW_CURSOR_SNOOP_HEIGHT * image_pitch);
+ } else {
+- /* Image is unsigned pointer. */
++ /* The destination stride is in pixels. */
+ for (i = 0; i < box->h; i++)
+- memcpy(srf->snooper.image + i * image_pitch,
+- virtual + i * cmd->dma.guest.pitch,
++ memcpy(srf->snooper.image + i * VMW_CURSOR_SNOOP_WIDTH,
++ virtual + (size_t)i * cmd->dma.guest.pitch,
+ box->w * desc->pitchBytesPerBlock);
+ }
+ srf->snooper.id++;
+diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
+index 73469ea5f333d3..f1dbdc802df81a 100644
+--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
++++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
+@@ -356,7 +356,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt,
+ drm_exec_retry_on_contention(&exec);
+ xe_validation_retry_on_oom(&ctx, &ret);
+ if (!ret)
+- ttm_bo_pin(&bo->ttm);
++ xe_bo_pin_account(bo);
+ }
+ if (ret)
+ goto err;
+@@ -373,7 +373,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt,
+
+ err_unpin:
+ ttm_bo_reserve(&bo->ttm, false, false, NULL);
+- ttm_bo_unpin(&bo->ttm);
++ xe_bo_unpin_account(bo);
+ ttm_bo_unreserve(&bo->ttm);
+ err:
+ kfree(vma);
+@@ -393,7 +393,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
+ xe_ggtt_node_remove(vma->node, false);
+
+ ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
+- ttm_bo_unpin(&vma->bo->ttm);
++ xe_bo_unpin_account(vma->bo);
+ ttm_bo_unreserve(&vma->bo->ttm);
+ kfree(vma);
+ }
+diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
+index 2c60e99249f932..f4c5151d61c7ce 100644
+--- a/drivers/gpu/drm/xe/xe_bo.c
++++ b/drivers/gpu/drm/xe/xe_bo.c
+@@ -443,6 +443,100 @@ static void xe_ttm_tt_account_subtract(struct xe_device *xe, struct ttm_tt *tt)
+ xe_shrinker_mod_pages(xe->mem.shrinker, -(long)tt->num_pages, 0);
+ }
+
++static bool xe_ttm_bo_is_imported(struct ttm_buffer_object *tbo)
++{
++ dma_resv_assert_held(tbo->base.resv);
++
++ return tbo->ttm &&
++ (tbo->ttm->page_flags & (TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE)) ==
++ TTM_TT_FLAG_EXTERNAL;
++}
++
++/*
++ * Account @bo's pages as pinned for the shrinker. Removes @bo's pages
++ * from the shrinker's shrinkable / purgeable counts on the transition
++ * from unpinned to pinned. Must be called with @bo's dma-resv held,
++ * after &ttm_buffer_object.pin_count has been incremented by
++ * ttm_bo_pin(). Safe to call unconditionally regardless of which pin
++ * path (kernel, external, framebuffer, backup object, ...) is pinning
++ * @bo, since it only acts on the true 0->1 pin_count transition.
++ *
++ * Imported bos (xe_ttm_bo_is_imported()) are excluded: for those,
++ * xe_ttm_tt_populate() never actually populates the tt or calls
++ * xe_ttm_tt_account_add(), but TTM core's ttm_tt_populate() still
++ * unconditionally marks the tt as populated on driver-hook success.
++ * Relying on ttm_tt_is_populated() for these would subtract pages that
++ * were never added, underflowing the shrinker's counts.
++ */
++static void xe_bo_account_pin(struct xe_bo *bo)
++{
++ struct xe_device *xe = xe_bo_device(bo);
++
++ if (bo->ttm.pin_count == 1 && bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm) &&
++ !xe_ttm_bo_is_imported(&bo->ttm))
++ xe_ttm_tt_account_subtract(xe, bo->ttm.ttm);
++}
++
++/*
++ * Counterpart to xe_bo_account_pin(). Must be called with @bo's dma-resv
++ * held, before &ttm_buffer_object.pin_count is decremented by
++ * ttm_bo_unpin(), so that the check against the true 1->0 transition sees
++ * the pin count that is about to be released. See xe_bo_account_pin() for
++ * why imported bos are excluded.
++ *
++ * On the true last unpin, also removes @bo from whichever pinned-bo list
++ * (external or kernel_bo_present) it may currently be linked on, since a
++ * bo's final unpin can happen through a pin path (e.g. framebuffer,
++ * backup object) that has no notion of, or ownership over, that list.
++ * This is safe and list-agnostic: list_del_init() only needs the node
++ * itself, not knowledge of which list it is threaded through, and is a
++ * no-op if @bo is not linked.
++ */
++static void xe_bo_account_unpin(struct xe_bo *bo)
++{
++ struct xe_device *xe = xe_bo_device(bo);
++ bool last_unpin = bo->ttm.pin_count == 1;
++
++ if (last_unpin && !list_empty(&bo->pinned_link)) {
++ spin_lock(&xe->pinned.lock);
++ list_del_init(&bo->pinned_link);
++ spin_unlock(&xe->pinned.lock);
++ }
++
++ if (last_unpin && bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm) &&
++ !xe_ttm_bo_is_imported(&bo->ttm))
++ xe_ttm_tt_account_add(xe, bo->ttm.ttm);
++}
++
++/**
++ * xe_bo_pin_account() - Pin a bo and account its pages for the shrinker
++ * @bo: The buffer object to pin.
++ *
++ * Pins @bo via ttm_bo_pin() and updates the shrinker's shrinkable /
++ * purgeable page accounting to match. Must be called with @bo's dma-resv
++ * held. Safe to call regardless of which pin path (kernel, external,
++ * framebuffer, backup object, ...) is pinning @bo.
++ */
++void xe_bo_pin_account(struct xe_bo *bo)
++{
++ ttm_bo_pin(&bo->ttm);
++ xe_bo_account_pin(bo);
++}
++
++/**
++ * xe_bo_unpin_account() - Unpin a bo and account its pages for the shrinker
++ * @bo: The buffer object to unpin.
++ *
++ * Counterpart to xe_bo_pin_account(). Updates the shrinker's shrinkable /
++ * purgeable page accounting to match, then unpins @bo via ttm_bo_unpin().
++ * Must be called with @bo's dma-resv held.
++ */
++void xe_bo_unpin_account(struct xe_bo *bo)
++{
++ xe_bo_account_unpin(bo);
++ ttm_bo_unpin(&bo->ttm);
++}
++
+ static void update_global_total_pages(struct ttm_device *ttm_dev,
+ long num_pages)
+ {
+@@ -1377,7 +1471,8 @@ int xe_bo_notifier_prepare_pinned(struct xe_bo *bo)
+ }
+
+ backup->parent_obj = xe_bo_get(bo); /* Released by bo_destroy */
+- ttm_bo_pin(&backup->ttm);
++ /* Note: XE_BO_FLAG_SYSTEM resolves to XE_PL_TT so already populated. */
++ xe_bo_pin_account(backup);
+ bo->backup_obj = backup;
+ }
+
+@@ -1397,7 +1492,7 @@ int xe_bo_notifier_unprepare_pinned(struct xe_bo *bo)
+ {
+ xe_bo_lock(bo, false);
+ if (bo->backup_obj) {
+- ttm_bo_unpin(&bo->backup_obj->ttm);
++ xe_bo_unpin_account(bo->backup_obj);
+ xe_bo_put(bo->backup_obj);
+ bo->backup_obj = NULL;
+ }
+@@ -1608,7 +1703,7 @@ out_backup:
+ xe_bo_vunmap(backup);
+ if (!bo->backup_obj) {
+ if (xe_bo_is_pinned(backup))
+- ttm_bo_unpin(&backup->ttm);
++ xe_bo_unpin_account(backup);
+ xe_bo_put(backup);
+ }
+ out_unlock_bo:
+@@ -2000,15 +2095,6 @@ static vm_fault_t xe_err_to_fault_t(int err)
+ return VM_FAULT_SIGBUS;
+ }
+
+-static bool xe_ttm_bo_is_imported(struct ttm_buffer_object *tbo)
+-{
+- dma_resv_assert_held(tbo->base.resv);
+-
+- return tbo->ttm &&
+- (tbo->ttm->page_flags & (TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE)) ==
+- TTM_TT_FLAG_EXTERNAL;
+-}
+-
+ static vm_fault_t xe_bo_cpu_fault_fastpath(struct vm_fault *vmf, struct xe_device *xe,
+ struct xe_bo *bo, bool needs_rpm)
+ {
+@@ -2975,12 +3061,13 @@ uint64_t vram_region_gpu_offset(struct ttm_resource *res)
+ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec)
+ {
+ struct xe_device *xe = xe_bo_device(bo);
++ bool first_pin = !xe_bo_is_pinned(bo);
+ int err;
+
+ xe_assert(xe, !bo->vm);
+ xe_assert(xe, xe_bo_is_user(bo));
+
+- if (!xe_bo_is_pinned(bo)) {
++ if (first_pin) {
+ if (!in_place) {
+ err = xe_bo_validate(bo, NULL, false, exec);
+ if (err)
+@@ -2992,9 +3079,7 @@ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec)
+ spin_unlock(&xe->pinned.lock);
+ }
+
+- ttm_bo_pin(&bo->ttm);
+- if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm))
+- xe_ttm_tt_account_subtract(xe, bo->ttm.ttm);
++ xe_bo_pin_account(bo);
+
+ /*
+ * FIXME: If we always use the reserve / unreserve functions for locking
+@@ -3050,9 +3135,7 @@ int xe_bo_pin(struct xe_bo *bo, struct drm_exec *exec)
+ spin_unlock(&xe->pinned.lock);
+ }
+
+- ttm_bo_pin(&bo->ttm);
+- if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm))
+- xe_ttm_tt_account_subtract(xe, bo->ttm.ttm);
++ xe_bo_pin_account(bo);
+
+ /*
+ * FIXME: If we always use the reserve / unreserve functions for locking
+@@ -3081,14 +3164,7 @@ void xe_bo_unpin_external(struct xe_bo *bo)
+ xe_assert(xe, xe_bo_is_pinned(bo));
+ xe_assert(xe, xe_bo_is_user(bo));
+
+- spin_lock(&xe->pinned.lock);
+- if (bo->ttm.pin_count == 1 && !list_empty(&bo->pinned_link))
+- list_del_init(&bo->pinned_link);
+- spin_unlock(&xe->pinned.lock);
+-
+- ttm_bo_unpin(&bo->ttm);
+- if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm))
+- xe_ttm_tt_account_add(xe, bo->ttm.ttm);
++ xe_bo_unpin_account(bo);
+
+ /*
+ * FIXME: If we always use the reserve / unreserve functions for locking
+@@ -3106,21 +3182,16 @@ void xe_bo_unpin(struct xe_bo *bo)
+ xe_assert(xe, xe_bo_is_pinned(bo));
+
+ if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) {
+- spin_lock(&xe->pinned.lock);
+ xe_assert(xe, !list_empty(&bo->pinned_link));
+- list_del_init(&bo->pinned_link);
+- spin_unlock(&xe->pinned.lock);
+
+ if (bo->backup_obj) {
+ if (xe_bo_is_pinned(bo->backup_obj))
+- ttm_bo_unpin(&bo->backup_obj->ttm);
++ xe_bo_unpin_account(bo->backup_obj);
+ xe_bo_put(bo->backup_obj);
+ bo->backup_obj = NULL;
+ }
+ }
+- ttm_bo_unpin(&bo->ttm);
+- if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm))
+- xe_ttm_tt_account_add(xe, bo->ttm.ttm);
++ xe_bo_unpin_account(bo);
+ }
+
+ /**
+diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
+index a9e5e1bb8e4f7d..f9c8c73a1e69ca 100644
+--- a/drivers/gpu/drm/xe/xe_bo.h
++++ b/drivers/gpu/drm/xe/xe_bo.h
+@@ -228,6 +228,8 @@ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec);
+ int xe_bo_pin(struct xe_bo *bo, struct drm_exec *exec);
+ void xe_bo_unpin_external(struct xe_bo *bo);
+ void xe_bo_unpin(struct xe_bo *bo);
++void xe_bo_pin_account(struct xe_bo *bo);
++void xe_bo_unpin_account(struct xe_bo *bo);
+ int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict,
+ struct drm_exec *exec);
+
+diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
+index b376a9167cc1c8..3127fb89d965fa 100644
+--- a/drivers/gpu/drm/xe/xe_i2c.c
++++ b/drivers/gpu/drm/xe/xe_i2c.c
+@@ -330,12 +330,15 @@ static void xe_i2c_remove(void *data)
+ xe_i2c_irq_reset(xe);
+ xe_amc_exit(i2c);
+
++ /* Stop the notifier from arming the client work before teardown. */
++ bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier);
++ cancel_work_sync(&i2c->work);
++
+ for (i = 0; i < XE_I2C_MAX_CLIENTS; i++) {
+ i2c_unregister_device(i2c->client[i]);
+ i2c->client[i] = NULL;
+ }
+
+- bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier);
+ xe_i2c_unregister_adapter(i2c);
+ xe->i2c = NULL;
+ }
+diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
+index 9f8217ff1904ca..224e64bccaebc6 100644
+--- a/drivers/gpu/drm/xe/xe_lrc.c
++++ b/drivers/gpu/drm/xe/xe_lrc.c
+@@ -1099,8 +1099,7 @@ static void xe_lrc_finish(struct xe_lrc *lrc)
+ #define CONTEXT_ACTIVE XE_LRC_CTX_TIMESTAMP_ACTIVE
+ static ssize_t setup_utilization_wa(struct xe_lrc *lrc,
+ struct xe_hw_engine *hwe,
+- u32 *batch,
+- size_t max_len)
++ u32 *batch, size_t max_len, bool indirect)
+ {
+ u32 *cmd = batch;
+
+@@ -1131,19 +1130,25 @@ static ssize_t setup_utilization_wa(struct xe_lrc *lrc,
+ }
+
+ static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
+- u32 *batch, size_t max_len)
++ u32 *batch, size_t max_len, bool indirect)
+ {
+ const u32 ts_addr = __xe_lrc_ctx_timestamp_ggtt_addr(lrc);
+ u32 *cmd = batch;
+
+- if (!XE_GT_WA(lrc->gt, 16010904313) ||
+- !(hwe->class == XE_ENGINE_CLASS_RENDER ||
+- hwe->class == XE_ENGINE_CLASS_COMPUTE ||
+- hwe->class == XE_ENGINE_CLASS_COPY ||
++ if (!XE_GT_WA(lrc->gt, 16010904313))
++ return 0;
++
++ if (!indirect &&
++ !(hwe->class == XE_ENGINE_CLASS_COPY ||
+ hwe->class == XE_ENGINE_CLASS_VIDEO_DECODE ||
+ hwe->class == XE_ENGINE_CLASS_VIDEO_ENHANCE))
+ return 0;
+
++ if (indirect &&
++ !(hwe->class == XE_ENGINE_CLASS_RENDER ||
++ hwe->class == XE_ENGINE_CLASS_COMPUTE))
++ return 0;
++
+ if (xe_gt_WARN_ON(lrc->gt, max_len < 12))
+ return -ENOSPC;
+
+@@ -1169,7 +1174,8 @@ static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
+
+ static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc,
+ struct xe_hw_engine *hwe,
+- u32 *batch, size_t max_len)
++ u32 *batch, size_t max_len,
++ bool indirect)
+ {
+ struct xe_device *xe = gt_to_xe(lrc->gt);
+ const u32 *user_batch;
+@@ -1198,7 +1204,8 @@ static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc,
+
+ static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc,
+ struct xe_hw_engine *hwe,
+- u32 *batch, size_t max_len)
++ u32 *batch, size_t max_len,
++ bool indirect)
+ {
+ struct xe_device *xe = gt_to_xe(lrc->gt);
+ const u32 *user_batch;
+@@ -1227,7 +1234,8 @@ static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc,
+
+ static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc,
+ struct xe_hw_engine *hwe,
+- u32 *batch, size_t max_len)
++ u32 *batch, size_t max_len,
++ bool indirect)
+ {
+ u32 *cmd = batch;
+
+@@ -1247,7 +1255,8 @@ static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc,
+
+ static ssize_t setup_invalidate_auxccs_wa(struct xe_lrc *lrc,
+ struct xe_hw_engine *hwe,
+- u32 *batch, size_t max_len)
++ u32 *batch, size_t max_len,
++ bool indirect)
+ {
+ struct xe_gt *gt = lrc->gt;
+ u32 *(*emit)(struct xe_gt *gt, u32 *cmd) =
+@@ -1264,7 +1273,7 @@ static ssize_t setup_invalidate_auxccs_wa(struct xe_lrc *lrc,
+
+ struct bo_setup {
+ ssize_t (*setup)(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
+- u32 *batch, size_t max_size);
++ u32 *batch, size_t max_size, bool indirect);
+ };
+
+ struct bo_setup_state {
+@@ -1273,6 +1282,7 @@ struct bo_setup_state {
+ struct xe_hw_engine *hwe;
+ size_t max_size;
+ size_t reserve_dw;
++ bool indirect;
+ unsigned int offset;
+ const struct bo_setup *funcs;
+ unsigned int num_funcs;
+@@ -1298,7 +1308,8 @@ static int setup_bo(struct bo_setup_state *state)
+
+ for (size_t i = 0; i < state->num_funcs; i++) {
+ ssize_t len = state->funcs[i].setup(state->lrc, state->hwe,
+- state->ptr, remain);
++ state->ptr, remain,
++ state->indirect);
+
+ remain -= len;
+
+@@ -1404,6 +1415,7 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
+ struct bo_setup_state state = {
+ .lrc = lrc,
+ .hwe = hwe,
++ .indirect = true,
+ .max_size = (63 * 64) /* max 63 cachelines */,
+ .buffer = NULL,
+ .offset = __xe_lrc_indirect_ctx_offset(lrc),
+diff --git a/drivers/gpu/drm/xe/xe_mmio.c b/drivers/gpu/drm/xe/xe_mmio.c
+index 78adb303b66303..6907c1127d3266 100644
+--- a/drivers/gpu/drm/xe/xe_mmio.c
++++ b/drivers/gpu/drm/xe/xe_mmio.c
+@@ -288,6 +288,7 @@ u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg)
+ return (u64)udw << 32 | ldw;
+ }
+
++#define __XE_MMIO_WAIT_MAX_BACKOFF_100MS (100 * USEC_PER_MSEC)
+ static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val,
+ u32 timeout_us, u32 *out_val, bool atomic, bool expect_match)
+ {
+@@ -318,10 +319,10 @@ static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u
+ wait = ktime_us_delta(end, cur);
+
+ if (atomic)
+- udelay(wait);
++ udelay(min_t(s64, wait, (MAX_UDELAY_MS * 1000)));
+ else
+ usleep_range(wait, wait << 1);
+- wait <<= 1;
++ wait = min_t(s64, wait << 1, __XE_MMIO_WAIT_MAX_BACKOFF_100MS);
+ }
+
+ if (ret != 0) {
+diff --git a/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c b/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
+index 72baf1aa4b3ad6..a0179e62abaaf0 100644
+--- a/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
++++ b/drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
+@@ -19,20 +19,20 @@
+ #include "xe_sysctrl_mailbox_types.h"
+
+ struct xe_sysctrl_mailbox_msg_hdr {
+- __le32 data;
+-} __packed;
++ u32 data;
++};
+
+ #define XE_SYSCTRL_HDR_GROUP_ID(hdr) \
+- FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, le32_to_cpu((hdr)->data))
++ FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, (hdr)->data)
+
+ #define XE_SYSCTRL_HDR_COMMAND(hdr) \
+- FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, le32_to_cpu((hdr)->data))
++ FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, (hdr)->data)
+
+ #define XE_SYSCTRL_HDR_IS_RESPONSE(hdr) \
+- FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, le32_to_cpu((hdr)->data))
++ FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, (hdr)->data)
+
+ #define XE_SYSCTRL_HDR_RESULT(hdr) \
+- FIELD_GET(SYSCTRL_HDR_RESULT_MASK, le32_to_cpu((hdr)->data))
++ FIELD_GET(SYSCTRL_HDR_RESULT_MASK, (hdr)->data)
+
+ static bool sysctrl_wait_bit_clear(struct xe_sysctrl *sc, u32 bit_mask,
+ unsigned int timeout_ms)
+@@ -126,8 +126,8 @@ static int sysctrl_prepare_command(struct xe_device *xe,
+ return -ENOMEM;
+
+ hdr = (struct xe_sysctrl_mailbox_msg_hdr *)buffer;
+- hdr->data = cpu_to_le32(FIELD_PREP(SYSCTRL_HDR_GROUP_ID_MASK, group_id) |
+- FIELD_PREP(SYSCTRL_HDR_COMMAND_MASK, command));
++ hdr->data = FIELD_PREP(SYSCTRL_HDR_GROUP_ID_MASK, group_id) |
++ FIELD_PREP(SYSCTRL_HDR_COMMAND_MASK, command);
+
+ if (data_in && data_in_len)
+ memcpy(buffer + sizeof(*hdr), data_in, data_in_len);
+diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
+index 80d2eabc930eca..84c90091d45fcd 100644
+--- a/drivers/hid/hid-steam.c
++++ b/drivers/hid/hid-steam.c
+@@ -327,12 +327,14 @@ struct steam_device {
+ spinlock_t lock;
+ struct hid_device *hdev, *client_hdev;
+ struct mutex report_mutex;
++ struct mutex registration_mutex;
+ unsigned long client_opened;
+ struct input_dev __rcu *input;
+ struct input_dev __rcu *sensors;
+ unsigned long quirks;
+ struct work_struct work_connect;
+ bool connected;
++ bool registered;
+ char serial_no[STEAM_SERIAL_LEN + 1];
+ struct power_supply_desc battery_desc;
+ struct power_supply __rcu *battery;
+@@ -346,7 +348,6 @@ struct steam_device {
+ u16 rumble_right;
+ unsigned int sensor_timestamp_us;
+ unsigned int sensor_update_rate_us;
+- struct work_struct unregister_work;
+ };
+
+ static int steam_recv_report(struct steam_device *steam,
+@@ -510,7 +511,6 @@ static int steam_get_serial(struct steam_device *steam)
+ u8 cmd[] = {ID_GET_STRING_ATTRIBUTE, sizeof(steam->serial_no), ATTRIB_STR_UNIT_SERIAL};
+ u8 reply[3 + STEAM_SERIAL_LEN + 1];
+
+- guard(mutex)(&steam->report_mutex);
+ ret = steam_send_report(steam, cmd, sizeof(cmd));
+ if (ret < 0)
+ return ret;
+@@ -537,7 +537,6 @@ static int steam_get_attributes(struct steam_device *steam)
+ int i;
+ struct steam_controller_attribute *attr;
+
+- guard(mutex)(&steam->report_mutex);
+ ret = steam_send_report(steam, cmd, sizeof(cmd));
+ if (ret < 0)
+ return ret;
+@@ -599,9 +598,7 @@ static inline int steam_haptic_pulse(struct steam_device *steam, u8 pad,
+ report[8] = count >> 8;
+ report[9] = gain;
+
+- mutex_lock(&steam->report_mutex);
+ ret = steam_send_report(steam, report, sizeof(report));
+- mutex_unlock(&steam->report_mutex);
+ return ret;
+ }
+
+@@ -621,9 +618,7 @@ static inline int steam_haptic_rumble(struct steam_device *steam,
+ report[9] = left_gain;
+ report[10] = right_gain;
+
+- mutex_lock(&steam->report_mutex);
+ ret = steam_send_report(steam, report, sizeof(report));
+- mutex_unlock(&steam->report_mutex);
+ return ret;
+ }
+
+@@ -631,8 +626,11 @@ static void steam_haptic_rumble_cb(struct work_struct *work)
+ {
+ struct steam_device *steam = container_of(work, struct steam_device,
+ rumble_work);
++
++ mutex_lock(&steam->report_mutex);
+ steam_haptic_rumble(steam, 0, steam->rumble_left,
+ steam->rumble_right, 2, 0);
++ mutex_unlock(&steam->report_mutex);
+ }
+
+ #ifdef CONFIG_STEAM_FF
+@@ -653,7 +651,6 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
+ if (steam->gamepad_mode)
+ enable = false;
+
+- mutex_lock(&steam->report_mutex);
+ if (enable) {
+ /* enable esc, enter, cursors */
+ steam_send_report_byte(steam, ID_SET_DEFAULT_DIGITAL_MAPPINGS);
+@@ -678,14 +675,13 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
+ 0);
+ }
+ }
+- mutex_unlock(&steam->report_mutex);
+ }
+
+ static int steam_input_open(struct input_dev *dev)
+ {
+ struct steam_device *steam = input_get_drvdata(dev);
+ unsigned long flags;
+- bool set_lizard_mode;
++ bool client_opened;
+
+ /*
+ * Disabling lizard mode automatically is only done on the Steam
+@@ -694,9 +690,10 @@ static int steam_input_open(struct input_dev *dev)
+ */
+ if (!(steam->quirks & STEAM_QUIRK_DECK)) {
+ spin_lock_irqsave(&steam->lock, flags);
+- set_lizard_mode = !steam->client_opened && lizard_mode;
++ client_opened = steam->client_opened;
+ spin_unlock_irqrestore(&steam->lock, flags);
+- if (set_lizard_mode)
++ guard(mutex)(&steam->report_mutex);
++ if (!client_opened && lizard_mode)
+ steam_set_lizard_mode(steam, false);
+ }
+
+@@ -707,13 +704,14 @@ static void steam_input_close(struct input_dev *dev)
+ {
+ struct steam_device *steam = input_get_drvdata(dev);
+ unsigned long flags;
+- bool set_lizard_mode;
++ bool client_opened;
+
+ if (!(steam->quirks & STEAM_QUIRK_DECK)) {
+ spin_lock_irqsave(&steam->lock, flags);
+- set_lizard_mode = !steam->client_opened && lizard_mode;
++ client_opened = steam->client_opened;
+ spin_unlock_irqrestore(&steam->lock, flags);
+- if (set_lizard_mode)
++ guard(mutex)(&steam->report_mutex);
++ if (!client_opened && lizard_mode)
+ steam_set_lizard_mode(steam, true);
+ }
+ }
+@@ -721,14 +719,11 @@ static void steam_input_close(struct input_dev *dev)
+ static int steam_sensor_open(struct input_dev *dev)
+ {
+ struct steam_device *steam = input_get_drvdata(dev);
+- unsigned long flags;
+- bool client_opened;
+
+- spin_lock_irqsave(&steam->lock, flags);
+- client_opened = steam->client_opened;
+- spin_unlock_irqrestore(&steam->lock, flags);
+- if (client_opened)
+- return 0;
++ scoped_guard(spinlock_irqsave, &steam->lock) {
++ if (steam->client_opened)
++ return 0;
++ }
+
+ guard(mutex)(&steam->report_mutex);
+ steam_write_settings(steam, SETTING_IMU_MODE,
+@@ -741,14 +736,11 @@ static int steam_sensor_open(struct input_dev *dev)
+ static void steam_sensor_close(struct input_dev *dev)
+ {
+ struct steam_device *steam = input_get_drvdata(dev);
+- unsigned long flags;
+- bool client_opened;
+
+- spin_lock_irqsave(&steam->lock, flags);
+- client_opened = steam->client_opened;
+- spin_unlock_irqrestore(&steam->lock, flags);
+- if (client_opened)
+- return;
++ scoped_guard(spinlock_irqsave, &steam->lock) {
++ if (steam->client_opened)
++ return;
++ }
+
+ guard(mutex)(&steam->report_mutex);
+ steam_write_settings(steam, SETTING_IMU_MODE, 0, 0);
+@@ -823,6 +815,7 @@ static int steam_battery_register(struct steam_device *steam)
+ &steam->battery_desc, &battery_cfg);
+ if (IS_ERR(battery)) {
+ ret = PTR_ERR(battery);
++ devm_kfree(&steam->hdev->dev, steam->battery_desc.name);
+ hid_err(steam->hdev,
+ "%s:power_supply_register failed with error %d\n",
+ __func__, ret);
+@@ -1082,103 +1075,117 @@ static void steam_battery_unregister(struct steam_device *steam)
+ RCU_INIT_POINTER(steam->battery, NULL);
+ synchronize_rcu();
+ power_supply_unregister(battery);
++ devm_kfree(&steam->hdev->dev, steam->battery_desc.name);
+ }
+
+ static int steam_register(struct steam_device *steam)
+ {
+ int ret;
+- unsigned long client_opened;
+- unsigned long flags;
+
++ mutex_lock(&steam->registration_mutex);
+ /*
+ * This function can be called several times in a row with the
+ * wireless adaptor, without steam_unregister() between them, because
+ * another client send a get_connection_status command, for example.
+ * The battery and serial number are set just once per device.
+ */
+- if (!steam->serial_no[0]) {
+- /*
+- * Unlikely, but getting the serial could fail, and it is not so
+- * important, so make up a serial number and go on.
+- */
+- if (steam_get_serial(steam) < 0)
+- strscpy(steam->serial_no, "XXXXXXXXXX",
+- sizeof(steam->serial_no));
++ if (steam->registered) {
++ mutex_unlock(&steam->registration_mutex);
++ return 0;
++ }
+
+- ret = steam_get_attributes(steam);
+- if (ret < 0)
+- hid_err(steam->hdev,
+- "%s:steam_get_attributes failed with error %d\n",
+- __func__, ret);
++ mutex_lock(&steam->report_mutex);
++ /*
++ * Unlikely, but getting the serial could fail, and it is not so
++ * important, so make up a serial number and go on.
++ */
++ if (steam_get_serial(steam) < 0 || !steam->serial_no[0])
++ strscpy(steam->serial_no, "XXXXXXXXXX",
++ sizeof(steam->serial_no));
+
+- hid_info(steam->hdev, "Steam Controller '%s' connected",
+- steam->serial_no);
++ ret = steam_get_attributes(steam);
++ if (ret < 0)
++ hid_err(steam->hdev,
++ "%s:steam_get_attributes failed with error %d\n",
++ __func__, ret);
+
+- /* ignore battery errors, we can live without it */
+- if (steam->quirks & STEAM_QUIRK_WIRELESS)
+- steam_battery_register(steam);
++ hid_info(steam->hdev, "Steam Controller '%s' connected",
++ steam->serial_no);
+
+- mutex_lock(&steam_devices_lock);
+- if (list_empty(&steam->list))
+- list_add(&steam->list, &steam_devices);
+- mutex_unlock(&steam_devices_lock);
+- }
++ steam_set_lizard_mode(steam, lizard_mode);
++ mutex_unlock(&steam->report_mutex);
+
+- spin_lock_irqsave(&steam->lock, flags);
+- client_opened = steam->client_opened;
+- spin_unlock_irqrestore(&steam->lock, flags);
++ /* ignore battery errors, we can live without it */
++ if (steam->quirks & STEAM_QUIRK_WIRELESS)
++ steam_battery_register(steam);
+
+- if (!client_opened) {
+- steam_set_lizard_mode(steam, lizard_mode);
+- ret = steam_input_register(steam);
+- if (ret != 0)
+- goto steam_register_input_fail;
+- ret = steam_sensors_register(steam);
+- if (ret != 0)
+- goto steam_register_sensors_fail;
+- }
++ ret = steam_input_register(steam);
++ if (ret != 0)
++ goto steam_register_input_fail;
++ ret = steam_sensors_register(steam);
++ if (ret != 0)
++ goto steam_register_sensors_fail;
++
++ steam->registered = true;
++ mutex_unlock(&steam->registration_mutex);
++ mutex_lock(&steam_devices_lock);
++ if (list_empty(&steam->list))
++ list_add(&steam->list, &steam_devices);
++ mutex_unlock(&steam_devices_lock);
+ return 0;
+
+ steam_register_sensors_fail:
+ steam_input_unregister(steam);
+ steam_register_input_fail:
++ steam_battery_unregister(steam);
++ mutex_unlock(&steam->registration_mutex);
++ cancel_work_sync(&steam->rumble_work);
++ cancel_delayed_work_sync(&steam->mode_switch);
+ return ret;
+ }
+
+ static void steam_unregister(struct steam_device *steam)
+ {
++ if (!steam->registered)
++ return;
++
++ hid_info(steam->hdev, "Steam Controller '%s' disconnected",
++ steam->serial_no);
++ mutex_lock(&steam->registration_mutex);
++ steam->registered = false;
+ steam_battery_unregister(steam);
+ steam_sensors_unregister(steam);
+ steam_input_unregister(steam);
+- if (steam->serial_no[0]) {
+- hid_info(steam->hdev, "Steam Controller '%s' disconnected",
+- steam->serial_no);
+- mutex_lock(&steam_devices_lock);
+- list_del_init(&steam->list);
+- mutex_unlock(&steam_devices_lock);
+- steam->serial_no[0] = 0;
+- }
++ mutex_unlock(&steam->registration_mutex);
++ cancel_work_sync(&steam->rumble_work);
++ cancel_delayed_work_sync(&steam->mode_switch);
++ mutex_lock(&steam_devices_lock);
++ list_del_init(&steam->list);
++ mutex_unlock(&steam_devices_lock);
++ steam->serial_no[0] = 0;
+ }
+
+ static void steam_work_connect_cb(struct work_struct *work)
+ {
+ struct steam_device *steam = container_of(work, struct steam_device,
+ work_connect);
++
+ unsigned long flags;
+ bool connected;
++ bool opened;
+ int ret;
+
+ spin_lock_irqsave(&steam->lock, flags);
++ opened = steam->client_opened;
+ connected = steam->connected;
+ spin_unlock_irqrestore(&steam->lock, flags);
+
+- if (connected) {
++ if (connected && !opened) {
+ ret = steam_register(steam);
+- if (ret) {
++ if (ret)
+ hid_err(steam->hdev,
+ "%s:steam_register failed with error %d\n",
+ __func__, ret);
+- }
+ } else {
+ steam_unregister(steam);
+ }
+@@ -1190,54 +1197,32 @@ static void steam_mode_switch_cb(struct work_struct *work)
+ struct steam_device, mode_switch);
+ unsigned long flags;
+ bool client_opened;
++ bool gamepad_mode;
++
+ if (!lizard_mode)
+ return;
+
++ spin_lock_irqsave(&steam->lock, flags);
+ steam->gamepad_mode = !steam->gamepad_mode;
+- hid_dbg(steam->hdev, "%s: switching gamepad mode to %i\n", __func__, steam->gamepad_mode);
+- if (steam->gamepad_mode)
++ gamepad_mode = steam->gamepad_mode;
++ client_opened = steam->client_opened;
++ spin_unlock_irqrestore(&steam->lock, flags);
++
++ guard(mutex)(&steam->report_mutex);
++ hid_dbg(steam->hdev, "%s: switching gamepad mode to %i\n", __func__, gamepad_mode);
++ if (gamepad_mode)
+ steam_set_lizard_mode(steam, false);
+- else {
+- spin_lock_irqsave(&steam->lock, flags);
+- client_opened = steam->client_opened;
+- spin_unlock_irqrestore(&steam->lock, flags);
+- if (!client_opened)
+- steam_set_lizard_mode(steam, lizard_mode);
+- }
++ else if (!client_opened)
++ steam_set_lizard_mode(steam, lizard_mode);
+
+ steam_haptic_pulse(steam, STEAM_PAD_RIGHT, 0x190, 0, 1, 0);
+- if (steam->gamepad_mode) {
++ if (gamepad_mode) {
+ steam_haptic_pulse(steam, STEAM_PAD_LEFT, 0x14D, 0x14D, 0x2D, 0);
+ } else {
+ steam_haptic_pulse(steam, STEAM_PAD_LEFT, 0x1F4, 0x1F4, 0x1E, 0);
+ }
+ }
+
+-static void steam_work_unregister_cb(struct work_struct *work)
+-{
+- struct steam_device *steam = container_of(work, struct steam_device,
+- unregister_work);
+- unsigned long flags;
+- bool connected;
+- bool opened;
+-
+- spin_lock_irqsave(&steam->lock, flags);
+- opened = steam->client_opened;
+- connected = steam->connected;
+- spin_unlock_irqrestore(&steam->lock, flags);
+-
+- if (connected) {
+- if (opened) {
+- steam_sensors_unregister(steam);
+- steam_input_unregister(steam);
+- } else {
+- steam_set_lizard_mode(steam, lizard_mode);
+- steam_input_register(steam);
+- steam_sensors_register(steam);
+- }
+- }
+-}
+-
+ static bool steam_is_valve_interface(struct hid_device *hdev)
+ {
+ struct hid_report_enum *rep_enum;
+@@ -1283,7 +1268,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
+ steam->client_opened++;
+ spin_unlock_irqrestore(&steam->lock, flags);
+
+- schedule_work(&steam->unregister_work);
++ schedule_work(&steam->work_connect);
+
+ return 0;
+ }
+@@ -1298,7 +1283,7 @@ static void steam_client_ll_close(struct hid_device *hdev)
+ steam->client_opened--;
+ spin_unlock_irqrestore(&steam->lock, flags);
+
+- schedule_work(&steam->unregister_work);
++ schedule_work(&steam->work_connect);
+ }
+
+ static int steam_client_ll_raw_request(struct hid_device *hdev,
+@@ -1384,6 +1369,7 @@ static int steam_probe(struct hid_device *hdev,
+ hid_set_drvdata(hdev, steam);
+ spin_lock_init(&steam->lock);
+ mutex_init(&steam->report_mutex);
++ mutex_init(&steam->registration_mutex);
+ steam->quirks = id->driver_data;
+ INIT_WORK(&steam->work_connect, steam_work_connect_cb);
+ INIT_DELAYED_WORK(&steam->mode_switch, steam_mode_switch_cb);
+@@ -1394,7 +1380,6 @@ static int steam_probe(struct hid_device *hdev,
+ steam->sensor_update_rate_us = 4000;
+ else
+ steam->sensor_update_rate_us = 9000;
+- INIT_WORK(&steam->unregister_work, steam_work_unregister_cb);
+
+ /*
+ * With the real steam controller interface, do not connect hidraw.
+@@ -1455,7 +1440,6 @@ err_cancel_work:
+ cancel_work_sync(&steam->work_connect);
+ cancel_delayed_work_sync(&steam->mode_switch);
+ cancel_work_sync(&steam->rumble_work);
+- cancel_work_sync(&steam->unregister_work);
+
+ return ret;
+ }
+@@ -1463,36 +1447,32 @@ err_cancel_work:
+ static void steam_remove(struct hid_device *hdev)
+ {
+ struct steam_device *steam = hid_get_drvdata(hdev);
++ unsigned long flags;
+
+ if (!steam || hdev->group == HID_GROUP_STEAM) {
+ hid_hw_stop(hdev);
+ return;
+ }
+
++ hid_hw_close(hdev);
+ hid_destroy_device(steam->client_hdev);
+- cancel_delayed_work_sync(&steam->mode_switch);
+- cancel_work_sync(&steam->work_connect);
+- cancel_work_sync(&steam->rumble_work);
+- cancel_work_sync(&steam->unregister_work);
+- steam->client_hdev = NULL;
++ spin_lock_irqsave(&steam->lock, flags);
+ steam->client_opened = 0;
++ spin_unlock_irqrestore(&steam->lock, flags);
++ cancel_work_sync(&steam->work_connect);
+ if (steam->quirks & STEAM_QUIRK_WIRELESS) {
+ hid_info(hdev, "Steam wireless receiver disconnected");
+ }
+- hid_hw_close(hdev);
+- hid_hw_stop(hdev);
+ steam_unregister(steam);
++ hid_hw_stop(hdev);
+ }
+
+ static void steam_do_connect_event(struct steam_device *steam, bool connected)
+ {
+- unsigned long flags;
+ bool changed;
+
+- spin_lock_irqsave(&steam->lock, flags);
+ changed = steam->connected != connected;
+ steam->connected = connected;
+- spin_unlock_irqrestore(&steam->lock, flags);
+
+ if (changed && schedule_work(&steam->work_connect) == 0)
+ dbg_hid("%s: connected=%d event already queued\n",
+@@ -1921,8 +1901,6 @@ static void steam_do_deck_sensors_event(struct steam_device *steam,
+ static void steam_do_battery_event(struct steam_device *steam,
+ struct power_supply *battery, u8 *data)
+ {
+- unsigned long flags;
+-
+ s16 volts = steam_le16(data + 12);
+ u8 batt = data[14];
+
+@@ -1930,10 +1908,8 @@ static void steam_do_battery_event(struct steam_device *steam,
+ rcu_read_lock();
+ battery = rcu_dereference(steam->battery);
+ if (likely(battery)) {
+- spin_lock_irqsave(&steam->lock, flags);
+ steam->voltage = volts;
+ steam->battery_charge = batt;
+- spin_unlock_irqrestore(&steam->lock, flags);
+ power_supply_changed(battery);
+ }
+ rcu_read_unlock();
+@@ -1951,6 +1927,7 @@ static int steam_raw_event(struct hid_device *hdev,
+ if (!steam)
+ return 0;
+
++ guard(spinlock_irqsave)(&steam->lock);
+ if (steam->client_opened)
+ hid_input_report(steam->client_hdev, HID_FEATURE_REPORT,
+ data, size, 0);
+@@ -2038,6 +2015,8 @@ static int steam_param_set_lizard_mode(const char *val,
+ {
+ struct steam_device *steam;
+ int ret;
++ bool client_opened;
++ unsigned long flags;
+
+ ret = param_set_bool(val, kp);
+ if (ret)
+@@ -2045,8 +2024,13 @@ static int steam_param_set_lizard_mode(const char *val,
+
+ mutex_lock(&steam_devices_lock);
+ list_for_each_entry(steam, &steam_devices, list) {
+- if (!steam->client_opened)
++ spin_lock_irqsave(&steam->lock, flags);
++ client_opened = steam->client_opened;
++ spin_unlock_irqrestore(&steam->lock, flags);
++ if (!client_opened) {
++ guard(mutex)(&steam->report_mutex);
+ steam_set_lizard_mode(steam, lizard_mode);
++ }
+ }
+ mutex_unlock(&steam_devices_lock);
+ return 0;
+diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
+index 6406ceab988ade..810e52782ae891 100644
+--- a/drivers/input/joystick/xpad.c
++++ b/drivers/input/joystick/xpad.c
+@@ -302,6 +302,8 @@ static const struct xpad_device {
+ { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 },
+ { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 },
+ { 0x1a86, 0xe310, "Legion Go S", 0, XTYPE_XBOX360 },
++ { 0x1b1c, 0x2b1f, "Corsair Novablade Pro (Wired)", 0, XTYPE_XBOX360 },
++ { 0x1b1c, 0x2b2b, "Corsair Novablade Pro (2.4 GHz Receiver)", 0, XTYPE_XBOX360 },
+ { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
+ { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+ { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
+@@ -379,6 +381,7 @@ static const struct xpad_device {
+ { 0x2993, 0x2001, "TECNO Pocket Go", 0, XTYPE_XBOX360 },
+ { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
+ { 0x2dc8, 0x200f, "8BitDo Ultimate 3-mode Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
++ { 0x2dc8, 0x201e, "8BitDo Pro 2 Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
+ { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
+ { 0x2dc8, 0x3109, "8BitDo Ultimate Wireless Bluetooth", 0, XTYPE_XBOX360 },
+ { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 },
+@@ -545,6 +548,7 @@ static const struct usb_device_id xpad_table[] = {
+ XPAD_XBOX360_VENDOR(0x17ef), /* Lenovo */
+ XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */
+ XPAD_XBOX360_VENDOR(0x1a86), /* Nanjing Qinheng Microelectronics (WCH) */
++ XPAD_XBOX360_VENDOR(0x1b1c), /* Corsair controllers */
+ XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */
+ XPAD_XBOX360_VENDOR(0x1ee9), /* ZOTAC Technology Limited */
+ XPAD_XBOX360_VENDOR(0x20bc), /* BETOP wireless dongles */
+diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
+index 8db2dca84975ca..3e0f874e9b16fc 100644
+--- a/drivers/input/misc/ati_remote2.c
++++ b/drivers/input/misc/ati_remote2.c
+@@ -672,8 +672,7 @@ static ssize_t ati_remote2_show_channel_mask(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+ {
+- struct usb_device *udev = to_usb_device(dev);
+- struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
++ struct usb_interface *intf = to_usb_interface(dev);
+ struct ati_remote2 *ar2 = usb_get_intfdata(intf);
+
+ return sprintf(buf, "0x%04x\n", ar2->channel_mask);
+@@ -683,8 +682,7 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+ {
+- struct usb_device *udev = to_usb_device(dev);
+- struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
++ struct usb_interface *intf = to_usb_interface(dev);
+ struct ati_remote2 *ar2 = usb_get_intfdata(intf);
+ unsigned int mask;
+ int r;
+@@ -720,8 +718,7 @@ static ssize_t ati_remote2_show_mode_mask(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+ {
+- struct usb_device *udev = to_usb_device(dev);
+- struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
++ struct usb_interface *intf = to_usb_interface(dev);
+ struct ati_remote2 *ar2 = usb_get_intfdata(intf);
+
+ return sprintf(buf, "0x%02x\n", ar2->mode_mask);
+@@ -731,8 +728,7 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+ {
+- struct usb_device *udev = to_usb_device(dev);
+- struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
++ struct usb_interface *intf = to_usb_interface(dev);
+ struct ati_remote2 *ar2 = usb_get_intfdata(intf);
+ unsigned int mask;
+ int err;
+diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
+index ae814d8c99c04a..5f901b4baf2160 100644
+--- a/drivers/iommu/dma-iommu.c
++++ b/drivers/iommu/dma-iommu.c
+@@ -1228,9 +1228,9 @@ dma_addr_t iommu_dma_map_phys(struct device *dev, phys_addr_t phys, size_t size,
+ * If both the physical buffer start address and size are page aligned,
+ * we don't need to use a bounce page.
+ */
+- if (dev_use_swiotlb(dev, size, dir) &&
++ if (!(attrs & DMA_ATTR_MMIO) && dev_use_swiotlb(dev, size, dir) &&
+ iova_unaligned(iovad, phys, size)) {
+- if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
++ if (attrs & DMA_ATTR_REQUIRE_COHERENT)
+ return DMA_MAPPING_ERROR;
+
+ phys = iommu_dma_map_swiotlb(dev, phys, size, dir, attrs);
+diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
+index 608b617fb817ff..ee36789a7f0d8a 100644
+--- a/drivers/md/dm-crypt.c
++++ b/drivers/md/dm-crypt.c
+@@ -2895,8 +2895,13 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *key
+ }
+ }
+
+- if (*ivmode && !strcmp(*ivmode, "lmk"))
++ if (*ivmode && !strcmp(*ivmode, "lmk")) {
++ if (crypt_integrity_aead(cc)) {
++ ti->error = "AEAD transforms not supported for LMK";
++ return -EINVAL;
++ }
+ cc->tfms_count = 64;
++ }
+
+ if (*ivmode && !strcmp(*ivmode, "essiv")) {
+ if (!*ivopts) {
+diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
+index 86fc35e76a0f7a..4bda7b5dba1a64 100644
+--- a/drivers/md/dm-integrity.c
++++ b/drivers/md/dm-integrity.c
+@@ -2721,7 +2721,7 @@ static void dm_integrity_inline_recheck(struct work_struct *w)
+ outgoing_data = dio->integrity_payload + PAGE_SIZE;
+
+ while (dio->bio_details.bi_iter.bi_size) {
+- char digest[HASH_MAX_DIGESTSIZE];
++ char digest[MAX_T(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)];
+ int r;
+ struct bio_integrity_payload *bip;
+ struct bio_vec bv;
+@@ -2788,7 +2788,7 @@ static inline bool dm_integrity_check(struct dm_integrity_c *ic, struct dm_integ
+ unsigned pos = 0;
+
+ while (dio->bio_details.bi_iter.bi_size) {
+- char digest[HASH_MAX_DIGESTSIZE];
++ char digest[MAX_T(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)];
+ struct bio_vec bv = bio_iter_iovec(bio, dio->bio_details.bi_iter);
+ char *mem = integrity_kmap(ic, bv.bv_page);
+ integrity_sector_checksum(ic, &dio->ahash_req, dio->bio_details.bi_iter.bi_sector, mem, bv.bv_offset, digest);
+diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
+index 61af2a437a0508..d3430825acad10 100644
+--- a/drivers/md/dm-ioctl.c
++++ b/drivers/md/dm-ioctl.c
+@@ -658,10 +658,16 @@ static void *get_result_buffer(struct dm_ioctl *param, size_t param_size,
+ {
+ param->data_start = align_ptr(param + 1) - (void *) param;
+
+- if (param->data_start < param_size)
++ if (param->data_start < param_size) {
+ *len = param_size - param->data_start;
+- else
++ } else {
++ /*
++ * The buffer can be as small as offsetof(*param, data), which
++ * is less than sizeof(*param), so don't run off the end of it.
++ */
+ *len = 0;
++ param->data_start = param_size;
++ }
+
+ return ((void *) param) + param->data_start;
+ }
+@@ -1289,6 +1295,7 @@ static int do_resume(struct dm_ioctl *param)
+ /* Do we need to load a new map ? */
+ if (new_map) {
+ sector_t old_size, new_size;
++ blk_mode_t new_map_mode;
+
+ dm_ima_context_table_op(md, ima_context, DM_IMA_TABLE_SAVE);
+ /* Suspend if it isn't already suspended */
+@@ -1321,6 +1328,7 @@ static int do_resume(struct dm_ioctl *param)
+ }
+ }
+
++ new_map_mode = dm_table_get_mode(new_map);
+ old_size = dm_get_size(md);
+ old_map = dm_swap_table(md, new_map);
+ if (IS_ERR(old_map)) {
+@@ -1336,7 +1344,7 @@ static int do_resume(struct dm_ioctl *param)
+ if (old_size && new_size && old_size != new_size)
+ need_resize_uevent = true;
+
+- if (dm_table_get_mode(new_map) & BLK_OPEN_WRITE)
++ if (new_map_mode & BLK_OPEN_WRITE)
+ set_disk_ro(dm_disk(md), 0);
+ else
+ set_disk_ro(dm_disk(md), 1);
+diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
+index 1489fda9d24a09..02e3cc4730267a 100644
+--- a/drivers/md/dm-snap.c
++++ b/drivers/md/dm-snap.c
+@@ -1294,6 +1294,20 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
+ goto bad_store;
+ }
+
++ /*
++ * snapshot-merge requires the optional prepare_merge/commit_merge
++ * callbacks; the transient exception store does not implement them.
++ * The handover path checks this in __validate_exception_handover(),
++ * but a directly constructed snapshot-merge never goes through it.
++ */
++ if (dm_target_is_snapshot_merge(ti) &&
++ (!s->store->type->prepare_merge ||
++ !s->store->type->commit_merge)) {
++ ti->error = "Snapshot exception store does not support snapshot-merge.";
++ r = -EINVAL;
++ goto bad_hash_tables;
++ }
++
+ argv += args_used;
+ argc -= args_used;
+
+diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
+index e03989c4e99ea1..0d15f48ef51d4f 100644
+--- a/drivers/memstick/core/memstick.c
++++ b/drivers/memstick/core/memstick.c
+@@ -370,9 +370,7 @@ int memstick_set_rw_addr(struct memstick_dev *card)
+ {
+ card->next_request = h_memstick_set_rw_addr;
+ memstick_new_req(card->host);
+- if (!wait_for_completion_timeout(&card->mrq_complete,
+- msecs_to_jiffies(500)))
+- card->current_mrq.error = -ETIMEDOUT;
++ wait_for_completion(&card->mrq_complete);
+
+ return card->current_mrq.error;
+ }
+@@ -405,9 +403,7 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host)
+
+ card->next_request = h_memstick_read_dev_id;
+ memstick_new_req(host);
+- if (!wait_for_completion_timeout(&card->mrq_complete,
+- msecs_to_jiffies(500)))
+- card->current_mrq.error = -ETIMEDOUT;
++ wait_for_completion(&card->mrq_complete);
+
+ if (card->current_mrq.error)
+ goto err_out;
+diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
+index beadc389f15f39..d5b3a96fc609a1 100644
+--- a/drivers/memstick/host/rtsx_usb_ms.c
++++ b/drivers/memstick/host/rtsx_usb_ms.c
+@@ -27,7 +27,6 @@ struct rtsx_usb_ms {
+ struct memstick_host *msh;
+ struct memstick_request *req;
+
+- struct mutex host_mutex;
+ struct work_struct handle_req;
+ struct delayed_work poll_card;
+
+@@ -514,6 +513,13 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work)
+ struct memstick_host *msh = host->msh;
+ int rc;
+
++ /* Fail requests after eject so their waiters are released. */
++ if (host->eject) {
++ while (!memstick_next_req(msh, &host->req))
++ host->req->error = -ENOMEDIUM;
++ return;
++ }
++
+ if (!host->req) {
+ pm_runtime_get_sync(ms_dev(host));
+ do {
+@@ -547,8 +553,7 @@ static void rtsx_usb_ms_request(struct memstick_host *msh)
+
+ dev_dbg(ms_dev(host), "--> %s\n", __func__);
+
+- if (!host->eject)
+- schedule_work(&host->handle_req);
++ schedule_work(&host->handle_req);
+ }
+
+ static int rtsx_usb_ms_set_param(struct memstick_host *msh,
+@@ -781,7 +786,6 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
+ host->power_mode = MEMSTICK_POWER_OFF;
+ platform_set_drvdata(pdev, host);
+
+- mutex_init(&host->host_mutex);
+ INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req);
+
+ INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card);
+@@ -812,27 +816,12 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
+ {
+ struct rtsx_usb_ms *host = platform_get_drvdata(pdev);
+ struct memstick_host *msh = host->msh;
+- int err;
+
+ host->eject = true;
+ msh->removing = true;
+- cancel_work_sync(&host->handle_req);
++ flush_work(&host->handle_req);
+ cancel_delayed_work_sync(&host->poll_card);
+
+- mutex_lock(&host->host_mutex);
+- if (host->req) {
+- dev_dbg(ms_dev(host),
+- "%s: Controller removed during transfer\n",
+- dev_name(&msh->dev));
+- host->req->error = -ENOMEDIUM;
+- do {
+- err = memstick_next_req(msh, &host->req);
+- if (!err)
+- host->req->error = -ENOMEDIUM;
+- } while (!err);
+- }
+- mutex_unlock(&host->host_mutex);
+-
+ /* Balance possible unbalanced usage count
+ * e.g. unconditional module removal
+ */
+@@ -841,6 +830,8 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
+
+ pm_runtime_disable(ms_dev(host));
+ memstick_remove_host(msh);
++ /* No card, no new requests; wait for the last failed one to finish. */
++ cancel_work_sync(&host->handle_req);
+ dev_dbg(ms_dev(host),
+ ": Realtek USB Memstick controller has been removed\n");
+ memstick_free_host(msh);
+diff --git a/drivers/mmc/host/cavium-octeon.c b/drivers/mmc/host/cavium-octeon.c
+index 8a0daddd9200ea..1c219cf35a8e4b 100644
+--- a/drivers/mmc/host/cavium-octeon.c
++++ b/drivers/mmc/host/cavium-octeon.c
+@@ -301,9 +301,12 @@ static void octeon_mmc_remove(struct platform_device *pdev)
+ u64 dma_cfg;
+ int i;
+
+- for (i = 0; i < CAVIUM_MAX_MMC; i++)
++ for (i = 0; i < CAVIUM_MAX_MMC; i++) {
+ if (host->slot[i])
+ cvm_mmc_of_slot_remove(host->slot[i]);
++ if (host->slot_pdev[i])
++ of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL);
++ }
+
+ dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host));
+ dma_cfg &= ~MIO_EMM_DMA_CFG_EN;
+diff --git a/drivers/mmc/host/cavium-thunderx.c b/drivers/mmc/host/cavium-thunderx.c
+index 84ff6d82ae3c0a..2635ac94ec5da3 100644
+--- a/drivers/mmc/host/cavium-thunderx.c
++++ b/drivers/mmc/host/cavium-thunderx.c
+@@ -173,9 +173,12 @@ static void thunder_mmc_remove(struct pci_dev *pdev)
+ u64 dma_cfg;
+ int i;
+
+- for (i = 0; i < CAVIUM_MAX_MMC; i++)
++ for (i = 0; i < CAVIUM_MAX_MMC; i++) {
+ if (host->slot[i])
+ cvm_mmc_of_slot_remove(host->slot[i]);
++ if (host->slot_pdev[i])
++ of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL);
++ }
+
+ dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host));
+ dma_cfg &= ~MIO_EMM_DMA_CFG_EN;
+diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
+index b2680cc054bda2..d70e37eb1cb59c 100644
+--- a/drivers/mmc/host/mtk-sd.c
++++ b/drivers/mmc/host/mtk-sd.c
+@@ -3216,6 +3216,7 @@ static void msdc_drv_remove(struct platform_device *pdev)
+
+ platform_set_drvdata(pdev, NULL);
+ mmc_remove_host(mmc);
++ cancel_delayed_work_sync(&host->req_timeout);
+ msdc_deinit_hw(host);
+ msdc_gate_clock(host);
+
+diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
+index 3584a2b314a9f9..0c8f389fe58471 100644
+--- a/drivers/mmc/host/sdhci-sprd.c
++++ b/drivers/mmc/host/sdhci-sprd.c
+@@ -890,6 +890,10 @@ static void sdhci_sprd_remove(struct platform_device *pdev)
+ struct sdhci_host *host = platform_get_drvdata(pdev);
+ struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
+
++ pm_runtime_get_sync(&pdev->dev);
++ pm_runtime_disable(&pdev->dev);
++ pm_runtime_put_noidle(&pdev->dev);
++
+ sdhci_remove_host(host, 0);
+
+ clk_disable_unprepare(sprd_host->clk_sdio);
+diff --git a/drivers/net/amt.c b/drivers/net/amt.c
+index 7645ce3a29ad96..189b3a43e4e2a2 100644
+--- a/drivers/net/amt.c
++++ b/drivers/net/amt.c
+@@ -80,15 +80,6 @@ static struct in6_addr mld2_all_node = MLD2_ALL_NODE_INIT;
+ static struct mld2_grec mldv2_zero_grec;
+ #endif
+
+-static struct amt_skb_cb *amt_skb_cb(struct sk_buff *skb)
+-{
+- BUILD_BUG_ON(sizeof(struct amt_skb_cb) + sizeof(struct tc_skb_cb) >
+- sizeof_field(struct sk_buff, cb));
+-
+- return (struct amt_skb_cb *)((void *)skb->cb +
+- sizeof(struct tc_skb_cb));
+-}
+-
+ static void __amt_source_gc_work(void)
+ {
+ struct amt_source_node *snode;
+@@ -789,6 +780,11 @@ out:
+ rcu_read_unlock();
+ }
+
++static bool amt_send_membership_query(struct amt_dev *amt,
++ struct sk_buff *skb,
++ struct amt_tunnel_list *tunnel,
++ bool v6);
++
+ static void amt_send_igmp_gq(struct amt_dev *amt,
+ struct amt_tunnel_list *tunnel)
+ {
+@@ -798,8 +794,11 @@ static void amt_send_igmp_gq(struct amt_dev *amt,
+ if (!skb)
+ return;
+
+- amt_skb_cb(skb)->tunnel = tunnel;
+- dev_queue_xmit(skb);
++ skb_pull(skb, sizeof(struct ethhdr));
++ if (amt_send_membership_query(amt, skb, tunnel, false)) {
++ amt->dev->stats.tx_dropped++;
++ kfree_skb(skb);
++ }
+ }
+
+ #if IS_ENABLED(CONFIG_IPV6)
+@@ -883,8 +882,11 @@ static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel)
+ if (!skb)
+ return;
+
+- amt_skb_cb(skb)->tunnel = tunnel;
+- dev_queue_xmit(skb);
++ skb_pull(skb, sizeof(struct ethhdr));
++ if (amt_send_membership_query(amt, skb, tunnel, true)) {
++ amt->dev->stats.tx_dropped++;
++ kfree_skb(skb);
++ }
+ }
+ #else
+ static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel)
+@@ -1183,7 +1185,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)
+ #endif
+ bool report = false;
+ struct igmphdr *ih;
+- bool query = false;
+ struct iphdr *iph;
+ bool data = false;
+ bool v6 = false;
+@@ -1201,9 +1202,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)
+ case IGMP_HOST_MEMBERSHIP_REPORT:
+ report = true;
+ break;
+- case IGMP_HOST_MEMBERSHIP_QUERY:
+- query = true;
+- break;
+ default:
+ goto free;
+ }
+@@ -1225,9 +1223,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)
+ case ICMPV6_MLD2_REPORT:
+ report = true;
+ break;
+- case ICMPV6_MGM_QUERY:
+- query = true;
+- break;
+ default:
+ goto free;
+ }
+@@ -1258,19 +1253,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)
+ goto free;
+ goto unlock;
+ } else if (amt->mode == AMT_MODE_RELAY) {
+- if (query) {
+- tunnel = amt_skb_cb(skb)->tunnel;
+- if (!tunnel) {
+- WARN_ON(1);
+- goto free;
+- }
+-
+- /* Do not forward unexpected query */
+- if (amt_send_membership_query(amt, skb, tunnel, v6))
+- goto free;
+- goto unlock;
+- }
+-
+ if (!data)
+ goto free;
+ list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) {
+diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
+index 5ef841c8552697..2bfad8653be6af 100644
+--- a/drivers/net/bareudp.c
++++ b/drivers/net/bareudp.c
+@@ -355,7 +355,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
+ if (err)
+ goto free_dst;
+
+- skb_set_inner_protocol(skb, bareudp->ethertype);
++ skb_set_inner_protocol(skb, skb->protocol);
+ udp_tunnel_xmit_skb(rt, sk, skb, saddr, info->key.u.ipv4.dst,
+ tos, ttl, df, sport, bareudp->port,
+ !net_eq(bareudp->net, dev_net(bareudp->dev)),
+@@ -423,6 +423,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
+ if (err)
+ goto free_dst;
+
++ skb_set_inner_protocol(skb, skb->protocol);
+ daddr = info->key.u.ipv6.dst;
+ udp_tunnel6_xmit_skb(dst, sk, skb, dev,
+ &saddr, &daddr, prio, ttl,
+diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
+index 34c5bbbed9aeea..507d655eca21e3 100644
+--- a/drivers/net/bonding/bond_main.c
++++ b/drivers/net/bonding/bond_main.c
+@@ -5738,12 +5738,12 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
+ bpf_prog_inc(prog);
+ }
+
+- if (prog) {
++ if (prog && !old_prog)
+ static_branch_inc(&bpf_master_redirect_enabled_key);
+- } else if (old_prog) {
+- bpf_prog_put(old_prog);
++ else if (!prog && old_prog)
+ static_branch_dec(&bpf_master_redirect_enabled_key);
+- }
++ if (old_prog)
++ bpf_prog_put(old_prog);
+
+ return 0;
+
+diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
+index 95fcdc1026f808..14edec5afb57e4 100644
+--- a/drivers/net/can/dev/skb.c
++++ b/drivers/net/can/dev/skb.c
+@@ -210,6 +210,10 @@ static void init_can_skb(struct sk_buff *skb)
+ {
+ skb->pkt_type = PACKET_BROADCAST;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
++
++ skb_reset_mac_header(skb);
++ skb_reset_network_header(skb);
++ skb_reset_transport_header(skb);
+ }
+
+ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
+diff --git a/drivers/net/can/usb/f81604.c b/drivers/net/can/usb/f81604.c
+index f12318268e46be..4c147b9d6d690a 100644
+--- a/drivers/net/can/usb/f81604.c
++++ b/drivers/net/can/usb/f81604.c
+@@ -169,7 +169,7 @@ struct f81604_int_data {
+ u8 rxerr;
+ u8 txerr;
+ u8 val;
+-} __packed __aligned(4);
++} __packed;
+
+ struct f81604_sff {
+ __be16 id;
+diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
+index e882250180ef65..f365deafaf5422 100644
+--- a/drivers/net/can/vxcan.c
++++ b/drivers/net/can/vxcan.c
+@@ -78,6 +78,9 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *oskb, struct net_device *dev)
+
+ /* reset CAN GW hop counter */
+ csx->can_gw_hops = 0;
++ /* start with new CAN skb UID in the other namespace */
++ csx->can_skb_uid = 0;
++
+ skb->pkt_type = PACKET_BROADCAST;
+ skb->dev = peer;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
+index b4a5673ba365cb..8f6ac13b5b1821 100644
+--- a/drivers/net/dsa/microchip/ksz_common.h
++++ b/drivers/net/dsa/microchip/ksz_common.h
+@@ -778,7 +778,7 @@ static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port)
+ #define KSZ88_FAMILY_ID 0x88
+ #define KSZ8895_FAMILY_ID 0x95
+
+-#define KSZ8_PORT_STATUS_0 0x08
++#define KSZ8_PORT_STATUS_0 0x18
+ #define KSZ8_PORT_FIBER_MODE BIT(7)
+
+ #define SW_CHIP_ID_M GENMASK(7, 4)
+diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
+index 2fc8c91f210c64..d4faf4503487e3 100644
+--- a/drivers/net/ethernet/airoha/airoha_eth.c
++++ b/drivers/net/ethernet/airoha/airoha_eth.c
+@@ -2716,14 +2716,34 @@ static int airoha_qdma_set_trtcm_param(struct airoha_qdma *qdma, int channel,
+ FIELD_PREP(TRTCM_METER_GROUP_MASK, group) |
+ FIELD_PREP(TRTCM_PARAM_INDEX_MASK, idx) |
+ FIELD_PREP(TRTCM_PARAM_RATE_TYPE_MASK, mode);
++ int i;
+
+- airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val);
+- airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config);
++ /*
++ * HW might be in the middle of bucket handling and might
++ * require an additional try to actually apply the new TRTCM
++ * config.
++ */
++ for (i = 0; i < TRTCM_CONFIG_RETRY_MAX; i++) {
++ u32 data = 0;
+
+- return read_poll_timeout(airoha_qdma_rr, val,
+- val & TRTCM_PARAM_RW_DONE_MASK,
+- USEC_PER_MSEC, 10 * USEC_PER_MSEC, true,
+- qdma, REG_TRTCM_CFG_PARAM(addr));
++ airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val);
++ airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config);
++
++ if (read_poll_timeout(airoha_qdma_rr, data,
++ data & TRTCM_PARAM_RW_DONE_MASK,
++ USEC_PER_MSEC, 10 * USEC_PER_MSEC,
++ true, qdma, REG_TRTCM_CFG_PARAM(addr)))
++ continue;
++
++ if (airoha_qdma_get_trtcm_param(qdma, channel, addr, param,
++ mode, &data, NULL))
++ continue;
++
++ if (data == val)
++ return 0;
++ }
++
++ return -EBUSY;
+ }
+
+ static int airoha_qdma_set_trtcm_config(struct airoha_qdma *qdma, int channel,
+diff --git a/drivers/net/ethernet/airoha/airoha_eth.h b/drivers/net/ethernet/airoha/airoha_eth.h
+index 70f16189b25827..dc0c29001f8103 100644
+--- a/drivers/net/ethernet/airoha/airoha_eth.h
++++ b/drivers/net/ethernet/airoha/airoha_eth.h
+@@ -171,6 +171,8 @@ enum trtcm_param {
+ #define TRTCM_TOKEN_RATE_MASK GENMASK(23, 6)
+ #define TRTCM_TOKEN_RATE_FRACTION_MASK GENMASK(5, 0)
+
++#define TRTCM_CONFIG_RETRY_MAX 2
++
+ enum airoha_dma_map_type {
+ AIROHA_DMA_UNMAPPED,
+ AIROHA_DMA_MAP_SINGLE,
+diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+index ced998399efc33..78583cee3414f0 100644
+--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+@@ -486,7 +486,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
+ struct netdev_queue *txq;
+ int i;
+ dma_addr_t mapping;
+- unsigned int length, pad = 0;
++ unsigned int length;
+ u32 len, free_size, vlan_tag_flags, cfa_action, flags;
+ struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+ struct pci_dev *pdev = bp->pdev;
+@@ -536,6 +536,16 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
+ return rc < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK;
+ }
+
++ /* Pad after the SW USO branch: bnxt_sw_udp_gso_xmit() would
++ * otherwise account the padding as UDP payload.
++ * Must be done before skb_shinfo(skb)->nr_frags is sampled,
++ * because skb_put_padto() might linearize the skb.
++ */
++ if (skb_put_padto(skb, BNXT_MIN_PKT_SIZE)) {
++ /* SKB already freed. */
++ goto tx_kick_pending;
++ }
++
+ free_size = bnxt_tx_avail(bp, txr);
+ if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) {
+ /* We must have raced with NAPI cleanup */
+@@ -672,14 +682,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
+ }
+
+ normal_tx:
+- if (length < BNXT_MIN_PKT_SIZE) {
+- pad = BNXT_MIN_PKT_SIZE - length;
+- if (skb_pad(skb, pad))
+- /* SKB already freed. */
+- goto tx_kick_pending;
+- length = BNXT_MIN_PKT_SIZE;
+- }
+-
+ mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE);
+
+ if (unlikely(dma_mapping_error(&pdev->dev, mapping)))
+@@ -759,10 +761,7 @@ normal_tx:
+ txbd->tx_bd_len_flags_type = cpu_to_le32(flags);
+ }
+
+- flags &= ~TX_BD_LEN;
+- txbd->tx_bd_len_flags_type =
+- cpu_to_le32(((len + pad) << TX_BD_LEN_SHIFT) | flags |
+- TX_BD_FLAGS_PACKET_END);
++ txbd->tx_bd_len_flags_type |= cpu_to_le32(TX_BD_FLAGS_PACKET_END);
+
+ netdev_tx_sent_queue(txq, skb->len);
+
+@@ -15506,7 +15505,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
+ if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) &&
+ !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state))
+ bnxt_dl_remote_reload(bp);
+- if (pci_enable_device(bp->pdev)) {
++ if (!pci_is_enabled(bp->pdev) && pci_enable_device(bp->pdev)) {
+ netdev_err(bp->dev, "Cannot re-enable PCI device\n");
+ rc = -ENODEV;
+ goto fw_reset_abort;
+@@ -17067,6 +17066,51 @@ void bnxt_print_device_info(struct bnxt *bp)
+ pcie_print_link_status(bp->pdev);
+ }
+
++static void bnxt_clear_bars(struct pci_dev *pdev)
++{
++ int off;
++
++ for (off = PCI_BASE_ADDRESS_0; off <= PCI_BASE_ADDRESS_5; off += 4)
++ pci_write_config_dword(pdev, off, 0);
++}
++
++/* Clear any pending DMA transactions from crash kernel while loading driver in
++ * capture kernel.
++ */
++static int bnxt_kdump_reset(struct pci_dev *pdev)
++{
++ int rc, i;
++ u16 cmd;
++
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
++ cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
++ pci_write_config_word(pdev, PCI_COMMAND, cmd);
++
++ if (pci_save_state(pdev))
++ dev_warn(&pdev->dev, "Failed to save PCI state, PCI restore may be incomplete\n");
++
++ rc = pcie_flr(pdev);
++ if (rc)
++ dev_warn(&pdev->dev, "pcie_flr() failed (rc: %d), trying to continue\n",
++ rc);
++
++ /* In case device is not returning CRS, wait 5 seconds longer */
++ for (i = 0; i < 50; i++) {
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
++ if (!PCI_POSSIBLE_ERROR(cmd))
++ break;
++ msleep(100);
++ }
++ if (PCI_POSSIBLE_ERROR(cmd)) {
++ dev_err(&pdev->dev, "PCI config space inaccessible after FLR, aborting\n");
++ return -ENODEV;
++ }
++
++ bnxt_clear_bars(pdev);
++ pci_restore_state(pdev);
++ return 0;
++}
++
+ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+ {
+ struct bnxt_hw_resc *hw_resc;
+@@ -17082,12 +17126,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+ return -ENODEV;
+ }
+
+- /* Clear any pending DMA transactions from crash kernel
+- * while loading driver in capture kernel.
+- */
+ if (is_kdump_kernel()) {
+- pci_clear_master(pdev);
+- pcie_flr(pdev);
++ rc = bnxt_kdump_reset(pdev);
++ if (rc)
++ return rc;
+ }
+
+ max_irqs = bnxt_get_max_irq(pdev);
+@@ -17515,10 +17557,8 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
+ * so we disable bus master to prevent any potential bad DMAs before
+ * freeing kernel memory.
+ */
+- if (state == pci_channel_io_frozen) {
+- set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state);
++ if (state == pci_channel_io_frozen)
+ bnxt_fw_fatal_close(bp);
+- }
+
+ if (netif_running(netdev))
+ __bnxt_close_nic(bp, true, true);
+@@ -17548,69 +17588,80 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
+ struct bnxt *bp = netdev_priv(netdev);
+ int retry = 0;
+ int err = 0;
+- int off;
++ u16 cmd;
+
+ netdev_info(bp->dev, "PCI Slot Reset\n");
+
+- if (test_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state)) {
+- /* After DPC, the chip should return CRS when the vendor ID
+- * config register is read until it is ready. On all chips,
+- * this is not happening reliably so add a 5-second delay as a
+- * workaround.
+- */
+- msleep(5000);
+- }
++ /* After a PCIe hot reset, the chip should return CRS when the
++ * vendor ID config register is read until it is ready. On all
++ * chips, this is not happening reliably so add a 5-second delay
++ * as a workaround.
++ */
++ msleep(5000);
+
+ netdev_lock(netdev);
+
+- if (pci_enable_device(pdev)) {
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
++ if (PCI_POSSIBLE_ERROR(cmd)) {
+ dev_err(&pdev->dev,
+- "Cannot re-enable PCI device after reset.\n");
+- } else {
+- pci_set_master(pdev);
+- /* Upon fatal error, our device internal logic that latches to
+- * BAR value is getting reset and will restore only upon
+- * rewriting the BARs.
+- *
+- * As pci_restore_state() does not re-write the BARs if the
+- * value is same as saved value earlier, driver needs to
+- * write the BARs to 0 to force restore, in case of fatal error.
+- */
+- if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN,
+- &bp->state)) {
+- for (off = PCI_BASE_ADDRESS_0;
+- off <= PCI_BASE_ADDRESS_5; off += 4)
+- pci_write_config_dword(bp->pdev, off, 0);
+- }
+- pci_restore_state(pdev);
++ "PCI config space inaccessible after reset\n");
++ goto reset_exit;
++ }
+
+- bnxt_inv_fw_health_reg(bp);
+- bnxt_try_map_fw_health_reg(bp);
++ /* Upon PCIe error, our device internal logic that latches to
++ * BAR value is getting reset and will restore only upon
++ * rewriting the BARs.
++ *
++ * As pci_restore_state() does not re-write the BARs if the
++ * value is same as saved value earlier, driver needs to
++ * write the BARs to 0 to force restore.
++ */
++ pci_clear_master(pdev);
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
++ cmd &= ~PCI_COMMAND_MEMORY;
++ pci_write_config_word(pdev, PCI_COMMAND, cmd);
+
+- /* In some PCIe AER scenarios, firmware may take up to
+- * 10 seconds to become ready in the worst case.
+- */
+- do {
+- err = bnxt_try_recover_fw(bp);
+- if (!err)
+- break;
+- retry++;
+- } while (retry < BNXT_FW_SLOT_RESET_RETRY);
++ bnxt_clear_bars(pdev);
++ pci_restore_state(pdev);
+
+- if (err) {
+- dev_err(&pdev->dev, "Firmware not ready\n");
+- goto reset_exit;
++ if (!pci_is_enabled(pdev) && pci_enable_device(pdev)) {
++ dev_err(&pdev->dev,
++ "Cannot re-enable PCI device after reset.\n");
++ pci_read_config_word(pdev, PCI_COMMAND, &cmd);
++ if (!PCI_POSSIBLE_ERROR(cmd)) {
++ cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
++ pci_write_config_word(pdev, PCI_COMMAND, cmd);
+ }
++ goto reset_exit;
++ }
++ pci_set_master(pdev);
+
+- err = bnxt_hwrm_func_reset(bp);
++ bnxt_inv_fw_health_reg(bp);
++ bnxt_try_map_fw_health_reg(bp);
++
++ /* In some PCIe AER scenarios, firmware may take up to
++ * 10 seconds to become ready in the worst case.
++ */
++ do {
++ err = bnxt_try_recover_fw(bp);
+ if (!err)
+- result = PCI_ERS_RESULT_RECOVERED;
++ break;
++ retry++;
++ } while (retry < BNXT_FW_SLOT_RESET_RETRY);
+
+- /* IRQ will be initialized later in bnxt_io_resume */
+- bnxt_ulp_irq_stop(bp);
+- bnxt_clear_int_mode(bp);
++ if (err) {
++ dev_err(&pdev->dev, "Firmware not ready\n");
++ goto reset_exit;
+ }
+
++ err = bnxt_hwrm_func_reset(bp);
++ if (!err)
++ result = PCI_ERS_RESULT_RECOVERED;
++
++ /* IRQ will be initialized later in bnxt_io_resume */
++ bnxt_ulp_irq_stop(bp);
++ bnxt_clear_int_mode(bp);
++
+ reset_exit:
+ clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
+ bnxt_clear_reservations(bp, true);
+diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+index 4dbcd08ef7c32f..a939f4ed10079a 100644
+--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+@@ -2470,7 +2470,6 @@ struct bnxt {
+ #define BNXT_STATE_ABORT_ERR 5
+ #define BNXT_STATE_FW_FATAL_COND 6
+ #define BNXT_STATE_DRV_REGISTERED 7
+-#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8
+ #define BNXT_STATE_NAPI_DISABLED 9
+ #define BNXT_STATE_FW_ACTIVATE 11
+ #define BNXT_STATE_RECOVER 12
+diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
+index 96d5d4f7f51fe8..984432952963ad 100644
+--- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
++++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
+@@ -253,6 +253,17 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,
+ reg = bcmgenet_umac_readl(priv, UMAC_CMD);
+ reg &= ~CMD_CRC_FWD;
+ bcmgenet_umac_writel(priv, reg, UMAC_CMD);
++
++ /*
++ * Mirror wol_power_down_cfg(). If only UMAC_RX
++ * is enabled, then we must place the UMAC back
++ * into SW_RESET.
++ */
++ reg = bcmgenet_umac_readl(priv, UMAC_CMD);
++ if ((reg & CMD_RX_EN) && !(reg & CMD_TX_EN)) {
++ reg |= CMD_SW_RESET;
++ bcmgenet_umac_writel(priv, reg, UMAC_CMD);
++ }
+ spin_unlock_bh(&priv->reg_lock);
+
+ /* Resume link status tracking */
+diff --git a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
+index f5acd4be1e69dc..dbec95b4977736 100644
+--- a/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
++++ b/drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
+@@ -389,7 +389,7 @@ static void chcr_ktls_dev_del(struct net_device *netdev,
+ cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan,
+ tx_info->tid, tx_info->ip_family);
+
+- xa_erase(&u_ctx->tid_list, tx_info->tid);
++ xa_erase_bh(&u_ctx->tid_list, tx_info->tid);
+ }
+
+ port_stats = &tx_info->adap->ch_ktls_stats.ktls_port[tx_info->port_id];
+@@ -577,7 +577,7 @@ free_tid:
+ cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan,
+ tx_info->tid, tx_info->ip_family);
+
+- xa_erase(&u_ctx->tid_list, tx_info->tid);
++ xa_erase_bh(&u_ctx->tid_list, tx_info->tid);
+
+ put_module:
+ /* release module refcount */
+diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
+index e4d78ae52dafec..0dd04ee30c9a5e 100644
+--- a/drivers/net/ethernet/google/gve/gve_main.c
++++ b/drivers/net/ethernet/google/gve/gve_main.c
+@@ -1708,17 +1708,17 @@ static int gve_xsk_pool_disable(struct net_device *dev,
+ }
+
+ napi_rx = &priv->ntfy_blocks[priv->rx[qid].ntfy_id].napi;
+- napi_disable(napi_rx); /* make sure current rx poll is done */
++ napi_disable_locked(napi_rx); /* make sure current rx poll is done */
+
+ tx_qid = gve_xdp_tx_queue_id(priv, qid);
+ napi_tx = &priv->ntfy_blocks[priv->tx[tx_qid].ntfy_id].napi;
+- napi_disable(napi_tx); /* make sure current tx poll is done */
++ napi_disable_locked(napi_tx); /* make sure current tx poll is done */
+
+ gve_unreg_xsk_pool(priv, qid);
+ smp_mb(); /* Make sure it is visible to the workers on datapath */
+
+- napi_enable(napi_rx);
+- napi_enable(napi_tx);
++ napi_enable_locked(napi_rx);
++ napi_enable_locked(napi_tx);
+ if (gve_is_gqi(priv)) {
+ if (gve_rx_work_pending(&priv->rx[qid]))
+ napi_schedule(napi_rx);
+diff --git a/drivers/net/ethernet/google/gve/gve_rx_dqo.c b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
+index 0ece2f6fdffb40..2e6d6abbddfc12 100644
+--- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
++++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
+@@ -113,6 +113,12 @@ static void gve_rx_reset_ring_dqo(struct gve_priv *priv, int idx)
+ gve_free_to_page_pool(rx, bs, false);
+ else
+ gve_free_qpl_page_dqo(bs);
++
++ if (gve_buf_state_is_allocated(rx, bs) &&
++ bs->xsk_buff) {
++ xsk_buff_free(bs->xsk_buff);
++ bs->xsk_buff = NULL;
++ }
+ }
+ }
+
+@@ -839,7 +845,12 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx,
+ }
+
+ if (unlikely(compl_desc->rx_error)) {
+- gve_free_buffer(rx, buf_state);
++ if (buf_state->xsk_buff) {
++ xsk_buff_free(buf_state->xsk_buff);
++ gve_free_buf_state(rx, buf_state);
++ } else {
++ gve_free_buffer(rx, buf_state);
++ }
+ return -EINVAL;
+ }
+
+diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
+index 73e051d26b9d88..abebdb1fc26289 100644
+--- a/drivers/net/ethernet/ibm/ibmveth.c
++++ b/drivers/net/ethernet/ibm/ibmveth.c
+@@ -553,10 +553,15 @@ static int ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter,
+
+ static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx)
+ {
++ void *ptr = adapter->tx_ltb_ptr[idx];
++
++ if (!ptr)
++ return;
++
++ adapter->tx_ltb_ptr[idx] = NULL;
+ dma_unmap_single(&adapter->vdev->dev, adapter->tx_ltb_dma[idx],
+ adapter->tx_ltb_size, DMA_TO_DEVICE);
+- kfree(adapter->tx_ltb_ptr[idx]);
+- adapter->tx_ltb_ptr[idx] = NULL;
++ kfree(ptr);
+ }
+
+ static int ibmveth_allocate_tx_ltb(struct ibmveth_adapter *adapter, int idx)
+@@ -667,7 +672,7 @@ static int ibmveth_open(struct net_device *netdev)
+
+ for (i = 0; i < netdev->real_num_tx_queues; i++) {
+ if (ibmveth_allocate_tx_ltb(adapter, i))
+- goto out_free_tx_ltb;
++ goto out_unmap_filter_list;
+ }
+
+ adapter->rx_queue.index = 0;
+@@ -718,10 +723,6 @@ static int ibmveth_open(struct net_device *netdev)
+ if (rc != 0) {
+ netdev_err(netdev, "unable to request irq 0x%x, rc %d\n",
+ netdev->irq, rc);
+- do {
+- lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
+- } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
+-
+ goto out_free_buffer_pools;
+ }
+
+@@ -737,6 +738,9 @@ static int ibmveth_open(struct net_device *netdev)
+ return 0;
+
+ out_free_buffer_pools:
++ do {
++ lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
++ } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
+ while (--i >= 0) {
+ if (adapter->rx_buff_pool[i].active)
+ ibmveth_free_buffer_pool(adapter,
+@@ -746,10 +750,8 @@ out_unmap_filter_list:
+ dma_unmap_single(dev, adapter->filter_list_dma, 4096,
+ DMA_BIDIRECTIONAL);
+
+-out_free_tx_ltb:
+- while (--i >= 0) {
++ for (i = netdev->real_num_tx_queues - 1; i >= 0; i--)
+ ibmveth_free_tx_ltb(adapter, i);
+- }
+
+ out_unmap_buffer_list:
+ dma_unmap_single(dev, adapter->buffer_list_dma, 4096,
+diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
+index 844f31ab37ad44..c282f65199e49e 100644
+--- a/drivers/net/ethernet/intel/e1000e/netdev.c
++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
+@@ -67,6 +67,13 @@ static const struct dmi_system_id disable_k1_list[] = {
+ DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro 16 Plus PB16250"),
+ },
+ },
++ {
++ .ident = "Lenovo ThinkPad P14s Gen 5",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
++ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad P14s Gen 5"),
++ },
++ },
+ {}
+ };
+
+diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
+index 050f8241ef5e6b..5fcbfa0ca8553c 100644
+--- a/drivers/net/ethernet/intel/iavf/iavf.h
++++ b/drivers/net/ethernet/intel/iavf/iavf.h
+@@ -259,7 +259,6 @@ struct iavf_adapter {
+ struct work_struct adminq_task;
+ struct work_struct finish_config;
+ wait_queue_head_t down_waitqueue;
+- wait_queue_head_t vc_waitqueue;
+ struct iavf_q_vector *q_vectors;
+ struct list_head vlan_filter_list;
+ int num_vlan_filters;
+@@ -588,8 +587,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter);
+ void iavf_enable_queues(struct iavf_adapter *adapter);
+ void iavf_disable_queues(struct iavf_adapter *adapter);
+ void iavf_map_queues(struct iavf_adapter *adapter);
+-void iavf_add_ether_addrs(struct iavf_adapter *adapter);
++int iavf_add_ether_addrs(struct iavf_adapter *adapter);
+ void iavf_del_ether_addrs(struct iavf_adapter *adapter);
++void iavf_mac_add_reject(struct iavf_adapter *adapter);
+ void iavf_add_vlans(struct iavf_adapter *adapter);
+ void iavf_del_vlans(struct iavf_adapter *adapter);
+ void iavf_set_promiscuous(struct iavf_adapter *adapter);
+@@ -606,6 +606,13 @@ void iavf_disable_vlan_stripping(struct iavf_adapter *adapter);
+ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
+ enum virtchnl_ops v_opcode,
+ enum iavf_status v_retval, u8 *msg, u16 msglen);
++int iavf_poll_virtchnl_response(struct iavf_adapter *adapter,
++ struct iavf_arq_event_info *event,
++ bool (*condition)(struct iavf_adapter *adapter,
++ const void *data,
++ enum virtchnl_ops v_op),
++ const void *cond_data,
++ unsigned int timeout_ms);
+ int iavf_config_rss(struct iavf_adapter *adapter);
+ void iavf_cfg_queues_bw(struct iavf_adapter *adapter);
+ void iavf_cfg_queues_quanta_size(struct iavf_adapter *adapter);
+diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
+index 29b8403a066bc8..2f8a80a1133626 100644
+--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
++++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
+@@ -1029,6 +1029,60 @@ static bool iavf_is_mac_set_handled(struct net_device *netdev,
+ return ret;
+ }
+
++/**
++ * iavf_mac_change_done - Check if MAC change completed
++ * @adapter: board private structure
++ * @data: MAC address being checked (as const void *)
++ * @v_op: virtchnl opcode from processed message
++ *
++ * Callback for iavf_poll_virtchnl_response() to check if MAC change completed.
++ *
++ * Return: true if MAC change completed, false otherwise
++ */
++static bool iavf_mac_change_done(struct iavf_adapter *adapter,
++ const void *data, enum virtchnl_ops v_op)
++{
++ const u8 *addr = data;
++
++ return iavf_is_mac_set_handled(adapter->netdev, addr);
++}
++
++/**
++ * iavf_set_mac_sync - Synchronously change MAC address
++ * @adapter: board private structure
++ * @addr: MAC address to set
++ *
++ * Send MAC change request to PF and poll admin queue for response.
++ * Caller must hold netdev_lock. This can sleep for up to 2.5 seconds.
++ * Event buffer is allocated before sending to avoid state mismatch if
++ * allocation fails after message is sent to PF.
++ *
++ * Return: 0 on success, negative on failure
++ */
++static int iavf_set_mac_sync(struct iavf_adapter *adapter, const u8 *addr)
++{
++ struct iavf_arq_event_info event;
++ int ret;
++
++ netdev_assert_locked(adapter->netdev);
++
++ event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
++ event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
++ if (!event.msg_buf)
++ return -ENOMEM;
++
++ ret = iavf_add_ether_addrs(adapter);
++ if (ret)
++ goto out;
++
++ ret = iavf_poll_virtchnl_response(adapter, &event,
++ iavf_mac_change_done, addr, 2500);
++
++out:
++ kfree(event.msg_buf);
++ return ret;
++}
++
+ /**
+ * iavf_set_mac - NDO callback to set port MAC address
+ * @netdev: network interface device structure
+@@ -1046,25 +1100,23 @@ static int iavf_set_mac(struct net_device *netdev, void *p)
+ return -EADDRNOTAVAIL;
+
+ ret = iavf_replace_primary_mac(adapter, addr->sa_data);
+-
+ if (ret)
+ return ret;
+
+- ret = wait_event_interruptible_timeout(adapter->vc_waitqueue,
+- iavf_is_mac_set_handled(netdev, addr->sa_data),
+- msecs_to_jiffies(2500));
+-
+- /* If ret < 0 then it means wait was interrupted.
+- * If ret == 0 then it means we got a timeout.
+- * else it means we got response for set MAC from PF,
+- * check if netdev MAC was updated to requested MAC,
+- * if yes then set MAC succeeded otherwise it failed return -EACCES
+- */
+- if (ret < 0)
++ ret = iavf_set_mac_sync(adapter, addr->sa_data);
++ if (ret) {
++ /* Rollback only if send failed (message never reached PF).
++ * Don't rollback on timeout (-EAGAIN) because the message was
++ * sent and PF will eventually respond. When the response arrives,
++ * iavf_virtchnl_completion() will handle rollback (on PF error)
++ * or acceptance (on PF success) automatically.
++ */
++ if (ret != -EAGAIN) {
++ iavf_mac_add_reject(adapter);
++ ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
++ }
+ return ret;
+-
+- if (!ret)
+- return -EAGAIN;
++ }
+
+ if (!ether_addr_equal(netdev->dev_addr, addr->sa_data))
+ return -EACCES;
+@@ -5394,9 +5446,6 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+ /* Setup the wait queue for indicating transition to down status */
+ init_waitqueue_head(&adapter->down_waitqueue);
+
+- /* Setup the wait queue for indicating virtchannel events */
+- init_waitqueue_head(&adapter->vc_waitqueue);
+-
+ INIT_LIST_HEAD(&adapter->ptp.aq_cmds);
+ init_waitqueue_head(&adapter->ptp.phc_time_waitqueue);
+ mutex_init(&adapter->ptp.aq_cmd_lock);
+diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+index ec234cc8bd9db0..e6b7e8f82c7c1f 100644
+--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
++++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+@@ -2,6 +2,7 @@
+ /* Copyright(c) 2013 - 2018 Intel Corporation. */
+
+ #include
++#include
+
+ #include "iavf.h"
+ #include "iavf_ptp.h"
+@@ -555,20 +556,23 @@ iavf_set_mac_addr_type(struct virtchnl_ether_addr *virtchnl_ether_addr,
+ * @adapter: adapter structure
+ *
+ * Request that the PF add one or more addresses to our filters.
+- **/
+-void iavf_add_ether_addrs(struct iavf_adapter *adapter)
++ *
++ * Return: 0 on success, negative on failure
++ */
++int iavf_add_ether_addrs(struct iavf_adapter *adapter)
+ {
+ struct virtchnl_ether_addr_list *veal;
+ struct iavf_mac_filter *f;
+ int i = 0, count = 0;
+ bool more = false;
+ size_t len;
++ int ret;
+
+ if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
+ /* bail because we already have a command pending */
+ dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
+ adapter->current_op);
+- return;
++ return -EBUSY;
+ }
+
+ spin_lock_bh(&adapter->mac_vlan_list_lock);
+@@ -580,7 +584,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter)
+ if (!count) {
+ adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
+ spin_unlock_bh(&adapter->mac_vlan_list_lock);
+- return;
++ return 0;
+ }
+ adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
+
+@@ -594,8 +598,9 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter)
+
+ veal = kzalloc(len, GFP_ATOMIC);
+ if (!veal) {
++ adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+ spin_unlock_bh(&adapter->mac_vlan_list_lock);
+- return;
++ return -ENOMEM;
+ }
+
+ veal->vsi_id = adapter->vsi_res->vsi_id;
+@@ -615,8 +620,15 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter)
+
+ spin_unlock_bh(&adapter->mac_vlan_list_lock);
+
+- iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len);
++ ret = iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len);
+ kfree(veal);
++ if (ret) {
++ dev_err(&adapter->pdev->dev,
++ "Unable to send ADD_ETH_ADDR message to PF, error %d\n", ret);
++ adapter->current_op = VIRTCHNL_OP_UNKNOWN;
++ }
++
++ return ret;
+ }
+
+ /**
+@@ -712,8 +724,8 @@ static void iavf_mac_add_ok(struct iavf_adapter *adapter)
+ * @adapter: adapter structure
+ *
+ * Remove filters from list based on PF response.
+- **/
+-static void iavf_mac_add_reject(struct iavf_adapter *adapter)
++ */
++void iavf_mac_add_reject(struct iavf_adapter *adapter)
+ {
+ struct net_device *netdev = adapter->netdev;
+ struct iavf_mac_filter *f, *ftmp;
+@@ -2364,7 +2376,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
+ iavf_mac_add_reject(adapter);
+ /* restore administratively set MAC address */
+ ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
+- wake_up(&adapter->vc_waitqueue);
+ break;
+ case VIRTCHNL_OP_DEL_ETH_ADDR:
+ dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
+@@ -2555,7 +2566,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
+ eth_hw_addr_set(netdev, adapter->hw.mac.addr);
+ netif_addr_unlock_bh(netdev);
+ }
+- wake_up(&adapter->vc_waitqueue);
+ break;
+ case VIRTCHNL_OP_GET_STATS: {
+ struct iavf_eth_stats *stats =
+@@ -2950,3 +2960,72 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
+ } /* switch v_opcode */
+ adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+ }
++
++/**
++ * iavf_poll_virtchnl_response - Poll admin queue for virtchnl response
++ * @adapter: adapter structure
++ * @event: pre-allocated event buffer to use for polling
++ * @condition: callback to check if desired response received
++ * @cond_data: context data passed to condition callback
++ * @timeout_ms: maximum time to wait in milliseconds
++ *
++ * Polls the admin queue and processes all incoming virtchnl messages.
++ * After processing each valid message, calls the condition callback to check
++ * if the expected response has been received. The callback receives the opcode
++ * of the processed message to identify which response was received. Continues
++ * polling until the callback returns true or timeout expires.
++ *
++ * Caller must allocate event buffer before sending any messages to PF to avoid
++ * state mismatch if allocation fails after message is sent.
++ *
++ * Caller must hold netdev_lock. This can sleep for up to timeout_ms while
++ * polling hardware.
++ *
++ * Return: 0 on success (condition met), -EAGAIN on timeout, or error code
++ */
++int iavf_poll_virtchnl_response(struct iavf_adapter *adapter,
++ struct iavf_arq_event_info *event,
++ bool (*condition)(struct iavf_adapter *adapter,
++ const void *data,
++ enum virtchnl_ops v_op),
++ const void *cond_data,
++ unsigned int timeout_ms)
++{
++ struct iavf_hw *hw = &adapter->hw;
++ enum virtchnl_ops received_op;
++ unsigned long timeout;
++ int ret = -EAGAIN;
++ u16 pending = 0;
++ u32 v_retval;
++
++ netdev_assert_locked(adapter->netdev);
++
++ timeout = jiffies + msecs_to_jiffies(timeout_ms);
++ do {
++ if (!pending)
++ usleep_range(50, 75);
++
++ if (iavf_clean_arq_element(hw, event, &pending) == IAVF_SUCCESS) {
++ received_op = (enum virtchnl_ops)le32_to_cpu(event->desc.cookie_high);
++ if (received_op != VIRTCHNL_OP_UNKNOWN) {
++ v_retval = le32_to_cpu(event->desc.cookie_low);
++
++ iavf_virtchnl_completion(adapter, received_op,
++ (enum iavf_status)v_retval,
++ event->msg_buf, event->msg_len);
++
++ if (condition(adapter, cond_data, received_op)) {
++ ret = 0;
++ break;
++ }
++ }
++
++ memset(event->msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE);
++
++ if (pending)
++ continue;
++ }
++ } while (time_before(jiffies, timeout));
++
++ return ret;
++}
+diff --git a/drivers/net/ethernet/intel/ice/devlink/port.c b/drivers/net/ethernet/intel/ice/devlink/port.c
+index 2a2e56777f9f75..3ede2464900272 100644
+--- a/drivers/net/ethernet/intel/ice/devlink/port.c
++++ b/drivers/net/ethernet/intel/ice/devlink/port.c
+@@ -590,8 +590,8 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port)
+
+ xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf);
+ ice_eswitch_detach_sf(pf, dyn_port);
+- ice_vsi_free(dyn_port->vsi);
+ xa_erase(&pf->dyn_ports, dyn_port->vsi->idx);
++ ice_vsi_free(dyn_port->vsi);
+ kfree(dyn_port);
+ }
+
+diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
+index b069e6c514fb12..6e7bba4738989b 100644
+--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
++++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
+@@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr)
+ return;
+
+ ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof);
+- metadata_dst_free(repr->dst);
++ dst_release(&repr->dst->dst);
+ repr->dst = NULL;
+ ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac,
+ ICE_FWD_TO_VSI);
+diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
+index c04c5856dad6e2..4e26ace793ec6d 100644
+--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
++++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
+@@ -1561,10 +1561,10 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first,
+ }
+ }
+ tstamp_ring->next_to_use = j;
+- writel_relaxed(j, tstamp_ring->tail);
++ writel(j, tstamp_ring->tail);
+ } else {
+ ring_kick:
+- writel_relaxed(i, tx_ring->tail);
++ writel(i, tx_ring->tail);
+ }
+ return;
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c
+index 4f984f6a2cb95e..55ec6387ab28d3 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c
+@@ -3,6 +3,7 @@
+
+ #include "rx.h"
+ #include "en/xdp.h"
++#include
+ #include
+ #include
+
+@@ -156,6 +157,7 @@ err_reuse_batch:
+ xsk_buff_free(xsk_buffs[batch]);
+
+ err:
++ bitmap_fill(wi->skip_release_bitmap, rq->mpwqe.pages_per_wqe);
+ rq->stats->buff_alloc_err++;
+ return -ENOMEM;
+ }
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+index 6fc6605d20549b..c75b064b04166a 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+@@ -410,8 +410,11 @@ static inline void mlx5e_free_rx_wqe(struct mlx5e_rq *rq,
+
+ static void mlx5e_xsk_free_rx_wqe(struct mlx5e_wqe_frag_info *wi)
+ {
+- if (!(wi->flags & BIT(MLX5E_WQE_FRAG_SKIP_RELEASE)))
+- xsk_buff_free(*wi->xskp);
++ if (wi->flags & BIT(MLX5E_WQE_FRAG_SKIP_RELEASE))
++ return;
++
++ xsk_buff_free(*wi->xskp);
++ wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
+ }
+
+ static void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix)
+@@ -905,10 +908,12 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
+ } while (!last_wqe);
+ } while ((++i < MLX5E_TX_CQ_POLL_BUDGET) && (cqe = mlx5_cqwq_get_cqe(&cq->wq)));
+
+- sq->cc = sqcc;
+-
+ mlx5_cqwq_update_db_record(&cq->wq);
+
++ /* ensure cq space is freed before enabling more cqes */
++ dma_wmb();
++
++ sq->cc = sqcc;
+ return i;
+ }
+
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
+index 7950b82d8b8aec..3624c680a861a5 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
+@@ -11,26 +11,6 @@ int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev, u16 vport,
+
+ lockdep_assert_held(&dev->priv.eswitch->state_lock);
+
+- if (MLX5_CAP_ESW(dev, esw_vport_state_max_tx_speed)) {
+- u8 op_mod = MLX5_VPORT_STATE_OP_MOD_ESW_VPORT;
+- struct mlx5_vport *esw_vport;
+- u32 speed = 0;
+- int err;
+-
+- err = mlx5_query_vport_max_tx_speed(dev, op_mod, vport,
+- true, &speed, NULL);
+- if (err) {
+- esw_vport = mlx5_eswitch_get_vport(dev->priv.eswitch,
+- vport);
+- speed = IS_ERR(esw_vport) ? 0 :
+- esw_vport->agg_max_tx_speed;
+- mlx5_core_dbg(dev,
+- "Failed to query vport %d max tx speed, err=%d, using cached %u\n",
+- vport, err, speed);
+- }
+- MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed);
+- }
+-
+ MLX5_SET(modify_vport_state_in, in, opcode,
+ MLX5_CMD_OP_MODIFY_VPORT_STATE);
+ MLX5_SET(modify_vport_state_in, in, op_mod,
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+index 3b34bec559e089..4e173b08cb37af 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+@@ -1432,30 +1432,40 @@ static bool mlx5_lag_should_disable_lag(struct mlx5_lag *ldev, bool do_bond)
+ }
+
+ #ifdef CONFIG_MLX5_ESWITCH
+-static int
+-mlx5_lag_sum_devices_speed(struct mlx5_lag *ldev, u32 *sum_speed,
+- int (*get_speed)(struct mlx5_core_dev *, u32 *))
++static int mlx5_lag_get_devices_oper_speed(struct mlx5_lag *ldev,
++ u32 *sum_speed)
+ {
+- struct mlx5_core_dev *pf_mdev;
+- struct lag_func *pf;
+ int pf_idx;
+- u32 speed;
+- int ret;
+
+ *sum_speed = 0;
+ mlx5_ldev_for_each(pf_idx, 0, ldev) {
++ u8 opmod = MLX5_VPORT_STATE_OP_MOD_VNIC_VPORT;
++ struct mlx5_core_dev *pf_mdev;
++ struct lag_func *pf;
++ u32 speed;
++ u8 state;
++ int ret;
++
+ pf = mlx5_lag_pf(ldev, pf_idx);
+ if (!pf)
+ continue;
+ pf_mdev = pf->dev;
+ if (!pf_mdev)
+ continue;
++ ret = mlx5_query_vport_max_tx_speed(pf_mdev, opmod, 0, 0,
++ &speed, &state);
++ if (ret) {
++ mlx5_core_dbg(pf_mdev, "State query failed (err=%d)\n",
++ ret);
++ return ret;
++ }
++ if (state != VPORT_STATE_UP)
++ continue;
+
+- ret = get_speed(pf_mdev, &speed);
++ ret = mlx5_port_oper_linkspeed(pf_mdev, &speed);
+ if (ret) {
+ mlx5_core_dbg(pf_mdev,
+- "Failed to get device speed using %ps. Device %s speed is not available (err=%d)\n",
+- get_speed, dev_name(pf_mdev->device),
++ "Failed to get oper speed (err=%d)\n",
+ ret);
+ return ret;
+ }
+@@ -1466,17 +1476,42 @@ mlx5_lag_sum_devices_speed(struct mlx5_lag *ldev, u32 *sum_speed,
+ return 0;
+ }
+
+-static int mlx5_lag_sum_devices_max_speed(struct mlx5_lag *ldev, u32 *max_speed)
++static int mlx5_lag_get_devices_max_speed(struct mlx5_lag *ldev, u32 *max_speed)
+ {
+- return mlx5_lag_sum_devices_speed(ldev, max_speed,
+- mlx5_port_max_linkspeed);
+-}
++ bool take_max;
++ int pf_idx;
+
+-static int mlx5_lag_sum_devices_oper_speed(struct mlx5_lag *ldev,
+- u32 *oper_speed)
+-{
+- return mlx5_lag_sum_devices_speed(ldev, oper_speed,
+- mlx5_port_oper_linkspeed);
++ take_max = ldev->tracker.tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP;
++ if (ldev->mode == MLX5_LAG_MODE_MPESW)
++ take_max = false;
++
++ *max_speed = 0;
++ mlx5_ldev_for_each(pf_idx, 0, ldev) {
++ struct mlx5_core_dev *pf_mdev;
++ struct lag_func *pf;
++ u32 speed;
++ int ret;
++
++ pf = mlx5_lag_pf(ldev, pf_idx);
++ if (!pf)
++ continue;
++ pf_mdev = pf->dev;
++ if (!pf_mdev)
++ continue;
++
++ ret = mlx5_port_max_linkspeed(pf_mdev, &speed);
++ if (ret) {
++ mlx5_core_dbg(pf_mdev,
++ "Failed to get max speed (err=%d)\n",
++ ret);
++ return ret;
++ }
++
++ *max_speed = take_max ?
++ max(*max_speed, speed) : *max_speed + speed;
++ }
++
++ return 0;
+ }
+
+ static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev,
+@@ -1525,7 +1560,7 @@ void mlx5_lag_set_vports_agg_speed(struct mlx5_lag *ldev)
+ int pf_idx;
+
+ if (ldev->mode == MLX5_LAG_MODE_MPESW) {
+- if (mlx5_lag_sum_devices_oper_speed(ldev, &speed))
++ if (mlx5_lag_get_devices_oper_speed(ldev, &speed))
+ return;
+ } else {
+ speed = ldev->tracker.bond_speed_mbps;
+@@ -1533,8 +1568,8 @@ void mlx5_lag_set_vports_agg_speed(struct mlx5_lag *ldev)
+ return;
+ }
+
+- /* If speed is not set, use the sum of max speeds of all PFs */
+- if (!speed && mlx5_lag_sum_devices_max_speed(ldev, &speed))
++ /* If speed is not set, fall back to the max achievable speed */
++ if (!speed && mlx5_lag_get_devices_max_speed(ldev, &speed))
+ return;
+
+ speed = speed / MLX5_MAX_TX_SPEED_UNIT;
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+index 8aa94ec87a0e3c..edac2d694e0f04 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c
+@@ -93,30 +93,6 @@ int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod,
+ lockdep_assert_held(&mdev->priv.eswitch->state_lock);
+ #endif
+
+- if (MLX5_CAP_ESW(mdev, esw_vport_state_max_tx_speed) &&
+- opmod == MLX5_VPORT_STATE_OP_MOD_ESW_VPORT &&
+- vport != MLX5_VPORT_UPLINK) {
+- u32 speed = 0;
+- int err;
+-
+- err = mlx5_query_vport_max_tx_speed(mdev, opmod, vport,
+- other_vport, &speed, NULL);
+- if (err) {
+-#ifdef CONFIG_MLX5_ESWITCH
+- struct mlx5_vport *esw_vport;
+-
+- esw_vport = mlx5_eswitch_get_vport(mdev->priv.eswitch,
+- vport);
+- speed = IS_ERR(esw_vport) ? 0 :
+- esw_vport->agg_max_tx_speed;
+-#endif
+- mlx5_core_dbg(mdev,
+- "Failed to query vport %d max tx speed, err=%d, using cached %u\n",
+- vport, err, speed);
+- }
+- MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed);
+- }
+-
+ MLX5_SET(modify_vport_state_in, in, opcode,
+ MLX5_CMD_OP_MODIFY_VPORT_STATE);
+ MLX5_SET(modify_vport_state_in, in, op_mod, opmod);
+diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+index b03ff9e044f9e2..10af08ce72efaf 100644
+--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+@@ -989,6 +989,8 @@ void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset,
+ struct mlxsw_sp_acl_rule_info *
+ mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl,
+ struct mlxsw_afa_block *afa_block);
++void mlxsw_sp_acl_rulei_free(struct mlxsw_sp *mlxsw_sp,
++ const struct mlxsw_sp_acl_rule_info *rulei);
+ void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp,
+ struct mlxsw_sp_acl_rule_info *rulei);
+ int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei);
+diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
+index cb232accb296aa..f7be4f3a151842 100644
+--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
+@@ -340,8 +340,8 @@ err_afa_block_create:
+ return ERR_PTR(err);
+ }
+
+-void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp,
+- struct mlxsw_sp_acl_rule_info *rulei)
++void mlxsw_sp_acl_rulei_free(struct mlxsw_sp *mlxsw_sp,
++ const struct mlxsw_sp_acl_rule_info *rulei)
+ {
+ if (rulei->action_created)
+ mlxsw_afa_block_destroy(rulei->act_block);
+@@ -351,6 +351,12 @@ void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp,
+ if (rulei->dst_port_range_reg_valid)
+ mlxsw_sp_port_range_reg_put(mlxsw_sp,
+ rulei->dst_port_range_reg_index);
++}
++
++void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp,
++ struct mlxsw_sp_acl_rule_info *rulei)
++{
++ mlxsw_sp_acl_rulei_free(mlxsw_sp, rulei);
+ kfree(rulei);
+ }
+
+diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
+index 353fd9ca89a68a..5e4632cb792d56 100644
+--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
+@@ -862,14 +862,19 @@ int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp,
+ memset(&rulei, 0, sizeof(rulei));
+ err = mlxsw_sp_flower_parse(mlxsw_sp, block, &rulei, f);
+ if (err)
+- return err;
++ goto out;
++
+ ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, block,
+ f->common.chain_index,
+ MLXSW_SP_ACL_PROFILE_FLOWER,
+ &rulei.values.elusage);
++ err = PTR_ERR_OR_ZERO(ruleset);
++
++out:
++ mlxsw_sp_acl_rulei_free(mlxsw_sp, &rulei);
+
+ /* keep the reference to the ruleset */
+- return PTR_ERR_OR_ZERO(ruleset);
++ return err;
+ }
+
+ void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp,
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
+index 5953e04ef14e6f..2826e48af1033e 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
+@@ -622,18 +622,9 @@ int sparx5_ptp_init(struct sparx5 *sparx5)
+ sparx5->ptp = 1;
+ }
+
+- if (!sparx5->ptp)
+- return 0;
+-
+- for (i = 0; i < SPARX5_PHC_COUNT; ++i) {
+- err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info);
+- if (err)
+- return err;
+- }
+-
+- spin_lock_init(&sparx5->ptp_clock_lock);
+- spin_lock_init(&sparx5->ptp_ts_id_lock);
+- mutex_init(&sparx5->ptp_lock);
++ /* The base, non-PTP-capable lan969x variants need the
++ * first TOD counter running to forward frames.
++ */
+
+ /* Disable master counters */
+ spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0), sparx5, PTP_PTP_DOM_CFG);
+@@ -657,6 +648,19 @@ int sparx5_ptp_init(struct sparx5 *sparx5)
+ /* Enable master counters */
+ spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG);
+
++ if (!sparx5->ptp)
++ return 0;
++
++ for (i = 0; i < SPARX5_PHC_COUNT; ++i) {
++ err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info);
++ if (err)
++ return err;
++ }
++
++ spin_lock_init(&sparx5->ptp_clock_lock);
++ spin_lock_init(&sparx5->ptp_ts_id_lock);
++ mutex_init(&sparx5->ptp_lock);
++
+ for (i = 0; i < sparx5->data->consts->n_ports; i++) {
+ port = sparx5->ports[i];
+ if (!port)
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
+index 702257979462d4..146d7f28e8f3dd 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
+@@ -160,6 +160,7 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev,
+ }
+
+ list_del(&entry->list);
++ kfree(entry);
+
+ return err;
+ }
+diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+index 010fef79ec01e2..0da3da7d0d1b80 100644
+--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+@@ -6222,6 +6222,13 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,
+ if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN))
+ features &= ~NETIF_F_CSUM_MASK;
+
++ if (priv->plat->core_type == DWMAC_CORE_XGMAC) {
++ if (features & NETIF_F_HW_VLAN_CTAG_RX)
++ features |= NETIF_F_HW_VLAN_STAG_RX;
++ else
++ features &= ~NETIF_F_HW_VLAN_STAG_RX;
++ }
++
+ return features;
+ }
+
+@@ -8016,14 +8023,18 @@ static int __stmmac_dvr_probe(struct device *device,
+ ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
+ #ifdef STMMAC_VLAN_TAG_USED
+ /* Both mac100 and gmac support receive VLAN tag detection */
+- ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX;
++ ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
++ if (priv->plat->core_type == DWMAC_CORE_XGMAC)
++ ndev->features |= NETIF_F_HW_VLAN_STAG_RX;
++
+ if (dwmac_is_xmac(priv->plat->core_type)) {
+ ndev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX;
+ priv->hw->hw_vlan_en = true;
+ }
+ if (priv->dma_cap.vlhash) {
+ ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
+- ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
++ if (priv->plat->core_type == DWMAC_CORE_XGMAC)
++ ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER;
+ }
+ if (priv->dma_cap.vlins)
+ ndev->features |= NETIF_F_HW_VLAN_CTAG_TX;
+diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
+index fcd3aaef27fc32..c63d99686d0bac 100644
+--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
++++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
+@@ -523,8 +523,9 @@ struct skbuf_dma_descriptor {
+ * @stats_work: Work for reading the hardware statistics counters often enough
+ * to catch overflows.
+ * @dma_err_task: Work structure to process Axi DMA errors
+- * @stopping: Set when @dma_err_task shouldn't do anything because we are
+- * about to stop the device.
++ * @stopping: Set when we are about to stop the device: makes @dma_err_task
++ * a no-op (legacy DMA path) and fences RX descriptor
++ * resubmission in axienet_dma_rx_cb() (dmaengine path).
+ * @tx_irq: Axidma TX IRQ number
+ * @rx_irq: Axidma RX IRQ number
+ * @eth_irq: Ethernet core IRQ number
+@@ -545,6 +546,7 @@ struct skbuf_dma_descriptor {
+ * @tx_ring_tail: TX skb ring buffer tail index.
+ * @rx_ring_head: RX skb ring buffer head index.
+ * @rx_ring_tail: RX skb ring buffer tail index.
++ * @rx_submit_lock: Protects RX ring resubmission vs teardown in dmaengine path.
+ */
+ struct axienet_local {
+ struct net_device *ndev;
+@@ -626,6 +628,7 @@ struct axienet_local {
+ int tx_ring_tail;
+ int rx_ring_head;
+ int rx_ring_tail;
++ spinlock_t rx_submit_lock;
+ };
+
+ /**
+diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+index fcf517069d161a..1ae4fd65e5ec51 100644
+--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
++++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+@@ -881,6 +881,7 @@ static void axienet_dma_tx_cb(void *data, const struct dmaengine_result *result)
+ u64_stats_update_end(&lp->tx_stat_sync);
+ dma_unmap_sg(lp->dev, skbuf_dma->sgl, skbuf_dma->sg_len, DMA_TO_DEVICE);
+ dev_consume_skb_any(skbuf_dma->skb);
++ skbuf_dma->skb = NULL;
+ netif_txq_completed_wake(txq, 1, len,
+ CIRC_SPACE(lp->tx_ring_head, lp->tx_ring_tail, TX_BD_NUM_MAX),
+ 2);
+@@ -1171,6 +1172,7 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
+ &meta_max_len);
+ dma_unmap_single(lp->dev, skbuf_dma->dma_address, lp->max_frm_size,
+ DMA_FROM_DEVICE);
++ skbuf_dma->skb = NULL;
+
+ if (IS_ERR(app_metadata)) {
+ if (net_ratelimit())
+@@ -1193,10 +1195,17 @@ static void axienet_dma_rx_cb(void *data, const struct dmaengine_result *result)
+ u64_stats_update_end(&lp->rx_stat_sync);
+
+ rx_submit:
++ spin_lock(&lp->rx_submit_lock);
++ if (lp->stopping) {
++ spin_unlock(&lp->rx_submit_lock);
++ return;
++ }
++
+ for (i = 0; i < CIRC_SPACE(lp->rx_ring_head, lp->rx_ring_tail,
+ RX_BUF_NUM_DEFAULT); i++)
+ axienet_rx_submit_desc(lp->ndev);
+ dma_async_issue_pending(lp->rx_chan);
++ spin_unlock(&lp->rx_submit_lock);
+ }
+
+ /**
+@@ -1541,6 +1550,7 @@ static int axienet_init_dmaengine(struct net_device *ndev)
+ lp->tx_ring_head = 0;
+ lp->rx_ring_tail = 0;
+ lp->rx_ring_head = 0;
++ lp->stopping = false;
+ lp->tx_skb_ring = kzalloc_objs(*lp->tx_skb_ring, TX_BD_NUM_MAX);
+ if (!lp->tx_skb_ring) {
+ ret = -ENOMEM;
+@@ -1752,20 +1762,42 @@ static int axienet_stop(struct net_device *ndev)
+ free_irq(lp->rx_irq, ndev);
+ axienet_dma_bd_release(ndev);
+ } else {
++ struct skbuf_dma_descriptor *skbuf_dma;
++
++ spin_lock_bh(&lp->rx_submit_lock);
++ lp->stopping = true;
++ spin_unlock_bh(&lp->rx_submit_lock);
++
+ dmaengine_terminate_sync(lp->tx_chan);
+- dmaengine_synchronize(lp->tx_chan);
+ dmaengine_terminate_sync(lp->rx_chan);
+- dmaengine_synchronize(lp->rx_chan);
+-
+- for (i = 0; i < TX_BD_NUM_MAX; i++)
+- kfree(lp->tx_skb_ring[i]);
+- kfree(lp->tx_skb_ring);
+- for (i = 0; i < RX_BUF_NUM_DEFAULT; i++)
+- kfree(lp->rx_skb_ring[i]);
+- kfree(lp->rx_skb_ring);
+
+ dma_release_channel(lp->rx_chan);
+ dma_release_channel(lp->tx_chan);
++
++ /* Unmap and free any buffer the terminate did not reclaim, so it
++ * is not leaked; a non-NULL skb marks such a slot.
++ */
++ for (i = 0; i < TX_BD_NUM_MAX; i++) {
++ skbuf_dma = lp->tx_skb_ring[i];
++ if (skbuf_dma && skbuf_dma->skb) {
++ dma_unmap_sg(lp->dev, skbuf_dma->sgl,
++ skbuf_dma->sg_len, DMA_TO_DEVICE);
++ dev_kfree_skb_any(skbuf_dma->skb);
++ }
++ kfree(skbuf_dma);
++ }
++ kfree(lp->tx_skb_ring);
++
++ for (i = 0; i < RX_BUF_NUM_DEFAULT; i++) {
++ skbuf_dma = lp->rx_skb_ring[i];
++ if (skbuf_dma && skbuf_dma->skb) {
++ dma_unmap_single(lp->dev, skbuf_dma->dma_address,
++ lp->max_frm_size, DMA_FROM_DEVICE);
++ dev_kfree_skb_any(skbuf_dma->skb);
++ }
++ kfree(skbuf_dma);
++ }
++ kfree(lp->rx_skb_ring);
+ }
+
+ netdev_reset_queue(ndev);
+@@ -3062,6 +3094,7 @@ static int axienet_probe(struct platform_device *pdev)
+
+ spin_lock_init(&lp->rx_cr_lock);
+ spin_lock_init(&lp->tx_cr_lock);
++ spin_lock_init(&lp->rx_submit_lock);
+ INIT_WORK(&lp->rx_dim.work, axienet_rx_dim_work);
+ lp->rx_dim_enabled = true;
+ lp->rx_dim.profile_ix = 1;
+diff --git a/drivers/net/pfcp.c b/drivers/net/pfcp.c
+index 8bbaf167db7593..08557c03818093 100644
+--- a/drivers/net/pfcp.c
++++ b/drivers/net/pfcp.c
+@@ -64,6 +64,13 @@ static int pfcp_encap_recv(struct sock *sk, struct sk_buff *skb)
+ goto drop;
+
+ unparsed = pfcp_hdr(skb);
++ if (unparsed->flags & PFCP_SEID_FLAG) {
++ if (unlikely(!pskb_may_pull(skb, PFCP_HLEN +
++ offsetofend(struct pfcphdr_session,
++ seid))))
++ goto drop;
++ unparsed = pfcp_hdr(skb);
++ }
+
+ ip_tunnel_flags_zero(flags);
+ tun_dst = udp_tun_rx_dst(skb, sk->sk_family, flags, 0,
+diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
+index feaa75fbf8fc25..3bf7c80f1d8e56 100644
+--- a/drivers/net/team/team_core.c
++++ b/drivers/net/team/team_core.c
+@@ -820,7 +820,8 @@ static struct list_head *__team_get_qom_list(struct team *team, u16 queue_id)
+ /*
+ * note: already called with rcu_read_lock
+ */
+-static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb)
++static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb,
++ bool *tx_success)
+ {
+ struct list_head *qom_list;
+ struct team_port *port;
+@@ -828,11 +829,11 @@ static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb)
+ if (!team->queue_override_enabled || !skb->queue_mapping)
+ return false;
+ qom_list = __team_get_qom_list(team, skb->queue_mapping);
+- list_for_each_entry_rcu(port, qom_list, qom_list) {
+- if (!team_dev_queue_xmit(team, port, skb))
+- return true;
+- }
+- return false;
++ port = list_first_or_null_rcu(qom_list, struct team_port, qom_list);
++ if (!port)
++ return false;
++ *tx_success = !team_dev_queue_xmit(team, port, skb);
++ return true;
+ }
+
+ static void __team_queue_override_port_del(struct team *team,
+@@ -1864,8 +1865,7 @@ static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev)
+ bool tx_success;
+ unsigned int len = skb->len;
+
+- tx_success = team_queue_override_transmit(team, skb);
+- if (!tx_success)
++ if (!team_queue_override_transmit(team, skb, &tx_success))
+ tx_success = READ_ONCE(team->ops.transmit)(team, skb);
+ if (tx_success) {
+ struct team_pcpu_stats *pcpu_stats;
+diff --git a/drivers/net/team/team_mode_broadcast.c b/drivers/net/team/team_mode_broadcast.c
+index 61d7d79f0c3638..69dc25a5847a17 100644
+--- a/drivers/net/team/team_mode_broadcast.c
++++ b/drivers/net/team/team_mode_broadcast.c
+@@ -37,6 +37,8 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb)
+ ret = !team_dev_queue_xmit(team, last, skb);
+ if (!sum_ret)
+ sum_ret = ret;
++ } else {
++ dev_kfree_skb_any(skb);
+ }
+ return sum_ret;
+ }
+diff --git a/drivers/net/tun.c b/drivers/net/tun.c
+index 5bbe3123979e00..dcd39815205a9a 100644
+--- a/drivers/net/tun.c
++++ b/drivers/net/tun.c
+@@ -1818,12 +1818,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
+ }
+ }
+
+- if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, &hdr)) {
+- atomic_long_inc(&tun->rx_frame_errors);
+- err = -EINVAL;
+- goto free_skb;
+- }
+-
++ skb->dev = tun->dev;
+ switch (tun->flags & TUN_TYPE_MASK) {
+ case IFF_TUN:
+ if (tun->flags & IFF_NO_PI) {
+@@ -1848,9 +1843,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
+ }
+ }
+
+- skb_reset_mac_header(skb);
++ skb_reset_network_header(skb);
+ skb->protocol = pi.proto;
+- skb->dev = tun->dev;
+ break;
+ case IFF_TAP:
+ if (!pskb_may_pull(skb, ETH_HLEN)) {
+@@ -1858,10 +1852,19 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
+ drop_reason = SKB_DROP_REASON_HDR_TRUNC;
+ goto drop;
+ }
+- skb->protocol = eth_type_trans(skb, tun->dev);
++ skb_set_network_header(skb, ETH_HLEN);
+ break;
+ }
+
++ if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, &hdr)) {
++ atomic_long_inc(&tun->rx_frame_errors);
++ err = -EINVAL;
++ goto free_skb;
++ }
++
++ if ((tun->flags & TUN_TYPE_MASK) == IFF_TAP)
++ skb->protocol = eth_type_trans(skb, tun->dev);
++
+ /* copy skb_ubuf_info for callback when skb has no error */
+ if (zerocopy) {
+ skb_zcopy_init(skb, msg_control);
+@@ -2469,6 +2472,8 @@ build:
+
+ features = tun_vnet_hdr_guest_features(READ_ONCE(tun->vnet_hdr_sz));
+ tnl_hdr = (struct virtio_net_hdr_v1_hash_tunnel *)gso;
++ skb->dev = tun->dev;
++ skb_set_network_header(skb, ETH_HLEN);
+ if (tun_vnet_hdr_tnl_to_skb(tun->flags, features, skb, tnl_hdr)) {
+ atomic_long_inc(&tun->rx_frame_errors);
+ kfree_skb(skb);
+diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
+index 81d8412ce8e2fa..cba1dc95d35942 100644
+--- a/drivers/net/usb/ax88179_178a.c
++++ b/drivers/net/usb/ax88179_178a.c
+@@ -1457,11 +1457,11 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
+ return 1;
+ }
+
+- ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len);
++ ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len - 2);
+ if (!ax_skb)
+ return 0;
+- skb_put(ax_skb, pkt_len);
+- memcpy(ax_skb->data, skb->data + 2, pkt_len);
++ skb_put(ax_skb, pkt_len - 2);
++ memcpy(ax_skb->data, skb->data + 2, pkt_len - 2);
+
+ ax88179_rx_checksum(ax_skb, pkt_hdr);
+ usbnet_skb_return(dev, ax_skb);
+diff --git a/drivers/net/veth.c b/drivers/net/veth.c
+index 2780b2dd073d1c..4f145c5f686ef0 100644
+--- a/drivers/net/veth.c
++++ b/drivers/net/veth.c
+@@ -1414,6 +1414,7 @@ static int veth_open(struct net_device *dev)
+ }
+
+ veth_set_xdp_features(dev);
++ veth_set_xdp_features(peer);
+
+ return 0;
+ }
+diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
+index bf82ef9874abb4..daab43ac92ce42 100644
+--- a/drivers/net/virtio_net.c
++++ b/drivers/net/virtio_net.c
+@@ -2515,6 +2515,8 @@ static void virtnet_receive_done(struct virtnet_info *vi, struct receive_queue *
+ goto frame_err;
+ }
+
++ skb->dev = dev;
++ skb_set_network_header(skb, ETH_HLEN);
+ if (virtio_net_hdr_tnl_to_skb(skb, &hdr->tnl_hdr, vi->rx_tnl,
+ vi->rx_tnl_csum,
+ virtio_is_little_endian(vi->vdev))) {
+diff --git a/drivers/net/wireguard/noise.c b/drivers/net/wireguard/noise.c
+index 9c0a09bf6c9562..ec2513d6dfab35 100644
+--- a/drivers/net/wireguard/noise.c
++++ b/drivers/net/wireguard/noise.c
+@@ -784,10 +784,11 @@ wg_noise_handshake_consume_response(struct message_handshake_response *src,
+
+ /* Success! Copy everything to peer */
+ down_write(&handshake->lock);
+- /* It's important to check that the state is still the same, while we
+- * have an exclusive lock.
++ /* Check that the state is the same and that this is still the
++ * initiation we started with, while we have an exclusive lock.
+ */
+- if (handshake->state != state) {
++ if (handshake->state != state ||
++ crypto_memneq(handshake->ephemeral_private, ephemeral_private, NOISE_PUBLIC_KEY_LEN)) {
+ up_write(&handshake->lock);
+ goto fail;
+ }
+diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h
+index 79b6d70de236bc..663b19b7839533 100644
+--- a/drivers/net/wireguard/queueing.h
++++ b/drivers/net/wireguard/queueing.h
+@@ -78,12 +78,14 @@ static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating)
+ u8 l4_hash = skb->l4_hash;
+ u8 sw_hash = skb->sw_hash;
+ u32 hash = skb->hash;
++ u8 tstamp_type = skb->tstamp_type;
+ skb_scrub_packet(skb, true);
+ memset(&skb->headers, 0, sizeof(skb->headers));
+ if (encapsulating) {
+ skb->l4_hash = l4_hash;
+ skb->sw_hash = sw_hash;
+ skb->hash = hash;
++ skb->tstamp_type = tstamp_type;
+ }
+ skb->queue_mapping = 0;
+ skb->nohdr = 0;
+diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
+index 5cdf4973d986af..992602965fb494 100644
+--- a/drivers/net/wireless/ath/ath12k/core.c
++++ b/drivers/net/wireless/ath/ath12k/core.c
+@@ -1770,29 +1770,6 @@ int ath12k_core_pre_init(struct ath12k_base *ab)
+ return 0;
+ }
+
+-static int ath12k_core_panic_handler(struct notifier_block *nb,
+- unsigned long action, void *data)
+-{
+- struct ath12k_base *ab = container_of(nb, struct ath12k_base,
+- panic_nb);
+-
+- return ath12k_hif_panic_handler(ab);
+-}
+-
+-static int ath12k_core_panic_notifier_register(struct ath12k_base *ab)
+-{
+- ab->panic_nb.notifier_call = ath12k_core_panic_handler;
+-
+- return atomic_notifier_chain_register(&panic_notifier_list,
+- &ab->panic_nb);
+-}
+-
+-static void ath12k_core_panic_notifier_unregister(struct ath12k_base *ab)
+-{
+- atomic_notifier_chain_unregister(&panic_notifier_list,
+- &ab->panic_nb);
+-}
+-
+ static inline
+ bool ath12k_core_hw_group_create_ready(struct ath12k_hw_group *ag)
+ {
+@@ -2208,18 +2185,13 @@ int ath12k_core_init(struct ath12k_base *ab)
+ struct ath12k_hw_group *ag;
+ int ret;
+
+- ret = ath12k_core_panic_notifier_register(ab);
+- if (ret)
+- ath12k_warn(ab, "failed to register panic handler: %d\n", ret);
+-
+ mutex_lock(&ath12k_hw_group_mutex);
+
+ ag = ath12k_core_hw_group_assign(ab);
+ if (!ag) {
+ mutex_unlock(&ath12k_hw_group_mutex);
+ ath12k_warn(ab, "unable to get hw group\n");
+- ret = -ENODEV;
+- goto err_unregister_notifier;
++ return -ENODEV;
+ }
+
+ mutex_unlock(&ath12k_hw_group_mutex);
+@@ -2244,8 +2216,6 @@ int ath12k_core_init(struct ath12k_base *ab)
+
+ err_unassign_hw_group:
+ ath12k_core_hw_group_unassign(ab);
+-err_unregister_notifier:
+- ath12k_core_panic_notifier_unregister(ab);
+
+ return ret;
+ }
+@@ -2254,7 +2224,6 @@ void ath12k_core_deinit(struct ath12k_base *ab)
+ {
+ ath12k_core_hw_group_destroy(ab->ag);
+ ath12k_core_hw_group_unassign(ab);
+- ath12k_core_panic_notifier_unregister(ab);
+ }
+
+ void ath12k_core_free(struct ath12k_base *ab)
+diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
+index f28d2e90b67b29..708479df4b89e8 100644
+--- a/drivers/net/wireless/ath/ath12k/core.h
++++ b/drivers/net/wireless/ath/ath12k/core.h
+@@ -15,7 +15,6 @@
+ #include
+ #include
+ #include
+-#include
+ #include
+ #include
+ #include
+@@ -1146,8 +1145,6 @@ struct ath12k_base {
+
+ #endif /* CONFIG_ACPI */
+
+- struct notifier_block panic_nb;
+-
+ struct ath12k_hw_group *ag;
+ struct ath12k_wsi_info wsi_info;
+ enum ath12k_firmware_mode fw_mode;
+diff --git a/drivers/net/wireless/ath/ath12k/hif.h b/drivers/net/wireless/ath/ath12k/hif.h
+index 4de8667690e915..aecdb0c5f2858d 100644
+--- a/drivers/net/wireless/ath/ath12k/hif.h
++++ b/drivers/net/wireless/ath/ath12k/hif.h
+@@ -30,7 +30,6 @@ struct ath12k_hif_ops {
+ void (*ce_irq_enable)(struct ath12k_base *ab);
+ void (*ce_irq_disable)(struct ath12k_base *ab);
+ void (*get_ce_msi_idx)(struct ath12k_base *ab, u32 ce_id, u32 *msi_idx);
+- int (*panic_handler)(struct ath12k_base *ab);
+ void (*coredump_download)(struct ath12k_base *ab);
+ };
+
+@@ -149,14 +148,6 @@ static inline void ath12k_hif_power_down(struct ath12k_base *ab, bool is_suspend
+ ab->hif.ops->power_down(ab, is_suspend);
+ }
+
+-static inline int ath12k_hif_panic_handler(struct ath12k_base *ab)
+-{
+- if (!ab->hif.ops->panic_handler)
+- return NOTIFY_DONE;
+-
+- return ab->hif.ops->panic_handler(ab);
+-}
+-
+ static inline void ath12k_hif_coredump_download(struct ath12k_base *ab)
+ {
+ if (ab->hif.ops->coredump_download)
+diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c
+index fee4129ea4055b..a41544665080a8 100644
+--- a/drivers/net/wireless/ath/ath12k/pci.c
++++ b/drivers/net/wireless/ath/ath12k/pci.c
+@@ -1473,13 +1473,6 @@ void ath12k_pci_power_down(struct ath12k_base *ab, bool is_suspend)
+ ath12k_pci_sw_reset(ab_pci->ab, false);
+ }
+
+-static int ath12k_pci_panic_handler(struct ath12k_base *ab)
+-{
+- ath12k_pci_sw_reset(ab, false);
+-
+- return NOTIFY_OK;
+-}
+-
+ static const struct ath12k_hif_ops ath12k_pci_hif_ops = {
+ .start = ath12k_pci_start,
+ .stop = ath12k_pci_stop,
+@@ -1497,7 +1490,6 @@ static const struct ath12k_hif_ops ath12k_pci_hif_ops = {
+ .ce_irq_enable = ath12k_pci_hif_ce_irq_enable,
+ .ce_irq_disable = ath12k_pci_hif_ce_irq_disable,
+ .get_ce_msi_idx = ath12k_pci_get_ce_msi_idx,
+- .panic_handler = ath12k_pci_panic_handler,
+ #ifdef CONFIG_ATH12K_COREDUMP
+ .coredump_download = ath12k_pci_coredump_download,
+ #endif
+diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+index d2ae679856067a..92ec269f43b232 100644
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1489,8 +1489,31 @@ void brcmf_detach(struct device *dev)
+ brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN);
+ /* make sure primary interface removed last */
+ for (i = BRCMF_MAX_IFS - 1; i > -1; i--) {
+- if (drvr->iflist[i])
+- brcmf_remove_interface(drvr->iflist[i], false);
++ struct brcmf_if *ifp = drvr->iflist[i];
++
++ if (!ifp)
++ continue;
++
++ if (ifp->ndev) {
++ brcmf_remove_interface(ifp, false);
++ continue;
++ }
++
++ /* The P2P device interface has no netdev. Its removal can
++ * race with NL80211_CMD_DEL_INTERFACE issued by a user space
++ * process that is exiting (e.g. wpa_supplicant), which ends
++ * in brcmf_p2p_del_vif() under RTNL and the wiphy mutex. If
++ * both paths remove the interface, the wdev is unregistered
++ * twice and the vif is used after being freed. Take the same
++ * locks and re-read iflist, so only one path removes it.
++ */
++ rtnl_lock();
++ wiphy_lock(drvr->wiphy);
++ ifp = drvr->iflist[i];
++ if (ifp)
++ brcmf_remove_interface(ifp, true);
++ wiphy_unlock(drvr->wiphy);
++ rtnl_unlock();
+ }
+ brcmf_bus_stop(drvr->bus_if);
+
+diff --git a/drivers/net/wireless/marvell/libertas/tx.c b/drivers/net/wireless/marvell/libertas/tx.c
+index 13d08022e41415..27304a98787d6a 100644
+--- a/drivers/net/wireless/marvell/libertas/tx.c
++++ b/drivers/net/wireless/marvell/libertas/tx.c
+@@ -117,13 +117,6 @@ netdev_tx_t lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+ if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR) {
+ struct tx_radiotap_hdr *rtap_hdr = (void *)skb->data;
+
+- if (skb->len < sizeof(*rtap_hdr) + 4 + ETH_ALEN) {
+- lbs_deb_tx("tx err: short monitor frame %u\n", skb->len);
+- dev->stats.tx_dropped++;
+- dev->stats.tx_errors++;
+- goto free;
+- }
+-
+ /* set txpd fields from the radiotap header */
+ txpd->tx_control = cpu_to_le32(convert_radiotap_rate_to_mv(rtap_hdr->rate));
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
+index 476578e2fbf0c5..9188a27e78652c 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76.h
++++ b/drivers/net/wireless/mediatek/mt76/mt76.h
+@@ -539,6 +539,7 @@ struct mt76_hw_cap {
+ #define MT_DRV_HW_MGMT_TXQ BIT(4)
+ #define MT_DRV_AMSDU_OFFLOAD BIT(5)
+ #define MT_DRV_IGNORE_TXS_FAILED BIT(6)
++#define MT_DRV_HW_PS_BUFFERING BIT(7)
+
+ struct mt76_driver_ops {
+ u32 drv_flags;
+@@ -1424,6 +1425,13 @@ mtxq_to_txq(struct mt76_txq *mtxq)
+ return container_of(ptr, struct ieee80211_txq, drv_priv);
+ }
+
++/* peer-wide state uses the wcid of the primary link */
++static inline struct mt76_wcid *
++mt76_wcid_primary(struct mt76_wcid *wcid)
++{
++ return wcid->def_wcid ? wcid->def_wcid : wcid;
++}
++
+ static inline struct ieee80211_sta *
+ wcid_to_sta(struct mt76_wcid *wcid)
+ {
+@@ -1541,6 +1549,8 @@ void mt76_release_buffered_frames(struct ieee80211_hw *hw,
+ u16 tids, int nframes,
+ enum ieee80211_frame_release_type reason,
+ bool more_data);
++void mt76_sta_ps_transition(struct mt76_dev *dev, struct mt76_wcid *wcid,
++ bool ps);
+ bool mt76_has_tx_pending(struct mt76_phy *phy);
+ int mt76_update_channel(struct mt76_phy *phy);
+ void mt76_update_survey(struct mt76_phy *phy);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/init.c b/drivers/net/wireless/mediatek/mt76/mt7603/init.c
+index 10f2ec70c792b8..218ec406d2a878 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7603/init.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7603/init.c
+@@ -230,6 +230,7 @@ mt7603_mac_init(struct mt7603_dev *dev)
+
+ eth_broadcast_addr(bc_addr);
+ mt7603_wtbl_init(dev, MT7603_WTBL_RESERVED, -1, bc_addr);
++ mt76_wcid_init(&dev->global_sta.wcid, 0);
+ dev->global_sta.wcid.idx = MT7603_WTBL_RESERVED;
+ rcu_assign_pointer(dev->mt76.wcid[MT7603_WTBL_RESERVED],
+ &dev->global_sta.wcid);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+index a9a4a87ae0a76b..fe03bc70e63a4e 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
++++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+@@ -1068,6 +1068,7 @@ enum {
+ MCU_UNI_EVENT_IE_COUNTDOWN = 0x09,
+ MCU_UNI_EVENT_COREDUMP = 0x0a,
+ MCU_UNI_EVENT_BSS_BEACON_LOSS = 0x0c,
++ MCU_UNI_EVENT_PS_SYNC = 0x0d,
+ MCU_UNI_EVENT_SCAN_DONE = 0x0e,
+ MCU_UNI_EVENT_RDD_REPORT = 0x11,
+ MCU_UNI_EVENT_ROC = 0x27,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+index 2ab38f9e525810..e768f4f72ed8e7 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+@@ -1208,6 +1208,12 @@ static void mt7915_unregister_ext_phy(struct mt7915_dev *dev)
+
+ static void mt7915_stop_hardware(struct mt7915_dev *dev)
+ {
++ int i;
++
++ mt76_for_each_q_rx(&dev->mt76, i) {
++ if (!mt76_queue_is_wed_rro(&dev->mt76.q_rx[i]))
++ napi_disable(&dev->mt76.napi[i]);
++ }
+ mt7915_mcu_exit(dev);
+ mt76_connac2_tx_token_put(&dev->mt76);
+ mt7915_dma_cleanup(dev);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+index 4783e5f52d2293..1830398ff719f0 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+@@ -805,6 +805,7 @@ __mt7915_drop_sta(void *ptr, u8 *mac, struct ieee80211_vif *vif)
+
+ msta = (struct mt7915_sta *)sta->drv_priv;
+ mt7915_mcu_add_sta(data->dev, vif, sta, CONN_STATE_DISCONNECT, false);
++ msta->wcid.tx_info &= ~MT_WCID_TX_INFO_SET;
+ msta->wcid.sta_disabled = 1;
+ msta->wcid.sta = 0;
+ }
+@@ -871,6 +872,7 @@ int mt7915_mac_sta_event(struct mt76_dev *mdev, struct ieee80211_vif *vif,
+ mutex_unlock(&dev->mt76.mutex);
+
+ mt7915_mcu_add_sta(dev, vif, sta, CONN_STATE_DISCONNECT, false);
++ msta->wcid.tx_info &= ~MT_WCID_TX_INFO_SET;
+ msta->wcid.sta_disabled = 1;
+ msta->wcid.sta = 0;
+ return 0;
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+index b52b6783306042..8603915ddc2eff 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+@@ -781,7 +781,8 @@ mt7925_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
+ val = FIELD_PREP(MT_TXD1_WLAN_IDX, wcid->idx) |
+ FIELD_PREP(MT_TXD1_OWN_MAC, omac_idx);
+
+- if (band_idx)
++ /* 0xff means BAND_AUTO to the firmware, and TGID cannot encode it */
++ if (band_idx && band_idx != 0xff)
+ val |= FIELD_PREP(MT_TXD1_TGID, band_idx);
+
+ txwi[1] = cpu_to_le32(val);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+index 9f080da13341b3..e6e5c26307a11d 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+@@ -2220,6 +2220,18 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+
+ mvif->valid_links = new_links;
+
++ /* Restore the legacy BSS after disabling MLO */
++ if (old_links && !new_links) {
++ mt792x_mac_link_bss_remove(dev, &mvif->bss_conf,
++ &mvif->sta.deflink);
++ err = mt7925_mac_link_bss_add(dev, &vif->bss_conf,
++ &mvif->sta.deflink);
++ if (err < 0) {
++ mt792x_mutex_release(dev);
++ return err;
++ }
++ }
++
+ mt792x_mutex_release(dev);
+
+ return 0;
+diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
+index 946dd7956e4a0d..ce5d5909d838dd 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
++++ b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
+@@ -108,68 +108,98 @@ mt792x_asar_acpi_read_mtcl(struct mt792x_dev *dev, u8 **table, u8 *version)
+ return ret;
+ }
+
++/* A table's layout is decided by the version byte in MTCL, but some firmware
++ * labels a version 2 table as version 1. Accept whichever layout the table
++ * actually has: for every accepted entry count the two do not overlap, since
++ * one is 6 + 5n bytes and the other 7 + 7n.
++ */
++static bool
++mt792x_asar_fits(u8 *table, int len, int prelen, int sarlen, int nr_off,
++ int min, int max)
++{
++ int tblcnt;
++
++ if (len < prelen || (len - prelen) % sarlen)
++ return false;
++
++ tblcnt = (len - prelen) / sarlen;
++ if (tblcnt < min || tblcnt > max)
++ return false;
++
++ return tblcnt == table[nr_off];
++}
++
+ /* MTDS : Dynamic SAR Power Table */
+ static int
+-mt792x_asar_acpi_read_mtds(struct mt792x_dev *dev, u8 **table, u8 version)
++mt792x_asar_acpi_read_mtds(struct mt792x_dev *dev, u8 **table, u8 version,
++ u8 *used)
+ {
+- int len, ret, sarlen, prelen, tblcnt;
+- bool enable;
++ int len, ret;
++ u8 *t;
+
+ ret = mt792x_acpi_read(dev, MT792x_ACPI_MTDS, table, &len);
+ if (ret)
+ return ret;
+
++ t = *table;
++
+ /* Table content validation */
+- switch (version) {
+- case 1:
+- enable = ((struct mt792x_asar_dyn *)*table)->enable;
+- sarlen = sizeof(struct mt792x_asar_dyn_limit);
+- prelen = sizeof(struct mt792x_asar_dyn);
+- break;
+- case 2:
+- enable = ((struct mt792x_asar_dyn_v2 *)*table)->enable;
+- sarlen = sizeof(struct mt792x_asar_dyn_limit_v2);
+- prelen = sizeof(struct mt792x_asar_dyn_v2);
+- break;
+- default:
++ if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_dyn),
++ sizeof(struct mt792x_asar_dyn_limit),
++ offsetof(struct mt792x_asar_dyn, nr_tbl),
++ MT792x_ASAR_MIN_DYN, MT792x_ASAR_MAX_DYN))
++ *used = 1;
++ else if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_dyn_v2),
++ sizeof(struct mt792x_asar_dyn_limit_v2),
++ offsetof(struct mt792x_asar_dyn_v2, nr_tbl),
++ MT792x_ASAR_MIN_DYN, MT792x_ASAR_MAX_DYN))
++ *used = 2;
++ else
+ return -EINVAL;
+- }
+
+- tblcnt = (len - prelen) / sarlen;
+- if (!enable ||
+- tblcnt > MT792x_ASAR_MAX_DYN || tblcnt < MT792x_ASAR_MIN_DYN)
++ if (!t[offsetof(struct mt792x_asar_dyn, enable)])
+ return -EINVAL;
+
++ if (version && *used != version)
++ dev_info(dev->mt76.dev,
++ "MTDS is v%u, MTCL says v%u; using v%u\n",
++ *used, version, *used);
++
+ return 0;
+ }
+
+ /* MTGS : Geo SAR Power Table */
+ static int
+-mt792x_asar_acpi_read_mtgs(struct mt792x_dev *dev, u8 **table, u8 version)
++mt792x_asar_acpi_read_mtgs(struct mt792x_dev *dev, u8 **table, u8 version,
++ u8 *used)
+ {
+- int len, ret, sarlen, prelen, tblcnt;
++ int len, ret;
++ u8 *t;
+
+ ret = mt792x_acpi_read(dev, MT792x_ACPI_MTGS, table, &len);
+ if (ret)
+ return ret;
+
++ t = *table;
++
+ /* Table content validation */
+- switch (version) {
+- case 1:
+- sarlen = sizeof(struct mt792x_asar_geo_limit);
+- prelen = sizeof(struct mt792x_asar_geo);
+- break;
+- case 2:
+- sarlen = sizeof(struct mt792x_asar_geo_limit_v2);
+- prelen = sizeof(struct mt792x_asar_geo_v2);
+- break;
+- default:
++ if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_geo),
++ sizeof(struct mt792x_asar_geo_limit),
++ offsetof(struct mt792x_asar_geo, nr_tbl),
++ MT792x_ASAR_MIN_GEO, MT792x_ASAR_MAX_GEO))
++ *used = 1;
++ else if (mt792x_asar_fits(t, len, sizeof(struct mt792x_asar_geo_v2),
++ sizeof(struct mt792x_asar_geo_limit_v2),
++ offsetof(struct mt792x_asar_geo_v2, nr_tbl),
++ MT792x_ASAR_MIN_GEO, MT792x_ASAR_MAX_GEO))
++ *used = 2;
++ else
+ return -EINVAL;
+- }
+
+- tblcnt = (len - prelen) / sarlen;
+- if (tblcnt > MT792x_ASAR_MAX_GEO || tblcnt < MT792x_ASAR_MIN_GEO)
+- return -EINVAL;
++ if (version && *used != version)
++ dev_info(dev->mt76.dev,
++ "MTGS is v%u, MTCL says v%u; using v%u\n",
++ *used, version, *used);
+
+ return 0;
+ }
+@@ -205,14 +235,16 @@ int mt792x_init_acpi_sar(struct mt792x_dev *dev)
+ asar->countrylist = NULL;
+ }
+
+- ret = mt792x_asar_acpi_read_mtds(dev, (u8 **)&asar->dyn, asar->ver);
++ ret = mt792x_asar_acpi_read_mtds(dev, (u8 **)&asar->dyn, asar->ver,
++ &asar->dyn_ver);
+ if (ret) {
+ devm_kfree(dev->mt76.dev, asar->dyn);
+ asar->dyn = NULL;
+ }
+
+ /* MTGS is optional */
+- ret = mt792x_asar_acpi_read_mtgs(dev, (u8 **)&asar->geo, asar->ver);
++ ret = mt792x_asar_acpi_read_mtgs(dev, (u8 **)&asar->geo, asar->ver,
++ &asar->geo_ver);
+ if (ret) {
+ devm_kfree(dev->mt76.dev, asar->geo);
+ asar->geo = NULL;
+@@ -254,7 +286,7 @@ mt792x_asar_get_geo_pwr(struct mt792x_phy *phy,
+ break;
+ }
+
+- if (asar->ver == 1) {
++ if (asar->geo_ver == 1) {
+ band_pwr = &asar->geo->tbl[idx].band[0];
+ max = ARRAY_SIZE(asar->geo->tbl[idx].band);
+ } else {
+@@ -279,10 +311,18 @@ mt792x_asar_get_geo_pwr(struct mt792x_phy *phy,
+ if (idx >= max)
+ return dyn_power;
+
+- geo_power = (band_pwr + idx)->pwr;
+- dyn_power += (band_pwr + idx)->offset;
++ band_pwr += idx;
++
++ /* Some OEM tables carry 0xff here; narrowed to s8 that is -1 and
++ * wins the min() below. Take it as no limit.
++ */
++ if (band_pwr->pwr == 0xff)
++ return dyn_power;
++
++ geo_power = band_pwr->pwr;
+
+- return min(geo_power, dyn_power);
++ return min_t(int, geo_power,
++ min_t(int, dyn_power + band_pwr->offset, 127));
+ }
+
+ static s8
+@@ -297,7 +337,7 @@ mt792x_asar_range_pwr(struct mt792x_phy *phy,
+ if (!capa)
+ return 127;
+
+- if (asar->ver == 1) {
++ if (asar->dyn_ver == 1) {
+ limit = &asar->dyn->tbl[0].frp[0];
+ max = ARRAY_SIZE(asar->dyn->tbl[0].frp);
+ } else {
+@@ -315,7 +355,9 @@ mt792x_asar_range_pwr(struct mt792x_phy *phy,
+ else
+ band = NL80211_BAND_2GHZ;
+
+- return mt792x_asar_get_geo_pwr(phy, band, limit[idx]);
++ /* 0xff: no dynamic limit, see mt792x_asar_get_geo_pwr() */
++ return mt792x_asar_get_geo_pwr(phy, band,
++ limit[idx] == 0xff ? 127 : limit[idx]);
+ }
+
+ int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default)
+diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h
+index 47403307383158..1d42f24b05f668 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h
++++ b/drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h
+@@ -105,6 +105,8 @@ struct mt792x_asar_fg {
+
+ struct mt792x_acpi_sar {
+ u8 ver;
++ u8 dyn_ver;
++ u8 geo_ver;
+ union {
+ struct mt792x_asar_dyn *dyn;
+ struct mt792x_asar_dyn_v2 *dyn_v2;
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
+index fa74aba4269037..95fb30404b8579 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
+@@ -536,6 +536,7 @@ mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed)
+ ieee80211_hw_set(hw, NO_VIRTUAL_MONITOR);
+ ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
+ ieee80211_hw_set(hw, CHANCTX_STA_CSA);
++ ieee80211_hw_set(hw, CONNECTION_MONITOR);
+
+ hw->max_tx_fragments = 4;
+ wiphy->txq_memory_limit = 32 << 20; /* 32 MiB */
+@@ -1237,7 +1238,7 @@ static int mt7996_variant_fem_init(struct mt7996_dev *dev)
+ adie_ver = u32_get_bits(regval, MT_ADIE_VERSION_MASK);
+ idx = MT7976C_EFUSE_OFFSET % MT7996_EEPROM_BLOCK_SIZE;
+ is_7976c = adie_ver == 0x8a10 || adie_ver == 0x8b00 ||
+- adie_ver == 0x8c10 || buf[idx] == 0xc;
++ adie_ver == 0x8c10 || (!ret && buf[idx] == 0xc);
+
+ adie_id = u32_get_bits(regval, MT_ADIE_CHIP_ID_MASK);
+ if (adie_id == 0x7975 || adie_id == 0x7979 ||
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+index c6140412ed3227..ae006f29091fff 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+@@ -310,7 +310,14 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
+ if (vif->type == NL80211_IFTYPE_AP)
+ return mt7996_mcu_mld_link_oper(dev, link_conf, link,
+ true);
+- return 0;
++
++ /* update the link address */
++ ret = mt7996_mcu_add_dev_info(phy, vif, link_conf, mlink, true);
++ if (ret)
++ return ret;
++
++ return mt7996_mcu_add_bss_info(phy, vif, link_conf, mlink,
++ msta_link, true);
+ }
+
+ mlink->idx = __ffs64(~dev->mt76.vif_mask);
+@@ -1422,6 +1429,7 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
+ else if (sta->mlo && links == BIT(link_id)) /* last link */
+ mt7996_mcu_teardown_mld_sta(dev, link,
+ msta_link);
++ msta_link->wcid.tx_info &= ~MT_WCID_TX_INFO_SET;
+ msta_link->wcid.sta_disabled = 1;
+ msta_link->wcid.sta = 0;
+ links = links & ~BIT(link_id);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
+index c673e986ecb52a..288b923750c0da 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
++++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h
+@@ -284,6 +284,9 @@ struct mt7996_mcu_wed_rro_ba_delete_event {
+ __le16 len;
+
+ __le16 session_id;
++ __le16 wlan_id;
++ u8 tid;
++ u8 __rsv1;
+ u8 __rsv2[2];
+ } __packed;
+
+diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
+index b03be0eb471282..65703dbb185c98 100644
+--- a/drivers/net/wireless/mediatek/mt76/tx.c
++++ b/drivers/net/wireless/mediatek/mt76/tx.c
+@@ -234,6 +234,8 @@ mt76_tx_check_non_aql(struct mt76_dev *dev, struct mt76_wcid *wcid,
+ if (!wcid || info->tx_time_est)
+ return;
+
++ wcid = mt76_wcid_primary(wcid);
++
+ pending = atomic_dec_return(&wcid->non_aql_packets);
+ if (pending < 0)
+ atomic_cmpxchg(&wcid->non_aql_packets, pending, 0);
+@@ -267,6 +269,21 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *
+ wcid = __mt76_wcid_ptr(dev, wcid_idx);
+ mt76_tx_check_non_aql(dev, wcid, skb);
+
++ if (wcid && (dev->drv->drv_flags & MT_DRV_HW_PS_BUFFERING) &&
++ test_bit(MT_WCID_FLAG_PS, &wcid->flags)) {
++ struct ieee80211_sta *sta = wcid_to_sta(wcid);
++
++ if (sta) {
++ struct ieee80211_hw *hw = mt76_phy_hw(dev, wcid->phy_idx);
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
++ if (sta->txq[i])
++ ieee80211_schedule_txq(hw, sta->txq[i]);
++ mt76_worker_schedule(&dev->tx_worker);
++ }
++ }
++
+ #ifdef CONFIG_NL80211_TESTMODE
+ if (mt76_is_testmode_skb(dev, skb, &hw)) {
+ struct mt76_phy *phy = hw->priv;
+@@ -329,7 +346,8 @@ __mt76_tx_queue_skb(struct mt76_phy *phy, int qid, struct sk_buff *skb,
+ if (!non_aql)
+ return idx;
+
+- pending = atomic_inc_return(&wcid->non_aql_packets);
++ /* the hardware can report the completion on a different link */
++ pending = atomic_inc_return(&mt76_wcid_primary(wcid)->non_aql_packets);
+ if (stop && pending >= MT_MAX_NON_AQL_PKT)
+ *stop = true;
+
+@@ -476,10 +494,15 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q,
+ bool stop = false;
+ int idx;
+
+- if (test_bit(MT_WCID_FLAG_PS, &wcid->flags))
+- return 0;
++ if (test_bit(MT_WCID_FLAG_PS, &wcid->flags)) {
++ if (!(dev->drv->drv_flags & MT_DRV_HW_PS_BUFFERING))
++ return 0;
++ if (ieee80211_txq_aql_pending(phy->hw, txq))
++ return 0;
++ }
+
+- if (atomic_read(&wcid->non_aql_packets) >= MT_MAX_NON_AQL_PKT)
++ if (atomic_read(&mt76_wcid_primary(wcid)->non_aql_packets) >=
++ MT_MAX_NON_AQL_PKT)
+ return 0;
+
+ skb = mt76_txq_dequeue(phy, mtxq);
+@@ -497,6 +520,9 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q,
+ if (idx < 0)
+ return idx;
+
++ if (test_bit(MT_WCID_FLAG_PS, &wcid->flags))
++ goto out;
++
+ do {
+ if (test_bit(MT76_RESET, &phy->state) || phy->offchannel)
+ break;
+@@ -522,6 +548,7 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q,
+ n_frames++;
+ } while (1);
+
++out:
+ spin_lock(&q->lock);
+ dev->queue_ops->kick(dev, q);
+ spin_unlock(&q->lock);
+@@ -548,10 +575,7 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
+
+ mtxq = (struct mt76_txq *)txq->drv_priv;
+ wcid = __mt76_wcid_ptr(dev, mtxq->wcid);
+- if (!wcid || test_bit(MT_WCID_FLAG_PS, &wcid->flags))
+- continue;
+-
+- if (atomic_read(&wcid->non_aql_packets) >= MT_MAX_NON_AQL_PKT)
++ if (!wcid)
+ continue;
+
+ phy = mt76_dev_phy(dev, wcid->phy_idx);
+@@ -559,6 +583,25 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid)
+ continue;
+
+ q = phy->q_tx[qid];
++
++ if (test_bit(MT_WCID_FLAG_PS, &wcid->flags)) {
++ if (!(dev->drv->drv_flags & MT_DRV_HW_PS_BUFFERING))
++ continue;
++
++ if (!mt76_txq_stopped(q))
++ n_frames = mt76_txq_send_burst(phy, q, mtxq, wcid);
++
++ ieee80211_return_txq(phy->hw, txq, false);
++
++ if (unlikely(n_frames < 0))
++ return n_frames;
++ ret += n_frames;
++ continue;
++ }
++
++ if (atomic_read(&mt76_wcid_primary(wcid)->non_aql_packets) >=
++ MT_MAX_NON_AQL_PKT)
++ continue;
+ if (dev->queue_ops->tx_cleanup &&
+ q->queued + 2 * MT_TXQ_FREE_THR >= q->ndesc) {
+ dev->queue_ops->tx_cleanup(dev, q, false);
+@@ -629,7 +672,8 @@ mt76_txq_schedule_pending_wcid(struct mt76_phy *phy, struct mt76_wcid *wcid,
+ if ((dev->drv->drv_flags & MT_DRV_HW_MGMT_TXQ) &&
+ !(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) &&
+ !ieee80211_is_data_present(hdr->frame_control) &&
+- (!ieee80211_is_bufferable_mmpdu(skb) ||
++ (!(wcid->tx_info & MT_WCID_TX_INFO_SET) ||
++ !ieee80211_is_bufferable_mmpdu(skb) ||
+ ieee80211_is_deauth(hdr->frame_control) ||
+ ieee80211_is_disassoc(hdr->frame_control) ||
+ head == &wcid->tx_offchannel))
+@@ -765,6 +809,33 @@ void mt76_stop_tx_queues(struct mt76_phy *phy, struct ieee80211_sta *sta,
+ }
+ EXPORT_SYMBOL_GPL(mt76_stop_tx_queues);
+
++void mt76_sta_ps_transition(struct mt76_dev *dev, struct mt76_wcid *wcid,
++ bool ps)
++{
++ struct ieee80211_sta *sta;
++ struct ieee80211_hw *hw;
++ int i;
++
++ if (ps) {
++ set_bit(MT_WCID_FLAG_PS, &wcid->flags);
++ mt76_worker_schedule(&dev->tx_worker);
++ return;
++ }
++
++ clear_bit(MT_WCID_FLAG_PS, &wcid->flags);
++
++ sta = wcid_to_sta(wcid);
++ if (!sta)
++ return;
++
++ hw = mt76_phy_hw(dev, wcid->phy_idx);
++ for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
++ if (sta->txq[i])
++ ieee80211_schedule_txq(hw, sta->txq[i]);
++ mt76_worker_schedule(&dev->tx_worker);
++}
++EXPORT_SYMBOL_GPL(mt76_sta_ps_transition);
++
+ void mt76_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *txq)
+ {
+ struct mt76_phy *phy = hw->priv;
+diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
+index d269457e839ea9..fdcb91042f2906 100644
+--- a/drivers/net/xen-netfront.c
++++ b/drivers/net/xen-netfront.c
+@@ -1346,8 +1346,10 @@ err:
+ skb->data_len = rx->status;
+ skb->len += rx->status;
+
+- if (unlikely(xennet_fill_frags(queue, skb, &tmpq)))
++ if (unlikely(xennet_fill_frags(queue, skb, &tmpq))) {
++ __skb_queue_head(&tmpq, skb);
+ goto err;
++ }
+
+ if (rx->flags & XEN_NETRXF_csum_blank)
+ skb->ip_summed = CHECKSUM_PARTIAL;
+diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
+index 2aa9ded7d55148..0b1f800c6cc8fd 100644
+--- a/drivers/nvme/target/core.c
++++ b/drivers/nvme/target/core.c
+@@ -1310,7 +1310,7 @@ static int nvmet_req_alloc_p2pmem_sgls(struct pci_dev *p2p_dev,
+
+ return 0;
+ out_free_sg:
+- pci_p2pmem_free_sgl(req->p2p_dev, req->sg);
++ pci_p2pmem_free_sgl(p2p_dev, req->sg);
+ out_err:
+ return -ENOMEM;
+ }
+diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
+index ad07f55e7f173f..acb44df15fc7ea 100644
+--- a/drivers/nvme/target/pr.c
++++ b/drivers/nvme/target/pr.c
+@@ -51,6 +51,8 @@ u16 nvmet_set_feat_resv_notif_mask(struct nvmet_req *req, u32 mask)
+
+ if (nsid != U32_MAX) {
+ status = nvmet_req_find_ns(req);
++ if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
++ return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
+ if (status)
+ return status;
+ if (!req->ns->pr.enable)
+@@ -75,6 +77,8 @@ u16 nvmet_get_feat_resv_notif_mask(struct nvmet_req *req)
+ u16 status;
+
+ status = nvmet_req_find_ns(req);
++ if (status == (NVME_SC_INVALID_NS | NVME_STATUS_DNR))
++ return NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
+ if (status)
+ return status;
+
+diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
+index 99d100e1d923f5..62c4f829605c64 100644
+--- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c
++++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c
+@@ -15,6 +15,7 @@
+ #include
+ #include
+ #include
++#include
+
+ #include
+ #include
+@@ -34,6 +35,12 @@ struct imx8m_blk_ctrl {
+ struct regmap *regmap;
+ struct imx8m_blk_ctrl_domain *domains;
+ struct genpd_onecell_data onecell_data;
++ /*
++ * Serializes the blk-ctrl reset/clock sequence across sibling domains;
++ * their transitions interact through the shared VPUMIX bus domain,
++ * VPU_NOC and the not-ack-verified ADB400 handshake (ERR050531).
++ */
++ struct mutex power_lock;
+ };
+
+ struct imx8m_blk_ctrl_domain_data {
+@@ -98,6 +105,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
+ struct imx8m_blk_ctrl *bc = domain->bc;
+ int ret;
+
++ guard(mutex)(&bc->power_lock);
++
+ /* make sure bus domain is awake */
+ ret = pm_runtime_get_sync(bc->bus_power_dev);
+ if (ret < 0) {
+@@ -164,6 +173,8 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
+ const struct imx8m_blk_ctrl_domain_data *data = domain->data;
+ struct imx8m_blk_ctrl *bc = domain->bc;
+
++ guard(mutex)(&bc->power_lock);
++
+ /* put devices into reset and disable clocks */
+ if (data->mipi_phy_rst_mask)
+ regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+@@ -202,6 +213,10 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev)
+
+ bc->dev = dev;
+
++ ret = devm_mutex_init(dev, &bc->power_lock);
++ if (ret)
++ return ret;
++
+ bc_data = of_device_get_match_data(dev);
+
+ base = devm_platform_ioremap_resource(pdev, 0);
+diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
+index 490bbb1d1d8e8f..b57581b367a90b 100644
+--- a/drivers/pmdomain/rockchip/pm-domains.c
++++ b/drivers/pmdomain/rockchip/pm-domains.c
+@@ -745,7 +745,19 @@ static int rockchip_pd_attach_dev(struct generic_pm_domain *genpd,
+ }
+
+ i = 0;
+- while ((clk = of_clk_get(dev->of_node, i++)) && !IS_ERR(clk)) {
++ while (1) {
++ clk = of_clk_get(dev->of_node, i++);
++ if (IS_ERR(clk)) {
++ error = PTR_ERR(clk);
++ if (error == -ENOENT)
++ break;
++
++ dev_err(dev, "failed to get clock %d: %d\n", i - 1,
++ error);
++ pm_clk_destroy(dev);
++ return error;
++ }
++
+ dev_dbg(dev, "adding clock '%pC' to list of PM clocks\n", clk);
+ error = pm_clk_add_clk(dev, clk);
+ if (error) {
+@@ -828,7 +840,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
+ dev_err(pmu->dev,
+ "%pOFn: failed to get clk at index %d: %d\n",
+ node, i, error);
+- return error;
++ goto err_put_clocks;
+ }
+ }
+
+@@ -1004,7 +1016,9 @@ static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
+ parent_domain->name, child_domain->name);
+ }
+
+- rockchip_pm_add_subdomain(pmu, np);
++ error = rockchip_pm_add_subdomain(pmu, np);
++ if (error)
++ return error;
+ }
+
+ return 0;
+diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
+index ddfe6ca824945e..c59c487c43e306 100644
+--- a/drivers/power/sequencing/pwrseq-pcie-m2.c
++++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
+@@ -562,6 +562,7 @@ err_destroy_mutex:
+ mutex_destroy(&ctx->list_lock);
+ err_free_regulators:
+ regulator_bulk_free(ctx->num_vregs, ctx->regs);
++ kfree(ctx->regs);
+
+ return ret;
+ }
+@@ -575,6 +576,7 @@ static void pwrseq_pcie_m2_remove(struct platform_device *pdev)
+ mutex_destroy(&ctx->list_lock);
+
+ regulator_bulk_free(ctx->num_vregs, ctx->regs);
++ kfree(ctx->regs);
+ }
+
+ static const struct of_device_id pwrseq_pcie_m2_of_match[] = {
+diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
+index 3d26ec1f7b9ec2..a8cba2f64b98ae 100644
+--- a/drivers/ptp/ptp_ocp.c
++++ b/drivers/ptp/ptp_ocp.c
+@@ -1825,7 +1825,7 @@ ptp_ocp_watchdog(struct timer_list *t)
+ static void
+ ptp_ocp_estimate_pci_timing(struct ptp_ocp *bp)
+ {
+- ktime_t start, end, delay = U64_MAX;
++ ktime_t start, end, delay = KTIME_MAX;
+ u32 ctrl;
+ int i;
+
+diff --git a/drivers/regulator/ltc3676.c b/drivers/regulator/ltc3676.c
+index 768cdce0d4ecfb..1ec218951829d2 100644
+--- a/drivers/regulator/ltc3676.c
++++ b/drivers/regulator/ltc3676.c
+@@ -232,7 +232,7 @@ static const struct regulator_desc ltc3676_regulators[LTC3676_NUM_REGULATORS] =
+ LTC3676_FIXED_REG(LDO4, ldo4, LDOB, 2),
+ };
+
+-static bool ltc3676_readable_writeable_reg(struct device *dev, unsigned int reg)
++static bool ltc3676_writeable_reg(struct device *dev, unsigned int reg)
+ {
+ switch (reg) {
+ case LTC3676_BUCK1 ... LTC3676_IRQSTAT:
+@@ -243,6 +243,15 @@ static bool ltc3676_readable_writeable_reg(struct device *dev, unsigned int reg)
+ return false;
+ }
+
++static bool ltc3676_readable_reg(struct device *dev, unsigned int reg)
++{
++ switch (reg) {
++ case LTC3676_BUCK1 ... LTC3676_IRQSTAT:
++ return true;
++ }
++ return false;
++}
++
+ static bool ltc3676_volatile_reg(struct device *dev, unsigned int reg)
+ {
+ switch (reg) {
+@@ -255,8 +264,8 @@ static bool ltc3676_volatile_reg(struct device *dev, unsigned int reg)
+ static const struct regmap_config ltc3676_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+- .writeable_reg = ltc3676_readable_writeable_reg,
+- .readable_reg = ltc3676_readable_writeable_reg,
++ .writeable_reg = ltc3676_writeable_reg,
++ .readable_reg = ltc3676_readable_reg,
+ .volatile_reg = ltc3676_volatile_reg,
+ .max_register = LTC3676_CLIRQ,
+ .use_single_read = true,
+diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
+index c0cc6cc0afd8bf..785b7a11dfc660 100644
+--- a/drivers/regulator/of_regulator.c
++++ b/drivers/regulator/of_regulator.c
+@@ -935,15 +935,15 @@ static int is_supply_name(const char *name)
+ int of_regulator_bulk_get_all(struct device *dev, struct device_node *np,
+ struct regulator_bulk_data **consumers)
+ {
+- int num_consumers = 0;
++ int num_consumers = 0, names_len = 0;
+ struct regulator *tmp;
+ struct regulator_bulk_data *_consumers = NULL;
+ struct property *prop;
++ char *names;
+ int i, n = 0, ret;
+- char name[64];
+
+ /*
+- * first pass: get numbers of xxx-supply
++ * first pass: get numbers of xxx-supply and the room their names take
+ * second pass: fill consumers
+ */
+ restart:
+@@ -953,16 +953,19 @@ restart:
+ continue;
+ if (!_consumers) {
+ num_consumers++;
++ names_len += i + 1;
+ continue;
+ } else {
+- memcpy(name, prop->name, i);
+- name[i] = '\0';
+- tmp = regulator_get(dev, name);
++ memcpy(names, prop->name, i);
++ names[i] = '\0';
++ tmp = regulator_get(dev, names);
+ if (IS_ERR(tmp)) {
+ ret = PTR_ERR(tmp);
+ goto error;
+ }
++ _consumers[n].supply = names;
+ _consumers[n].consumer = tmp;
++ names += i + 1;
+ n++;
+ continue;
+ }
+@@ -973,9 +976,16 @@ restart:
+ }
+ if (num_consumers == 0)
+ return 0;
+- _consumers = kmalloc_objs(struct regulator_bulk_data, num_consumers);
++ /*
++ * The supply names are kept in the same allocation as the array, so
++ * that they share its lifetime and the caller has nothing extra to
++ * free.
++ */
++ _consumers = kzalloc(size_add(size_mul(num_consumers, sizeof(*_consumers)),
++ names_len), GFP_KERNEL);
+ if (!_consumers)
+ return -ENOMEM;
++ names = (char *)(_consumers + num_consumers);
+ goto restart;
+
+ error:
+diff --git a/drivers/regulator/tps6594-regulator.c b/drivers/regulator/tps6594-regulator.c
+index 31a5218d551059..503b89a2f5f810 100644
+--- a/drivers/regulator/tps6594-regulator.c
++++ b/drivers/regulator/tps6594-regulator.c
+@@ -241,21 +241,21 @@ static const struct regulator_desc tps65224_buck_regs[] = {
+ TPS65224_MASK_BUCKS_VSET,
+ TPS6594_REG_BUCKX_CTRL(1),
+ TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges,
+- 4, 0, 0, NULL, 0, 0),
++ ARRAY_SIZE(tps65224_bucks_2_3_4_ranges), 0, 0, NULL, 0, 0),
+ TPS6594_REGULATOR("BUCK3", "buck3", TPS6594_BUCK_3,
+ REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET,
+ TPS6594_REG_BUCKX_VOUT_1(2),
+ TPS65224_MASK_BUCKS_VSET,
+ TPS6594_REG_BUCKX_CTRL(2),
+ TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges,
+- 4, 0, 0, NULL, 0, 0),
++ ARRAY_SIZE(tps65224_bucks_2_3_4_ranges), 0, 0, NULL, 0, 0),
+ TPS6594_REGULATOR("BUCK4", "buck4", TPS6594_BUCK_4,
+ REGULATOR_VOLTAGE, tps6594_bucks_ops, TPS65224_MASK_BUCKS_VSET,
+ TPS6594_REG_BUCKX_VOUT_1(3),
+ TPS65224_MASK_BUCKS_VSET,
+ TPS6594_REG_BUCKX_CTRL(3),
+ TPS6594_BIT_BUCK_EN, 0, 0, tps65224_bucks_2_3_4_ranges,
+- 4, 0, 0, NULL, 0, 0),
++ ARRAY_SIZE(tps65224_bucks_2_3_4_ranges), 0, 0, NULL, 0, 0),
+ };
+
+ static const struct tps6594_regulator_irq_type tps6594_buck1_irq_types[] = {
+diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
+index 4010fdbf813cc7..c36539c83ed1a4 100644
+--- a/drivers/scsi/ch.c
++++ b/drivers/scsi/ch.c
+@@ -112,7 +112,6 @@ typedef struct {
+ int minor;
+ char name[8];
+ struct scsi_device *device;
+- struct scsi_device **dt; /* ptrs to data transfer elements */
+ u_int firsts[CH_TYPES];
+ u_int counts[CH_TYPES];
+ u_int voltags;
+@@ -363,15 +362,10 @@ ch_readconfig(scsi_changer *ch)
+ vendor_labels[i]);
+ }
+
+- /* look up the devices of the data transfer elements */
+- ch->dt = kzalloc_objs(*ch->dt, ch->counts[CHET_DT]);
+-
+- if (!ch->dt) {
+- kfree(buffer);
+- return -ENOMEM;
+- }
+-
++ /* report the devices of the data transfer elements */
+ for (elem = 0; elem < ch->counts[CHET_DT]; elem++) {
++ struct scsi_device *sdev;
++
+ id = -1;
+ lun = 0;
+ if (elem < CH_DT_MAX && -1 != dt_id[elem]) {
+@@ -387,10 +381,8 @@ ch_readconfig(scsi_changer *ch)
+ VPRINTK(KERN_INFO, "dt 0x%x: ",elem+ch->firsts[CHET_DT]);
+ if (data[6] & 0x80) {
+ VPRINTK(KERN_CONT, "not this SCSI bus\n");
+- ch->dt[elem] = NULL;
+ } else if (0 == (data[6] & 0x30)) {
+ VPRINTK(KERN_CONT, "ID/LUN unknown\n");
+- ch->dt[elem] = NULL;
+ } else {
+ id = ch->device->id;
+ lun = 0;
+@@ -400,18 +392,16 @@ ch_readconfig(scsi_changer *ch)
+ }
+ if (-1 != id) {
+ VPRINTK(KERN_CONT, "ID %i, LUN %i, ",id,lun);
+- ch->dt[elem] =
+- scsi_device_lookup(ch->device->host,
+- ch->device->channel,
+- id,lun);
+- if (!ch->dt[elem]) {
++ sdev = scsi_device_lookup(ch->device->host,
++ ch->device->channel,
++ id, lun);
++ if (!sdev) {
+ /* should not happen */
+ VPRINTK(KERN_CONT, "Huh? device not found!\n");
+ } else {
+ VPRINTK(KERN_CONT, "name: %8.8s %16.16s %4.4s\n",
+- ch->dt[elem]->vendor,
+- ch->dt[elem]->model,
+- ch->dt[elem]->rev);
++ sdev->vendor, sdev->model, sdev->rev);
++ scsi_device_put(sdev);
+ }
+ }
+ }
+@@ -575,7 +565,6 @@ static void ch_destroy(struct kref *ref)
+ scsi_changer *ch = container_of(ref, scsi_changer, ref);
+
+ ch->device = NULL;
+- kfree(ch->dt);
+ kfree(ch);
+ }
+
+diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
+index 227ff7bd1bdc9b..f394fcbb97e7ee 100644
+--- a/drivers/scsi/qedi/qedi_main.c
++++ b/drivers/scsi/qedi/qedi_main.c
+@@ -2652,8 +2652,6 @@ retry_probe:
+ snprintf(host_buf, sizeof(host_buf), "host_%d", qedi->shost->host_no);
+ qedi_ops->common->set_name(qedi->cdev, host_buf);
+
+- qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi);
+-
+ memset(¶ms, 0, sizeof(params));
+ params.mtu = DEF_PATH_MTU + IPV6_HDR_LEN + TCP_HDR_LEN;
+ qedi->ll2_mtu = DEF_PATH_MTU;
+@@ -2670,6 +2668,7 @@ retry_probe:
+ spin_lock_init(&qedi->task_idx_lock);
+ mutex_init(&qedi->stats_lock);
+ }
++ qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi);
+ qedi_ops->ll2->register_cb_ops(qedi->cdev, &qedi_ll2_cb_ops, qedi);
+ qedi_ops->ll2->start(qedi->cdev, ¶ms);
+
+diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
+index 4425132432ec87..e0c88e9f81833b 100644
+--- a/drivers/spi/spi-nxp-fspi.c
++++ b/drivers/spi/spi-nxp-fspi.c
+@@ -898,10 +898,10 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
+ dev_dbg(f->dev, "Target device [CS:%x] selected\n", spi_get_chipselect(spi, 0));
+
+ /*
+- * Per the FlexSPI reference manual (initialization sequence), MCR0 and
+- * the DLL control registers should be configured while the module is in
+- * stop mode (MCR0[MDIS] = 1). Enter stop mode before reconfiguring the
+- * RX sample clock source and the DLL, then exit stop mode afterwards.
++ * Per the FlexSPI reference manual (initialization sequence), MCR0
++ * should be configured while the module is in stop mode (MCR0[MDIS] = 1).
++ * Enter stop mode before reconfiguring the RX sample clock source, then
++ * exit stop mode afterwards.
+ */
+ reg = fspi_readl(f, f->iobase + FSPI_MCR0);
+ fspi_writel(f, reg | FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0);
+@@ -936,6 +936,16 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
+ if (ret)
+ return ret;
+
++ /*
++ * Exit stop mode before running the DLL calibration. The DLL
++ * reference clock is derived from the module clock domain, which is
++ * gated while MCR0[MDIS] = 1. Calibrating the DLL in stop mode leaves
++ * the STS2 lock bits stuck at 0 (the DLL never runs), so clear MDIS
++ * first and let the module and reference clock run.
++ */
++ reg = fspi_readl(f, f->iobase + FSPI_MCR0);
++ fspi_writel(f, reg & ~FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0);
++
+ /*
+ * If clock rate > 100MHz, then switch from DLL override mode to
+ * DLL calibration mode.
+@@ -945,10 +955,6 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
+ else
+ nxp_fspi_dll_override(f);
+
+- /* Exit stop mode now that MCR0 and the DLL have been reconfigured. */
+- reg = fspi_readl(f, f->iobase + FSPI_MCR0);
+- fspi_writel(f, reg & ~FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0);
+-
+ f->pre_op_rate = op->max_freq;
+
+ f->selected = spi_get_chipselect(spi, 0);
+diff --git a/drivers/spi/spi-sg2044-nor.c b/drivers/spi/spi-sg2044-nor.c
+index f3bcb8a1b92bb1..bc9a8ee9bce448 100644
+--- a/drivers/spi/spi-sg2044-nor.c
++++ b/drivers/spi/spi-sg2044-nor.c
+@@ -307,15 +307,15 @@ static ssize_t sg2044_spifmc_tran_cmd(struct sg2044_spifmc *spifmc,
+ return 0;
+ }
+
+-static void sg2044_spifmc_trans(struct sg2044_spifmc *spifmc,
+- const struct spi_mem_op *op)
++static int sg2044_spifmc_trans(struct sg2044_spifmc *spifmc,
++ const struct spi_mem_op *op)
+ {
+ if (op->data.dir == SPI_MEM_DATA_IN)
+- sg2044_spifmc_read(spifmc, op);
++ return sg2044_spifmc_read(spifmc, op);
+ else if (op->data.dir == SPI_MEM_DATA_OUT)
+- sg2044_spifmc_write(spifmc, op);
++ return sg2044_spifmc_write(spifmc, op);
+ else
+- sg2044_spifmc_tran_cmd(spifmc, op);
++ return sg2044_spifmc_tran_cmd(spifmc, op);
+ }
+
+ static ssize_t sg2044_spifmc_trans_reg(struct sg2044_spifmc *spifmc,
+@@ -385,29 +385,64 @@ static ssize_t sg2044_spifmc_trans_reg(struct sg2044_spifmc *spifmc,
+ return 0;
+ }
+
++static int sg2044_spifmc_set_speed(struct sg2044_spifmc *spifmc,
++ unsigned int speed_hz)
++{
++ unsigned long rate = clk_get_rate(spifmc->clk);
++ u64 div;
++ u32 reg;
++
++ if (!rate)
++ return -EINVAL;
++
++ /* SCK = HCLK / (2 * (SckDiv + 1)); round down the resulting SCK. */
++ div = speed_hz ? DIV_ROUND_UP_ULL(rate, 2ULL * speed_hz) : 1;
++ if (div > SPIFMC_CTRL_SCK_DIV_MASK + 1)
++ return -EINVAL;
++
++ reg = readl(spifmc->io_base + SPIFMC_CTRL);
++ reg &= ~SPIFMC_CTRL_SCK_DIV_MASK;
++ reg |= div - 1;
++ writel(reg, spifmc->io_base + SPIFMC_CTRL);
++
++ return 0;
++}
++
+ static int sg2044_spifmc_exec_op(struct spi_mem *mem,
+ const struct spi_mem_op *op)
+ {
+ struct sg2044_spifmc *spifmc;
++ int ret;
+
+ spifmc = spi_controller_get_devdata(mem->spi->controller);
+
+ mutex_lock(&spifmc->lock);
+
++ ret = sg2044_spifmc_set_speed(spifmc, op->max_freq ?
++ min(op->max_freq, mem->spi->max_speed_hz) :
++ mem->spi->max_speed_hz);
++ if (ret)
++ goto out_unlock;
++
+ if (op->addr.nbytes == 0)
+- sg2044_spifmc_trans_reg(spifmc, op);
++ ret = sg2044_spifmc_trans_reg(spifmc, op);
+ else
+- sg2044_spifmc_trans(spifmc, op);
++ ret = sg2044_spifmc_trans(spifmc, op);
+
++out_unlock:
+ mutex_unlock(&spifmc->lock);
+
+- return 0;
++ return ret;
+ }
+
+ static const struct spi_controller_mem_ops sg2044_spifmc_mem_ops = {
+ .exec_op = sg2044_spifmc_exec_op,
+ };
+
++static const struct spi_controller_mem_caps sg2044_spifmc_mem_caps = {
++ .per_op_freq = true,
++};
++
+ static void sg2044_spifmc_init(struct sg2044_spifmc *spifmc)
+ {
+ u32 tran_csr;
+@@ -447,6 +482,10 @@ static int sg2044_spifmc_probe(struct platform_device *pdev)
+ if (IS_ERR(spifmc->clk))
+ return dev_err_probe(dev, PTR_ERR(spifmc->clk), "Cannot get and enable AHB clock\n");
+
++ ctrl->max_speed_hz = clk_get_rate(spifmc->clk) / 2;
++ if (!ctrl->max_speed_hz)
++ return dev_err_probe(dev, -EINVAL, "Invalid AHB clock rate\n");
++
+ spifmc->dev = &pdev->dev;
+ spifmc->ctrl = ctrl;
+
+@@ -458,6 +497,7 @@ static int sg2044_spifmc_probe(struct platform_device *pdev)
+ ctrl->bits_per_word_mask = SPI_BPW_MASK(8);
+ ctrl->auto_runtime_pm = false;
+ ctrl->mem_ops = &sg2044_spifmc_mem_ops;
++ ctrl->mem_caps = &sg2044_spifmc_mem_caps;
+ ctrl->mode_bits = SPI_RX_DUAL | SPI_TX_DUAL | SPI_RX_QUAD | SPI_TX_QUAD;
+
+ ret = devm_mutex_init(dev, &spifmc->lock);
+diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
+index 633715b98625cd..d027fe7ce86fd7 100644
+--- a/drivers/tee/optee/ffa_abi.c
++++ b/drivers/tee/optee/ffa_abi.c
+@@ -198,7 +198,8 @@ static int to_msg_param_ffa_mem(struct optee_msg_param *mp,
+ if (shm) {
+ u64 shm_offs = p->u.memref.shm_offs;
+
+- mp->u.fmem.internal_offs = shm->offset;
++ mp->u.fmem.internal_offs = tee_shm_get_page_offset(shm) &
++ (FFA_PAGE_SIZE - 1);
+
+ mp->u.fmem.offs_low = shm_offs;
+ mp->u.fmem.offs_high = shm_offs >> 32;
+@@ -284,14 +285,26 @@ static int optee_ffa_shm_register(struct tee_context *ctx, struct tee_shm *shm,
+ .nattrs = 1,
+ };
+ struct sg_table sgt;
++ size_t ffa_offs;
+ int rc;
+
++ if (!num_pages)
++ return -EINVAL;
++
+ rc = optee_check_mem_type(start, num_pages);
+ if (rc)
+ return rc;
+
+- rc = sg_alloc_table_from_pages(&sgt, pages, num_pages, 0,
+- num_pages * PAGE_SIZE, GFP_KERNEL);
++ /*
++ * Start the FF-A descriptor at the 4 KiB page containing the shared
++ * buffer, skipping unused leading 4 KiB pages when PAGE_SIZE is
++ * larger. Same approach as optee_fill_pages_list() in the SMC ABI.
++ * This leaves only the offset into that 4 KiB page for internal_offs.
++ */
++ ffa_offs = round_down(tee_shm_get_page_offset(shm), FFA_PAGE_SIZE);
++ rc = sg_alloc_table_from_pages(&sgt, pages, num_pages, ffa_offs,
++ num_pages * PAGE_SIZE - ffa_offs,
++ GFP_KERNEL);
+ if (rc)
+ return rc;
+ args.sg = sgt.sgl;
+@@ -458,7 +471,8 @@ static void handle_ffa_rpc_func_cmd_shm_alloc(struct tee_context *ctx,
+ .attr = OPTEE_MSG_ATTR_TYPE_FMEM_OUTPUT,
+ .u.fmem.size = tee_shm_get_size(shm),
+ .u.fmem.global_id = shm->sec_world_id,
+- .u.fmem.internal_offs = shm->offset,
++ .u.fmem.internal_offs = tee_shm_get_page_offset(shm) &
++ (FFA_PAGE_SIZE - 1),
+ };
+
+ arg->ret = TEEC_SUCCESS;
+@@ -1123,14 +1137,6 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
+
+ optee_set_dev_group(optee);
+
+- rc = tee_device_register(optee->teedev);
+- if (rc)
+- goto err_unreg_supp_teedev;
+-
+- rc = tee_device_register(optee->supp_teedev);
+- if (rc)
+- goto err_unreg_supp_teedev;
+-
+ rc = rhashtable_init(&optee->ffa.global_ids, &shm_rhash_params);
+ if (rc)
+ goto err_unreg_supp_teedev;
+@@ -1159,6 +1165,14 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
+ if (optee_ffa_protmem_pool_init(optee, sec_caps))
+ pr_info("Protected memory service not available\n");
+
++ rc = tee_device_register(optee->teedev);
++ if (rc)
++ goto err_unregister_devices;
++
++ rc = tee_device_register(optee->supp_teedev);
++ if (rc)
++ goto err_unregister_devices;
++
+ rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES);
+ if (rc)
+ goto err_unregister_devices;
+diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h
+index 7d9b12e71c0354..6c3043f8da33c6 100644
+--- a/drivers/tee/optee/optee_msg.h
++++ b/drivers/tee/optee/optee_msg.h
+@@ -136,8 +136,8 @@ struct optee_msg_param_rmem {
+ * struct optee_msg_param_fmem - FF-A memory reference parameter
+ * @offs_low: lower bits of offset into shared memory reference
+ * @offs_high: higher bits of offset into shared memory reference
+- * @internal_offs: internal offset into the first page of shared memory
+- * reference
++ * @internal_offs: offset into the first 4 KiB page of the FF-A shared
++ * memory region
+ * @size: size of the buffer
+ * @global_id: global identifier of the shared memory
+ */
+diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
+index b8a2bdac3208f9..51624443359bfb 100644
+--- a/drivers/tee/optee/smc_abi.c
++++ b/drivers/tee/optee/smc_abi.c
+@@ -1849,14 +1849,6 @@ static int optee_probe(struct platform_device *pdev)
+
+ optee_set_dev_group(optee);
+
+- rc = tee_device_register(optee->teedev);
+- if (rc)
+- goto err_unreg_supp_teedev;
+-
+- rc = tee_device_register(optee->supp_teedev);
+- if (rc)
+- goto err_unreg_supp_teedev;
+-
+ optee_cq_init(&optee->call_queue, thread_count);
+ optee_supp_init(&optee->supp);
+ optee->smc.memremaped_shm = memremaped_shm;
+@@ -1916,6 +1908,14 @@ static int optee_probe(struct platform_device *pdev)
+ if (optee->smc.sec_caps & OPTEE_SMC_SEC_CAP_DYNAMIC_SHM)
+ pr_info("dynamic shared memory is enabled\n");
+
++ rc = tee_device_register(optee->teedev);
++ if (rc)
++ goto err_disable_shm_cache;
++
++ rc = tee_device_register(optee->supp_teedev);
++ if (rc)
++ goto err_disable_shm_cache;
++
+ rc = optee_enumerate_devices(PTA_CMD_GET_DEVICES);
+ if (rc)
+ goto err_disable_shm_cache;
+@@ -1942,7 +1942,6 @@ err_supp_uninit:
+ optee_shm_arg_cache_uninit(optee);
+ optee_supp_uninit(&optee->supp);
+ mutex_destroy(&optee->call_queue.mutex);
+-err_unreg_supp_teedev:
+ tee_device_unregister(optee->supp_teedev);
+ err_unreg_teedev:
+ tee_device_unregister(optee->teedev);
+diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
+index 6742b3579c86d6..daa4af1e089e59 100644
+--- a/drivers/tee/tee_shm.c
++++ b/drivers/tee/tee_shm.c
+@@ -343,6 +343,10 @@ int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align,
+ unsigned int i;
+ int rc = 0;
+
++ /* get_order(0) is undefined and exceeds MAX_PAGE_ORDER. */
++ if (!nr_pages)
++ return -EINVAL;
++
+ /*
+ * Ignore alignment since this is already going to be page aligned
+ * and there's no need for any larger alignment.
+diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
+index 13b60a2d06db6a..967b51ca57a0e6 100644
+--- a/drivers/ufs/core/ufs-mcq.c
++++ b/drivers/ufs/core/ufs-mcq.c
+@@ -306,20 +306,24 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba, struct cq_entry *cqe)
+ return div_u64(addr, ufshcd_get_ucd_size(hba));
+ }
+
++static void ufshcd_mcq_compl_cqe(struct ufs_hba *hba, struct cq_entry *cqe)
++{
++ int tag = ufshcd_mcq_get_tag(hba, cqe);
++
++ ufshcd_compl_one_cqe(hba, tag, cqe);
++ /* After processing the CQE, mark it as an empty (invalid) entry. */
++ cqe->command_desc_base_addr = 0;
++}
++
+ static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
+ struct ufs_hw_queue *hwq)
+ {
+ struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq);
+
+- if (cqe->command_desc_base_addr) {
+- int tag = ufshcd_mcq_get_tag(hba, cqe);
+-
+- ufshcd_compl_one_cqe(hba, tag, cqe);
+- /* After processed the cqe, mark it empty (invalid) entry */
+- cqe->command_desc_base_addr = 0;
+- } else {
++ if (cqe->command_desc_base_addr)
++ ufshcd_mcq_compl_cqe(hba, cqe);
++ else
+ dev_err(hba->dev, "Abnormal CQ entry!\n");
+- }
+ }
+
+ /*
+@@ -327,7 +331,7 @@ static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
+ * controller disabled (HCE = 0). Reading host controller registers, e.g. the
+ * CQ tail pointer (CQTPy), may not be safe with the host controller disabled.
+ * Hence, iterate over all completion queue entries. This won't result in
+- * double completions because ufshcd_mcq_process_cqe() clears a CQE after it
++ * double completions because ufshcd_mcq_compl_cqe() clears a CQE after it
+ * has been processed.
+ */
+ void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
+@@ -338,13 +342,13 @@ void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
+
+ spin_lock_irqsave(&hwq->cq_lock, flags);
+ while (entries > 0) {
+- ufshcd_mcq_process_cqe(hba, hwq);
++ struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq);
++
++ if (cqe->command_desc_base_addr)
++ ufshcd_mcq_compl_cqe(hba, cqe);
+ ufshcd_mcq_inc_cq_head_slot(hwq);
+ entries--;
+ }
+-
+- ufshcd_mcq_update_cq_tail_slot(hwq);
+- hwq->cq_head_slot = hwq->cq_tail_slot;
+ spin_unlock_irqrestore(&hwq->cq_lock, flags);
+ }
+
+diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
+index bc33da89af2679..0a9366f21483fe 100644
+--- a/drivers/ufs/core/ufshcd.c
++++ b/drivers/ufs/core/ufshcd.c
+@@ -5975,8 +5975,6 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv)
+ if (blk_mq_is_reserved_rq(rq) || !hwq)
+ return true;
+
+- ufshcd_mcq_compl_all_cqes_lock(hba, hwq);
+-
+ /*
+ * For those cmds of which the cqes are not present in the cq, complete
+ * them explicitly.
+@@ -5992,19 +5990,6 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv)
+ return true;
+ }
+
+-static bool ufshcd_mcq_compl_one(struct request *rq, void *priv)
+-{
+- struct scsi_device *sdev = rq->q->queuedata;
+- struct Scsi_Host *shost = sdev->host;
+- struct ufs_hba *hba = shost_priv(shost);
+- struct ufs_hw_queue *hwq = ufshcd_mcq_req_to_hwq(hba, rq);
+-
+- if (!blk_mq_is_reserved_rq(rq) && hwq)
+- ufshcd_mcq_poll_cqe_lock(hba, hwq);
+-
+- return true;
+-}
+-
+ /**
+ * ufshcd_mcq_compl_pending_transfer - MCQ mode function. It is
+ * invoked from the error handler context or ufshcd_host_reset_and_restore()
+@@ -6019,10 +6004,18 @@ static bool ufshcd_mcq_compl_one(struct request *rq, void *priv)
+ static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba,
+ bool force_compl)
+ {
+- blk_mq_tagset_busy_iter(&hba->host->tag_set,
+- force_compl ? ufshcd_mcq_force_compl_one :
+- ufshcd_mcq_compl_one,
+- NULL);
++ int i;
++
++ for (i = 0; i < hba->nr_hw_queues; i++) {
++ if (force_compl)
++ ufshcd_mcq_compl_all_cqes_lock(hba, &hba->uhq[i]);
++ else
++ ufshcd_mcq_poll_cqe_lock(hba, &hba->uhq[i]);
++ }
++
++ if (force_compl)
++ blk_mq_tagset_busy_iter(&hba->host->tag_set,
++ ufshcd_mcq_force_compl_one, NULL);
+ }
+
+ /**
+@@ -9491,6 +9484,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
+ ret = ufshcd_add_lus(hba);
+
+ out:
++ ufshcd_release(hba);
+ pm_runtime_put_sync(hba->dev);
+
+ if (ret)
+@@ -11213,6 +11207,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
+
+ ufshcd_init_clk_gating(hba);
+
++ /* Released by ufshcd_async_scan(), or by out_release on failure. */
++ ufshcd_hold(hba);
++
+ ufshcd_init_clk_scaling(hba);
+
+ /*
+@@ -11233,7 +11230,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
+ err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba);
+ if (err) {
+ dev_err(hba->dev, "request irq failed\n");
+- goto out_disable;
++ goto out_release;
+ } else {
+ hba->is_irq_enabled = true;
+ }
+@@ -11249,7 +11246,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
+ dev_err(hba->dev, "Host controller enable failed\n");
+ ufshcd_print_evt_hist(hba);
+ ufshcd_print_host_state(hba);
+- goto out_disable;
++ goto out_release;
+ }
+
+ INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, ufshcd_rpm_dev_flush_recheck_work);
+@@ -11263,7 +11260,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
+
+ err = ufshcd_add_scsi_host(hba);
+ if (err)
+- goto out_disable;
++ goto out_release;
+
+ /* Hold auto suspend until async scan completes */
+ pm_runtime_get_sync(dev);
+@@ -11283,7 +11280,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
+
+ err = ufshcd_link_startup(hba);
+ if (err)
+- goto out_disable;
++ goto out_release;
+
+ if (hba->mcq_enabled)
+ ufshcd_config_mcq(hba);
+@@ -11300,23 +11297,23 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
+ /* Verify device initialization by sending NOP OUT UPIU */
+ err = ufshcd_verify_dev_init(hba);
+ if (err)
+- goto out_disable;
++ goto out_release;
+
+ /* Initiate UFS initialization, and waiting until completion */
+ err = ufshcd_complete_dev_init(hba);
+ if (err)
+- goto out_disable;
++ goto out_release;
+
+ err = ufshcd_device_params_init(hba);
+ if (err)
+- goto out_disable;
++ goto out_release;
+
+ err = ufshcd_post_device_init(hba);
+
+ initialized:
+ ufshcd_process_probe_result(hba, probe_start, err);
+ if (err)
+- goto out_disable;
++ goto out_release;
+
+ ufs_sysfs_add_nodes(hba->dev);
+ hba->dme_qos_sysfs_handle = sysfs_get_dirent(hba->dev->kobj.sd,
+@@ -11327,6 +11324,8 @@ initialized:
+ ufshcd_pm_qos_init(hba);
+ return 0;
+
++out_release:
++ ufshcd_release(hba);
+ out_disable:
+ hba->is_irq_enabled = false;
+ ufshcd_hba_exit(hba);
+diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
+index 3991a51263a6d5..a2defbe3b7483c 100644
+--- a/drivers/ufs/host/ufs-mediatek.c
++++ b/drivers/ufs/host/ufs-mediatek.c
+@@ -509,6 +509,7 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
+ struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+ struct phy *mphy = host->mphy;
+ struct arm_smccc_res res;
++ int err;
+ int ret = 0;
+
+ if (!mphy || !(on ^ host->mphy_powered_on))
+@@ -523,7 +524,18 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
+ usleep_range(200, 210);
+ ufs_mtk_va09_pwr_ctrl(res, 1);
+ }
+- phy_power_on(mphy);
++ ret = phy_power_on(mphy);
++ if (ret) {
++ if (ufs_mtk_is_va09_supported(hba)) {
++ ufs_mtk_va09_pwr_ctrl(res, 0);
++ err = regulator_disable(host->reg_va09);
++ if (err)
++ dev_err(hba->dev,
++ "failed to unwind va09: %d\n", err);
++ }
++ dev_err(hba->dev, "failed to enable mphy: %d\n", ret);
++ return ret;
++ }
+ } else {
+ phy_power_off(mphy);
+ if (ufs_mtk_is_va09_supported(hba)) {
+@@ -1295,7 +1307,9 @@ static int ufs_mtk_init(struct ufs_hba *hba)
+ *
+ * Enable phy clocks specifically here.
+ */
+- ufs_mtk_mphy_power_on(hba, true);
++ err = ufs_mtk_mphy_power_on(hba, true);
++ if (err)
++ goto out_variant_clear;
+
+ if (ufs_mtk_is_rtff_mtcmos(hba)) {
+ /* First Restore here, to avoid backup unexpected value */
+diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
+index 7fe0a63d690a35..579b82e27b5acb 100644
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -9622,7 +9622,6 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
+ struct completion sync_reads;
+ unsigned long i = 0;
+ struct btrfs_bio *bbio;
+- int ret;
+
+ /*
+ * Fast path for synchronous reads which completes in this call, io_uring
+@@ -9669,10 +9668,10 @@ int btrfs_encoded_read_regular_fill_pages(struct btrfs_inode *inode,
+
+ if (uring_ctx) {
+ if (refcount_dec_and_test(&priv->pending_refs)) {
+- ret = blk_status_to_errno(READ_ONCE(priv->status));
+- btrfs_uring_read_extent_endio(uring_ctx, ret);
++ int error = blk_status_to_errno(READ_ONCE(priv->status));
++
++ btrfs_uring_read_extent_endio(uring_ctx, error);
+ kfree(priv);
+- return ret;
+ }
+
+ return -EIOCBQUEUED;
+diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
+index a537036303a476..833052306964b1 100644
+--- a/fs/btrfs/ioctl.c
++++ b/fs/btrfs/ioctl.c
+@@ -4559,7 +4559,7 @@ static void btrfs_uring_read_finished(struct io_tw_req tw_req, io_tw_token_t tw)
+ size_t page_offset;
+ ssize_t ret;
+
+- /* The inode lock has already been acquired in btrfs_uring_read_extent. */
++ /* The inode lock has already been acquired in btrfs_encoded_read(). */
+ btrfs_lockdep_inode_acquire(inode, i_rwsem);
+
+ if (priv->err) {
+@@ -4625,7 +4625,6 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
+ struct iovec *iov, struct io_uring_cmd *cmd)
+ {
+ struct btrfs_inode *inode = BTRFS_I(file_inode(iocb->ki_filp));
+- struct extent_io_tree *io_tree = &inode->io_tree;
+ struct page **pages = NULL;
+ struct btrfs_uring_priv *priv = NULL;
+ unsigned long nr_pages;
+@@ -4681,8 +4680,6 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
+ return -EIOCBQUEUED;
+
+ out_fail:
+- btrfs_unlock_extent(io_tree, start, lockend, &cached_state);
+- btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
+ kfree(priv);
+ for (int i = 0; i < nr_pages; i++) {
+ if (pages[i])
+@@ -4795,7 +4792,7 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
+ ret = btrfs_encoded_read(&kiocb, &data->iter, &data->args, &cached_state,
+ &disk_bytenr, &disk_io_size);
+ if (ret == -EAGAIN)
+- goto out_acct;
++ goto out_free;
+ if (ret < 0 && ret != -EIOCBQUEUED)
+ goto out_free;
+
+@@ -4823,8 +4820,10 @@ static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
+ cached_state, disk_bytenr, disk_io_size,
+ count, data->args.compression,
+ data->iov, cmd);
+-
+- goto out_acct;
++ if (ret == -EIOCBQUEUED)
++ goto out_acct;
++ btrfs_unlock_extent(io_tree, start, lockend, &cached_state);
++ btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
+ }
+
+ out_free:
+@@ -4835,8 +4834,10 @@ out_acct:
+ add_rchar(current, ret);
+ inc_syscr(current);
+
+- if (ret != -EIOCBQUEUED && ret != -EAGAIN)
++ if (ret != -EIOCBQUEUED) {
+ kfree(data);
++ bc->data = NULL;
++ }
+
+ return ret;
+ }
+@@ -4865,6 +4866,11 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
+ goto out_acct;
+ }
+
++ if (issue_flags & IO_URING_F_NONBLOCK) {
++ ret = -EAGAIN;
++ goto out_acct;
++ }
++
+ if (!data) {
+ data = kzalloc_obj(*data, GFP_NOFS);
+ if (!data) {
+@@ -4933,11 +4939,6 @@ static int btrfs_uring_encoded_write(struct io_uring_cmd *cmd, unsigned int issu
+ }
+ }
+
+- if (issue_flags & IO_URING_F_NONBLOCK) {
+- ret = -EAGAIN;
+- goto out_acct;
+- }
+-
+ pos = data->args.offset;
+ ret = rw_verify_area(WRITE, file, &pos, data->args.len);
+ if (ret < 0)
+@@ -4963,8 +4964,8 @@ out_acct:
+ add_wchar(current, ret);
+ inc_syscw(current);
+
+- if (ret != -EAGAIN)
+- kfree(data);
++ kfree(data);
++ bc->data = NULL;
+ return ret;
+ }
+
+diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
+index 3b3f04521369d7..9db8f8b6d3d544 100644
+--- a/fs/btrfs/scrub.c
++++ b/fs/btrfs/scrub.c
+@@ -550,8 +550,10 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
+ }
+ ret = paths_from_inode(inum, ipath);
+
+- if (ret < 0)
++ if (ret < 0) {
++ btrfs_put_root(local_root);
+ goto err;
++ }
+
+ /*
+ * we deliberately ignore the bit ipath might have been too small to
+diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
+index ab55d10bd71fdb..cb001a211f5575 100644
+--- a/fs/btrfs/xattr.c
++++ b/fs/btrfs/xattr.c
+@@ -161,6 +161,7 @@ int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode,
+ const u16 old_data_len = btrfs_dir_data_len(leaf, di);
+ const u32 item_size = btrfs_item_size(leaf, slot);
+ const u32 data_size = sizeof(*di) + name_len + size;
++ unsigned long name_ptr;
+ unsigned long data_ptr;
+ char *ptr;
+
+@@ -189,8 +190,16 @@ int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode,
+ ptr = btrfs_item_ptr(leaf, slot, char);
+ ptr += btrfs_item_size(leaf, slot) - data_size;
+ di = (struct btrfs_dir_item *)ptr;
++ memzero_extent_buffer(leaf, (unsigned long)ptr +
++ offsetof(struct btrfs_dir_item, location),
++ sizeof(struct btrfs_disk_key));
++ btrfs_set_dir_flags(leaf, di, BTRFS_FT_XATTR);
++ btrfs_set_dir_transid(leaf, di, trans->transid);
++ btrfs_set_dir_name_len(leaf, di, name_len);
+ btrfs_set_dir_data_len(leaf, di, size);
++ name_ptr = (unsigned long)(di + 1);
+ data_ptr = ((unsigned long)(di + 1)) + name_len;
++ write_extent_buffer(leaf, name, name_ptr, name_len);
+ write_extent_buffer(leaf, value, data_ptr, size);
+ } else {
+ /*
+@@ -320,10 +329,8 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
+ if (!size)
+ goto next;
+
+- if (!buffer || (name_len + 1) > size_left) {
+- iter_ret = -ERANGE;
+- break;
+- }
++ if (!buffer || (name_len + 1) > size_left)
++ return -ERANGE;
+
+ read_extent_buffer(leaf, buffer, name_ptr, name_len);
+ buffer[name_len] = '\0';
+diff --git a/fs/dcache.c b/fs/dcache.c
+index 073c2ce2d44486..d6fbb4fa7dbc50 100644
+--- a/fs/dcache.c
++++ b/fs/dcache.c
+@@ -1583,6 +1583,8 @@ EXPORT_SYMBOL(path_has_submounts);
+ *
+ * Only one of d_invalidate() and d_set_mounted() must succeed. For
+ * this reason take rename_lock and d_lock on dentry and ancestors.
++ * Likewise for dont_mount() which marks a dentry that is being removed
++ * under d_lock.
+ */
+ int d_set_mounted(struct dentry *dentry)
+ {
+@@ -1599,7 +1601,7 @@ int d_set_mounted(struct dentry *dentry)
+ spin_unlock(&p->d_lock);
+ }
+ spin_lock(&dentry->d_lock);
+- if (!d_unlinked(dentry)) {
++ if (!d_unlinked(dentry) && !cant_mount(dentry)) {
+ ret = -EBUSY;
+ if (!d_mountpoint(dentry)) {
+ dentry->d_flags |= DCACHE_MOUNTED;
+diff --git a/fs/fcntl.c b/fs/fcntl.c
+index c158f082f1da4f..9b71bc9d71d159 100644
+--- a/fs/fcntl.c
++++ b/fs/fcntl.c
+@@ -372,6 +372,9 @@ static long fcntl_set_rw_hint(struct file *file, unsigned long arg)
+ u64 __user *argp = (u64 __user *)arg;
+ u64 hint;
+
++ /* nothing is ever written to it */
++ if (IS_IMMUTABLE(inode))
++ return -EPERM;
+ if (!inode_owner_or_capable(file_mnt_idmap(file), inode))
+ return -EPERM;
+
+diff --git a/fs/fs_context.c b/fs/fs_context.c
+index 23ad66cd94e1f9..a50584df97bea7 100644
+--- a/fs/fs_context.c
++++ b/fs/fs_context.c
+@@ -315,6 +315,10 @@ struct fs_context *fs_context_for_reconfigure(struct dentry *dentry,
+ unsigned int sb_flags,
+ unsigned int sb_flags_mask)
+ {
++ /* kernel-internal superblocks are nobody's to reconfigure */
++ if (dentry->d_sb->s_flags & SB_NOUSER)
++ return ERR_PTR(-EINVAL);
++
+ return alloc_fs_context(dentry->d_sb->s_type, dentry, sb_flags,
+ sb_flags_mask, FS_CONTEXT_FOR_RECONFIGURE);
+ }
+diff --git a/fs/inode.c b/fs/inode.c
+index c6b08e8c5f6277..efa801f3eb1106 100644
+--- a/fs/inode.c
++++ b/fs/inode.c
+@@ -763,21 +763,18 @@ void clear_inode(struct inode *inode)
+ fsverity_cleanup_inode(inode);
+
+ /*
+- * We have to cycle the i_pages lock here because reclaim can be in the
+- * process of removing the last page (in __filemap_remove_folio())
+- * and we must not free the mapping under it.
++ * We have to cycle the i_pages lock here because reclaim
++ * can be in the process of removing the last page (in
++ * __filemap_remove_folio()) and we must not free the mapping
++ * under it. We also remove nodes which are empty; these
++ * can occur in two different ways. The first is that radix
++ * tree expansion can fail partway and the second is that THP
++ * collapse_file() can allocate some temporary nodes and not
++ * clean them up.
+ */
+- xa_lock_irq(&inode->i_data.i_pages);
++ xa_destroy(&inode->i_data.i_pages);
++
+ BUG_ON(inode->i_data.nrpages);
+- /*
+- * Almost always, mapping_empty(&inode->i_data) here; but there are
+- * two known and long-standing ways in which nodes may get left behind
+- * (when deep radix-tree node allocation failed partway; or when THP
+- * collapse_file() failed). Until those two known cases are cleaned up,
+- * or a cleanup function is called here, do not BUG_ON(!mapping_empty),
+- * nor even WARN_ON(!mapping_empty).
+- */
+- xa_unlock_irq(&inode->i_data.i_pages);
+ BUG_ON(!(inode_state_read_once(inode) & I_FREEING));
+ BUG_ON(inode_state_read_once(inode) & I_CLEAR);
+ BUG_ON(!list_empty(&inode->i_wb_list));
+diff --git a/fs/mount.h b/fs/mount.h
+index 94fcc306d21e7d..2223fb141499fe 100644
+--- a/fs/mount.h
++++ b/fs/mount.h
+@@ -33,7 +33,8 @@ struct mnt_namespace {
+ } __randomize_layout;
+
+ struct mnt_pcp {
+- int mnt_count;
++ unsigned int mnt_gets;
++ unsigned int mnt_puts;
+ int mnt_writers;
+ };
+
+@@ -233,6 +234,9 @@ static inline struct mnt_namespace *to_mnt_ns(struct ns_common *ns)
+ #ifdef CONFIG_FSNOTIFY
+ static inline void mnt_notify_add(struct mount *m)
+ {
++ /* queued already under this namespace_sem hold */
++ if (!list_empty(&m->to_notify))
++ return;
+ /* Optimize the case where there are no watches */
+ if ((m->mnt_ns && m->mnt_ns->n_fsnotify_marks) ||
+ (m->prev_ns && m->prev_ns->n_fsnotify_marks))
+diff --git a/fs/namei.c b/fs/namei.c
+index 19ce43c9a6e662..27e0637bfdda2a 100644
+--- a/fs/namei.c
++++ b/fs/namei.c
+@@ -2086,6 +2086,33 @@ all_done: // pure jump
+ return NULL;
+ }
+
++/*
++ * Be careful in case the dentry is unlinked or renamed. Any mounts
++ * stacked on top of it are going away. We need to make sure that we
++ * don't reveal the underyling dentry during refwalk. In rcuwalk we
++ * catch this via d_seq and another lookup for the name. Give the same
++ * guarantee in refwalk.
++ */
++static bool unlink_may_reveal(struct nameidata *nd, int flags,
++ struct path *path, struct dentry *dentry)
++{
++ /* ".." and LOOKUP_DOWN may land on an unhashed directory */
++ if (flags & WALK_NOFOLLOW)
++ return false;
++ if (nd->flags & LOOKUP_REVAL)
++ return false;
++ /* We crossed onto a mount and the name led us here while it still existed */
++ if (path->mnt != nd->path.mnt)
++ return false;
++ /* only a name on its way out is flagged */
++ if (likely(!cant_mount(dentry)))
++ return false;
++ if (!d_unlinked(dentry))
++ return false;
++ dput(no_free_ptr(path->dentry));
++ return true;
++}
++
+ /*
+ * Do we need to follow links? We _really_ want to be able
+ * to do this check without having to look at inode->i_op,
+@@ -2115,6 +2142,8 @@ static noinline const char *step_into_slowpath(struct nameidata *nd, int flags,
+ if (unlikely(!inode))
+ return ERR_PTR(-ENOENT);
+ } else {
++ if (unlikely(unlink_may_reveal(nd, flags, &path, dentry)))
++ return ERR_PTR(-ESTALE);
+ dput(nd->path.dentry);
+ if (nd->path.mnt != path.mnt)
+ mntput(nd->path.mnt);
+diff --git a/fs/namespace.c b/fs/namespace.c
+index 3d5cd5bf3b0537..ec93bdac9e7894 100644
+--- a/fs/namespace.c
++++ b/fs/namespace.c
+@@ -130,7 +130,6 @@ static void mnt_ns_release(struct mnt_namespace *ns)
+ {
+ /* keep alive for {list,stat}mount() */
+ if (ns && refcount_dec_and_test(&ns->passive)) {
+- fsnotify_mntns_delete(ns);
+ put_user_ns(ns->user_ns);
+ kfree(ns);
+ }
+@@ -249,16 +248,24 @@ void mnt_release_group_id(struct mount *mnt)
+ mnt->mnt_group_id = 0;
+ }
+
+-/*
+- * vfsmount lock must be held for read
+- */
+-static inline void mnt_add_count(struct mount *mnt, int n)
++static inline void mnt_inc_count(struct mount *mnt)
+ {
+ #ifdef CONFIG_SMP
+- this_cpu_add(mnt->mnt_pcp->mnt_count, n);
++ this_cpu_inc(mnt->mnt_pcp->mnt_gets);
+ #else
+ preempt_disable();
+- mnt->mnt_count += n;
++ mnt->mnt_count++;
++ preempt_enable();
++#endif
++}
++
++static inline void mnt_dec_count(struct mount *mnt)
++{
++#ifdef CONFIG_SMP
++ this_cpu_inc(mnt->mnt_pcp->mnt_puts);
++#else
++ preempt_disable();
++ mnt->mnt_count--;
+ preempt_enable();
+ #endif
+ }
+@@ -269,14 +276,17 @@ static inline void mnt_add_count(struct mount *mnt, int n)
+ int mnt_get_count(struct mount *mnt)
+ {
+ #ifdef CONFIG_SMP
+- int count = 0;
++ unsigned int gets = 0, puts = 0;
+ int cpu;
+
+- for_each_possible_cpu(cpu) {
+- count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count;
+- }
++ /* puts first, so a put counted here has its get counted below */
++ for_each_possible_cpu(cpu)
++ puts += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_puts;
++ smp_mb(); /* pairs with the smp_wmb() in mntput_no_expire() */
++ for_each_possible_cpu(cpu)
++ gets += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_gets;
+
+- return count;
++ return gets - puts;
+ #else
+ return mnt->mnt_count;
+ #endif
+@@ -305,7 +315,7 @@ static struct mount *alloc_vfsmnt(const char *name)
+ if (!mnt->mnt_pcp)
+ goto out_free_devname;
+
+- this_cpu_add(mnt->mnt_pcp->mnt_count, 1);
++ this_cpu_inc(mnt->mnt_pcp->mnt_gets);
+ #else
+ mnt->mnt_count = 1;
+ mnt->mnt_writers = 0;
+@@ -322,6 +332,9 @@ static struct mount *alloc_vfsmnt(const char *name)
+ INIT_HLIST_NODE(&mnt->mnt_mp_list);
+ INIT_HLIST_HEAD(&mnt->mnt_stuck_children);
+ INIT_HLIST_NODE(&mnt->mnt_ns_visible);
++#ifdef CONFIG_FSNOTIFY
++ INIT_LIST_HEAD(&mnt->to_notify);
++#endif
+ RB_CLEAR_NODE(&mnt->mnt_node);
+ mnt->mnt.mnt_idmap = &nop_mnt_idmap;
+ }
+@@ -746,13 +759,13 @@ int __legitimize_mnt(struct vfsmount *bastard, unsigned seq)
+ if (bastard == NULL)
+ return 0;
+ mnt = real_mount(bastard);
+- mnt_add_count(mnt, 1);
+- smp_mb(); // see mntput_no_expire() and do_umount()
++ mnt_inc_count(mnt);
++ smp_mb(); /* see mntput_no_expire_slowpath() and do_umount() */
+ if (likely(!read_seqretry(&mount_lock, seq)))
+ return 0;
+ lock_mount_hash();
+ if (unlikely(bastard->mnt_flags & (MNT_SYNC_UMOUNT | MNT_DOOMED))) {
+- mnt_add_count(mnt, -1);
++ mnt_dec_count(mnt);
+ unlock_mount_hash();
+ return 1;
+ }
+@@ -1058,7 +1071,10 @@ static void attach_mnt(struct mount *mnt, struct mount *parent,
+ void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp, struct mount *mnt)
+ {
+ struct mountpoint *old_mp = mnt->mnt_mp;
++ struct mount *old_parent = mnt->mnt_parent;
+
++ if (old_parent->overmount == mnt)
++ old_parent->overmount = NULL;
+ list_del_init(&mnt->mnt_child);
+ hlist_del_init(&mnt->mnt_mp_list);
+ hlist_del_init_rcu(&mnt->mnt_hash);
+@@ -1254,6 +1270,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
+
+ mnt->mnt.mnt_flags = READ_ONCE(old->mnt.mnt_flags) &
+ ~MNT_INTERNAL_FLAGS;
++ mnt->mnt_t_flags = old->mnt_t_flags & T_UNBINDABLE;
+
+ if (flag & (CL_SLAVE | CL_PRIVATE))
+ mnt->mnt_group_id = 0; /* not a peer of original */
+@@ -1347,7 +1364,7 @@ static void noinline mntput_no_expire_slowpath(struct mount *mnt)
+ * mount_lock, we'll see their refcount increment here.
+ */
+ smp_mb();
+- mnt_add_count(mnt, -1);
++ mnt_dec_count(mnt);
+ count = mnt_get_count(mnt);
+ if (count != 0) {
+ WARN_ON(count < 0);
+@@ -1404,7 +1421,8 @@ static void mntput_no_expire(struct mount *mnt)
+ * non-NULL under rcu_read_lock(), the reference
+ * we are dropping is not the final one.
+ */
+- mnt_add_count(mnt, -1);
++ smp_wmb(); /* pairs with the smp_mb() in mnt_get_count() */
++ mnt_dec_count(mnt);
+ rcu_read_unlock();
+ return;
+ }
+@@ -1426,7 +1444,7 @@ EXPORT_SYMBOL(mntput);
+ struct vfsmount *mntget(struct vfsmount *mnt)
+ {
+ if (mnt)
+- mnt_add_count(real_mount(mnt), 1);
++ mnt_inc_count(real_mount(mnt));
+ return mnt;
+ }
+ EXPORT_SYMBOL(mntget);
+@@ -1783,6 +1801,8 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
+
+ /* Gather the mounts to umount */
+ for (p = mnt; p; p = next_mnt(p, mnt)) {
++ /* A mount is unmounted once. */
++ VFS_WARN_ON_ONCE(p->mnt.mnt_flags & MNT_UMOUNT);
+ p->mnt.mnt_flags |= MNT_UMOUNT;
+ if (mnt_ns_attached(p))
+ move_from_ns(p);
+@@ -1976,6 +1996,9 @@ out:
+ * detach_mounts allows lazily unmounting those mounts instead of
+ * leaking them.
+ *
++ * The dentry is unhashed before the mounts go so that no lookup finds
++ * what they covered. The caller removes it for good afterwards.
++ *
+ * The caller may hold dentry->d_inode->i_rwsem.
+ */
+ void __detach_mounts(struct dentry *dentry)
+@@ -1989,6 +2012,8 @@ void __detach_mounts(struct dentry *dentry)
+ if (!lookup_mountpoint(dentry, &mp))
+ return;
+
++ /* the name goes first, what covered it goes second */
++ d_drop(dentry);
+ event++;
+ while (mp.node.next) {
+ mnt = hlist_entry(mp.node.next, struct mount, mnt_mp_list);
+@@ -2345,6 +2370,18 @@ bool has_locked_children(struct mount *mnt, struct dentry *dentry)
+ return __has_locked_children(mnt, dentry);
+ }
+
++/* locks: namespace_shared && pinned(mnt) || mount_locked_reader */
++static bool __has_children(struct mount *mnt, struct dentry *dentry)
++{
++ struct mount *child;
++
++ list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) {
++ if (is_subdir(child->mnt_mountpoint, dentry))
++ return true;
++ }
++ return false;
++}
++
+ /*
+ * Check that there aren't references to earlier/same mount namespaces in the
+ * specified subtree. Such references can act as pins for mount namespaces
+@@ -2564,11 +2601,11 @@ enum mnt_tree_flags_t {
+ static int attach_recursive_mnt(struct mount *source_mnt,
+ const struct pinned_mountpoint *dest)
+ {
+- struct user_namespace *user_ns = current->nsproxy->mnt_ns->user_ns;
+ struct mount *dest_mnt = dest->parent;
+ struct mountpoint *dest_mp = dest->mp;
+ HLIST_HEAD(tree_list);
+ struct mnt_namespace *ns = dest_mnt->mnt_ns;
++ struct user_namespace *user_ns = ns->user_ns;
+ struct pinned_mountpoint root = {};
+ struct mountpoint *shorter = NULL;
+ struct mount *child, *p;
+@@ -2577,13 +2614,31 @@ static int attach_recursive_mnt(struct mount *source_mnt,
+ int err = 0;
+ bool moving = mnt_has_parent(source_mnt);
+
++ /*
++ * A caller in an unprivileged mount namespaces may trigger an
++ * automount and propagate locked mounts into privileged mount
++ * namespaces. Take ownership from the target mount namespace.
++ * It's equivalent for everything but the automount case.
++ *
++ * Detached trees in anonymous mount namespaces by be handed
++ * over via SCM_RIGHTS or inherited in other ways on purpose
++ * the attaching task's mount namespace is authoritative, not
++ * the creator of the detached tree.
++ */
++ if (is_anon_ns(ns))
++ user_ns = current->nsproxy->mnt_ns->user_ns;
++ else
++ user_ns = ns->user_ns;
++
+ /*
+ * Preallocate a mountpoint in case the new mounts need to be
+ * mounted beneath mounts on the same mountpoint.
+ */
+- for (top = source_mnt; unlikely(top->overmount); top = top->overmount) {
++ for (top = source_mnt; ; top = top->overmount) {
+ if (!shorter && is_mnt_ns_file(top->mnt.mnt_root))
+ shorter = top->mnt_mp;
++ if (likely(!top->overmount))
++ break;
+ }
+ err = get_mountpoint(top->mnt.mnt_root, &root);
+ if (err)
+@@ -2654,15 +2709,17 @@ static int attach_recursive_mnt(struct mount *source_mnt,
+ /*
+ * If @q was locked it was meant to hide
+ * whatever was under it. Let @child take over
+- * that job and lock it, then we can unlock @q.
+- * That'll allow another namespace to shed @q
+- * and reveal @child. Clearly, that mounter
+- * consented to this by not severing the mount
+- * relationship. Otherwise, what's the point.
++ * that job and lock it. If @child is the mount
++ * the caller placed we can then unlock @q:
++ * nothing another namespace does removes it
++ * again. A propagated copy goes away when the
++ * mounter of the original unmounts it, so @q
++ * keeps its lock.
+ */
+ if (IS_MNT_LOCKED(q)) {
+ child->mnt.mnt_flags |= MNT_LOCKED;
+- q->mnt.mnt_flags &= ~MNT_LOCKED;
++ if (child == source_mnt)
++ q->mnt.mnt_flags &= ~MNT_LOCKED;
+ }
+ mnt_change_mountpoint(r, mp, q);
+ }
+@@ -2986,6 +3043,13 @@ static struct mount *__do_loopback(const struct path *old_path,
+ if (!may_copy_tree(old_path))
+ return ERR_PTR(-EINVAL);
+
++ /* a pseudo dentry is freed without an RCU delay, no walk may find it */
++ if (old_path->dentry->d_flags & DCACHE_NORCU)
++ return ERR_PTR(-EINVAL);
++
++ if (recurse && !old->mnt_ns)
++ return ERR_PTR(-EINVAL);
++
+ if (!recurse && __has_locked_children(old, old_path->dentry))
+ return ERR_PTR(-EINVAL);
+
+@@ -3025,7 +3089,11 @@ static int do_loopback(const struct path *path, const char *old_name,
+ if (IS_ERR(mnt))
+ return PTR_ERR(mnt);
+
+- err = graft_tree(mnt, &mp);
++ /* the copy may carry mount namespace files from below the source */
++ if (recurse && !check_for_nsfs_mounts(mnt))
++ err = -EINVAL;
++ else
++ err = graft_tree(mnt, &mp);
+ if (err) {
+ lock_mount_hash();
+ umount_tree(mnt, UMOUNT_SYNC);
+@@ -3107,12 +3175,18 @@ static struct mnt_namespace *create_new_namespace(struct path *path,
+ struct mount *mnt;
+ unsigned int copy_flags = 0;
+ bool locked = false, recurse = flags & MOUNT_COPY_RECURSIVE;
++ bool foreign = user_ns != ns->user_ns;
+
+ if (unlikely(!d_can_lookup(path->dentry)))
+ return ERR_PTR(-ENOTDIR);
+
+- if (user_ns != ns->user_ns)
+- copy_flags |= CL_SLAVE;
++ /*
++ * Without privileges over the mount namespace the copy is made from
++ * nothing mounted below @path may be left out. It would reveal what
++ * it covers. That's what unshare() gives such a caller as well.
++ */
++ if (foreign)
++ copy_flags |= CL_SLAVE | CL_COPY_UNBINDABLE;
+
+ new_ns = alloc_mnt_ns(user_ns, false);
+ if (IS_ERR(new_ns))
+@@ -3146,10 +3220,14 @@ static struct mnt_namespace *create_new_namespace(struct path *path,
+ /*
+ * We don't emulate unshare()ing a mount namespace. We stick to
+ * the restrictions of creating detached bind-mounts. It has a
+- * lot saner and simpler semantics.
++ * lot saner and simpler semantics. A caller without privileges
++ * over the mount namespace can't leave out any child though.
+ */
+ if (flags & MOUNT_COPY_NEW)
+ mnt = clone_mnt(real_mount(path->mnt), path->dentry, copy_flags);
++ else if (foreign && !recurse &&
++ __has_children(real_mount(path->mnt), path->dentry))
++ mnt = ERR_PTR(-EINVAL);
+ else
+ mnt = __do_loopback(path, recurse, copy_flags);
+ scoped_guard(mount_writer) {
+@@ -3166,7 +3244,7 @@ static struct mnt_namespace *create_new_namespace(struct path *path,
+ * of the real rootfs we created.
+ */
+ attach_mnt(mnt, new_ns_root, mp.mp);
+- if (user_ns != ns->user_ns)
++ if (foreign)
+ lock_mnt_tree(new_ns_root);
+ }
+
+@@ -3464,7 +3542,7 @@ static int do_set_group(const struct path *from_path, const struct path *to_path
+ return -EINVAL;
+
+ /* Setting sharing groups is only allowed on private mounts */
+- if (IS_MNT_SHARED(to) || IS_MNT_SLAVE(to))
++ if (IS_MNT_SHARED(to) || IS_MNT_SLAVE(to) || IS_MNT_UNBINDABLE(to))
+ return -EINVAL;
+
+ /* From should not be private */
+@@ -3736,7 +3814,7 @@ static int do_add_mount(struct mount *newmnt, const struct pinned_mountpoint *mp
+ if (!(mnt_flags & MNT_SHRINKABLE))
+ return -EINVAL;
+ /* ... and for those we'd better have mountpoint still alive */
+- if (!parent->mnt_ns)
++ if (!is_mounted(&parent->mnt))
+ return -EINVAL;
+ }
+
+@@ -3946,6 +4024,8 @@ void mark_mounts_for_expiry(struct list_head *mounts)
+ list_for_each_entry_safe(mnt, next, mounts, mnt_expire) {
+ if (!is_mounted(&mnt->mnt))
+ continue;
++ /* lock_mnt_tree() leaves expirable mounts alone */
++ VFS_WARN_ON_ONCE(IS_MNT_LOCKED(mnt));
+ if (!xchg(&mnt->mnt_expiry_mark, 1) ||
+ propagate_mount_busy(mnt, 1))
+ continue;
+@@ -3953,6 +4033,11 @@ void mark_mounts_for_expiry(struct list_head *mounts)
+ }
+ while (!list_empty(&graveyard)) {
+ mnt = list_first_entry(&graveyard, struct mount, mnt_expire);
++ /* an earlier umount_tree() may have moved a busy mount here */
++ if (propagate_mount_busy(mnt, 1)) {
++ list_move(&mnt->mnt_expire, mounts);
++ continue;
++ }
+ touch_mnt_namespace(mnt->mnt_ns);
+ umount_tree(mnt, UMOUNT_PROPAGATE|UMOUNT_SYNC);
+ }
+@@ -3960,17 +4045,38 @@ void mark_mounts_for_expiry(struct list_head *mounts)
+
+ EXPORT_SYMBOL_GPL(mark_mounts_for_expiry);
+
++/*
++ * Unmount @mnt if it's a shrinkable mount without children that nobody uses.
++ *
++ * mount_lock must be held for write
++ */
++static bool shrink_submount(struct mount *mnt)
++{
++ /* not the kernel's to remove either */
++ if (IS_MNT_LOCKED(mnt) || propagate_mount_busy(mnt, 1))
++ return false;
++ touch_mnt_namespace(mnt->mnt_ns);
++ umount_tree(mnt, UMOUNT_PROPAGATE|UMOUNT_SYNC);
++ return true;
++}
++
+ /*
+ * Ripoff of 'select_parent()'
+ *
+- * search the list of submounts for a given mountpoint, and move any
+- * shrinkable submounts to the 'graveyard' list.
++ * unmount the shrinkable submounts of @parent that aren't busy, children
++ * before their parent, and say whether anything went
++ *
++ * The cursor into the children of @this_parent survives the umount of a
++ * child mount without child mounts. The mounts that get umounted together with
++ * it are located under receiving mounts of @this_parent and never under
++ * @this_parent itself. The one exception is @this_parent getting unmounted
++ * then the walk starts over.
+ */
+-static int select_submounts(struct mount *parent, struct list_head *graveyard)
++static bool __shrink_submounts(struct mount *parent)
+ {
+ struct mount *this_parent = parent;
+ struct list_head *next;
+- int found = 0;
++ bool shrunk = false;
+
+ repeat:
+ next = this_parent->mnt_mounts.next;
+@@ -3989,42 +4095,45 @@ resume:
+ this_parent = mnt;
+ goto repeat;
+ }
+-
+- if (!propagate_mount_busy(mnt, 1)) {
+- list_move_tail(&mnt->mnt_expire, graveyard);
+- found++;
+- }
++ if (!shrink_submount(mnt))
++ continue;
++ shrunk = true;
++ if (unlikely(this_parent->mnt.mnt_flags & MNT_UMOUNT))
++ return true;
+ }
+ /*
+ * All done at this level ... ascend and resume the search
+ */
+ if (this_parent != parent) {
+- next = this_parent->mnt_child.next;
+- this_parent = this_parent->mnt_parent;
++ struct mount *mnt = this_parent;
++
++ next = mnt->mnt_child.next;
++ this_parent = mnt->mnt_parent;
++ /* its children are gone, maybe it can go as well */
++ if (shrink_submount(mnt)) {
++ shrunk = true;
++ if (unlikely(this_parent->mnt.mnt_flags & MNT_UMOUNT))
++ return true;
++ }
+ goto resume;
+ }
+- return found;
++ return shrunk;
+ }
+
+ /*
+- * process a list of expirable mountpoints with the intent of discarding any
+- * submounts of a specific parent mountpoint
++ * unmount the shrinkable submounts of @mnt that aren't busy
++ *
++ * The busy check and the umount of a mount are adjacent. An umount can
++ * still empty or move a mount in a part of the tree that was walked
++ * already, so walk again until nothing goes.
+ *
+ * mount_lock must be held for write
+ */
+ static void shrink_submounts(struct mount *mnt)
+ {
+- LIST_HEAD(graveyard);
+- struct mount *m;
+-
+- /* extract submounts of 'mountpoint' from the expiration list */
+- while (select_submounts(mnt, &graveyard)) {
+- while (!list_empty(&graveyard)) {
+- m = list_first_entry(&graveyard, struct mount,
+- mnt_expire);
+- touch_mnt_namespace(m->mnt_ns);
+- umount_tree(m, UMOUNT_PROPAGATE|UMOUNT_SYNC);
+- }
++ for (;;) {
++ if (!__shrink_submounts(mnt))
++ break;
+ }
+ }
+
+@@ -4189,6 +4298,8 @@ static void free_mnt_ns(struct mnt_namespace *ns)
+ if (!is_anon_ns(ns))
+ ns_common_free(ns);
+ dec_mnt_namespaces(ns->ucounts);
++ /* the last active reference is gone, no mark can show up anymore */
++ fsnotify_mntns_delete(ns);
+ mnt_ns_tree_remove(ns);
+ }
+
+@@ -4690,14 +4801,15 @@ int path_pivot_root(struct path *new, struct path *old)
+
+ new_mnt = real_mount(new->mnt);
+ root_mnt = real_mount(root.mnt);
++ /* only a mounted mount has a parent that namespace_sem pins */
++ if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
++ return -EINVAL;
+ ex_parent = new_mnt->mnt_parent;
+ root_parent = root_mnt->mnt_parent;
+ if (IS_MNT_SHARED(old_mnt) ||
+ IS_MNT_SHARED(ex_parent) ||
+ IS_MNT_SHARED(root_parent))
+ return -EINVAL;
+- if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
+- return -EINVAL;
+ if (new_mnt->mnt.mnt_flags & MNT_LOCKED)
+ return -EINVAL;
+ if (d_unlinked(new->dentry))
+@@ -4948,6 +5060,11 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr)
+ * propagation.
+ */
+ namespace_lock();
++ /* invent_group_ids() walks the tree, only walk a mounted one */
++ if (!anon_ns_root(mnt) && !check_mnt(mnt)) {
++ namespace_unlock();
++ return -EINVAL;
++ }
+ if (kattr->propagation == MS_SHARED) {
+ err = invent_group_ids(mnt, kattr->kflags & MOUNT_KATTR_RECURSE);
+ if (err) {
+@@ -4960,6 +5077,7 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr)
+ err = -EINVAL;
+ lock_mount_hash();
+
++ /* Checked under namespace_sem already if the propagation changes. */
+ if (!anon_ns_root(mnt) && !check_mnt(mnt))
+ goto out;
+
+@@ -5312,15 +5430,25 @@ static void statmount_sb_basic(struct kstatmount *s)
+ s->sm.sb_flags = sb->s_flags & (SB_RDONLY|SB_SYNCHRONOUS|SB_DIRSYNC|SB_LAZYTIME);
+ }
+
++static void statmount_mnt_parent(struct kstatmount *s, const struct mount *m)
++{
++ s->sm.mnt_parent_id = m->mnt_parent->mnt_id_unique;
++ s->sm.mnt_parent_id_old = m->mnt_parent->mnt_id;
++}
++
+ static void statmount_mnt_basic(struct kstatmount *s)
+ {
+ struct mount *m = real_mount(s->mnt);
+
+ s->sm.mask |= STATMOUNT_MNT_BASIC;
+ s->sm.mnt_id = m->mnt_id_unique;
+- s->sm.mnt_parent_id = m->mnt_parent->mnt_id_unique;
+ s->sm.mnt_id_old = m->mnt_id;
+- s->sm.mnt_parent_id_old = m->mnt_parent->mnt_id;
++ /* An unmounted mount is cut loose from its parent under mount_lock alone. */
++ if (likely(is_mounted(s->mnt)))
++ statmount_mnt_parent(s, m);
++ else
++ scoped_guard(mount_locked_reader)
++ statmount_mnt_parent(s, m);
+ s->sm.mnt_attr = mnt_to_attr_flags(&m->mnt);
+ s->sm.mnt_propagation = mnt_to_propagation_flags(m);
+ s->sm.mnt_peer_group = m->mnt_group_id;
+diff --git a/fs/nullfs.c b/fs/nullfs.c
+index fdbd3e5d3d71f5..20d3aa627a47de 100644
+--- a/fs/nullfs.c
++++ b/fs/nullfs.c
+@@ -30,8 +30,8 @@ static int nullfs_fs_fill_super(struct super_block *s, struct fs_context *fc)
+ make_empty_dir_inode(inode);
+ simple_inode_init_ts(inode);
+ inode->i_ino = 1;
+- /* ... and immutable. */
+- inode->i_flags |= S_IMMUTABLE;
++ /* ... and immutable, reading it leaves no trace either. */
++ inode->i_flags |= S_IMMUTABLE | S_NOATIME;
+
+ s->s_root = d_make_root(inode);
+ if (!s->s_root)
+diff --git a/fs/pnode.c b/fs/pnode.c
+index 5d91c3e58d2a35..2cd667958efe1b 100644
+--- a/fs/pnode.c
++++ b/fs/pnode.c
+@@ -410,19 +410,99 @@ bool propagation_would_overmount(const struct mount *from,
+ return false;
+ }
+
++/* Does @m receive propagation from @parent? */
++static bool receives_from(struct mount *m, struct mount *parent)
++{
++ if (m == parent)
++ return false;
++ for (; m; m = m->mnt_master)
++ if (m == parent || peers(m, parent))
++ return true;
++ return false;
++}
++
++/*
++ * Does @m receive propagation from the victim's parent as well? If so, then
++ * the mount at the victim's mountpoint inside of @m is a umount candidate as
++ * well. So it's the next candidate in the chain. Otherwise the chain ends at
++ * @m.
++ */
++static struct mount *next_candidate(struct mount *m, struct mount *victim)
++{
++ if (!receives_from(m, victim->mnt_parent))
++ return NULL;
++ return __lookup_mnt(&m->mnt, victim->mnt_mountpoint);
++}
++
++/*
++ * Would propagate_umount() pull out a mount of the chain of candidates that
++ * starts at @c, and does that mount have references beyond its own?
++ *
++ * This mirrors how trim_one(), trim_ancestors() and handle_locked() handle a
++ * synchronous umount:
++ *
++ * - single victim
++ * - without children
++ * - with MNT_LOCKED already cleared on every candidate by propagate_mount_unlock()
++ *
++ * A copy of the victim gets unmounted when each of its children is
++ * the next candidate in the chain or its overmount, unless the next
++ * unmount candidate is not its overmount and some unmount candidate further
++ * down has a child outside the chain. Keep this in sync with
++ * Documentation/filesystems/propagate_umount.txt.
++ */
++static bool chain_busy(struct mount *c, struct mount *victim)
++{
++ struct mount *m, *n, *next, *deepest = NULL;
++ bool above;
++
++ /* the deepest candidate with a child outside the chain */
++ for (m = c; m; m = next) {
++ next = next_candidate(m, victim);
++ list_for_each_entry(n, &m->mnt_mounts, mnt_child) {
++ if (n != next && n != victim) {
++ deepest = m;
++ break;
++ }
++ }
++ }
++
++ above = deepest != NULL; /* @deepest is at or below @m */
++ for (m = c; m; m = next) {
++ bool goes = true;
++
++ next = next_candidate(m, victim);
++ list_for_each_entry(n, &m->mnt_mounts, mnt_child) {
++ if (n != next && n != m->overmount && n != victim) {
++ goes = false;
++ break;
++ }
++ }
++ if (goes && next && next != m->overmount && above && m != deepest)
++ goes = false;
++ if (m == deepest)
++ above = false;
++ if (goes && do_refcount_check(m, 1))
++ return true;
++ }
++ return false;
++}
++
+ /*
+ * check if the mount 'mnt' can be unmounted successfully.
+ * @mnt: the mount to be checked for unmount
+ * NOTE: unmounting 'mnt' would naturally propagate to all
+ * other mounts its parent propagates to.
+- * Check if any of these mounts that **do not have submounts**
+- * have more references than 'refcnt'. If so return busy.
++ * Check if any of the mounts that propagate_umount() would pull out
++ * along with it have more references than their own. If so return busy.
+ *
+ * vfsmount lock must be held for write
+ */
+ int propagate_mount_busy(struct mount *mnt, int refcnt)
+ {
+ struct mount *parent = mnt->mnt_parent;
++ struct dentry *mp = mnt->mnt_mountpoint;
++ struct mount *m;
+
+ /*
+ * quickly check if the current mount can be unmounted.
+@@ -435,24 +515,16 @@ int propagate_mount_busy(struct mount *mnt, int refcnt)
+ if (mnt == parent)
+ return 0;
+
+- for (struct mount *m = propagation_next(parent, parent); m;
+- m = propagation_next(m, parent)) {
+- struct list_head *head;
+- struct mount *child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint);
++ /* the candidates are the mounts at @mp below the receivers */
++ for (m = propagation_next(parent, parent); m;
++ m = propagation_next(m, parent)) {
++ struct mount *c = __lookup_mnt(&m->mnt, mp);
+
+- if (!child)
++ /* each chain once, from its top: skip receivers that are candidates */
++ if (!c || (mnt_has_parent(m) && m->mnt_mountpoint == mp &&
++ receives_from(m->mnt_parent, parent)))
+ continue;
+-
+- head = &child->mnt_mounts;
+- if (!list_empty(head)) {
+- /*
+- * a mount that covers child completely wouldn't prevent
+- * it being pulled out; any other would.
+- */
+- if (!list_is_singular(head) || !child->overmount)
+- continue;
+- }
+- if (do_refcount_check(child, 1))
++ if (chain_busy(c, mnt))
+ return 1;
+ }
+ return 0;
+diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
+index 881d46f25e087c..6f85f63861aaa1 100644
+--- a/fs/verity/fsverity_private.h
++++ b/fs/verity/fsverity_private.h
+@@ -11,6 +11,7 @@
+ #define pr_fmt(fmt) "fs-verity: " fmt
+
+ #include
++#include
+ #include
+
+ /*
+@@ -76,7 +77,19 @@ struct merkle_tree_params {
+ struct fsverity_info {
+ struct rhash_head rhash_head;
+ struct merkle_tree_params tree_params;
+- u8 root_hash[FS_VERITY_MAX_DIGEST_SIZE];
++ union {
++ u8 root_hash[FS_VERITY_MAX_DIGEST_SIZE];
++
++ /*
++ * Used for final freeing of the struct, in which case root_hash
++ * is no longer needed. Specifically, the only fields needed
++ * besides the rcu_head are those needed by fsverity_free_info()
++ * itself, and those that can be accessed by fsverity_get_info()
++ * (rhash_head and inode) during the RCU-protected rhashtable
++ * chain search trying to find another inode's fsverity_info.
++ */
++ struct rcu_head rcu_head;
++ };
+ u8 file_digest[FS_VERITY_MAX_DIGEST_SIZE];
+ struct inode *inode;
+ unsigned long *hash_block_verified;
+diff --git a/fs/verity/open.c b/fs/verity/open.c
+index d0c56a7faa3bb1..52c8cd0149216e 100644
+--- a/fs/verity/open.c
++++ b/fs/verity/open.c
+@@ -399,11 +399,22 @@ void fsverity_free_info(struct fsverity_info *vi)
+ kmem_cache_free(fsverity_info_cachep, vi);
+ }
+
++static void fsverity_free_info_rcu(struct rcu_head *head)
++{
++ fsverity_free_info(container_of(head, struct fsverity_info, rcu_head));
++}
++
+ void fsverity_remove_info(struct fsverity_info *vi)
+ {
+ rhashtable_remove_fast(&fsverity_info_hash, &vi->rhash_head,
+ fsverity_info_hash_params);
+- fsverity_free_info(vi);
++ /*
++ * The freeing must be RCU-delayed because __fsverity_get_info() for a
++ * *different* inode's fsverity_info in the same rhashtable hash chain
++ * can still be accessing *this* fsverity_info's rhash_head and inode
++ * fields as part of the RCU-protected hash chain search.
++ */
++ call_rcu(&vi->rcu_head, fsverity_free_info_rcu);
+ }
+
+ void fsverity_cleanup_inode(struct inode *inode)
+diff --git a/fs/xfs/libxfs/xfs_exchmaps.c b/fs/xfs/libxfs/xfs_exchmaps.c
+index 49eda8d0994dee..37595f579b635a 100644
+--- a/fs/xfs/libxfs/xfs_exchmaps.c
++++ b/fs/xfs/libxfs/xfs_exchmaps.c
+@@ -49,7 +49,7 @@ struct xfs_exchmaps_adjacent {
+ .right2 = { .br_startblock = HOLESTARTBLOCK }, \
+ }
+
+-/* Information to reset reflink flag / CoW fork state after an exchange. */
++/* Information to reset CoW fork state after an exchange. */
+
+ /*
+ * If the reflink flag is set on either inode, make sure it has an incore CoW
+@@ -127,9 +127,7 @@ xmi_has_more_exchange_work(const struct xfs_exchmaps_intent *xmi)
+ static inline bool
+ xmi_has_postop_work(const struct xfs_exchmaps_intent *xmi)
+ {
+- return xmi->xmi_flags & (XFS_EXCHMAPS_CLEAR_INO1_REFLINK |
+- XFS_EXCHMAPS_CLEAR_INO2_REFLINK |
+- __XFS_EXCHMAPS_INO2_SHORTFORM);
++ return xmi->xmi_flags & __XFS_EXCHMAPS_INO2_SHORTFORM;
+ }
+
+ /* Check all mappings to make sure we can actually exchange them. */
+@@ -525,18 +523,6 @@ free:
+ return error;
+ }
+
+-/* Clear the reflink flag after an exchange. */
+-static inline void
+-xfs_exchmaps_clear_reflink(
+- struct xfs_trans *tp,
+- struct xfs_inode *ip)
+-{
+- trace_xfs_reflink_unset_inode_flag(ip);
+-
+- ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+- xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
+-}
+-
+ /* Finish whatever work might come after an exchange operation. */
+ static int
+ xfs_exchmaps_do_postop_work(
+@@ -557,16 +543,6 @@ xfs_exchmaps_do_postop_work(
+ return error;
+ }
+
+- if (xmi->xmi_flags & XFS_EXCHMAPS_CLEAR_INO1_REFLINK) {
+- xfs_exchmaps_clear_reflink(tp, xmi->xmi_ip1);
+- xmi->xmi_flags &= ~XFS_EXCHMAPS_CLEAR_INO1_REFLINK;
+- }
+-
+- if (xmi->xmi_flags & XFS_EXCHMAPS_CLEAR_INO2_REFLINK) {
+- xfs_exchmaps_clear_reflink(tp, xmi->xmi_ip2);
+- xmi->xmi_flags &= ~XFS_EXCHMAPS_CLEAR_INO2_REFLINK;
+- }
+-
+ return 0;
+ }
+
+@@ -948,56 +924,14 @@ xfs_exchmaps_intent_destroy_cache(void)
+ }
+
+ /*
+- * Decide if we will exchange the reflink flags between the two files after the
+- * exchange. The only time we want to do this is if we're exchanging all
+- * mappings under EOF and the inode reflink flags have different states.
++ * Allocate and initialize a new incore intent item from a request.
+ */
+-static inline bool
+-xmi_can_exchange_reflink_flags(
+- const struct xfs_exchmaps_req *req,
+- unsigned int reflink_state)
+-{
+- struct xfs_mount *mp = req->ip1->i_mount;
+-
+- /*
+- * The INO1_WRITTEN optimization can skip exchanging hole and
+- * unwritten mappings, which means we cannot guarantee that all
+- * shared extents actually moved to the other file. Clearing the
+- * reflink flag of an inode that still holds shared extents breaks
+- * the CoW write path, so refuse to exchange the flags in that case.
+- */
+- if (req->flags & XFS_EXCHMAPS_INO1_WRITTEN)
+- return false;
+-
+- /*
+- * The INO1_WRITTEN optimization can skip exchanging hole and
+- * unwritten mappings, which means we cannot guarantee that all
+- * shared extents actually moved to the other file. Clearing the
+- * reflink flag of an inode that still holds shared extents breaks
+- * the CoW write path, so refuse to exchange the flags in that case.
+- */
+- if (req->flags & XFS_EXCHMAPS_INO1_WRITTEN)
+- return false;
+-
+- if (hweight32(reflink_state) != 1)
+- return false;
+- if (req->startoff1 != 0 || req->startoff2 != 0)
+- return false;
+- if (req->blockcount != XFS_B_TO_FSB(mp, req->ip1->i_disk_size))
+- return false;
+- if (req->blockcount != XFS_B_TO_FSB(mp, req->ip2->i_disk_size))
+- return false;
+- return true;
+-}
+-
+-
+-/* Allocate and initialize a new incore intent item from a request. */
+ struct xfs_exchmaps_intent *
+ xfs_exchmaps_init_intent(
+ const struct xfs_exchmaps_req *req)
+ {
+ struct xfs_exchmaps_intent *xmi;
+- unsigned int rs = 0;
++ struct xfs_mount *mp = req->ip1->i_mount;
+
+ xmi = kmem_cache_zalloc(xfs_exchmaps_intent_cache,
+ GFP_NOFS | __GFP_NOFAIL);
+@@ -1015,27 +949,18 @@ xfs_exchmaps_init_intent(
+ return xmi;
+ }
+
+- if (req->flags & XFS_EXCHMAPS_SET_SIZES) {
+- xmi->xmi_flags |= XFS_EXCHMAPS_SET_SIZES;
+- xmi->xmi_isize1 = req->ip2->i_disk_size;
+- xmi->xmi_isize2 = req->ip1->i_disk_size;
+- }
+-
+- /* Record the state of each inode's reflink flag before the op. */
+- if (xfs_is_reflink_inode(req->ip1))
+- rs |= 1;
+- if (xfs_is_reflink_inode(req->ip2))
+- rs |= 2;
+-
+ /*
+- * Figure out if we're clearing the reflink flags (which effectively
+- * exchanges them) after the operation.
++ * If the caller wanted, set each file's size to that file's exchange
++ * offset + length exchanged from the other file because the ranges in
++ * each file might be different lengths.
+ */
+- if (xmi_can_exchange_reflink_flags(req, rs)) {
+- if (rs & 1)
+- xmi->xmi_flags |= XFS_EXCHMAPS_CLEAR_INO1_REFLINK;
+- if (rs & 2)
+- xmi->xmi_flags |= XFS_EXCHMAPS_CLEAR_INO2_REFLINK;
++ if (req->flags & XFS_EXCHMAPS_SET_SIZES) {
++ loff_t off1 = XFS_FSB_TO_B(mp, xmi->xmi_startoff1);
++ loff_t off2 = XFS_FSB_TO_B(mp, xmi->xmi_startoff2);
++
++ xmi->xmi_flags |= XFS_EXCHMAPS_SET_SIZES;
++ xmi->xmi_isize1 = off1 + (req->ip2->i_disk_size - off2);
++ xmi->xmi_isize2 = off2 + (req->ip1->i_disk_size - off1);
+ }
+
+ if (S_ISDIR(VFS_I(xmi->xmi_ip2)->i_mode) ||
+diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
+index a4e1b3eb425cda..6e620380d5dc86 100644
+--- a/fs/xfs/libxfs/xfs_log_format.h
++++ b/fs/xfs/libxfs/xfs_log_format.h
+@@ -927,10 +927,8 @@ struct xfs_xmi_log_format {
+ */
+ #define XFS_EXCHMAPS_INO1_WRITTEN (1ULL << 2)
+
+-/* Clear the reflink flag from inode1 after the operation. */
++/* No longer set, but older intents may carry them; keep them valid. */
+ #define XFS_EXCHMAPS_CLEAR_INO1_REFLINK (1ULL << 3)
+-
+-/* Clear the reflink flag from inode2 after the operation. */
+ #define XFS_EXCHMAPS_CLEAR_INO2_REFLINK (1ULL << 4)
+
+ #define XFS_EXCHMAPS_LOGGED_FLAGS (XFS_EXCHMAPS_ATTR_FORK | \
+diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
+index c88b9ade7389dd..2ea6507678050a 100644
+--- a/fs/xfs/xfs_bmap_util.c
++++ b/fs/xfs/xfs_bmap_util.c
+@@ -1514,7 +1514,6 @@ xfs_swap_extents(
+ struct xfs_bstat *sbp = &sxp->sx_stat;
+ int src_log_flags, target_log_flags;
+ int error = 0;
+- uint64_t f;
+ int resblks = 0;
+ unsigned int flags = 0;
+ struct timespec64 ctime, mtime;
+@@ -1670,14 +1669,12 @@ xfs_swap_extents(
+ if (error)
+ goto out_trans_cancel;
+
+- /* Do we have to swap reflink flags? */
+- if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^
+- (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) {
+- f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
+- ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+- ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK;
+- tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
+- tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK;
++ /* Either inode may now own shared blocks; flag both, with CoW forks. */
++ if ((ip->i_diflags2 | tip->i_diflags2) & XFS_DIFLAG2_REFLINK) {
++ ip->i_diflags2 |= XFS_DIFLAG2_REFLINK;
++ tip->i_diflags2 |= XFS_DIFLAG2_REFLINK;
++ xfs_ifork_init_cow(ip);
++ xfs_ifork_init_cow(tip);
+ }
+
+ /* Swap the cow forks. */
+diff --git a/fs/xfs/xfs_exchrange.c b/fs/xfs/xfs_exchrange.c
+index fafb4e3f065c75..935b561dfd3c5c 100644
+--- a/fs/xfs/xfs_exchrange.c
++++ b/fs/xfs/xfs_exchrange.c
+@@ -290,17 +290,20 @@ retry:
+ goto out_unlock;
+
+ /*
+- * If the caller wanted us to exchange the contents of two complete
+- * files of unequal length, exchange the incore sizes now. This should
+- * be safe because we flushed both files' page caches, exchanged all
+- * the mappings, and updated the ondisk sizes.
++ * If the caller wanted, set each file's size to that file's exchange
++ * offset + length exchanged from the other file because the ranges in
++ * each file might be different lengths. This should be safe because
++ * we flushed both files' page caches, exchanged all the mappings, and
++ * updated the ondisk sizes.
+ */
+ if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) {
+- loff_t temp;
++ loff_t old_ip1_size = i_size_read(VFS_I(ip1));
++ loff_t old_ip2_size = i_size_read(VFS_I(ip2));
+
+- temp = i_size_read(VFS_I(ip2));
+- i_size_write(VFS_I(ip2), i_size_read(VFS_I(ip1)));
+- i_size_write(VFS_I(ip1), temp);
++ i_size_write(VFS_I(ip2), fxr->file2_offset +
++ (old_ip1_size - fxr->file1_offset));
++ i_size_write(VFS_I(ip1), fxr->file1_offset +
++ (old_ip2_size - fxr->file2_offset));
+ }
+
+ out_unlock:
+@@ -445,6 +448,30 @@ xfs_exchange_range_checks(
+ return blen == fxr->length ? 0 : -EINVAL;
+ }
+
++/* Flush all relevant dirty pagecache near the range to be exchanged. */
++static inline int
++xfs_exchange_range_flush(
++ struct xfs_inode *ip,
++ const struct xfs_exchrange *fxr,
++ loff_t offset)
++{
++ /*
++ * If TO_EOF is set, the ondisk file size update logic depends on the
++ * ondisk file size matching the incore file size. Flush everything.
++ */
++ if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF)
++ return filemap_write_and_wait(VFS_I(ip)->i_mapping);
++
++ /*
++ * Because we're updating the ondisk mappings, flush all dirty data
++ * between the ondisk size and the exchange offset to reduce the chance
++ * of zeroed file contents in that gap after a crash.
++ */
++ return filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
++ min(offset, ip->i_disk_size),
++ offset + fxr->length - 1);
++}
++
+ /*
+ * Check that the two inodes are eligible for range exchanges, the ranges make
+ * sense, and then flush all dirty data. Caller must ensure that the inodes
+@@ -470,15 +497,11 @@ xfs_exchange_range_prep(
+ if (!same_inode)
+ inode_dio_wait(inode2);
+
+- error = filemap_write_and_wait_range(inode1->i_mapping,
+- fxr->file1_offset,
+- fxr->file1_offset + fxr->length - 1);
++ error = xfs_exchange_range_flush(XFS_I(inode1), fxr, fxr->file1_offset);
+ if (error)
+ return error;
+
+- error = filemap_write_and_wait_range(inode2->i_mapping,
+- fxr->file2_offset,
+- fxr->file2_offset + fxr->length - 1);
++ error = xfs_exchange_range_flush(XFS_I(inode2), fxr, fxr->file2_offset);
+ if (error)
+ return error;
+
+diff --git a/include/linux/can/core.h b/include/linux/can/core.h
+index 3287232e3cad92..2de74c2b78b6c1 100644
+--- a/include/linux/can/core.h
++++ b/include/linux/can/core.h
+@@ -17,6 +17,7 @@
+ #include
+ #include
+ #include
++#include
+
+ #define DNAME(dev) ((dev) ? (dev)->name : "any")
+
+@@ -58,7 +59,7 @@ extern void can_rx_unregister(struct net *net, struct net_device *dev,
+ void *data);
+
+ extern int can_send(struct sk_buff *skb, int loop);
+-void can_set_skb_uid(struct sk_buff *skb);
++void can_set_skb_uid(struct can_skb_ext *csx);
+ void can_sock_destruct(struct sock *sk);
+
+ #endif /* !_CAN_CORE_H */
+diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
+index a70a0296707115..5d27843862fca4 100644
+--- a/include/linux/can/skb.h
++++ b/include/linux/can/skb.h
+@@ -43,8 +43,10 @@ static inline struct can_skb_ext *can_skb_ext_add(struct sk_buff *skb)
+ struct can_skb_ext *csx = skb_ext_add(skb, SKB_EXT_CAN);
+
+ /* skb_ext_add() returns uninitialized space */
+- if (csx)
++ if (csx) {
+ csx->can_gw_hops = 0;
++ csx->can_skb_uid = 0;
++ }
+
+ return csx;
+ }
+diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
+index dac5b2cb8aaaa3..20116462cf3d76 100644
+--- a/include/linux/io_uring_types.h
++++ b/include/linux/io_uring_types.h
+@@ -316,6 +316,8 @@ enum {
+ IO_RING_F_DRAIN_DISABLED = BIT(10),
+ IO_RING_F_COMPAT = BIT(11),
+ IO_RING_F_IOWQ_LIMITS_SET = BIT(12),
++ /* restrictions were inherited from the task that created the ring */
++ IO_RING_F_RESTRICT_INHERITED = BIT(13),
+ };
+
+ struct iou_ctx {};
+diff --git a/include/linux/mount.h b/include/linux/mount.h
+index acfe7ef86a1b3f..b16ba5d456057a 100644
+--- a/include/linux/mount.h
++++ b/include/linux/mount.h
+@@ -52,7 +52,7 @@ enum mount_flags {
+ MNT_ATIME_MASK = MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME,
+
+ MNT_INTERNAL_FLAGS = MNT_INTERNAL | MNT_DOOMED |
+- MNT_SYNC_UMOUNT | MNT_LOCKED
++ MNT_SYNC_UMOUNT | MNT_LOCKED | MNT_UMOUNT
+ };
+
+ struct vfsmount {
+diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
+index 5a67648721c7d9..dc2447f5f09240 100644
+--- a/include/linux/nsproxy.h
++++ b/include/linux/nsproxy.h
+@@ -100,6 +100,7 @@ void exit_cred_namespaces(struct task_struct *tsk);
+ void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
+ int exec_task_namespaces(void);
+ void deactivate_nsproxy(struct nsproxy *ns);
++void nsproxy_free(struct nsproxy *ns);
+ int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
+ struct cred *, struct fs_struct *);
+ int __init nsproxy_cache_init(void);
+diff --git a/include/linux/nvme.h b/include/linux/nvme.h
+index 041f30931a908a..03ddd2c6d7fa7a 100644
+--- a/include/linux/nvme.h
++++ b/include/linux/nvme.h
+@@ -1266,8 +1266,8 @@ enum {
+ NVME_ZRASF_ZONE_STATE_IMP_OPEN = 0x02,
+ NVME_ZRASF_ZONE_STATE_EXP_OPEN = 0x03,
+ NVME_ZRASF_ZONE_STATE_CLOSED = 0x04,
+- NVME_ZRASF_ZONE_STATE_READONLY = 0x05,
+- NVME_ZRASF_ZONE_STATE_FULL = 0x06,
++ NVME_ZRASF_ZONE_STATE_FULL = 0x05,
++ NVME_ZRASF_ZONE_STATE_READONLY = 0x06,
+ NVME_ZRASF_ZONE_STATE_OFFLINE = 0x07,
+ NVME_REPORT_ZONE_PARTIAL = 1,
+ };
+diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h
+index 87e353f7e0112e..67a97429d8a6ce 100644
+--- a/include/linux/sched/ext.h
++++ b/include/linux/sched/ext.h
+@@ -198,6 +198,7 @@ struct sched_ext_entity {
+ s32 sticky_cpu;
+ s32 holding_cpu;
+ s32 selected_cpu;
++ u32 ops_qseq; /* protected by rq lock */
+ struct task_struct *kf_tasks[2]; /* see SCX_CALL_OP_TASK() */
+
+ struct list_head runnable_node; /* rq->scx.runnable_list */
+diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
+index c381b916c1b54a..d6466f96cdd00c 100644
+--- a/include/linux/virtio_net.h
++++ b/include/linux/virtio_net.h
+@@ -111,48 +111,38 @@ static inline int __virtio_net_hdr_to_skb(struct sk_buff *skb,
+ p_off = nh_min_len + thlen;
+ if (!pskb_may_pull(skb, p_off))
+ return -EINVAL;
+- } else {
++ } else if (gso_type) {
+ /* gso packets without NEEDS_CSUM do not set transport_offset.
+ * probe and drop if does not match one of the above types.
+ */
+- if (gso_type && skb->network_header) {
+- struct flow_keys_basic keys;
+-
+- if (!skb->protocol) {
+- __be16 protocol = dev_parse_header_protocol(skb);
+-
+- if (!protocol)
+- virtio_net_hdr_set_proto(skb, hdr);
+- else if (!virtio_net_hdr_match_proto(protocol,
+- hdr_gso_type))
+- return -EINVAL;
+- else
+- skb->protocol = protocol;
+- }
++ struct flow_keys_basic keys;
++
++ if (!skb->protocol) {
++ skb->protocol = dev_parse_header_protocol(skb);
++ if (!skb->protocol)
++ virtio_net_hdr_set_proto(skb, hdr);
++ }
+ retry:
+- if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys,
+- NULL, 0, 0, 0,
+- 0)) {
+- /* UFO does not specify ipv4 or 6: try both */
+- if (gso_type & SKB_GSO_UDP &&
+- skb->protocol == htons(ETH_P_IP)) {
+- skb->protocol = htons(ETH_P_IPV6);
+- goto retry;
+- }
+- return -EINVAL;
++ if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys,
++ NULL, 0, 0, 0,
++ 0)) {
++ /* UFO does not specify ipv4 or 6: try both */
++ if (gso_type & SKB_GSO_UDP &&
++ skb->protocol == htons(ETH_P_IP)) {
++ skb->protocol = htons(ETH_P_IPV6);
++ goto retry;
+ }
++ return -EINVAL;
++ }
+
+- p_off = keys.control.thoff + thlen;
+- if (!pskb_may_pull(skb, p_off) ||
+- keys.basic.ip_proto != ip_proto)
+- return -EINVAL;
++ p_off = keys.control.thoff + thlen;
++ if (!pskb_may_pull(skb, p_off) ||
++ keys.basic.ip_proto != ip_proto ||
++ !virtio_net_hdr_match_proto(keys.basic.n_proto,
++ hdr_gso_type))
++ return -EINVAL;
+
+- skb_set_transport_header(skb, keys.control.thoff);
+- } else if (gso_type) {
+- p_off = nh_min_len + thlen;
+- if (!pskb_may_pull(skb, p_off))
+- return -EINVAL;
+- }
++ skb_set_transport_header(skb, keys.control.thoff);
+ }
+
+ if (hdr_gso_type != VIRTIO_NET_HDR_GSO_NONE) {
+diff --git a/include/net/amt.h b/include/net/amt.h
+index a0255491f5b05e..2846dde0cadce3 100644
+--- a/include/net/amt.h
++++ b/include/net/amt.h
+@@ -231,10 +231,6 @@ struct amt_relay_headers {
+ };
+ } __packed;
+
+-struct amt_skb_cb {
+- struct amt_tunnel_list *tunnel;
+-};
+-
+ struct amt_tunnel_list {
+ struct list_head list;
+ /* Protect All resources under an amt_tunne_list */
+diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
+index 102c278e35844c..9dc5fd4cb8c815 100644
+--- a/include/net/bluetooth/rfcomm.h
++++ b/include/net/bluetooth/rfcomm.h
+@@ -207,6 +207,7 @@ struct rfcomm_dlc {
+ #define RFCOMM_AUTH_REJECT 7
+ #define RFCOMM_DEFER_SETUP 8
+ #define RFCOMM_ENC_DROP 9
++#define RFCOMM_CLOSED 10
+
+ /* Scheduling flags and events */
+ #define RFCOMM_SCHED_WAKEUP 31
+diff --git a/include/net/can.h b/include/net/can.h
+index 6db9e826f0e05f..2b8af2598732c0 100644
+--- a/include/net/can.h
++++ b/include/net/can.h
+@@ -17,12 +17,14 @@
+ * @can_framelen: cached echo CAN frame length for bql
+ * @can_gw_hops: can-gw CAN frame time-to-live counter
+ * @can_ext_flags: CAN skb extensions flags
++ * @can_skb_uid: CAN skb UID for raw_rcv and isotp echo handling
+ */
+ struct can_skb_ext {
+ int can_iif;
+ u16 can_framelen;
+ u8 can_gw_hops;
+ u8 can_ext_flags;
++ u32 can_skb_uid;
+ };
+
+ #endif /* _NET_CAN_H */
+diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
+index f5abf1db7558bc..7354ba079363a5 100644
+--- a/include/net/cfg80211.h
++++ b/include/net/cfg80211.h
+@@ -3722,6 +3722,7 @@ enum wiphy_params_flags {
+ /* The per TXQ device queue limit in airtime */
+ #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L 5000
+ #define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H 12000
++#define IEEE80211_DEFAULT_AQL_TXQ_LIMIT_MC 50000
+
+ /* The per interface airtime threshold to switch to lower queue limit */
+ #define IEEE80211_AQL_THRESHOLD 24000
+diff --git a/include/net/ip.h b/include/net/ip.h
+index 6f602df72ee621..d07c2c5730240b 100644
+--- a/include/net/ip.h
++++ b/include/net/ip.h
+@@ -74,6 +74,13 @@ static inline unsigned int ip_hdrlen(const struct sk_buff *skb)
+ return ip_hdr(skb)->ihl * 4;
+ }
+
++static inline int ip_check_csum_start(const struct sk_buff *skb)
++{
++ if (unlikely(skb->csum_start < skb->network_header + ip_hdrlen(skb)))
++ return -EINVAL;
++ return 0;
++}
++
+ struct ipcm_cookie {
+ struct sockcm_cookie sockc;
+ __be32 addr;
+diff --git a/include/net/mac80211.h b/include/net/mac80211.h
+index 36055d40172a18..7b610dfee28670 100644
+--- a/include/net/mac80211.h
++++ b/include/net/mac80211.h
+@@ -1317,6 +1317,7 @@ ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
+ * @status_data: internal data for TX status handling, assigned privately,
+ * see also &enum ieee80211_status_data for the internal documentation
+ * @status_data_idr: indicates status data is IDR allocated ID for ack frame
++ * @tx_time_mc: TX time estimate is for a multicast frame, used internally
+ * @tx_time_est: TX time estimate in units of 4us, used internally
+ * @control: union part for control data
+ * @control.rates: TX rates array to try
+@@ -1354,8 +1355,8 @@ struct ieee80211_tx_info {
+ status_data_idr:1,
+ status_data:13,
+ hw_queue:4,
++ tx_time_mc:1,
+ tx_time_est:10;
+- /* 1 free bit */
+
+ union {
+ struct {
+@@ -6876,6 +6877,17 @@ void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,
+ bool
+ ieee80211_txq_airtime_check(struct ieee80211_hw *hw, struct ieee80211_txq *txq);
+
++/**
++ * ieee80211_txq_aql_pending - get pending AQL airtime for a txq
++ *
++ * @hw: pointer obtained from ieee80211_alloc_hw()
++ * @txq: pointer obtained from station or virtual interface
++ *
++ * Return: pending airtime (in usec) for the given txq.
++ */
++u32 ieee80211_txq_aql_pending(struct ieee80211_hw *hw,
++ struct ieee80211_txq *txq);
++
+ /**
+ * ieee80211_iter_keys - iterate keys programmed into the device
+ * @hw: pointer obtained from ieee80211_alloc_hw()
+diff --git a/include/net/strparser.h b/include/net/strparser.h
+index 0ed73e364faa29..881b7ae3449864 100644
+--- a/include/net/strparser.h
++++ b/include/net/strparser.h
+@@ -91,11 +91,11 @@ static inline struct strp_msg *strp_msg(struct sk_buff *skb)
+ struct strparser {
+ struct sock *sk;
+
+- u32 stopped : 1;
+- u32 paused : 1;
+- u32 aborted : 1;
+- u32 interrupted : 1;
+- u32 unrecov_intr : 1;
++ u8 stopped;
++ u8 paused;
++ u8 aborted;
++ u8 interrupted;
++ u8 unrecov_intr;
+
+ struct sk_buff **skb_nextp;
+ struct sk_buff *skb_head;
+diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
+index c5404fbe3f7efb..3d8c8a50fd3128 100644
+--- a/io_uring/io_uring.c
++++ b/io_uring/io_uring.c
+@@ -2077,8 +2077,9 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
+
+ static void io_rings_free(struct io_ring_ctx *ctx)
+ {
+- io_free_region(ctx->user, &ctx->sq_region);
+- io_free_region(ctx->user, &ctx->ring_region);
++ /* ring memory is not charged to RLIMIT_MEMLOCK, hence no user */
++ io_free_region(NULL, &ctx->sq_region);
++ io_free_region(NULL, &ctx->ring_region);
+ ctx->rings = NULL;
+ RCU_INIT_POINTER(ctx->rings_rcu, NULL);
+ ctx->sq_sqes = NULL;
+@@ -2742,7 +2743,8 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx,
+ rd.user_addr = p->cq_off.user_addr;
+ rd.flags |= IORING_MEM_REGION_TYPE_USER;
+ }
+- ret = io_create_region(ctx, &ctx->ring_region, &rd, IORING_OFF_CQ_RING);
++ /* ring memory is not charged to RLIMIT_MEMLOCK, hence no user */
++ ret = io_create_region(NULL, &ctx->ring_region, &rd, IORING_OFF_CQ_RING);
+ if (ret)
+ return ret;
+ ctx->rings = rings = io_region_get_ptr(&ctx->ring_region);
+@@ -2756,7 +2758,7 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx,
+ rd.user_addr = p->sq_off.user_addr;
+ rd.flags |= IORING_MEM_REGION_TYPE_USER;
+ }
+- ret = io_create_region(ctx, &ctx->sq_region, &rd, IORING_OFF_SQES);
++ ret = io_create_region(NULL, &ctx->sq_region, &rd, IORING_OFF_SQES);
+ if (ret) {
+ io_rings_free(ctx);
+ return ret;
+@@ -2967,7 +2969,8 @@ static void io_ctx_restriction_clone(struct io_ring_ctx *ctx,
+ if (dst->op_registered)
+ ctx->int_flags |= IO_RING_F_OP_RESTRICTED;
+ if (dst->reg_registered)
+- ctx->int_flags |= IO_RING_F_REG_RESTRICTED;
++ ctx->int_flags |= IO_RING_F_REG_RESTRICTED |
++ IO_RING_F_RESTRICT_INHERITED;
+ }
+
+ static __cold int io_uring_create(struct io_ctx_config *config)
+diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
+index 1cf5be62bb6563..5065a3eff80946 100644
+--- a/io_uring/kbuf.c
++++ b/io_uring/kbuf.c
+@@ -458,7 +458,7 @@ static int io_remove_buffers_legacy(struct io_ring_ctx *ctx,
+ static void io_put_bl(struct io_ring_ctx *ctx, struct io_buffer_list *bl)
+ {
+ if (bl->flags & IOBL_BUF_RING)
+- io_free_region(ctx->user, &bl->region);
++ io_free_region(NULL, &bl->region);
+ else
+ io_remove_buffers_legacy(ctx, bl, -1U);
+
+@@ -675,7 +675,7 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
+ rd.user_addr = reg.ring_addr;
+ rd.flags |= IORING_MEM_REGION_TYPE_USER;
+ }
+- ret = io_create_region(ctx, &bl->region, &rd, mmap_offset);
++ ret = io_create_region(NULL, &bl->region, &rd, mmap_offset);
+ if (ret)
+ goto fail;
+ br = io_region_get_ptr(&bl->region);
+@@ -708,7 +708,7 @@ int io_register_pbuf_ring(struct io_ring_ctx *ctx, void __user *arg)
+ if (!ret)
+ return 0;
+ fail:
+- io_free_region(ctx->user, &bl->region);
++ io_free_region(NULL, &bl->region);
+ kfree(bl);
+ return ret;
+ }
+diff --git a/io_uring/memmap.c b/io_uring/memmap.c
+index 23e8a85111bca6..d4d71694697149 100644
+--- a/io_uring/memmap.c
++++ b/io_uring/memmap.c
+@@ -16,8 +16,10 @@
+ #include "zcrx.h"
+
+ static bool io_mem_alloc_compound(struct page **pages, int nr_pages,
+- size_t size, gfp_t gfp)
++ size_t size, gfp_t gfp,
++ struct user_struct *user)
+ {
++ unsigned long nr_compound, extra;
+ struct page *page;
+ int i, order;
+
+@@ -27,9 +29,22 @@ static bool io_mem_alloc_compound(struct page **pages, int nr_pages,
+ else if (order)
+ gfp |= __GFP_COMP;
+
++ /*
++ * get_order() rounds a non power of two size up, so the allocation
++ * can hold more pages than the region exposes. Account those too,
++ * and leave the compound allocation alone if they do not fit.
++ */
++ nr_compound = 1UL << order;
++ extra = nr_compound - nr_pages;
++ if (extra && user && __io_account_mem(user, extra))
++ return false;
++
+ page = alloc_pages(gfp, order);
+- if (!page)
++ if (!page) {
++ if (extra && user)
++ __io_unaccount_mem(user, extra);
+ return false;
++ }
+
+ for (i = 0; i < nr_pages; i++)
+ pages[i] = page + i;
+@@ -105,8 +120,15 @@ void io_free_region(struct user_struct *user, struct io_mapped_region *mr)
+ }
+ if ((mr->flags & IO_REGION_F_VMAP) && mr->ptr)
+ vunmap(mr->ptr);
+- if (mr->nr_pages && user)
+- __io_unaccount_mem(user, mr->nr_pages);
++ if (mr->nr_pages && user) {
++ unsigned long nr_accounted = mr->nr_pages;
++
++ /* a compound region was accounted for the whole allocation */
++ if (mr->flags & IO_REGION_F_SINGLE_REF)
++ nr_accounted = 1UL << get_order(io_region_size(mr));
++
++ __io_unaccount_mem(user, nr_accounted);
++ }
+
+ memset(mr, 0, sizeof(*mr));
+ }
+@@ -151,7 +173,8 @@ static int io_region_pin_pages(struct io_mapped_region *mr,
+
+ static int io_region_allocate_pages(struct io_mapped_region *mr,
+ struct io_uring_region_desc *reg,
+- unsigned long mmap_offset)
++ unsigned long mmap_offset,
++ struct user_struct *user)
+ {
+ gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO | __GFP_NOWARN;
+ size_t size = io_region_size(mr);
+@@ -162,7 +185,7 @@ static int io_region_allocate_pages(struct io_mapped_region *mr,
+ if (!pages)
+ return -ENOMEM;
+
+- if (io_mem_alloc_compound(pages, mr->nr_pages, size, gfp)) {
++ if (io_mem_alloc_compound(pages, mr->nr_pages, size, gfp, user)) {
+ mr->flags |= IO_REGION_F_SINGLE_REF;
+ goto done;
+ }
+@@ -181,7 +204,7 @@ done:
+ return 0;
+ }
+
+-int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr,
++int io_create_region(struct user_struct *user, struct io_mapped_region *mr,
+ struct io_uring_region_desc *reg,
+ unsigned long mmap_offset)
+ {
+@@ -207,8 +230,8 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr,
+ return -EOVERFLOW;
+
+ nr_pages = reg->size >> PAGE_SHIFT;
+- if (ctx->user) {
+- ret = __io_account_mem(ctx->user, nr_pages);
++ if (user) {
++ ret = __io_account_mem(user, nr_pages);
+ if (ret)
+ return ret;
+ }
+@@ -217,7 +240,7 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr,
+ if (reg->flags & IORING_MEM_REGION_TYPE_USER)
+ ret = io_region_pin_pages(mr, reg);
+ else
+- ret = io_region_allocate_pages(mr, reg, mmap_offset);
++ ret = io_region_allocate_pages(mr, reg, mmap_offset, user);
+ if (ret)
+ goto out_free;
+
+@@ -226,7 +249,7 @@ int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr,
+ goto out_free;
+ return 0;
+ out_free:
+- io_free_region(ctx->user, mr);
++ io_free_region(user, mr);
+ return ret;
+ }
+
+diff --git a/io_uring/memmap.h b/io_uring/memmap.h
+index f4cfbb6b9a1f46..0714bb5a9616ef 100644
+--- a/io_uring/memmap.h
++++ b/io_uring/memmap.h
+@@ -18,7 +18,7 @@ unsigned long io_uring_get_unmapped_area(struct file *file, unsigned long addr,
+ int io_uring_mmap(struct file *file, struct vm_area_struct *vma);
+
+ void io_free_region(struct user_struct *user, struct io_mapped_region *mr);
+-int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr,
++int io_create_region(struct user_struct *user, struct io_mapped_region *mr,
+ struct io_uring_region_desc *reg,
+ unsigned long mmap_offset);
+
+diff --git a/io_uring/net.c b/io_uring/net.c
+index e6847fb084abcb..37fc7baa55b277 100644
+--- a/io_uring/net.c
++++ b/io_uring/net.c
+@@ -7,6 +7,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+
+ #include
+@@ -1772,7 +1773,8 @@ void io_connect_bpf_populate(struct io_uring_bpf_ctx *bctx, struct io_kiocb *req
+ case AF_INET6: {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ss;
+
+- if (conn->addr_len < (int)sizeof(*sin6))
++ /* The IPv6 stack accepts SIN6_LEN_RFC2133; port and addr are in it. */
++ if (conn->addr_len < SIN6_LEN_RFC2133)
+ break;
+ bctx->connect.port = sin6->sin6_port;
+ memcpy(bctx->connect.v6_addr, &sin6->sin6_addr,
+diff --git a/io_uring/register.c b/io_uring/register.c
+index 02bc103bcc9d54..dab3eb4258dffe 100644
+--- a/io_uring/register.c
++++ b/io_uring/register.c
+@@ -480,8 +480,9 @@ struct io_ring_ctx_rings {
+ static void io_register_free_rings(struct io_ring_ctx *ctx,
+ struct io_ring_ctx_rings *r)
+ {
+- io_free_region(ctx->user, &r->sq_region);
+- io_free_region(ctx->user, &r->ring_region);
++ /* ring memory is not charged to RLIMIT_MEMLOCK, hence no user */
++ io_free_region(NULL, &r->sq_region);
++ io_free_region(NULL, &r->ring_region);
+ }
+
+ #define swap_old(ctx, o, n, field) \
+@@ -529,7 +530,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
+ rd.user_addr = p->cq_off.user_addr;
+ rd.flags |= IORING_MEM_REGION_TYPE_USER;
+ }
+- ret = io_create_region(ctx, &n.ring_region, &rd, IORING_OFF_CQ_RING);
++ ret = io_create_region(NULL, &n.ring_region, &rd, IORING_OFF_CQ_RING);
+ if (ret)
+ return ret;
+
+@@ -559,7 +560,7 @@ static int io_register_resize_rings(struct io_ring_ctx *ctx, void __user *arg)
+ rd.user_addr = p->sq_off.user_addr;
+ rd.flags |= IORING_MEM_REGION_TYPE_USER;
+ }
+- ret = io_create_region(ctx, &n.sq_region, &rd, IORING_OFF_SQES);
++ ret = io_create_region(NULL, &n.sq_region, &rd, IORING_OFF_SQES);
+ if (ret) {
+ io_register_free_rings(ctx, &n);
+ return ret;
+@@ -730,7 +731,8 @@ static int io_register_mem_region(struct io_ring_ctx *ctx, void __user *uarg)
+ !(ctx->flags & IORING_SETUP_R_DISABLED))
+ return -EINVAL;
+
+- ret = io_create_region(ctx, ®ion, &rd, IORING_MAP_OFF_PARAM_REGION);
++ ret = io_create_region(ctx->user, ®ion, &rd,
++ IORING_MAP_OFF_PARAM_REGION);
+ if (ret)
+ return ret;
+ if (copy_to_user(rd_uptr, &rd, sizeof(rd))) {
+@@ -764,7 +766,14 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode,
+ if (ctx->submitter_task && ctx->submitter_task != current)
+ return -EEXIST;
+
+- if ((ctx->int_flags & IO_RING_F_REG_RESTRICTED) && !(ctx->flags & IORING_SETUP_R_DISABLED)) {
++ /*
++ * A disabled ring is exempt from its own register restrictions, so
++ * that the creator can set them up and then enable the ring. That
++ * does not apply to restrictions inherited from the task.
++ */
++ if ((ctx->int_flags & IO_RING_F_REG_RESTRICTED) &&
++ (!(ctx->flags & IORING_SETUP_R_DISABLED) ||
++ (ctx->int_flags & IO_RING_F_RESTRICT_INHERITED))) {
+ opcode = array_index_nospec(opcode, IORING_REGISTER_LAST);
+ if (!test_bit(opcode, ctx->restrictions.register_op))
+ return -EACCES;
+diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
+index 1b6832f6e10fa2..0a9e8a58b99a14 100644
+--- a/io_uring/zcrx.c
++++ b/io_uring/zcrx.c
+@@ -398,7 +398,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
+ mmap_offset = IORING_MAP_OFF_ZCRX_REGION;
+ mmap_offset += (u64)id << IORING_OFF_ZCRX_SHIFT;
+
+- ret = io_create_region(ctx, &ifq->rq_region, rd, mmap_offset);
++ ret = io_create_region(ctx->user, &ifq->rq_region, rd, mmap_offset);
+ if (ret < 0)
+ return ret;
+
+diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
+index c43f15c9917c1a..501f12de533f42 100644
+--- a/kernel/cgroup/cpuset.c
++++ b/kernel/cgroup/cpuset.c
+@@ -151,6 +151,12 @@ static cpumask_var_t isolated_cpus; /* CSCB */
+ */
+ static bool update_housekeeping; /* RWCS */
+
++/*
++ * Set if "cpuset_v2_mode" mount option is used
++ * Cached at bind time and not lock protected; accessed via {READ,WRITE}_ONCE
++ */
++static bool cpuset_v2_mode;
++
+ /*
+ * Copy of isolated_cpus to be passed to housekeeping_update()
+ */
+@@ -403,8 +409,7 @@ static inline bool cpuset_v2(void)
+ */
+ static inline bool is_in_v2_mode(void)
+ {
+- return cpuset_v2() ||
+- (cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE);
++ return cpuset_v2() || READ_ONCE(cpuset_v2_mode);
+ }
+
+ /**
+@@ -478,10 +483,26 @@ static void guarantee_active_cpus(struct task_struct *tsk,
+ rcu_read_lock();
+ cs = task_cs(tsk);
+
+- while (!cpumask_intersects(cs->effective_cpus, pmask))
++ while (!cpumask_intersects(cs->effective_cpus, pmask)) {
+ cs = parent_cs(cs);
+-
++ if (unlikely(!cs)) {
++ /*
++ * The top cpuset doesn't have any active cpu as a
++ * consequence of a race between its caller and the cpu
++ * hotplug operation where cpu_active_mask is updated
++ * asynchronously before cpuset_handle_hotplug() is
++ * being called to adjust the effective_cpus of the
++ * affected cpusets. But we know the top cpuset's
++ * effective_cpus is on its way to be identical to
++ * cpu_active_mask minus the exclusive CPUs dedicated
++ * to other valid cpuset partitions. Just pass back
++ * the filtered cpu_active_mask in this case.
++ */
++ goto out_unlock;
++ }
++ }
+ cpumask_and(pmask, pmask, cs->effective_cpus);
++out_unlock:
+ rcu_read_unlock();
+ }
+
+@@ -3586,6 +3607,8 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css)
+ mutex_lock(&cpuset_mutex);
+ spin_lock_irq(&callback_lock);
+
++ WRITE_ONCE(cpuset_v2_mode,
++ !!(cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE));
+ if (is_in_v2_mode()) {
+ cpumask_copy(top_cpuset.cpus_allowed, cpu_possible_mask);
+ cpumask_copy(top_cpuset.effective_xcpus, cpu_possible_mask);
+@@ -3902,15 +3925,16 @@ static void cpuset_handle_hotplug(void)
+ static cpumask_t new_cpus;
+ static nodemask_t new_mems;
+ bool cpus_updated, mems_updated;
+- bool on_dfl = is_in_v2_mode();
++ bool on_dfl;
+ struct tmpmasks tmp, *ptmp = NULL;
+
+- if (on_dfl && !alloc_tmpmasks(&tmp))
+- ptmp = &tmp;
+-
+ lockdep_assert_cpus_held();
+ mutex_lock(&cpuset_mutex);
+
++ on_dfl = is_in_v2_mode();
++ if (on_dfl && !alloc_tmpmasks(&tmp))
++ ptmp = &tmp;
++
+ /* fetch the available cpus/mems and find out which changed how */
+ cpumask_copy(&new_cpus, cpu_active_mask);
+ new_mems = node_states[N_MEMORY];
+diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
+index bd539313375336..08ded023328f69 100644
+--- a/kernel/dma/swiotlb.c
++++ b/kernel/dma/swiotlb.c
+@@ -1680,10 +1680,10 @@ phys_addr_t default_swiotlb_base(void)
+ phys_addr_t default_swiotlb_limit(void)
+ {
+ #ifdef CONFIG_SWIOTLB_DYNAMIC
+- return io_tlb_default_mem.phys_limit;
+-#else
+- return io_tlb_default_mem.defpool.end - 1;
++ if (io_tlb_default_mem.can_grow)
++ return io_tlb_default_mem.phys_limit;
+ #endif
++ return io_tlb_default_mem.defpool.end - 1;
+ }
+
+ #ifdef CONFIG_DEBUG_FS
+diff --git a/kernel/fork.c b/kernel/fork.c
+index b22b5ba9a5431b..854448152696b2 100644
+--- a/kernel/fork.c
++++ b/kernel/fork.c
+@@ -3326,8 +3326,9 @@ int ksys_unshare(unsigned long unshare_flags)
+ perf_event_namespaces(current);
+
+ bad_unshare_cleanup_nsproxy:
++ /* never installed, so no active references to drop */
+ if (new_nsproxy)
+- put_nsproxy(new_nsproxy);
++ nsproxy_free(new_nsproxy);
+ bad_unshare_cleanup_cred:
+ if (new_cred)
+ put_cred(new_cred);
+diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
+index d9d3d5973bf523..3fb1595a4a5934 100644
+--- a/kernel/nsproxy.c
++++ b/kernel/nsproxy.c
+@@ -61,7 +61,7 @@ static inline struct nsproxy *create_nsproxy(void)
+ return nsproxy;
+ }
+
+-static inline void nsproxy_free(struct nsproxy *ns)
++void nsproxy_free(struct nsproxy *ns)
+ {
+ put_mnt_ns(ns->mnt_ns);
+ put_uts_ns(ns->uts_ns);
+diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
+index cd7cbd1c99a263..a9f33e2b17aceb 100644
+--- a/kernel/sched/ext/ext.c
++++ b/kernel/sched/ext/ext.c
+@@ -1953,8 +1953,14 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
+ if (unlikely(!SCX_HAS_OP(sch, enqueue)))
+ goto global;
+
+- /* DSQ bypass didn't trigger, enqueue on the BPF scheduler */
+- qseq = rq->scx.ops_qseq++ << SCX_OPSS_QSEQ_SHIFT;
++ /*
++ * DSQ bypass didn't trigger, enqueue on the BPF scheduler. Wrap the
++ * per-task qseq counter where the QSEQ field wraps and skip 0, which is
++ * what scx_bpf_dsq_insert() records for a task in NONE or DISPATCHING.
++ */
++ p->scx.ops_qseq = ((p->scx.ops_qseq + 1) &
++ (SCX_OPSS_QSEQ_MASK >> SCX_OPSS_QSEQ_SHIFT)) ?: 1;
++ qseq = (unsigned long)p->scx.ops_qseq << SCX_OPSS_QSEQ_SHIFT;
+
+ WARN_ON_ONCE(atomic_long_read(&p->scx.ops_state) != SCX_OPSS_NONE);
+ atomic_long_set(&p->scx.ops_state, SCX_OPSS_QUEUEING | qseq);
+@@ -2044,6 +2050,13 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_
+ int sticky_cpu = p->scx.sticky_cpu;
+ u64 enq_flags = core_enq_flags | rq->scx.extra_enq_flags;
+
++ /*
++ * An SCX-internal migration ends on arrival. Clear sticky_cpu so @p can
++ * leave custody when inserted into the destination DSQ.
++ */
++ if (sticky_cpu >= 0)
++ p->scx.sticky_cpu = -1;
++
+ /*
+ * SCX_RQ_IN_WAKEUP promises a task_woken_scx() call once this enqueue
+ * returns. Only the core's wakeup path delivers one. The flags stashed
+@@ -2082,9 +2095,6 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_
+ dl_server_start(&rq->ext_server);
+
+ do_enqueue_task(rq, p, enq_flags, sticky_cpu);
+-
+- if (sticky_cpu >= 0)
+- p->scx.sticky_cpu = -1;
+ out:
+ rq->scx.flags &= ~SCX_RQ_IN_WAKEUP;
+
+@@ -6690,10 +6700,9 @@ static void scx_dump_cpu(struct scx_sched *sch, struct seq_buf *s,
+ seq_buf_init(&ns, buf, avail);
+
+ dump_newline(&ns);
+- dump_line(&ns, "CPU %-4d: nr_run=%u flags=0x%x cpu_rel=%d ops_qseq=%lu ksync=%lu",
++ dump_line(&ns, "CPU %-4d: nr_run=%u flags=0x%x cpu_rel=%d ksync=%lu",
+ cpu, rq->scx.nr_running, rq->scx.flags,
+- rq->scx.cpu_released, rq->scx.ops_qseq,
+- rq->scx.kick_sync);
++ rq->scx.cpu_released, rq->scx.kick_sync);
+ dump_line(&ns, " curr=%s[%d] class=%ps",
+ rq->curr->comm, rq->curr->pid,
+ rq->curr->sched_class);
+diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
+index b295991b9f10c5..3cd223c6d7639a 100644
+--- a/kernel/sched/ext/internal.h
++++ b/kernel/sched/ext/internal.h
+@@ -1508,6 +1508,11 @@ enum scx_ops_state {
+ * dequeue/requeue, the dispatcher can tell whether it still has a claim
+ * on the task being dispatched.
+ *
++ * QSEQ is generated from the per-task p->scx.ops_qseq counter so that
++ * it doesn't repeat across QUEUED instances of the same task even if
++ * the task moves between rqs. 0 is never used as a valid QSEQ since
++ * NONE and DISPATCHING map to this value.
++ *
+ * As some 32bit archs can't do 64bit store_release/load_acquire,
+ * p->scx.ops_state is atomic_long_t which leaves 30 bits for QSEQ on
+ * 32bit machines. The dispatch race window QSEQ protects is very narrow
+diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
+index f76e6f7f4a0147..a6c6f8165eecc8 100644
+--- a/kernel/sched/sched.h
++++ b/kernel/sched/sched.h
+@@ -795,7 +795,6 @@ struct scx_rq {
+ struct scx_dispatch_q local_dsq;
+ struct list_head runnable_list; /* runnable tasks on this rq */
+ struct list_head ddsp_deferred_locals; /* deferred ddsps from enq */
+- unsigned long ops_qseq;
+ u64 extra_enq_flags; /* see move_task_to_local_dsq() */
+ u32 nr_running;
+ u32 cpuperf_target; /* [0, SCHED_CAPACITY_SCALE] */
+diff --git a/kernel/workqueue.c b/kernel/workqueue.c
+index 53608ac01fab1b..cb7055aee3afc7 100644
+--- a/kernel/workqueue.c
++++ b/kernel/workqueue.c
+@@ -2244,7 +2244,7 @@ static bool is_chained_work(struct workqueue_struct *wq)
+ * Return %true iff I'm a worker executing a work item on @wq. If
+ * I'm @worker, it's safe to dereference it without locking.
+ */
+- return worker && worker->current_pwq->wq == wq;
++ return worker && worker->current_pwq && worker->current_pwq->wq == wq;
+ }
+
+ /*
+diff --git a/lib/dim/dim.c b/lib/dim/dim.c
+index 97c3d084ebf023..7f3eebae73cb92 100644
+--- a/lib/dim/dim.c
++++ b/lib/dim/dim.c
+@@ -69,11 +69,15 @@ bool dim_calc_stats(const struct dim_sample *start,
+ if (!delta_us)
+ return false;
+
+- curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us);
+- curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
++ /* u32 * USEC_PER_MSEC overflows a 32-bit long */
++ curr_stats->ppms = DIV_ROUND_UP_ULL((u64)npkts * USEC_PER_MSEC,
++ delta_us);
++ curr_stats->bpms = DIV_ROUND_UP_ULL((u64)nbytes * USEC_PER_MSEC,
++ delta_us);
+ curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC,
+ delta_us);
+- curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us);
++ curr_stats->cpms = DIV_ROUND_UP_ULL((u64)ncomps * USEC_PER_MSEC,
++ delta_us);
+ if (curr_stats->epms != 0)
+ curr_stats->cpe_ratio = DIV_ROUND_DOWN_ULL(
+ curr_stats->cpms * 100, curr_stats->epms);
+diff --git a/mm/mremap.c b/mm/mremap.c
+index ecd92620956055..ff1cf59b26c710 100644
+--- a/mm/mremap.c
++++ b/mm/mremap.c
+@@ -1029,6 +1029,7 @@ static void vrm_stat_account(struct vma_remap_struct *vrm,
+ }
+
+ static bool __check_map_count_against_split(struct mm_struct *mm,
++ bool pre_split,
+ bool before_unmaps)
+ {
+ const int sys_map_count = get_sysctl_max_map_count();
+@@ -1080,26 +1081,42 @@ static bool __check_map_count_against_split(struct mm_struct *mm,
+ * Therefore we must check to ensure we have headroom of 2 additional
+ * VMAs.
+ */
+- return map_count + 2 <= sys_map_count;
++ map_count += 2;
++
++ /* If pre-split, the -1 observed above doesn't apply. */
++ if (pre_split)
++ map_count++;
++
++ return map_count <= sys_map_count;
++}
++
++static bool needs_pre_split(struct vma_remap_struct *vrm)
++{
++ /*
++ * An MREMAP_DONTUNMAP of a mlock()'d VMA needs to unlock the
++ * source VMA, so split in this case.
++ */
++ return (vrm->flags & MREMAP_DONTUNMAP) &&
++ vma_test(vrm->vma, VMA_LOCKED_BIT);
+ }
+
+ /* Do we violate the map count limit if we split VMAs when moving the VMA? */
+-static bool check_map_count_against_split(void)
++static bool check_map_count_against_split(struct vma_remap_struct *vrm)
+ {
+ return __check_map_count_against_split(current->mm,
+- /*before_unmaps=*/false);
++ needs_pre_split(vrm), /*before_unmaps=*/false);
+ }
+
+ /* Do we violate the map count limit if we split VMAs prior to early unmaps? */
+-static bool check_map_count_against_split_early(void)
++static bool check_map_count_against_split_early(struct vma_remap_struct *vrm)
+ {
+ return __check_map_count_against_split(current->mm,
+- /*before_unmaps=*/true);
++ vrm->flags & MREMAP_DONTUNMAP, /*before_unmaps=*/true);
+ }
+
+ /*
+- * Perform checks before attempting to write a VMA prior to it being
+- * moved.
++ * Perform checks and preparation before attempting to write a VMA prior to it
++ * being moved.
+ */
+ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
+ {
+@@ -1108,19 +1125,17 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
+ unsigned long old_addr = vrm->addr;
+ unsigned long old_len = vrm->old_len;
+ vm_flags_t dummy = vma->vm_flags;
++ const bool split_before = vma->vm_start != old_addr;
++ const bool split_after = vma->vm_end != old_addr + old_len;
+
+- /*
+- * We'd prefer to avoid failure later on in do_munmap: we copy a VMA,
+- * which may not merge, then (if MREMAP_DONTUNMAP is not set) unmap the
+- * source, which may split, causing a net increase of 2 mappings.
+- */
+- if (!check_map_count_against_split())
++ /* Avoid failure later on. */
++ if (!check_map_count_against_split(vrm))
+ return -ENOMEM;
+
+ if (vma->vm_ops && vma->vm_ops->may_split) {
+- if (vma->vm_start != old_addr)
++ if (split_before)
+ err = vma->vm_ops->may_split(vma, old_addr);
+- if (!err && vma->vm_end != old_addr + old_len)
++ if (!err && split_after)
+ err = vma->vm_ops->may_split(vma, old_addr + old_len);
+ if (err)
+ return err;
+@@ -1138,6 +1153,21 @@ static unsigned long prep_move_vma(struct vma_remap_struct *vrm)
+ if (err)
+ return err;
+
++ /*
++ * To account mlock()'d pages correctly in the MREMAP_DONTUNMAP
++ * case perform any split ahead of time for an mlock()'d VMA.
++ */
++ if (needs_pre_split(vrm)) {
++ VMA_ITERATOR(vmi, vma->vm_mm, old_addr);
++
++ if (split_before)
++ err = split_vma(&vmi, vma, old_addr, 1);
++ if (!err && split_after)
++ err = split_vma(&vmi, vma, old_addr + old_len, 0);
++ vrm->vmi_needs_invalidate = true;
++ return err;
++ }
++
+ return 0;
+ }
+
+@@ -1265,7 +1295,8 @@ static int copy_vma_and_data(struct vma_remap_struct *vrm,
+ PAGETABLE_MOVE(pmc, NULL, NULL, vrm->addr, vrm->new_addr, vrm->old_len);
+
+ new_vma = copy_vma(&vma, vrm->new_addr, vrm->new_len, new_pgoff,
+- &pmc.need_rmap_locks);
++ &pmc.need_rmap_locks,
++ vrm->flags & MREMAP_DONTUNMAP);
+ if (!new_vma) {
+ vrm_uncharge(vrm);
+ *new_vma_ptr = NULL;
+@@ -1325,6 +1356,9 @@ static void dontunmap_complete(struct vma_remap_struct *vrm,
+ unsigned long old_start = vma->vm_start;
+ unsigned long old_end = vma->vm_end;
+
++ /* Self-merge is disallowed. */
++ VM_WARN_ON_ONCE(new_vma == vma);
++
+ /* We always clear VM_LOCKED[ONFAULT] on the old VMA. */
+ vm_flags_clear(vma, VM_LOCKED_MASK);
+
+@@ -1332,7 +1366,7 @@ static void dontunmap_complete(struct vma_remap_struct *vrm,
+ * anon_vma links of the old vma is no longer needed after its page
+ * table has been moved.
+ */
+- if (new_vma != vma && start == old_start && end == old_end) {
++ if (start == old_start && end == old_end) {
+ const pgoff_t pgoff_unfaulted = vma->vm_start >> PAGE_SHIFT;
+
+ unlink_anon_vmas(vma);
+@@ -1992,7 +2026,7 @@ static unsigned long do_mremap(struct vma_remap_struct *vrm)
+ return -EINTR;
+ vrm->mmap_locked = true;
+
+- if (!check_map_count_against_split_early()) {
++ if (!check_map_count_against_split_early(vrm)) {
+ mmap_write_unlock(mm);
+ return -ENOMEM;
+ }
+diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c
+index b91b1a98029c7f..cd227fc05d2d8f 100644
+--- a/mm/pgtable-generic.c
++++ b/mm/pgtable-generic.c
+@@ -438,12 +438,30 @@ static void kernel_pgtable_work_func(struct work_struct *work)
+ __pagetable_free(pt);
+ }
+
++static void schedule_kernel_pgtable_free(void)
++{
++ schedule_work(&kernel_pgtable_work.work);
++}
++
+ void pagetable_free_kernel(struct ptdesc *pt)
+ {
+ spin_lock(&kernel_pgtable_work.lock);
+ list_add(&pt->pt_list, &kernel_pgtable_work.list);
+ spin_unlock(&kernel_pgtable_work.lock);
+
+- schedule_work(&kernel_pgtable_work.work);
++ /*
++ * The workqueue may not exist yet while the system is booting.
++ * kernel_pgtable_drain_early() schedules the work once it does.
++ */
++ if (system_state != SYSTEM_BOOTING)
++ schedule_kernel_pgtable_free();
++}
++
++static int __init kernel_pgtable_drain_early(void)
++{
++ /* Free the kernel page tables queued while booting. */
++ schedule_kernel_pgtable_free();
++ return 0;
+ }
++core_initcall(kernel_pgtable_drain_early);
+ #endif
+diff --git a/mm/vma.c b/mm/vma.c
+index 8f7f77a4c7cece..07881c0987cf9f 100644
+--- a/mm/vma.c
++++ b/mm/vma.c
+@@ -590,8 +590,8 @@ out_free_vma:
+ * Split a vma into two pieces at address 'addr', a new vma is allocated
+ * either for the first part or the tail.
+ */
+-static int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma,
+- unsigned long addr, int new_below)
++int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma,
++ unsigned long addr, int new_below)
+ {
+ if (vma->vm_mm->map_count >= get_sysctl_max_map_count())
+ return -ENOMEM;
+@@ -1863,7 +1863,7 @@ static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma)
+ */
+ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+ unsigned long addr, unsigned long len, pgoff_t pgoff,
+- bool *need_rmap_locks)
++ bool *need_rmap_locks, bool keep_source)
+ {
+ struct vm_area_struct *vma = *vmap;
+ unsigned long vma_start = vma->vm_start;
+@@ -1896,6 +1896,21 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+
+ vmg.pgoff = pgoff;
+ vmg.next = vma_iter_next_rewind(&vmi, NULL);
++
++ /*
++ * If the original VMA is kept (MREMAP_DONTUNMAP), the source and
++ * destination VMA must be treated distinctly.
++ *
++ * A merge violates this, so in this case disallow a self-merge.
++ */
++ if (!faulted_in_anon_vma && keep_source) {
++ if (vmg.prev == vma)
++ vmg.prev = NULL;
++ if (vmg.next == vma)
++ vmg.next = NULL;
++ faulted_in_anon_vma = true;
++ }
++
+ new_vma = vma_merge_copied_range(&vmg);
+
+ if (new_vma) {
+diff --git a/mm/vma.h b/mm/vma.h
+index 8e4b61a7304c68..3d2fa4f0d7779d 100644
+--- a/mm/vma.h
++++ b/mm/vma.h
+@@ -449,7 +449,7 @@ void unlink_file_vma_batch_add(struct unlink_vma_file_batch *vb,
+
+ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
+ unsigned long addr, unsigned long len, pgoff_t pgoff,
+- bool *need_rmap_locks);
++ bool *need_rmap_locks, bool keep_source);
+
+ struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *vma);
+
+@@ -470,6 +470,11 @@ int do_brk_flags(struct vma_iterator *vmi, struct vm_area_struct *brkvma,
+ unsigned long unmapped_area(struct vm_unmapped_area_info *info);
+ unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
+
++#ifdef CONFIG_MMU
++int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma,
++ unsigned long addr, int new_below);
++#endif
++
+ static inline bool vma_wants_manual_pte_write_upgrade(struct vm_area_struct *vma)
+ {
+ /*
+diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
+index aea017ee5b0a36..b19e68844e1a98 100644
+--- a/net/bluetooth/hci_core.c
++++ b/net/bluetooth/hci_core.c
+@@ -4113,9 +4113,11 @@ static int hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)
+
+ bt_dev_dbg(hdev, "skb %p", skb);
+
++ hci_dev_lock(hdev);
+ kfree_skb(hdev->sent_cmd);
+
+ hdev->sent_cmd = skb_clone(skb, GFP_KERNEL);
++ hci_dev_unlock(hdev);
+ if (!hdev->sent_cmd) {
+ skb_queue_head(&hdev->cmd_q, skb);
+ queue_work(hdev->workqueue, &hdev->cmd_work);
+@@ -4136,8 +4138,10 @@ static int hci_send_cmd_sync(struct hci_dev *hdev, struct sk_buff *skb)
+
+ if (READ_ONCE(hdev->req_status) == HCI_REQ_PEND &&
+ !hci_dev_test_and_set_flag(hdev, HCI_CMD_PENDING)) {
++ hci_dev_lock(hdev);
+ kfree_skb(hdev->req_skb);
+ hdev->req_skb = skb_get(hdev->sent_cmd);
++ hci_dev_unlock(hdev);
+ }
+
+ return err;
+diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
+index 6d56c77741e194..81068b585764e8 100644
+--- a/net/bluetooth/hci_sock.c
++++ b/net/bluetooth/hci_sock.c
+@@ -1223,8 +1223,10 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr_unsized *addr,
+ */
+ hdev = hci_pi(sk)->hdev;
+ if (hdev && hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
++ write_lock(&hci_sk_list.lock);
+ hci_pi(sk)->hdev = NULL;
+ sk->sk_state = BT_OPEN;
++ write_unlock(&hci_sk_list.lock);
+ hci_dev_put(hdev);
+ }
+ hdev = NULL;
+diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
+index 17882feeeeee08..110135848bd69d 100644
+--- a/net/bluetooth/hci_sync.c
++++ b/net/bluetooth/hci_sync.c
+@@ -32,8 +32,10 @@ static void hci_cmd_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,
+ WRITE_ONCE(hdev->req_status, HCI_REQ_DONE);
+
+ /* Free the request command so it is not used as response */
++ hci_dev_lock(hdev);
+ kfree_skb(hdev->req_skb);
+ hdev->req_skb = NULL;
++ hci_dev_unlock(hdev);
+
+ if (skb) {
+ struct sock *sk = hci_skb_sk(skb);
+@@ -3060,15 +3062,21 @@ static int hci_le_set_ext_scan_param_sync(struct hci_dev *hdev, u8 type,
+ */
+ if (hci_dev_test_flag(hdev, HCI_PA_SYNC)) {
+ struct hci_cp_le_add_to_accept_list *sent;
++ bdaddr_t bdaddr;
+
++ hci_dev_lock(hdev);
+ sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_ACCEPT_LIST);
++ if (sent)
++ bacpy(&bdaddr, &sent->bdaddr);
++ hci_dev_unlock(hdev);
++
+ if (sent) {
+ struct hci_conn *conn;
+
+ rcu_read_lock();
+
+ conn = hci_conn_hash_lookup_ba(hdev, PA_LINK,
+- &sent->bdaddr);
++ &bdaddr);
+ if (conn) {
+ struct bt_iso_qos *qos = &conn->iso_qos;
+
+diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
+index 7657c2a0abbf7c..d6ac5b1f49bc13 100644
+--- a/net/bluetooth/iso.c
++++ b/net/bluetooth/iso.c
+@@ -61,6 +61,7 @@ enum {
+ BT_SK_BIG_SYNC,
+ BT_SK_PA_SYNC,
+ BT_SK_KILLED,
++ BT_SK_CONNECTING,
+ };
+
+ struct iso_pinfo {
+@@ -350,6 +351,9 @@ static int __iso_chan_add(struct iso_conn *conn, struct sock *sk,
+ return -EBUSY;
+ }
+
++ if (iso_pi(sk)->conn)
++ return -EISCONN;
++
+ if (!conn->hcon) {
+ BT_ERR("conn->hcon missing");
+ return -EIO;
+@@ -410,6 +414,11 @@ static int iso_connect_bis(struct sock *sk)
+ hci_dev_lock(hdev);
+ lock_sock(sk);
+
++ if (iso_pi(sk)->conn) {
++ err = -EISCONN;
++ goto unlock;
++ }
++
+ if (!bis_capable(hdev)) {
+ err = -EOPNOTSUPP;
+ goto unlock;
+@@ -562,6 +571,13 @@ static int iso_connect_cis(struct sock *sk)
+
+ lockdep_assert_held(&hcon->hdev->lock);
+
++ /* The socket lock keeps the current attachment and its hcon stable. */
++ if (iso_pi(sk)->conn && iso_pi(sk)->conn->hcon != hcon) {
++ hci_conn_drop(hcon);
++ err = -EISCONN;
++ goto unlock;
++ }
++
+ conn = iso_conn_add(hcon);
+ if (!conn) {
+ hci_conn_drop(hcon);
+@@ -1269,17 +1285,26 @@ static int iso_sock_connect(struct socket *sock, struct sockaddr_unsized *addr,
+ addr->sa_family != AF_BLUETOOTH)
+ return -EINVAL;
+
+- if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
+- return -EBADFD;
++ lock_sock(sk);
+
+- if (sk->sk_type != SOCK_SEQPACKET)
+- return -EINVAL;
++ if ((sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) ||
++ test_bit(BT_SK_CONNECTING, &iso_pi(sk)->flags)) {
++ err = -EBADFD;
++ goto done;
++ }
++
++ if (sk->sk_type != SOCK_SEQPACKET) {
++ err = -EINVAL;
++ goto done;
++ }
+
+ /* Check if the address type is of LE type */
+- if (!bdaddr_type_is_le(sa->iso_bdaddr_type))
+- return -EINVAL;
++ if (!bdaddr_type_is_le(sa->iso_bdaddr_type)) {
++ err = -EINVAL;
++ goto done;
++ }
+
+- lock_sock(sk);
++ set_bit(BT_SK_CONNECTING, &iso_pi(sk)->flags);
+
+ bacpy(&iso_pi(sk)->dst, &sa->iso_bdaddr);
+ iso_pi(sk)->dst_type = sa->iso_bdaddr_type;
+@@ -1291,16 +1316,18 @@ static int iso_sock_connect(struct socket *sock, struct sockaddr_unsized *addr,
+ else
+ err = iso_connect_bis(sk);
+
+- if (err)
+- return err;
+-
+ lock_sock(sk);
+
++ clear_bit(BT_SK_CONNECTING, &iso_pi(sk)->flags);
++ if (err)
++ goto done;
++
+ if (!test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
+ err = bt_sock_wait_state(sk, BT_CONNECTED,
+ sock_sndtimeo(sk, flags & O_NONBLOCK));
+ }
+
++done:
+ release_sock(sk);
+ return err;
+ }
+@@ -1340,6 +1367,11 @@ static int iso_listen_bis(struct sock *sk)
+ hci_dev_lock(hdev);
+ lock_sock(sk);
+
++ if (sk->sk_state != BT_BOUND || iso_pi(sk)->conn) {
++ err = -EBADFD;
++ goto unlock;
++ }
++
+ /* Fail if user set invalid QoS */
+ if (iso_pi(sk)->qos_user_set && !check_bcast_qos(&iso_pi(sk)->qos)) {
+ iso_pi(sk)->qos = default_qos;
+diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
+index 2a177cd17a9efb..7928d9e45f98ab 100644
+--- a/net/bluetooth/mgmt.c
++++ b/net/bluetooth/mgmt.c
+@@ -1489,7 +1489,7 @@ static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)
+ return;
+ }
+
+- cmd_status_rsp(cmd, data);
++ cmd_status_rsp(cmd, &match->mgmt_status);
+ }
+
+ static int generic_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
+diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
+index 3f757198051a21..7a7791fe56b0e9 100644
+--- a/net/bluetooth/rfcomm/core.c
++++ b/net/bluetooth/rfcomm/core.c
+@@ -62,10 +62,9 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr);
+
+ static void rfcomm_process_connect(struct rfcomm_session *s);
+
+-static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
+- bdaddr_t *dst,
+- u8 sec_level,
+- int *err);
++static struct socket *rfcomm_session_connect(bdaddr_t *src, bdaddr_t *dst,
++ u8 sec_level, int *err);
++static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state);
+ static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst);
+ static struct rfcomm_session *rfcomm_session_del(struct rfcomm_session *s);
+
+@@ -365,28 +364,17 @@ static int rfcomm_check_channel(u8 channel)
+ return channel < 1 || channel > 30;
+ }
+
+-static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel)
++static int __rfcomm_dlc_open(struct rfcomm_dlc *d, struct rfcomm_session *s,
++ u8 channel)
+ {
+- struct rfcomm_session *s;
+- int err = 0;
+ u8 dlci;
+
+- BT_DBG("dlc %p state %ld %pMR -> %pMR channel %d",
+- d, d->state, src, dst, channel);
+-
+- if (rfcomm_check_channel(channel))
+- return -EINVAL;
++ BT_DBG("dlc %p state %ld session %p channel %d",
++ d, d->state, s, channel);
+
+ if (d->state != BT_OPEN && d->state != BT_CLOSED)
+ return 0;
+
+- s = rfcomm_session_get(src, dst);
+- if (!s) {
+- s = rfcomm_session_create(src, dst, d->sec_level, &err);
+- if (!s)
+- return err;
+- }
+-
+ dlci = __dlci(__session_dir(s), channel);
+
+ /* Check if DLCI already exists */
+@@ -421,14 +409,84 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
+
+ int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel)
+ {
+- int r;
++ struct rfcomm_session *s;
++ struct socket *sock;
++ int err;
++
++ BT_DBG("dlc %p state %ld %pMR -> %pMR channel %d",
++ d, d->state, src, dst, channel);
++
++ if (rfcomm_check_channel(channel))
++ return -EINVAL;
+
+ rfcomm_lock();
+
+- r = __rfcomm_dlc_open(d, src, dst, channel);
++ clear_bit(RFCOMM_CLOSED, &d->flags);
+
++ /* Do not page the remote device for a DLC that cannot be opened
++ * anyway. __rfcomm_dlc_open() looks at the state again once the
++ * lock has been re-acquired below.
++ */
++ if (d->state != BT_OPEN && d->state != BT_CLOSED) {
++ rfcomm_unlock();
++ return 0;
++ }
++
++ s = rfcomm_session_get(src, dst);
++ if (s) {
++ err = __rfcomm_dlc_open(d, s, channel);
++ rfcomm_unlock();
++ return err;
++ }
+ rfcomm_unlock();
+- return r;
++
++ /* There is no session for this pair yet. kernel_connect() ends up in
++ * l2cap_chan_connect(), which takes hdev->lock, and the HCI event
++ * path takes rfcomm_mutex while holding hdev->lock, so the socket has
++ * to be connected with rfcomm_mutex released.
++ */
++ sock = rfcomm_session_connect(src, dst, d->sec_level, &err);
++ if (!sock)
++ return err;
++
++ rfcomm_lock();
++
++ /* The DLC may have been closed while the socket was connecting. It
++ * was not on a session, so rfcomm_dlc_close() could only mark it;
++ * attaching it now would leave it with no owner.
++ */
++ if (test_bit(RFCOMM_CLOSED, &d->flags)) {
++ rfcomm_unlock();
++ sock_release(sock);
++ return -ECONNRESET;
++ }
++
++ /* Another opener may have added a session for the same pair in the
++ * meantime; that one is used and this socket is dropped.
++ */
++ s = rfcomm_session_get(src, dst);
++ if (!s) {
++ s = rfcomm_session_add(sock, BT_BOUND);
++ if (s) {
++ s->initiator = 1;
++ sock = NULL;
++ }
++ }
++
++ err = s ? __rfcomm_dlc_open(d, s, channel) : -ENOMEM;
++
++ rfcomm_unlock();
++
++ if (sock)
++ sock_release(sock);
++
++ /* Over an existing ACL link the connection can complete before the
++ * session reaches the list, and that wakeup is then lost, so let
++ * krfcommd look at the socket state now.
++ */
++ rfcomm_schedule();
++
++ return err;
+ }
+
+ static void __rfcomm_dlc_disconn(struct rfcomm_dlc *d)
+@@ -508,8 +566,14 @@ int rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
+ rfcomm_lock();
+
+ s = d->session;
+- if (!s)
++ if (!s) {
++ /* Not on a session yet: rfcomm_dlc_open() may be connecting a
++ * socket for it with rfcomm_mutex released. Leave a mark so
++ * that it does not attach the DLC once it holds the lock again.
++ */
++ set_bit(RFCOMM_CLOSED, &d->flags);
+ goto no_session;
++ }
+
+ /* after waiting on the mutex check the session still exists
+ * then check the dlc still exists
+@@ -757,12 +821,12 @@ static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s,
+ return rfcomm_session_del(s);
+ }
+
+-static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
+- bdaddr_t *dst,
+- u8 sec_level,
+- int *err)
++/* Creates the L2CAP socket a new session will run on and starts connecting
++ * it. Must be called with rfcomm_mutex released.
++ */
++static struct socket *rfcomm_session_connect(bdaddr_t *src, bdaddr_t *dst,
++ u8 sec_level, int *err)
+ {
+- struct rfcomm_session *s = NULL;
+ struct sockaddr_l2 addr;
+ struct socket *sock;
+ struct sock *sk;
+@@ -792,24 +856,16 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
+ l2cap_pi(sk)->chan->mode = L2CAP_MODE_ERTM;
+ release_sock(sk);
+
+- s = rfcomm_session_add(sock, BT_BOUND);
+- if (!s) {
+- *err = -ENOMEM;
+- goto failed;
+- }
+-
+- s->initiator = 1;
+-
+ bacpy(&addr.l2_bdaddr, dst);
+ addr.l2_family = AF_BLUETOOTH;
+ addr.l2_psm = cpu_to_le16(L2CAP_PSM_RFCOMM);
+ addr.l2_cid = 0;
+ addr.l2_bdaddr_type = BDADDR_BREDR;
+ *err = kernel_connect(sock, (struct sockaddr_unsized *)&addr, sizeof(addr), O_NONBLOCK);
+- if (*err == 0 || *err == -EINPROGRESS)
+- return s;
++ if (*err && *err != -EINPROGRESS)
++ goto failed;
+
+- return rfcomm_session_del(s);
++ return sock;
+
+ failed:
+ sock_release(sock);
+diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
+index d2855f9b3abc3a..0a6ba8ca230f0c 100644
+--- a/net/bluetooth/rfcomm/sock.c
++++ b/net/bluetooth/rfcomm/sock.c
+@@ -48,8 +48,11 @@ static void rfcomm_sock_kill(struct sock *sk);
+ static void rfcomm_sk_data_ready(struct rfcomm_dlc *d, struct sk_buff *skb)
+ {
+ struct sock *sk = d->owner;
+- if (!sk)
++
++ if (!sk) {
++ kfree_skb(skb);
+ return;
++ }
+
+ atomic_add(skb->len, &sk->sk_rmem_alloc);
+ skb_queue_tail(&sk->sk_receive_queue, skb);
+diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
+index dc3cdf614defe2..198c7dd1a95b42 100644
+--- a/net/bluetooth/rfcomm/tty.c
++++ b/net/bluetooth/rfcomm/tty.c
+@@ -128,7 +128,7 @@ static void rfcomm_dev_shutdown(struct tty_port *port)
+ {
+ struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port);
+
+- if (dev->tty_dev->parent)
++ if (dev->tty_dev && dev->tty_dev->parent)
+ device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
+
+ /* close the dlc */
+diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
+index 3d4362a09df4cd..f4a20d7b5f9cb9 100644
+--- a/net/bluetooth/sco.c
++++ b/net/bluetooth/sco.c
+@@ -84,12 +84,14 @@ static void sco_conn_free(struct kref *ref)
+ if (conn->sk)
+ sco_pi(conn->sk)->conn = NULL;
+
+- if (conn->hcon) {
+- conn->hcon->sco_data = NULL;
+- hci_conn_drop(conn->hcon);
+- }
++ /* hcon->sco_data is cleared and the association's reference on the
++ * sco_conn is dropped in sco_conn_del() under hdev->lock, and the
++ * hci_conn is now owned by the socket (held in __sco_chan_add() and
++ * dropped in sco_chan_del()/sco_sock_destruct()), so there is nothing
++ * left to release towards hcon here.
++ */
+
+- /* Ensure no more work items will run since hci_conn has been dropped */
++ /* Ensure no more work items will run before the connection is freed */
+ disable_delayed_work_sync(&conn->timeout_work);
+
+ kfree(conn);
+@@ -188,25 +190,19 @@ static void sco_sock_clear_timer(struct sock *sk)
+ }
+
+ /* ---- SCO connections ---- */
+-/* Consumes a reference on @hcon, which the returned sco_conn owns until it is
+- * freed. On failure (NULL return) the reference is left for the caller to drop.
++/* Returns a new reference the caller must drop with sco_conn_put(). The
++ * hcon->sco_data association holds its own reference on the sco_conn for the
++ * connection's lifetime; it is dropped in sco_conn_del() under hdev->lock.
++ * @hcon is not consumed: the hci_conn reference is taken and owned by the
++ * socket in __sco_chan_add().
+ */
+ static struct sco_conn *sco_conn_add(struct hci_conn *hcon)
+ {
+ struct sco_conn *conn = hcon->sco_data;
+
+ conn = sco_conn_hold_unless_zero(conn);
+- if (conn) {
+- if (!conn->hcon) {
+- sco_conn_lock(conn);
+- conn->hcon = hcon;
+- sco_conn_unlock(conn);
+- } else {
+- /* conn already owns a reference on hcon */
+- hci_conn_drop(hcon);
+- }
++ if (conn)
+ return conn;
+- }
+
+ conn = kzalloc_obj(struct sco_conn);
+ if (!conn)
+@@ -227,7 +223,10 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon)
+
+ BT_DBG("hcon %p conn %p", hcon, conn);
+
+- return conn;
++ /* kref_init() above set the association reference owned by
++ * hcon->sco_data; hand the caller its own reference.
++ */
++ return sco_conn_hold(conn);
+ }
+
+ /* Delete channel.
+@@ -242,6 +241,19 @@ static void sco_chan_del(struct sock *sk, int err)
+ BT_DBG("sk %p, conn %p, err %d", sk, conn, err);
+
+ if (conn) {
++ struct hci_conn *hcon;
++
++ sco_conn_lock(conn);
++ hcon = conn->hcon;
++ sco_conn_unlock(conn);
++
++ /* Drop the socket's hci_conn reference BEFORE clearing
++ * conn->sk, so sco_conn_del() on another CPU cannot free
++ * the hci_conn while we still hold a pointer to it.
++ */
++ if (hcon)
++ hci_conn_drop(hcon);
++
+ sco_conn_lock(conn);
+ conn->sk = NULL;
+ sco_conn_unlock(conn);
+@@ -266,6 +278,13 @@ static void sco_conn_del(struct hci_conn *hcon, int err)
+
+ BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
+
++ /* Detach from the hci_conn and drop the association's reference.
++ * The caller holds hdev->lock, which serialises this against the
++ * read of hcon->sco_data in sco_recv_scodata().
++ */
++ hcon->sco_data = NULL;
++ sco_conn_put(conn);
++
+ sco_conn_lock(conn);
+ sk = sco_sock_hold(conn);
+ sco_conn_unlock(conn);
+@@ -290,6 +309,11 @@ static void __sco_chan_add(struct sco_conn *conn, struct sock *sk,
+ sco_pi(sk)->conn = sco_conn_hold(conn);
+ conn->sk = sk;
+
++ /* The socket owns an hci_conn reference for as long as it stays
++ * attached; it is dropped in sco_chan_del()/sco_sock_destruct().
++ */
++ hci_conn_hold(conn->hcon);
++
+ if (parent)
+ bt_accept_enqueue(parent, sk, true);
+ }
+@@ -371,6 +395,7 @@ static int sco_connect(struct sock *sk)
+ if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) {
+ release_sock(sk);
+ sco_conn_put(conn);
++ hci_conn_drop(hcon);
+ err = -EBADFD;
+ goto unlock;
+ }
+@@ -379,9 +404,13 @@ static int sco_connect(struct sock *sk)
+ sco_conn_put(conn);
+ if (err) {
+ release_sock(sk);
++ hci_conn_drop(hcon);
+ goto unlock;
+ }
+
++ /* __sco_chan_add() took its own hci_conn reference; drop ours. */
++ hci_conn_drop(hcon);
++
+ /* Update source addr of the socket */
+ bacpy(&sco_pi(sk)->src, &hcon->src);
+
+@@ -495,9 +524,25 @@ static struct sock *sco_get_sock_listen(bdaddr_t *src)
+
+ static void sco_sock_destruct(struct sock *sk)
+ {
++ struct sco_conn *conn = sco_pi(sk)->conn;
++
+ BT_DBG("sk %p", sk);
+
+- sco_conn_put(sco_pi(sk)->conn);
++ /* If the channel was not already torn down via sco_chan_del(), drop
++ * the socket's own references here.
++ */
++ if (conn) {
++ struct hci_conn *hcon;
++
++ sco_conn_lock(conn);
++ hcon = conn->hcon;
++ sco_conn_unlock(conn);
++
++ if (hcon)
++ hci_conn_drop(hcon);
++ sco_pi(sk)->conn = NULL;
++ sco_conn_put(conn);
++ }
+
+ skb_queue_purge(&sk->sk_receive_queue);
+ skb_queue_purge(&sk->sk_write_queue);
+@@ -1511,12 +1556,10 @@ static void sco_connect_cfm(struct hci_conn *hcon, __u8 status)
+ if (!status) {
+ struct sco_conn *conn;
+
+- conn = sco_conn_add(hci_conn_hold(hcon));
++ conn = sco_conn_add(hcon);
+ if (conn) {
+ sco_conn_ready(conn);
+ sco_conn_put(conn);
+- } else {
+- hci_conn_drop(hcon);
+ }
+ } else
+ sco_conn_del(hcon, bt_to_errno(status));
+diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
+index 2191d35d9fa07a..79b6fe54a7cbe6 100644
+--- a/net/bridge/br_multicast.c
++++ b/net/bridge/br_multicast.c
+@@ -81,6 +81,10 @@ __br_multicast_add_group(struct net_bridge_mcast *brmctx,
+ bool blocked);
+ static void br_multicast_find_del_pg(struct net_bridge *br,
+ struct net_bridge_port_group *pg);
++static void __br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
++ struct net_bridge_port_group *pg,
++ struct net_bridge_port_group __rcu **pp,
++ bool sg_del_exclude_ports);
+ static void __br_multicast_stop(struct net_bridge_mcast *brmctx);
+
+ static int br_mc_disabled_update(struct net_device *dev, bool value,
+@@ -458,7 +462,7 @@ static void br_multicast_sg_del_exclude_ports(struct net_bridge_mdb_entry *sgmp)
+ for (pp = &sgmp->ports;
+ (p = mlock_dereference(*pp, sgmp->br)) != NULL;) {
+ if (!(p->flags & MDB_PG_FLAGS_PERMANENT))
+- br_multicast_del_pg(sgmp, p, pp);
++ __br_multicast_del_pg(sgmp, p, pp, false);
+ else
+ pp = &p->next;
+ }
+@@ -799,9 +803,10 @@ static void br_multicast_destroy_port_group(struct net_bridge_mcast_gc *gc)
+ kfree_rcu(pg, rcu);
+ }
+
+-void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
+- struct net_bridge_port_group *pg,
+- struct net_bridge_port_group __rcu **pp)
++static void __br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
++ struct net_bridge_port_group *pg,
++ struct net_bridge_port_group __rcu **pp,
++ bool sg_del_exclude_ports)
+ {
+ struct net_bridge *br = pg->key.port->br;
+ struct net_bridge_group_src *ent;
+@@ -816,7 +821,8 @@ void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
+ if (!br_multicast_is_star_g(&mp->addr)) {
+ rhashtable_remove_fast(&br->sg_port_tbl, &pg->rhnode,
+ br_sg_port_rht_params);
+- br_multicast_sg_del_exclude_ports(mp);
++ if (sg_del_exclude_ports)
++ br_multicast_sg_del_exclude_ports(mp);
+ } else {
+ br_multicast_star_g_handle_mode(pg, MCAST_INCLUDE);
+ }
+@@ -828,6 +834,13 @@ void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
+ mod_timer(&mp->timer, jiffies);
+ }
+
++void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
++ struct net_bridge_port_group *pg,
++ struct net_bridge_port_group __rcu **pp)
++{
++ __br_multicast_del_pg(mp, pg, pp, true);
++}
++
+ static void br_multicast_find_del_pg(struct net_bridge *br,
+ struct net_bridge_port_group *pg)
+ {
+diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c
+index 7ecb8a26bfa3a7..b5444335b86f2b 100644
+--- a/net/bridge/netfilter/nf_conntrack_bridge.c
++++ b/net/bridge/netfilter/nf_conntrack_bridge.c
+@@ -39,9 +39,13 @@ static int nf_br_ip_fragment(struct net *net, struct sock *sk,
+ int err = 0;
+
+ /* for offloaded checksums cleanup checksum before fragmentation */
+- if (skb->ip_summed == CHECKSUM_PARTIAL &&
+- (err = skb_checksum_help(skb)))
+- goto blackhole;
++ if (skb->ip_summed == CHECKSUM_PARTIAL) {
++ err = ip_check_csum_start(skb);
++ if (!err)
++ err = skb_checksum_help(skb);
++ if (err)
++ goto blackhole;
++ }
+
+ iph = ip_hdr(skb);
+
+diff --git a/net/can/af_can.c b/net/can/af_can.c
+index 7bc86b176b4de3..34fe3b28d576f3 100644
+--- a/net/can/af_can.c
++++ b/net/can/af_can.c
+@@ -641,13 +641,10 @@ static int can_rcv_filter(struct can_dev_rcv_lists *dev_rcv_lists, struct sk_buf
+ return matches;
+ }
+
+-void can_set_skb_uid(struct sk_buff *skb)
++void can_set_skb_uid(struct can_skb_ext *csx)
+ {
+- /* create non-zero unique skb identifier together with *skb */
+- while (!(skb->hash))
+- skb->hash = atomic_inc_return(&skbcounter);
+-
+- skb->sw_hash = 1;
++ while (!(csx->can_skb_uid))
++ csx->can_skb_uid = atomic_inc_return(&skbcounter);
+ }
+ EXPORT_SYMBOL(can_set_skb_uid);
+
+@@ -662,8 +659,6 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev)
+ atomic_long_inc(&pkg_stats->rx_frames);
+ atomic_long_inc(&pkg_stats->rx_frames_delta);
+
+- can_set_skb_uid(skb);
+-
+ rcu_read_lock();
+
+ /* deliver the packet to sockets listening on all devices */
+@@ -687,8 +682,10 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev)
+ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
+ struct packet_type *pt, struct net_device *orig_dev)
+ {
++ struct can_skb_ext *csx = can_skb_ext_find(skb);
++
+ if (unlikely(dev->type != ARPHRD_CAN || !can_get_ml_priv(dev) ||
+- !can_skb_ext_find(skb) || !can_is_can_skb(skb))) {
++ !csx || !can_is_can_skb(skb))) {
+ pr_warn_once("PF_CAN: dropped non conform CAN skbuff: dev type %d, len %d\n",
+ dev->type, skb->len);
+
+@@ -696,6 +693,14 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
+ return NET_RX_DROP;
+ }
+
++ /* create unshared CAN skb_extension for netem/mirred skb clones */
++ csx = skb_ext_add(skb, SKB_EXT_CAN);
++ if (unlikely(!csx)) {
++ kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
++ return NET_RX_DROP;
++ }
++
++ can_set_skb_uid(csx);
+ can_receive(skb, dev);
+ return NET_RX_SUCCESS;
+ }
+@@ -703,8 +708,10 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
+ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
+ struct packet_type *pt, struct net_device *orig_dev)
+ {
++ struct can_skb_ext *csx = can_skb_ext_find(skb);
++
+ if (unlikely(dev->type != ARPHRD_CAN || !can_get_ml_priv(dev) ||
+- !can_skb_ext_find(skb) || !can_is_canfd_skb(skb))) {
++ !csx || !can_is_canfd_skb(skb))) {
+ pr_warn_once("PF_CAN: dropped non conform CAN FD skbuff: dev type %d, len %d\n",
+ dev->type, skb->len);
+
+@@ -712,6 +719,14 @@ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
+ return NET_RX_DROP;
+ }
+
++ /* create unshared CAN skb_extension for netem/mirred skb clones */
++ csx = skb_ext_add(skb, SKB_EXT_CAN);
++ if (unlikely(!csx)) {
++ kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
++ return NET_RX_DROP;
++ }
++
++ can_set_skb_uid(csx);
+ can_receive(skb, dev);
+ return NET_RX_SUCCESS;
+ }
+@@ -719,8 +734,10 @@ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
+ static int canxl_rcv(struct sk_buff *skb, struct net_device *dev,
+ struct packet_type *pt, struct net_device *orig_dev)
+ {
++ struct can_skb_ext *csx = can_skb_ext_find(skb);
++
+ if (unlikely(dev->type != ARPHRD_CAN || !can_get_ml_priv(dev) ||
+- !can_skb_ext_find(skb) || !can_is_canxl_skb(skb))) {
++ !csx || !can_is_canxl_skb(skb))) {
+ pr_warn_once("PF_CAN: dropped non conform CAN XL skbuff: dev type %d, len %d\n",
+ dev->type, skb->len);
+
+@@ -728,6 +745,14 @@ static int canxl_rcv(struct sk_buff *skb, struct net_device *dev,
+ return NET_RX_DROP;
+ }
+
++ /* create unshared CAN skb_extension for netem/mirred skb clones */
++ csx = skb_ext_add(skb, SKB_EXT_CAN);
++ if (unlikely(!csx)) {
++ kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
++ return NET_RX_DROP;
++ }
++
++ can_set_skb_uid(csx);
+ can_receive(skb, dev);
+ return NET_RX_SUCCESS;
+ }
+diff --git a/net/can/gw.c b/net/can/gw.c
+index 0ec99f68aa452d..5793cb2420ed3c 100644
+--- a/net/can/gw.c
++++ b/net/can/gw.c
+@@ -527,6 +527,9 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data)
+ /* put the incremented hop counter in the cloned skb */
+ ncsx->can_gw_hops = csx->can_gw_hops + 1;
+
++ /* force a new CAN UID generation for the routed frame */
++ ncsx->can_skb_uid = 0;
++
+ /* first processing of this CAN frame -> adjust to private hop limit */
+ if (gwj->limit_hops && ncsx->can_gw_hops == 1)
+ ncsx->can_gw_hops = max_hops - gwj->limit_hops + 1;
+diff --git a/net/can/isotp.c b/net/can/isotp.c
+index 155530aedce2e3..f5dc9d04bd6862 100644
+--- a/net/can/isotp.c
++++ b/net/can/isotp.c
+@@ -891,7 +891,7 @@ static void isotp_send_cframe(struct isotp_sock *so)
+ csx->can_iif = dev->ifindex;
+
+ /* set uid in tx skb to identify CF echo frames */
+- can_set_skb_uid(skb);
++ can_set_skb_uid(csx);
+
+ cf = (struct canfd_frame *)skb->data;
+ skb_put_zero(skb, so->ll.mtu);
+@@ -917,7 +917,7 @@ static void isotp_send_cframe(struct isotp_sock *so)
+ pr_notice_once("can-isotp: cfecho is %08X != 0\n", old_cfecho);
+
+ /* set consecutive frame echo tag */
+- WRITE_ONCE(so->cfecho, skb->hash);
++ WRITE_ONCE(so->cfecho, csx->can_skb_uid);
+
+ /* send frame with local echo enabled */
+ can_send_ret = can_send(skb, 1);
+@@ -969,18 +969,22 @@ static void isotp_rcv_echo(struct sk_buff *skb, void *data)
+ {
+ struct sock *sk = (struct sock *)data;
+ struct isotp_sock *so = isotp_sk(sk);
++ struct can_skb_ext *csx = can_skb_ext_find(skb);
+
+ /* only handle my own local echo CF/SF skb's (no FF!) */
+ if (skb->sk != sk)
+ return;
+
++ if (WARN_ON_ONCE(!csx))
++ return;
++
+ /* unlike isotp_rcv_fc()/isotp_rcv_cf(), not already under so->rx_lock
+ * (no isotp_rcv() caller here), so take it ourselves
+ */
+ spin_lock(&so->rx_lock);
+
+ /* so->cfecho may since belong to a new transfer; recheck under lock */
+- if (READ_ONCE(so->cfecho) != skb->hash)
++ if (READ_ONCE(so->cfecho) != csx->can_skb_uid)
+ goto out_unlock;
+
+ /* cancel local echo timeout */
+@@ -1222,7 +1226,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
+ csx->can_iif = dev->ifindex;
+
+ /* set uid in tx skb to identify CF echo frames */
+- can_set_skb_uid(skb);
++ can_set_skb_uid(csx);
+
+ so->tx.len = size;
+ so->tx.idx = 0;
+@@ -1261,7 +1265,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
+ cf->data[ae] |= size;
+
+ /* set CF echo tag for isotp_rcv_echo() (SF-mode) */
+- WRITE_ONCE(so->cfecho, skb->hash);
++ WRITE_ONCE(so->cfecho, csx->can_skb_uid);
+ } else {
+ /* send first frame */
+
+@@ -1278,7 +1282,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
+ so->txfc.bs = 0;
+
+ /* set CF echo tag for isotp_rcv_echo() (CF-mode) */
+- WRITE_ONCE(so->cfecho, skb->hash);
++ WRITE_ONCE(so->cfecho, csx->can_skb_uid);
+ } else {
+ /* standard flow control check */
+ new_state = ISOTP_WAIT_FIRST_FC;
+diff --git a/net/can/raw.c b/net/can/raw.c
+index 82d9c0499c95fa..0acd4f6c6dd672 100644
+--- a/net/can/raw.c
++++ b/net/can/raw.c
+@@ -77,7 +77,7 @@ MODULE_ALIAS("can-proto-1");
+
+ struct uniqframe {
+ const struct sk_buff *skb;
+- u32 hash;
++ u32 can_skb_uid;
+ unsigned int join_rx_count;
+ };
+
+@@ -133,12 +133,16 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
+ enum skb_drop_reason reason;
+ struct sockaddr_can *addr;
+ struct sk_buff *skb;
++ struct can_skb_ext *csx = can_skb_ext_find(oskb);
+ unsigned int *pflags;
+
+ /* check the received tx sock reference */
+ if (!ro->recv_own_msgs && oskb->sk == sk)
+ return;
+
++ if (WARN_ON_ONCE(!csx))
++ return;
++
+ /* make sure to not pass oversized frames to the socket */
+ if (!ro->fd_frames && can_is_canfd_skb(oskb))
+ return;
+@@ -165,7 +169,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
+
+ /* eliminate multiple filter matches for the same skb */
+ if (this_cpu_ptr(ro->uniq)->skb == oskb &&
+- this_cpu_ptr(ro->uniq)->hash == oskb->hash) {
++ this_cpu_ptr(ro->uniq)->can_skb_uid == csx->can_skb_uid) {
+ if (!ro->join_filters)
+ return;
+
+@@ -175,7 +179,7 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
+ return;
+ } else {
+ this_cpu_ptr(ro->uniq)->skb = oskb;
+- this_cpu_ptr(ro->uniq)->hash = oskb->hash;
++ this_cpu_ptr(ro->uniq)->can_skb_uid = csx->can_skb_uid;
+ this_cpu_ptr(ro->uniq)->join_rx_count = 1;
+ /* drop first frame to check all enabled filters? */
+ if (ro->join_filters && ro->count > 1)
+diff --git a/net/core/dev.c b/net/core/dev.c
+index 6f75d1d1af32ce..1a06976e195630 100644
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -10356,13 +10356,15 @@ EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
+
+ u8 dev_xdp_sb_prog_count(struct net_device *dev)
+ {
++ struct bpf_prog *prog;
+ u8 count = 0;
+ int i;
+
+- for (i = 0; i < __MAX_XDP_MODE; i++)
+- if (dev->xdp_state[i].prog &&
+- !dev->xdp_state[i].prog->aux->xdp_has_frags)
++ for (i = 0; i < __MAX_XDP_MODE; i++) {
++ prog = dev_xdp_prog(dev, i);
++ if (prog && !prog->aux->xdp_has_frags)
+ count++;
++ }
+ return count;
+ }
+
+@@ -10742,11 +10744,12 @@ static int bpf_xdp_link_update(struct bpf_link *link, struct bpf_prog *new_prog,
+ bpf_op = dev_xdp_bpf_op(xdp_link->dev, mode);
+ err = dev_xdp_install(xdp_link->dev, mode, bpf_op, NULL,
+ xdp_link->flags, new_prog);
++ if (!err)
++ old_prog = xchg(&link->prog, new_prog);
+ netdev_unlock_ops(xdp_link->dev);
+ if (err)
+ goto out_unlock;
+
+- old_prog = xchg(&link->prog, new_prog);
+ bpf_prog_put(old_prog);
+
+ out_unlock:
+diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
+index 8aa4f9b4df8101..1be6c739e3c718 100644
+--- a/net/core/flow_dissector.c
++++ b/net/core/flow_dissector.c
+@@ -1023,6 +1023,8 @@ u32 bpf_flow_dissect(struct bpf_prog *prog, struct bpf_flow_dissector *ctx,
+
+ result = bpf_prog_run_pin_on_cpu(prog, ctx);
+
++ /* bpf_flow_keys offsets are u16: do not let @hlen be truncated. */
++ hlen = min_t(int, hlen, U16_MAX);
+ flow_keys->nhoff = clamp_t(u16, flow_keys->nhoff, nhoff, hlen);
+ flow_keys->thoff = clamp_t(u16, flow_keys->thoff,
+ flow_keys->nhoff, hlen);
+@@ -1071,6 +1073,7 @@ bool __skb_flow_dissect(const struct net *net,
+ int mpls_lse = 0;
+ int num_hdrs = 0;
+ u8 ip_proto = 0;
++ u32 thoff;
+ bool ret;
+
+ if (!data) {
+@@ -1692,7 +1695,13 @@ out_good:
+ ret = true;
+
+ out:
+- key_control->thoff = min_t(u16, nhoff, skb ? skb->len : hlen);
++ thoff = min_t(u32, nhoff, skb ? skb->len : hlen);
++ if (unlikely(thoff > U16_MAX)) {
++ /* Cannot be represented in key_control->thoff. */
++ thoff = U16_MAX;
++ ret = false;
++ }
++ key_control->thoff = thoff;
+ key_basic->n_proto = proto;
+ key_basic->ip_proto = ip_proto;
+
+diff --git a/net/core/skbuff.c b/net/core/skbuff.c
+index 88febbc5803ec1..fa5c1c15d417e8 100644
+--- a/net/core/skbuff.c
++++ b/net/core/skbuff.c
+@@ -3633,8 +3633,12 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
+ pos = copy;
+ }
+
+- if (!skb_frags_readable(skb))
++ if (!skb_frags_readable(skb)) {
++ /* Don't hand the caller a buffer with stale bytes in it. */
++ if (len > 0)
++ memset(to, 0, len);
+ return 0;
++ }
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+ int end;
+diff --git a/net/devlink/core.c b/net/devlink/core.c
+index fe9f6a0a67d5b3..42c16940e4c438 100644
+--- a/net/devlink/core.c
++++ b/net/devlink/core.c
+@@ -96,13 +96,19 @@ rel_put:
+ return;
+
+ reschedule_work:
+- schedule_delayed_work(&rel->nested_in.notify_work, 1);
++ /* The work may have been queued again meanwhile, which took its own
++ * reference. Drop ours in that case.
++ */
++ if (!schedule_delayed_work(&rel->nested_in.notify_work, 1))
++ __devlink_rel_put(rel);
+ }
+
+ static void devlink_rel_nested_in_notify_work_schedule(struct devlink_rel *rel)
+ {
+ __devlink_rel_get(rel);
+- schedule_delayed_work(&rel->nested_in.notify_work, 0);
++ /* The pending work holds a reference already, drop the new one. */
++ if (!schedule_delayed_work(&rel->nested_in.notify_work, 0))
++ __devlink_rel_put(rel);
+ }
+
+ static struct devlink_rel *devlink_rel_alloc(void)
+diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
+index a05aa075de1a5b..1aacbbeffbc647 100644
+--- a/net/ipv4/cipso_ipv4.c
++++ b/net/ipv4/cipso_ipv4.c
+@@ -2287,6 +2287,14 @@ int cipso_v4_skbuff_delattr(struct sk_buff *skb)
+ new_hdr_len - new_hdr_len_actual);
+
+ opt->optlen -= hdr_len_delta;
++ if (opt->srr > opt->cipso)
++ opt->srr -= cipso_len;
++ if (opt->rr > opt->cipso)
++ opt->rr -= cipso_len;
++ if (opt->ts > opt->cipso)
++ opt->ts -= cipso_len;
++ if (opt->router_alert > opt->cipso)
++ opt->router_alert -= cipso_len;
+ opt->cipso = 0;
+ opt->is_changed = 1;
+ if (hdr_len_delta != 0) {
+diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
+index 0c25f6dfb8a6f9..92cfc838e5d3b4 100644
+--- a/net/ipv4/fib_semantics.c
++++ b/net/ipv4/fib_semantics.c
+@@ -542,6 +542,9 @@ size_t fib_nlmsg_size(struct fib_info *fi)
+ struct fib_nh_common *nhc = fib_info_nhc(fi, i);
+ size_t nhsize;
+
++ if (!nhc)
++ break;
++
+ nhsize = fib_nexthop_nlmsg_size(nhc, nhs != 1);
+
+ if (nhs != 1)
+diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
+index 6badad29593b71..58be0752b0350f 100644
+--- a/net/ipv4/fib_trie.c
++++ b/net/ipv4/fib_trie.c
+@@ -1079,8 +1079,6 @@ void fib_alias_hw_flags_set(struct net *net, const struct fib_rt_info *fri)
+
+ err = fib_dump_info(skb, 0, 0, RTM_NEWROUTE, fri, 0);
+ if (err < 0) {
+- /* -EMSGSIZE implies BUG in fib_nlmsg_size() */
+- WARN_ON(err == -EMSGSIZE);
+ kfree_skb(skb);
+ goto errout;
+ }
+diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
+index a24cc8ee11d3ea..eaa6fabda347e9 100644
+--- a/net/ipv4/ip_output.c
++++ b/net/ipv4/ip_output.c
+@@ -771,9 +771,13 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
+ int err = 0;
+
+ /* for offloaded checksums cleanup checksum before fragmentation */
+- if (skb->ip_summed == CHECKSUM_PARTIAL &&
+- (err = skb_checksum_help(skb)))
+- goto fail;
++ if (skb->ip_summed == CHECKSUM_PARTIAL) {
++ err = ip_check_csum_start(skb);
++ if (!err)
++ err = skb_checksum_help(skb);
++ if (err)
++ goto fail;
++ }
+
+ /*
+ * Point into the IP datagram header.
+diff --git a/net/ipv4/route.c b/net/ipv4/route.c
+index f07231447883f3..196ca7e8acff01 100644
+--- a/net/ipv4/route.c
++++ b/net/ipv4/route.c
+@@ -1080,6 +1080,8 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
+
+ for (nhsel = 0; nhsel < fib_info_num_path(res.fi); nhsel++) {
+ nhc = fib_info_nhc(res.fi, nhsel);
++ if (!nhc)
++ break;
+ update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
+ jiffies + net->ipv4.ip_rt_mtu_expires);
+ }
+@@ -3163,6 +3165,9 @@ int fib_dump_info_fnhe(struct sk_buff *skb, struct netlink_callback *cb,
+ struct fnhe_hash_bucket *bucket;
+ int err;
+
++ if (!nhc)
++ break;
++
+ if (nhc->nhc_flags & RTNH_F_DEAD)
+ continue;
+
+diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
+index 47a34a993972af..93efc948d2be78 100644
+--- a/net/ipv4/tcp.c
++++ b/net/ipv4/tcp.c
+@@ -1908,6 +1908,8 @@ static bool can_map_frag(const skb_frag_t *frag)
+
+ if (skb_frag_size(frag) != PAGE_SIZE || skb_frag_off(frag))
+ return false;
++ if (skb_frag_is_net_iov(frag))
++ return false;
+
+ page = skb_frag_page(frag);
+
+diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
+index 59afce196079a8..a50dccfbf4205f 100644
+--- a/net/ipv4/udp.c
++++ b/net/ipv4/udp.c
+@@ -908,6 +908,15 @@ out:
+ return sk;
+ }
+
++static void udp_err_update_exception(struct net *net, struct sk_buff *skb,
++ int type, int code, u32 info)
++{
++ if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED)
++ ipv4_update_pmtu(skb, net, info, 0, IPPROTO_UDP);
++ else if (type == ICMP_REDIRECT)
++ ipv4_redirect(skb, net, 0, IPPROTO_UDP);
++}
++
+ /*
+ * This routine is called by the ICMP module when it gets some
+ * sort of error condition. If err < 0 then the socket should
+@@ -931,6 +940,8 @@ int udp_err(struct sk_buff *skb, u32 info)
+ int harderr;
+ int err;
+
++ udp_err_update_exception(net, skb, type, code, info);
++
+ uh = (struct udphdr *)(skb->data + (iph->ihl << 2));
+ sk = __udp4_lib_lookup(net, iph->daddr, uh->dest,
+ iph->saddr, uh->source, skb->dev->ifindex,
+diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
+index e6913a7f688117..6d7c547232a2d7 100644
+--- a/net/ipv6/ip6_gre.c
++++ b/net/ipv6/ip6_gre.c
+@@ -923,7 +923,6 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
+ {
+ struct ip_tunnel_info *tun_info = NULL;
+ struct ip6_tnl *t = netdev_priv(dev);
+- struct dst_entry *dst = skb_dst(skb);
+ IP_TUNNEL_DECLARE_FLAGS(flags) = { };
+ bool truncate = false;
+ int encap_limit = -1;
+@@ -1059,12 +1058,6 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
+ gre_build_header(skb, 8, flags, proto, 0,
+ htonl(atomic_fetch_inc(&t->o_seqno)));
+
+- /* TooBig packet may have updated dst->dev's mtu */
+- if (!t->parms.collect_md && dst) {
+- mtu = READ_ONCE(dst_dev(dst)->mtu);
+- if (dst_mtu(dst) > mtu)
+- dst->ops->update_pmtu(dst, NULL, skb, mtu, false);
+- }
+ err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ NEXTHDR_GRE);
+ if (err != 0) {
+diff --git a/net/ipv6/route.c b/net/ipv6/route.c
+index 8fddcc631fcb62..5d80a025c3e6d1 100644
+--- a/net/ipv6/route.c
++++ b/net/ipv6/route.c
+@@ -3261,7 +3261,7 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif)
+
+ void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk)
+ {
+- ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if,
++ ip6_redirect(skb, sock_net(sk), skb->dev->ifindex,
+ READ_ONCE(sk->sk_mark), sk_uid(sk));
+ }
+
+@@ -6474,8 +6474,6 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,
+ err = rt6_fill_node(net, skb, f6i, NULL, NULL, NULL, 0, RTM_NEWROUTE, 0,
+ 0, 0);
+ if (err < 0) {
+- /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */
+- WARN_ON(err == -EMSGSIZE);
+ kfree_skb(skb);
+ goto errout;
+ }
+diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
+index 15e032194eccc3..b73cf02ac1b6e6 100644
+--- a/net/ipv6/udp.c
++++ b/net/ipv6/udp.c
+@@ -690,6 +690,17 @@ out:
+ return sk;
+ }
+
++static void udpv6_err_update_exception(struct net *net, struct sk_buff *skb,
++ u8 type, __be32 info)
++{
++ if (type == ICMPV6_PKT_TOOBIG)
++ ip6_update_pmtu(skb, net, info, skb->dev->ifindex, 0,
++ sock_net_uid(net, NULL));
++ else if (type == NDISC_REDIRECT)
++ ip6_redirect(skb, net, skb->dev->ifindex, 0,
++ sock_net_uid(net, NULL));
++}
++
+ static int udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+ u8 type, u8 code, int offset, __be32 info)
+ {
+@@ -703,6 +714,8 @@ static int udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
+ int harderr;
+ int err;
+
++ udpv6_err_update_exception(net, skb, type, info);
++
+ daddr = seg6_get_daddr(skb, opt) ? : &hdr->daddr;
+ saddr = &hdr->saddr;
+ sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
+diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
+index f36cc25903050f..3a671225c12777 100644
+--- a/net/mac80211/debugfs.c
++++ b/net/mac80211/debugfs.c
+@@ -210,11 +210,13 @@ static ssize_t aql_pending_read(struct file *file,
+ "VI %u us\n"
+ "BE %u us\n"
+ "BK %u us\n"
++ "MC %u us\n"
+ "total %u us\n",
+ atomic_read(&local->aql_ac_pending_airtime[IEEE80211_AC_VO]),
+ atomic_read(&local->aql_ac_pending_airtime[IEEE80211_AC_VI]),
+ atomic_read(&local->aql_ac_pending_airtime[IEEE80211_AC_BE]),
+ atomic_read(&local->aql_ac_pending_airtime[IEEE80211_AC_BK]),
++ atomic_read(&local->aql_mc_pending_airtime),
+ atomic_read(&local->aql_total_pending_airtime));
+ return simple_read_from_buffer(user_buf, count, ppos,
+ buf, len);
+@@ -239,7 +241,8 @@ static ssize_t aql_txq_limit_read(struct file *file,
+ "VO %u %u\n"
+ "VI %u %u\n"
+ "BE %u %u\n"
+- "BK %u %u\n",
++ "BK %u %u\n"
++ "MC %u\n",
+ local->aql_txq_limit_low[IEEE80211_AC_VO],
+ local->aql_txq_limit_high[IEEE80211_AC_VO],
+ local->aql_txq_limit_low[IEEE80211_AC_VI],
+@@ -247,7 +250,8 @@ static ssize_t aql_txq_limit_read(struct file *file,
+ local->aql_txq_limit_low[IEEE80211_AC_BE],
+ local->aql_txq_limit_high[IEEE80211_AC_BE],
+ local->aql_txq_limit_low[IEEE80211_AC_BK],
+- local->aql_txq_limit_high[IEEE80211_AC_BK]);
++ local->aql_txq_limit_high[IEEE80211_AC_BK],
++ local->aql_txq_limit_mc);
+ return simple_read_from_buffer(user_buf, count, ppos,
+ buf, len);
+ }
+@@ -273,6 +277,11 @@ static ssize_t aql_txq_limit_write(struct file *file,
+ else
+ buf[count] = '\0';
+
++ if (sscanf(buf, "mcast %u", &q_limit_low) == 1) {
++ local->aql_txq_limit_mc = q_limit_low;
++ return count;
++ }
++
+ if (sscanf(buf, "%u %u %u", &ac, &q_limit_low, &q_limit_high) != 3)
+ return -EINVAL;
+
+diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
+index 011ec7fbb71185..2854dcc86b21b3 100644
+--- a/net/mac80211/ieee80211_i.h
++++ b/net/mac80211/ieee80211_i.h
+@@ -1464,10 +1464,12 @@ struct ieee80211_local {
+ spinlock_t handle_wake_tx_queue_lock;
+
+ u16 airtime_flags;
++ u32 aql_txq_limit_mc;
+ u32 aql_txq_limit_low[IEEE80211_NUM_ACS];
+ u32 aql_txq_limit_high[IEEE80211_NUM_ACS];
+ u32 aql_threshold;
+ atomic_t aql_total_pending_airtime;
++ atomic_t aql_mc_pending_airtime;
+ atomic_t aql_ac_pending_airtime[IEEE80211_NUM_ACS];
+
+ const struct ieee80211_ops *ops;
+diff --git a/net/mac80211/main.c b/net/mac80211/main.c
+index 8edfef2b57f80f..d5ef44f2b3f2dd 100644
+--- a/net/mac80211/main.c
++++ b/net/mac80211/main.c
+@@ -988,6 +988,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
+ spin_lock_init(&local->rx_path_lock);
+ spin_lock_init(&local->queue_stop_reason_lock);
+
++ local->aql_txq_limit_mc = IEEE80211_DEFAULT_AQL_TXQ_LIMIT_MC;
+ for (i = 0; i < IEEE80211_NUM_ACS; i++) {
+ INIT_LIST_HEAD(&local->active_txqs[i]);
+ spin_lock_init(&local->active_txq_lock[i]);
+diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
+index 01d70f71c43ec2..ce7a3f839ce2eb 100644
+--- a/net/mac80211/sta_info.c
++++ b/net/mac80211/sta_info.c
+@@ -2493,13 +2493,28 @@ EXPORT_SYMBOL(ieee80211_sta_recalc_aggregates);
+
+ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
+ struct sta_info *sta, u8 ac,
+- u16 tx_airtime, bool tx_completed)
++ u16 tx_airtime, bool tx_completed,
++ bool mcast)
+ {
+ int tx_pending;
+
+ if (!wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL))
+ return;
+
++ if (mcast) {
++ if (!tx_completed) {
++ atomic_add(tx_airtime, &local->aql_mc_pending_airtime);
++ return;
++ }
++
++ tx_pending = atomic_sub_return(tx_airtime,
++ &local->aql_mc_pending_airtime);
++ if (tx_pending < 0)
++ atomic_cmpxchg(&local->aql_mc_pending_airtime,
++ tx_pending, 0);
++ return;
++ }
++
+ if (!tx_completed) {
+ if (sta)
+ atomic_add(tx_airtime,
+diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
+index 5da3142d8516ef..ee0d32877c5b47 100644
+--- a/net/mac80211/sta_info.h
++++ b/net/mac80211/sta_info.h
+@@ -147,7 +147,8 @@ struct airtime_info {
+
+ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local,
+ struct sta_info *sta, u8 ac,
+- u16 tx_airtime, bool tx_completed);
++ u16 tx_airtime, bool tx_completed,
++ bool mcast);
+
+ struct sta_info;
+
+diff --git a/net/mac80211/status.c b/net/mac80211/status.c
+index e10e5bcc279b6a..a9da9fe87cf157 100644
+--- a/net/mac80211/status.c
++++ b/net/mac80211/status.c
+@@ -774,7 +774,7 @@ static void ieee80211_report_used_skb(struct ieee80211_local *local,
+ ieee80211_sta_update_pending_airtime(local, sta,
+ skb_get_queue_mapping(skb),
+ tx_time_est,
+- true);
++ true, info->tx_time_mc);
+ rcu_read_unlock();
+ }
+
+@@ -1255,10 +1255,11 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
+ /* Do this here to avoid the expensive lookup of the sta
+ * in ieee80211_report_used_skb().
+ */
++ bool mcast = IEEE80211_SKB_CB(skb)->tx_time_mc;
+ ieee80211_sta_update_pending_airtime(local, sta,
+ skb_get_queue_mapping(skb),
+ tx_time_est,
+- true);
++ true, mcast);
+ ieee80211_info_set_tx_time_est(IEEE80211_SKB_CB(skb), 0);
+ }
+
+diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
+index 65c5a6519b8953..3e5b1c05f4a3e1 100644
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -4083,20 +4083,20 @@ begin:
+ encap_out:
+ info->control.vif = vif;
+
+- if (tx.sta &&
+- wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
+- bool ampdu = txq->ac != IEEE80211_AC_VO;
++ if (wiphy_ext_feature_isset(local->hw.wiphy, NL80211_EXT_FEATURE_AQL)) {
++ bool ampdu = txq->sta && txq->ac != IEEE80211_AC_VO;
+ u32 airtime;
+
+ airtime = ieee80211_calc_expected_tx_airtime(hw, vif, txq->sta,
+ skb->len, ampdu);
+- if (airtime) {
+- airtime = ieee80211_info_set_tx_time_est(info, airtime);
+- ieee80211_sta_update_pending_airtime(local, tx.sta,
+- txq->ac,
+- airtime,
+- false);
+- }
++ if (!airtime)
++ return skb;
++
++ airtime = ieee80211_info_set_tx_time_est(info, airtime);
++ info->tx_time_mc = !tx.sta;
++ ieee80211_sta_update_pending_airtime(local, tx.sta, txq->ac,
++ airtime, false,
++ info->tx_time_mc);
+ }
+
+ return skb;
+@@ -4148,6 +4148,7 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
+ struct ieee80211_txq *ret = NULL;
+ struct txq_info *txqi = NULL, *head = NULL;
+ bool found_eligible_txq = false;
++ bool aql_check;
+
+ spin_lock_bh(&local->active_txq_lock[ac]);
+
+@@ -4171,26 +4172,28 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
+ if (!head)
+ head = txqi;
+
++ aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq);
++ if (aql_check)
++ found_eligible_txq = true;
++
+ if (txqi->txq.sta) {
+ struct sta_info *sta = container_of(txqi->txq.sta,
+ struct sta_info, sta);
+- bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq);
+- s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac);
+
+- if (aql_check)
+- found_eligible_txq = true;
+-
+- if (deficit < 0)
++ if (ieee80211_sta_deficit(sta, txqi->txq.ac) < 0) {
+ sta->airtime[txqi->txq.ac].deficit +=
+ sta->airtime_weight;
+
+- if (deficit < 0 || !aql_check) {
+- list_move_tail(&txqi->schedule_order,
+- &local->active_txqs[txqi->txq.ac]);
+- goto begin;
++ aql_check = false;
+ }
+ }
+
++ if (!aql_check) {
++ list_move_tail(&txqi->schedule_order,
++ &local->active_txqs[txqi->txq.ac]);
++ goto begin;
++ }
++
+ if (txqi->schedule_round == local->schedule_round[ac])
+ goto out;
+
+@@ -4257,7 +4260,8 @@ bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
+ return true;
+
+ if (!txq->sta)
+- return true;
++ return atomic_read(&local->aql_mc_pending_airtime) <
++ local->aql_txq_limit_mc;
+
+ if (unlikely(txq->tid == IEEE80211_NUM_TIDS))
+ return true;
+@@ -4277,6 +4281,24 @@ bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw,
+ }
+ EXPORT_SYMBOL(ieee80211_txq_airtime_check);
+
++u32 ieee80211_txq_aql_pending(struct ieee80211_hw *hw,
++ struct ieee80211_txq *txq)
++{
++ struct ieee80211_local *local = hw_to_local(hw);
++ struct sta_info *sta;
++
++ if (unlikely(txq->tid == IEEE80211_NUM_TIDS))
++ return 0;
++
++ if (!txq->sta)
++ return atomic_read(&local->aql_mc_pending_airtime);
++
++ sta = container_of(txq->sta, struct sta_info, sta);
++
++ return atomic_read(&sta->airtime[txq->ac].aql_tx_pending);
++}
++EXPORT_SYMBOL(ieee80211_txq_aql_pending);
++
+ static bool
+ ieee80211_txq_schedule_airtime_check(struct ieee80211_local *local, u8 ac)
+ {
+@@ -4306,15 +4328,15 @@ bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw,
+
+ spin_lock_bh(&local->active_txq_lock[ac]);
+
+- if (!txqi->txq.sta)
+- goto out;
+-
+ if (list_empty(&txqi->schedule_order))
+ goto out;
+
+ if (!ieee80211_txq_schedule_airtime_check(local, ac))
+ goto out;
+
++ if (!txqi->txq.sta)
++ goto out;
++
+ list_for_each_entry_safe(iter, tmp, &local->active_txqs[ac],
+ schedule_order) {
+ if (iter == txqi)
+diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
+index ec5e7716df8b5d..8a5240a9be222d 100644
+--- a/net/netfilter/nfnetlink_queue.c
++++ b/net/netfilter/nfnetlink_queue.c
+@@ -33,6 +33,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -667,6 +668,12 @@ nla_put_failure:
+
+ static int nf_queue_checksum_help(struct sk_buff *entskb)
+ {
++ if (entskb->protocol == htons(ETH_P_IP)) {
++ if (!pskb_network_may_pull(entskb, sizeof(struct iphdr)) ||
++ ip_check_csum_start(entskb))
++ return -EINVAL;
++ }
++
+ if (skb_csum_is_sctp(entskb))
+ return skb_crc32c_csum_help(entskb);
+
+diff --git a/net/netfilter/xt_CHECKSUM.c b/net/netfilter/xt_CHECKSUM.c
+index 9d99f5a3d1764b..1fb0f8118404d6 100644
+--- a/net/netfilter/xt_CHECKSUM.c
++++ b/net/netfilter/xt_CHECKSUM.c
+@@ -15,6 +15,7 @@
+
+ #include
+ #include
++#include
+
+ MODULE_LICENSE("GPL");
+ MODULE_AUTHOR("Michael S. Tsirkin ");
+@@ -25,8 +26,11 @@ MODULE_ALIAS("ip6t_CHECKSUM");
+ static unsigned int
+ checksum_tg(struct sk_buff *skb, const struct xt_action_param *par)
+ {
+- if (skb->ip_summed == CHECKSUM_PARTIAL && !skb_is_gso(skb))
++ if (skb->ip_summed == CHECKSUM_PARTIAL && !skb_is_gso(skb)) {
++ if (xt_family(par) == NFPROTO_IPV4 && ip_check_csum_start(skb))
++ return NF_DROP;
+ skb_checksum_help(skb);
++ }
+
+ return XT_CONTINUE;
+ }
+diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
+index dc5ff859f11451..27152bca8a8ce7 100644
+--- a/net/openvswitch/actions.c
++++ b/net/openvswitch/actions.c
+@@ -358,7 +358,12 @@ static void set_ip_addr(struct sk_buff *skb, struct iphdr *nh,
+ static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto,
+ __be32 addr[4], const __be32 new_addr[4])
+ {
+- int transport_len = skb->len - skb_transport_offset(skb);
++ int transport_len;
++
++ if (l4_proto == NEXTHDR_FRAGMENT)
++ return;
++
++ transport_len = skb->len - skb_transport_offset(skb);
+
+ if (l4_proto == NEXTHDR_TCP) {
+ if (likely(transport_len >= sizeof(struct tcphdr)))
+diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
+index b601e4859de920..21bc56e796277e 100644
+--- a/net/openvswitch/datapath.c
++++ b/net/openvswitch/datapath.c
+@@ -1529,6 +1529,12 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
+ return -ENODEV;
+ }
+
++ /*
++ * Not needed for safety. Stops every spin_unlock_bh() in
++ * ovs_flow_stats_get() from running the softirq backlog.
++ */
++ local_bh_disable();
++
+ ti = rcu_dereference(dp->table.ti);
+ for (;;) {
+ struct sw_flow *flow;
+@@ -1549,6 +1555,8 @@ static int ovs_flow_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
+ cb->args[0] = bucket;
+ cb->args[1] = obj;
+ }
++
++ local_bh_enable();
+ rcu_read_unlock();
+ return skb->len;
+ }
+diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
+index 8865c1a4266796..52ae3d875e971b 100644
+--- a/net/packet/af_packet.c
++++ b/net/packet/af_packet.c
+@@ -1911,7 +1911,8 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
+
+ spkt = &PACKET_SKB_CB(skb)->sa.pkt;
+
+- skb_push(skb, skb->data - skb_mac_header(skb));
++ if (dev_has_header(dev))
++ skb_push(skb, skb->data - skb_mac_header(skb));
+
+ /*
+ * The SOCK_PACKET socket receives _all_ frames.
+@@ -1942,8 +1943,7 @@ static void packet_parse_headers(struct sk_buff *skb, struct socket *sock)
+ /* On TX skb->data is the L2 header; anchor it for all socket types. */
+ skb_reset_mac_header(skb);
+
+- if ((!skb->protocol || skb->protocol == htons(ETH_P_ALL)) &&
+- sock->type == SOCK_RAW)
++ if (!skb->protocol && sock->type == SOCK_RAW)
+ skb->protocol = dev_parse_header_protocol(skb);
+
+ skb_probe_transport_header(skb);
+@@ -2613,7 +2613,8 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
+ struct page *page;
+ int err;
+
+- skb->protocol = proto;
++ if (proto != htons(ETH_P_ALL))
++ skb->protocol = proto;
+ skb->dev = dev;
+ skb->priority = sockc->priority;
+ skb->mark = sockc->mark;
+@@ -2677,8 +2678,6 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
+ if (unlikely(!skb->len))
+ return -EINVAL;
+
+- packet_parse_headers(skb, sock);
+-
+ return tp_len;
+ }
+
+@@ -2918,9 +2917,13 @@ tpacket_error:
+ tp_len = -EINVAL;
+ goto tpacket_error;
+ }
+- virtio_net_hdr_set_proto(skb, &vnet_hdr);
+ }
+
++ packet_parse_headers(skb, po->sk.sk_socket);
++
++ if (has_vnet_hdr)
++ virtio_net_hdr_set_proto(skb, &vnet_hdr);
++
+ uarg = kmalloc(sizeof(*uarg), GFP_KERNEL);
+ if (unlikely(!uarg)) {
+ if (likely(len_sum > 0))
+@@ -3121,7 +3124,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
+ goto out_free;
+ }
+
+- skb->protocol = proto;
++ if (proto != htons(ETH_P_ALL))
++ skb->protocol = proto;
+ skb->dev = dev;
+ skb->priority = sockc.priority;
+ skb->mark = sockc.mark;
+@@ -3130,16 +3134,18 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
+ if (unlikely(extra_len == 4))
+ skb->no_fcs = 1;
+
+- packet_parse_headers(skb, sock);
+-
+ if (vnet_hdr_sz) {
+ err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le());
+ if (err)
+ goto out_free;
+ len += vnet_hdr_sz;
+- virtio_net_hdr_set_proto(skb, &vnet_hdr);
+ }
+
++ packet_parse_headers(skb, sock);
++
++ if (vnet_hdr_sz)
++ virtio_net_hdr_set_proto(skb, &vnet_hdr);
++
+ err = packet_xmit(po, skb);
+
+ if (unlikely(err != 0)) {
+diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
+index 0f211f030fd9a7..dca812a7526981 100644
+--- a/net/sched/cls_route.c
++++ b/net/sched/cls_route.c
+@@ -434,6 +434,12 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
+ if (handle && (!fold || nhandle == (handle & ~0x7F00)))
+ nhandle |= handle & 0x7F00;
+
++ if (fold && !tb[TCA_ROUTE4_TO] && !tb[TCA_ROUTE4_FROM] &&
++ !tb[TCA_ROUTE4_IIF] && nhandle != fold->handle) {
++ NL_SET_ERR_MSG(extack, "Routing attributes required");
++ return -EINVAL;
++ }
++
+ if (handle && !fold && nhandle != handle) {
+ NL_SET_ERR_MSG_FMT(extack,
+ "Handle mismatch constructed: %x (expected: %x)",
+diff --git a/net/sched/em_text.c b/net/sched/em_text.c
+index 4132f8c3c5fc95..bc45edb8c03bff 100644
+--- a/net/sched/em_text.c
++++ b/net/sched/em_text.c
+@@ -58,6 +58,9 @@ static int em_text_change(struct net *net, void *data, int len,
+ if (len < sizeof(*conf) || len < (sizeof(*conf) + conf->pattern_len))
+ return -EINVAL;
+
++ if (!memchr(conf->algo, '\0', sizeof(conf->algo)))
++ return -EINVAL;
++
+ if (conf->from_layer > conf->to_layer)
+ return -EINVAL;
+
+diff --git a/net/sctp/socket.c b/net/sctp/socket.c
+index 4652fd90d9a6c4..e35692dd8d303b 100644
+--- a/net/sctp/socket.c
++++ b/net/sctp/socket.c
+@@ -7569,11 +7569,7 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
+ /* Not allocated yet, means all stats are 0 */
+ params.sprstat_abandoned_unsent = 0;
+ params.sprstat_abandoned_sent = 0;
+- retval = 0;
+- goto out;
+- }
+-
+- if (policy == SCTP_PR_SCTP_ALL) {
++ } else if (policy == SCTP_PR_SCTP_ALL) {
+ params.sprstat_abandoned_unsent = 0;
+ params.sprstat_abandoned_sent = 0;
+ for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) {
+diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
+index e9f93b3ab435bb..8b3ee70f8433f4 100644
+--- a/net/smc/af_smc.c
++++ b/net/smc/af_smc.c
+@@ -2784,6 +2784,7 @@ int smc_getname(struct socket *sock, struct sockaddr *addr,
+ int peer)
+ {
+ struct smc_sock *smc;
++ int rc = -EBADF;
+
+ if (peer && (sock->sk->sk_state != SMC_ACTIVE) &&
+ (sock->sk->sk_state != SMC_APPCLOSEWAIT1))
+@@ -2791,7 +2792,11 @@ int smc_getname(struct socket *sock, struct sockaddr *addr,
+
+ smc = smc_sk(sock->sk);
+
+- return smc->clcsock->ops->getname(smc->clcsock, addr, peer);
++ mutex_lock(&smc->clcsock_release_lock);
++ if (smc->clcsock)
++ rc = smc->clcsock->ops->getname(smc->clcsock, addr, peer);
++ mutex_unlock(&smc->clcsock_release_lock);
++ return rc;
+ }
+
+ int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c
+index a23f4b4dfc6733..d5b17d099a0e78 100644
+--- a/net/strparser/strparser.c
++++ b/net/strparser/strparser.c
+@@ -505,12 +505,16 @@ void strp_unpause(struct strparser *strp)
+ EXPORT_SYMBOL_GPL(strp_unpause);
+
+ /* strp must already be stopped so that strp_recv will no longer be called.
+- * Note that strp_done is not called with the lower socket held.
++ * Note that strp_done must not be called with the lower socket held.
+ */
+ void strp_done(struct strparser *strp)
+ {
+ WARN_ON(!strp->stopped);
+
++ lock_sock(strp->sk);
++ /* sync with pending strp_recv */
++ release_sock(strp->sk);
++
+ cancel_delayed_work_sync(&strp->msg_timer_work);
+ cancel_work_sync(&strp->work);
+
+diff --git a/net/tipc/node.c b/net/tipc/node.c
+index 683a136e53efcf..5a7487dab31dae 100644
+--- a/net/tipc/node.c
++++ b/net/tipc/node.c
+@@ -2419,8 +2419,11 @@ static struct tipc_node *tipc_node_find_by_name(struct net *net,
+ }
+ }
+ tipc_node_read_unlock(n);
+- if (found_node)
++ if (found_node) {
++ if (!kref_get_unless_zero(&found_node->kref))
++ found_node = NULL;
+ break;
++ }
+ }
+ rcu_read_unlock();
+
+@@ -2505,6 +2508,7 @@ out:
+ tipc_node_read_unlock(node);
+ tipc_bearer_xmit(net, bearer_id, &xmitq, &node->links[bearer_id].maddr,
+ NULL);
++ tipc_node_put(node);
+ return res;
+ }
+
+@@ -2556,12 +2560,14 @@ int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info)
+ link = node->links[bearer_id].link;
+ if (!link) {
+ tipc_node_read_unlock(node);
++ tipc_node_put(node);
+ err = -EINVAL;
+ goto err_free;
+ }
+
+ err = __tipc_nl_add_link(net, &msg, link, 0);
+ tipc_node_read_unlock(node);
++ tipc_node_put(node);
+ if (err)
+ goto err_free;
+ }
+@@ -2632,11 +2638,13 @@ int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info)
+ if (!link) {
+ spin_unlock_bh(&le->lock);
+ tipc_node_read_unlock(node);
++ tipc_node_put(node);
+ return -EINVAL;
+ }
+ tipc_link_reset_stats(link);
+ spin_unlock_bh(&le->lock);
+ tipc_node_read_unlock(node);
++ tipc_node_put(node);
+ return 0;
+ }
+
+diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c
+index af530c9ed8402c..82e9f44e2fe46e 100644
+--- a/net/tipc/topsrv.c
++++ b/net/tipc/topsrv.c
+@@ -55,7 +55,7 @@
+ /**
+ * struct tipc_topsrv - TIPC server structure
+ * @conn_idr: identifier set of connection
+- * @idr_lock: protect the connection identifier set
++ * @idr_lock: protect the connection identifier set and listener
+ * @idr_in_use: amount of allocated identifier entry
+ * @net: network namespace instance
+ * @awork: accept work item
+@@ -218,6 +218,10 @@ static struct tipc_conn *tipc_conn_lookup(struct tipc_topsrv *s, int conid)
+ struct tipc_conn *con;
+
+ spin_lock_bh(&s->idr_lock);
++ if (!s->listener) {
++ spin_unlock_bh(&s->idr_lock);
++ return NULL;
++ }
+ con = idr_find(&s->conn_idr, conid);
+ if (!connected(con) || !kref_get_unless_zero(&con->kref))
+ con = NULL;
+@@ -301,10 +305,20 @@ static void tipc_conn_send_to_sock(struct tipc_conn *con)
+ static void tipc_conn_send_work(struct work_struct *work)
+ {
+ struct tipc_conn *con = container_of(work, struct tipc_conn, swork);
++ struct tipc_topsrv *srv;
++
++ srv = con->server;
++ spin_lock_bh(&srv->idr_lock);
++ if (!srv->listener) {
++ spin_unlock_bh(&srv->idr_lock);
++ goto out;
++ }
++ spin_unlock_bh(&srv->idr_lock);
+
+ if (connected(con))
+ tipc_conn_send_to_sock(con);
+
++out:
+ conn_put(con);
+ }
+
+@@ -334,8 +348,14 @@ void tipc_topsrv_queue_evt(struct net *net, int conid,
+ list_add_tail(&e->list, &con->outqueue);
+ spin_unlock_bh(&con->outqueue_lock);
+
+- if (queue_work(srv->send_wq, &con->swork))
+- return;
++ spin_lock_bh(&srv->idr_lock);
++ if (srv->listener) {
++ if (queue_work(srv->send_wq, &con->swork)) {
++ spin_unlock_bh(&srv->idr_lock);
++ return;
++ }
++ }
++ spin_unlock_bh(&srv->idr_lock);
+ err:
+ conn_put(con);
+ }
+@@ -346,14 +366,20 @@ err:
+ */
+ static void tipc_conn_write_space(struct sock *sk)
+ {
++ struct tipc_topsrv *srv;
+ struct tipc_conn *con;
+
+ read_lock_bh(&sk->sk_callback_lock);
+ con = sk->sk_user_data;
+ if (connected(con)) {
+- conn_get(con);
+- if (!queue_work(con->server->send_wq, &con->swork))
+- conn_put(con);
++ srv = con->server;
++ spin_lock_bh(&srv->idr_lock);
++ if (srv->listener) {
++ conn_get(con);
++ if (!queue_work(srv->send_wq, &con->swork))
++ conn_put(con);
++ }
++ spin_unlock_bh(&srv->idr_lock);
+ }
+ read_unlock_bh(&sk->sk_callback_lock);
+ }
+@@ -418,8 +444,17 @@ static int tipc_conn_rcv_from_sock(struct tipc_conn *con)
+ static void tipc_conn_recv_work(struct work_struct *work)
+ {
+ struct tipc_conn *con = container_of(work, struct tipc_conn, rwork);
++ struct tipc_topsrv *srv;
+ int count = 0;
+
++ srv = con->server;
++ spin_lock_bh(&srv->idr_lock);
++ if (!srv->listener) {
++ spin_unlock_bh(&srv->idr_lock);
++ goto out;
++ }
++ spin_unlock_bh(&srv->idr_lock);
++
+ while (connected(con)) {
+ if (tipc_conn_rcv_from_sock(con))
+ break;
+@@ -430,6 +465,7 @@ static void tipc_conn_recv_work(struct work_struct *work)
+ count = 0;
+ }
+ }
++out:
+ conn_put(con);
+ }
+
+@@ -438,6 +474,7 @@ static void tipc_conn_recv_work(struct work_struct *work)
+ */
+ static void tipc_conn_data_ready(struct sock *sk)
+ {
++ struct tipc_topsrv *srv;
+ struct tipc_conn *con;
+
+ trace_sk_data_ready(sk);
+@@ -445,9 +482,14 @@ static void tipc_conn_data_ready(struct sock *sk)
+ read_lock_bh(&sk->sk_callback_lock);
+ con = sk->sk_user_data;
+ if (connected(con)) {
+- conn_get(con);
+- if (!queue_work(con->server->rcv_wq, &con->rwork))
+- conn_put(con);
++ srv = con->server;
++ spin_lock_bh(&srv->idr_lock);
++ if (srv->listener) {
++ conn_get(con);
++ if (!queue_work(srv->rcv_wq, &con->rwork))
++ conn_put(con);
++ }
++ spin_unlock_bh(&srv->idr_lock);
+ }
+ read_unlock_bh(&sk->sk_callback_lock);
+ }
+@@ -503,8 +545,12 @@ static void tipc_topsrv_listener_data_ready(struct sock *sk)
+
+ read_lock_bh(&sk->sk_callback_lock);
+ srv = sk->sk_user_data;
+- if (srv)
+- queue_work(srv->rcv_wq, &srv->awork);
++ if (srv) {
++ spin_lock_bh(&srv->idr_lock);
++ if (srv->listener)
++ queue_work(srv->rcv_wq, &srv->awork);
++ spin_unlock_bh(&srv->idr_lock);
++ }
+ read_unlock_bh(&sk->sk_callback_lock);
+ }
+
+@@ -700,23 +746,27 @@ static void tipc_topsrv_stop(struct net *net)
+ struct tipc_conn *con;
+ int id;
+
++ spin_lock_bh(&srv->idr_lock);
++ srv->listener = NULL;
++ spin_unlock_bh(&srv->idr_lock);
++ tipc_topsrv_work_stop(srv);
++
+ spin_lock_bh(&srv->idr_lock);
+ for (id = 0; srv->idr_in_use; id++) {
+ con = idr_find(&srv->conn_idr, id);
+ if (con) {
+- conn_get(con);
+ spin_unlock_bh(&srv->idr_lock);
+ tipc_conn_close(con);
+- conn_put(con);
+ spin_lock_bh(&srv->idr_lock);
++ continue;
+ }
++ spin_unlock_bh(&srv->idr_lock);
++ spin_lock_bh(&srv->idr_lock);
+ }
+ __module_get(lsock->ops->owner);
+ __module_get(lsock->sk->sk_prot_creator->owner);
+- srv->listener = NULL;
+ spin_unlock_bh(&srv->idr_lock);
+
+- tipc_topsrv_work_stop(srv);
+ sock_release(lsock);
+ idr_destroy(&srv->conn_idr);
+ kfree(srv);
+diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
+index 4a1dfde8414f44..f271a095996c9f 100644
+--- a/net/vmw_vsock/af_vsock.c
++++ b/net/vmw_vsock/af_vsock.c
+@@ -1021,6 +1021,8 @@ static void vsock_sk_destruct(struct sock *sk)
+ {
+ struct vsock_sock *vsk = vsock_sk(sk);
+
++ /* Socket buffers may remain in the queue in VMCI datagram mode */
++ __skb_queue_purge(&sk->sk_receive_queue);
+ /* Flush MSG_ZEROCOPY leftovers. */
+ __skb_queue_purge(&sk->sk_error_queue);
+
+diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
+index 8becad81279c86..1f3fd0895f7c63 100644
+--- a/net/vmw_vsock/virtio_transport_common.c
++++ b/net/vmw_vsock/virtio_transport_common.c
+@@ -1916,6 +1916,7 @@ int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t recv_acto
+ struct sock *sk = sk_vsock(vsk);
+ struct virtio_vsock_hdr *hdr;
+ struct sk_buff *skb;
++ u32 bytes_read;
+ u32 pkt_len;
+ int off = 0;
+ int err;
+@@ -1935,7 +1936,8 @@ int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t recv_acto
+ vvs->msg_count--;
+
+ pkt_len = le32_to_cpu(hdr->len);
+- virtio_transport_dec_rx_pkt(vvs, pkt_len, pkt_len);
++ bytes_read = skb->len - VIRTIO_VSOCK_SKB_CB(skb)->offset;
++ virtio_transport_dec_rx_pkt(vvs, bytes_read, pkt_len);
+ spin_unlock_bh(&vvs->rx_lock);
+
+ virtio_transport_send_credit_update(vsk);
+diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
+index e305ba32e356b7..f1f612cd7b438d 100644
+--- a/net/xfrm/xfrm_output.c
++++ b/net/xfrm/xfrm_output.c
+@@ -823,16 +823,22 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
+ }
+
+ if (skb->ip_summed == CHECKSUM_PARTIAL) {
+- err = skb_checksum_help(skb);
+- if (err) {
+- XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
+- kfree_skb(skb);
+- return err;
++ if (skb->protocol == htons(ETH_P_IP)) {
++ err = ip_check_csum_start(skb);
++ if (err)
++ goto error;
+ }
++ err = skb_checksum_help(skb);
++ if (err)
++ goto error;
+ }
+
+ out:
+ return xfrm_output2(net, sk, skb);
++error:
++ XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
++ kfree_skb(skb);
++ return err;
+ }
+ EXPORT_SYMBOL_GPL(xfrm_output);
+
+diff --git a/security/keys/key.c b/security/keys/key.c
+index b34a64d81d47ab..a438c4508595d9 100644
+--- a/security/keys/key.c
++++ b/security/keys/key.c
+@@ -840,9 +840,6 @@ static key_ref_t __key_create_or_update(key_ref_t keyring_ref,
+
+ key_check(keyring);
+
+- if (!(flags & KEY_ALLOC_BYPASS_RESTRICTION))
+- restrict_link = keyring->restrict_link;
+-
+ key_ref = ERR_PTR(-ENOTDIR);
+ if (keyring->type != &key_type_keyring)
+ goto error_put_type;
+@@ -880,6 +877,9 @@ static key_ref_t __key_create_or_update(key_ref_t keyring_ref,
+ goto error_link_end;
+ }
+
++ if (!(flags & KEY_ALLOC_BYPASS_RESTRICTION))
++ restrict_link = keyring->restrict_link;
++
+ if (restrict_link && restrict_link->check) {
+ ret = restrict_link->check(keyring, index_key.type,
+ &prep.payload, restrict_link->key);
+diff --git a/security/keys/persistent.c b/security/keys/persistent.c
+index 97af230aa4b22b..bdab9953932613 100644
+--- a/security/keys/persistent.c
++++ b/security/keys/persistent.c
+@@ -33,25 +33,31 @@ static int key_create_persistent_register(struct user_namespace *ns)
+ }
+
+ /*
+- * Create the persistent keyring for the specified user.
++ * Get or create the persistent keyring for the specified user.
+ *
+ * Called with the namespace's sem locked for writing.
++ *
++ * Returns a boolean indicating whether the keyring already existed,
++ * or a negative error. On success, *persistent_ref holds a reference
++ * to the keyring.
+ */
+-static key_ref_t key_create_persistent(struct user_namespace *ns, kuid_t uid,
+- struct keyring_index_key *index_key)
++static int key_get_or_create_persistent(struct user_namespace *ns, kuid_t uid,
++ struct keyring_index_key *index_key,
++ key_ref_t *persistent_ref)
+ {
+ struct key *persistent;
+- key_ref_t reg_ref, persistent_ref;
++ key_ref_t reg_ref;
+
+ if (!ns->persistent_keyring_register) {
+- long err = key_create_persistent_register(ns);
++ int err = key_create_persistent_register(ns);
++
+ if (err < 0)
+- return ERR_PTR(err);
++ return err;
+ } else {
+ reg_ref = make_key_ref(ns->persistent_keyring_register, true);
+- persistent_ref = find_key_to_update(reg_ref, index_key);
+- if (persistent_ref)
+- return persistent_ref;
++ *persistent_ref = find_key_to_update(reg_ref, index_key);
++ if (*persistent_ref)
++ return 1;
+ }
+
+ persistent = keyring_alloc(index_key->description,
+@@ -61,9 +67,10 @@ static key_ref_t key_create_persistent(struct user_namespace *ns, kuid_t uid,
+ KEY_ALLOC_NOT_IN_QUOTA, NULL,
+ ns->persistent_keyring_register);
+ if (IS_ERR(persistent))
+- return ERR_CAST(persistent);
++ return PTR_ERR(persistent);
+
+- return make_key_ref(persistent, true);
++ *persistent_ref = make_key_ref(persistent, true);
++ return 0;
+ }
+
+ /*
+@@ -78,6 +85,7 @@ static long key_get_persistent(struct user_namespace *ns, kuid_t uid,
+ key_ref_t reg_ref, persistent_ref;
+ char buf[32];
+ long ret;
++ bool created = false;
+
+ /* Look in the register if it exists */
+ memset(&index_key, 0, sizeof(index_key));
+@@ -100,23 +108,24 @@ static long key_get_persistent(struct user_namespace *ns, kuid_t uid,
+ * also need to create the register.
+ */
+ down_write(&ns->keyring_sem);
+- persistent_ref = key_create_persistent(ns, uid, &index_key);
++ ret = key_get_or_create_persistent(ns, uid, &index_key,
++ &persistent_ref);
+ up_write(&ns->keyring_sem);
+- if (!IS_ERR(persistent_ref))
+- goto found;
+-
+- return PTR_ERR(persistent_ref);
++ if (ret < 0)
++ return ret;
++ created = ret == 0;
+
+ found:
++ persistent = key_ref_to_ptr(persistent_ref);
+ ret = key_task_permission(persistent_ref, current_cred(), KEY_NEED_LINK);
+- if (ret == 0) {
+- persistent = key_ref_to_ptr(persistent_ref);
++ if (ret == 0)
+ ret = key_link(key_ref_to_ptr(dest_ref), persistent);
+- if (ret == 0) {
+- key_set_timeout(persistent, persistent_keyring_expiry);
+- ret = persistent->serial;
+- }
+- }
++
++ if (ret == 0 || created)
++ key_set_timeout(persistent, persistent_keyring_expiry);
++
++ if (ret == 0)
++ ret = persistent->serial;
+
+ key_ref_put(persistent_ref);
+ return ret;
+diff --git a/security/selinux/avc.c b/security/selinux/avc.c
+index 221c41978dc509..436b9af7b92c1d 100644
+--- a/security/selinux/avc.c
++++ b/security/selinux/avc.c
+@@ -579,7 +579,7 @@ static int avc_latest_notif_update(u32 seqno, int is_insert)
+ }
+ } else {
+ if (seqno > selinux_avc.avc_cache.latest_notif)
+- selinux_avc.avc_cache.latest_notif = seqno;
++ WRITE_ONCE(selinux_avc.avc_cache.latest_notif, seqno);
+ }
+ spin_unlock_irqrestore(¬if_lock, flag);
+
+@@ -1207,5 +1207,6 @@ int avc_has_perm(u32 ssid, u32 tsid, u16 tclass,
+
+ u32 avc_policy_seqno(void)
+ {
+- return selinux_avc.avc_cache.latest_notif;
++ /* Writers hold notif_lock; readers only sample the sequence number. */
++ return READ_ONCE(selinux_avc.avc_cache.latest_notif);
+ }
+diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
+index 5832131f29c47d..cf7297072ec03f 100644
+--- a/security/selinux/hooks.c
++++ b/security/selinux/hooks.c
+@@ -688,8 +688,12 @@ static int selinux_set_mnt_opts(struct super_block *sb,
+ * will be used for both mounts)
+ */
+ if ((sbsec->flags & SE_SBINITIALIZED) && (sb->s_type->fs_flags & FS_BINARY_MOUNTDATA)
+- && !opts)
++ && !opts) {
++ if ((kern_flags & SECURITY_LSM_NATIVE_LABELS) &&
++ sbsec->behavior == SECURITY_FS_USE_NATIVE)
++ *set_kern_flags |= SECURITY_LSM_NATIVE_LABELS;
+ goto out;
++ }
+
+ root_isec = backing_inode_security_novalidate(root);
+
+@@ -733,6 +737,9 @@ static int selinux_set_mnt_opts(struct super_block *sb,
+ /* previously mounted with options, but not on this attempt? */
+ if ((sbsec->flags & SE_MNTMASK) && !opts)
+ goto out_double_mount;
++ if ((kern_flags & SECURITY_LSM_NATIVE_LABELS) &&
++ sbsec->behavior == SECURITY_FS_USE_NATIVE)
++ *set_kern_flags |= SECURITY_LSM_NATIVE_LABELS;
+ rc = 0;
+ goto out;
+ }
+diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.c b/sound/hda/codecs/side-codecs/tas2781_hda.c
+index b22f93424c6211..e0da299df780c2 100644
+--- a/sound/hda/codecs/side-codecs/tas2781_hda.c
++++ b/sound/hda/codecs/side-codecs/tas2781_hda.c
+@@ -139,9 +139,21 @@ static void tas2781_apply_calib(struct tasdevice_priv *p)
+ */
+ crc = crc32(~0, data, 84) ^ ~0;
+ if (crc != tmp_val[21]) {
+- cali_data->total_sz = 0;
+- dev_err(p->dev, "%s: V1 CRC error\n", __func__);
+- return;
++ /*
++ * Some Lenovo BIOSes (e.g. Legion Pro 7 16IRX9H,
++ * SSID 17aa:38cd) store valid V1 calibration data
++ * but leave TimeStamp and CRC zeroed.
++ */
++ if (!tmp_val[20] && !tmp_val[21] &&
++ tmp_val[0] && tmp_val[1]) {
++ dev_warn(p->dev,
++ "%s: V1 data without CRC, accepting\n",
++ __func__);
++ } else {
++ cali_data->total_sz = 0;
++ dev_err(p->dev, "%s: V1 CRC error\n", __func__);
++ return;
++ }
+ }
+
+ for (j = p->ndev - 1; j >= 0; j--) {
+diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c
+index 69aacd06716cef..59ed96fb938a23 100644
+--- a/sound/pci/ctxfi/ctdaio.c
++++ b/sound/pci/ctxfi/ctdaio.c
+@@ -221,14 +221,18 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input)
+
+ static int dao_clear_input(struct dao *dao, unsigned int start, unsigned int end)
+ {
++ struct imapper *entry;
+ unsigned int i;
+
+- if (!dao->imappers[start])
++ entry = dao->imappers[start];
++ if (!entry)
+ return 0;
++
+ for (i = start; i < end; i++) {
+ dao->mgr->imap_delete(dao->mgr, dao->imappers[i]);
+ dao->imappers[i] = NULL;
+ }
++ kfree(entry);
+
+ return 0;
+ }
+diff --git a/sound/soc/amd/yc/acp6x-mach.c b/sound/soc/amd/yc/acp6x-mach.c
+index 79858fc9480651..7eaf15a27b7b91 100644
+--- a/sound/soc/amd/yc/acp6x-mach.c
++++ b/sound/soc/amd/yc/acp6x-mach.c
+@@ -759,6 +759,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = {
+ DMI_MATCH(DMI_BOARD_NAME, "Herbag_MDU"),
+ }
+ },
++ {
++ .driver_data = &acp6x_card,
++ .matches = {
++ DMI_MATCH(DMI_BOARD_VENDOR, "MDC"),
++ DMI_MATCH(DMI_BOARD_NAME, "Herbag2_MDU"),
++ }
++ },
+ {
+ .driver_data = &acp6x_card,
+ .matches = {
+diff --git a/sound/soc/codecs/adau1372.c b/sound/soc/codecs/adau1372.c
+index cc174ec3a1f825..c3d3be898ba6cc 100644
+--- a/sound/soc/codecs/adau1372.c
++++ b/sound/soc/codecs/adau1372.c
+@@ -798,7 +798,7 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
+ if (ret)
+ return ret;
+ if (adau1372->pd_gpio)
+- gpiod_set_value(adau1372->pd_gpio, 0);
++ gpiod_set_value_cansleep(adau1372->pd_gpio, 0);
+
+ if (adau1372->switch_mode)
+ adau1372->switch_mode(adau1372->dev);
+@@ -818,8 +818,7 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
+ ADAU1372_CLK_CTRL_PLL_EN,
+ 0);
+ regcache_cache_only(adau1372->regmap, true);
+- if (adau1372->pd_gpio)
+- gpiod_set_value(adau1372->pd_gpio, 1);
++ gpiod_set_value_cansleep(adau1372->pd_gpio, 1);
+ clk_disable_unprepare(adau1372->mclk);
+ return ret;
+ }
+@@ -836,7 +835,7 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)
+ * map. No need to do any register writes to manually
+ * turn things off.
+ */
+- gpiod_set_value(adau1372->pd_gpio, 1);
++ gpiod_set_value_cansleep(adau1372->pd_gpio, 1);
+ regcache_mark_dirty(adau1372->regmap);
+ } else {
+ regmap_update_bits(adau1372->regmap, ADAU1372_REG_CLK_CTRL,
+@@ -1003,6 +1002,17 @@ int adau1372_probe(struct device *dev, struct regmap *regmap,
+
+ regmap_write(regmap, ADAU1372_REG_OP_STAGE_MUTE, 0x0);
+
++ /*
++ * Set sane default values for the Output ASRC and DAC input muxes,
++ * since the power-on reset defaults are invalid "Reserved" states.
++ */
++ regmap_write(regmap, ADAU1372_REG_ASRCO_SOURCE_0_1,
++ 0x54); /* Decimator0, Decimator1 */
++ regmap_write(regmap, ADAU1372_REG_ASRCO_SOURCE_2_3,
++ 0x76); /* Decimator2, Decimator3 */
++ regmap_write(regmap, ADAU1372_REG_DAC_SOURCE,
++ 0xdc); /* Input ASRC0, Input ASRC1 */
++
+ regmap_write(regmap, 0x7, 0x01); /* CLOCK OUT */
+
+ return devm_snd_soc_register_component(dev, &adau1372_driver, &adau1372_dai_driver, 1);
+diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
+index f80e8d49815652..525126ecb0c302 100644
+--- a/sound/soc/samsung/i2s.c
++++ b/sound/soc/samsung/i2s.c
+@@ -1518,9 +1518,16 @@ static int samsung_i2s_probe(struct platform_device *pdev)
+ goto err_disable_pm;
+
+ priv->op_clk = clk_get_parent(priv->clk_table[CLK_I2S_RCLK_SRC]);
++ ret = clk_prepare_enable(priv->op_clk);
++ if (ret < 0) {
++ priv->op_clk = NULL;
++ goto err_unregister_clk;
++ }
+
+ return 0;
+
++err_unregister_clk:
++ i2s_unregister_clock_provider(priv);
+ err_disable_pm:
+ pm_runtime_disable(&pdev->dev);
+ err_del_sec:
+@@ -1543,6 +1550,7 @@ static void samsung_i2s_remove(struct platform_device *pdev)
+
+ i2s_unregister_clock_provider(priv);
+ i2s_delete_secondary_device(priv);
++ clk_disable_unprepare(priv->op_clk);
+ clk_disable_unprepare(priv->clk);
+
+ pm_runtime_put_noidle(&pdev->dev);
+diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
+index 5266720e58b3ce..a47f34afd1d19c 100644
+--- a/sound/soc/sdw_utils/soc_sdw_utils.c
++++ b/sound/soc/sdw_utils/soc_sdw_utils.c
+@@ -797,7 +797,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
+ },
+ {
+ .direction = {false, true},
+- .dai_name = "cs35l56-sdw1c",
++ .dai_name = "cs35l56-ot25",
+ .dai_type = SOC_SDW_DAI_TYPE_AMP,
+ .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
+ .rtd_init = asoc_sdw_cs_spk_feedback_rtd_init,
+@@ -826,7 +826,36 @@ struct asoc_sdw_codec_info codec_info_list[] = {
+ },
+ {
+ .direction = {false, true},
+- .dai_name = "cs35l56-sdw1c",
++ .dai_name = "cs35l56-ot25",
++ .dai_type = SOC_SDW_DAI_TYPE_AMP,
++ .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
++ .rtd_init = asoc_sdw_cs_spk_feedback_rtd_init,
++ },
++ },
++ .dai_num = 2,
++ },
++ {
++ .vendor_id = 0x01fa,
++ .part_id = 0x3562,
++ .name_prefix = "AMP",
++ .is_amp = true,
++ .dais = {
++ {
++ .direction = {true, false},
++ .dai_name = "cs35l56-sdw1",
++ .component_name = "cs35l56",
++ .dai_type = SOC_SDW_DAI_TYPE_AMP,
++ .dailink = {SOC_SDW_AMP_OUT_DAI_ID, SOC_SDW_UNUSED_DAI_ID},
++ .init = asoc_sdw_cs_amp_init,
++ .rtd_init = asoc_sdw_cs_spk_rtd_init,
++ .controls = generic_spk_controls,
++ .num_controls = ARRAY_SIZE(generic_spk_controls),
++ .widgets = generic_spk_widgets,
++ .num_widgets = ARRAY_SIZE(generic_spk_widgets),
++ },
++ {
++ .direction = {false, true},
++ .dai_name = "cs35l56-ot25",
+ .dai_type = SOC_SDW_DAI_TYPE_AMP,
+ .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
+ .rtd_init = asoc_sdw_cs_spk_feedback_rtd_init,
+@@ -855,7 +884,7 @@ struct asoc_sdw_codec_info codec_info_list[] = {
+ },
+ {
+ .direction = {false, true},
+- .dai_name = "cs35l56-sdw1c",
++ .dai_name = "cs35l56-ot25",
+ .dai_type = SOC_SDW_DAI_TYPE_AMP,
+ .dailink = {SOC_SDW_UNUSED_DAI_ID, SOC_SDW_AMP_IN_DAI_ID},
+ .rtd_init = asoc_sdw_cs_spk_feedback_rtd_init,
+diff --git a/tools/testing/selftests/mm/hugetlb-mmap.c b/tools/testing/selftests/mm/hugetlb-mmap.c
+index 0f2aad1b7dbd6f..2edbc992e6bcf0 100644
+--- a/tools/testing/selftests/mm/hugetlb-mmap.c
++++ b/tools/testing/selftests/mm/hugetlb-mmap.c
+@@ -122,7 +122,7 @@ int main(int argc, char **argv)
+ hugepage_size = default_huge_page_size();
+ if (!hugepage_size)
+ ksft_exit_skip("Could not detect default hugetlb page size.");
+- ksft_print_msg("Default size hugepages (%lu kB)\n", hugepage_size >> 10);
++ ksft_print_msg("Default size hugepages (%zu kB)\n", hugepage_size >> 10);
+ }
+
+ /* munmap will fail if the length is not page aligned */
+@@ -131,7 +131,7 @@ int main(int argc, char **argv)
+
+ hugetlb_set_nr_pages(hugepage_size, nr);
+ if (hugetlb_free_pages(hugepage_size) < nr)
+- ksft_exit_skip("Not enough %lu Kb pages\n", hugepage_size >> 10);
++ ksft_exit_skip("Not enough %zu Kb pages\n", hugepage_size >> 10);
+
+ ksft_set_plan(2);
+ ksft_print_msg("Mapping %lu Mbytes\n", (unsigned long)length >> 20);
+diff --git a/tools/testing/vma/tests/vma.c b/tools/testing/vma/tests/vma.c
+index 754a2da0632157..b7563ff20277e7 100644
+--- a/tools/testing/vma/tests/vma.c
++++ b/tools/testing/vma/tests/vma.c
+@@ -38,7 +38,7 @@ static bool test_copy_vma(void)
+ /* Move backwards and do not merge. */
+
+ vma = alloc_and_link_vma(&mm, 0x3000, 0x5000, 3, vma_flags);
+- vma_new = copy_vma(&vma, 0, 0x2000, 0, &need_locks);
++ vma_new = copy_vma(&vma, 0, 0x2000, 0, &need_locks, false);
+ ASSERT_NE(vma_new, vma);
+ ASSERT_EQ(vma_new->vm_start, 0);
+ ASSERT_EQ(vma_new->vm_end, 0x2000);
+@@ -51,7 +51,7 @@ static bool test_copy_vma(void)
+
+ vma = alloc_and_link_vma(&mm, 0, 0x2000, 0, vma_flags);
+ vma_next = alloc_and_link_vma(&mm, 0x6000, 0x8000, 6, vma_flags);
+- vma_new = copy_vma(&vma, 0x4000, 0x2000, 4, &need_locks);
++ vma_new = copy_vma(&vma, 0x4000, 0x2000, 4, &need_locks, false);
+ vma_assert_attached(vma_new);
+
+ ASSERT_EQ(vma_new, vma_next);
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.11-12.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.11-12.patch
new file mode 100644
index 0000000..318bb2d
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.11-12.patch
@@ -0,0 +1,790 @@
+diff --git a/Makefile b/Makefile
+index 4b60c83ab75c17..a550506403fe15 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0
+ VERSION = 7
+ PATCHLEVEL = 2
+-SUBLEVEL = 11
++SUBLEVEL = 12
+ EXTRAVERSION =
+ NAME = Baby Opossum Posse
+
+diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
+index 9973f905955a78..ded77a4c8069ac 100644
+--- a/arch/x86/kvm/x86.h
++++ b/arch/x86/kvm/x86.h
+@@ -313,7 +313,7 @@ static inline bool is_noncanonical_invlpg_address(u64 la, struct kvm_vcpu *vcpu)
+ static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
+ gva_t gva, gfn_t gfn, unsigned access)
+ {
+- u64 gen = kvm_memslots(vcpu->kvm)->generation;
++ u64 gen = kvm_vcpu_memslots(vcpu)->generation;
+
+ if (unlikely(gen & KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS))
+ return;
+@@ -330,7 +330,7 @@ static inline void vcpu_cache_mmio_info(struct kvm_vcpu *vcpu,
+
+ static inline bool vcpu_match_mmio_gen(struct kvm_vcpu *vcpu)
+ {
+- return vcpu->arch.mmio_gen == kvm_memslots(vcpu->kvm)->generation;
++ return vcpu->arch.mmio_gen == kvm_vcpu_memslots(vcpu)->generation;
+ }
+
+ /*
+diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
+index 4bda7b5dba1a64..3b36f4b8ec67b3 100644
+--- a/drivers/md/dm-integrity.c
++++ b/drivers/md/dm-integrity.c
+@@ -180,6 +180,7 @@ struct dm_integrity_c {
+ struct dm_bufio_client *bufio;
+ struct workqueue_struct *metadata_wq;
+ struct superblock *sb;
++ struct superblock *sb_copy;
+ unsigned int journal_pages;
+ unsigned int n_bitmap_blocks;
+
+@@ -3857,6 +3858,35 @@ static void dm_integrity_postsuspend(struct dm_target *ti)
+ ic->journal_uptodate = true;
+ }
+
++/*
++ * The superblock is re-read from the device on every resume, so that we pick
++ * up the flags and the recalculate position. The geometry described by the
++ * superblock must not change though - the in-memory structures (and the
++ * journal in particular) were sized according to the superblock that was
++ * validated in the constructor. Reject a superblock that was modified behind
++ * our back.
++ *
++ * Only the fields that the driver never rewrites may be tested here. In
++ * particular, "version" is recalculated by sb_set_version on every superblock
++ * write and it depends on SB_FLAG_RECALCULATING and SB_FLAG_DIRTY_BITMAP, and
++ * SB_FLAG_DISCARD_KEYED may be set by dm_integrity_resume itself.
++ */
++static bool superblock_changed(struct dm_integrity_c *ic)
++{
++ const __le32 immutable_flags = cpu_to_le32(SB_FLAG_HAVE_JOURNAL_MAC |
++ SB_FLAG_FIXED_PADDING |
++ SB_FLAG_FIXED_HMAC |
++ SB_FLAG_INLINE);
++
++ return memcmp(ic->sb->magic, ic->sb_copy->magic, sizeof(ic->sb->magic)) != 0 ||
++ ic->sb->log2_interleave_sectors != ic->sb_copy->log2_interleave_sectors ||
++ ic->sb->integrity_tag_size != ic->sb_copy->integrity_tag_size ||
++ ic->sb->journal_sections != ic->sb_copy->journal_sections ||
++ ic->sb->log2_sectors_per_block != ic->sb_copy->log2_sectors_per_block ||
++ ((ic->sb->flags ^ ic->sb_copy->flags) & immutable_flags) != 0 ||
++ memcmp(ic->sb->salt, ic->sb_copy->salt, SALT_SIZE) != 0;
++}
++
+ static void dm_integrity_resume(struct dm_target *ti)
+ {
+ struct dm_integrity_c *ic = ti->private;
+@@ -3874,6 +3904,22 @@ static void dm_integrity_resume(struct dm_target *ti)
+ r = sync_rw_sb(ic, REQ_OP_READ);
+ if (r)
+ dm_integrity_io_error(ic, "reading superblock", r);
++
++ if (unlikely(superblock_changed(ic))) {
++ /*
++ * Restore the superblock that we validated in the constructor,
++ * so that the rest of the driver doesn't operate on values
++ * that don't match the in-memory structures.
++ */
++ memcpy(ic->sb, ic->sb_copy, sizeof(struct superblock));
++ DMERR("The superblock was changed while the device was suspended");
++ dm_integrity_io_error(ic, "superblock check", -EINVAL);
++ goto skip_writes;
++ }
++
++ if (ic->mode == 'R')
++ goto skip_writes;
++
+ if ((ic->sb->flags & flags) != flags) {
+ ic->sb->flags |= flags;
+ r = sync_rw_sb(ic, REQ_OP_WRITE | REQ_FUA);
+@@ -3983,6 +4029,7 @@ static void dm_integrity_resume(struct dm_target *ti)
+ }
+ }
+
++skip_writes:
+ ic->reboot_notifier.notifier_call = dm_integrity_reboot;
+ ic->reboot_notifier.next = NULL;
+ ic->reboot_notifier.priority = INT_MAX - 1; /* be notified after md and before hardware drivers */
+@@ -5416,6 +5463,13 @@ try_smaller_buffer:
+ ic->just_formatted = true;
+ }
+
++ ic->sb_copy = kmemdup(ic->sb, sizeof(struct superblock), GFP_KERNEL);
++ if (!ic->sb_copy) {
++ ti->error = "Cannot allocate superblock copy";
++ r = -ENOMEM;
++ goto bad;
++ }
++
+ if (!ic->meta_dev && ic->mode != 'I') {
+ r = dm_set_target_max_io_len(ti, 1U << ic->sb->log2_interleave_sectors);
+ if (r)
+@@ -5514,6 +5568,7 @@ static void dm_integrity_dtr(struct dm_target *ti)
+ kvfree(ic->journal_tree);
+ if (ic->sb)
+ free_pages_exact(ic->sb, SB_SECTORS << SECTOR_SHIFT);
++ kfree(ic->sb_copy);
+
+ if (ic->internal_shash)
+ crypto_free_shash(ic->internal_shash);
+diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
+index 5c9961ee9747ab..b27fd9b8c4f6d8 100644
+--- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
++++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
+@@ -91,7 +91,7 @@ u32 mana_run_xdp(struct net_device *ndev, struct mana_rxq *rxq,
+ goto out;
+
+ xdp_init_buff(xdp, PAGE_SIZE, &rxq->xdp_rxq);
+- xdp_prepare_buff(xdp, buf_va, XDP_PACKET_HEADROOM, pkt_len, true);
++ xdp_prepare_buff(xdp, buf_va, rxq->headroom, pkt_len, true);
+
+ act = bpf_prog_run_xdp(prog, xdp);
+
+@@ -183,9 +183,9 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
+ if (!old_prog && !prog)
+ return 0;
+
+- if (prog && ndev->mtu > MANA_XDP_MTU_MAX) {
++ if (prog && ndev->mtu > MANA_XDP_MTU_MAX(ndev)) {
+ netdev_err(ndev, "XDP: mtu:%u too large, mtu_max:%lu\n",
+- ndev->mtu, MANA_XDP_MTU_MAX);
++ ndev->mtu, MANA_XDP_MTU_MAX(ndev));
+ NL_SET_ERR_MSG_MOD(extack, "XDP: mtu too large");
+
+ return -EOPNOTSUPP;
+@@ -238,7 +238,7 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
+ bpf_prog_put(old_prog);
+
+ if (prog)
+- ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX,
++ ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX(ndev),
+ gc->adapter_mtu - ETH_HLEN);
+ else
+ ndev->max_mtu = gc->adapter_mtu - ETH_HLEN;
+diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
+index 8fb29dcddf8e2e..af5d4a4f56f165 100644
+--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
++++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
+@@ -755,26 +755,62 @@ static void *mana_get_rxbuf_pre(struct mana_rxq *rxq, dma_addr_t *da)
+ return va;
+ }
+
+-/* Get RX buffer's data size, alloc size, XDP headroom based on MTU */
++/* Reserve enough headroom to satisfy the skb_cow() in ip_forward() and avoid
++ * reallocation: the TX path keeps the SGE DMA mappings in struct mana_skb_head
++ * at skb->head, so the port advertises ndev->needed_headroom = MANA_HEADROOM.
++ */
++static u32 mana_get_rxbuf_headroom(struct mana_port_context *apc)
++{
++ if (mana_xdp_get(apc))
++ return mana_xdp_headroom(apc->ndev);
++
++ return LL_RESERVED_SPACE(apc->ndev);
++}
++
++static u32 mana_get_rxbuf_size(struct mana_port_context *apc, u32 mtu)
++{
++ u32 len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD +
++ mana_get_rxbuf_headroom(apc));
++
++ return ALIGN(len, MANA_RX_FRAG_ALIGNMENT);
++}
++
++/* Returns true when one RX buffer per page is already required by XDP or by
++ * the buffer size implied by the MTU, i.e. regardless of the
++ * MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF private flag.
++ */
++bool mana_single_rxbuf_per_page_forced(struct mana_port_context *apc, u32 mtu)
++{
++ /* For xdp make sure only one packet fits per page. */
++ if (mana_xdp_get(apc))
++ return true;
++
++ /* Only use the page_pool fragment path when at least two buffers,
++ * including the headroom each of them has to reserve, actually fit
++ * into one page. Otherwise the fragment path degenerates into one
++ * buffer per page while still paying the fragment accounting cost.
++ */
++ return PAGE_SIZE / mana_get_rxbuf_size(apc, mtu) < 2;
++}
++
++/* Get RX buffer's data size, alloc size, headroom and frag count based on MTU */
+ static void mana_get_rxbuf_cfg(struct mana_port_context *apc,
+ int mtu, u32 *datasize, u32 *alloc_size,
+ u32 *headroom, u32 *frag_count)
+ {
+- u32 len, buf_size;
++ u32 buf_size;
+
+ /* Calculate datasize first (consistent across all cases) */
+ *datasize = mtu + ETH_HLEN;
+
+- /* For xdp and jumbo frames make sure only one packet fits per page */
+- if (mtu + MANA_RXBUF_PAD > PAGE_SIZE / 2 || mana_xdp_get(apc)) {
+- if (mana_xdp_get(apc)) {
+- *headroom = XDP_PACKET_HEADROOM;
++ *headroom = mana_get_rxbuf_headroom(apc);
++
++ if (mana_single_rxbuf_per_page_forced(apc, mtu)) {
++ if (mana_xdp_get(apc))
+ *alloc_size = PAGE_SIZE;
+- } else {
+- *headroom = 0; /* no support for XDP */
++ else
+ *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD +
+ *headroom);
+- }
+
+ *frag_count = 1;
+
+@@ -788,11 +824,7 @@ static void mana_get_rxbuf_cfg(struct mana_port_context *apc,
+ }
+
+ /* Standard MTU case - optimize for multiple packets per page */
+- *headroom = 0;
+-
+- /* Calculate base buffer size needed */
+- len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom);
+- buf_size = ALIGN(len, MANA_RX_FRAG_ALIGNMENT);
++ buf_size = mana_get_rxbuf_size(apc, mtu);
+
+ /* Calculate how many packets can fit in a page */
+ *frag_count = PAGE_SIZE / buf_size;
+diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
+index 881df597d7f9c7..3531abfdaf4338 100644
+--- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
++++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c
+@@ -138,53 +138,70 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset)
+ struct mana_port_context *apc = netdev_priv(ndev);
+ unsigned int num_queues = apc->num_queues;
+
+- if (stringset != ETH_SS_STATS)
++ switch (stringset) {
++ case ETH_SS_STATS:
++ return ARRAY_SIZE(mana_eth_stats) +
++ ARRAY_SIZE(mana_phy_stats) +
++ ARRAY_SIZE(mana_hc_stats) +
++ num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT);
++ default:
+ return -EINVAL;
+-
+- return ARRAY_SIZE(mana_eth_stats) + ARRAY_SIZE(mana_phy_stats) + ARRAY_SIZE(mana_hc_stats) +
+- num_queues * (MANA_STATS_RX_COUNT + MANA_STATS_TX_COUNT);
++ }
+ }
+
+-static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
++static void mana_get_strings_stats(struct mana_port_context *apc, u8 **data)
+ {
+- struct mana_port_context *apc = netdev_priv(ndev);
+ unsigned int num_queues = apc->num_queues;
+ int i, j;
+
+- if (stringset != ETH_SS_STATS)
+- return;
+ for (i = 0; i < ARRAY_SIZE(mana_eth_stats); i++)
+- ethtool_puts(&data, mana_eth_stats[i].name);
++ ethtool_puts(data, mana_eth_stats[i].name);
+
+ for (i = 0; i < ARRAY_SIZE(mana_hc_stats); i++)
+- ethtool_puts(&data, mana_hc_stats[i].name);
++ ethtool_puts(data, mana_hc_stats[i].name);
+
+ for (i = 0; i < ARRAY_SIZE(mana_phy_stats); i++)
+- ethtool_puts(&data, mana_phy_stats[i].name);
++ ethtool_puts(data, mana_phy_stats[i].name);
+
+ for (i = 0; i < num_queues; i++) {
+- ethtool_sprintf(&data, "rx_%d_packets", i);
+- ethtool_sprintf(&data, "rx_%d_bytes", i);
+- ethtool_sprintf(&data, "rx_%d_xdp_drop", i);
+- ethtool_sprintf(&data, "rx_%d_xdp_tx", i);
+- ethtool_sprintf(&data, "rx_%d_xdp_redirect", i);
+- ethtool_sprintf(&data, "rx_%d_pkt_len0_err", i);
++ ethtool_sprintf(data, "rx_%d_packets", i);
++ ethtool_sprintf(data, "rx_%d_bytes", i);
++ ethtool_sprintf(data, "rx_%d_xdp_drop", i);
++ ethtool_sprintf(data, "rx_%d_xdp_tx", i);
++ ethtool_sprintf(data, "rx_%d_xdp_redirect", i);
++ ethtool_sprintf(data, "rx_%d_pkt_len0_err", i);
+ for (j = 0; j < MANA_RXCOMP_OOB_NUM_PPI - 1; j++)
+- ethtool_sprintf(&data, "rx_%d_coalesced_cqe_%d", i, j + 2);
++ ethtool_sprintf(data,
++ "rx_%d_coalesced_cqe_%d",
++ i,
++ j + 2);
+ }
+
+ for (i = 0; i < num_queues; i++) {
+- ethtool_sprintf(&data, "tx_%d_packets", i);
+- ethtool_sprintf(&data, "tx_%d_bytes", i);
+- ethtool_sprintf(&data, "tx_%d_xdp_xmit", i);
+- ethtool_sprintf(&data, "tx_%d_tso_packets", i);
+- ethtool_sprintf(&data, "tx_%d_tso_bytes", i);
+- ethtool_sprintf(&data, "tx_%d_tso_inner_packets", i);
+- ethtool_sprintf(&data, "tx_%d_tso_inner_bytes", i);
+- ethtool_sprintf(&data, "tx_%d_long_pkt_fmt", i);
+- ethtool_sprintf(&data, "tx_%d_short_pkt_fmt", i);
+- ethtool_sprintf(&data, "tx_%d_csum_partial", i);
+- ethtool_sprintf(&data, "tx_%d_mana_map_err", i);
++ ethtool_sprintf(data, "tx_%d_packets", i);
++ ethtool_sprintf(data, "tx_%d_bytes", i);
++ ethtool_sprintf(data, "tx_%d_xdp_xmit", i);
++ ethtool_sprintf(data, "tx_%d_tso_packets", i);
++ ethtool_sprintf(data, "tx_%d_tso_bytes", i);
++ ethtool_sprintf(data, "tx_%d_tso_inner_packets", i);
++ ethtool_sprintf(data, "tx_%d_tso_inner_bytes", i);
++ ethtool_sprintf(data, "tx_%d_long_pkt_fmt", i);
++ ethtool_sprintf(data, "tx_%d_short_pkt_fmt", i);
++ ethtool_sprintf(data, "tx_%d_csum_partial", i);
++ ethtool_sprintf(data, "tx_%d_mana_map_err", i);
++ }
++}
++
++static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
++{
++ struct mana_port_context *apc = netdev_priv(ndev);
++
++ switch (stringset) {
++ case ETH_SS_STATS:
++ mana_get_strings_stats(apc, &data);
++ break;
++ default:
++ break;
+ }
+ }
+
+diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c
+index 4a08babb6d9d67..44e91815a15943 100644
+--- a/drivers/net/wireless/ath/ath9k/wmi.c
++++ b/drivers/net/wireless/ath/ath9k/wmi.c
+@@ -206,16 +206,9 @@ static void ath9k_wmi_rsp_callback(struct wmi *wmi, struct sk_buff *skb)
+ {
+ skb_pull(skb, sizeof(struct wmi_cmd_hdr));
+
+- if (wmi->cmd_rsp_buf && wmi->cmd_rsp_len) {
+- if (skb->len < wmi->cmd_rsp_len) {
+- wmi->cmd_rsp_status = -EMSGSIZE;
+- goto complete;
+- }
++ if (wmi->cmd_rsp_buf != NULL && wmi->cmd_rsp_len != 0)
+ memcpy(wmi->cmd_rsp_buf, skb->data, wmi->cmd_rsp_len);
+- }
+- wmi->cmd_rsp_status = 0;
+
+-complete:
+ complete(&wmi->cmd_wait);
+ }
+
+@@ -307,7 +300,6 @@ static int ath9k_wmi_cmd_issue(struct wmi *wmi,
+ /* record the rsp buffer and length */
+ wmi->cmd_rsp_buf = rsp_buf;
+ wmi->cmd_rsp_len = rsp_len;
+- wmi->cmd_rsp_status = 0;
+
+ wmi->last_seq_id = wmi->tx_seq_id;
+ spin_unlock_irqrestore(&wmi->wmi_lock, flags);
+@@ -364,13 +356,9 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
+ return -ETIMEDOUT;
+ }
+
+- spin_lock_irqsave(&wmi->wmi_lock, flags);
+- ret = wmi->cmd_rsp_status;
+- spin_unlock_irqrestore(&wmi->wmi_lock, flags);
+-
+ mutex_unlock(&wmi->op_mutex);
+
+- return ret;
++ return 0;
+
+ out:
+ ath_dbg(common, WMI, "WMI failure for: %s\n", wmi_cmd_to_name(cmd_id));
+diff --git a/drivers/net/wireless/ath/ath9k/wmi.h b/drivers/net/wireless/ath/ath9k/wmi.h
+index 0bb9d31f1a1cc4..5c3b710b8f3190 100644
+--- a/drivers/net/wireless/ath/ath9k/wmi.h
++++ b/drivers/net/wireless/ath/ath9k/wmi.h
+@@ -157,7 +157,6 @@ struct wmi {
+ u16 tx_seq_id;
+ u8 *cmd_rsp_buf;
+ u32 cmd_rsp_len;
+- int cmd_rsp_status;
+ bool stopped;
+
+ struct list_head pending_tx_events;
+diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
+index 939749709e416d..7c29557962b0e6 100644
+--- a/fs/nfsd/nfs4proc.c
++++ b/fs/nfsd/nfs4proc.c
+@@ -2243,6 +2243,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
+ goto out_dec_async_copy_err;
+ memcpy(&result->cb_stateid, &async_copy->cp_stateid.cs_stid,
+ sizeof(result->cb_stateid));
++ memcpy(&async_copy->cp_res.cb_stateid, &async_copy->cp_stateid.cs_stid,
++ sizeof(async_copy->cp_res.cb_stateid));
+ if ((READ_ONCE(copy->nf_dst->nf_file->f_mode) &
+ FMODE_NOCMTIME) != 0)
+ async_copy->attr_update = true;
+diff --git a/fs/nullfs.c b/fs/nullfs.c
+index 20d3aa627a47de..c89181daf208c2 100644
+--- a/fs/nullfs.c
++++ b/fs/nullfs.c
+@@ -8,6 +8,35 @@ static const struct super_operations nullfs_super_operations = {
+ .statfs = simple_statfs,
+ };
+
++static loff_t nullfs_dir_llseek(struct file *file, loff_t offset, int whence)
++{
++ /* an empty directory has two entries . and .. at offsets 0 and 1 */
++ return generic_file_llseek_size(file, offset, whence, 2, 2);
++}
++
++static int nullfs_dir_readdir(struct file *file, struct dir_context *ctx)
++{
++ dir_emit_dots(file, ctx);
++ return 0;
++}
++
++/* the one inode of nullfs is shared by every holder, so no locks on it */
++static int nullfs_nolock(struct file *file, int cmd, struct file_lock *fl)
++{
++ return -ENOLCK;
++}
++
++/* what libfs gives an empty directory, plus the refusal of file locks */
++static const struct file_operations nullfs_dir_operations = {
++ .llseek = nullfs_dir_llseek,
++ .read = generic_read_dir,
++ .iterate_shared = nullfs_dir_readdir,
++ .fsync = noop_fsync,
++ .lock = nullfs_nolock,
++ .flock = nullfs_nolock,
++ .fop_flags = FOP_IMMUTABLE,
++};
++
+ static int nullfs_fs_fill_super(struct super_block *s, struct fs_context *fc)
+ {
+ struct inode *inode;
+@@ -28,6 +57,7 @@ static int nullfs_fs_fill_super(struct super_block *s, struct fs_context *fc)
+
+ /* nullfs is permanently empty... */
+ make_empty_dir_inode(inode);
++ inode->i_fop = &nullfs_dir_operations;
+ simple_inode_init_ts(inode);
+ inode->i_ino = 1;
+ /* ... and immutable, reading it leaves no trace either. */
+diff --git a/fs/readdir.c b/fs/readdir.c
+index 76bb1ae3a45041..f2288841337ad1 100644
+--- a/fs/readdir.c
++++ b/fs/readdir.c
+@@ -87,6 +87,8 @@ EXPORT_SYMBOL(wrap_directory_iterator);
+ int iterate_dir(struct file *file, struct dir_context *ctx)
+ {
+ struct inode *inode = file_inode(file);
++ /* never an entry, never removed: nothing for the lock to keep still */
++ bool locked = !(file->f_op->fop_flags & FOP_IMMUTABLE);
+ int res = -ENOTDIR;
+
+ if (!file->f_op->iterate_shared)
+@@ -100,9 +102,11 @@ int iterate_dir(struct file *file, struct dir_context *ctx)
+ if (res)
+ goto out;
+
+- res = down_read_killable(&inode->i_rwsem);
+- if (res)
+- goto out;
++ if (locked) {
++ res = down_read_killable(&inode->i_rwsem);
++ if (res)
++ goto out;
++ }
+
+ res = -ENOENT;
+ if (!IS_DEADDIR(inode)) {
+@@ -112,7 +116,8 @@ int iterate_dir(struct file *file, struct dir_context *ctx)
+ fsnotify_access(file);
+ file_accessed(file);
+ }
+- inode_unlock_shared(inode);
++ if (locked)
++ inode_unlock_shared(inode);
+ out:
+ return res;
+ }
+diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
+index 07de36aac0bffc..5f82dcd9a0b559 100644
+--- a/fs/smb/server/smb2pdu.c
++++ b/fs/smb/server/smb2pdu.c
+@@ -2098,7 +2098,7 @@ static int krb5_authenticate(struct ksmbd_work *work,
+ in_len = le16_to_cpu(req->SecurityBufferLength);
+ out_blob = (char *)&rsp->hdr.ProtocolId +
+ le16_to_cpu(rsp->SecurityBufferOffset);
+- out_len = work->response_sz -
++ out_len = work->response_sz - work->next_smb2_rsp_hdr_off -
+ (le16_to_cpu(rsp->SecurityBufferOffset) + 4);
+
+ retval = ksmbd_krb5_authenticate(sess, in_blob, in_len,
+diff --git a/include/linux/fs.h b/include/linux/fs.h
+index 09de7bf6f1d28e..a07031fd4ae242 100644
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -1980,6 +1980,8 @@ struct file_operations {
+ #define FOP_ASYNC_LOCK ((__force fop_flags_t)(1 << 6))
+ /* File system supports uncached read/write buffered IO */
+ #define FOP_DONTCACHE ((__force fop_flags_t)(1 << 7))
++/* Never changes and is never removed, readdir of a directory takes no lock */
++#define FOP_IMMUTABLE ((__force fop_flags_t)(1 << 8))
+
+ /* Wrap a directory iterator that needs exclusive inode access */
+ int wrap_directory_iterator(struct file *, struct dir_context *,
+diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
+index 04acb6791dbd97..cd44856fa474c8 100644
+--- a/include/net/mana/mana.h
++++ b/include/net/mana/mana.h
+@@ -328,7 +328,18 @@ struct mana_recv_buf_oob {
+ #define MANA_RXBUF_PAD (SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) \
+ + ETH_HLEN)
+
+-#define MANA_XDP_MTU_MAX (PAGE_SIZE - MANA_RXBUF_PAD - XDP_PACKET_HEADROOM)
++/* Headroom an RX buffer has to reserve while XDP is attached: the XDP program
++ * needs XDP_PACKET_HEADROOM, and the TX path needs LL_RESERVED_SPACE() (see
++ * mana_get_rxbuf_headroom()). LL_RESERVED_SPACE() grows with MAX_SKB_FRAGS and
++ * exceeds XDP_PACKET_HEADROOM once CONFIG_MAX_SKB_FRAGS is 19 or more.
++ */
++static inline u32 mana_xdp_headroom(struct net_device *ndev)
++{
++ return max_t(u32, LL_RESERVED_SPACE(ndev), XDP_PACKET_HEADROOM);
++}
++
++#define MANA_XDP_MTU_MAX(ndev) \
++ (PAGE_SIZE - MANA_RXBUF_PAD - mana_xdp_headroom(ndev))
+
+ struct mana_rxq {
+ struct gdma_queue *gdma_rq;
+@@ -625,6 +636,7 @@ int mana_query_link_cfg(struct mana_port_context *apc);
+ int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed,
+ int enable_clamping);
+ void mana_query_phy_stats(struct mana_port_context *apc);
++bool mana_single_rxbuf_per_page_forced(struct mana_port_context *apc, u32 mtu);
+ int mana_pre_alloc_rxbufs(struct mana_port_context *apc, int mtu, int num_queues);
+ void mana_pre_dealloc_rxbufs(struct mana_port_context *apc);
+ void mana_unmap_skb(struct sk_buff *skb, struct mana_port_context *apc);
+diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h
+index 2490b72c0a7a8c..07434e644b89d5 100644
+--- a/include/sound/cs35l56.h
++++ b/include/sound/cs35l56.h
+@@ -312,6 +312,7 @@ struct snd_ctl_elem_value;
+
+ #define CS35L56_SDW1_PLAYBACK_PORT 1
+ #define CS35L56_SDW1_CAPTURE_PORT 3
++#define CS35L56_OT25_CAPTURE_PORT 4
+
+ #define CS35L56_NUM_BULK_SUPPLIES 3
+ #define CS35L56_NUM_DSP_REGIONS 5
+diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
+index a9f33e2b17aceb..8d4992e7e01208 100644
+--- a/kernel/sched/ext/ext.c
++++ b/kernel/sched/ext/ext.c
+@@ -2031,8 +2031,8 @@ static void set_task_runnable(struct rq *rq, struct task_struct *p)
+ }
+
+ /*
+- * list_add_tail() must be used. scx_bypass() depends on tasks being
+- * appended to the runnable_list.
++ * list_add_tail() must be used. scx_bypass() and rq_offline_scx()
++ * depend on tasks being appended to the runnable_list.
+ */
+ list_add_tail(&p->scx.runnable_node, &rq->scx.runnable_list);
+ }
+@@ -2868,7 +2868,13 @@ scx_dispatch_sched(struct scx_sched *sch, struct rq *rq,
+ #endif /* CONFIG_EXT_SUB_SCHED */
+ }
+
+- if (unlikely(!SCX_HAS_OP(sch, dispatch)) || !scx_rq_online(rq))
++ /*
++ * scx_rq_online() can't be used. Its cpu_active() test goes false
++ * before CPU hotplug waits for an RCU grace period, and
++ * rq_offline_scx() moves this CPU's tasks to the local DSQ only after
++ * the wait. The grace period can depend on those tasks running.
++ */
++ if (unlikely(!SCX_HAS_OP(sch, dispatch)) || !(rq->scx.flags & SCX_RQ_ONLINE))
+ return SCX_DSP_NONE;
+
+ dspc->rq = rq;
+@@ -3608,7 +3614,24 @@ static void rq_online_scx(struct rq *rq)
+
+ static void rq_offline_scx(struct rq *rq)
+ {
++ struct task_struct *p, *n;
++
+ rq->scx.flags &= ~SCX_RQ_ONLINE;
++
++ /* sched domain rebuilds call rq_offline with the CPU staying alive */
++ if (cpu_active(cpu_of(rq)))
++ return;
++
++ /*
++ * An offline CPU no longer calls ops.dispatch(). Re-enqueue its tasks
++ * onto the local DSQ so that they run here and balance_push() moves
++ * them off.
++ */
++ list_for_each_entry_safe_reverse(p, n, &rq->scx.runnable_list, scx.runnable_node) {
++ if (p->scx.dsq == &rq->scx.local_dsq)
++ continue;
++ guard(sched_change)(p, DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK);
++ }
+ }
+
+ static bool check_rq_for_timeouts(struct rq *rq)
+diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
+index a6c6f8165eecc8..d25defb116caae 100644
+--- a/kernel/sched/sched.h
++++ b/kernel/sched/sched.h
+@@ -4185,8 +4185,9 @@ extern void balance_callbacks(struct rq *rq, struct balance_callback *head);
+ * after which it is enqueued again.
+ *
+ * Typically this must be called while holding task_rq_lock, since most/all
+- * properties are serialized under those locks. There is currently one
+- * exception to this rule in sched/ext which only holds rq->lock.
++ * properties are serialized under those locks. There are currently two
++ * exceptions to this rule in sched/ext which only hold rq->lock: scx_bypass()
++ * and rq_offline_scx().
+ */
+
+ /*
+diff --git a/sound/soc/codecs/cs35l56-sdw.c b/sound/soc/codecs/cs35l56-sdw.c
+index a3812ab4c02271..d52209111fe2ea 100644
+--- a/sound/soc/codecs/cs35l56-sdw.c
++++ b/sound/soc/codecs/cs35l56-sdw.c
+@@ -295,11 +295,11 @@ static int cs35l56_sdw_read_prop(struct sdw_slave *peripheral)
+ if (ret == 0)
+ prop->clk_stop_mode1 = !!clock_stop_1;
+
+- ports = devm_kcalloc(cs35l56->base.dev, 2, sizeof(*ports), GFP_KERNEL);
++ ports = devm_kcalloc(cs35l56->base.dev, 3, sizeof(*ports), GFP_KERNEL);
+ if (!ports)
+ return -ENOMEM;
+
+- prop->source_ports = BIT(CS35L56_SDW1_CAPTURE_PORT);
++ prop->source_ports = BIT(CS35L56_SDW1_CAPTURE_PORT) | BIT(CS35L56_OT25_CAPTURE_PORT);
+ prop->sink_ports = BIT(CS35L56_SDW1_PLAYBACK_PORT);
+ prop->paging_support = true;
+ prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY;
+@@ -315,6 +315,11 @@ static int cs35l56_sdw_read_prop(struct sdw_slave *peripheral)
+ ports[1].num = CS35L56_SDW1_CAPTURE_PORT;
+ ports[1].type = SDW_DPN_FULL;
+ ports[1].ch_prep_timeout = 10;
++
++ /* DP4 - capture */
++ ports[2].num = CS35L56_OT25_CAPTURE_PORT;
++ ports[2].type = SDW_DPN_FULL;
++ ports[2].ch_prep_timeout = 10;
+ prop->src_dpn_prop = &ports[1];
+
+ dev_dbg(&peripheral->dev, "clock stop mode 1 supported: %s\n",
+diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
+index 8beef93ac4676b..79f0a39d12b96c 100644
+--- a/sound/soc/codecs/cs35l56.c
++++ b/sound/soc/codecs/cs35l56.c
+@@ -32,6 +32,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -323,6 +324,7 @@ static const struct snd_soc_dapm_widget cs35l56_dapm_widgets[] = {
+ SND_SOC_DAPM_SIGGEN("VDDBMON ADC"),
+ SND_SOC_DAPM_SIGGEN("VBSTMON ADC"),
+ SND_SOC_DAPM_SIGGEN("TEMPMON ADC"),
++ SND_SOC_DAPM_SIGGEN("OT25 Reference"),
+
+ SND_SOC_DAPM_INPUT("Calibrate"),
+ };
+@@ -387,6 +389,8 @@ static const struct snd_soc_dapm_route cs35l56_audio_map[] = {
+ { "SDW1 Capture", NULL, "SDW1 TX2 Source" },
+ { "SDW1 Capture", NULL, "SDW1 TX3 Source" },
+ { "SDW1 Capture", NULL, "SDW1 TX4 Source" },
++
++ { "OT25", NULL, "OT25 Reference" },
+ };
+
+ static int cs35l56_dsp_event(struct snd_soc_dapm_widget *w,
+@@ -711,6 +715,37 @@ static int cs35l56_sdw_dai_set_stream(struct snd_soc_dai *dai,
+ return 0;
+ }
+
++static int cs35l56_ot25_dai_hw_params(struct snd_pcm_substream *substream,
++ struct snd_pcm_hw_params *params,
++ struct snd_soc_dai *dai)
++{
++ struct cs35l56_private *cs35l56 = snd_soc_component_get_drvdata(dai->component);
++ struct sdw_stream_runtime *sdw_stream = snd_soc_dai_get_dma_data(dai, substream);
++ struct sdw_stream_config sconfig = { };
++ struct sdw_port_config pconfig = { };
++ int ret;
++
++ dev_dbg(cs35l56->base.dev, "%s: rate %d\n", __func__, params_rate(params));
++
++ if (!cs35l56->base.init_done)
++ return -ENODEV;
++
++ if (!sdw_stream)
++ return -EINVAL;
++
++ snd_sdw_params_to_config(substream, params, &sconfig, &pconfig);
++ pconfig.num = CS35L56_OT25_CAPTURE_PORT;
++
++ ret = sdw_stream_add_slave(cs35l56->sdw_peripheral, &sconfig, &pconfig,
++ 1, sdw_stream);
++ if (ret) {
++ dev_err(dai->dev, "Failed to add OT25 stream: %d\n", ret);
++ return ret;
++ }
++
++ return 0;
++}
++
+ static const struct snd_soc_dai_ops cs35l56_sdw_dai_ops = {
+ .set_tdm_slot = cs35l56_sdw_dai_set_tdm_slot,
+ .shutdown = cs35l56_sdw_dai_shutdown,
+@@ -719,6 +754,13 @@ static const struct snd_soc_dai_ops cs35l56_sdw_dai_ops = {
+ .set_stream = cs35l56_sdw_dai_set_stream,
+ };
+
++static const struct snd_soc_dai_ops cs35l56_ot25_dai_ops = {
++ .shutdown = cs35l56_sdw_dai_shutdown,
++ .hw_params = cs35l56_ot25_dai_hw_params,
++ .hw_free = cs35l56_sdw_dai_hw_free,
++ .set_stream = cs35l56_sdw_dai_set_stream,
++};
++
+ static struct snd_soc_dai_driver cs35l56_dai[] = {
+ {
+ .name = "cs35l56-asp1",
+@@ -767,6 +809,18 @@ static struct snd_soc_dai_driver cs35l56_dai[] = {
+ .symmetric_rate = 1,
+ .ops = &cs35l56_sdw_dai_ops,
+ },
++ {
++ .name = "cs35l56-ot25",
++ .id = 3,
++ .capture = {
++ .stream_name = "OT25",
++ .channels_min = 1,
++ .channels_max = 2,
++ .rates = CS35L56_RATES,
++ .formats = CS35L56_TX_FORMATS,
++ },
++ .ops = &cs35l56_ot25_dai_ops,
++ },
+ };
+
+ static int cs35l56_write_cal(struct cs35l56_private *cs35l56)
diff --git a/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.3-4.patch b/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.3-4.patch
new file mode 100644
index 0000000..e36c7c1
--- /dev/null
+++ b/ports/candidate/linux-postmarketos-qcom-sdm660/stable-7.2.3-4.patch
@@ -0,0 +1,28233 @@
+diff --git a/Documentation/ABI/testing/sysfs-bus-nvdimm b/Documentation/ABI/testing/sysfs-bus-nvdimm
+index 64eb8f4c6a41f2..46dafd8482b9ed 100644
+--- a/Documentation/ABI/testing/sysfs-bus-nvdimm
++++ b/Documentation/ABI/testing/sysfs-bus-nvdimm
+@@ -48,7 +48,8 @@ What: /sys/bus/nd/devices/nmemX/cxl/id
+ Date: November 2022
+ KernelVersion: 6.2
+ Contact: Dave Jiang
+-Description: (RO) Show the id (serial) of the device. This is CXL specific.
++Description: (RO) Show the id (serial) of the device, formatted as an
++ unsigned 64-bit decimal value. This is CXL specific.
+
+ What: /sys/bus/nd/devices/nmemX/cxl/provider
+ Date: November 2022
+diff --git a/Documentation/admin-guide/blockdev/zoned_loop.rst b/Documentation/admin-guide/blockdev/zoned_loop.rst
+index f4f1f3121bf953..95974425ca0546 100644
+--- a/Documentation/admin-guide/blockdev/zoned_loop.rst
++++ b/Documentation/admin-guide/blockdev/zoned_loop.rst
+@@ -30,11 +30,10 @@ indicates the position of the write pointer of the zone.
+
+ When resetting a sequential zone, its backing file size is truncated to zero.
+ Conversely, for a zone finish operation, the backing file is truncated to the
+-zone size. With this, the maximum capacity of a zloop zoned block device created
+-can be larger configured to be larger than the storage space available on the
+-backing file system. Of course, for such configuration, writing more data than
+-the storage space available on the backing file system will result in write
+-errors.
++zone capacity. With this, a zloop zoned block device can be configured with a
++larger capacity than the storage space available on the backing file system. Of
++course, for such configuration, writing more data than the storage space
++available on the backing file system will result in write errors.
+
+ The zoned loop block device driver implements a complete zone transition state
+ machine. That is, zones can be empty, implicitly opened, explicitly opened,
+diff --git a/Makefile b/Makefile
+index 150b1c1d7bede8..91d6e74db4dca4 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,7 @@
+ # SPDX-License-Identifier: GPL-2.0
+ VERSION = 7
+ PATCHLEVEL = 2
+-SUBLEVEL = 3
++SUBLEVEL = 4
+ EXTRAVERSION =
+ NAME = Baby Opossum Posse
+
+@@ -1083,6 +1083,16 @@ endif
+ export CC_FLAGS_SCS
+ endif
+
++ifdef CONFIG_RUST_INLINE_HELPERS
++# `rustc` normally emits traps for unreachable paths during code generation.
++# With inline helpers, Clang performs code generation from the linked bitcode
++# instead, so request the same behavior explicitly. Otherwise `objtool` may
++# follow an impossible Rust path into the next function.
++CC_FLAGS_RUST_INLINE_HELPERS := -mllvm -trap-unreachable \
++ -mllvm -no-trap-after-noreturn
++export CC_FLAGS_RUST_INLINE_HELPERS
++endif
++
+ ifdef CONFIG_LTO_CLANG
+ ifdef CONFIG_LTO_CLANG_FULL
+ CC_FLAGS_LTO := -flto
+@@ -1118,7 +1128,8 @@ endif
+ ifdef CONFIG_RUST
+ # Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
+ # CONFIG_CFI_ICALL_NORMALIZE_INTEGERS.
+- RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
++ # Disable function merging as LLVM incorrectly merges functions with different KCFI types.
++ RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled
+ KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI)
+ export RUSTC_FLAGS_CFI
+ endif
+diff --git a/arch/alpha/include/uapi/asm/fpu.h b/arch/alpha/include/uapi/asm/fpu.h
+index cea9eafa056fc0..d28dc36786e271 100644
+--- a/arch/alpha/include/uapi/asm/fpu.h
++++ b/arch/alpha/include/uapi/asm/fpu.h
+@@ -101,7 +101,12 @@ ieee_swcr_to_fpcr(unsigned long sw)
+ | IEEE_TRAP_ENABLE_OVF)) << 48;
+ fp |= (~sw & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE)) << 57;
+ fp |= (sw & IEEE_MAP_UMZ ? FPCR_UNDZ | FPCR_UNFD : 0);
+- fp |= (~sw & IEEE_TRAP_ENABLE_DNO) << 41;
++ /*
++ * Disable denormal operand traps only when denormal inputs are to be
++ * flushed to zero. Otherwise they must keep trapping, so that /S
++ * instructions reach the kernel emulation handler.
++ */
++ fp |= (sw & IEEE_MAP_DMZ ? FPCR_DNOD : 0);
+ return fp;
+ }
+
+@@ -116,7 +121,6 @@ ieee_fpcr_to_swcr(unsigned long fp)
+ | IEEE_TRAP_ENABLE_OVF);
+ sw |= (~fp >> 57) & (IEEE_TRAP_ENABLE_UNF | IEEE_TRAP_ENABLE_INE);
+ sw |= (fp >> 47) & IEEE_MAP_UMZ;
+- sw |= (~fp >> 41) & IEEE_TRAP_ENABLE_DNO;
+ return sw;
+ }
+
+diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c
+index 94dbc470cd6c00..7050f0f7fe3d72 100644
+--- a/arch/alpha/kernel/pci-sysfs.c
++++ b/arch/alpha/kernel/pci-sysfs.c
+@@ -224,17 +224,17 @@ int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, size_t size)
+
+ switch(size) {
+ case 1:
+- outb(port, val);
++ outb(val, port);
+ return 1;
+ case 2:
+ if (port & 1)
+ return -EINVAL;
+- outw(port, val);
++ outw(val, port);
+ return 2;
+ case 4:
+ if (port & 3)
+ return -EINVAL;
+- outl(port, val);
++ outl(val, port);
+ return 4;
+ }
+ return -EINVAL;
+diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c
+index 1f99b03effc2ee..a37707e05e34e9 100644
+--- a/arch/alpha/kernel/sys_marvel.c
++++ b/arch/alpha/kernel/sys_marvel.c
+@@ -263,6 +263,18 @@ init_io7_irqs(struct io7 *io7,
+ */
+ printk(" Interrupts reported to CPU at PE %u\n", boot_cpuid);
+
++ /* Set up the lsi irqs. */
++ for (i = 0; i < 128; ++i) {
++ irq_set_chip_and_handler(base + i, lsi_ops, handle_level_irq);
++ irq_set_status_flags(base + i, IRQ_LEVEL);
++ }
++
++ /* Set up the msi irqs. */
++ for (i = 128; i < (128 + 512); ++i) {
++ irq_set_chip_and_handler(base + i, msi_ops, handle_level_irq);
++ irq_set_status_flags(base + i, IRQ_LEVEL);
++ }
++
+ raw_spin_lock(&io7->irq_lock);
+
+ /* set up the error irqs */
+@@ -272,12 +284,6 @@ init_io7_irqs(struct io7 *io7,
+ io7_redirect_irq(io7, &io7->csrs->STV_CTL.csr, boot_cpuid);
+ io7_redirect_irq(io7, &io7->csrs->HEI_CTL.csr, boot_cpuid);
+
+- /* Set up the lsi irqs. */
+- for (i = 0; i < 128; ++i) {
+- irq_set_chip_and_handler(base + i, lsi_ops, handle_level_irq);
+- irq_set_status_flags(i, IRQ_LEVEL);
+- }
+-
+ /* Disable the implemented irqs in hardware. */
+ for (i = 0; i < 0x60; ++i)
+ init_one_io7_lsi(io7, i, boot_cpuid);
+@@ -285,13 +291,6 @@ init_io7_irqs(struct io7 *io7,
+ init_one_io7_lsi(io7, 0x74, boot_cpuid);
+ init_one_io7_lsi(io7, 0x75, boot_cpuid);
+
+-
+- /* Set up the msi irqs. */
+- for (i = 128; i < (128 + 512); ++i) {
+- irq_set_chip_and_handler(base + i, msi_ops, handle_level_irq);
+- irq_set_status_flags(i, IRQ_LEVEL);
+- }
+-
+ for (i = 0; i < 16; ++i)
+ init_one_io7_msi(io7, i, boot_cpuid);
+
+diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
+index 7004397937cfda..7cd20e5f9ee03e 100644
+--- a/arch/alpha/kernel/traps.c
++++ b/arch/alpha/kernel/traps.c
+@@ -166,12 +166,12 @@ static long dummy_emul(void) { return 0; }
+ long (*alpha_fp_emul_imprecise)(struct pt_regs *regs, unsigned long writemask)
+ = (void *)dummy_emul;
+ EXPORT_SYMBOL_GPL(alpha_fp_emul_imprecise);
+-long (*alpha_fp_emul) (unsigned long pc)
++long (*alpha_fp_emul) (unsigned long pc, unsigned long summary)
+ = (void *)dummy_emul;
+ EXPORT_SYMBOL_GPL(alpha_fp_emul);
+ #else
+ long alpha_fp_emul_imprecise(struct pt_regs *regs, unsigned long writemask);
+-long alpha_fp_emul (unsigned long pc);
++long alpha_fp_emul (unsigned long pc, unsigned long summary);
+ #endif
+
+ asmlinkage void
+@@ -185,7 +185,7 @@ do_entArith(unsigned long summary, unsigned long write_mask,
+ emulate the instruction. If the processor supports
+ precise exceptions, we don't have to search. */
+ if (!amask(AMASK_PRECISE_TRAP))
+- si_code = alpha_fp_emul(regs->pc - 4);
++ si_code = alpha_fp_emul(regs->pc - 4, summary);
+ else
+ si_code = alpha_fp_emul_imprecise(regs, write_mask);
+ if (si_code == 0)
+diff --git a/arch/alpha/math-emu/math.c b/arch/alpha/math-emu/math.c
+index 68d420bfd3c0d7..e3f2df3729e3ad 100644
+--- a/arch/alpha/math-emu/math.c
++++ b/arch/alpha/math-emu/math.c
+@@ -52,13 +52,13 @@ MODULE_DESCRIPTION("FP Software completion module");
+ MODULE_LICENSE("GPL v2");
+
+ extern long (*alpha_fp_emul_imprecise)(struct pt_regs *, unsigned long);
+-extern long (*alpha_fp_emul) (unsigned long pc);
++extern long (*alpha_fp_emul) (unsigned long pc, unsigned long summary);
+
+ static long (*save_emul_imprecise)(struct pt_regs *, unsigned long);
+-static long (*save_emul) (unsigned long pc);
++static long (*save_emul) (unsigned long pc, unsigned long summary);
+
+ long do_alpha_fp_emul_imprecise(struct pt_regs *, unsigned long);
+-long do_alpha_fp_emul(unsigned long);
++long do_alpha_fp_emul(unsigned long, unsigned long);
+
+ static int alpha_fp_emul_init_module(void)
+ {
+@@ -86,7 +86,22 @@ module_exit(alpha_fp_emul_cleanup_module);
+
+
+ /*
+- * Emulate the floating point instruction at address PC. Returns -1 if the
++ * Exception bits of the exception summary register (EXC_SUM). Bit 0 is the
++ * software completion bit; bits 1 through 5 report the exceptions the
++ * hardware attributed to the trapping instruction, and lie at the same
++ * positions as the corresponding IEEE_TRAP_ENABLE_* bits.
++ */
++#define EXC_SUM_INV (1UL << 1)
++#define EXC_SUM_DZE (1UL << 2)
++#define EXC_SUM_OVF (1UL << 3)
++#define EXC_SUM_UNF (1UL << 4)
++#define EXC_SUM_INE (1UL << 5)
++#define EXC_SUM_MASK (EXC_SUM_INV | EXC_SUM_DZE | EXC_SUM_OVF \
++ | EXC_SUM_UNF | EXC_SUM_INE)
++
++/*
++ * Emulate the floating point instruction at address PC. SUMMARY is the
++ * exception summary register the trap was delivered with. Returns -1 if the
+ * instruction to be emulated is illegal (such as with the opDEC trap), else
+ * the SI_CODE for a SIGFPE signal, else 0 if everything's ok.
+ *
+@@ -95,7 +110,7 @@ module_exit(alpha_fp_emul_cleanup_module);
+ * stick the result of the operation into the appropriate register.
+ */
+ long
+-alpha_fp_emul (unsigned long pc)
++alpha_fp_emul (unsigned long pc, unsigned long summary)
+ {
+ FP_DECL_EX;
+ FP_DECL_S(SA); FP_DECL_S(SB); FP_DECL_S(SR);
+@@ -300,12 +315,56 @@ done:
+ swcr |= (_fex << IEEE_STATUS_TO_EXCSUM_SHIFT);
+ current_thread_info()->ieee_state
+ |= (_fex << IEEE_STATUS_TO_EXCSUM_SHIFT);
++ }
+
+- /* Update hardware control register. */
+- fpcr &= (~FPCR_MASK | FPCR_DYN_MASK);
+- fpcr |= ieee_swcr_to_fpcr(swcr);
+- wrfpcr(fpcr);
++ /*
++ * EV6 records exception status bits in the FPCR before delivering the
++ * software completion trap, and swcr_update_status() above merged them
++ * into SWCR. Some can be wrong for the instruction we just emulated:
++ * a CVTTS of a value exactly representable as a subnormal sets FPCR_UNF
++ * even though the result is exact. Clear the exceptions the trap
++ * reported but that soft-fp did not raise.
++ */
++ if (implver() == IMPLVER_EV6) {
++ unsigned long spurious = summary & EXC_SUM_MASK;
++
++ if (spurious & (EXC_SUM_UNF | EXC_SUM_OVF)) {
++ /*
++ * EXC_SUM reports only the underflow or overflow,
++ * but the hardware sets INE alongside it in the FPCR.
++ */
++ spurious |= EXC_SUM_INE;
++ } else if (!spurious) {
++ /*
++ * No exception reported, so this was a denormal
++ * operand trap, for which INE and UNF can be
++ * fabricated as well.
++ */
++ spurious = EXC_SUM_INE | EXC_SUM_UNF;
++ }
+
++ /*
++ * Never clear an exception software has confirmed. Every
++ * instruction that genuinely raises one traps for software
++ * completion and is recorded in ieee_state above, so a bit
++ * found there -- including one just set from _fex -- belongs
++ * to this or an earlier instruction and must survive.
++ */
++ spurious &= ~(current_thread_info()->ieee_state
++ >> IEEE_STATUS_TO_EXCSUM_SHIFT);
++
++ swcr &= ~(spurious << IEEE_STATUS_TO_EXCSUM_SHIFT);
++ }
++
++ /*
++ * Update hardware control register. This has to happen even when
++ * soft-fp raised nothing, to clear any fabricated bits.
++ */
++ fpcr &= (~FPCR_MASK | FPCR_DYN_MASK);
++ fpcr |= ieee_swcr_to_fpcr(swcr);
++ wrfpcr(fpcr);
++
++ if (_fex) {
+ /* Do we generate a signal? */
+ _fex = _fex & swcr & IEEE_TRAP_ENABLE_MASK;
+ si_code = 0;
+@@ -387,9 +446,16 @@ alpha_fp_emul_imprecise (struct pt_regs *regs, unsigned long write_mask)
+ break;
+ }
+ if (!write_mask) {
+- /* Re-execute insns in the trap-shadow. */
++ /*
++ * Re-execute insns in the trap-shadow. Pass no
++ * exception summary: it describes the trap, which
++ * was taken anywhere in the shadow, and so is not
++ * attribution for this instruction. Nothing is
++ * lost, since only EV6 -- which traps precisely and
++ * never comes this way -- needs it.
++ */
+ regs->pc = trigger_pc + 4;
+- si_code = alpha_fp_emul(trigger_pc);
++ si_code = alpha_fp_emul(trigger_pc, 0);
+ goto egress;
+ }
+ trigger_pc -= 4;
+diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
+index 9187240a02db54..b8aa3fcce1078e 100644
+--- a/arch/arm/Kconfig
++++ b/arch/arm/Kconfig
+@@ -98,7 +98,7 @@ config ARM
+ select HAVE_ARCH_TRACEHOOK
+ select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARM_LPAE
+ select HAVE_ARM_SMCCC if CPU_V7
+- select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
++ select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 && !CPU_32v3
+ select HAVE_CONTEXT_TRACKING_USER
+ select HAVE_C_RECORDMCOUNT
+ select HAVE_BUILDTIME_MCOUNT_SORT
+diff --git a/arch/arm64/boot/dts/qcom/kodiak.dtsi b/arch/arm64/boot/dts/qcom/kodiak.dtsi
+index fa540d8c2615dc..ba907760fa6d62 100644
+--- a/arch/arm64/boot/dts/qcom/kodiak.dtsi
++++ b/arch/arm64/boot/dts/qcom/kodiak.dtsi
+@@ -191,9 +191,12 @@
+ qcom,vmid = ;
+ };
+
+- adsp_rpc_remote_heap_mem: adsp-rpc-remote-heap@9cb80000 {
+- reg = <0x0 0x9cb80000 0x0 0x800000>;
+- no-map;
++ adsp_rpc_remote_heap_mem: adsp-rpc-remote-heap {
++ compatible = "shared-dma-pool";
++ alloc-ranges = <0x0 0x80000000 0x0 0x80000000>;
++ reusable;
++ alignment = <0x0 0x400000>;
++ size = <0x0 0x800000>;
+ };
+ };
+
+diff --git a/arch/arm64/boot/dts/qcom/sm6115-fxtec-pro1x.dts b/arch/arm64/boot/dts/qcom/sm6115-fxtec-pro1x.dts
+index 0f23eaef01f213..b290f0f4c0e107 100644
+--- a/arch/arm64/boot/dts/qcom/sm6115-fxtec-pro1x.dts
++++ b/arch/arm64/boot/dts/qcom/sm6115-fxtec-pro1x.dts
+@@ -151,7 +151,7 @@
+
+ interrupts-extended = <&tlmm 80 IRQ_TYPE_LEVEL_LOW>;
+
+- irq-gpios = <&tlmm 80 IRQ_TYPE_LEVEL_LOW>;
++ irq-gpios = <&tlmm 80 GPIO_ACTIVE_LOW>;
+ reset-gpios = <&tlmm 71 GPIO_ACTIVE_HIGH>;
+ AVDD28-supply = <&ts_vdd_supply>;
+ VDDIO-supply = <&ts_vddio_supply>;
+diff --git a/arch/arm64/boot/dts/qcom/x1-dell-thena.dtsi b/arch/arm64/boot/dts/qcom/x1-dell-thena.dtsi
+index db291730130c7b..d6de4da02dcd38 100644
+--- a/arch/arm64/boot/dts/qcom/x1-dell-thena.dtsi
++++ b/arch/arm64/boot/dts/qcom/x1-dell-thena.dtsi
+@@ -589,6 +589,7 @@
+ regulator-min-microvolt = <1200000>;
+ regulator-max-microvolt = <1200000>;
+ regulator-initial-mode = ;
++ regulator-always-on;
+ };
+
+ vreg_l13b_3p0: ldo13 {
+@@ -610,6 +611,7 @@
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-initial-mode = ;
++ regulator-always-on;
+ };
+ };
+
+diff --git a/arch/arm64/boot/dts/rockchip/px30-cobra.dtsi b/arch/arm64/boot/dts/rockchip/px30-cobra.dtsi
+index add917af5de783..f14f9eca7d3423 100644
+--- a/arch/arm64/boot/dts/rockchip/px30-cobra.dtsi
++++ b/arch/arm64/boot/dts/rockchip/px30-cobra.dtsi
+@@ -35,7 +35,7 @@
+ compatible = "mmc-pwrseq-emmc";
+ pinctrl-0 = <&emmc_reset>;
+ pinctrl-names = "default";
+- reset-gpios = <&gpio1 RK_PB3 GPIO_ACTIVE_HIGH>;
++ reset-gpios = <&gpio1 RK_PB3 GPIO_ACTIVE_LOW>;
+ };
+
+ gpio-leds {
+diff --git a/arch/arm64/boot/dts/rockchip/px30-pp1516.dtsi b/arch/arm64/boot/dts/rockchip/px30-pp1516.dtsi
+index 192791993f0591..02200de695d31b 100644
+--- a/arch/arm64/boot/dts/rockchip/px30-pp1516.dtsi
++++ b/arch/arm64/boot/dts/rockchip/px30-pp1516.dtsi
+@@ -33,7 +33,7 @@
+ compatible = "mmc-pwrseq-emmc";
+ pinctrl-0 = <&emmc_reset>;
+ pinctrl-names = "default";
+- reset-gpios = <&gpio1 RK_PB3 GPIO_ACTIVE_HIGH>;
++ reset-gpios = <&gpio1 RK_PB3 GPIO_ACTIVE_LOW>;
+ };
+
+ gpio-leds {
+diff --git a/arch/arm64/boot/dts/rockchip/px30-ringneck.dtsi b/arch/arm64/boot/dts/rockchip/px30-ringneck.dtsi
+index 973b4c5880e24d..29794216592d80 100644
+--- a/arch/arm64/boot/dts/rockchip/px30-ringneck.dtsi
++++ b/arch/arm64/boot/dts/rockchip/px30-ringneck.dtsi
+@@ -26,7 +26,7 @@
+ compatible = "mmc-pwrseq-emmc";
+ pinctrl-0 = <&emmc_reset>;
+ pinctrl-names = "default";
+- reset-gpios = <&gpio1 RK_PB3 GPIO_ACTIVE_HIGH>;
++ reset-gpios = <&gpio1 RK_PB3 GPIO_ACTIVE_LOW>;
+ };
+
+ leds {
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
+index 8d26bd9b75003c..d46cdfe3f7849a 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
+@@ -734,12 +734,6 @@
+ };
+ };
+
+- wifi {
+- wifi_host_wake_l: wifi-host-wake-l {
+- rockchip,pins = <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>;
+- };
+- };
+-
+ wireless-bluetooth {
+ bt_wake_pin: bt-wake-pin {
+ rockchip,pins = <2 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>;
+@@ -766,19 +760,7 @@
+ pinctrl-names = "default";
+ pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
+ sd-uhs-sdr104;
+- #address-cells = <1>;
+- #size-cells = <0>;
+ status = "okay";
+-
+- brcmf: wifi@1 {
+- compatible = "brcm,bcm4329-fmac";
+- reg = <1>;
+- interrupt-parent = <&gpio4>;
+- interrupts = ;
+- interrupt-names = "host-wake";
+- pinctrl-names = "default";
+- pinctrl-0 = <&wifi_host_wake_l>;
+- };
+ };
+
+ &pwm0 {
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts b/arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts
+index 4f2831097624e4..f6d62ee51f1b91 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3399-roc-pc-plus.dts
+@@ -136,6 +136,18 @@
+ <3 RK_PD7 1 &pcfg_pull_none>;
+ };
+
++&i2s0_8ch_bus_bclk_off {
++ rockchip,pins =
++ <3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>,
++ <3 RK_PD1 1 &pcfg_pull_none>,
++ <3 RK_PD2 1 &pcfg_pull_none>,
++ <3 RK_PD3 1 &pcfg_pull_none>,
++ <3 RK_PD4 1 &pcfg_pull_none>,
++ <3 RK_PD5 1 &pcfg_pull_none>,
++ <3 RK_PD6 1 &pcfg_pull_none>,
++ <3 RK_PD7 1 &pcfg_pull_none>;
++};
++
+ &i2s1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s_8ch_mclk_pin>, <&i2s1_2ch_bus>;
+diff --git a/arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts b/arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts
+index d534d662c40f11..99853880aaac6f 100644
+--- a/arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts
++++ b/arch/arm64/boot/dts/rockchip/rk3588s-roc-pc.dts
+@@ -23,16 +23,19 @@
+ compatible = "simple-audio-card";
+ pinctrl-names = "default";
+ pinctrl-0 = <&hp_detect>;
++ simple-audio-card,aux-devs = <&headphones_amp>;
+ simple-audio-card,name = "rockchip,es8388";
+- simple-audio-card,bitclock-master = <&masterdai>;
++ simple-audio-card,bitclock-master = <&cpudai>;
+ simple-audio-card,format = "i2s";
+- simple-audio-card,frame-master = <&masterdai>;
++ simple-audio-card,frame-master = <&cpudai>;
+ simple-audio-card,hp-det-gpios = <&gpio1 RK_PA6 GPIO_ACTIVE_LOW>;
+ simple-audio-card,mclk-fs = <256>;
+ simple-audio-card,pin-switches = "Headphones";
+ simple-audio-card,routing =
+- "Headphones", "LOUT1",
+- "Headphones", "ROUT1",
++ "Headphones", "Headphone Amp OUTL",
++ "Headphones", "Headphone Amp OUTR",
++ "Headphone Amp INL", "LOUT2",
++ "Headphone Amp INR", "ROUT2",
+ "LINPUT1", "Microphone Jack",
+ "RINPUT1", "Microphone Jack",
+ "LINPUT2", "Onboard Microphone",
+@@ -47,11 +50,17 @@
+ system-clock-frequency = <12288000>;
+ };
+
+- simple-audio-card,cpu {
++ cpudai: simple-audio-card,cpu {
+ sound-dai = <&i2s0_8ch>;
+ };
+ };
+
++ headphones_amp: audio-amplifier-headphones {
++ compatible = "simple-audio-amplifier";
++ enable-gpios = <&gpio1 RK_PA4 GPIO_ACTIVE_HIGH>;
++ sound-name-prefix = "Headphone Amp";
++ };
++
+ chosen {
+ stdout-path = "serial2:1500000n8";
+ };
+@@ -327,12 +336,12 @@
+ es8388: audio-codec@11 {
+ compatible = "everest,es8388", "everest,es8328";
+ reg = <0x11>;
+- clocks = <&cru I2S1_8CH_MCLKOUT>;
++ clocks = <&cru I2S0_8CH_MCLKOUT>;
+ AVDD-supply = <&vcc_3v3_s0>;
+ DVDD-supply = <&vcc_1v8_s0>;
+ HPVDD-supply = <&vcc_3v3_s0>;
+ PVDD-supply = <&vcc_3v3_s0>;
+- assigned-clocks = <&cru I2S1_8CH_MCLKOUT>;
++ assigned-clocks = <&cru I2S0_8CH_MCLKOUT>;
+ assigned-clock-rates = <12288000>;
+ #sound-dai-cells = <0>;
+ };
+diff --git a/arch/arm64/kernel/compat_alignment.c b/arch/arm64/kernel/compat_alignment.c
+index b68e1d328d4cb9..9b58d0aa38d225 100644
+--- a/arch/arm64/kernel/compat_alignment.c
++++ b/arch/arm64/kernel/compat_alignment.c
+@@ -114,8 +114,8 @@ do_alignment_ldrdstrd(unsigned long addr, u32 instr, struct pt_regs *regs)
+ static int
+ do_alignment_ldmstm(unsigned long addr, u32 instr, struct pt_regs *regs)
+ {
+- unsigned int rd, rn, nr_regs, regbits;
+- unsigned long eaddr, newaddr;
++ unsigned int rd, rn, regbits;
++ unsigned long eaddr, newaddr, nr_regs;
+ unsigned int val;
+
+ /* count the number of registers in the mask to be transferred */
+diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c
+index 7bb6553fec087a..3bcf86154d95cd 100644
+--- a/arch/arm64/kernel/proton-pack.c
++++ b/arch/arm64/kernel/proton-pack.c
+@@ -1023,6 +1023,11 @@ static int __init parse_spectre_bhb_param(char *str)
+ }
+ early_param("nospectre_bhb", parse_spectre_bhb_param);
+
++static bool spectre_bhb_mitigations_off(void)
++{
++ return __nospectre_bhb || cpu_mitigations_off();
++}
++
+ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)
+ {
+ bp_hardening_cb_t cpu_cb;
+@@ -1036,6 +1041,8 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry)
+ /* No point mitigating Spectre-BHB alone. */
+ } else if (!IS_ENABLED(CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY)) {
+ /* Do nothing */
++ } else if (spectre_bhb_mitigations_off()) {
++ /* Mitigation disabled on the command line */
+ } else if (supports_ecbhb(SCOPE_LOCAL_CPU)) {
+ state = SPECTRE_MITIGATED;
+ set_bit(BHB_HW, &system_bhb_mitigations);
+@@ -1201,6 +1208,6 @@ void spectre_print_disabled_mitigations(void)
+ if (spectre_v4_mitigations_off())
+ pr_info("spectre-v4 %s", spectre_disabled_suffix);
+
+- if (__nospectre_bhb || cpu_mitigations_off())
++ if (spectre_bhb_mitigations_off())
+ pr_info("spectre-bhb %s", spectre_disabled_suffix);
+ }
+diff --git a/arch/arm64/kvm/vgic/vgic-v2.c b/arch/arm64/kvm/vgic/vgic-v2.c
+index cafa3cb32bda6f..7182f63fc9382c 100644
+--- a/arch/arm64/kvm/vgic/vgic-v2.c
++++ b/arch/arm64/kvm/vgic/vgic-v2.c
+@@ -170,8 +170,9 @@ void vgic_v2_deactivate(struct kvm_vcpu *vcpu, u32 val)
+ /* Make sure we're in the same context as LR handling */
+ local_irq_save(flags);
+
++ /* Guest-supplied INTID: out of range yields no irq, so ignore it */
+ irq = vgic_get_vcpu_irq(vcpu, val);
+- if (WARN_ON_ONCE(!irq))
++ if (!irq)
+ goto out;
+
+ /* See the corresponding v3 code for the rationale */
+diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
+index c7e90b09645e4d..18e68680471eb9 100644
+--- a/arch/openrisc/kernel/entry.S
++++ b/arch/openrisc/kernel/entry.S
+@@ -1223,15 +1223,50 @@ _no_syscall_trace:
+ *
+ */
+
++/* Keep this literal; hi()/lo() can't use the UL-suffixed TASK_SIZE. */
++#define OR1K_ATOMIC_ADDR_LIMIT 0x7ffffffc
++
+ ENTRY(sys_or1k_atomic)
+ /* FIXME: This ignores r3 and always does an XCHG */
++
++ /* Check both user pointers before accessing them. */
++ l.movhi r13,hi(OR1K_ATOMIC_ADDR_LIMIT)
++ l.ori r13,r13,lo(OR1K_ATOMIC_ADDR_LIMIT)
++ l.sfgtu r4,r13
++ l.bf 9f
++ l.nop
++ l.sfgtu r5,r13
++ l.bf 9f
++ l.nop
++
+ DISABLE_INTERRUPTS(r17,r19)
+- l.lwz r29,0(r4)
+- l.lwz r27,0(r5)
+- l.sw 0(r4),r27
+- l.sw 0(r5),r29
++10: l.lwz r29,0(r4)
++11: l.lwz r27,0(r5)
++12: l.sw 0(r4),r27
++13: l.sw 0(r5),r29
+ ENABLE_INTERRUPTS(r17)
+ l.jr r9
+ l.or r11,r0,r0
+
++ /*
++ * Either pointer was outside user space, or turned out to be
++ * unmapped/inaccessible when we actually touched it.
++ */
++9: l.jr r9
++ l.addi r11,r0,-EFAULT
++
++ .section .fixup, "ax"
++14:
++ ENABLE_INTERRUPTS(r17)
++ l.j 9b
++ l.nop
++ .previous
++
++ .section __ex_table, "a"
++ .long 10b, 14b
++ .long 11b, 14b
++ .long 12b, 14b
++ .long 13b, 14b
++ .previous
++
+ /* ============================================================[ EOF ]=== */
+diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
+index 3c4ca90e2ab772..4fc52c21fe5d4f 100644
+--- a/arch/powerpc/kernel/pci-common.c
++++ b/arch/powerpc/kernel/pci-common.c
+@@ -626,19 +626,14 @@ int pci_legacy_write(struct pci_bus *bus, loff_t port, u32 val, size_t size)
+ return -ENXIO;
+ addr = hose->io_base_virt + port;
+
+- /* WARNING: The generic code is idiotic. It gets passed a pointer
+- * to what can be a 1, 2 or 4 byte quantity and always reads that
+- * as a u32, which means that we have to correct the location of
+- * the data read within those 32 bits for size 1 and 2
+- */
+ switch(size) {
+ case 1:
+- out_8(addr, val >> 24);
++ out_8(addr, val);
+ return 1;
+ case 2:
+ if (port & 1)
+ return -EINVAL;
+- out_le16(addr, val >> 16);
++ out_le16(addr, val);
+ return 2;
+ case 4:
+ if (port & 3)
+diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
+index da72a30ab8657e..973f58771d9636 100644
+--- a/arch/powerpc/platforms/powermac/low_i2c.c
++++ b/arch/powerpc/platforms/powermac/low_i2c.c
+@@ -1471,7 +1471,7 @@ static int __init pmac_i2c_create_platform_devices(void)
+ if (bus->platform_dev == NULL)
+ return -ENOMEM;
+ bus->platform_dev->dev.platform_data = bus;
+- bus->platform_dev->dev.of_node = bus->busnode;
++ bus->platform_dev->dev.of_node = of_node_get(bus->busnode);
+ platform_device_add(bus->platform_dev);
+ }
+
+diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
+index 3e1f915fe4f66d..272e9aab66d4f6 100644
+--- a/arch/powerpc/platforms/pseries/iommu.c
++++ b/arch/powerpc/platforms/pseries/iommu.c
+@@ -812,18 +812,11 @@ static struct device_node *pci_dma_find(struct device_node *dn,
+
+ /* parse DMA window property. During normal system boot, only default
+ * DMA window is passed in OF. But, for kdump, a dedicated adapter might
+- * have both default and DDW in FDT. In this scenario, DDW takes precedence
+- * over default window.
++ * have both default and DDW in FDT. In this scenario, default window
++ * takes precedence over DDW. For a dedicated adapter, default window will
++ * potentially have more unused TCEs.
+ */
+- if (ddw_win) {
+- struct dynamic_dma_window_prop *p;
+-
+- p = (struct dynamic_dma_window_prop *)ddw_prop;
+- prop->liobn = p->liobn;
+- prop->dma_base = p->dma_base;
+- prop->tce_shift = p->tce_shift;
+- prop->window_shift = p->window_shift;
+- } else if (default_win) {
++ if (default_win) {
+ unsigned long offset, size, liobn;
+
+ of_parse_dma_window(rdn, default_prop, &liobn, &offset, &size);
+@@ -832,6 +825,14 @@ static struct device_node *pci_dma_find(struct device_node *dn,
+ prop->dma_base = cpu_to_be64(offset);
+ prop->tce_shift = cpu_to_be32(IOMMU_PAGE_SHIFT_4K);
+ prop->window_shift = cpu_to_be32(order_base_2(size));
++ } else {
++ struct dynamic_dma_window_prop *p;
++
++ p = (struct dynamic_dma_window_prop *)ddw_prop;
++ prop->liobn = p->liobn;
++ prop->dma_base = p->dma_base;
++ prop->tce_shift = p->tce_shift;
++ prop->window_shift = p->window_shift;
+ }
+
+ return rdn;
+diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
+index 72f77e9edd63db..d2abda5f5383aa 100644
+--- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
++++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
+@@ -204,14 +204,14 @@
+ regulators {
+ buck1 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck2 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+diff --git a/arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts b/arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts
+index 2fc8d653378637..c800153077a80c 100644
+--- a/arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts
++++ b/arch/riscv/boot/dts/spacemit/k1-milkv-jupiter.dts
+@@ -211,14 +211,14 @@
+ regulators {
+ buck1 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck2 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+diff --git a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
+index 0d809e4ad3b1f7..96623454116eb7 100644
+--- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
++++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
+@@ -180,14 +180,14 @@
+ regulators {
+ buck1 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck2 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
+index b13a8d6a2670e3..564a48c70b5d31 100644
+--- a/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
++++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-r2s.dts
+@@ -126,14 +126,14 @@
+ regulators {
+ buck1 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck2 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
+index 7c49bce427f307..b907a1396b21ff 100644
+--- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
++++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
+@@ -164,14 +164,14 @@
+ regulators {
+ buck1 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ buck2 {
+ regulator-min-microvolt = <500000>;
+- regulator-max-microvolt = <3450000>;
++ regulator-max-microvolt = <1050000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
+index 26ab37c171bcf6..f4db04f5bbe758 100644
+--- a/arch/riscv/include/asm/acpi.h
++++ b/arch/riscv/include/asm/acpi.h
+@@ -12,6 +12,8 @@
+ #ifndef _ASM_ACPI_H
+ #define _ASM_ACPI_H
+
++#include
++
+ /* Basic configuration for ACPI */
+ #ifdef CONFIG_ACPI
+
+@@ -67,6 +69,23 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,
+
+ void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size,
+ u32 *cboz_size, u32 *cbop_size);
++
++/*
++ * RISC-V Functional Fixed Hardware Specification Version v1.0.1,
++ * Chapter 3.1.2, Table 4: Arch. Context Lost Flags
++ */
++#define RISCV_LPI_HART_TIMER_CTXT_LOST BIT(0)
++
++static inline unsigned int arch_get_idle_state_flags(u32 arch_flags)
++{
++ if (arch_flags & RISCV_LPI_HART_TIMER_CTXT_LOST)
++ return CPUIDLE_FLAG_TIMER_STOP;
++
++ return 0;
++}
++
++#define arch_get_idle_state_flags arch_get_idle_state_flags
++
+ #else
+ static inline void acpi_init_rintc_map(void) { }
+ static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu)
+diff --git a/arch/riscv/kernel/unaligned_access_speed.c b/arch/riscv/kernel/unaligned_access_speed.c
+index 36201613d2cafe..67f1a03716597a 100644
+--- a/arch/riscv/kernel/unaligned_access_speed.c
++++ b/arch/riscv/kernel/unaligned_access_speed.c
+@@ -6,7 +6,6 @@
+ #include
+ #include
+ #include
+-#include
+ #include
+ #include
+ #include
+@@ -288,18 +287,9 @@ free:
+ __free_pages(page, MISALIGNED_BUFFER_ORDER);
+ }
+
+-/* Measure unaligned access speed on all CPUs present at boot in parallel. */
+-static int vec_check_unaligned_access_speed_all_cpus(void *unused __always_unused)
+-{
+- schedule_on_each_cpu(check_vector_unaligned_access);
+- riscv_hwprobe_complete_async_probe();
+-
+- return 0;
+-}
+ #else /* CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS */
+-static int vec_check_unaligned_access_speed_all_cpus(void *unused __always_unused)
++static void check_vector_unaligned_access(struct work_struct *work __always_unused)
+ {
+- return 0;
+ }
+ #endif
+
+@@ -387,12 +377,7 @@ static int __init check_unaligned_access_all_cpus(void)
+ per_cpu(vector_misaligned_access, cpu) = unaligned_vector_speed_param;
+ } else if (!check_vector_unaligned_access_emulated_all_cpus() &&
+ IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
+- riscv_hwprobe_register_async_probe();
+- if (IS_ERR(kthread_run(vec_check_unaligned_access_speed_all_cpus,
+- NULL, "vec_check_unaligned_access_speed_all_cpus"))) {
+- pr_warn("Failed to create vec_unalign_check kthread\n");
+- riscv_hwprobe_complete_async_probe();
+- }
++ schedule_on_each_cpu(check_vector_unaligned_access);
+ }
+
+ /*
+diff --git a/arch/riscv/kvm/vcpu_pmu.c b/arch/riscv/kvm/vcpu_pmu.c
+index 2025b664961c80..a7f948410d5310 100644
+--- a/arch/riscv/kvm/vcpu_pmu.c
++++ b/arch/riscv/kvm/vcpu_pmu.c
+@@ -12,7 +12,9 @@
+ #include
+ #include
+ #include
++#include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -479,13 +481,14 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
+ unsigned long flags, struct kvm_vcpu_sbi_return *retdata)
+ {
+ struct riscv_pmu_event_info *einfo = NULL;
+- int shmem_size = num_events * sizeof(*einfo);
++ size_t shmem_size;
+ gpa_t shmem;
+ u32 eidx, etype;
+ u64 econfig;
+ int ret;
+
+- if (flags != 0 || (saddr_low & (SZ_16 - 1) || num_events == 0)) {
++ if (flags != 0 || (saddr_low & (SZ_16 - 1)) || num_events == 0 ||
++ check_mul_overflow(num_events, sizeof(*einfo), &shmem_size)) {
+ ret = SBI_ERR_INVALID_PARAM;
+ goto out;
+ }
+@@ -500,7 +503,8 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
+ }
+ }
+
+- einfo = kzalloc(shmem_size, GFP_KERNEL);
++ einfo = kvcalloc(num_events, sizeof(*einfo),
++ GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
+ if (!einfo) {
+ ret = SBI_ERR_FAILURE;
+ goto out;
+@@ -512,7 +516,7 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
+ goto free_mem;
+ }
+
+- for (int i = 0; i < num_events; i++) {
++ for (unsigned long i = 0; i < num_events; i++) {
+ eidx = einfo[i].event_idx;
+ etype = kvm_pmu_get_perf_event_type(eidx);
+ econfig = kvm_pmu_get_perf_event_config(eidx, einfo[i].event_data);
+@@ -525,7 +529,7 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
+ ret = SBI_ERR_INVALID_ADDRESS;
+
+ free_mem:
+- kfree(einfo);
++ kvfree(einfo);
+ out:
+ retdata->err_val = ret;
+
+diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h
+index 1d955dd0defa3f..feb58acf87d69f 100644
+--- a/arch/s390/include/asm/percpu.h
++++ b/arch/s390/include/asm/percpu.h
+@@ -107,8 +107,8 @@
+ " .endif\n" \
+ ".endr\n" \
+ ".endm\n" \
+- ALTERNATIVE("GEN_MVIY " __stringify(disp) " " __stringify(reg) "\n", \
+- "GEN_MVIY " __stringify(dispalt) " " __stringify(reg) "\n", \
++ ALTERNATIVE("GEN_MVIY " disp ", " reg "\n", \
++ "GEN_MVIY " dispalt ", " reg "\n", \
+ ALT_FEATURE(MFEATURE_LOWCORE)) \
+ ".purgem GEN_MVIY\n"
+
+diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
+index 2076ac22e2c497..2a8d4cc1d6a2ca 100644
+--- a/arch/s390/kernel/perf_cpum_cf.c
++++ b/arch/s390/kernel/perf_cpum_cf.c
+@@ -110,6 +110,7 @@ struct cpu_cf_ptr {
+
+ static struct cpu_cf_root { /* Anchor to per CPU data */
+ refcount_t refcnt; /* Overall active events */
++ unsigned int tskctx; /* Users tracking all CPUs (cpu == -1) */
+ struct cpu_cf_ptr __percpu *cfptr;
+ } cpu_cf_root;
+
+@@ -118,13 +119,15 @@ static struct cpu_cf_root { /* Anchor to per CPU data */
+ * user space in task context with perf_event_open() and close()
+ * system calls.
+ *
+- * This mutex serializes functions cpum_cf_alloc_cpu() called at event
+- * initialization via cpumf_pmu_event_init() and function cpum_cf_free_cpu()
+- * called at event removal via call back function hw_perf_event_destroy()
+- * when the event is deleted. They are serialized to enforce correct
+- * bookkeeping of pointer and reference counts anchored by
+- * struct cpu_cf_root and the access to cpu_cf_root::refcnt and the
+- * per CPU pointers stored in cpu_cf_root::cfptr.
++ * This mutex serializes the allocation and removal of the per CPU counter
++ * data via cpum_cf_alloc_cpu() and cpum_cf_free_cpu(). They are called with
++ * this mutex held at event initialization via cpumf_pmu_event_init(), at
++ * event removal via call back function hw_perf_event_destroy() when the
++ * event is deleted, and from the CPU hotplug prepare/dead callbacks. The
++ * mutex enforces correct bookkeeping of pointer and reference counts
++ * anchored by struct cpu_cf_root and protects the access to
++ * cpu_cf_root::refcnt, cpu_cf_root::tskctx and the per CPU pointers
++ * stored in cpu_cf_root::cfptr.
+ */
+ static DEFINE_MUTEX(pmc_reserve_mutex);
+
+@@ -167,12 +170,14 @@ static void cpum_cf_reset_cpu(void *flags)
+ }
+
+ /* Free per CPU data when the last event is removed. */
+-static void cpum_cf_free_root(void)
++static void cpum_cf_free_root(unsigned int num)
+ {
+- if (!refcount_dec_and_test(&cpu_cf_root.refcnt))
++ struct cpu_cf_ptr __percpu *p = cpu_cf_root.cfptr;
++
++ if (!refcount_sub_and_test(num, &cpu_cf_root.refcnt))
+ return;
+- free_percpu(cpu_cf_root.cfptr);
+ cpu_cf_root.cfptr = NULL;
++ free_percpu(p);
+ irq_subclass_unregister(IRQ_SUBCLASS_MEASUREMENT_ALERT);
+ on_each_cpu(cpum_cf_reset_cpu, NULL, 1);
+ debug_sprintf_event(cf_dbg, 4, "%s root.refcnt %u cfptr %d\n",
+@@ -186,17 +191,17 @@ static void cpum_cf_free_root(void)
+ * CPUs possible, which might be larger than the number of CPUs currently
+ * online.
+ */
+-static int cpum_cf_alloc_root(void)
++static int cpum_cf_alloc_root(unsigned int num)
+ {
+ int rc = 0;
+
+- if (refcount_inc_not_zero(&cpu_cf_root.refcnt))
++ if (refcount_add_not_zero(num, &cpu_cf_root.refcnt))
+ return rc;
+
+ /* The memory is already zeroed. */
+ cpu_cf_root.cfptr = alloc_percpu(struct cpu_cf_ptr);
+ if (cpu_cf_root.cfptr) {
+- refcount_set(&cpu_cf_root.refcnt, 1);
++ refcount_set(&cpu_cf_root.refcnt, num);
+ on_each_cpu(cpum_cf_reset_cpu, NULL, 1);
+ irq_subclass_register(IRQ_SUBCLASS_MEASUREMENT_ALERT);
+ } else {
+@@ -206,20 +211,23 @@ static int cpum_cf_alloc_root(void)
+ return rc;
+ }
+
+-/* Free CPU counter data structure for a PMU */
+-static void cpum_cf_free_cpu(int cpu)
++/*
++ * Remove num references to the CPU counter data structure of a PMU.
++ * Called with pmc_reserve_mutex held.
++ */
++static void cpum_cf_free_cpu(int cpu, unsigned int num)
+ {
+ struct cpu_cf_events *cpuhw;
+ struct cpu_cf_ptr *p;
+
+- mutex_lock(&pmc_reserve_mutex);
++ lockdep_assert_held(&pmc_reserve_mutex);
+ /*
+ * When invoked via CPU hotplug handler, there might be no events
+ * installed or that particular CPU might not have an
+ * event installed. This anchor pointer can be NULL!
+ */
+ if (!cpu_cf_root.cfptr)
+- goto out;
++ return;
+ p = per_cpu_ptr(cpu_cf_root.cfptr, cpu);
+ cpuhw = p->cpucf;
+ /*
+@@ -227,28 +235,29 @@ static void cpum_cf_free_cpu(int cpu)
+ * installed on that CPU, but on different CPUs.
+ */
+ if (!cpuhw)
+- goto out;
++ return;
+
+- if (refcount_dec_and_test(&cpuhw->refcnt)) {
+- kfree(cpuhw);
++ if (refcount_sub_and_test(num, &cpuhw->refcnt)) {
+ p->cpucf = NULL;
++ kfree(cpuhw);
+ }
+- cpum_cf_free_root();
+-out:
+- mutex_unlock(&pmc_reserve_mutex);
++ cpum_cf_free_root(num);
+ }
+
+-/* Allocate CPU counter data structure for a PMU. Called under mutex lock. */
+-static int cpum_cf_alloc_cpu(int cpu)
++/*
++ * Add num references to the CPU counter data structure of a PMU and
++ * allocate it when necessary. Called with pmc_reserve_mutex held.
++ */
++static int cpum_cf_alloc_cpu(int cpu, unsigned int num)
+ {
+ struct cpu_cf_events *cpuhw;
+ struct cpu_cf_ptr *p;
+ int rc;
+
+- mutex_lock(&pmc_reserve_mutex);
+- rc = cpum_cf_alloc_root();
++ lockdep_assert_held(&pmc_reserve_mutex);
++ rc = cpum_cf_alloc_root(num);
+ if (rc)
+- goto unlock;
++ return rc;
+ p = per_cpu_ptr(cpu_cf_root.cfptr, cpu);
+ cpuhw = p->cpucf;
+
+@@ -256,12 +265,12 @@ static int cpum_cf_alloc_cpu(int cpu)
+ cpuhw = kzalloc_obj(*cpuhw);
+ if (cpuhw) {
+ p->cpucf = cpuhw;
+- refcount_set(&cpuhw->refcnt, 1);
++ refcount_set(&cpuhw->refcnt, num);
+ } else {
+ rc = -ENOMEM;
+ }
+ } else {
+- refcount_inc(&cpuhw->refcnt);
++ refcount_add(num, &cpuhw->refcnt);
+ }
+ if (rc) {
+ /*
+@@ -269,10 +278,8 @@ static int cpum_cf_alloc_cpu(int cpu)
+ * cpu_cf_event in not created, its destroy() function is not
+ * invoked. Adjust the reference counter for the anchor.
+ */
+- cpum_cf_free_root();
++ cpum_cf_free_root(num);
+ }
+-unlock:
+- mutex_unlock(&pmc_reserve_mutex);
+ return rc;
+ }
+
+@@ -284,39 +291,70 @@ unlock:
+ * perf_event_open() with task context and /dev/hwctr interface.
+ * If cpu is non-zero install event on this CPU only. This setup handles
+ * perf_event_open() with CPU context.
++ * Users with cpu == -1 are counted in cpu_cf_root::tskctx. The CPU hotplug
++ * prepare and dead callbacks use this count to install and remove the per
++ * CPU counter data on a new or dying CPU.
+ */
+-static int cpum_cf_alloc(int cpu)
++static int cpum_cf_alloc_cpuslocked(int cpu)
+ {
+ cpumask_var_t mask;
+ int rc;
+
++ lockdep_assert_cpus_held();
+ if (cpu == -1) {
+ if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
+ return -ENOMEM;
++ mutex_lock(&pmc_reserve_mutex);
+ for_each_online_cpu(cpu) {
+- rc = cpum_cf_alloc_cpu(cpu);
++ rc = cpum_cf_alloc_cpu(cpu, 1);
+ if (rc) {
+ for_each_cpu(cpu, mask)
+- cpum_cf_free_cpu(cpu);
++ cpum_cf_free_cpu(cpu, 1);
+ break;
+ }
+ cpumask_set_cpu(cpu, mask);
+ }
++ if (!rc)
++ cpu_cf_root.tskctx++;
++ mutex_unlock(&pmc_reserve_mutex);
+ free_cpumask_var(mask);
+ } else {
+- rc = cpum_cf_alloc_cpu(cpu);
++ mutex_lock(&pmc_reserve_mutex);
++ rc = cpum_cf_alloc_cpu(cpu, 1);
++ mutex_unlock(&pmc_reserve_mutex);
+ }
+ return rc;
+ }
+
+-static void cpum_cf_free(int cpu)
++static int cpum_cf_alloc(int cpu)
++{
++ int rc;
++
++ cpus_read_lock();
++ rc = cpum_cf_alloc_cpuslocked(cpu);
++ cpus_read_unlock();
++ return rc;
++}
++
++static void cpum_cf_free_cpuslocked(int cpu)
+ {
++ lockdep_assert_cpus_held();
++ mutex_lock(&pmc_reserve_mutex);
+ if (cpu == -1) {
++ cpu_cf_root.tskctx--;
+ for_each_online_cpu(cpu)
+- cpum_cf_free_cpu(cpu);
++ cpum_cf_free_cpu(cpu, 1);
+ } else {
+- cpum_cf_free_cpu(cpu);
++ cpum_cf_free_cpu(cpu, 1);
+ }
++ mutex_unlock(&pmc_reserve_mutex);
++}
++
++static void cpum_cf_free(int cpu)
++{
++ cpus_read_lock();
++ cpum_cf_free_cpuslocked(cpu);
++ cpus_read_unlock();
+ }
+
+ #define CF_DIAG_CTRSET_DEF 0xfeef /* Counter set header mark */
+@@ -1090,53 +1128,67 @@ static refcount_t cfset_opencnt = REFCOUNT_INIT(0); /* Access count */
+ static DEFINE_MUTEX(cfset_ctrset_mutex);
+
+ /*
+- * CPU hotplug handles only /dev/hwctr device.
+- * For perf_event_open() the CPU hotplug handling is done on kernel common
+- * code:
++ * CPU hotplug handling:
++ *
++ * cpum_cf_prepare_cpu() and cpum_cf_dead_cpu() run while the new or dying
++ * CPU is offline. They create and remove the per CPU counter data for all
++ * users tracking every CPU (cpu == -1), that is perf_event_open() events
++ * with task context and /dev/hwctr device sessions. Each such user holds
++ * one reference to the per CPU counter data of each CPU. Therefore install
++ * and remove one reference per user, tracked in cpu_cf_root::tskctx. This
++ * guarantees the per CPU counter data exists before the new CPU executes
++ * its first task and is removed only after the dying CPU is gone.
++ *
++ * cpum_cf_online_cpu() and cpum_cf_offline_cpu() run while the new or
++ * dying CPU is online. They handle only the counter set state of open
++ * /dev/hwctr device sessions on that CPU. For perf_event_open() events
++ * nothing is done:
+ * - CPU add: Nothing is done since a file descriptor can not be created
+ * and returned to the user.
+ * - CPU delete: Handled by common code via pmu_disable(), pmu_stop() and
+- * pmu_delete(). The event itself is removed when the file descriptor is
+- * closed.
++ * pmu_delete(). During task exit processing of grouped perf events
++ * triggered by CPU hotplug processing, pmu_disable() is called as part
++ * of perf context removal process. The event itself is removed when the
++ * event file descriptor is closed.
+ */
++static int cpum_cf_prepare_cpu(unsigned int cpu)
++{
++ int rc = 0;
++
++ mutex_lock(&pmc_reserve_mutex);
++ if (cpu_cf_root.tskctx)
++ rc = cpum_cf_alloc_cpu(cpu, cpu_cf_root.tskctx);
++ mutex_unlock(&pmc_reserve_mutex);
++ return rc;
++}
++
++static int cpum_cf_dead_cpu(unsigned int cpu)
++{
++ mutex_lock(&pmc_reserve_mutex);
++ if (cpu_cf_root.tskctx)
++ cpum_cf_free_cpu(cpu, cpu_cf_root.tskctx);
++ mutex_unlock(&pmc_reserve_mutex);
++ return 0;
++}
++
+ static int cfset_online_cpu(unsigned int cpu);
+
+ static int cpum_cf_online_cpu(unsigned int cpu)
+ {
+- int rc = 0;
+-
+- /*
+- * Ignore notification for perf_event_open().
+- * Handle only /dev/hwctr device sessions.
+- */
+ mutex_lock(&cfset_ctrset_mutex);
+- if (refcount_read(&cfset_opencnt)) {
+- rc = cpum_cf_alloc_cpu(cpu);
+- if (!rc)
+- cfset_online_cpu(cpu);
+- }
++ if (refcount_read(&cfset_opencnt))
++ cfset_online_cpu(cpu);
+ mutex_unlock(&cfset_ctrset_mutex);
+- return rc;
++ return 0;
+ }
+
+ static int cfset_offline_cpu(unsigned int cpu);
+
+ static int cpum_cf_offline_cpu(unsigned int cpu)
+ {
+- /*
+- * During task exit processing of grouped perf events triggered by CPU
+- * hotplug processing, pmu_disable() is called as part of perf context
+- * removal process. Therefore do not trigger event removal now for
+- * perf_event_open() created events. Perf common code triggers event
+- * destruction when the event file descriptor is closed.
+- *
+- * Handle only /dev/hwctr device sessions.
+- */
+ mutex_lock(&cfset_ctrset_mutex);
+- if (refcount_read(&cfset_opencnt)) {
++ if (refcount_read(&cfset_opencnt))
+ cfset_offline_cpu(cpu);
+- cpum_cf_free_cpu(cpu);
+- }
+ mutex_unlock(&cfset_ctrset_mutex);
+ return 0;
+ }
+@@ -1183,7 +1235,7 @@ static void cpumf_measurement_alert(struct ext_code ext_code,
+ static int cfset_init(void);
+ static int __init cpumf_pmu_init(void)
+ {
+- int rc;
++ int state, rc;
+
+ /* Extract counter measurement facility information */
+ if (!cpum_cf_avail() || qctri(&cpumf_ctr_info))
+@@ -1225,11 +1277,24 @@ static int __init cpumf_pmu_init(void)
+ cfset_init();
+ }
+
++ rc = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN,
++ "perf/s390/cf:prepare",
++ cpum_cf_prepare_cpu, cpum_cf_dead_cpu);
++ if (rc < 0)
++ goto out3;
++ state = rc;
++
+ rc = cpuhp_setup_state(CPUHP_AP_PERF_S390_CF_ONLINE,
+ "perf/s390/cf:online",
+ cpum_cf_online_cpu, cpum_cf_offline_cpu);
+- return rc;
++ if (rc < 0)
++ goto out4;
++ return 0;
+
++out4:
++ cpuhp_remove_state(state);
++out3:
++ perf_pmu_unregister(&cpumf_pmu);
+ out2:
+ debug_unregister_view(cf_dbg, &debug_sprintf_view);
+ debug_unregister(cf_dbg);
+@@ -1385,6 +1450,7 @@ static void cfset_all_stop(struct cfset_request *req)
+ */
+ static int cfset_release(struct inode *inode, struct file *file)
+ {
++ cpus_read_lock();
+ mutex_lock(&cfset_ctrset_mutex);
+ /* Open followed by close/exit has no private_data */
+ if (file->private_data) {
+@@ -1395,9 +1461,10 @@ static int cfset_release(struct inode *inode, struct file *file)
+ }
+ if (refcount_dec_and_test(&cfset_opencnt)) { /* Last close */
+ on_each_cpu(cfset_release_cpu, NULL, 1);
+- cpum_cf_free(-1);
++ cpum_cf_free_cpuslocked(-1);
+ }
+ mutex_unlock(&cfset_ctrset_mutex);
++ cpus_read_unlock();
+ return 0;
+ }
+
+@@ -1416,15 +1483,17 @@ static int cfset_open(struct inode *inode, struct file *file)
+ return -EPERM;
+ file->private_data = NULL;
+
++ cpus_read_lock();
+ mutex_lock(&cfset_ctrset_mutex);
+ if (!refcount_inc_not_zero(&cfset_opencnt)) { /* First open */
+- rc = cpum_cf_alloc(-1);
++ rc = cpum_cf_alloc_cpuslocked(-1);
+ if (!rc) {
+ cfset_session_init();
+ refcount_set(&cfset_opencnt, 1);
+ }
+ }
+ mutex_unlock(&cfset_ctrset_mutex);
++ cpus_read_unlock();
+
+ /* nonseekable_open() never fails */
+ return rc ?: nonseekable_open(inode, file);
+diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
+index 29b6f1ed59ec54..f904a636d449ba 100644
+--- a/arch/x86/coco/tdx/tdx.c
++++ b/arch/x86/coco/tdx/tdx.c
+@@ -694,8 +694,8 @@ static bool handle_in(struct pt_regs *regs, int size, int port)
+ .r13 = PORT_READ,
+ .r14 = port,
+ };
+- u64 mask = GENMASK(BITS_PER_BYTE * size, 0);
+ bool success;
++ u64 val;
+
+ /*
+ * Emulate the I/O read via hypercall. More info about ABI can be found
+@@ -703,18 +703,16 @@ static bool handle_in(struct pt_regs *regs, int size, int port)
+ * "TDG.VP.VMCALL".
+ */
+ success = !__tdx_hypercall(&args);
++ val = success ? args.r11 : 0;
+
+- /* Update part of the register affected by the emulated instruction */
+- regs->ax &= ~mask;
+- if (success)
+- regs->ax |= args.r11 & mask;
++ insn_assign_reg(®s->ax, val, size);
+
+ return success;
+ }
+
+ static bool handle_out(struct pt_regs *regs, int size, int port)
+ {
+- u64 mask = GENMASK(BITS_PER_BYTE * size, 0);
++ u64 mask = GENMASK(BITS_PER_BYTE * size - 1, 0);
+
+ /*
+ * Emulate the I/O write via hypercall. More info about ABI can be found
+diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
+index db70832232d4a4..3e78bb76153ce0 100644
+--- a/arch/x86/include/asm/barrier.h
++++ b/arch/x86/include/asm/barrier.h
+@@ -17,7 +17,7 @@
+ #define rmb() asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "lfence", \
+ X86_FEATURE_XMM2) ::: "memory", "cc")
+ #define wmb() asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "sfence", \
+- X86_FEATURE_XMM2) ::: "memory", "cc")
++ X86_FEATURE_XMM) ::: "memory", "cc")
+ #else
+ #define __mb() asm volatile("mfence":::"memory")
+ #define __rmb() asm volatile("lfence":::"memory")
+diff --git a/arch/x86/include/asm/insn-eval.h b/arch/x86/include/asm/insn-eval.h
+index 4733e9064ee555..ae05647a0afbf1 100644
+--- a/arch/x86/include/asm/insn-eval.h
++++ b/arch/x86/include/asm/insn-eval.h
+@@ -9,6 +9,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+
+ #define INSN_CODE_SEG_ADDR_SZ(params) ((params >> 4) & 0xf)
+@@ -46,4 +47,39 @@ enum insn_mmio_type insn_decode_mmio(struct insn *insn, int *bytes);
+
+ bool insn_is_nop(struct insn *insn);
+
++/*
++ * Write @val into *@reg following the x86 rules for writes to
++ * general-purpose registers (Intel SDM Vol. 1, "General-Purpose
++ * Registers in 64-Bit Mode"): an 8- or 16-bit write leaves the rest of
++ * the register untouched, a 32-bit write zero-extends the result into
++ * the upper 32 bits, and a 64-bit write replaces the whole register.
++ *
++ * @bytes is the width of the write, not a property of the instruction:
++ * an instruction that, say, sign-extends a 32-bit immediate into a
++ * 64-bit register does a 64-bit write here.
++ *
++ * @reg need not be 8-byte aligned: KVM's instruction emulator offsets
++ * the pointer by one byte to address the high-byte registers (AH, CH,
++ * DH, BH). Use narrow stores for the sub-word cases so the access
++ * width matches @bytes and the adjacent bytes are left alone.
++ */
++static inline void insn_assign_reg(unsigned long *reg, u64 val, int bytes)
++{
++ switch (bytes) {
++ case 1:
++ *(u8 *)reg = (u8)val;
++ break;
++ case 2:
++ *(u16 *)reg = (u16)val;
++ break;
++ case 4:
++ /* A 32-bit write zero-extends into the upper 32 bits. */
++ *reg = (u32)val;
++ break;
++ case 8:
++ *reg = val;
++ break;
++ }
++}
++
+ #endif /* _ASM_X86_INSN_EVAL_H */
+diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
+index b566ab5c751566..c6dcb5ac48afec 100644
+--- a/arch/x86/kvm/emulate.c
++++ b/arch/x86/kvm/emulate.c
+@@ -24,6 +24,7 @@
+ #include "kvm_emulate.h"
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -439,25 +440,6 @@ static void assign_masked(ulong *dest, ulong src, ulong mask)
+ *dest = (*dest & ~mask) | (src & mask);
+ }
+
+-static void assign_register(unsigned long *reg, u64 val, int bytes)
+-{
+- /* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */
+- switch (bytes) {
+- case 1:
+- *(u8 *)reg = (u8)val;
+- break;
+- case 2:
+- *(u16 *)reg = (u16)val;
+- break;
+- case 4:
+- *reg = (u32)val;
+- break; /* 64b: zero-extend */
+- case 8:
+- *reg = val;
+- break;
+- }
+-}
+-
+ static inline unsigned long ad_mask(struct x86_emulate_ctxt *ctxt)
+ {
+ return (1UL << (ctxt->ad_bytes << 3)) - 1;
+@@ -505,7 +487,7 @@ register_address_increment(struct x86_emulate_ctxt *ctxt, int reg, int inc)
+ {
+ ulong *preg = reg_rmw(ctxt, reg);
+
+- assign_register(preg, *preg + inc, ctxt->ad_bytes);
++ insn_assign_reg(preg, *preg + inc, ctxt->ad_bytes);
+ }
+
+ static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc)
+@@ -1767,7 +1749,7 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
+
+ static void write_register_operand(struct operand *op)
+ {
+- return assign_register(op->addr.reg, op->val, op->bytes);
++ return insn_assign_reg(op->addr.reg, op->val, op->bytes);
+ }
+
+ static int writeback(struct x86_emulate_ctxt *ctxt, struct operand *op)
+@@ -2008,7 +1990,7 @@ static int em_popa(struct x86_emulate_ctxt *ctxt)
+ rc = emulate_pop(ctxt, &val, ctxt->op_bytes);
+ if (rc != X86EMUL_CONTINUE)
+ break;
+- assign_register(reg_rmw(ctxt, reg), val, ctxt->op_bytes);
++ insn_assign_reg(reg_rmw(ctxt, reg), val, ctxt->op_bytes);
+ --reg;
+ }
+ return rc;
+diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
+index de7515ea1beae8..276d076d299381 100644
+--- a/arch/x86/net/bpf_jit_comp.c
++++ b/arch/x86/net/bpf_jit_comp.c
+@@ -1887,7 +1887,7 @@ static int do_jit(struct bpf_verifier_env *env, struct bpf_prog *bpf_prog, int *
+ EMIT_mov(dst_reg, src_reg);
+ #ifdef CONFIG_SMP
+ /* add , gs:[] */
+- EMIT2(0x65, add_1mod(0x48, dst_reg));
++ EMIT2(0x65, add_2mod(0x48, 0, dst_reg));
+ EMIT3(0x03, add_2reg(0x04, 0, dst_reg), 0x25);
+ EMIT((u32)(unsigned long)&this_cpu_off, 4);
+ #endif
+diff --git a/block/bio.c b/block/bio.c
+index 6a2f6fc3413e89..5018a6fc2f36b7 100644
+--- a/block/bio.c
++++ b/block/bio.c
+@@ -1221,10 +1221,45 @@ static int bio_iov_iter_align_down(struct bio *bio, struct iov_iter *iter,
+ return 0;
+ }
+
++#ifdef CONFIG_DEBUG_KERNEL
++static inline bool bio_iov_bvec_aligned(const struct bio *bio,
++ unsigned mem_align_mask)
++{
++ struct bvec_iter iter;
++ struct bio_vec bv;
++
++ /*
++ * Correct callers never break the alignment requirements, so this
++ * exhaustive check is only paid for in debug builds.
++ */
++ for_each_mp_bvec(bv, bio->bi_io_vec, iter, bio->bi_iter)
++ if ((bv.bv_offset | bv.bv_len) & mem_align_mask)
++ return false;
++ return true;
++}
++#else
++static inline bool bio_iov_bvec_aligned(const struct bio *bio,
++ unsigned mem_align_mask)
++{
++ /*
++ * We forward the bio_vec as-is, so ITER_BVEC callers must provide
++ * segments already aligned to the device's DMA alignment. The only
++ * unchecked user-controllable offset that reaches here is an io_uring
++ * registered buffer where just the first segment can be unaligned
++ * (the rest is virtually contiguous), so checking only that one is
++ * sufficient to know if the entire vector is valid.
++ */
++ return !(mp_bvec_iter_offset(bio->bi_io_vec, bio->bi_iter) &
++ mem_align_mask);
++}
++#endif
++
+ /**
+ * bio_iov_iter_get_pages - add user or kernel pages to a bio
+ * @bio: bio to add pages to
+ * @iter: iov iterator describing the region to be added
++ * @mem_align_mask: the mask the source address and length must be aligned to,
++ * 0 for no requirement
+ * @len_align_mask: the mask to align the total size to, 0 for any length
+ *
+ * This takes either an iterator pointing to user memory, or one pointing to
+@@ -1243,7 +1278,7 @@ static int bio_iov_iter_align_down(struct bio *bio, struct iov_iter *iter,
+ * is returned only if 0 pages could be pinned.
+ */
+ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter,
+- unsigned len_align_mask)
++ unsigned mem_align_mask, unsigned len_align_mask)
+ {
+ iov_iter_extraction_t flags = 0;
+
+@@ -1252,6 +1287,10 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter,
+
+ if (iov_iter_is_bvec(iter)) {
+ bio_iov_bvec_set(bio, iter);
++
++ if (!bio_iov_bvec_aligned(bio, mem_align_mask))
++ return -EINVAL;
++
+ iov_iter_advance(iter, bio->bi_iter.bi_size);
+ return 0;
+ }
+@@ -1266,8 +1305,19 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter,
+
+ ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec,
+ BIO_MAX_SIZE - bio->bi_iter.bi_size,
+- &bio->bi_vcnt, bio->bi_max_vecs, flags);
++ &bio->bi_vcnt, bio->bi_max_vecs,
++ mem_align_mask, flags);
+ if (ret <= 0) {
++ /*
++ * A misaligned vector fails the whole I/O. Release any
++ * pages pinned by earlier iterations before returning
++ * since this bio won't be submitted to release them.
++ */
++ if (ret == -EINVAL) {
++ bio_release_pages(bio, false);
++ bio_clear_flag(bio, BIO_PAGE_PINNED);
++ bio->bi_vcnt = 0;
++ }
+ if (!bio->bi_vcnt)
+ return ret;
+ break;
+@@ -1380,7 +1430,7 @@ static int bio_iov_iter_bounce_read(struct bio *bio, struct iov_iter *iter,
+
+ do {
+ ret = iov_iter_extract_bvecs(iter, bio->bi_io_vec + 1, len,
+- &bio->bi_vcnt, bio->bi_max_vecs - 1, 0);
++ &bio->bi_vcnt, bio->bi_max_vecs - 1, 0, 0);
+ if (ret <= 0) {
+ if (!bio->bi_vcnt)
+ goto out_folio_put;
+diff --git a/block/blk-map.c b/block/blk-map.c
+index d1d6bbe0ecf1f9..615d29bb840eb9 100644
+--- a/block/blk-map.c
++++ b/block/blk-map.c
+@@ -274,7 +274,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
+ * No alignment requirements on our part to support arbitrary
+ * passthrough commands.
+ */
+- ret = bio_iov_iter_get_pages(bio, iter, 0);
++ ret = bio_iov_iter_get_pages(bio, iter, 0, 0);
+ if (ret)
+ goto out_put;
+ ret = blk_rq_append_bio(rq, bio);
+diff --git a/block/fops.c b/block/fops.c
+index 15783a6180dec1..a84450d79b3cc9 100644
+--- a/block/fops.c
++++ b/block/fops.c
+@@ -46,7 +46,7 @@ static bool blkdev_dio_invalid(struct block_device *bdev, struct kiocb *iocb,
+ static inline int blkdev_iov_iter_get_pages(struct bio *bio,
+ struct iov_iter *iter, struct block_device *bdev)
+ {
+- return bio_iov_iter_get_pages(bio, iter,
++ return bio_iov_iter_get_pages(bio, iter, bdev_dma_alignment(bdev),
+ bdev_logical_block_size(bdev) - 1);
+ }
+
+diff --git a/block/genhd.c b/block/genhd.c
+index e8ce0cabf392ca..f1990c7cdfb910 100644
+--- a/block/genhd.c
++++ b/block/genhd.c
+@@ -681,6 +681,7 @@ static bool __blk_mark_disk_dead(struct gendisk *disk)
+ */
+ void blk_mark_disk_dead(struct gendisk *disk)
+ {
++ blk_queue_flag_set(QUEUE_FLAG_DYING, disk->queue);
+ __blk_mark_disk_dead(disk);
+ blk_report_disk_dead(disk, true);
+ }
+diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
+index ac51bff39833fa..3141f210fcd1b5 100644
+--- a/drivers/accel/rocket/rocket_job.c
++++ b/drivers/accel/rocket/rocket_job.c
+@@ -8,6 +8,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -102,6 +103,7 @@ rocket_copy_tasks(struct drm_device *dev,
+
+ fail:
+ kvfree(rjob->tasks);
++ rjob->tasks = NULL;
+ return ret;
+ }
+
+@@ -188,14 +190,19 @@ static int rocket_job_push(struct rocket_job *job)
+ struct rocket_device *rdev = job->rdev;
+ struct drm_gem_object **bos;
+ struct ww_acquire_ctx acquire_ctx;
++ u32 bo_count;
+ int ret = 0;
+
+- bos = kvmalloc_array(job->in_bo_count + job->out_bo_count, sizeof(void *),
+- GFP_KERNEL);
++ if (check_add_overflow(job->in_bo_count, job->out_bo_count, &bo_count))
++ return -EINVAL;
++
++ bos = kvmalloc_array(bo_count, sizeof(*bos), GFP_KERNEL);
++ if (!bos)
++ return -ENOMEM;
+ memcpy(bos, job->in_bos, job->in_bo_count * sizeof(void *));
+ memcpy(&bos[job->in_bo_count], job->out_bos, job->out_bo_count * sizeof(void *));
+
+- ret = drm_gem_lock_reservations(bos, job->in_bo_count + job->out_bo_count, &acquire_ctx);
++ ret = drm_gem_lock_reservations(bos, bo_count, &acquire_ctx);
+ if (ret)
+ goto err;
+
+@@ -220,7 +227,7 @@ static int rocket_job_push(struct rocket_job *job)
+ rocket_attach_object_fences(job->out_bos, job->out_bo_count, job->inference_done_fence);
+
+ err_unlock:
+- drm_gem_unlock_reservations(bos, job->in_bo_count + job->out_bo_count, &acquire_ctx);
++ drm_gem_unlock_reservations(bos, bo_count, &acquire_ctx);
+ err:
+ kvfree(bos);
+
+@@ -310,13 +317,13 @@ static struct dma_fence *rocket_job_run(struct drm_sched_job *sched_job)
+ dma_fence_put(job->done_fence);
+ job->done_fence = dma_fence_get(fence);
+
+- ret = pm_runtime_get_sync(core->dev);
++ ret = pm_runtime_resume_and_get(core->dev);
+ if (ret < 0)
+- return fence;
++ goto err_put_fences;
+
+ ret = iommu_attach_group(job->domain->domain, core->iommu_group);
+ if (ret < 0)
+- return fence;
++ goto err_put_pm;
+
+ scoped_guard(mutex, &core->job_lock) {
+ core->in_flight_job = job;
+@@ -324,6 +331,14 @@ static struct dma_fence *rocket_job_run(struct drm_sched_job *sched_job)
+ }
+
+ return fence;
++
++err_put_pm:
++ pm_runtime_put(core->dev);
++err_put_fences:
++ dma_fence_put(job->done_fence);
++ job->done_fence = NULL;
++ dma_fence_put(fence);
++ return ERR_PTR(ret);
+ }
+
+ static void rocket_job_handle_irq(struct rocket_core *core)
+@@ -549,6 +564,7 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
+ kref_init(&rjob->refcount);
+
+ rjob->rdev = rdev;
++ rjob->domain = rocket_iommu_domain_get(file_priv);
+
+ ret = drm_sched_job_init(&rjob->base,
+ &file_priv->sched_entity,
+@@ -574,8 +590,6 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
+
+ rjob->out_bo_count = job->out_bo_handle_count;
+
+- rjob->domain = rocket_iommu_domain_get(file_priv);
+-
+ ret = rocket_job_push(rjob);
+ if (ret)
+ goto out_cleanup_job;
+diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
+index a09636a4168ec5..e3c77a65f61c8d 100644
+--- a/drivers/acpi/acpi_platform.c
++++ b/drivers/acpi/acpi_platform.c
+@@ -12,6 +12,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -71,6 +72,42 @@ static struct notifier_block acpi_platform_notifier = {
+ .notifier_call = acpi_platform_device_remove_notify,
+ };
+
++static unsigned int acpi_platform_adjust_resources(struct acpi_device *adev,
++ struct resource *new_res,
++ struct resource *resources,
++ unsigned int count)
++{
++ unsigned int i;
++
++ if (!(new_res->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
++ return count;
++
++ for (i = 0; i < count; ) {
++ struct resource *res = &resources[i];
++
++ /*
++ * Look for overlaps of resources of the same type that would
++ * cause resource insertion to fail down the road.
++ */
++ if (__resource_contains_unbound(res, new_res) ||
++ __resource_contains_unbound(new_res, res) ||
++ resource_type(new_res) != resource_type(res) ||
++ !resource_union(new_res, res, new_res)) {
++ i++;
++ continue;
++ }
++
++ dev_info(&adev->dev, "%pR expanded due to overlap\n", new_res);
++ /*
++ * Eliminate the previously processed resource that overlapped
++ * with the new one because it is not necessary any more.
++ */
++ memmove(res, res + 1, (--count - i) * sizeof(*res));
++ }
++
++ return count;
++}
++
+ static void acpi_platform_fill_resource(struct acpi_device *adev,
+ const struct resource *src, struct resource *dest)
+ {
+@@ -151,10 +188,14 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
+ return ERR_PTR(-ENOMEM);
+ }
+ count = 0;
+- list_for_each_entry(rentry, &resource_list, node)
++ list_for_each_entry(rentry, &resource_list, node) {
++ count = acpi_platform_adjust_resources(adev,
++ rentry->res,
++ resources,
++ count);
+ acpi_platform_fill_resource(adev, rentry->res,
+ &resources[count++]);
+-
++ }
+ acpi_dev_free_resource_list(&resource_list);
+ }
+ }
+diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
+index fc43df083738c4..45459a4cafae30 100644
+--- a/drivers/acpi/acpi_tad.c
++++ b/drivers/acpi/acpi_tad.c
+@@ -27,6 +27,7 @@
+ #include
+ #include
+ #include
++#include
+ #include
+ #include
+ #include
+@@ -86,6 +87,8 @@ static bool acpi_tad_rt_is_invalid(struct acpi_tad_rt *rt)
+ rt->daylight > 3;
+ }
+
++static DEFINE_MUTEX(acpi_tad_aml_lock);
++
+ static int acpi_tad_set_real_time(struct device *dev, struct acpi_tad_rt *rt)
+ {
+ acpi_handle handle = ACPI_HANDLE(dev);
+@@ -113,6 +116,8 @@ static int acpi_tad_set_real_time(struct device *dev, struct acpi_tad_rt *rt)
+ if (PM_RUNTIME_ACQUIRE_ERR(&pm))
+ return -ENXIO;
+
++ guard(mutex)(&acpi_tad_aml_lock);
++
+ status = acpi_evaluate_integer(handle, "_SRT", &arg_list, &retval);
+ if (ACPI_FAILURE(status) || retval)
+ return -EIO;
+@@ -124,30 +129,27 @@ static int acpi_tad_evaluate_grt(struct device *dev, struct acpi_tad_rt *rt)
+ {
+ acpi_handle handle = ACPI_HANDLE(dev);
+ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER };
+- union acpi_object *out_obj;
+- struct acpi_tad_rt *data;
+ acpi_status status;
+ int ret = -EIO;
+
+- status = acpi_evaluate_object(handle, "_GRT", NULL, &output);
+- if (ACPI_FAILURE(status))
+- goto out_free;
+-
+- out_obj = output.pointer;
+- if (out_obj->type != ACPI_TYPE_BUFFER)
+- goto out_free;
+-
+- if (out_obj->buffer.length != sizeof(*rt))
+- goto out_free;
+-
+- data = (struct acpi_tad_rt *)(out_obj->buffer.pointer);
+- if (!data->valid)
+- goto out_free;
+-
+- memcpy(rt, data, sizeof(*rt));
+- ret = 0;
++ guard(mutex)(&acpi_tad_aml_lock);
+
+-out_free:
++ status = acpi_evaluate_object(handle, "_GRT", NULL, &output);
++ if (ACPI_SUCCESS(status)) {
++ union acpi_object *out_obj;
++
++ out_obj = output.pointer;
++ if (out_obj->type == ACPI_TYPE_BUFFER &&
++ out_obj->buffer.length == sizeof(*rt)) {
++ struct acpi_tad_rt *data;
++
++ data = (struct acpi_tad_rt *)(out_obj->buffer.pointer);
++ if (data->valid) {
++ memcpy(rt, data, sizeof(*rt));
++ ret = 0;
++ }
++ }
++ }
+ ACPI_FREE(output.pointer);
+ return ret;
+ }
+@@ -193,6 +195,8 @@ static int __acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
+ args[0].integer.value = timer_id;
+ args[1].integer.value = value;
+
++ guard(mutex)(&acpi_tad_aml_lock);
++
+ status = acpi_evaluate_integer(handle, method, &arg_list, &retval);
+ if (ACPI_FAILURE(status) || retval)
+ return -EIO;
+@@ -215,6 +219,8 @@ static int __acpi_tad_wake_read(struct device *dev, char *method, u32 timer_id,
+
+ args[0].integer.value = timer_id;
+
++ guard(mutex)(&acpi_tad_aml_lock);
++
+ status = acpi_evaluate_integer(handle, method, &arg_list, retval);
+ if (ACPI_FAILURE(status))
+ return -EIO;
+@@ -416,6 +422,8 @@ static int acpi_tad_clear_status(struct device *dev, u32 timer_id)
+ if (PM_RUNTIME_ACQUIRE_ERR(&pm))
+ return -ENXIO;
+
++ guard(mutex)(&acpi_tad_aml_lock);
++
+ status = acpi_evaluate_integer(handle, "_CWS", &arg_list, &retval);
+ if (ACPI_FAILURE(status) || retval)
+ return -EIO;
+@@ -456,6 +464,8 @@ static ssize_t acpi_tad_status_read(struct device *dev, char *buf, u32 timer_id)
+ if (PM_RUNTIME_ACQUIRE_ERR(&pm))
+ return -ENXIO;
+
++ guard(mutex)(&acpi_tad_aml_lock);
++
+ status = acpi_evaluate_integer(handle, "_GWS", &arg_list, &retval);
+ if (ACPI_FAILURE(status))
+ return -EIO;
+diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
+index bf65e346153145..15ab797641cfcc 100644
+--- a/drivers/acpi/apei/erst.c
++++ b/drivers/acpi/apei/erst.c
+@@ -108,7 +108,7 @@ static inline u64 erst_get_timeout(void)
+
+ if (erst_erange.attr & ERST_RANGE_SLOW) {
+ timeout = ((erst_erange.timings & ERST_EXEC_TIMING_MAX_MASK) >>
+- ERST_EXEC_TIMING_MAX_SHIFT) * NSEC_PER_MSEC;
++ ERST_EXEC_TIMING_MAX_SHIFT) * NSEC_PER_USEC;
+ if (timeout < FIRMWARE_TIMEOUT)
+ timeout = FIRMWARE_TIMEOUT;
+ }
+diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
+index 3236a3ce79d6bd..c40df9a3b37cda 100644
+--- a/drivers/acpi/apei/ghes.c
++++ b/drivers/acpi/apei/ghes.c
+@@ -576,7 +576,7 @@ static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdata,
+ return false;
+
+ p = (char *)(err + 1);
+- length -= sizeof(err);
++ length -= sizeof(*err);
+
+ for (i = 0; i < err->err_info_num; i++) {
+ struct cper_arm_err_info *err_info;
+@@ -749,7 +749,7 @@ static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,
+ CXL_CPER_PROT_ERR_FIFO_DEPTH);
+
+ /* Synchronize schedule_work() with cxl_cper_prot_err_work changes */
+-static DEFINE_SPINLOCK(cxl_cper_prot_err_work_lock);
++static DEFINE_RAW_SPINLOCK(cxl_cper_prot_err_work_lock);
+ struct work_struct *cxl_cper_prot_err_work;
+
+ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+@@ -761,7 +761,7 @@ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+ if (cxl_cper_sec_prot_err_valid(prot_err))
+ return;
+
+- guard(spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
++ guard(raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
+
+ if (!cxl_cper_prot_err_work)
+ return;
+@@ -780,10 +780,11 @@ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,
+
+ int cxl_cper_register_prot_err_work(struct work_struct *work)
+ {
+- if (cxl_cper_prot_err_work)
+- return -EINVAL;
++ guard(raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
+
+- guard(spinlock)(&cxl_cper_prot_err_work_lock);
++ if (WARN_ONCE(cxl_cper_prot_err_work,
++ "CPER-CXL kfifo consumer already registered\n"))
++ return -EINVAL;
+ cxl_cper_prot_err_work = work;
+ return 0;
+ }
+@@ -791,11 +792,18 @@ EXPORT_SYMBOL_NS_GPL(cxl_cper_register_prot_err_work, "CXL");
+
+ int cxl_cper_unregister_prot_err_work(struct work_struct *work)
+ {
+- if (cxl_cper_prot_err_work != work)
+- return -EINVAL;
++ scoped_guard(raw_spinlock_irqsave, &cxl_cper_prot_err_work_lock) {
++ if (WARN_ONCE(cxl_cper_prot_err_work != work,
++ "CPER-CXL kfifo consumer mismatch on unregister\n"))
++ return -EINVAL;
++ cxl_cper_prot_err_work = NULL;
++ }
++
++ cancel_work_sync(work);
++
++ /* Discard stale entries so they are not replayed on next module load */
++ kfifo_reset(&cxl_cper_prot_err_fifo);
+
+- guard(spinlock)(&cxl_cper_prot_err_work_lock);
+- cxl_cper_prot_err_work = NULL;
+ return 0;
+ }
+ EXPORT_SYMBOL_NS_GPL(cxl_cper_unregister_prot_err_work, "CXL");
+@@ -811,7 +819,7 @@ EXPORT_SYMBOL_NS_GPL(cxl_cper_prot_err_kfifo_get, "CXL");
+ DEFINE_KFIFO(cxl_cper_fifo, struct cxl_cper_work_data, CXL_CPER_FIFO_DEPTH);
+
+ /* Synchronize schedule_work() with cxl_cper_work changes */
+-static DEFINE_SPINLOCK(cxl_cper_work_lock);
++static DEFINE_RAW_SPINLOCK(cxl_cper_work_lock);
+ struct work_struct *cxl_cper_work;
+
+ static void cxl_cper_post_event(enum cxl_event_type event_type,
+@@ -831,7 +839,7 @@ static void cxl_cper_post_event(enum cxl_event_type event_type,
+ return;
+ }
+
+- guard(spinlock_irqsave)(&cxl_cper_work_lock);
++ guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
+
+ if (!cxl_cper_work)
+ return;
+@@ -849,10 +857,11 @@ static void cxl_cper_post_event(enum cxl_event_type event_type,
+
+ int cxl_cper_register_work(struct work_struct *work)
+ {
+- if (cxl_cper_work)
++ guard(raw_spinlock_irqsave)(&cxl_cper_work_lock);
++ if (WARN_ONCE(cxl_cper_work,
++ "CXL CPER kfifo consumer already registered\n"))
+ return -EINVAL;
+
+- guard(spinlock)(&cxl_cper_work_lock);
+ cxl_cper_work = work;
+ return 0;
+ }
+@@ -860,11 +869,18 @@ EXPORT_SYMBOL_NS_GPL(cxl_cper_register_work, "CXL");
+
+ int cxl_cper_unregister_work(struct work_struct *work)
+ {
+- if (cxl_cper_work != work)
+- return -EINVAL;
++ scoped_guard(raw_spinlock_irqsave, &cxl_cper_work_lock) {
++ if (WARN_ONCE(cxl_cper_work != work,
++ "CXL CPER kfifo consumer mismatch on unregister\n"))
++ return -EINVAL;
++ cxl_cper_work = NULL;
++ }
++
++ cancel_work_sync(work);
++
++ /* Discard stale entries so they are not replayed on next module load */
++ kfifo_reset(&cxl_cper_fifo);
+
+- guard(spinlock)(&cxl_cper_work_lock);
+- cxl_cper_work = NULL;
+ return 0;
+ }
+ EXPORT_SYMBOL_NS_GPL(cxl_cper_unregister_work, "CXL");
+diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
+index 53d09ca98f0668..becb7e442b30e1 100644
+--- a/drivers/acpi/cppc_acpi.c
++++ b/drivers/acpi/cppc_acpi.c
+@@ -1316,15 +1316,30 @@ static int cppc_set_reg_val(int cpu, enum cppc_regs reg_idx, u64 val)
+ return cpc_write(cpu, reg, val);
+ }
+
++static bool cppc_desired_perf_readable(const struct cpc_desc *cpc_desc)
++{
++ return cpc_desc->version < CPPC_V4_REV;
++}
++
+ /**
+ * cppc_get_desired_perf - Get the desired performance register value.
+ * @cpunum: CPU from which to get desired performance.
+ * @desired_perf: Return address.
+ *
+- * Return: 0 for success, -EIO otherwise.
++ * Return: 0 for success, -EOPNOTSUPP for _CPC revision 4 or later, and a
++ * negative errno otherwise.
+ */
+ int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
+ {
++ struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
++
++ if (!cpc_desc)
++ return -ENODEV;
++
++ /* _CPC revision 4 no longer specifies Desired Performance as readable. */
++ if (!cppc_desired_perf_readable(cpc_desc))
++ return -EOPNOTSUPP;
++
+ return cppc_get_reg_val(cpunum, DESIRED_PERF, desired_perf);
+ }
+ EXPORT_SYMBOL_GPL(cppc_get_desired_perf);
+@@ -1830,12 +1845,14 @@ int cppc_get_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
+ u64 desired_perf = 0, min = 0, max = 0, energy_perf = 0, auto_sel = 0;
+ int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
+ struct cppc_pcc_data *pcc_ss_data = NULL;
++ bool read_desired_perf;
+ int ret = 0, regs_in_pcc = 0;
+
+ if (!cpc_desc) {
+ pr_debug("No CPC descriptor for CPU:%d\n", cpu);
+ return -ENODEV;
+ }
++ read_desired_perf = cppc_desired_perf_readable(cpc_desc);
+
+ if (!perf_ctrls) {
+ pr_debug("Invalid perf_ctrls pointer\n");
+@@ -1849,7 +1866,8 @@ int cppc_get_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
+ auto_sel_reg = &cpc_desc->cpc_regs[AUTO_SEL_ENABLE];
+
+ /* Are any of the regs PCC ?*/
+- if (CPC_IN_PCC(desired_perf_reg) || CPC_IN_PCC(min_perf_reg) ||
++ if ((read_desired_perf && CPC_IN_PCC(desired_perf_reg)) ||
++ CPC_IN_PCC(min_perf_reg) ||
+ CPC_IN_PCC(max_perf_reg) || CPC_IN_PCC(energy_perf_reg) ||
+ CPC_IN_PCC(auto_sel_reg)) {
+ if (pcc_ss_id < 0) {
+@@ -1881,7 +1899,7 @@ int cppc_get_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
+ }
+ perf_ctrls->min_perf = min;
+
+- if (CPC_SUPPORTED(desired_perf_reg)) {
++ if (read_desired_perf && CPC_SUPPORTED(desired_perf_reg)) {
+ ret = cpc_read(cpu, desired_perf_reg, &desired_perf);
+ if (ret)
+ goto out_err;
+diff --git a/drivers/acpi/pfr_update.c b/drivers/acpi/pfr_update.c
+index 6283105bb0e8b2..9afd2c52fdbd88 100644
+--- a/drivers/acpi/pfr_update.c
++++ b/drivers/acpi/pfr_update.c
+@@ -120,7 +120,7 @@ static int query_capability(struct pfru_update_cap_info *cap_hdr,
+ struct pfru_device *pfru_dev)
+ {
+ acpi_handle handle = ACPI_HANDLE(pfru_dev->parent_dev);
+- union acpi_object *out_obj;
++ union acpi_object *out_obj, *elem;
+ int ret = -EINVAL;
+
+ out_obj = acpi_evaluate_dsm_typed(handle, &pfru_guid,
+@@ -150,7 +150,9 @@ static int query_capability(struct pfru_update_cap_info *cap_hdr,
+ goto free_acpi_buffer;
+ }
+
+- cap_hdr->status = out_obj->package.elements[CAP_STATUS_IDX].integer.value;
++ elem = out_obj->package.elements;
++
++ cap_hdr->status = elem[CAP_STATUS_IDX].integer.value;
+ if (cap_hdr->status != DSM_SUCCEED) {
+ ret = -EBUSY;
+ dev_dbg(pfru_dev->parent_dev, "Query cap Error Status:%d\n",
+@@ -158,29 +160,30 @@ static int query_capability(struct pfru_update_cap_info *cap_hdr,
+ goto free_acpi_buffer;
+ }
+
+- cap_hdr->update_cap = out_obj->package.elements[CAP_UPDATE_IDX].integer.value;
++ if (elem[CAP_CODE_TYPE_IDX].buffer.length > sizeof(cap_hdr->code_type) ||
++ elem[CAP_DRV_TYPE_IDX].buffer.length > sizeof(cap_hdr->drv_type) ||
++ elem[CAP_PLAT_ID_IDX].buffer.length > sizeof(cap_hdr->platform_id) ||
++ elem[CAP_OEM_ID_IDX].buffer.length > sizeof(cap_hdr->oem_id))
++ goto free_acpi_buffer;
++
++ cap_hdr->update_cap = elem[CAP_UPDATE_IDX].integer.value;
+ memcpy(&cap_hdr->code_type,
+- out_obj->package.elements[CAP_CODE_TYPE_IDX].buffer.pointer,
+- out_obj->package.elements[CAP_CODE_TYPE_IDX].buffer.length);
+- cap_hdr->fw_version =
+- out_obj->package.elements[CAP_FW_VER_IDX].integer.value;
+- cap_hdr->code_rt_version =
+- out_obj->package.elements[CAP_CODE_RT_VER_IDX].integer.value;
++ elem[CAP_CODE_TYPE_IDX].buffer.pointer,
++ elem[CAP_CODE_TYPE_IDX].buffer.length);
++ cap_hdr->fw_version = elem[CAP_FW_VER_IDX].integer.value;
++ cap_hdr->code_rt_version = elem[CAP_CODE_RT_VER_IDX].integer.value;
+ memcpy(&cap_hdr->drv_type,
+- out_obj->package.elements[CAP_DRV_TYPE_IDX].buffer.pointer,
+- out_obj->package.elements[CAP_DRV_TYPE_IDX].buffer.length);
+- cap_hdr->drv_rt_version =
+- out_obj->package.elements[CAP_DRV_RT_VER_IDX].integer.value;
+- cap_hdr->drv_svn =
+- out_obj->package.elements[CAP_DRV_SVN_IDX].integer.value;
++ elem[CAP_DRV_TYPE_IDX].buffer.pointer,
++ elem[CAP_DRV_TYPE_IDX].buffer.length);
++ cap_hdr->drv_rt_version = elem[CAP_DRV_RT_VER_IDX].integer.value;
++ cap_hdr->drv_svn = elem[CAP_DRV_SVN_IDX].integer.value;
+ memcpy(&cap_hdr->platform_id,
+- out_obj->package.elements[CAP_PLAT_ID_IDX].buffer.pointer,
+- out_obj->package.elements[CAP_PLAT_ID_IDX].buffer.length);
++ elem[CAP_PLAT_ID_IDX].buffer.pointer,
++ elem[CAP_PLAT_ID_IDX].buffer.length);
+ memcpy(&cap_hdr->oem_id,
+- out_obj->package.elements[CAP_OEM_ID_IDX].buffer.pointer,
+- out_obj->package.elements[CAP_OEM_ID_IDX].buffer.length);
+- cap_hdr->oem_info_len =
+- out_obj->package.elements[CAP_OEM_INFO_IDX].buffer.length;
++ elem[CAP_OEM_ID_IDX].buffer.pointer,
++ elem[CAP_OEM_ID_IDX].buffer.length);
++ cap_hdr->oem_info_len = elem[CAP_OEM_INFO_IDX].buffer.length;
+
+ ret = 0;
+
+diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
+index d2160ee7ca7d4b..f0bb4068d14d92 100644
+--- a/drivers/ata/libata-scsi.c
++++ b/drivers/ata/libata-scsi.c
+@@ -3545,17 +3545,13 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
+ static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax,
+ u64 sector, u32 count)
+ {
+- struct scsi_device *sdp = cmd->device;
+- size_t len = sdp->sector_size;
++ size_t len = ATA_SECT_SIZE;
+ size_t r;
+ __le64 *buf;
+ u32 i = 0;
+ unsigned long flags;
+
+- WARN_ON(len > ATA_SCSI_RBUF_SIZE);
+-
+- if (len > ATA_SCSI_RBUF_SIZE)
+- len = ATA_SCSI_RBUF_SIZE;
++ BUILD_BUG_ON(ATA_SECT_SIZE > ATA_SCSI_RBUF_SIZE);
+
+ spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
+ buf = ((void *)ata_scsi_rbuf);
+@@ -3590,13 +3586,11 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
+ {
+ struct ata_taskfile *tf = &qc->tf;
+ struct scsi_cmnd *scmd = qc->scsicmd;
+- struct scsi_device *sdp = scmd->device;
+- size_t len = sdp->sector_size;
+ struct ata_device *dev = qc->dev;
+ const u8 *cdb = scmd->cmnd;
+ u64 block;
+ u32 n_block;
+- const u32 trmax = len >> 3;
++ const u32 trmax = ATA_MAX_TRIM_RNUM;
+ u32 size;
+ u16 fp;
+ u8 bp = 0xff;
+@@ -3640,13 +3634,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
+ goto invalid_param_len;
+
+ /*
+- * size must match sector size in bytes
+- * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count)
+- * is defined as number of 512 byte blocks to be transferred.
++ * The TRIM descriptor is a single 512-byte page, which is the maximum
++ * WRITE SAME length advertised in the Block Limits VPD page. For DATA
++ * SET MANAGEMENT TRIM the COUNT field (aka nsect) is the number of
++ * 512-byte blocks to be transferred.
+ */
+-
+ size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block);
+- if (size != len)
++ if (size != ATA_SECT_SIZE)
+ goto invalid_param_len;
+
+ if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
+@@ -3672,6 +3666,12 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
+ ATA_TFLAG_WRITE;
+
+ ata_qc_set_pc_nbytes(qc);
++ /*
++ * The DSM TRIM payload is a single 512-byte page, which may be smaller
++ * than the WRITE SAME data-out buffer (one logical block); only
++ * transfer that page so the length matches the COUNT field.
++ */
++ qc->nbytes = size;
+
+ return 0;
+
+diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
+index 09020bb8ad15fa..ae2692ec396396 100644
+--- a/drivers/auxdisplay/charlcd.c
++++ b/drivers/auxdisplay/charlcd.c
+@@ -595,6 +595,16 @@ static int charlcd_init(struct charlcd *lcd)
+ return 0;
+ }
+
++static void charlcd_deinit(struct charlcd *lcd)
++{
++ struct charlcd_priv *priv = charlcd_to_priv(lcd);
++
++ if (lcd->ops->backlight) {
++ cancel_delayed_work_sync(&priv->bl_work);
++ lcd->ops->backlight(lcd, CHARLCD_OFF);
++ }
++}
++
+ struct charlcd *charlcd_alloc(unsigned int drvdata_size)
+ {
+ struct charlcd_priv *priv;
+@@ -654,8 +664,10 @@ int charlcd_register(struct charlcd *lcd)
+ return ret;
+
+ ret = misc_register(&charlcd_dev);
+- if (ret)
++ if (ret) {
++ charlcd_deinit(lcd);
+ return ret;
++ }
+
+ the_charlcd = lcd;
+ register_reboot_notifier(&panel_notifier);
+@@ -665,16 +677,11 @@ EXPORT_SYMBOL_GPL(charlcd_register);
+
+ int charlcd_unregister(struct charlcd *lcd)
+ {
+- struct charlcd_priv *priv = charlcd_to_priv(lcd);
+-
+ unregister_reboot_notifier(&panel_notifier);
+ charlcd_puts(lcd, "\x0cLCD driver unloaded.\x1b[Lc\x1b[Lb\x1b[L-");
+ misc_deregister(&charlcd_dev);
+ the_charlcd = NULL;
+- if (lcd->ops->backlight) {
+- cancel_delayed_work_sync(&priv->bl_work);
+- priv->lcd.ops->backlight(&priv->lcd, CHARLCD_OFF);
+- }
++ charlcd_deinit(lcd);
+
+ return 0;
+ }
+diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
+index c99f2ab105e5b7..a36c939b8e9052 100644
+--- a/drivers/base/arch_numa.c
++++ b/drivers/base/arch_numa.c
+@@ -105,6 +105,18 @@ static void __init setup_node_to_cpumask_map(void)
+ if (nr_node_ids == MAX_NUMNODES)
+ setup_nr_node_ids();
+
++ /*
++ * This check should never be true but it makes it clear to compilers
++ * that node_to_cpumask_map is bound by nr_node_ids, avoiding false
++ * positive fortify warnings when accessing node_to_cpumask_map in the
++ * for loop below.
++ */
++ if (unlikely(nr_node_ids > MAX_NUMNODES)) {
++ pr_err("nr_node_ids (%u) is larger than MAX_NUMNODES (%u)\n",
++ nr_node_ids, MAX_NUMNODES);
++ return;
++ }
++
+ /* allocate and clear the mapping */
+ for (node = 0; node < nr_node_ids; node++) {
+ alloc_bootmem_cpumask_var(&node_to_cpumask_map[node]);
+diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
+index f71467f6ada4ee..4ed2e9b7e99b70 100644
+--- a/drivers/base/power/main.c
++++ b/drivers/base/power/main.c
+@@ -2234,6 +2234,7 @@ unlock:
+
+ if (ret < 0) {
+ suspend_report_result(dev, callback, ret);
++ pm_runtime_unblock(dev);
+ pm_runtime_put(dev);
+ return ret;
+ }
+diff --git a/drivers/base/property.c b/drivers/base/property.c
+index e08eadd66f4f9f..e0f570f48bc320 100644
+--- a/drivers/base/property.c
++++ b/drivers/base/property.c
+@@ -807,18 +807,31 @@ struct fwnode_handle *
+ fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
+ struct fwnode_handle *child)
+ {
++ const struct fwnode_handle *parent;
++ struct fwnode_handle *child_parent __free(fwnode_handle) = NULL;
+ struct fwnode_handle *next;
+
+- if (IS_ERR_OR_NULL(fwnode))
++ /*
++ * If this function is in a loop and the previous iteration returned
++ * an child from fwnode->secondary, then we need to use the secondary
++ * as parent rather than @fwnode.
++ */
++ if (child) {
++ child_parent = fwnode_get_parent(child);
++ parent = child_parent;
++ } else {
++ parent = fwnode;
++ }
++ if (IS_ERR_OR_NULL(parent))
+ return NULL;
+
+ /* Try to find a child in primary fwnode */
+- next = fwnode_call_ptr_op(fwnode, get_next_child_node, child);
++ next = fwnode_call_ptr_op(parent, get_next_child_node, child);
+ if (next)
+ return next;
+
+ /* When no more children in primary, continue with secondary */
+- return fwnode_call_ptr_op(fwnode->secondary, get_next_child_node, child);
++ return fwnode_get_next_child_node(parent->secondary, NULL);
+ }
+ EXPORT_SYMBOL_GPL(fwnode_get_next_child_node);
+
+diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
+index 55eeb6aac0ea3b..1333fae05ac5dd 100644
+--- a/drivers/block/zloop.c
++++ b/drivers/block/zloop.c
+@@ -478,7 +478,8 @@ static int zloop_finish_zone(struct zloop_device *zlo, unsigned int zone_no)
+ zone->cond == BLK_ZONE_COND_FULL)
+ goto unlock;
+
+- if (vfs_truncate(&zone->file->f_path, zlo->zone_size << SECTOR_SHIFT)) {
++ if (vfs_truncate(&zone->file->f_path,
++ zlo->zone_capacity << SECTOR_SHIFT)) {
+ set_bit(ZLOOP_ZONE_SEQ_ERROR, &zone->flags);
+ ret = -EIO;
+ goto unlock;
+diff --git a/drivers/block/zram/backend_deflate.c b/drivers/block/zram/backend_deflate.c
+index f92a52a720d1e2..b3f7d08b49d934 100644
+--- a/drivers/block/zram/backend_deflate.c
++++ b/drivers/block/zram/backend_deflate.c
+@@ -24,8 +24,16 @@ static int deflate_setup_params(struct zcomp_params *params)
+ {
+ if (params->level == ZCOMP_PARAM_NOT_SET)
+ params->level = Z_DEFAULT_COMPRESSION;
+- if (params->deflate.winbits == ZCOMP_PARAM_NOT_SET)
++ if (params->deflate.winbits == ZCOMP_PARAM_NOT_SET) {
+ params->deflate.winbits = DEFLATE_DEF_WINBITS;
++ } else {
++ s32 wb = params->deflate.winbits;
++
++ if ((wb < -15 || wb > -9) && (wb < 9 || wb > 15)) {
++ pr_err("invalid deflate winbits: %d\n", wb);
++ return -EINVAL;
++ }
++ }
+
+ return 0;
+ }
+diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
+index ace65c586072ba..f173f4c54b5906 100644
+--- a/drivers/block/zram/zram_drv.c
++++ b/drivers/block/zram/zram_drv.c
+@@ -1244,8 +1244,8 @@ static ssize_t writeback_store(struct device *dev,
+ const char *buf, size_t len)
+ {
+ struct zram *zram = dev_to_zram(dev);
+- u64 nr_pages = zram->disksize >> PAGE_SHIFT;
+- unsigned long lo = 0, hi = nr_pages;
++ u64 nr_pages;
++ unsigned long lo = 0, hi;
+ struct zram_pp_ctl *pp_ctl = NULL;
+ struct zram_wb_ctl *wb_ctl = NULL;
+ char *args, *param, *val;
+@@ -1259,6 +1259,9 @@ static ssize_t writeback_store(struct device *dev,
+ if (!zram->backing_dev)
+ return -ENODEV;
+
++ nr_pages = zram->disksize >> PAGE_SHIFT;
++ hi = nr_pages;
++
+ pp_ctl = init_pp_ctl();
+ if (!pp_ctl)
+ return -ENOMEM;
+@@ -1549,7 +1552,7 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
+ char *kbuf;
+ ssize_t index, written = 0;
+ struct zram *zram = file->private_data;
+- unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
++ unsigned long nr_pages;
+
+ kbuf = kvmalloc(count, GFP_KERNEL);
+ if (!kbuf)
+@@ -1561,6 +1564,8 @@ static ssize_t read_block_state(struct file *file, char __user *buf,
+ return -EINVAL;
+ }
+
++ nr_pages = zram->disksize >> PAGE_SHIFT;
++
+ for (index = *ppos; index < nr_pages; index++) {
+ int copied;
+
+@@ -2836,6 +2841,7 @@ static void zram_destroy_comps(struct zram *zram)
+ zram->comp_algs[prio] = NULL;
+
+ zram_comp_params_reset(zram);
++ comp_algorithm_set(zram, ZRAM_PRIMARY_COMP, default_compressor);
+ }
+
+ static void zram_reset_device(struct zram *zram)
+@@ -2853,8 +2859,6 @@ static void zram_reset_device(struct zram *zram)
+ zram_destroy_comps(zram);
+ memset(&zram->stats, 0, sizeof(zram->stats));
+ reset_bdev(zram);
+-
+- comp_algorithm_set(zram, ZRAM_PRIMARY_COMP, default_compressor);
+ }
+
+ static ssize_t disksize_store(struct device *dev, struct device_attribute *attr,
+diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
+index 7f54d2d2d13a04..03fa9409e3ee49 100644
+--- a/drivers/bluetooth/btrtl.c
++++ b/drivers/bluetooth/btrtl.c
+@@ -1343,19 +1343,6 @@ void btrtl_set_quirks(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev)
+ if (!btrtl_dev->ic_info)
+ return;
+
+- switch (btrtl_dev->project_id) {
+- case CHIP_ID_8761B:
+- /* RTL8761B/BU reports HCI version 5.1 but does not support
+- * the LE Extended Scan commands (Opcode 0x2042), causing
+- * repeated -EBUSY failures when BlueZ attempts extended
+- * scanning while a connection is active.
+- */
+- hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_SCAN);
+- break;
+- default:
+- break;
+- }
+-
+ switch (btrtl_dev->ic_info->lmp_subver) {
+ case RTL_ROM_LMP_8703B:
+ /* 8723CS reports two pages for local ext features,
+diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
+index 184e95c1625e57..91b22ddc9f5df0 100644
+--- a/drivers/bluetooth/btusb.c
++++ b/drivers/bluetooth/btusb.c
+@@ -67,6 +67,7 @@ static struct usb_driver btusb_driver;
+ #define BTUSB_INTEL_NO_WBS_SUPPORT BIT(26)
+ #define BTUSB_ACTIONS_SEMI BIT(27)
+ #define BTUSB_BARROT BIT(28)
++#define BTUSB_BROKEN_EXT_SCAN BIT(29)
+
+ static const struct usb_device_id btusb_table[] = {
+ /* Generic Bluetooth USB device */
+@@ -615,6 +616,10 @@ static const struct usb_device_id quirks_table[] = {
+ { USB_DEVICE(0x0489, 0xe130), .driver_info = BTUSB_REALTEK |
+ BTUSB_WIDEBAND_SPEECH },
+
++ /* Realtek 8761BU Bluetooth devices */
++ { USB_DEVICE(0x0bda, 0xa728), .driver_info = BTUSB_REALTEK |
++ BTUSB_BROKEN_EXT_SCAN },
++
+ /* Realtek Bluetooth devices */
+ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
+ .driver_info = BTUSB_REALTEK },
+@@ -850,6 +855,12 @@ static const struct usb_device_id quirks_table[] = {
+ { USB_DEVICE(0x37ad, 0x0600), .driver_info = BTUSB_REALTEK |
+ BTUSB_WIDEBAND_SPEECH },
+
++ /* Additional Realtek 8761CU Bluetooth devices */
++ { USB_DEVICE(0x0b05, 0x1bef), .driver_info = BTUSB_REALTEK |
++ BTUSB_WIDEBAND_SPEECH },
++ { USB_DEVICE(0x0b05, 0x1d70), .driver_info = BTUSB_REALTEK |
++ BTUSB_WIDEBAND_SPEECH },
++
+ /* Additional Realtek 8821AE Bluetooth devices */
+ { USB_DEVICE(0x0b05, 0x17dc), .driver_info = BTUSB_REALTEK },
+ { USB_DEVICE(0x13d3, 0x3414), .driver_info = BTUSB_REALTEK },
+@@ -4366,6 +4377,9 @@ static int btusb_probe(struct usb_interface *intf,
+ if (id->driver_info & BTUSB_INVALID_LE_STATES)
+ hci_set_quirk(hdev, HCI_QUIRK_BROKEN_LE_STATES);
+
++ if (id->driver_info & BTUSB_BROKEN_EXT_SCAN)
++ hci_set_quirk(hdev, HCI_QUIRK_BROKEN_EXT_SCAN);
++
+ if (id->driver_info & BTUSB_DIGIANSWER) {
+ data->cmdreq_type = USB_TYPE_VENDOR;
+ hci_set_quirk(hdev, HCI_QUIRK_RESET_ON_CLOSE);
+diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
+index 1a4fc3882fd2a7..cc419e1960de56 100644
+--- a/drivers/bluetooth/hci_bcm.c
++++ b/drivers/bluetooth/hci_bcm.c
+@@ -547,6 +547,7 @@ static int bcm_close(struct hci_uart *hu)
+ if (IS_ENABLED(CONFIG_PM) && bdev->irq_acquired) {
+ devm_free_irq(bdev->dev, bdev->irq, bdev);
+ device_init_wakeup(bdev->dev, false);
++ pm_runtime_dont_use_autosuspend(bdev->dev);
+ pm_runtime_disable(bdev->dev);
+ }
+
+diff --git a/drivers/bluetooth/hci_bcm4377.c b/drivers/bluetooth/hci_bcm4377.c
+index 925d0a6359453e..66d49b4715440a 100644
+--- a/drivers/bluetooth/hci_bcm4377.c
++++ b/drivers/bluetooth/hci_bcm4377.c
+@@ -2490,6 +2490,7 @@ static const struct bcm4377_hw bcm4377_hw_variants[] = {
+ .has_bar0_core2_window2 = true,
+ .broken_mws_transport_config = true,
+ .broken_le_coded = true,
++ .broken_le_ext_adv_report_phy = true,
+ .send_calibration = bcm4378_send_calibration,
+ .send_ptb = bcm4378_send_ptb,
+ },
+diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
+index 93cdde9818401a..a5e7e9b0ea7463 100644
+--- a/drivers/bluetooth/hci_h5.c
++++ b/drivers/bluetooth/hci_h5.c
+@@ -1023,8 +1023,10 @@ static void h5_btrtl_open(struct h5 *h5)
+
+ static void h5_btrtl_close(struct h5 *h5)
+ {
+- if (!test_bit(H5_WAKEUP_DISABLE, &h5->flags))
++ if (!test_bit(H5_WAKEUP_DISABLE, &h5->flags)) {
++ pm_runtime_dont_use_autosuspend(&h5->hu->serdev->dev);
+ pm_runtime_disable(&h5->hu->serdev->dev);
++ }
+
+ gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
+ gpiod_set_value_cansleep(h5->enable_gpio, 0);
+diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c
+index c31105b91e4767..1919547ff2a1ce 100644
+--- a/drivers/bluetooth/hci_intel.c
++++ b/drivers/bluetooth/hci_intel.c
+@@ -345,6 +345,7 @@ static int intel_set_power(struct hci_uart *hu, bool powered)
+ devm_free_irq(&idev->pdev->dev, idev->irq, idev);
+ device_wakeup_disable(&idev->pdev->dev);
+
++ pm_runtime_dont_use_autosuspend(&idev->pdev->dev);
+ pm_runtime_disable(&idev->pdev->dev);
+ }
+ }
+diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
+index 2ad42c3bbaac78..27644d2e53f8ca 100644
+--- a/drivers/bluetooth/hci_ldisc.c
++++ b/drivers/bluetooth/hci_ldisc.c
+@@ -451,7 +451,7 @@ static int hci_uart_setup(struct hci_dev *hdev)
+ if (IS_ERR(skb)) {
+ BT_ERR("%s: Reading local version information failed (%ld)",
+ hdev->name, PTR_ERR(skb));
+- return 0;
++ return PTR_ERR(skb);
+ }
+
+ if (skb->len != sizeof(*ver)) {
+diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
+index 593d9cefbbf925..d2eaf2f12aa278 100644
+--- a/drivers/bluetooth/hci_serdev.c
++++ b/drivers/bluetooth/hci_serdev.c
+@@ -221,7 +221,7 @@ static int hci_uart_setup(struct hci_dev *hdev)
+ if (IS_ERR(skb)) {
+ bt_dev_err(hdev, "Reading local version info failed (%ld)",
+ PTR_ERR(skb));
+- return 0;
++ return PTR_ERR(skb);
+ }
+
+ if (skb->len != sizeof(*ver))
+diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
+index d3d23024726215..a118a89a7779d6 100644
+--- a/drivers/cdx/cdx.c
++++ b/drivers/cdx/cdx.c
+@@ -738,7 +738,6 @@ static int cdx_create_res_attr(struct cdx_device *cdx_dev, int num)
+
+ sysfs_bin_attr_init(res_attr);
+
+- cdx_dev->res_attr[num] = res_attr;
+ sprintf(res_attr_name, "resource%d", num);
+
+ res_attr->mmap = cdx_mmap_resource;
+@@ -747,8 +746,12 @@ static int cdx_create_res_attr(struct cdx_device *cdx_dev, int num)
+ res_attr->size = cdx_resource_len(cdx_dev, num);
+ res_attr->private = (void *)(unsigned long)num;
+ ret = sysfs_create_bin_file(&cdx_dev->dev.kobj, res_attr);
+- if (ret)
++ if (ret) {
+ kfree(res_attr);
++ return ret;
++ }
++
++ cdx_dev->res_attr[num] = res_attr;
+
+ return ret;
+ }
+diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
+index 9a8c00586ab096..f5bfe54c01dc79 100644
+--- a/drivers/char/hw_random/stm32-rng.c
++++ b/drivers/char/hw_random/stm32-rng.c
+@@ -368,11 +368,6 @@ static int stm32_rng_init(struct hwrng *rng)
+ return 0;
+ }
+
+-static void stm32_rng_remove(struct platform_device *ofdev)
+-{
+- pm_runtime_disable(&ofdev->dev);
+-}
+-
+ static int __maybe_unused stm32_rng_runtime_suspend(struct device *dev)
+ {
+ struct stm32_rng_private *priv = dev_get_drvdata(dev);
+@@ -590,7 +585,9 @@ static int stm32_rng_probe(struct platform_device *ofdev)
+
+ pm_runtime_set_autosuspend_delay(dev, 100);
+ pm_runtime_use_autosuspend(dev);
+- pm_runtime_enable(dev);
++ ret = devm_pm_runtime_enable(dev);
++ if (ret)
++ return ret;
+
+ return devm_hwrng_register(dev, &priv->rng);
+ }
+@@ -602,7 +599,6 @@ static struct platform_driver stm32_rng_driver = {
+ .of_match_table = stm32_rng_match,
+ },
+ .probe = stm32_rng_probe,
+- .remove = stm32_rng_remove,
+ };
+
+ module_platform_driver(stm32_rng_driver);
+diff --git a/drivers/char/ipmi/ipmb_dev_int.c b/drivers/char/ipmi/ipmb_dev_int.c
+index 680ff15c30ab9a..e4c50d9ae3e135 100644
+--- a/drivers/char/ipmi/ipmb_dev_int.c
++++ b/drivers/char/ipmi/ipmb_dev_int.c
+@@ -141,13 +141,14 @@ static ssize_t ipmb_write(struct file *file, const char __user *buf,
+ u8 msg[MAX_MSG_LEN];
+ ssize_t ret;
+
+- if (count > sizeof(msg))
++ if (!count || count > sizeof(msg))
+ return -EINVAL;
+
+ if (copy_from_user(&msg, buf, count))
+ return -EFAULT;
+
+- if (count < msg[0])
++ if (msg[IPMB_MSG_LEN_IDX] < IPMB_REQUEST_LEN_MIN ||
++ count < (size_t)msg[IPMB_MSG_LEN_IDX] + 1)
+ return -EINVAL;
+
+ rq_sa = GET_7BIT_ADDR(msg[RQ_SA_8BIT_IDX]);
+diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
+index ab4c85f3d6fe8f..0330d8412a0e73 100644
+--- a/drivers/char/ipmi/ipmi_msghandler.c
++++ b/drivers/char/ipmi/ipmi_msghandler.c
+@@ -1391,6 +1391,7 @@ static void _ipmi_destroy_user(struct ipmi_user *user)
+ }
+ }
+ mutex_unlock(&intf->cmd_rcvrs_mutex);
++ synchronize_rcu();
+ while (rcvrs) {
+ rcvr = rcvrs;
+ rcvrs = rcvr->next;
+@@ -3740,6 +3741,7 @@ int ipmi_add_smi(struct module *owner,
+ sysfs_attr_init(&intf->maintenance_mode_devattr.attr);
+ rv = device_create_file(intf->si_dev, &intf->maintenance_mode_devattr);
+ if (rv) {
++ device_remove_file(intf->si_dev, &intf->nr_msgs_devattr);
+ device_remove_file(intf->si_dev, &intf->nr_users_devattr);
+ goto out_err_bmc_reg;
+ }
+@@ -3757,12 +3759,14 @@ int ipmi_add_smi(struct module *owner,
+ out_err_bmc_reg:
+ ipmi_bmc_unregister(intf);
+ out_err_started:
++ intf->in_shutdown = true;
+ if (intf->handlers->shutdown)
+ intf->handlers->shutdown(intf->send_info);
+ out_err:
+ list_del(&intf->link);
+ mutex_unlock(&ipmi_interfaces_mutex);
+ mutex_unlock(&smi_watchers_mutex);
++ cancel_work_sync(&intf->smi_work);
+ kref_put(&intf->refcount, intf_free);
+
+ return rv;
+diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
+index d44903b299294d..aa3673002f3aa6 100644
+--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
++++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
+@@ -182,8 +182,10 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
+ timeout);
+ if (rc > 0)
+ return 0;
+- /* At this point we know that the SINT pin is asserted, so we
+- * do not need to do i2c_nuvoton_check_status */
++
++ disable_irq(priv->irq);
++ if (rc < 0)
++ return rc;
+ } else {
+ unsigned long ten_msec, stop;
+ bool status_valid;
+diff --git a/drivers/clocksource/timer-nxp-pit.c b/drivers/clocksource/timer-nxp-pit.c
+index bc5157e2ba57c6..2f70d1d5e21b22 100644
+--- a/drivers/clocksource/timer-nxp-pit.c
++++ b/drivers/clocksource/timer-nxp-pit.c
+@@ -328,8 +328,10 @@ static int pit_timer_init(struct device_node *np)
+ if (pit_instances == max_pit_instances) {
+ ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "PIT timer:starting",
+ pit_clockevent_starting_cpu, NULL);
+- if (ret < 0)
++ if (ret < 0) {
++ pit_clockevent_per_cpu_exit(pit, pit_instances);
+ goto out_pit_clocksource_unregister;
++ }
+ }
+
+ return 0;
+diff --git a/drivers/clocksource/timer-sun4i.c b/drivers/clocksource/timer-sun4i.c
+index 7bdcc60ad43cb5..c2d04ab7cf2d38 100644
+--- a/drivers/clocksource/timer-sun4i.c
++++ b/drivers/clocksource/timer-sun4i.c
+@@ -208,7 +208,7 @@ static int __init sun4i_timer_init(struct device_node *node)
+ sun4i_timer_clear_interrupt(timer_of_base(&to));
+
+ clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
+- TIMER_SYNC_TICKS, 0xffffffff);
++ TIMER_SYNC_TICKS + 1, 0xffffffff);
+
+ /* Enable timer0 interrupt */
+ val = readl(timer_of_base(&to) + TIMER_IRQ_EN_REG);
+diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c
+index 638e5bf72185a7..3f64f266e695b6 100644
+--- a/drivers/cpufreq/apple-soc-cpufreq.c
++++ b/drivers/cpufreq/apple-soc-cpufreq.c
+@@ -249,21 +249,19 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
+ return -ENODEV;
+ }
+
+- ret = dev_pm_opp_of_add_table(cpu_dev);
+- if (ret < 0) {
+- dev_err(cpu_dev, "%s: failed to add OPP table: %d\n", __func__, ret);
+- return ret;
+- }
++ priv = kzalloc_obj(*priv);
++ if (!priv)
++ return -ENOMEM;
+
+ ret = apple_soc_cpufreq_find_cluster(policy, ®_base, &info);
+ if (ret) {
+ dev_err(cpu_dev, "%s: failed to get cluster info: %d\n", __func__, ret);
+- return ret;
++ goto out_free_priv;
+ }
+
+- ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus);
+- if (ret) {
+- dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", __func__, ret);
++ ret = dev_pm_opp_of_cpumask_add_table(policy->cpus);
++ if (ret < 0) {
++ dev_err(cpu_dev, "%s: failed to add OPP table: %d\n", __func__, ret);
+ goto out_iounmap;
+ }
+
+@@ -271,19 +269,13 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
+ if (ret <= 0) {
+ dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n");
+ ret = -EPROBE_DEFER;
+- goto out_free_opp;
+- }
+-
+- priv = kzalloc_obj(*priv);
+- if (!priv) {
+- ret = -ENOMEM;
+- goto out_free_opp;
++ goto out_free_table;
+ }
+
+ ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
+ if (ret) {
+ dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
+- goto out_free_priv;
++ goto out_free_table;
+ }
+
+ /* Get OPP levels (p-state indexes) and stash them in driver_data */
+@@ -318,12 +310,12 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
+
+ out_free_cpufreq_table:
+ dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
+-out_free_priv:
+- kfree(priv);
+-out_free_opp:
+- dev_pm_opp_remove_all_dynamic(cpu_dev);
++out_free_table:
++ dev_pm_opp_of_cpumask_remove_table(policy->cpus);
+ out_iounmap:
+ iounmap(reg_base);
++out_free_priv:
++ kfree(priv);
+ return ret;
+ }
+
+@@ -332,7 +324,7 @@ static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy)
+ struct apple_cpu_priv *priv = policy->driver_data;
+
+ dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
+- dev_pm_opp_remove_all_dynamic(priv->cpu_dev);
++ dev_pm_opp_of_cpumask_remove_table(policy->cpus);
+ iounmap(priv->reg_base);
+ kfree(priv);
+ }
+diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
+index 6fe0e972952af3..80893844353ca1 100644
+--- a/drivers/cpufreq/cppc_cpufreq.c
++++ b/drivers/cpufreq/cppc_cpufreq.c
+@@ -836,7 +836,7 @@ out_invalid_counters:
+ * value first as some platforms may update the actual delivered perf
+ * there; if failed, resort to the cached desired perf.
+ */
+- if (cppc_get_desired_perf(cpu, &delivered_perf))
++ if (cppc_get_desired_perf(cpu, &delivered_perf) || !delivered_perf)
+ delivered_perf = cpu_data->perf_ctrls.desired_perf;
+
+ return cppc_perf_to_khz(&cpu_data->perf_caps, delivered_perf);
+diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
+index 9da9dd6585dfc6..4dc34c5bc0f6c4 100644
+--- a/drivers/crypto/atmel-ecc.c
++++ b/drivers/crypto/atmel-ecc.c
+@@ -27,15 +27,14 @@ static struct atmel_ecc_driver_data driver_data;
+
+ /**
+ * struct atmel_ecdh_ctx - transformation context
+- * @client : pointer to i2c client device
+- * @fallback : used for unsupported curves or when user wants to use its own
+- * private key.
+- * @public_key : generated when calling set_secret(). It's the responsibility
+- * of the user to not call set_secret() while
+- * generate_public_key() or compute_shared_secret() are in flight.
+- * @curve_id : elliptic curve id
+- * @do_fallback: true when the device doesn't support the curve or when the user
+- * wants to use its own private key.
++ * @client: I2C client device
++ * @fallback: ECDH fallback used for caller-provided private keys
++ * @public_key: cached public key for the device-generated private key
++ * @curve_id: elliptic curve id
++ * @do_fallback: true when ECDH operations should use @fallback
++ *
++ * The caller must not invoke set_secret() while generate_public_key()
++ * or compute_shared_secret() are in flight.
+ */
+ struct atmel_ecdh_ctx {
+ struct i2c_client *client;
+@@ -55,7 +54,7 @@ static void atmel_ecdh_done(struct atmel_i2c_work_data *work_data, void *areq,
+ if (status)
+ goto free_work_data;
+
+- /* might want less than we've got */
++ /* copy only as much as requested, capped at 32 bytes */
+ n_sz = min(ATMEL_ECC_NIST_P256_N_SIZE, req->dst_len);
+
+ /* copy the shared secret */
+@@ -64,15 +63,15 @@ static void atmel_ecdh_done(struct atmel_i2c_work_data *work_data, void *areq,
+ if (copied != n_sz)
+ status = -EINVAL;
+
+- /* fall through */
+ free_work_data:
+ kfree_sensitive(work_data);
+ kpp_request_complete(req, status);
+ }
+
+ /*
+- * A random private key is generated and stored in the device. The device
+- * returns the pair public key.
++ * If no private key is provided, generate one in the device and cache
++ * the corresponding public key. The generated private key never leaves
++ * the device.
+ */
+ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,
+ unsigned int len)
+@@ -83,10 +82,9 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,
+ struct ecdh params;
+ int ret = -ENOMEM;
+
+- /* free the old public key, if any */
+ kfree(ctx->public_key);
+- /* make sure you don't free the old public key twice */
+ ctx->public_key = NULL;
++ ctx->do_fallback = false;
+
+ if (crypto_ecdh_decode_key(buf, len, ¶ms) < 0) {
+ dev_err(&ctx->client->dev, "crypto_ecdh_decode_key failed\n");
+@@ -94,33 +92,25 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,
+ }
+
+ if (params.key_size) {
+- /* fallback to ecdh software implementation */
+- ctx->do_fallback = true;
+- return crypto_kpp_set_secret(ctx->fallback, buf, len);
++ ret = crypto_kpp_set_secret(ctx->fallback, buf, len);
++ ctx->do_fallback = !ret;
++ return ret;
+ }
+
+ cmd = kmalloc_obj(*cmd);
+ if (!cmd)
+ return -ENOMEM;
+
+- /*
+- * The device only supports NIST P256 ECC keys. The public key size will
+- * always be the same. Use a macro for the key size to avoid unnecessary
+- * computations.
+- */
+ public_key = kmalloc(ATMEL_ECC_PUBKEY_SIZE, GFP_KERNEL);
+ if (!public_key)
+ goto free_cmd;
+
+- ctx->do_fallback = false;
+-
+ atmel_i2c_init_genkey_cmd(cmd, DATA_SLOT_2);
+
+ ret = atmel_i2c_send_receive(ctx->client, cmd);
+ if (ret)
+ goto free_public_key;
+
+- /* save the public key */
+ memcpy(public_key, &cmd->data[RSP_DATA_IDX], ATMEL_ECC_PUBKEY_SIZE);
+ ctx->public_key = public_key;
+
+@@ -149,7 +139,7 @@ static int atmel_ecdh_generate_public_key(struct kpp_request *req)
+ if (!ctx->public_key)
+ return -EINVAL;
+
+- /* might want less than we've got */
++ /* copy only as much as requested, capped at 64 bytes */
+ nbytes = min(ATMEL_ECC_PUBKEY_SIZE, req->dst_len);
+
+ /* public key was saved at private key generation */
+@@ -175,7 +165,7 @@ static int atmel_ecdh_compute_shared_secret(struct kpp_request *req)
+ return crypto_kpp_compute_shared_secret(req);
+ }
+
+- /* must have exactly two points to be on the curve */
++ /* A P-256 public key must contain two 32-byte coordinates */
+ if (req->src_len != ATMEL_ECC_PUBKEY_SIZE)
+ return -EINVAL;
+
+diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
+index 904d9413ba1826..cdfe00464fa36c 100644
+--- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
++++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
+@@ -1058,13 +1058,17 @@ static void iaa_desc_complete(struct idxd_desc *idxd_desc,
+ pr_warn("%s: falling back to deflate-generic decompress, "
+ "analytics error code %x\n", __func__,
+ idxd_desc->iax_completion->error_code);
++ dma_unmap_sg(dev, ctx->req->dst, sg_nents(ctx->req->dst),
++ DMA_FROM_DEVICE);
++ dma_unmap_sg(dev, ctx->req->src, 1, DMA_TO_DEVICE);
++
+ ret = deflate_generic_decompress(ctx->req);
+ if (ret) {
+ dev_dbg(dev, "%s: deflate-generic failed ret=%d\n",
+ __func__, ret);
+ err = -EIO;
+- goto err;
+ }
++ goto out;
+ } else {
+ err = -EIO;
+ goto err;
+@@ -1447,19 +1451,9 @@ static int iaa_decompress(struct crypto_tfm *tfm, struct acomp_req *req,
+ ret = check_completion(dev, idxd_desc->iax_completion, false, false);
+ if (ret) {
+ dev_dbg(dev, "%s: check_completion failed ret=%d\n", __func__, ret);
+- if (idxd_desc->iax_completion->status == IAA_ANALYTICS_ERROR) {
+- pr_warn("%s: falling back to deflate-generic decompress, "
+- "analytics error code %x\n", __func__,
+- idxd_desc->iax_completion->error_code);
+- ret = deflate_generic_decompress(req);
+- if (ret) {
+- dev_dbg(dev, "%s: deflate-generic failed ret=%d\n",
+- __func__, ret);
+- goto err;
+- }
+- } else {
+- goto err;
+- }
++ if (idxd_desc->iax_completion->status == IAA_ANALYTICS_ERROR)
++ ret = -EAGAIN;
++ goto err;
+ } else {
+ req->dlen = idxd_desc->iax_completion->output_size;
+ }
+@@ -1647,13 +1641,16 @@ static int iaa_comp_adecompress(struct acomp_req *req)
+ if (ret == -EINPROGRESS)
+ return ret;
+
+- if (ret != 0)
++ if (ret != 0 && ret != -EAGAIN)
+ dev_dbg(dev, "asynchronous decompress failed ret=%d\n", ret);
+
+ dma_unmap_sg(dev, req->dst, 1, DMA_FROM_DEVICE);
+ dma_unmap_sg(dev, req->src, 1, DMA_TO_DEVICE);
+ iaa_wq_put(wq);
+
++ if (ret == -EAGAIN)
++ ret = deflate_generic_decompress(req);
++
+ return ret;
+ }
+
+diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
+index 85185af46b72d8..738a89863ee896 100644
+--- a/drivers/cxl/core/features.c
++++ b/drivers/cxl/core/features.c
+@@ -649,7 +649,13 @@ static void *cxlctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
+ struct cxl_memdev *cxlmd = fwctl_to_memdev(fwctl_dev);
+ struct cxl_features_state *cxlfs = to_cxlfs(cxlmd->cxlds);
+ const struct fwctl_rpc_cxl *rpc_in = in;
+- u16 opcode = rpc_in->opcode;
++ u16 opcode;
++
++ if (in_len < sizeof(rpc_in->hdr) ||
++ rpc_in->op_size > in_len - sizeof(rpc_in->hdr))
++ return ERR_PTR(-EINVAL);
++
++ opcode = rpc_in->opcode;
+
+ if (!cxlctl_validate_hw_command(cxlfs, rpc_in, scope, opcode))
+ return ERR_PTR(-EINVAL);
+diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
+index 7c6c5b7450a54a..1fa1f78565e310 100644
+--- a/drivers/cxl/core/mbox.c
++++ b/drivers/cxl/core/mbox.c
+@@ -11,7 +11,6 @@
+
+ #include "core.h"
+ #include "trace.h"
+-#include "mce.h"
+
+ static bool cxl_raw_allow_all;
+
+@@ -1526,7 +1525,6 @@ struct cxl_memdev_state *cxl_memdev_state_create(struct device *dev, u64 serial,
+ u16 dvsec)
+ {
+ struct cxl_memdev_state *mds;
+- int rc;
+
+ mds = devm_cxl_dev_state_create(dev, CXL_DEVTYPE_CLASSMEM, serial,
+ dvsec, struct cxl_memdev_state, cxlds,
+@@ -1538,12 +1536,6 @@ struct cxl_memdev_state *cxl_memdev_state_create(struct device *dev, u64 serial,
+
+ mutex_init(&mds->event.log_lock);
+
+- rc = devm_cxl_register_mce_notifier(dev, &mds->mce_notifier);
+- if (rc == -EOPNOTSUPP)
+- dev_warn(dev, "CXL MCE unsupported\n");
+- else if (rc)
+- return ERR_PTR(rc);
+-
+ return mds;
+ }
+ EXPORT_SYMBOL_NS_GPL(cxl_memdev_state_create, "CXL");
+diff --git a/drivers/cxl/core/mce.c b/drivers/cxl/core/mce.c
+index ff8d078c6ca1e9..65fed913b22179 100644
+--- a/drivers/cxl/core/mce.c
++++ b/drivers/cxl/core/mce.c
+@@ -4,16 +4,16 @@
+ #include
+ #include
+ #include
+-#include
++#include
++#include "core.h"
+ #include "mce.h"
+
+ static int cxl_handle_mce(struct notifier_block *nb, unsigned long val,
+ void *data)
+ {
+- struct cxl_memdev_state *mds = container_of(nb, struct cxl_memdev_state,
+- mce_notifier);
+- struct cxl_memdev *cxlmd = mds->cxlds.cxlmd;
+- struct cxl_port *endpoint = cxlmd->endpoint;
++ struct cxl_region *cxlr = container_of(nb, struct cxl_region,
++ mce_notifier);
++ struct cxl_region_params *p = &cxlr->params;
+ struct mce *mce = data;
+ u64 spa, spa_alias;
+ unsigned long pfn;
+@@ -21,26 +21,25 @@ static int cxl_handle_mce(struct notifier_block *nb, unsigned long val,
+ if (!mce || !mce_usable_address(mce))
+ return NOTIFY_DONE;
+
+- if (!endpoint)
+- return NOTIFY_DONE;
+-
+ spa = mce->addr & MCI_ADDR_PHYSADDR;
+
+- pfn = spa >> PAGE_SHIFT;
+- if (!pfn_valid(pfn))
++ if (!cxl_resource_contains_addr(p->res, spa))
+ return NOTIFY_DONE;
+
+- spa_alias = cxl_port_get_spa_cache_alias(endpoint, spa);
+- if (spa_alias == ~0ULL)
+- return NOTIFY_DONE;
++ if (spa >= p->res->start + p->cache_size)
++ spa_alias = spa - p->cache_size;
++ else
++ spa_alias = spa + p->cache_size;
+
+ pfn = spa_alias >> PAGE_SHIFT;
++ if (!pfn_valid(pfn))
++ return NOTIFY_DONE;
+
+ /*
+ * Take down the aliased memory page. The original memory page flagged
+ * by the MCE will be taken cared of by the standard MCE handler.
+ */
+- dev_emerg(mds->cxlds.dev, "Offlining aliased SPA address0: %#llx\n",
++ dev_emerg(&cxlr->dev, "Offlining aliased SPA address0: %#llx\n",
+ spa_alias);
+ if (!memory_failure(pfn, 0))
+ set_mce_nospec(pfn);
+diff --git a/drivers/cxl/core/pmem.c b/drivers/cxl/core/pmem.c
+index 68462e38a977b1..5a3bb7e8a1f14a 100644
+--- a/drivers/cxl/core/pmem.c
++++ b/drivers/cxl/core/pmem.c
+@@ -219,12 +219,14 @@ static struct cxl_nvdimm *cxl_nvdimm_alloc(struct cxl_nvdimm_bridge *cxl_nvb,
+ dev->bus = &cxl_bus_type;
+ dev->type = &cxl_nvdimm_type;
+ /*
+- * A "%llx" string is 17-bytes vs dimm_id that is max
+- * NVDIMM_KEY_DESC_LEN
++ * dev_id is the nvdimm dimm_id used for security key lookup.
++ * It must match id_show(), which emits the CXL serial as an
++ * unsigned decimal. A u64 decimal string is at most 20 digits
++ * plus NUL.
+ */
+- BUILD_BUG_ON(sizeof(cxl_nvd->dev_id) < 17 ||
++ BUILD_BUG_ON(sizeof(cxl_nvd->dev_id) < 21 ||
+ sizeof(cxl_nvd->dev_id) > NVDIMM_KEY_DESC_LEN);
+- sprintf(cxl_nvd->dev_id, "%llx", cxlmd->cxlds->serial);
++ sprintf(cxl_nvd->dev_id, "%llu", cxlmd->cxlds->serial);
+
+ return cxl_nvd;
+ }
+diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
+index 99fb00949c2fac..bc74d4848132ec 100644
+--- a/drivers/cxl/core/ras.c
++++ b/drivers/cxl/core/ras.c
+@@ -137,7 +137,6 @@ int cxl_ras_init(void)
+ void cxl_ras_exit(void)
+ {
+ cxl_cper_unregister_prot_err_work(&cxl_cper_prot_err_work);
+- cancel_work_sync(&cxl_cper_prot_err_work);
+ }
+
+ static void cxl_dport_map_ras(struct cxl_dport *dport)
+diff --git a/drivers/cxl/core/ras_rch.c b/drivers/cxl/core/ras_rch.c
+index 0a8b3b9b638841..e0e01aa5eba6cd 100644
+--- a/drivers/cxl/core/ras_rch.c
++++ b/drivers/cxl/core/ras_rch.c
+@@ -58,13 +58,28 @@ void cxl_disable_rch_root_ints(struct cxl_dport *dport)
+ static bool cxl_rch_get_aer_info(void __iomem *aer_base,
+ struct aer_capability_regs *aer_regs)
+ {
+- int read_cnt = sizeof(struct aer_capability_regs) / sizeof(u32);
++ /*
++ * Bound the copy to the physically-defined AER registers (header
++ * through the 16-byte Header Log). struct aer_capability_regs is a
++ * software layout whose embedded struct pcie_tlp_log is larger than
++ * the on-wire AER capability; copying sizeof(*aer_regs) would
++ * over-read the RCRB-mapped MMIO block.
++ */
++ int read_cnt = (PCI_ERR_HEADER_LOG + 16) / sizeof(u32);
+ u32 *aer_regs_buf = (u32 *)aer_regs;
+ int n;
+
+ if (!aer_base)
+ return false;
+
++ /*
++ * Zero the destination so the software-only tail fields
++ * (e.g. header_log.header_len) are deterministic rather than
++ * left as uninitialized stack, which could drive a bogus loop
++ * length in pcie_print_tlp_log().
++ */
++ memset(aer_regs, 0, sizeof(*aer_regs));
++
+ /* Use readl() to guarantee 32-bit accesses */
+ for (n = 0; n < read_cnt; n++)
+ aer_regs_buf[n] = readl(aer_base + n * sizeof(u32));
+@@ -79,11 +94,11 @@ static bool cxl_rch_get_aer_info(void __iomem *aer_base,
+ static bool cxl_rch_get_aer_severity(struct aer_capability_regs *aer_regs,
+ int *severity)
+ {
+- if (aer_regs->uncor_status & ~aer_regs->uncor_mask) {
+- if (aer_regs->uncor_status & PCI_ERR_ROOT_FATAL_RCV)
+- *severity = AER_FATAL;
+- else
+- *severity = AER_NONFATAL;
++ u32 uncor_status = aer_regs->uncor_status & ~aer_regs->uncor_mask;
++
++ if (uncor_status) {
++ *severity = (uncor_status & aer_regs->uncor_severity) ?
++ AER_FATAL : AER_NONFATAL;
+ return true;
+ }
+
+diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
+index 1e211542b6b641..578622240401d4 100644
+--- a/drivers/cxl/core/region.c
++++ b/drivers/cxl/core/region.c
+@@ -15,6 +15,7 @@
+ #include
+ #include
+ #include "core.h"
++#include "mce.h"
+
+ /**
+ * DOC: cxl core region
+@@ -3859,34 +3860,6 @@ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled)
+ }
+ EXPORT_SYMBOL_NS_GPL(cxl_add_to_region, "CXL");
+
+-u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa)
+-{
+- struct cxl_region_ref *iter;
+- unsigned long index;
+-
+- if (!endpoint)
+- return ~0ULL;
+-
+- guard(rwsem_write)(&cxl_rwsem.region);
+-
+- xa_for_each(&endpoint->regions, index, iter) {
+- struct cxl_region_params *p = &iter->region->params;
+-
+- if (cxl_resource_contains_addr(p->res, spa)) {
+- if (!p->cache_size)
+- return ~0ULL;
+-
+- if (spa >= p->res->start + p->cache_size)
+- return spa - p->cache_size;
+-
+- return spa + p->cache_size;
+- }
+- }
+-
+- return ~0ULL;
+-}
+-EXPORT_SYMBOL_NS_GPL(cxl_port_get_spa_cache_alias, "CXL");
+-
+ static int is_system_ram(struct resource *res, void *arg)
+ {
+ struct cxl_region *cxlr = arg;
+@@ -4217,6 +4190,20 @@ static int cxl_region_probe(struct device *dev)
+ if (rc)
+ return rc;
+
++ /*
++ * Regions fronted by an extended linear cache need the MCE notifier to
++ * offline the aliased page on a memory error.
++ */
++ if (p->cache_size) {
++ rc = devm_cxl_register_mce_notifier(&cxlr->dev,
++ &cxlr->mce_notifier);
++ if (rc == -EOPNOTSUPP)
++ dev_warn(&cxlr->dev,
++ "CONFIG_CXL_MCE disabled, MCE notifier not registered\n");
++ else if (rc)
++ return rc;
++ }
++
+ rc = cxl_region_setup_poison(cxlr);
+ if (rc)
+ return rc;
+diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
+index c0e5308e4d1b84..cab8ce39f46533 100644
+--- a/drivers/cxl/cxl.h
++++ b/drivers/cxl/cxl.h
+@@ -478,6 +478,7 @@ struct cxl_region_params {
+ * @coord: QoS access coordinates for the region
+ * @node_notifier: notifier for setting the access coordinates to node
+ * @adist_notifier: notifier for calculating the abstract distance of node
++ * @mce_notifier: notifier for MCE
+ */
+ struct cxl_region {
+ struct device dev;
+@@ -493,6 +494,7 @@ struct cxl_region {
+ struct access_coordinate coord[ACCESS_COORDINATE_MAX];
+ struct notifier_block node_notifier;
+ struct notifier_block adist_notifier;
++ struct notifier_block mce_notifier;
+ };
+
+ struct cxl_nvdimm_bridge {
+@@ -503,7 +505,8 @@ struct cxl_nvdimm_bridge {
+ struct nvdimm_bus_descriptor nd_desc;
+ };
+
+-#define CXL_DEV_ID_LEN 19
++/* Holds a u64 serial as a decimal string: up to 20 digits + NUL */
++#define CXL_DEV_ID_LEN 21
+
+ enum {
+ CXL_NVD_F_INVALIDATED = 0,
+@@ -870,7 +873,6 @@ bool is_cxl_pmem_region(struct device *dev);
+ struct cxl_pmem_region *to_cxl_pmem_region(struct device *dev);
+ int cxl_add_to_region(struct cxl_endpoint_decoder *cxled);
+ struct cxl_dax_region *to_cxl_dax_region(struct device *dev);
+-u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint, u64 spa);
+ bool cxl_region_contains_resource(const struct resource *res);
+ #else
+ static inline bool is_cxl_pmem_region(struct device *dev)
+@@ -889,11 +891,6 @@ static inline struct cxl_dax_region *to_cxl_dax_region(struct device *dev)
+ {
+ return NULL;
+ }
+-static inline u64 cxl_port_get_spa_cache_alias(struct cxl_port *endpoint,
+- u64 spa)
+-{
+- return 0;
+-}
+ static inline bool cxl_region_contains_resource(const struct resource *res)
+ {
+ return false;
+diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
+index ed419d0c59f2f1..c288e624c1f68d 100644
+--- a/drivers/cxl/cxlmem.h
++++ b/drivers/cxl/cxlmem.h
+@@ -431,7 +431,6 @@ static inline struct cxl_dev_state *mbox_to_cxlds(struct cxl_mailbox *cxl_mbox)
+ * @poison: poison driver state info
+ * @security: security driver state info
+ * @fw: firmware upload / activation state
+- * @mce_notifier: MCE notifier
+ *
+ * See CXL 3.0 8.2.9.8.2 Capacity Configuration and Label Storage for
+ * details on capacity parameters.
+@@ -451,7 +450,6 @@ struct cxl_memdev_state {
+ struct cxl_poison_state poison;
+ struct cxl_security_state security;
+ struct cxl_fw_state fw;
+- struct notifier_block mce_notifier;
+ };
+
+ static inline struct cxl_memdev_state *
+diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
+index 267c679b0b3c20..7c6faee7f85ed5 100644
+--- a/drivers/cxl/pci.c
++++ b/drivers/cxl/pci.c
+@@ -1083,7 +1083,6 @@ static int __init cxl_pci_driver_init(void)
+ static void __exit cxl_pci_driver_exit(void)
+ {
+ cxl_cper_unregister_work(&cxl_cper_work);
+- cancel_work_sync(&cxl_cper_work);
+ pci_unregister_driver(&cxl_pci_driver);
+ }
+
+diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
+index 261dff7ced9f15..a9f50281875d83 100644
+--- a/drivers/cxl/pmem.c
++++ b/drivers/cxl/pmem.c
+@@ -52,7 +52,7 @@ static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *
+ struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm);
+ struct cxl_dev_state *cxlds = cxl_nvd->cxlmd->cxlds;
+
+- return sysfs_emit(buf, "%lld\n", cxlds->serial);
++ return sysfs_emit(buf, "%llu\n", cxlds->serial);
+ }
+ static DEVICE_ATTR_RO(id);
+
+diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
+index 44badfd11e1b0a..070c025ee21549 100644
+--- a/drivers/fpga/altera-cvp.c
++++ b/drivers/fpga/altera-cvp.c
+@@ -16,6 +16,7 @@
+ #include
+ #include
+ #include
++#include
+
+ #define CVP_BAR 0 /* BAR used for data transfer in memory mode */
+ #define CVP_DUMMY_WR 244 /* dummy writes to clear CvP state machine */
+@@ -261,7 +262,7 @@ static int altera_cvp_v2_wait_for_credit(struct fpga_manager *mgr,
+ static int altera_cvp_send_block(struct altera_cvp_conf *conf,
+ const u32 *data, size_t len)
+ {
+- u32 mask, words = len / sizeof(u32);
++ u32 words = len / sizeof(u32);
+ int i, remainder;
+
+ for (i = 0; i < words; i++)
+@@ -270,9 +271,10 @@ static int altera_cvp_send_block(struct altera_cvp_conf *conf,
+ /* write up to 3 trailing bytes, if any */
+ remainder = len % sizeof(u32);
+ if (remainder) {
+- mask = BIT(remainder * 8) - 1;
+- if (mask)
+- conf->write_data(conf, *data & mask);
++ u32 word = 0;
++
++ memcpy(&word, data, remainder);
++ conf->write_data(conf, word);
+ }
+
+ return 0;
+diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
+index 0a295ccf1644a8..b8ec2e6f615fad 100644
+--- a/drivers/fpga/stratix10-soc.c
++++ b/drivers/fpga/stratix10-soc.c
+@@ -195,20 +195,18 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
+ ret = s10_svc_send_msg(priv, COMMAND_RECONFIG,
+ &ctype, sizeof(ctype));
+ if (ret < 0)
+- goto init_done;
++ goto init_error;
+
+- ret = wait_for_completion_timeout(
+- &priv->status_return_completion, S10_RECONFIG_TIMEOUT);
+- if (!ret) {
++ if (!wait_for_completion_timeout(&priv->status_return_completion,
++ S10_RECONFIG_TIMEOUT)) {
+ dev_err(dev, "timeout waiting for RECONFIG_REQUEST\n");
+ ret = -ETIMEDOUT;
+- goto init_done;
++ goto init_error;
+ }
+
+- ret = 0;
+ if (!test_and_clear_bit(SVC_STATUS_OK, &priv->status)) {
+ ret = -ETIMEDOUT;
+- goto init_done;
++ goto init_error;
+ }
+
+ /* Allocate buffers from the service layer's pool. */
+@@ -217,14 +215,16 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
+ if (IS_ERR(kbuf)) {
+ s10_free_buffers(mgr);
+ ret = PTR_ERR(kbuf);
+- goto init_done;
++ goto init_error;
+ }
+
+ priv->svc_bufs[i].buf = kbuf;
+ priv->svc_bufs[i].lock = 0;
+ }
+
+-init_done:
++ return 0;
++
++init_error:
+ stratix10_svc_done(priv->chan);
+ return ret;
+ }
+@@ -342,6 +342,9 @@ static int s10_ops_write(struct fpga_manager *mgr, const char *buf,
+ if (!s10_free_buffers(mgr))
+ dev_err(dev, "%s not all buffers were freed\n", __func__);
+
++ if (ret < 0)
++ stratix10_svc_done(priv->chan);
++
+ return ret;
+ }
+
+diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+index 941c1a31282498..9320e49e44289b 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+@@ -7846,6 +7846,39 @@ amdgpu_dm_connector_poll(struct amdgpu_dm_connector *aconnector, bool force)
+ return status;
+ }
+
++/*
++ * Apple Studio Display exposes two SST DP links for a 2x1 tiled panel.
++ * The primary tile advertises the full 5120x2880 mode (with DSC on the
++ * bandwidth-sufficient link) while the secondary carries a per-tile
++ * 2560x2880 timing on a insufficient bandwidth link. Hide the secondary
++ * connector from userspace so compositors configure a single 5K stream
++ * on the primary link only.
++ */
++static bool amdgpu_dm_hide_secondary_tile_from_userspace(struct drm_connector *connector)
++{
++ struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
++
++ if (!aconnector->dc_sink)
++ return false;
++
++ if (!aconnector->dc_sink->edid_caps.panel_patch.disable_second_tile)
++ return false;
++
++ drm_edid_connector_update(connector, aconnector->drm_edid);
++
++ if (!connector->has_tile)
++ return false;
++
++ if (!connector->tile_h_loc && !connector->tile_v_loc)
++ return false;
++
++ drm_dbg_kms(connector->dev,
++ "[CONNECTOR:%d:%s] hiding secondary Apple Studio Display tile from userspace\n",
++ connector->base.id, connector->name);
++
++ return true;
++}
++
+ /**
+ * amdgpu_dm_connector_detect() - Detect whether a DRM connector is connected to a display
+ *
+@@ -7889,6 +7922,9 @@ amdgpu_dm_connector_detect(struct drm_connector *connector, bool force)
+ (!aconnector->dc_sink || aconnector->dc_sink->edid_caps.analog))
+ return amdgpu_dm_connector_poll(aconnector, force);
+
++ if (amdgpu_dm_hide_secondary_tile_from_userspace(connector))
++ return connector_status_disconnected;
++
+ return (aconnector->dc_sink ? connector_status_connected :
+ connector_status_disconnected);
+ }
+@@ -9080,6 +9116,47 @@ static void amdgpu_dm_connector_add_common_modes(struct drm_encoder *encoder,
+ }
+ }
+
++/*
++ * The Apple Studio Display primary tile advertises both the full 5120x2880
++ * mode and the per-tile 2560x2880 timing. As the secondary tile is hidden from
++ * userspace (see amdgpu_dm_hide_secondary_tile_from_userspace()), drop the
++ * per-tile timing from the primary connector so compositors only pick the full
++ * 5K mode.
++ */
++static void amdgpu_dm_prune_primary_tile_modes(struct drm_connector *connector)
++{
++ struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
++ struct drm_display_mode *mode, *t;
++
++ if (!aconnector->dc_sink)
++ return;
++
++ if (!aconnector->dc_sink->edid_caps.panel_patch.disable_second_tile)
++ return;
++
++ if (!connector->has_tile)
++ return;
++
++ /* Only prune the per-tile timing from the primary tile. */
++ if (connector->tile_h_loc || connector->tile_v_loc)
++ return;
++
++ list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
++ if (mode->hdisplay != connector->tile_h_size ||
++ mode->vdisplay != connector->tile_v_size)
++ continue;
++
++ drm_dbg_kms(connector->dev,
++ "[CONNECTOR:%d:%s] pruning per-tile %dx%d timing from primary Apple Studio Display tile\n",
++ connector->base.id, connector->name,
++ mode->hdisplay, mode->vdisplay);
++
++ list_del(&mode->head);
++ drm_mode_destroy(connector->dev, mode);
++ aconnector->num_modes--;
++ }
++}
++
+ static void amdgpu_set_panel_orientation(struct drm_connector *connector)
+ {
+ struct drm_encoder *encoder;
+@@ -9122,6 +9199,8 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
+ amdgpu_dm_connector->num_modes =
+ drm_edid_connector_add_modes(connector);
+
++ amdgpu_dm_prune_primary_tile_modes(connector);
++
+ /* sorting the probed modes before calling function
+ * amdgpu_dm_get_native_mode() since EDID can have
+ * more than one preferred mode. The modes that are
+diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+index 4c164ae4a4f9c3..8304e8897a3eda 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+@@ -535,15 +535,27 @@ static bool enable_assr(void *handle, struct dc_link *link)
+ static void update_config(void *handle, struct cp_psp_stream_config *config)
+ {
+ struct hdcp_workqueue *hdcp_work = handle;
+- struct amdgpu_dm_connector *aconnector = config->dm_stream_ctx;
+- int link_index = aconnector->dc_link->link_index;
+- unsigned int conn_index = aconnector->base.index;
+- struct mod_hdcp_display *display = &hdcp_work[link_index].display;
+- struct mod_hdcp_link *link = &hdcp_work[link_index].link;
+- struct hdcp_workqueue *hdcp_w = &hdcp_work[link_index];
++ struct amdgpu_dm_connector *aconnector;
++ const struct dc *dc;
++ int link_index;
++ unsigned int conn_index;
++ struct mod_hdcp_display *display;
++ struct mod_hdcp_link *link;
++ struct hdcp_workqueue *hdcp_w;
+ struct dc_sink *sink = NULL;
+ bool link_is_hdcp14 = false;
+- const struct dc *dc = aconnector->dc_link->dc;
++
++ aconnector = config->dm_stream_ctx;
++ if (!aconnector || !aconnector->dc_link)
++ return;
++
++ link_index = aconnector->dc_link->link_index;
++ display = &hdcp_work[link_index].display;
++ link = &hdcp_work[link_index].link;
++ hdcp_w = &hdcp_work[link_index];
++
++ conn_index = aconnector->base.index;
++ dc = aconnector->dc_link->dc;
+
+ if (config->dpms_off) {
+ hdcp_remove_display(hdcp_work, link_index, aconnector);
+@@ -581,7 +593,7 @@ static void update_config(void *handle, struct cp_psp_stream_config *config)
+ link->dp.mst_enabled = config->mst_enabled;
+ link->dp.dp2_enabled = config->dp2_enabled;
+ link->dp.usb4_enabled = config->usb4_enabled;
+- if (aconnector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_FRL)
++ if (sink && sink->sink_signal == SIGNAL_TYPE_HDMI_FRL)
+ link->hdmi.frl_enabled = config->frl_enabled;
+ display->adjust.disable = MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION;
+ link->adjust.auth_delay = 2;
+diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+index 6be7f6edd0b293..41aa8f9bb152bb 100644
+--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+@@ -134,6 +134,17 @@ static void apply_edid_quirks(struct dc_link *link, struct edid *edid,
+ drm_dbg_driver(dev, "Skip PHY SSC reduction on panel id %X\n", panel_id);
+ link->wa_flags.skip_phy_ssc_reduction = true;
+ break;
++ /*
++ * Workaround for Apple Studio Display which exposes a 2x1 tiled panel
++ * over two SST DP links. Hide the secondary tile from userspace so
++ * compositors drive a single 5K stream on the primary link only.
++ */
++ case drm_edid_encode_panel_id('A', 'P', 'P', 0xAE3A):
++ case drm_edid_encode_panel_id('A', 'P', 'P', 0xAE42):
++ case drm_edid_encode_panel_id('A', 'P', 'P', 0xAE46):
++ drm_dbg_driver(dev, "Hiding secondary tile on panel id %X\n", panel_id);
++ edid_caps->panel_patch.disable_second_tile = true;
++ break;
+ default:
+ return;
+ }
+diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h
+index 4ed1efa172709a..6482e275e63bf6 100644
+--- a/drivers/gpu/drm/amd/display/dc/dc_types.h
++++ b/drivers/gpu/drm/amd/display/dc/dc_types.h
+@@ -187,6 +187,7 @@ struct dc_panel_patch {
+ unsigned int skip_audio_sab_check;
+ unsigned int mst_start_top_delay;
+ unsigned int remove_sink_ext_caps;
++ bool disable_second_tile;
+ unsigned int disable_colorimetry;
+ uint8_t blankstream_before_otg_off;
+ bool oled_optimize_display_on;
+diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
+index 20dba02d6175bc..c5a24dff4b69b4 100644
+--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
+@@ -313,11 +313,20 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
+ rep->offset = nvbo->offset;
+ if (vmm->vmm.object.oclass >= NVIF_CLASS_VMM_NV50 &&
+ !nouveau_cli_uvmm(cli)) {
++ int ret;
++
++ ret = ttm_bo_reserve(&nvbo->bo, false, false, NULL);
++ if (ret)
++ return ret;
++
+ vma = nouveau_vma_find(nvbo, vmm);
+- if (!vma)
++ if (!vma) {
++ ttm_bo_unreserve(&nvbo->bo);
+ return -EINVAL;
++ }
+
+ rep->offset = vma->addr;
++ ttm_bo_unreserve(&nvbo->bo);
+ } else
+ rep->offset = 0;
+
+diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
+index bf7dd0fbf2496f..a5f232cc2b66e3 100644
+--- a/drivers/hid/hid-apple.c
++++ b/drivers/hid/hid-apple.c
+@@ -91,6 +91,9 @@ struct apple_sc_backlight {
+ struct hid_device *hdev;
+ };
+
++/* T2 VHCI re-enumerates the internal keyboard across system resume. */
++static int apple_backlight_resume_brightness = -1;
++
+ struct apple_backlight_config_report {
+ u8 report_id;
+ u8 version;
+@@ -825,6 +828,7 @@ static int apple_backlight_led_set(struct led_classdev *led_cdev,
+ static int apple_backlight_init(struct hid_device *hdev)
+ {
+ int ret;
++ int brightness;
+ struct apple_sc *asc = hid_get_drvdata(hdev);
+ struct apple_backlight_config_report *rep;
+
+@@ -860,13 +864,20 @@ static int apple_backlight_init(struct hid_device *hdev)
+ asc->backlight->cdev.name = "apple::kbd_backlight";
+ asc->backlight->cdev.max_brightness = rep->backlight_on_max;
+ asc->backlight->cdev.brightness_set_blocking = apple_backlight_led_set;
+- asc->backlight->cdev.flags = LED_CORE_SUSPENDRESUME;
++ /* VHCI re-enumeration restores the cached brightness in the next probe. */
++
++ brightness = READ_ONCE(apple_backlight_resume_brightness);
++ if (brightness < 0)
++ brightness = LED_OFF;
++ else
++ brightness = min_t(int, brightness, rep->backlight_on_max);
+
+- ret = apple_backlight_set(hdev, 0, 0);
++ ret = apple_backlight_set(hdev, brightness, 0);
+ if (ret < 0) {
+ hid_err(hdev, "backlight set request failed: %d\n", ret);
+ goto cleanup_and_exit;
+ }
++ asc->backlight->cdev.brightness = brightness;
+
+ ret = devm_led_classdev_register(&hdev->dev, &asc->backlight->cdev);
+
+@@ -999,6 +1010,9 @@ static void apple_remove(struct hid_device *hdev)
+
+ if (asc->quirks & APPLE_RDESC_BATTERY)
+ timer_delete_sync(&asc->battery_timer);
++ if (asc->backlight)
++ WRITE_ONCE(apple_backlight_resume_brightness,
++ asc->backlight->cdev.brightness);
+
+ hid_hw_stop(hdev);
+ }
+diff --git a/drivers/hid/hid-corsair-void.c b/drivers/hid/hid-corsair-void.c
+index 5e9a5b8f7f167b..071a663a6c2686 100644
+--- a/drivers/hid/hid-corsair-void.c
++++ b/drivers/hid/hid-corsair-void.c
+@@ -92,6 +92,9 @@
+ #define CORSAIR_VOID_STATUS_REPORT_ID 0x64
+ #define CORSAIR_VOID_FIRMWARE_REPORT_ID 0x66
+
++#define CORSAIR_VOID_STATUS_REPORT_SIZE 5
++#define CORSAIR_VOID_FIRMWARE_REPORT_SIZE 5
++
+ #define CORSAIR_VOID_USB_SIDETONE_REQUEST 0x1
+ #define CORSAIR_VOID_USB_SIDETONE_REQUEST_TYPE 0x21
+ #define CORSAIR_VOID_USB_SIDETONE_VALUE 0x200
+@@ -742,6 +745,13 @@ static int corsair_void_raw_event(struct hid_device *hid_dev,
+
+ /* Description of packets are documented at the top of this file */
+ if (hid_report->id == CORSAIR_VOID_STATUS_REPORT_ID) {
++ if (size < CORSAIR_VOID_STATUS_REPORT_SIZE) {
++ hid_warn_ratelimited(hid_dev,
++ "unexpected status report of size %d",
++ size);
++ return 1;
++ }
++
+ drvdata->mic_up = FIELD_GET(CORSAIR_VOID_MIC_MASK, data[2]);
+ drvdata->connected = (data[3] == CORSAIR_VOID_WIRELESS_CONNECTED) ||
+ drvdata->is_wired;
+@@ -750,6 +760,13 @@ static int corsair_void_raw_event(struct hid_device *hid_dev,
+ FIELD_GET(CORSAIR_VOID_CAPACITY_MASK, data[2]),
+ data[3], data[4]);
+ } else if (hid_report->id == CORSAIR_VOID_FIRMWARE_REPORT_ID) {
++ if (size < CORSAIR_VOID_FIRMWARE_REPORT_SIZE) {
++ hid_warn_ratelimited(hid_dev,
++ "unexpected firmware report of size %d",
++ size);
++ return 1;
++ }
++
+ drvdata->fw_receiver_major = data[1];
+ drvdata->fw_receiver_minor = data[2];
+ drvdata->fw_headset_major = data[3];
+diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
+index e4ddd8e9293b68..d52ce3531ab706 100644
+--- a/drivers/hid/hid-mcp2221.c
++++ b/drivers/hid/hid-mcp2221.c
+@@ -343,7 +343,7 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
+
+ ret = mcp_send_data_req_status(mcp, mcp->txbuf, 4);
+ if (ret)
+- return ret;
++ goto out;
+
+ mcp->rxbuf_idx = 0;
+
+@@ -365,7 +365,7 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
+ } else {
+ usleep_range(980, 1000);
+ mcp_cancel_last_cmd(mcp);
+- return ret;
++ goto out;
+ }
+ } else {
+ retries = 0;
+@@ -375,6 +375,10 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
+ usleep_range(980, 1000);
+ ret = mcp_chk_last_cmd_status_free_bus(mcp);
+
++out:
++ mcp->rxbuf = NULL;
++ mcp->rxbuf_size = 0;
++
+ return ret;
+ }
+
+@@ -861,6 +865,9 @@ static int mcp2221_raw_event(struct hid_device *hdev,
+ u8 *buf;
+ struct mcp2221 *mcp = hid_get_drvdata(hdev);
+
++ if (size < 4)
++ return 0;
++
+ switch (data[0]) {
+
+ case MCP2221_I2C_WR_DATA:
+@@ -926,6 +933,10 @@ static int mcp2221_raw_event(struct hid_device *hdev,
+ mcp->status = -EINVAL;
+ break;
+ }
++ if (4 + data[3] > size) {
++ mcp->status = -EINVAL;
++ break;
++ }
+ buf = mcp->rxbuf;
+ memcpy(&buf[mcp->rxbuf_idx], &data[4], data[3]);
+ mcp->rxbuf_idx = mcp->rxbuf_idx + data[3];
+@@ -1049,6 +1060,8 @@ static void mcp2221_hid_unregister(void *ptr)
+ {
+ struct hid_device *hdev = ptr;
+
++ if (hdev->io_started)
++ hid_device_io_stop(hdev);
+ hid_hw_close(hdev);
+ hid_hw_stop(hdev);
+ }
+diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
+index 085847a92e07dd..1f7dfe60e9ba2b 100644
+--- a/drivers/hid/hid-picolcd_debugfs.c
++++ b/drivers/hid/hid-picolcd_debugfs.c
+@@ -99,6 +99,15 @@ static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u,
+ ret = resp->raw_data[2];
+ if (ret > s)
+ ret = s;
++ /*
++ * raw_data[2] is a device-supplied length; also clamp it to
++ * what picolcd_raw_event() actually stored (raw_size), or a
++ * hostile device overruns the raw_data[] buffer.
++ */
++ if (ret > resp->raw_size - 3)
++ ret = resp->raw_size - 3;
++ if (ret < 0)
++ ret = 0;
+ if (copy_to_user(u, resp->raw_data+3, ret))
+ ret = -EFAULT;
+ else
+diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c
+index d6fff53d4ee7ab..4f15eb95103968 100644
+--- a/drivers/hid/hid-roccat.c
++++ b/drivers/hid/hid-roccat.c
+@@ -70,6 +70,15 @@ static struct roccat_device *devices[ROCCAT_MAX_DEVICES];
+ /* protects modifications of devices array */
+ static DEFINE_MUTEX(devices_lock);
+
++static void roccat_free_device(struct roccat_device *device)
++{
++ int i;
++
++ for (i = 0; i < ROCCAT_CBUF_SIZE; i++)
++ kfree(device->cbuf[i].value);
++ kfree(device);
++}
++
+ static ssize_t roccat_read(struct file *file, char __user *buffer,
+ size_t count, loff_t *ppos)
+ {
+@@ -226,7 +235,7 @@ static int roccat_release(struct inode *inode, struct file *file)
+ hid_hw_power(device->hid, PM_HINT_NORMAL);
+ hid_hw_close(device->hid);
+ } else {
+- kfree(device);
++ roccat_free_device(device);
+ }
+ }
+
+@@ -374,7 +383,7 @@ void roccat_disconnect(int minor)
+ hid_hw_close(device->hid);
+ wake_up_interruptible(&device->wait);
+ } else {
+- kfree(device);
++ roccat_free_device(device);
+ }
+ }
+ EXPORT_SYMBOL_GPL(roccat_disconnect);
+diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
+index 6b0da2e0e1c93e..c2b425afd951be 100644
+--- a/drivers/hid/hid-sensor-custom.c
++++ b/drivers/hid/hid-sensor-custom.c
+@@ -609,7 +609,7 @@ static int hid_sensor_custom_add_attributes(struct hid_sensor_custom
+ &sensor_inst->fields[i].
+ hid_custom_attribute_group);
+ if (ret)
+- break;
++ goto err_remove_groups;
+
+ /* For power or report field store indexes */
+ if (sensor_inst->fields[i].attribute.attrib_id ==
+@@ -621,6 +621,13 @@ static int hid_sensor_custom_add_attributes(struct hid_sensor_custom
+ }
+
+ return ret;
++
++err_remove_groups:
++ while (--i >= 0)
++ sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
++ &sensor_inst->fields[i].hid_custom_attribute_group);
++ kfree(sensor_inst->fields);
++ return ret;
+ }
+
+ static void hid_sensor_custom_remove_attributes(struct hid_sensor_custom *
+diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
+index 34f710c465b80a..6470a290ebfc5b 100644
+--- a/drivers/hid/hid-sensor-hub.c
++++ b/drivers/hid/hid-sensor-hub.c
+@@ -239,12 +239,17 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
+ u32 field_index, int buffer_size, void *buffer)
+ {
+ struct hid_report *report;
++ struct hid_field *field;
+ struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
+- int report_size;
++ size_t field_size;
++ size_t report_size;
++ size_t copied = 0;
++ size_t to_copy;
+ int ret = 0;
+- u8 *val_ptr;
+- int buffer_index = 0;
+- int i;
++ unsigned int i;
++
++ if (!buffer || buffer_size <= 0)
++ return -EINVAL;
+
+ memset(buffer, 0, buffer_size);
+
+@@ -258,26 +263,29 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
+ hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
+ hid_hw_wait(hsdev->hdev);
+
++ field = report->field[field_index];
++
+ /* calculate number of bytes required to read this field */
+- report_size = DIV_ROUND_UP(report->field[field_index]->report_size,
+- 8) *
+- report->field[field_index]->report_count;
+- if (!report_size) {
++ field_size = DIV_ROUND_UP(field->report_size, 8);
++ /* HID core stores each parsed report value in a __s32 slot. */
++ if (!field_size || field_size > sizeof(field->value[0])) {
++ ret = -EINVAL;
++ goto done_proc;
++ }
++ if (field->report_count > SIZE_MAX / field_size) {
+ ret = -EINVAL;
+ goto done_proc;
+ }
+- ret = min(report_size, buffer_size);
+
+- val_ptr = (u8 *)report->field[field_index]->value;
+- for (i = 0; i < report->field[field_index]->report_count; ++i) {
+- if (buffer_index >= ret)
+- break;
++ report_size = field_size * field->report_count;
++ report_size = min_t(size_t, report_size, buffer_size);
+
+- memcpy(&((u8 *)buffer)[buffer_index], val_ptr,
+- report->field[field_index]->report_size / 8);
+- val_ptr += sizeof(__s32);
+- buffer_index += (report->field[field_index]->report_size / 8);
++ for (i = 0; i < field->report_count && copied < report_size; ++i) {
++ to_copy = min(field_size, report_size - copied);
++ memcpy(&((u8 *)buffer)[copied], &field->value[i], to_copy);
++ copied += to_copy;
+ }
++ ret = copied;
+
+ done_proc:
+ mutex_unlock(&data->mutex);
+diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
+index e75246d29e16d1..77ab30303080e2 100644
+--- a/drivers/hid/hid-sony.c
++++ b/drivers/hid/hid-sony.c
+@@ -2424,7 +2424,9 @@ static void sony_remove(struct hid_device *hdev)
+ struct sony_sc *sc = hid_get_drvdata(hdev);
+
+ if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
+- timer_delete_sync(&sc->ghl_poke_timer);
++ /* poison, not kill: a pending timer must not re-submit during teardown */
++ usb_poison_urb(sc->ghl_urb);
++ timer_shutdown_sync(&sc->ghl_poke_timer);
+ usb_free_urb(sc->ghl_urb);
+ }
+
+diff --git a/drivers/hid/hid-universal-pidff.c b/drivers/hid/hid-universal-pidff.c
+index 549dac555d4088..60180467a0bfd9 100644
+--- a/drivers/hid/hid-universal-pidff.c
++++ b/drivers/hid/hid-universal-pidff.c
+@@ -104,12 +104,14 @@ static int universal_pidff_probe(struct hid_device *hdev,
+ error = init_function(hdev, id->driver_data);
+ if (error) {
+ hid_warn(hdev, "Error initialising force feedback\n");
+- goto err;
++ goto err_stop;
+ }
+
+ hid_info(hdev, "Universal pidff driver loaded successfully!");
+
+ return 0;
++err_stop:
++ hid_hw_stop(hdev);
+ err:
+ return error;
+ }
+diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+index 46d3e9a019995f..4126c2408d9869 100644
+--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
++++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+@@ -774,6 +774,7 @@ static void quicki2c_remove(struct pci_dev *pdev)
+ quicki2c_hid_remove(qcdev);
+ quicki2c_dma_deinit(qcdev);
+
++ pm_runtime_dont_use_autosuspend(qcdev->dev);
+ pm_runtime_get_noresume(qcdev->dev);
+
+ quicki2c_dev_deinit(qcdev);
+diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
+index 4ae2e1718b30cf..5d35edf2b6d86b 100644
+--- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
++++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
+@@ -555,7 +555,14 @@ static int quickspi_alloc_report_buf(struct quickspi_device *qsdev)
+ max_report_len = max(le16_to_cpu(qsdev->dev_desc.max_output_len),
+ le16_to_cpu(qsdev->dev_desc.max_input_len));
+
+- qsdev->report_buf = devm_kzalloc(qsdev->dev, max_report_len, GFP_KERNEL);
++ /*
++ * write_cmd_to_txdma() writes the output report header ahead of the
++ * content in this buffer, so it has to hold both.
++ */
++ qsdev->report_buf_size = HIDSPI_OUTPUT_REPORT_SIZE(max_report_len);
++
++ qsdev->report_buf = devm_kzalloc(qsdev->dev, qsdev->report_buf_size,
++ GFP_KERNEL);
+ if (!qsdev->report_buf)
+ return -ENOMEM;
+
+@@ -713,6 +720,7 @@ static void quickspi_remove(struct pci_dev *pdev)
+ quickspi_hid_remove(qsdev);
+ quickspi_dma_deinit(qsdev);
+
++ pm_runtime_dont_use_autosuspend(qsdev->dev);
+ pm_runtime_get_noresume(qsdev->dev);
+
+ quickspi_dev_deinit(qsdev);
+diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h
+index bf5e18f5a5f425..0ed964bfe3dd2d 100644
+--- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h
++++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h
+@@ -157,6 +157,7 @@ struct quickspi_device {
+ u8 *report_descriptor;
+ u8 *input_buf;
+ u8 *report_buf;
++ u32 report_buf_size;
+ u32 report_len;
+
+ wait_queue_head_t reset_ack_wq;
+diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c
+index 91d5807b4a8302..a60a0a7f16aad3 100644
+--- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c
++++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c
+@@ -61,7 +61,7 @@ static int quickspi_hid_raw_request(struct hid_device *hid,
+
+ switch (reqtype) {
+ case HID_REQ_GET_REPORT:
+- ret = quickspi_get_report(qsdev, rtype, reportnum, buf);
++ ret = quickspi_get_report(qsdev, rtype, reportnum, buf, len);
+ break;
+ case HID_REQ_SET_REPORT:
+ ret = quickspi_set_report(qsdev, rtype, reportnum, buf, len);
+diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
+index cb19057f1191ba..847c5ec55569a2 100644
+--- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
++++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
+@@ -30,6 +30,9 @@ static int write_cmd_to_txdma(struct quickspi_device *qsdev,
+
+ write_buf = (struct output_report *)qsdev->report_buf;
+
++ if (HIDSPI_OUTPUT_REPORT_SIZE(report_buf_len) > qsdev->report_buf_size)
++ return -EINVAL;
++
+ write_buf->output_hdr.report_type = report_type;
+ write_buf->output_hdr.content_len = cpu_to_le16(report_buf_len);
+ write_buf->output_hdr.content_id = report_id;
+@@ -342,10 +345,12 @@ int reset_tic(struct quickspi_device *qsdev)
+ }
+
+ int quickspi_get_report(struct quickspi_device *qsdev,
+- u8 report_type, unsigned int report_id, void *buf)
++ u8 report_type, unsigned int report_id, void *buf,
++ u32 buf_len)
+ {
+ int rep_type;
+ int ret;
++ u32 report_len;
+
+ if (report_type == HID_INPUT_REPORT) {
+ rep_type = GET_INPUT_REPORT;
+@@ -372,9 +377,17 @@ int quickspi_get_report(struct quickspi_device *qsdev,
+ }
+ qsdev->get_report_cmpl = false;
+
+- memcpy(buf, qsdev->report_buf, qsdev->report_len);
++ /* quickspi_handle_input_data() updates this from IRQ context. */
++ report_len = READ_ONCE(qsdev->report_len);
++ if (report_len > buf_len) {
++ dev_err_once(qsdev->dev, "Get report response too big, %u vs %u\n",
++ report_len, buf_len);
++ return -EINVAL;
++ }
++
++ memcpy(buf, qsdev->report_buf, report_len);
+
+- return qsdev->report_len;
++ return report_len;
+ }
+
+ int quickspi_set_report(struct quickspi_device *qsdev,
+diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h
+index 775e29c1ed1366..8a2338bee80856 100644
+--- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h
++++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h
+@@ -12,7 +12,7 @@ struct quickspi_device;
+
+ void quickspi_handle_input_data(struct quickspi_device *qsdev, u32 buf_len);
+ int quickspi_get_report(struct quickspi_device *qsdev, u8 report_type,
+- unsigned int report_id, void *buf);
++ unsigned int report_id, void *buf, u32 buf_len);
+ int quickspi_set_report(struct quickspi_device *qsdev, u8 report_type,
+ unsigned int report_id, void *buf, u32 buf_len);
+ int quickspi_get_report_descriptor(struct quickspi_device *qsdev);
+diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c
+index eeacc427fd6590..47826315d7d628 100644
+--- a/drivers/hsi/controllers/omap_ssi_core.c
++++ b/drivers/hsi/controllers/omap_ssi_core.c
+@@ -502,6 +502,12 @@ static int ssi_probe(struct platform_device *pd)
+
+ pm_runtime_enable(&pd->dev);
+
++ ssi->device.dma_mask = &ssi->device.coherent_dma_mask;
++
++ err = dma_set_mask_and_coherent(&ssi->device, DMA_BIT_MASK(32));
++ if (err)
++ goto out2;
++
+ err = ssi_hw_init(ssi);
+ if (err < 0)
+ goto out2;
+diff --git a/drivers/hwmon/max6621.c b/drivers/hwmon/max6621.c
+index e86ec6d237ca63..1a644d78714314 100644
+--- a/drivers/hwmon/max6621.c
++++ b/drivers/hwmon/max6621.c
+@@ -17,8 +17,8 @@
+
+ #define MAX6621_DRV_NAME "max6621"
+ #define MAX6621_TEMP_INPUT_REG_NUM 9
+-#define MAX6621_TEMP_INPUT_MIN -127000
+-#define MAX6621_TEMP_INPUT_MAX 128000
++#define MAX6621_TEMP_INPUT_MIN -128000
++#define MAX6621_TEMP_INPUT_MAX 127000
+ #define MAX6621_TEMP_ALERT_CHAN_SHIFT 1
+
+ #define MAX6621_TEMP_S0D0_REG 0x00
+@@ -239,7 +239,7 @@ max6621_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
+ if (ret)
+ return ret;
+
+- *val = (regval >> MAX6621_REG_TEMP_SHIFT) *
++ *val = ((s16)regval >> MAX6621_REG_TEMP_SHIFT) *
+ 1000L;
+
+ break;
+@@ -254,7 +254,7 @@ max6621_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
+ if (ret)
+ return ret;
+
+- *val = regval * 1000L;
++ *val = (s16)regval * 1000L;
+
+ break;
+ case hwmon_temp_crit_alarm:
+diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
+index 762109307b869f..b3c67e96a82a49 100644
+--- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
++++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c
+@@ -717,26 +717,19 @@ static DEVICE_ATTR_RW(cntr_rld_event);
+ static ssize_t cntr_val_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+ {
+- int i, ret = 0;
+ u32 val;
+ struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
+ struct etm_config *config = &drvdata->config;
+
+ if (!coresight_get_mode(drvdata->csdev)) {
+ spin_lock(&drvdata->spinlock);
+- for (i = 0; i < drvdata->nr_cntr; i++)
+- ret += sprintf(buf, "counter %d: %x\n",
+- i, config->cntr_val[i]);
++ val = config->cntr_val[config->cntr_idx];
+ spin_unlock(&drvdata->spinlock);
+- return ret;
+- }
+-
+- for (i = 0; i < drvdata->nr_cntr; i++) {
+- val = etm_readl(drvdata, ETMCNTVRn(i));
+- ret += sprintf(buf, "counter %d: %x\n", i, val);
++ } else {
++ val = etm_readl(drvdata, ETMCNTVRn(config->cntr_idx));
+ }
+
+- return ret;
++ return sysfs_emit(buf, "%#x\n", val);
+ }
+
+ static ssize_t cntr_val_store(struct device *dev,
+diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
+index 94c371c4913571..b5d851281fbf08 100644
+--- a/drivers/hwtracing/ptt/hisi_ptt.c
++++ b/drivers/hwtracing/ptt/hisi_ptt.c
+@@ -171,13 +171,13 @@ static bool hisi_ptt_wait_trace_hw_idle(struct hisi_ptt *hisi_ptt)
+ HISI_PTT_WAIT_TRACE_TIMEOUT_US);
+ }
+
+-static void hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
++static bool hisi_ptt_wait_dma_reset_done(struct hisi_ptt *hisi_ptt)
+ {
+ u32 val;
+
+- readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS,
+- val, !val, HISI_PTT_RESET_POLL_INTERVAL_US,
+- HISI_PTT_RESET_TIMEOUT_US);
++ return !readl_poll_timeout_atomic(hisi_ptt->iobase + HISI_PTT_TRACE_WR_STS,
++ val, !val, HISI_PTT_RESET_POLL_INTERVAL_US,
++ HISI_PTT_RESET_TIMEOUT_US);
+ }
+
+ static void hisi_ptt_trace_end(struct hisi_ptt *hisi_ptt)
+@@ -202,14 +202,18 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
+ return -EBUSY;
+ }
+
+- ctrl->started = true;
+-
+ /* Reset the DMA before start tracing */
+ val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
+ val |= HISI_PTT_TRACE_CTRL_RST;
+ writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
+
+- hisi_ptt_wait_dma_reset_done(hisi_ptt);
++ if (!hisi_ptt_wait_dma_reset_done(hisi_ptt)) {
++ pci_err(hisi_ptt->pdev, "timed out waiting for DMA reset\n");
++ val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
++ val &= ~HISI_PTT_TRACE_CTRL_RST;
++ writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
++ return -ETIMEDOUT;
++ }
+
+ val = readl(hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
+ val &= ~HISI_PTT_TRACE_CTRL_RST;
+@@ -234,6 +238,8 @@ static int hisi_ptt_trace_start(struct hisi_ptt *hisi_ptt)
+ if (!hisi_ptt->trace_ctrl.is_port)
+ val |= HISI_PTT_TRACE_CTRL_FILTER_MODE;
+
++ ctrl->started = true;
++
+ /* Start the Trace */
+ val |= HISI_PTT_TRACE_CTRL_EN;
+ writel(val, hisi_ptt->iobase + HISI_PTT_TRACE_CTRL);
+diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
+index 4e07babea9c3f4..eee4fdcd9df31a 100644
+--- a/drivers/i2c/busses/i2c-mxs.c
++++ b/drivers/i2c/busses/i2c-mxs.c
+@@ -839,7 +839,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
+ }
+
+ /* Setup the DMA */
+- i2c->dmach = dma_request_chan(dev, "rx-tx");
++ i2c->dmach = devm_dma_request_chan(dev, "rx-tx");
+ if (IS_ERR(i2c->dmach)) {
+ return dev_err_probe(dev, PTR_ERR(i2c->dmach),
+ "Failed to request dma\n");
+@@ -877,9 +877,6 @@ static void mxs_i2c_remove(struct platform_device *pdev)
+
+ i2c_del_adapter(&i2c->adapter);
+
+- if (i2c->dmach)
+- dma_release_channel(i2c->dmach);
+-
+ writel(MXS_I2C_CTRL0_SFTRST, i2c->regs + MXS_I2C_CTRL0_SET);
+ }
+
+diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c
+index 101eaa77de6860..a3778282e84c28 100644
+--- a/drivers/i3c/device.c
++++ b/drivers/i3c/device.c
+@@ -309,7 +309,7 @@ EXPORT_SYMBOL_GPL(i3c_device_match_id);
+ */
+ u32 i3c_device_get_supported_xfer_mode(struct i3c_device *dev)
+ {
+- return i3c_dev_get_master(dev->desc)->this->info.hdr_cap | BIT(I3C_SDR);
++ return i3c_bus_to_i3c_master(dev->bus)->this->info.hdr_cap | BIT(I3C_SDR);
+ }
+ EXPORT_SYMBOL_GPL(i3c_device_get_supported_xfer_mode);
+
+diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h
+index 0f1f3f76662379..86a36b951e0d57 100644
+--- a/drivers/i3c/internals.h
++++ b/drivers/i3c/internals.h
+@@ -72,4 +72,9 @@ static inline void i3c_readl_fifo(const void __iomem *addr, void *buf,
+ }
+ }
+
++static inline struct i3c_master_controller *i3c_bus_to_i3c_master(struct i3c_bus *i3cbus)
++{
++ return container_of(i3cbus, struct i3c_master_controller, bus);
++}
++
+ #endif /* I3C_INTERNAL_H */
+diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
+index f1be38a640ca11..b51b159fadeed2 100644
+--- a/drivers/i3c/master.c
++++ b/drivers/i3c/master.c
+@@ -97,12 +97,6 @@ void i3c_bus_normaluse_unlock(struct i3c_bus *bus)
+ up_read(&bus->lock);
+ }
+
+-static struct i3c_master_controller *
+-i3c_bus_to_i3c_master(struct i3c_bus *i3cbus)
+-{
+- return container_of(i3cbus, struct i3c_master_controller, bus);
+-}
+-
+ static struct i3c_master_controller *dev_to_i3cmaster(struct device *dev)
+ {
+ return container_of(dev, struct i3c_master_controller, dev);
+@@ -2977,11 +2971,12 @@ static void i3c_master_unregister_i3c_devs(struct i3c_master_controller *master)
+ if (!i3cdev->dev)
+ continue;
+
+- i3cdev->dev->desc = NULL;
+- if (device_is_registered(&i3cdev->dev->dev))
++ if (device_is_registered(&i3cdev->dev->dev)) {
++ get_device(&i3cdev->dev->dev);
+ device_unregister(&i3cdev->dev->dev);
+- else
+- put_device(&i3cdev->dev->dev);
++ }
++ i3cdev->dev->desc = NULL;
++ put_device(&i3cdev->dev->dev);
+ i3cdev->dev = NULL;
+ }
+ }
+diff --git a/drivers/i3c/master/adi-i3c-master.c b/drivers/i3c/master/adi-i3c-master.c
+index 047081c9f06439..e29aac28695775 100644
+--- a/drivers/i3c/master/adi-i3c-master.c
++++ b/drivers/i3c/master/adi-i3c-master.c
+@@ -964,17 +964,9 @@ static int adi_i3c_master_probe(struct platform_device *pdev)
+ writel(0x00, master->regs + REG_ENABLE);
+ writel(0x00, master->regs + REG_IRQ_MASK);
+
+- ret = devm_request_irq(&pdev->dev, irq, adi_i3c_master_irq, 0,
+- dev_name(&pdev->dev), master);
+- if (ret)
+- return ret;
+-
+ platform_set_drvdata(pdev, master);
+
+ master->free_rr_slots = GENMASK(ADI_MAX_DEVS, 1);
+-
+- writel(REG_IRQ_PENDING_CMDR, master->regs + REG_IRQ_MASK);
+-
+ spin_lock_init(&master->ibi.lock);
+ master->ibi.num_slots = 15;
+ master->ibi.slots = devm_kcalloc(&pdev->dev, master->ibi.num_slots,
+@@ -986,6 +978,13 @@ static int adi_i3c_master_probe(struct platform_device *pdev)
+ spin_lock_init(&master->xferqueue.lock);
+ INIT_LIST_HEAD(&master->xferqueue.list);
+
++ ret = devm_request_irq(&pdev->dev, irq, adi_i3c_master_irq, 0,
++ dev_name(&pdev->dev), master);
++ if (ret)
++ return ret;
++
++ writel(REG_IRQ_PENDING_CMDR, master->regs + REG_IRQ_MASK);
++
+ return i3c_master_register(&master->base, &pdev->dev,
+ &adi_i3c_master_ops, false);
+ }
+diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-i3c.c
+index f39c449922ca26..c459e40fd5ffc3 100644
+--- a/drivers/i3c/master/renesas-i3c.c
++++ b/drivers/i3c/master/renesas-i3c.c
+@@ -260,11 +260,11 @@ struct renesas_i3c {
+ u32 dyn_addr;
+ u32 i2c_STDBR;
+ u32 i3c_STDBR;
++ u32 extbr;
+ unsigned long rate;
+ u8 addrs[RENESAS_I3C_MAX_DEVS];
+ struct renesas_i3c_xferqueue xferqueue;
+ void __iomem *regs;
+- u32 *DATBASn;
+ struct clk_bulk_data *clks;
+ struct reset_control *presetn;
+ struct reset_control *tresetn;
+@@ -433,6 +433,21 @@ static void renesas_i3c_enqueue_xfer(struct renesas_i3c *i3c, struct renesas_i3c
+ }
+ }
+
++static void renesas_i3c_irqs_mask_and_clear_locked(struct renesas_i3c *i3c)
++{
++ /* Disable all the interrupts. */
++ renesas_writel(i3c->regs, BIE, 0);
++ renesas_writel(i3c->regs, NTIE, 0);
++
++ /* Clear normal transfer status flags. */
++ renesas_writel(i3c->regs, NTST, 0);
++
++ /* Clear bus status flags. */
++ renesas_writel(i3c->regs, BST, 0);
++ /* Read back registers to confirm writes have fully propagated. */
++ renesas_readl(i3c->regs, BST);
++}
++
+ static void renesas_i3c_wait_xfer(struct renesas_i3c *i3c, struct renesas_i3c_xfer *xfer)
+ {
+ unsigned long time_left;
+@@ -607,10 +622,9 @@ static int renesas_i3c_bus_init(struct i3c_master_controller *m)
+ renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR);
+
+ /* Extended Bit Rate setting */
+- renesas_writel(i3c->regs, EXTBR, EXTBR_EBRLO(od_low_ticks) |
+- EXTBR_EBRHO(od_high_ticks) |
+- EXTBR_EBRLP(pp_low_ticks) |
+- EXTBR_EBRHP(pp_high_ticks));
++ i3c->extbr = EXTBR_EBRLO(od_low_ticks) | EXTBR_EBRHO(od_high_ticks) |
++ EXTBR_EBRLP(pp_low_ticks) | EXTBR_EBRHP(pp_high_ticks);
++ renesas_writel(i3c->regs, EXTBR, i3c->extbr);
+
+ renesas_writel(i3c->regs, REFCKCTL, REFCKCTL_IREFCKS(cks));
+ i3c->refclk_div = cks;
+@@ -689,7 +703,11 @@ static int renesas_i3c_daa(struct i3c_master_controller *m)
+
+ renesas_i3c_wait_xfer(i3c, xfer);
+
+- newdevs = GENMASK(i3c->maxdevs - cmd->rx_count - 1, 0);
++ if (cmd->rx_count >= i3c->maxdevs)
++ newdevs = 0;
++ else
++ newdevs = GENMASK(i3c->maxdevs - cmd->rx_count - 1, 0);
++
+ newdevs &= ~olddevs;
+
+ for (pos = 0; pos < i3c->maxdevs; pos++) {
+@@ -892,10 +910,26 @@ static int renesas_i3c_reattach_i3c_dev(struct i3c_dev_desc *dev,
+ struct i3c_master_controller *m = i3c_dev_get_master(dev);
+ struct renesas_i3c *i3c = to_renesas_i3c(m);
+ struct renesas_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev);
++ int pos;
++
++ pos = renesas_i3c_get_free_pos(i3c);
++
++ if (data->index > pos && pos >= 0) {
++ renesas_writel(i3c->regs, DATBAS(data->index), 0);
++ i3c->addrs[data->index] = 0;
++ i3c->free_pos |= BIT(data->index);
++
++ data->index = pos;
++ i3c->free_pos &= ~BIT(data->index);
++ }
+
+ i3c->addrs[data->index] = dev->info.dyn_addr ? dev->info.dyn_addr :
+ dev->info.static_addr;
+
++ renesas_writel(i3c->regs, DATBAS(data->index),
++ DATBAS_DVSTAD(dev->info.static_addr) |
++ datbas_dvdyad_with_parity(i3c->addrs[data->index]));
++
+ return 0;
+ }
+
+@@ -905,6 +939,8 @@ static void renesas_i3c_detach_i3c_dev(struct i3c_dev_desc *dev)
+ struct i3c_master_controller *m = i3c_dev_get_master(dev);
+ struct renesas_i3c *i3c = to_renesas_i3c(m);
+
++ renesas_writel(i3c->regs, DATBAS(data->index), 0);
++
+ i3c_dev_set_master_data(dev, NULL);
+ i3c->addrs[data->index] = 0;
+ i3c->free_pos |= BIT(data->index);
+@@ -1014,6 +1050,11 @@ static irqreturn_t renesas_i3c_tx_isr(int irq, void *data)
+
+ scoped_guard(spinlock, &i3c->xferqueue.lock) {
+ xfer = i3c->xferqueue.cur;
++ if (!xfer) {
++ renesas_i3c_irqs_mask_and_clear_locked(i3c);
++ return IRQ_HANDLED;
++ }
++
+ cmd = xfer->cmds;
+
+ if (xfer->is_i2c_xfer) {
+@@ -1054,6 +1095,11 @@ static irqreturn_t renesas_i3c_resp_isr(int irq, void *data)
+
+ scoped_guard(spinlock, &i3c->xferqueue.lock) {
+ xfer = i3c->xferqueue.cur;
++ if (!xfer) {
++ renesas_i3c_irqs_mask_and_clear_locked(i3c);
++ return IRQ_HANDLED;
++ }
++
+ cmd = xfer->cmds;
+
+ /* Clear the Respone Queue Full status flag*/
+@@ -1138,6 +1184,11 @@ static irqreturn_t renesas_i3c_tend_isr(int irq, void *data)
+
+ scoped_guard(spinlock, &i3c->xferqueue.lock) {
+ xfer = i3c->xferqueue.cur;
++ if (!xfer) {
++ renesas_i3c_irqs_mask_and_clear_locked(i3c);
++ return IRQ_HANDLED;
++ }
++
+ cmd = xfer->cmds;
+
+ if (xfer->is_i2c_xfer) {
+@@ -1184,6 +1235,11 @@ static irqreturn_t renesas_i3c_rx_isr(int irq, void *data)
+
+ scoped_guard(spinlock, &i3c->xferqueue.lock) {
+ xfer = i3c->xferqueue.cur;
++ if (!xfer) {
++ renesas_i3c_irqs_mask_and_clear_locked(i3c);
++ return IRQ_HANDLED;
++ }
++
+ cmd = xfer->cmds;
+
+ if (xfer->is_i2c_xfer) {
+@@ -1234,15 +1290,13 @@ static irqreturn_t renesas_i3c_stop_isr(int irq, void *data)
+ struct renesas_i3c_xfer *xfer;
+
+ scoped_guard(spinlock, &i3c->xferqueue.lock) {
+- xfer = i3c->xferqueue.cur;
+-
+- /* read back registers to confirm writes have fully propagated */
+- renesas_writel(i3c->regs, BST, 0);
+- renesas_readl(i3c->regs, BST);
+- renesas_writel(i3c->regs, BIE, 0);
+- renesas_clear_bit(i3c->regs, NTST, NTST_TDBEF0 | NTST_RDBFF0);
++ renesas_i3c_irqs_mask_and_clear_locked(i3c);
+ renesas_clear_bit(i3c->regs, SCSTRCTL, SCSTRCTL_RWE);
+
++ xfer = i3c->xferqueue.cur;
++ if (!xfer)
++ return IRQ_HANDLED;
++
+ xfer->ret = 0;
+ complete(&xfer->comp);
+ }
+@@ -1259,6 +1313,11 @@ static irqreturn_t renesas_i3c_start_isr(int irq, void *data)
+
+ scoped_guard(spinlock, &i3c->xferqueue.lock) {
+ xfer = i3c->xferqueue.cur;
++ if (!xfer) {
++ renesas_i3c_irqs_mask_and_clear_locked(i3c);
++ return IRQ_HANDLED;
++ }
++
+ cmd = xfer->cmds;
+
+ if (xfer->is_i2c_xfer) {
+@@ -1365,12 +1424,6 @@ static int renesas_i3c_probe(struct platform_device *pdev)
+ i3c->maxdevs = RENESAS_I3C_MAX_DEVS;
+ i3c->free_pos = GENMASK(i3c->maxdevs - 1, 0);
+
+- /* Allocate dynamic Device Address Table backup. */
+- i3c->DATBASn = devm_kzalloc(&pdev->dev, sizeof(u32) * i3c->maxdevs,
+- GFP_KERNEL);
+- if (!i3c->DATBASn)
+- return -ENOMEM;
+-
+ return i3c_master_register(&i3c->base, &pdev->dev, &renesas_i3c_ops, false);
+ }
+
+@@ -1381,17 +1434,13 @@ static void renesas_i3c_remove(struct platform_device *pdev)
+ i3c_master_unregister(&i3c->base);
+ }
+
+-static int renesas_i3c_suspend_noirq(struct device *dev)
++static int renesas_i3c_suspend(struct device *dev)
+ {
+ struct renesas_i3c *i3c = dev_get_drvdata(dev);
+- int i, ret;
++ int ret;
+
+ i2c_mark_adapter_suspended(&i3c->base.i2c);
+
+- /* Store Device Address Table values. */
+- for (i = 0; i < i3c->maxdevs; i++)
+- i3c->DATBASn[i] = renesas_readl(i3c->regs, DATBAS(i));
+-
+ ret = reset_control_assert(i3c->presetn);
+ if (ret)
+ goto err_mark_resumed;
+@@ -1412,50 +1461,61 @@ err_mark_resumed:
+ return ret;
+ }
+
+-static int renesas_i3c_resume_noirq(struct device *dev)
++static int renesas_i3c_resume(struct device *dev)
+ {
+ struct renesas_i3c *i3c = dev_get_drvdata(dev);
+- int i, ret;
++ int ret;
+
+- ret = reset_control_deassert(i3c->presetn);
++ ret = reset_control_deassert(i3c->tresetn);
+ if (ret)
+ return ret;
+
+- ret = reset_control_deassert(i3c->tresetn);
++ ret = reset_control_deassert(i3c->presetn);
+ if (ret)
+- goto err_presetn;
++ goto err_tresetn;
+
+ ret = clk_bulk_enable(i3c->num_clks, i3c->clks);
+ if (ret)
+- goto err_tresetn;
++ goto err_presetn;
++
++ ret = renesas_i3c_reset(i3c);
++ if (ret)
++ goto err_clks_disable;
+
+ /* Re-store I3C registers value. */
++ renesas_writel(i3c->regs, STDBR, i3c->i3c_STDBR);
++ renesas_writel(i3c->regs, EXTBR, i3c->extbr);
+ renesas_writel(i3c->regs, REFCKCTL,
+ REFCKCTL_IREFCKS(i3c->refclk_div));
+ renesas_writel(i3c->regs, MSDVAD, MSDVAD_MDYADV |
+ MSDVAD_MDYAD(i3c->dyn_addr));
+
+- /* Restore Device Address Table values. */
+- for (i = 0; i < i3c->maxdevs; i++)
+- renesas_writel(i3c->regs, DATBAS(i), i3c->DATBASn[i]);
+-
+ /* I3C hw init. */
+ renesas_i3c_hw_init(i3c);
+
++ ret = i3c_master_do_daa_ext(&i3c->base, true);
++ if (ret)
++ dev_err(dev, "DAA failed on resume, ret=%d", ret);
++
+ i2c_mark_adapter_resumed(&i3c->base.i2c);
+
++ /*
++ * I3C devices may have retained their dynamic address anyway. Do not
++ * fail the resume because of DAA error.
++ */
+ return 0;
+
+-err_tresetn:
+- reset_control_assert(i3c->tresetn);
++err_clks_disable:
++ clk_bulk_disable(i3c->num_clks, i3c->clks);
+ err_presetn:
+ reset_control_assert(i3c->presetn);
++err_tresetn:
++ reset_control_assert(i3c->tresetn);
+ return ret;
+ }
+
+ static const struct dev_pm_ops renesas_i3c_pm_ops = {
+- NOIRQ_SYSTEM_SLEEP_PM_OPS(renesas_i3c_suspend_noirq,
+- renesas_i3c_resume_noirq)
++ SYSTEM_SLEEP_PM_OPS(renesas_i3c_suspend, renesas_i3c_resume)
+ };
+
+ static const struct of_device_id renesas_i3c_of_ids[] = {
+diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
+index 93805df8a9406e..71f1fc6933233a 100644
+--- a/drivers/i3c/master/svc-i3c-master.c
++++ b/drivers/i3c/master/svc-i3c-master.c
+@@ -455,14 +455,22 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master,
+ buf = slot->data;
+
+ while (SVC_I3C_MSTATUS_RXPEND(readl(master->regs + SVC_I3C_MSTATUS)) &&
+- slot->len < SVC_I3C_FIFO_SIZE) {
++ slot->len < dev->ibi->max_payload_len) {
+ mdatactrl = readl(master->regs + SVC_I3C_MDATACTRL);
+ count = SVC_I3C_MDATACTRL_RXCOUNT(mdatactrl);
++ count = min(count, dev->ibi->max_payload_len - slot->len);
+ readsb(master->regs + SVC_I3C_MRDATAB, buf, count);
+ slot->len += count;
+ buf += count;
+ }
+
++ /*
++ * The device may have sent more than the requested payload. Drop the
++ * extra bytes so they do not leak into the next transfer.
++ */
++ if (SVC_I3C_MSTATUS_RXPEND(readl(master->regs + SVC_I3C_MSTATUS)))
++ writel(SVC_I3C_MDATACTRL_FLUSHRB, master->regs + SVC_I3C_MDATACTRL);
++
+ master->ibi.tbq_slot = slot;
+
+ return 0;
+diff --git a/drivers/infiniband/core/ib_core_uverbs.c b/drivers/infiniband/core/ib_core_uverbs.c
+index dbbc0875132a30..41c84ffe8c0930 100644
+--- a/drivers/infiniband/core/ib_core_uverbs.c
++++ b/drivers/infiniband/core/ib_core_uverbs.c
+@@ -424,6 +424,9 @@ static uverbs_api_ioctl_handler_fn uverbs_get_handler_fn(struct ib_udata *udata)
+
+ lockdep_assert_held(&bundle->ufile->device->disassociate_srcu);
+
++ if (!bundle->method_elm)
++ return NULL;
++
+ return srcu_dereference(bundle->method_elm->handler,
+ &bundle->ufile->device->disassociate_srcu);
+ }
+diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
+index 878561fa1cb557..ac29dfa69bb3a6 100644
+--- a/drivers/infiniband/core/ucma.c
++++ b/drivers/infiniband/core/ucma.c
+@@ -1404,7 +1404,10 @@ static int ucma_set_ib_path(struct ucma_context *ctx,
+
+ memset(&event, 0, sizeof event);
+ event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
+- return ucma_event_handler(ctx->cm_id, &event);
++ rdma_lock_handler(ctx->cm_id);
++ ret = ucma_event_handler(ctx->cm_id, &event);
++ rdma_unlock_handler(ctx->cm_id);
++ return ret;
+ }
+
+ static int ucma_set_option_ib(struct ucma_context *ctx, int optname,
+@@ -1776,6 +1779,13 @@ static ssize_t ucma_write_cm_event(struct ucma_file *file,
+ goto out;
+ }
+
++ rdma_lock_handler(ctx->cm_id);
++ if (!ctx->uid) {
++ kfree(uevent);
++ ret = -EINVAL;
++ goto err_unlock;
++ }
++
+ uevent->ctx = ctx;
+ uevent->resp.uid = ctx->uid;
+ uevent->resp.id = ctx->id;
+@@ -1789,6 +1799,8 @@ static ssize_t ucma_write_cm_event(struct ucma_file *file,
+ mutex_unlock(&ctx->file->mut);
+ wake_up_interruptible(&ctx->file->poll_wait);
+
++err_unlock:
++ rdma_unlock_handler(ctx->cm_id);
+ out:
+ ucma_put_ctx(ctx);
+ return ret;
+diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
+index 3ccf58e96aedeb..0d88b2ee68ffa1 100644
+--- a/drivers/infiniband/core/uverbs_main.c
++++ b/drivers/infiniband/core/uverbs_main.c
+@@ -556,6 +556,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
+ bundle.ufile = file;
+ bundle.context = NULL; /* only valid if bundle has uobject */
+ bundle.uobject = NULL;
++ bundle.method_elm = NULL;
+ if (!method_elm->is_ex) {
+ size_t in_len = hdr.in_words * 4 - sizeof(hdr);
+ size_t out_len = hdr.out_words * 4;
+diff --git a/drivers/infiniband/core/uverbs_std_types_mr.c b/drivers/infiniband/core/uverbs_std_types_mr.c
+index 570b9656801d72..0c72f801e0d32d 100644
+--- a/drivers/infiniband/core/uverbs_std_types_mr.c
++++ b/drivers/infiniband/core/uverbs_std_types_mr.c
+@@ -364,7 +364,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_REG_MR)(
+ dmah, attrs);
+ else
+ mr = pd->device->ops.reg_user_mr(pd, addr, length, iova,
+- access_flags, dmah, NULL);
++ access_flags, dmah,
++ &attrs->driver_udata);
+
+ if (IS_ERR(mr))
+ return PTR_ERR(mr);
+@@ -527,7 +528,8 @@ DECLARE_UVERBS_NAMED_METHOD(
+ UA_MANDATORY),
+ UVERBS_ATTR_PTR_OUT(UVERBS_ATTR_REG_MR_RESP_RKEY,
+ UVERBS_ATTR_TYPE(u32),
+- UA_MANDATORY));
++ UA_MANDATORY),
++ UVERBS_ATTR_UHW());
+
+ DECLARE_UVERBS_NAMED_METHOD_DESTROY(
+ UVERBS_METHOD_MR_DESTROY,
+diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
+index 102c5646b9ed61..c1815972aecff7 100644
+--- a/drivers/infiniband/hw/cxgb4/device.c
++++ b/drivers/infiniband/hw/cxgb4/device.c
+@@ -951,6 +951,12 @@ void c4iw_dealloc(struct uld_ctx *ctx)
+ static void c4iw_remove(struct uld_ctx *ctx)
+ {
+ pr_debug("c4iw_dev %p\n", ctx->dev);
++
++ /* c4iw_register_device() may still be using ctx->dev. */
++ cancel_work_sync(&ctx->reg_work);
++ if (!ctx->dev)
++ return;
++
+ debugfs_remove_recursive(ctx->dev->debugfs_root);
+ c4iw_unregister_device(ctx->dev);
+ c4iw_dealloc(ctx);
+diff --git a/drivers/infiniband/hw/ionic/ionic_hw_stats.c b/drivers/infiniband/hw/ionic/ionic_hw_stats.c
+index f72c9837e135ef..4f0a2dedbdfe78 100644
+--- a/drivers/infiniband/hw/ionic/ionic_hw_stats.c
++++ b/drivers/infiniband/hw/ionic/ionic_hw_stats.c
+@@ -235,35 +235,34 @@ err_dma:
+ static struct rdma_hw_stats *
+ ionic_counter_alloc_stats(struct rdma_counter *counter)
+ {
++ struct ionic_rdma_counter *cntr = to_ionic_rdma_counter(counter);
+ struct ionic_ibdev *dev = to_ionic_ibdev(counter->device);
+- struct ionic_counter *cntr;
+- int err;
++ struct rdma_hw_stats *stats;
++ int id;
+
+- cntr = kzalloc_obj(*cntr);
+- if (!cntr)
+- return NULL;
+-
+- /* buffer for current values from the device */
+ cntr->vals = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!cntr->vals)
+- goto err_vals;
++ return NULL;
+
+- err = xa_alloc(&dev->counter_stats->xa_counters, &counter->id,
+- cntr,
+- XA_LIMIT(0, IONIC_MAX_QPID),
+- GFP_KERNEL);
+- if (err)
+- goto err_xa;
++ id = ida_alloc_max(&dev->counter_stats->counter_ida,
++ IONIC_MAX_QPID, GFP_KERNEL);
++ if (id < 0)
++ goto err_ida;
+
+- INIT_LIST_HEAD(&cntr->qp_list);
++ counter->id = id;
++
++ stats = rdma_alloc_hw_stats_struct(dev->counter_stats->stats_hdrs,
++ dev->counter_stats->queue_stats_count,
++ RDMA_HW_STATS_DEFAULT_LIFESPAN);
++ if (!stats)
++ goto err_hw_stats;
++
++ return stats;
+
+- return rdma_alloc_hw_stats_struct(dev->counter_stats->stats_hdrs,
+- dev->counter_stats->queue_stats_count,
+- RDMA_HW_STATS_DEFAULT_LIFESPAN);
+-err_xa:
++err_hw_stats:
++ ida_free(&dev->counter_stats->counter_ida, id);
++err_ida:
+ kfree(cntr->vals);
+-err_vals:
+- kfree(cntr);
+
+ return NULL;
+ }
+@@ -271,14 +270,10 @@ err_vals:
+ static int ionic_counter_dealloc(struct rdma_counter *counter)
+ {
+ struct ionic_ibdev *dev = to_ionic_ibdev(counter->device);
+- struct ionic_counter *cntr;
+-
+- cntr = xa_erase(&dev->counter_stats->xa_counters, counter->id);
+- if (!cntr)
+- return -EINVAL;
++ struct ionic_rdma_counter *cntr = to_ionic_rdma_counter(counter);
+
++ ida_free(&dev->counter_stats->counter_ida, counter->id);
+ kfree(cntr->vals);
+- kfree(cntr);
+
+ return 0;
+ }
+@@ -287,13 +282,8 @@ static int ionic_counter_bind_qp(struct rdma_counter *counter,
+ struct ib_qp *ibqp,
+ u32 port)
+ {
+- struct ionic_ibdev *dev = to_ionic_ibdev(counter->device);
++ struct ionic_rdma_counter *cntr = to_ionic_rdma_counter(counter);
+ struct ionic_qp *qp = to_ionic_qp(ibqp);
+- struct ionic_counter *cntr;
+-
+- cntr = xa_load(&dev->counter_stats->xa_counters, counter->id);
+- if (!cntr)
+- return -EINVAL;
+
+ list_add_tail(&qp->qp_list_counter, &cntr->qp_list);
+ ibqp->counter = counter;
+@@ -313,29 +303,23 @@ static int ionic_counter_unbind_qp(struct ib_qp *ibqp, u32 port)
+ return 0;
+ }
+
+-static int ionic_get_qp_stats(struct ib_device *ibdev,
+- struct rdma_hw_stats *hw_stats,
+- u32 counter_id)
++static int ionic_counter_update_stats(struct rdma_counter *counter)
+ {
+- struct ionic_ibdev *dev = to_ionic_ibdev(ibdev);
+- struct ionic_counter_stats *cs;
+- struct ionic_counter *cntr;
++ struct ionic_rdma_counter *cntr = to_ionic_rdma_counter(counter);
++ struct ionic_ibdev *dev = to_ionic_ibdev(counter->device);
++ struct ionic_counter_stats *cs = dev->counter_stats;
+ dma_addr_t hw_stats_dma;
+ struct ionic_qp *qp;
+ int rc, stat_i = 0;
+
+- cs = dev->counter_stats;
+- cntr = xa_load(&cs->xa_counters, counter_id);
+- if (!cntr)
+- return -EINVAL;
+-
+ hw_stats_dma = dma_map_single(dev->lif_cfg.hwdev, cntr->vals,
+ PAGE_SIZE, DMA_FROM_DEVICE);
+ rc = dma_mapping_error(dev->lif_cfg.hwdev, hw_stats_dma);
+ if (rc)
+ return rc;
+
+- memset(hw_stats->value, 0, sizeof(u64) * hw_stats->num_counters);
++ memset(counter->stats->value, 0,
++ sizeof(u64) * counter->stats->num_counters);
+
+ list_for_each_entry(qp, &cntr->qp_list, qp_list_counter) {
+ rc = ionic_hw_stats_cmd(dev, hw_stats_dma, PAGE_SIZE,
+@@ -345,7 +329,7 @@ static int ionic_get_qp_stats(struct ib_device *ibdev,
+ goto err_cmd;
+
+ for (stat_i = 0; stat_i < cs->queue_stats_count; ++stat_i)
+- hw_stats->value[stat_i] +=
++ counter->stats->value[stat_i] +=
+ ionic_v1_stat_val(&cs->hdr[stat_i],
+ cntr->vals,
+ PAGE_SIZE);
+@@ -360,11 +344,6 @@ err_cmd:
+ return rc;
+ }
+
+-static int ionic_counter_update_stats(struct rdma_counter *counter)
+-{
+- return ionic_get_qp_stats(counter->device, counter->stats, counter->id);
+-}
+-
+ static int ionic_alloc_counters(struct ionic_ibdev *dev)
+ {
+ struct ionic_counter_stats *cs = dev->counter_stats;
+@@ -424,12 +403,22 @@ static const struct ib_device_ops ionic_hw_stats_ops = {
+ .get_hw_stats = ionic_get_hw_stats,
+ };
+
++static void ionic_counter_init(struct rdma_counter *counter)
++{
++ struct ionic_rdma_counter *cntr = to_ionic_rdma_counter(counter);
++
++ INIT_LIST_HEAD(&cntr->qp_list);
++}
++
+ static const struct ib_device_ops ionic_counter_stats_ops = {
+ .counter_alloc_stats = ionic_counter_alloc_stats,
+ .counter_dealloc = ionic_counter_dealloc,
+ .counter_bind_qp = ionic_counter_bind_qp,
+ .counter_unbind_qp = ionic_counter_unbind_qp,
+ .counter_update_stats = ionic_counter_update_stats,
++ .counter_init = ionic_counter_init,
++
++ INIT_RDMA_OBJ_SIZE(rdma_counter, ionic_rdma_counter, rdma_counter),
+ };
+
+ void ionic_stats_init(struct ionic_ibdev *dev)
+@@ -458,7 +447,7 @@ void ionic_stats_init(struct ionic_ibdev *dev)
+ return;
+ }
+
+- xa_init_flags(&dev->counter_stats->xa_counters, XA_FLAGS_ALLOC);
++ ida_init(&dev->counter_stats->counter_ida);
+
+ ib_set_device_ops(&dev->ibdev, &ionic_counter_stats_ops);
+ }
+@@ -467,7 +456,7 @@ void ionic_stats_init(struct ionic_ibdev *dev)
+ void ionic_stats_cleanup(struct ionic_ibdev *dev)
+ {
+ if (dev->counter_stats) {
+- xa_destroy(&dev->counter_stats->xa_counters);
++ ida_destroy(&dev->counter_stats->counter_ida);
+ kfree(dev->counter_stats->hdr);
+ kfree(dev->counter_stats->stats_hdrs);
+ kfree(dev->counter_stats);
+diff --git a/drivers/infiniband/hw/ionic/ionic_ibdev.h b/drivers/infiniband/hw/ionic/ionic_ibdev.h
+index 63828240d6590b..1c43344ec93ce1 100644
+--- a/drivers/infiniband/hw/ionic/ionic_ibdev.h
++++ b/drivers/infiniband/hw/ionic/ionic_ibdev.h
+@@ -331,14 +331,21 @@ struct ionic_counter_stats {
+ int queue_stats_count;
+ struct ionic_v1_stat *hdr;
+ struct rdma_stat_desc *stats_hdrs;
+- struct xarray xa_counters;
++ struct ida counter_ida;
+ };
+
+-struct ionic_counter {
++struct ionic_rdma_counter {
++ struct rdma_counter rdma_counter;
+ void *vals;
+ struct list_head qp_list;
+ };
+
++static inline struct ionic_rdma_counter *
++to_ionic_rdma_counter(struct rdma_counter *counter)
++{
++ return container_of(counter, struct ionic_rdma_counter, rdma_counter);
++}
++
+ static inline struct ionic_ibdev *to_ionic_ibdev(struct ib_device *ibdev)
+ {
+ return container_of(ibdev, struct ionic_ibdev, ibdev);
+diff --git a/drivers/infiniband/hw/ionic/ionic_lif_cfg.c b/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
+index f3cd281c3a2f86..45846dc2e89b2d 100644
+--- a/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
++++ b/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
+@@ -70,7 +70,7 @@ void ionic_fill_lif_cfg(struct ionic_lif *lif, struct ionic_lif_cfg *cfg)
+ * eq_count is tunable; see ionic_eq_count
+ */
+ cfg->aq_count = le32_to_cpu(ident->rdma.aq_qtype.qid_count);
+- cfg->eq_count = le32_to_cpu(ident->rdma.eq_qtype.qid_count);
++ cfg->eq_count = lif->ionic->neqs_per_lif;
+ cfg->cq_count = le32_to_cpu(ident->rdma.cq_qtype.qid_count);
+ cfg->qp_count = le32_to_cpu(ident->rdma.sq_qtype.qid_count);
+ cfg->dbid_count = le32_to_cpu(lif->ionic->ident.dev.ndbpgs_per_lif);
+diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
+index 73a9db2c7537ff..4aa991a5410183 100644
+--- a/drivers/interconnect/core.c
++++ b/drivers/interconnect/core.c
+@@ -548,7 +548,7 @@ struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
+ path->name = kasprintf(GFP_KERNEL, "%s-%s",
+ src_data->node->name, dst_data->node->name);
+ if (!path->name) {
+- kfree(path);
++ icc_put(path);
+ path = ERR_PTR(-ENOMEM);
+ }
+
+@@ -646,8 +646,9 @@ struct icc_path *icc_get(struct device *dev, const char *src, const char *dst)
+
+ path->name = kasprintf(GFP_KERNEL, "%s-%s", src_node->name, dst_node->name);
+ if (!path->name) {
+- kfree(path);
+- path = ERR_PTR(-ENOMEM);
++ mutex_unlock(&icc_lock);
++ icc_put(path);
++ return ERR_PTR(-ENOMEM);
+ }
+ out:
+ mutex_unlock(&icc_lock);
+diff --git a/drivers/iommu/amd/ppr.c b/drivers/iommu/amd/ppr.c
+index 1f8d2823bea42c..80369ca1e316ef 100644
+--- a/drivers/iommu/amd/ppr.c
++++ b/drivers/iommu/amd/ppr.c
+@@ -151,7 +151,7 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw)
+
+ /* Submit event */
+ iommu_report_device_fault(&pdev->dev, &event);
+-
++ pci_dev_put(pdev);
+ return;
+
+ out:
+@@ -159,6 +159,7 @@ out:
+ amd_iommu_complete_ppr(&pdev->dev, PPR_PASID(raw[0]),
+ IOMMU_PAGE_RESP_FAILURE,
+ PPR_TAG(raw[0]) & 0x1FF);
++ pci_dev_put(pdev);
+ }
+
+ void amd_iommu_poll_ppr_log(struct amd_iommu *iommu)
+diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
+index 1ed8a6f29dc445..4cd60d3c450acc 100644
+--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
++++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
+@@ -92,16 +92,6 @@ void arm_smmu_make_sva_cd(struct arm_smmu_cd *target,
+
+ target->data[1] = cpu_to_le64(virt_to_phys(mm->pgd) &
+ CTXDESC_CD_1_TTB0_MASK);
+-
+- /*
+- * Enable Hardware Access and Dirty updates (DBM) if supported.
+- * This is safe to enable by default, as PTE_WRITE and PTE_DBM
+- * share the same bit.
+- */
+- if (master->smmu->features & ARM_SMMU_FEAT_HA)
+- target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA);
+- if (master->smmu->features & ARM_SMMU_FEAT_HD)
+- target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HD);
+ } else {
+ target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_EPD0);
+
+@@ -114,6 +104,17 @@ void arm_smmu_make_sva_cd(struct arm_smmu_cd *target,
+ target->data[0] &=
+ cpu_to_le64(~(CTXDESC_CD_0_S | CTXDESC_CD_0_R));
+ }
++ /*
++ * Enable Hardware Access and Dirty updates (DBM) if supported. This is
++ * safe to enable by default, as PTE_WRITE and PTE_DBM share the same bit,
++ * while the EPD0 config can't get as far as fetching any PTEs anyway.
++ */
++ if (master->smmu->features & ARM_SMMU_FEAT_HA)
++ target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HA);
++ if (master->smmu->features & ARM_SMMU_FEAT_HD)
++ target->data[0] |= cpu_to_le64(CTXDESC_CD_0_TCR_HD);
++ if (master->smmu->features & ARM_SMMU_FEAT_HAFT && system_supports_haft())
++ target->data[1] |= cpu_to_le64(CTXDESC_CD_1_HAFT);
+
+ /*
+ * MAIR value is pretty much constant and global, so we can just get it
+@@ -211,6 +212,9 @@ bool arm_smmu_sva_supported(struct arm_smmu_device *smmu)
+ if (system_supports_bbml2_noabort())
+ feat_mask |= ARM_SMMU_FEAT_BBML2;
+
++ if (system_supports_haft())
++ feat_mask |= ARM_SMMU_FEAT_HAFT;
++
+ if ((smmu->features & feat_mask) != feat_mask)
+ return false;
+
+diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+index 10f105a0b29fad..5f933d806a1478 100644
+--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
++++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+@@ -4398,6 +4398,20 @@ int arm_smmu_cmdq_init(struct arm_smmu_device *smmu,
+ return 0;
+ }
+
++static void arm_smmu_free_iopf_action(void *data)
++{
++ struct iopf_queue *queue = data;
++
++ iopf_queue_free(queue);
++}
++
++static void arm_smmu_destroy_vmid_map(void *data)
++{
++ struct ida *ida = data;
++
++ ida_destroy(ida);
++}
++
+ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
+ {
+ int ret;
+@@ -4425,6 +4439,11 @@ static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
+ smmu->evtq.iopf = iopf_queue_alloc(dev_name(smmu->dev));
+ if (!smmu->evtq.iopf)
+ return -ENOMEM;
++ ret = devm_add_action_or_reset(smmu->dev,
++ arm_smmu_free_iopf_action,
++ smmu->evtq.iopf);
++ if (ret)
++ return ret;
+ }
+
+ /* priq */
+@@ -4503,7 +4522,8 @@ static int arm_smmu_init_strtab(struct arm_smmu_device *smmu)
+
+ ida_init(&smmu->vmid_map);
+
+- return 0;
++ return devm_add_action_or_reset(smmu->dev, arm_smmu_destroy_vmid_map,
++ &smmu->vmid_map);
+ }
+
+ static int arm_smmu_init_structures(struct arm_smmu_device *smmu)
+@@ -4716,6 +4736,13 @@ static int arm_smmu_device_disable(struct arm_smmu_device *smmu)
+ return ret;
+ }
+
++static void arm_smmu_disable_action(void *data)
++{
++ struct arm_smmu_device *smmu = data;
++
++ arm_smmu_device_disable(smmu);
++}
++
+ static void arm_smmu_write_strtab(struct arm_smmu_device *smmu)
+ {
+ struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
+@@ -4921,10 +4948,14 @@ static void arm_smmu_device_iidr_probe(struct arm_smmu_device *smmu)
+
+ static void arm_smmu_get_httu(struct arm_smmu_device *smmu, u32 reg)
+ {
+- u32 fw_features = smmu->features & (ARM_SMMU_FEAT_HA | ARM_SMMU_FEAT_HD);
++ u32 fw_features = smmu->features & (ARM_SMMU_FEAT_HA | ARM_SMMU_FEAT_HD |
++ ARM_SMMU_FEAT_HAFT);
+ u32 hw_features = 0;
+
+ switch (FIELD_GET(IDR0_HTTU, reg)) {
++ case IDR0_HTTU_ACCESS_DIRTY_HAFT:
++ hw_features |= ARM_SMMU_FEAT_HAFT;
++ fallthrough;
+ case IDR0_HTTU_ACCESS_DIRTY:
+ hw_features |= ARM_SMMU_FEAT_HD;
+ fallthrough;
+@@ -5256,6 +5287,9 @@ static int arm_smmu_device_acpi_probe(struct platform_device *pdev,
+ smmu->features |= ARM_SMMU_FEAT_COHERENCY;
+
+ switch (FIELD_GET(ACPI_IORT_SMMU_V3_HTTU_OVERRIDE, iort_smmu->flags)) {
++ case IDR0_HTTU_ACCESS_DIRTY_HAFT:
++ smmu->features |= ARM_SMMU_FEAT_HAFT;
++ fallthrough;
+ case IDR0_HTTU_ACCESS_DIRTY:
+ smmu->features |= ARM_SMMU_FEAT_HD;
+ fallthrough;
+@@ -5472,7 +5506,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
+ /* Initialise in-memory data structures */
+ ret = arm_smmu_init_structures(smmu);
+ if (ret)
+- goto err_free_iopf;
++ return ret;
+
+ /* Record our private device structure */
+ platform_set_drvdata(pdev, smmu);
+@@ -5482,30 +5516,30 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
+
+ /* Reset the device */
+ ret = arm_smmu_device_reset(smmu);
++ if (ret) {
++ arm_smmu_device_disable(smmu);
++ return ret;
++ }
++
++ /* Register last so it unwinds first, while the CMDQ is still up. */
++ ret = devm_add_action_or_reset(smmu->dev, arm_smmu_disable_action, smmu);
+ if (ret)
+- goto err_disable;
++ return ret;
+
+ /* And we're up. Go go go! */
+ ret = iommu_device_sysfs_add(&smmu->iommu, dev, NULL,
+ "smmu3.%pa", &ioaddr);
+ if (ret)
+- goto err_disable;
++ return ret;
+
+ ret = iommu_device_register(&smmu->iommu, &arm_smmu_ops, dev);
+ if (ret) {
+ dev_err(dev, "Failed to register iommu\n");
+- goto err_free_sysfs;
++ iommu_device_sysfs_remove(&smmu->iommu);
++ return ret;
+ }
+
+ return 0;
+-
+-err_free_sysfs:
+- iommu_device_sysfs_remove(&smmu->iommu);
+-err_disable:
+- arm_smmu_device_disable(smmu);
+-err_free_iopf:
+- iopf_queue_free(smmu->evtq.iopf);
+- return ret;
+ }
+
+ static void arm_smmu_device_remove(struct platform_device *pdev)
+@@ -5514,9 +5548,6 @@ static void arm_smmu_device_remove(struct platform_device *pdev)
+
+ iommu_device_unregister(&smmu->iommu);
+ iommu_device_sysfs_remove(&smmu->iommu);
+- arm_smmu_device_disable(smmu);
+- iopf_queue_free(smmu->evtq.iopf);
+- ida_destroy(&smmu->vmid_map);
+ }
+
+ static void arm_smmu_device_shutdown(struct platform_device *pdev)
+diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
+index 1c4877ada1eef0..6859570248e9e8 100644
+--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
++++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
+@@ -40,6 +40,7 @@ struct arm_vsmmu;
+ #define IDR0_HTTU GENMASK(7, 6)
+ #define IDR0_HTTU_ACCESS 1
+ #define IDR0_HTTU_ACCESS_DIRTY 2
++#define IDR0_HTTU_ACCESS_DIRTY_HAFT 3
+ #define IDR0_COHACC (1 << 4)
+ #define IDR0_TTF GENMASK(3, 2)
+ #define IDR0_TTF_AARCH64 2
+@@ -369,6 +370,7 @@ static inline unsigned int arm_smmu_cdtab_l2_idx(unsigned int ssid)
+ #define CTXDESC_CD_0_ASET (1UL << 47)
+ #define CTXDESC_CD_0_ASID GENMASK_ULL(63, 48)
+
++#define CTXDESC_CD_1_HAFT (1UL << 3)
+ #define CTXDESC_CD_1_TTB0_MASK GENMASK_ULL(51, 4)
+
+ /*
+@@ -922,6 +924,7 @@ struct arm_smmu_device {
+ #define ARM_SMMU_FEAT_HD (1 << 22)
+ #define ARM_SMMU_FEAT_S2FWB (1 << 23)
+ #define ARM_SMMU_FEAT_BBML2 (1 << 24)
++#define ARM_SMMU_FEAT_HAFT (1 << 25)
+ u32 features;
+
+ #define ARM_SMMU_OPT_SKIP_PREFETCH (1 << 0)
+diff --git a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
+index aaf9ce38bd93f0..e5f52c0f6e9adf 100644
+--- a/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
++++ b/drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c
+@@ -56,6 +56,8 @@
+ #define VINTF_ENABLED BIT(0)
+
+ #define TEGRA241_VINTF_SID_MATCH(s) (0x0040 + 0x4*(s))
++#define VINTF_SID_MATCH_VIRT_SID GENMASK(20, 1)
++#define VINTF_SID_MATCH_ENABLE BIT(0)
+ #define TEGRA241_VINTF_SID_REPLACE(s) (0x0080 + 0x4*(s))
+
+ #define TEGRA241_VINTF_LVCMDQ_ERR_MAP_64(m) \
+@@ -1189,7 +1191,7 @@ static int tegra241_vintf_init_vsid(struct iommufd_vdevice *vdev)
+ u64 virt_sid = vdev->virt_id;
+ int sidx;
+
+- if (virt_sid > UINT_MAX)
++ if (virt_sid > FIELD_MAX(VINTF_SID_MATCH_VIRT_SID))
+ return -EINVAL;
+
+ WARN_ON_ONCE(master->num_streams != 1);
+@@ -1201,7 +1203,9 @@ static int tegra241_vintf_init_vsid(struct iommufd_vdevice *vdev)
+ return sidx;
+
+ writel(stream->id, REG_VINTF(vintf, SID_REPLACE(sidx)));
+- writel(virt_sid << 1 | 0x1, REG_VINTF(vintf, SID_MATCH(sidx)));
++ writel(FIELD_PREP(VINTF_SID_MATCH_VIRT_SID, virt_sid) |
++ VINTF_SID_MATCH_ENABLE,
++ REG_VINTF(vintf, SID_MATCH(sidx)));
+ dev_dbg(vintf->cmdqv->dev,
+ "VINTF%u: allocated SID_REPLACE%d for pSID=%x, vSID=%x\n",
+ vintf->idx, sidx, stream->id, (u32)virt_sid);
+diff --git a/drivers/iommu/generic_pt/iommu_pt.h b/drivers/iommu/generic_pt/iommu_pt.h
+index c2752151c80af1..07ec2b3ab986a6 100644
+--- a/drivers/iommu/generic_pt/iommu_pt.h
++++ b/drivers/iommu/generic_pt/iommu_pt.h
+@@ -224,7 +224,7 @@ phys_addr_t DOMAIN_NS(iova_to_phys)(struct iommu_domain *domain,
+
+ ret = make_range(common_from_iommu(iommu_table), &range, iova, 1);
+ if (ret)
+- return ret;
++ return 0;
+
+ ret = pt_walk_range(&range, __iova_to_phys, &res);
+ /* PHYS_ADDR_MAX would be a better error code */
+diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
+index 767ec092accd75..e32685402f74b7 100644
+--- a/drivers/iommu/intel/dmar.c
++++ b/drivers/iommu/intel/dmar.c
+@@ -915,6 +915,18 @@ dmar_validate_one_drhd(struct acpi_dmar_header *entry, void *arg)
+ return 0;
+ }
+
++static bool dmar_required(void)
++{
++ /* tboot supersedes any user/platform opt */
++ if (!intel_iommu_tboot_noforce && tboot_enabled())
++ return true;
++
++ if (!no_iommu && (!dmar_disabled || dmar_platform_optin()))
++ return true;
++
++ return false;
++}
++
+ void __init detect_intel_iommu(void)
+ {
+ int ret;
+@@ -928,8 +940,7 @@ void __init detect_intel_iommu(void)
+ if (!ret)
+ ret = dmar_walk_dmar_table((struct acpi_table_dmar *)dmar_tbl,
+ &validate_drhd_cb);
+- if (!ret && !no_iommu && !iommu_detected &&
+- (!dmar_disabled || dmar_platform_optin())) {
++ if (!ret && !iommu_detected && dmar_required()) {
+ iommu_detected = 1;
+ /* Make sure ACS will be enabled */
+ pci_request_acs();
+diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
+index 849d06dfe1aecf..4e7ba60f3a0a22 100644
+--- a/drivers/iommu/intel/iommu.c
++++ b/drivers/iommu/intel/iommu.c
+@@ -57,7 +57,7 @@ static int rwbf_quirk;
+ * (used when kernel is launched w/ TXT)
+ */
+ static int force_on = 0;
+-static int intel_iommu_tboot_noforce;
++int intel_iommu_tboot_noforce;
+ static int no_platform_optin;
+
+ #define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
+@@ -2482,10 +2482,11 @@ static bool has_external_pci(void)
+
+ static int __init platform_optin_force_iommu(void)
+ {
+- if (!dmar_platform_optin() || no_platform_optin || !has_external_pci())
++ if (no_iommu || !dmar_platform_optin() || no_platform_optin ||
++ !has_external_pci())
+ return 0;
+
+- if (no_iommu || dmar_disabled)
++ if (dmar_disabled)
+ pr_info("Intel-IOMMU force enabled due to platform opt in\n");
+
+ /*
+@@ -2496,7 +2497,6 @@ static int __init platform_optin_force_iommu(void)
+ iommu_set_default_passthrough(false);
+
+ dmar_disabled = 0;
+- no_iommu = 0;
+
+ return 1;
+ }
+diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
+index 775f1c4ae34632..2cee36138d6e1e 100644
+--- a/drivers/iommu/intel/iommu.h
++++ b/drivers/iommu/intel/iommu.h
+@@ -1354,6 +1354,7 @@ static inline bool ecmd_has_pmu_essential(struct intel_iommu *iommu)
+
+ extern int dmar_disabled;
+ extern int intel_iommu_enabled;
++extern int intel_iommu_tboot_noforce;
+ #else
+ static inline int iommu_calculate_agaw(struct intel_iommu *iommu)
+ {
+@@ -1366,6 +1367,7 @@ static inline int iommu_calculate_max_sagaw(struct intel_iommu *iommu)
+ #define dmar_disabled (1)
+ #define intel_iommu_enabled (0)
+ #define intel_iommu_sm (0)
++#define intel_iommu_tboot_noforce (0)
+ #endif
+
+ static inline const char *decode_prq_descriptor(char *str, size_t size,
+diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
+index bc7c7232a43e2d..9742cb593577df 100644
+--- a/drivers/iommu/iommu-sva.c
++++ b/drivers/iommu/iommu-sva.c
+@@ -145,8 +145,8 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
+ list_add(&domain->next, &iommu_mm->sva_domains);
+ out:
+ refcount_set(&handle->users, 1);
+- mutex_unlock(&iommu_sva_lock);
+ handle->dev = dev;
++ mutex_unlock(&iommu_sva_lock);
+ return handle;
+
+ out_free_domain:
+diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
+index e8f13dcebbde50..23a531595835f4 100644
+--- a/drivers/iommu/iommu.c
++++ b/drivers/iommu/iommu.c
+@@ -390,7 +390,7 @@ int iommu_mock_device_add(struct device *dev, struct iommu_device *iommu)
+
+ rc = device_add(dev);
+ if (rc)
+- iommu_fwspec_free(dev);
++ dev_iommu_free(dev);
+ return rc;
+ }
+ EXPORT_SYMBOL_GPL(iommu_mock_device_add);
+diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
+index 2895e5370910fe..d488c23fd35383 100644
+--- a/drivers/iommu/iommufd/device.c
++++ b/drivers/iommu/iommufd/device.c
+@@ -1307,8 +1307,8 @@ void iommufd_access_notify_unmap(struct io_pagetable *iopt, unsigned long iova,
+
+ xa_lock(&ioas->iopt.access_list);
+ xa_for_each(&ioas->iopt.access_list, index, access) {
+- if (!iommufd_lock_obj(&access->obj) ||
+- iommufd_access_is_internal(access))
++ if (iommufd_access_is_internal(access) ||
++ !iommufd_lock_obj(&access->obj))
+ continue;
+ xa_unlock(&ioas->iopt.access_list);
+
+diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c
+index 71bffece84b593..3459776871e6c6 100644
+--- a/drivers/iommu/iommufd/ioas.c
++++ b/drivers/iommu/iommufd/ioas.c
+@@ -427,6 +427,8 @@ static int iommufd_take_all_iova_rwsem(struct iommufd_ctx *ictx,
+
+ rc = xa_err(xa_store(ioas_list, index, ioas, GFP_KERNEL));
+ if (rc) {
++ up_write(&ioas->iopt.iova_rwsem);
++ refcount_dec(&ioas->obj.users);
+ iommufd_release_all_iova_rwsem(ictx, ioas_list);
+ return rc;
+ }
+diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
+index af07c642a5260e..727b59799d5f08 100644
+--- a/drivers/iommu/iommufd/selftest.c
++++ b/drivers/iommu/iommufd/selftest.c
+@@ -177,6 +177,7 @@ struct mock_dev {
+ struct device dev;
+ struct mock_viommu *viommu;
+ struct rw_semaphore viommu_rwsem;
++ struct rw_semaphore iopf_rwsem;
+ unsigned long flags;
+ unsigned long vdev_id;
+ int id;
+@@ -997,6 +998,7 @@ static struct mock_dev *mock_dev_create(unsigned long dev_flags)
+ return ERR_PTR(-ENOMEM);
+
+ init_rwsem(&mdev->viommu_rwsem);
++ init_rwsem(&mdev->iopf_rwsem);
+ device_initialize(&mdev->dev);
+ mdev->flags = dev_flags;
+ mdev->dev.release = mock_dev_release;
+@@ -1022,7 +1024,9 @@ static struct mock_dev *mock_dev_create(unsigned long dev_flags)
+ goto err_put;
+ }
+
++ down_write(&mdev->iopf_rwsem);
+ rc = iommu_mock_device_add(&mdev->dev, &mock_iommu.iommu_dev);
++ up_write(&mdev->iopf_rwsem);
+ if (rc)
+ goto err_put;
+ return mdev;
+@@ -1077,7 +1081,9 @@ static int iommufd_test_mock_domain(struct iommufd_ucmd *ucmd,
+ }
+ sobj->idev.idev = idev;
+
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ rc = iommufd_device_attach(idev, IOMMU_NO_PASID, &pt_id);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ if (rc)
+ goto out_unbind;
+
+@@ -1092,7 +1098,9 @@ static int iommufd_test_mock_domain(struct iommufd_ucmd *ucmd,
+ return 0;
+
+ out_detach:
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ iommufd_device_detach(idev, IOMMU_NO_PASID);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ out_unbind:
+ iommufd_device_unbind(idev);
+ out_mdev:
+@@ -1136,7 +1144,9 @@ static int iommufd_test_mock_domain_replace(struct iommufd_ucmd *ucmd,
+ if (IS_ERR(sobj))
+ return PTR_ERR(sobj);
+
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ rc = iommufd_device_replace(sobj->idev.idev, IOMMU_NO_PASID, &pt_id);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ if (rc)
+ goto out_sobj;
+
+@@ -1739,10 +1749,16 @@ static int iommufd_test_trigger_iopf(struct iommufd_ucmd *ucmd,
+ {
+ struct iopf_fault event = {};
+ struct iommufd_device *idev;
++ struct mock_dev *mdev;
+
+ idev = iommufd_get_device(ucmd, cmd->trigger_iopf.dev_id);
+ if (IS_ERR(idev))
+ return PTR_ERR(idev);
++ if (!iommufd_selftest_is_mock_dev(idev->dev)) {
++ iommufd_put_object(ucmd->ictx, &idev->obj);
++ return -EINVAL;
++ }
++ mdev = to_mock_dev(idev->dev);
+
+ event.fault.prm.flags = IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
+ if (cmd->trigger_iopf.pasid != IOMMU_NO_PASID)
+@@ -1753,7 +1769,9 @@ static int iommufd_test_trigger_iopf(struct iommufd_ucmd *ucmd,
+ event.fault.prm.grpid = cmd->trigger_iopf.grpid;
+ event.fault.prm.perm = cmd->trigger_iopf.perm;
+
++ down_read(&mdev->iopf_rwsem);
+ iommu_report_device_fault(idev->dev, &event);
++ up_read(&mdev->iopf_rwsem);
+ iommufd_put_object(ucmd->ictx, &idev->obj);
+
+ return 0;
+@@ -1861,14 +1879,19 @@ static int iommufd_test_pasid_attach(struct iommufd_ucmd *ucmd,
+ if (IS_ERR(sobj))
+ return PTR_ERR(sobj);
+
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ rc = iommufd_device_attach(sobj->idev.idev, cmd->pasid_attach.pasid,
+ &cmd->pasid_attach.pt_id);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ if (rc)
+ goto out_sobj;
+
+ rc = iommufd_ucmd_respond(ucmd, sizeof(*cmd));
+- if (rc)
++ if (rc) {
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ iommufd_device_detach(sobj->idev.idev, cmd->pasid_attach.pasid);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
++ }
+
+ out_sobj:
+ iommufd_put_object(ucmd->ictx, &sobj->obj);
+@@ -1885,8 +1908,10 @@ static int iommufd_test_pasid_replace(struct iommufd_ucmd *ucmd,
+ if (IS_ERR(sobj))
+ return PTR_ERR(sobj);
+
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ rc = iommufd_device_replace(sobj->idev.idev, cmd->pasid_attach.pasid,
+ &cmd->pasid_attach.pt_id);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ if (rc)
+ goto out_sobj;
+
+@@ -1906,7 +1931,9 @@ static int iommufd_test_pasid_detach(struct iommufd_ucmd *ucmd,
+ if (IS_ERR(sobj))
+ return PTR_ERR(sobj);
+
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ iommufd_device_detach(sobj->idev.idev, cmd->pasid_detach.pasid);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ iommufd_put_object(ucmd->ictx, &sobj->obj);
+ return 0;
+ }
+@@ -1917,7 +1944,9 @@ void iommufd_selftest_destroy(struct iommufd_object *obj)
+
+ switch (sobj->type) {
+ case TYPE_IDEV:
++ down_write(&sobj->idev.mock_dev->iopf_rwsem);
+ iommufd_device_detach(sobj->idev.idev, IOMMU_NO_PASID);
++ up_write(&sobj->idev.mock_dev->iopf_rwsem);
+ iommufd_device_unbind(sobj->idev.idev);
+ mock_dev_destroy(sobj->idev.mock_dev);
+ break;
+diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
+index 0ad5ff431d5b6e..d0d926be7495cf 100644
+--- a/drivers/iommu/msm_iommu.c
++++ b/drivers/iommu/msm_iommu.c
+@@ -784,19 +784,25 @@ static int msm_iommu_probe(struct platform_device *pdev)
+ "msm-smmu.%pa", &ioaddr);
+ if (ret) {
+ pr_err("Could not add msm-smmu at %pa to sysfs\n", &ioaddr);
+- return ret;
++ goto err_remove_list;
+ }
+
+ ret = iommu_device_register(&iommu->iommu, &msm_iommu_ops, &pdev->dev);
+ if (ret) {
+ pr_err("Could not register msm-smmu at %pa\n", &ioaddr);
+- return ret;
++ goto err_remove_sysfs;
+ }
+
+ pr_info("device mapped at %p, irq %d with %d ctx banks\n",
+ iommu->base, iommu->irq, iommu->ncb);
+
+ return ret;
++
++err_remove_sysfs:
++ iommu_device_sysfs_remove(&iommu->iommu);
++err_remove_list:
++ list_del(&iommu->dev_node);
++ return ret;
+ }
+
+ static const struct of_device_id msm_iommu_dt_match[] = {
+diff --git a/drivers/mailbox/qcom-ipcc.c b/drivers/mailbox/qcom-ipcc.c
+index d957d989c0ceeb..dead907aa7a282 100644
+--- a/drivers/mailbox/qcom-ipcc.c
++++ b/drivers/mailbox/qcom-ipcc.c
+@@ -167,7 +167,7 @@ static struct mbox_chan *qcom_ipcc_mbox_xlate(struct mbox_controller *mbox,
+ {
+ struct qcom_ipcc *ipcc = to_qcom_ipcc(mbox);
+ struct qcom_ipcc_chan_info *mchan;
+- struct mbox_chan *chan;
++ struct mbox_chan *chan, *free_chan = NULL;
+ struct device *dev;
+ int chan_id;
+
+@@ -180,16 +180,21 @@ static struct mbox_chan *qcom_ipcc_mbox_xlate(struct mbox_controller *mbox,
+ chan = &ipcc->chans[chan_id];
+ mchan = chan->con_priv;
+
+- if (!mchan)
+- break;
+- else if (mchan->client_id == ph->args[0] &&
+- mchan->signal_id == ph->args[1])
++ if (!mchan) {
++ /* Keep scanning past holes to reject duplicate channel requests. */
++ if (!free_chan)
++ free_chan = chan;
++ } else if (mchan->client_id == ph->args[0] &&
++ mchan->signal_id == ph->args[1]) {
+ return ERR_PTR(-EBUSY);
++ }
+ }
+
+- if (chan_id >= mbox->num_chans)
++ if (!free_chan)
+ return ERR_PTR(-EBUSY);
+
++ chan = free_chan;
++
+ mchan = devm_kzalloc(dev, sizeof(*mchan), GFP_KERNEL);
+ if (!mchan)
+ return ERR_PTR(-ENOMEM);
+diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
+index a458b9fd2fcd62..d58eed96a8ff57 100644
+--- a/drivers/md/dm-bufio.c
++++ b/drivers/md/dm-bufio.c
+@@ -1287,11 +1287,11 @@ static void free_buffer(struct dm_buffer *b)
+ * dm-io completion routine. It just calls b->bio.bi_end_io, pretending
+ * that the request was handled directly with bio interface.
+ */
+-static void dmio_complete(unsigned long error, void *context)
++static void dmio_complete(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct dm_buffer *b = context;
+
+- b->end_io(b, unlikely(error != 0) ? BLK_STS_IOERR : 0);
++ b->end_io(b, unlikely(error != 0) ? BLK_STS_IOERR : unlikely(unsup != 0) ? BLK_STS_NOTSUPP : 0);
+ }
+
+ static void use_dmio(struct dm_buffer *b, enum req_op op, sector_t sector,
+@@ -1319,7 +1319,7 @@ static void use_dmio(struct dm_buffer *b, enum req_op op, sector_t sector,
+ io_req.mem.ptr.vma = (char *)b->data + offset;
+ }
+
+- r = dm_io(&io_req, 1, ®ion, NULL, ioprio);
++ r = dm_io(&io_req, 1, ®ion, NULL, NULL, ioprio);
+ if (unlikely(r))
+ b->end_io(b, errno_to_blk_status(r));
+ }
+@@ -2220,7 +2220,7 @@ int dm_bufio_issue_flush(struct dm_bufio_client *c)
+ if (WARN_ON_ONCE(dm_bufio_in_request()))
+ return -EINVAL;
+
+- return dm_io(&io_req, 1, &io_reg, NULL, IOPRIO_DEFAULT);
++ return dm_io(&io_req, 1, &io_reg, NULL, NULL, IOPRIO_DEFAULT);
+ }
+ EXPORT_SYMBOL_GPL(dm_bufio_issue_flush);
+
+@@ -2246,7 +2246,7 @@ int dm_bufio_issue_discard(struct dm_bufio_client *c, sector_t block, sector_t c
+ if (WARN_ON_ONCE(dm_bufio_in_request()))
+ return -EINVAL; /* discards are optional */
+
+- return dm_io(&io_req, 1, &io_reg, NULL, IOPRIO_DEFAULT);
++ return dm_io(&io_req, 1, &io_reg, NULL, NULL, IOPRIO_DEFAULT);
+ }
+ EXPORT_SYMBOL_GPL(dm_bufio_issue_discard);
+
+diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
+index 7fe4d19ade4f03..ea499adca4ce2a 100644
+--- a/drivers/md/dm-era-target.c
++++ b/drivers/md/dm-era-target.c
+@@ -1034,6 +1034,7 @@ static int metadata_checkpoint(struct era_metadata *md)
+ static int metadata_take_snap(struct era_metadata *md)
+ {
+ int r, inc;
++ dm_block_t location;
+ struct dm_block *clone;
+
+ if (md->metadata_snap != SUPERBLOCK_LOCATION) {
+@@ -1071,7 +1072,9 @@ static int metadata_take_snap(struct era_metadata *md)
+ r = dm_sm_inc_block(md->sm, md->writeset_tree_root);
+ if (r) {
+ DMERR("%s: couldn't inc writeset tree root", __func__);
++ location = dm_block_location(clone);
+ dm_tm_unlock(md->tm, clone);
++ dm_sm_dec_block(md->sm, location);
+ return r;
+ }
+
+@@ -1079,7 +1082,9 @@ static int metadata_take_snap(struct era_metadata *md)
+ if (r) {
+ DMERR("%s: couldn't inc era tree root", __func__);
+ dm_sm_dec_block(md->sm, md->writeset_tree_root);
++ location = dm_block_location(clone);
+ dm_tm_unlock(md->tm, clone);
++ dm_sm_dec_block(md->sm, location);
+ return r;
+ }
+
+diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
+index 1f2593f113f642..81d3f42c4f48c7 100644
+--- a/drivers/md/dm-integrity.c
++++ b/drivers/md/dm-integrity.c
+@@ -562,7 +562,7 @@ static int sync_rw_sb(struct dm_integrity_c *ic, blk_opf_t opf)
+ }
+ }
+
+- r = dm_io(&io_req, 1, &io_loc, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &io_loc, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r))
+ return r;
+
+@@ -1035,12 +1035,14 @@ static void encrypt_journal(struct dm_integrity_c *ic, bool encrypt, unsigned in
+ return crypt_journal(ic, encrypt, section, n_sections, comp);
+ }
+
+-static void complete_journal_io(unsigned long error, void *context)
++static void complete_journal_io(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct journal_completion *comp = context;
+
+ if (unlikely(error != 0))
+ dm_integrity_io_error(comp->ic, "writing journal", -EIO);
++ else if (unlikely(unsup != 0))
++ dm_integrity_io_error(comp->ic, "writing journal", -EOPNOTSUPP);
+ complete_journal_op(comp);
+ }
+
+@@ -1055,7 +1057,7 @@ static void rw_journal_sectors(struct dm_integrity_c *ic, blk_opf_t opf,
+
+ if (unlikely(dm_integrity_failed(ic))) {
+ if (comp)
+- complete_journal_io(-1UL, comp);
++ complete_journal_io(-1UL, -1UL, comp);
+ return;
+ }
+
+@@ -1080,13 +1082,13 @@ static void rw_journal_sectors(struct dm_integrity_c *ic, blk_opf_t opf,
+ io_loc.sector = ic->start + SB_SECTORS + sector;
+ io_loc.count = n_sectors;
+
+- r = dm_io(&io_req, 1, &io_loc, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &io_loc, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r)) {
+ dm_integrity_io_error(ic, (opf & REQ_OP_MASK) == REQ_OP_READ ?
+ "reading journal" : "writing journal", r);
+ if (comp) {
+ WARN_ONCE(1, "asynchronous dm_io failed: %d", r);
+- complete_journal_io(-1UL, comp);
++ complete_journal_io(-1UL, -1UL, comp);
+ }
+ }
+ }
+@@ -1177,7 +1179,7 @@ static void copy_from_journal(struct dm_integrity_c *ic, unsigned int section, u
+ BUG_ON((target | n_sectors | offset) & (unsigned int)(ic->sectors_per_block - 1));
+
+ if (unlikely(dm_integrity_failed(ic))) {
+- fn(-1UL, data);
++ fn(-1UL, -1UL, data);
+ return;
+ }
+
+@@ -1197,10 +1199,10 @@ static void copy_from_journal(struct dm_integrity_c *ic, unsigned int section, u
+ io_loc.sector = target;
+ io_loc.count = n_sectors;
+
+- r = dm_io(&io_req, 1, &io_loc, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &io_loc, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r)) {
+ WARN_ONCE(1, "asynchronous dm_io failed: %d", r);
+- fn(-1UL, data);
++ fn(-1UL, -1UL, data);
+ }
+ }
+
+@@ -1493,12 +1495,14 @@ struct flush_request {
+ struct completion comp;
+ };
+
+-static void flush_notify(unsigned long error, void *fr_)
++static void flush_notify(unsigned long error, unsigned long unsup, void *fr_)
+ {
+ struct flush_request *fr = fr_;
+
+ if (unlikely(error != 0))
+ dm_integrity_io_error(fr->ic, "flushing disk cache", -EIO);
++ else if (unlikely(unsup != 0))
++ dm_integrity_io_error(fr->ic, "flushing disk cache", -EOPNOTSUPP);
+ complete(&fr->comp);
+ }
+
+@@ -1521,7 +1525,7 @@ static void dm_integrity_flush_buffers(struct dm_integrity_c *ic, bool flush_dat
+ fr.io_reg.count = 0;
+ fr.ic = ic;
+ init_completion(&fr.comp);
+- r = dm_io(&fr.io_req, 1, &fr.io_reg, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&fr.io_req, 1, &fr.io_reg, NULL, NULL, IOPRIO_DEFAULT);
+ BUG_ON(r);
+ }
+
+@@ -1837,7 +1841,7 @@ static noinline void integrity_recheck(struct dm_integrity_io *dio, char *checks
+ buffer_offset = (sector - io_loc.sector) << SECTOR_SHIFT;
+ io_loc.count = round_up(io_loc.count, alignment);
+
+- r = dm_io(&io_req, 1, &io_loc, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &io_loc, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r)) {
+ dio->bi_status = errno_to_blk_status(r);
+ goto free_ret;
+@@ -2890,7 +2894,7 @@ release_flush_bios:
+ }
+ }
+
+-static void complete_copy_from_journal(unsigned long error, void *context)
++static void complete_copy_from_journal(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct journal_io *io = context;
+ struct journal_completion *comp = io->comp;
+@@ -2900,6 +2904,8 @@ static void complete_copy_from_journal(unsigned long error, void *context)
+ mempool_free(io, &ic->journal_io_mempool);
+ if (unlikely(error != 0))
+ dm_integrity_io_error(ic, "copying from journal", -EIO);
++ else if (unlikely(unsup != 0))
++ dm_integrity_io_error(ic, "copying from journal", -EOPNOTSUPP);
+ complete_journal_op(comp);
+ }
+
+@@ -3215,7 +3221,7 @@ next_chunk:
+ io_loc.sector = get_data_sector(ic, area, offset);
+ io_loc.count = n_sectors;
+
+- r = dm_io(&io_req, 1, &io_loc, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &io_loc, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r)) {
+ dm_integrity_io_error(ic, "reading data", r);
+ goto err;
+diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
+index 1db565b376200a..777b917be40020 100644
+--- a/drivers/md/dm-io.c
++++ b/drivers/md/dm-io.c
+@@ -33,6 +33,7 @@ struct dm_io_client {
+ */
+ struct io {
+ unsigned long error_bits;
++ unsigned long unsup_bits;
+ atomic_t count;
+ struct dm_io_client *client;
+ io_notify_fn callback;
+@@ -119,6 +120,7 @@ static void retrieve_io_and_region_from_bio(struct bio *bio, struct io **io,
+ static void complete_io(struct io *io)
+ {
+ unsigned long error_bits = io->error_bits;
++ unsigned long unsup_bits = io->unsup_bits;
+ io_notify_fn fn = io->callback;
+ void *context = io->context;
+
+@@ -127,13 +129,17 @@ static void complete_io(struct io *io)
+ io->vma_invalidate_size);
+
+ mempool_free(io, &io->client->pool);
+- fn(error_bits, context);
++ fn(error_bits, unsup_bits, context);
+ }
+
+ static void dec_count(struct io *io, unsigned int region, blk_status_t error)
+ {
+- if (error)
+- set_bit(region, &io->error_bits);
++ if (unlikely(error)) {
++ if (error == BLK_STS_NOTSUPP || error == BLK_STS_INVAL)
++ set_bit(region, &io->unsup_bits);
++ else
++ set_bit(region, &io->error_bits);
++ }
+
+ if (atomic_dec_and_test(&io->count))
+ complete_io(io);
+@@ -170,12 +176,11 @@ struct dpages {
+ struct page **p, unsigned long *len, unsigned int *offset);
+ void (*next_page)(struct dpages *dp);
+
+- union {
+- unsigned int context_u;
+- struct bvec_iter context_bi;
+- };
++ unsigned int context_u;
+ void *context_ptr;
+
++ struct bio *orig_bio;
++
+ void *vma_invalidate_address;
+ unsigned long vma_invalidate_size;
+ };
+@@ -210,44 +215,6 @@ static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned int o
+ dp->context_ptr = pl;
+ }
+
+-/*
+- * Functions for getting the pages from a bvec.
+- */
+-static void bio_get_page(struct dpages *dp, struct page **p,
+- unsigned long *len, unsigned int *offset)
+-{
+- struct bio_vec bvec = bvec_iter_bvec((struct bio_vec *)dp->context_ptr,
+- dp->context_bi);
+-
+- *p = bvec.bv_page;
+- *len = bvec.bv_len;
+- *offset = bvec.bv_offset;
+-
+- /* avoid figuring it out again in bio_next_page() */
+- dp->context_bi.bi_sector = (sector_t)bvec.bv_len;
+-}
+-
+-static void bio_next_page(struct dpages *dp)
+-{
+- unsigned int len = (unsigned int)dp->context_bi.bi_sector;
+-
+- bvec_iter_advance((struct bio_vec *)dp->context_ptr,
+- &dp->context_bi, len);
+-}
+-
+-static void bio_dp_init(struct dpages *dp, struct bio *bio)
+-{
+- dp->get_page = bio_get_page;
+- dp->next_page = bio_next_page;
+-
+- /*
+- * We just use bvec iterator to retrieve pages, so it is ok to
+- * access the bvec table directly here
+- */
+- dp->context_ptr = bio->bi_io_vec;
+- dp->context_bi = bio->bi_iter;
+-}
+-
+ /*
+ * Functions for getting the pages from a VMA.
+ */
+@@ -332,6 +299,21 @@ static void do_region(const blk_opf_t opf, unsigned int region,
+ return;
+ }
+
++ if (dp->orig_bio) {
++ bio = bio_alloc_clone(where->bdev, dp->orig_bio, GFP_NOIO,
++ &io->client->bios);
++ bio->bi_iter.bi_sector = where->sector;
++ bio->bi_iter.bi_size = where->count << SECTOR_SHIFT;
++ bio->bi_opf = opf;
++ bio->bi_end_io = endio;
++ bio->bi_ioprio = ioprio;
++ store_io_and_region_in_bio(bio, io, region);
++
++ atomic_inc(&io->count);
++ submit_bio(bio);
++ return;
++ }
++
+ /*
+ * where->count may be zero if op holds a flush and we need to
+ * send a zero-sized flush.
+@@ -418,6 +400,7 @@ static void async_io(struct dm_io_client *client, unsigned int num_regions,
+
+ io = mempool_alloc(&client->pool, GFP_NOIO);
+ io->error_bits = 0;
++ io->unsup_bits = 0;
+ atomic_set(&io->count, 1); /* see dispatch_io() */
+ io->client = client;
+ io->callback = fn;
+@@ -431,20 +414,23 @@ static void async_io(struct dm_io_client *client, unsigned int num_regions,
+
+ struct sync_io {
+ unsigned long error_bits;
++ unsigned long unsup_bits;
+ struct completion wait;
+ };
+
+-static void sync_io_complete(unsigned long error, void *context)
++static void sync_io_complete(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct sync_io *sio = context;
+
+ sio->error_bits = error;
++ sio->unsup_bits = unsup;
+ complete(&sio->wait);
+ }
+
+ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
+ struct dm_io_region *where, blk_opf_t opf, struct dpages *dp,
+- unsigned long *error_bits, unsigned short ioprio)
++ unsigned long *error_bits, unsigned long *unsup_bits,
++ unsigned short ioprio)
+ {
+ struct sync_io sio;
+
+@@ -457,8 +443,10 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
+
+ if (error_bits)
+ *error_bits = sio.error_bits;
++ if (unsup_bits)
++ *unsup_bits = sio.unsup_bits;
+
+- return sio.error_bits ? -EIO : 0;
++ return sio.error_bits ? -EIO : sio.unsup_bits ? -EOPNOTSUPP : 0;
+ }
+
+ static int dp_init(struct dm_io_request *io_req, struct dpages *dp,
+@@ -468,6 +456,7 @@ static int dp_init(struct dm_io_request *io_req, struct dpages *dp,
+
+ dp->vma_invalidate_address = NULL;
+ dp->vma_invalidate_size = 0;
++ dp->orig_bio = NULL;
+
+ switch (io_req->mem.type) {
+ case DM_IO_PAGE_LIST:
+@@ -475,7 +464,11 @@ static int dp_init(struct dm_io_request *io_req, struct dpages *dp,
+ break;
+
+ case DM_IO_BIO:
+- bio_dp_init(dp, io_req->mem.ptr.bio);
++ /*
++ * The destination bios clone this bio's biovec directly, so
++ * there are no per-page accessors to set up here.
++ */
++ dp->orig_bio = io_req->mem.ptr.bio;
+ break;
+
+ case DM_IO_VMA:
+@@ -500,7 +493,7 @@ static int dp_init(struct dm_io_request *io_req, struct dpages *dp,
+
+ int dm_io(struct dm_io_request *io_req, unsigned int num_regions,
+ struct dm_io_region *where, unsigned long *sync_error_bits,
+- unsigned short ioprio)
++ unsigned long *sync_unsup_bits, unsigned short ioprio)
+ {
+ int r;
+ struct dpages dp;
+@@ -516,7 +509,8 @@ int dm_io(struct dm_io_request *io_req, unsigned int num_regions,
+
+ if (!io_req->notify.fn)
+ return sync_io(io_req->client, num_regions, where,
+- io_req->bi_opf, &dp, sync_error_bits, ioprio);
++ io_req->bi_opf, &dp, sync_error_bits,
++ sync_unsup_bits, ioprio);
+
+ async_io(io_req->client, num_regions, where, io_req->bi_opf, &dp,
+ io_req->notify.fn, io_req->notify.context, ioprio);
+diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c
+index 96c8b8ff61c20b..5c9c24a3dcd999 100644
+--- a/drivers/md/dm-kcopyd.c
++++ b/drivers/md/dm-kcopyd.c
+@@ -517,16 +517,16 @@ static int run_complete_job(struct kcopyd_job *job)
+ return 0;
+ }
+
+-static void complete_io(unsigned long error, void *context)
++static void complete_io(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct kcopyd_job *job = context;
+ struct dm_kcopyd_client *kc = job->kc;
+
+ io_job_finish(kc->throttle);
+
+- if (error) {
++ if (unlikely((error | unsup) != 0)) {
+ if (op_is_write(job->op))
+- job->write_err |= error;
++ job->write_err |= error | unsup;
+ else
+ job->read_err = 1;
+
+@@ -578,9 +578,9 @@ static int run_io_job(struct kcopyd_job *job)
+ io_job_start(job->kc->throttle);
+
+ if (job->op == REQ_OP_READ)
+- r = dm_io(&io_req, 1, &job->source, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &job->source, NULL, NULL, IOPRIO_DEFAULT);
+ else
+- r = dm_io(&io_req, job->num_dests, job->dests, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, job->num_dests, job->dests, NULL, NULL, IOPRIO_DEFAULT);
+
+ return r;
+ }
+diff --git a/drivers/md/dm-log-userspace-base.c b/drivers/md/dm-log-userspace-base.c
+index 9d5918eb0a30e0..3ca35aa4e057d1 100644
+--- a/drivers/md/dm-log-userspace-base.c
++++ b/drivers/md/dm-log-userspace-base.c
+@@ -139,6 +139,7 @@ static int build_constructor_string(struct dm_target *ti,
+ str_size += strlen(argv[i]) + 1; /* +1 for space between args */
+
+ str_size += 20; /* Max number of chars in a printed u64 number */
++ str_size++; /* For NUL-terminator */
+
+ str = kzalloc(str_size, GFP_KERNEL);
+ if (!str) {
+diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
+index 2ddeb4250c5929..4c114fc5ef8375 100644
+--- a/drivers/md/dm-log.c
++++ b/drivers/md/dm-log.c
+@@ -300,7 +300,7 @@ static int rw_header(struct log_c *lc, enum req_op op)
+ {
+ lc->io_req.bi_opf = op;
+
+- return dm_io(&lc->io_req, 1, &lc->header_location, NULL, IOPRIO_DEFAULT);
++ return dm_io(&lc->io_req, 1, &lc->header_location, NULL, NULL, IOPRIO_DEFAULT);
+ }
+
+ static int flush_header(struct log_c *lc)
+@@ -313,7 +313,7 @@ static int flush_header(struct log_c *lc)
+
+ lc->io_req.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+
+- return dm_io(&lc->io_req, 1, &null_location, NULL, IOPRIO_DEFAULT);
++ return dm_io(&lc->io_req, 1, &null_location, NULL, NULL, IOPRIO_DEFAULT);
+ }
+
+ static int read_header(struct log_c *log)
+diff --git a/drivers/md/dm-pcache/cache.c b/drivers/md/dm-pcache/cache.c
+index bb1ada31e4836c..e68dacb69459c3 100644
+--- a/drivers/md/dm-pcache/cache.c
++++ b/drivers/md/dm-pcache/cache.c
+@@ -119,6 +119,10 @@ int cache_pos_decode(struct pcache_cache *cache,
+ return -EIO;
+
+ pos->cache_seg = &cache->segments[latest.cache_seg_id];
++
++ if (latest.seg_off >= pos->cache_seg->segment.data_size)
++ return -EIO;
++
+ pos->seg_off = latest.seg_off;
+ *seq = latest.header.seq;
+ *index = (latest_addr - pos_onmedia);
+@@ -247,6 +251,13 @@ static int get_seg_id(struct pcache_cache *cache,
+ } else {
+ *seg_id = cache->cache_info.seg_id;
+ }
++
++ if (*seg_id >= cache_dev->seg_num) {
++ pcache_dev_err(pcache, "invalid segment id %u from cache device (seg_num %u)\n",
++ *seg_id, cache_dev->seg_num);
++ ret = -EIO;
++ goto err;
++ }
+ }
+ return 0;
+ err:
+@@ -262,6 +273,13 @@ static int cache_segs_init(struct pcache_cache *cache)
+ int ret;
+ u32 i;
+
++ if (cache_info->n_segs > cache->cache_dev->seg_num) {
++ pcache_dev_err(CACHE_TO_PCACHE(cache),
++ "cache_info n_segs %u exceeds cache device segments %u\n",
++ cache_info->n_segs, cache->cache_dev->seg_num);
++ return -EIO;
++ }
++
+ for (i = 0; i < cache_info->n_segs; i++) {
+ ret = get_seg_id(cache, prev_cache_seg, new_cache, &seg_id);
+ if (ret)
+diff --git a/drivers/md/dm-pcache/cache.h b/drivers/md/dm-pcache/cache.h
+index 27613b56be54c2..afc112b79496ac 100644
+--- a/drivers/md/dm-pcache/cache.h
++++ b/drivers/md/dm-pcache/cache.h
+@@ -491,6 +491,27 @@ static inline u32 cache_key_data_crc(struct pcache_cache_key *key)
+ return crc32c(PCACHE_CRC_SEED, data, key->len);
+ }
+
++/**
++ * kset_onmedia_valid - Validate a kset header read from the cache device.
++ * @kset_onmedia: Pointer to the kset copied from on-media metadata.
++ *
++ * The magic and CRC are attacker-computable (fixed public seed). A non-last
++ * kset stores key_num keys inline, and cache_kset_crc() and the replay loop
++ * read struct_size(.., data, key_num) bytes from a buffer sized for
++ * PCACHE_KSET_KEYS_MAX keys, so key_num must be bounded before any such use.
++ */
++static inline bool kset_onmedia_valid(struct pcache_cache_kset_onmedia *kset_onmedia)
++{
++ if (kset_onmedia->magic != PCACHE_KSET_MAGIC)
++ return false;
++
++ if (!(kset_onmedia->flags & PCACHE_KSET_FLAGS_LAST) &&
++ kset_onmedia->key_num > PCACHE_KSET_KEYS_MAX)
++ return false;
++
++ return true;
++}
++
+ static inline u32 cache_kset_crc(struct pcache_cache_kset_onmedia *kset_onmedia)
+ {
+ u32 crc_size;
+diff --git a/drivers/md/dm-pcache/cache_dev.c b/drivers/md/dm-pcache/cache_dev.c
+index ece689e6ce59d8..f0259353ee3978 100644
+--- a/drivers/md/dm-pcache/cache_dev.c
++++ b/drivers/md/dm-pcache/cache_dev.c
+@@ -242,6 +242,8 @@ int cache_dev_start(struct dm_pcache *pcache)
+ struct pcache_cache_dev *cache_dev = &pcache->cache_dev;
+ struct pcache_sb sb;
+ bool format = false;
++ u32 seg_num;
++ u64 max_segs;
+ int ret;
+
+ mutex_init(&cache_dev->seg_lock);
+@@ -269,7 +271,25 @@ int cache_dev_start(struct dm_pcache *pcache)
+ goto dax_release;
+
+ cache_dev->sb_flags = le32_to_cpu(sb.flags);
+- ret = cache_dev_init(cache_dev, le32_to_cpu(sb.seg_num));
++
++ /*
++ * seg_num is read from the crc32c-only superblock, so whoever supplies
++ * the cache device controls it. It is the ceiling every later on-media
++ * segment id is validated against, so bound it against what the device
++ * physically holds before it is trusted, or a forged seg_num lets a
++ * segment id address past the DAX mapping.
++ */
++ seg_num = le32_to_cpu(sb.seg_num);
++ max_segs = (bdev_nr_bytes(cache_dev->dm_dev->bdev) - PCACHE_SEGMENTS_OFF) /
++ PCACHE_SEG_SIZE;
++ if (seg_num == 0 || seg_num > max_segs || seg_num > PCACHE_CACHE_SEGS_MAX) {
++ pcache_dev_err(pcache, "invalid seg_num %u from cache device (device holds %llu, max %u)\n",
++ seg_num, max_segs, (u32)PCACHE_CACHE_SEGS_MAX);
++ ret = -EIO;
++ goto dax_release;
++ }
++
++ ret = cache_dev_init(cache_dev, seg_num);
+ if (ret)
+ goto dax_release;
+
+diff --git a/drivers/md/dm-pcache/cache_gc.c b/drivers/md/dm-pcache/cache_gc.c
+index 94f8b276a02128..3088cfef951bc1 100644
+--- a/drivers/md/dm-pcache/cache_gc.c
++++ b/drivers/md/dm-pcache/cache_gc.c
+@@ -37,18 +37,18 @@ static bool need_gc(struct pcache_cache *cache, struct pcache_cache_pos *dirty_t
+
+ kset_onmedia = (struct pcache_cache_kset_onmedia *)cache->gc_kset_onmedia_buf;
+
+- to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, PCACHE_SEG_SIZE - key_tail->seg_off);
++ to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, cache_seg_remain(key_tail));
+ ret = copy_mc_to_kernel(kset_onmedia, key_addr, to_copy);
+ if (ret) {
+ pcache_dev_err(pcache, "error to read kset: %d", ret);
+ return false;
+ }
+
+- /* Check if kset_onmedia is corrupted */
+- if (kset_onmedia->magic != PCACHE_KSET_MAGIC) {
+- pcache_dev_debug(pcache, "gc error: magic is not as expected. key_tail: %u:%u magic: %llx, expected: %llx\n",
++ /* Reject a corrupted or out-of-bounds kset before reading its keys */
++ if (!kset_onmedia_valid(kset_onmedia)) {
++ pcache_dev_debug(pcache, "gc error: invalid kset. key_tail: %u:%u magic: %llx, key_num: %u\n",
+ key_tail->cache_seg->cache_seg_id, key_tail->seg_off,
+- kset_onmedia->magic, PCACHE_KSET_MAGIC);
++ kset_onmedia->magic, kset_onmedia->key_num);
+ return false;
+ }
+
+diff --git a/drivers/md/dm-pcache/cache_key.c b/drivers/md/dm-pcache/cache_key.c
+index e068e878231b42..51dd1ccf4e2fde 100644
+--- a/drivers/md/dm-pcache/cache_key.c
++++ b/drivers/md/dm-pcache/cache_key.c
+@@ -97,6 +97,14 @@ int cache_key_decode(struct pcache_cache *cache,
+ key->cache_pos.cache_seg = &cache->segments[key_onmedia->cache_seg_id];
+ key->cache_pos.seg_off = key_onmedia->cache_seg_off;
+
++ if ((u64)key->cache_pos.seg_off + key->len >
++ key->cache_pos.cache_seg->segment.data_size) {
++ pcache_dev_err(pcache, "key seg_off %u + len %u exceeds segment data size %u\n",
++ key->cache_pos.seg_off, key->len,
++ key->cache_pos.cache_seg->segment.data_size);
++ return -EIO;
++ }
++
+ key->seg_gen = key_onmedia->seg_gen;
+ key->flags = key_onmedia->flags;
+
+@@ -728,18 +736,17 @@ static int kset_replay(struct pcache_cache *cache, struct pcache_cache_kset_onme
+ goto err;
+ }
+
+- __set_bit(key->cache_pos.cache_seg->cache_seg_id, cache->seg_map);
+-
+ /* Check if the segment generation is valid for insertion. */
+ if (key->seg_gen < key->cache_pos.cache_seg->gen) {
+ cache_key_put(key);
+- } else {
+- cache_subtree = get_subtree(&cache->req_key_tree, key->off);
+- spin_lock(&cache_subtree->tree_lock);
+- cache_key_insert(&cache->req_key_tree, key, true);
+- spin_unlock(&cache_subtree->tree_lock);
++ continue;
+ }
+
++ __set_bit(key->cache_pos.cache_seg->cache_seg_id, cache->seg_map);
++ cache_subtree = get_subtree(&cache->req_key_tree, key->off);
++ spin_lock(&cache_subtree->tree_lock);
++ cache_key_insert(&cache->req_key_tree, key, true);
++ spin_unlock(&cache_subtree->tree_lock);
+ cache_seg_get(key->cache_pos.cache_seg);
+ }
+
+@@ -754,7 +761,7 @@ int cache_replay(struct pcache_cache *cache)
+ struct pcache_cache_pos pos_tail;
+ struct pcache_cache_pos *pos;
+ struct pcache_cache_kset_onmedia *kset_onmedia;
+- u32 to_copy, count = 0;
++ u32 to_copy, count = 0, last_hops = 0;
+ int ret = 0;
+
+ kset_onmedia = kzalloc(PCACHE_KSET_ONMEDIA_SIZE_MAX, GFP_KERNEL);
+@@ -771,14 +778,14 @@ int cache_replay(struct pcache_cache *cache)
+ __set_bit(pos->cache_seg->cache_seg_id, cache->seg_map);
+
+ while (true) {
+- to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, PCACHE_SEG_SIZE - pos->seg_off);
++ to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, cache_seg_remain(pos));
+ ret = copy_mc_to_kernel(kset_onmedia, cache_pos_addr(pos), to_copy);
+ if (ret) {
+ ret = -EIO;
+ goto out;
+ }
+
+- if (kset_onmedia->magic != PCACHE_KSET_MAGIC ||
++ if (!kset_onmedia_valid(kset_onmedia) ||
+ kset_onmedia->crc != cache_kset_crc(kset_onmedia)) {
+ break;
+ }
+@@ -789,6 +796,11 @@ int cache_replay(struct pcache_cache *cache)
+
+ pcache_dev_debug(pcache, "last kset replay, next: %u\n", kset_onmedia->next_cache_seg_id);
+
++ if (++last_hops > cache->n_segs) {
++ ret = -EIO;
++ goto out;
++ }
++
+ next_seg = &cache->segments[kset_onmedia->next_cache_seg_id];
+
+ pos->cache_seg = next_seg;
+diff --git a/drivers/md/dm-pcache/cache_segment.c b/drivers/md/dm-pcache/cache_segment.c
+index 9d92e2b067ed04..c698ebbc626d27 100644
+--- a/drivers/md/dm-pcache/cache_segment.c
++++ b/drivers/md/dm-pcache/cache_segment.c
+@@ -243,8 +243,16 @@ struct pcache_cache_segment *get_cache_segment(struct pcache_cache *cache)
+
+ spin_lock(&cache->seg_map_lock);
+ again:
+- seg_id = find_next_zero_bit(cache->seg_map, cache->n_segs, cache->last_cache_seg);
+- if (seg_id == cache->n_segs) {
++ /*
++ * Only allocate initialized segments. cache_segs_init() initializes
++ * cache_info.n_segs of the cache->n_segs device segments; a forged
++ * smaller cache_info.n_segs leaves the rest as zeroed structs whose data
++ * pointer is NULL. Bounding the search to cache_info.n_segs keeps such a
++ * segment from reaching cache_kset_close(), which writes through it.
++ */
++ seg_id = find_next_zero_bit(cache->seg_map, cache->cache_info.n_segs,
++ cache->last_cache_seg);
++ if (seg_id == cache->cache_info.n_segs) {
+ /* reset the hint of ->last_cache_seg and retry */
+ if (cache->last_cache_seg) {
+ cache->last_cache_seg = 0;
+diff --git a/drivers/md/dm-pcache/cache_writeback.c b/drivers/md/dm-pcache/cache_writeback.c
+index 87a82b3fe8363a..3df8687e2382f7 100644
+--- a/drivers/md/dm-pcache/cache_writeback.c
++++ b/drivers/md/dm-pcache/cache_writeback.c
+@@ -48,18 +48,18 @@ static inline bool is_cache_clean(struct pcache_cache *cache, struct pcache_cach
+ addr = cache_pos_addr(dirty_tail);
+ kset_onmedia = (struct pcache_cache_kset_onmedia *)cache->wb_kset_onmedia_buf;
+
+- to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, PCACHE_SEG_SIZE - dirty_tail->seg_off);
++ to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, cache_seg_remain(dirty_tail));
+ ret = copy_mc_to_kernel(kset_onmedia, addr, to_copy);
+ if (ret) {
+ pcache_dev_err(pcache, "error to read kset: %d", ret);
+ return true;
+ }
+
+- /* Check if the magic number matches the expected value */
+- if (kset_onmedia->magic != PCACHE_KSET_MAGIC) {
+- pcache_dev_debug(pcache, "dirty_tail: %u:%u magic: %llx, not expected: %llx\n",
++ /* Reject a corrupted or out-of-bounds kset before reading its keys */
++ if (!kset_onmedia_valid(kset_onmedia)) {
++ pcache_dev_debug(pcache, "dirty_tail: %u:%u invalid kset magic: %llx, key_num: %u\n",
+ dirty_tail->cache_seg->cache_seg_id, dirty_tail->seg_off,
+- kset_onmedia->magic, PCACHE_KSET_MAGIC);
++ kset_onmedia->magic, kset_onmedia->key_num);
+ return true;
+ }
+
+diff --git a/drivers/md/dm-pcache/dm_pcache.c b/drivers/md/dm-pcache/dm_pcache.c
+index d5cfd162c06335..645fc27d82ba4a 100644
+--- a/drivers/md/dm-pcache/dm_pcache.c
++++ b/drivers/md/dm-pcache/dm_pcache.c
+@@ -439,13 +439,13 @@ static int dm_pcache_message(struct dm_target *ti, unsigned int argc,
+ char **argv, char *result, unsigned int maxlen)
+ {
+ struct dm_pcache *pcache = ti->private;
+- unsigned long val;
++ u8 val;
+
+ if (argc != 2)
+ goto err;
+
+ if (!strcasecmp(argv[0], "gc_percent")) {
+- if (kstrtoul(argv[1], 10, &val))
++ if (kstrtou8(argv[1], 10, &val))
+ goto err;
+
+ return pcache_cache_set_gc_percent(&pcache->cache, val);
+diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
+index de5c00704e69c6..da2a5e2002ecaf 100644
+--- a/drivers/md/dm-raid1.c
++++ b/drivers/md/dm-raid1.c
+@@ -258,7 +258,7 @@ out:
+ static int mirror_flush(struct dm_target *ti)
+ {
+ struct mirror_set *ms = ti->private;
+- unsigned long error_bits;
++ unsigned long error_bits, unsup_bits;
+
+ unsigned int i;
+ struct dm_io_region io[MAX_NR_MIRRORS];
+@@ -277,8 +277,8 @@ static int mirror_flush(struct dm_target *ti)
+ }
+
+ error_bits = -1;
+- dm_io(&io_req, ms->nr_mirrors, io, &error_bits, IOPRIO_DEFAULT);
+- if (unlikely(error_bits != 0)) {
++ dm_io(&io_req, ms->nr_mirrors, io, &error_bits, &unsup_bits, IOPRIO_DEFAULT);
++ if (unlikely((error_bits | unsup_bits) != 0)) {
+ for (i = 0; i < ms->nr_mirrors; i++)
+ if (test_bit(i, &error_bits))
+ fail_mirror(ms->mirror + i,
+@@ -511,7 +511,7 @@ static void hold_bio(struct mirror_set *ms, struct bio *bio)
+ * Reads
+ *---------------------------------------------------------------
+ */
+-static void read_callback(unsigned long error, void *context)
++static void read_callback(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct bio *bio = context;
+ struct mirror *m;
+@@ -520,6 +520,8 @@ static void read_callback(unsigned long error, void *context)
+ bio_set_m(bio, NULL);
+
+ if (likely(!error)) {
++ if (unlikely(unsup != 0))
++ bio->bi_status = BLK_STS_INVAL;
+ bio_endio(bio);
+ return;
+ }
+@@ -553,7 +555,7 @@ static void read_async_bio(struct mirror *m, struct bio *bio)
+
+ map_region(&io, m, bio);
+ bio_set_m(bio, m);
+- BUG_ON(dm_io(&io_req, 1, &io, NULL, IOPRIO_DEFAULT));
++ BUG_ON(dm_io(&io_req, 1, &io, NULL, NULL, IOPRIO_DEFAULT));
+ }
+
+ static inline int region_in_sync(struct mirror_set *ms, region_t region,
+@@ -600,7 +602,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
+ * NOSYNC: increment pending, just write to the default mirror
+ *---------------------------------------------------------------------
+ */
+-static void write_callback(unsigned long error, void *context)
++static void write_callback(unsigned long error, unsigned long unsup, void *context)
+ {
+ unsigned int i;
+ struct bio *bio = context;
+@@ -617,7 +619,7 @@ static void write_callback(unsigned long error, void *context)
+ * This way we handle both writes to SYNC and NOSYNC
+ * regions with the same code.
+ */
+- if (likely(!error)) {
++ if (likely(!(error | unsup))) {
+ bio_endio(bio);
+ return;
+ }
+@@ -632,6 +634,12 @@ static void write_callback(unsigned long error, void *context)
+ return;
+ }
+
++ if (!error && unsup) {
++ bio->bi_status = BLK_STS_INVAL;
++ bio_endio(bio);
++ return;
++ }
++
+ for (i = 0; i < ms->nr_mirrors; i++)
+ if (test_bit(i, &error))
+ fail_mirror(ms->mirror + i, DM_RAID1_WRITE_ERROR);
+@@ -680,7 +688,7 @@ static void do_write(struct mirror_set *ms, struct bio *bio)
+ */
+ bio_set_m(bio, get_default_mirror(ms));
+
+- BUG_ON(dm_io(&io_req, ms->nr_mirrors, io, NULL, IOPRIO_DEFAULT));
++ BUG_ON(dm_io(&io_req, ms->nr_mirrors, io, NULL, NULL, IOPRIO_DEFAULT));
+ }
+
+ static void do_writes(struct mirror_set *ms, struct bio_list *writes)
+@@ -1262,7 +1270,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
+ return DM_ENDIO_DONE;
+ }
+
+- if (*error == BLK_STS_NOTSUPP)
++ if (*error == BLK_STS_NOTSUPP || *error == BLK_STS_INVAL)
+ goto out;
+
+ if (bio->bi_opf & REQ_RAHEAD)
+diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
+index aa239ccda270e9..e86d929b0e9518 100644
+--- a/drivers/md/dm-snap-persistent.c
++++ b/drivers/md/dm-snap-persistent.c
+@@ -223,7 +223,7 @@ static void do_metadata(struct work_struct *work)
+ {
+ struct mdata_req *req = container_of(work, struct mdata_req, work);
+
+- req->result = dm_io(req->io_req, 1, req->where, NULL, IOPRIO_DEFAULT);
++ req->result = dm_io(req->io_req, 1, req->where, NULL, NULL, IOPRIO_DEFAULT);
+ }
+
+ /*
+@@ -247,7 +247,7 @@ static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, blk_opf_t opf,
+ struct mdata_req req;
+
+ if (!metadata)
+- return dm_io(&io_req, 1, &where, NULL, IOPRIO_DEFAULT);
++ return dm_io(&io_req, 1, &where, NULL, NULL, IOPRIO_DEFAULT);
+
+ req.where = &where;
+ req.io_req = &io_req;
+diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
+index 5df710061a1165..beabbe3b39f3bd 100644
+--- a/drivers/md/dm-stats.c
++++ b/drivers/md/dm-stats.c
+@@ -178,8 +178,10 @@ static void dm_stat_free(struct rcu_head *head)
+ kfree(s->program_id);
+ kfree(s->aux_data);
+ for_each_possible_cpu(cpu) {
+- dm_kvfree(s->stat_percpu[cpu][0].histogram, s->histogram_alloc_size);
+- dm_kvfree(s->stat_percpu[cpu], s->percpu_alloc_size);
++ if (s->stat_percpu[cpu]) {
++ dm_kvfree(s->stat_percpu[cpu][0].histogram, s->histogram_alloc_size);
++ dm_kvfree(s->stat_percpu[cpu], s->percpu_alloc_size);
++ }
+ }
+ dm_kvfree(s->stat_shared[0].tmp.histogram, s->histogram_alloc_size);
+ dm_kvfree(s, s->shared_alloc_size);
+diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c
+index 5952f02de1e626..e5b507b4fa7bf8 100644
+--- a/drivers/md/dm-switch.c
++++ b/drivers/md/dm-switch.c
+@@ -184,7 +184,7 @@ static void switch_region_table_write(struct switch_ctx *sctx, unsigned long reg
+ pte = sctx->region_table[region_index];
+ pte &= ~((((region_table_slot_t)1 << sctx->region_table_entry_bits) - 1) << bit);
+ pte |= (region_table_slot_t)value << bit;
+- sctx->region_table[region_index] = pte;
++ WRITE_ONCE(sctx->region_table[region_index], pte);
+ }
+
+ /*
+diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
+index 1b076309125403..c67dea40c9cd38 100644
+--- a/drivers/md/dm-verity-target.c
++++ b/drivers/md/dm-verity-target.c
+@@ -395,7 +395,7 @@ static noinline int verity_recheck(struct dm_verity *v, struct dm_verity_io *io,
+ io_loc.bdev = v->data_dev->bdev;
+ io_loc.sector = cur_block << (v->data_dev_block_bits - SECTOR_SHIFT);
+ io_loc.count = 1 << (v->data_dev_block_bits - SECTOR_SHIFT);
+- r = dm_io(&io_req, 1, &io_loc, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&io_req, 1, &io_loc, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r))
+ goto free_ret;
+
+diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
+index 493f5202ad0426..f02305de1c882c 100644
+--- a/drivers/md/dm-writecache.c
++++ b/drivers/md/dm-writecache.c
+@@ -474,12 +474,14 @@ struct io_notify {
+ atomic_t count;
+ };
+
+-static void writecache_notify_io(unsigned long error, void *context)
++static void writecache_notify_io(unsigned long error, unsigned long unsup, void *context)
+ {
+ struct io_notify *endio = context;
+
+ if (unlikely(error != 0))
+ writecache_error(endio->wc, -EIO, "error writing metadata");
++ else if (unlikely(unsup != 0))
++ writecache_error(endio->wc, -EOPNOTSUPP, "error writing metadata");
+ BUG_ON(atomic_read(&endio->count) <= 0);
+ if (atomic_dec_and_test(&endio->count))
+ complete(&endio->c);
+@@ -530,11 +532,11 @@ static void ssd_commit_flushed(struct dm_writecache *wc, bool wait_for_ios)
+ req.notify.context = &endio;
+
+ /* writing via async dm-io (implied by notify.fn above) won't return an error */
+- (void) dm_io(&req, 1, ®ion, NULL, IOPRIO_DEFAULT);
++ (void) dm_io(&req, 1, ®ion, NULL, NULL, IOPRIO_DEFAULT);
+ i = j;
+ }
+
+- writecache_notify_io(0, &endio);
++ writecache_notify_io(0, 0, &endio);
+ wait_for_completion_io(&endio.c);
+
+ if (wait_for_ios)
+@@ -567,7 +569,7 @@ static void ssd_commit_superblock(struct dm_writecache *wc)
+ req.notify.fn = NULL;
+ req.notify.context = NULL;
+
+- r = dm_io(&req, 1, ®ion, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&req, 1, ®ion, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r))
+ writecache_error(wc, r, "error writing superblock");
+ }
+@@ -595,7 +597,7 @@ static void writecache_disk_flush(struct dm_writecache *wc, struct dm_dev *dev)
+ req.client = wc->dm_io;
+ req.notify.fn = NULL;
+
+- r = dm_io(&req, 1, ®ion, NULL, IOPRIO_DEFAULT);
++ r = dm_io(&req, 1, ®ion, NULL, NULL, IOPRIO_DEFAULT);
+ if (unlikely(r))
+ writecache_error(wc, r, "error flushing metadata: %d", r);
+ }
+@@ -989,7 +991,7 @@ static int writecache_read_metadata(struct dm_writecache *wc, sector_t n_sectors
+ req.client = wc->dm_io;
+ req.notify.fn = NULL;
+
+- return dm_io(&req, 1, ®ion, NULL, IOPRIO_DEFAULT);
++ return dm_io(&req, 1, ®ion, NULL, NULL, IOPRIO_DEFAULT);
+ }
+
+ static void writecache_resume(struct dm_target *ti)
+diff --git a/drivers/md/md.c b/drivers/md/md.c
+index d1465bcd86c812..4dd133445539aa 100644
+--- a/drivers/md/md.c
++++ b/drivers/md/md.c
+@@ -1920,6 +1920,13 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
+ rdev->bb_page, REQ_OP_READ, true))
+ return -EIO;
+ bbp = (__le64 *)page_address(rdev->bb_page);
++
++ /* check for badblocks api. */
++ if (sb->bblog_shift >= BITS_PER_TYPE(sector_t)) {
++ pr_err("md: %pg: bogus bblog_shift %u for badblocks.\n",
++ rdev->bdev, sb->bblog_shift);
++ return -EINVAL;
++ }
+ rdev->badblocks.shift = sb->bblog_shift;
+ for (i = 0 ; i < (sectors << (9-3)) ; i++, bbp++) {
+ u64 bb = le64_to_cpu(*bbp);
+diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c
+index 8f8792e5580639..961fa3c1439a5b 100644
+--- a/drivers/md/persistent-data/dm-array.c
++++ b/drivers/md/persistent-data/dm-array.c
+@@ -38,6 +38,14 @@ struct array_block {
+ */
+ #define CSUM_XOR 595846735
+
++/*
++ * Each array block can hold this many values.
++ */
++static uint32_t calc_max_entries(size_t value_size, size_t size_of_block)
++{
++ return (size_of_block - sizeof(struct array_block)) / value_size;
++}
++
+ static void array_block_prepare_for_write(const struct dm_block_validator *v,
+ struct dm_block *b,
+ size_t size_of_block)
+@@ -55,6 +63,7 @@ static int array_block_check(const struct dm_block_validator *v,
+ size_t size_of_block)
+ {
+ struct array_block *bh_le = dm_block_data(b);
++ uint32_t nr_entries, max_entries, value_size;
+ __le32 csum_disk;
+
+ if (dm_block_location(b) != le64_to_cpu(bh_le->blocknr)) {
+@@ -74,6 +83,26 @@ static int array_block_check(const struct dm_block_validator *v,
+ return -EILSEQ;
+ }
+
++ nr_entries = le32_to_cpu(bh_le->nr_entries);
++ max_entries = le32_to_cpu(bh_le->max_entries);
++ value_size = le32_to_cpu(bh_le->value_size);
++
++ if (!value_size) {
++ DMERR_LIMIT("%s failed: value_size is zero", __func__);
++ return -EILSEQ;
++ }
++
++ if (max_entries != calc_max_entries(value_size, size_of_block)) {
++ DMERR_LIMIT("%s failed: max_entries %u invalid for value_size %u",
++ __func__, max_entries, value_size);
++ return -EILSEQ;
++ }
++
++ if (nr_entries > max_entries) {
++ DMERR_LIMIT("%s failed: too many entries", __func__);
++ return -EILSEQ;
++ }
++
+ return 0;
+ }
+
+@@ -138,14 +167,6 @@ static void dec_ablock_entries(struct dm_array_info *info, struct array_block *a
+ on_entries(info, ab, vt->dec);
+ }
+
+-/*
+- * Each array block can hold this many values.
+- */
+-static uint32_t calc_max_entries(size_t value_size, size_t size_of_block)
+-{
+- return (size_of_block - sizeof(struct array_block)) / value_size;
+-}
+-
+ /*
+ * Allocate a new array block. The caller will need to unlock block.
+ */
+@@ -225,6 +246,14 @@ static int get_ablock(struct dm_array_info *info, dm_block_t b,
+ return r;
+
+ *ab = dm_block_data(*block);
++ if (le32_to_cpu((*ab)->value_size) != info->value_type.size) {
++ DMERR_LIMIT("%s failed: value_size %u != wanted %u", __func__,
++ le32_to_cpu((*ab)->value_size),
++ info->value_type.size);
++ dm_tm_unlock(info->btree_info.tm, *block);
++ return -EILSEQ;
++ }
++
+ return 0;
+ }
+
+@@ -287,6 +316,14 @@ static int __shadow_ablock(struct dm_array_info *info, dm_block_t b,
+ return r;
+
+ *ab = dm_block_data(*block);
++ if (le32_to_cpu((*ab)->value_size) != info->value_type.size) {
++ DMERR_LIMIT("%s failed: value_size %u != wanted %u", __func__,
++ le32_to_cpu((*ab)->value_size),
++ info->value_type.size);
++ dm_tm_unlock(info->btree_info.tm, *block);
++ return -EILSEQ;
++ }
++
+ if (inc)
+ inc_ablock_entries(info, *ab);
+
+diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
+index 0a3cfdd3f5df80..54cddb3a98cd62 100644
+--- a/drivers/md/raid10.c
++++ b/drivers/md/raid10.c
+@@ -3365,7 +3365,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
+ struct md_rdev *rdev = conf->mirrors[j].rdev;
+
+ if (rdev == NULL || test_bit(Faulty, &rdev->flags)) {
+- still_degraded = false;
++ still_degraded = true;
+ break;
+ }
+ }
+diff --git a/drivers/media/cec/platform/stm32/stm32-cec.c b/drivers/media/cec/platform/stm32/stm32-cec.c
+index 1ec0cece0a5b71..8c2fc232202de2 100644
+--- a/drivers/media/cec/platform/stm32/stm32-cec.c
++++ b/drivers/media/cec/platform/stm32/stm32-cec.c
+@@ -132,7 +132,8 @@ static void stm32_rx_done(struct stm32_cec *cec, u32 status)
+ u32 val;
+
+ regmap_read(cec->regmap, CEC_RXDR, &val);
+- cec->rx_msg.msg[cec->rx_msg.len++] = val & 0xFF;
++ if (cec->rx_msg.len < CEC_MAX_MSG_SIZE)
++ cec->rx_msg.msg[cec->rx_msg.len++] = val & 0xFF;
+ }
+
+ if (cec->irq_status & RXEND) {
+diff --git a/drivers/media/test-drivers/vicodec/vicodec-core.c b/drivers/media/test-drivers/vicodec/vicodec-core.c
+index 318e8330f16aef..ff9d50fb05fd13 100644
+--- a/drivers/media/test-drivers/vicodec/vicodec-core.c
++++ b/drivers/media/test-drivers/vicodec/vicodec-core.c
+@@ -63,11 +63,11 @@ struct pixfmt_info {
+ };
+
+ static const struct v4l2_fwht_pixfmt_info pixfmt_fwht = {
+- V4L2_PIX_FMT_FWHT, 0, 3, 1, 1, 1, 1, 1, 0, 1
++ V4L2_PIX_FMT_FWHT, 0, 4, 1, 1, 1, 1, 1, 0, 1
+ };
+
+ static const struct v4l2_fwht_pixfmt_info pixfmt_stateless_fwht = {
+- V4L2_PIX_FMT_FWHT_STATELESS, 0, 3, 1, 1, 1, 1, 1, 0, 1
++ V4L2_PIX_FMT_FWHT_STATELESS, 0, 4, 1, 1, 1, 1, 1, 0, 1
+ };
+
+ static void vicodec_dev_release(struct device *dev)
+diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
+index 5516b2bbb08f09..d750bf10febec1 100644
+--- a/drivers/media/v4l2-core/v4l2-dev.c
++++ b/drivers/media/v4l2-core/v4l2-dev.c
+@@ -1071,25 +1071,25 @@ int __video_register_device(struct video_device *vdev,
+ vdev->dev.class = &video_class;
+ vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
+ vdev->dev.parent = vdev->dev_parent;
+- vdev->dev.release = v4l2_device_release;
+ dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
+-
+- /* Increase v4l2_device refcount */
+- v4l2_device_get(vdev->v4l2_dev);
+-
+ mutex_lock(&videodev_lock);
+ ret = device_register(&vdev->dev);
+ if (ret < 0) {
+ mutex_unlock(&videodev_lock);
+ pr_err("%s: device_register failed\n", __func__);
+- put_device(&vdev->dev);
+- return ret;
++ goto cleanup;
+ }
++ /* Register the release callback that will be called when the last
++ reference to the device goes away. */
++ vdev->dev.release = v4l2_device_release;
+
+ if (nr != -1 && nr != vdev->num && warn_if_nr_in_use)
+ pr_warn("%s: requested %s%d, got %s\n", __func__,
+ name_base, nr, video_device_node_name(vdev));
+
++ /* Increase v4l2_device refcount */
++ v4l2_device_get(vdev->v4l2_dev);
++
+ /* Part 5: Register the entity. */
+ ret = video_register_media_controller(vdev);
+
+diff --git a/drivers/mfd/cgbc-core.c b/drivers/mfd/cgbc-core.c
+index 10bb4b414c34d2..2becaf797646da 100644
+--- a/drivers/mfd/cgbc-core.c
++++ b/drivers/mfd/cgbc-core.c
+@@ -364,9 +364,9 @@ static void cgbc_remove(struct platform_device *pdev)
+ {
+ struct cgbc_device_data *cgbc = platform_get_drvdata(pdev);
+
+- cgbc_session_release(cgbc);
+-
+ mfd_remove_devices(&pdev->dev);
++
++ cgbc_session_release(cgbc);
+ }
+
+ static struct platform_driver cgbc_driver = {
+diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c
+index 8de974ddac3e72..93a3dd93404dd9 100644
+--- a/drivers/mfd/qnap-mcu.c
++++ b/drivers/mfd/qnap-mcu.c
+@@ -56,6 +56,7 @@ struct qnap_mcu_reply {
+ * @reply: Reply data structure
+ * @variant: Device variant specific information
+ * @version: MCU firmware version
++ * @rx: Receive buffer the reply is assembled in
+ */
+ struct qnap_mcu {
+ struct serdev_device *serdev;
+@@ -63,6 +64,7 @@ struct qnap_mcu {
+ struct qnap_mcu_reply reply;
+ const struct qnap_mcu_variant *variant;
+ u8 version[QNAP_MCU_VERSION_LEN];
++ u8 rx[QNAP_MCU_RX_BUFFER_SIZE];
+ };
+
+ /*
+@@ -214,19 +216,18 @@ int qnap_mcu_exec(struct qnap_mcu *mcu,
+ const u8 *cmd_data, size_t cmd_data_size,
+ u8 *reply_data, size_t reply_data_size)
+ {
+- unsigned char rx[QNAP_MCU_RX_BUFFER_SIZE];
+ size_t length = reply_data_size + QNAP_MCU_CHECKSUM_SIZE;
+ struct qnap_mcu_reply *reply = &mcu->reply;
+ int ret = 0;
+
+- if (length > sizeof(rx)) {
++ if (length > sizeof(mcu->rx)) {
+ dev_err(&mcu->serdev->dev, "expected data too big for receive buffer");
+ return -EINVAL;
+ }
+
+ guard(mutex)(&mcu->bus_lock);
+
+- reply->data = rx;
++ reply->data = mcu->rx;
+ reply->length = length;
+ reply->received = 0;
+ reinit_completion(&reply->done);
+@@ -242,15 +243,15 @@ int qnap_mcu_exec(struct qnap_mcu *mcu,
+ return -ETIMEDOUT;
+ }
+
+- if (!qnap_mcu_verify_checksum(rx, reply->received)) {
++ if (!qnap_mcu_verify_checksum(mcu->rx, reply->received)) {
+ dev_err(&mcu->serdev->dev, "Invalid Checksum received from controller\n");
+ return -EPROTO;
+ }
+
+- if (qnap_mcu_reply_is_any_error(mcu, rx, reply->received))
++ if (qnap_mcu_reply_is_any_error(mcu, mcu->rx, reply->received))
+ return -EPROTO;
+
+- memcpy(reply_data, rx, reply_data_size);
++ memcpy(reply_data, mcu->rx, reply_data_size);
+
+ return 0;
+ }
+diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
+index b5bda477ebfc26..77888965d91ed8 100644
+--- a/drivers/mfd/sm501.c
++++ b/drivers/mfd/sm501.c
+@@ -1627,6 +1627,7 @@ static void sm501_pci_remove(struct pci_dev *dev)
+ release_mem_region(sm->io_res->start, 0x100);
+
+ pci_disable_device(dev);
++ kfree(sm);
+ }
+
+ static void sm501_plat_remove(struct platform_device *dev)
+@@ -1637,6 +1638,7 @@ static void sm501_plat_remove(struct platform_device *dev)
+ iounmap(sm->regs);
+
+ release_mem_region(sm->io_res->start, 0x100);
++ kfree(sm);
+ }
+
+ static const struct pci_device_id sm501_pci_tbl[] = {
+diff --git a/drivers/misc/nsm.c b/drivers/misc/nsm.c
+index 3960506eb7ab3d..c3b474450d159a 100644
+--- a/drivers/misc/nsm.c
++++ b/drivers/misc/nsm.c
+@@ -243,7 +243,7 @@ static int nsm_sendrecv_msg_locked(struct nsm *nsm)
+ goto cleanup;
+ }
+
+- msg->resp.len = len;
++ msg->resp.len = min_t(unsigned int, len, sizeof(msg->resp.data));
+
+ rc = 0;
+
+diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c
+index 8c049f8355cdf9..4910d0f444bab7 100644
+--- a/drivers/mmc/host/via-sdmmc.c
++++ b/drivers/mmc/host/via-sdmmc.c
+@@ -1153,10 +1153,16 @@ static int via_sd_probe(struct pci_dev *pcidev,
+
+ ret = mmc_add_host(mmc);
+ if (ret)
+- goto unmap;
++ goto free_irq;
+
+ return 0;
+
++free_irq:
++ writeb(0x0, sdhost->pcictrl_mmiobase + VIA_CRDR_PCIINTCTRL);
++ free_irq(pcidev->irq, sdhost);
++ cancel_work_sync(&sdhost->carddet_work);
++ /* carddet_work may re-enable the interrupt via via_reset_pcictrl(). */
++ writeb(0x0, sdhost->pcictrl_mmiobase + VIA_CRDR_PCIINTCTRL);
+ unmap:
+ iounmap(sdhost->mmiobase);
+ release:
+@@ -1199,6 +1205,10 @@ static void via_sd_remove(struct pci_dev *pcidev)
+
+ free_irq(pcidev->irq, sdhost);
+
++ cancel_work_sync(&sdhost->carddet_work);
++ /* carddet_work may re-enable the interrupt via via_reset_pcictrl(). */
++ writeb(0x0, sdhost->pcictrl_mmiobase + VIA_CRDR_PCIINTCTRL);
++
+ timer_delete_sync(&sdhost->timer);
+
+ cancel_work_sync(&sdhost->finish_bh_work);
+diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
+index 9dd50b20c000a0..d2e92bab55d29d 100644
+--- a/drivers/net/dsa/realtek/rtl83xx.c
++++ b/drivers/net/dsa/realtek/rtl83xx.c
+@@ -321,7 +321,7 @@ void rtl83xx_reset_assert(struct realtek_priv *priv)
+ "Failed to assert the switch reset control: %pe\n",
+ ERR_PTR(ret));
+
+- gpiod_set_value(priv->reset, true);
++ gpiod_set_value_cansleep(priv->reset, true);
+ }
+
+ void rtl83xx_reset_deassert(struct realtek_priv *priv)
+@@ -334,7 +334,7 @@ void rtl83xx_reset_deassert(struct realtek_priv *priv)
+ "Failed to deassert the switch reset control: %pe\n",
+ ERR_PTR(ret));
+
+- gpiod_set_value(priv->reset, false);
++ gpiod_set_value_cansleep(priv->reset, false);
+ }
+
+ /**
+diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+index 208a894d6190c6..39eb6ab5f8058b 100644
+--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+@@ -13473,10 +13473,13 @@ static int bnx2x_init_firmware(struct bnx2x *bp)
+
+ iro_alloc_err:
+ kfree(bp->init_ops_offsets);
++ bp->init_ops_offsets = NULL;
+ init_offsets_alloc_err:
+ kfree(bp->init_ops);
++ bp->init_ops = NULL;
+ init_ops_alloc_err:
+ kfree(bp->init_data);
++ bp->init_data = NULL;
+ request_firmware_exit:
+ release_firmware(bp->firmware);
+ bp->firmware = NULL;
+diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+index bc7b37cb74a717..54bae193d1f637 100644
+--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+@@ -485,6 +485,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
+ struct bnxt_sw_tx_bd *tx_buf;
+ __le32 lflags = 0;
+ skb_frag_t *frag;
++ netdev_tx_t ret;
+
+ i = skb_get_queue_mapping(skb);
+ if (unlikely(i >= bp->tx_nr_rings)) {
+@@ -501,17 +502,19 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
+ if (skb_shinfo(skb)->nr_frags > TX_MAX_FRAGS) {
+ netdev_warn_once(dev, "SKB has too many (%d) fragments, max supported is %d. SKB will be linearized.\n",
+ skb_shinfo(skb)->nr_frags, TX_MAX_FRAGS);
+- if (skb_linearize(skb)) {
+- dev_kfree_skb_any(skb);
+- dev_core_stats_tx_dropped_inc(dev);
+- return NETDEV_TX_OK;
+- }
++ if (skb_linearize(skb))
++ goto tx_free;
+ }
+ #endif
+ if (skb_is_gso(skb) &&
+ (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) &&
+- !(bp->flags & BNXT_FLAG_UDP_GSO_CAP))
+- return bnxt_sw_udp_gso_xmit(bp, txr, txq, skb);
++ !(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) {
++ ret = bnxt_sw_udp_gso_xmit(bp, txr, txq, skb);
++ if (txr->kick_pending)
++ bnxt_txr_db_kick(bp, txr, txr->tx_prod);
++
++ return ret;
++ }
+
+ free_size = bnxt_tx_avail(bp, txr);
+ if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) {
+diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
+index f317f60414e813..f7e18bea0fb84f 100644
+--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
+@@ -223,9 +223,7 @@ netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp,
+ netdev_tx_sent_queue(txq, skb->len);
+
+ WRITE_ONCE(txr->tx_prod, prod);
+- /* Sync BDs before doorbell */
+- wmb();
+- bnxt_db_write(bp, &txr->tx_db, prod);
++ txr->kick_pending = 1;
+
+ if (unlikely(bnxt_tx_avail(bp, txr) <= bp->tx_wake_thresh))
+ netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr),
+diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c
+index 74526002d52bdf..42027665f2a93f 100644
+--- a/drivers/net/ethernet/ibm/emac/mal.c
++++ b/drivers/net/ethernet/ibm/emac/mal.c
+@@ -35,6 +35,7 @@ int mal_register_commac(struct mal_instance *mal, struct mal_commac *commac)
+ {
+ unsigned long flags;
+
++ netdev_lock(mal->napi.dev);
+ spin_lock_irqsave(&mal->lock, flags);
+
+ MAL_DBG(mal, "reg(%08x, %08x)" NL,
+@@ -44,18 +45,20 @@ int mal_register_commac(struct mal_instance *mal, struct mal_commac *commac)
+ if ((mal->tx_chan_mask & commac->tx_chan_mask) ||
+ (mal->rx_chan_mask & commac->rx_chan_mask)) {
+ spin_unlock_irqrestore(&mal->lock, flags);
++ netdev_unlock(mal->napi.dev);
+ printk(KERN_WARNING "mal%d: COMMAC channels conflict!\n",
+ mal->index);
+ return -EBUSY;
+ }
+
+ if (list_empty(&mal->list))
+- napi_enable(&mal->napi);
++ napi_enable_locked(&mal->napi);
+ mal->tx_chan_mask |= commac->tx_chan_mask;
+ mal->rx_chan_mask |= commac->rx_chan_mask;
+ list_add(&commac->list, &mal->list);
+
+ spin_unlock_irqrestore(&mal->lock, flags);
++ netdev_unlock(mal->napi.dev);
+
+ return 0;
+ }
+@@ -64,7 +67,9 @@ void mal_unregister_commac(struct mal_instance *mal,
+ struct mal_commac *commac)
+ {
+ unsigned long flags;
++ bool disable_napi;
+
++ netdev_lock(mal->napi.dev);
+ spin_lock_irqsave(&mal->lock, flags);
+
+ MAL_DBG(mal, "unreg(%08x, %08x)" NL,
+@@ -73,10 +78,12 @@ void mal_unregister_commac(struct mal_instance *mal,
+ mal->tx_chan_mask &= ~commac->tx_chan_mask;
+ mal->rx_chan_mask &= ~commac->rx_chan_mask;
+ list_del_init(&commac->list);
+- if (list_empty(&mal->list))
+- napi_disable(&mal->napi);
++ disable_napi = list_empty(&mal->list);
+
+ spin_unlock_irqrestore(&mal->lock, flags);
++ if (disable_napi)
++ napi_disable_locked(&mal->napi);
++ netdev_unlock(mal->napi.dev);
+ }
+
+ int mal_set_rcbs(struct mal_instance *mal, int channel, unsigned long size)
+diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+index 6fbc0441c4b845..6fc6605d20549b 100644
+--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+@@ -2263,6 +2263,11 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
+
+ data_offset = wqe_offset & (page_size - 1);
+ page_idx = wqe_offset >> rq->mpwqe.page_shift;
++ if (unlikely(cqe_bcnt <= ETH_ZLEN + 2 * VLAN_HLEN)) {
++ match = false;
++ flush = true;
++ }
++
+ if (*skb &&
+ !(match && mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt,
+ page_size))) {
+diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
+index 58d3e55def486b..dc804e11156415 100644
+--- a/drivers/net/ethernet/nvidia/forcedeth.c
++++ b/drivers/net/ethernet/nvidia/forcedeth.c
+@@ -6221,7 +6221,7 @@ static int nv_suspend(struct device *device)
+ netif_device_detach(dev);
+
+ /* save non-pci configuration space */
+- for (i = 0; i <= np->register_size/sizeof(u32); i++)
++ for (i = 0; i < np->register_size/sizeof(u32); i++)
+ np->saved_config_space[i] = readl(base + i*sizeof(u32));
+
+ return 0;
+@@ -6236,7 +6236,7 @@ static int nv_resume(struct device *device)
+ int i, rc = 0;
+
+ /* restore non-pci configuration space */
+- for (i = 0; i <= np->register_size/sizeof(u32); i++)
++ for (i = 0; i < np->register_size/sizeof(u32); i++)
+ writel(np->saved_config_space[i], base+i*sizeof(u32));
+
+ if (np->driver_data & DEV_NEED_MSI_FIX)
+diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h
+index 042a75f3406082..0e7a0c2c176517 100644
+--- a/drivers/net/ethernet/qlogic/qede/qede.h
++++ b/drivers/net/ethernet/qlogic/qede/qede.h
+@@ -303,10 +303,10 @@ enum qede_agg_state {
+ };
+
+ struct qede_agg_info {
+- /* rx_buf is a data buffer that can be placed / consumed from rx bd
+- * chain. It has two purposes: We will preallocate the data buffer
+- * for each aggregation when we open the interface and will place this
+- * buffer on the rx-bd-ring when we receive TPA_START. We don't want
++ /* buffer is used to retain the Rx consumer descriptor when a TPA
++ * session starts. If the SKB allocation fails during TPA_START,
++ * we use this saved buffer to safely recycle the physical page
++ * back into the rx-bd-ring via qede_reuse_page(). We don't want
+ * to be in a state where allocation fails, as we can't reuse the
+ * consumer buffer in the rx-chain since FW may still be writing to it
+ * (since header needs to be modified for TPA).
+diff --git a/drivers/net/ethernet/qlogic/qede/qede_fp.c b/drivers/net/ethernet/qlogic/qede/qede_fp.c
+index c11e0d8f98aa5c..a02624f6d6d59c 100644
+--- a/drivers/net/ethernet/qlogic/qede/qede_fp.c
++++ b/drivers/net/ethernet/qlogic/qede/qede_fp.c
+@@ -850,6 +850,7 @@ static void qede_tpa_start(struct qede_dev *edev,
+ pad, false);
+ tpa_info->buffer.page_offset = sw_rx_data_cons->page_offset;
+ tpa_info->buffer.mapping = sw_rx_data_cons->mapping;
++ tpa_info->buffer.data = sw_rx_data_cons->data;
+
+ if (unlikely(!tpa_info->skb)) {
+ DP_NOTICE(edev, "Failed to allocate SKB for gro\n");
+diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
+index 5e56ec9b1013ab..3ee4c61081890c 100644
+--- a/drivers/net/ethernet/renesas/ravb.h
++++ b/drivers/net/ethernet/renesas/ravb.h
+@@ -1028,6 +1028,7 @@ struct ravb_ptp_perout {
+ struct ravb_ptp {
+ struct ptp_clock *clock;
+ struct ptp_clock_info info;
++ int phc_index;
+ u32 default_addend;
+ u32 current_addend;
+ int extts[N_EXT_TS];
+@@ -1123,6 +1124,8 @@ struct ravb_private {
+ int msg_enable;
+ int speed;
+ int emac_irq;
++ int err_irq;
++ int mgmt_irq;
+
+ unsigned no_avb_link:1;
+ unsigned avb_link_active_low:1;
+diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
+index 5f88733094d0fc..ea1c7e536791e8 100644
+--- a/drivers/net/ethernet/renesas/ravb_main.c
++++ b/drivers/net/ethernet/renesas/ravb_main.c
+@@ -1779,7 +1779,7 @@ static int ravb_get_ts_info(struct net_device *ndev,
+ (1 << HWTSTAMP_FILTER_NONE) |
+ (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
+ (1 << HWTSTAMP_FILTER_ALL);
+- info->phc_index = ptp_clock_index(priv->ptp.clock);
++ info->phc_index = READ_ONCE(priv->ptp.phc_index);
+ }
+
+ return 0;
+@@ -2885,11 +2885,13 @@ static int ravb_setup_irqs(struct ravb_private *priv)
+ return error;
+
+ if (info->err_mgmt_irqs) {
+- error = ravb_setup_irq(priv, "err_a", "err_a", NULL, ravb_multi_interrupt);
++ error = ravb_setup_irq(priv, "err_a", "err_a", &priv->err_irq,
++ ravb_multi_interrupt);
+ if (error)
+ return error;
+
+- error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", NULL, ravb_multi_interrupt);
++ error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &priv->mgmt_irq,
++ ravb_multi_interrupt);
+ if (error)
+ return error;
+ }
+@@ -2953,6 +2955,7 @@ static int ravb_probe(struct platform_device *pdev)
+ priv->rstc = rstc;
+ priv->ndev = ndev;
+ priv->pdev = pdev;
++ priv->ptp.phc_index = -1;
+ priv->num_tx_ring[RAVB_BE] = BE_TX_RING_SIZE;
+ priv->num_rx_ring[RAVB_BE] = BE_RX_RING_SIZE;
+ if (info->nc_queues) {
+diff --git a/drivers/net/ethernet/renesas/ravb_ptp.c b/drivers/net/ethernet/renesas/ravb_ptp.c
+index 226c6c0ab945b6..43218bc15b1519 100644
+--- a/drivers/net/ethernet/renesas/ravb_ptp.c
++++ b/drivers/net/ethernet/renesas/ravb_ptp.c
+@@ -289,16 +289,17 @@ static const struct ptp_clock_info ravb_ptp_info = {
+ void ravb_ptp_interrupt(struct net_device *ndev)
+ {
+ struct ravb_private *priv = netdev_priv(ndev);
++ struct ptp_clock *clock = READ_ONCE(priv->ptp.clock);
+ u32 gis = ravb_read(ndev, GIS);
+
+ gis &= ravb_read(ndev, GIC);
+- if (gis & GIS_PTCF) {
++ if ((gis & GIS_PTCF) && clock) {
+ struct ptp_clock_event event;
+
+ event.type = PTP_CLOCK_EXTTS;
+ event.index = 0;
+ event.timestamp = ravb_read(ndev, GCPT);
+- ptp_clock_event(priv->ptp.clock, &event);
++ ptp_clock_event(clock, &event);
+ }
+ if (gis & GIS_PTMF) {
+ struct ravb_ptp_perout *perout = priv->ptp.perout;
+@@ -315,6 +316,7 @@ void ravb_ptp_interrupt(struct net_device *ndev)
+ void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev)
+ {
+ struct ravb_private *priv = netdev_priv(ndev);
++ struct ptp_clock *clock;
+ unsigned long flags;
+
+ priv->ptp.info = ravb_ptp_info;
+@@ -327,15 +329,45 @@ void ravb_ptp_init(struct net_device *ndev, struct platform_device *pdev)
+ ravb_modify(ndev, GCCR, GCCR_TCSS, GCCR_TCSS_ADJGPTP);
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+- priv->ptp.clock = ptp_clock_register(&priv->ptp.info, &pdev->dev);
++ clock = ptp_clock_register(&priv->ptp.info, &pdev->dev);
++ if (IS_ERR(clock)) {
++ netdev_err(ndev, "failed to register PTP clock: %pe\n", clock);
++ clock = NULL;
++ }
++
++ WRITE_ONCE(priv->ptp.clock, clock);
++ if (clock)
++ WRITE_ONCE(priv->ptp.phc_index, ptp_clock_index(clock));
++}
++
++static void ravb_ptp_disable(struct net_device *ndev)
++{
++ ravb_write(ndev, 0, GIC);
++ ravb_write(ndev, 0, GIS);
++}
++
++static void ravb_ptp_sync_irqs(struct net_device *ndev)
++{
++ struct ravb_private *priv = netdev_priv(ndev);
++
++ synchronize_irq(ndev->irq);
++ if (priv->info->err_mgmt_irqs) {
++ synchronize_irq(priv->err_irq);
++ synchronize_irq(priv->mgmt_irq);
++ }
+ }
+
+ void ravb_ptp_stop(struct net_device *ndev)
+ {
+ struct ravb_private *priv = netdev_priv(ndev);
++ struct ptp_clock *clock;
+
+- ravb_write(ndev, 0, GIC);
+- ravb_write(ndev, 0, GIS);
++ WRITE_ONCE(priv->ptp.phc_index, -1);
++ clock = xchg(&priv->ptp.clock, NULL);
++
++ ravb_ptp_disable(ndev);
++ ravb_ptp_sync_irqs(ndev);
+
+- ptp_clock_unregister(priv->ptp.clock);
++ if (clock)
++ ptp_clock_unregister(clock);
+ }
+diff --git a/drivers/net/ipa/ipa_modem.c b/drivers/net/ipa/ipa_modem.c
+index 9b136f6b8b4ae8..d84c1dbd3b1a84 100644
+--- a/drivers/net/ipa/ipa_modem.c
++++ b/drivers/net/ipa/ipa_modem.c
+@@ -266,13 +266,29 @@ void ipa_modem_suspend(struct net_device *netdev)
+ * the modem. We can't enable the queue directly in ipa_modem_resume()
+ * because transmits restart the instant the queue is awakened; but the
+ * device power state won't be ACTIVE until *after* ipa_modem_resume()
+- * returns.
++ * returns. A transmit restarted before that would stop the queue
++ * again and get -EINPROGRESS from pm_runtime_get(), and with this
++ * work having already run, nothing would ever wake the queue again.
++ * So wait for the resume to complete before waking the queue.
+ */
+ static void ipa_modem_wake_queue_work(struct work_struct *work)
+ {
+ struct ipa_priv *priv = container_of(work, struct ipa_priv, work);
++ struct device *dev = priv->ipa->dev;
++ int ret;
++
++ ret = pm_runtime_get_sync(dev);
+
++ /* Wake the queue even if the device could not be resumed, so
++ * that pending packets are dropped by the transmit path rather
++ * than stranded behind a stopped queue.
++ */
+ netif_wake_queue(priv->tx->netdev);
++
++ if (ret < 0)
++ pm_runtime_put_noidle(dev);
++ else
++ (void)pm_runtime_put_autosuspend(dev);
+ }
+
+ /** ipa_modem_resume() - resume callback for runtime_pm
+diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c
+index 029a4a532a104e..9c171697e76209 100644
+--- a/drivers/net/ntb_netdev.c
++++ b/drivers/net/ntb_netdev.c
+@@ -144,6 +144,9 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
+ goto enqueue_again;
+ }
+
++ ndev->stats.rx_packets++;
++ ndev->stats.rx_bytes += len;
++
+ new_skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN);
+ if (!new_skb) {
+ ndev->stats.rx_dropped++;
+@@ -155,13 +158,7 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
+ skb->ip_summed = CHECKSUM_NONE;
+ skb_record_rx_queue(skb, q->qid);
+
+- if (netif_rx(skb) == NET_RX_DROP) {
+- ndev->stats.rx_errors++;
+- ndev->stats.rx_dropped++;
+- } else {
+- ndev->stats.rx_packets++;
+- ndev->stats.rx_bytes += len;
+- }
++ netif_rx(skb);
+
+ skb = new_skb;
+
+@@ -199,8 +196,10 @@ static int __ntb_netdev_maybe_stop_tx(struct net_device *netdev,
+ static int ntb_netdev_maybe_stop_tx(struct net_device *ndev,
+ struct ntb_netdev_queue *q, int size)
+ {
+- if (__netif_subqueue_stopped(ndev, q->qid) ||
+- (ntb_transport_tx_free_entry(q->qp) >= size))
++ if (__netif_subqueue_stopped(ndev, q->qid))
++ return -EBUSY;
++
++ if (ntb_transport_tx_free_entry(q->qp) >= size)
+ return 0;
+
+ return __ntb_netdev_maybe_stop_tx(ndev, q, size);
+@@ -256,21 +255,30 @@ static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb,
+
+ q = &dev->queues[qid];
+
+- ntb_netdev_maybe_stop_tx(ndev, q, tx_stop);
++ if (unlikely(ntb_netdev_maybe_stop_tx(ndev, q, tx_stop)))
++ return NETDEV_TX_BUSY;
+
+ rc = ntb_transport_tx_enqueue(q->qp, skb, skb->data, skb->len);
+- if (rc)
+- goto err;
++ if (rc) {
++ if (rc == -EAGAIN || rc == -EBUSY) {
++ netif_stop_subqueue(ndev, q->qid);
++ mod_timer(&q->tx_timer,
++ jiffies + usecs_to_jiffies(tx_time));
++ return NETDEV_TX_BUSY;
++ }
++
++ goto drop;
++ }
+
+ /* check for next submit */
+ ntb_netdev_maybe_stop_tx(ndev, q, tx_stop);
+
+ return NETDEV_TX_OK;
+
+-err:
++drop:
++ dev_kfree_skb_any(skb);
+ ndev->stats.tx_dropped++;
+- ndev->stats.tx_errors++;
+- return NETDEV_TX_BUSY;
++ return NETDEV_TX_OK;
+ }
+
+ static void ntb_netdev_tx_timer(struct timer_list *t)
+diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
+index 18d2ead97aa547..7397169236fdfe 100644
+--- a/drivers/net/phy/phylink.c
++++ b/drivers/net/phy/phylink.c
+@@ -965,7 +965,7 @@ static unsigned int phylink_inband_caps(struct phylink *pl,
+ return 0;
+
+ pcs = pl->mac_ops->mac_select_pcs(pl->config, interface);
+- if (!pcs)
++ if (IS_ERR_OR_NULL(pcs))
+ return 0;
+
+ return phylink_pcs_inband_caps(pcs, interface);
+diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
+index faae711cf793d3..85b2438e892351 100644
+--- a/drivers/net/slip/slip.c
++++ b/drivers/net/slip/slip.c
+@@ -628,9 +628,15 @@ static void sl_uninit(struct net_device *dev)
+ struct slip *sl = netdev_priv(dev);
+
+ sl_free_bufs(sl);
++ /* Drop the slip_devs[] entry here rather than from the destructor:
++ * ndo_uninit runs under RTNL, so it cannot race sl_sync().
++ */
++ slip_devs[dev->base_addr] = NULL;
+ }
+
+-/* Hook the destructor so we can free slip devices at the right point in time */
++/* Only for the slip_open() error path: register_netdevice() can fail before
++ * ndo_init, and then ndo_uninit is not called either.
++ */
+ static void sl_free_netdev(struct net_device *dev)
+ {
+ int i = dev->base_addr;
+@@ -657,7 +663,6 @@ static void sl_setup(struct net_device *dev)
+ {
+ dev->netdev_ops = &sl_netdev_ops;
+ dev->needs_free_netdev = true;
+- dev->priv_destructor = sl_free_netdev;
+
+ dev->hard_header_len = 0;
+ dev->addr_len = 0;
+@@ -908,7 +913,7 @@ static void slip_close(struct tty_struct *tty)
+ #endif
+ /* Flush network side */
+ unregister_netdev(sl->dev);
+- /* This will complete via sl_free_netdev */
++ /* sl_uninit() has dropped the slip_devs[] entry by now */
+ }
+
+ static void slip_hangup(struct tty_struct *tty)
+diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c
+index 98893732bc6e46..2a1728621887aa 100644
+--- a/drivers/net/thunderbolt/main.c
++++ b/drivers/net/thunderbolt/main.c
+@@ -626,6 +626,14 @@ static int tbnet_alloc_tx_buffers(struct tbnet *net)
+ return 0;
+ }
+
++static void tbnet_connect_failed(struct tbnet *net)
++{
++ /* Leave login_received set: only the peer can make it true again. */
++ mutex_lock(&net->connection_lock);
++ net->login_sent = false;
++ mutex_unlock(&net->connection_lock);
++}
++
+ static void tbnet_connected_work(struct work_struct *work)
+ {
+ struct tbnet *net = container_of(work, typeof(*net), connected_work);
+@@ -647,6 +655,9 @@ static void tbnet_connected_work(struct work_struct *work)
+ ret = tb_xdomain_alloc_in_hopid(net->xd, net->remote_transmit_path);
+ if (ret != net->remote_transmit_path) {
+ netdev_err(net->dev, "failed to allocate Rx HopID\n");
++ if (ret >= 0)
++ tb_xdomain_release_in_hopid(net->xd, ret);
++ tbnet_connect_failed(net);
+ return;
+ }
+
+@@ -691,6 +702,7 @@ err_stop_rings:
+ tb_ring_stop(net->rx_ring.ring);
+ tb_ring_stop(net->tx_ring.ring);
+ tb_xdomain_release_in_hopid(net->xd, net->remote_transmit_path);
++ tbnet_connect_failed(net);
+ }
+
+ static void tbnet_login_work(struct work_struct *work)
+diff --git a/drivers/net/tun.c b/drivers/net/tun.c
+index fed9dfdfcc3bc0..5bbe3123979e00 100644
+--- a/drivers/net/tun.c
++++ b/drivers/net/tun.c
+@@ -1107,11 +1107,16 @@ static netdev_features_t tun_net_fix_features(struct net_device *dev,
+ static void tun_set_headroom(struct net_device *dev, int new_hr)
+ {
+ struct tun_struct *tun = netdev_priv(dev);
++ size_t max_headroom;
+
+- if (new_hr < NET_SKB_PAD)
+- new_hr = NET_SKB_PAD;
++ max_headroom = min_t(size_t, SKB_MAX_HEAD(0), U16_MAX - 1);
+
+- tun->align = new_hr;
++ if ((tun->flags & TUN_TYPE_MASK) == IFF_TAP)
++ max_headroom -= ETH_HLEN + NET_IP_ALIGN;
++ else
++ max_headroom -= 1;
++
++ tun->align = clamp_t(int, new_hr, NET_SKB_PAD, max_headroom);
+ }
+
+ static void
+@@ -1822,7 +1827,13 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
+ switch (tun->flags & TUN_TYPE_MASK) {
+ case IFF_TUN:
+ if (tun->flags & IFF_NO_PI) {
+- u8 ip_version = skb->len ? (skb->data[0] >> 4) : 0;
++ u8 ip_version;
++
++ if (!pskb_may_pull(skb, 1)) {
++ err = -EINVAL;
++ goto drop;
++ }
++ ip_version = skb->data[0] >> 4;
+
+ switch (ip_version) {
+ case 4:
+@@ -1842,7 +1853,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
+ skb->dev = tun->dev;
+ break;
+ case IFF_TAP:
+- if (frags && !pskb_may_pull(skb, ETH_HLEN)) {
++ if (!pskb_may_pull(skb, ETH_HLEN)) {
+ err = -ENOMEM;
+ drop_reason = SKB_DROP_REASON_HDR_TRUNC;
+ goto drop;
+diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
+index 94cdb61dca83db..8178a8758cd3fc 100644
+--- a/drivers/net/usb/qmi_wwan.c
++++ b/drivers/net/usb/qmi_wwan.c
+@@ -1360,6 +1360,7 @@ static const struct usb_device_id products[] = {
+ {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
+ {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
+ {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
++ {QMI_QUIRK_SET_DTR(0x1bc7, 0x0991, 0)}, /* Telit FE990D50 */
+ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1031, 3)}, /* Telit LE910C1-EUX */
+ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1034, 2)}, /* Telit LE910C4-WWX */
+ {QMI_QUIRK_SET_DTR(0x1bc7, 0x1037, 4)}, /* Telit LE910C4-WWX */
+diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
+index cc0f2c45fc3a30..62f663c0daa265 100644
+--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
++++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
+@@ -754,6 +754,11 @@ void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
+ u8 *assoc_resp_ie = assoc_info + beacon_ie_len + assoc_req_len +
+ assoc_resp_ie_offset;
+
++ if (assoc_req_len < assoc_req_ie_offset)
++ assoc_req_len = assoc_req_ie_offset;
++ if (assoc_resp_len < assoc_resp_ie_offset)
++ assoc_resp_len = assoc_resp_ie_offset;
++
+ assoc_req_len -= assoc_req_ie_offset;
+ assoc_resp_len -= assoc_resp_ie_offset;
+
+diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+index 9f7ed1d293a066..381801af3ac982 100644
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+@@ -1827,17 +1827,18 @@ gotpkt:
+ if (bus->rxctl) {
+ brcmf_err("last control frame is being processed.\n");
+ spin_unlock_bh(&bus->rxctl_lock);
+- vfree(buf);
+ goto done;
+ }
+ bus->rxctl = buf + doff;
+ bus->rxctl_orig = buf;
+ bus->rxlen = len - doff;
+ spin_unlock_bh(&bus->rxctl_lock);
++ buf = NULL;
+
+ done:
+ /* Awake any waiters */
+ brcmf_sdio_dcmd_resp_wake(bus);
++ vfree(buf);
+ }
+
+ /* Pad read to blocksize for efficiency */
+diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/main.c b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
+index ca5a8140908afb..6bd5b6d84b2a9b 100644
+--- a/drivers/net/wireless/intel/iwlwifi/dvm/main.c
++++ b/drivers/net/wireless/intel/iwlwifi/dvm/main.c
+@@ -1511,10 +1511,10 @@ out_destroy_workqueue:
+ priv->workqueue = NULL;
+ out_uninit_drv:
+ iwl_uninit_drv(priv);
+-out_free_eeprom_blob:
+- kfree(priv->eeprom_blob);
+ out_free_eeprom:
+ kfree(priv->nvm_data);
++out_free_eeprom_blob:
++ kfree(priv->eeprom_blob);
+ out_leave_trans:
+ iwl_trans_op_mode_leave(priv->trans);
+ out_free_hw:
+diff --git a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
+index 9460d5352b234e..19196848778c0c 100644
+--- a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
++++ b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
+@@ -57,6 +57,18 @@ int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
+ mwifiex_dbg(adapter, ERROR, "cmd_wait_q terminated: %d\n",
+ status);
+ mwifiex_cancel_all_pending_cmd(adapter);
++
++ /* The command response path writes through cmd_node->data_buf.
++ * On an interrupted wait, the caller can return and release a
++ * stack-allocated data_buf before a late firmware response is
++ * processed. Detach the caller-owned buffer from the current
++ * command so a late response cannot corrupt freed stack memory.
++ */
++ spin_lock_bh(&adapter->mwifiex_cmd_lock);
++ if (adapter->curr_cmd == cmd_queued)
++ adapter->curr_cmd->data_buf = NULL;
++ spin_unlock_bh(&adapter->mwifiex_cmd_lock);
++
+ return status;
+ }
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+index fc619acbb40d0b..67f56e428d9a15 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+@@ -1239,11 +1239,12 @@ static int mt7615_suspend(struct ieee80211_hw *hw,
+ cancel_delayed_work_sync(&dev->pm.ps_work);
+ mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
+
++ cancel_delayed_work_sync(&phy->scan_work);
++ cancel_delayed_work_sync(&phy->mt76->mac_work);
++
+ mt7615_mutex_acquire(dev);
+
+ clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
+- cancel_delayed_work_sync(&phy->scan_work);
+- cancel_delayed_work_sync(&phy->mt76->mac_work);
+
+ set_bit(MT76_STATE_SUSPEND, &phy->mt76->state);
+ ieee80211_iterate_active_interfaces(hw,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+index e8fe86f9330972..bbb2fedacb25af 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+@@ -2917,8 +2917,15 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
+ return ret;
+
+ res = (struct mt7915_mcu_eeprom_info *)skb->data;
+- if (!buf)
+- buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
++ if (!buf) {
++ u32 addr = le32_to_cpu(res->addr);
++
++ if (addr > dev->mt76.eeprom.size - MT7915_EEPROM_BLOCK_SIZE) {
++ dev_kfree_skb(skb);
++ return -EINVAL;
++ }
++ buf = dev->mt76.eeprom.data + addr;
++ }
+ memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
+
+ dev_kfree_skb(skb);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+index c7a07c72744412..9b58ffec36493d 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7925/mac.c
+@@ -1323,6 +1323,7 @@ void mt7925_mac_reset_work(struct work_struct *work)
+
+ cancel_delayed_work_sync(&dev->mphy.mac_work);
+ cancel_delayed_work_sync(&pm->ps_work);
++ cancel_delayed_work_sync(&dev->mlo_pm_work);
+ cancel_work_sync(&pm->wake_work);
+
+ for (i = 0; i < 10; i++) {
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+index 2b6cc8e253c0e9..3beb2c1fbec9c5 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c
+@@ -1640,6 +1640,7 @@ static int mt7925_suspend(struct ieee80211_hw *hw,
+ cancel_delayed_work_sync(&phy->mt76->mac_work);
+
+ cancel_delayed_work_sync(&dev->pm.ps_work);
++ cancel_delayed_work_sync(&dev->mlo_pm_work);
+ mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
+
+ mt792x_mutex_acquire(dev);
+@@ -2484,10 +2485,19 @@ static void mt7925_channel_switch_rx_beacon(struct ieee80211_hw *hw,
+ }
+ }
+
++static void mt7925_stop(struct ieee80211_hw *hw, bool suspend)
++{
++ struct mt792x_dev *dev = mt792x_hw_dev(hw);
++
++ cancel_delayed_work_sync(&dev->mlo_pm_work);
++
++ mt792x_stop(hw, suspend);
++}
++
+ const struct ieee80211_ops mt7925_ops = {
+ .tx = mt792x_tx,
+ .start = mt7925_start,
+- .stop = mt792x_stop,
++ .stop = mt7925_stop,
+ .add_interface = mt7925_add_interface,
+ .remove_interface = mt792x_remove_interface,
+ .config = mt7925_config,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
+index ea64303283edbe..084baadfa18336 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7925/pci.c
+@@ -48,6 +48,7 @@ static void mt7925e_unregister_device(struct mt792x_dev *dev)
+ mt76_for_each_q_rx(&dev->mt76, i)
+ napi_disable(&dev->mt76.napi[i]);
+ cancel_delayed_work_sync(&pm->ps_work);
++ cancel_delayed_work_sync(&dev->mlo_pm_work);
+ cancel_work_sync(&pm->wake_work);
+ cancel_work_sync(&dev->reset_work);
+
+@@ -517,6 +518,7 @@ static int mt7925_pci_suspend(struct device *device)
+ dev->hif_resumed = false;
+ flush_work(&dev->reset_work);
+ cancel_delayed_work_sync(&pm->ps_work);
++ cancel_delayed_work_sync(&dev->mlo_pm_work);
+ cancel_work_sync(&pm->wake_work);
+
+ mt7925_roc_abort_sync(dev);
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/usb.c b/drivers/net/wireless/mediatek/mt76/mt7925/usb.c
+index e9f58492bf7df8..a798164b9a0545 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7925/usb.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7925/usb.c
+@@ -269,6 +269,7 @@ static int mt7925u_suspend(struct usb_interface *intf, pm_message_t state)
+ pm->suspended = true;
+ dev->hif_resumed = false;
+ flush_work(&dev->reset_work);
++ cancel_delayed_work_sync(&dev->mlo_pm_work);
+
+ mt76_connac_mcu_set_hif_suspend(&dev->mt76, true, false);
+ ret = wait_event_timeout(dev->wait,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
+index ac05f7d75d63d6..ec33521db564bd 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
+@@ -150,6 +150,12 @@ mt7996_eeprom_check_or_use_default(struct mt7996_dev *dev, bool use_default)
+ goto out;
+ }
+
++ if (fw->size < MT7996_EEPROM_SIZE) {
++ dev_err(dev->mt76.dev, "Invalid default bin size\n");
++ ret = -EINVAL;
++ goto out;
++ }
++
+ if (!use_default && mt7996_eeprom_variant_valid(dev, fw->data))
+ goto out;
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+index 0eebc8182ca9aa..730fd8e2fa0577 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+@@ -1239,6 +1239,30 @@ mt7996_tx_check_aggr(struct ieee80211_link_sta *link_sta,
+ clear_bit(tid, &wcid->ampdu_state);
+ }
+
++static void
++mt7996_txp_skb_unmap(struct mt76_dev *mdev, struct mt76_txwi_cache *t)
++{
++ u8 *txwi_ptr = mt76_get_txwi_ptr(mdev, t);
++ __le32 *txwi = (__le32 *)txwi_ptr;
++ __le32 *txp;
++ dma_addr_t addr;
++ u32 val;
++
++ if (!(le32_to_cpu(txwi[7]) & MT_TXD7_MAC_TXD)) {
++ mt76_connac_txp_skb_unmap(mdev, t);
++ return;
++ }
++
++ txp = (__le32 *)(txwi_ptr + MT_TXD_SIZE);
++ val = le32_to_cpu(txp[3]);
++ addr = le32_to_cpu(txp[2]);
++#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
++ addr |= (dma_addr_t)FIELD_GET(MT_TXP3_DMA_ADDR_H, val) << 32;
++#endif
++ dma_unmap_single(mdev->dma_dev, addr, FIELD_GET(MT_TXP_BUF_LEN, val),
++ DMA_TO_DEVICE);
++}
++
+ static void
+ mt7996_txwi_free(struct mt7996_dev *dev, struct mt76_txwi_cache *t,
+ struct ieee80211_link_sta *link_sta,
+@@ -1248,7 +1272,7 @@ mt7996_txwi_free(struct mt7996_dev *dev, struct mt76_txwi_cache *t,
+ __le32 *txwi;
+ u16 wcid_idx;
+
+- mt76_connac_txp_skb_unmap(mdev, t);
++ mt7996_txp_skb_unmap(mdev, t);
+ if (!t->skb)
+ goto out;
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+index 2e83f4b79c8704..a1bae5db85007d 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
+@@ -4352,11 +4352,18 @@ int mt7996_mcu_get_eeprom(struct mt7996_dev *dev, u32 offset, u8 *buf, u32 buf_l
+ event = (struct mt7996_mcu_eeprom_access_event *)skb->data;
+ if (event->valid) {
+ u32 ret_len = le32_to_cpu(event->eeprom.ext_eeprom.data_len);
++ u32 block = mode == EEPROM_MODE_EXT ? MT7996_EXT_EEPROM_BLOCK_SIZE :
++ MT7996_EEPROM_BLOCK_SIZE;
+
+ addr = le32_to_cpu(event->addr);
+
+- if (!buf)
++ if (!buf) {
++ if (addr > dev->mt76.eeprom.size - block) {
++ dev_kfree_skb(skb);
++ return -EINVAL;
++ }
+ buf = (u8 *)dev->mt76.eeprom.data + addr;
++ }
+
+ switch (mode) {
+ case EEPROM_MODE_EFUSE:
+diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
+index 070c0431c4821c..4a5989172a5e3e 100644
+--- a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
++++ b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
+@@ -1652,7 +1652,7 @@ static void rtl8180_eeprom_register_write(struct eeprom_93cx6 *eeprom)
+
+ static void rtl8180_eeprom_read(struct rtl8180_priv *priv)
+ {
+- struct eeprom_93cx6 eeprom;
++ struct eeprom_93cx6 eeprom = {};
+ int eeprom_cck_table_adr;
+ u16 eeprom_val;
+ int i;
+diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
+index 1d21c468a23685..a766712187f77c 100644
+--- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
++++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c
+@@ -1445,7 +1445,7 @@ static int rtl8187_probe(struct usb_interface *intf,
+ struct usb_device *udev = interface_to_usbdev(intf);
+ struct ieee80211_hw *dev;
+ struct rtl8187_priv *priv;
+- struct eeprom_93cx6 eeprom;
++ struct eeprom_93cx6 eeprom = {};
+ struct ieee80211_channel *channel;
+ const char *chip_name;
+ u16 txpwr, reg;
+diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
+index 646fe76b086e75..4f4bda3e0ce263 100644
+--- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
++++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
+@@ -5838,14 +5838,19 @@ static void rtl8xxxu_queue_rx_urb(struct rtl8xxxu_priv *priv,
+ {
+ struct sk_buff *skb;
+ unsigned long flags;
+- int pending = 0;
+
+ spin_lock_irqsave(&priv->rx_urb_lock, flags);
+
+ if (!priv->shutdown) {
+ list_add_tail(&rx_urb->list, &priv->rx_urb_pending_list);
+ priv->rx_urb_pending_count++;
+- pending = priv->rx_urb_pending_count;
++ /*
++ * Arm the worker under rx_urb_lock so this is atomic with the
++ * shutdown check: moving it out of the lock would let a
++ * completion arm the work after rtl8xxxu_stop() canceled it.
++ */
++ if (priv->rx_urb_pending_count > RTL8XXXU_RX_URB_PENDING_WATER)
++ schedule_work(&priv->rx_urb_wq);
+ } else {
+ skb = (struct sk_buff *)rx_urb->urb.context;
+ dev_kfree_skb_irq(skb);
+@@ -5853,9 +5858,6 @@ static void rtl8xxxu_queue_rx_urb(struct rtl8xxxu_priv *priv,
+ }
+
+ spin_unlock_irqrestore(&priv->rx_urb_lock, flags);
+-
+- if (pending > RTL8XXXU_RX_URB_PENDING_WATER)
+- schedule_work(&priv->rx_urb_wq);
+ }
+
+ static void rtl8xxxu_rx_urb_work(struct work_struct *work)
+@@ -7507,6 +7509,13 @@ static void rtl8xxxu_stop(struct ieee80211_hw *hw, bool suspend)
+ priv->shutdown = true;
+ spin_unlock_irqrestore(&priv->rx_urb_lock, flags);
+
++ /*
++ * Cancel before killing rx_anchor: the worker re-anchors every URB
++ * it drained via rtl8xxxu_submit_rx_urb(), so a worker still running
++ * after the kill could submit a URB that escapes it.
++ */
++ cancel_work_sync(&priv->rx_urb_wq);
++
+ usb_kill_anchored_urbs(&priv->rx_anchor);
+ usb_kill_anchored_urbs(&priv->tx_anchor);
+ if (priv->usb_interrupts)
+diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
+index 7bafb051d5ec95..88e8cc590c544b 100644
+--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
+@@ -145,8 +145,10 @@ static int rtl92du_init_sw_vars(struct ieee80211_hw *hw)
+
+ /* for firmware buf */
+ rtlpriv->rtlhal.pfirmware = kmalloc(0x8000, GFP_KERNEL);
+- if (!rtlpriv->rtlhal.pfirmware)
+- return -ENOMEM;
++ if (!rtlpriv->rtlhal.pfirmware) {
++ err = -ENOMEM;
++ goto error;
++ }
+
+ rtlpriv->max_fw_size = 0x8000;
+ pr_info("Driver for Realtek RTL8192DU WLAN interface\n");
+@@ -160,10 +162,14 @@ static int rtl92du_init_sw_vars(struct ieee80211_hw *hw)
+ pr_err("Failed to request firmware!\n");
+ kfree(rtlpriv->rtlhal.pfirmware);
+ rtlpriv->rtlhal.pfirmware = NULL;
+- return err;
++ goto error;
+ }
+
+ return 0;
++
++error:
++ rtl92du_deinit_shared_data(hw);
++ return err;
+ }
+
+ static void rtl92du_deinit_sw_vars(struct ieee80211_hw *hw)
+diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.c
+index 743ce0cfffe6dd..c608c51f1b785c 100644
+--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.c
++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.c
+@@ -106,7 +106,8 @@ void rtl92du_tx_fill_desc(struct ieee80211_hw *hw,
+ if (sta) {
+ sta_entry = (struct rtl_sta_info *)sta->drv_priv;
+ tid = ieee80211_get_tid(hdr);
+- agg_state = sta_entry->tids[tid].agg.agg_state;
++ if (tid < MAX_TID_COUNT)
++ agg_state = sta_entry->tids[tid].agg.agg_state;
+ ampdu_density = sta->deflink.ht_cap.ampdu_density;
+ }
+
+diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
+index a3046722891242..69f2840fed095d 100644
+--- a/drivers/net/wireless/realtek/rtw88/pci.c
++++ b/drivers/net/wireless/realtek/rtw88/pci.c
+@@ -1834,7 +1834,7 @@ int rtw_pci_probe(struct pci_dev *pdev,
+ ret = rtw_pci_napi_init(rtwdev);
+ if (ret) {
+ rtw_err(rtwdev, "failed to setup NAPI\n");
+- goto err_pci_declaim;
++ goto err_destroy_rsrc;
+ }
+
+ ret = rtw_chip_info_setup(rtwdev);
+@@ -1866,6 +1866,8 @@ int rtw_pci_probe(struct pci_dev *pdev,
+
+ err_destroy_pci:
+ rtw_pci_napi_deinit(rtwdev);
++
++err_destroy_rsrc:
+ rtw_pci_destroy(rtwdev, pdev);
+
+ err_pci_declaim:
+diff --git a/drivers/net/wireless/realtek/rtw88/tx.c b/drivers/net/wireless/realtek/rtw88/tx.c
+index 9d747a060b984c..8786bbb421c2b9 100644
+--- a/drivers/net/wireless/realtek/rtw88/tx.c
++++ b/drivers/net/wireless/realtek/rtw88/tx.c
+@@ -619,6 +619,7 @@ static int rtw_txq_push_skb(struct rtw_dev *rtwdev,
+ ret = rtw_hci_tx_write(rtwdev, &pkt_info, skb);
+ if (ret) {
+ rtw_err(rtwdev, "failed to write TX skb to HCI\n");
++ ieee80211_free_txskb(rtwdev->hw, skb);
+ return ret;
+ }
+ return 0;
+diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
+index 5547888d7e67a4..a85b9c39c25708 100644
+--- a/drivers/net/wireless/realtek/rtw89/core.h
++++ b/drivers/net/wireless/realtek/rtw89/core.h
+@@ -5373,6 +5373,7 @@ enum rtw89_flags {
+ RTW89_FLAG_CHANGING_INTERFACE,
+ RTW89_FLAG_HW_RFKILL_STATE,
+ RTW89_FLAG_UNPLUGGED,
++ RTW89_FLAG_SHUTDOWN,
+
+ NUM_OF_RTW89_FLAGS,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c b/drivers/net/wireless/realtek/rtw89/mac80211.c
+index aade5c5b79e82d..9baedfde708542 100644
+--- a/drivers/net/wireless/realtek/rtw89/mac80211.c
++++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
+@@ -1979,7 +1979,8 @@ static void rtw89_ops_rfkill_poll(struct ieee80211_hw *hw)
+ lockdep_assert_wiphy(hw->wiphy);
+
+ /* wl_disable GPIO get floating when entering LPS */
+- if (test_bit(RTW89_FLAG_RUNNING, rtwdev->flags))
++ if (test_bit(RTW89_FLAG_RUNNING, rtwdev->flags) ||
++ test_bit(RTW89_FLAG_SHUTDOWN, rtwdev->flags))
+ return;
+
+ rtw89_core_rfkill_poll(rtwdev, false);
+diff --git a/drivers/net/wireless/realtek/rtw89/pci.c b/drivers/net/wireless/realtek/rtw89/pci.c
+index 102bae4881805b..61c54b52be1f5f 100644
+--- a/drivers/net/wireless/realtek/rtw89/pci.c
++++ b/drivers/net/wireless/realtek/rtw89/pci.c
+@@ -4874,6 +4874,19 @@ void rtw89_pci_remove(struct pci_dev *pdev)
+ }
+ EXPORT_SYMBOL(rtw89_pci_remove);
+
++void rtw89_pci_shutdown(struct pci_dev *pdev)
++{
++ struct ieee80211_hw *hw = pci_get_drvdata(pdev);
++ struct rtw89_dev *rtwdev;
++
++ if (!hw)
++ return;
++
++ rtwdev = hw->priv;
++ set_bit(RTW89_FLAG_SHUTDOWN, rtwdev->flags);
++}
++EXPORT_SYMBOL(rtw89_pci_shutdown);
++
+ MODULE_AUTHOR("Realtek Corporation");
+ MODULE_DESCRIPTION("Realtek PCI 802.11ax wireless driver");
+ MODULE_LICENSE("Dual BSD/GPL");
+diff --git a/drivers/net/wireless/realtek/rtw89/pci.h b/drivers/net/wireless/realtek/rtw89/pci.h
+index c3f2d0df5846d8..0728120d721ffc 100644
+--- a/drivers/net/wireless/realtek/rtw89/pci.h
++++ b/drivers/net/wireless/realtek/rtw89/pci.h
+@@ -1751,6 +1751,7 @@ struct pci_device_id;
+
+ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id);
+ void rtw89_pci_remove(struct pci_dev *pdev);
++void rtw89_pci_shutdown(struct pci_dev *pdev);
+ void rtw89_pci_basic_cfg(struct rtw89_dev *rtwdev, bool resume);
+ void rtw89_pci_ops_reset(struct rtw89_dev *rtwdev);
+ int rtw89_pci_ltr_set(struct rtw89_dev *rtwdev, bool en);
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8851be.c b/drivers/net/wireless/realtek/rtw89/rtw8851be.c
+index 640672eb0d268a..61e6c997b206f8 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8851be.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8851be.c
+@@ -93,6 +93,7 @@ static struct pci_driver rtw89_8851be_driver = {
+ .id_table = rtw89_8851be_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852ae.c b/drivers/net/wireless/realtek/rtw89/rtw8852ae.c
+index 64306cdc1ee481..e6fbcf75f1ad32 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8852ae.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8852ae.c
+@@ -95,6 +95,7 @@ static struct pci_driver rtw89_8852ae_driver = {
+ .id_table = rtw89_8852ae_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852be.c b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
+index 5bc0a6a99d1d2b..25463342ac890c 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8852be.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8852be.c
+@@ -97,6 +97,7 @@ static struct pci_driver rtw89_8852be_driver = {
+ .id_table = rtw89_8852be_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852bte.c b/drivers/net/wireless/realtek/rtw89/rtw8852bte.c
+index 49a72ca835ac7e..bf22be739f399e 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8852bte.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8852bte.c
+@@ -99,6 +99,7 @@ static struct pci_driver rtw89_8852bte_driver = {
+ .id_table = rtw89_8852bte_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8852ce.c b/drivers/net/wireless/realtek/rtw89/rtw8852ce.c
+index 3c64c0539205cf..b8d4d9f0268699 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8852ce.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8852ce.c
+@@ -122,6 +122,7 @@ static struct pci_driver rtw89_8852ce_driver = {
+ .id_table = rtw89_8852ce_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922ae.c b/drivers/net/wireless/realtek/rtw89/rtw8922ae.c
+index 5527a8db393b5c..54bcd3f3d00822 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8922ae.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8922ae.c
+@@ -111,6 +111,7 @@ static struct pci_driver rtw89_8922ae_driver = {
+ .id_table = rtw89_8922ae_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops_be,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922de.c b/drivers/net/wireless/realtek/rtw89/rtw8922de.c
+index a1a81c338be3f6..65476a35a323cd 100644
+--- a/drivers/net/wireless/realtek/rtw89/rtw8922de.c
++++ b/drivers/net/wireless/realtek/rtw89/rtw8922de.c
+@@ -111,6 +111,7 @@ static struct pci_driver rtw89_8922de_driver = {
+ .id_table = rtw89_8922de_id_table,
+ .probe = rtw89_pci_probe,
+ .remove = rtw89_pci_remove,
++ .shutdown = rtw89_pci_shutdown,
+ .driver.pm = &rtw89_pm_ops_be,
+ .err_handler = &rtw89_pci_err_handler,
+ };
+diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
+index f59f926d4bfaa9..f9caa1a653c5b1 100644
+--- a/drivers/ntb/ntb_transport.c
++++ b/drivers/ntb/ntb_transport.c
+@@ -1719,9 +1719,16 @@ static void ntb_transport_rxc_db(unsigned long data)
+ static void ntb_tx_copy_callback(void *data,
+ const struct dmaengine_result *res)
+ {
++ struct ntb_payload_header __iomem *hdr;
+ struct ntb_queue_entry *entry = data;
+- struct ntb_transport_qp *qp = entry->qp;
+- struct ntb_payload_header __iomem *hdr = entry->tx_hdr;
++ struct ntb_transport_qp *qp;
++ unsigned int len;
++ void *cb_data;
++
++ qp = entry->qp;
++ hdr = entry->tx_hdr;
++ cb_data = entry->cb_data;
++ len = entry->len;
+
+ /* we need to check DMA results if we are using DMA */
+ if (res) {
+@@ -1768,15 +1775,13 @@ static void ntb_tx_copy_callback(void *data,
+ * "link down" or similar. Since no payload is being sent in these
+ * cases, there is nothing to add to the completion queue.
+ */
+- if (entry->len > 0) {
+- qp->tx_bytes += entry->len;
+-
+- if (qp->tx_handler)
+- qp->tx_handler(qp, qp->cb_data, entry->cb_data,
+- entry->len);
+- }
++ if (len > 0)
++ qp->tx_bytes += len;
+
+ ntb_list_add(&qp->ntb_tx_free_q_lock, &entry->entry, &qp->tx_free_q);
++
++ if (len > 0 && qp->tx_handler)
++ qp->tx_handler(qp, qp->cb_data, cb_data, len);
+ }
+
+ static void ntb_memcpy_tx_on_stack(struct ntb_queue_entry *entry, void __iomem *offset)
+@@ -1950,15 +1955,6 @@ static int ntb_process_tx(struct ntb_transport_qp *qp,
+ return -EAGAIN;
+ }
+
+- if (entry->len > qp->tx_max_frame - sizeof(struct ntb_payload_header)) {
+- if (qp->tx_handler)
+- qp->tx_handler(qp, qp->cb_data, NULL, -EIO);
+-
+- ntb_list_add(&qp->ntb_tx_free_q_lock, &entry->entry,
+- &qp->tx_free_q);
+- return 0;
+- }
+-
+ ntb_async_tx(qp, entry);
+
+ qp->tx_pkts++;
+@@ -2348,9 +2344,11 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
+ if (!qp || !len)
+ return -EINVAL;
+
+- /* If the qp link is down already, just ignore. */
+ if (!qp->link_is_up)
+- return 0;
++ return -ENOLINK;
++
++ if (len > qp->tx_max_frame - sizeof(struct ntb_payload_header))
++ return -EMSGSIZE;
+
+ entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
+ if (!entry) {
+diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
+index 4218e3ac4a2ab1..ec12ce72cfe2ca 100644
+--- a/drivers/nvdimm/label.c
++++ b/drivers/nvdimm/label.c
+@@ -202,7 +202,7 @@ static int __nd_label_validate(struct nvdimm_drvdata *ndd)
+ }
+
+ nslot = __le32_to_cpu(nsindex[i]->nslot);
+- if (nslot * sizeof_namespace_label(ndd)
++ if ((u64)nslot * sizeof_namespace_label(ndd)
+ + 2 * sizeof_namespace_index(ndd)
+ > ndd->nsarea.config_size) {
+ dev_dbg(dev, "nsindex%d nslot: %u invalid, config_size: %#x\n",
+diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
+index 453c1f0b2dd094..ee993dfa1e415b 100644
+--- a/drivers/nvme/host/core.c
++++ b/drivers/nvme/host/core.c
+@@ -5195,7 +5195,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
+
+ BUILD_BUG_ON(NVME_DSM_MAX_RANGES * sizeof(struct nvme_dsm_range) >
+ PAGE_SIZE);
+- ctrl->discard_page = alloc_page(GFP_KERNEL);
++ ctrl->discard_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+ if (!ctrl->discard_page) {
+ ret = -ENOMEM;
+ goto out;
+diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
+index 04363b9c4489e0..cd76a1be203847 100644
+--- a/drivers/nvme/host/fc.c
++++ b/drivers/nvme/host/fc.c
+@@ -2318,7 +2318,7 @@ nvme_fc_create_hw_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)
+ return 0;
+
+ delete_queues:
+- for (; i > 0; i--)
++ for (--i; i > 0; i--)
+ __nvme_fc_delete_hw_queue(ctrl, &ctrl->queues[i], i);
+ return ret;
+ }
+diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
+index 69932d640b5379..d094717c17a014 100644
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -2400,6 +2400,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev)
+ result = queue_request_irq(nvmeq);
+ if (result) {
+ dev->online_queues--;
++ nvme_disable_ctrl(&dev->ctrl, false);
+ return result;
+ }
+
+diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
+index dd40798bc2487a..06d46f72df5cd6 100644
+--- a/drivers/nvme/host/tcp.c
++++ b/drivers/nvme/host/tcp.c
+@@ -80,6 +80,7 @@ struct nvme_tcp_request {
+
+ struct bio *curr_bio;
+ struct iov_iter iter;
++ u32 data_recvd;
+
+ /* send state */
+ size_t offset;
+@@ -615,6 +616,29 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl)
+ queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work);
+ }
+
++/*
++ * NVMe has no short read: a read that completes successfully must
++ * have transferred everything it asked for.
++ */
++static bool nvme_tcp_data_in_short(struct nvme_tcp_queue *queue,
++ struct request *rq)
++{
++ struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
++
++ if (le16_to_cpu(req->status) >> 1)
++ return false;
++ if (req_op(rq) != REQ_OP_READ || !req->data_len)
++ return false;
++ if (likely(req->data_recvd == req->data_len))
++ return false;
++
++ dev_err(queue->ctrl->ctrl.device,
++ "queue %d tag %#x short data-in: got %u of %u\n",
++ nvme_tcp_queue_id(queue), rq->tag,
++ req->data_recvd, req->data_len);
++ return true;
++}
++
+ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
+ struct nvme_completion *cqe)
+ {
+@@ -634,6 +658,9 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
+ if (req->status == cpu_to_le16(NVME_SC_SUCCESS))
+ req->status = cqe->status;
+
++ if (unlikely(nvme_tcp_data_in_short(queue, rq)))
++ return -EPROTO;
++
+ if (!nvme_try_complete_req(rq, req->status, cqe->result))
+ nvme_complete_rq(rq);
+ queue->nr_cqe++;
+@@ -644,6 +671,7 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
+ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue,
+ struct nvme_tcp_data_pdu *pdu)
+ {
++ struct nvme_tcp_request *req;
+ struct request *rq;
+
+ rq = nvme_find_rq(nvme_tcp_tagset(queue), pdu->command_id);
+@@ -654,7 +682,8 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue,
+ return -ENOENT;
+ }
+
+- if (!blk_rq_payload_bytes(rq)) {
++ req = blk_mq_rq_to_pdu(rq);
++ if (!blk_rq_payload_bytes(rq) || !req->curr_bio || !req->data_len) {
+ dev_err(queue->ctrl->ctrl.device,
+ "queue %d tag %#x unexpected data\n",
+ nvme_tcp_queue_id(queue), rq->tag);
+@@ -748,6 +777,13 @@ static int nvme_tcp_handle_r2t(struct nvme_tcp_queue *queue,
+ }
+ req = blk_mq_rq_to_pdu(rq);
+
++ if (unlikely(rq_data_dir(rq) != WRITE)) {
++ dev_err(queue->ctrl->ctrl.device,
++ "req %d unexpected r2t for a non-write command\n",
++ rq->tag);
++ return -EPROTO;
++ }
++
+ if (unlikely(!r2t_length)) {
+ dev_err(queue->ctrl->ctrl.device,
+ "req %d r2t len is %u, probably a bug...\n",
+@@ -956,6 +992,7 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
+ *len -= recv_len;
+ *offset += recv_len;
+ queue->data_remaining -= recv_len;
++ req->data_recvd += recv_len;
+ }
+
+ if (!queue->data_remaining) {
+@@ -964,6 +1001,8 @@ static int nvme_tcp_recv_data(struct nvme_tcp_queue *queue, struct sk_buff *skb,
+ queue->ddgst_remaining = NVME_TCP_DIGEST_LENGTH;
+ } else {
+ if (pdu->hdr.flags & NVME_TCP_F_DATA_SUCCESS) {
++ if (unlikely(nvme_tcp_data_in_short(queue, rq)))
++ return -EPROTO;
+ nvme_tcp_end_request(rq,
+ le16_to_cpu(req->status));
+ queue->nr_cqe++;
+@@ -1012,6 +1051,9 @@ static int nvme_tcp_recv_ddgst(struct nvme_tcp_queue *queue,
+ pdu->command_id);
+ struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
+
++ if (unlikely(nvme_tcp_data_in_short(queue, rq)))
++ return -EPROTO;
++
+ nvme_tcp_end_request(rq, le16_to_cpu(req->status));
+ queue->nr_cqe++;
+ }
+@@ -2744,6 +2786,7 @@ static blk_status_t nvme_tcp_setup_cmd_pdu(struct nvme_ns *ns,
+ req->status = cpu_to_le16(NVME_SC_SUCCESS);
+ req->offset = 0;
+ req->data_sent = 0;
++ req->data_recvd = 0;
+ req->pdu_len = 0;
+ req->pdu_sent = 0;
+ req->h2cdata_left = 0;
+diff --git a/drivers/of/base.c b/drivers/of/base.c
+index 6e7a42dedad3f2..477017ed6f49b2 100644
+--- a/drivers/of/base.c
++++ b/drivers/of/base.c
+@@ -1967,7 +1967,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
+
+ /* walk the alias backwards to extract the id and work out
+ * the 'stem' string */
+- while (isdigit(*(end-1)) && end > start)
++ while (end > start && isdigit(*(end - 1)))
+ end--;
+ len = end - start;
+
+diff --git a/drivers/pci/controller/dwc/pci-meson.c b/drivers/pci/controller/dwc/pci-meson.c
+index 7a4da9fae1eaa8..71b0ebc0e4727c 100644
+--- a/drivers/pci/controller/dwc/pci-meson.c
++++ b/drivers/pci/controller/dwc/pci-meson.c
+@@ -401,7 +401,7 @@ static int meson_pcie_probe(struct platform_device *pdev)
+ return PTR_ERR(mp->phy);
+ }
+
+- mp->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
++ mp->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(mp->reset_gpio)) {
+ dev_err(dev, "get reset gpio failed\n");
+ return PTR_ERR(mp->reset_gpio);
+diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
+index cfc8fa403dad66..89816a2bd7cd3a 100644
+--- a/drivers/pci/controller/pci-hyperv.c
++++ b/drivers/pci/controller/pci-hyperv.c
+@@ -2119,6 +2119,7 @@ static bool hv_pcie_init_dev_msi_info(struct device *dev, struct irq_domain *dom
+ info->ops->msi_prepare = hv_msi_prepare;
+
+ chip->irq_set_affinity = irq_chip_set_affinity_parent;
++ chip->irq_retrigger = irq_chip_retrigger_hierarchy;
+
+ if (IS_ENABLED(CONFIG_X86))
+ chip->flags |= IRQCHIP_MOVE_DEFERRED;
+diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c
+index f9a34f323ad8c5..fd1a11b4c8eb81 100644
+--- a/drivers/pci/controller/plda/pcie-plda-host.c
++++ b/drivers/pci/controller/plda/pcie-plda-host.c
+@@ -419,6 +419,8 @@ static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port)
+ return plda_allocate_msi_domains(port);
+ }
+
++static void plda_pcie_irq_domain_deinit(struct plda_pcie_rp *pcie);
++
+ int plda_init_interrupts(struct platform_device *pdev,
+ struct plda_pcie_rp *port,
+ const struct plda_event *event)
+@@ -440,14 +442,17 @@ int plda_init_interrupts(struct platform_device *pdev,
+ }
+
+ port->irq = platform_get_irq(pdev, 0);
+- if (port->irq < 0)
+- return -ENODEV;
++ if (port->irq < 0) {
++ ret = -ENODEV;
++ goto err_irq_domain_deinit;
++ }
+
+ for_each_set_bit(i, &port->events_bitmap, port->num_events) {
+ event_irq = irq_create_mapping(port->event_domain, i);
+ if (!event_irq) {
+ dev_err(dev, "failed to map hwirq %d\n", i);
+- return -ENXIO;
++ ret = -ENXIO;
++ goto err_irq_domain_deinit;
+ }
+
+ if (event->request_event_irq)
+@@ -459,7 +464,7 @@ int plda_init_interrupts(struct platform_device *pdev,
+
+ if (ret) {
+ dev_err(dev, "failed to request IRQ %d\n", event_irq);
+- return ret;
++ goto err_irq_domain_deinit;
+ }
+ }
+
+@@ -467,7 +472,8 @@ int plda_init_interrupts(struct platform_device *pdev,
+ event->intx_event);
+ if (!port->intx_irq) {
+ dev_err(dev, "failed to map INTx interrupt\n");
+- return -ENXIO;
++ ret = -ENXIO;
++ goto err_irq_domain_deinit;
+ }
+
+ /* Plug the INTx chained handler */
+@@ -475,8 +481,11 @@ int plda_init_interrupts(struct platform_device *pdev,
+
+ port->msi_irq = irq_create_mapping(port->event_domain,
+ event->msi_event);
+- if (!port->msi_irq)
+- return -ENXIO;
++ if (!port->msi_irq) {
++ dev_err(dev, "failed to map MSI interrupt\n");
++ ret = -ENXIO;
++ goto err_irq_domain_deinit;
++ }
+
+ /* Plug the MSI chained handler */
+ irq_set_chained_handler_and_data(port->msi_irq, plda_handle_msi, port);
+@@ -485,6 +494,11 @@ int plda_init_interrupts(struct platform_device *pdev,
+ irq_set_chained_handler_and_data(port->irq, plda_handle_event, port);
+
+ return 0;
++
++err_irq_domain_deinit:
++ plda_pcie_irq_domain_deinit(port);
++
++ return ret;
+ }
+ EXPORT_SYMBOL_GPL(plda_init_interrupts);
+
+@@ -559,9 +573,27 @@ EXPORT_SYMBOL_GPL(plda_pcie_setup_iomems);
+
+ static void plda_pcie_irq_domain_deinit(struct plda_pcie_rp *pcie)
+ {
+- irq_set_chained_handler_and_data(pcie->irq, NULL, NULL);
+- irq_set_chained_handler_and_data(pcie->msi_irq, NULL, NULL);
+- irq_set_chained_handler_and_data(pcie->intx_irq, NULL, NULL);
++ u32 i, event_irq;
++
++ if (pcie->irq > 0)
++ irq_set_chained_handler_and_data(pcie->irq, NULL, NULL);
++ if (pcie->msi_irq > 0)
++ irq_set_chained_handler_and_data(pcie->msi_irq, NULL, NULL);
++ if (pcie->intx_irq > 0)
++ irq_set_chained_handler_and_data(pcie->intx_irq, NULL, NULL);
++
++ for_each_set_bit(i, &pcie->events_bitmap, pcie->num_events) {
++ event_irq = irq_find_mapping(pcie->event_domain, i);
++ if (event_irq) {
++ devm_free_irq(pcie->dev, event_irq, pcie);
++ irq_dispose_mapping(event_irq);
++ }
++ }
++
++ if (pcie->intx_irq)
++ irq_dispose_mapping(pcie->intx_irq);
++ if (pcie->msi_irq)
++ irq_dispose_mapping(pcie->msi_irq);
+
+ irq_domain_remove(pcie->msi.dev_domain);
+
+diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c
+index 298036c3e7f949..628f8c8d67471d 100644
+--- a/drivers/pci/controller/plda/pcie-starfive.c
++++ b/drivers/pci/controller/plda/pcie-starfive.c
+@@ -304,12 +304,14 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
+
+ ret = starfive_pcie_clk_rst_init(pcie);
+ if (ret)
+- return ret;
++ goto err_disable_phy;
+
+ if (pcie->vpcie3v3) {
+ ret = regulator_enable(pcie->vpcie3v3);
+- if (ret)
++ if (ret) {
+ dev_err_probe(dev, ret, "failed to enable vpcie3v3 regulator\n");
++ goto err_clk_rst;
++ }
+ }
+
+ if (pcie->reset_gpio)
+@@ -379,6 +381,13 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
+ dev_info(dev, "port link down\n");
+
+ return 0;
++
++err_clk_rst:
++ starfive_pcie_clk_rst_deinit(pcie);
++err_disable_phy:
++ starfive_pcie_disable_phy(pcie);
++
++ return ret;
+ }
+
+ static const struct plda_pcie_host_ops sf_host_ops = {
+diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
+index 209373c92e9e10..80a9db417dc876 100644
+--- a/drivers/pci/msi/msi.c
++++ b/drivers/pci/msi/msi.c
+@@ -870,6 +870,7 @@ void __pci_restore_msix_state(struct pci_dev *dev)
+ {
+ struct msi_desc *entry;
+ bool write_msg;
++ u16 cmd;
+
+ if (!dev->msix_enabled)
+ return;
+@@ -879,6 +880,14 @@ void __pci_restore_msix_state(struct pci_dev *dev)
+ pci_msix_clear_and_set_ctrl(dev, 0,
+ PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
+
++ /*
++ * The restored device state may not have Memory Space enabled.
++ * Since the MSI-X Table and PBA are in Memory Space, enable it
++ * while restoring them.
++ */
++ pci_read_config_word(dev, PCI_COMMAND, &cmd);
++ pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
++
+ write_msg = arch_restore_msi_irqs(dev);
+
+ scoped_guard (msi_descs_lock, &dev->dev) {
+@@ -889,6 +898,7 @@ void __pci_restore_msix_state(struct pci_dev *dev)
+ }
+ }
+
++ pci_write_config_word(dev, PCI_COMMAND, cmd);
+ pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
+ }
+
+diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
+index 5ec0b245a69bdf..1be627913a9bec 100644
+--- a/drivers/pci/pci-sysfs.c
++++ b/drivers/pci/pci-sysfs.c
+@@ -718,7 +718,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
+ else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+ size = 128;
+
+- if (off > size)
++ if (off >= size)
+ return 0;
+ if (off + count > size) {
+ size -= off;
+@@ -799,7 +799,7 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
+ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
+ }
+
+- if (off > dev->cfg_size)
++ if (off >= dev->cfg_size)
+ return 0;
+ if (off + count > dev->cfg_size) {
+ size = dev->cfg_size - off;
+@@ -888,12 +888,30 @@ static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,
+ char *buf, loff_t off, size_t count)
+ {
+ struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
++ u32 val = 0;
++ int ret;
+
+ /* Only support 1, 2 or 4 byte accesses */
+ if (count != 1 && count != 2 && count != 4)
+ return -EINVAL;
+
+- return pci_legacy_read(bus, off, (u32 *)buf, count);
++ ret = pci_legacy_read(bus, off, &val, count);
++ if (ret < 0)
++ return ret;
++
++ switch (count) {
++ case 1:
++ buf[0] = *(u8 *)&val;
++ break;
++ case 2:
++ put_unaligned_le16(*(u16 *)&val, buf);
++ break;
++ case 4:
++ put_unaligned_le32(val, buf);
++ break;
++ }
++
++ return ret;
+ }
+
+ /**
+@@ -913,12 +931,24 @@ static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
+ char *buf, loff_t off, size_t count)
+ {
+ struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj));
++ u32 val;
+
+- /* Only support 1, 2 or 4 byte accesses */
+- if (count != 1 && count != 2 && count != 4)
++ /* Only support 1, 2 or 4 byte accesses. */
++ switch (count) {
++ case 1:
++ val = *(u8 *)buf;
++ break;
++ case 2:
++ val = get_unaligned_le16(buf);
++ break;
++ case 4:
++ val = get_unaligned_le32(buf);
++ break;
++ default:
+ return -EINVAL;
++ }
+
+- return pci_legacy_write(bus, off, *(u32 *)buf, count);
++ return pci_legacy_write(bus, off, val, count);
+ }
+
+ /**
+diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
+index c4fd9c0b2a5482..fbb764ffb916dd 100644
+--- a/drivers/pci/pcie/aer.c
++++ b/drivers/pci/pcie/aer.c
+@@ -428,23 +428,32 @@ void pci_aer_exit(struct pci_dev *dev)
+ #define AER_AGENT_REQUESTER 1
+ #define AER_AGENT_COMPLETER 2
+ #define AER_AGENT_TRANSMITTER 3
++#define AER_AGENT_COMPONENT 4
+
+ #define AER_AGENT_REQUESTER_MASK(t) ((t == AER_CORRECTABLE) ? \
+- 0 : (PCI_ERR_UNC_COMP_TIME|PCI_ERR_UNC_UNSUP))
++ 0 : PCI_ERR_UNC_COMP_TIME)
+ #define AER_AGENT_COMPLETER_MASK(t) ((t == AER_CORRECTABLE) ? \
+ 0 : PCI_ERR_UNC_COMP_ABORT)
+ #define AER_AGENT_TRANSMITTER_MASK(t) ((t == AER_CORRECTABLE) ? \
+- (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : 0)
++ (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : \
++ (PCI_ERR_UNC_POISON_BLK|PCI_ERR_UNC_ATOMEG| \
++ PCI_ERR_UNC_DMWR_BLK|PCI_ERR_UNC_XLAT_BLK| \
++ PCI_ERR_UNC_TLPPRE))
++#define AER_AGENT_COMPONENT_MASK(t) ((t == AER_CORRECTABLE) ? \
++ (PCI_ERR_COR_INTERNAL|PCI_ERR_COR_LOG_OVER) : \
++ (PCI_ERR_UNC_INTN|PCI_ERR_UNC_SURPDN))
+
+ #define AER_GET_AGENT(t, e) \
+ ((e & AER_AGENT_COMPLETER_MASK(t)) ? AER_AGENT_COMPLETER : \
+ (e & AER_AGENT_REQUESTER_MASK(t)) ? AER_AGENT_REQUESTER : \
+ (e & AER_AGENT_TRANSMITTER_MASK(t)) ? AER_AGENT_TRANSMITTER : \
++ (e & AER_AGENT_COMPONENT_MASK(t)) ? AER_AGENT_COMPONENT : \
+ AER_AGENT_RECEIVER)
+
+ #define AER_PHYSICAL_LAYER_ERROR 0
+ #define AER_DATA_LINK_LAYER_ERROR 1
+ #define AER_TRANSACTION_LAYER_ERROR 2
++#define AER_GENERAL_ERROR 3
+
+ #define AER_PHYSICAL_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
+ PCI_ERR_COR_RCVR : 0)
+@@ -452,11 +461,14 @@ void pci_aer_exit(struct pci_dev *dev)
+ (PCI_ERR_COR_BAD_TLP| \
+ PCI_ERR_COR_BAD_DLLP| \
+ PCI_ERR_COR_REP_ROLL| \
+- PCI_ERR_COR_REP_TIMER) : PCI_ERR_UNC_DLP)
++ PCI_ERR_COR_REP_TIMER) : (PCI_ERR_UNC_DLP|PCI_ERR_UNC_SURPDN))
++#define AER_GENERAL_ERROR_MASK(t) ((t == AER_CORRECTABLE) ? \
++ (PCI_ERR_COR_INTERNAL|PCI_ERR_COR_LOG_OVER) : PCI_ERR_UNC_INTN)
+
+ #define AER_GET_LAYER_ERROR(t, e) \
+ ((e & AER_PHYSICAL_LAYER_ERROR_MASK(t)) ? AER_PHYSICAL_LAYER_ERROR : \
+ (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
++ (e & AER_GENERAL_ERROR_MASK(t)) ? AER_GENERAL_ERROR : \
+ AER_TRANSACTION_LAYER_ERROR)
+
+ /*
+@@ -471,7 +483,8 @@ static const char * const aer_error_severity_string[] = {
+ static const char *aer_error_layer[] = {
+ "Physical Layer",
+ "Data Link Layer",
+- "Transaction Layer"
++ "Transaction Layer",
++ "General",
+ };
+
+ static const char *aer_correctable_error_string[] = {
+@@ -548,7 +561,8 @@ static const char *aer_agent_string[] = {
+ "Receiver ID",
+ "Requester ID",
+ "Completer ID",
+- "Transmitter ID"
++ "Transmitter ID",
++ "Component ID",
+ };
+
+ #define aer_stats_dev_attr(name, stats_array, strings_array, \
+@@ -942,7 +956,8 @@ void pci_print_aer(struct pci_dev *dev, int aer_severity,
+ status = aer->uncor_status;
+ mask = aer->uncor_mask;
+ info.level = KERN_ERR;
+- tlp_header_valid = tlp_header_logged(status, aer->cap_control);
++ tlp_header_valid = tlp_header_logged(status & ~mask,
++ aer->cap_control);
+ }
+
+ info.status = status;
+@@ -1336,7 +1351,7 @@ int aer_get_device_error_info(struct aer_err_info *info, int i)
+ pci_read_config_dword(dev, aer + PCI_ERR_CAP, &aercc);
+ info->first_error = PCI_ERR_CAP_FEP(aercc);
+
+- if (tlp_header_logged(info->status, aercc)) {
++ if (tlp_header_logged(info->status & ~info->mask, aercc)) {
+ info->tlp_header_valid = 1;
+ pcie_read_tlp_log(dev, aer + PCI_ERR_HEADER_LOG,
+ aer + PCI_ERR_PREFIX_LOG,
+diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
+index 71ad289fcb8e31..f5fd860a0540b4 100644
+--- a/drivers/pci/proc.c
++++ b/drivers/pci/proc.c
+@@ -14,6 +14,8 @@
+ #include
+ #include
+ #include
++#include
++#include
+ #include
+ #include "pci.h"
+
+@@ -39,13 +41,16 @@ static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
+ * undefined locations (think of Intel PIIX4 as a typical example).
+ */
+
+- if (capable(CAP_SYS_ADMIN))
++ if (file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN))
+ size = dev->cfg_size;
+ else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+ size = 128;
+ else
+ size = 64;
+
++ if (!nbytes)
++ return 0;
++
+ if (pos >= size)
+ return 0;
+ if (nbytes >= size)
+@@ -122,6 +127,15 @@ static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
+ if (ret)
+ return ret;
+
++ if (!nbytes)
++ return 0;
++
++ if (resource_is_exclusive(&dev->driver_exclusive_resource, pos, nbytes)) {
++ pci_warn_once(dev, "%s: Unexpected write to kernel-exclusive config offset %x",
++ current->comm, pos);
++ add_taint(TAINT_USER, LOCKDEP_STILL_OK);
++ }
++
+ if (pos >= size)
+ return 0;
+ if (nbytes >= size)
+diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
+index b09f27f7846fcd..0500d5fd4f112e 100644
+--- a/drivers/pci/quirks.c
++++ b/drivers/pci/quirks.c
+@@ -2507,6 +2507,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s);
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s);
+
++/* Realtek RTS525A generates a Replay Timer Timeout storm when L0s is enabled. */
++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_REALTEK, 0x525a, quirk_disable_aspm_l0s);
++
+ static void quirk_disable_aspm_l0s_l1(struct pci_dev *dev)
+ {
+ pcie_aspm_remove_cap(dev,
+@@ -5361,7 +5364,7 @@ static void pci_quirk_enable_intel_rp_mpc_acs(struct pci_dev *dev)
+ if (!(mpc & INTEL_MPC_REG_IRBNCE)) {
+ pci_info(dev, "Enabling MPC IRBNCE\n");
+ mpc |= INTEL_MPC_REG_IRBNCE;
+- pci_write_config_word(dev, INTEL_MPC_REG, mpc);
++ pci_write_config_dword(dev, INTEL_MPC_REG, mpc);
+ }
+ }
+
+@@ -6263,6 +6266,10 @@ DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0xb404,
+ pci_fixup_pericom_acs_store_forward);
+ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0xb404,
+ pci_fixup_pericom_acs_store_forward);
++DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_PERICOM, 0x2608,
++ pci_fixup_pericom_acs_store_forward);
++DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_PERICOM, 0x2608,
++ pci_fixup_pericom_acs_store_forward);
+
+ static void nvidia_ion_ahci_fixup(struct pci_dev *pdev)
+ {
+diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+index b05d80e849a144..9a33c06d6fc39d 100644
+--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
++++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+@@ -173,9 +173,9 @@ static struct typec_switch_dev *tca_blk_get_typec_switch(struct platform_device
+ return sw;
+ }
+
+-static void tca_blk_put_typec_switch(struct typec_switch_dev *sw)
++static void tca_blk_put_typec_switch(void *data)
+ {
+- typec_switch_unregister(sw);
++ typec_switch_unregister(data);
+ }
+
+ static void tca_blk_orientation_set(struct tca_blk *tca,
+@@ -248,6 +248,7 @@ static struct tca_blk *imx95_usb_phy_get_tca(struct platform_device *pdev,
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ struct tca_blk *tca;
++ int ret;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ if (!res)
+@@ -266,17 +267,11 @@ static struct tca_blk *imx95_usb_phy_get_tca(struct platform_device *pdev,
+ tca->orientation = TYPEC_ORIENTATION_NORMAL;
+ tca->sw = tca_blk_get_typec_switch(pdev, imx_phy);
+
+- return tca;
+-}
+-
+-static void imx95_usb_phy_put_tca(struct imx8mq_usb_phy *imx_phy)
+-{
+- struct tca_blk *tca = imx_phy->tca;
+-
+- if (!tca)
+- return;
++ ret = devm_add_action_or_reset(&pdev->dev, tca_blk_put_typec_switch, tca->sw);
++ if (ret)
++ return ERR_PTR(ret);
+
+- tca_blk_put_typec_switch(tca->sw);
++ return tca;
+ }
+
+ static u32 phy_tx_vref_tune_from_property(u32 percent)
+@@ -741,9 +736,7 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
+
+ static void imx8mq_usb_phy_remove(struct platform_device *pdev)
+ {
+- struct imx8mq_usb_phy *imx_phy = platform_get_drvdata(pdev);
+
+- imx95_usb_phy_put_tca(imx_phy);
+ }
+
+ static struct platform_driver imx8mq_usb_phy_driver = {
+diff --git a/drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c b/drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c
+index cbd780556da8fd..18f5f582d1d7a9 100644
+--- a/drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c
++++ b/drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c
+@@ -1526,7 +1526,7 @@ static const struct regmap_config samsung_mipi_dcphy_regmap_config = {
+ .reg_bits = 32,
+ .val_bits = 32,
+ .reg_stride = 4,
+- .max_register = 0x10000,
++ .max_register = 0xfffc,
+ };
+
+ static struct phy *samsung_mipi_dcphy_xlate(struct device *dev,
+diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+index a10579144c34b3..e613dce244302f 100644
+--- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
++++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+@@ -475,6 +475,21 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
+ fifo_timestamp,
+ *current_timestamp,
+ now);
++
++ /*
++ * A standalone timestamp event typically has a sensor_num of
++ * 0xff. Return early here to prevent it from hitting the
++ * bounds check below and spamming the logs.
++ */
++ return false;
++ }
++
++ /* Skip event if sensor_num from EC is out of bounds. */
++ if (in->sensor_num >= sensorhub->sensor_num) {
++ dev_warn_ratelimited(sensorhub->dev,
++ "Invalid sensor number %u from EC\n",
++ in->sensor_num);
++ return false;
+ }
+
+ if (in->flags & MOTIONSENSE_SENSOR_FLAG_ODR) {
+@@ -502,10 +517,6 @@ cros_ec_sensor_ring_process_event(struct cros_ec_sensorhub *sensorhub,
+ return true;
+ }
+
+- if (in->flags & MOTIONSENSE_SENSOR_FLAG_TIMESTAMP)
+- /* If we just have a timestamp, skip this entry. */
+- return false;
+-
+ /* Regular sample */
+ out->sensor_id = in->sensor_num;
+ trace_cros_ec_sensorhub_data(in->sensor_num,
+diff --git a/drivers/platform/x86/amd/pmc/mp1_stb.c b/drivers/platform/x86/amd/pmc/mp1_stb.c
+index 753d630f3283df..1ec0e599df7f3b 100644
+--- a/drivers/platform/x86/amd/pmc/mp1_stb.c
++++ b/drivers/platform/x86/amd/pmc/mp1_stb.c
+@@ -157,7 +157,7 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
+ struct amd_pmc_dev *dev = filp->f_inode->i_private;
+ u32 fsize, num_samples, val, stb_rdptr_offset = 0;
+ struct amd_stb_v2_data *stb_data_arr;
+- int ret;
++ int ret = 0;
+
+ /* Write dummy postcode while reading the STB buffer */
+ ret = amd_stb_write(dev, AMD_PMC_STB_DUMMY_PC);
+@@ -176,22 +176,24 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
+ * the enhanced dram size. Note that we land here only for the
+ * platforms that support enhanced dram size reporting.
+ */
+- if (dump_custom_stb)
+- return amd_stb_handle_efr(filp);
++ if (dump_custom_stb) {
++ ret = amd_stb_handle_efr(filp);
++ goto out;
++ }
+
+ /* Get the num_samples to calculate the last push location */
+ ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, dev->stb_arg.s2d_msg_id, true);
+- /* Clear msg_port for other SMU operation */
+- dev->msg_port = MSG_PORT_PMC;
+ if (ret) {
+ dev_err(dev->dev, "error: S2D_NUM_SAMPLES not supported : %d\n", ret);
+- return ret;
++ goto out;
+ }
+
+ fsize = min(num_samples, S2D_TELEMETRY_BYTES_MAX);
+ stb_data_arr = kmalloc_flex(*stb_data_arr, data, fsize);
+- if (!stb_data_arr)
+- return -ENOMEM;
++ if (!stb_data_arr) {
++ ret = -ENOMEM;
++ goto out;
++ }
+
+ stb_data_arr->size = fsize;
+
+@@ -214,7 +216,10 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
+
+ filp->private_data = stb_data_arr;
+
+- return 0;
++out:
++ /* Restore the default message port for subsequent SMU operations */
++ dev->msg_port = MSG_PORT_PMC;
++ return ret;
+ }
+
+ static ssize_t amd_stb_debugfs_read_v2(struct file *filp, char __user *buf, size_t size,
+@@ -289,7 +294,7 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)
+ u32 phys_addr_low, phys_addr_hi;
+ u64 stb_phys_addr;
+ u32 size = 0;
+- int ret;
++ int ret = 0;
+
+ if (!enable_stb)
+ return 0;
+@@ -306,27 +311,42 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)
+ /* Spill to DRAM feature uses separate SMU message port */
+ dev->msg_port = MSG_PORT_S2D;
+
+- amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, dev->stb_arg.s2d_msg_id, true);
+- if (size != S2D_TELEMETRY_BYTES_MAX)
+- return -EIO;
++ ret = amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, dev->stb_arg.s2d_msg_id, true);
++ if (ret)
++ goto out;
++ if (size != S2D_TELEMETRY_BYTES_MAX) {
++ ret = -EIO;
++ goto out;
++ }
+
+- /* Get DRAM size */
+- ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, dev->stb_arg.s2d_msg_id, true);
+- if (ret || !dev->dram_size)
++ /* Get DRAM size; fall back to the default if the query fails */
++ if (amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, dev->stb_arg.s2d_msg_id, true) ||
++ !dev->dram_size)
+ dev->dram_size = S2D_TELEMETRY_DRAMBYTES_MAX;
+
+ /* Get STB DRAM address */
+- amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->stb_arg.s2d_msg_id, true);
+- amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->stb_arg.s2d_msg_id, true);
++ ret = amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low,
++ dev->stb_arg.s2d_msg_id, true);
++ if (ret)
++ goto out;
++ ret = amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi,
++ dev->stb_arg.s2d_msg_id, true);
++ if (ret)
++ goto out;
+
+ stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
+-
+- /* Clear msg_port for other SMU operation */
+- dev->msg_port = MSG_PORT_PMC;
++ if (!stb_phys_addr) {
++ dev_err(dev->dev, "S2D phys addr query returned invalid address\n");
++ ret = -ENXIO;
++ goto out;
++ }
+
+ dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, dev->dram_size);
+ if (!dev->stb_virt_addr)
+- return -ENOMEM;
++ ret = -ENOMEM;
+
+- return 0;
++out:
++ /* Restore the default message port for subsequent SMU operations */
++ dev->msg_port = MSG_PORT_PMC;
++ return ret;
+ }
+diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
+index a37083cdb9083f..542b5d04515ae7 100644
+--- a/drivers/platform/x86/amd/pmc/pmc.c
++++ b/drivers/platform/x86/amd/pmc/pmc.c
+@@ -941,13 +941,17 @@ static int amd_pmc_probe(struct platform_device *pdev)
+ amd_pmc_dbgfs_register(dev);
+ err = amd_stb_s2d_init(dev);
+ if (err)
+- goto err_pci_dev_put;
++ goto err_dbgfs_unregister;
+
+ if (IS_ENABLED(CONFIG_AMD_MP2_STB))
+ amd_mp2_stb_init(dev);
+ pm_report_max_hw_sleep(U64_MAX);
+ return 0;
+
++err_dbgfs_unregister:
++ amd_pmc_dbgfs_unregister(dev);
++ if (IS_ENABLED(CONFIG_SUSPEND))
++ acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops);
+ err_pci_dev_put:
+ pci_dev_put(rdev);
+ return err;
+diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/biosattr-interface.c b/drivers/platform/x86/dell/dell-wmi-sysman/biosattr-interface.c
+index db278ff4cc4d45..154e115af4b4c6 100644
+--- a/drivers/platform/x86/dell/dell-wmi-sysman/biosattr-interface.c
++++ b/drivers/platform/x86/dell/dell-wmi-sysman/biosattr-interface.c
+@@ -84,7 +84,6 @@ int set_attribute(const char *a_name, const char *a_value)
+ if (ret < 0)
+ goto out;
+
+- print_hex_dump_bytes("set attribute data: ", DUMP_PREFIX_NONE, buffer, buffer_size);
+ ret = call_biosattributes_interface(wmi_priv.bios_attr_wdev,
+ buffer, buffer_size,
+ SETATTRIBUTE_METHOD_ID);
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
+index 27fd6cd2152908..309634c1cc20ee 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
+@@ -85,7 +85,7 @@ int hp_get_string_from_buffer(u8 **buffer, u32 *buffer_size, char *dst, u32 dst_
+ * bytes.
+ */
+ conv_dst_size = size;
+- if (size > dst_size)
++ if (size >= dst_size)
+ conv_dst_size = dst_size - 1;
+
+ /*
+@@ -661,12 +661,17 @@ static int hp_init_bios_package_attribute(enum hp_wmi_data_type attr_type,
+ int ret = 0;
+
+ /* Take action appropriate to each ACPI TYPE */
+- if (obj->package.count < min_elements) {
+- pr_err("ACPI-package does not have enough elements: %d < %d\n",
+- obj->package.count, min_elements);
++ if (obj->package.count < COMMON_ELEM_CNT) {
++ pr_err("ACPI-package is missing common elements: %d < %d\n",
++ obj->package.count, COMMON_ELEM_CNT);
+ goto pack_attr_exit;
+ }
+
++ if (obj->package.count < min_elements) {
++ pr_warn("ACPI-package has fewer elements than expected: %d < %d, parsing available elements\n",
++ obj->package.count, min_elements);
++ }
++
+ elements = obj->package.elements;
+
+ /* sanity checking */
+@@ -731,26 +736,31 @@ static int hp_init_bios_package_attribute(enum hp_wmi_data_type attr_type,
+ switch (attr_type) {
+ case HPWMI_STRING_TYPE:
+ ret = hp_populate_string_package_data(elements,
++ obj->package.count,
+ instance_id,
+ attr_name_kobj);
+ break;
+ case HPWMI_INTEGER_TYPE:
+ ret = hp_populate_integer_package_data(elements,
++ obj->package.count,
+ instance_id,
+ attr_name_kobj);
+ break;
+ case HPWMI_ENUMERATION_TYPE:
+ ret = hp_populate_enumeration_package_data(elements,
++ obj->package.count,
+ instance_id,
+ attr_name_kobj);
+ break;
+ case HPWMI_ORDERED_LIST_TYPE:
+ ret = hp_populate_ordered_list_package_data(elements,
++ obj->package.count,
+ instance_id,
+ attr_name_kobj);
+ break;
+ case HPWMI_PASSWORD_TYPE:
+ ret = hp_populate_password_package_data(elements,
++ obj->package.count,
+ instance_id,
+ attr_name_kobj);
+ break;
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.h b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.h
+index f1eec0e4ba075b..ac57d6eab4c358 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.h
++++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.h
+@@ -279,6 +279,9 @@ enum hp_wmi_data_elements {
+ PSWD_ENCODINGS = 13,
+ PSWD_IS_SET = 14,
+ PSWD_ELEM_CNT = 15,
++
++ /* Minimum elements shared by all attribute types (NAME..SECURITY_LEVEL) */
++ COMMON_ELEM_CNT = SECURITY_LEVEL + 1,
+ };
+
+ #define GET_INSTANCE_ID(type) \
+@@ -401,6 +404,7 @@ int hp_populate_string_buffer_data(u8 *buffer_ptr, u32 *buffer_size,
+ int hp_alloc_string_data(void);
+ void hp_exit_string_attributes(void);
+ int hp_populate_string_package_data(union acpi_object *str_obj,
++ int str_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj);
+
+@@ -411,6 +415,7 @@ int hp_populate_integer_buffer_data(u8 *buffer_ptr, u32 *buffer_size,
+ int hp_alloc_integer_data(void);
+ void hp_exit_integer_attributes(void);
+ int hp_populate_integer_package_data(union acpi_object *integer_obj,
++ int integer_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj);
+
+@@ -421,6 +426,7 @@ int hp_populate_enumeration_buffer_data(u8 *buffer_ptr, u32 *buffer_size,
+ int hp_alloc_enumeration_data(void);
+ void hp_exit_enumeration_attributes(void);
+ int hp_populate_enumeration_package_data(union acpi_object *enum_obj,
++ int enum_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj);
+
+@@ -432,6 +438,7 @@ int hp_populate_ordered_list_buffer_data(u8 *buffer_ptr,
+ int hp_alloc_ordered_list_data(void);
+ void hp_exit_ordered_list_attributes(void);
+ int hp_populate_ordered_list_package_data(union acpi_object *order_obj,
++ int order_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj);
+
+@@ -440,6 +447,7 @@ int hp_populate_password_buffer_data(u8 *buffer_ptr, u32 *buffer_size,
+ int instance_id,
+ struct kobject *attr_name_kobj);
+ int hp_populate_password_package_data(union acpi_object *password_obj,
++ int password_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj);
+ int hp_alloc_password_data(void);
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
+index af4d1920d48809..446dd18d2cee4f 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
+@@ -163,10 +163,11 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
+
+ /* Check that both expected and read object type match */
+ if (expected_enum_types[eloc] != enum_obj[elem].type) {
+- pr_err("Error expected type %d for elem %d, but got type %d instead\n",
+- expected_enum_types[eloc], elem, enum_obj[elem].type);
++ pr_warn("Unexpected element type at elem %d: expected %d, got %d, skipping\n",
++ elem, expected_enum_types[eloc], enum_obj[elem].type);
+ kfree(str_value);
+- return -EIO;
++ str_value = NULL;
++ continue;
+ }
+
+ /* Assign appropriate element value to corresponding field */
+@@ -227,6 +228,8 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
+ kfree(str_value);
+ str_value = NULL;
+ }
++ if (size)
++ elem += size - 1;
+ break;
+
+ case SECURITY_LEVEL:
+@@ -280,6 +283,8 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
+ kfree(str_value);
+ str_value = NULL;
+ }
++ if (size)
++ elem += (size < MAX_VALUES_SIZE ? size : MAX_VALUES_SIZE) - 1;
+ break;
+ default:
+ pr_warn("Invalid element: %d found in Enumeration attribute or data may be malformed\n", elem);
+@@ -300,10 +305,12 @@ exit_enumeration_package:
+ * Populate all properties of an instance under enumeration attribute
+ *
+ * @enum_obj: ACPI object with enumeration data
++ * @enum_obj_count: Number of elements in @enum_obj
+ * @instance_id: The instance to enumerate
+ * @attr_name_kobj: The parent kernel object
+ */
+ int hp_populate_enumeration_package_data(union acpi_object *enum_obj,
++ int enum_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj)
+ {
+@@ -312,7 +319,7 @@ int hp_populate_enumeration_package_data(union acpi_object *enum_obj,
+ enum_data->attr_name_kobj = attr_name_kobj;
+
+ hp_populate_enumeration_elements_from_package(enum_obj,
+- enum_obj->package.count,
++ enum_obj_count,
+ instance_id);
+ hp_update_attribute_permissions(enum_data->common.is_readonly,
+ &enumeration_current_val);
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
+index d96e160953e393..a2790706644801 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
+@@ -243,6 +243,8 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
+ kfree(str_value);
+ str_value = NULL;
+ }
++ if (size)
++ elem += size - 1;
+ break;
+
+ case SECURITY_LEVEL:
+@@ -275,10 +277,12 @@ exit_integer_package:
+ * Populate all properties of an instance under integer attribute
+ *
+ * @integer_obj: ACPI object with integer data
++ * @integer_obj_count: Number of elements in @integer_obj
+ * @instance_id: The instance to enumerate
+ * @attr_name_kobj: The parent kernel object
+ */
+ int hp_populate_integer_package_data(union acpi_object *integer_obj,
++ int integer_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj)
+ {
+@@ -286,7 +290,7 @@ int hp_populate_integer_package_data(union acpi_object *integer_obj,
+
+ integer_data->attr_name_kobj = attr_name_kobj;
+ hp_populate_integer_elements_from_package(integer_obj,
+- integer_obj->package.count,
++ integer_obj_count,
+ instance_id);
+ hp_update_attribute_permissions(integer_data->common.is_readonly,
+ &integer_current_val);
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
+index f09489a085c860..5bf8d40bdf8167 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
+@@ -145,7 +145,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
+ if (!order_obj)
+ return -EINVAL;
+
+- for (elem = 1, eloc = 1; eloc < ORD_ELEM_CNT; elem++, eloc++) {
++ for (elem = 1, eloc = 1; eloc < ORD_ELEM_CNT && elem < order_obj_count; elem++, eloc++) {
+
+ switch (order_obj[elem].type) {
+ case ACPI_TYPE_STRING:
+@@ -232,6 +232,8 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
+ kfree(str_value);
+ str_value = NULL;
+ }
++ if (size)
++ elem += size - 1;
+ break;
+
+ case SECURITY_LEVEL:
+@@ -261,7 +263,9 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
+ * Ordered list data is stored in hex and comma separated format
+ * Convert the data and split it to show each element
+ */
+- ret = hp_convert_hexstr_to_str(str_value, value_len, &tmpstr, &tmp_len);
++ ret = hp_convert_hexstr_to_str(order_obj[elem].string.pointer,
++ order_obj[elem].string.length,
++ &tmpstr, &tmp_len);
+ if (ret)
+ goto exit_list;
+
+@@ -298,10 +302,12 @@ exit_list:
+ * Populate all properties of an instance under ordered_list attribute
+ *
+ * @order_obj: ACPI object with ordered_list data
++ * @order_obj_count: Number of elements in @order_obj
+ * @instance_id: The instance to enumerate
+ * @attr_name_kobj: The parent kernel object
+ */
+-int hp_populate_ordered_list_package_data(union acpi_object *order_obj, int instance_id,
++int hp_populate_ordered_list_package_data(union acpi_object *order_obj, int order_obj_count,
++ int instance_id,
+ struct kobject *attr_name_kobj)
+ {
+ struct ordered_list_data *ordered_list_data = &bioscfg_drv.ordered_list_data[instance_id];
+@@ -309,7 +315,7 @@ int hp_populate_ordered_list_package_data(union acpi_object *order_obj, int inst
+ ordered_list_data->attr_name_kobj = attr_name_kobj;
+
+ hp_populate_ordered_list_elements_from_package(order_obj,
+- order_obj->package.count,
++ order_obj_count,
+ instance_id);
+ hp_update_attribute_permissions(ordered_list_data->common.is_readonly,
+ &ordered_list_current_val);
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
+index 4d79eb8056a5d8..9821403e42b644 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
+@@ -66,7 +66,7 @@ static int validate_password_input(int instance_id, const char *buf)
+ struct password_data *password_data = &bioscfg_drv.password_data[instance_id];
+
+ length = strlen(buf);
+- if (buf[length - 1] == '\n')
++ if (length > 0 && buf[length - 1] == '\n')
+ length--;
+
+ if (length > MAX_PASSWD_SIZE)
+@@ -123,7 +123,7 @@ static ssize_t new_password_store(struct kobject *kobj,
+ struct kobj_attribute *attr,
+ const char *buf, size_t count)
+ {
+- return store_password_instance(kobj, buf, count, true);
++ return store_password_instance(kobj, buf, count, false);
+ }
+
+ static struct kobj_attribute password_new_password = __ATTR_WO(new_password);
+@@ -321,6 +321,8 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
+ str_value = NULL;
+
+ }
++ if (size)
++ elem += size - 1;
+ break;
+ case SECURITY_LEVEL:
+ password_data->common.security_level = int_value;
+@@ -362,6 +364,8 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
+ str_value = NULL;
+
+ }
++ if (size)
++ elem += size - 1;
+ break;
+ case PSWD_IS_SET:
+ password_data->is_enabled = int_value;
+@@ -385,10 +389,12 @@ exit_package:
+ * Populate all properties for an instance under password attribute
+ *
+ * @password_obj: ACPI object with password data
++ * @password_obj_count: Number of elements in @password_obj
+ * @instance_id: The instance to enumerate
+ * @attr_name_kobj: The parent kernel object
+ */
+-int hp_populate_password_package_data(union acpi_object *password_obj, int instance_id,
++int hp_populate_password_package_data(union acpi_object *password_obj, int password_obj_count,
++ int instance_id,
+ struct kobject *attr_name_kobj)
+ {
+ struct password_data *password_data = &bioscfg_drv.password_data[instance_id];
+@@ -396,7 +402,7 @@ int hp_populate_password_package_data(union acpi_object *password_obj, int insta
+ password_data->attr_name_kobj = attr_name_kobj;
+
+ hp_populate_password_elements_from_package(password_obj,
+- password_obj->package.count,
++ password_obj_count,
+ instance_id);
+
+ hp_friendly_user_name_update(password_data->common.path,
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
+index 2b00a14792e921..4d94e48c1a4c80 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
+@@ -238,7 +238,7 @@ static ssize_t sk_store(struct kobject *kobj,
+ ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_SK,
+ HPWMI_SECUREPLATFORM,
+ (void *)bioscfg_drv.spm_data.signing_key,
+- count, 0);
++ length, 0);
+
+ if (!ret) {
+ bioscfg_drv.spm_data.mechanism = SIGNING_KEY;
+@@ -274,7 +274,7 @@ static ssize_t kek_store(struct kobject *kobj,
+ ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_KEK,
+ HPWMI_SECUREPLATFORM,
+ (void *)bioscfg_drv.spm_data.endorsement_key,
+- count, 0);
++ length, 0);
+
+ if (!ret) {
+ bioscfg_drv.spm_data.mechanism = ENDORSEMENT_KEY;
+diff --git a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
+index fe5a9a3a4ef174..f3dfba270f7e81 100644
+--- a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
++++ b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
+@@ -233,6 +233,8 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
+ kfree(str_value);
+ str_value = NULL;
+ }
++ if (size)
++ elem += size - 1;
+ break;
+
+ case SECURITY_LEVEL:
+@@ -263,10 +265,12 @@ exit_string_package:
+ * Populate all properties of an instance under string attribute
+ *
+ * @string_obj: ACPI object with string data
++ * @string_obj_count: Number of elements in @string_obj
+ * @instance_id: The instance to enumerate
+ * @attr_name_kobj: The parent kernel object
+ */
+ int hp_populate_string_package_data(union acpi_object *string_obj,
++ int string_obj_count,
+ int instance_id,
+ struct kobject *attr_name_kobj)
+ {
+@@ -275,7 +279,7 @@ int hp_populate_string_package_data(union acpi_object *string_obj,
+ string_data->attr_name_kobj = attr_name_kobj;
+
+ hp_populate_string_elements_from_package(string_obj,
+- string_obj->package.count,
++ string_obj_count,
+ instance_id);
+
+ hp_update_attribute_permissions(string_data->common.is_readonly,
+diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
+index 8ba286ed87216e..94147102cca43a 100644
+--- a/drivers/platform/x86/hp/hp-wmi.c
++++ b/drivers/platform/x86/hp/hp-wmi.c
+@@ -265,6 +265,10 @@ static const struct dmi_system_id victus_s_thermal_profile_boards[] __initconst
+ .matches = { DMI_MATCH(DMI_BOARD_NAME, "8D87") },
+ .driver_data = (void *)&omen_v1_no_ec_thermal_params,
+ },
++ {
++ .matches = { DMI_MATCH(DMI_BOARD_NAME, "8DD6") },
++ .driver_data = (void *)&omen_v1_no_ec_thermal_params,
++ },
+ {
+ .matches = { DMI_MATCH(DMI_BOARD_NAME, "8E35") },
+ .driver_data = (void *)&omen_v1_legacy_thermal_params,
+diff --git a/drivers/platform/x86/intel/int1092/intel_sar.c b/drivers/platform/x86/intel/int1092/intel_sar.c
+index 849f7b415c1e59..7263114f0b3d07 100644
+--- a/drivers/platform/x86/intel/int1092/intel_sar.c
++++ b/drivers/platform/x86/intel/int1092/intel_sar.c
+@@ -91,8 +91,10 @@ static acpi_status parse_package(struct wwan_sar_context *context, union acpi_ob
+ item->package.count <= data->total_dev_mode)
+ return AE_ERROR;
+
+- data->device_mode_info = kmalloc_objs(struct wwan_device_mode_info,
+- data->total_dev_mode);
++ data->device_mode_info = devm_kmalloc_array(&context->sar_device->dev,
++ data->total_dev_mode,
++ sizeof(*data->device_mode_info),
++ GFP_KERNEL);
+ if (!data->device_mode_info)
+ return AE_ERROR;
+
+@@ -253,7 +255,7 @@ static int sar_probe(struct platform_device *device)
+ if (!handle)
+ return -ENODEV;
+
+- context = kzalloc_obj(*context);
++ context = devm_kzalloc(&device->dev, sizeof(*context), GFP_KERNEL);
+ if (!context)
+ return -ENOMEM;
+
+@@ -264,7 +266,7 @@ static int sar_probe(struct platform_device *device)
+ result = guid_parse(SAR_DSM_UUID, &context->guid);
+ if (result) {
+ dev_err(&device->dev, "SAR UUID parse error: %d\n", result);
+- goto r_free;
++ return result;
+ }
+
+ for (reg = 0; reg < MAX_REGULATORY; reg++)
+@@ -272,43 +274,29 @@ static int sar_probe(struct platform_device *device)
+
+ if (sar_get_device_mode(device) != AE_OK) {
+ dev_err(&device->dev, "Failed to get device mode\n");
+- result = -EIO;
+- goto r_free;
++ return -EIO;
+ }
+
+ result = sysfs_create_group(&device->dev.kobj, &intcsar_group);
+ if (result) {
+ dev_err(&device->dev, "sysfs creation failed\n");
+- goto r_free;
++ return result;
+ }
+
+ if (acpi_install_notify_handler(ACPI_HANDLE(&device->dev), ACPI_DEVICE_NOTIFY,
+ sar_notify, (void *)device) != AE_OK) {
+ dev_err(&device->dev, "Failed acpi_install_notify_handler\n");
+- result = -EIO;
+- goto r_sys;
++ sysfs_remove_group(&device->dev.kobj, &intcsar_group);
++ return -EIO;
+ }
+ return 0;
+-
+-r_sys:
+- sysfs_remove_group(&device->dev.kobj, &intcsar_group);
+-r_free:
+- kfree(context);
+- return result;
+ }
+
+ static void sar_remove(struct platform_device *device)
+ {
+- struct wwan_sar_context *context = dev_get_drvdata(&device->dev);
+- int reg;
+-
+ acpi_remove_notify_handler(ACPI_HANDLE(&device->dev),
+ ACPI_DEVICE_NOTIFY, sar_notify);
+ sysfs_remove_group(&device->dev.kobj, &intcsar_group);
+- for (reg = 0; reg < MAX_REGULATORY; reg++)
+- kfree(context->config_data[reg].device_mode_info);
+-
+- kfree(context);
+ }
+
+ static struct platform_driver sar_driver = {
+diff --git a/drivers/platform/x86/intel/ishtp_eclite.c b/drivers/platform/x86/intel/ishtp_eclite.c
+index 93ac8b2dbf3878..bca7e217878b4a 100644
+--- a/drivers/platform/x86/intel/ishtp_eclite.c
++++ b/drivers/platform/x86/intel/ishtp_eclite.c
+@@ -600,13 +600,16 @@ static int ecl_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
+ rv = acpi_opregion_init(opr_dev);
+ if (rv) {
+ dev_err(cl_data_to_dev(opr_dev), "ACPI opregion init failed\n");
+- goto err_exit;
++ goto err_put;
+ }
+
+ /* Reprobe devices depending on ECLite - battery, fan, etc. */
+ acpi_dev_clear_dependencies(opr_dev->adev);
+
+ return 0;
++
++err_put:
++ acpi_dev_put(opr_dev->adev);
+ err_exit:
+ ishtp_set_connection_state(ecl_ishtp_cl, ISHTP_CL_DISCONNECTING);
+ ishtp_cl_disconnect(ecl_ishtp_cl);
+diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c
+index 24334ae70d8252..66dd974720beab 100644
+--- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c
++++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c
+@@ -336,8 +336,11 @@ static int sst_add_perf_profiles(struct auxiliary_device *auxdev,
+ int i;
+
+ pd_info->perf_levels = devm_kcalloc(dev, levels, sizeof(struct perf_level), GFP_KERNEL);
+- if (!pd_info->perf_levels)
+- return 0;
++ if (!pd_info->perf_levels) {
++ pd_info->pp_header.allowed_level_mask = 0;
++ pd_info->pp_header.level_en_mask = 0;
++ return -ENOMEM;
++ }
+
+ pd_info->ratio_unit = pd_info->pp_header.ratio_unit;
+ pd_info->avx_levels = SST_MAX_AVX_LEVELS;
+@@ -367,7 +370,7 @@ static int sst_add_perf_profiles(struct auxiliary_device *auxdev,
+ static int sst_main(struct auxiliary_device *auxdev, struct tpmi_per_power_domain_info *pd_info)
+ {
+ struct device *dev = &auxdev->dev;
+- int i, mask, levels;
++ int i, ret, mask, levels;
+
+ *((u64 *)&pd_info->sst_header) = readq(pd_info->sst_base);
+ pd_info->sst_header.cp_offset *= 8;
+@@ -399,8 +402,12 @@ static int sst_main(struct auxiliary_device *auxdev, struct tpmi_per_power_domai
+ levels = i;
+ mask <<= 1;
+ }
++
++ ret = sst_add_perf_profiles(auxdev, pd_info, levels + 1);
++ if (ret)
++ return ret;
++
+ pd_info->max_level = levels;
+- sst_add_perf_profiles(auxdev, pd_info, levels + 1);
+
+ return 0;
+ }
+@@ -599,6 +606,9 @@ static bool disable_dynamic_sst_features(void)
+ #define SST_CP_PRIORITY_TYPE_START 1
+ #define SST_CP_PRIORITY_TYPE_WIDTH 1
+
++#define SST_CP_MAX_ENABLE 1
++#define SST_CP_MAX_PRIORITY_TYPE 1
++
+ static long isst_if_core_power_state(void __user *argp)
+ {
+ struct tpmi_per_power_domain_info *power_domain_info;
+@@ -618,6 +628,10 @@ static long isst_if_core_power_state(void __user *argp)
+ if (power_domain_info->write_blocked || !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
++ if (core_power.enable > SST_CP_MAX_ENABLE ||
++ core_power.priority_type > SST_CP_MAX_PRIORITY_TYPE)
++ return -EINVAL;
++
+ _write_cp_info("cp_enable", core_power.enable, SST_CP_CONTROL_OFFSET,
+ SST_CP_ENABLE_START, SST_CP_ENABLE_WIDTH, SST_MUL_FACTOR_NONE)
+ _write_cp_info("cp_prio_type", core_power.priority_type, SST_CP_CONTROL_OFFSET,
+@@ -649,6 +663,11 @@ static long isst_if_core_power_state(void __user *argp)
+ #define SST_CLOS_CONFIG_MAX_START 16
+ #define SST_CLOS_CONFIG_MAX_WIDTH 8
+
++#define SST_MAX_CLOS 3
++
++#define SST_MAX_FREQ 0xff
++#define SST_CLOS_MAX_PRIORITY 0x0f
++
+ static long isst_if_clos_param(void __user *argp)
+ {
+ struct tpmi_per_power_domain_info *power_domain_info;
+@@ -657,6 +676,9 @@ static long isst_if_clos_param(void __user *argp)
+ if (copy_from_user(&clos_param, argp, sizeof(clos_param)))
+ return -EFAULT;
+
++ if (clos_param.clos > SST_MAX_CLOS)
++ return -EINVAL;
++
+ power_domain_info = get_instance(clos_param.socket_id, clos_param.power_domain_id);
+ if (!power_domain_info)
+ return -EINVAL;
+@@ -665,6 +687,15 @@ static long isst_if_clos_param(void __user *argp)
+ if (power_domain_info->write_blocked || !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
++ if (!in_range(clos_param.min_freq_mhz / SST_MUL_FACTOR_FREQ, 0, SST_MAX_FREQ + 1))
++ return -EINVAL;
++
++ if (!in_range(clos_param.max_freq_mhz / SST_MUL_FACTOR_FREQ, 0, SST_MAX_FREQ + 1))
++ return -EINVAL;
++
++ if (!in_range(clos_param.prop_prio, 0, SST_CLOS_MAX_PRIORITY + 1))
++ return -EINVAL;
++
+ _write_cp_info("clos.min_freq", clos_param.min_freq_mhz,
+ (SST_CLOS_CONFIG_0_OFFSET + clos_param.clos * SST_REG_SIZE),
+ SST_CLOS_CONFIG_MIN_START, SST_CLOS_CONFIG_MIN_WIDTH,
+@@ -703,6 +734,8 @@ static long isst_if_clos_param(void __user *argp)
+ #define SST_CLOS_ASSOC_CPUS_PER_REG 16
+ #define SST_CLOS_ASSOC_BITS_PER_CPU 4
+
++#define SST_CLOS_ASSOC_MAX_LOGICAL_CPU 63
++
+ static long isst_if_clos_assoc(void __user *argp)
+ {
+ struct isst_if_clos_assoc_cmds assoc_cmds;
+@@ -729,7 +762,13 @@ static long isst_if_clos_assoc(void __user *argp)
+ if (copy_from_user(&clos_assoc, ptr, sizeof(clos_assoc)))
+ return -EFAULT;
+
+- if (clos_assoc.socket_id > topology_max_packages())
++ if (clos_assoc.clos > SST_MAX_CLOS)
++ return -EINVAL;
++
++ if (clos_assoc.socket_id >= topology_max_packages())
++ return -EINVAL;
++
++ if (clos_assoc.logical_cpu > SST_CLOS_ASSOC_MAX_LOGICAL_CPU)
+ return -EINVAL;
+
+ cpu = clos_assoc.logical_cpu;
+@@ -747,6 +786,8 @@ static long isst_if_clos_assoc(void __user *argp)
+ pkg_id = clos_assoc.socket_id;
+
+ sst_inst = isst_common.sst_inst[pkg_id];
++ if (!sst_inst)
++ return -EINVAL;
+
+ punit_id = map_partition_power_domain_id(sst_inst, punit_id, &part);
+ if (punit_id < 0)
+@@ -845,6 +886,7 @@ static long isst_if_clos_assoc(void __user *argp)
+
+ #define SST_PP_FEATURE_STATE_START 8
+ #define SST_PP_FEATURE_STATE_WIDTH 8
++#define SST_PP_FEATURE_STATE_VALID_MASK GENMASK(1, 0)
+
+ #define SST_BF_FEATURE_SUPPORTED_START 12
+ #define SST_BF_FEATURE_SUPPORTED_WIDTH 1
+@@ -877,7 +919,7 @@ static int isst_if_get_perf_level(void __user *argp)
+ SST_PP_FEATURE_STATE_START, SST_PP_FEATURE_STATE_WIDTH, SST_MUL_FACTOR_NONE)
+ perf_level.enabled = !!(power_domain_info->sst_header.cap_mask & BIT(1));
+
+- level_mask = perf_level.level_mask;
++ level_mask = perf_level.level_mask & power_domain_info->pp_header.level_en_mask;
+ perf_level.sst_bf_support = 0;
+ for_each_set_bit(level, &level_mask, BITS_PER_BYTE) {
+ /*
+@@ -932,6 +974,9 @@ static int isst_if_set_perf_level(void __user *argp)
+ if (!power_domain_info)
+ return -EINVAL;
+
++ if (perf_level.level > power_domain_info->max_level)
++ return -EINVAL;
++
+ if (power_domain_info->write_blocked || !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+@@ -995,6 +1040,9 @@ static int isst_if_set_perf_feature(void __user *argp)
+ if (power_domain_info->write_blocked || !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
++ if (perf_feature.feature & ~SST_PP_FEATURE_STATE_VALID_MASK)
++ return -EINVAL;
++
+ _write_pp_info("perf_feature", perf_feature.feature, SST_PP_CONTROL_OFFSET,
+ SST_PP_FEATURE_STATE_START, SST_PP_FEATURE_STATE_WIDTH,
+ SST_MUL_FACTOR_NONE)
+@@ -1261,6 +1309,12 @@ static int isst_if_get_perf_level_mask(void __user *argp)
+ if (!power_domain_info)
+ return -EINVAL;
+
++ if (cpumask.level > power_domain_info->max_level)
++ return -EINVAL;
++
++ if (!(power_domain_info->pp_header.level_en_mask & BIT(cpumask.level)))
++ return -EINVAL;
++
+ _read_pp_level_info("mask", mask, cpumask.level, SST_PP_INFO_2_OFFSET,
+ SST_PP_RSLVD_CORE_MASK_START, SST_PP_RSLVD_CORE_MASK_WIDTH,
+ SST_MUL_FACTOR_NONE)
+@@ -1306,6 +1360,9 @@ static int isst_if_get_base_freq_info(void __user *argp)
+ if (base_freq.level > power_domain_info->max_level)
+ return -EINVAL;
+
++ if (!(power_domain_info->pp_header.level_en_mask & BIT(base_freq.level)))
++ return -EINVAL;
++
+ _read_bf_level_info("p1_high", base_freq.high_base_freq_mhz, base_freq.level,
+ SST_BF_INFO_0_OFFSET, SST_BF_P1_HIGH_START, SST_BF_P1_HIGH_WIDTH,
+ SST_MUL_FACTOR_FREQ)
+@@ -1342,6 +1399,12 @@ static int isst_if_get_base_freq_mask(void __user *argp)
+ if (!power_domain_info)
+ return -EINVAL;
+
++ if (cpumask.level > power_domain_info->max_level)
++ return -EINVAL;
++
++ if (!(power_domain_info->pp_header.level_en_mask & BIT(cpumask.level)))
++ return -EINVAL;
++
+ _read_bf_level_info("BF-cpumask", mask, cpumask.level, SST_BF_INFO_1_OFFSET,
+ P1_HI_CORE_MASK_START, P1_HI_CORE_MASK_WIDTH,
+ SST_MUL_FACTOR_NONE)
+@@ -1370,6 +1433,8 @@ static int isst_if_get_tpmi_instance_count(void __user *argp)
+ return -EINVAL;
+
+ sst_inst = isst_common.sst_inst[tpmi_inst.socket_id];
++ if (!sst_inst)
++ return -EINVAL;
+
+ tpmi_inst.count = isst_instance_count(sst_inst);
+
+@@ -1437,6 +1502,9 @@ static int isst_if_get_turbo_freq_info(void __user *argp)
+ if (turbo_freq.level > power_domain_info->max_level)
+ return -EINVAL;
+
++ if (!(power_domain_info->pp_header.level_en_mask & BIT(turbo_freq.level)))
++ return -EINVAL;
++
+ turbo_freq.max_buckets = TRL_MAX_BUCKETS;
+ turbo_freq.max_trl_levels = TRL_MAX_LEVELS;
+ turbo_freq.max_clip_freqs = SST_TF_MAX_LP_CLIP_RATIOS;
+diff --git a/drivers/platform/x86/lenovo/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
+index e215e86e3db736..a0e3fa766e37b5 100644
+--- a/drivers/platform/x86/lenovo/think-lmi.c
++++ b/drivers/platform/x86/lenovo/think-lmi.c
+@@ -438,14 +438,13 @@ static ssize_t current_password_store(struct kobject *kobj,
+ struct tlmi_pwd_setting *setting = to_tlmi_pwd_setting(kobj);
+ size_t pwdlen;
+
+- pwdlen = strlen(buf);
++ /* Strip newline; setting password won't work if one is present. */
++ pwdlen = strchrnul(buf, '\n') - buf;
+ /* pwdlen == 0 is allowed to clear the password */
+ if (pwdlen && ((pwdlen < setting->minlen) || (pwdlen > setting->maxlen)))
+ return -EINVAL;
+
+- strscpy(setting->password, buf, setting->maxlen);
+- /* Strip out CR if one is present, setting password won't work if it is present */
+- strreplace(setting->password, '\n', '\0');
++ strscpy(setting->password, buf, pwdlen + 1);
+ return count;
+ }
+
+@@ -745,6 +744,8 @@ static ssize_t certificate_thumbprint_show(struct kobject *kobj, struct kobj_att
+ return -EOPNOTSUPP;
+
+ for (i = 0; i < ARRAY_SIZE(thumbtypes); i++) {
++ ssize_t ret;
++
+ if (tlmi_priv.pwdcfg.core.password_mode >= TLMI_PWDCFG_MODE_MULTICERT) {
+ /* Format: 'SVC | SMC, Thumbtype' */
+ wmistr = kasprintf(GFP_KERNEL, "%s,%s",
+@@ -756,8 +757,12 @@ static ssize_t certificate_thumbprint_show(struct kobject *kobj, struct kobj_att
+ }
+ if (!wmistr)
+ return -ENOMEM;
+- count += cert_thumbprint(buf, wmistr, count);
++
++ ret = cert_thumbprint(buf, wmistr, count);
+ kfree(wmistr);
++ if (ret < 0)
++ return ret;
++ count = ret;
+ }
+
+ return count;
+@@ -1456,6 +1461,10 @@ static void tlmi_release_attr(void)
+ /* Free up any saved signatures */
+ kfree(tlmi_priv.pwd_admin->signature);
+ kfree(tlmi_priv.pwd_admin->save_signature);
++ if (tlmi_priv.pwd_system) {
++ kfree(tlmi_priv.pwd_system->signature);
++ kfree(tlmi_priv.pwd_system->save_signature);
++ }
+
+ /* Authentication structures */
+ list_for_each_entry_safe(pos, n, &tlmi_priv.authentication_kset->list, entry)
+diff --git a/drivers/platform/x86/lenovo/ymc.c b/drivers/platform/x86/lenovo/ymc.c
+index 1b73a55f1b89c7..015e046b0fcea8 100644
+--- a/drivers/platform/x86/lenovo/ymc.c
++++ b/drivers/platform/x86/lenovo/ymc.c
+@@ -8,6 +8,8 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include
++#include
++#include
+ #include
+ #include
+ #include
+@@ -20,6 +22,8 @@
+ #define LENOVO_YMC_QUERY_INSTANCE 0
+ #define LENOVO_YMC_QUERY_METHOD 0x01
+
++#define LENOVO_YMC_STATE_MASK GENMASK(7, 0)
++
+ static bool force;
+ module_param(force, bool, 0444);
+ MODULE_PARM_DESC(force, "Force loading on boards without a convertible DMI chassis-type");
+@@ -85,7 +89,9 @@ static void lenovo_ymc_notify(struct wmi_device *wdev, union acpi_object *data)
+ "WMI event data is not an integer\n");
+ goto free_obj;
+ }
+- code = obj->integer.value;
++
++ /* strip upper bits (e.g. 0x50000) on newer devices */
++ code = FIELD_GET(LENOVO_YMC_STATE_MASK, obj->integer.value);
+
+ if (!sparse_keymap_report_event(priv->input_dev, code, 1, true))
+ dev_warn(&wdev->dev, "Unknown key %d pressed\n", code);
+diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
+index 719add753cb3da..49098d82d6e02f 100644
+--- a/drivers/platform/x86/panasonic-laptop.c
++++ b/drivers/platform/x86/panasonic-laptop.c
+@@ -360,7 +360,16 @@ static int acpi_pcc_retrieve_biosdata(struct pcc_acpi *pcc)
+ } else
+ pr_err("Invalid HKEY.SINF data\n");
+ }
+- pcc->sinf[hkey->package.count] = -1;
++ /*
++ * pcc->sinf[] has pcc->num_sifr elements (valid indices
++ * 0..num_sifr-1). On DSDTs where SINF's package count equals
++ * num_sifr exactly -- the off-by-one case probe()'s num_sifr++
++ * already allocates a spare element for -- there is no room left
++ * for this trailing sentinel; nothing reads it back, so just skip
++ * the write rather than running one element past the flex array.
++ */
++ if (hkey->package.count < pcc->num_sifr)
++ pcc->sinf[hkey->package.count] = -1;
+
+ end:
+ kfree(buffer.pointer);
+diff --git a/drivers/power/supply/bq24257_charger.c b/drivers/power/supply/bq24257_charger.c
+index 72f1bfea8d5415..54dd9d4ec39cd5 100644
+--- a/drivers/power/supply/bq24257_charger.c
++++ b/drivers/power/supply/bq24257_charger.c
+@@ -18,6 +18,7 @@
+ #include
+ #include
+ #include
++#include
+
+ #include
+ #include
+@@ -1003,10 +1004,6 @@ static int bq24257_probe(struct i2c_client *client)
+ if (bq->info->chip == BQ24250)
+ bq->iilimit_autoset_enable = false;
+
+- if (bq->iilimit_autoset_enable)
+- INIT_DELAYED_WORK(&bq->iilimit_setup_work,
+- bq24257_iilimit_setup_work);
+-
+ /*
+ * The BQ24250 doesn't have a dedicated Power Good (PG) pin so let's
+ * not probe for it and instead use a SW-based approach to determine
+@@ -1047,6 +1044,14 @@ static int bq24257_probe(struct i2c_client *client)
+ return ret;
+ }
+
++ if (bq->iilimit_autoset_enable) {
++ ret = devm_delayed_work_autocancel(dev,
++ &bq->iilimit_setup_work,
++ bq24257_iilimit_setup_work);
++ if (ret)
++ return ret;
++ }
++
+ ret = devm_request_threaded_irq(dev, client->irq, NULL,
+ bq24257_irq_handler_thread,
+ IRQF_TRIGGER_FALLING |
+@@ -1064,9 +1069,6 @@ static void bq24257_remove(struct i2c_client *client)
+ {
+ struct bq24257_device *bq = i2c_get_clientdata(client);
+
+- if (bq->iilimit_autoset_enable)
+- cancel_delayed_work_sync(&bq->iilimit_setup_work);
+-
+ bq24257_field_write(bq, F_RESET, 1); /* reset to defaults */
+ }
+
+diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
+index 5a6634fde83768..43e1da849df420 100644
+--- a/drivers/power/supply/bq256xx_charger.c
++++ b/drivers/power/supply/bq256xx_charger.c
+@@ -896,6 +896,8 @@ static void bq256xx_charger_reset(void *data)
+
+ if (!IS_ERR_OR_NULL(bq->usb3_phy))
+ usb_unregister_notifier(bq->usb3_phy, &bq->usb_nb);
++
++ cancel_work_sync(&bq->usb_work);
+ }
+
+ static int bq256xx_set_charger_property(struct power_supply *psy,
+@@ -1721,24 +1723,12 @@ static int bq256xx_probe(struct i2c_client *client)
+ return ret;
+ }
+
+- ret = devm_add_action_or_reset(dev, bq256xx_charger_reset, bq);
+- if (ret)
+- return ret;
++ INIT_WORK(&bq->usb_work, bq256xx_usb_work);
++ bq->usb_nb.notifier_call = bq256xx_usb_notifier;
+
+ /* OTG reporting */
+ bq->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+- if (!IS_ERR_OR_NULL(bq->usb2_phy)) {
+- INIT_WORK(&bq->usb_work, bq256xx_usb_work);
+- bq->usb_nb.notifier_call = bq256xx_usb_notifier;
+- usb_register_notifier(bq->usb2_phy, &bq->usb_nb);
+- }
+-
+ bq->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
+- if (!IS_ERR_OR_NULL(bq->usb3_phy)) {
+- INIT_WORK(&bq->usb_work, bq256xx_usb_work);
+- bq->usb_nb.notifier_call = bq256xx_usb_notifier;
+- usb_register_notifier(bq->usb3_phy, &bq->usb_nb);
+- }
+
+ ret = bq256xx_power_supply_init(bq, &psy_cfg, dev);
+ if (ret) {
+@@ -1746,6 +1736,17 @@ static int bq256xx_probe(struct i2c_client *client)
+ return ret;
+ }
+
++ /* Register after the power supplies so devm runs it first. */
++ ret = devm_add_action_or_reset(dev, bq256xx_charger_reset, bq);
++ if (ret)
++ return ret;
++
++ if (!IS_ERR_OR_NULL(bq->usb2_phy))
++ usb_register_notifier(bq->usb2_phy, &bq->usb_nb);
++
++ if (!IS_ERR_OR_NULL(bq->usb3_phy))
++ usb_register_notifier(bq->usb3_phy, &bq->usb_nb);
++
+ if (client->irq) {
+ ret = devm_request_threaded_irq(dev, client->irq, NULL,
+ bq256xx_irq_handler_thread,
+diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
+index 180bc137a86325..741a45cc5f35dd 100644
+--- a/drivers/power/supply/bq25890_charger.c
++++ b/drivers/power/supply/bq25890_charger.c
+@@ -1389,6 +1389,14 @@ static int bq25890_fw_read_u32_props(struct bq25890_device *bq)
+ return 0;
+ }
+
++static void bq25890_release_secondary_chrg(void *data)
++{
++ struct bq25890_device *bq = data;
++
++ power_supply_put(bq->secondary_chrg);
++ bq->secondary_chrg = NULL;
++}
++
+ static int bq25890_fw_probe(struct bq25890_device *bq)
+ {
+ int ret;
+@@ -1401,6 +1409,10 @@ static int bq25890_fw_probe(struct bq25890_device *bq)
+ bq->secondary_chrg = power_supply_get_by_name(str);
+ if (!bq->secondary_chrg)
+ return -EPROBE_DEFER;
++
++ ret = devm_add_action_or_reset(bq->dev, bq25890_release_secondary_chrg, bq);
++ if (ret)
++ return ret;
+ }
+
+ /* Optional, left at 0 if property is not present */
+diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
+index 71b6e49a835f83..fd4cd9cd2ce2aa 100644
+--- a/drivers/power/supply/charger-manager.c
++++ b/drivers/power/supply/charger-manager.c
+@@ -1014,6 +1014,29 @@ static int charger_extcon_init(struct charger_manager *cm,
+ return 0;
+ }
+
++static int charger_manager_get_regulators(struct charger_manager *cm)
++{
++ struct charger_desc *desc = cm->desc;
++ struct charger_regulator *charger;
++ int i, ret;
++
++ for (i = 0; i < desc->num_charger_regulators; i++) {
++ charger = &desc->charger_regulators[i];
++ charger->consumer = regulator_get(cm->dev,
++ charger->regulator_name);
++ if (IS_ERR(charger->consumer)) {
++ dev_err(cm->dev, "Cannot find charger(%s)\n",
++ charger->regulator_name);
++ ret = PTR_ERR(charger->consumer);
++ while (i-- > 0)
++ regulator_put(desc->charger_regulators[i].consumer);
++ return ret;
++ }
++ charger->cm = cm;
++ }
++ return 0;
++}
++
+ /**
+ * charger_manager_register_extcon - Register extcon device to receive state
+ * of charger cable.
+@@ -1036,15 +1059,6 @@ static int charger_manager_register_extcon(struct charger_manager *cm)
+ for (i = 0; i < desc->num_charger_regulators; i++) {
+ charger = &desc->charger_regulators[i];
+
+- charger->consumer = regulator_get(cm->dev,
+- charger->regulator_name);
+- if (IS_ERR(charger->consumer)) {
+- dev_err(cm->dev, "Cannot find charger(%s)\n",
+- charger->regulator_name);
+- return PTR_ERR(charger->consumer);
+- }
+- charger->cm = cm;
+-
+ for (j = 0; j < charger->num_cables; j++) {
+ struct charger_cable *cable = &charger->cables[j];
+
+@@ -1580,13 +1594,23 @@ static int charger_manager_probe(struct platform_device *pdev)
+ }
+ psy_cfg.attr_grp = desc->sysfs_groups;
+
++ /*
++ * Acquire charger regulators before exposing the sysfs entries, so
++ * userspace cannot reach externally_control before the regulators
++ * (and charger->cm) are available. Mirrors the order in remove().
++ */
++ ret = charger_manager_get_regulators(cm);
++ if (ret < 0)
++ return ret;
++
+ cm->charger_psy = power_supply_register(&pdev->dev,
+ &cm->charger_psy_desc,
+ &psy_cfg);
+ if (IS_ERR(cm->charger_psy)) {
+ dev_err(&pdev->dev, "Cannot register charger-manager with name \"%s\"\n",
+ cm->charger_psy_desc.name);
+- return PTR_ERR(cm->charger_psy);
++ ret = PTR_ERR(cm->charger_psy);
++ goto err_regulator;
+ }
+
+ /* Register extcon device for charger cable */
+@@ -1620,11 +1644,11 @@ static int charger_manager_probe(struct platform_device *pdev)
+ return 0;
+
+ err_reg_extcon:
++ power_supply_unregister(cm->charger_psy);
++err_regulator:
+ for (i = 0; i < desc->num_charger_regulators; i++)
+ regulator_put(desc->charger_regulators[i].consumer);
+
+- power_supply_unregister(cm->charger_psy);
+-
+ return ret;
+ }
+
+@@ -1642,12 +1666,12 @@ static void charger_manager_remove(struct platform_device *pdev)
+ cancel_work_sync(&setup_polling);
+ cancel_delayed_work_sync(&cm_monitor_work);
+
+- for (i = 0 ; i < desc->num_charger_regulators ; i++)
+- regulator_put(desc->charger_regulators[i].consumer);
++ try_charger_enable(cm, false);
+
+ power_supply_unregister(cm->charger_psy);
+
+- try_charger_enable(cm, false);
++ for (i = 0 ; i < desc->num_charger_regulators ; i++)
++ regulator_put(desc->charger_regulators[i].consumer);
+ }
+
+ static const struct platform_device_id charger_manager_id[] = {
+diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c
+index c1cbe6e5476e98..69d227ceb5c9ec 100644
+--- a/drivers/power/supply/cros_usbpd-charger.c
++++ b/drivers/power/supply/cros_usbpd-charger.c
+@@ -124,6 +124,11 @@ static int cros_usbpd_charger_get_num_ports(struct charger_data *charger)
+ if (ret < 0)
+ return ret;
+
++ if (resp.port_count > EC_USB_PD_MAX_PORTS) {
++ dev_warn(charger->dev, "Charge port count out of bounds\n");
++ return EC_USB_PD_MAX_PORTS;
++ }
++
+ return resp.port_count;
+ }
+
+@@ -137,6 +142,11 @@ static int cros_usbpd_charger_get_usbpd_num_ports(struct charger_data *charger)
+ if (ret < 0)
+ return ret;
+
++ if (resp.num_ports > EC_USB_PD_MAX_PORTS) {
++ dev_warn(charger->dev, "USB PD port count out of bounds\n");
++ return EC_USB_PD_MAX_PORTS;
++ }
++
+ return resp.num_ports;
+ }
+
+@@ -588,10 +598,13 @@ static int cros_usbpd_charger_probe(struct platform_device *pd)
+
+ /*
+ * Sanity checks on the number of ports:
+- * there should be at most 1 dedicated port
++ * there should be at most 1 dedicated port, and the count must
++ * not exceed the maximum number of supported ports
++ * (EC_USB_PD_MAX_PORTS).
+ */
+ if (charger->num_charger_ports < charger->num_usbpd_ports ||
+- charger->num_charger_ports > (charger->num_usbpd_ports + 1)) {
++ charger->num_charger_ports > (charger->num_usbpd_ports + 1) ||
++ charger->num_charger_ports > EC_USB_PD_MAX_PORTS) {
+ dev_err(dev, "Unexpected number of charge port count\n");
+ ret = -EPROTO;
+ goto fail_nowarn;
+diff --git a/drivers/power/supply/lp8727_charger.c b/drivers/power/supply/lp8727_charger.c
+index 641e0445a4109d..4537b7b413ddc2 100644
+--- a/drivers/power/supply/lp8727_charger.c
++++ b/drivers/power/supply/lp8727_charger.c
+@@ -280,10 +280,10 @@ static int lp8727_setup_irq(struct lp8727_chg *pchg)
+
+ static void lp8727_release_irq(struct lp8727_chg *pchg)
+ {
+- cancel_delayed_work_sync(&pchg->work);
+-
+ if (pchg->irq)
+ free_irq(pchg->irq, pchg);
++
++ cancel_delayed_work_sync(&pchg->work);
+ }
+
+ static enum power_supply_property lp8727_charger_prop[] = {
+diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
+index f0a680c155c485..1bc2c150fb9127 100644
+--- a/drivers/power/supply/lp8788-charger.c
++++ b/drivers/power/supply/lp8788-charger.c
+@@ -710,8 +710,8 @@ static void lp8788_charger_remove(struct platform_device *pdev)
+ {
+ struct lp8788_charger *pchg = platform_get_drvdata(pdev);
+
+- flush_work(&pchg->charger_work);
+ lp8788_irq_unregister(pdev, pchg);
++ cancel_work_sync(&pchg->charger_work);
+ }
+
+ static struct platform_driver lp8788_charger_driver = {
+diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
+index 03ac569e185c54..41744191a3638d 100644
+--- a/drivers/power/supply/max17040_battery.c
++++ b/drivers/power/supply/max17040_battery.c
+@@ -192,8 +192,11 @@ static int max17040_raw_vcell_to_uvolts(struct max17040_chip *chip, u16 vcell)
+ static int max17040_get_vcell(struct max17040_chip *chip)
+ {
+ u32 vcell;
++ int ret;
+
+- regmap_read(chip->regmap, MAX17040_VCELL, &vcell);
++ ret = regmap_read(chip->regmap, MAX17040_VCELL, &vcell);
++ if (ret)
++ return ret;
+
+ return max17040_raw_vcell_to_uvolts(chip, vcell);
+ }
+@@ -201,8 +204,11 @@ static int max17040_get_vcell(struct max17040_chip *chip)
+ static int max17040_get_soc(struct max17040_chip *chip)
+ {
+ u32 soc;
++ int ret;
+
+- regmap_read(chip->regmap, MAX17040_SOC, &soc);
++ ret = regmap_read(chip->regmap, MAX17040_SOC, &soc);
++ if (ret)
++ return ret;
+
+ return soc >> (chip->quirk_double_soc ? 9 : 8);
+ }
+@@ -261,7 +267,11 @@ static int max17040_get_of_data(struct max17040_chip *chip)
+
+ static void max17040_check_changes(struct max17040_chip *chip)
+ {
+- chip->soc = max17040_get_soc(chip);
++ int soc;
++
++ soc = max17040_get_soc(chip);
++ if (soc >= 0)
++ chip->soc = soc;
+ }
+
+ static void max17040_queue_work(struct max17040_chip *chip)
+@@ -396,10 +406,16 @@ static int max17040_get_property(struct power_supply *psy,
+ val->intval = max17040_get_online(chip);
+ break;
+ case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+- val->intval = max17040_get_vcell(chip);
++ ret = max17040_get_vcell(chip);
++ if (ret < 0)
++ return ret;
++ val->intval = ret;
+ break;
+ case POWER_SUPPLY_PROP_CAPACITY:
+- val->intval = max17040_get_soc(chip);
++ ret = max17040_get_soc(chip);
++ if (ret < 0)
++ return ret;
++ val->intval = ret;
+ break;
+ case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
+ val->intval = chip->low_soc_alert;
+@@ -458,16 +474,12 @@ static const struct power_supply_desc max17040_battery_desc = {
+ static int max17040_probe(struct i2c_client *client)
+ {
+ const struct i2c_device_id *id = i2c_client_get_device_id(client);
+- struct i2c_adapter *adapter = client->adapter;
+ struct power_supply_config psy_cfg = {};
+ struct max17040_chip *chip;
+ enum chip_id chip_id;
+ bool enable_irq = false;
+ int ret;
+
+- if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
+- return -EIO;
+-
+ chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
+ if (!chip)
+ return -ENOMEM;
+@@ -568,7 +580,7 @@ static int max17040_suspend(struct device *dev)
+ // disable soc alert to prevent wakeup
+ max17040_set_soc_alert(chip, 0);
+ else
+- cancel_delayed_work(&chip->work);
++ cancel_delayed_work_sync(&chip->work);
+
+ if (client->irq && device_may_wakeup(dev))
+ enable_irq_wake(client->irq);
+diff --git a/drivers/power/supply/pf1550-charger.c b/drivers/power/supply/pf1550-charger.c
+index 41036f4cb64a0a..38cac156d2e683 100644
+--- a/drivers/power/supply/pf1550-charger.c
++++ b/drivers/power/supply/pf1550-charger.c
+@@ -514,7 +514,7 @@ static int pf1550_reg_init(struct pf1550_charger *chg)
+ * a battery. The other supported mode is mode 2, the charger is turned
+ * on to charge a battery when present.
+ */
+- if (power_supply_get_battery_info(chg->charger, &info)) {
++ if (!power_supply_get_battery_info(chg->charger, &info)) {
+ ret = regmap_write(chg->pf1550->regmap,
+ PF1550_CHARG_REG_CHG_OPER,
+ PF1550_CHG_BAT_ON);
+diff --git a/drivers/power/supply/qcom_battmgr.c b/drivers/power/supply/qcom_battmgr.c
+index 490137a23d00e9..91cf39b0083a32 100644
+--- a/drivers/power/supply/qcom_battmgr.c
++++ b/drivers/power/supply/qcom_battmgr.c
+@@ -5,6 +5,7 @@
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+ #include
++#include