1. 06 May, 2021 7 commits
    • Rouven Czerwinski's avatar
      riscv: remove unused handle_exception symbol · beaf5ae1
      Rouven Czerwinski authored
      Since commit 79b1feba ("RISC-V: Setup exception vector early")
      exception vectors are setup early and the handle_exception symbol from
      the asm files is no longer referenced in traps.c. Remove it.
      Signed-off-by: default avatarRouven Czerwinski <rouven@czerwinskis.de>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      beaf5ae1
    • Geert Uytterhoeven's avatar
      riscv: Consistify protect_kernel_linear_mapping_text_rodata() use · 8d91b097
      Geert Uytterhoeven authored
      The various uses of protect_kernel_linear_mapping_text_rodata() are
      not consistent:
        - Its definition depends on "64BIT && !XIP_KERNEL",
        - Its forward declaration depends on MMU,
        - Its single caller depends on "STRICT_KERNEL_RWX && 64BIT && MMU &&
          !XIP_KERNEL".
      
      Fix this by settling on the dependencies of the caller, which can be
      simplified as STRICT_KERNEL_RWX depends on "MMU && !XIP_KERNEL".
      Provide a dummy definition, as the caller is protected by
      "IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)" instead of "#ifdef
      CONFIG_STRICT_KERNEL_RWX".
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      8d91b097
    • Vincent Chen's avatar
      riscv: enable SiFive errata CIP-453 and CIP-1200 Kconfig only if CONFIG_64BIT=y · 0e0d4992
      Vincent Chen authored
      The corresponding hardware issues of CONFIG_ERRATA_SIFIVE_CIP_453 and
      CONFIG_ERRATA_SIFIVE_CIP_1200 only exist in the SiFive 64bit CPU cores.
      Therefore, these two errata are required only if CONFIG_64BIT=y
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarVincent Chen <vincent.chen@sifive.com>
      Fixes: bff3ff52 ("riscv: sifive: Apply errata "cip-1200" patch")
      Fixes: 800149a7 ("riscv: sifive: Apply errata "cip-453" patch")
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      0e0d4992
    • Geert Uytterhoeven's avatar
      riscv: Only extend kernel reservation if mapped read-only · 8db6f937
      Geert Uytterhoeven authored
      When the kernel mapping was moved outside of the linear mapping, the
      kernel memory reservation was increased, to take into account mapping
      granularity.  However, this is done unconditionally, regardless of
      whether the kernel memory is mapped read-only or not.
      
      If this extension is not needed, up to 2 MiB may be lost, which has a
      big impact on e.g. Canaan K210 (64-bit nommu) platforms with only 8 MiB
      of RAM.
      
      Reclaim the lost memory by only extending the reserved region when
      needed, i.e. depending on a simplified version of the conditional logic
      around the call to protect_kernel_linear_mapping_text_rodata().
      
      Fixes: 2bfc6cd8 ("riscv: Move kernel mapping outside of linear mapping")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      8db6f937
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · 939b7cbc
      Linus Torvalds authored
      Pull RISC-V updates from Palmer Dabbelt:
      
       - Support for the memtest= kernel command-line argument.
      
       - Support for building the kernel with FORTIFY_SOURCE.
      
       - Support for generic clockevent broadcasts.
      
       - Support for the buildtar build target.
      
       - Some build system cleanups to pass more LLVM-friendly arguments.
      
       - Support for kprobes.
      
       - A rearranged kernel memory map, the first part of supporting sv48
         systems.
      
       - Improvements to kexec, along with support for kdump and crash
         kernels.
      
       - An alternatives-based errata framework, along with support for
         handling a pair of errata that manifest on some SiFive designs
         (including the HiFive Unmatched).
      
       - Support for XIP.
      
       - A device tree for the Microchip PolarFire ICICLE SoC and associated
         dev board.
      
      ... along with a bunch of cleanups.  There are already a handful of fixes
      on the list so there will likely be a part 2.
      
      * tag 'riscv-for-linus-5.13-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (45 commits)
        RISC-V: Always define XIP_FIXUP
        riscv: Remove 32b kernel mapping from page table dump
        riscv: Fix 32b kernel build with CONFIG_DEBUG_VIRTUAL=y
        RISC-V: Fix error code returned by riscv_hartid_to_cpuid()
        RISC-V: Enable Microchip PolarFire ICICLE SoC
        RISC-V: Initial DTS for Microchip ICICLE board
        dt-bindings: riscv: microchip: Add YAML documentation for the PolarFire SoC
        RISC-V: Add Microchip PolarFire SoC kconfig option
        RISC-V: enable XIP
        RISC-V: Add crash kernel support
        RISC-V: Add kdump support
        RISC-V: Improve init_resources()
        RISC-V: Add kexec support
        RISC-V: Add EM_RISCV to kexec UAPI header
        riscv: vdso: fix and clean-up Makefile
        riscv/mm: Use BUG_ON instead of if condition followed by BUG.
        riscv/kprobe: fix kernel panic when invoking sys_read traced by kprobe
        riscv: Set ARCH_HAS_STRICT_MODULE_RWX if MMU
        riscv: module: Create module allocations without exec permissions
        riscv: bpf: Avoid breaking W^X
        ...
      939b7cbc
    • Linus Torvalds's avatar
      Merge tag 'hexagon-5.13-0' of git://git.kernel.org/pub/scm/linux/kernel/git/bcain/linux · 5e5948e5
      Linus Torvalds authored
      Pull Hexagon updates from Brian Cain:
       "Hexagon architecture build fixes + builtins
      
        Small build fixes applied:
      
         - use -mlong-calls to build
      
         - extend jumps in futex_atomic_*
      
         - etc
      
        Also, for convenience and portability, the hexagon compiler builtin
        functions like memcpy etc have been added to the kernel -- following
        the idiom used by other architectures"
      
      * tag 'hexagon-5.13-0' of git://git.kernel.org/pub/scm/linux/kernel/git/bcain/linux:
        Hexagon: add target builtins to kernel
        Hexagon: remove DEBUG from comet config
        Hexagon: change jumps to must-extend in futex_atomic_*
        Hexagon: fix build errors
      5e5948e5
    • Linus Torvalds's avatar
      Merge tag 'docs-5.13-2' of git://git.lwn.net/linux · a3f53e8a
      Linus Torvalds authored
      Pull documentation fixes from Jonathan Corbet:
       "A few late-arriving documentation fixes, including some oprofile
        cleanup, a kernel-doc fix, some regression-reporting updates, and the
        usual minor fixes"
      
      * tag 'docs-5.13-2' of git://git.lwn.net/linux:
        Enlisted oprofile version line removed
        oprofiled version output line removed from the list
        Removed the oprofiled version option
        docs: reporting-issues.rst: CC subsystem and maintainers on regressions
        docs: correct URL to bios and kernel developer's guide
        docs/core-api: Consistent code style
        docs/zh_CN: Adjust order and content of zh_CN/index.rst
        Documentation: input: joydev file corrections
        docs: Fix typo in Documentation/x86/x86_64/5level-paging.rst
        kernel-doc: Add support for __deprecated
      a3f53e8a
  2. 05 May, 2021 33 commits
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · 8404c9fb
      Linus Torvalds authored
      Merge more updates from Andrew Morton:
       "The remainder of the main mm/ queue.
      
        143 patches.
      
        Subsystems affected by this patch series (all mm): pagecache, hugetlb,
        userfaultfd, vmscan, compaction, migration, cma, ksm, vmstat, mmap,
        kconfig, util, memory-hotplug, zswap, zsmalloc, highmem, cleanups, and
        kfence"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (143 commits)
        kfence: use power-efficient work queue to run delayed work
        kfence: maximize allocation wait timeout duration
        kfence: await for allocation using wait_event
        kfence: zero guard page after out-of-bounds access
        mm/process_vm_access.c: remove duplicate include
        mm/mempool: minor coding style tweaks
        mm/highmem.c: fix coding style issue
        btrfs: use memzero_page() instead of open coded kmap pattern
        iov_iter: lift memzero_page() to highmem.h
        mm/zsmalloc: use BUG_ON instead of if condition followed by BUG.
        mm/zswap.c: switch from strlcpy to strscpy
        arm64/Kconfig: introduce ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
        x86/Kconfig: introduce ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
        mm,memory_hotplug: add kernel boot option to enable memmap_on_memory
        acpi,memhotplug: enable MHP_MEMMAP_ON_MEMORY when supported
        mm,memory_hotplug: allocate memmap from the added memory range
        mm,memory_hotplug: factor out adjusting present pages into adjust_present_page_count()
        mm,memory_hotplug: relax fully spanned sections check
        drivers/base/memory: introduce memory_block_{online,offline}
        mm/memory_hotplug: remove broken locking of zone PCP structures during hot remove
        ...
      8404c9fb
    • Linus Torvalds's avatar
      Merge tag 'nfsd-5.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux · a79cdfba
      Linus Torvalds authored
      Pull more nfsd updates from Chuck Lever:
       "Additional fixes and clean-ups for NFSD since tags/nfsd-5.13,
        including a fix to grant read delegations for files open for writing"
      
      * tag 'nfsd-5.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
        SUNRPC: Fix null pointer dereference in svc_rqst_free()
        SUNRPC: fix ternary sign expansion bug in tracing
        nfsd: Fix fall-through warnings for Clang
        nfsd: grant read delegations to clients holding writes
        nfsd: reshuffle some code
        nfsd: track filehandle aliasing in nfs4_files
        nfsd: hash nfs4_files by inode number
        nfsd: ensure new clients break delegations
        nfsd: removed unused argument in nfsd_startup_generic()
        nfsd: remove unused function
        svcrdma: Pass a useful error code to the send_err tracepoint
        svcrdma: Rename goto labels in svc_rdma_sendto()
        svcrdma: Don't leak send_ctxt on Send errors
      a79cdfba
    • Linus Torvalds's avatar
      Merge tag '5.13-rc-smb3-part2' of git://git.samba.org/sfrench/cifs-2.6 · 7c9e41e0
      Linus Torvalds authored
      Pull cifs updates from Steve French:
       "Ten CIFS/SMB3 changes - including two marked for stable - including
        some important multichannel fixes, as well as support for handle
        leases (deferred close) and shutdown support:
      
         - some important multichannel fixes
      
         - support for handle leases (deferred close)
      
         - shutdown support (which is also helpful since it enables multiple
           xfstests)
      
         - enable negotiating stronger encryption by default (GCM256)
      
         - improve wireshark debugging by allowing more options for root to
           dump decryption keys
      
        SambaXP and the SMB3 Plugfest test event are going on now so I am
        expecting more patches over the next few days due to extra testing
        (including more multichannel fixes)"
      
      * tag '5.13-rc-smb3-part2' of git://git.samba.org/sfrench/cifs-2.6:
        fs/cifs: Fix resource leak
        Cifs: Fix kernel oops caused by deferred close for files.
        cifs: fix regression when mounting shares with prefix paths
        cifs: use echo_interval even when connection not ready.
        cifs: detect dead connections only when echoes are enabled.
        smb3.1.1: allow dumping keys for multiuser mounts
        smb3.1.1: allow dumping GCM256 keys to improve debugging of encrypted shares
        cifs: add shutdown support
        cifs: Deferred close for files
        smb3.1.1: enable negotiating stronger encryption by default
      7c9e41e0
    • Linus Torvalds's avatar
      Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost · 16bb86b5
      Linus Torvalds authored
      Pull virtio updates from Michael Tsirkin:
       "A bunch of new drivers including vdpa support for block and
        virtio-vdpa.
      
        Beginning of vq kick (aka doorbell) mapping support.
      
        Misc fixes"
      
      * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (40 commits)
        virtio_pci_modern: correct sparse tags for notify
        virtio_pci_modern: __force cast the notify mapping
        vDPA/ifcvf: get_config_size should return dev specific config size
        vDPA/ifcvf: enable Intel C5000X-PL virtio-block for vDPA
        vDPA/ifcvf: deduce VIRTIO device ID when probe
        vdpa_sim_blk: add support for vdpa management tool
        vdpa_sim_blk: handle VIRTIO_BLK_T_GET_ID
        vdpa_sim_blk: implement ramdisk behaviour
        vdpa: add vdpa simulator for block device
        vhost/vdpa: Remove the restriction that only supports virtio-net devices
        vhost/vdpa: use get_config_size callback in vhost_vdpa_config_validate()
        vdpa: add get_config_size callback in vdpa_config_ops
        vdpa_sim: cleanup kiovs in vdpasim_free()
        vringh: add vringh_kiov_length() helper
        vringh: implement vringh_kiov_advance()
        vringh: explain more about cleaning riov and wiov
        vringh: reset kiov 'consumed' field in __vringh_iov()
        vringh: add 'iotlb_lock' to synchronize iotlb accesses
        vdpa_sim: use iova module to allocate IOVA addresses
        vDPA/ifcvf: deduce VIRTIO device ID from pdev ids
        ...
      16bb86b5
    • Linus Torvalds's avatar
      Merge tag 'pci-v5.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · 57151b50
      Linus Torvalds authored
      Pull pci updates from Bjorn Helgaas:
       "Enumeration:
         - Release OF node when pci_scan_device() fails (Dmitry Baryshkov)
         - Add pci_disable_parity() (Bjorn Helgaas)
         - Disable Mellanox Tavor parity reporting (Heiner Kallweit)
         - Disable N2100 r8169 parity reporting (Heiner Kallweit)
         - Fix RCiEP device to RCEC association (Qiuxu Zhuo)
         - Convert sysfs "config", "rom", "reset", "label", "index",
           "acpi_index" to static attributes to help fix races in device
           enumeration (Krzysztof Wilczyński)
         - Convert sysfs "vpd" to static attribute (Heiner Kallweit, Krzysztof
           Wilczyński)
         - Use sysfs_emit() in "show" functions (Krzysztof Wilczyński)
         - Remove unused alloc_pci_root_info() return value (Krzysztof
           Wilczyński)
      
        PCI device hotplug:
         - Fix acpiphp reference count leak (Feilong Lin)
      
        Power management:
         - Fix acpi_pci_set_power_state() debug message (Rafael J. Wysocki)
         - Fix runtime PM imbalance (Dinghao Liu)
      
        Virtualization:
         - Increase delay after FLR to work around Intel DC P4510 NVMe erratum
           (Raphael Norwitz)
      
        MSI:
         - Convert rcar, tegra, xilinx to MSI domains (Marc Zyngier)
         - For rcar, xilinx, use controller address as MSI doorbell (Marc
           Zyngier)
         - Remove unused hv msi_controller struct (Marc Zyngier)
         - Remove unused PCI core msi_controller support (Marc Zyngier)
         - Remove struct msi_controller altogether (Marc Zyngier)
         - Remove unused default_teardown_msi_irqs() (Marc Zyngier)
         - Let host bridges declare their reliance on MSI domains (Marc
           Zyngier)
         - Make pci_host_common_probe() declare its reliance on MSI domains
           (Marc Zyngier)
         - Advertise mediatek lack of built-in MSI handling (Thomas Gleixner)
         - Document ways of ending up with NO_MSI (Marc Zyngier)
         - Refactor HT advertising of NO_MSI flag (Marc Zyngier)
      
        VPD:
         - Remove obsolete Broadcom NIC VPD length-limiting quirk (Heiner
           Kallweit)
         - Remove sysfs VPD size checking dead code (Heiner Kallweit)
         - Convert VPF sysfs file to static attribute (Heiner Kallweit)
         - Remove unnecessary pci_set_vpd_size() (Heiner Kallweit)
         - Tone down "missing VPD" message (Heiner Kallweit)
      
        Endpoint framework:
         - Fix NULL pointer dereference when epc_features not implemented
           (Shradha Todi)
         - Add missing destroy_workqueue() in endpoint test (Yang Yingliang)
      
        Amazon Annapurna Labs PCIe controller driver:
         - Fix compile testing without CONFIG_PCI_ECAM (Arnd Bergmann)
         - Fix "no symbols" warnings when compile testing with
           CONFIG_TRIM_UNUSED_KSYMS (Arnd Bergmann)
      
        APM X-Gene PCIe controller driver:
         - Fix cfg resource mapping regression (Dejin Zheng)
      
        Broadcom iProc PCIe controller driver:
         - Return zero for success of iproc_msi_irq_domain_alloc() (Pali
           Rohár)
      
        Broadcom STB PCIe controller driver:
         - Add reset_control_rearm() stub for !CONFIG_RESET_CONTROLLER (Jim
           Quinlan)
         - Fix use of BCM7216 reset controller (Jim Quinlan)
         - Use reset/rearm for Broadcom STB pulse reset instead of
           deassert/assert (Jim Quinlan)
         - Fix brcm_pcie_probe() error return for unsupported revision (Wei
           Yongjun)
      
        Cavium ThunderX PCIe controller driver:
         - Fix compile testing (Arnd Bergmann)
         - Fix "no symbols" warnings when compile testing with
           CONFIG_TRIM_UNUSED_KSYMS (Arnd Bergmann)
      
        Freescale Layerscape PCIe controller driver:
         - Fix ls_pcie_ep_probe() syntax error (comma for semicolon)
           (Krzysztof Wilczyński)
         - Remove layerscape-gen4 dependencies on OF and ARM64, add dependency
           on ARCH_LAYERSCAPE (Geert Uytterhoeven)
      
        HiSilicon HIP PCIe controller driver:
         - Remove obsolete HiSilicon PCIe DT description (Dongdong Liu)
      
        Intel Gateway PCIe controller driver:
         - Remove unused pcie_app_rd() (Jiapeng Chong)
      
        Intel VMD host bridge driver:
         - Program IRTE with Requester ID of VMD endpoint, not child device
           (Jon Derrick)
         - Disable VMD MSI-X remapping when possible so children can use more
           MSI-X vectors (Jon Derrick)
      
        MediaTek PCIe controller driver:
         - Configure FC and FTS for functions other than 0 (Ryder Lee)
         - Add YAML schema for MediaTek (Jianjun Wang)
         - Export pci_pio_to_address() for module use (Jianjun Wang)
         - Add MediaTek MT8192 PCIe controller driver (Jianjun Wang)
         - Add MediaTek MT8192 INTx support (Jianjun Wang)
         - Add MediaTek MT8192 MSI support (Jianjun Wang)
         - Add MediaTek MT8192 system power management support (Jianjun Wang)
         - Add missing MODULE_DEVICE_TABLE (Qiheng Lin)
      
        Microchip PolarFlare PCIe controller driver:
         - Make several symbols static (Wei Yongjun)
      
        NVIDIA Tegra PCIe controller driver:
         - Add MCFG quirks for Tegra194 ECAM errata (Vidya Sagar)
         - Make several symbols const (Rikard Falkeborn)
         - Fix Kconfig host/endpoint typo (Wesley Sheng)
      
        SiFive FU740 PCIe controller driver:
         - Add pcie_aux clock to prci driver (Greentime Hu)
         - Use reset-simple in prci driver for PCIe (Greentime Hu)
         - Add SiFive FU740 PCIe host controller driver and DT binding (Paul
           Walmsley, Greentime Hu)
      
        Synopsys DesignWare PCIe controller driver:
         - Move MSI Receiver init to dw_pcie_host_init() so it is
           re-initialized along with the RC in resume (Jisheng Zhang)
         - Move iATU detection earlier to fix regression (Hou Zhiqiang)
      
        TI J721E PCIe driver:
         - Add DT binding and TI j721e support for refclk to PCIe connector
           (Kishon Vijay Abraham I)
         - Add host mode and endpoint mode DT bindings for TI AM64 SoC (Kishon
           Vijay Abraham I)
      
        TI Keystone PCIe controller driver:
         - Use generic config accessors for TI AM65x (K3) to fix regression
           (Kishon Vijay Abraham I)
      
        Xilinx NWL PCIe controller driver:
         - Add support for coherent PCIe DMA traffic using CCI (Bharat Kumar
           Gogada)
         - Add optional "dma-coherent" DT property (Bharat Kumar Gogada)
      
        Miscellaneous:
         - Fix kernel-doc warnings (Krzysztof Wilczyński)
         - Remove unused MicroGate SyncLink device IDs (Jiri Slaby)
         - Remove redundant dev_err() for devm_ioremap_resource() failure
           (Chen Hui)
         - Remove redundant initialization (Colin Ian King)
         - Drop redundant dev_err() for platform_get_irq() errors (Krzysztof
           Wilczyński)"
      
      * tag 'pci-v5.13-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (98 commits)
        riscv: dts: Add PCIe support for the SiFive FU740-C000 SoC
        PCI: fu740: Add SiFive FU740 PCIe host controller driver
        dt-bindings: PCI: Add SiFive FU740 PCIe host controller
        MAINTAINERS: Add maintainers for SiFive FU740 PCIe driver
        clk: sifive: Use reset-simple in prci driver for PCIe driver
        clk: sifive: Add pcie_aux clock in prci driver for PCIe driver
        PCI: brcmstb: Use reset/rearm instead of deassert/assert
        ata: ahci_brcm: Fix use of BCM7216 reset controller
        reset: add missing empty function reset_control_rearm()
        PCI: Allow VPD access for QLogic ISP2722
        PCI/VPD: Add helper pci_get_func0_dev()
        PCI/VPD: Remove pci_vpd_find_tag() SRDT handling
        PCI/VPD: Remove pci_vpd_find_tag() 'offset' argument
        PCI/VPD: Change pci_vpd_init() return type to void
        PCI/VPD: Make missing VPD message less alarming
        PCI/VPD: Remove pci_set_vpd_size()
        x86/PCI: Remove unused alloc_pci_root_info() return value
        MAINTAINERS: Add Jianjun Wang as MediaTek PCI co-maintainer
        PCI: mediatek-gen3: Add system PM support
        PCI: mediatek-gen3: Add MSI support
        ...
      57151b50
    • Linus Torvalds's avatar
      Merge tag 'pwm/for-5.13-rc1' of... · 7b9df264
      Linus Torvalds authored
      Merge tag 'pwm/for-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
      
      Pull pwm updates from Thierry Reding:
       "This adds support for the PWM controller found on Toshiba Visconti
        SoCs and converts a couple of drivers to the atomic API.
      
        There's also a bunch of cleanups and minor fixes across the board"
      
      * tag 'pwm/for-5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (35 commits)
        pwm: Reword docs about pwm_apply_state()
        pwm: atmel: Improve duty cycle calculation in .apply()
        pwm: atmel: Fix duty cycle calculation in .get_state()
        pwm: visconti: Add Toshiba Visconti SoC PWM support
        dt-bindings: pwm: Add bindings for Toshiba Visconti PWM Controller
        arm64: dts: rockchip: Remove clock-names from PWM nodes
        ARM: dts: rockchip: Remove clock-names from PWM nodes
        dt-bindings: pwm: rockchip: Add more compatible strings
        dt-bindings: pwm: Convert pwm-rockchip.txt to YAML
        pwm: mediatek: Remove unused function
        pwm: pca9685: Improve runtime PM behavior
        pwm: pca9685: Support hardware readout
        pwm: pca9685: Switch to atomic API
        pwm: lpss: Don't modify HW state in .remove callback
        pwm: sti: Free resources only after pwmchip_remove()
        pwm: sti: Don't modify HW state in .remove callback
        pwm: lpc3200: Don't modify HW state in .remove callback
        pwm: lpc18xx-sct: Free resources only after pwmchip_remove()
        pwm: bcm-kona: Don't modify HW state in .remove callback
        pwm: bcm2835: Free resources only after pwmchip_remove()
        ...
      7b9df264
    • Linus Torvalds's avatar
      Merge tag 'thermal-v5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux · 583f2bcf
      Linus Torvalds authored
      Pull thermal updates from Daniel Lezcano:
      
       - Remove duplicate error message for the amlogic driver (Tang Bin)
      
       - Fix spellos in comments for the tegra and sun8i (Bhaskar Chowdhury)
      
       - Add the missing fifth node on the rcar_gen3 sensor (Niklas Söderlund)
      
       - Remove duplicate include in ti-bandgap (Zhang Yunkai)
      
       - Assign error code in the error path in the function
         thermal_of_populate_bind_params() (Jia-Ju Bai)
      
       - Fix spelling mistake in a comment 'disabed' -> 'disabled' (Colin Ian
         King)
      
       - Use the device name instead of auto-numbering for a better
         identification of the cooling device (Daniel Lezcano)
      
       - Improve a bit the division accuracy in the power allocator governor
         (Jeson Gao)
      
       - Enable the missing third sensor on msm8976 (Konrad Dybcio)
      
       - Add QCom tsens driver co-maintainer (Thara Gopinath)
      
       - Fix memory leak and use after free errors in the core code (Daniel
         Lezcano)
      
       - Add the MDM9607 compatible bindings (Konrad Dybcio)
      
       - Fix trivial spello in the copyright name for Hisilicon (Hao Fang)
      
       - Fix negative index array access when converting the frequency to
         power in the energy model (Brian-sy Yang)
      
       - Add support for Gen2 new PMIC support for Qcom SPMI (David Collins)
      
       - Update maintainer file for CPU cooling device section (Lukasz Luba)
      
       - Fix missing put_device on error in the Qcom tsens driver (Guangqing
         Zhu)
      
       - Add compatible DT binding for sm8350 (Robert Foss)
      
       - Add support for the MDM9607's tsens driver (Konrad Dybcio)
      
       - Remove duplicate error messages in thermal_mmio and the bcm2835
         driver (Ruiqi Gong)
      
       - Add the Thermal Temperature Cooling driver (Zhang Rui)
      
       - Remove duplicate error messages in the Hisilicon sensor driver (Ye
         Bin)
      
       - Use the devm_platform_ioremap_resource_byname() function instead of a
         couple of corresponding calls (dingsenjie)
      
       - Sort the headers alphabetically in the ti-bandgap driver (Zhen Lei)
      
       - Add missing property in the DT thermal sensor binding (Rafał Miłecki)
      
       - Remove dead code in the ti-bandgap sensor driver (Lin Ruizhe)
      
       - Convert the BRCM DT bindings to the yaml schema (Rafał Miłecki)
      
       - Replace the thermal_notify_framework() call by a call to the
         thermal_zone_device_update() function. Remove the function as well as
         the corresponding documentation (Thara Gopinath)
      
       - Add support for the ipq8064-tsens sensor along with a set of cleanups
         and code preparation (Ansuel Smith)
      
       - Add a lockless __thermal_cdev_update() function to improve the
         locking scheme in the core code and governors (Lukasz Luba)
      
       - Fix multiple cooling device notification changes (Lukasz Luba)
      
       - Remove unneeded variable initialization (Colin Ian King)
      
      * tag 'thermal-v5.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux: (55 commits)
        thermal/drivers/mtk_thermal: Remove redundant initializations of several variables
        thermal/core/power allocator: Use the lockless __thermal_cdev_update() function
        thermal/core/fair share: Use the lockless __thermal_cdev_update() function
        thermal/core/fair share: Lock the thermal zone while looping over instances
        thermal/core/power_allocator: Update once cooling devices when temp is low
        thermal/core/power_allocator: Maintain the device statistics from going stale
        thermal/core: Create a helper __thermal_cdev_update() without a lock
        dt-bindings: thermal: tsens: Document ipq8064 bindings
        thermal/drivers/tsens: Add support for ipq8064-tsens
        thermal/drivers/tsens: Drop unused define for msm8960
        thermal/drivers/tsens: Replace custom 8960 apis with generic apis
        thermal/drivers/tsens: Fix bug in sensor enable for msm8960
        thermal/drivers/tsens: Use init_common for msm8960
        thermal/drivers/tsens: Add VER_0 tsens version
        thermal/drivers/tsens: Convert msm8960 to reg_field
        thermal/drivers/tsens: Don't hardcode sensor slope
        Documentation: driver-api: thermal: Remove thermal_notify_framework from documentation
        thermal/core: Remove thermal_notify_framework
        iwlwifi: mvm: tt: Replace thermal_notify_framework
        dt-bindings: thermal: brcm,ns-thermal: Convert to the json-schema
        ...
      583f2bcf
    • Linus Torvalds's avatar
      Merge tag 'gpio-updates-for-v5.13-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux · 5d6a1b84
      Linus Torvalds authored
      Pull gpio updates from Bartosz Golaszewski:
      
       - new driver for the Realtek Otto GPIO controller
      
       - ACPI support for gpio-mpc8xxx
      
       - edge event support for gpio-sch (+ Kconfig fixes)
      
       - Kconfig improvements in gpio-ich
      
       - fixes to older issues in gpio-mockup
      
       - ACPI quirk for ignoring EC wakeups on Dell Venue 10 Pro 5055
      
       - improve the GPIO aggregator code by using more generic interfaces
         instead of reimplementing them in the driver
      
       - convert the DT bindings for gpio-74x164 to yaml
      
       - documentation improvements
      
       - a slew of other minor fixes and improvements to GPIO drivers
      
      * tag 'gpio-updates-for-v5.13-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (34 commits)
        dt-bindings: gpio: add YAML description for rockchip,gpio-bank
        gpio: mxs: remove useless function
        dt-bindings: gpio: fairchild,74hc595: Convert to json-schema
        gpio: it87: remove unused code
        gpio: 104-dio-48e: Fix coding style issues
        gpio: mpc8xxx: Add ACPI support
        gpio: ich: Switch to be dependent on LPC_ICH
        gpio: sch: Drop MFD_CORE selection
        gpio: sch: depends on LPC_SCH
        gpiolib: acpi: Add quirk to ignore EC wakeups on Dell Venue 10 Pro 5055
        gpio: sch: Hook into ACPI GPE handler to catch GPIO edge events
        gpio: sch: Add edge event support
        gpio: aggregator: Replace custom get_arg() with a generic next_arg()
        lib/cmdline: Export next_arg() for being used in modules
        gpio: omap: Use device_get_match_data() helper
        gpio: Add Realtek Otto GPIO support
        dt-bindings: gpio: Binding for Realtek Otto GPIO
        docs: kernel-parameters: Add gpio_mockup_named_lines
        docs: kernel-parameters: Move gpio-mockup for alphabetic order
        lib: bitmap: provide devm_bitmap_alloc() and devm_bitmap_zalloc()
        ...
      5d6a1b84
    • Linus Torvalds's avatar
      Merge tag 'char-misc-5.13-rc1-round2' of... · 5a5bcd43
      Linus Torvalds authored
      Merge tag 'char-misc-5.13-rc1-round2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
      
      Pull char/misc driver fixes from Greg KH:
       "Here are two char/misc fixes for 5.13-rc1 to resolve reported issues.
      
        The first is a bugfix for the nitro_enclaves driver that fixed some
        important problems. The second was a dyndbg bugfix that resolved some
        reported problems in dynamic debugging control.
      
        Both have been in linux-next for a while with no reported issues"
      
      * tag 'char-misc-5.13-rc1-round2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        dyndbg: fix parsing file query without a line-range suffix
        nitro_enclaves: Fix stale file descriptors on failed usercopy
      5a5bcd43
    • Linus Torvalds's avatar
      Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux · d8cb379c
      Linus Torvalds authored
      Pull turbostat updates from Len Brown:
       "Bug fixes and a smattering of features"
      
      * 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: (21 commits)
        tools/power turbostat: version 2021.05.04
        tools/power turbostat: Support "turbostat --hide idle"
        tools/power turbostat: elevate priority of interval mode
        tools/power turbostat: formatting
        tools/power turbostat: rename tcc variables
        tools/power turbostat: add TCC Offset support
        tools/power turbostat: save original CPU model
        tools/power turbostat: Fix Core C6 residency on Atom CPUs
        tools/power turbostat: Print the C-state Pre-wake settings
        tools/power turbostat: Enable tsc_tweak for Elkhart Lake and Jasper Lake
        tools/power turbostat: unmark non-kernel-doc comment
        tools/power/turbostat: Remove Package C6 Retention on Ice Lake Server
        tools/power turbostat: Fix offset overflow issue in index converting
        tools/power/turbostat: Fix turbostat for AMD Zen CPUs
        tools/power turbostat: update version number
        tools/power turbostat: Fix DRAM Energy Unit on SKX
        Revert "tools/power turbostat: adjust for temperature offset"
        tools/power turbostat: Support Ice Lake D
        tools/power turbostat: Support Alder Lake Mobile
        tools/power turbostat: print microcode patch level
        ...
      d8cb379c
    • Linus Torvalds's avatar
      Merge tag 'ktest-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest · dd8c86c6
      Linus Torvalds authored
      Pull ktest updates from Steven Rostedt:
      
       - Added a KTEST section in the MAINTAINERS file
      
       - Included John Hawley as a co-maintainer
      
       - Add an example config that would work with VMware workstation guests
      
       - Cleanups to the code
      
      * tag 'ktest-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-ktest:
        ktest: Add KTEST section to MAINTAINERS file
        ktest: Re-arrange the code blocks for better discoverability
        ktest: Further consistency cleanups
        ktest: Fixing indentation to match expected pattern
        ktest: Adding editor hints to improve consistency
        ktest: Add example config for using VMware VMs
        ktest: Minor cleanup with uninitialized variable $build_options
      dd8c86c6
    • Linus Torvalds's avatar
      Merge tag 'safesetid-5.13' of git://github.com/micah-morton/linux · d29c9bb0
      Linus Torvalds authored
      Pull SafeSetID update from Micah Morton:
       "Simple code cleanup
      
        This just has a single three-line code cleanup to eliminate some
        unnecessary 'break' statements"
      
      * tag 'safesetid-5.13' of git://github.com/micah-morton/linux:
        LSM: SafeSetID: Fix code specification by scripts/checkpatch.pl
      d29c9bb0
    • Marco Elver's avatar
      kfence: use power-efficient work queue to run delayed work · 36f0b35d
      Marco Elver authored
      Use the power-efficient work queue, to avoid the pathological case where
      we keep pinning ourselves on the same possibly idle CPU on systems that
      want to be power-efficient (https://lwn.net/Articles/731052/).
      
      Link: https://lkml.kernel.org/r/20210421105132.3965998-4-elver@google.comSigned-off-by: default avatarMarco Elver <elver@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      36f0b35d
    • Marco Elver's avatar
      kfence: maximize allocation wait timeout duration · 37c9284f
      Marco Elver authored
      The allocation wait timeout was initially added because of warnings due to
      CONFIG_DETECT_HUNG_TASK=y [1].  While the 1 sec timeout is sufficient to
      resolve the warnings (given the hung task timeout must be 1 sec or larger)
      it may cause unnecessary wake-ups if the system is idle:
      
        https://lkml.kernel.org/r/CADYN=9J0DQhizAGB0-jz4HOBBh+05kMBXb4c0cXMS7Qi5NAJiw@mail.gmail.com
      
      Fix it by computing the timeout duration in terms of the current
      sysctl_hung_task_timeout_secs value.
      
      Link: https://lkml.kernel.org/r/20210421105132.3965998-3-elver@google.comSigned-off-by: default avatarMarco Elver <elver@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      37c9284f
    • Marco Elver's avatar
      kfence: await for allocation using wait_event · 407f1d8c
      Marco Elver authored
      Patch series "kfence: optimize timer scheduling", v2.
      
      We have observed that mostly-idle systems with KFENCE enabled wake up
      otherwise idle CPUs, preventing such to enter a lower power state.
      Debugging revealed that KFENCE spends too much active time in
      toggle_allocation_gate().
      
      While the first version of KFENCE was using all the right bits to be
      scheduling optimal, and thus power efficient, by simply using wait_event()
      + wake_up(), that code was unfortunately removed.
      
      As KFENCE was exposed to various different configs and tests, the
      scheduling optimal code slowly disappeared.  First because of hung task
      warnings, and finally because of deadlocks when an allocation is made by
      timer code with debug objects enabled.  Clearly, the "fixes" were not too
      friendly for devices that want to be power efficient.
      
      Therefore, let's try a little harder to fix the hung task and deadlock
      problems that we have with wait_event() + wake_up(), while remaining as
      scheduling friendly and power efficient as possible.
      
      Crucially, we need to defer the wake_up() to an irq_work, avoiding any
      potential for deadlock.
      
      The result with this series is that on the devices where we observed a
      power regression, power usage returns back to baseline levels.
      
      This patch (of 3):
      
      On mostly-idle systems, we have observed that toggle_allocation_gate() is
      a cause of frequent wake-ups, preventing an otherwise idle CPU to go into
      a lower power state.
      
      A late change in KFENCE's development, due to a potential deadlock [1],
      required changing the scheduling-friendly wait_event_timeout() and
      wake_up() to an open-coded wait-loop using schedule_timeout().  [1]
      https://lkml.kernel.org/r/000000000000c0645805b7f982e4@google.com
      
      To avoid unnecessary wake-ups, switch to using wait_event_timeout().
      
      Unfortunately, we still cannot use a version with direct wake_up() in
      __kfence_alloc() due to the same potential for deadlock as in [1].
      Instead, add a level of indirection via an irq_work that is scheduled if
      we determine that the kfence_timer requires a wake_up().
      
      Link: https://lkml.kernel.org/r/20210421105132.3965998-1-elver@google.com
      Link: https://lkml.kernel.org/r/20210421105132.3965998-2-elver@google.com
      Fixes: 0ce20dd8 ("mm: add Kernel Electric-Fence infrastructure")
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      407f1d8c
    • Marco Elver's avatar
      kfence: zero guard page after out-of-bounds access · 94868a1e
      Marco Elver authored
      After an out-of-bounds accesses, zero the guard page before re-protecting
      in kfence_guarded_free().  On one hand this helps make the failure mode of
      subsequent out-of-bounds accesses more deterministic, but could also
      prevent certain information leaks.
      
      Link: https://lkml.kernel.org/r/20210312121653.348518-1-elver@google.comSigned-off-by: default avatarMarco Elver <elver@google.com>
      Acked-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Cc: Jann Horn <jannh@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      94868a1e
    • Zhang Yunkai's avatar
      mm/process_vm_access.c: remove duplicate include · 0c4ff27a
      Zhang Yunkai authored
      'linux/compat.h' included in 'process_vm_access.c' is duplicated.
      
      Link: https://lkml.kernel.org/r/20210306132122.220431-1-zhang.yunkai@zte.com.cnSigned-off-by: default avatarZhang Yunkai <zhang.yunkai@zte.com.cn>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0c4ff27a
    • Zhiyuan Dai's avatar
      mm/mempool: minor coding style tweaks · 68d68ff6
      Zhiyuan Dai authored
      Various coding style tweaks to various files under mm/
      
      [daizhiyuan@phytium.com.cn: mm/swapfile: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614223624-16055-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/sparse: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614227288-19363-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/vmscan: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614227649-19853-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/compaction: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614228218-20770-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/oom_kill: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614228360-21168-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/shmem: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614228504-21491-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/page_alloc: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614228613-21754-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/filemap: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1614228936-22337-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/mlock: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1613956588-2453-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/frontswap: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1613962668-15045-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/vmalloc: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1613963379-15988-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/memory_hotplug: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1613971784-24878-1-git-send-email-daizhiyuan@phytium.com.cn
      [daizhiyuan@phytium.com.cn: mm/mempolicy: minor coding style tweaks]
        Link: https://lkml.kernel.org/r/1613972228-25501-1-git-send-email-daizhiyuan@phytium.com.cn
      
      Link: https://lkml.kernel.org/r/1614222374-13805-1-git-send-email-daizhiyuan@phytium.com.cnSigned-off-by: default avatarZhiyuan Dai <daizhiyuan@phytium.com.cn>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      68d68ff6
    • songqiang's avatar
      9727688d
    • Ira Weiny's avatar
      btrfs: use memzero_page() instead of open coded kmap pattern · d048b9c2
      Ira Weiny authored
      There are many places where kmap/memset/kunmap patterns occur.
      
      Use the newly lifted memzero_page() to eliminate direct uses of kmap and
      leverage the new core functions use of kmap_local_page().
      
      The development of this patch was aided by the following coccinelle
      script:
      
      // <smpl>
      // SPDX-License-Identifier: GPL-2.0-only
      // Find kmap/memset/kunmap pattern and replace with memset*page calls
      //
      // NOTE: Offsets and other expressions may be more complex than what the script
      // will automatically generate.  Therefore a catchall rule is provided to find
      // the pattern which then must be evaluated by hand.
      //
      // Confidence: Low
      // Copyright: (C) 2021 Intel Corporation
      // URL: http://coccinelle.lip6.fr/
      // Comments:
      // Options:
      
      //
      // Then the memset pattern
      //
      @ memset_rule1 @
      expression page, V, L, Off;
      identifier ptr;
      type VP;
      @@
      
      (
      -VP ptr = kmap(page);
      |
      -ptr = kmap(page);
      |
      -VP ptr = kmap_atomic(page);
      |
      -ptr = kmap_atomic(page);
      )
      <+...
      (
      -memset(ptr, 0, L);
      +memzero_page(page, 0, L);
      |
      -memset(ptr + Off, 0, L);
      +memzero_page(page, Off, L);
      |
      -memset(ptr, V, L);
      +memset_page(page, V, 0, L);
      |
      -memset(ptr + Off, V, L);
      +memset_page(page, V, Off, L);
      )
      ...+>
      (
      -kunmap(page);
      |
      -kunmap_atomic(ptr);
      )
      
      // Remove any pointers left unused
      @
      depends on memset_rule1
      @
      identifier memset_rule1.ptr;
      type VP, VP1;
      @@
      
      -VP ptr;
      	... when != ptr;
      ? VP1 ptr;
      
      //
      // Catch all
      //
      @ memset_rule2 @
      expression page;
      identifier ptr;
      expression GenTo, GenSize, GenValue;
      type VP;
      @@
      
      (
      -VP ptr = kmap(page);
      |
      -ptr = kmap(page);
      |
      -VP ptr = kmap_atomic(page);
      |
      -ptr = kmap_atomic(page);
      )
      <+...
      (
      //
      // Some call sites have complex expressions within the memset/memcpy
      // The follow are catch alls which need to be evaluated by hand.
      //
      -memset(GenTo, 0, GenSize);
      +memzero_pageExtra(page, GenTo, GenSize);
      |
      -memset(GenTo, GenValue, GenSize);
      +memset_pageExtra(page, GenValue, GenTo, GenSize);
      )
      ...+>
      (
      -kunmap(page);
      |
      -kunmap_atomic(ptr);
      )
      
      // Remove any pointers left unused
      @
      depends on memset_rule2
      @
      identifier memset_rule2.ptr;
      type VP, VP1;
      @@
      
      -VP ptr;
      	... when != ptr;
      ? VP1 ptr;
      
      // </smpl>
      
      Link: https://lkml.kernel.org/r/20210309212137.2610186-4-ira.weiny@intel.comSigned-off-by: default avatarIra Weiny <ira.weiny@intel.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
      Cc: Chris Mason <clm@fb.com>
      Cc: Josef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d048b9c2
    • Ira Weiny's avatar
      iov_iter: lift memzero_page() to highmem.h · 28961998
      Ira Weiny authored
      Patch series "btrfs: Convert kmap/memset/kunmap to memzero_user()".
      
      Lifting memzero_user(), convert it to kmap_local_page() and then use it
      in btrfs.
      
      This patch (of 3):
      
      memzero_page() can replace the kmap/memset/kunmap pattern in other
      places in the code.  While zero_user() has the same interface it is not
      the same call and its use should be limited and some of those calls may
      be better converted from zero_user() to memzero_page().[1] But that is
      not addressed in this series.
      
      Lift memzero_page() to highmem.
      
      [1] https://lore.kernel.org/lkml/CAHk-=wijdojzo56FzYqE5TOYw2Vws7ik3LEMGj9SPQaJJ+Z73Q@mail.gmail.com/
      
      Link: https://lkml.kernel.org/r/20210309212137.2610186-1-ira.weiny@intel.com
      Link: https://lkml.kernel.org/r/20210309212137.2610186-2-ira.weiny@intel.comSigned-off-by: default avatarIra Weiny <ira.weiny@intel.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Chris Mason <clm@fb.com>
      Cc: Josef Bacik <josef@toxicpanda.com>
      Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      28961998
    • zhouchuangao's avatar
      mm/zsmalloc: use BUG_ON instead of if condition followed by BUG. · ecfc2bda
      zhouchuangao authored
      It can be optimized at compile time.
      
      Link: https://lkml.kernel.org/r/1616727798-9110-1-git-send-email-zhouchuangao@vivo.comSigned-off-by: default avatarzhouchuangao <zhouchuangao@vivo.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ecfc2bda
    • Zhiyuan Dai's avatar
      mm/zswap.c: switch from strlcpy to strscpy · 79cd4202
      Zhiyuan Dai authored
      strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
      and there is no functional difference when the caller expects truncation
      (when not checking the return value).  strscpy is relatively better as
      it also avoids scanning the whole source string.
      
      Link: https://lkml.kernel.org/r/1614227981-20367-1-git-send-email-daizhiyuan@phytium.com.cnSigned-off-by: default avatarZhiyuan Dai <daizhiyuan@phytium.com.cn>
      Cc: Seth Jennings <sjenning@redhat.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: Vitaly Wool <vitaly.wool@konsulko.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      79cd4202
    • Oscar Salvador's avatar
      arm64/Kconfig: introduce ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE · ca6e51d5
      Oscar Salvador authored
      Enable arm64 platform to use the MHP_MEMMAP_ON_MEMORY feature.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-9-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ca6e51d5
    • Oscar Salvador's avatar
      x86/Kconfig: introduce ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE · f91ef222
      Oscar Salvador authored
      Enable x86_64 platform to use the MHP_MEMMAP_ON_MEMORY feature.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-8-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f91ef222
    • Oscar Salvador's avatar
      mm,memory_hotplug: add kernel boot option to enable memmap_on_memory · e3a9d9fc
      Oscar Salvador authored
      Self stored memmap leads to a sparse memory situation which is
      unsuitable for workloads that requires large contiguous memory chunks,
      so make this an opt-in which needs to be explicitly enabled.
      
      To control this, let memory_hotplug have its own memory space, as
      suggested by David, so we can add memory_hotplug.memmap_on_memory
      parameter.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-7-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e3a9d9fc
    • Oscar Salvador's avatar
      acpi,memhotplug: enable MHP_MEMMAP_ON_MEMORY when supported · 4a3e5de9
      Oscar Salvador authored
      Let the caller check whether it can pass MHP_MEMMAP_ON_MEMORY by
      checking mhp_supports_memmap_on_memory().  MHP_MEMMAP_ON_MEMORY can only
      be set in case ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE is enabled, the
      architecture supports altmap, and the range to be added spans a single
      memory block.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-6-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4a3e5de9
    • Oscar Salvador's avatar
      mm,memory_hotplug: allocate memmap from the added memory range · a08a2ae3
      Oscar Salvador authored
      Physical memory hotadd has to allocate a memmap (struct page array) for
      the newly added memory section.  Currently, alloc_pages_node() is used
      for those allocations.
      
      This has some disadvantages:
       a) an existing memory is consumed for that purpose
          (eg: ~2MB per 128MB memory section on x86_64)
          This can even lead to extreme cases where system goes OOM because
          the physically hotplugged memory depletes the available memory before
          it is onlined.
       b) if the whole node is movable then we have off-node struct pages
          which has performance drawbacks.
       c) It might be there are no PMD_ALIGNED chunks so memmap array gets
          populated with base pages.
      
      This can be improved when CONFIG_SPARSEMEM_VMEMMAP is enabled.
      
      Vmemap page tables can map arbitrary memory.  That means that we can
      reserve a part of the physically hotadded memory to back vmemmap page
      tables.  This implementation uses the beginning of the hotplugged memory
      for that purpose.
      
      There are some non-obviously things to consider though.
      
      Vmemmap pages are allocated/freed during the memory hotplug events
      (add_memory_resource(), try_remove_memory()) when the memory is
      added/removed.  This means that the reserved physical range is not
      online although it is used.  The most obvious side effect is that
      pfn_to_online_page() returns NULL for those pfns.  The current design
      expects that this should be OK as the hotplugged memory is considered a
      garbage until it is onlined.  For example hibernation wouldn't save the
      content of those vmmemmaps into the image so it wouldn't be restored on
      resume but this should be OK as there no real content to recover anyway
      while metadata is reachable from other data structures (e.g.  vmemmap
      page tables).
      
      The reserved space is therefore (de)initialized during the {on,off}line
      events (mhp_{de}init_memmap_on_memory).  That is done by extracting page
      allocator independent initialization from the regular onlining path.
      The primary reason to handle the reserved space outside of
      {on,off}line_pages is to make each initialization specific to the
      purpose rather than special case them in a single function.
      
      As per above, the functions that are introduced are:
      
       - mhp_init_memmap_on_memory:
         Initializes vmemmap pages by calling move_pfn_range_to_zone(), calls
         kasan_add_zero_shadow(), and onlines as many sections as vmemmap pages
         fully span.
      
       - mhp_deinit_memmap_on_memory:
         Offlines as many sections as vmemmap pages fully span, removes the
         range from zhe zone by remove_pfn_range_from_zone(), and calls
         kasan_remove_zero_shadow() for the range.
      
      The new function memory_block_online() calls mhp_init_memmap_on_memory()
      before doing the actual online_pages().  Should online_pages() fail, we
      clean up by calling mhp_deinit_memmap_on_memory().  Adjusting of
      present_pages is done at the end once we know that online_pages()
      succedeed.
      
      On offline, memory_block_offline() needs to unaccount vmemmap pages from
      present_pages() before calling offline_pages().  This is necessary because
      offline_pages() tears down some structures based on the fact whether the
      node or the zone become empty.  If offline_pages() fails, we account back
      vmemmap pages.  If it succeeds, we call mhp_deinit_memmap_on_memory().
      
      Hot-remove:
      
       We need to be careful when removing memory, as adding and
       removing memory needs to be done with the same granularity.
       To check that this assumption is not violated, we check the
       memory range we want to remove and if a) any memory block has
       vmemmap pages and b) the range spans more than a single memory
       block, we scream out loud and refuse to proceed.
      
       If all is good and the range was using memmap on memory (aka vmemmap pages),
       we construct an altmap structure so free_hugepage_table does the right
       thing and calls vmem_altmap_free instead of free_pagetable.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-5-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a08a2ae3
    • David Hildenbrand's avatar
      mm,memory_hotplug: factor out adjusting present pages into adjust_present_page_count() · f9901144
      David Hildenbrand authored
      Let's have a single place (inspired by adjust_managed_page_count())
      where we adjust present pages.
      
      In contrast to adjust_managed_page_count(), only memory onlining or
      offlining is allowed to modify the number of present pages.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-4-osalvador@suse.deSigned-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f9901144
    • Oscar Salvador's avatar
      mm,memory_hotplug: relax fully spanned sections check · dd8e2f23
      Oscar Salvador authored
      We want {online,offline}_pages to operate on whole memblocks, but
      memmap_on_memory will poke pageblock_nr_pages aligned holes in the
      beginning, which is a special case we want to allow.  Relax the check to
      account for that case.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-3-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dd8e2f23
    • Oscar Salvador's avatar
      drivers/base/memory: introduce memory_block_{online,offline} · 8736cc2d
      Oscar Salvador authored
      Patch series "Allocate memmap from hotadded memory (per device)", v10.
      
      The primary goal of this patchset is to reduce memory overhead of the
      hot-added memory (at least for SPARSEMEM_VMEMMAP memory model).  The
      current way we use to populate memmap (struct page array) has two main
      drawbacks:
      
      a) it consumes an additional memory until the hotadded memory itself is
         onlined and
      
      b) memmap might end up on a different numa node which is especially
         true for movable_node configuration.
      
      c) due to fragmentation we might end up populating memmap with base
         pages
      
      One way to mitigate all these issues is to simply allocate memmap array
      (which is the largest memory footprint of the physical memory hotplug)
      from the hot-added memory itself.  SPARSEMEM_VMEMMAP memory model allows
      us to map any pfn range so the memory doesn't need to be online to be
      usable for the array.  See patch 4 for more details.  This feature is
      only usable when CONFIG_SPARSEMEM_VMEMMAP is set.
      
      [Overall design]:
      
      Implementation wise we reuse vmem_altmap infrastructure to override the
      default allocator used by vmemap_populate.  memory_block structure gains a
      new field called nr_vmemmap_pages, which accounts for the number of
      vmemmap pages used by that memory_block.  E.g: On x86_64, that is 512
      vmemmap pages on small memory bloks and 4096 on large memory blocks (1GB)
      
      We also introduce new two functions: memory_block_{online,offline}.  These
      functions take care of initializing/unitializing vmemmap pages prior to
      calling {online,offline}_pages, so the latter functions can remain totally
      untouched.
      
      More details can be found in the respective changelogs.
      
      This patch (of 8):
      
      This is a preparatory patch that introduces two new functions:
      memory_block_online() and memory_block_offline().
      
      For now, these functions will only call online_pages() and offline_pages()
      respectively, but they will be later in charge of preparing the vmemmap
      pages, carrying out the initialization and proper accounting of such
      pages.
      
      Since memory_block struct contains all the information, pass this struct
      down the chain till the end functions.
      
      Link: https://lkml.kernel.org/r/20210421102701.25051-1-osalvador@suse.de
      Link: https://lkml.kernel.org/r/20210421102701.25051-2-osalvador@suse.deSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8736cc2d
    • Mel Gorman's avatar
      mm/memory_hotplug: remove broken locking of zone PCP structures during hot remove · 8ca55913
      Mel Gorman authored
      zone_pcp_reset allegedly protects against a race with drain_pages using
      local_irq_save but this is bogus.  local_irq_save only operates on the
      local CPU.  If memory hotplug is running on CPU A and drain_pages is
      running on CPU B, disabling IRQs on CPU A does not affect CPU B and
      offers no protection.
      
      This patch deletes IRQ disable/enable on the grounds that IRQs protect
      nothing and assumes the existing hotplug paths guarantees the PCP cannot
      be used after zone_pcp_enable().  That should be the case already
      because all the pages have been freed and there is no page to put on the
      PCP lists.
      
      Link: https://lkml.kernel.org/r/20210412090346.GQ3697@techsingularity.netSigned-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Reviewed-by: default avatarOscar Salvador <osalvador@suse.de>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: David Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8ca55913
    • Pavel Tatashin's avatar
      selftests/vm: gup_test: test faulting in kernel, and verify pinnable pages · e44605a8
      Pavel Tatashin authored
      When pages are pinned they can be faulted in userland and migrated, and
      they can be faulted right in kernel without migration.
      
      In either case, the pinned pages must end-up being pinnable (not
      movable).
      
      Add a new test to gup_test, to help verify that the gup/pup
      (get_user_pages() / pin_user_pages()) behavior with respect to pinnable
      and movable pages is reasonable and correct.  Specifically, provide a
      way to:
      
      1) Verify that only "pinnable" pages are pinned.  This is checked
         automatically for you.
      
      2) Verify that gup/pup performance is reasonable.  This requires
         comparing benchmarks between doing gup/pup on pages that have been
         pre-faulted in from user space, vs.  doing gup/pup on pages that are
         not faulted in until gup/pup time (via FOLL_TOUCH).  This decision is
         controlled with the new -z command line option.
      
      Link: https://lkml.kernel.org/r/20210215161349.246722-15-pasha.tatashin@soleen.comSigned-off-by: default avatarPavel Tatashin <pasha.tatashin@soleen.com>
      Reviewed-by: default avatarJohn Hubbard <jhubbard@nvidia.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Jason Gunthorpe <jgg@nvidia.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sasha Levin <sashal@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tyler Hicks <tyhicks@linux.microsoft.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e44605a8