Merge tag 'dma-mapping-5.11-2' of git://git.infradead.org/users/hch/dma-mapping
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 7 Feb 2021 18:40:48 +0000 (10:40 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 7 Feb 2021 18:40:48 +0000 (10:40 -0800)
Pull dma-mapping fix from Christoph Hellwig:
 "Fix a 32 vs 64-bit padding issue in the new benchmark code (Barry
  Song)"

* tag 'dma-mapping-5.11-2' of git://git.infradead.org/users/hch/dma-mapping:
  dma-mapping: benchmark: use u8 for reserved field in uAPI structure

166 files changed:
.mailmap
Documentation/Makefile
Documentation/admin-guide/syscall-user-dispatch.rst
Documentation/devicetree/bindings/input/adc-keys.txt
Documentation/devicetree/bindings/input/touchscreen/goodix.yaml
Documentation/kbuild/gcc-plugins.rst
Documentation/kbuild/llvm.rst
Documentation/kbuild/makefiles.rst
Documentation/virt/kvm/nested-vmx.rst
Documentation/virt/kvm/running-nested-guests.rst
MAINTAINERS
Makefile
arch/arm/include/asm/kexec-internal.h [new file with mode: 0644]
arch/arm/include/debug/tegra.S
arch/arm/kernel/asm-offsets.c
arch/arm/kernel/machine_kexec.c
arch/arm/kernel/relocate_kernel.S
arch/arm/kernel/signal.c
arch/arm/mach-footbridge/dc21285.c
arch/arm64/kvm/hyp/nvhe/hyp-init.S
arch/ia64/Makefile
arch/ia64/scripts/unwcheck.py
arch/powerpc/kernel/Makefile
arch/powerpc/kernel/vdso32/Makefile
arch/powerpc/kernel/vdso32/vdso32_wrapper.S [deleted file]
arch/powerpc/kernel/vdso32_wrapper.S [new file with mode: 0644]
arch/powerpc/kernel/vdso64/Makefile
arch/powerpc/kernel/vdso64/sigtramp.S
arch/powerpc/kernel/vdso64/vdso64.lds.S
arch/powerpc/kernel/vdso64/vdso64_wrapper.S [deleted file]
arch/powerpc/kernel/vdso64_wrapper.S [new file with mode: 0644]
arch/powerpc/lib/sstep.c
arch/riscv/Kconfig
arch/riscv/include/asm/page.h
arch/riscv/include/asm/set_memory.h
arch/riscv/kernel/setup.c
arch/x86/Makefile
arch/x86/include/asm/apic.h
arch/x86/include/asm/barrier.h
arch/x86/include/asm/entry-common.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_phys.c
arch/x86/kernel/cpu/intel.c
arch/x86/kernel/hw_breakpoint.c
arch/x86/kernel/step.c
arch/x86/kvm/cpuid.c
arch/x86/kvm/emulate.c
arch/x86/kvm/mmu/tdp_mmu.c
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c
arch/x86/kvm/x86.h
arch/x86/mm/mem_encrypt.c
arch/x86/platform/efi/efi_64.c
block/bfq-iosched.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
drivers/gpu/drm/amd/display/dc/dc_stream.h
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
drivers/gpu/drm/bridge/lontium-lt9611uxc.c
drivers/gpu/drm/drm_dp_mst_topology.c
drivers/gpu/drm/i915/display/intel_ddi.c
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_dp.c
drivers/gpu/drm/i915/display/intel_dp.h
drivers/gpu/drm/i915/display/intel_dp_link_training.c
drivers/gpu/drm/i915/display/intel_dp_link_training.h
drivers/gpu/drm/i915/display/intel_dp_mst.c
drivers/gpu/drm/i915/display/intel_overlay.c
drivers/gpu/drm/i915/display/intel_sprite.c
drivers/gpu/drm/i915/gem/i915_gem_domain.c
drivers/gpu/drm/i915/gem/i915_gem_object.h
drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/ttm/ttm_pool.c
drivers/input/joystick/xpad.c
drivers/input/misc/ariel-pwrbutton.c
drivers/input/serio/i8042-x86ia64io.h
drivers/input/touchscreen/goodix.c
drivers/input/touchscreen/ili210x.c
drivers/input/touchscreen/st1232.c
drivers/mmc/core/sdio_cis.c
drivers/mmc/host/sdhci-pltfm.h
drivers/nvme/host/pci.c
drivers/nvme/target/tcp.c
drivers/rtc/rtc-cmos.c
drivers/rtc/rtc-mc146818-lib.c
drivers/scsi/lpfc/lpfc_nvme.c
drivers/thunderbolt/acpi.c
drivers/usb/class/usblp.c
drivers/usb/dwc2/gadget.c
drivers/usb/dwc3/core.c
drivers/usb/gadget/legacy/ether.c
drivers/usb/gadget/udc/aspeed-vhub/hub.c
drivers/usb/host/xhci-mtk-sch.c
drivers/usb/host/xhci-mtk.c
drivers/usb/host/xhci-mtk.h
drivers/usb/host/xhci-mvebu.c
drivers/usb/host/xhci-mvebu.h
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci-plat.h
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h
drivers/usb/renesas_usbhs/fifo.c
drivers/usb/serial/cp210x.c
drivers/usb/serial/option.c
drivers/vdpa/mlx5/net/mlx5_vnet.c
fs/cifs/dir.c
fs/cifs/smb2pdu.h
fs/cifs/transport.c
fs/hugetlbfs/inode.c
fs/io_uring.c
include/drm/drm_dp_mst_helper.h
include/linux/entry-common.h
include/linux/hugetlb.h
include/linux/iommu.h
include/linux/irq.h
include/linux/kasan.h
include/linux/msi.h
include/linux/thread_info.h
include/linux/vmalloc.h
include/uapi/linux/prctl.h
init/Kconfig
init/main.c
kernel/entry/common.c
kernel/entry/syscall_user_dispatch.c
kernel/gcov/Kconfig
kernel/irq/msi.c
kernel/time/ntp.c
lib/cpumask.c
lib/ubsan.c
lib/ubsan.h
mm/compaction.c
mm/filemap.c
mm/huge_memory.c
mm/hugetlb.c
mm/kasan/kasan.h
mm/memblock.c
mm/migrate.c
net/sunrpc/svcsock.c
scripts/Makefile
scripts/bloat-o-meter
scripts/checkpatch.pl
scripts/clang-tools/gen_compile_commands.py
scripts/clang-tools/run-clang-tools.py
scripts/diffconfig
scripts/dummy-tools/gcc
scripts/jobserver-exec
scripts/kallsyms.c
scripts/kconfig/mconf-cfg.sh
tools/power/x86/turbostat/turbostat.c
tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
tools/testing/selftests/syscall_user_dispatch/sud_test.c

index cc4e91d3075e824d5188a7186648e57a6a729280..d674968df008b6b242d84bed04a7ddbdac0ba278 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -179,6 +179,8 @@ Kees Cook <keescook@chromium.org> <kees.cook@canonical.com>
 Kees Cook <keescook@chromium.org> <keescook@google.com>
 Kees Cook <keescook@chromium.org> <kees@outflux.net>
 Kees Cook <keescook@chromium.org> <kees@ubuntu.com>
+Keith Busch <kbusch@kernel.org> <keith.busch@intel.com>
+Keith Busch <kbusch@kernel.org> <keith.busch@linux.intel.com>
 Kenneth W Chen <kenneth.w.chen@intel.com>
 Konstantin Khlebnikov <koct9i@gmail.com> <khlebnikov@yandex-team.ru>
 Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com>
@@ -199,6 +201,8 @@ Li Yang <leoyang.li@nxp.com> <leoli@freescale.com>
 Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org>
 Lukasz Luba <lukasz.luba@arm.com> <l.luba@partner.samsung.com>
 Maciej W. Rozycki <macro@mips.com> <macro@imgtec.com>
+Manivannan Sadhasivam <mani@kernel.org> <manivannanece23@gmail.com>
+Manivannan Sadhasivam <mani@kernel.org> <manivannan.sadhasivam@linaro.org>
 Marcin Nowakowski <marcin.nowakowski@mips.com> <marcin.nowakowski@imgtec.com>
 Marc Zyngier <maz@kernel.org> <marc.zyngier@arm.com>
 Mark Brown <broonie@sirena.org.uk>
@@ -244,6 +248,7 @@ Morten Welinder <welinder@anemone.rentec.com>
 Morten Welinder <welinder@darter.rentec.com>
 Morten Welinder <welinder@troll.com>
 Mythri P K <mythripk@ti.com>
+Nathan Chancellor <nathan@kernel.org> <natechancellor@gmail.com>
 Nguyen Anh Quynh <aquynh@gmail.com>
 Nicolas Ferre <nicolas.ferre@microchip.com> <nicolas.ferre@atmel.com>
 Nicolas Pitre <nico@fluxnic.net> <nicolas.pitre@linaro.org>
@@ -334,6 +339,8 @@ Vinod Koul <vkoul@kernel.org> <vkoul@infradead.org>
 Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com>
 Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com>
 Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com>
+Viresh Kumar <viresh.kumar@linaro.org> <viresh.kumar@linaro.org>
+Viresh Kumar <viresh.kumar@linaro.org> <viresh.kumar@linaro.com>
 Vivien Didelot <vivien.didelot@gmail.com> <vivien.didelot@savoirfairelinux.com>
 Vlad Dogaru <ddvlad@gmail.com> <vlad.dogaru@intel.com>
 Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com>
index 61a7310b49e0ce355e8f73e4afa33d6026545387..9c42dde97671f21d42fc7f484b0eeb217e5c1014 100644 (file)
@@ -75,7 +75,7 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
       cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \
        PYTHONDONTWRITEBYTECODE=1 \
        BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
-       $(PYTHON) $(srctree)/scripts/jobserver-exec \
+       $(PYTHON3) $(srctree)/scripts/jobserver-exec \
        $(SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \
        $(SPHINXBUILD) \
        -b $2 \
index a380d651577457c6a03060beb072085707517c2b..60314953c72841bb9c43149e168edcc91c8a9e46 100644 (file)
@@ -70,8 +70,8 @@ trampoline code on the vDSO, that trampoline is never intercepted.
 [selector] is a pointer to a char-sized region in the process memory
 region, that provides a quick way to enable disable syscall redirection
 thread-wide, without the need to invoke the kernel directly.  selector
-can be set to PR_SYS_DISPATCH_ON or PR_SYS_DISPATCH_OFF.  Any other
-value should terminate the program with a SIGSYS.
+can be set to SYSCALL_DISPATCH_FILTER_ALLOW or SYSCALL_DISPATCH_FILTER_BLOCK.
+Any other value should terminate the program with a SIGSYS.
 
 Security Notes
 --------------
index e551814629b48e3a0ece53bf226864a701d1ed61..6c8be6a9ace286c359c1ed50fca83879b01e18ed 100644 (file)
@@ -5,7 +5,8 @@ Required properties:
  - compatible: "adc-keys"
  - io-channels: Phandle to an ADC channel
  - io-channel-names = "buttons";
- - keyup-threshold-microvolt: Voltage at which all the keys are considered up.
+ - keyup-threshold-microvolt: Voltage above or equal to which all the keys are
+                             considered up.
 
 Optional properties:
        - poll-interval: Poll interval time in milliseconds
@@ -17,7 +18,12 @@ Each button (key) is represented as a sub-node of "adc-keys":
 Required subnode-properties:
        - label: Descriptive name of the key.
        - linux,code: Keycode to emit.
-       - press-threshold-microvolt: Voltage ADC input when this key is pressed.
+       - press-threshold-microvolt: voltage above or equal to which this key is
+                                    considered pressed.
+
+No two values of press-threshold-microvolt may be the same.
+All values of press-threshold-microvolt must be less than
+keyup-threshold-microvolt.
 
 Example:
 
@@ -47,3 +53,15 @@ Example:
                        press-threshold-microvolt = <500000>;
                };
        };
+
++--------------------------------+------------------------+
+| 2.000.000 <= value             | no key pressed         |
++--------------------------------+------------------------+
+| 1.500.000 <= value < 2.000.000 | KEY_VOLUMEUP pressed   |
++--------------------------------+------------------------+
+| 1.000.000 <= value < 1.500.000 | KEY_VOLUMEDOWN pressed |
++--------------------------------+------------------------+
+|   500.000 <= value < 1.000.000 | KEY_ENTER pressed      |
++--------------------------------+------------------------+
+|              value <   500.000 | no key pressed         |
++--------------------------------+------------------------+
index da5b0d87e16d08aefec0c59826ff2253b6852c2e..93f2ce3130ae7e9c55806162d994a0414c3e94b4 100644 (file)
@@ -26,6 +26,7 @@ properties:
       - goodix,gt927
       - goodix,gt9271
       - goodix,gt928
+      - goodix,gt9286
       - goodix,gt967
 
   reg:
index 4b1c10f88e304ee8e03bb0855e7491c4c123538c..3349966f213dcff110e855fcc42efbb638a9cae6 100644 (file)
@@ -11,16 +11,13 @@ compiler [1]_. They are useful for runtime instrumentation and static analysis.
 We can analyse, change and add further code during compilation via
 callbacks [2]_, GIMPLE [3]_, IPA [4]_ and RTL passes [5]_.
 
-The GCC plugin infrastructure of the kernel supports all gcc versions from
-4.5 to 6.0, building out-of-tree modules, cross-compilation and building in a
-separate directory.
-Plugin source files have to be compilable by both a C and a C++ compiler as well
-because gcc versions 4.5 and 4.6 are compiled by a C compiler,
-gcc-4.7 can be compiled by a C or a C++ compiler,
-and versions 4.8+ can only be compiled by a C++ compiler.
+The GCC plugin infrastructure of the kernel supports building out-of-tree
+modules, cross-compilation and building in a separate directory.
+Plugin source files have to be compilable by a C++ compiler.
 
-Currently the GCC plugin infrastructure supports only the x86, arm, arm64 and
-powerpc architectures.
+Currently the GCC plugin infrastructure supports only some architectures.
+Grep "select HAVE_GCC_PLUGINS" to find out which architectures support
+GCC plugins.
 
 This infrastructure was ported from grsecurity [6]_ and PaX [7]_.
 
@@ -47,20 +44,13 @@ Files
        This is a compatibility header for GCC plugins.
        It should be always included instead of individual gcc headers.
 
-**$(src)/scripts/gcc-plugin.sh**
-
-       This script checks the availability of the included headers in
-       gcc-common.h and chooses the proper host compiler to build the plugins
-       (gcc-4.7 can be built by either gcc or g++).
-
 **$(src)/scripts/gcc-plugins/gcc-generate-gimple-pass.h,
 $(src)/scripts/gcc-plugins/gcc-generate-ipa-pass.h,
 $(src)/scripts/gcc-plugins/gcc-generate-simple_ipa-pass.h,
 $(src)/scripts/gcc-plugins/gcc-generate-rtl-pass.h**
 
        These headers automatically generate the registration structures for
-       GIMPLE, SIMPLE_IPA, IPA and RTL passes. They support all gcc versions
-       from 4.5 to 6.0.
+       GIMPLE, SIMPLE_IPA, IPA and RTL passes.
        They should be preferred to creating the structures by hand.
 
 
@@ -68,21 +58,25 @@ Usage
 =====
 
 You must install the gcc plugin headers for your gcc version,
-e.g., on Ubuntu for gcc-4.9::
+e.g., on Ubuntu for gcc-10::
 
-       apt-get install gcc-4.9-plugin-dev
+       apt-get install gcc-10-plugin-dev
 
 Or on Fedora::
 
        dnf install gcc-plugin-devel
 
-Enable a GCC plugin based feature in the kernel config::
+Enable the GCC plugin infrastructure and some plugin(s) you want to use
+in the kernel config::
 
-       CONFIG_GCC_PLUGIN_CYC_COMPLEXITY = y
+       CONFIG_GCC_PLUGINS=y
+       CONFIG_GCC_PLUGIN_CYC_COMPLEXITY=y
+       CONFIG_GCC_PLUGIN_LATENT_ENTROPY=y
+       ...
 
-To compile only the plugin(s)::
+To compile the minimum tool set including the plugin(s)::
 
-       make gcc-plugins
+       make scripts
 
 or just run the kernel make and compile the whole kernel with
 the cyclomatic complexity GCC plugin.
@@ -91,7 +85,8 @@ the cyclomatic complexity GCC plugin.
 4. How to add a new GCC plugin
 ==============================
 
-The GCC plugins are in $(src)/scripts/gcc-plugins/. You can use a file or a directory
-here. It must be added to $(src)/scripts/gcc-plugins/Makefile,
-$(src)/scripts/Makefile.gcc-plugins and $(src)/arch/Kconfig.
+The GCC plugins are in scripts/gcc-plugins/. You need to put plugin source files
+right under scripts/gcc-plugins/. Creating subdirectories is not supported.
+It must be added to scripts/gcc-plugins/Makefile, scripts/Makefile.gcc-plugins
+and a relevant Kconfig file.
 See the cyc_complexity_plugin.c (CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) GCC plugin.
index 21c847890d03c4a337ec2824a1a152ede3b300f7..b18401d2ba8204bb66551f5e5c67bc22c13a52f4 100644 (file)
@@ -63,6 +63,50 @@ They can be enabled individually. The full list of the parameters: ::
 Currently, the integrated assembler is disabled by default. You can pass
 ``LLVM_IAS=1`` to enable it.
 
+Supported Architectures
+-----------------------
+
+LLVM does not target all of the architectures that Linux supports and
+just because a target is supported in LLVM does not mean that the kernel
+will build or work without any issues. Below is a general summary of
+architectures that currently work with ``CC=clang`` or ``LLVM=1``. Level
+of support corresponds to "S" values in the MAINTAINERS files. If an
+architecture is not present, it either means that LLVM does not target
+it or there are known issues. Using the latest stable version of LLVM or
+even the development tree will generally yield the best results.
+An architecture's ``defconfig`` is generally expected to work well,
+certain configurations may have problems that have not been uncovered
+yet. Bug reports are always welcome at the issue tracker below!
+
+.. list-table::
+   :widths: 10 10 10
+   :header-rows: 1
+
+   * - Architecture
+     - Level of support
+     - ``make`` command
+   * - arm
+     - Supported
+     - ``LLVM=1``
+   * - arm64
+     - Supported
+     - ``LLVM=1``
+   * - mips
+     - Maintained
+     - ``CC=clang``
+   * - powerpc
+     - Maintained
+     - ``CC=clang``
+   * - riscv
+     - Maintained
+     - ``CC=clang``
+   * - s390
+     - Maintained
+     - ``CC=clang``
+   * - x86
+     - Supported
+     - ``LLVM=1``
+
 Getting Help
 ------------
 
index 9f6a1188195136089fda768bf2ab88cc60c5dae4..300d8edcb994e5f286b3e890d296496d82fd3768 100644 (file)
@@ -755,7 +755,7 @@ more details, with real examples.
        bits on the scripts nonetheless.
 
        Kbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL),
-       $(PYTHON) and $(PYTHON3) to refer to interpreters for the respective
+       and $(PYTHON3) to refer to interpreters for the respective
        scripts.
 
        Example::
index 6ab4e35cee233c408338d3d7efbff4d6c9f065a9..ac2095d41f020c9095918bede118a72b34b118a1 100644 (file)
@@ -37,8 +37,10 @@ call L2.
 Running nested VMX
 ------------------
 
-The nested VMX feature is disabled by default. It can be enabled by giving
-the "nested=1" option to the kvm-intel module.
+The nested VMX feature is enabled by default since Linux kernel v4.20. For
+older Linux kernel, it can be enabled by giving the "nested=1" option to the
+kvm-intel module.
+
 
 No modifications are required to user space (qemu). However, qemu's default
 emulated CPU type (qemu64) does not list the "VMX" CPU feature, so it must be
index d0a1fc754c84f4addc328e359d4d4f41319ec45b..bd70c69468aebb236937232d41adce56654e3149 100644 (file)
@@ -74,7 +74,7 @@ few:
 Enabling "nested" (x86)
 -----------------------
 
-From Linux kernel v4.19 onwards, the ``nested`` KVM parameter is enabled
+From Linux kernel v4.20 onwards, the ``nested`` KVM parameter is enabled
 by default for Intel and AMD.  (Though your Linux distribution might
 override this default.)
 
index 2a0737dfca89b48742b85c6da8c0322fe78fe9df..667d03852191fbbcb6827eaa7bdbd9bbfc8c0a4f 100644 (file)
@@ -4304,7 +4304,7 @@ S:        Maintained
 F:     .clang-format
 
 CLANG/LLVM BUILD SUPPORT
-M:     Nathan Chancellor <natechancellor@gmail.com>
+M:     Nathan Chancellor <nathan@kernel.org>
 M:     Nick Desaulniers <ndesaulniers@google.com>
 L:     clang-built-linux@googlegroups.com
 S:     Supported
index f5842126e89d471cf41143f9291870a2b742fcd6..70035c522bd3e20bb6fa7118a762fab880a4bc9a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -452,7 +452,6 @@ AWK         = awk
 INSTALLKERNEL  := installkernel
 DEPMOD         = depmod
 PERL           = perl
-PYTHON         = python
 PYTHON3                = python3
 CHECK          = sparse
 BASH           = bash
@@ -508,7 +507,7 @@ CLANG_FLAGS :=
 
 export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
-export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
+export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
 export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
 export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
 
@@ -812,10 +811,12 @@ KBUILD_CFLAGS     += -ftrivial-auto-var-init=zero
 KBUILD_CFLAGS  += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
 endif
 
+DEBUG_CFLAGS   :=
+
 # Workaround for GCC versions < 5.0
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
 ifdef CONFIG_CC_IS_GCC
-DEBUG_CFLAGS   := $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
+DEBUG_CFLAGS   += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
 endif
 
 ifdef CONFIG_DEBUG_INFO
@@ -948,12 +949,6 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 # change __FILE__ to the relative path from the srctree
 KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
 
-# ensure -fcf-protection is disabled when using retpoline as it is
-# incompatible with -mindirect-branch=thunk-extern
-ifdef CONFIG_RETPOLINE
-KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
-endif
-
 # include additional Makefiles when needed
 include-y                      := scripts/Makefile.extrawarn
 include-$(CONFIG_KASAN)                += scripts/Makefile.kasan
diff --git a/arch/arm/include/asm/kexec-internal.h b/arch/arm/include/asm/kexec-internal.h
new file mode 100644 (file)
index 0000000..ecc2322
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ARM_KEXEC_INTERNAL_H
+#define _ARM_KEXEC_INTERNAL_H
+
+struct kexec_relocate_data {
+       unsigned long kexec_start_address;
+       unsigned long kexec_indirection_page;
+       unsigned long kexec_mach_type;
+       unsigned long kexec_r2;
+};
+
+#endif
index 98daa7f483148bf5a972743dc4d569446fb3e023..7454480d084b2ec63a9ee0547eb94fa1aec56bd7 100644 (file)
 
                .align
 99:            .word   .
+#if defined(ZIMAGE)
+               .word   . + 4
+/*
+ * Storage for the state maintained by the macro.
+ *
+ * In the kernel proper, this data is located in arch/arm/mach-tegra/tegra.c.
+ * That's because this header is included from multiple files, and we only
+ * want a single copy of the data. In particular, the UART probing code above
+ * assumes it's running using physical addresses. This is true when this file
+ * is included from head.o, but not when included from debug.o. So we need
+ * to share the probe results between the two copies, rather than having
+ * to re-run the probing again later.
+ *
+ * In the decompressor, we put the storage right here, since common.c
+ * isn't included in the decompressor build. This storage data gets put in
+ * .text even though it's really data, since .data is discarded from the
+ * decompressor. Luckily, .text is writeable in the decompressor, unless
+ * CONFIG_ZBOOT_ROM. That dependency is handled in arch/arm/Kconfig.debug.
+ */
+               /* Debug UART initialization required */
+               .word   1
+               /* Debug UART physical address */
+               .word   0
+               /* Debug UART virtual address */
+               .word   0
+#else
                .word   tegra_uart_config
+#endif
                .ltorg
 
                /* Load previously selected UART address */
 
                .macro  waituarttxrdy,rd,rx
                .endm
-
-/*
- * Storage for the state maintained by the macros above.
- *
- * In the kernel proper, this data is located in arch/arm/mach-tegra/tegra.c.
- * That's because this header is included from multiple files, and we only
- * want a single copy of the data. In particular, the UART probing code above
- * assumes it's running using physical addresses. This is true when this file
- * is included from head.o, but not when included from debug.o. So we need
- * to share the probe results between the two copies, rather than having
- * to re-run the probing again later.
- *
- * In the decompressor, we put the symbol/storage right here, since common.c
- * isn't included in the decompressor build. This symbol gets put in .text
- * even though it's really data, since .data is discarded from the
- * decompressor. Luckily, .text is writeable in the decompressor, unless
- * CONFIG_ZBOOT_ROM. That dependency is handled in arch/arm/Kconfig.debug.
- */
-#if defined(ZIMAGE)
-tegra_uart_config:
-       /* Debug UART initialization required */
-       .word 1
-       /* Debug UART physical address */
-       .word 0
-       /* Debug UART virtual address */
-       .word 0
-#endif
index a1570c8bab25acd9bdbfbc7f26db705fa923f873..be8050b0c3dfbfb3e2d9e70705e014a0ec7ff915 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
 #include <asm/cacheflush.h>
+#include <asm/kexec-internal.h>
 #include <asm/glue-df.h>
 #include <asm/glue-pf.h>
 #include <asm/mach/arch.h>
@@ -170,5 +171,9 @@ int main(void)
   DEFINE(MPU_RGN_PRBAR,        offsetof(struct mpu_rgn, prbar));
   DEFINE(MPU_RGN_PRLAR,        offsetof(struct mpu_rgn, prlar));
 #endif
+  DEFINE(KEXEC_START_ADDR,     offsetof(struct kexec_relocate_data, kexec_start_address));
+  DEFINE(KEXEC_INDIR_PAGE,     offsetof(struct kexec_relocate_data, kexec_indirection_page));
+  DEFINE(KEXEC_MACH_TYPE,      offsetof(struct kexec_relocate_data, kexec_mach_type));
+  DEFINE(KEXEC_R2,             offsetof(struct kexec_relocate_data, kexec_r2));
   return 0; 
 }
index 5d84ad333f050aa6cd85446cedc3613a873d5e82..2b09dad7935eb4ed3496f77be46b5748bfdd7cc4 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/of_fdt.h>
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
+#include <asm/kexec-internal.h>
 #include <asm/fncpy.h>
 #include <asm/mach-types.h>
 #include <asm/smp_plat.h>
 extern void relocate_new_kernel(void);
 extern const unsigned int relocate_new_kernel_size;
 
-extern unsigned long kexec_start_address;
-extern unsigned long kexec_indirection_page;
-extern unsigned long kexec_mach_type;
-extern unsigned long kexec_boot_atags;
-
 static atomic_t waiting_for_crash_ipi;
 
 /*
@@ -159,6 +155,7 @@ void (*kexec_reinit)(void);
 void machine_kexec(struct kimage *image)
 {
        unsigned long page_list, reboot_entry_phys;
+       struct kexec_relocate_data *data;
        void (*reboot_entry)(void);
        void *reboot_code_buffer;
 
@@ -174,18 +171,17 @@ void machine_kexec(struct kimage *image)
 
        reboot_code_buffer = page_address(image->control_code_page);
 
-       /* Prepare parameters for reboot_code_buffer*/
-       set_kernel_text_rw();
-       kexec_start_address = image->start;
-       kexec_indirection_page = page_list;
-       kexec_mach_type = machine_arch_type;
-       kexec_boot_atags = image->arch.kernel_r2;
-
        /* copy our kernel relocation code to the control code page */
        reboot_entry = fncpy(reboot_code_buffer,
                             &relocate_new_kernel,
                             relocate_new_kernel_size);
 
+       data = reboot_code_buffer + relocate_new_kernel_size;
+       data->kexec_start_address = image->start;
+       data->kexec_indirection_page = page_list;
+       data->kexec_mach_type = machine_arch_type;
+       data->kexec_r2 = image->arch.kernel_r2;
+
        /* get the identity mapping physical address for the reboot code */
        reboot_entry_phys = virt_to_idmap(reboot_entry);
 
index 72a08786e16eb0bbc172e144e9300c75a6b6f988..218d524360fcd3f3a752fd3168665d20e4507a2f 100644 (file)
@@ -5,14 +5,16 @@
 
 #include <linux/linkage.h>
 #include <asm/assembler.h>
+#include <asm/asm-offsets.h>
 #include <asm/kexec.h>
 
        .align  3       /* not needed for this code, but keeps fncpy() happy */
 
 ENTRY(relocate_new_kernel)
 
-       ldr     r0,kexec_indirection_page
-       ldr     r1,kexec_start_address
+       adr     r7, relocate_new_kernel_end
+       ldr     r0, [r7, #KEXEC_INDIR_PAGE]
+       ldr     r1, [r7, #KEXEC_START_ADDR]
 
        /*
         * If there is no indirection page (we are doing crashdumps)
@@ -57,34 +59,16 @@ ENTRY(relocate_new_kernel)
 
 2:
        /* Jump to relocated kernel */
-       mov lr,r1
-       mov r0,#0
-       ldr r1,kexec_mach_type
-       ldr r2,kexec_boot_atags
- ARM(  ret lr  )
- THUMB(        bx lr           )
-
-       .align
-
-       .globl kexec_start_address
-kexec_start_address:
-       .long   0x0
-
-       .globl kexec_indirection_page
-kexec_indirection_page:
-       .long   0x0
-
-       .globl kexec_mach_type
-kexec_mach_type:
-       .long   0x0
-
-       /* phy addr of the atags for the new kernel */
-       .globl kexec_boot_atags
-kexec_boot_atags:
-       .long   0x0
+       mov     lr, r1
+       mov     r0, #0
+       ldr     r1, [r7, #KEXEC_MACH_TYPE]
+       ldr     r2, [r7, #KEXEC_R2]
+ ARM(  ret     lr      )
+ THUMB(        bx      lr      )
 
 ENDPROC(relocate_new_kernel)
 
+       .align  3
 relocate_new_kernel_end:
 
        .globl relocate_new_kernel_size
index 9d2e916121be4ebfc331b9771a553c66a6aa2e28..a3a38d0a4c853332102aefd01c02b0967e0ccc3f 100644 (file)
@@ -693,18 +693,20 @@ struct page *get_signal_page(void)
 
        addr = page_address(page);
 
+       /* Poison the entire page */
+       memset32(addr, __opcode_to_mem_arm(0xe7fddef1),
+                PAGE_SIZE / sizeof(u32));
+
        /* Give the signal return code some randomness */
        offset = 0x200 + (get_random_int() & 0x7fc);
        signal_return_offset = offset;
 
-       /*
-        * Copy signal return handlers into the vector page, and
-        * set sigreturn to be a pointer to these.
-        */
+       /* Copy signal return handlers into the page */
        memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
 
-       ptr = (unsigned long)addr + offset;
-       flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
+       /* Flush out all instructions in this page */
+       ptr = (unsigned long)addr;
+       flush_icache_range(ptr, ptr + PAGE_SIZE);
 
        return page;
 }
index 416462e3f5d63676fe8f00abca7aaa94c17f3e90..f9713dc561cf77447dc1ad65cce249b3ea3ca0dd 100644 (file)
@@ -65,15 +65,15 @@ dc21285_read_config(struct pci_bus *bus, unsigned int devfn, int where,
        if (addr)
                switch (size) {
                case 1:
-                       asm("ldrb       %0, [%1, %2]"
+                       asm volatile("ldrb      %0, [%1, %2]"
                                : "=r" (v) : "r" (addr), "r" (where) : "cc");
                        break;
                case 2:
-                       asm("ldrh       %0, [%1, %2]"
+                       asm volatile("ldrh      %0, [%1, %2]"
                                : "=r" (v) : "r" (addr), "r" (where) : "cc");
                        break;
                case 4:
-                       asm("ldr        %0, [%1, %2]"
+                       asm volatile("ldr       %0, [%1, %2]"
                                : "=r" (v) : "r" (addr), "r" (where) : "cc");
                        break;
                }
@@ -99,17 +99,17 @@ dc21285_write_config(struct pci_bus *bus, unsigned int devfn, int where,
        if (addr)
                switch (size) {
                case 1:
-                       asm("strb       %0, [%1, %2]"
+                       asm volatile("strb      %0, [%1, %2]"
                                : : "r" (value), "r" (addr), "r" (where)
                                : "cc");
                        break;
                case 2:
-                       asm("strh       %0, [%1, %2]"
+                       asm volatile("strh      %0, [%1, %2]"
                                : : "r" (value), "r" (addr), "r" (where)
                                : "cc");
                        break;
                case 4:
-                       asm("str        %0, [%1, %2]"
+                       asm volatile("str       %0, [%1, %2]"
                                : : "r" (value), "r" (addr), "r" (where)
                                : "cc");
                        break;
index 31b060a4404524720cf5ae05f1e21014a35de0c6..b17bf19217f1100b962bb5794c05a9214262cb54 100644 (file)
@@ -47,6 +47,8 @@ __invalid:
        b       .
 
        /*
+        * Only uses x0..x3 so as to not clobber callee-saved SMCCC registers.
+        *
         * x0: SMCCC function ID
         * x1: struct kvm_nvhe_init_params PA
         */
@@ -70,9 +72,9 @@ __do_hyp_init:
        eret
 
 1:     mov     x0, x1
-       mov     x4, lr
-       bl      ___kvm_hyp_init
-       mov     lr, x4
+       mov     x3, lr
+       bl      ___kvm_hyp_init                 // Clobbers x0..x2
+       mov     lr, x3
 
        /* Hello, World! */
        mov     x0, #SMCCC_RET_SUCCESS
@@ -82,8 +84,8 @@ SYM_CODE_END(__kvm_hyp_init)
 /*
  * Initialize the hypervisor in EL2.
  *
- * Only uses x0..x3 so as to not clobber callee-saved SMCCC registers
- * and leave x4 for the caller.
+ * Only uses x0..x2 so as to not clobber callee-saved SMCCC registers
+ * and leave x3 for the caller.
  *
  * x0: struct kvm_nvhe_init_params PA
  */
@@ -112,9 +114,9 @@ alternative_else_nop_endif
        /*
         * Set the PS bits in TCR_EL2.
         */
-       ldr     x1, [x0, #NVHE_INIT_TCR_EL2]
-       tcr_compute_pa_size x1, #TCR_EL2_PS_SHIFT, x2, x3
-       msr     tcr_el2, x1
+       ldr     x0, [x0, #NVHE_INIT_TCR_EL2]
+       tcr_compute_pa_size x0, #TCR_EL2_PS_SHIFT, x1, x2
+       msr     tcr_el2, x0
 
        isb
 
@@ -193,7 +195,7 @@ SYM_CODE_START_LOCAL(__kvm_hyp_init_cpu)
 
        /* Enable MMU, set vectors and stack. */
        mov     x0, x28
-       bl      ___kvm_hyp_init                 // Clobbers x0..x3
+       bl      ___kvm_hyp_init                 // Clobbers x0..x2
 
        /* Leave idmap. */
        mov     x0, x29
index 703b1c4f6d12355f1115f33f45c2433c6db16ab0..45d5368d6a99c895d6ac815868baf5896a31b4ff 100644 (file)
@@ -69,7 +69,7 @@ vmlinux.bin: vmlinux FORCE
        $(call if_changed,objcopy)
 
 unwcheck: vmlinux
-       -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $<
+       -$(Q)READELF=$(READELF) $(PYTHON3) $(srctree)/arch/ia64/scripts/unwcheck.py $<
 
 archclean:
 
index bfd1b671e35fcb96f5b56c332f802a00b9d5f374..9581742f0db23c21c811a0c1802044125e78b23d 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: GPL-2.0
 #
 # Usage: unwcheck.py FILE
index fe2ef598e2ead0a5f429cd30a90e0edd48e22664..79ee7750937db06bade246afd710016a6fef2f1b 100644 (file)
@@ -51,7 +51,7 @@ obj-y                         += ptrace/
 obj-$(CONFIG_PPC64)            += setup_64.o \
                                   paca.o nvram_64.o note.o syscall_64.o
 obj-$(CONFIG_COMPAT)           += sys_ppc32.o signal_32.o
-obj-$(CONFIG_VDSO32)           += vdso32/
+obj-$(CONFIG_VDSO32)           += vdso32_wrapper.o
 obj-$(CONFIG_PPC_WATCHDOG)     += watchdog.o
 obj-$(CONFIG_HAVE_HW_BREAKPOINT)       += hw_breakpoint.o
 obj-$(CONFIG_PPC_DAWR)         += dawr.o
@@ -60,7 +60,7 @@ obj-$(CONFIG_PPC_BOOK3S_64)   += cpu_setup_power.o
 obj-$(CONFIG_PPC_BOOK3S_64)    += mce.o mce_power.o
 obj-$(CONFIG_PPC_BOOK3E_64)    += exceptions-64e.o idle_book3e.o
 obj-$(CONFIG_PPC_BARRIER_NOSPEC) += security.o
-obj-$(CONFIG_PPC64)            += vdso64/
+obj-$(CONFIG_PPC64)            += vdso64_wrapper.o
 obj-$(CONFIG_ALTIVEC)          += vecemu.o
 obj-$(CONFIG_PPC_BOOK3S_IDLE)  += idle_book3s.o
 procfs-y                       := proc_powerpc.o
index 9cb6f524854b9d6f480e32f3cf346fe7d7a57071..7d9a6fee0e3dc1a01e066314721f09e732af8ae6 100644 (file)
@@ -30,7 +30,7 @@ CC32FLAGS += -m32
 KBUILD_CFLAGS := $(filter-out -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc,$(KBUILD_CFLAGS))
 endif
 
-targets := $(obj-vdso32) vdso32.so.dbg
+targets := $(obj-vdso32) vdso32.so.dbg vgettimeofday.o
 obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
 
 GCOV_PROFILE := n
@@ -46,9 +46,6 @@ obj-y += vdso32_wrapper.o
 targets += vdso32.lds
 CPPFLAGS_vdso32.lds += -P -C -Upowerpc
 
-# Force dependency (incbin is bad)
-$(obj)/vdso32_wrapper.o : $(obj)/vdso32.so.dbg
-
 # link rule for the .so file, .lds has to be first
 $(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE
        $(call if_changed,vdso32ld_and_check)
diff --git a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
deleted file mode 100644 (file)
index 3f5ef03..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#include <linux/linkage.h>
-#include <asm/page.h>
-
-       __PAGE_ALIGNED_DATA
-
-       .globl vdso32_start, vdso32_end
-       .balign PAGE_SIZE
-vdso32_start:
-       .incbin "arch/powerpc/kernel/vdso32/vdso32.so.dbg"
-       .balign PAGE_SIZE
-vdso32_end:
-
-       .previous
diff --git a/arch/powerpc/kernel/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32_wrapper.S
new file mode 100644 (file)
index 0000000..3f5ef03
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/linkage.h>
+#include <asm/page.h>
+
+       __PAGE_ALIGNED_DATA
+
+       .globl vdso32_start, vdso32_end
+       .balign PAGE_SIZE
+vdso32_start:
+       .incbin "arch/powerpc/kernel/vdso32/vdso32.so.dbg"
+       .balign PAGE_SIZE
+vdso32_end:
+
+       .previous
index bf363ff371521c65477853f89c8f4a16d3a0d3de..2813e3f98db65611e0c83ac1891fe5b30b445820 100644 (file)
@@ -17,7 +17,7 @@ endif
 
 # Build rules
 
-targets := $(obj-vdso64) vdso64.so.dbg
+targets := $(obj-vdso64) vdso64.so.dbg vgettimeofday.o
 obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
 
 GCOV_PROFILE := n
@@ -29,15 +29,9 @@ ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
        -Wl,-soname=linux-vdso64.so.1 -Wl,--hash-style=both
 asflags-y := -D__VDSO64__ -s
 
-obj-y += vdso64_wrapper.o
 targets += vdso64.lds
 CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)
 
-$(obj)/vgettimeofday.o: %.o: %.c FORCE
-
-# Force dependency (incbin is bad)
-$(obj)/vdso64_wrapper.o : $(obj)/vdso64.so.dbg
-
 # link rule for the .so file, .lds has to be first
 $(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday.o FORCE
        $(call if_changed,vdso64ld_and_check)
index bbf68cd01088b5ab04092c099c922709c44eef1f..2d4067561293ea76645e57ba5748819992108ad8 100644 (file)
 
        .text
 
+/*
+ * __kernel_start_sigtramp_rt64 and __kernel_sigtramp_rt64 together
+ * are one function split in two parts. The kernel jumps to the former
+ * and the signal handler indirectly (by blr) returns to the latter.
+ * __kernel_sigtramp_rt64 needs to point to the return address so
+ * glibc can correctly identify the trampoline stack frame.
+ */
        .balign 8
        .balign IFETCH_ALIGN_BYTES
-V_FUNCTION_BEGIN(__kernel_sigtramp_rt64)
+V_FUNCTION_BEGIN(__kernel_start_sigtramp_rt64)
 .Lsigrt_start:
        bctrl   /* call the handler */
+V_FUNCTION_END(__kernel_start_sigtramp_rt64)
+V_FUNCTION_BEGIN(__kernel_sigtramp_rt64)
        addi    r1, r1, __SIGNAL_FRAMESIZE
        li      r0,__NR_rt_sigreturn
        sc
index 6164d1a1ba11b7d8d0a303411cd9519b41089c60..2f3c359cacd3a850a373141f37a46a9238fbd58d 100644 (file)
@@ -131,4 +131,4 @@ VERSION
 /*
  * Make the sigreturn code visible to the kernel.
  */
-VDSO_sigtramp_rt64     = __kernel_sigtramp_rt64;
+VDSO_sigtramp_rt64     = __kernel_start_sigtramp_rt64;
diff --git a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
deleted file mode 100644 (file)
index 1d56d81..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#include <linux/linkage.h>
-#include <asm/page.h>
-
-       __PAGE_ALIGNED_DATA
-
-       .globl vdso64_start, vdso64_end
-       .balign PAGE_SIZE
-vdso64_start:
-       .incbin "arch/powerpc/kernel/vdso64/vdso64.so.dbg"
-       .balign PAGE_SIZE
-vdso64_end:
-
-       .previous
diff --git a/arch/powerpc/kernel/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64_wrapper.S
new file mode 100644 (file)
index 0000000..1d56d81
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/linkage.h>
+#include <asm/page.h>
+
+       __PAGE_ALIGNED_DATA
+
+       .globl vdso64_start, vdso64_end
+       .balign PAGE_SIZE
+vdso64_start:
+       .incbin "arch/powerpc/kernel/vdso64/vdso64.so.dbg"
+       .balign PAGE_SIZE
+vdso64_end:
+
+       .previous
index bf7a7d62ae8b5d5bb367926ebb3dd120ff76a4b7..ede093e9623472f1f9652d98843ef9f48fcc7aaa 100644 (file)
@@ -818,13 +818,15 @@ void emulate_vsx_store(struct instruction_op *op, const union vsx_reg *reg,
                        break;
                if (rev) {
                        /* reverse 32 bytes */
-                       buf.d[0] = byterev_8(reg->d[3]);
-                       buf.d[1] = byterev_8(reg->d[2]);
-                       buf.d[2] = byterev_8(reg->d[1]);
-                       buf.d[3] = byterev_8(reg->d[0]);
-                       reg = &buf;
+                       union vsx_reg buf32[2];
+                       buf32[0].d[0] = byterev_8(reg[1].d[1]);
+                       buf32[0].d[1] = byterev_8(reg[1].d[0]);
+                       buf32[1].d[0] = byterev_8(reg[0].d[1]);
+                       buf32[1].d[1] = byterev_8(reg[0].d[0]);
+                       memcpy(mem, buf32, size);
+               } else {
+                       memcpy(mem, reg, size);
                }
-               memcpy(mem, reg, size);
                break;
        case 16:
                /* stxv, stxvx, stxvl, stxvll */
index e9e2c1f0a690594389a2d034a56f59f8a376a89f..e0a34eb5ed3b37a199d44fd661a4dabd57be603b 100644 (file)
@@ -252,8 +252,10 @@ choice
        default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
 
        config MAXPHYSMEM_1GB
+               depends on 32BIT
                bool "1GiB"
        config MAXPHYSMEM_2GB
+               depends on 64BIT && CMODEL_MEDLOW
                bool "2GiB"
        config MAXPHYSMEM_128GB
                depends on 64BIT && CMODEL_MEDANY
index 2d50f76efe4819ffa8645ac1aa1d1c7473fe400f..64a675c5c30acb2c9806645ba9f3f5e7297cef21 100644 (file)
@@ -135,7 +135,10 @@ extern phys_addr_t __phys_addr_symbol(unsigned long x);
 
 #endif /* __ASSEMBLY__ */
 
-#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
+#define virt_addr_valid(vaddr) ({                                              \
+       unsigned long _addr = (unsigned long)vaddr;                             \
+       (unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \
+})
 
 #define VM_DATA_DEFAULT_FLAGS  VM_DATA_FLAGS_NON_EXEC
 
index 211eb8244a454bd4038e6a9867643d4232b3fd4e..8b80c80c7f1acad9d9e1b3cb29d28a005fd83cd3 100644 (file)
@@ -32,14 +32,14 @@ bool kernel_page_present(struct page *page);
 
 #endif /* __ASSEMBLY__ */
 
-#ifdef CONFIG_ARCH_HAS_STRICT_KERNEL_RWX
+#ifdef CONFIG_STRICT_KERNEL_RWX
 #ifdef CONFIG_64BIT
 #define SECTION_ALIGN (1 << 21)
 #else
 #define SECTION_ALIGN (1 << 22)
 #endif
-#else /* !CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */
+#else /* !CONFIG_STRICT_KERNEL_RWX */
 #define SECTION_ALIGN L1_CACHE_BYTES
-#endif /* CONFIG_ARCH_HAS_STRICT_KERNEL_RWX */
+#endif /* CONFIG_STRICT_KERNEL_RWX */
 
 #endif /* _ASM_RISCV_SET_MEMORY_H */
index 3fa3f26dde85664a6ccd993d9ee3bdcdf118eee3..c7c0655dd45b0f617a34d89b315e5829638c43af 100644 (file)
@@ -293,6 +293,8 @@ void free_initmem(void)
        unsigned long init_begin = (unsigned long)__init_begin;
        unsigned long init_end = (unsigned long)__init_end;
 
-       set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
+       if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
+               set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
+
        free_initmem_default(POISON_FREE_INITMEM);
 }
index 7116da3980be4546e459707035a35121db8137ca..5857917f83eee9082bd09c2faa3aecd9e01537d5 100644 (file)
@@ -120,6 +120,9 @@ else
 
         KBUILD_CFLAGS += -mno-red-zone
         KBUILD_CFLAGS += -mcmodel=kernel
+
+       # Intel CET isn't enabled in the kernel
+       KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
 endif
 
 ifdef CONFIG_X86_X32
index 34cb3c159481b7327bf5ec9c3f97c1053627c067..412b51e059c80674977968d0f3d1cece99075a2b 100644 (file)
@@ -197,16 +197,6 @@ static inline bool apic_needs_pit(void) { return true; }
 #endif /* !CONFIG_X86_LOCAL_APIC */
 
 #ifdef CONFIG_X86_X2APIC
-/*
- * Make previous memory operations globally visible before
- * sending the IPI through x2apic wrmsr. We need a serializing instruction or
- * mfence for this.
- */
-static inline void x2apic_wrmsr_fence(void)
-{
-       asm volatile("mfence" : : : "memory");
-}
-
 static inline void native_apic_msr_write(u32 reg, u32 v)
 {
        if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
index 7f828fe497978e3132a2c6d87786d02029719fd2..4819d5e5a3353d7db2fa314f9665a6cd07db741a 100644 (file)
@@ -84,4 +84,22 @@ do {                                                                 \
 
 #include <asm-generic/barrier.h>
 
+/*
+ * Make previous memory operations globally visible before
+ * a WRMSR.
+ *
+ * MFENCE makes writes visible, but only affects load/store
+ * instructions.  WRMSR is unfortunately not a load/store
+ * instruction and is unaffected by MFENCE.  The LFENCE ensures
+ * that the WRMSR is not reordered.
+ *
+ * Most WRMSRs are full serializing instructions themselves and
+ * do not require this barrier.  This is only required for the
+ * IA32_TSC_DEADLINE and X2APIC MSRs.
+ */
+static inline void weak_wrmsr_fence(void)
+{
+       asm volatile("mfence; lfence" : : : "memory");
+}
+
 #endif /* _ASM_X86_BARRIER_H */
index 6fe54b2813c13960786595db35b7b1f2b0c0dba1..2b87b191b3b8470cf80ad8d5004a7baf4ab4d6da 100644 (file)
@@ -43,8 +43,6 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs)
 }
 #define arch_check_user_regs arch_check_user_regs
 
-#define ARCH_SYSCALL_EXIT_WORK         (_TIF_SINGLESTEP)
-
 static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
                                                  unsigned long ti_work)
 {
index 6bd20c0de8bc605c9f9d82a1c76060e71b13d3fa..7f4c081f59f0cd1caf461c4a8e329c248656a7f9 100644 (file)
@@ -41,6 +41,7 @@
 #include <asm/perf_event.h>
 #include <asm/x86_init.h>
 #include <linux/atomic.h>
+#include <asm/barrier.h>
 #include <asm/mpspec.h>
 #include <asm/i8259.h>
 #include <asm/proto.h>
@@ -477,6 +478,9 @@ static int lapic_next_deadline(unsigned long delta,
 {
        u64 tsc;
 
+       /* This MSR is special and need a special fence: */
+       weak_wrmsr_fence();
+
        tsc = rdtsc();
        wrmsrl(MSR_IA32_TSC_DEADLINE, tsc + (((u64) delta) * TSC_DIVISOR));
        return 0;
index df6adc5674c986df5f5c99d004e7a0e4a9993588..f4da9bb69a8859ff10824315388aeb49c2ccfad9 100644 (file)
@@ -29,7 +29,8 @@ static void x2apic_send_IPI(int cpu, int vector)
 {
        u32 dest = per_cpu(x86_cpu_to_logical_apicid, cpu);
 
-       x2apic_wrmsr_fence();
+       /* x2apic MSRs are special and need a special fence: */
+       weak_wrmsr_fence();
        __x2apic_send_IPI_dest(dest, vector, APIC_DEST_LOGICAL);
 }
 
@@ -41,7 +42,8 @@ __x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
        unsigned long flags;
        u32 dest;
 
-       x2apic_wrmsr_fence();
+       /* x2apic MSRs are special and need a special fence: */
+       weak_wrmsr_fence();
        local_irq_save(flags);
 
        tmpmsk = this_cpu_cpumask_var_ptr(ipi_mask);
index 0e4e81971567b43c97320dfcd78c758daeadec04..6bde05a86b4edde5b0ea91b4f088424a97c4a216 100644 (file)
@@ -43,7 +43,8 @@ static void x2apic_send_IPI(int cpu, int vector)
 {
        u32 dest = per_cpu(x86_cpu_to_apicid, cpu);
 
-       x2apic_wrmsr_fence();
+       /* x2apic MSRs are special and need a special fence: */
+       weak_wrmsr_fence();
        __x2apic_send_IPI_dest(dest, vector, APIC_DEST_PHYSICAL);
 }
 
@@ -54,7 +55,8 @@ __x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
        unsigned long this_cpu;
        unsigned long flags;
 
-       x2apic_wrmsr_fence();
+       /* x2apic MSRs are special and need a special fence: */
+       weak_wrmsr_fence();
 
        local_irq_save(flags);
 
@@ -125,7 +127,8 @@ void __x2apic_send_IPI_shorthand(int vector, u32 which)
 {
        unsigned long cfg = __prepare_ICR(which, vector, 0);
 
-       x2apic_wrmsr_fence();
+       /* x2apic MSRs are special and need a special fence: */
+       weak_wrmsr_fence();
        native_x2apic_icr_write(cfg, 0);
 }
 
index 59a1e3ce3f145cc7b7115431dd7c025cf6d55498..816fdbec795a47333a67188252c2e3c496e3b9bc 100644 (file)
@@ -1159,6 +1159,7 @@ static const struct x86_cpu_id split_lock_cpu_ids[] __initconst = {
        X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE,           1),
        X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X,    1),
        X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE,           1),
+       X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE_L,         1),
        {}
 };
 
index 03aa33b5816586959a77235f13ec1ecaefdcb74b..668a4a6533d923c7eddef457f3f2ebac0040a00b 100644 (file)
@@ -269,6 +269,20 @@ static inline bool within_cpu_entry(unsigned long addr, unsigned long end)
                        CPU_ENTRY_AREA_TOTAL_SIZE))
                return true;
 
+       /*
+        * When FSGSBASE is enabled, paranoid_entry() fetches the per-CPU
+        * GSBASE value via __per_cpu_offset or pcpu_unit_offsets.
+        */
+#ifdef CONFIG_SMP
+       if (within_area(addr, end, (unsigned long)__per_cpu_offset,
+                       sizeof(unsigned long) * nr_cpu_ids))
+               return true;
+#else
+       if (within_area(addr, end, (unsigned long)&pcpu_unit_offsets,
+                       sizeof(pcpu_unit_offsets)))
+               return true;
+#endif
+
        for_each_possible_cpu(cpu) {
                /* The original rw GDT is being used after load_direct_gdt() */
                if (within_area(addr, end, (unsigned long)get_cpu_gdt_rw(cpu),
@@ -293,6 +307,14 @@ static inline bool within_cpu_entry(unsigned long addr, unsigned long end)
                                (unsigned long)&per_cpu(cpu_tlbstate, cpu),
                                sizeof(struct tlb_state)))
                        return true;
+
+               /*
+                * When in guest (X86_FEATURE_HYPERVISOR), local_db_save()
+                * will read per-cpu cpu_dr7 before clear dr7 register.
+                */
+               if (within_area(addr, end, (unsigned long)&per_cpu(cpu_dr7, cpu),
+                               sizeof(cpu_dr7)))
+                       return true;
        }
 
        return false;
@@ -491,15 +513,12 @@ static int hw_breakpoint_handler(struct die_args *args)
        struct perf_event *bp;
        unsigned long *dr6_p;
        unsigned long dr6;
+       bool bpx;
 
        /* The DR6 value is pointed by args->err */
        dr6_p = (unsigned long *)ERR_PTR(args->err);
        dr6 = *dr6_p;
 
-       /* If it's a single step, TRAP bits are random */
-       if (dr6 & DR_STEP)
-               return NOTIFY_DONE;
-
        /* Do an early return if no trap bits are set in DR6 */
        if ((dr6 & DR_TRAP_BITS) == 0)
                return NOTIFY_DONE;
@@ -509,28 +528,29 @@ static int hw_breakpoint_handler(struct die_args *args)
                if (likely(!(dr6 & (DR_TRAP0 << i))))
                        continue;
 
+               bp = this_cpu_read(bp_per_reg[i]);
+               if (!bp)
+                       continue;
+
+               bpx = bp->hw.info.type == X86_BREAKPOINT_EXECUTE;
+
                /*
-                * The counter may be concurrently released but that can only
-                * occur from a call_rcu() path. We can then safely fetch
-                * the breakpoint, use its callback, touch its counter
-                * while we are in an rcu_read_lock() path.
+                * TF and data breakpoints are traps and can be merged, however
+                * instruction breakpoints are faults and will be raised
+                * separately.
+                *
+                * However DR6 can indicate both TF and instruction
+                * breakpoints. In that case take TF as that has precedence and
+                * delay the instruction breakpoint for the next exception.
                 */
-               rcu_read_lock();
+               if (bpx && (dr6 & DR_STEP))
+                       continue;
 
-               bp = this_cpu_read(bp_per_reg[i]);
                /*
                 * Reset the 'i'th TRAP bit in dr6 to denote completion of
                 * exception handling
                 */
                (*dr6_p) &= ~(DR_TRAP0 << i);
-               /*
-                * bp can be NULL due to lazy debug register switching
-                * or due to concurrent perf counter removing.
-                */
-               if (!bp) {
-                       rcu_read_unlock();
-                       break;
-               }
 
                perf_bp_event(bp, args->regs);
 
@@ -538,11 +558,10 @@ static int hw_breakpoint_handler(struct die_args *args)
                 * Set up resume flag to avoid breakpoint recursion when
                 * returning back to origin.
                 */
-               if (bp->hw.info.type == X86_BREAKPOINT_EXECUTE)
+               if (bpx)
                        args->regs->flags |= X86_EFLAGS_RF;
-
-               rcu_read_unlock();
        }
+
        /*
         * Further processing in do_debug() is needed for a) user-space
         * breakpoints (to generate signals) and b) when the system has
index 60d2c3798ba28ffe902151e27541958a99d71b24..0f3c307b37b3af40745996489ee207fd2a733e01 100644 (file)
@@ -127,12 +127,17 @@ static int enable_single_step(struct task_struct *child)
                regs->flags |= X86_EFLAGS_TF;
 
        /*
-        * Always set TIF_SINGLESTEP - this guarantees that
-        * we single-step system calls etc..  This will also
+        * Always set TIF_SINGLESTEP.  This will also
         * cause us to set TF when returning to user mode.
         */
        set_tsk_thread_flag(child, TIF_SINGLESTEP);
 
+       /*
+        * Ensure that a trap is triggered once stepping out of a system
+        * call prior to executing any user instruction.
+        */
+       set_task_syscall_work(child, SYSCALL_EXIT_TRAP);
+
        oflags = regs->flags;
 
        /* Set TF on the kernel stack.. */
@@ -230,6 +235,7 @@ void user_disable_single_step(struct task_struct *child)
 
        /* Always clear TIF_SINGLESTEP... */
        clear_tsk_thread_flag(child, TIF_SINGLESTEP);
+       clear_task_syscall_work(child, SYSCALL_EXIT_TRAP);
 
        /* But touch TF only if it was set by us.. */
        if (test_and_clear_tsk_thread_flag(child, TIF_FORCED_TF))
index 13036cf0b9124587002b4bf50a1796f6171539d6..38172ca627d36d2199fdfc64d7fa41ebba2f0e07 100644 (file)
@@ -321,7 +321,7 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
        if (cpuid->nent < vcpu->arch.cpuid_nent)
                goto out;
        r = -EFAULT;
-       if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
+       if (copy_to_user(entries, vcpu->arch.cpuid_entries,
                         vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
                goto out;
        return 0;
index 56cae1ff9e3fe46362947f0911b39573d44397a8..66a08322988f223a179edb33cf97c190c6136a54 100644 (file)
@@ -2879,6 +2879,8 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
        ops->get_msr(ctxt, MSR_IA32_SYSENTER_ESP, &msr_data);
        *reg_write(ctxt, VCPU_REGS_RSP) = (efer & EFER_LMA) ? msr_data :
                                                              (u32)msr_data;
+       if (efer & EFER_LMA)
+               ctxt->mode = X86EMUL_MODE_PROT64;
 
        return X86EMUL_CONTINUE;
 }
index 2ef8615f9dba87bca72d4912df6e4cd9394def56..b56d604809b8afdf2d7080e4cf471ed649e675d7 100644 (file)
@@ -1049,8 +1049,8 @@ bool kvm_tdp_mmu_slot_set_dirty(struct kvm *kvm, struct kvm_memory_slot *slot)
 }
 
 /*
- * Clear non-leaf entries (and free associated page tables) which could
- * be replaced by large mappings, for GFNs within the slot.
+ * Clear leaf entries which could be replaced by large mappings, for
+ * GFNs within the slot.
  */
 static void zap_collapsible_spte_range(struct kvm *kvm,
                                       struct kvm_mmu_page *root,
@@ -1062,7 +1062,7 @@ static void zap_collapsible_spte_range(struct kvm *kvm,
 
        tdp_root_for_each_pte(iter, root, start, end) {
                if (!is_shadow_present_pte(iter.old_spte) ||
-                   is_last_spte(iter.old_spte, iter.level))
+                   !is_last_spte(iter.old_spte, iter.level))
                        continue;
 
                pfn = spte_to_pfn(iter.old_spte);
index 7a605ad8254db19835860e3c5372b52f69c4fc8a..db30670dd8c4a8ccf2ca611f513e056a0480e696 100644 (file)
@@ -231,6 +231,7 @@ static bool nested_vmcb_check_controls(struct vmcb_control_area *control)
 
 static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12)
 {
+       struct kvm_vcpu *vcpu = &svm->vcpu;
        bool vmcb12_lma;
 
        if ((vmcb12->save.efer & EFER_SVME) == 0)
@@ -244,18 +245,10 @@ static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12)
 
        vmcb12_lma = (vmcb12->save.efer & EFER_LME) && (vmcb12->save.cr0 & X86_CR0_PG);
 
-       if (!vmcb12_lma) {
-               if (vmcb12->save.cr4 & X86_CR4_PAE) {
-                       if (vmcb12->save.cr3 & MSR_CR3_LEGACY_PAE_RESERVED_MASK)
-                               return false;
-               } else {
-                       if (vmcb12->save.cr3 & MSR_CR3_LEGACY_RESERVED_MASK)
-                               return false;
-               }
-       } else {
+       if (vmcb12_lma) {
                if (!(vmcb12->save.cr4 & X86_CR4_PAE) ||
                    !(vmcb12->save.cr0 & X86_CR0_PE) ||
-                   (vmcb12->save.cr3 & MSR_CR3_LONG_MBZ_MASK))
+                   (vmcb12->save.cr3 & vcpu->arch.cr3_lm_rsvd_bits))
                        return false;
        }
        if (!kvm_is_valid_cr4(&svm->vcpu, vmcb12->save.cr4))
index ac652bc476ae7ec7df0d45a7f234d48076549db8..48017fef1cd9ccd0fff5c207031da4f6bf12588f 100644 (file)
@@ -342,6 +342,8 @@ static struct page **sev_pin_memory(struct kvm *kvm, unsigned long uaddr,
        unsigned long first, last;
        int ret;
 
+       lockdep_assert_held(&kvm->lock);
+
        if (ulen == 0 || uaddr + ulen < uaddr)
                return ERR_PTR(-EINVAL);
 
@@ -1119,12 +1121,20 @@ int svm_register_enc_region(struct kvm *kvm,
        if (!region)
                return -ENOMEM;
 
+       mutex_lock(&kvm->lock);
        region->pages = sev_pin_memory(kvm, range->addr, range->size, &region->npages, 1);
        if (IS_ERR(region->pages)) {
                ret = PTR_ERR(region->pages);
+               mutex_unlock(&kvm->lock);
                goto e_free;
        }
 
+       region->uaddr = range->addr;
+       region->size = range->size;
+
+       list_add_tail(&region->list, &sev->regions_list);
+       mutex_unlock(&kvm->lock);
+
        /*
         * The guest may change the memory encryption attribute from C=0 -> C=1
         * or vice versa for this memory range. Lets make sure caches are
@@ -1133,13 +1143,6 @@ int svm_register_enc_region(struct kvm *kvm,
         */
        sev_clflush_pages(region->pages, region->npages);
 
-       region->uaddr = range->addr;
-       region->size = range->size;
-
-       mutex_lock(&kvm->lock);
-       list_add_tail(&region->list, &sev->regions_list);
-       mutex_unlock(&kvm->lock);
-
        return ret;
 
 e_free:
index f923e14e87df2e12a97af016b2e3c72aa92eac16..3442d44ca53b854ca978185a351ef078d416ce80 100644 (file)
@@ -454,6 +454,11 @@ static int has_svm(void)
                return 0;
        }
 
+       if (sev_active()) {
+               pr_info("KVM is unsupported when running as an SEV guest\n");
+               return 0;
+       }
+
        return 1;
 }
 
index 0fe874ae54982e146ee4ffda756ac80470d73bcb..6e7d070f8b86d17b89e941b175e2d944f9f5978a 100644 (file)
@@ -403,9 +403,6 @@ static inline bool gif_set(struct vcpu_svm *svm)
 }
 
 /* svm.c */
-#define MSR_CR3_LEGACY_RESERVED_MASK           0xfe7U
-#define MSR_CR3_LEGACY_PAE_RESERVED_MASK       0x7U
-#define MSR_CR3_LONG_MBZ_MASK                  0xfff0000000000000U
 #define MSR_INVALID                            0xffffffffU
 
 extern int sev;
index cc60b1fc3ee71c7fd81e28a4cc9f7294048ea0b5..eb69fef57485d61b846ba321ef9a34ec056617f8 100644 (file)
@@ -6860,11 +6860,20 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
                switch (index) {
                case MSR_IA32_TSX_CTRL:
                        /*
-                        * No need to pass TSX_CTRL_CPUID_CLEAR through, so
-                        * let's avoid changing CPUID bits under the host
-                        * kernel's feet.
+                        * TSX_CTRL_CPUID_CLEAR is handled in the CPUID
+                        * interception.  Keep the host value unchanged to avoid
+                        * changing CPUID bits under the host kernel's feet.
+                        *
+                        * hle=0, rtm=0, tsx_ctrl=1 can be found with some
+                        * combinations of new kernel and old userspace.  If
+                        * those guests run on a tsx=off host, do allow guests
+                        * to use TSX_CTRL, but do not change the value on the
+                        * host so that TSX remains always disabled.
                         */
-                       vmx->guest_uret_msrs[j].mask = ~(u64)TSX_CTRL_CPUID_CLEAR;
+                       if (boot_cpu_has(X86_FEATURE_RTM))
+                               vmx->guest_uret_msrs[j].mask = ~(u64)TSX_CTRL_CPUID_CLEAR;
+                       else
+                               vmx->guest_uret_msrs[j].mask = 0;
                        break;
                default:
                        vmx->guest_uret_msrs[j].mask = -1ull;
index 76bce832cade251d6818d4899055252697213683..1b404e4d7dd8e0441c436811b42ec1b62a048855 100644 (file)
@@ -1394,16 +1394,24 @@ static u64 kvm_get_arch_capabilities(void)
        if (!boot_cpu_has_bug(X86_BUG_MDS))
                data |= ARCH_CAP_MDS_NO;
 
-       /*
-        * On TAA affected systems:
-        *      - nothing to do if TSX is disabled on the host.
-        *      - we emulate TSX_CTRL if present on the host.
-        *        This lets the guest use VERW to clear CPU buffers.
-        */
-       if (!boot_cpu_has(X86_FEATURE_RTM))
-               data &= ~(ARCH_CAP_TAA_NO | ARCH_CAP_TSX_CTRL_MSR);
-       else if (!boot_cpu_has_bug(X86_BUG_TAA))
+       if (!boot_cpu_has(X86_FEATURE_RTM)) {
+               /*
+                * If RTM=0 because the kernel has disabled TSX, the host might
+                * have TAA_NO or TSX_CTRL.  Clear TAA_NO (the guest sees RTM=0
+                * and therefore knows that there cannot be TAA) but keep
+                * TSX_CTRL: some buggy userspaces leave it set on tsx=on hosts,
+                * and we want to allow migrating those guests to tsx=off hosts.
+                */
+               data &= ~ARCH_CAP_TAA_NO;
+       } else if (!boot_cpu_has_bug(X86_BUG_TAA)) {
                data |= ARCH_CAP_TAA_NO;
+       } else {
+               /*
+                * Nothing to do here; we emulate TSX_CTRL if present on the
+                * host so the guest can choose between disabling TSX or
+                * using VERW to clear CPU buffers.
+                */
+       }
 
        return data;
 }
@@ -9616,6 +9624,8 @@ static bool kvm_is_valid_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
                 */
                if (!(sregs->cr4 & X86_CR4_PAE) || !(sregs->efer & EFER_LMA))
                        return false;
+               if (sregs->cr3 & vcpu->arch.cr3_lm_rsvd_bits)
+                       return false;
        } else {
                /*
                 * Not in 64-bit mode: EFER.LMA is clear and the code
@@ -9993,6 +10003,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
        fx_init(vcpu);
 
        vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu);
+       vcpu->arch.cr3_lm_rsvd_bits = rsvd_bits(cpuid_maxphyaddr(vcpu), 63);
 
        vcpu->arch.pat = MSR_IA32_CR_PAT_DEFAULT;
 
@@ -10494,7 +10505,7 @@ void __user * __x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
                        return 0;
 
                old_npages = slot->npages;
-               hva = 0;
+               hva = slot->userspace_addr;
        }
 
        for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
index c5ee0f5ce0f13e236c43cbd4886ef39f3a67c855..0f727b50bd3d2dcabbcf3d661b9b6aefe02e924a 100644 (file)
@@ -425,6 +425,8 @@ bool kvm_msr_allowed(struct kvm_vcpu *vcpu, u32 index, u32 type);
                __reserved_bits |= X86_CR4_UMIP;        \
        if (!__cpu_has(__c, X86_FEATURE_VMX))           \
                __reserved_bits |= X86_CR4_VMXE;        \
+       if (!__cpu_has(__c, X86_FEATURE_PCID))          \
+               __reserved_bits |= X86_CR4_PCIDE;       \
        __reserved_bits;                                \
 })
 
index c79e5736ab2b7ebf43182e773c9c35457edcf366..c3d5f0236f353cd42159ab487163d5bc511df95b 100644 (file)
@@ -382,6 +382,7 @@ bool sev_active(void)
 {
        return sev_status & MSR_AMD64_SEV_ENABLED;
 }
+EXPORT_SYMBOL_GPL(sev_active);
 
 /* Needs to be called from non-instrumentable code */
 bool noinstr sev_es_active(void)
index e1e8d4e3a213930a38d738b47305dc5c8ba2e736..8efd003540caef36a9d1d53be03cee70063e7ac7 100644 (file)
@@ -115,31 +115,12 @@ void efi_sync_low_kernel_mappings(void)
        pud_t *pud_k, *pud_efi;
        pgd_t *efi_pgd = efi_mm.pgd;
 
-       /*
-        * We can share all PGD entries apart from the one entry that
-        * covers the EFI runtime mapping space.
-        *
-        * Make sure the EFI runtime region mappings are guaranteed to
-        * only span a single PGD entry and that the entry also maps
-        * other important kernel regions.
-        */
-       MAYBE_BUILD_BUG_ON(pgd_index(EFI_VA_END) != pgd_index(MODULES_END));
-       MAYBE_BUILD_BUG_ON((EFI_VA_START & PGDIR_MASK) !=
-                       (EFI_VA_END & PGDIR_MASK));
-
        pgd_efi = efi_pgd + pgd_index(PAGE_OFFSET);
        pgd_k = pgd_offset_k(PAGE_OFFSET);
 
        num_entries = pgd_index(EFI_VA_END) - pgd_index(PAGE_OFFSET);
        memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries);
 
-       /*
-        * As with PGDs, we share all P4D entries apart from the one entry
-        * that covers the EFI runtime mapping space.
-        */
-       BUILD_BUG_ON(p4d_index(EFI_VA_END) != p4d_index(MODULES_END));
-       BUILD_BUG_ON((EFI_VA_START & P4D_MASK) != (EFI_VA_END & P4D_MASK));
-
        pgd_efi = efi_pgd + pgd_index(EFI_VA_END);
        pgd_k = pgd_offset_k(EFI_VA_END);
        p4d_efi = p4d_offset(pgd_efi, 0);
index 9e4eb0fc1c16e7fb2ecce1091c499de6a0878912..9e81d1052091fcbc9a71bdf6aa36bcfa50a221f7 100644 (file)
@@ -6332,13 +6332,13 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
         * limit 'something'.
         */
        /* no more than 50% of tags for async I/O */
-       bfqd->word_depths[0][0] = max(bt->sb.depth >> 1, 1U);
+       bfqd->word_depths[0][0] = max((1U << bt->sb.shift) >> 1, 1U);
        /*
         * no more than 75% of tags for sync writes (25% extra tags
         * w.r.t. async I/O, to prevent async I/O from starving sync
         * writes)
         */
-       bfqd->word_depths[0][1] = max((bt->sb.depth * 3) >> 2, 1U);
+       bfqd->word_depths[0][1] = max(((1U << bt->sb.shift) * 3) >> 2, 1U);
 
        /*
         * In-word depths in case some bfq_queue is being weight-
@@ -6348,9 +6348,9 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd,
         * shortage.
         */
        /* no more than ~18% of tags for async I/O */
-       bfqd->word_depths[1][0] = max((bt->sb.depth * 3) >> 4, 1U);
+       bfqd->word_depths[1][0] = max(((1U << bt->sb.shift) * 3) >> 4, 1U);
        /* no more than ~37% of tags for sync writes (~20% extra tags) */
-       bfqd->word_depths[1][1] = max((bt->sb.depth * 6) >> 4, 1U);
+       bfqd->word_depths[1][1] = max(((1U << bt->sb.shift) * 6) >> 4, 1U);
 
        for (i = 0; i < 2; i++)
                for (j = 0; j < 2; j++)
index 2d991da2cead7ed7386f8e7828d7a89d27e56d55..d1ed4f8df2b76d7dd41286b52426dfbde175f33f 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/sched/task.h>
 
 #include "amdgpu_object.h"
+#include "amdgpu_gem.h"
 #include "amdgpu_vm.h"
 #include "amdgpu_amdkfd.h"
 #include "amdgpu_dma_buf.h"
@@ -1152,7 +1153,7 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
        struct sg_table *sg = NULL;
        uint64_t user_addr = 0;
        struct amdgpu_bo *bo;
-       struct amdgpu_bo_param bp;
+       struct drm_gem_object *gobj;
        u32 domain, alloc_domain;
        u64 alloc_flags;
        int ret;
@@ -1220,19 +1221,14 @@ int amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu(
        pr_debug("\tcreate BO VA 0x%llx size 0x%llx domain %s\n",
                        va, size, domain_string(alloc_domain));
 
-       memset(&bp, 0, sizeof(bp));
-       bp.size = size;
-       bp.byte_align = 1;
-       bp.domain = alloc_domain;
-       bp.flags = alloc_flags;
-       bp.type = bo_type;
-       bp.resv = NULL;
-       ret = amdgpu_bo_create(adev, &bp, &bo);
+       ret = amdgpu_gem_object_create(adev, size, 1, alloc_domain, alloc_flags,
+                                      bo_type, NULL, &gobj);
        if (ret) {
                pr_debug("Failed to create BO on domain %s. ret %d\n",
-                               domain_string(alloc_domain), ret);
+                        domain_string(alloc_domain), ret);
                goto err_bo_create;
        }
+       bo = gem_to_amdgpu_bo(gobj);
        if (bo_type == ttm_bo_type_sg) {
                bo->tbo.sg = sg;
                bo->tbo.ttm->sg = sg;
index f764803c53a4bb2466485d12e0f7c75099bf0e41..48cb33e5b3826caac252debfc011dc6b2c91c322 100644 (file)
@@ -926,8 +926,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
                                       struct drm_file *file_priv,
                                       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
-       struct drm_gem_object *obj;
        struct amdgpu_framebuffer *amdgpu_fb;
+       struct drm_gem_object *obj;
+       struct amdgpu_bo *bo;
+       uint32_t domains;
        int ret;
 
        obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]);
@@ -938,7 +940,9 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev,
        }
 
        /* Handle is imported dma-buf, so cannot be migrated to VRAM for scanout */
-       if (obj->import_attach) {
+       bo = gem_to_amdgpu_bo(obj);
+       domains = amdgpu_display_supported_domains(drm_to_adev(dev), bo->flags);
+       if (obj->import_attach && !(domains & AMDGPU_GEM_DOMAIN_GTT)) {
                drm_dbg_kms(dev, "Cannot create framebuffer from imported dma_buf\n");
                return ERR_PTR(-EINVAL);
        }
index d0a1fee1f5f6f9761dc0c56ea9d7013329ab946b..174a73eb23f08117528f8a458a68e57d50f89a72 100644 (file)
@@ -269,8 +269,8 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
                resv = vm->root.base.bo->tbo.base.resv;
        }
 
-retry:
        initial_domain = (u32)(0xffffffff & args->in.domains);
+retry:
        r = amdgpu_gem_object_create(adev, size, args->in.alignment,
                                     initial_domain,
                                     flags, ttm_bo_type_device, resv, &gobj);
index 25ec4d57333f6a9786e98551044e2476cb8fc39f..b4c8e5d5c763cd5416b712e60c3a7ec2a10ed44a 100644 (file)
@@ -897,7 +897,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
                return -EINVAL;
 
        /* A shared bo cannot be migrated to VRAM */
-       if (bo->prime_shared_count) {
+       if (bo->prime_shared_count || bo->tbo.base.import_attach) {
                if (domain & AMDGPU_GEM_DOMAIN_GTT)
                        domain = AMDGPU_GEM_DOMAIN_GTT;
                else
index 346963e3cf7313cf056e9de612e45dfc74873147..d86b42a36560183b4d1ef0bde1a199800bec4285 100644 (file)
 #define mmGCR_GENERAL_CNTL_Sienna_Cichlid                      0x1580
 #define mmGCR_GENERAL_CNTL_Sienna_Cichlid_BASE_IDX     0
 
+#define mmCGTS_TCC_DISABLE_Vangogh                0x5006
+#define mmCGTS_TCC_DISABLE_Vangogh_BASE_IDX       1
+#define mmCGTS_USER_TCC_DISABLE_Vangogh                0x5007
+#define mmCGTS_USER_TCC_DISABLE_Vangogh_BASE_IDX       1
 #define mmGOLDEN_TSC_COUNT_UPPER_Vangogh                0x0025
 #define mmGOLDEN_TSC_COUNT_UPPER_Vangogh_BASE_IDX       1
 #define mmGOLDEN_TSC_COUNT_LOWER_Vangogh                0x0026
@@ -4936,8 +4940,18 @@ static void gfx_v10_0_tcp_harvest(struct amdgpu_device *adev)
 static void gfx_v10_0_get_tcc_info(struct amdgpu_device *adev)
 {
        /* TCCs are global (not instanced). */
-       uint32_t tcc_disable = RREG32_SOC15(GC, 0, mmCGTS_TCC_DISABLE) |
-                              RREG32_SOC15(GC, 0, mmCGTS_USER_TCC_DISABLE);
+       uint32_t tcc_disable;
+
+       switch (adev->asic_type) {
+       case CHIP_VANGOGH:
+               tcc_disable = RREG32_SOC15(GC, 0, mmCGTS_TCC_DISABLE_Vangogh) |
+                               RREG32_SOC15(GC, 0, mmCGTS_USER_TCC_DISABLE_Vangogh);
+               break;
+       default:
+               tcc_disable = RREG32_SOC15(GC, 0, mmCGTS_TCC_DISABLE) |
+                               RREG32_SOC15(GC, 0, mmCGTS_USER_TCC_DISABLE);
+               break;
+       }
 
        adev->gfx.config.tcc_disabled_mask =
                REG_GET_FIELD(tcc_disable, CGTS_TCC_DISABLE, TCC_DISABLE) |
index c6da89df055de87c89ba0ba05ed8739993a1c97b..961abf1cf040cc0372d0d9c74d456684f81cb07d 100644 (file)
@@ -1833,8 +1833,8 @@ static void emulated_link_detect(struct dc_link *link)
        link->type = dc_connection_none;
        prev_sink = link->local_sink;
 
-       if (prev_sink != NULL)
-               dc_sink_retain(prev_sink);
+       if (prev_sink)
+               dc_sink_release(prev_sink);
 
        switch (link->connector_signal) {
        case SIGNAL_TYPE_HDMI_TYPE_A: {
@@ -1934,7 +1934,7 @@ static void dm_gpureset_commit_state(struct dc_state *dc_state,
                dc_commit_updates_for_stream(
                        dm->dc, bundle->surface_updates,
                        dc_state->stream_status->plane_count,
-                       dc_state->streams[k], &bundle->stream_update, dc_state);
+                       dc_state->streams[k], &bundle->stream_update);
        }
 
 cleanup:
@@ -1965,8 +1965,7 @@ static void dm_set_dpms_off(struct dc_link *link)
 
        stream_update.stream = stream_state;
        dc_commit_updates_for_stream(stream_state->ctx->dc, NULL, 0,
-                                    stream_state, &stream_update,
-                                    stream_state->ctx->dc->current_state);
+                                    stream_state, &stream_update);
        mutex_unlock(&adev->dm.dc_lock);
 }
 
@@ -2330,8 +2329,10 @@ void amdgpu_dm_update_connector_after_detect(
                 * TODO: check if we still need the S3 mode update workaround.
                 * If yes, put it here.
                 */
-               if (aconnector->dc_sink)
+               if (aconnector->dc_sink) {
                        amdgpu_dm_update_freesync_caps(connector, NULL);
+                       dc_sink_release(aconnector->dc_sink);
+               }
 
                aconnector->dc_sink = sink;
                dc_sink_retain(aconnector->dc_sink);
@@ -2347,8 +2348,6 @@ void amdgpu_dm_update_connector_after_detect(
 
                        drm_connector_update_edid_property(connector,
                                                           aconnector->edid);
-                       drm_add_edid_modes(connector, aconnector->edid);
-
                        if (aconnector->dc_link->aux_mode)
                                drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
                                                    aconnector->edid);
@@ -7549,7 +7548,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                                    struct drm_crtc *pcrtc,
                                    bool wait_for_vblank)
 {
-       uint32_t i;
+       int i;
        uint64_t timestamp_ns;
        struct drm_plane *plane;
        struct drm_plane_state *old_plane_state, *new_plane_state;
@@ -7590,7 +7589,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                amdgpu_dm_commit_cursors(state);
 
        /* update planes when needed */
-       for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
+       for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
                struct drm_crtc *crtc = new_plane_state->crtc;
                struct drm_crtc_state *new_crtc_state;
                struct drm_framebuffer *fb = new_plane_state->fb;
@@ -7813,8 +7812,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
                                                     bundle->surface_updates,
                                                     planes_count,
                                                     acrtc_state->stream,
-                                                    &bundle->stream_update,
-                                                    dc_state);
+                                                    &bundle->stream_update);
 
                /**
                 * Enable or disable the interrupts on the backend.
@@ -8150,13 +8148,13 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
                struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
                struct dm_connector_state *dm_old_con_state = to_dm_connector_state(old_con_state);
                struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
-               struct dc_surface_update dummy_updates[MAX_SURFACES];
+               struct dc_surface_update surface_updates[MAX_SURFACES];
                struct dc_stream_update stream_update;
                struct dc_info_packet hdr_packet;
                struct dc_stream_status *status = NULL;
                bool abm_changed, hdr_changed, scaling_changed;
 
-               memset(&dummy_updates, 0, sizeof(dummy_updates));
+               memset(&surface_updates, 0, sizeof(surface_updates));
                memset(&stream_update, 0, sizeof(stream_update));
 
                if (acrtc) {
@@ -8213,16 +8211,15 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
                 * To fix this, DC should permit updating only stream properties.
                 */
                for (j = 0; j < status->plane_count; j++)
-                       dummy_updates[j].surface = status->plane_states[0];
+                       surface_updates[j].surface = status->plane_states[j];
 
 
                mutex_lock(&dm->dc_lock);
                dc_commit_updates_for_stream(dm->dc,
-                                                    dummy_updates,
+                                               surface_updates,
                                                     status->plane_count,
                                                     dm_new_crtc_state->stream,
-                                                    &stream_update,
-                                                    dc_state);
+                                                    &stream_update);
                mutex_unlock(&dm->dc_lock);
        }
 
@@ -8359,14 +8356,14 @@ static int dm_force_atomic_commit(struct drm_connector *connector)
 
        ret = PTR_ERR_OR_ZERO(conn_state);
        if (ret)
-               goto err;
+               goto out;
 
        /* Attach crtc to drm_atomic_state*/
        crtc_state = drm_atomic_get_crtc_state(state, &disconnected_acrtc->base);
 
        ret = PTR_ERR_OR_ZERO(crtc_state);
        if (ret)
-               goto err;
+               goto out;
 
        /* force a restore */
        crtc_state->mode_changed = true;
@@ -8376,17 +8373,15 @@ static int dm_force_atomic_commit(struct drm_connector *connector)
 
        ret = PTR_ERR_OR_ZERO(plane_state);
        if (ret)
-               goto err;
-
+               goto out;
 
        /* Call commit internally with the state we just constructed */
        ret = drm_atomic_commit(state);
-       if (!ret)
-               return 0;
 
-err:
-       DRM_ERROR("Restoring old state failed with %i\n", ret);
+out:
        drm_atomic_state_put(state);
+       if (ret)
+               DRM_ERROR("Restoring old state failed with %i\n", ret);
 
        return ret;
 }
index 8ab0b9060d2bbabcfc714af6917f4ad9efbc9ae6..f2d8cf34be46e92bbd2c83cf832835389a8936b6 100644 (file)
@@ -833,6 +833,9 @@ bool compute_mst_dsc_configs_for_state(struct drm_atomic_state *state,
                if (computed_streams[i])
                        continue;
 
+               if (dcn20_remove_stream_from_ctx(stream->ctx->dc, dc_state, stream) != DC_OK)
+                       return false;
+
                mutex_lock(&aconnector->mst_mgr.lock);
                if (!compute_mst_dsc_configs_for_link(state, dc_state, stream->link)) {
                        mutex_unlock(&aconnector->mst_mgr.lock);
@@ -850,7 +853,8 @@ bool compute_mst_dsc_configs_for_state(struct drm_atomic_state *state,
                stream = dc_state->streams[i];
 
                if (stream->timing.flags.DSC == 1)
-                       dc_stream_add_dsc_to_resource(stream->ctx->dc, dc_state, stream);
+                       if (dc_stream_add_dsc_to_resource(stream->ctx->dc, dc_state, stream) != DC_OK)
+                               return false;
        }
 
        return true;
index 58eb0d69873a6225698486a1038ed58d085d502f..6cf1a5a2a5ecc0f5dda72f60930325b1df4de9cb 100644 (file)
@@ -2679,8 +2679,7 @@ void dc_commit_updates_for_stream(struct dc *dc,
                struct dc_surface_update *srf_updates,
                int surface_count,
                struct dc_stream_state *stream,
-               struct dc_stream_update *stream_update,
-               struct dc_state *state)
+               struct dc_stream_update *stream_update)
 {
        const struct dc_stream_status *stream_status;
        enum surface_update_type update_type;
@@ -2699,6 +2698,12 @@ void dc_commit_updates_for_stream(struct dc *dc,
 
 
        if (update_type >= UPDATE_TYPE_FULL) {
+               struct dc_plane_state *new_planes[MAX_SURFACES];
+
+               memset(new_planes, 0, sizeof(new_planes));
+
+               for (i = 0; i < surface_count; i++)
+                       new_planes[i] = srf_updates[i].surface;
 
                /* initialize scratch memory for building context */
                context = dc_create_state(dc);
@@ -2707,15 +2712,21 @@ void dc_commit_updates_for_stream(struct dc *dc,
                        return;
                }
 
-               dc_resource_state_copy_construct(state, context);
+               dc_resource_state_copy_construct(
+                               dc->current_state, context);
 
-               for (i = 0; i < dc->res_pool->pipe_count; i++) {
-                       struct pipe_ctx *new_pipe = &context->res_ctx.pipe_ctx[i];
-                       struct pipe_ctx *old_pipe = &dc->current_state->res_ctx.pipe_ctx[i];
+               /*remove old surfaces from context */
+               if (!dc_rem_all_planes_for_stream(dc, stream, context)) {
+                       DC_ERROR("Failed to remove streams for new validate context!\n");
+                       return;
+               }
 
-                       if (new_pipe->plane_state && new_pipe->plane_state != old_pipe->plane_state)
-                               new_pipe->plane_state->force_full_update = true;
+               /* add surface to context */
+               if (!dc_add_all_planes_for_stream(dc, stream, new_planes, surface_count, context)) {
+                       DC_ERROR("Failed to add streams for new validate context!\n");
+                       return;
                }
+
        }
 
 
index f95bade5962429b1c4c352aca4a3f1295d952903..1e4794e2825caf2b23b330255b899ec6c5614a05 100644 (file)
@@ -892,13 +892,13 @@ static uint32_t translate_training_aux_read_interval(uint32_t dpcd_aux_read_inte
 
        switch (dpcd_aux_read_interval) {
        case 0x01:
-               aux_rd_interval_us = 400;
+               aux_rd_interval_us = 4000;
                break;
        case 0x02:
-               aux_rd_interval_us = 4000;
+               aux_rd_interval_us = 8000;
                break;
        case 0x03:
-               aux_rd_interval_us = 8000;
+               aux_rd_interval_us = 12000;
                break;
        case 0x04:
                aux_rd_interval_us = 16000;
index b7910976b81a74ab2ef78bc39fae2fc112e98afd..e243c01b9672eee14e92e384e300d61213c4a601 100644 (file)
@@ -283,8 +283,7 @@ void dc_commit_updates_for_stream(struct dc *dc,
                struct dc_surface_update *srf_updates,
                int surface_count,
                struct dc_stream_state *stream,
-               struct dc_stream_update *stream_update,
-               struct dc_state *state);
+               struct dc_stream_update *stream_update);
 /*
  * Log the current stream state.
  */
index b000b43a820d470bf6e0ee6ae33fd3c4656876bd..6743764289167a06639268284dba98356c883f8f 100644 (file)
@@ -906,6 +906,8 @@ enum dcn20_clk_src_array_id {
        DCN20_CLK_SRC_PLL0,
        DCN20_CLK_SRC_PLL1,
        DCN20_CLK_SRC_PLL2,
+       DCN20_CLK_SRC_PLL3,
+       DCN20_CLK_SRC_PLL4,
        DCN20_CLK_SRC_TOTAL_DCN21
 };
 
@@ -2030,6 +2032,14 @@ static bool dcn21_resource_construct(
                        dcn21_clock_source_create(ctx, ctx->dc_bios,
                                CLOCK_SOURCE_COMBO_PHY_PLL2,
                                &clk_src_regs[2], false);
+       pool->base.clock_sources[DCN20_CLK_SRC_PLL3] =
+                       dcn21_clock_source_create(ctx, ctx->dc_bios,
+                               CLOCK_SOURCE_COMBO_PHY_PLL3,
+                               &clk_src_regs[3], false);
+       pool->base.clock_sources[DCN20_CLK_SRC_PLL4] =
+                       dcn21_clock_source_create(ctx, ctx->dc_bios,
+                               CLOCK_SOURCE_COMBO_PHY_PLL4,
+                               &clk_src_regs[4], false);
 
        pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL_DCN21;
 
index 5c1482d4ca43e3af916596de68571092c25ea276..92ad2cdbae107c18aef29ac906e3ea4a14e08ba4 100644 (file)
@@ -591,14 +591,17 @@ static ssize_t vangogh_get_gpu_metrics(struct smu_context *smu,
        gpu_metrics->average_socket_power = metrics.CurrentSocketPower;
        gpu_metrics->average_cpu_power = metrics.Power[0];
        gpu_metrics->average_soc_power = metrics.Power[1];
+       gpu_metrics->average_gfx_power = metrics.Power[2];
        memcpy(&gpu_metrics->average_core_power[0],
                &metrics.CorePower[0],
                sizeof(uint16_t) * 8);
 
        gpu_metrics->average_gfxclk_frequency = metrics.GfxclkFrequency;
        gpu_metrics->average_socclk_frequency = metrics.SocclkFrequency;
+       gpu_metrics->average_uclk_frequency = metrics.MemclkFrequency;
        gpu_metrics->average_fclk_frequency = metrics.MemclkFrequency;
        gpu_metrics->average_vclk_frequency = metrics.VclkFrequency;
+       gpu_metrics->average_dclk_frequency = metrics.DclkFrequency;
 
        memcpy(&gpu_metrics->current_coreclk[0],
                &metrics.CoreFrequency[0],
index 0c98d27f84ac7da2b4b23b557e7e28c24377e70a..fee27952ec6d1f01c2d48b7b8a8694bd451f8805 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/wait.h>
+#include <linux/workqueue.h>
 
 #include <sound/hdmi-codec.h>
 
@@ -36,6 +37,7 @@ struct lt9611uxc {
        struct mutex ocm_lock;
 
        struct wait_queue_head wq;
+       struct work_struct work;
 
        struct device_node *dsi0_node;
        struct device_node *dsi1_node;
@@ -52,6 +54,8 @@ struct lt9611uxc {
 
        bool hpd_supported;
        bool edid_read;
+       /* can be accessed from different threads, so protect this with ocm_lock */
+       bool hdmi_connected;
        uint8_t fw_version;
 };
 
@@ -143,21 +147,41 @@ static irqreturn_t lt9611uxc_irq_thread_handler(int irq, void *dev_id)
        if (irq_status)
                regmap_write(lt9611uxc->regmap, 0xb022, 0);
 
-       lt9611uxc_unlock(lt9611uxc);
-
-       if (irq_status & BIT(0))
+       if (irq_status & BIT(0)) {
                lt9611uxc->edid_read = !!(hpd_status & BIT(0));
+               wake_up_all(&lt9611uxc->wq);
+       }
 
        if (irq_status & BIT(1)) {
-               if (lt9611uxc->connector.dev)
-                       drm_kms_helper_hotplug_event(lt9611uxc->connector.dev);
-               else
-                       drm_bridge_hpd_notify(&lt9611uxc->bridge, !!(hpd_status & BIT(1)));
+               lt9611uxc->hdmi_connected = hpd_status & BIT(1);
+               schedule_work(&lt9611uxc->work);
        }
 
+       lt9611uxc_unlock(lt9611uxc);
+
        return IRQ_HANDLED;
 }
 
+static void lt9611uxc_hpd_work(struct work_struct *work)
+{
+       struct lt9611uxc *lt9611uxc = container_of(work, struct lt9611uxc, work);
+       bool connected;
+
+       if (lt9611uxc->connector.dev)
+               drm_kms_helper_hotplug_event(lt9611uxc->connector.dev);
+       else {
+
+               mutex_lock(&lt9611uxc->ocm_lock);
+               connected = lt9611uxc->hdmi_connected;
+               mutex_unlock(&lt9611uxc->ocm_lock);
+
+               drm_bridge_hpd_notify(&lt9611uxc->bridge,
+                                     connected ?
+                                     connector_status_connected :
+                                     connector_status_disconnected);
+       }
+}
+
 static void lt9611uxc_reset(struct lt9611uxc *lt9611uxc)
 {
        gpiod_set_value_cansleep(lt9611uxc->reset_gpio, 1);
@@ -445,18 +469,21 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid
        struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
        unsigned int reg_val = 0;
        int ret;
-       int connected = 1;
+       bool connected = true;
+
+       lt9611uxc_lock(lt9611uxc);
 
        if (lt9611uxc->hpd_supported) {
-               lt9611uxc_lock(lt9611uxc);
                ret = regmap_read(lt9611uxc->regmap, 0xb023, &reg_val);
-               lt9611uxc_unlock(lt9611uxc);
 
                if (ret)
                        dev_err(lt9611uxc->dev, "failed to read hpd status: %d\n", ret);
                else
                        connected  = reg_val & BIT(1);
        }
+       lt9611uxc->hdmi_connected = connected;
+
+       lt9611uxc_unlock(lt9611uxc);
 
        return connected ?  connector_status_connected :
                                connector_status_disconnected;
@@ -465,7 +492,7 @@ static enum drm_connector_status lt9611uxc_bridge_detect(struct drm_bridge *brid
 static int lt9611uxc_wait_for_edid(struct lt9611uxc *lt9611uxc)
 {
        return wait_event_interruptible_timeout(lt9611uxc->wq, lt9611uxc->edid_read,
-                       msecs_to_jiffies(100));
+                       msecs_to_jiffies(500));
 }
 
 static int lt9611uxc_get_edid_block(void *data, u8 *buf, unsigned int block, size_t len)
@@ -503,7 +530,10 @@ static struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge,
        ret = lt9611uxc_wait_for_edid(lt9611uxc);
        if (ret < 0) {
                dev_err(lt9611uxc->dev, "wait for EDID failed: %d\n", ret);
-               return ERR_PTR(ret);
+               return NULL;
+       } else if (ret == 0) {
+               dev_err(lt9611uxc->dev, "wait for EDID timeout\n");
+               return NULL;
        }
 
        return drm_do_get_edid(connector, lt9611uxc_get_edid_block, lt9611uxc);
@@ -926,6 +956,8 @@ retry:
        lt9611uxc->fw_version = ret;
 
        init_waitqueue_head(&lt9611uxc->wq);
+       INIT_WORK(&lt9611uxc->work, lt9611uxc_hpd_work);
+
        ret = devm_request_threaded_irq(dev, client->irq, NULL,
                                        lt9611uxc_irq_thread_handler,
                                        IRQF_ONESHOT, "lt9611uxc", lt9611uxc);
@@ -962,6 +994,7 @@ static int lt9611uxc_remove(struct i2c_client *client)
        struct lt9611uxc *lt9611uxc = i2c_get_clientdata(client);
 
        disable_irq(client->irq);
+       flush_scheduled_work();
        lt9611uxc_audio_exit(lt9611uxc);
        drm_bridge_remove(&lt9611uxc->bridge);
 
index 0401b2f47500274ad73f337298624988167aefd3..8781deefeae3e69642930fb2013b61fea149cafd 100644 (file)
@@ -3629,14 +3629,26 @@ static int drm_dp_send_up_ack_reply(struct drm_dp_mst_topology_mgr *mgr,
        return 0;
 }
 
-static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8  dp_link_count)
+/**
+ * drm_dp_get_vc_payload_bw - get the VC payload BW for an MST link
+ * @link_rate: link rate in 10kbits/s units
+ * @link_lane_count: lane count
+ *
+ * Calculate the total bandwidth of a MultiStream Transport link. The returned
+ * value is in units of PBNs/(timeslots/1 MTP). This value can be used to
+ * convert the number of PBNs required for a given stream to the number of
+ * timeslots this stream requires in each MTP.
+ */
+int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count)
 {
-       if (dp_link_bw == 0 || dp_link_count == 0)
-               DRM_DEBUG_KMS("invalid link bandwidth in DPCD: %x (link count: %d)\n",
-                             dp_link_bw, dp_link_count);
+       if (link_rate == 0 || link_lane_count == 0)
+               DRM_DEBUG_KMS("invalid link rate/lane count: (%d / %d)\n",
+                             link_rate, link_lane_count);
 
-       return dp_link_bw * dp_link_count / 2;
+       /* See DP v2.0 2.6.4.2, VCPayload_Bandwidth_for_OneTimeSlotPer_MTP_Allocation */
+       return link_rate * link_lane_count / 54000;
 }
+EXPORT_SYMBOL(drm_dp_get_vc_payload_bw);
 
 /**
  * drm_dp_read_mst_cap() - check whether or not a sink supports MST
@@ -3692,7 +3704,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
                        goto out_unlock;
                }
 
-               mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1],
+               mgr->pbn_div = drm_dp_get_vc_payload_bw(drm_dp_bw_code_to_link_rate(mgr->dpcd[1]),
                                                        mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK);
                if (mgr->pbn_div == 0) {
                        ret = -EINVAL;
index bf17365857caf82084e1d8a7d86bf4026ab4f72f..dc13d1814d95d6c2074709754df8f71ee463655f 100644 (file)
@@ -2754,6 +2754,9 @@ static void icl_mg_phy_ddi_vswing_sequence(struct intel_encoder *encoder,
        int n_entries, ln;
        u32 val;
 
+       if (enc_to_dig_port(encoder)->tc_mode == TC_PORT_TBT_ALT)
+               return;
+
        ddi_translations = icl_get_mg_buf_trans(encoder, crtc_state, &n_entries);
        if (level >= n_entries) {
                drm_dbg_kms(&dev_priv->drm,
@@ -2890,6 +2893,9 @@ tgl_dkl_phy_ddi_vswing_sequence(struct intel_encoder *encoder,
        u32 val, dpcnt_mask, dpcnt_val;
        int n_entries, ln;
 
+       if (enc_to_dig_port(encoder)->tc_mode == TC_PORT_TBT_ALT)
+               return;
+
        ddi_translations = tgl_get_dkl_buf_trans(encoder, crtc_state, &n_entries);
 
        if (level >= n_entries)
@@ -3531,6 +3537,23 @@ static void intel_ddi_disable_fec_state(struct intel_encoder *encoder,
        intel_de_posting_read(dev_priv, dp_tp_ctl_reg(encoder, crtc_state));
 }
 
+static void intel_ddi_power_up_lanes(struct intel_encoder *encoder,
+                                    const struct intel_crtc_state *crtc_state)
+{
+       struct drm_i915_private *i915 = to_i915(encoder->base.dev);
+       struct intel_digital_port *dig_port = enc_to_dig_port(encoder);
+       enum phy phy = intel_port_to_phy(i915, encoder->port);
+
+       if (intel_phy_is_combo(i915, phy)) {
+               bool lane_reversal =
+                       dig_port->saved_port_bits & DDI_BUF_PORT_REVERSAL;
+
+               intel_combo_phy_power_up_lanes(i915, phy, false,
+                                              crtc_state->lane_count,
+                                              lane_reversal);
+       }
+}
+
 static void tgl_ddi_pre_enable_dp(struct intel_atomic_state *state,
                                  struct intel_encoder *encoder,
                                  const struct intel_crtc_state *crtc_state,
@@ -3620,14 +3643,7 @@ static void tgl_ddi_pre_enable_dp(struct intel_atomic_state *state,
         * 7.f Combo PHY: Configure PORT_CL_DW10 Static Power Down to power up
         * the used lanes of the DDI.
         */
-       if (intel_phy_is_combo(dev_priv, phy)) {
-               bool lane_reversal =
-                       dig_port->saved_port_bits & DDI_BUF_PORT_REVERSAL;
-
-               intel_combo_phy_power_up_lanes(dev_priv, phy, false,
-                                              crtc_state->lane_count,
-                                              lane_reversal);
-       }
+       intel_ddi_power_up_lanes(encoder, crtc_state);
 
        /*
         * 7.g Configure and enable DDI_BUF_CTL
@@ -3712,14 +3728,7 @@ static void hsw_ddi_pre_enable_dp(struct intel_atomic_state *state,
        else
                intel_prepare_dp_ddi_buffers(encoder, crtc_state);
 
-       if (intel_phy_is_combo(dev_priv, phy)) {
-               bool lane_reversal =
-                       dig_port->saved_port_bits & DDI_BUF_PORT_REVERSAL;
-
-               intel_combo_phy_power_up_lanes(dev_priv, phy, false,
-                                              crtc_state->lane_count,
-                                              lane_reversal);
-       }
+       intel_ddi_power_up_lanes(encoder, crtc_state);
 
        intel_ddi_init_dp_buf_reg(encoder, crtc_state);
        if (!is_mst)
@@ -4205,6 +4214,8 @@ static void intel_enable_ddi_hdmi(struct intel_atomic_state *state,
                intel_de_write(dev_priv, reg, val);
        }
 
+       intel_ddi_power_up_lanes(encoder, crtc_state);
+
        /* In HDMI/DVI mode, the port width, and swing/emphasis values
         * are ignored so nothing special needs to be done besides
         * enabling the port.
index 53a00cf3fa325ef280f649bed2bbd98b3aae20bc..61be6bed916291d614245b10a8cbe1299ff7eda1 100644 (file)
@@ -2309,7 +2309,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
                 */
                ret = i915_vma_pin_fence(vma);
                if (ret != 0 && INTEL_GEN(dev_priv) < 4) {
-                       i915_gem_object_unpin_from_display_plane(vma);
+                       i915_vma_unpin(vma);
                        vma = ERR_PTR(ret);
                        goto err;
                }
@@ -2327,12 +2327,9 @@ err:
 
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags)
 {
-       i915_gem_object_lock(vma->obj, NULL);
        if (flags & PLANE_HAS_FENCE)
                i915_vma_unpin_fence(vma);
-       i915_gem_object_unpin_from_display_plane(vma);
-       i915_gem_object_unlock(vma->obj);
-
+       i915_vma_unpin(vma);
        i915_vma_put(vma);
 }
 
@@ -4807,6 +4804,8 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
                        plane_color_ctl |= PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;
        } else if (fb->format->is_yuv) {
                plane_color_ctl |= PLANE_COLOR_INPUT_CSC_ENABLE;
+               if (plane_state->hw.color_range == DRM_COLOR_YCBCR_FULL_RANGE)
+                       plane_color_ctl |= PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;
        }
 
        return plane_color_ctl;
index 09123e8625c498f8f01fcb27ebd29563813d5461..8a26307c48960110b678af7075db41ad3e65de6f 100644 (file)
@@ -4637,24 +4637,6 @@ ivb_cpu_edp_set_signal_levels(struct intel_dp *intel_dp,
        intel_de_posting_read(dev_priv, intel_dp->output_reg);
 }
 
-void intel_dp_set_signal_levels(struct intel_dp *intel_dp,
-                               const struct intel_crtc_state *crtc_state)
-{
-       struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
-       u8 train_set = intel_dp->train_set[0];
-
-       drm_dbg_kms(&dev_priv->drm, "Using vswing level %d%s\n",
-                   train_set & DP_TRAIN_VOLTAGE_SWING_MASK,
-                   train_set & DP_TRAIN_MAX_SWING_REACHED ? " (max)" : "");
-       drm_dbg_kms(&dev_priv->drm, "Using pre-emphasis level %d%s\n",
-                   (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) >>
-                   DP_TRAIN_PRE_EMPHASIS_SHIFT,
-                   train_set & DP_TRAIN_MAX_PRE_EMPHASIS_REACHED ?
-                   " (max)" : "");
-
-       intel_dp->set_signal_levels(intel_dp, crtc_state);
-}
-
 void
 intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
                                       const struct intel_crtc_state *crtc_state,
@@ -5703,7 +5685,7 @@ static void intel_dp_process_phy_request(struct intel_dp *intel_dp,
 
        intel_dp_autotest_phy_ddi_disable(intel_dp, crtc_state);
 
-       intel_dp_set_signal_levels(intel_dp, crtc_state);
+       intel_dp_set_signal_levels(intel_dp, crtc_state, DP_PHY_DPRX);
 
        intel_dp_phy_pattern_update(intel_dp, crtc_state);
 
index 05f7ddf7a79527620b9cc2db5e6e1ee570fcb539..6620f9efdcbbaebb525ee3425bfc58ce08fd7a91 100644 (file)
@@ -96,9 +96,6 @@ void
 intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
                                       const struct intel_crtc_state *crtc_state,
                                       u8 dp_train_pat);
-void
-intel_dp_set_signal_levels(struct intel_dp *intel_dp,
-                          const struct intel_crtc_state *crtc_state);
 void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
                           u8 *link_bw, u8 *rate_select);
 bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
index 91d3979902d03cb891474ad587a79c760118797c..d8c6d7054d11d929ff8d4170b10b96dcd2c6dcda 100644 (file)
@@ -334,6 +334,27 @@ intel_dp_set_link_train(struct intel_dp *intel_dp,
        return drm_dp_dpcd_write(&intel_dp->aux, reg, buf, len) == len;
 }
 
+void intel_dp_set_signal_levels(struct intel_dp *intel_dp,
+                               const struct intel_crtc_state *crtc_state,
+                               enum drm_dp_phy dp_phy)
+{
+       struct drm_i915_private *dev_priv = dp_to_i915(intel_dp);
+       u8 train_set = intel_dp->train_set[0];
+       char phy_name[10];
+
+       drm_dbg_kms(&dev_priv->drm, "Using vswing level %d%s, pre-emphasis level %d%s, at %s\n",
+                   train_set & DP_TRAIN_VOLTAGE_SWING_MASK,
+                   train_set & DP_TRAIN_MAX_SWING_REACHED ? " (max)" : "",
+                   (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) >>
+                   DP_TRAIN_PRE_EMPHASIS_SHIFT,
+                   train_set & DP_TRAIN_MAX_PRE_EMPHASIS_REACHED ?
+                   " (max)" : "",
+                   intel_dp_phy_name(dp_phy, phy_name, sizeof(phy_name)));
+
+       if (intel_dp_phy_is_downstream_of_source(intel_dp, dp_phy))
+               intel_dp->set_signal_levels(intel_dp, crtc_state);
+}
+
 static bool
 intel_dp_reset_link_train(struct intel_dp *intel_dp,
                          const struct intel_crtc_state *crtc_state,
@@ -341,7 +362,7 @@ intel_dp_reset_link_train(struct intel_dp *intel_dp,
                          u8 dp_train_pat)
 {
        memset(intel_dp->train_set, 0, sizeof(intel_dp->train_set));
-       intel_dp_set_signal_levels(intel_dp, crtc_state);
+       intel_dp_set_signal_levels(intel_dp, crtc_state, dp_phy);
        return intel_dp_set_link_train(intel_dp, crtc_state, dp_phy, dp_train_pat);
 }
 
@@ -355,7 +376,7 @@ intel_dp_update_link_train(struct intel_dp *intel_dp,
                            DP_TRAINING_LANE0_SET_PHY_REPEATER(dp_phy);
        int ret;
 
-       intel_dp_set_signal_levels(intel_dp, crtc_state);
+       intel_dp_set_signal_levels(intel_dp, crtc_state, dp_phy);
 
        ret = drm_dp_dpcd_write(&intel_dp->aux, reg,
                                intel_dp->train_set, crtc_state->lane_count);
index 86905aa24db76a6c079118b32fca14beb91cc65f..6a1f76bd8c7586a6f40fea2e4b8b61cb30e97225 100644 (file)
@@ -17,6 +17,9 @@ void intel_dp_get_adjust_train(struct intel_dp *intel_dp,
                               const struct intel_crtc_state *crtc_state,
                               enum drm_dp_phy dp_phy,
                               const u8 link_status[DP_LINK_STATUS_SIZE]);
+void intel_dp_set_signal_levels(struct intel_dp *intel_dp,
+                               const struct intel_crtc_state *crtc_state,
+                               enum drm_dp_phy dp_phy);
 void intel_dp_start_link_train(struct intel_dp *intel_dp,
                               const struct intel_crtc_state *crtc_state);
 void intel_dp_stop_link_train(struct intel_dp *intel_dp,
index 27f04aed8764a87287175ab3c51fbc8f200f2208..3286b232be0b8f0d1dbb1340a9408fea82b1fc9c 100644 (file)
@@ -69,7 +69,9 @@ static int intel_dp_mst_compute_link_config(struct intel_encoder *encoder,
 
                slots = drm_dp_atomic_find_vcpi_slots(state, &intel_dp->mst_mgr,
                                                      connector->port,
-                                                     crtc_state->pbn, 0);
+                                                     crtc_state->pbn,
+                                                     drm_dp_get_vc_payload_bw(crtc_state->port_clock,
+                                                                              crtc_state->lane_count));
                if (slots == -EDEADLK)
                        return slots;
                if (slots >= 0)
index 52b4f6193b4ce5a32b5de8001a1e88a734d00cb5..0095c8cac9b40f1e0856151d958f26516226e25f 100644 (file)
@@ -359,7 +359,7 @@ static void intel_overlay_release_old_vma(struct intel_overlay *overlay)
        intel_frontbuffer_flip_complete(overlay->i915,
                                        INTEL_FRONTBUFFER_OVERLAY(overlay->crtc->pipe));
 
-       i915_gem_object_unpin_from_display_plane(vma);
+       i915_vma_unpin(vma);
        i915_vma_put(vma);
 }
 
@@ -860,7 +860,7 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
        return 0;
 
 out_unpin:
-       i915_gem_object_unpin_from_display_plane(vma);
+       i915_vma_unpin(vma);
 out_pin_section:
        atomic_dec(&dev_priv->gpu_error.pending_fb_pin);
 
index 019a2d6d807a6873fe7a184f12a52c6c6f62aeb8..3da2544fa1c0b6dfdadb206fb1ee9cd48762a359 100644 (file)
@@ -618,13 +618,19 @@ skl_program_scaler(struct intel_plane *plane,
 
 /* Preoffset values for YUV to RGB Conversion */
 #define PREOFF_YUV_TO_RGB_HI           0x1800
-#define PREOFF_YUV_TO_RGB_ME           0x1F00
+#define PREOFF_YUV_TO_RGB_ME           0x0000
 #define PREOFF_YUV_TO_RGB_LO           0x1800
 
 #define  ROFF(x)          (((x) & 0xffff) << 16)
 #define  GOFF(x)          (((x) & 0xffff) << 0)
 #define  BOFF(x)          (((x) & 0xffff) << 16)
 
+/*
+ * Programs the input color space conversion stage for ICL HDR planes.
+ * Note that it is assumed that this stage always happens after YUV
+ * range correction. Thus, the input to this stage is assumed to be
+ * in full-range YCbCr.
+ */
 static void
 icl_program_input_csc(struct intel_plane *plane,
                      const struct intel_crtc_state *crtc_state,
@@ -672,52 +678,7 @@ icl_program_input_csc(struct intel_plane *plane,
                        0x0, 0x7800, 0x7F10,
                },
        };
-
-       /* Matrix for Limited Range to Full Range Conversion */
-       static const u16 input_csc_matrix_lr[][9] = {
-               /*
-                * BT.601 Limted range YCbCr -> full range RGB
-                * The matrix required is :
-                * [1.164384, 0.000, 1.596027,
-                *  1.164384, -0.39175, -0.812813,
-                *  1.164384, 2.017232, 0.0000]
-                */
-               [DRM_COLOR_YCBCR_BT601] = {
-                       0x7CC8, 0x7950, 0x0,
-                       0x8D00, 0x7950, 0x9C88,
-                       0x0, 0x7950, 0x6810,
-               },
-               /*
-                * BT.709 Limited range YCbCr -> full range RGB
-                * The matrix required is :
-                * [1.164384, 0.000, 1.792741,
-                *  1.164384, -0.213249, -0.532909,
-                *  1.164384, 2.112402, 0.0000]
-                */
-               [DRM_COLOR_YCBCR_BT709] = {
-                       0x7E58, 0x7950, 0x0,
-                       0x8888, 0x7950, 0xADA8,
-                       0x0, 0x7950,  0x6870,
-               },
-               /*
-                * BT.2020 Limited range YCbCr -> full range RGB
-                * The matrix required is :
-                * [1.164, 0.000, 1.678,
-                *  1.164, -0.1873, -0.6504,
-                *  1.164, 2.1417, 0.0000]
-                */
-               [DRM_COLOR_YCBCR_BT2020] = {
-                       0x7D70, 0x7950, 0x0,
-                       0x8A68, 0x7950, 0xAC00,
-                       0x0, 0x7950, 0x6890,
-               },
-       };
-       const u16 *csc;
-
-       if (plane_state->hw.color_range == DRM_COLOR_YCBCR_FULL_RANGE)
-               csc = input_csc_matrix[plane_state->hw.color_encoding];
-       else
-               csc = input_csc_matrix_lr[plane_state->hw.color_encoding];
+       const u16 *csc = input_csc_matrix[plane_state->hw.color_encoding];
 
        intel_de_write_fw(dev_priv, PLANE_INPUT_CSC_COEFF(pipe, plane_id, 0),
                          ROFF(csc[0]) | GOFF(csc[1]));
@@ -734,14 +695,8 @@ icl_program_input_csc(struct intel_plane *plane,
 
        intel_de_write_fw(dev_priv, PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 0),
                          PREOFF_YUV_TO_RGB_HI);
-       if (plane_state->hw.color_range == DRM_COLOR_YCBCR_FULL_RANGE)
-               intel_de_write_fw(dev_priv,
-                                 PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 1),
-                                 0);
-       else
-               intel_de_write_fw(dev_priv,
-                                 PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 1),
-                                 PREOFF_YUV_TO_RGB_ME);
+       intel_de_write_fw(dev_priv, PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 1),
+                         PREOFF_YUV_TO_RGB_ME);
        intel_de_write_fw(dev_priv, PLANE_INPUT_CSC_PREOFF(pipe, plane_id, 2),
                          PREOFF_YUV_TO_RGB_LO);
        intel_de_write_fw(dev_priv,
index fcce6909f201769876dea539f22681ff37d80ec6..3d435bfff7649aeaf279164b8b16ce3fe6391c54 100644 (file)
@@ -387,48 +387,6 @@ err:
        return vma;
 }
 
-static void i915_gem_object_bump_inactive_ggtt(struct drm_i915_gem_object *obj)
-{
-       struct drm_i915_private *i915 = to_i915(obj->base.dev);
-       struct i915_vma *vma;
-
-       if (list_empty(&obj->vma.list))
-               return;
-
-       mutex_lock(&i915->ggtt.vm.mutex);
-       spin_lock(&obj->vma.lock);
-       for_each_ggtt_vma(vma, obj) {
-               if (!drm_mm_node_allocated(&vma->node))
-                       continue;
-
-               GEM_BUG_ON(vma->vm != &i915->ggtt.vm);
-               list_move_tail(&vma->vm_link, &vma->vm->bound_list);
-       }
-       spin_unlock(&obj->vma.lock);
-       mutex_unlock(&i915->ggtt.vm.mutex);
-
-       if (i915_gem_object_is_shrinkable(obj)) {
-               unsigned long flags;
-
-               spin_lock_irqsave(&i915->mm.obj_lock, flags);
-
-               if (obj->mm.madv == I915_MADV_WILLNEED &&
-                   !atomic_read(&obj->mm.shrink_pin))
-                       list_move_tail(&obj->mm.link, &i915->mm.shrink_list);
-
-               spin_unlock_irqrestore(&i915->mm.obj_lock, flags);
-       }
-}
-
-void
-i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
-{
-       /* Bump the LRU to try and avoid premature eviction whilst flipping  */
-       i915_gem_object_bump_inactive_ggtt(vma->obj);
-
-       i915_vma_unpin(vma);
-}
-
 /**
  * Moves a single object to the CPU read, and possibly write domain.
  * @obj: object to act on
@@ -569,9 +527,6 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
        else
                err = i915_gem_object_set_to_cpu_domain(obj, write_domain);
 
-       /* And bump the LRU for this access */
-       i915_gem_object_bump_inactive_ggtt(obj);
-
        i915_gem_object_unlock(obj);
 
        if (write_domain)
index be14486f63a7aa1e157625a7d34a3573112abbd7..4556afe18f16d41779e043d904ca02408649b013 100644 (file)
@@ -486,7 +486,6 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
                                     u32 alignment,
                                     const struct i915_ggtt_view *view,
                                     unsigned int flags);
-void i915_gem_object_unpin_from_display_plane(struct i915_vma *vma);
 
 void i915_gem_object_make_unshrinkable(struct drm_i915_gem_object *obj);
 void i915_gem_object_make_shrinkable(struct drm_i915_gem_object *obj);
index 0625cbb3b431202b33373f7af3367e015c8c42a3..1d1757584f49026d7f3b6fb7cedfb875fce68a0f 100644 (file)
@@ -187,18 +187,6 @@ static void add_retire(struct intel_breadcrumbs *b, struct intel_timeline *tl)
                intel_engine_add_retire(b->irq_engine, tl);
 }
 
-static bool __signal_request(struct i915_request *rq)
-{
-       GEM_BUG_ON(test_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags));
-
-       if (!__dma_fence_signal(&rq->fence)) {
-               i915_request_put(rq);
-               return false;
-       }
-
-       return true;
-}
-
 static struct llist_node *
 slist_add(struct llist_node *node, struct llist_node *head)
 {
@@ -269,9 +257,11 @@ static void signal_irq_work(struct irq_work *work)
                        release = remove_signaling_context(b, ce);
                        spin_unlock(&ce->signal_lock);
 
-                       if (__signal_request(rq))
+                       if (__dma_fence_signal(&rq->fence))
                                /* We own signal_node now, xfer to local list */
                                signal = slist_add(&rq->signal_node, signal);
+                       else
+                               i915_request_put(rq);
 
                        if (release) {
                                add_retire(b, ce->timeline);
@@ -358,6 +348,17 @@ void intel_breadcrumbs_free(struct intel_breadcrumbs *b)
        kfree(b);
 }
 
+static void irq_signal_request(struct i915_request *rq,
+                              struct intel_breadcrumbs *b)
+{
+       if (!__dma_fence_signal(&rq->fence))
+               return;
+
+       i915_request_get(rq);
+       if (llist_add(&rq->signal_node, &b->signaled_requests))
+               irq_work_queue(&b->irq_work);
+}
+
 static void insert_breadcrumb(struct i915_request *rq)
 {
        struct intel_breadcrumbs *b = READ_ONCE(rq->engine)->breadcrumbs;
@@ -367,17 +368,13 @@ static void insert_breadcrumb(struct i915_request *rq)
        if (test_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags))
                return;
 
-       i915_request_get(rq);
-
        /*
         * If the request is already completed, we can transfer it
         * straight onto a signaled list, and queue the irq worker for
         * its signal completion.
         */
        if (__i915_request_is_complete(rq)) {
-               if (__signal_request(rq) &&
-                   llist_add(&rq->signal_node, &b->signaled_requests))
-                       irq_work_queue(&b->irq_work);
+               irq_signal_request(rq, b);
                return;
        }
 
@@ -408,6 +405,8 @@ static void insert_breadcrumb(struct i915_request *rq)
                                break;
                }
        }
+
+       i915_request_get(rq);
        list_add_rcu(&rq->signal_link, pos);
        GEM_BUG_ON(!check_signal_order(ce, rq));
        GEM_BUG_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags));
@@ -448,19 +447,25 @@ bool i915_request_enable_breadcrumb(struct i915_request *rq)
 
 void i915_request_cancel_breadcrumb(struct i915_request *rq)
 {
+       struct intel_breadcrumbs *b = READ_ONCE(rq->engine)->breadcrumbs;
        struct intel_context *ce = rq->context;
        bool release;
 
-       if (!test_and_clear_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags))
+       spin_lock(&ce->signal_lock);
+       if (!test_and_clear_bit(I915_FENCE_FLAG_SIGNAL, &rq->fence.flags)) {
+               spin_unlock(&ce->signal_lock);
                return;
+       }
 
-       spin_lock(&ce->signal_lock);
        list_del_rcu(&rq->signal_link);
-       release = remove_signaling_context(rq->engine->breadcrumbs, ce);
+       release = remove_signaling_context(b, ce);
        spin_unlock(&ce->signal_lock);
        if (release)
                intel_context_put(ce);
 
+       if (__i915_request_is_complete(rq))
+               irq_signal_request(rq, b);
+
        i915_request_put(rq);
 }
 
index c85b1af06b7bf97627a9248651032f05a431aeaf..7ea367a5444dd3e26d96a601200e3670ff663f72 100644 (file)
@@ -547,7 +547,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
 {
        struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
        struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
-       int i;
+       int i, j;
 
        if (!ttm_dma)
                return;
@@ -556,10 +556,21 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
        if (nvbo->force_coherent)
                return;
 
-       for (i = 0; i < ttm_dma->num_pages; i++)
+       for (i = 0; i < ttm_dma->num_pages; ++i) {
+               struct page *p = ttm_dma->pages[i];
+               size_t num_pages = 1;
+
+               for (j = i + 1; j < ttm_dma->num_pages; ++j) {
+                       if (++p != ttm_dma->pages[j])
+                               break;
+
+                       ++num_pages;
+               }
                dma_sync_single_for_device(drm->dev->dev,
                                           ttm_dma->dma_address[i],
-                                          PAGE_SIZE, DMA_TO_DEVICE);
+                                          num_pages * PAGE_SIZE, DMA_TO_DEVICE);
+               i += num_pages;
+       }
 }
 
 void
@@ -567,7 +578,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
 {
        struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
        struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
-       int i;
+       int i, j;
 
        if (!ttm_dma)
                return;
@@ -576,9 +587,21 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
        if (nvbo->force_coherent)
                return;
 
-       for (i = 0; i < ttm_dma->num_pages; i++)
+       for (i = 0; i < ttm_dma->num_pages; ++i) {
+               struct page *p = ttm_dma->pages[i];
+               size_t num_pages = 1;
+
+               for (j = i + 1; j < ttm_dma->num_pages; ++j) {
+                       if (++p != ttm_dma->pages[j])
+                               break;
+
+                       ++num_pages;
+               }
+
                dma_sync_single_for_cpu(drm->dev->dev, ttm_dma->dma_address[i],
-                                       PAGE_SIZE, DMA_FROM_DEVICE);
+                                       num_pages * PAGE_SIZE, DMA_FROM_DEVICE);
+               i += num_pages;
+       }
 }
 
 void nouveau_bo_add_io_reserve_lru(struct ttm_buffer_object *bo)
index 11e0313db0ea681d4a100b583597c20fad09eee9..74bf1c84b63742065c546a8442e973169c31db8f 100644 (file)
@@ -84,7 +84,7 @@ static struct page *ttm_pool_alloc_page(struct ttm_pool *pool, gfp_t gfp_flags,
         * put_page() on a TTM allocated page is illegal.
         */
        if (order)
-               gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY |
+               gfp_flags |= __GFP_NOMEMALLOC | __GFP_NORETRY | __GFP_NOWARN |
                        __GFP_KSWAPD_RECLAIM;
 
        if (!pool->use_dma_alloc) {
index 0687f0ed60b838a96a00f6d015c192467fd0696a..8cc8ca4a9ac01d68dc8b82f753feb8f18f7cbac7 100644 (file)
@@ -215,9 +215,17 @@ static const struct xpad_device {
        { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
        { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 },
        { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE },
-       { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02a0, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02a1, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02a2, "PDP Wired Controller for Xbox One - Crimson Red", 0, XTYPE_XBOXONE },
        { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
        { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02a7, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02a8, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02ad, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02b3, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
+       { 0x0e6f, 0x02b8, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
        { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
        { 0x0e6f, 0x0346, "Rock Candy Gamepad for Xbox One 2016", 0, XTYPE_XBOXONE },
        { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
@@ -296,6 +304,9 @@ static const struct xpad_device {
        { 0x1bad, 0xfa01, "MadCatz GamePad", 0, XTYPE_XBOX360 },
        { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 },
        { 0x1bad, 0xfd01, "Razer Onza", 0, XTYPE_XBOX360 },
+       { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE },
+       { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 },
+       { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
        { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
        { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
        { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
@@ -429,8 +440,12 @@ static const struct usb_device_id xpad_table[] = {
        XPAD_XBOX360_VENDOR(0x162e),            /* Joytech X-Box 360 controllers */
        XPAD_XBOX360_VENDOR(0x1689),            /* Razer Onza */
        XPAD_XBOX360_VENDOR(0x1bad),            /* Harminix Rock Band Guitar and Drums */
+       XPAD_XBOX360_VENDOR(0x20d6),            /* PowerA Controllers */
+       XPAD_XBOXONE_VENDOR(0x20d6),            /* PowerA Controllers */
        XPAD_XBOX360_VENDOR(0x24c6),            /* PowerA Controllers */
        XPAD_XBOXONE_VENDOR(0x24c6),            /* PowerA Controllers */
+       XPAD_XBOXONE_VENDOR(0x2e24),            /* Hyperkin Duke X-Box One pad */
+       XPAD_XBOX360_VENDOR(0x2f24),            /* GameSir Controllers */
        { }
 };
 
index eda86ab552b9cea04e49afffd9f63bfd05a39a69..17bbaac8b80c892692264cc63772f0a5f25879d3 100644 (file)
@@ -149,12 +149,6 @@ static const struct of_device_id ariel_pwrbutton_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ariel_pwrbutton_of_match);
 
-static const struct spi_device_id ariel_pwrbutton_id_table[] = {
-       { "wyse-ariel-ec-input", 0 },
-       {}
-};
-MODULE_DEVICE_TABLE(spi, ariel_pwrbutton_id_table);
-
 static struct spi_driver ariel_pwrbutton_driver = {
        .driver = {
                .name = "dell-wyse-ariel-ec-input",
index 3a2dcf0805f12386116d46a99a65d1ab5b0c60c7..c74b020796a94134434d79014c48e562136144d1 100644 (file)
@@ -219,6 +219,8 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
                        DMI_MATCH(DMI_SYS_VENDOR, "PEGATRON CORPORATION"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "C15B"),
                },
+       },
+       {
                .matches = {
                        DMI_MATCH(DMI_SYS_VENDOR, "ByteSpeed LLC"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "ByteSpeed Laptop C15B"),
index 19765f1c04f7e3bad7b0e8357b5332545a01c89e..c682b028f0a29d2edb623030c790ebea4540e574 100644 (file)
@@ -157,6 +157,7 @@ static const struct goodix_chip_id goodix_chip_ids[] = {
        { .id = "5663", .data = &gt1x_chip_data },
        { .id = "5688", .data = &gt1x_chip_data },
        { .id = "917S", .data = &gt1x_chip_data },
+       { .id = "9286", .data = &gt1x_chip_data },
 
        { .id = "911", .data = &gt911_chip_data },
        { .id = "9271", .data = &gt911_chip_data },
@@ -1448,6 +1449,7 @@ static const struct of_device_id goodix_of_match[] = {
        { .compatible = "goodix,gt927" },
        { .compatible = "goodix,gt9271" },
        { .compatible = "goodix,gt928" },
+       { .compatible = "goodix,gt9286" },
        { .compatible = "goodix,gt967" },
        { }
 };
index 199cf3daec10661d13e248cec654b3fddd3b4ae6..d8fccf048bf449b465422922e96deaaf71a2a40f 100644 (file)
@@ -29,11 +29,13 @@ struct ili2xxx_chip {
                        void *buf, size_t len);
        int (*get_touch_data)(struct i2c_client *client, u8 *data);
        bool (*parse_touch_data)(const u8 *data, unsigned int finger,
-                                unsigned int *x, unsigned int *y);
+                                unsigned int *x, unsigned int *y,
+                                unsigned int *z);
        bool (*continue_polling)(const u8 *data, bool touch);
        unsigned int max_touches;
        unsigned int resolution;
        bool has_calibrate_reg;
+       bool has_pressure_reg;
 };
 
 struct ili210x {
@@ -82,7 +84,8 @@ static int ili210x_read_touch_data(struct i2c_client *client, u8 *data)
 
 static bool ili210x_touchdata_to_coords(const u8 *touchdata,
                                        unsigned int finger,
-                                       unsigned int *x, unsigned int *y)
+                                       unsigned int *x, unsigned int *y,
+                                       unsigned int *z)
 {
        if (touchdata[0] & BIT(finger))
                return false;
@@ -137,7 +140,8 @@ static int ili211x_read_touch_data(struct i2c_client *client, u8 *data)
 
 static bool ili211x_touchdata_to_coords(const u8 *touchdata,
                                        unsigned int finger,
-                                       unsigned int *x, unsigned int *y)
+                                       unsigned int *x, unsigned int *y,
+                                       unsigned int *z)
 {
        u32 data;
 
@@ -169,7 +173,8 @@ static const struct ili2xxx_chip ili211x_chip = {
 
 static bool ili212x_touchdata_to_coords(const u8 *touchdata,
                                        unsigned int finger,
-                                       unsigned int *x, unsigned int *y)
+                                       unsigned int *x, unsigned int *y,
+                                       unsigned int *z)
 {
        u16 val;
 
@@ -235,7 +240,8 @@ static int ili251x_read_touch_data(struct i2c_client *client, u8 *data)
 
 static bool ili251x_touchdata_to_coords(const u8 *touchdata,
                                        unsigned int finger,
-                                       unsigned int *x, unsigned int *y)
+                                       unsigned int *x, unsigned int *y,
+                                       unsigned int *z)
 {
        u16 val;
 
@@ -245,6 +251,7 @@ static bool ili251x_touchdata_to_coords(const u8 *touchdata,
 
        *x = val & 0x3fff;
        *y = get_unaligned_be16(touchdata + 1 + (finger * 5) + 2);
+       *z = touchdata[1 + (finger * 5) + 4];
 
        return true;
 }
@@ -261,6 +268,7 @@ static const struct ili2xxx_chip ili251x_chip = {
        .continue_polling       = ili251x_check_continue_polling,
        .max_touches            = 10,
        .has_calibrate_reg      = true,
+       .has_pressure_reg       = true,
 };
 
 static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
@@ -268,14 +276,16 @@ static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
        struct input_dev *input = priv->input;
        int i;
        bool contact = false, touch;
-       unsigned int x = 0, y = 0;
+       unsigned int x = 0, y = 0, z = 0;
 
        for (i = 0; i < priv->chip->max_touches; i++) {
-               touch = priv->chip->parse_touch_data(touchdata, i, &x, &y);
+               touch = priv->chip->parse_touch_data(touchdata, i, &x, &y, &z);
 
                input_mt_slot(input, i);
                if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) {
                        touchscreen_report_pos(input, &priv->prop, x, y, true);
+                       if (priv->chip->has_pressure_reg)
+                               input_report_abs(input, ABS_MT_PRESSURE, z);
                        contact = true;
                }
        }
@@ -437,6 +447,8 @@ static int ili210x_i2c_probe(struct i2c_client *client,
        max_xy = (chip->resolution ?: SZ_64K) - 1;
        input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0);
        input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_xy, 0, 0);
+       if (priv->chip->has_pressure_reg)
+               input_set_abs_params(input, ABS_MT_PRESSURE, 0, 0xa, 0, 0);
        touchscreen_parse_properties(input, true, &priv->prop);
 
        error = input_mt_init_slots(input, priv->chip->max_touches,
index bda96762744e6da3e9c3d9a1549a5fc54c9c35b8..b4e7bcbe9b91d9c5e527ccb4d773e20ae4b8d847 100644 (file)
 #define ST1232_TS_NAME "st1232-ts"
 #define ST1633_TS_NAME "st1633-ts"
 
+#define REG_STATUS             0x01    /* Device Status | Error Code */
+
+#define STATUS_NORMAL          0x00
+#define STATUS_INIT            0x01
+#define STATUS_ERROR           0x02
+#define STATUS_AUTO_TUNING     0x03
+#define STATUS_IDLE            0x04
+#define STATUS_POWER_DOWN      0x05
+
+#define ERROR_NONE             0x00
+#define ERROR_INVALID_ADDRESS  0x10
+#define ERROR_INVALID_VALUE    0x20
+#define ERROR_INVALID_PLATFORM 0x30
+
 #define REG_XY_RESOLUTION      0x04
 #define REG_XY_COORDINATES     0x12
 #define ST_TS_MAX_FINGERS      10
@@ -47,7 +61,8 @@ struct st1232_ts_data {
        u8 *read_buf;
 };
 
-static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
+static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg,
+                              unsigned int n)
 {
        struct i2c_client *client = ts->client;
        struct i2c_msg msg[] = {
@@ -59,7 +74,7 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
                {
                        .addr   = client->addr,
                        .flags  = I2C_M_RD | I2C_M_DMA_SAFE,
-                       .len    = ts->read_buf_len,
+                       .len    = n,
                        .buf    = ts->read_buf,
                }
        };
@@ -72,6 +87,22 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts, u8 reg)
        return 0;
 }
 
+static int st1232_ts_wait_ready(struct st1232_ts_data *ts)
+{
+       unsigned int retries;
+       int error;
+
+       for (retries = 10; retries; retries--) {
+               error = st1232_ts_read_data(ts, REG_STATUS, 1);
+               if (!error && ts->read_buf[0] == (STATUS_NORMAL | ERROR_NONE))
+                       return 0;
+
+               usleep_range(1000, 2000);
+       }
+
+       return -ENXIO;
+}
+
 static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
                                     u16 *max_y)
 {
@@ -79,14 +110,14 @@ static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x,
        int error;
 
        /* select resolution register */
-       error = st1232_ts_read_data(ts, REG_XY_RESOLUTION);
+       error = st1232_ts_read_data(ts, REG_XY_RESOLUTION, 3);
        if (error)
                return error;
 
        buf = ts->read_buf;
 
-       *max_x = ((buf[0] & 0x0070) << 4) | buf[1];
-       *max_y = ((buf[0] & 0x0007) << 8) | buf[2];
+       *max_x = (((buf[0] & 0x0070) << 4) | buf[1]) - 1;
+       *max_y = (((buf[0] & 0x0007) << 8) | buf[2]) - 1;
 
        return 0;
 }
@@ -140,7 +171,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
        int count;
        int error;
 
-       error = st1232_ts_read_data(ts, REG_XY_COORDINATES);
+       error = st1232_ts_read_data(ts, REG_XY_COORDINATES, ts->read_buf_len);
        if (error)
                goto out;
 
@@ -251,6 +282,11 @@ static int st1232_ts_probe(struct i2c_client *client,
        input_dev->name = "st1232-touchscreen";
        input_dev->id.bustype = BUS_I2C;
 
+       /* Wait until device is ready */
+       error = st1232_ts_wait_ready(ts);
+       if (error)
+               return error;
+
        /* Read resolution from the chip */
        error = st1232_ts_read_resolution(ts, &max_x, &max_y);
        if (error) {
index 44bea5e4aeda19b05c8e5c8149f2276f7e4e4ae9..b23773583179df8071bce6f64772c0a6e2560159 100644 (file)
@@ -20,6 +20,8 @@
 #include "sdio_cis.h"
 #include "sdio_ops.h"
 
+#define SDIO_READ_CIS_TIMEOUT_MS  (10 * 1000) /* 10s */
+
 static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,
                         const unsigned char *buf, unsigned size)
 {
@@ -274,6 +276,8 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
 
        do {
                unsigned char tpl_code, tpl_link;
+               unsigned long timeout = jiffies +
+                       msecs_to_jiffies(SDIO_READ_CIS_TIMEOUT_MS);
 
                ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code);
                if (ret)
@@ -326,6 +330,8 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
                        prev = &this->next;
 
                        if (ret == -ENOENT) {
+                               if (time_after(jiffies, timeout))
+                                       break;
                                /* warn about unknown tuples */
                                pr_warn_ratelimited("%s: queuing unknown"
                                       " CIS tuple 0x%02x (%u bytes)\n",
index 6301b81cf5731b871e1c7d1523e18583d20f0c63..9bd717ff784be7775fdd31dd9e412799ee7e68f0 100644 (file)
@@ -111,8 +111,13 @@ static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host)
        return host->private;
 }
 
+extern const struct dev_pm_ops sdhci_pltfm_pmops;
+#ifdef CONFIG_PM_SLEEP
 int sdhci_pltfm_suspend(struct device *dev);
 int sdhci_pltfm_resume(struct device *dev);
-extern const struct dev_pm_ops sdhci_pltfm_pmops;
+#else
+static inline int sdhci_pltfm_suspend(struct device *dev) { return 0; }
+static inline int sdhci_pltfm_resume(struct device *dev) { return 0; }
+#endif
 
 #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */
index 81e6389b204205988908064da04a639787d0a8de..6bad4d4dcdf073a13c4b71af5a7e5a97cf7b1173 100644 (file)
@@ -3242,6 +3242,8 @@ static const struct pci_device_id nvme_id_table[] = {
        { PCI_DEVICE(0x144d, 0xa822),   /* Samsung PM1725a */
                .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY |
                                NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+       { PCI_DEVICE(0x1987, 0x5016),   /* Phison E16 */
+               .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
        { PCI_DEVICE(0x1d1d, 0x1f1f),   /* LighNVM qemu device */
                .driver_data = NVME_QUIRK_LIGHTNVM, },
        { PCI_DEVICE(0x1d1d, 0x2807),   /* CNEX WL */
@@ -3259,6 +3261,8 @@ static const struct pci_device_id nvme_id_table[] = {
                .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
        { PCI_DEVICE(0x1d97, 0x2263),   /* SPCC */
                .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, },
+       { PCI_DEVICE(0x2646, 0x2263),   /* KINGSTON A2000 NVMe SSD  */
+               .driver_data = NVME_QUIRK_NO_DEEPEST_PS, },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001),
                .driver_data = NVME_QUIRK_SINGLE_VECTOR },
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) },
index dc1f0f6471896e3dfd3f38dee4084184bc5d588c..aacf06f0b4312539c0d295d96ce5a2d7542c7c17 100644 (file)
@@ -305,7 +305,7 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd)
        length = cmd->pdu_len;
        cmd->nr_mapped = DIV_ROUND_UP(length, PAGE_SIZE);
        offset = cmd->rbytes_done;
-       cmd->sg_idx = DIV_ROUND_UP(offset, PAGE_SIZE);
+       cmd->sg_idx = offset / PAGE_SIZE;
        sg_offset = offset % PAGE_SIZE;
        sg = &cmd->req.sg[cmd->sg_idx];
 
@@ -318,6 +318,7 @@ static void nvmet_tcp_map_pdu_iovec(struct nvmet_tcp_cmd *cmd)
                length -= iov_len;
                sg = sg_next(sg);
                iov++;
+               sg_offset = 0;
        }
 
        iov_iter_kvec(&cmd->recv_msg.msg_iter, READ, cmd->iov,
index 68a9ac6f2fe1776a1f3d2206f5a2145f815f51b0..a701dae653c4a617b46865c9556ad5c969149ab7 100644 (file)
@@ -805,8 +805,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 
        spin_lock_irq(&rtc_lock);
 
-       /* Ensure that the RTC is accessible. Bit 0-6 must be 0! */
-       if ((CMOS_READ(RTC_VALID) & 0x7f) != 0) {
+       /* Ensure that the RTC is accessible. Bit 6 must be 0! */
+       if ((CMOS_READ(RTC_VALID) & 0x40) != 0) {
                spin_unlock_irq(&rtc_lock);
                dev_warn(dev, "not accessible\n");
                retval = -ENXIO;
index f83c13818af3b6d207ae73226ef07a2b351118ea..dcfaf09946ee36de628ded0d776f3ddecc5b84ae 100644 (file)
@@ -21,8 +21,8 @@ unsigned int mc146818_get_time(struct rtc_time *time)
 
 again:
        spin_lock_irqsave(&rtc_lock, flags);
-       /* Ensure that the RTC is accessible. Bit 0-6 must be 0! */
-       if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x7f) != 0)) {
+       /* Ensure that the RTC is accessible. Bit 6 must be 0! */
+       if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x40) != 0)) {
                spin_unlock_irqrestore(&rtc_lock, flags);
                memset(time, 0xff, sizeof(*time));
                return 0;
index 1cb82fa6a60e4c40d6e1c9d35287c274dc286fd0..39d147e251bf4f2e103a9b003b2fcf4a025b880a 100644 (file)
@@ -559,6 +559,9 @@ __lpfc_nvme_ls_req(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                return -ENODEV;
        }
 
+       if (!vport->phba->sli4_hba.nvmels_wq)
+               return -ENOMEM;
+
        /*
         * there are two dma buf in the request, actually there is one and
         * the second one is just the start address + cmd size.
index a5f988a9f9482bd54eef3f96cce4928c42ee02a5..b5442f979b4d0170950d9ded3d3dbe9e3066d6da 100644 (file)
@@ -56,7 +56,7 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
         * managed with the xHCI and the SuperSpeed hub so we create the
         * link from xHCI instead.
         */
-       while (!dev_is_pci(dev))
+       while (dev && !dev_is_pci(dev))
                dev = dev->parent;
 
        if (!dev)
index 134dc2005ce97de81ee1787510d4772395da8ef4..c9f6e975828852f09206ca11ed84c0fb6582e21c 100644 (file)
@@ -1329,14 +1329,17 @@ static int usblp_set_protocol(struct usblp *usblp, int protocol)
        if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL)
                return -EINVAL;
 
-       alts = usblp->protocol[protocol].alt_setting;
-       if (alts < 0)
-               return -EINVAL;
-       r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
-       if (r < 0) {
-               printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
-                       alts, usblp->ifnum);
-               return r;
+       /* Don't unnecessarily set the interface if there's a single alt. */
+       if (usblp->intf->num_altsetting > 1) {
+               alts = usblp->protocol[protocol].alt_setting;
+               if (alts < 0)
+                       return -EINVAL;
+               r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
+               if (r < 0) {
+                       printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
+                               alts, usblp->ifnum);
+                       return r;
+               }
        }
 
        usblp->bidir = (usblp->protocol[protocol].epread != NULL);
index 0a0d11151cfb88cb6ecbd7e9264f26e75de148d6..ad4c94366dadfd4051c8459f4db0bd566fd18b04 100644 (file)
@@ -1543,7 +1543,6 @@ static void dwc2_hsotg_complete_oursetup(struct usb_ep *ep,
 static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg,
                                            u32 windex)
 {
-       struct dwc2_hsotg_ep *ep;
        int dir = (windex & USB_DIR_IN) ? 1 : 0;
        int idx = windex & 0x7F;
 
@@ -1553,12 +1552,7 @@ static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg,
        if (idx > hsotg->num_of_eps)
                return NULL;
 
-       ep = index_to_ep(hsotg, idx, dir);
-
-       if (idx && ep->dir_in != dir)
-               return NULL;
-
-       return ep;
+       return index_to_ep(hsotg, idx, dir);
 }
 
 /**
index 841daec70b6efd808b1407da9a4ba561eb98c660..3101f0dcf6ae853260c2f3abc6c78a61b1b1d89f 100644 (file)
@@ -1758,7 +1758,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
                if (PMSG_IS_AUTO(msg))
                        break;
 
-               ret = dwc3_core_init(dwc);
+               ret = dwc3_core_init_for_resume(dwc);
                if (ret)
                        return ret;
 
index 30313b233680d6a875928846d8fa8bd5eb7b1c25..99c7fc0d1d597369b819d98c238d63b1009f2f6c 100644 (file)
@@ -403,8 +403,10 @@ static int eth_bind(struct usb_composite_dev *cdev)
                struct usb_descriptor_header *usb_desc;
 
                usb_desc = usb_otg_descriptor_alloc(gadget);
-               if (!usb_desc)
+               if (!usb_desc) {
+                       status = -ENOMEM;
                        goto fail1;
+               }
                usb_otg_descriptor_init(gadget, usb_desc);
                otg_desc[0] = usb_desc;
                otg_desc[1] = NULL;
index 6497185ec4e7ab822cec2651385f64b1981fcdcb..bfd8e77788e29fe1c051b4f3f8ef14c772cb5dae 100644 (file)
@@ -999,8 +999,10 @@ static int ast_vhub_of_parse_str_desc(struct ast_vhub *vhub,
                str_array[offset].s = NULL;
 
                ret = ast_vhub_str_alloc_add(vhub, &lang_str);
-               if (ret)
+               if (ret) {
+                       of_node_put(child);
                        break;
+               }
        }
 
        return ret;
index 45c54d56ecbd55fd8241983c2c3ce42d76ffb809..b45e5bf0899798efbda164feab120da4c424fd30 100644 (file)
@@ -200,6 +200,8 @@ static struct mu3h_sch_ep_info *create_sch_ep(struct usb_device *udev,
 
        sch_ep->sch_tt = tt;
        sch_ep->ep = ep;
+       INIT_LIST_HEAD(&sch_ep->endpoint);
+       INIT_LIST_HEAD(&sch_ep->tt_endpoint);
 
        return sch_ep;
 }
@@ -373,6 +375,7 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
                                        sch_ep->bw_budget_table[j];
                }
        }
+       sch_ep->allocated = used;
 }
 
 static int check_sch_tt(struct usb_device *udev,
@@ -541,6 +544,22 @@ static int check_sch_bw(struct usb_device *udev,
        return 0;
 }
 
+static void destroy_sch_ep(struct usb_device *udev,
+       struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep)
+{
+       /* only release ep bw check passed by check_sch_bw() */
+       if (sch_ep->allocated)
+               update_bus_bw(sch_bw, sch_ep, 0);
+
+       list_del(&sch_ep->endpoint);
+
+       if (sch_ep->sch_tt) {
+               list_del(&sch_ep->tt_endpoint);
+               drop_tt(udev);
+       }
+       kfree(sch_ep);
+}
+
 static bool need_bw_sch(struct usb_host_endpoint *ep,
        enum usb_device_speed speed, int has_tt)
 {
@@ -583,6 +602,8 @@ int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk)
 
        mtk->sch_array = sch_array;
 
+       INIT_LIST_HEAD(&mtk->bw_ep_chk_list);
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(xhci_mtk_sch_init);
@@ -601,19 +622,14 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
        struct xhci_ep_ctx *ep_ctx;
        struct xhci_slot_ctx *slot_ctx;
        struct xhci_virt_device *virt_dev;
-       struct mu3h_sch_bw_info *sch_bw;
        struct mu3h_sch_ep_info *sch_ep;
-       struct mu3h_sch_bw_info *sch_array;
        unsigned int ep_index;
-       int bw_index;
-       int ret = 0;
 
        xhci = hcd_to_xhci(hcd);
        virt_dev = xhci->devs[udev->slot_id];
        ep_index = xhci_get_endpoint_index(&ep->desc);
        slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
        ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
-       sch_array = mtk->sch_array;
 
        xhci_dbg(xhci, "%s() type:%d, speed:%d, mpkt:%d, dir:%d, ep:%p\n",
                __func__, usb_endpoint_type(&ep->desc), udev->speed,
@@ -632,35 +648,13 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
                return 0;
        }
 
-       bw_index = get_bw_index(xhci, udev, ep);
-       sch_bw = &sch_array[bw_index];
-
        sch_ep = create_sch_ep(udev, ep, ep_ctx);
        if (IS_ERR_OR_NULL(sch_ep))
                return -ENOMEM;
 
        setup_sch_info(udev, ep_ctx, sch_ep);
 
-       ret = check_sch_bw(udev, sch_bw, sch_ep);
-       if (ret) {
-               xhci_err(xhci, "Not enough bandwidth!\n");
-               if (is_fs_or_ls(udev->speed))
-                       drop_tt(udev);
-
-               kfree(sch_ep);
-               return -ENOSPC;
-       }
-
-       list_add_tail(&sch_ep->endpoint, &sch_bw->bw_ep_list);
-
-       ep_ctx->reserved[0] |= cpu_to_le32(EP_BPKTS(sch_ep->pkts)
-               | EP_BCSCOUNT(sch_ep->cs_count) | EP_BBM(sch_ep->burst_mode));
-       ep_ctx->reserved[1] |= cpu_to_le32(EP_BOFFSET(sch_ep->offset)
-               | EP_BREPEAT(sch_ep->repeat));
-
-       xhci_dbg(xhci, " PKTS:%x, CSCOUNT:%x, BM:%x, OFFSET:%x, REPEAT:%x\n",
-                       sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode,
-                       sch_ep->offset, sch_ep->repeat);
+       list_add_tail(&sch_ep->endpoint, &mtk->bw_ep_chk_list);
 
        return 0;
 }
@@ -675,7 +669,7 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
        struct xhci_virt_device *virt_dev;
        struct mu3h_sch_bw_info *sch_array;
        struct mu3h_sch_bw_info *sch_bw;
-       struct mu3h_sch_ep_info *sch_ep;
+       struct mu3h_sch_ep_info *sch_ep, *tmp;
        int bw_index;
 
        xhci = hcd_to_xhci(hcd);
@@ -694,17 +688,79 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
        bw_index = get_bw_index(xhci, udev, ep);
        sch_bw = &sch_array[bw_index];
 
-       list_for_each_entry(sch_ep, &sch_bw->bw_ep_list, endpoint) {
+       list_for_each_entry_safe(sch_ep, tmp, &sch_bw->bw_ep_list, endpoint) {
                if (sch_ep->ep == ep) {
-                       update_bus_bw(sch_bw, sch_ep, 0);
-                       list_del(&sch_ep->endpoint);
-                       if (is_fs_or_ls(udev->speed)) {
-                               list_del(&sch_ep->tt_endpoint);
-                               drop_tt(udev);
-                       }
-                       kfree(sch_ep);
+                       destroy_sch_ep(udev, sch_bw, sch_ep);
                        break;
                }
        }
 }
 EXPORT_SYMBOL_GPL(xhci_mtk_drop_ep_quirk);
+
+int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct xhci_virt_device *virt_dev = xhci->devs[udev->slot_id];
+       struct mu3h_sch_bw_info *sch_bw;
+       struct mu3h_sch_ep_info *sch_ep, *tmp;
+       int bw_index, ret;
+
+       xhci_dbg(xhci, "%s() udev %s\n", __func__, dev_name(&udev->dev));
+
+       list_for_each_entry(sch_ep, &mtk->bw_ep_chk_list, endpoint) {
+               bw_index = get_bw_index(xhci, udev, sch_ep->ep);
+               sch_bw = &mtk->sch_array[bw_index];
+
+               ret = check_sch_bw(udev, sch_bw, sch_ep);
+               if (ret) {
+                       xhci_err(xhci, "Not enough bandwidth!\n");
+                       return -ENOSPC;
+               }
+       }
+
+       list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) {
+               struct xhci_ep_ctx *ep_ctx;
+               struct usb_host_endpoint *ep = sch_ep->ep;
+               unsigned int ep_index = xhci_get_endpoint_index(&ep->desc);
+
+               bw_index = get_bw_index(xhci, udev, ep);
+               sch_bw = &mtk->sch_array[bw_index];
+
+               list_move_tail(&sch_ep->endpoint, &sch_bw->bw_ep_list);
+
+               ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
+               ep_ctx->reserved[0] |= cpu_to_le32(EP_BPKTS(sch_ep->pkts)
+                       | EP_BCSCOUNT(sch_ep->cs_count)
+                       | EP_BBM(sch_ep->burst_mode));
+               ep_ctx->reserved[1] |= cpu_to_le32(EP_BOFFSET(sch_ep->offset)
+                       | EP_BREPEAT(sch_ep->repeat));
+
+               xhci_dbg(xhci, " PKTS:%x, CSCOUNT:%x, BM:%x, OFFSET:%x, REPEAT:%x\n",
+                       sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode,
+                       sch_ep->offset, sch_ep->repeat);
+       }
+
+       return xhci_check_bandwidth(hcd, udev);
+}
+EXPORT_SYMBOL_GPL(xhci_mtk_check_bandwidth);
+
+void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+{
+       struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct mu3h_sch_bw_info *sch_bw;
+       struct mu3h_sch_ep_info *sch_ep, *tmp;
+       int bw_index;
+
+       xhci_dbg(xhci, "%s() udev %s\n", __func__, dev_name(&udev->dev));
+
+       list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) {
+               bw_index = get_bw_index(xhci, udev, sch_ep->ep);
+               sch_bw = &mtk->sch_array[bw_index];
+               destroy_sch_ep(udev, sch_bw, sch_ep);
+       }
+
+       xhci_reset_bandwidth(hcd, udev);
+}
+EXPORT_SYMBOL_GPL(xhci_mtk_reset_bandwidth);
index 8f321f39ab960f169f4fbca420eb3381e3ae206e..fe010cc61f19bbc3180c6ff29876a09dca1a92a0 100644 (file)
@@ -347,6 +347,8 @@ static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
 static int xhci_mtk_setup(struct usb_hcd *hcd);
 static const struct xhci_driver_overrides xhci_mtk_overrides __initconst = {
        .reset = xhci_mtk_setup,
+       .check_bandwidth = xhci_mtk_check_bandwidth,
+       .reset_bandwidth = xhci_mtk_reset_bandwidth,
 };
 
 static struct hc_driver __read_mostly xhci_mtk_hc_driver;
index a93cfe8179049d5d6518d27c4d504aaf13c1b918..cbb09dfea62e0f8be63a5ac4eac18c972c85ed7a 100644 (file)
@@ -59,6 +59,7 @@ struct mu3h_sch_bw_info {
  * @ep_type: endpoint type
  * @maxpkt: max packet size of endpoint
  * @ep: address of usb_host_endpoint struct
+ * @allocated: the bandwidth is aready allocated from bus_bw
  * @offset: which uframe of the interval that transfer should be
  *             scheduled first time within the interval
  * @repeat: the time gap between two uframes that transfers are
@@ -86,6 +87,7 @@ struct mu3h_sch_ep_info {
        u32 ep_type;
        u32 maxpkt;
        void *ep;
+       bool allocated;
        /*
         * mtk xHCI scheduling information put into reserved DWs
         * in ep context
@@ -131,6 +133,7 @@ struct xhci_hcd_mtk {
        struct device *dev;
        struct usb_hcd *hcd;
        struct mu3h_sch_bw_info *sch_array;
+       struct list_head bw_ep_chk_list;
        struct mu3c_ippc_regs __iomem *ippc_regs;
        bool has_ippc;
        int num_u2_ports;
@@ -166,6 +169,8 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
                struct usb_host_endpoint *ep);
 void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
                struct usb_host_endpoint *ep);
+int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
+void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
 
 #else
 static inline int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd,
@@ -179,6 +184,16 @@ static inline void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd,
 {
 }
 
+static inline int xhci_mtk_check_bandwidth(struct usb_hcd *hcd,
+               struct usb_device *udev)
+{
+       return 0;
+}
+
+static inline void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd,
+               struct usb_device *udev)
+{
+}
 #endif
 
 #endif         /* _XHCI_MTK_H_ */
index 60651a50770f93aa9e652e4ddbd127169cceba7a..8ca1a235d1645144824e1cdd129926f699f4a298 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/mbus.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/phy/phy.h>
 
 #include <linux/usb.h>
 #include <linux/usb/hcd.h>
@@ -74,6 +75,47 @@ int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd)
        return 0;
 }
 
+int xhci_mvebu_a3700_plat_setup(struct usb_hcd *hcd)
+{
+       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct device *dev = hcd->self.controller;
+       struct phy *phy;
+       int ret;
+
+       /* Old bindings miss the PHY handle */
+       phy = of_phy_get(dev->of_node, "usb3-phy");
+       if (IS_ERR(phy) && PTR_ERR(phy) == -EPROBE_DEFER)
+               return -EPROBE_DEFER;
+       else if (IS_ERR(phy))
+               goto phy_out;
+
+       ret = phy_init(phy);
+       if (ret)
+               goto phy_put;
+
+       ret = phy_set_mode(phy, PHY_MODE_USB_HOST_SS);
+       if (ret)
+               goto phy_exit;
+
+       ret = phy_power_on(phy);
+       if (ret == -EOPNOTSUPP) {
+               /* Skip initializatin of XHCI PHY when it is unsupported by firmware */
+               dev_warn(dev, "PHY unsupported by firmware\n");
+               xhci->quirks |= XHCI_SKIP_PHY_INIT;
+       }
+       if (ret)
+               goto phy_exit;
+
+       phy_power_off(phy);
+phy_exit:
+       phy_exit(phy);
+phy_put:
+       of_phy_put(phy);
+phy_out:
+
+       return 0;
+}
+
 int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
index 3be021793cc8b07fcab2529214e57599c6f20d2d..01bf3fcb3eca5da04cbb7017e11cc176e2bf6eb3 100644 (file)
@@ -12,6 +12,7 @@ struct usb_hcd;
 
 #if IS_ENABLED(CONFIG_USB_XHCI_MVEBU)
 int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd);
+int xhci_mvebu_a3700_plat_setup(struct usb_hcd *hcd);
 int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd);
 #else
 static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd)
@@ -19,6 +20,11 @@ static inline int xhci_mvebu_mbus_init_quirk(struct usb_hcd *hcd)
        return 0;
 }
 
+static inline int xhci_mvebu_a3700_plat_setup(struct usb_hcd *hcd)
+{
+       return 0;
+}
+
 static inline int xhci_mvebu_a3700_init_quirk(struct usb_hcd *hcd)
 {
        return 0;
index 4d34f6005381e6eb1b9dab31dd2e5ec9180ab5e4..c1edcc9b13cece07c9dc0e00c27a7f0848f4875c 100644 (file)
@@ -44,6 +44,16 @@ static void xhci_priv_plat_start(struct usb_hcd *hcd)
                priv->plat_start(hcd);
 }
 
+static int xhci_priv_plat_setup(struct usb_hcd *hcd)
+{
+       struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
+
+       if (!priv->plat_setup)
+               return 0;
+
+       return priv->plat_setup(hcd);
+}
+
 static int xhci_priv_init_quirk(struct usb_hcd *hcd)
 {
        struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
@@ -111,6 +121,7 @@ static const struct xhci_plat_priv xhci_plat_marvell_armada = {
 };
 
 static const struct xhci_plat_priv xhci_plat_marvell_armada3700 = {
+       .plat_setup = xhci_mvebu_a3700_plat_setup,
        .init_quirk = xhci_mvebu_a3700_init_quirk,
 };
 
@@ -330,7 +341,14 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
        hcd->tpl_support = of_usb_host_tpl_support(sysdev->of_node);
        xhci->shared_hcd->tpl_support = hcd->tpl_support;
-       if (priv && (priv->quirks & XHCI_SKIP_PHY_INIT))
+
+       if (priv) {
+               ret = xhci_priv_plat_setup(hcd);
+               if (ret)
+                       goto disable_usb_phy;
+       }
+
+       if ((xhci->quirks & XHCI_SKIP_PHY_INIT) || (priv && (priv->quirks & XHCI_SKIP_PHY_INIT)))
                hcd->skip_phy_initialization = 1;
 
        if (priv && (priv->quirks & XHCI_SG_TRB_CACHE_SIZE_QUIRK))
index 1fb149d1fbcea319d712ccc9af6857e54c9cc6f8..561d0b7bce0980c10d821c96c338a2c1f909d26a 100644 (file)
@@ -13,6 +13,7 @@
 struct xhci_plat_priv {
        const char *firmware_name;
        unsigned long long quirks;
+       int (*plat_setup)(struct usb_hcd *);
        void (*plat_start)(struct usb_hcd *);
        int (*init_quirk)(struct usb_hcd *);
        int (*suspend_quirk)(struct usb_hcd *);
index cf0c93a90200f8c487dbd0e3fa728c7c552d40d4..89c3be9917f6610374b3647e81429b2e04e32753 100644 (file)
@@ -699,11 +699,16 @@ static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci,
        dma_unmap_single(dev, seg->bounce_dma, ring->bounce_buf_len,
                         DMA_FROM_DEVICE);
        /* for in tranfers we need to copy the data from bounce to sg */
-       len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, seg->bounce_buf,
-                            seg->bounce_len, seg->bounce_offs);
-       if (len != seg->bounce_len)
-               xhci_warn(xhci, "WARN Wrong bounce buffer read length: %zu != %d\n",
-                               len, seg->bounce_len);
+       if (urb->num_sgs) {
+               len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs, seg->bounce_buf,
+                                          seg->bounce_len, seg->bounce_offs);
+               if (len != seg->bounce_len)
+                       xhci_warn(xhci, "WARN Wrong bounce buffer read length: %zu != %d\n",
+                                 len, seg->bounce_len);
+       } else {
+               memcpy(urb->transfer_buffer + seg->bounce_offs, seg->bounce_buf,
+                      seg->bounce_len);
+       }
        seg->bounce_len = 0;
        seg->bounce_offs = 0;
 }
@@ -3277,12 +3282,16 @@ static int xhci_align_td(struct xhci_hcd *xhci, struct urb *urb, u32 enqd_len,
 
        /* create a max max_pkt sized bounce buffer pointed to by last trb */
        if (usb_urb_dir_out(urb)) {
-               len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
-                                  seg->bounce_buf, new_buff_len, enqd_len);
-               if (len != new_buff_len)
-                       xhci_warn(xhci,
-                               "WARN Wrong bounce buffer write length: %zu != %d\n",
-                               len, new_buff_len);
+               if (urb->num_sgs) {
+                       len = sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
+                                                seg->bounce_buf, new_buff_len, enqd_len);
+                       if (len != new_buff_len)
+                               xhci_warn(xhci, "WARN Wrong bounce buffer write length: %zu != %d\n",
+                                         len, new_buff_len);
+               } else {
+                       memcpy(seg->bounce_buf, urb->transfer_buffer + enqd_len, new_buff_len);
+               }
+
                seg->bounce_dma = dma_map_single(dev, seg->bounce_buf,
                                                 max_pkt, DMA_TO_DEVICE);
        } else {
index e86940571b4cf1ec7153ad15a0f22a2a2510544e..345a221028c6f254d8095867a8c85fb1f62c9e0d 100644 (file)
@@ -2985,7 +2985,7 @@ static void xhci_check_bw_drop_ep_streams(struct xhci_hcd *xhci,
  * else should be touching the xhci->devs[slot_id] structure, so we
  * don't need to take the xhci->lock for manipulating that.
  */
-static int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
 {
        int i;
        int ret = 0;
@@ -3083,7 +3083,7 @@ command_cleanup:
        return ret;
 }
 
-static void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
+void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
 {
        struct xhci_hcd *xhci;
        struct xhci_virt_device *virt_dev;
@@ -5510,6 +5510,10 @@ void xhci_init_driver(struct hc_driver *drv,
                        drv->reset = over->reset;
                if (over->start)
                        drv->start = over->start;
+               if (over->check_bandwidth)
+                       drv->check_bandwidth = over->check_bandwidth;
+               if (over->reset_bandwidth)
+                       drv->reset_bandwidth = over->reset_bandwidth;
        }
 }
 EXPORT_SYMBOL_GPL(xhci_init_driver);
index 25e57bc9c3cc6b655b7ec1d4c1dfa54a80eaec85..07ff95016f119abff7c268095d6f4eee897e1e2c 100644 (file)
@@ -1920,6 +1920,8 @@ struct xhci_driver_overrides {
        size_t extra_priv_size;
        int (*reset)(struct usb_hcd *hcd);
        int (*start)(struct usb_hcd *hcd);
+       int (*check_bandwidth)(struct usb_hcd *, struct usb_device *);
+       void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
 };
 
 #define        XHCI_CFC_DELAY          10
@@ -2074,6 +2076,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
 void xhci_shutdown(struct usb_hcd *hcd);
 void xhci_init_driver(struct hc_driver *drv,
                      const struct xhci_driver_overrides *over);
+int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
+void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);
 int xhci_ext_cap_init(struct xhci_hcd *xhci);
 
index ac9a81ae821642e01d96b2151ca13384c7111cf3..e6fa13701808247542ea6905a0659b194f466fd8 100644 (file)
@@ -126,6 +126,7 @@ struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt)
                }
 
                usbhs_pipe_clear_without_sequence(pipe, 0, 0);
+               usbhs_pipe_running(pipe, 0);
 
                __usbhsf_pkt_del(pkt);
        }
index fbb10dfc56e3184a44277a16a5dc7c1d074a2127..7bec1e730b2093147feda765c189f5cfc349a5b1 100644 (file)
@@ -61,6 +61,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */
        { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */
        { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */
+       { USB_DEVICE(0x0988, 0x0578) }, /* Teraoka AD2000 */
        { USB_DEVICE(0x0B00, 0x3070) }, /* Ingenico 3070 */
        { USB_DEVICE(0x0BED, 0x1100) }, /* MEI (TM) Cashflow-SC Bill/Voucher Acceptor */
        { USB_DEVICE(0x0BED, 0x1101) }, /* MEI series 2000 Combo Acceptor */
@@ -201,6 +202,7 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */
        { USB_DEVICE(0x1901, 0x0195) }, /* GE B850/B650/B450 CP2104 DP UART interface */
        { USB_DEVICE(0x1901, 0x0196) }, /* GE B850 CP2105 DP UART interface */
+       { USB_DEVICE(0x199B, 0xBA30) }, /* LORD WSDA-200-USB */
        { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */
        { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
        { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
index 3fe959104311b4019497b288194647afe1aba653..2049e66f34a3fd1c73c832ffd1866b0864869544 100644 (file)
@@ -425,6 +425,8 @@ static void option_instat_callback(struct urb *urb);
 #define CINTERION_PRODUCT_AHXX_2RMNET          0x0084
 #define CINTERION_PRODUCT_AHXX_AUDIO           0x0085
 #define CINTERION_PRODUCT_CLS8                 0x00b0
+#define CINTERION_PRODUCT_MV31_MBIM            0x00b3
+#define CINTERION_PRODUCT_MV31_RMNET           0x00b7
 
 /* Olivetti products */
 #define OLIVETTI_VENDOR_ID                     0x0b3c
@@ -1914,6 +1916,10 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC25_MDMNET) },
        { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) }, /* HC28 enumerates with Siemens or Cinterion VID depending on FW revision */
        { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
+       { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV31_MBIM, 0xff),
+         .driver_info = RSVD(3)},
+       { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_MV31_RMNET, 0xff),
+         .driver_info = RSVD(0)},
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100),
          .driver_info = RSVD(4) },
        { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD120),
index 88dde3455bfd99ddc585eeba97cdf434a4dd43a6..b5fe6d2ad22f5133b6d27142f5440785a2852c36 100644 (file)
@@ -87,6 +87,7 @@ struct mlx5_vq_restore_info {
        u64 device_addr;
        u64 driver_addr;
        u16 avail_index;
+       u16 used_index;
        bool ready;
        struct vdpa_callback cb;
        bool restore;
@@ -121,6 +122,7 @@ struct mlx5_vdpa_virtqueue {
        u32 virtq_id;
        struct mlx5_vdpa_net *ndev;
        u16 avail_idx;
+       u16 used_idx;
        int fw_state;
 
        /* keep last in the struct */
@@ -804,6 +806,7 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 
        obj_context = MLX5_ADDR_OF(create_virtio_net_q_in, in, obj_context);
        MLX5_SET(virtio_net_q_object, obj_context, hw_available_index, mvq->avail_idx);
+       MLX5_SET(virtio_net_q_object, obj_context, hw_used_index, mvq->used_idx);
        MLX5_SET(virtio_net_q_object, obj_context, queue_feature_bit_mask_12_3,
                 get_features_12_3(ndev->mvdev.actual_features));
        vq_ctx = MLX5_ADDR_OF(virtio_net_q_object, obj_context, virtio_q_context);
@@ -1022,6 +1025,7 @@ static int connect_qps(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m
 struct mlx5_virtq_attr {
        u8 state;
        u16 available_index;
+       u16 used_index;
 };
 
 static int query_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq,
@@ -1052,6 +1056,7 @@ static int query_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueu
        memset(attr, 0, sizeof(*attr));
        attr->state = MLX5_GET(virtio_net_q_object, obj_context, state);
        attr->available_index = MLX5_GET(virtio_net_q_object, obj_context, hw_available_index);
+       attr->used_index = MLX5_GET(virtio_net_q_object, obj_context, hw_used_index);
        kfree(out);
        return 0;
 
@@ -1535,6 +1540,16 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev)
        }
 }
 
+static void clear_virtqueues(struct mlx5_vdpa_net *ndev)
+{
+       int i;
+
+       for (i = ndev->mvdev.max_vqs - 1; i >= 0; i--) {
+               ndev->vqs[i].avail_idx = 0;
+               ndev->vqs[i].used_idx = 0;
+       }
+}
+
 /* TODO: cross-endian support */
 static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev)
 {
@@ -1610,6 +1625,7 @@ static int save_channel_info(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqu
                return err;
 
        ri->avail_index = attr.available_index;
+       ri->used_index = attr.used_index;
        ri->ready = mvq->ready;
        ri->num_ent = mvq->num_ent;
        ri->desc_addr = mvq->desc_addr;
@@ -1654,6 +1670,7 @@ static void restore_channels_info(struct mlx5_vdpa_net *ndev)
                        continue;
 
                mvq->avail_idx = ri->avail_index;
+               mvq->used_idx = ri->used_index;
                mvq->ready = ri->ready;
                mvq->num_ent = ri->num_ent;
                mvq->desc_addr = ri->desc_addr;
@@ -1768,6 +1785,7 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status)
        if (!status) {
                mlx5_vdpa_info(mvdev, "performing device reset\n");
                teardown_driver(ndev);
+               clear_virtqueues(ndev);
                mlx5_vdpa_destroy_mr(&ndev->mvdev);
                ndev->mvdev.status = 0;
                ndev->mvdev.mlx_features = 0;
index 68900f1629bffa97d243d645c73777157a59d414..97ac363b5df169db6c8f594b6bc3080c7473280f 100644 (file)
@@ -737,6 +737,7 @@ static int
 cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
 {
        struct inode *inode;
+       int rc;
 
        if (flags & LOOKUP_RCU)
                return -ECHILD;
@@ -746,8 +747,25 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
                if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
                        CIFS_I(inode)->time = 0; /* force reval */
 
-               if (cifs_revalidate_dentry(direntry))
-                       return 0;
+               rc = cifs_revalidate_dentry(direntry);
+               if (rc) {
+                       cifs_dbg(FYI, "cifs_revalidate_dentry failed with rc=%d", rc);
+                       switch (rc) {
+                       case -ENOENT:
+                       case -ESTALE:
+                               /*
+                                * Those errors mean the dentry is invalid
+                                * (file was deleted or recreated)
+                                */
+                               return 0;
+                       default:
+                               /*
+                                * Otherwise some unexpected error happened
+                                * report it as-is to VFS layer
+                                */
+                               return rc;
+                       }
+               }
                else {
                        /*
                         * If the inode wasn't known to be a dfs entry when
index d85edf5d1429418728d9fa44fac2a2d9a6df7684..a5a9e33c0d739dbe1c80c97c12e9e4a4b4c1d390 100644 (file)
@@ -286,7 +286,7 @@ struct smb2_negotiate_req {
        __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
        __le16 NegotiateContextCount;  /* SMB3.1.1 only. MBZ earlier */
        __le16 Reserved2;
-       __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
+       __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
 } __packed;
 
 /* Dialects */
index 95ef26b555b911c620a5c357bea82bb25e3c8f11..4a2b836eb0177024627b252b11d81e802bd0851f 100644 (file)
@@ -666,10 +666,22 @@ wait_for_compound_request(struct TCP_Server_Info *server, int num,
 
        if (*credits < num) {
                /*
-                * Return immediately if not too many requests in flight since
-                * we will likely be stuck on waiting for credits.
+                * If the server is tight on resources or just gives us less
+                * credits for other reasons (e.g. requests are coming out of
+                * order and the server delays granting more credits until it
+                * processes a missing mid) and we exhausted most available
+                * credits there may be situations when we try to send
+                * a compound request but we don't have enough credits. At this
+                * point the client needs to decide if it should wait for
+                * additional credits or fail the request. If at least one
+                * request is in flight there is a high probability that the
+                * server will return enough credits to satisfy this compound
+                * request.
+                *
+                * Return immediately if no requests in flight since we will be
+                * stuck on waiting for credits.
                 */
-               if (server->in_flight < num - *credits) {
+               if (server->in_flight == 0) {
                        spin_unlock(&server->req_lock);
                        trace_smb3_insufficient_credits(server->CurrentMid,
                                        server->hostname, scredits, sin_flight);
index b5c109703daaf9ff2f4384c1f53e15ee1c5f3e55..21c20fd5f9ee75a096241df596ec9ed45292eaa5 100644 (file)
@@ -735,9 +735,10 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
 
                mutex_unlock(&hugetlb_fault_mutex_table[hash]);
 
+               set_page_huge_active(page);
                /*
                 * unlock_page because locked by add_to_page_cache()
-                * page_put due to reference from alloc_huge_page()
+                * put_page() due to reference from alloc_huge_page()
                 */
                unlock_page(page);
                put_page(page);
index 38c6cbe1ab387d8d50560dd71e9f6008d6566764..1f68105a41ed996622a4c35dbcb6e97e55e00922 100644 (file)
@@ -2205,6 +2205,9 @@ static void __io_req_task_submit(struct io_kiocb *req)
        else
                __io_req_task_cancel(req, -EFAULT);
        mutex_unlock(&ctx->uring_lock);
+
+       if (ctx->flags & IORING_SETUP_SQPOLL)
+               io_sq_thread_drop_mm_files();
 }
 
 static void io_req_task_submit(struct callback_head *cb)
@@ -8982,12 +8985,6 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
 
        if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
                atomic_dec(&task->io_uring->in_idle);
-               /*
-                * If the files that are going away are the ones in the thread
-                * identity, clear them out.
-                */
-               if (task->io_uring->identity->files == files)
-                       task->io_uring->identity->files = NULL;
                io_sq_thread_unpark(ctx->sq_data);
        }
 }
index f5e92fe9151c389a9e55a2c6f857eb91279a2fdb..bd1c39907b924a4f0ab5ad1db20a4d3002f11a88 100644 (file)
@@ -783,6 +783,7 @@ drm_dp_mst_detect_port(struct drm_connector *connector,
 
 struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
 
+int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count);
 
 int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);
 
index ca86a00abe862112b77b3007ba33811ee1bd2698..a104b298019ae4630ea5e39f06d8eeee327ef853 100644 (file)
@@ -46,6 +46,7 @@
                                 SYSCALL_WORK_SYSCALL_TRACE |           \
                                 SYSCALL_WORK_SYSCALL_AUDIT |           \
                                 SYSCALL_WORK_SYSCALL_USER_DISPATCH |   \
+                                SYSCALL_WORK_SYSCALL_EXIT_TRAP |       \
                                 ARCH_SYSCALL_WORK_EXIT)
 
 /*
index ebca2ef022127519ce9ec2c5c58cbe33b6a198af..b5807f23caf80458a6238d286c4deec6fd21fe07 100644 (file)
@@ -770,6 +770,8 @@ static inline void huge_ptep_modify_prot_commit(struct vm_area_struct *vma,
 }
 #endif
 
+void set_page_huge_active(struct page *page);
+
 #else  /* CONFIG_HUGETLB_PAGE */
 struct hstate {};
 
index b3f0e2018c6238a67a2b1cda397c3dab00689755..efa96263b81b3053d3dc1ec460e019ffb841ec64 100644 (file)
@@ -616,7 +616,10 @@ static inline void dev_iommu_fwspec_set(struct device *dev,
 
 static inline void *dev_iommu_priv_get(struct device *dev)
 {
-       return dev->iommu->priv;
+       if (dev->iommu)
+               return dev->iommu->priv;
+       else
+               return NULL;
 }
 
 static inline void dev_iommu_priv_set(struct device *dev, void *priv)
index 4aeb1c4c7e07bb86665e4f58ce7b70dc3b83adc3..2efde6a79b7ee7095aad7d7123e6cf4f61b97189 100644 (file)
@@ -928,7 +928,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
        __irq_alloc_descs(irq, from, cnt, node, THIS_MODULE, NULL)
 
 #define irq_alloc_desc(node)                   \
-       irq_alloc_descs(-1, 0, 1, node)
+       irq_alloc_descs(-1, 1, 1, node)
 
 #define irq_alloc_desc_at(at, node)            \
        irq_alloc_descs(at, at, 1, node)
@@ -943,7 +943,7 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
        __devm_irq_alloc_descs(dev, irq, from, cnt, node, THIS_MODULE, NULL)
 
 #define devm_irq_alloc_desc(dev, node)                         \
-       devm_irq_alloc_descs(dev, -1, 0, 1, node)
+       devm_irq_alloc_descs(dev, -1, 1, 1, node)
 
 #define devm_irq_alloc_desc_at(dev, at, node)                  \
        devm_irq_alloc_descs(dev, at, at, 1, node)
index fe1ae73ff8b574a8ee31e03b07f06cb6d5ca2473..0aea9e2a2a01d18d4036997967518d56774f371e 100644 (file)
@@ -333,6 +333,13 @@ static inline void *kasan_reset_tag(const void *addr)
        return (void *)arch_kasan_reset_tag(addr);
 }
 
+/**
+ * kasan_report - print a report about a bad memory access detected by KASAN
+ * @addr: address of the bad access
+ * @size: size of the bad access
+ * @is_write: whether the bad access is a write or a read
+ * @ip: instruction pointer for the accessibility check or the bad access itself
+ */
 bool kasan_report(unsigned long addr, size_t size,
                bool is_write, unsigned long ip);
 
index 360a0a7e73415fee1cacc582ba1da3ae9fec3e51..aef35fd1cf116f5d53ee922a8f81da575212ac38 100644 (file)
@@ -178,6 +178,12 @@ struct msi_desc {
        list_for_each_entry((desc), dev_to_msi_list((dev)), list)
 #define for_each_msi_entry_safe(desc, tmp, dev)        \
        list_for_each_entry_safe((desc), (tmp), dev_to_msi_list((dev)), list)
+#define for_each_msi_vector(desc, __irq, dev)                          \
+       for_each_msi_entry((desc), (dev))                               \
+               if ((desc)->irq)                                        \
+                       for (__irq = (desc)->irq;                       \
+                            __irq < ((desc)->irq + (desc)->nvec_used); \
+                            __irq++)
 
 #ifdef CONFIG_IRQ_MSI_IOMMU
 static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
index c8a974cead730da476d67210898d04624fc97aad..9b2158c69275e1069430beae14f2b4dfdb590825 100644 (file)
@@ -43,6 +43,7 @@ enum syscall_work_bit {
        SYSCALL_WORK_BIT_SYSCALL_EMU,
        SYSCALL_WORK_BIT_SYSCALL_AUDIT,
        SYSCALL_WORK_BIT_SYSCALL_USER_DISPATCH,
+       SYSCALL_WORK_BIT_SYSCALL_EXIT_TRAP,
 };
 
 #define SYSCALL_WORK_SECCOMP           BIT(SYSCALL_WORK_BIT_SECCOMP)
@@ -51,6 +52,7 @@ enum syscall_work_bit {
 #define SYSCALL_WORK_SYSCALL_EMU       BIT(SYSCALL_WORK_BIT_SYSCALL_EMU)
 #define SYSCALL_WORK_SYSCALL_AUDIT     BIT(SYSCALL_WORK_BIT_SYSCALL_AUDIT)
 #define SYSCALL_WORK_SYSCALL_USER_DISPATCH BIT(SYSCALL_WORK_BIT_SYSCALL_USER_DISPATCH)
+#define SYSCALL_WORK_SYSCALL_EXIT_TRAP BIT(SYSCALL_WORK_BIT_SYSCALL_EXIT_TRAP)
 #endif
 
 #include <asm/thread_info.h>
index 80c0181c411dff2a2f165d8e26e774841f80f9a6..cedcda6593f6134b239e640c44d3dbb5e000e5a0 100644 (file)
@@ -24,7 +24,8 @@ struct notifier_block;                /* in notifier.h */
 #define VM_UNINITIALIZED       0x00000020      /* vm_struct is not fully initialized */
 #define VM_NO_GUARD            0x00000040      /* don't add guard page */
 #define VM_KASAN               0x00000080      /* has allocated kasan shadow memory */
-#define VM_MAP_PUT_PAGES       0x00000100      /* put pages and free array in vfree */
+#define VM_FLUSH_RESET_PERMS   0x00000100      /* reset direct map and flush TLB on unmap, can't be freed in atomic context */
+#define VM_MAP_PUT_PAGES       0x00000200      /* put pages and free array in vfree */
 
 /*
  * VM_KASAN is used slighly differently depending on CONFIG_KASAN_VMALLOC.
@@ -37,12 +38,6 @@ struct notifier_block;               /* in notifier.h */
  * determine which allocations need the module shadow freed.
  */
 
-/*
- * Memory with VM_FLUSH_RESET_PERMS cannot be freed in an interrupt or with
- * vfree_atomic().
- */
-#define VM_FLUSH_RESET_PERMS   0x00000100      /* Reset direct map and flush TLB on unmap */
-
 /* bits [20..32] reserved for arch specific ioremap internals */
 
 /*
index 90deb41c8a34637bc3d5bf5704f49729ef51c1e9..667f1aed091c23c45494264a9c6940ed5ff623ef 100644 (file)
@@ -251,5 +251,8 @@ struct prctl_mm_map {
 #define PR_SET_SYSCALL_USER_DISPATCH   59
 # define PR_SYS_DISPATCH_OFF           0
 # define PR_SYS_DISPATCH_ON            1
+/* The control values for the user space selector when dispatch is enabled */
+# define SYSCALL_DISPATCH_FILTER_ALLOW 0
+# define SYSCALL_DISPATCH_FILTER_BLOCK 1
 
 #endif /* _LINUX_PRCTL_H */
index b77c60f8b963d4ae43140cce57b4c19af2e28732..29ad6832502880b8485f5cb76bd4348e7894e0de 100644 (file)
@@ -76,7 +76,6 @@ config CC_HAS_ASM_INLINE
 
 config CONSTRUCTORS
        bool
-       depends on !UML
 
 config IRQ_WORK
        bool
index c68d784376ca1058d58e3a6dfb664420c6ded461..a626e78dbf0611df73be6e5f20ce464c8b110d38 100644 (file)
@@ -1066,7 +1066,13 @@ asmlinkage __visible void __init __no_sanitize_address start_kernel(void)
 /* Call all constructor functions linked into the kernel. */
 static void __init do_ctors(void)
 {
-#ifdef CONFIG_CONSTRUCTORS
+/*
+ * For UML, the constructors have already been called by the
+ * normal setup code as it's just a normal ELF binary, so we
+ * cannot do it again - but we do need CONFIG_CONSTRUCTORS
+ * even on UML for modules.
+ */
+#if defined(CONFIG_CONSTRUCTORS) && !defined(CONFIG_UML)
        ctor_fn_t *fn = (ctor_fn_t *) __ctors_start;
 
        for (; fn < (ctor_fn_t *) __ctors_end; fn++)
index 6dd82be60df81698dbe8e20a73a03d653b0bd04c..f9d491b17b78b59b59b68a47f6ad161b05c7bce0 100644 (file)
@@ -209,15 +209,9 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs)
        lockdep_sys_exit();
 }
 
-#ifndef _TIF_SINGLESTEP
-static inline bool report_single_step(unsigned long work)
-{
-       return false;
-}
-#else
 /*
  * If SYSCALL_EMU is set, then the only reason to report is when
- * TIF_SINGLESTEP is set (i.e. PTRACE_SYSEMU_SINGLESTEP).  This syscall
+ * SINGLESTEP is set (i.e. PTRACE_SYSEMU_SINGLESTEP).  This syscall
  * instruction has been already reported in syscall_enter_from_user_mode().
  */
 static inline bool report_single_step(unsigned long work)
@@ -225,10 +219,8 @@ static inline bool report_single_step(unsigned long work)
        if (work & SYSCALL_WORK_SYSCALL_EMU)
                return false;
 
-       return !!(current_thread_info()->flags & _TIF_SINGLESTEP);
+       return work & SYSCALL_WORK_SYSCALL_EXIT_TRAP;
 }
-#endif
-
 
 static void syscall_exit_work(struct pt_regs *regs, unsigned long work)
 {
index b0338a5625d93f7afa50289f234433478b2706e4..c240302f56e233cd536665829e4a3184da728d73 100644 (file)
@@ -50,10 +50,10 @@ bool syscall_user_dispatch(struct pt_regs *regs)
                if (unlikely(__get_user(state, sd->selector)))
                        do_exit(SIGSEGV);
 
-               if (likely(state == PR_SYS_DISPATCH_OFF))
+               if (likely(state == SYSCALL_DISPATCH_FILTER_ALLOW))
                        return false;
 
-               if (state != PR_SYS_DISPATCH_ON)
+               if (state != SYSCALL_DISPATCH_FILTER_BLOCK)
                        do_exit(SIGSYS);
        }
 
index 3110c77230c7f7729b7a4488680ee0003e1797f0..f62de2dea8a3178cbf5bdc4ae697f69a946cb038 100644 (file)
@@ -4,7 +4,7 @@ menu "GCOV-based kernel profiling"
 config GCOV_KERNEL
        bool "Enable gcov-based kernel profiling"
        depends on DEBUG_FS
-       select CONSTRUCTORS if !UML
+       select CONSTRUCTORS
        default n
        help
        This option enables gcov-based code profiling (e.g. for code coverage
index dc0e2d7fbdfd927c98aade002389549f89477a0c..b338d622f26e330e0e889c1453fec4b4849eab79 100644 (file)
@@ -436,22 +436,22 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
 
        can_reserve = msi_check_reservation_mode(domain, info, dev);
 
-       for_each_msi_entry(desc, dev) {
-               virq = desc->irq;
-               if (desc->nvec_used == 1)
-                       dev_dbg(dev, "irq %d for MSI\n", virq);
-               else
+       /*
+        * This flag is set by the PCI layer as we need to activate
+        * the MSI entries before the PCI layer enables MSI in the
+        * card. Otherwise the card latches a random msi message.
+        */
+       if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY))
+               goto skip_activate;
+
+       for_each_msi_vector(desc, i, dev) {
+               if (desc->irq == i) {
+                       virq = desc->irq;
                        dev_dbg(dev, "irq [%d-%d] for MSI\n",
                                virq, virq + desc->nvec_used - 1);
-               /*
-                * This flag is set by the PCI layer as we need to activate
-                * the MSI entries before the PCI layer enables MSI in the
-                * card. Otherwise the card latches a random msi message.
-                */
-               if (!(info->flags & MSI_FLAG_ACTIVATE_EARLY))
-                       continue;
+               }
 
-               irq_data = irq_domain_get_irq_data(domain, desc->irq);
+               irq_data = irq_domain_get_irq_data(domain, i);
                if (!can_reserve) {
                        irqd_clr_can_reserve(irq_data);
                        if (domain->flags & IRQ_DOMAIN_MSI_NOMASK_QUIRK)
@@ -462,28 +462,24 @@ int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
                        goto cleanup;
        }
 
+skip_activate:
        /*
         * If these interrupts use reservation mode, clear the activated bit
         * so request_irq() will assign the final vector.
         */
        if (can_reserve) {
-               for_each_msi_entry(desc, dev) {
-                       irq_data = irq_domain_get_irq_data(domain, desc->irq);
+               for_each_msi_vector(desc, i, dev) {
+                       irq_data = irq_domain_get_irq_data(domain, i);
                        irqd_clr_activated(irq_data);
                }
        }
        return 0;
 
 cleanup:
-       for_each_msi_entry(desc, dev) {
-               struct irq_data *irqd;
-
-               if (desc->irq == virq)
-                       break;
-
-               irqd = irq_domain_get_irq_data(domain, desc->irq);
-               if (irqd_is_activated(irqd))
-                       irq_domain_deactivate_irq(irqd);
+       for_each_msi_vector(desc, i, dev) {
+               irq_data = irq_domain_get_irq_data(domain, i);
+               if (irqd_is_activated(irq_data))
+                       irq_domain_deactivate_irq(irq_data);
        }
        msi_domain_free_irqs(domain, dev);
        return ret;
index 87389b9e21abaa5f4a876eeec52840b5ad65e403..5247afd7f34552b0c4fe0f1421302ad7c1cbc5c1 100644 (file)
@@ -502,7 +502,7 @@ static struct hrtimer sync_hrtimer;
 
 static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer)
 {
-       queue_work(system_power_efficient_wq, &sync_work);
+       queue_work(system_freezable_power_efficient_wq, &sync_work);
 
        return HRTIMER_NORESTART;
 }
@@ -668,7 +668,7 @@ void ntp_notify_cmos_timer(void)
         * just a pointless work scheduled.
         */
        if (ntp_synced() && !hrtimer_is_queued(&sync_hrtimer))
-               queue_work(system_power_efficient_wq, &sync_work);
+               queue_work(system_freezable_power_efficient_wq, &sync_work);
 }
 
 static void __init ntp_init_cmos_sync(void)
index 35924025097b963b513da7cd75f06073a8d71c31..c3c76b833384686e43f0b9389874625ebf30709b 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/export.h>
 #include <linux/memblock.h>
 #include <linux/numa.h>
-#include <linux/sched/isolation.h>
 
 /**
  * cpumask_next - get the next cpu in a cpumask
@@ -206,27 +205,22 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask)
  */
 unsigned int cpumask_local_spread(unsigned int i, int node)
 {
-       int cpu, hk_flags;
-       const struct cpumask *mask;
+       int cpu;
 
-       hk_flags = HK_FLAG_DOMAIN | HK_FLAG_MANAGED_IRQ;
-       mask = housekeeping_cpumask(hk_flags);
        /* Wrap: we always want a cpu. */
-       i %= cpumask_weight(mask);
+       i %= num_online_cpus();
 
        if (node == NUMA_NO_NODE) {
-               for_each_cpu(cpu, mask) {
+               for_each_cpu(cpu, cpu_online_mask)
                        if (i-- == 0)
                                return cpu;
-               }
        } else {
                /* NUMA first. */
-               for_each_cpu_and(cpu, cpumask_of_node(node), mask) {
+               for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask)
                        if (i-- == 0)
                                return cpu;
-               }
 
-               for_each_cpu(cpu, mask) {
+               for_each_cpu(cpu, cpu_online_mask) {
                        /* Skip NUMA nodes, done above. */
                        if (cpumask_test_cpu(cpu, cpumask_of_node(node)))
                                continue;
index 3e3352f3d0da7b9e9f764bf7eb106463872f0a3e..bec38c64d6a624fe5680cff59bdc1a0b9dc7d803 100644 (file)
@@ -427,3 +427,34 @@ void __ubsan_handle_load_invalid_value(void *_data, void *val)
        ubsan_epilogue();
 }
 EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
+
+void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
+                                        unsigned long align,
+                                        unsigned long offset);
+void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
+                                        unsigned long align,
+                                        unsigned long offset)
+{
+       struct alignment_assumption_data *data = _data;
+       unsigned long real_ptr;
+
+       if (suppress_report(&data->location))
+               return;
+
+       ubsan_prologue(&data->location, "alignment-assumption");
+
+       if (offset)
+               pr_err("assumption of %lu byte alignment (with offset of %lu byte) for pointer of type %s failed",
+                      align, offset, data->type->type_name);
+       else
+               pr_err("assumption of %lu byte alignment for pointer of type %s failed",
+                      align, data->type->type_name);
+
+       real_ptr = ptr - offset;
+       pr_err("%saddress is %lu aligned, misalignment offset is %lu bytes",
+              offset ? "offset " : "", BIT(real_ptr ? __ffs(real_ptr) : 0),
+              real_ptr & (align - 1));
+
+       ubsan_epilogue();
+}
+EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
index 7b56c09473a98e7fcff4c8e6640459d1d178c49c..9a0b71c5ff9fbf45492c0043f24a8578f06acaf6 100644 (file)
@@ -78,6 +78,12 @@ struct invalid_value_data {
        struct type_descriptor *type;
 };
 
+struct alignment_assumption_data {
+       struct source_location location;
+       struct source_location assumption_location;
+       struct type_descriptor *type;
+};
+
 #if defined(CONFIG_ARCH_SUPPORTS_INT128)
 typedef __int128 s_max;
 typedef unsigned __int128 u_max;
index e5acb9714436307f3ecc3e42b53301f2c8c92475..190ccdaa6c192f641a456c15bd6623b85178abce 100644 (file)
@@ -1342,7 +1342,7 @@ fast_isolate_freepages(struct compact_control *cc)
 {
        unsigned int limit = min(1U, freelist_scan_limit(cc) >> 1);
        unsigned int nr_scanned = 0;
-       unsigned long low_pfn, min_pfn, high_pfn = 0, highest = 0;
+       unsigned long low_pfn, min_pfn, highest = 0;
        unsigned long nr_isolated = 0;
        unsigned long distance;
        struct page *page = NULL;
@@ -1387,6 +1387,7 @@ fast_isolate_freepages(struct compact_control *cc)
                struct page *freepage;
                unsigned long flags;
                unsigned int order_scanned = 0;
+               unsigned long high_pfn = 0;
 
                if (!area->nr_free)
                        continue;
index 5c9d564317a5c5eb2e7f5c4edc6e5e3571bd9c2d..aa0e0fb046700a0b5a468abfe57f91ca01970829 100644 (file)
@@ -835,6 +835,7 @@ noinline int __add_to_page_cache_locked(struct page *page,
        XA_STATE(xas, &mapping->i_pages, offset);
        int huge = PageHuge(page);
        int error;
+       bool charged = false;
 
        VM_BUG_ON_PAGE(!PageLocked(page), page);
        VM_BUG_ON_PAGE(PageSwapBacked(page), page);
@@ -848,6 +849,7 @@ noinline int __add_to_page_cache_locked(struct page *page,
                error = mem_cgroup_charge(page, current->mm, gfp);
                if (error)
                        goto error;
+               charged = true;
        }
 
        gfp &= GFP_RECLAIM_MASK;
@@ -896,6 +898,8 @@ unlock:
 
        if (xas_error(&xas)) {
                error = xas_error(&xas);
+               if (charged)
+                       mem_cgroup_uncharge(page);
                goto error;
        }
 
index 9237976abe72b7a7aa6afe50fce36c0b34007939..91ca9b103ee527283f0dc2cef8816d43beb9c6bc 100644 (file)
@@ -2202,7 +2202,7 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
 {
        spinlock_t *ptl;
        struct mmu_notifier_range range;
-       bool was_locked = false;
+       bool do_unlock_page = false;
        pmd_t _pmd;
 
        mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,
@@ -2218,7 +2218,6 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
        VM_BUG_ON(freeze && !page);
        if (page) {
                VM_WARN_ON_ONCE(!PageLocked(page));
-               was_locked = true;
                if (page != pmd_page(*pmd))
                        goto out;
        }
@@ -2227,19 +2226,29 @@ repeat:
        if (pmd_trans_huge(*pmd)) {
                if (!page) {
                        page = pmd_page(*pmd);
-                       if (unlikely(!trylock_page(page))) {
-                               get_page(page);
-                               _pmd = *pmd;
-                               spin_unlock(ptl);
-                               lock_page(page);
-                               spin_lock(ptl);
-                               if (unlikely(!pmd_same(*pmd, _pmd))) {
-                                       unlock_page(page);
+                       /*
+                        * An anonymous page must be locked, to ensure that a
+                        * concurrent reuse_swap_page() sees stable mapcount;
+                        * but reuse_swap_page() is not used on shmem or file,
+                        * and page lock must not be taken when zap_pmd_range()
+                        * calls __split_huge_pmd() while i_mmap_lock is held.
+                        */
+                       if (PageAnon(page)) {
+                               if (unlikely(!trylock_page(page))) {
+                                       get_page(page);
+                                       _pmd = *pmd;
+                                       spin_unlock(ptl);
+                                       lock_page(page);
+                                       spin_lock(ptl);
+                                       if (unlikely(!pmd_same(*pmd, _pmd))) {
+                                               unlock_page(page);
+                                               put_page(page);
+                                               page = NULL;
+                                               goto repeat;
+                                       }
                                        put_page(page);
-                                       page = NULL;
-                                       goto repeat;
                                }
-                               put_page(page);
+                               do_unlock_page = true;
                        }
                }
                if (PageMlocked(page))
@@ -2249,7 +2258,7 @@ repeat:
        __split_huge_pmd_locked(vma, pmd, range.start, freeze);
 out:
        spin_unlock(ptl);
-       if (!was_locked && page)
+       if (do_unlock_page)
                unlock_page(page);
        /*
         * No need to double call mmu_notifier->invalidate_range() callback.
index 18f6ee3179002a7f218dfafb4e7724685ff1c215..4bdb58ab14cbbd659a1f9ca2e531a995fed03077 100644 (file)
@@ -79,6 +79,21 @@ DEFINE_SPINLOCK(hugetlb_lock);
 static int num_fault_mutexes;
 struct mutex *hugetlb_fault_mutex_table ____cacheline_aligned_in_smp;
 
+static inline bool PageHugeFreed(struct page *head)
+{
+       return page_private(head + 4) == -1UL;
+}
+
+static inline void SetPageHugeFreed(struct page *head)
+{
+       set_page_private(head + 4, -1UL);
+}
+
+static inline void ClearPageHugeFreed(struct page *head)
+{
+       set_page_private(head + 4, 0);
+}
+
 /* Forward declaration */
 static int hugetlb_acct_memory(struct hstate *h, long delta);
 
@@ -1028,6 +1043,7 @@ static void enqueue_huge_page(struct hstate *h, struct page *page)
        list_move(&page->lru, &h->hugepage_freelists[nid]);
        h->free_huge_pages++;
        h->free_huge_pages_node[nid]++;
+       SetPageHugeFreed(page);
 }
 
 static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid)
@@ -1044,6 +1060,7 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid)
 
                list_move(&page->lru, &h->hugepage_activelist);
                set_page_refcounted(page);
+               ClearPageHugeFreed(page);
                h->free_huge_pages--;
                h->free_huge_pages_node[nid]--;
                return page;
@@ -1344,12 +1361,11 @@ struct hstate *size_to_hstate(unsigned long size)
  */
 bool page_huge_active(struct page *page)
 {
-       VM_BUG_ON_PAGE(!PageHuge(page), page);
-       return PageHead(page) && PagePrivate(&page[1]);
+       return PageHeadHuge(page) && PagePrivate(&page[1]);
 }
 
 /* never called for tail page */
-static void set_page_huge_active(struct page *page)
+void set_page_huge_active(struct page *page)
 {
        VM_BUG_ON_PAGE(!PageHeadHuge(page), page);
        SetPagePrivate(&page[1]);
@@ -1505,6 +1521,7 @@ static void prep_new_huge_page(struct hstate *h, struct page *page, int nid)
        spin_lock(&hugetlb_lock);
        h->nr_huge_pages++;
        h->nr_huge_pages_node[nid]++;
+       ClearPageHugeFreed(page);
        spin_unlock(&hugetlb_lock);
 }
 
@@ -1755,6 +1772,7 @@ int dissolve_free_huge_page(struct page *page)
 {
        int rc = -EBUSY;
 
+retry:
        /* Not to disrupt normal path by vainly holding hugetlb_lock */
        if (!PageHuge(page))
                return 0;
@@ -1771,6 +1789,26 @@ int dissolve_free_huge_page(struct page *page)
                int nid = page_to_nid(head);
                if (h->free_huge_pages - h->resv_huge_pages == 0)
                        goto out;
+
+               /*
+                * We should make sure that the page is already on the free list
+                * when it is dissolved.
+                */
+               if (unlikely(!PageHugeFreed(head))) {
+                       spin_unlock(&hugetlb_lock);
+                       cond_resched();
+
+                       /*
+                        * Theoretically, we should return -EBUSY when we
+                        * encounter this race. In fact, we have a chance
+                        * to successfully dissolve the page if we do a
+                        * retry. Because the race window is quite small.
+                        * If we seize this opportunity, it is an optimization
+                        * for increasing the success rate of dissolving page.
+                        */
+                       goto retry;
+               }
+
                /*
                 * Move PageHWPoison flag from head page to the raw error page,
                 * which makes any subpages rather than the error page reusable.
@@ -2009,13 +2047,16 @@ retry:
 
        /* Free the needed pages to the hugetlb pool */
        list_for_each_entry_safe(page, tmp, &surplus_list, lru) {
+               int zeroed;
+
                if ((--needed) < 0)
                        break;
                /*
                 * This page is now managed by the hugetlb allocator and has
                 * no users -- drop the buddy allocator's reference.
                 */
-               VM_BUG_ON_PAGE(!put_page_testzero(page), page);
+               zeroed = put_page_testzero(page);
+               VM_BUG_ON_PAGE(!zeroed, page);
                enqueue_huge_page(h, page);
        }
 free:
@@ -5555,9 +5596,9 @@ bool isolate_huge_page(struct page *page, struct list_head *list)
 {
        bool ret = true;
 
-       VM_BUG_ON_PAGE(!PageHead(page), page);
        spin_lock(&hugetlb_lock);
-       if (!page_huge_active(page) || !get_page_unless_zero(page)) {
+       if (!PageHeadHuge(page) || !page_huge_active(page) ||
+           !get_page_unless_zero(page)) {
                ret = false;
                goto unlock;
        }
index cc4d9e1d49b1d046d579863ec36461152f4a2d12..8c706e7652f2b1fa026b7da658382cdcc4b8b8ea 100644 (file)
@@ -209,7 +209,7 @@ bool check_memory_region(unsigned long addr, size_t size, bool write,
 
 static inline bool addr_has_metadata(const void *addr)
 {
-       return true;
+       return (is_vmalloc_addr(addr) || virt_addr_valid(addr));
 }
 
 #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
index 1eaaec1e7687cc0c15c5d19ecee92e201875dadf..8d9b5f1e70409e1ea0ba95b3c576185cb80def05 100644 (file)
@@ -275,14 +275,6 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,
  *
  * Find @size free area aligned to @align in the specified range and node.
  *
- * When allocation direction is bottom-up, the @start should be greater
- * than the end of the kernel image. Otherwise, it will be trimmed. The
- * reason is that we want the bottom-up allocation just near the kernel
- * image so it is highly likely that the allocated memory and the kernel
- * will reside in the same node.
- *
- * If bottom-up allocation failed, will try to allocate memory top-down.
- *
  * Return:
  * Found address on success, 0 on failure.
  */
@@ -291,8 +283,6 @@ static phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,
                                        phys_addr_t end, int nid,
                                        enum memblock_flags flags)
 {
-       phys_addr_t kernel_end, ret;
-
        /* pump up @end */
        if (end == MEMBLOCK_ALLOC_ACCESSIBLE ||
            end == MEMBLOCK_ALLOC_KASAN)
@@ -301,40 +291,13 @@ static phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t size,
        /* avoid allocating the first page */
        start = max_t(phys_addr_t, start, PAGE_SIZE);
        end = max(start, end);
-       kernel_end = __pa_symbol(_end);
-
-       /*
-        * try bottom-up allocation only when bottom-up mode
-        * is set and @end is above the kernel image.
-        */
-       if (memblock_bottom_up() && end > kernel_end) {
-               phys_addr_t bottom_up_start;
-
-               /* make sure we will allocate above the kernel */
-               bottom_up_start = max(start, kernel_end);
 
-               /* ok, try bottom-up allocation first */
-               ret = __memblock_find_range_bottom_up(bottom_up_start, end,
-                                                     size, align, nid, flags);
-               if (ret)
-                       return ret;
-
-               /*
-                * we always limit bottom-up allocation above the kernel,
-                * but top-down allocation doesn't have the limit, so
-                * retrying top-down allocation may succeed when bottom-up
-                * allocation failed.
-                *
-                * bottom-up allocation is expected to be fail very rarely,
-                * so we use WARN_ONCE() here to see the stack trace if
-                * fail happens.
-                */
-               WARN_ONCE(IS_ENABLED(CONFIG_MEMORY_HOTREMOVE),
-                         "memblock: bottom-up allocation failed, memory hotremove may be affected\n");
-       }
-
-       return __memblock_find_range_top_down(start, end, size, align, nid,
-                                             flags);
+       if (memblock_bottom_up())
+               return __memblock_find_range_bottom_up(start, end, size, align,
+                                                      nid, flags);
+       else
+               return __memblock_find_range_top_down(start, end, size, align,
+                                                     nid, flags);
 }
 
 /**
index c0efe921bca5c608fbaf385ddccd1e85319be7ab..20ca887ea76943c97236872c2b046ffa7647a613 100644 (file)
@@ -1280,6 +1280,12 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
                return -ENOSYS;
        }
 
+       if (page_count(hpage) == 1) {
+               /* page was freed from under us. So we are done. */
+               putback_active_hugepage(hpage);
+               return MIGRATEPAGE_SUCCESS;
+       }
+
        new_hpage = get_new_page(hpage, private);
        if (!new_hpage)
                return -ENOMEM;
index c9766d07eb81a1cdee4cad8bfc4a393114543e6f..5a809c64dc7b9c5673969da158f1453e62a03d16 100644 (file)
@@ -1113,14 +1113,15 @@ static int svc_tcp_sendmsg(struct socket *sock, struct msghdr *msg,
                unsigned int offset, len, remaining;
                struct bio_vec *bvec;
 
-               bvec = xdr->bvec;
-               offset = xdr->page_base;
+               bvec = xdr->bvec + (xdr->page_base >> PAGE_SHIFT);
+               offset = offset_in_page(xdr->page_base);
                remaining = xdr->page_len;
                flags = MSG_MORE | MSG_SENDPAGE_NOTLAST;
                while (remaining > 0) {
                        if (remaining <= PAGE_SIZE && tail->iov_len == 0)
                                flags = 0;
-                       len = min(remaining, bvec->bv_len);
+
+                       len = min(remaining, bvec->bv_len - offset);
                        ret = kernel_sendpage(sock, bvec->bv_page,
                                              bvec->bv_offset + offset,
                                              len, flags);
index b5418ec587fbd2cd6ca6896b8868b93f12e59ef3..9de3c03b94aa763ec76e2bb9c2fe17cd0b66152a 100644 (file)
@@ -3,6 +3,9 @@
 # scripts contains sources for various helper programs used throughout
 # the kernel for the build process.
 
+CRYPTO_LIBS = $(shell pkg-config --libs libcrypto 2> /dev/null || echo -lcrypto)
+CRYPTO_CFLAGS = $(shell pkg-config --cflags libcrypto 2> /dev/null)
+
 hostprogs-always-$(CONFIG_BUILD_BIN2C)                 += bin2c
 hostprogs-always-$(CONFIG_KALLSYMS)                    += kallsyms
 hostprogs-always-$(BUILD_C_RECORDMCOUNT)               += recordmcount
@@ -14,8 +17,9 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)   += insert-sys-cert
 
 HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
 HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
-HOSTLDLIBS_sign-file = -lcrypto
-HOSTLDLIBS_extract-cert = -lcrypto
+HOSTLDLIBS_sign-file = $(CRYPTO_LIBS)
+HOSTCFLAGS_extract-cert.o = $(CRYPTO_CFLAGS)
+HOSTLDLIBS_extract-cert = $(CRYPTO_LIBS)
 
 ifdef CONFIG_UNWINDER_ORC
 ifeq ($(ARCH),x86_64)
index 652e9542043f28ab995e5379e949d7578a26c673..dcd8d8750b8bf3b7204718c379edc5a71e31711b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Copyright 2004 Matt Mackall <mpm@selenic.com>
 #
index 92e888ed939f9833a3b17f32ae7d15813ec4c46f..1afe3af1cc09726c0e0c91c3803b0f8a020584b8 100755 (executable)
@@ -3390,13 +3390,6 @@ sub process {
                        }
                }
 
-# discourage the use of boolean for type definition attributes of Kconfig options
-               if ($realfile =~ /Kconfig/ &&
-                   $line =~ /^\+\s*\bboolean\b/) {
-                       WARN("CONFIG_TYPE_BOOLEAN",
-                            "Use of boolean is deprecated, please use bool instead.\n" . $herecurr);
-               }
-
                if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
                    ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
                        my $flag = $1;
index 19963708bcf87712384eaedbba359e278cb78321..8ddb5d099029f717d9b3732f76d123c2a2315be5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: GPL-2.0
 #
 # Copyright (C) Google LLC, 2018
index fa7655c7cec0e8df222278d14c3e7ecb18113fc5..f754415af398b7eb97710931c1ce5761e664f879 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: GPL-2.0
 #
 # Copyright (C) Google LLC, 2020
index 627eba5849b5ccf6a018cb1be1fd27341807fb62..d5da5fa05d1d3c264775dbb5c960bc3f69cd8684 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: GPL-2.0
 #
 # diffconfig - a tool to compare .config files.
index 33487e99d83e5c0fe076c317f218a93fae3ada01..5c113cad5601742083addba09cb076b116933bc8 100755 (executable)
@@ -75,16 +75,12 @@ if arg_contain -S "$@"; then
        fi
 fi
 
-# For scripts/gcc-plugin.sh
+# To set GCC_PLUGINS
 if arg_contain -print-file-name=plugin "$@"; then
        plugin_dir=$(mktemp -d)
 
-       sed -n 's/.*#include "\(.*\)"/\1/p' $(dirname $0)/../gcc-plugins/gcc-common.h |
-       while read header
-       do
-               mkdir -p $plugin_dir/include/$(dirname $header)
-               touch $plugin_dir/include/$header
-       done
+       mkdir -p $plugin_dir/include
+       touch $plugin_dir/include/plugin-version.h
 
        echo $plugin_dir
        exit 0
index 0fdb31a790a810ff649701187076b815bad832d0..48d141e3ec56f280045a996f926a8213ace36dac 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: GPL-2.0+
 #
 # This determines how many parallel tasks "make" is expecting, as it is
index 7ecd2ccba531bb4c46a01b4ecad7ea8078f29027..54ad86d13784995cfb8eb57bd0827204c6c36886 100644 (file)
@@ -112,6 +112,12 @@ static bool is_ignored_symbol(const char *name, char type)
                "__crc_",               /* modversions */
                "__efistub_",           /* arm64 EFI stub namespace */
                "__kvm_nvhe_",          /* arm64 non-VHE KVM namespace */
+               "__AArch64ADRPThunk_",  /* arm64 lld */
+               "__ARMV5PILongThunk_",  /* arm lld */
+               "__ARMV7PILongThunk_",
+               "__ThumbV7PILongThunk_",
+               "__LA25Thunk_",         /* mips lld */
+               "__microLA25Thunk_",
                NULL
        };
 
index fcd4acd4e9cbc10002fd72c91b0ce3677d11f01e..b520e407a8ebb6f4b72e3679d6672bd0f4db2026 100755 (executable)
@@ -35,7 +35,7 @@ fi
 
 # As a final fallback before giving up, check if $HOSTCC knows of a default
 # ncurses installation (e.g. from a vendor-specific sysroot).
-if echo '#include <ncurses.h>' | "${HOSTCC}" -E - >/dev/null 2>&1; then
+if echo '#include <ncurses.h>' | ${HOSTCC} -E - >/dev/null 2>&1; then
        echo cflags=\"-D_GNU_SOURCE\"
        echo libs=\"-lncurses\"
        exit 0
index 389ea5209a83ddb76da8eab908830b15f52d3799..a7c4f0772e5342e2b95af302a633cb37e503bfd3 100644 (file)
@@ -1834,12 +1834,15 @@ int get_mp(int cpu, struct msr_counter *mp, unsigned long long *counterp)
 int get_epb(int cpu)
 {
        char path[128 + PATH_BYTES];
+       unsigned long long msr;
        int ret, epb = -1;
        FILE *fp;
 
        sprintf(path, "/sys/devices/system/cpu/cpu%d/power/energy_perf_bias", cpu);
 
-       fp = fopen_or_die(path, "r");
+       fp = fopen(path, "r");
+       if (!fp)
+               goto msr_fallback;
 
        ret = fscanf(fp, "%d", &epb);
        if (ret != 1)
@@ -1848,6 +1851,11 @@ int get_epb(int cpu)
        fclose(fp);
 
        return epb;
+
+msr_fallback:
+       get_msr(cpu, MSR_IA32_ENERGY_PERF_BIAS, &msr);
+
+       return msr & 0xf;
 }
 
 void get_apic_id(struct thread_data *t)
index 6689f1183dbff43c524df7a6cf7654d8add44066..073a03702ff5e6626e0640c8033f102d03d364f0 100644 (file)
@@ -22,6 +22,8 @@
 # define PR_SET_SYSCALL_USER_DISPATCH  59
 # define PR_SYS_DISPATCH_OFF   0
 # define PR_SYS_DISPATCH_ON    1
+# define SYSCALL_DISPATCH_FILTER_ALLOW 0
+# define SYSCALL_DISPATCH_FILTER_BLOCK 1
 #endif
 
 #ifdef __NR_syscalls
@@ -55,8 +57,8 @@ unsigned long trapped_call_count = 0;
 unsigned long native_call_count = 0;
 
 char selector;
-#define SYSCALL_BLOCK   (selector = PR_SYS_DISPATCH_ON)
-#define SYSCALL_UNBLOCK (selector = PR_SYS_DISPATCH_OFF)
+#define SYSCALL_BLOCK   (selector = SYSCALL_DISPATCH_FILTER_BLOCK)
+#define SYSCALL_UNBLOCK (selector = SYSCALL_DISPATCH_FILTER_ALLOW)
 
 #define CALIBRATION_STEP 100000
 #define CALIBRATE_TO_SECS 5
@@ -170,7 +172,7 @@ int main(void)
        syscall(MAGIC_SYSCALL_1);
 
 #ifdef TEST_BLOCKED_RETURN
-       if (selector == PR_SYS_DISPATCH_OFF) {
+       if (selector == SYSCALL_DISPATCH_FILTER_ALLOW) {
                fprintf(stderr, "Failed to return with selector blocked.\n");
                exit(-1);
        }
index 6498b050ef89b77699ccc58ff1955c3eea6b522f..b5d592d4099e85c6ad9d19d36de055eb27415409 100644 (file)
@@ -18,6 +18,8 @@
 # define PR_SET_SYSCALL_USER_DISPATCH  59
 # define PR_SYS_DISPATCH_OFF   0
 # define PR_SYS_DISPATCH_ON    1
+# define SYSCALL_DISPATCH_FILTER_ALLOW 0
+# define SYSCALL_DISPATCH_FILTER_BLOCK 1
 #endif
 
 #ifndef SYS_USER_DISPATCH
@@ -30,8 +32,8 @@
 # define MAGIC_SYSCALL_1 (0xff00)  /* Bad Linux syscall number */
 #endif
 
-#define SYSCALL_DISPATCH_ON(x) ((x) = 1)
-#define SYSCALL_DISPATCH_OFF(x) ((x) = 0)
+#define SYSCALL_DISPATCH_ON(x) ((x) = SYSCALL_DISPATCH_FILTER_BLOCK)
+#define SYSCALL_DISPATCH_OFF(x) ((x) = SYSCALL_DISPATCH_FILTER_ALLOW)
 
 /* Test Summary:
  *
@@ -56,7 +58,7 @@
 
 TEST_SIGNAL(dispatch_trigger_sigsys, SIGSYS)
 {
-       char sel = 0;
+       char sel = SYSCALL_DISPATCH_FILTER_ALLOW;
        struct sysinfo info;
        int ret;
 
@@ -79,7 +81,7 @@ TEST_SIGNAL(dispatch_trigger_sigsys, SIGSYS)
 
 TEST(bad_prctl_param)
 {
-       char sel = 0;
+       char sel = SYSCALL_DISPATCH_FILTER_ALLOW;
        int op;
 
        /* Invalid op */
@@ -220,7 +222,7 @@ TEST_SIGNAL(bad_selector, SIGSYS)
        sigset_t mask;
        struct sysinfo info;
 
-       glob_sel = 0;
+       glob_sel = SYSCALL_DISPATCH_FILTER_ALLOW;
        nr_syscalls_emulated = 0;
        si_code = 0;
        si_errno = 0;
@@ -288,7 +290,7 @@ TEST(direct_dispatch_range)
 {
        int ret = 0;
        struct sysinfo info;
-       char sel = 0;
+       char sel = SYSCALL_DISPATCH_FILTER_ALLOW;
 
        /*
         * Instead of calculating libc addresses; allow the entire