platform/kernel/linux-amlogic.git
5 years agoMerge tag 'v4.9.181' into khadas-vims-4.9.y-update
Nick Xie [Thu, 25 Jul 2019 10:03:59 +0000 (18:03 +0800)]
Merge tag 'v4.9.181' into khadas-vims-4.9.y-update

This is the 4.9.181 stable release

 Conflicts:
drivers/android/binder.c
drivers/firmware/efi/libstub/arm-stub.c
drivers/firmware/efi/libstub/efi-stub-helper.c

5 years agoRevert "chardev: add additional check for minor range overlap"
Nick Xie [Thu, 25 Jul 2019 09:55:07 +0000 (17:55 +0800)]
Revert "chardev: add additional check for minor range overlap"

This reverts commit bb22efcb872b8108131a38399ae910dcb0304770.

5 years agoMerge tag 'v4.9.180' into khadas-vims-4.9.y-update
Nick Xie [Thu, 25 Jul 2019 09:03:43 +0000 (17:03 +0800)]
Merge tag 'v4.9.180' into khadas-vims-4.9.y-update

This is the 4.9.180 stable release

 Conflicts:
arch/arm64/mm/proc.S

5 years agofixup! sound: fixup sound card
Nick Xie [Wed, 24 Jul 2019 01:48:57 +0000 (09:48 +0800)]
fixup! sound: fixup sound card

5 years agodrivers/amlogic/mmc: don't use Amlogic partition layout if there is no device tree...
Nick Xie [Tue, 23 Jul 2019 08:20:56 +0000 (16:20 +0800)]
drivers/amlogic/mmc: don't use Amlogic partition layout if there is no device tree node

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoRevert "builddeb: dtb: add dtb upgrade mark"
Nick Xie [Fri, 19 Jul 2019 10:15:16 +0000 (18:15 +0800)]
Revert "builddeb: dtb: add dtb upgrade mark"

This reverts commit f40ff6266fb6d061ba13e28fc4224521f97cfa07.

5 years agobuilddeb: dtb: add dtb upgrade mark
Nick Xie [Fri, 19 Jul 2019 05:57:42 +0000 (13:57 +0800)]
builddeb: dtb: add dtb upgrade mark

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoremove unused fusb302 driver
Nick Xie [Fri, 19 Jul 2019 01:55:16 +0000 (09:55 +0800)]
remove unused fusb302 driver

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: defconfig: enable XFS_FS as module
Nick Xie [Fri, 19 Jul 2019 01:52:48 +0000 (09:52 +0800)]
arm64: defconfig: enable XFS_FS as module

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: dts: VIM3: remove fusb302 node
Nick Xie [Mon, 15 Jul 2019 08:55:15 +0000 (16:55 +0800)]
arm64: dts: VIM3: remove fusb302 node

don't setup FUB302 in kernel, setup it in u-boot

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: defconfig: remove CONFIG_FUSB302
Nick Xie [Mon, 15 Jul 2019 02:56:42 +0000 (10:56 +0800)]
arm64: defconfig: remove CONFIG_FUSB302

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoWakeUp: add WOL_WAKEUP event support
terry [Sat, 13 Jul 2019 07:05:43 +0000 (15:05 +0800)]
WakeUp: add WOL_WAKEUP event support

5 years agophy/realtek: fixup suspend failed issue
Nick Xie [Sat, 13 Jul 2019 03:36:43 +0000 (11:36 +0800)]
phy/realtek: fixup suspend failed issue

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoamlogic/media_modules: update Kconfig
Nick Xie [Fri, 12 Jul 2019 05:55:41 +0000 (13:55 +0800)]
amlogic/media_modules: update Kconfig

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoamlogic/avs2: fix amlogic multi dec
Nick Xie [Thu, 11 Jul 2019 07:09:48 +0000 (15:09 +0800)]
amlogic/avs2: fix amlogic multi dec

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: defconfig: disable CONFIG_AMLOGIC_MEDIA_MULTI_DEC
Nick Xie [Thu, 11 Jul 2019 07:09:02 +0000 (15:09 +0800)]
arm64: defconfig: disable CONFIG_AMLOGIC_MEDIA_MULTI_DEC

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agovp9: fix CONFIG_AMLOGIC_MEDIA_MULTI_DEC patch
afl1 [Wed, 26 Jun 2019 17:14:17 +0000 (19:14 +0200)]
vp9: fix CONFIG_AMLOGIC_MEDIA_MULTI_DEC patch

5 years agoamlogic/vvp9: fix amlogic multi dec
afl1 [Sun, 10 Mar 2019 20:08:12 +0000 (21:08 +0100)]
amlogic/vvp9: fix amlogic multi dec

5 years agodrivers/of: put extended cmdline at the end
kszaq [Sun, 26 Jun 2016 23:37:55 +0000 (01:37 +0200)]
drivers/of: put extended cmdline at the end

5 years agoproc: fix make cmdline writable for amlogic-4.9
adamg [Tue, 25 Jun 2019 04:51:02 +0000 (05:51 +0100)]
proc: fix make cmdline writable for amlogic-4.9

5 years agofs/proc: make cmdline writable
kszaq [Mon, 15 Aug 2016 00:45:14 +0000 (02:45 +0200)]
fs/proc: make cmdline writable

5 years agodrivers/amlogic/media/osd: change L2C1 register for osd_two_ports function
Portisch [Tue, 9 Jul 2019 05:57:43 +0000 (07:57 +0200)]
drivers/amlogic/media/osd: change L2C1 register for osd_two_ports function

This will change the osd _two_port register to VPU_WRARB_MODE_L2C1.
On S922X devices the system freezed sometimes on osd hardware init.

5 years agoaml: automatically switch on double write 1:2 mode with 8K content
Arthur Liberman [Sat, 6 Jul 2019 18:26:36 +0000 (21:26 +0300)]
aml: automatically switch on double write 1:2 mode with 8K content

5 years agoamlogic/bluetooth: Turn BT device on after probe
Radostan Riedel [Fri, 26 Jan 2018 20:55:36 +0000 (21:55 +0100)]
amlogic/bluetooth: Turn BT device on after probe

5 years agoamlogic/deinterlace: Don't bypass if the stream is mixed Interlaced and Progressive
Ray [Wed, 5 Jun 2019 09:15:04 +0000 (11:15 +0200)]
amlogic/deinterlace: Don't bypass if the stream is mixed Interlaced and Progressive

It fixes slowdowns on I/P switching.
Some UK streams switch between I and P (mostly) in commercials. 98% of
the stream is still interlaced so it is safe to DI the whole stream.

5 years agovh265: less kernel log spam
Ray [Wed, 20 Mar 2019 09:47:26 +0000 (10:47 +0100)]
vh265: less kernel log spam

5 years agovvc1: less pr_info spam
Ray [Wed, 20 Mar 2019 08:36:41 +0000 (09:36 +0100)]
vvc1: less pr_info spam

5 years agoh265: increase margin for dynamic buffers
afl1 [Fri, 31 May 2019 05:27:01 +0000 (07:27 +0200)]
h265: increase margin for dynamic buffers

Increasing margin from 7 to 8 fixes playback issue for some non-standard hevc streams.

5 years agoamlogic/decoder/vh264: Define ENABLE_SEI_ITU_T35
Ray [Mon, 27 May 2019 12:05:52 +0000 (14:05 +0200)]
amlogic/decoder/vh264: Define ENABLE_SEI_ITU_T35

This fixes fatal errors in the decoder when qos data is empty

5 years agoamlogic/decoder/vh264: use stretchblt_noalpha_noblk to not block ge2d
Ray [Fri, 24 May 2019 11:11:45 +0000 (13:11 +0200)]
amlogic/decoder/vh264: use stretchblt_noalpha_noblk to not block ge2d

5 years agovideo_sink: add amvideocap module This will add the amvideocap module to kernel 4...
Portisch [Mon, 8 Apr 2019 08:10:17 +0000 (08:10 +0000)]
video_sink: add amvideocap module This will add the amvideocap module to kernel 4.9 If the frame rate is higher than 30 fps each second frame get captured. stretchblt: fix missing block assignment in _stretchblt_noalpha

5 years agoEXPORT_SYMBOL(videosync_pcrscr_update)
afl1 [Wed, 15 May 2019 22:20:13 +0000 (00:20 +0200)]
EXPORT_SYMBOL(videosync_pcrscr_update)

5 years agotype override
afl1 [Wed, 15 May 2019 21:06:50 +0000 (23:06 +0200)]
type override

5 years agoamstream.c: Tweak video buffers
Ray [Fri, 3 May 2019 09:51:29 +0000 (11:51 +0200)]
amstream.c: Tweak video buffers

5 years agoenable build amlvideodri.ko
afl1 [Fri, 29 Mar 2019 05:17:00 +0000 (06:17 +0100)]
enable build amlvideodri.ko

5 years agoamlogic/vh264: Set enable_switch_fense to 0
Ray [Fri, 3 May 2019 09:56:51 +0000 (11:56 +0200)]
amlogic/vh264: Set enable_switch_fense to 0

5 years agoamlogic/vh264: non-idr or non-I frame will set pts_valid
afl1 [Sun, 10 Mar 2019 07:51:06 +0000 (08:51 +0100)]
amlogic/vh264: non-idr or non-I frame will set pts_valid

5 years agoamlogic/vh264: use error_recovery_mode = 1 for H264
afl1 [Sun, 10 Mar 2019 07:03:35 +0000 (08:03 +0100)]
amlogic/vh264: use error_recovery_mode = 1 for H264

5 years agoamlogic/vmpeg4: calculate PTS from DTS for PTS_ON_KEYFRAME
Ray [Wed, 6 Mar 2019 08:22:42 +0000 (09:22 +0100)]
amlogic/vmpeg4: calculate PTS from DTS for PTS_ON_KEYFRAME

5 years agoamlogic/vvc1: calculate PTS from DTS for PTS_ON_KEYFRAME
Ray [Wed, 6 Mar 2019 08:01:57 +0000 (09:01 +0100)]
amlogic/vvc1: calculate PTS from DTS for PTS_ON_KEYFRAME

5 years agoAML: v4l2_qbuf
Ray [Wed, 6 Mar 2019 08:25:36 +0000 (09:25 +0100)]
AML: v4l2_qbuf

5 years agodeinterlace.c: bypass on progressive
Ray [Fri, 3 May 2019 09:55:30 +0000 (11:55 +0200)]
deinterlace.c: bypass on progressive

5 years agoTSin: fix FEC_INPUT_CONTROL
afl1 [Wed, 1 May 2019 09:53:04 +0000 (11:53 +0200)]
TSin: fix FEC_INPUT_CONTROL

5 years agotee: disable by default
Ray [Mon, 29 Apr 2019 13:31:17 +0000 (15:31 +0200)]
tee: disable by default

Fixes weird h264 reset bug

5 years agorealtek: Reinit phy after wakeup when WOL is disabled
Ray [Wed, 24 Apr 2019 13:41:44 +0000 (15:41 +0200)]
realtek: Reinit phy after wakeup when WOL is disabled

When WOL is disabled the power is cut in uboot. After wakeup the speed
is very slow. Re-init fixes it.

5 years agovpp: disable super_scaler
Ray [Tue, 16 Apr 2019 07:17:44 +0000 (09:17 +0200)]
vpp: disable super_scaler

fixes cartoon like bleeding effects

5 years agohdmitx: add "now" to attr to trigger set_disp_mode_auto()
cdu13a [Thu, 11 Apr 2019 03:58:08 +0000 (23:58 -0400)]
hdmitx: add "now" to attr to trigger set_disp_mode_auto()

Useful for testing. Adding "now" to attr is a one shot way to force
changes to current hdmi settings to take effect imediatly instead of
waiting for a mode change.

5 years agohdmi_tx: improve display of current hdmi config
cdu13a [Sun, 7 Apr 2019 01:04:11 +0000 (21:04 -0400)]
hdmi_tx: improve display of current hdmi config

Use register info to get info about current config and display it in a more human
readable format.

5 years agodrivers/amlogic: fix 'dobly' typos to 'dolby'
Arthur Liberman [Sat, 9 Mar 2019 13:23:35 +0000 (15:23 +0200)]
drivers/amlogic: fix 'dobly' typos to 'dolby'

5 years agohdmi_audio: fix passthrough for 4k DD+ This hack is no longer required, as hdmi_get_a...
Arthur Liberman [Sun, 28 Apr 2019 20:35:34 +0000 (23:35 +0300)]
hdmi_audio: fix passthrough for 4k DD+ This hack is no longer required, as hdmi_get_aud_n_paras() now handles the multiplier correctly.

5 years agosound/soc/auge: fix clock for DD+
afl1 [Sat, 9 Mar 2019 16:10:51 +0000 (17:10 +0100)]
sound/soc/auge: fix clock for DD+

5 years agosound/soc/auge: fix HD audio passthrough
afl1 [Wed, 6 Mar 2019 20:18:55 +0000 (21:18 +0100)]
sound/soc/auge: fix HD audio passthrough

5 years agophy_device: fix: do not check for suspend on resume Only check if the device was...
Portisch [Tue, 5 Mar 2019 12:10:12 +0000 (13:10 +0100)]
phy_device: fix: do not check for suspend on resume Only check if the device was sent to suspend before.

5 years agoosd: don't call osd_wait_vsync_event during HW decoded video playback
Arthur Liberman [Mon, 8 Apr 2019 22:03:16 +0000 (01:03 +0300)]
osd: don't call osd_wait_vsync_event during HW decoded video playback

5 years agodrivers/amlogic/media/osd: fix potentially incorrect hw/pxp modes
adamg [Fri, 22 Feb 2019 11:08:02 +0000 (11:08 +0000)]
drivers/amlogic/media/osd: fix potentially incorrect hw/pxp modes

5 years agosound: fixup sound card
Nick Xie [Wed, 3 Jul 2019 09:52:13 +0000 (17:52 +0800)]
sound: fixup sound card

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agosound: spdif: disable mono sound channel
Nick Xie [Wed, 3 Jul 2019 08:52:56 +0000 (16:52 +0800)]
sound: spdif: disable mono sound channel

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: dts: VIM3: remove memory node to support 4GB DDR
Nick Xie [Mon, 1 Jul 2019 02:53:39 +0000 (10:53 +0800)]
arm64: dts: VIM3: remove memory node to support 4GB DDR

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoMCU: FAN: fixup speed level
Nick Xie [Wed, 26 Jun 2019 07:02:07 +0000 (15:02 +0800)]
MCU: FAN: fixup speed level

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoMCU: VIM3: fixup temperature read issue
Nick Xie [Wed, 26 Jun 2019 06:40:22 +0000 (14:40 +0800)]
MCU: VIM3: fixup temperature read issue

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoMCU: add poweroff node
Nick Xie [Wed, 26 Jun 2019 03:25:02 +0000 (11:25 +0800)]
MCU: add poweroff node

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoMCU: VIM3: add USB PCIe switch node
Nick Xie [Wed, 26 Jun 2019 03:07:41 +0000 (11:07 +0800)]
MCU: VIM3: add USB PCIe switch node

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoVIM3: tca6408: setup all gpios to output low when initialize
Nick Xie [Mon, 24 Jun 2019 14:08:57 +0000 (22:08 +0800)]
VIM3: tca6408: setup all gpios to output low when initialize

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoemmc: After standby sleep, clear the CMD tuning flag [1/1]
Long Yu [Tue, 28 May 2019 07:28:12 +0000 (15:28 +0800)]
emmc: After standby sleep, clear the CMD tuning flag [1/1]

PD#SWPL-9075

Problem:
Because the CMD tune flag was not cleared before standby,
debug printing was performed during auto tune

Solution:
After standby sleep, clear the CMD tuning flag

Verify:
passed on TL1

Change-Id: Ie4a531346f50983009477131408d81c76d5c020f
Signed-off-by: Long Yu <long.yu@amlogic.com>
5 years agoemmc: report response crc error on G12B when hs400 200M busmode [1/1]
Long Yu [Tue, 14 May 2019 07:17:30 +0000 (15:17 +0800)]
emmc: report response crc error on G12B when hs400 200M busmode [1/1]

PD#SWPL-8670

Problem:
G12B report response crc error when hs400 200M busmode

Solution:
find a eyetest hole between 14-20 or 48-54, otherwise
tuning tx_delay and find again and
adjust CMD rx timing dynamically in HS400 mode

Verify:
passed on G12B

Change-Id: I23e4d5118e0ca0564367a77102aea9e1085633a9
Signed-off-by: Long Yu <long.yu@amlogic.com>
5 years agoemmc: report response crc error on tl1 when hs400 200M busmode [1/1]
Ruixuan Li [Thu, 18 Apr 2019 07:48:44 +0000 (15:48 +0800)]
emmc: report response crc error on tl1 when hs400 200M busmode [1/1]

PD#SWPL-7740

Problem:
tl1 report response crc error on tl1 when hs400 200M busmode

Solution:
find a eyetest hole between 14-20 or 48-54, otherwise
tuning tx_delay and find again

Verify:
passed on tl1_skt

Change-Id: I46e2c3c4d7ef24bcac7b44fee73112894540fc33
Signed-off-by: Ruixuan Li <ruixuan.li@amlogic.com>
5 years agoemmc: run hs400 200M on sm1 [1/1]
Ruixuan Li [Tue, 23 Apr 2019 08:07:12 +0000 (16:07 +0800)]
emmc: run hs400 200M on sm1 [1/1]

PD#SWPL-5404

Problem:
run hs400 200M on sm1

Solution:
config sm1 and modify dts

Verify:
passed on ac200

Change-Id: I34e54f88db79ce42f9effbf8d673ade613de328f
Signed-off-by: Ruixuan Li <ruixuan.li@amlogic.com>
5 years agoarm64: dts: emmc: VIM3: Add HS400 busmode support
Nick Xie [Wed, 19 Jun 2019 03:43:39 +0000 (11:43 +0800)]
arm64: dts: emmc: VIM3: Add HS400 busmode support

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agostorage: emmc: Add HS400 busmode support for G12B-RevB [1/1]
long yu [Thu, 21 Feb 2019 07:22:01 +0000 (15:22 +0800)]
storage: emmc: Add HS400 busmode support for G12B-RevB [1/1]

PD#SWPL-5040

Problem:
not support HS400 busmode

Solution:
add HS400 busmode support for G12B-RevB

Verify:
T962X-R311,TL1-T962X2_X301,G12B-W400

Change-Id: I11a1f47b9473fa341c7d754a51d6e270551758a7
Signed-off-by: long yu <long.yu@amlogic.com>
5 years agostorage: emmc: Add HS400 busmode support for TL1 [1/1]
Long Yu [Fri, 14 Dec 2018 09:13:36 +0000 (17:13 +0800)]
storage: emmc: Add HS400 busmode support for TL1 [1/1]

PD#SWPL-2311

Problem:
not support HS400 busmode

Solution:
add HS400 busmode support for TL1

Verify:
TL1-T962X2_X301

Change-Id: I95ac19e9c0c5b84c9225602cda6964aaaee4151e
Signed-off-by: Long Yu <long.yu@amlogic.com>
Signed-off-by: Luan Yuan <luan.yuan@amlogic.com>
5 years agoarm64: dts: VIM3: fixup USB 3.0
Nick Xie [Mon, 24 Jun 2019 06:35:41 +0000 (14:35 +0800)]
arm64: dts: VIM3: fixup USB 3.0

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoVIM3: add MCU control support
Nick Xie [Sat, 22 Jun 2019 08:51:07 +0000 (16:51 +0800)]
VIM3: add MCU control support

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: dts: VIM1/VIM2: add missing reset-cells property
Nick Xie [Wed, 19 Jun 2019 14:37:04 +0000 (22:37 +0800)]
arm64: dts: VIM1/VIM2: add missing reset-cells property

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: dts: VIMs: add dummy node 'chosen {}' for KEXEC
Nick Xie [Tue, 18 Jun 2019 10:22:00 +0000 (18:22 +0800)]
arm64: dts: VIMs: add dummy node 'chosen {}' for KEXEC

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: config: enable CONFIG_KEXEC
Nick Xie [Tue, 18 Jun 2019 10:18:42 +0000 (18:18 +0800)]
arm64: config: enable CONFIG_KEXEC

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: dts: VIM3: move to Amlogic A311D
Nick Xie [Wed, 12 Jun 2019 13:33:59 +0000 (21:33 +0800)]
arm64: dts: VIM3: move to Amlogic A311D

dts sync from 'g12b_a311d_w400_buildroot.dts'

backup S922X dts as 'kvim3_s922x_linux.dts'

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoarm64: dts: VIM3: disable fusb302
Nick Xie [Wed, 12 Jun 2019 12:39:24 +0000 (20:39 +0800)]
arm64: dts: VIM3: disable fusb302

Signed-off-by: Nick Xie <nick@khadas.com>
5 years agoLinux 4.9.181 v4.9.181
Greg Kroah-Hartman [Tue, 11 Jun 2019 10:22:50 +0000 (12:22 +0200)]
Linux 4.9.181

5 years agoethtool: check the return value of get_regs_len
Yunsheng Lin [Wed, 26 Dec 2018 11:51:46 +0000 (19:51 +0800)]
ethtool: check the return value of get_regs_len

commit f9fc54d313fab2834f44f516459cdc8ac91d797f upstream.

The return type for get_regs_len in struct ethtool_ops is int,
the hns3 driver may return error when failing to get the regs
len by sending cmd to firmware.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoipv4: Define __ipv4_neigh_lookup_noref when CONFIG_INET is disabled
David Ahern [Sun, 5 May 2019 18:16:20 +0000 (11:16 -0700)]
ipv4: Define __ipv4_neigh_lookup_noref when CONFIG_INET is disabled

commit 9b3040a6aafd7898ece7fc7efcbca71e42aa8069 upstream.

Define __ipv4_neigh_lookup_noref to return NULL when CONFIG_INET is disabled.

Fixes: 4b2a2bfeb3f0 ("neighbor: Call __ipv4_neigh_lookup_noref in neigh_xmit")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agofuse: Add FOPEN_STREAM to use stream_open()
Kirill Smelkov [Wed, 24 Apr 2019 07:13:57 +0000 (07:13 +0000)]
fuse: Add FOPEN_STREAM to use stream_open()

commit bbd84f33652f852ce5992d65db4d020aba21f882 upstream.

Starting from commit 9c225f2655e3 ("vfs: atomic f_pos accesses as per
POSIX") files opened even via nonseekable_open gate read and write via lock
and do not allow them to be run simultaneously. This can create read vs
write deadlock if a filesystem is trying to implement a socket-like file
which is intended to be simultaneously used for both read and write from
filesystem client.  See commit 10dce8af3422 ("fs: stream_open - opener for
stream-like files so that read and write can run simultaneously without
deadlock") for details and e.g. commit 581d21a2d02a ("xenbus: fix deadlock
on writes to /proc/xen/xenbus") for a similar deadlock example on
/proc/xen/xenbus.

To avoid such deadlock it was tempting to adjust fuse_finish_open to use
stream_open instead of nonseekable_open on just FOPEN_NONSEEKABLE flags,
but grepping through Debian codesearch shows users of FOPEN_NONSEEKABLE,
and in particular GVFS which actually uses offset in its read and write
handlers

https://codesearch.debian.net/search?q=-%3Enonseekable+%3D
https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1080
https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1247-1346
https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1399-1481

so if we would do such a change it will break a real user.

Add another flag (FOPEN_STREAM) for filesystem servers to indicate that the
opened handler is having stream-like semantics; does not use file position
and thus the kernel is free to issue simultaneous read and write request on
opened file handle.

This patch together with stream_open() should be added to stable kernels
starting from v3.14+. This will allow to patch OSSPD and other FUSE
filesystems that provide stream-like files to return FOPEN_STREAM |
FOPEN_NONSEEKABLE in open handler and this way avoid the deadlock on all
kernel versions. This should work because fuse_finish_open ignores unknown
open flags returned from a filesystem and so passing FOPEN_STREAM to a
kernel that is not aware of this flag cannot hurt. In turn the kernel that
is not aware of FOPEN_STREAM will be < v3.14 where just FOPEN_NONSEEKABLE
is sufficient to implement streams without read vs write deadlock.

Cc: stable@vger.kernel.org # v3.14+
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agofs: stream_open - opener for stream-like files so that read and write can run simulta...
Kirill Smelkov [Tue, 26 Mar 2019 22:20:43 +0000 (22:20 +0000)]
fs: stream_open - opener for stream-like files so that read and write can run simultaneously without deadlock

commit 10dce8af34226d90fa56746a934f8da5dcdba3df upstream.

Commit 9c225f2655e3 ("vfs: atomic f_pos accesses as per POSIX") added
locking for file.f_pos access and in particular made concurrent read and
write not possible - now both those functions take f_pos lock for the
whole run, and so if e.g. a read is blocked waiting for data, write will
deadlock waiting for that read to complete.

This caused regression for stream-like files where previously read and
write could run simultaneously, but after that patch could not do so
anymore. See e.g. commit 581d21a2d02a ("xenbus: fix deadlock on writes
to /proc/xen/xenbus") which fixes such regression for particular case of
/proc/xen/xenbus.

The patch that added f_pos lock in 2014 did so to guarantee POSIX thread
safety for read/write/lseek and added the locking to file descriptors of
all regular files. In 2014 that thread-safety problem was not new as it
was already discussed earlier in 2006.

However even though 2006'th version of Linus's patch was adding f_pos
locking "only for files that are marked seekable with FMODE_LSEEK (thus
avoiding the stream-like objects like pipes and sockets)", the 2014
version - the one that actually made it into the tree as 9c225f2655e3 -
is doing so irregardless of whether a file is seekable or not.

See

    https://lore.kernel.org/lkml/53022DB1.4070805@gmail.com/
    https://lwn.net/Articles/180387
    https://lwn.net/Articles/180396

for historic context.

The reason that it did so is, probably, that there are many files that
are marked non-seekable, but e.g. their read implementation actually
depends on knowing current position to correctly handle the read. Some
examples:

kernel/power/user.c snapshot_read
fs/debugfs/file.c u32_array_read
fs/fuse/control.c fuse_conn_waiting_read + ...
drivers/hwmon/asus_atk0110.c atk_debugfs_ggrp_read
arch/s390/hypfs/inode.c hypfs_read_iter
...

Despite that, many nonseekable_open users implement read and write with
pure stream semantics - they don't depend on passed ppos at all. And for
those cases where read could wait for something inside, it creates a
situation similar to xenbus - the write could be never made to go until
read is done, and read is waiting for some, potentially external, event,
for potentially unbounded time -> deadlock.

Besides xenbus, there are 14 such places in the kernel that I've found
with semantic patch (see below):

drivers/xen/evtchn.c:667:8-24: ERROR: evtchn_fops: .read() can deadlock .write()
drivers/isdn/capi/capi.c:963:8-24: ERROR: capi_fops: .read() can deadlock .write()
drivers/input/evdev.c:527:1-17: ERROR: evdev_fops: .read() can deadlock .write()
drivers/char/pcmcia/cm4000_cs.c:1685:7-23: ERROR: cm4000_fops: .read() can deadlock .write()
net/rfkill/core.c:1146:8-24: ERROR: rfkill_fops: .read() can deadlock .write()
drivers/s390/char/fs3270.c:488:1-17: ERROR: fs3270_fops: .read() can deadlock .write()
drivers/usb/misc/ldusb.c:310:1-17: ERROR: ld_usb_fops: .read() can deadlock .write()
drivers/hid/uhid.c:635:1-17: ERROR: uhid_fops: .read() can deadlock .write()
net/batman-adv/icmp_socket.c:80:1-17: ERROR: batadv_fops: .read() can deadlock .write()
drivers/media/rc/lirc_dev.c:198:1-17: ERROR: lirc_fops: .read() can deadlock .write()
drivers/leds/uleds.c:77:1-17: ERROR: uleds_fops: .read() can deadlock .write()
drivers/input/misc/uinput.c:400:1-17: ERROR: uinput_fops: .read() can deadlock .write()
drivers/infiniband/core/user_mad.c:985:7-23: ERROR: umad_fops: .read() can deadlock .write()
drivers/gnss/core.c:45:1-17: ERROR: gnss_fops: .read() can deadlock .write()

In addition to the cases above another regression caused by f_pos
locking is that now FUSE filesystems that implement open with
FOPEN_NONSEEKABLE flag, can no longer implement bidirectional
stream-like files - for the same reason as above e.g. read can deadlock
write locking on file.f_pos in the kernel.

FUSE's FOPEN_NONSEEKABLE was added in 2008 in a7c1b990f715 ("fuse:
implement nonseekable open") to support OSSPD. OSSPD implements /dev/dsp
in userspace with FOPEN_NONSEEKABLE flag, with corresponding read and
write routines not depending on current position at all, and with both
read and write being potentially blocking operations:

See

    https://github.com/libfuse/osspd
    https://lwn.net/Articles/308445

    https://github.com/libfuse/osspd/blob/14a9cff0/osspd.c#L1406
    https://github.com/libfuse/osspd/blob/14a9cff0/osspd.c#L1438-L1477
    https://github.com/libfuse/osspd/blob/14a9cff0/osspd.c#L1479-L1510

Corresponding libfuse example/test also describes FOPEN_NONSEEKABLE as
"somewhat pipe-like files ..." with read handler not using offset.
However that test implements only read without write and cannot exercise
the deadlock scenario:

    https://github.com/libfuse/libfuse/blob/fuse-3.4.2-3-ga1bff7d/example/poll.c#L124-L131
    https://github.com/libfuse/libfuse/blob/fuse-3.4.2-3-ga1bff7d/example/poll.c#L146-L163
    https://github.com/libfuse/libfuse/blob/fuse-3.4.2-3-ga1bff7d/example/poll.c#L209-L216

I've actually hit the read vs write deadlock for real while implementing
my FUSE filesystem where there is /head/watch file, for which open
creates separate bidirectional socket-like stream in between filesystem
and its user with both read and write being later performed
simultaneously. And there it is semantically not easy to split the
stream into two separate read-only and write-only channels:

    https://lab.nexedi.com/kirr/wendelin.core/blob/f13aa600/wcfs/wcfs.go#L88-169

Let's fix this regression. The plan is:

1. We can't change nonseekable_open to include &~FMODE_ATOMIC_POS -
   doing so would break many in-kernel nonseekable_open users which
   actually use ppos in read/write handlers.

2. Add stream_open() to kernel to open stream-like non-seekable file
   descriptors. Read and write on such file descriptors would never use
   nor change ppos. And with that property on stream-like files read and
   write will be running without taking f_pos lock - i.e. read and write
   could be running simultaneously.

3. With semantic patch search and convert to stream_open all in-kernel
   nonseekable_open users for which read and write actually do not
   depend on ppos and where there is no other methods in file_operations
   which assume @offset access.

4. Add FOPEN_STREAM to fs/fuse/ and open in-kernel file-descriptors via
   steam_open if that bit is present in filesystem open reply.

   It was tempting to change fs/fuse/ open handler to use stream_open
   instead of nonseekable_open on just FOPEN_NONSEEKABLE flags, but
   grepping through Debian codesearch shows users of FOPEN_NONSEEKABLE,
   and in particular GVFS which actually uses offset in its read and
   write handlers

https://codesearch.debian.net/search?q=-%3Enonseekable+%3D
https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1080
https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1247-1346
https://gitlab.gnome.org/GNOME/gvfs/blob/1.40.0-6-gcbc54396/client/gvfsfusedaemon.c#L1399-1481

   so if we would do such a change it will break a real user.

5. Add stream_open and FOPEN_STREAM handling to stable kernels starting
   from v3.14+ (the kernel where 9c225f2655 first appeared).

   This will allow to patch OSSPD and other FUSE filesystems that
   provide stream-like files to return FOPEN_STREAM | FOPEN_NONSEEKABLE
   in their open handler and this way avoid the deadlock on all kernel
   versions. This should work because fs/fuse/ ignores unknown open
   flags returned from a filesystem and so passing FOPEN_STREAM to a
   kernel that is not aware of this flag cannot hurt. In turn the kernel
   that is not aware of FOPEN_STREAM will be < v3.14 where just
   FOPEN_NONSEEKABLE is sufficient to implement streams without read vs
   write deadlock.

This patch adds stream_open, converts /proc/xen/xenbus to it and adds
semantic patch to automatically locate in-kernel places that are either
required to be converted due to read vs write deadlock, or that are just
safe to be converted because read and write do not use ppos and there
are no other funky methods in file_operations.

Regarding semantic patch I've verified each generated change manually -
that it is correct to convert - and each other nonseekable_open instance
left - that it is either not correct to convert there, or that it is not
converted due to current stream_open.cocci limitations.

The script also does not convert files that should be valid to convert,
but that currently have .llseek = noop_llseek or generic_file_llseek for
unknown reason despite file being opened with nonseekable_open (e.g.
drivers/input/mousedev.c)

Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Yongzhi Pan <panyongzhi@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Tejun Heo <tj@kernel.org>
Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Nikolaus Rath <Nikolaus@rath.org>
Cc: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoTTY: serial_core, add ->install
Jiri Slaby [Wed, 17 Apr 2019 08:58:53 +0000 (10:58 +0200)]
TTY: serial_core, add ->install

commit 4cdd17ba1dff20ffc99fdbd2e6f0201fc7fe67df upstream.

We need to compute the uart state only on the first open. This is
usually what is done in the ->install hook. serial_core used to do this
in ->open on every open. So move it to ->install.

As a side effect, it ensures the state is set properly in the window
after tty_init_dev is called, but before uart_open. This fixes a bunch
of races between tty_open and flush_to_ldisc we were dealing with
recently.

One of such bugs was attempted to fix in commit fedb5760648a (serial:
fix race between flush_to_ldisc and tty_open), but it only took care of
a couple of functions (uart_start and uart_unthrottle).  I was able to
reproduce the crash on a SLE system, but in uart_write_room which is
also called from flush_to_ldisc via process_echoes. I was *unable* to
reproduce the bug locally. It is due to having this patch in my queue
since 2012!

 general protection fault: 0000 [#1] SMP KASAN PTI
 CPU: 1 PID: 5 Comm: kworker/u4:0 Tainted: G             L 4.12.14-396-default #1 SLE15-SP1 (unreleased)
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c89-prebuilt.qemu.org 04/01/2014
 Workqueue: events_unbound flush_to_ldisc
 task: ffff8800427d8040 task.stack: ffff8800427f0000
 RIP: 0010:uart_write_room+0xc4/0x590
 RSP: 0018:ffff8800427f7088 EFLAGS: 00010202
 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
 RDX: 000000000000002f RSI: 00000000000000ee RDI: ffff88003888bd90
 RBP: ffffffffb9545850 R08: 0000000000000001 R09: 0000000000000400
 R10: ffff8800427d825c R11: 000000000000006e R12: 1ffff100084fee12
 R13: ffffc900004c5000 R14: ffff88003888bb28 R15: 0000000000000178
 FS:  0000000000000000(0000) GS:ffff880043300000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000561da0794148 CR3: 000000000ebf4000 CR4: 00000000000006e0
 Call Trace:
  tty_write_room+0x6d/0xc0
  __process_echoes+0x55/0x870
  n_tty_receive_buf_common+0x105e/0x26d0
  tty_ldisc_receive_buf+0xb7/0x1c0
  tty_port_default_receive_buf+0x107/0x180
  flush_to_ldisc+0x35d/0x5c0
...

0 in rbx means tty->driver_data is NULL in uart_write_room. 0x178 is
tried to be dereferenced (0x178 >> 3 is 0x2f in rdx) at
uart_write_room+0xc4. 0x178 is exactly (struct uart_state *)NULL->refcount
used in uart_port_lock from uart_write_room.

So revert the upstream commit here as my local patch should fix the
whole family.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Li RongQing <lirongqing@baidu.com>
Cc: Wang Li <wangli39@baidu.com>
Cc: Zhang Yu <zhangyu31@baidu.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agodrm/i915: Fix I915_EXEC_RING_MASK
Chris Wilson [Fri, 1 Mar 2019 14:03:47 +0000 (14:03 +0000)]
drm/i915: Fix I915_EXEC_RING_MASK

commit d90c06d57027203f73021bb7ddb30b800d65c636 upstream.

This was supposed to be a mask of all known rings, but it is being used
by execbuffer to filter out invalid rings, and so is instead mapping high
unused values onto valid rings. Instead of a mask of all known rings,
we need it to be the mask of all possible rings.

Fixes: 549f7365820a ("drm/i915: Enable SandyBridge blitter ring")
Fixes: de1add360522 ("drm/i915: Decouple execbuf uAPI from internal implementation")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v4.6+
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190301140404.26690-21-chris@chris-wilson.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agodrm/radeon: prefer lower reference dividers
Christian König [Mon, 6 May 2019 17:57:52 +0000 (19:57 +0200)]
drm/radeon: prefer lower reference dividers

commit 2e26ccb119bde03584be53406bbd22e711b0d6e6 upstream.

Instead of the closest reference divider prefer the lowest,
this fixes flickering issues on HP Compaq nx9420.

Bugs: https://bugs.freedesktop.org/show_bug.cgi?id=108514
Suggested-by: Paul Dufresne <dufresnep@gmail.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agodrm/gma500/cdv: Check vbt config bits when detecting lvds panels
Patrik Jakobsson [Tue, 16 Apr 2019 11:46:07 +0000 (13:46 +0200)]
drm/gma500/cdv: Check vbt config bits when detecting lvds panels

commit 7c420636860a719049fae9403e2c87804f53bdde upstream.

Some machines have an lvds child device in vbt even though a panel is
not attached. To make detection more reliable we now also check the lvds
config bits available in the vbt.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1665766
Cc: stable@vger.kernel.org
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190416114607.1072-1-patrik.r.jakobsson@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agogenwqe: Prevent an integer overflow in the ioctl
Dan Carpenter [Tue, 7 May 2019 08:36:34 +0000 (11:36 +0300)]
genwqe: Prevent an integer overflow in the ioctl

commit 110080cea0d0e4dfdb0b536e7f8a5633ead6a781 upstream.

There are a couple potential integer overflows here.

round_up(m->size + (m->addr & ~PAGE_MASK), PAGE_SIZE);

The first thing is that the "m->size + (...)" addition could overflow,
and the second is that round_up() overflows to zero if the result is
within PAGE_SIZE of the type max.

In this code, the "m->size" variable is an u64 but we're saving the
result in "map_size" which is an unsigned long and genwqe_user_vmap()
takes an unsigned long as well.  So I have used ULONG_MAX as the upper
bound.  From a practical perspective unsigned long is fine/better than
trying to change all the types to u64.

Fixes: eaf4722d4645 ("GenWQE Character device and DDCB queue")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoRevert "MIPS: perf: ath79: Fix perfcount IRQ assignment"
Greg Kroah-Hartman [Sun, 9 Jun 2019 10:02:32 +0000 (12:02 +0200)]
Revert "MIPS: perf: ath79: Fix perfcount IRQ assignment"

This reverts commit f9b1baac265600a61d36ebaf9ba657119303b5b5 which is
commit a1e8783db8e0d58891681bc1e6d9ada66eae8e20 upstream.

Petr writes:
Karl has reported to me today, that he's experiencing weird
reboot hang on his devices with 4.9.180 kernel and that he has
bisected it down to my backported patch.

I would like to kindly ask you for removal of this patch.  This
patch should be reverted from all stable kernels up to 5.1,
because perf counters were not broken on those kernels, and this
patch won't work on the ath79 legacy IRQ code anyway, it needs
new irqchip driver which was enabled on ath79 with commit
51fa4f8912c0 ("MIPS: ath79: drop legacy IRQ code").

Reported-by: Petr Štetiar <ynezz@true.cz>
Cc: Kevin 'ldir' Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Cc: John Crispin <john@phrozen.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Paul Burton <paul.burton@mips.com>
Cc: linux-mips@vger.kernel.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoMIPS: pistachio: Build uImage.gz by default
Paul Burton [Tue, 28 May 2019 17:21:26 +0000 (17:21 +0000)]
MIPS: pistachio: Build uImage.gz by default

commit e4f2d1af7163becb181419af9dece9206001e0a6 upstream.

The pistachio platform uses the U-Boot bootloader & generally boots a
kernel in the uImage format. As such it's useful to build one when
building the kernel, but to do so currently requires the user to
manually specify a uImage target on the make command line.

Make uImage.gz the pistachio platform's default build target, so that
the default is to build a kernel image that we can actually boot on a
board such as the MIPS Creator Ci40.

Marked for stable backport as far as v4.1 where pistachio support was
introduced. This is primarily useful for CI systems such as kernelci.org
which will benefit from us building a suitable image which can then be
booted as part of automated testing, extending our test coverage to the
affected stable branches.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Kevin Hilman <khilman@baylibre.com>
Tested-by: Kevin Hilman <khilman@baylibre.com>
URL: https://groups.io/g/kernelci/message/388
Cc: stable@vger.kernel.org # v4.1+
Cc: linux-mips@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agox86/power: Fix 'nosmt' vs hibernation triple fault during resume
Jiri Kosina [Wed, 29 May 2019 22:09:39 +0000 (00:09 +0200)]
x86/power: Fix 'nosmt' vs hibernation triple fault during resume

commit ec527c318036a65a083ef68d8ba95789d2212246 upstream.

As explained in

0cc3cd21657b ("cpu/hotplug: Boot HT siblings at least once")

we always, no matter what, have to bring up x86 HT siblings during boot at
least once in order to avoid first MCE bringing the system to its knees.

That means that whenever 'nosmt' is supplied on the kernel command-line,
all the HT siblings are as a result sitting in mwait or cpudile after
going through the online-offline cycle at least once.

This causes a serious issue though when a kernel, which saw 'nosmt' on its
commandline, is going to perform resume from hibernation: if the resume
from the hibernated image is successful, cr3 is flipped in order to point
to the address space of the kernel that is being resumed, which in turn
means that all the HT siblings are all of a sudden mwaiting on address
which is no longer valid.

That results in triple fault shortly after cr3 is switched, and machine
reboots.

Fix this by always waking up all the SMT siblings before initiating the
'restore from hibernation' process; this guarantees that all the HT
siblings will be properly carried over to the resumed kernel waiting in
resume_play_dead(), and acted upon accordingly afterwards, based on the
target kernel configuration.

Symmetricaly, the resumed kernel has to push the SMT siblings to mwait
again in case it has SMT disabled; this means it has to online all
the siblings when resuming (so that they come out of hlt) and offline
them again to let them reach mwait.

Cc: 4.19+ <stable@vger.kernel.org> # v4.19+
Debugged-by: Thomas Gleixner <tglx@linutronix.de>
Fixes: 0cc3cd21657b ("cpu/hotplug: Boot HT siblings at least once")
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agofuse: fallocate: fix return with locked inode
Miklos Szeredi [Mon, 27 May 2019 09:42:07 +0000 (11:42 +0200)]
fuse: fallocate: fix return with locked inode

commit 35d6fcbb7c3e296a52136347346a698a35af3fda upstream.

Do the proper cleanup in case the size check fails.

Tested with xfstests:generic/228

Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 0cbade024ba5 ("fuse: honor RLIMIT_FSIZE in fuse_file_fallocate")
Cc: Liu Bo <bo.liu@linux.alibaba.com>
Cc: <stable@vger.kernel.org> # v3.5
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoparisc: Use implicit space register selection for loading the coherence index of...
John David Anglin [Tue, 28 May 2019 00:15:14 +0000 (20:15 -0400)]
parisc: Use implicit space register selection for loading the coherence index of I/O pdirs

commit 63923d2c3800919774f5c651d503d1dd2adaddd5 upstream.

We only support I/O to kernel space. Using %sr1 to load the coherence
index may be racy unless interrupts are disabled. This patch changes the
code used to load the coherence index to use implicit space register
selection. This saves one instruction and eliminates the race.

Tested on rp3440, c8000 and c3750.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agorcu: locking and unlocking need to always be at least barriers
Linus Torvalds [Mon, 3 Jun 2019 20:26:20 +0000 (13:26 -0700)]
rcu: locking and unlocking need to always be at least barriers

commit 66be4e66a7f422128748e3c3ef6ee72b20a6197b upstream.

Herbert Xu pointed out that commit bb73c52bad36 ("rcu: Don't disable
preemption for Tiny and Tree RCU readers") was incorrect in making the
preempt_disable/enable() be conditional on CONFIG_PREEMPT_COUNT.

If CONFIG_PREEMPT_COUNT isn't enabled, the preemption enable/disable is
a no-op, but still is a compiler barrier.

And RCU locking still _needs_ that compiler barrier.

It is simply fundamentally not true that RCU locking would be a complete
no-op: we still need to guarantee (for example) that things that can
trap and cause preemption cannot migrate into the RCU locked region.

The way we do that is by making it a barrier.

See for example commit 386afc91144b ("spinlocks and preemption points
need to be at least compiler barriers") from back in 2013 that had
similar issues with spinlocks that become no-ops on UP: they must still
constrain the compiler from moving other operations into the critical
region.

Now, it is true that a lot of RCU operations already use READ_ONCE() and
WRITE_ONCE() (which in practice likely would never be re-ordered wrt
anything remotely interesting), but it is also true that that is not
globally the case, and that it's not even necessarily always possible
(ie bitfields etc).

Reported-by: Herbert Xu <herbert@gondor.apana.org.au>
Fixes: bb73c52bad36 ("rcu: Don't disable preemption for Tiny and Tree RCU readers")
Cc: stable@kernel.org
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoRevert "fib_rules: return 0 directly if an exactly same rule exists when NLM_F_EXCL...
Hangbin Liu [Wed, 5 Jun 2019 04:27:14 +0000 (12:27 +0800)]
Revert "fib_rules: return 0 directly if an exactly same rule exists when NLM_F_EXCL not supplied"

[ Upstream commit 4970b42d5c362bf873982db7d93245c5281e58f4 ]

This reverts commit e9919a24d3022f72bcadc407e73a6ef17093a849.

Nathan reported the new behaviour breaks Android, as Android just add
new rules and delete old ones.

If we return 0 without adding dup rules, Android will remove the new
added rules and causing system to soft-reboot.

Fixes: e9919a24d302 ("fib_rules: return 0 directly if an exactly same rule exists when NLM_F_EXCL not supplied")
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Reported-by: Yaro Slav <yaro330@gmail.com>
Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoRevert "fib_rules: fix error in backport of e9919a24d302 ("fib_rules: return 0...")"
Greg Kroah-Hartman [Sun, 9 Jun 2019 07:55:08 +0000 (09:55 +0200)]
Revert "fib_rules: fix error in backport of e9919a24d302 ("fib_rules: return 0...")"

This reverts commit d5c71a7c533e88a9fcc74fe1b5c25743868fa300 as the
patch that this "fixes" is about to be reverted...

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoipv6: use READ_ONCE() for inet->hdrincl as in ipv4
Olivier Matz [Thu, 6 Jun 2019 07:15:18 +0000 (09:15 +0200)]
ipv6: use READ_ONCE() for inet->hdrincl as in ipv4

[ Upstream commit 59e3e4b52663a9d97efbce7307f62e4bc5c9ce91 ]

As it was done in commit 8f659a03a0ba ("net: ipv4: fix for a race
condition in raw_sendmsg") and commit 20b50d79974e ("net: ipv4: emulate
READ_ONCE() on ->hdrincl bit-field in raw_sendmsg()") for ipv4, copy the
value of inet->hdrincl in a local variable, to avoid introducing a race
condition in the next commit.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agoipv6: fix EFAULT on sendto with icmpv6 and hdrincl
Olivier Matz [Thu, 6 Jun 2019 07:15:19 +0000 (09:15 +0200)]
ipv6: fix EFAULT on sendto with icmpv6 and hdrincl

[ Upstream commit b9aa52c4cb457e7416cc0c95f475e72ef4a61336 ]

The following code returns EFAULT (Bad address):

  s = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
  setsockopt(s, SOL_IPV6, IPV6_HDRINCL, 1);
  sendto(ipv6_icmp6_packet, addr);   /* returns -1, errno = EFAULT */

The IPv4 equivalent code works. A workaround is to use IPPROTO_RAW
instead of IPPROTO_ICMPV6.

The failure happens because 2 bytes are eaten from the msghdr by
rawv6_probe_proto_opt() starting from commit 19e3c66b52ca ("ipv6
equivalent of "ipv4: Avoid reading user iov twice after
raw_probe_proto_opt""), but at that time it was not a problem because
IPV6_HDRINCL was not yet introduced.

Only eat these 2 bytes if hdrincl == 0.

Fixes: 715f504b1189 ("ipv6: add IPV6_HDRINCL option for raw sockets")
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agopktgen: do not sleep with the thread lock held.
Paolo Abeni [Thu, 6 Jun 2019 13:45:03 +0000 (15:45 +0200)]
pktgen: do not sleep with the thread lock held.

[ Upstream commit 720f1de4021f09898b8c8443f3b3e995991b6e3a ]

Currently, the process issuing a "start" command on the pktgen procfs
interface, acquires the pktgen thread lock and never release it, until
all pktgen threads are completed. The above can blocks indefinitely any
other pktgen command and any (even unrelated) netdevice removal - as
the pktgen netdev notifier acquires the same lock.

The issue is demonstrated by the following script, reported by Matteo:

ip -b - <<'EOF'
link add type dummy
link add type veth
link set dummy0 up
EOF
modprobe pktgen
echo reset >/proc/net/pktgen/pgctrl
{
echo rem_device_all
echo add_device dummy0
} >/proc/net/pktgen/kpktgend_0
echo count 0 >/proc/net/pktgen/dummy0
echo start >/proc/net/pktgen/pgctrl &
sleep 1
rmmod veth

Fix the above releasing the thread lock around the sleep call.

Additionally we must prevent racing with forcefull rmmod - as the
thread lock no more protects from them. Instead, acquire a self-reference
before waiting for any thread. As a side effect, running

rmmod pktgen

while some thread is running now fails with "module in use" error,
before this patch such command hanged indefinitely.

Note: the issue predates the commit reported in the fixes tag, but
this fix can't be applied before the mentioned commit.

v1 -> v2:
 - no need to check for thread existence after flipping the lock,
   pktgen threads are freed only at net exit time
 -

Fixes: 6146e6a43b35 ("[PKTGEN]: Removes thread_{un,}lock() macros.")
Reported-and-tested-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agonet: rds: fix memory leak in rds_ib_flush_mr_pool
Zhu Yanjun [Thu, 6 Jun 2019 08:00:03 +0000 (04:00 -0400)]
net: rds: fix memory leak in rds_ib_flush_mr_pool

[ Upstream commit 85cb928787eab6a2f4ca9d2a798b6f3bed53ced1 ]

When the following tests last for several hours, the problem will occur.

Server:
    rds-stress -r 1.1.1.16 -D 1M
Client:
    rds-stress -r 1.1.1.14 -s 1.1.1.16 -D 1M -T 30

The following will occur.

"
Starting up....
tsks   tx/s   rx/s  tx+rx K/s    mbi K/s    mbo K/s tx us/c   rtt us cpu
%
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
  1      0      0       0.00       0.00       0.00    0.00 0.00 -1.00
"
>From vmcore, we can find that clean_list is NULL.

>From the source code, rds_mr_flushd calls rds_ib_mr_pool_flush_worker.
Then rds_ib_mr_pool_flush_worker calls
"
 rds_ib_flush_mr_pool(pool, 0, NULL);
"
Then in function
"
int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *pool,
                         int free_all, struct rds_ib_mr **ibmr_ret)
"
ibmr_ret is NULL.

In the source code,
"
...
list_to_llist_nodes(pool, &unmap_list, &clean_nodes, &clean_tail);
if (ibmr_ret)
        *ibmr_ret = llist_entry(clean_nodes, struct rds_ib_mr, llnode);

/* more than one entry in llist nodes */
if (clean_nodes->next)
        llist_add_batch(clean_nodes->next, clean_tail, &pool->clean_list);
...
"
When ibmr_ret is NULL, llist_entry is not executed. clean_nodes->next
instead of clean_nodes is added in clean_list.
So clean_nodes is discarded. It can not be used again.
The workqueue is executed periodically. So more and more clean_nodes are
discarded. Finally the clean_list is NULL.
Then this problem will occur.

Fixes: 1bc144b62524 ("net, rds, Replace xlist in net/rds/xlist.h with llist")
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agonet/mlx4_en: ethtool, Remove unsupported SFP EEPROM high pages query
Erez Alfasi [Mon, 20 May 2019 14:42:52 +0000 (17:42 +0300)]
net/mlx4_en: ethtool, Remove unsupported SFP EEPROM high pages query

[ Upstream commit 135dd9594f127c8a82d141c3c8430e9e2143216a ]

Querying EEPROM high pages data for SFP module is currently
not supported by our driver but is still tried, resulting in
invalid FW queries.

Set the EEPROM ethtool data length to 256 for SFP module to
limit the reading for page 0 only and prevent invalid FW queries.

Fixes: 7202da8b7f71 ("ethtool, net/mlx4_en: Cable info, get_module_info/eeprom ethtool support")
Signed-off-by: Erez Alfasi <ereza@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>