* common/android-4.9-q:
ANDROID: android-verity: Prevent double-freeing metadata
Linux 4.9.317
bpf: Enlarge offset check value to INT_MAX in bpf_skb_{load,store}_bytes
NFSD: Fix possible sleep during nfsd4_release_lockowner()
tpm: ibmvtpm: Correct the return value in tpm_ibmvtpm_probe()
dm verity: set DM_TARGET_IMMUTABLE feature flag
dm stats: add cond_resched when looping over entries
dm crypt: make printing of the key constant-time
exec: Force single empty string when argv is empty
block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern
drm/i915: Fix -Wstringop-overflow warning in call to intel_read_wm_latency()
assoc_array: Fix BUG_ON during garbage collect
drivers: i2c: thunderx: Allow driver to work with ACPI defined TWSI controllers
net: af_key: check encryption module availability consistency
Linux 4.9.316
net: stmmac: fix missing pci_disable_device() on error in stmmac_pci_probe()
ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one()
mac80211: fix rx reordering with non explicit / psmp ack policy
scsi: qla2xxx: Fix missed DMA unmap for aborted commands
perf bench numa: Address compiler error on s390
igb: skip phy status check where unavailable
ARM: 9197/1: spectre-bhb: fix loop8 sequence for Thumb2
ARM: 9196/1: spectre-bhb: enable for Cortex-A15
net: af_key: add check for pfkey_broadcast in function pfkey_process
NFC: nci: fix sleep in atomic context bugs caused by nci_skb_alloc
net/qla3xxx: Fix a test in ql_reset_work()
net: vmxnet3: fix possible NULL pointer dereference in vmxnet3_rq_cleanup()
net: vmxnet3: fix possible use-after-free bugs in vmxnet3_rq_alloc_rx_buf()
drm/dp/mst: fix a possible memory leak in fetch_monitor_name()
perf: Fix sys_perf_event_open() race against self
ALSA: wavefront: Proper check of get_user() error
mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch()
mmc: block: Use generic_cmd6_time when modifying INAND_CMD38_ARG_EXT_CSD
mmc: core: Specify timeouts for BKOPS and CACHE_FLUSH for eMMC
ARM: 9191/1: arm/stacktrace, kasan: Silence KASAN warnings in unwind_frame()
drbd: remove usage of list iterator variable after loop
MIPS: lantiq: check the return value of kzalloc()
Input: add bounds checking to input_set_capability()
um: Cleanup syscall_handler_t definition/cast, fix warning
floppy: use a statically allocated error counter
Linux 4.9.315
tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
ping: fix address binding wrt vrf
USB: serial: option: add Fibocom MA510 modem
USB: serial: option: add Fibocom L610 modem
USB: serial: qcserial: add support for Sierra Wireless EM7590
USB: serial: pl2303: add device id for HP LM930 Display
usb: cdc-wdm: fix reading stuck on device close
ASoC: ops: Validate input values in snd_soc_put_volsw_range()
ASoC: max98090: Generate notifications on changes for custom control
ASoC: max98090: Reject invalid values in custom control put()
hwmon: (f71882fg) Fix negative temperature
net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe()
s390/lcs: fix variable dereferenced before check
s390/ctcm: fix potential memory leak
s390/ctcm: fix variable dereferenced before check
mac80211_hwsim: call ieee80211_tx_prepare_skb under RCU protection
netlink: do not reset transport header in netlink_recvmsg()
ipv4: drop dst in multicast routing path
net: Fix features skip in for_each_netdev_feature()
Linux 4.9.314
mm: userfaultfd: fix missing cache flush in mcopy_atomic_pte() and __mcopy_atomic()
mmc: rtsx: add 74 Clocks in power on flow
Bluetooth: Fix the creation of hdev->name
can: grcan: only use the NAPI poll budget for RX
can: grcan: grcan_probe(): fix broken system id check for errata workaround needs
block: drbd: drbd_nl: Make conversion to 'enum drbd_ret_code' explicit
MIPS: Use address-of operator on section symbols
Linux 4.9.313
dm: interlock pending dm_io and dm_wait_for_bios_completion
dm: fix mempool NULL pointer race when completing IO
net: ipv6: ensure we call ipv6_mc_down() at most once
net: sched: prevent UAF on tc_ctl_tfilter when temporarily dropping rtnl_lock
kvm: x86/cpuid: Only provide CPUID leaf 0xA if host has architectural PMU
net: igmp: respect RCU rules in ip_mc_source() and ip_mc_msfilter()
btrfs: always log symlinks in full mode
smsc911x: allow using IRQ0
net: emaclite: Add error handling for of_address_to_resource()
ASoC: dmaengine: Restore NULL prepare_slave_config() callback
hwmon: (adt7470) Fix warning on module removal
NFC: netlink: fix sleep in atomic bug when firmware download timeout
nfc: nfcmrvl: main: reorder destructive operations in nfcmrvl_nci_unregister_dev to avoid bugs
nfc: replace improper check device_is_registered() in netlink related functions
can: grcan: use ofdev->dev when allocating DMA memory
can: grcan: grcan_close(): fix deadlock
ASoC: wm8958: Fix change notifications for DSP controls
firewire: core: extend card->lock in fw_core_handle_bus_reset
firewire: remove check of list iterator against head past the loop body
firewire: fix potential uaf in outbound_phy_packet_callback()
Revert "SUNRPC: attempt AF_LOCAL connect on setup"
ALSA: fireworks: fix wrong return count shorter than expected by 4 bytes
parisc: Merge model and model name into one line in /proc/cpuinfo
MIPS: Fix CP0 counter erratum detection for R4k CPUs
tty: n_gsm: fix incorrect UA handling
tty: n_gsm: fix wrong command frame length field encoding
tty: n_gsm: fix wrong command retry handling
tty: n_gsm: fix missing explicit ldisc flush
tty: n_gsm: fix insufficient txframe size
tty: n_gsm: fix malformed counter for out of frame data
tty: n_gsm: fix wrong signal octet encoding in convergence layer type 2
x86/cpu: Load microcode during restore_processor_state()
drivers: net: hippi: Fix deadlock in rr_close()
ASoC: wm8731: Disable the regulator when probing fails
bnx2x: fix napi API usage sequence
clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()
bus: sunxi-rsb: Fix the return value of sunxi_rsb_device_create()
tcp: fix potential xmit stalls caused by TCP_NOTSENT_LOWAT
ip_gre: Make o_seqno start from 0 in native mode
pinctrl: pistachio: fix use of irq_of_parse_and_map()
mtd: rawnand: Fix return value check of wait_for_completion_timeout
ARM: dts: Fix mmc order for omap3-gta04
ARM: OMAP2+: Fix refcount leak in omap_gic_of_init
phy: samsung: exynos5250-sata: fix missing device put in probe error paths
phy: samsung: Fix missing of_node_put() in exynos_sata_phy_probe
ARM: dts: imx6qdl-apalis: Fix sgtl5000 detection issue
hex2bin: fix access beyond string end
hex2bin: make the function hex_to_bin constant-time
serial: 8250: Correct the clock for EndRun PTP/1588 PCIe device
serial: 8250: Also set sticky MCR bits in console restoration
usb: gadget: configfs: clear deactivation flag in configfs_composite_unbind()
usb: gadget: uvc: Fix crash when encoding data for usb request
usb: misc: fix improper handling of refcount in uss720_probe()
iio: magnetometer: ak8975: Fix the error handling in ak8975_power_on()
iio: dac: ad5446: Fix read_raw not returning set value
iio: dac: ad5592r: Fix the missing return value.
xhci: stop polling roothubs after shutdown
USB: serial: option: add Telit 0x1057, 0x1058, 0x1075 compositions
USB: serial: option: add support for Cinterion MV32-WA/MV32-WB
USB: serial: cp210x: add PIDs for Kamstrup USB Meter Reader
USB: serial: whiteheat: fix heap overflow in WHITEHEAT_GET_DTR_RTS
USB: quirks: add STRING quirk for VCOM device
USB: quirks: add a Realtek card reader
lightnvm: disable the subsystem
Revert "net: ethernet: stmmac: fix altr_tse_pcs function when using a fixed-link"
floppy: disable FDRAWCMD by default
Linux 4.9.312
block/compat_ioctl: fix range check in BLKGETSIZE
ext4: force overhead calculation if the s_overhead_cluster makes no sense
ext4: fix overhead calculation to account for the reserved gdt blocks
ext4: limit length to bitmap_maxbytes - blocksize in punch_hole
ARC: entry: fix syscall_trace_exit argument
e1000e: Fix possible overflow in LTR decoding
ASoC: soc-dapm: fix two incorrect uses of list iterator
openvswitch: fix OOB access in reserve_sfa_size()
dma: at_xdmac: fix a missing check on list iterator
ata: pata_marvell: Check the 'bmdma_addr' beforing reading
drm/msm/mdp5: check the return of kzalloc()
brcmfmac: sdio: Fix undefined behavior due to shift overflowing the constant
cifs: Check the IOCB_DIRECT flag, not O_DIRECT
vxlan: fix error return code in vxlan_fdb_append
ALSA: usb-audio: Fix undefined behavior due to shift overflowing the constant
platform/x86: samsung-laptop: Fix an unsigned comparison which can never be negative
ARM: vexpress/spc: Avoid negative array index when !SMP
netlink: reset network and mac headers in netlink_dump()
net/packet: fix packet_sock xmit return value checking
dmaengine: imx-sdma: Fix error checking in sdma_event_remap
ALSA: usb-audio: Clear MIDI port active flag after draining
gfs2: assign rgrp glock before compute_bitstructs
mm: page_alloc: fix building error on -Werror=array-compare
etherdevice: Adjust ether_addr* prototypes to silence -Wstringop-overead
Linux 4.9.311
gcc-plugins: latent_entropy: use /dev/urandom
i2c: pasemi: Wait for write xfers to finish
smp: Fix offline cpu check in flush_smp_call_function_queue()
ARM: davinci: da850-evm: Avoid NULL pointer dereference
ALSA: pcm: Test for "silence" field in struct "pcm_format_data"
mm: kmemleak: take a full lowmem check in kmemleak_*_phys()
mm, page_alloc: fix build_zonerefs_node()
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
net: micrel: fix KS8851_MLL Kconfig
scsi: ibmvscsis: Increase INITIAL_SRP_LIMIT to 1024
drm/amdkfd: Check for potential null return of kmalloc_array()
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
veth: Ensure eth header is in skb's linear part
xfrm: policy: match with both mark and mask on user interfaces
arm64: module: remove (NOLOAD) from linker script
mm: don't skip swap entry even if zap_details specified
dmaengine: Revert "dmaengine: shdma: Fix runtime PM imbalance on error"
tools build: Use $(shell ) instead of `` to get embedded libperl's ccopts
arm64: patch_text: Fixup last cpu should be master
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)
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()
mm: fix race between MADV_FREE reclaim and blkdev direct IO read
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()
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
Bluetooth: Fix use after free in hci_send_acl
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
bnxt_en: Eliminate unintended link toggle during FW reset
scsi: aha152x: Fix aha152x_setup() __setup handler return value
scsi: pm8001: Fix pm8001_mpi_task_abort_resp()
dm ioctl: prevent potential spectre v1 gadget
iommu/arm-smmu-v3: fix event handling soft lockup
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
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
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
ACPI: CPPC: Avoid out of bounds access when parsing _CPC data
pinctrl: pinconf-generic: Print arguments for bias-pull-*
gfs2: Make sure FITRIM minlen is rounded up to fs block size
ubifs: setflags: Make dirtied_ino_d 8 bytes aligned
ubifs: Add missing iput if do_tmpfile() failed in rename whiteout
KVM: Prevent module exit until all VMs are freed
scsi: qla2xxx: Fix incorrect reporting of task management failure
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
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
spi: tegra20: Use of_device_get_match_data()
PM: core: keep irq flags in device_pm_check_callbacks()
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()
selinux: use correct type for context length
net/x25: Fix null-ptr-deref caused by x25_disconnect
qlcnic: dcb: default to returning -EOPNOTSUPP
net: phy: broadcom: Fix brcm_fet_config_init()
netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options
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
iio: adc: Add check for devm_request_threaded_irq
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
i2c: mux: demux-pinctrl: do not deactivate a master that is not active
af_netlink: Fix shift out of bounds in group mask calculation
USB: storage: ums-realtek: fix error code in rts51x_read_mem()
MIPS: RB532: fix return value of __setup handler
mfd: mc13xxx: Add check for mc13xxx_irq_request
powerpc/sysdev: fix incorrect use to determine if list is empty
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
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()
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
ath9k_htc: fix uninit value bugs
drm/edid: Don't clear formats if using deep color
mtd: onenand: Check for error irq
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
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
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()
video: fbdev: smscufx: Fix null-ptr-deref in ufx_usb_probe()
perf/x86/intel/pt: Fix address filter config for 32-bit kernel
perf/core: Fix address filter parser for multiple filters
sched/debug: Remove mpol_get/put and task_lock/unlock from sched_show_numa
clocksource: acpi_pm: fix return value of __setup handler
hwmon: (pmbus) Add Vin unit off handling
crypto: ccp - ccp_dmaengine_unregister release dma channels
crypto: vmx - add missing dependencies
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
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
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
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
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()
ALSA: cs4236: fix an incorrect NULL check on list iterator
Revert "Input: clear BTN_RIGHT/MIDDLE on buttonpads"
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
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
NFSD: prevent underflow in nfssvc_decode_writeargs()
SUNRPC: avoid race between mod_timer() and del_timer_sync()
ptrace: Check PTRACE_O_SUSPEND_SECCOMP permission on PTRACE_SEIZE
clk: uniphier: Fix fixed-rate initialization
iio: inkern: make a best effort on offset calculation
iio: inkern: apply consumer scale on IIO_VAL_INT cases
coresight: Fix TRCCONFIGR.QE sysfs interface
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
af_key: add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register
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
USB: serial: simple: add Nokia phone driver
USB: serial: pl2303: add IBM device IDs
Linux 4.9.310
arm64: Use the clearbhb instruction in mitigations
arm64: add ID_AA64ISAR2_EL1 sys register
KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated
arm64: Mitigate spectre style branch history side channels
KVM: arm64: Add templates for BHB mitigation sequences
arm64: Add percpu vectors for EL1
arm64: entry: Add macro for reading symbol addresses from the trampoline
arm64: entry: Add vectors that have the bhb mitigation sequences
arm64: Move arm64_update_smccc_conduit() out of SSBD ifdef
arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations
arm64: entry: Allow the trampoline text to occupy multiple pages
arm64: entry: Make the kpti trampoline's kpti sequence optional
arm64: entry: Move trampoline macros out of ifdef'd section
arm64: entry: Don't assume tramp_vectors is the start of the vectors
arm64: entry: Allow tramp_alias to access symbols after the 4K boundary
arm64: entry: Move the trampoline data page before the text page
arm64: entry: Free up another register on kpti's tramp_exit path
arm64: entry: Make the trampoline cleanup optional
arm64: entry.S: Add ventry overflow sanity checks
arm64: Add helper to decode register from instruction
arm64: Add Cortex-X2 CPU part definition
arm64: Add Neoverse-N2, Cortex-A710 CPU part definition
arm64: Add part number for Arm Cortex-A77
arm64: Add part number for Neoverse N1
arm64: Make ARM64_ERRATUM_1188873 depend on COMPAT
arm64: Add silicon-errata.txt entry for ARM erratum 1188873
arm64: arch_timer: avoid unused function warning
arm64: arch_timer: Add workaround for ARM erratum 1188873
arm64: arch_timer: Add erratum handler for CPU-specific capability
arm64: arch_timer: Add infrastructure for multiple erratum detection methods
clocksource/drivers/arm_arch_timer: Introduce generic errata handling infrastructure
clocksource/drivers/arm_arch_timer: Remove fsl-a008585 parameter
arm64: capabilities: Add support for checks based on a list of MIDRs
arm64: Add helpers for checking CPU MIDR against a range
arm64: capabilities: Clean up midr range helpers
arm64: capabilities: Add flags to handle the conflicts on late CPU
arm64: capabilities: Prepare for fine grained capabilities
arm64: capabilities: Move errata processing code
arm64: capabilities: Move errata work around check on boot CPU
arm64: capabilities: Update prototype for enable call back
arm64: Add MIDR encoding for Arm Cortex-A55 and Cortex-A35
arm64: Remove useless UAO IPI and describe how this gets enabled
arm64: errata: Provide macro for major and minor cpu revisions
Conflicts:
arch/arm64/include/asm/assembler.h
arch/arm64/include/asm/cputype.h
arch/arm64/kernel/bpi.S
arch/arm64/kernel/cpu_errata.c
drivers/clk/qcom/clk-rcg2.c
drivers/gpu/drm/drm_edid.c
drivers/mmc/core/core.c
drivers/mmc/core/host.c
mm/memory.c
Change-Id: Ibea04b7ed72b8d1fd7c575cbc23dd0e73d321e6c
814 lines
22 KiB
C
814 lines
22 KiB
C
/*
|
|
* Generic helpers for smp ipi calls
|
|
*
|
|
* (C) Jens Axboe <jens.axboe@oracle.com> 2008
|
|
*/
|
|
#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/hypervisor.h>
|
|
#include <linux/suspend.h>
|
|
|
|
#include "smpboot.h"
|
|
|
|
enum {
|
|
CSD_FLAG_LOCK = 0x01,
|
|
CSD_FLAG_SYNCHRONOUS = 0x02,
|
|
};
|
|
|
|
struct call_function_data {
|
|
struct call_single_data __percpu *csd;
|
|
cpumask_var_t cpumask;
|
|
};
|
|
|
|
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;
|
|
cfd->csd = alloc_percpu(struct call_single_data);
|
|
if (!cfd->csd) {
|
|
free_cpumask_var(cfd->cpumask);
|
|
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_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 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(struct call_single_data, csd_data);
|
|
|
|
/*
|
|
* Insert a previously allocated call_single_data 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;
|
|
struct call_single_data *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)
|
|
{
|
|
struct call_single_data *csd;
|
|
struct call_single_data 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;
|
|
|
|
for_each_cpu(cpu, cfd->cpumask) {
|
|
struct call_single_data *csd = per_cpu_ptr(cfd->csd, cpu);
|
|
|
|
csd_lock(csd);
|
|
if (wait)
|
|
csd->flags |= CSD_FLAG_SYNCHRONOUS;
|
|
csd->func = func;
|
|
csd->info = info;
|
|
llist_add(&csd->llist, &per_cpu(call_single_queue, cpu));
|
|
}
|
|
|
|
/* Send a message to all CPUs in the map */
|
|
arch_send_call_function_ipi_mask(cfd->cpumask);
|
|
|
|
if (wait) {
|
|
for_each_cpu(cpu, cfd->cpumask) {
|
|
struct call_single_data *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 */
|
|
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;
|
|
}
|
|
|
|
void __weak smp_announce(void)
|
|
{
|
|
printk(KERN_INFO "Brought up %d CPUs\n", num_online_cpus());
|
|
}
|
|
|
|
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)
|
|
{
|
|
unsigned int cpu;
|
|
|
|
idle_threads_init();
|
|
cpuhp_threads_init();
|
|
|
|
/* 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();
|
|
|
|
/* Final decision about SMT support */
|
|
cpu_smt_check_topology();
|
|
/* Any cleanup work */
|
|
smp_announce();
|
|
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 (suspend_freeze_state == FREEZE_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);
|