Merge 4.14.276 into android-4.14-stable
Linux 4.14.276
i2c: pasemi: Wait for write xfers to finish
* smp: Fix offline cpu check in flush_smp_call_function_queue()
kernel/smp.c
ARM: davinci: da850-evm: Avoid NULL pointer dereference
* ALSA: pcm: Test for "silence" field in struct "pcm_format_data"
sound/core/pcm_misc.c
gcc-plugins: latent_entropy: use /dev/urandom
mm: kmemleak: take a full lowmem check in kmemleak_*_phys()
* mm, page_alloc: fix build_zonerefs_node()
mm/page_alloc.c
drivers: net: slip: fix NPD bug in sl_tx_timeout()
scsi: mvsas: Add PCI ID of RocketRaid 2640
gpu: ipu-v3: Fix dev_dbg frequency output
ata: libata-core: Disable READ LOG DMA EXT for Samsung 840 EVOs
* net: micrel: fix KS8851_MLL Kconfig
drivers/net/ethernet/micrel/Kconfig
scsi: ibmvscsis: Increase INITIAL_SRP_LIMIT to 1024
scsi: target: tcmu: Fix possible page UAF
Drivers: hv: vmbus: Prevent load re-ordering when reading ring buffer
drm/amdkfd: Check for potential null return of kmalloc_array()
drm/amd: Add USBC connector ID
cifs: potential buffer overflow in handling symlinks
nfc: nci: add flush_workqueue to prevent uaf
net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link
mlxsw: i2c: Fix initialization error flow
gpiolib: acpi: use correct format characters
* veth: Ensure eth header is in skb's linear part
drivers/net/veth.c
memory: atmel-ebi: Fix missing of_node_put in atmel_ebi_probe
* xfrm: policy: match with both mark and mask on user interfaces
include/net/xfrm.h
net/key/af_key.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_user.c
* cgroup: Use open-time cgroup namespace for process migration perm checks
kernel/cgroup/cgroup-internal.h
kernel/cgroup/cgroup.c
* cgroup: Allocate cgroup_file_ctx for kernfs_open_file->priv
kernel/cgroup/cgroup-internal.h
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup.c
* cgroup: Use open-time credentials for process migraton perm checks
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup.c
* mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning
include/linux/mmzone.h
* arm64: module: remove (NOLOAD) from linker script
arch/arm64/kernel/module.lds
* mm: don't skip swap entry even if zap_details specified
mm/memory.c
dmaengine: Revert "dmaengine: shdma: Fix runtime PM imbalance on error"
tools build: Use $(shell ) instead of `` to get embedded libperl's ccopts
perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator
* arm64: patch_text: Fixup last cpu should be master
arch/arm64/kernel/insn.c
btrfs: fix qgroup reserve overflow the qgroup limit
x86/speculation: Restore speculation related MSRs during S3 resume
x86/pm: Save the MSR validity status at context setup
mm/mempolicy: fix mpol_new leak in shared_policy_replace
* mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0)
mm/mremap.c
Revert "mmc: sdhci-xenon: fix annoying 1.8V regulator warning"
drbd: Fix five use after free bugs in get_initial_state
drm/imx: Fix memory leak in imx_pd_connector_get_modes
net: stmmac: Fix unset max_speed difference between DT and non-DT platforms
scsi: zorro7xx: Fix a resource leak in zorro7xx_remove_one()
drm/amdgpu: fix off by one in amdgpu_gfx_kiq_acquire()
* mm: fix race between MADV_FREE reclaim and blkdev direct IO read
mm/rmap.c
* net: add missing SOF_TIMESTAMPING_OPT_ID support
include/net/sock.h
net/ipv4/raw.c
net/ipv6/raw.c
net/packet/af_packet.c
* ipv6: add missing tx timestamping on IPPROTO_RAW
net/ipv6/raw.c
parisc: Fix CPU affinity for Lasi, WAX and Dino chips
jfs: prevent NULL deref in diFree
virtio_console: eliminate anonymous module_init & module_exit
serial: samsung_tty: do not unlock port->lock for uart_write_wakeup()
NFS: swap-out must always use STABLE writes.
* NFS: swap IO handling is slightly different for O_DIRECT IO
include/linux/nfs_fs.h
SUNRPC/call_alloc: async tasks mustn't block waiting for memory
w1: w1_therm: fixes w1_seq for ds28ea00 sensors
* init/main.c: return 1 from handled __setup() functions
init/main.c
* Bluetooth: Fix use after free in hci_send_acl
net/bluetooth/hci_event.c
xtensa: fix DTC warning unit_address_format
usb: dwc3: omap: fix "unbalanced disables for smps10_out1" on omap5evm
scsi: libfc: Fix use after free in fc_exch_abts_resp()
* MIPS: fix fortify panic when copying asm exception handlers
arch/mips/include/asm/setup.h
bnxt_en: Eliminate unintended link toggle during FW reset
macvtap: advertise link netns via netlink
net/smc: correct settings of RMB window update limit
scsi: aha152x: Fix aha152x_setup() __setup handler return value
scsi: pm8001: Fix pm8001_mpi_task_abort_resp()
* dm ioctl: prevent potential spectre v1 gadget
drivers/md/dm-ioctl.c
iommu/arm-smmu-v3: fix event handling soft lockup
PCI: aardvark: Fix support for MSI interrupts
powerpc: Set crashkernel offset to mid of RMA region
power: supply: axp20x_battery: properly report current when discharging
scsi: bfa: Replace snprintf() with sysfs_emit()
scsi: mvsas: Replace snprintf() with sysfs_emit()
powerpc: dts: t104xrdb: fix phy type for FMAN 4/5
* ptp: replace snprintf with sysfs_emit
drivers/ptp/ptp_sysfs.c
ath5k: fix OOB in ath5k_eeprom_read_pcal_info_5111
KVM: x86/svm: Clear reserved bits written to PerfEvtSeln MSRs
ARM: 9187/1: JIVE: fix return value of __setup handler
rtc: wm8350: Handle error for wm8350_register_irq
ubifs: Rectify space amount budget for mkdir/tmpfile operations
KVM: x86: Forbid VMM to set SYNIC/STIMER MSRs when SynIC wasn't activated
openvswitch: Fixed nd target mask field in the flow dump.
ARM: dts: spear13xx: Update SPI dma properties
ARM: dts: spear1340: Update serial node properties
ASoC: topology: Allow TLV control to be either read or write
ubi: fastmap: Return error code if memory allocation fails in add_aeb()
mm/memcontrol: return 1 from cgroup.memory __setup() handler
* mm/mmap: return 1 from stack_guard_gap __setup() handler
mm/mmap.c
ACPI: CPPC: Avoid out of bounds access when parsing _CPC data
ubi: Fix race condition between ctrl_cdev_ioctl and ubi_cdev_ioctl
* pinctrl: pinconf-generic: Print arguments for bias-pull-*
drivers/pinctrl/pinconf-generic.c
gfs2: Make sure FITRIM minlen is rounded up to fs block size
can: mcba_usb: properly check endpoint type
can: mcba_usb: mcba_usb_start_xmit(): fix double dev_kfree_skb in error path
ubifs: rename_whiteout: correct old_dir size computing
ubifs: setflags: Make dirtied_ino_d 8 bytes aligned
ubifs: Add missing iput if do_tmpfile() failed in rename whiteout
ubifs: rename_whiteout: Fix double free for whiteout_ui->data
KVM: Prevent module exit until all VMs are freed
scsi: qla2xxx: Suppress a kernel complaint in qla_create_qpair()
scsi: qla2xxx: Fix warning for missing error code
powerpc/lib/sstep: Fix build errors with newer binutils
powerpc/lib/sstep: Fix 'sthcx' instruction
mmc: host: Return an error when ->enable_sdio_irq() ops is missing
media: hdpvr: initialize dev->worker at hdpvr_register_videodev
video: fbdev: sm712fb: Fix crash in smtcfb_write()
ARM: mmp: Fix failure to remove sram device
ARM: tegra: tamonten: Fix I2C3 pad setting
media: cx88-mpeg: clear interrupt status register before streaming video
* ASoC: soc-core: skip zero num_dai component in searching dai name
sound/soc/soc-core.c
video: fbdev: omapfb: panel-tpo-td043mtea1: Use sysfs_emit() instead of snprintf()
video: fbdev: omapfb: panel-dsi-cm: Use sysfs_emit() instead of snprintf()
ARM: dts: bcm2837: Add the missing L1/L2 cache information
ARM: dts: qcom: fix gic_irq_domain_translate warnings for msm8960
video: fbdev: omapfb: acx565akm: replace snprintf with sysfs_emit
video: fbdev: cirrusfb: check pixclock to avoid divide by zero
video: fbdev: w100fb: Reset global state
video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow
ntfs: add sanity check on allocation size
* ext4: don't BUG if someone dirty pages without asking ext4 first
fs/ext4/inode.c
spi: tegra20: Use of_device_get_match_data()
* PM: core: keep irq flags in device_pm_check_callbacks()
drivers/base/power/main.c
ACPI/APEI: Limit printable size of BERT table data
ACPICA: Avoid walking the ACPI Namespace if it is not there
irqchip/nvic: Release nvic_base upon failure
Fix incorrect type in assignment of ipv6 port for audit
* loop: use sysfs_emit() in the sysfs xxx show()
drivers/block/loop.c
selinux: use correct type for context length
lib/test: use after free in register_test_dev_kmod()
NFSv4/pNFS: Fix another issue with a list iterator pointing to the head
net/x25: Fix null-ptr-deref caused by x25_disconnect
qlcnic: dcb: default to returning -EOPNOTSUPP
net: phy: broadcom: Fix brcm_fet_config_init()
* xen: fix is_xen_pmu()
arch/x86/xen/pmu.h
* netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options
net/netfilter/nf_conntrack_proto_tcp.c
jfs: fix divide error in dbNextAG
kgdbts: fix return value of __setup handler
kgdboc: fix return value of __setup handler
tty: hvc: fix return value of __setup handler
pinctrl/rockchip: Add missing of_node_put() in rockchip_pinctrl_probe
pinctrl: nomadik: Add missing of_node_put() in nmk_pinctrl_probe
pinctrl: mediatek: Fix missing of_node_put() in mtk_pctrl_init
NFS: remove unneeded check in decode_devicenotify_args()
clk: tegra: tegra124-emc: Fix missing put_device() call in emc_ensure_emc_driver
clk: clps711x: Terminate clk_div_table with sentinel element
clk: loongson1: Terminate clk_div_table with sentinel element
remoteproc: qcom_wcnss: Add missing of_node_put() in wcnss_alloc_memory_region
* clk: qcom: clk-rcg2: Update the frac table for pixel clock
drivers/clk/qcom/clk-rcg2.c
iio: adc: Add check for devm_request_threaded_irq
serial: 8250: Fix race condition in RTS-after-send handling
serial: 8250_mid: Balance reference count for PCI DMA device
staging:iio:adc:ad7280a: Fix handing of device address bit reversing.
pwm: lpc18xx-sct: Initialize driver data and hardware before pwmchip_add()
mxser: fix xmit_buf leak in activate when LSR == 0xff
mfd: asic3: Add missing iounmap() on error asic3_mfd_probe
* tcp: ensure PMTU updates are processed during fastopen
net/ipv4/tcp_output.c
i2c: mux: demux-pinctrl: do not deactivate a master that is not active
* af_netlink: Fix shift out of bounds in group mask calculation
net/netlink/af_netlink.c
USB: storage: ums-realtek: fix error code in rts51x_read_mem()
mtd: rawnand: atmel: fix refcount issue in atmel_nand_controller_init
MIPS: RB532: fix return value of __setup handler
vxcan: enable local echo for sent CAN frames
mfd: mc13xxx: Add check for mc13xxx_irq_request
powerpc/sysdev: fix incorrect use to determine if list is empty
* PCI: Reduce warnings on possible RW1C corruption
drivers/pci/access.c
include/linux/pci.h
power: supply: wm8350-power: Add missing free in free_charger_irq
power: supply: wm8350-power: Handle error for wm8350_register_irq
i2c: xiic: Make bus names unique
KVM: x86/emulator: Defer not-present segment check in __load_segment_descriptor()
KVM: x86: Fix emulation in writing cr8
power: supply: bq24190_charger: Fix bq24190_vbus_is_enabled() wrong false return
drm/tegra: Fix reference leak in tegra_dsi_ganged_probe
ext2: correct max file size computing
TOMOYO: fix __setup handlers return values
scsi: pm8001: Fix abort all task initialization
scsi: pm8001: Fix payload initialization in pm80xx_set_thermal_config()
scsi: pm8001: Fix command initialization in pm8001_chip_ssp_tm_req()
scsi: pm8001: Fix command initialization in pm80XX_send_read_log()
* dm crypt: fix get_key_size compiler warning if !CONFIG_KEYS
drivers/md/dm-crypt.c
iwlwifi: Fix -EIO error code that is never returned
HID: i2c-hid: fix GET/SET_REPORT for unnumbered reports
power: supply: ab8500: Fix memory leak in ab8500_fg_sysfs_init
ray_cs: Check ioremap return value
power: reset: gemini-poweroff: Fix IRQ check in gemini_poweroff_probe
ath9k_htc: fix uninit value bugs
* drm/edid: Don't clear formats if using deep color
drivers/gpu/drm/drm_edid.c
mtd: onenand: Check for error irq
ASoC: msm8916-wcd-digital: Fix missing clk_disable_unprepare() in msm8916_wcd_digital_probe
ASoC: imx-es8328: Fix error return code in imx_es8328_probe()
ASoC: mxs: Fix error handling in mxs_sgtl5000_probe
ASoC: dmaengine: do not use a NULL prepare_slave_config() callback
video: fbdev: omapfb: Add missing of_node_put() in dvic_probe_of
ASoC: fsi: Add check for clk_enable
ASoC: wm8350: Handle error for wm8350_register_irq
ASoC: atmel: Add missing of_node_put() in at91sam9g20ek_audio_probe
media: stk1160: If start stream fails, return buffers with VB2_BUF_STATE_QUEUED
ALSA: firewire-lib: fix uninitialized flag for AV/C deferred transaction
memory: emif: check the pointer temp in get_device_details()
memory: emif: Add check for setup_interrupts
ASoC: atmel_ssc_dai: Handle errors for clk_enable
ASoC: mxs-saif: Handle errors for clk_enable
* printk: fix return value of printk.devkmsg __setup handler
kernel/printk/printk.c
arm64: dts: broadcom: Fix sata nodename
arm64: dts: ns2: Fix spi-cpol and spi-cpha property
ALSA: spi: Add check for clk_enable()
ASoC: ti: davinci-i2s: Add check for clk_enable()
media: usb: go7007: s2250-board: fix leak in probe()
soc: ti: wkup_m3_ipc: Fix IRQ check in wkup_m3_ipc_probe
ARM: dts: qcom: ipq4019: fix sleep clock
* video: fbdev: fbcvt.c: fix printing in fb_cvt_print_name()
drivers/video/fbdev/core/fbcvt.c
video: fbdev: smscufx: Fix null-ptr-deref in ufx_usb_probe()
media: coda: Fix missing put_device() call in coda_get_vdoa_data
perf/x86/intel/pt: Fix address filter config for 32-bit kernel
* perf/core: Fix address filter parser for multiple filters
kernel/events/core.c
* sched/debug: Remove mpol_get/put and task_lock/unlock from sched_show_numa
kernel/sched/debug.c
clocksource: acpi_pm: fix return value of __setup handler
hwmon: (pmbus) Add Vin unit off handling
crypto: ccp - ccp_dmaengine_unregister release dma channels
ACPI: APEI: fix return value of __setup handlers
* crypto: vmx - add missing dependencies
drivers/crypto/vmx/Kconfig
hwrng: atmel - disable trng on failure path
PM: suspend: fix return value of __setup handler
PM: hibernate: fix __setup handler error handling
hwmon: (sch56xx-common) Replace WDOG_ACTIVE with WDOG_HW_RUNNING
hwmon: (pmbus) Add mutex to regulator ops
spi: pxa2xx-pci: Balance reference count for PCI DMA device
selftests/x86: Add validity check and allow field splitting
spi: tegra114: Add missing IRQ check in tegra_spi_probe
crypto: mxs-dcp - Fix scatterlist processing
* crypto: authenc - Fix sleep in atomic context in decrypt_tail
crypto/authenc.c
PCI: pciehp: Clear cmd_busy bit in polling mode
brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio
brcmfmac: firmware: Allocate space for default boardrev in nvram
media: davinci: vpif: fix unbalanced runtime PM get
* DEC: Limit PMAX memory probing to R3k systems
arch/mips/include/asm/dec/prom.h
lib/raid6/test: fix multiple definition linking error
thermal: int340x: Increase bitmap size
carl9170: fix missing bit-wise or operator for tx_params
ARM: dts: exynos: add missing HDMI supplies on SMDK5420
ARM: dts: exynos: add missing HDMI supplies on SMDK5250
ARM: dts: exynos: fix UART3 pins configuration in Exynos5250
ARM: dts: at91: sama5d2: Fix PMERRLOC resource size
video: fbdev: atari: Atari 2 bpp (STe) palette bugfix
video: fbdev: sm712fb: Fix crash in smtcfb_read()
drivers: hamradio: 6pack: fix UAF bug caused by mod_timer()
ACPI: properties: Consistently return -ENOENT if there are no more references
drbd: fix potential silent data corruption
ALSA: cs4236: fix an incorrect NULL check on list iterator
* Revert "Input: clear BTN_RIGHT/MIDDLE on buttonpads"
drivers/input/input.c
qed: validate and restrict untrusted VFs vlan promisc mode
qed: display VF trust config
scsi: libsas: Fix sas_ata_qc_issue() handling of NCQ NON DATA commands
mempolicy: mbind_range() set_policy() after vma_merge()
* mm/pages_alloc.c: don't create ZONE_MOVABLE beyond the end of a node
mm/page_alloc.c
jffs2: fix memory leak in jffs2_scan_medium
jffs2: fix memory leak in jffs2_do_mount_fs
jffs2: fix use-after-free in jffs2_clear_xattr_subsystem
can: ems_usb: ems_usb_start_xmit(): fix double dev_kfree_skb() in error path
pinctrl: samsung: drop pin banks references on error paths
NFSD: prevent underflow in nfssvc_decode_writeargs()
SUNRPC: avoid race between mod_timer() and del_timer_sync()
Documentation: update stable tree link
Documentation: add link to stable release candidate tree
* ptrace: Check PTRACE_O_SUSPEND_SECCOMP permission on PTRACE_SEIZE
kernel/ptrace.c
clk: uniphier: Fix fixed-rate initialization
* iio: inkern: make a best effort on offset calculation
drivers/iio/inkern.c
* iio: inkern: apply consumer scale when no channel scale is available
drivers/iio/inkern.c
* iio: inkern: apply consumer scale on IIO_VAL_INT cases
drivers/iio/inkern.c
* coresight: Fix TRCCONFIGR.QE sysfs interface
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
USB: usb-storage: Fix use of bitfields for hardware data in ene_ub6250.c
virtio-blk: Use blk_validate_block_size() to validate block size
* block: Add a helper to validate the block size
include/linux/blkdev.h
tpm: fix reference counting for struct tpm_chip
* fuse: fix pipe buffer lifetime for direct_io
fs/fuse/dev.c
fs/fuse/file.c
fs/fuse/fuse_i.h
* af_key: add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register
net/key/af_key.c
* spi: Fix erroneous sgs value with min_t()
drivers/spi/spi.c
* spi: Fix invalid sgs value
drivers/spi/spi.c
ethernet: sun: Free the coherent when failing in probing
virtio_console: break out of buf poll on remove
* netdevice: add the case if dev is NULL
include/linux/netdevice.h
* USB: serial: simple: add Nokia phone driver
drivers/usb/serial/Kconfig
USB: serial: pl2303: add IBM device IDs
* ANDROID: incremental-fs: limit mount stack depth
fs/incfs/data_mgmt.h
fs/incfs/vfs.c
* UPSTREAM: binderfs: use __u32 for device numbers
include/uapi/linux/android/binderfs.h
Merge 4.14.275 into android-4.14-stable
Linux 4.14.275
* arm64: Use the clearbhb instruction in mitigations
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/sysreg.h
arch/arm64/include/asm/vectors.h
arch/arm64/kernel/cpu_errata.c
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/entry.S
* arm64: add ID_AA64ISAR2_EL1 sys register
arch/arm64/include/asm/cpu.h
arch/arm64/include/asm/sysreg.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/cpuinfo.c
* KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated
arch/arm/include/asm/kvm_host.h
arch/arm64/include/asm/kvm_host.h
* arm64: Mitigate spectre style branch history side channels
arch/arm64/Kconfig
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/cputype.h
arch/arm64/include/asm/sysreg.h
arch/arm64/include/asm/vectors.h
arch/arm64/kernel/cpu_errata.c
* KVM: arm64: Add templates for BHB mitigation sequences
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/kvm_mmu.h
arch/arm64/include/asm/mmu.h
arch/arm64/kernel/cpu_errata.c
* arm64: proton-pack: Report Spectre-BHB vulnerabilities as part of Spectre-v2
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpu_errata.c
* arm64: Add percpu vectors for EL1
arch/arm64/include/asm/mmu.h
arch/arm64/include/asm/vectors.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/entry.S
* arm64: entry: Add macro for reading symbol addresses from the trampoline
arch/arm64/kernel/entry.S
* arm64: entry: Add vectors that have the bhb mitigation sequences
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/vectors.h
arch/arm64/kernel/entry.S
include/linux/arm-smccc.h
* arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations
arch/arm64/kernel/entry.S
* arm64: entry: Allow the trampoline text to occupy multiple pages
arch/arm64/include/asm/fixmap.h
arch/arm64/include/asm/sections.h
arch/arm64/kernel/entry.S
arch/arm64/kernel/vmlinux.lds.S
arch/arm64/mm/mmu.c
* arm64: entry: Make the kpti trampoline's kpti sequence optional
arch/arm64/kernel/entry.S
* arm64: entry: Move trampoline macros out of ifdef'd section
arch/arm64/kernel/entry.S
* arm64: entry: Don't assume tramp_vectors is the start of the vectors
arch/arm64/kernel/entry.S
* arm64: entry: Allow tramp_alias to access symbols after the 4K boundary
arch/arm64/kernel/entry.S
* arm64: entry: Move the trampoline data page before the text page
arch/arm64/include/asm/fixmap.h
arch/arm64/kernel/entry.S
* arm64: entry: Free up another register on kpti's tramp_exit path
arch/arm64/kernel/entry.S
* arm64: entry: Make the trampoline cleanup optional
arch/arm64/kernel/entry.S
* arm64: entry.S: Add ventry overflow sanity checks
arch/arm64/kernel/entry.S
* arm64: Add Cortex-X2 CPU part definition
arch/arm64/include/asm/cputype.h
* arm64: Add Neoverse-N2, Cortex-A710 CPU part definition
arch/arm64/include/asm/cputype.h
* arm64: Add part number for Arm Cortex-A77
arch/arm64/include/asm/cputype.h
* arm64: Add part number for Neoverse N1
arch/arm64/include/asm/cputype.h
* arm64: Make ARM64_ERRATUM_1188873 depend on COMPAT
arch/arm64/Kconfig
arm64: Add silicon-errata.txt entry for ARM erratum 1188873
* arm64: arch_timer: avoid unused function warning
arch/arm64/Kconfig
* arm64: arch_timer: Add workaround for ARM erratum 1188873
arch/arm64/Kconfig
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/cputype.h
arch/arm64/kernel/cpu_errata.c
drivers/clocksource/arm_arch_timer.c
Merge 4.14.274 into android-4.14-stable
Linux 4.14.274
llc: only change llc->dev when bind() succeeds
mac80211: fix potential double free on mesh join
crypto: qat - disable registration of algorithms
ACPI: video: Force backlight native for Clevo NL5xRU and NL5xNU
ACPI: battery: Add device HID and quirk for Microsoft Surface Go 3
ACPI / x86: Work around broken XSDT on Advantech DAC-BJ01 board
netfilter: nf_tables: initialize registers in nft_do_chain()
drivers: net: xgene: Fix regression in CRC stripping
ALSA: pci: fix reading of swapped values from pcmreg in AC97 codec
ALSA: cmipci: Restore aux vol on suspend/resume
* ALSA: usb-audio: Add mute TLV for playback volumes on RODE NT-USB
sound/usb/mixer_quirks.c
* ALSA: pcm: Add stream lock during PCM reset ioctl operations
sound/core/pcm_native.c
llc: fix netdevice reference leaks in llc_ui_bind()
thermal: int340x: fix memory leak in int3400_notify()
staging: fbtft: fb_st7789v: reset display before initialization
* esp: Fix possible buffer overflow in ESP transformation
include/net/esp.h
include/net/sock.h
net/core/sock.c
net/ipv4/esp4.c
net/ipv6/esp6.c
* net: ipv6: fix skb_over_panic in __ip6_append_data
net/ipv6/ip6_output.c
nfc: st21nfca: Fix potential buffer overflows in EVT_TRANSACTION
Merge 4.14.273 into android-4.14-stable
Linux 4.14.273
perf symbols: Fix symbol size calculation condition
Input: aiptek - properly check endpoint type
* usb: gadget: Fix use-after-free bug by not setting udc->dev.driver
drivers/usb/gadget/udc/core.c
* usb: gadget: rndis: prevent integer overflow in rndis_set_response()
drivers/usb/gadget/function/rndis.c
* net: handle ARPHRD_PIMREG in dev_is_mac_header_xmit()
include/linux/if_arp.h
atm: eni: Add check for dma_map_single
* net/packet: fix slab-out-of-bounds access in packet_recvmsg()
net/packet/af_packet.c
efi: fix return value of __setup handlers
* fs: sysfs_emit: Remove PAGE_SIZE alignment check
fs/sysfs/file.c
kselftest/vm: fix tests build with old libc
sfc: extend the locking on mcdi->seqno
* tcp: make tcp_read_sock() more robust
net/ipv4/tcp.c
* nl80211: Update bss channel on channel switch for P2P_CLIENT
net/wireless/nl80211.c
atm: firestream: check the return value of ioremap() in fs_init()
can: rcar_canfd: rcar_canfd_channel_probe(): register the CAN device when fully ready
* ARM: 9178/1: fix unmet dependency on BITREVERSE for HAVE_ARCH_BITREVERSE
lib/Kconfig
MIPS: smp: fill in sibling and core maps earlier
ARM: dts: rockchip: fix a typo on rk3288 crypto-controller
arm64: dts: rockchip: fix rk3399-puma eMMC HS400 signal integrity
* xfrm: Fix xfrm migrate issues when address family changes
net/xfrm/xfrm_state.c
* sctp: fix the processing for INIT_ACK chunk
net/sctp/sm_statefuns.c
* sctp: fix the processing for INIT chunk
net/sctp/sm_statefuns.c
Merge 4.14.272 into android-4.14-stable
Linux 4.14.272
btrfs: unlock newly allocated extent buffer after error
* ext4: add check to prevent attempting to resize an fs with sparse_super2
fs/ext4/resize.c
ARM: fix Thumb2 regression with Spectre BHB
* virtio: acknowledge all features before access
include/linux/virtio_config.h
* virtio: unexport virtio_finalize_features
include/linux/virtio.h
staging: gdm724x: fix use after free in gdm_lte_rx()
* ARM: Spectre-BHB: provide empty stub for non-config
arch/arm/include/asm/spectre.h
selftests/memfd: clean up mapping in mfd_fail_write
* tracing: Ensure trace buffer is at least 4096 bytes large
kernel/trace/trace.c
Revert "xen-netback: Check for hotplug-status existence before watching"
Revert "xen-netback: remove 'hotplug-status' once it has served its purpose"
* net-sysfs: add check for netdevice being present to speed_show
net/core/net-sysfs.c
* sctp: fix kernel-infoleak for SCTP sockets
net/sctp/sctp_diag.c
gpio: ts4900: Do not set DAT and OE together
NFC: port100: fix use-after-free in port100_send_complete
* net/mlx5: Fix size field in bufferx_reg struct
include/linux/mlx5/mlx5_ifc.h
ax25: Fix NULL pointer dereference in ax25_kill_by_device
net: ethernet: lpc_eth: Handle error for clk_enable
net: ethernet: ti: cpts: Handle error for clk_enable
ethernet: Fix error handling in xemaclite_of_probe
qed: return status of qed_iov_get_link
net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare()
Bug: 229982346
Change-Id: I5f44cf8b4adab635addd715739ada57c12d99ff4
Signed-off-by: Lucas Wei <lucaswei@google.com>
832 lines
22 KiB
C
832 lines
22 KiB
C
/*
|
|
* Generic helpers for smp ipi calls
|
|
*
|
|
* (C) Jens Axboe <jens.axboe@oracle.com> 2008
|
|
*/
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
#include <linux/irq_work.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/rculist.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/export.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/init.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/sched/idle.h>
|
|
#include <linux/hypervisor.h>
|
|
#include <linux/suspend.h>
|
|
|
|
#include "smpboot.h"
|
|
|
|
enum {
|
|
CSD_FLAG_LOCK = 0x01,
|
|
CSD_FLAG_SYNCHRONOUS = 0x02,
|
|
};
|
|
|
|
struct call_function_data {
|
|
call_single_data_t __percpu *csd;
|
|
cpumask_var_t cpumask;
|
|
cpumask_var_t cpumask_ipi;
|
|
};
|
|
|
|
static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_function_data, cfd_data);
|
|
|
|
static DEFINE_PER_CPU_SHARED_ALIGNED(struct llist_head, call_single_queue);
|
|
|
|
static void flush_smp_call_function_queue(bool warn_cpu_offline);
|
|
/* CPU mask indicating which CPUs to bring online during smp_init() */
|
|
static bool have_boot_cpu_mask;
|
|
static cpumask_var_t boot_cpu_mask;
|
|
|
|
int smpcfd_prepare_cpu(unsigned int cpu)
|
|
{
|
|
struct call_function_data *cfd = &per_cpu(cfd_data, cpu);
|
|
|
|
if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
|
|
cpu_to_node(cpu)))
|
|
return -ENOMEM;
|
|
if (!zalloc_cpumask_var_node(&cfd->cpumask_ipi, GFP_KERNEL,
|
|
cpu_to_node(cpu))) {
|
|
free_cpumask_var(cfd->cpumask);
|
|
return -ENOMEM;
|
|
}
|
|
cfd->csd = alloc_percpu(call_single_data_t);
|
|
if (!cfd->csd) {
|
|
free_cpumask_var(cfd->cpumask);
|
|
free_cpumask_var(cfd->cpumask_ipi);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int smpcfd_dead_cpu(unsigned int cpu)
|
|
{
|
|
struct call_function_data *cfd = &per_cpu(cfd_data, cpu);
|
|
|
|
free_cpumask_var(cfd->cpumask);
|
|
free_cpumask_var(cfd->cpumask_ipi);
|
|
free_percpu(cfd->csd);
|
|
return 0;
|
|
}
|
|
|
|
int smpcfd_dying_cpu(unsigned int cpu)
|
|
{
|
|
/*
|
|
* The IPIs for the smp-call-function callbacks queued by other
|
|
* CPUs might arrive late, either due to hardware latencies or
|
|
* because this CPU disabled interrupts (inside stop-machine)
|
|
* before the IPIs were sent. So flush out any pending callbacks
|
|
* explicitly (without waiting for the IPIs to arrive), to
|
|
* ensure that the outgoing CPU doesn't go offline with work
|
|
* still pending.
|
|
*/
|
|
flush_smp_call_function_queue(false);
|
|
return 0;
|
|
}
|
|
|
|
void __init call_function_init(void)
|
|
{
|
|
int i;
|
|
|
|
for_each_possible_cpu(i)
|
|
init_llist_head(&per_cpu(call_single_queue, i));
|
|
|
|
smpcfd_prepare_cpu(smp_processor_id());
|
|
}
|
|
|
|
/*
|
|
* csd_lock/csd_unlock used to serialize access to per-cpu csd resources
|
|
*
|
|
* For non-synchronous ipi calls the csd can still be in use by the
|
|
* previous function call. For multi-cpu calls its even more interesting
|
|
* as we'll have to ensure no other cpu is observing our csd.
|
|
*/
|
|
static __always_inline void csd_lock_wait(struct __call_single_data *csd)
|
|
{
|
|
smp_cond_load_acquire(&csd->flags, !(VAL & CSD_FLAG_LOCK));
|
|
}
|
|
|
|
static __always_inline void csd_lock(struct __call_single_data *csd)
|
|
{
|
|
csd_lock_wait(csd);
|
|
csd->flags |= CSD_FLAG_LOCK;
|
|
|
|
/*
|
|
* prevent CPU from reordering the above assignment
|
|
* to ->flags with any subsequent assignments to other
|
|
* fields of the specified call_single_data_t structure:
|
|
*/
|
|
smp_wmb();
|
|
}
|
|
|
|
static __always_inline void csd_unlock(struct __call_single_data *csd)
|
|
{
|
|
WARN_ON(!(csd->flags & CSD_FLAG_LOCK));
|
|
|
|
/*
|
|
* ensure we're all done before releasing data:
|
|
*/
|
|
smp_store_release(&csd->flags, 0);
|
|
}
|
|
|
|
static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data);
|
|
|
|
/*
|
|
* Insert a previously allocated call_single_data_t element
|
|
* for execution on the given CPU. data must already have
|
|
* ->func, ->info, and ->flags set.
|
|
*/
|
|
static int generic_exec_single(int cpu, struct __call_single_data *csd,
|
|
smp_call_func_t func, void *info)
|
|
{
|
|
if (cpu == smp_processor_id()) {
|
|
unsigned long flags;
|
|
|
|
/*
|
|
* We can unlock early even for the synchronous on-stack case,
|
|
* since we're doing this from the same CPU..
|
|
*/
|
|
csd_unlock(csd);
|
|
local_irq_save(flags);
|
|
func(info);
|
|
local_irq_restore(flags);
|
|
return 0;
|
|
}
|
|
|
|
|
|
if ((unsigned)cpu >= nr_cpu_ids || !cpu_online(cpu)) {
|
|
csd_unlock(csd);
|
|
return -ENXIO;
|
|
}
|
|
|
|
csd->func = func;
|
|
csd->info = info;
|
|
|
|
/*
|
|
* The list addition should be visible before sending the IPI
|
|
* handler locks the list to pull the entry off it because of
|
|
* normal cache coherency rules implied by spinlocks.
|
|
*
|
|
* If IPIs can go out of order to the cache coherency protocol
|
|
* in an architecture, sufficient synchronisation should be added
|
|
* to arch code to make it appear to obey cache coherency WRT
|
|
* locking and barrier primitives. Generic code isn't really
|
|
* equipped to do the right thing...
|
|
*/
|
|
if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu)))
|
|
arch_send_call_function_single_ipi(cpu);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* generic_smp_call_function_single_interrupt - Execute SMP IPI callbacks
|
|
*
|
|
* Invoked by arch to handle an IPI for call function single.
|
|
* Must be called with interrupts disabled.
|
|
*/
|
|
void generic_smp_call_function_single_interrupt(void)
|
|
{
|
|
flush_smp_call_function_queue(true);
|
|
}
|
|
|
|
/**
|
|
* flush_smp_call_function_queue - Flush pending smp-call-function callbacks
|
|
*
|
|
* @warn_cpu_offline: If set to 'true', warn if callbacks were queued on an
|
|
* offline CPU. Skip this check if set to 'false'.
|
|
*
|
|
* Flush any pending smp-call-function callbacks queued on this CPU. This is
|
|
* invoked by the generic IPI handler, as well as by a CPU about to go offline,
|
|
* to ensure that all pending IPI callbacks are run before it goes completely
|
|
* offline.
|
|
*
|
|
* Loop through the call_single_queue and run all the queued callbacks.
|
|
* Must be called with interrupts disabled.
|
|
*/
|
|
static void flush_smp_call_function_queue(bool warn_cpu_offline)
|
|
{
|
|
struct llist_head *head;
|
|
struct llist_node *entry;
|
|
call_single_data_t *csd, *csd_next;
|
|
static bool warned;
|
|
|
|
WARN_ON(!irqs_disabled());
|
|
|
|
head = this_cpu_ptr(&call_single_queue);
|
|
entry = llist_del_all(head);
|
|
entry = llist_reverse_order(entry);
|
|
|
|
/* There shouldn't be any pending callbacks on an offline CPU. */
|
|
if (unlikely(warn_cpu_offline && !cpu_online(smp_processor_id()) &&
|
|
!warned && entry != NULL)) {
|
|
warned = true;
|
|
WARN(1, "IPI on offline CPU %d\n", smp_processor_id());
|
|
|
|
/*
|
|
* We don't have to use the _safe() variant here
|
|
* because we are not invoking the IPI handlers yet.
|
|
*/
|
|
llist_for_each_entry(csd, entry, llist)
|
|
pr_warn("IPI callback %pS sent to offline CPU\n",
|
|
csd->func);
|
|
}
|
|
|
|
llist_for_each_entry_safe(csd, csd_next, entry, llist) {
|
|
smp_call_func_t func = csd->func;
|
|
void *info = csd->info;
|
|
|
|
/* Do we wait until *after* callback? */
|
|
if (csd->flags & CSD_FLAG_SYNCHRONOUS) {
|
|
func(info);
|
|
csd_unlock(csd);
|
|
} else {
|
|
csd_unlock(csd);
|
|
func(info);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Handle irq works queued remotely by irq_work_queue_on().
|
|
* Smp functions above are typically synchronous so they
|
|
* better run first since some other CPUs may be busy waiting
|
|
* for them.
|
|
*/
|
|
irq_work_run();
|
|
}
|
|
|
|
/*
|
|
* smp_call_function_single - Run a function on a specific CPU
|
|
* @func: The function to run. This must be fast and non-blocking.
|
|
* @info: An arbitrary pointer to pass to the function.
|
|
* @wait: If true, wait until function has completed on other CPUs.
|
|
*
|
|
* Returns 0 on success, else a negative status code.
|
|
*/
|
|
int smp_call_function_single(int cpu, smp_call_func_t func, void *info,
|
|
int wait)
|
|
{
|
|
call_single_data_t *csd;
|
|
call_single_data_t csd_stack = {
|
|
.flags = CSD_FLAG_LOCK | CSD_FLAG_SYNCHRONOUS,
|
|
};
|
|
int this_cpu;
|
|
int err;
|
|
|
|
/*
|
|
* prevent preemption and reschedule on another processor,
|
|
* as well as CPU removal
|
|
*/
|
|
this_cpu = get_cpu();
|
|
|
|
/*
|
|
* Can deadlock when called with interrupts disabled.
|
|
* We allow cpu's that are not yet online though, as no one else can
|
|
* send smp call function interrupt to this cpu and as such deadlocks
|
|
* can't happen.
|
|
*/
|
|
WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
|
|
&& !oops_in_progress);
|
|
|
|
csd = &csd_stack;
|
|
if (!wait) {
|
|
csd = this_cpu_ptr(&csd_data);
|
|
csd_lock(csd);
|
|
}
|
|
|
|
err = generic_exec_single(cpu, csd, func, info);
|
|
|
|
if (wait)
|
|
csd_lock_wait(csd);
|
|
|
|
put_cpu();
|
|
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL(smp_call_function_single);
|
|
|
|
/**
|
|
* smp_call_function_single_async(): Run an asynchronous function on a
|
|
* specific CPU.
|
|
* @cpu: The CPU to run on.
|
|
* @csd: Pre-allocated and setup data structure
|
|
*
|
|
* Like smp_call_function_single(), but the call is asynchonous and
|
|
* can thus be done from contexts with disabled interrupts.
|
|
*
|
|
* The caller passes his own pre-allocated data structure
|
|
* (ie: embedded in an object) and is responsible for synchronizing it
|
|
* such that the IPIs performed on the @csd are strictly serialized.
|
|
*
|
|
* NOTE: Be careful, there is unfortunately no current debugging facility to
|
|
* validate the correctness of this serialization.
|
|
*/
|
|
int smp_call_function_single_async(int cpu, struct __call_single_data *csd)
|
|
{
|
|
int err = 0;
|
|
|
|
preempt_disable();
|
|
|
|
/* We could deadlock if we have to wait here with interrupts disabled! */
|
|
if (WARN_ON_ONCE(csd->flags & CSD_FLAG_LOCK))
|
|
csd_lock_wait(csd);
|
|
|
|
csd->flags = CSD_FLAG_LOCK;
|
|
smp_wmb();
|
|
|
|
err = generic_exec_single(cpu, csd, csd->func, csd->info);
|
|
preempt_enable();
|
|
|
|
return err;
|
|
}
|
|
EXPORT_SYMBOL_GPL(smp_call_function_single_async);
|
|
|
|
/*
|
|
* smp_call_function_any - Run a function on any of the given cpus
|
|
* @mask: The mask of cpus it can run on.
|
|
* @func: The function to run. This must be fast and non-blocking.
|
|
* @info: An arbitrary pointer to pass to the function.
|
|
* @wait: If true, wait until function has completed.
|
|
*
|
|
* Returns 0 on success, else a negative status code (if no cpus were online).
|
|
*
|
|
* Selection preference:
|
|
* 1) current cpu if in @mask
|
|
* 2) any cpu of current node if in @mask
|
|
* 3) any other online cpu in @mask
|
|
*/
|
|
int smp_call_function_any(const struct cpumask *mask,
|
|
smp_call_func_t func, void *info, int wait)
|
|
{
|
|
unsigned int cpu;
|
|
const struct cpumask *nodemask;
|
|
int ret;
|
|
|
|
/* Try for same CPU (cheapest) */
|
|
cpu = get_cpu();
|
|
if (cpumask_test_cpu(cpu, mask))
|
|
goto call;
|
|
|
|
/* Try for same node. */
|
|
nodemask = cpumask_of_node(cpu_to_node(cpu));
|
|
for (cpu = cpumask_first_and(nodemask, mask); cpu < nr_cpu_ids;
|
|
cpu = cpumask_next_and(cpu, nodemask, mask)) {
|
|
if (cpu_online(cpu))
|
|
goto call;
|
|
}
|
|
|
|
/* Any online will do: smp_call_function_single handles nr_cpu_ids. */
|
|
cpu = cpumask_any_and(mask, cpu_online_mask);
|
|
call:
|
|
ret = smp_call_function_single(cpu, func, info, wait);
|
|
put_cpu();
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(smp_call_function_any);
|
|
|
|
/**
|
|
* smp_call_function_many(): Run a function on a set of other CPUs.
|
|
* @mask: The set of cpus to run on (only runs on online subset).
|
|
* @func: The function to run. This must be fast and non-blocking.
|
|
* @info: An arbitrary pointer to pass to the function.
|
|
* @wait: If true, wait (atomically) until function has completed
|
|
* on other CPUs.
|
|
*
|
|
* If @wait is true, then returns once @func has returned.
|
|
*
|
|
* You must not call this function with disabled interrupts or from a
|
|
* hardware interrupt handler or from a bottom half handler. Preemption
|
|
* must be disabled when calling this function.
|
|
*/
|
|
void smp_call_function_many(const struct cpumask *mask,
|
|
smp_call_func_t func, void *info, bool wait)
|
|
{
|
|
struct call_function_data *cfd;
|
|
int cpu, next_cpu, this_cpu = smp_processor_id();
|
|
|
|
/*
|
|
* Can deadlock when called with interrupts disabled.
|
|
* We allow cpu's that are not yet online though, as no one else can
|
|
* send smp call function interrupt to this cpu and as such deadlocks
|
|
* can't happen.
|
|
*/
|
|
WARN_ON_ONCE(cpu_online(this_cpu) && irqs_disabled()
|
|
&& !oops_in_progress && !early_boot_irqs_disabled);
|
|
|
|
/* Try to fastpath. So, what's a CPU they want? Ignoring this one. */
|
|
cpu = cpumask_first_and(mask, cpu_online_mask);
|
|
if (cpu == this_cpu)
|
|
cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
|
|
|
|
/* No online cpus? We're done. */
|
|
if (cpu >= nr_cpu_ids)
|
|
return;
|
|
|
|
/* Do we have another CPU which isn't us? */
|
|
next_cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
|
|
if (next_cpu == this_cpu)
|
|
next_cpu = cpumask_next_and(next_cpu, mask, cpu_online_mask);
|
|
|
|
/* Fastpath: do that cpu by itself. */
|
|
if (next_cpu >= nr_cpu_ids) {
|
|
smp_call_function_single(cpu, func, info, wait);
|
|
return;
|
|
}
|
|
|
|
cfd = this_cpu_ptr(&cfd_data);
|
|
|
|
cpumask_and(cfd->cpumask, mask, cpu_online_mask);
|
|
__cpumask_clear_cpu(this_cpu, cfd->cpumask);
|
|
|
|
/* Some callers race with other cpus changing the passed mask */
|
|
if (unlikely(!cpumask_weight(cfd->cpumask)))
|
|
return;
|
|
|
|
cpumask_clear(cfd->cpumask_ipi);
|
|
for_each_cpu(cpu, cfd->cpumask) {
|
|
call_single_data_t *csd = per_cpu_ptr(cfd->csd, cpu);
|
|
|
|
csd_lock(csd);
|
|
if (wait)
|
|
csd->flags |= CSD_FLAG_SYNCHRONOUS;
|
|
csd->func = func;
|
|
csd->info = info;
|
|
if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu)))
|
|
__cpumask_set_cpu(cpu, cfd->cpumask_ipi);
|
|
}
|
|
|
|
/* Send a message to all CPUs in the map */
|
|
arch_send_call_function_ipi_mask(cfd->cpumask_ipi);
|
|
|
|
if (wait) {
|
|
for_each_cpu(cpu, cfd->cpumask) {
|
|
call_single_data_t *csd;
|
|
|
|
csd = per_cpu_ptr(cfd->csd, cpu);
|
|
csd_lock_wait(csd);
|
|
}
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(smp_call_function_many);
|
|
|
|
/**
|
|
* smp_call_function(): Run a function on all other CPUs.
|
|
* @func: The function to run. This must be fast and non-blocking.
|
|
* @info: An arbitrary pointer to pass to the function.
|
|
* @wait: If true, wait (atomically) until function has completed
|
|
* on other CPUs.
|
|
*
|
|
* Returns 0.
|
|
*
|
|
* If @wait is true, then returns once @func has returned; otherwise
|
|
* it returns just before the target cpu calls @func.
|
|
*
|
|
* You must not call this function with disabled interrupts or from a
|
|
* hardware interrupt handler or from a bottom half handler.
|
|
*/
|
|
int smp_call_function(smp_call_func_t func, void *info, int wait)
|
|
{
|
|
preempt_disable();
|
|
smp_call_function_many(cpu_online_mask, func, info, wait);
|
|
preempt_enable();
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(smp_call_function);
|
|
|
|
/* Setup configured maximum number of CPUs to activate */
|
|
unsigned int setup_max_cpus = NR_CPUS;
|
|
EXPORT_SYMBOL(setup_max_cpus);
|
|
|
|
|
|
/*
|
|
* Setup routine for controlling SMP activation
|
|
*
|
|
* Command-line option of "nosmp" or "maxcpus=0" will disable SMP
|
|
* activation entirely (the MPS table probe still happens, though).
|
|
*
|
|
* Command-line option of "maxcpus=<NUM>", where <NUM> is an integer
|
|
* greater than 0, limits the maximum number of CPUs activated in
|
|
* SMP mode to <NUM>.
|
|
*/
|
|
|
|
void __weak arch_disable_smp_support(void) { }
|
|
|
|
static int __init nosmp(char *str)
|
|
{
|
|
setup_max_cpus = 0;
|
|
arch_disable_smp_support();
|
|
|
|
return 0;
|
|
}
|
|
|
|
early_param("nosmp", nosmp);
|
|
|
|
/* this is hard limit */
|
|
static int __init nrcpus(char *str)
|
|
{
|
|
int nr_cpus;
|
|
|
|
get_option(&str, &nr_cpus);
|
|
if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
|
|
nr_cpu_ids = nr_cpus;
|
|
|
|
return 0;
|
|
}
|
|
|
|
early_param("nr_cpus", nrcpus);
|
|
|
|
static int __init maxcpus(char *str)
|
|
{
|
|
get_option(&str, &setup_max_cpus);
|
|
if (setup_max_cpus == 0)
|
|
arch_disable_smp_support();
|
|
|
|
return 0;
|
|
}
|
|
|
|
early_param("maxcpus", maxcpus);
|
|
|
|
static int __init boot_cpus(char *str)
|
|
{
|
|
alloc_bootmem_cpumask_var(&boot_cpu_mask);
|
|
if (cpulist_parse(str, boot_cpu_mask) < 0) {
|
|
pr_warn("SMP: Incorrect boot_cpus cpumask\n");
|
|
return -EINVAL;
|
|
}
|
|
have_boot_cpu_mask = true;
|
|
return 0;
|
|
}
|
|
|
|
early_param("boot_cpus", boot_cpus);
|
|
|
|
/* Setup number of possible processor ids */
|
|
unsigned int nr_cpu_ids __read_mostly = NR_CPUS;
|
|
EXPORT_SYMBOL(nr_cpu_ids);
|
|
|
|
/* An arch may set nr_cpu_ids earlier if needed, so this would be redundant */
|
|
void __init setup_nr_cpu_ids(void)
|
|
{
|
|
nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
|
|
}
|
|
|
|
static inline bool boot_cpu(int cpu)
|
|
{
|
|
if (!have_boot_cpu_mask)
|
|
return true;
|
|
|
|
return cpumask_test_cpu(cpu, boot_cpu_mask);
|
|
}
|
|
|
|
static inline void free_boot_cpu_mask(void)
|
|
{
|
|
if (have_boot_cpu_mask) /* Allocated from boot_cpus() */
|
|
free_bootmem_cpumask_var(boot_cpu_mask);
|
|
}
|
|
|
|
/* Called by boot processor to activate the rest. */
|
|
void __init smp_init(void)
|
|
{
|
|
int num_nodes, num_cpus;
|
|
unsigned int cpu;
|
|
|
|
idle_threads_init();
|
|
cpuhp_threads_init();
|
|
|
|
pr_info("Bringing up secondary CPUs ...\n");
|
|
|
|
/* FIXME: This should be done in userspace --RR */
|
|
for_each_present_cpu(cpu) {
|
|
if (num_online_cpus() >= setup_max_cpus)
|
|
break;
|
|
if (!cpu_online(cpu) && boot_cpu(cpu))
|
|
cpu_up(cpu);
|
|
}
|
|
free_boot_cpu_mask();
|
|
|
|
num_nodes = num_online_nodes();
|
|
num_cpus = num_online_cpus();
|
|
pr_info("Brought up %d node%s, %d CPU%s\n",
|
|
num_nodes, (num_nodes > 1 ? "s" : ""),
|
|
num_cpus, (num_cpus > 1 ? "s" : ""));
|
|
|
|
/* Any cleanup work */
|
|
smp_cpus_done(setup_max_cpus);
|
|
}
|
|
|
|
/*
|
|
* Call a function on all processors. May be used during early boot while
|
|
* early_boot_irqs_disabled is set. Use local_irq_save/restore() instead
|
|
* of local_irq_disable/enable().
|
|
*/
|
|
int on_each_cpu(void (*func) (void *info), void *info, int wait)
|
|
{
|
|
unsigned long flags;
|
|
int ret = 0;
|
|
|
|
preempt_disable();
|
|
ret = smp_call_function(func, info, wait);
|
|
local_irq_save(flags);
|
|
func(info);
|
|
local_irq_restore(flags);
|
|
preempt_enable();
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(on_each_cpu);
|
|
|
|
/**
|
|
* on_each_cpu_mask(): Run a function on processors specified by
|
|
* cpumask, which may include the local processor.
|
|
* @mask: The set of cpus to run on (only runs on online subset).
|
|
* @func: The function to run. This must be fast and non-blocking.
|
|
* @info: An arbitrary pointer to pass to the function.
|
|
* @wait: If true, wait (atomically) until function has completed
|
|
* on other CPUs.
|
|
*
|
|
* If @wait is true, then returns once @func has returned.
|
|
*
|
|
* You must not call this function with disabled interrupts or from a
|
|
* hardware interrupt handler or from a bottom half handler. The
|
|
* exception is that it may be used during early boot while
|
|
* early_boot_irqs_disabled is set.
|
|
*/
|
|
void on_each_cpu_mask(const struct cpumask *mask, smp_call_func_t func,
|
|
void *info, bool wait)
|
|
{
|
|
int cpu = get_cpu();
|
|
|
|
smp_call_function_many(mask, func, info, wait);
|
|
if (cpumask_test_cpu(cpu, mask)) {
|
|
unsigned long flags;
|
|
local_irq_save(flags);
|
|
func(info);
|
|
local_irq_restore(flags);
|
|
}
|
|
put_cpu();
|
|
}
|
|
EXPORT_SYMBOL(on_each_cpu_mask);
|
|
|
|
/*
|
|
* on_each_cpu_cond(): Call a function on each processor for which
|
|
* the supplied function cond_func returns true, optionally waiting
|
|
* for all the required CPUs to finish. This may include the local
|
|
* processor.
|
|
* @cond_func: A callback function that is passed a cpu id and
|
|
* the the info parameter. The function is called
|
|
* with preemption disabled. The function should
|
|
* return a blooean value indicating whether to IPI
|
|
* the specified CPU.
|
|
* @func: The function to run on all applicable CPUs.
|
|
* This must be fast and non-blocking.
|
|
* @info: An arbitrary pointer to pass to both functions.
|
|
* @wait: If true, wait (atomically) until function has
|
|
* completed on other CPUs.
|
|
* @gfp_flags: GFP flags to use when allocating the cpumask
|
|
* used internally by the function.
|
|
*
|
|
* The function might sleep if the GFP flags indicates a non
|
|
* atomic allocation is allowed.
|
|
*
|
|
* Preemption is disabled to protect against CPUs going offline but not online.
|
|
* CPUs going online during the call will not be seen or sent an IPI.
|
|
*
|
|
* You must not call this function with disabled interrupts or
|
|
* from a hardware interrupt handler or from a bottom half handler.
|
|
*/
|
|
void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
|
|
smp_call_func_t func, void *info, bool wait,
|
|
gfp_t gfp_flags)
|
|
{
|
|
cpumask_var_t cpus;
|
|
int cpu, ret;
|
|
|
|
might_sleep_if(gfpflags_allow_blocking(gfp_flags));
|
|
|
|
if (likely(zalloc_cpumask_var(&cpus, (gfp_flags|__GFP_NOWARN)))) {
|
|
preempt_disable();
|
|
for_each_online_cpu(cpu)
|
|
if (cond_func(cpu, info))
|
|
cpumask_set_cpu(cpu, cpus);
|
|
on_each_cpu_mask(cpus, func, info, wait);
|
|
preempt_enable();
|
|
free_cpumask_var(cpus);
|
|
} else {
|
|
/*
|
|
* No free cpumask, bother. No matter, we'll
|
|
* just have to IPI them one by one.
|
|
*/
|
|
preempt_disable();
|
|
for_each_online_cpu(cpu)
|
|
if (cond_func(cpu, info)) {
|
|
ret = smp_call_function_single(cpu, func,
|
|
info, wait);
|
|
WARN_ON_ONCE(ret);
|
|
}
|
|
preempt_enable();
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(on_each_cpu_cond);
|
|
|
|
static void do_nothing(void *unused)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* kick_all_cpus_sync - Force all cpus out of idle
|
|
*
|
|
* Used to synchronize the update of pm_idle function pointer. It's
|
|
* called after the pointer is updated and returns after the dummy
|
|
* callback function has been executed on all cpus. The execution of
|
|
* the function can only happen on the remote cpus after they have
|
|
* left the idle function which had been called via pm_idle function
|
|
* pointer. So it's guaranteed that nothing uses the previous pointer
|
|
* anymore.
|
|
*/
|
|
void kick_all_cpus_sync(void)
|
|
{
|
|
/* Make sure the change is visible before we kick the cpus */
|
|
smp_mb();
|
|
smp_call_function(do_nothing, NULL, 1);
|
|
}
|
|
EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
|
|
|
|
/**
|
|
* wake_up_all_idle_cpus - break all cpus out of idle
|
|
* wake_up_all_idle_cpus try to break all cpus which is in idle state even
|
|
* including idle polling cpus, for non-idle cpus, we will do nothing
|
|
* for them.
|
|
*/
|
|
void wake_up_all_idle_cpus(void)
|
|
{
|
|
int cpu;
|
|
|
|
preempt_disable();
|
|
for_each_online_cpu(cpu) {
|
|
if (cpu == smp_processor_id())
|
|
continue;
|
|
|
|
if (s2idle_state == S2IDLE_STATE_ENTER ||
|
|
!cpu_isolated(cpu))
|
|
wake_up_if_idle(cpu);
|
|
}
|
|
preempt_enable();
|
|
}
|
|
EXPORT_SYMBOL_GPL(wake_up_all_idle_cpus);
|
|
|
|
/**
|
|
* smp_call_on_cpu - Call a function on a specific cpu
|
|
*
|
|
* Used to call a function on a specific cpu and wait for it to return.
|
|
* Optionally make sure the call is done on a specified physical cpu via vcpu
|
|
* pinning in order to support virtualized environments.
|
|
*/
|
|
struct smp_call_on_cpu_struct {
|
|
struct work_struct work;
|
|
struct completion done;
|
|
int (*func)(void *);
|
|
void *data;
|
|
int ret;
|
|
int cpu;
|
|
};
|
|
|
|
static void smp_call_on_cpu_callback(struct work_struct *work)
|
|
{
|
|
struct smp_call_on_cpu_struct *sscs;
|
|
|
|
sscs = container_of(work, struct smp_call_on_cpu_struct, work);
|
|
if (sscs->cpu >= 0)
|
|
hypervisor_pin_vcpu(sscs->cpu);
|
|
sscs->ret = sscs->func(sscs->data);
|
|
if (sscs->cpu >= 0)
|
|
hypervisor_pin_vcpu(-1);
|
|
|
|
complete(&sscs->done);
|
|
}
|
|
|
|
int smp_call_on_cpu(unsigned int cpu, int (*func)(void *), void *par, bool phys)
|
|
{
|
|
struct smp_call_on_cpu_struct sscs = {
|
|
.done = COMPLETION_INITIALIZER_ONSTACK(sscs.done),
|
|
.func = func,
|
|
.data = par,
|
|
.cpu = phys ? cpu : -1,
|
|
};
|
|
|
|
INIT_WORK_ONSTACK(&sscs.work, smp_call_on_cpu_callback);
|
|
|
|
if (cpu >= nr_cpu_ids || !cpu_online(cpu))
|
|
return -ENXIO;
|
|
|
|
queue_work_on(cpu, system_wq, &sscs.work);
|
|
wait_for_completion(&sscs.done);
|
|
|
|
return sscs.ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(smp_call_on_cpu);
|