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

This is the 4.9.184 stable release

5 years agoMerge tag 'v4.9.183' into khadas-vims-4.9.y-update
Nick Xie [Thu, 25 Jul 2019 10:04:19 +0000 (18:04 +0800)]
Merge tag 'v4.9.183' into khadas-vims-4.9.y-update

This is the 4.9.183 stable release

5 years agoMerge tag 'v4.9.182' into khadas-vims-4.9.y-update
Nick Xie [Thu, 25 Jul 2019 10:04:16 +0000 (18:04 +0800)]
Merge tag 'v4.9.182' into khadas-vims-4.9.y-update

This is the 4.9.182 stable release

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 agoLinux 4.9.184 v4.9.184
Greg Kroah-Hartman [Thu, 27 Jun 2019 00:14:21 +0000 (08:14 +0800)]
Linux 4.9.184

5 years agotcp: refine memory limit test in tcp_fragment()
Eric Dumazet [Fri, 21 Jun 2019 13:09:55 +0000 (06:09 -0700)]
tcp: refine memory limit test in tcp_fragment()

commit b6653b3629e5b88202be3c9abc44713973f5c4b4 upstream.

tcp_fragment() might be called for skbs in the write queue.

Memory limits might have been exceeded because tcp_sendmsg() only
checks limits at full skb (64KB) boundaries.

Therefore, we need to make sure tcp_fragment() wont punish applications
that might have setup very low SO_SNDBUF values.

Fixes: f070ef2ac667 ("tcp: tcp_fragment() should apply sane memory limits")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Christoph Paasch <cpaasch@apple.com>
Tested-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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 agoLinux 4.9.183 v4.9.183
Greg Kroah-Hartman [Sat, 22 Jun 2019 06:17:25 +0000 (08:17 +0200)]
Linux 4.9.183

5 years agoAbort file_remove_privs() for non-reg. files
Alexander Lochmann [Fri, 14 Dec 2018 10:55:52 +0000 (11:55 +0100)]
Abort file_remove_privs() for non-reg. files

commit f69e749a49353d96af1a293f56b5b56de59c668a upstream.

file_remove_privs() might be called for non-regular files, e.g.
blkdev inode. There is no reason to do its job on things
like blkdev inodes, pipes, or cdevs. Hence, abort if
file does not refer to a regular inode.

AV: more to the point, for devices there might be any number of
inodes refering to given device.  Which one to strip the permissions
from, even if that made any sense in the first place?  All of them
will be observed with contents modified, after all.

Found by LockDoc (Alexander Lochmann, Horst Schirmeier and Olaf
Spinczyk)

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Alexander Lochmann <alexander.lochmann@tu-dortmund.de>
Signed-off-by: Horst Schirmeier <horst.schirmeier@tu-dortmund.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Zubin Mithra <zsm@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 years agomlxsw: spectrum: Prevent force of 56G
Amit Cohen [Wed, 29 May 2019 07:59:45 +0000 (10:59 +0300)]
mlxsw: spectrum: Prevent force of 56G

[ Upstream commit 275e928f19117d22f6d26dee94548baf4041b773 ]

Force of 56G is not supported by hardware in Ethernet devices. This
configuration fails with a bad parameter error from firmware.

Add check of this case. Instead of trying to set 56G with autoneg off,
return a meaningful error.

Fixes: 56ade8fe3fe1 ("mlxsw: spectrum: Add initial support for Spectrum ASIC")
Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoscsi: libsas: delete sas port if expander discover failed
Jason Yan [Tue, 14 May 2019 02:42:39 +0000 (10:42 +0800)]
scsi: libsas: delete sas port if expander discover failed

[ Upstream commit 3b0541791453fbe7f42867e310e0c9eb6295364d ]

The sas_port(phy->port) allocated in sas_ex_discover_expander() will not be
deleted when the expander failed to discover. This will cause resource leak
and a further issue of kernel BUG like below:

[159785.843156]  port-2:17:29: trying to add phy phy-2:17:29 fails: it's
already part of another port
[159785.852144] ------------[ cut here  ]------------
[159785.856833] kernel BUG at drivers/scsi/scsi_transport_sas.c:1086!
[159785.863000] Internal error: Oops - BUG: 0 [#1] SMP
[159785.867866] CPU: 39 PID: 16993 Comm: kworker/u96:2 Tainted: G
W  OE     4.19.25-vhulk1901.1.0.h111.aarch64 #1
[159785.878458] Hardware name: Huawei Technologies Co., Ltd.
Hi1620EVBCS/Hi1620EVBCS, BIOS Hi1620 CS B070 1P TA 03/21/2019
[159785.889231] Workqueue: 0000:74:02.0_disco_q sas_discover_domain
[159785.895224] pstate: 40c00009 (nZcv daif +PAN +UAO)
[159785.900094] pc : sas_port_add_phy+0x188/0x1b8
[159785.904524] lr : sas_port_add_phy+0x188/0x1b8
[159785.908952] sp : ffff0001120e3b80
[159785.912341] x29: ffff0001120e3b80 x28: 0000000000000000
[159785.917727] x27: ffff802ade8f5400 x26: ffff0000681b7560
[159785.923111] x25: ffff802adf11a800 x24: ffff0000680e8000
[159785.928496] x23: ffff802ade8f5728 x22: ffff802ade8f5708
[159785.933880] x21: ffff802adea2db40 x20: ffff802ade8f5400
[159785.939264] x19: ffff802adea2d800 x18: 0000000000000010
[159785.944649] x17: 00000000821bf734 x16: ffff00006714faa0
[159785.950033] x15: ffff0000e8ab4ecf x14: 7261702079646165
[159785.955417] x13: 726c612073277469 x12: ffff00006887b830
[159785.960802] x11: ffff00006773eaa0 x10: 7968702079687020
[159785.966186] x9 : 0000000000002453 x8 : 726f702072656874
[159785.971570] x7 : 6f6e6120666f2074 x6 : ffff802bcfb21290
[159785.976955] x5 : ffff802bcfb21290 x4 : 0000000000000000
[159785.982339] x3 : ffff802bcfb298c8 x2 : 337752b234c2ab00
[159785.987723] x1 : 337752b234c2ab00 x0 : 0000000000000000
[159785.993108] Process kworker/u96:2 (pid: 16993, stack limit =
0x0000000072dae094)
[159786.000576] Call trace:
[159786.003097]  sas_port_add_phy+0x188/0x1b8
[159786.007179]  sas_ex_get_linkrate.isra.5+0x134/0x140
[159786.012130]  sas_ex_discover_expander+0x128/0x408
[159786.016906]  sas_ex_discover_dev+0x218/0x4c8
[159786.021249]  sas_ex_discover_devices+0x9c/0x1a8
[159786.025852]  sas_discover_root_expander+0x134/0x160
[159786.030802]  sas_discover_domain+0x1b8/0x1e8
[159786.035148]  process_one_work+0x1b4/0x3f8
[159786.039230]  worker_thread+0x54/0x470
[159786.042967]  kthread+0x134/0x138
[159786.046269]  ret_from_fork+0x10/0x18
[159786.049918] Code: 91322300 f0004402 91178042 97fe4c9b (d4210000)
[159786.056083] Modules linked in: hns3_enet_ut(OE) hclge(OE) hnae3(OE)
hisi_sas_test_hw(OE) hisi_sas_test_main(OE) serdes(OE)
[159786.067202] ---[ end trace 03622b9e2d99e196  ]---
[159786.071893] Kernel panic - not syncing: Fatal exception
[159786.077190] SMP: stopping secondary CPUs
[159786.081192] Kernel Offset: disabled
[159786.084753] CPU features: 0x2,a2a00a38

Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
Reported-by: Jian Luo <luojian5@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoscsi: smartpqi: properly set both the DMA mask and the coherent DMA mask
Lianbo Jiang [Mon, 27 May 2019 00:59:34 +0000 (08:59 +0800)]
scsi: smartpqi: properly set both the DMA mask and the coherent DMA mask

[ Upstream commit 1d94f06e7f5df4064ef336b7b710f50143b64a53 ]

When SME is enabled, the smartpqi driver won't work on the HP DL385 G10
machine, which causes the failure of kernel boot because it fails to
allocate pqi error buffer. Please refer to the kernel log:
....
[    9.431749] usbcore: registered new interface driver uas
[    9.441524] Microsemi PQI Driver (v1.1.4-130)
[    9.442956] i40e 0000:04:00.0: fw 6.70.48768 api 1.7 nvm 10.2.5
[    9.447237] smartpqi 0000:23:00.0: Microsemi Smart Family Controller found
         Starting dracut initqueue hook...
[  OK  ] Started Show Plymouth Boot Scre[    9.471654] Broadcom NetXtreme-C/E driver bnxt_en v1.9.1
en.
[  OK  ] Started Forward Password Requests to Plymouth Directory Watch.
[[0;[    9.487108] smartpqi 0000:23:00.0: failed to allocate PQI error buffer
....
[  139.050544] dracut-initqueue[949]: Warning: dracut-initqueue timeout - starting timeout scripts
[  139.589779] dracut-initqueue[949]: Warning: dracut-initqueue timeout - starting timeout scripts

Basically, the fact that the coherent DMA mask value wasn't set caused the
driver to fall back to SWIOTLB when SME is active.

For correct operation, lets call the dma_set_mask_and_coherent() to
properly set the mask for both streaming and coherent, in order to inform
the kernel about the devices DMA addressing capabilities.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
Acked-by: Don Brace <don.brace@microsemi.com>
Tested-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoscsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route()
Varun Prakash [Wed, 22 May 2019 14:40:55 +0000 (20:10 +0530)]
scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route()

[ Upstream commit cc555759117e8349088e0c5d19f2f2a500bafdbd ]

ip_dev_find() can return NULL so add a check for NULL pointer.

Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agonet: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs
Yoshihiro Shimoda [Tue, 28 May 2019 04:10:46 +0000 (13:10 +0900)]
net: sh_eth: fix mdio access in sh_eth_close() for R-Car Gen2 and RZ/A1 SoCs

[ Upstream commit 315ca92dd863fecbffc0bb52ae0ac11e0398726a ]

The sh_eth_close() resets the MAC and then calls phy_stop()
so that mdio read access result is incorrect without any error
according to kernel trace like below:

ifconfig-216   [003] .n..   109.133124: mdio_access: ee700000.ethernet-ffffffff read  phy:0x01 reg:0x00 val:0xffff

According to the hardware manual, the RMII mode should be set to 1
before operation the Ethernet MAC. However, the previous code was not
set to 1 after the driver issued the soft_reset in sh_eth_dev_exit()
so that the mdio read access result seemed incorrect. To fix the issue,
this patch adds a condition and set the RMII mode register in
sh_eth_dev_exit() for R-Car Gen2 and RZ/A1 SoCs.

Note that when I have tried to move the sh_eth_dev_exit() calling
after phy_stop() on sh_eth_close(), but it gets worse (kernel panic
happened and it seems that a register is accessed while the clock is
off).

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoKVM: PPC: Book3S HV: Don't take kvm->lock around kvm_for_each_vcpu
Paul Mackerras [Thu, 23 May 2019 06:36:32 +0000 (16:36 +1000)]
KVM: PPC: Book3S HV: Don't take kvm->lock around kvm_for_each_vcpu

[ Upstream commit 5a3f49364c3ffa1107bd88f8292406e98c5d206c ]

Currently the HV KVM code takes the kvm->lock around calls to
kvm_for_each_vcpu() and kvm_get_vcpu_by_id() (which can call
kvm_for_each_vcpu() internally).  However, that leads to a lock
order inversion problem, because these are called in contexts where
the vcpu mutex is held, but the vcpu mutexes nest within kvm->lock
according to Documentation/virtual/kvm/locking.txt.  Hence there
is a possibility of deadlock.

To fix this, we simply don't take the kvm->lock mutex around these
calls.  This is safe because the implementations of kvm_for_each_vcpu()
and kvm_get_vcpu_by_id() have been designed to be able to be called
locklessly.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoKVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list
Paul Mackerras [Wed, 29 May 2019 01:54:00 +0000 (11:54 +1000)]
KVM: PPC: Book3S: Use new mutex to synchronize access to rtas token list

[ Upstream commit 1659e27d2bc1ef47b6d031abe01b467f18cb72d9 ]

Currently the Book 3S KVM code uses kvm->lock to synchronize access
to the kvm->arch.rtas_tokens list.  Because this list is scanned
inside kvmppc_rtas_hcall(), which is called with the vcpu mutex held,
taking kvm->lock cause a lock inversion problem, which could lead to
a deadlock.

To fix this, we add a new mutex, kvm->arch.rtas_token_lock, which nests
inside the vcpu mutexes, and use that instead of kvm->lock when
accessing the rtas token list.

This removes the lockdep_assert_held() in kvmppc_rtas_tokens_free().
At this point we don't hold the new mutex, but that is OK because
kvmppc_rtas_tokens_free() is only called when the whole VM is being
destroyed, and at that point nothing can be looking up a token in
the list.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoia64: fix build errors by exporting paddr_to_nid()
Randy Dunlap [Tue, 28 May 2019 16:14:30 +0000 (09:14 -0700)]
ia64: fix build errors by exporting paddr_to_nid()

[ Upstream commit 9a626c4a6326da4433a0d4d4a8a7d1571caf1ed3 ]

Fix build errors on ia64 when DISCONTIGMEM=y and NUMA=y by
exporting paddr_to_nid().

Fixes these build errors:

ERROR: "paddr_to_nid" [sound/core/snd-pcm.ko] undefined!
ERROR: "paddr_to_nid" [net/sunrpc/sunrpc.ko] undefined!
ERROR: "paddr_to_nid" [fs/cifs/cifs.ko] undefined!
ERROR: "paddr_to_nid" [drivers/video/fbdev/core/fb.ko] undefined!
ERROR: "paddr_to_nid" [drivers/usb/mon/usbmon.ko] undefined!
ERROR: "paddr_to_nid" [drivers/usb/core/usbcore.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/raid1.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/dm-mod.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/dm-crypt.ko] undefined!
ERROR: "paddr_to_nid" [drivers/md/dm-bufio.ko] undefined!
ERROR: "paddr_to_nid" [drivers/ide/ide-core.ko] undefined!
ERROR: "paddr_to_nid" [drivers/ide/ide-cd_mod.ko] undefined!
ERROR: "paddr_to_nid" [drivers/gpu/drm/drm.ko] undefined!
ERROR: "paddr_to_nid" [drivers/char/agp/agpgart.ko] undefined!
ERROR: "paddr_to_nid" [drivers/block/nbd.ko] undefined!
ERROR: "paddr_to_nid" [drivers/block/loop.ko] undefined!
ERROR: "paddr_to_nid" [drivers/block/brd.ko] undefined!
ERROR: "paddr_to_nid" [crypto/ccm.ko] undefined!

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoperf record: Fix s390 missing module symbol and warning for non-root users
Thomas Richter [Wed, 22 May 2019 14:46:01 +0000 (16:46 +0200)]
perf record: Fix s390 missing module symbol and warning for non-root users

[ Upstream commit 6738028dd57df064b969d8392c943ef3b3ae705d ]

Command 'perf record' and 'perf report' on a system without kernel
debuginfo packages uses /proc/kallsyms and /proc/modules to find
addresses for kernel and module symbols. On x86 this works for root and
non-root users.

On s390, when invoked as non-root user, many of the following warnings
are shown and module symbols are missing:

    proc/{kallsyms,modules} inconsistency while looking for
        "[sha1_s390]" module!

Command 'perf record' creates a list of module start addresses by
parsing the output of /proc/modules and creates a PERF_RECORD_MMAP
record for the kernel and each module. The following function call
sequence is executed:

  machine__create_kernel_maps
    machine__create_module
      modules__parse
        machine__create_module --> for each line in /proc/modules
          arch__fix_module_text_start

Function arch__fix_module_text_start() is s390 specific. It opens
file /sys/module/<name>/sections/.text to extract the module's .text
section start address. On s390 the module loader prepends a header
before the first section, whereas on x86 the module's text section
address is identical the the module's load address.

However module section files are root readable only. For non-root the
read operation fails and machine__create_module() returns an error.
Command perf record does not generate any PERF_RECORD_MMAP record
for loaded modules. Later command perf report complains about missing
module maps.

To fix this function arch__fix_module_text_start() always returns
success. For root users there is no change, for non-root users
the module's load address is used as module's text start address
(the prepended header then counts as part of the text section).

This enable non-root users to use module symbols and avoid the
warning when perf report is executed.

Output before:

  [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
  0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text

Output after:

  [tmricht@m83lp54 perf]$ ./perf report -D | fgrep MMAP
  0 0x168 [0x50]: PERF_RECORD_MMAP ... x [kernel.kallsyms]_text
  0 0x1b8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../autofs4.ko.xz
  0 0x250 [0xa8]: PERF_RECORD_MMAP ... x /lib/modules/.../sha_common.ko.xz
  0 0x2f8 [0x98]: PERF_RECORD_MMAP ... x /lib/modules/.../des_generic.ko.xz

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Link: http://lkml.kernel.org/r/20190522144601.50763-4-tmricht@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoperf data: Fix 'strncat may truncate' build failure with recent gcc
Shawn Landden [Sat, 18 May 2019 18:32:38 +0000 (15:32 -0300)]
perf data: Fix 'strncat may truncate' build failure with recent gcc

[ Upstream commit 97acec7df172cd1e450f81f5e293c0aa145a2797 ]

This strncat() is safe because the buffer was allocated with zalloc(),
however gcc doesn't know that. Since the string always has 4 non-null
bytes, just use memcpy() here.

    CC       /home/shawn/linux/tools/perf/util/data-convert-bt.o
  In file included from /usr/include/string.h:494,
                   from /home/shawn/linux/tools/lib/traceevent/event-parse.h:27,
                   from util/data-convert-bt.c:22:
  In function ‘strncat’,
      inlined from ‘string_set_value’ at util/data-convert-bt.c:274:4:
  /usr/include/powerpc64le-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation]
    136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Shawn Landden <shawn@git.icu>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
LPU-Reference: 20190518183238.10954-1-shawn@git.icu
Link: https://lkml.kernel.org/n/tip-289f1jice17ta7tr3tstm9jm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoconfigfs: Fix use-after-free when accessing sd->s_dentry
Sahitya Tummala [Thu, 3 Jan 2019 11:18:15 +0000 (16:48 +0530)]
configfs: Fix use-after-free when accessing sd->s_dentry

[ Upstream commit f6122ed2a4f9c9c1c073ddf6308d1b2ac10e0781 ]

In the vfs_statx() context, during path lookup, the dentry gets
added to sd->s_dentry via configfs_attach_attr(). In the end,
vfs_statx() kills the dentry by calling path_put(), which invokes
configfs_d_iput(). Ideally, this dentry must be removed from
sd->s_dentry but it doesn't if the sd->s_count >= 3. As a result,
sd->s_dentry is holding reference to a stale dentry pointer whose
memory is already freed up. This results in use-after-free issue,
when this stale sd->s_dentry is accessed later in
configfs_readdir() path.

This issue can be easily reproduced, by running the LTP test case -
sh fs_racer_file_list.sh /config
(https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/fs/racer/fs_racer_file_list.sh)

Fixes: 76ae281f6307 ('configfs: fix race between dentry put and lookup')
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoi2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr
Yingjoe Chen [Tue, 7 May 2019 14:20:32 +0000 (22:20 +0800)]
i2c: dev: fix potential memory leak in i2cdev_ioctl_rdwr

[ Upstream commit a0692f0eef91354b62c2b4c94954536536be5425 ]

If I2C_M_RECV_LEN check failed, msgs[i].buf allocated by memdup_user
will not be freed. Pump index up so it will be freed.

Fixes: 838bfa6049fb ("i2c-dev: Add support for I2C_M_RECV_LEN")
Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agonet: tulip: de4x5: Drop redundant MODULE_DEVICE_TABLE()
Kees Cook [Fri, 24 May 2019 20:20:19 +0000 (13:20 -0700)]
net: tulip: de4x5: Drop redundant MODULE_DEVICE_TABLE()

[ Upstream commit 3e66b7cc50ef921121babc91487e1fb98af1ba6e ]

Building with Clang reports the redundant use of MODULE_DEVICE_TABLE():

drivers/net/ethernet/dec/tulip/de4x5.c:2110:1: error: redefinition of '__mod_eisa__de4x5_eisa_ids_device_table'
MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids);
^
./include/linux/module.h:229:21: note: expanded from macro 'MODULE_DEVICE_TABLE'
extern typeof(name) __mod_##type##__##name##_device_table               \
                    ^
<scratch space>:90:1: note: expanded from here
__mod_eisa__de4x5_eisa_ids_device_table
^
drivers/net/ethernet/dec/tulip/de4x5.c:2100:1: note: previous definition is here
MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids);
^
./include/linux/module.h:229:21: note: expanded from macro 'MODULE_DEVICE_TABLE'
extern typeof(name) __mod_##type##__##name##_device_table               \
                    ^
<scratch space>:85:1: note: expanded from here
__mod_eisa__de4x5_eisa_ids_device_table
^

This drops the one further from the table definition to match the common
use of MODULE_DEVICE_TABLE().

Fixes: 07563c711fbc ("EISA bus MODALIAS attributes support")
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agogpio: fix gpio-adp5588 build errors
Randy Dunlap [Thu, 23 May 2019 22:00:41 +0000 (15:00 -0700)]
gpio: fix gpio-adp5588 build errors

[ Upstream commit e9646f0f5bb62b7d43f0968f39d536cfe7123b53 ]

The gpio-adp5588 driver uses interfaces that are provided by
GPIOLIB_IRQCHIP, so select that symbol in its Kconfig entry.

Fixes these build errors:

../drivers/gpio/gpio-adp5588.c: In function ‘adp5588_irq_handler’:
../drivers/gpio/gpio-adp5588.c:266:26: error: ‘struct gpio_chip’ has no member named ‘irq’
            dev->gpio_chip.irq.domain, gpio));
                          ^
../drivers/gpio/gpio-adp5588.c: In function ‘adp5588_irq_setup’:
../drivers/gpio/gpio-adp5588.c:298:2: error: implicit declaration of function ‘gpiochip_irqchip_add_nested’ [-Werror=implicit-function-declaration]
  ret = gpiochip_irqchip_add_nested(&dev->gpio_chip,
  ^
../drivers/gpio/gpio-adp5588.c:307:2: error: implicit declaration of function ‘gpiochip_set_nested_irqchip’ [-Werror=implicit-function-declaration]
  gpiochip_set_nested_irqchip(&dev->gpio_chip,
  ^

Fixes: 459773ae8dbb ("gpio: adp5588-gpio: support interrupt controller")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: linux-gpio@vger.kernel.org
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoperf/ring_buffer: Add ordering to rb->nest increment
Peter Zijlstra [Fri, 17 May 2019 11:52:32 +0000 (13:52 +0200)]
perf/ring_buffer: Add ordering to rb->nest increment

[ Upstream commit 3f9fbe9bd86c534eba2faf5d840fd44c6049f50e ]

Similar to how decrementing rb->next too early can cause data_head to
(temporarily) be observed to go backward, so too can this happen when
we increment too late.

This barrier() ensures the rb->head load happens after the increment,
both the one in the 'goto again' path, as the one from
perf_output_get_handle() -- albeit very unlikely to matter for the
latter.

Suggested-by: Yabin Cui <yabinc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: acme@kernel.org
Cc: mark.rutland@arm.com
Cc: namhyung@kernel.org
Fixes: ef60777c9abd ("perf: Optimize the perf_output() path by removing IRQ-disables")
Link: http://lkml.kernel.org/r/20190517115418.309516009@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoperf/ring_buffer: Fix exposing a temporarily decreased data_head
Yabin Cui [Fri, 17 May 2019 11:52:31 +0000 (13:52 +0200)]
perf/ring_buffer: Fix exposing a temporarily decreased data_head

[ Upstream commit 1b038c6e05ff70a1e66e3e571c2e6106bdb75f53 ]

In perf_output_put_handle(), an IRQ/NMI can happen in below location and
write records to the same ring buffer:

...
local_dec_and_test(&rb->nest)
...                          <-- an IRQ/NMI can happen here
rb->user_page->data_head = head;
...

In this case, a value A is written to data_head in the IRQ, then a value
B is written to data_head after the IRQ. And A > B. As a result,
data_head is temporarily decreased from A to B. And a reader may see
data_head < data_tail if it read the buffer frequently enough, which
creates unexpected behaviors.

This can be fixed by moving dec(&rb->nest) to after updating data_head,
which prevents the IRQ/NMI above from updating data_head.

[ Split up by peterz. ]

Signed-off-by: Yabin Cui <yabinc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: mark.rutland@arm.com
Fixes: ef60777c9abd ("perf: Optimize the perf_output() path by removing IRQ-disables")
Link: http://lkml.kernel.org/r/20190517115418.224478157@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agox86/CPU/AMD: Don't force the CPB cap when running under a hypervisor
Frank van der Linden [Wed, 22 May 2019 22:17:45 +0000 (22:17 +0000)]
x86/CPU/AMD: Don't force the CPB cap when running under a hypervisor

[ Upstream commit 2ac44ab608705948564791ce1d15d43ba81a1e38 ]

For F17h AMD CPUs, the CPB capability ('Core Performance Boost') is forcibly set,
because some versions of that chip incorrectly report that they do not have it.

However, a hypervisor may filter out the CPB capability, for good
reasons. For example, KVM currently does not emulate setting the CPB
bit in MSR_K7_HWCR, and unchecked MSR access errors will be thrown
when trying to set it as a guest:

unchecked MSR access error: WRMSR to 0xc0010015 (tried to write 0x0000000001000011) at rIP: 0xffffffff890638f4 (native_write_msr+0x4/0x20)

Call Trace:
boost_set_msr+0x50/0x80 [acpi_cpufreq]
cpuhp_invoke_callback+0x86/0x560
sort_range+0x20/0x20
cpuhp_thread_fun+0xb0/0x110
smpboot_thread_fn+0xef/0x160
kthread+0x113/0x130
kthread_create_worker_on_cpu+0x70/0x70
ret_from_fork+0x35/0x40

To avoid this issue, don't forcibly set the CPB capability for a CPU
when running under a hypervisor.

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
Acked-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: bp@alien8.de
Cc: jiaxun.yang@flygoat.com
Fixes: 0237199186e7 ("x86/CPU/AMD: Set the CPB bit unconditionally on F17h")
Link: http://lkml.kernel.org/r/20190522221745.GA15789@dev-dsk-fllinden-2c-c1893d73.us-west-2.amazon.com
[ Minor edits to the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agomISDN: make sure device name is NUL terminated
Dan Carpenter [Wed, 22 May 2019 08:45:13 +0000 (11:45 +0300)]
mISDN: make sure device name is NUL terminated

[ Upstream commit ccfb62f27beb295103e9392462b20a6ed807d0ea ]

The user can change the device_name with the IMSETDEVNAME ioctl, but we
need to ensure that the user's name is NUL terminated.  Otherwise it
could result in a buffer overflow when we copy the name back to the user
with IMGETDEVINFO ioctl.

I also changed two strcpy() calls which handle the name to strscpy().
Hopefully, there aren't any other ways to create a too long name, but
it's nice to do this as a kernel hardening measure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoselftests: netfilter: missing error check when setting up veth interface
Jeffrin Jose T [Wed, 15 May 2019 06:44:04 +0000 (12:14 +0530)]
selftests: netfilter: missing error check when setting up veth interface

[ Upstream commit 82ce6eb1dd13fd12e449b2ee2c2ec051e6f52c43 ]

A test for the basic NAT functionality uses ip command which needs veth
device. There is a condition where the kernel support for veth is not
compiled into the kernel and the test script breaks. This patch contains
code for reasonable error display and correct code exit.

Signed-off-by: Jeffrin Jose T <jeffrin@rajagiritech.edu.in>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoperf/x86/intel/ds: Fix EVENT vs. UEVENT PEBS constraints
Stephane Eranian [Tue, 21 May 2019 00:52:46 +0000 (17:52 -0700)]
perf/x86/intel/ds: Fix EVENT vs. UEVENT PEBS constraints

[ Upstream commit 23e3983a466cd540ffdd2bbc6e0c51e31934f941 ]

This patch fixes an bug revealed by the following commit:

  6b89d4c1ae85 ("perf/x86/intel: Fix INTEL_FLAGS_EVENT_CONSTRAINT* masking")

That patch modified INTEL_FLAGS_EVENT_CONSTRAINT() to only look at the event code
when matching a constraint. If code+umask were needed, then the
INTEL_FLAGS_UEVENT_CONSTRAINT() macro was needed instead.
This broke with some of the constraints for PEBS events.

Several of them, including the one used for cycles:p, cycles:pp, cycles:ppp
fell in that category and caused the event to be rejected in PEBS mode.
In other words, on some platforms a cmdline such as:

  $ perf top -e cycles:pp

would fail with -EINVAL.

This patch fixes this bug by properly using INTEL_FLAGS_UEVENT_CONSTRAINT()
when needed in the PEBS constraint tables.

Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: kan.liang@intel.com
Link: http://lkml.kernel.org/r/20190521005246.423-1-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5 years agoRevert "staging: vc04_services: prevent integer overflow in create_pagelist()"
Greg Kroah-Hartman [Wed, 19 Jun 2019 17:15:29 +0000 (19:15 +0200)]
Revert "staging: vc04_services: prevent integer overflow in create_pagelist()"

This reverts commit cf07331c8827c9e9e0b4274c9b60204c18592241 which was
commit ca641bae6da977d638458e78cd1487b6160a2718 upstream.

Martin writes:
This commit breaks the kernel build because the vchiq_pagelist_info
struct is not defined in v4.9.182.

It was only added in v4.10, in commit
4807f2c0e684e907c501cb96049809d7a957dbc2.

Reported-by: Martin Weinelt <martin@linuxlounge.net>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>