firefly-linux-kernel-4.4.55.git
7 years agoiommu/rockchip: Fix runtime status unsupported
Elaine Zhang [Fri, 21 Jul 2017 08:46:19 +0000 (16:46 +0800)]
iommu/rockchip: Fix runtime status unsupported

Change-Id: Ief14da568aa641470a3a22d011739f474b9ed1ad
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
7 years agoarm64: rockchip_linux_defconfig: add chinese display support
Binyuan Lan [Thu, 20 Jul 2017 15:29:04 +0000 (23:29 +0800)]
arm64: rockchip_linux_defconfig: add chinese display support

Change-Id: I31002a63a38fa46fb0f170222b0ddceeaf27427c
Signed-off-by: Binyuan Lan <lby@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3366: Add hdmi node
WeiYong Bi [Wed, 19 Jul 2017 06:56:22 +0000 (14:56 +0800)]
arm64: dts: rockchip: rk3366: Add hdmi node

Change-Id: I99b95a9fd3e70c70b6066729dd4213f8beb33e19
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoarm64: dts: rk3399-sapphire-excavator-linux: add camera node
zhoupeng [Thu, 20 Jul 2017 07:26:28 +0000 (15:26 +0800)]
arm64: dts: rk3399-sapphire-excavator-linux: add camera node

dts: support tc358749xbg for HDMI IN

Change-Id: I5a5874d08ea13c27cac7b3507a46bb1f2288e3f4
Signed-off-by: zhoupeng <benjo.zhou@rock-chips.com>
7 years agomedia: soc_camera: add tc358749xgb sensor driver
zhoupeng [Thu, 20 Jul 2017 07:49:59 +0000 (15:49 +0800)]
media: soc_camera: add tc358749xgb sensor driver

Change-Id: I66ccb856cb2689bf26a8a12069b29c7ec6dae6f0
Signed-off-by: zhoupeng <benjo.zhou@rock-chips.com>
7 years agoMALI: utgard: fix the too small "max_job_runtime" in platform information
chenzhen [Tue, 11 Jul 2017 07:01:20 +0000 (15:01 +0800)]
MALI: utgard: fix the too small "max_job_runtime" in platform information

The original setting of "max_job_runtime" is too small
that jobs are too easy to timeout and be killed.

Change-Id: I5316c2b594d94dd0b844ef9a297baa7b226c4665
Signed-off-by: chenzhen <chenzhen@rock-chips.com>
7 years agoARM: dts: rockchip: rk3368-sheep add vsel gpio for syr827
Jianqun Xu [Fri, 21 Jul 2017 06:22:12 +0000 (14:22 +0800)]
ARM: dts: rockchip: rk3368-sheep add vsel gpio for syr827

Add vsel gpio for syr827, which is PMIC_SLEEP in hardware pcb.

The driver will parse the gpio and use it to indicate the chip
work status, as the following codes:

static int fan53555_is_enabled ()
if defined vsel_gpio
gpiod_get_raw_value
else
regmap_read

Before the patch, the log shows:
CPU4: update cpu_capacity 1024
CPU4: Booted secondary processor [410fd033]
  cache: parent cpu4 should not be sleeping
rk3x-i2c ff650000.i2c: timeout, ipd: 0x10, state: 1

Since cpu4 is the base core for cluster1, which need to initialize
cpufreq during boot up, finally call fan53555_is_enabled. But the
i2c is suspended at that time, can't get interrupt until timeout.

Change-Id: I301e95be3b60d2faa456759d88c06cf64c2019ca
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
7 years agoARM: dts: rockchip: rk3368-p9: add vsel gpio for syr827
Jianqun Xu [Fri, 21 Jul 2017 06:36:13 +0000 (14:36 +0800)]
ARM: dts: rockchip: rk3368-p9: add vsel gpio for syr827

Change-Id: I847334e0588659e5950b01a4e40bf0a24f5646bf
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
7 years agodrm/rockchip: vop: don't force enable post scale
Mark Yao [Thu, 20 Jul 2017 10:57:40 +0000 (18:57 +0800)]
drm/rockchip: vop: don't force enable post scale

Vop would always report post buf empty error if enable
post scale config with non-scale factor

Change-Id: Ibc3f27c674195e6467471069488f14471927f709
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agodrm/rockchip: vop: add error irq handle
Mark Yao [Thu, 25 May 2017 01:40:34 +0000 (09:40 +0800)]
drm/rockchip: vop: add error irq handle

Change-Id: I84a3bc5c9798bbd4e0b11bc499f4df5ca1907cb7
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agodrm/rockchip: support backlight device
Mark Yao [Thu, 6 Jul 2017 08:02:16 +0000 (16:02 +0800)]
drm/rockchip: support backlight device

Change-Id: Ib793b0dec8fe62027ca8e3085089d2e431b59eb5
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agophy: rockchip-inno-usb2: delay suspending phy if plug out device
William Wu [Thu, 20 Jul 2017 07:02:02 +0000 (15:02 +0800)]
phy: rockchip-inno-usb2: delay suspending phy if plug out device

The otg_sm_work will suspend the usb2 phy immediately
if it detects disconnection from host. However, the usb2
controller(e.g. DWC2) may need to reinit registers and
reset usb core after usb disconnect, and it needs to
keep the usb2 phy stay in power on state to get utmi clk
for these usb controller operation. We don't have a good
synchronization mechanism to operate usb2 phy between
usb2 phy driver and usb2 controller driver, so we delay
4s to suspend phy if detect otg device disconnect from
host, this can make sure that usb2 controller completes
reinitialization before suspend usb2 phy.

Change-Id: I79288b8c7b141bb16e6d96d80cfee75f7558d2c0
Signed-off-by: William Wu <william.wu@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured
xubilv [Tue, 18 Jul 2017 03:46:48 +0000 (11:46 +0800)]
drm/rockchip: dw-mipi-dsi: don't enable PHY PLL until it's configured

Change-Id: Id28702ac62030b112dc57e4c3fc5b91cd1421a3f
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: use positive check for N{H, V}SYNC
xubilv [Tue, 18 Jul 2017 03:38:16 +0000 (11:38 +0800)]
drm/rockchip: dw-mipi-dsi: use positive check for N{H, V}SYNC

This matches other drivers.

Change-Id: I1e5773b926c274e99ea117a2a0fdc5ab096c49aa
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: fix escape clock rate
xubilv [Tue, 18 Jul 2017 03:24:39 +0000 (11:24 +0800)]
drm/rockchip: dw-mipi-dsi: fix escape clock rate

Use the same calculation as the vendor kernel to derive the escape clock
speed.

Change-Id: I7aff4dc7fa9598df164148eaf44304caad704f23
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: only request HS clock when required
xubilv [Tue, 18 Jul 2017 02:29:17 +0000 (10:29 +0800)]
drm/rockchip: dw-mipi-dsi: only request HS clock when required

Requesting the HS clock from the PHY before we initialize it causes an
invalid signal to be sent out since the input clock is not yet
configured.  The PHY databook suggests only asserting this signal when
performing HS transfers, so let's do that.

Change-Id: I7006f81d8c620dc84e84f99383c7b5414d6ac12d
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_get_hcomponent_lbcc function
xubilv [Mon, 17 Jul 2017 10:05:48 +0000 (18:05 +0800)]
drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_get_hcomponent_lbcc function

Use the common interface to calculate

Change-Id: I21836061d1442048efaba3b2930811b8a0aab0aa
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: support read lane-rate from dts
xubilv [Mon, 17 Jul 2017 09:54:43 +0000 (17:54 +0800)]
drm/rockchip: dw-mipi-dsi: support read lane-rate from dts

It is convenient for the client to manually adjust
the value of lane rate.

Change-Id: Ic6d8c4d235eacc8cb7540d172bd69c29c2b277dd
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: analyze the platform parameters in the probe function
xubilv [Mon, 17 Jul 2017 08:24:22 +0000 (16:24 +0800)]
drm/rockchip: dw-mipi-dsi: analyze the platform parameters in the probe function

The analysis of platform parameters Only need to do it once,
if this in bind function, when return -EPROBE_DEFER,
it will be executed more than once.

Change-Id: I508021f930d39e1b79e1421c4262b9e7ab501b6c
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_video_mode_config function
xubilv [Fri, 14 Jul 2017 09:40:28 +0000 (17:40 +0800)]
drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_video_mode_config function

Change-Id: Id11053734b1c35dc77028f2ac537bd39c096da7d
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: add mode_flags as a judgment condition
xubilv [Fri, 14 Jul 2017 08:59:13 +0000 (16:59 +0800)]
drm/rockchip: dw-mipi-dsi: add mode_flags as a judgment condition

This flag is used as a condition for the register configuration

Change-Id: I6741063b106ae00f4f1a690abde79d76bc529e95
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_set_mode function
xubilv [Fri, 14 Jul 2017 08:48:48 +0000 (16:48 +0800)]
drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_set_mode function

Change-Id: I4ba2a1519c1e5ac485a4d7416c0066ad8ce6527a
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_encoder_disable function
xubilv [Fri, 14 Jul 2017 08:27:15 +0000 (16:27 +0800)]
drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_encoder_disable function

Change-Id: I4c5ba54748bd1965a9f2cdea924efa6d449677a1
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_host_transfer function
xubilv [Fri, 14 Jul 2017 07:45:25 +0000 (15:45 +0800)]
drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_host_transfer function

Change-Id: I2a9bf2f21950f9fffc89d244308d6270663d5ef2
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: add delay for panel power on
xubilv [Thu, 13 Jul 2017 11:40:00 +0000 (19:40 +0800)]
drm/rockchip: dw-mipi-dsi: add delay for panel power on

Change-Id: Ife1a3c421dd192fc76b1ff6c84dbfe4afb1b0a54
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agoARM: dts: rk3288: add delay for panel power on
xubilv [Thu, 13 Jul 2017 11:27:36 +0000 (19:27 +0800)]
ARM: dts: rk3288: add delay for panel power on

Change-Id: I132ee50b9b3e0d8a3641135c94723d0a23bb5c40
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/panel: simple: move panel_simple_dsi_send_cmds from enable to prepare
xubilv [Thu, 13 Jul 2017 11:21:38 +0000 (19:21 +0800)]
drm/panel: simple: move panel_simple_dsi_send_cmds from enable to prepare

Change-Id: I9fdd1192523bc5bd99ca2fdc37fdf2f4b06cbb8a
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agodrm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_encoder_enable function
xubilv [Thu, 13 Jul 2017 10:44:49 +0000 (18:44 +0800)]
drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_encoder_enable function

Change-Id: I9d3f43f9d320cc33026bce2ce173a0baf3008ce0
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agoARM64: rockchip_defconfig: select CONFIG_TOUCHSCREEN_GSLX680_PAD
Jianqun Xu [Mon, 17 Jul 2017 08:36:07 +0000 (16:36 +0800)]
ARM64: rockchip_defconfig: select CONFIG_TOUCHSCREEN_GSLX680_PAD

Change-Id: I48bf260eedbabcd0ac8cdf827b4f5f629582e936
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3399 firefly android dts file
Jianqun Xu [Mon, 17 Jul 2017 02:46:32 +0000 (10:46 +0800)]
arm64: dts: rockchip: rk3399 firefly android dts file

Add dts file for firefly rk3399 board to run android os.
Support soc sub-system, vop, edp, rga, audio, wifi and
so on.

Change-Id: Ia921769b81d4a74784bb3e638b2cb01111c621c9
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
7 years agoarm: dts: rockchip: add names for vop register
Mark Yao [Tue, 27 Jun 2017 02:47:30 +0000 (10:47 +0800)]
arm: dts: rockchip: add names for vop register

Change-Id: I463cc2dc92f233b5b4b6f91b71cf78af92d4a2c1
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agodrm/rockchip: hdmi: Add support for rk3366
WeiYong Bi [Wed, 12 Jul 2017 06:20:54 +0000 (14:20 +0800)]
drm/rockchip: hdmi: Add support for rk3366

Change-Id: I086533ed5c94110f913ab88f4760d452beaf12d1
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoARM64: dts: rockchip: rename mipi to dsi for rk3368
WeiYong Bi [Thu, 13 Jul 2017 08:10:11 +0000 (16:10 +0800)]
ARM64: dts: rockchip: rename mipi to dsi for rk3368

Change-Id: Ied02b4d521ad3c49ce7b7a591a3d3f8544182e12
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoARM64: dts: rockchip: rename mipi to dsi for rk3366
WeiYong Bi [Fri, 14 Jul 2017 07:26:41 +0000 (15:26 +0800)]
ARM64: dts: rockchip: rename mipi to dsi for rk3366

Change-Id: I677f4554bdc0d6df9cfdffa86eebe0fa4e1759dd
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agodrm/rockchip: lvds: add loader protect
WeiYong Bi [Mon, 10 Jul 2017 08:30:02 +0000 (16:30 +0800)]
drm/rockchip: lvds: add loader protect

Change-Id: Ia0866cb9125a98ffb4ce99be26be9e0ccd665765
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoARM: dts: sync tinker board dts
Jacob Chen [Wed, 19 Jul 2017 08:15:35 +0000 (16:15 +0800)]
ARM: dts: sync tinker board dts

Sync our kernel with asus to reduce rebase work.

origin:
https://github.com/TinkerBoard/debian_kernel/blob/linux4.4-rk3288/arch/arm/boot/dts/rk3288-miniarm.dts
with dmc and camera nodes deleted

Change-Id: I7e699ca57465c03f41acb4ae47e5e70794118489
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3288: add dts file for lvds panel
Huang Jiachai [Fri, 14 Jul 2017 06:51:31 +0000 (14:51 +0800)]
arm64: dts: rockchip: rk3288: add dts file for lvds panel

Change-Id: I5991d0301935b5bdf51aead7719f84b6aa9264c5
Signed-off-by: Huang Jiachai <hjc@rock-chips.com>
7 years agophy: rockchip-inno-hdmi-phy: update 3328 phy pixclock in the recalc_rate
Zheng Yang [Thu, 20 Jul 2017 02:15:32 +0000 (10:15 +0800)]
phy: rockchip-inno-hdmi-phy: update 3328 phy pixclock in the recalc_rate

If default phy pre-pll output pixclock is same to the requested rate,
the set_rate function is not called, inno->pixclock is zero and
make phy work not ok. This patch update inno->pixclock both in the
recalc_rate and set_rate, make pixclock be the real value.

Change-Id: Ifd4e145c499c2e82f96918ca62235627bf326734
Signed-off-by: Zheng Yang <zhengyang@rock-chips.com>
7 years agodrm/panel: support drm_find_panel_by_connector
Mark Yao [Thu, 6 Jul 2017 07:43:10 +0000 (15:43 +0800)]
drm/panel: support drm_find_panel_by_connector

Change-Id: Iee970e013ff8b1558a060f334c700dea36c38d0f
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agodrm/rockchip: vop: add rk3399 cabc registers
Mark Yao [Fri, 7 Jul 2017 06:56:08 +0000 (14:56 +0800)]
drm/rockchip: vop: add rk3399 cabc registers

Change-Id: Ia7929e4c62ac031453fdb50ed4dcb20d11faee95
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agodrm/rockchip: add cabc support
Mark Yao [Wed, 28 Jun 2017 07:11:01 +0000 (15:11 +0800)]
drm/rockchip: add cabc support

CABC(Content Adaptive Backlight Control) is used to
increase the contrast of such LCD-screens the backlight
can be (globally) dimmed when the image to be displayed
is dark (i.e. not comprising high intensity image data)
while the image data is numerically corrected and adapted
to the reduced backlight intensity.

Change-Id: I0bd84375264675943f1b601f0cac8b843567087d
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3399: add 528MHz and 600MHz for dmc
Finley Xiao [Tue, 18 Jul 2017 03:21:31 +0000 (11:21 +0800)]
arm64: dts: rockchip: rk3399: add 528MHz and 600MHz for dmc

Only 200MHz, 300MHz, 400MHz, 528MHz, 600MHz, 666MHz, 732MHz and
800MHz are available at present.

Change-Id: I3a376b389fe6b06b3b32f0c695de2cbde05dfeea
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agodrm/rockchip: lvds: set correct step to power off lvds
Huang Jiachai [Fri, 14 Jul 2017 06:59:33 +0000 (14:59 +0800)]
drm/rockchip: lvds: set correct step to power off lvds

Change-Id: I6ce0fea548a0bc66c231ac184b45b74fd9acaf1f
Signed-off-by: Huang Jiachai <hjc@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3368: fix compatible string for lvds node
WeiYong Bi [Thu, 13 Jul 2017 01:46:02 +0000 (09:46 +0800)]
arm64: dts: rockchip: rk3368: fix compatible string for lvds node

Replace "rockchip,rk33xx-lvds" with "rockchip,rk3368-lvds"

Change-Id: I065de5d994f167129591025e4251944478fa43e7
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agodrm/rockchip: lvds: Add support for rk3366
WeiYong Bi [Wed, 12 Jul 2017 06:20:34 +0000 (14:20 +0800)]
drm/rockchip: lvds: Add support for rk3366

Change-Id: Iaf54c4667042b0b24a9083cb7ca931c1b0603804
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoarm64: rockchip_defconfig: remove CONFIG_RK31XX_LVDS
WeiYong Bi [Fri, 14 Jul 2017 07:49:42 +0000 (15:49 +0800)]
arm64: rockchip_defconfig: remove CONFIG_RK31XX_LVDS

Change-Id: Ie7716e38dd68876ab037cc3ed6072dba4118a798
Signed-off-by: WeiYong Bi <bivvy.bi@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3368-r88: Select xin32k from pwm1 out
Zhangbin Tong [Mon, 17 Jul 2017 08:00:22 +0000 (16:00 +0800)]
arm64: dts: rockchip: rk3368-r88: Select xin32k from pwm1 out

Change-Id: Iff675d47600cd7bf1d30564ca82697ce3b1fd9f4
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
7 years agoarm64: rockchip_defconfig: enable CONFIG_COMMON_CLK_PWM
Zhangbin Tong [Mon, 17 Jul 2017 07:58:46 +0000 (15:58 +0800)]
arm64: rockchip_defconfig: enable CONFIG_COMMON_CLK_PWM

Change-Id: Ie8c076e6d4c1a0a81c90f7dcd5653bef424b27e2
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
7 years agoUPSTREAM: clk: pwm: Use pwm_get_args() where appropriate
Stephen Boyd [Tue, 1 Mar 2016 19:00:18 +0000 (11:00 -0800)]
UPSTREAM: clk: pwm: Use pwm_get_args() where appropriate

The PWM framework has clarified the concept of reference PWM config (the
platform dependent config retrieved from the DT or the PWM lookup table)
and real PWM state.

Use pwm_get_args() when the PWM user wants to retrieve this reference
config and not the current state.

This is part of the rework allowing the PWM framework to support
hardware readout and expose real PWM state even when the PWM has just
been requested (before the user calls pwm_config/enable/disable()).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
(cherry picked from commit dd0b38b7ca0d8c8aadcf8a17d7c90d36ab8ab6e4)

Change-Id: I54c4b3853359b5fa41f8f949b504f82c6f069034
Signed-off-by: Zhangbin Tong <zebulun.tong@rock-chips.com>
7 years agodrm/rockchip: lvds: if port is null return -EINVAL
Huang Jiachai [Tue, 18 Jul 2017 03:59:59 +0000 (11:59 +0800)]
drm/rockchip: lvds: if port is null return -EINVAL

Change-Id: I9503b4f2d317a12d91ce136213d8d2e629b72823
Signed-off-by: Huang Jiachai <hjc@rock-chips.com>
7 years agoARM: dts: rk3288: rename mipi to dsi
xubilv [Thu, 13 Jul 2017 09:04:54 +0000 (17:04 +0800)]
ARM: dts: rk3288: rename mipi to dsi

Change-Id: I35d348068df3720608fc9cd22f97be0264a03f67
Signed-off-by: xubilv <xbl@rock-chips.com>
7 years agousb: dwc_otg_310: fix bad unlock balance issue
William Wu [Mon, 17 Jul 2017 12:10:46 +0000 (20:10 +0800)]
usb: dwc_otg_310: fix bad unlock balance issue

There is a bad unlock balance issue in the following case:
1. Use micro USB 2.0 interface;
2. Vbus 5v is always powered on;
3. Wait until DWC2 completes initialization, and then plug
   in OTG to Host cable;
4. Plug out the OTG cable, and then we will reproduce this
   issue, and we'll get the following log if we enable the
   kernel lock debugging.

=====================================
[ BUG: bad unlock balance detected! ]
4.4.71 #303 Not tainted
-------------------------------------
swapper/0/0 is trying to release lock (&(sl)->rlock) at:
[<c0795848>] dwc_otg_pcd_suspend_cb+0x20/0x48
but there are no more locks to release!

other info that might help us debug this:
1 lock held by swapper/0/0:

stack backtrace:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.71 #303
Hardware name: Rockchip (Device Tree)
[<c0110018>] (unwind_backtrace) from [<c010c04c>] (show_stack+0x10/0x14)
[<c010c04c>] (show_stack) from [<c0423e28>] (dump_stack+0x9c/0xd4)
[<c0423e28>] (dump_stack) from [<c021803c>] (print_unlock_imbalance_bug.part.7+0x8c/0xb8)
[<c021803c>] (print_unlock_imbalance_bug.part.7) from [<c018ce74>] (lock_release+0x284/0x54c)
[<c018ce74>] (lock_release) from [<c0c0e03c>] (_raw_spin_unlock+0x18/0x54)
[<c0c0e03c>] (_raw_spin_unlock) from [<c0795848>] (dwc_otg_pcd_suspend_cb+0x20/0x48)
[<c0795848>] (dwc_otg_pcd_suspend_cb) from [<c0792cc4>] (dwc_otg_handle_usb_suspend_intr+0x68/0x37c)
[<c0792cc4>] (dwc_otg_handle_usb_suspend_intr) from [<c079329c>] (dwc_otg_handle_common_intr+0x2c4/0xd58)
[<c079329c>] (dwc_otg_handle_common_intr) from [<c0786a18>] (dwc_otg_common_irq+0xc/0x18)
[<c0786a18>] (dwc_otg_common_irq) from [<c0199e48>] (handle_irq_event_percpu+0x188/0x4d4)
[<c0199e48>] (handle_irq_event_percpu) from [<c019a1cc>] (handle_irq_event+0x38/0x5c)
[<c019a1cc>] (handle_irq_event) from [<c019d654>] (handle_fasteoi_irq+0xa8/0x124)
[<c019d654>] (handle_fasteoi_irq) from [<c0199454>] (generic_handle_irq+0x18/0x28)
[<c0199454>] (generic_handle_irq) from [<c0199754>] (__handle_domain_irq+0x88/0xb0)
[<c0199754>] (__handle_domain_irq) from [<c01014b4>] (gic_handle_irq+0x4c/0x94)
[<c01014b4>] (gic_handle_irq) from [<c010cbb8>] (__irq_svc+0x58/0x98)

It's because that when plug in OTG to host cable, the
core_if->lock will be initialized to hcd->lock (check_id()->
id_status_change()->cil_hcd_start()->dwc_otg_hcd_reinit()),
so we should release core_if->lock before call cil_pcd_suspend()
rather than release the pcd->lock inside of callback function.

Change-Id: I1e32f37c701d1a8d741947b6bf385c1bbcb6da78
Signed-off-by: William Wu <william.wu@rock-chips.com>
7 years agoarm64: dts: rockchip: add vpu for rk3366 android7.1
Zorro Liu [Fri, 14 Jul 2017 03:22:33 +0000 (11:22 +0800)]
arm64: dts: rockchip: add vpu for rk3366 android7.1

Change-Id: I798a6518a2a74fe07ae2bb82abaca2da501ae07b
Signed-off-by: Zorro Liu <lyx@rock-chips.com>
7 years agoFROMLIST: drm: skip wait on vblank for set plane
Jonas Karlman [Tue, 2 May 2017 05:53:15 +0000 (07:53 +0200)]
FROMLIST: drm: skip wait on vblank for set plane

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
(am from https://github.com/LongChair/LibreELEC.tv/commit/debdec6)

Change-Id: I20d3d03638388fbb1e84215cba187f2e89089a62
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm/rockchip: Replace custom wait_for_vblanks with helper
Tomasz Figa [Wed, 14 Sep 2016 12:54:58 +0000 (21:54 +0900)]
UPSTREAM: drm/rockchip: Replace custom wait_for_vblanks with helper

Currently the driver uses a custom function to wait for flip to complete
after an atomic commit. It was needed before because of two problems:
 - there is no hardware vblank counter, so the original helper would
   have a race condition with the vblank interrupt,
 - the driver didn't support unreferencing cursor framebuffers
   asynchronously to the commit, which was what the helper expected.
Since both problems have been solved by previous patches, we can now
make the driver use the generic helper and remove custom waiting code.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
(cherry picked from commit 81c248f75a130c1ce46c67e8b05b37e8ffbbb33e)

Change-Id: Ida5a38b71f9e7812f415eb8889d906d2fe3b093e
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm/rockchip: Unreference framebuffers from flip work
Tomasz Figa [Wed, 14 Sep 2016 12:54:57 +0000 (21:54 +0900)]
UPSTREAM: drm/rockchip: Unreference framebuffers from flip work

Currently the driver waits for vblank and then unreferences old
framebuffers from atomic commit code path. This is however breaking the
legacy cursor API, which requires the updates to be fully asynchronous.
Instead of just adding a special case for cursor, we can have actually
smaller amount of code to unreference any changed framebuffer from a
flip work.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
(cherry picked from commit 47a7eb4597775ecdc29d2630d875a991f0449bf3)

Change-Id: Id36cdef1ea3962ac8c9a99549732d1810c57c4f9
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoUPSTREAM: drm/rockchip: Avoid race with vblank count increment
Tomasz Figa [Wed, 14 Sep 2016 12:54:56 +0000 (21:54 +0900)]
UPSTREAM: drm/rockchip: Avoid race with vblank count increment

Since VOP does not have a hardware vblank count register, the ongoing
commit might be racing with a requested vblank interrupt, which would
increment the software vblank counter before the changes being committed
actually happen.

To avoid this, we can extend .atomic_flush(), so after it sets cfg_done
bit, it polls the vblank interrupt bit until it's inactive to make sure
that any old vblank interrupt gets to the handler and then uses
synchronize_irq(vop->irq) to make sure the handler finishes running.

The polling case should happen very rarely, but even if, the total wait
time should be relatively low and in practice almost equal to the vop
hardirq handler running time.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
(cherry picked from commit 7caecdbec1128a934ee628f399110dff8a50c9a1)

Change-Id: Ic5f6231300214485ea569a2296c990aa123f6ff7
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoARM: dts: rockchip: add node for ov8858 on rk3288 evb
Jacob Chen [Wed, 12 Jul 2017 03:33:36 +0000 (11:33 +0800)]
ARM: dts: rockchip: add node for ov8858 on rk3288 evb

Disabled by default to avoid error messages.

Change-Id: I4fc05c0a782d6b1035b9e4bc7b31cc462d65166a
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoARM: dts: rockchip: use iommu for rk3288 v4l2 isp
Jacob Chen [Tue, 11 Jul 2017 05:26:40 +0000 (13:26 +0800)]
ARM: dts: rockchip: use iommu for rk3288 v4l2 isp

we have videobuf2 cip isp support now

Change-Id: I7f6da305f2a4a658a4097e06361c694ca6ba9a18
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agomfd: rk808: add rk816 support
shengfei Xu [Fri, 7 Jul 2017 09:18:10 +0000 (17:18 +0800)]
mfd: rk808: add rk816 support

include sub modules: regulator, rtc, gpio, pwrkey

Change-Id: I59cc4b943403f1e0b1210a314cfcbf61fc193bdf
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
7 years agoARM: config: enable MIPI CSI config for rockchip linux
Jacob Chen [Mon, 17 Jul 2017 00:35:33 +0000 (08:35 +0800)]
ARM: config: enable MIPI CSI config for rockchip linux

Change-Id: I32d3b569ffeb44132b2e28efdb0f2759f9f8498c
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
7 years agoarm64: dts: rockchip: fix lcd pinctrl define error for rk3368
Huang Jiachai [Fri, 14 Jul 2017 07:17:20 +0000 (15:17 +0800)]
arm64: dts: rockchip: fix lcd pinctrl define error for rk3368

Change-Id: I843049573cda97cc226730e34f043bd54021951e
Signed-off-by: Huang Jiachai <hjc@rock-chips.com>
7 years agoarm64: dts: rockchip: rk3366: add leakage nvmem-cells for cpu
Finley Xiao [Fri, 14 Jul 2017 09:39:20 +0000 (17:39 +0800)]
arm64: dts: rockchip: rk3366: add leakage nvmem-cells for cpu

Change-Id: I5e546ecbf5e1d8cc0a36d8ebd439663e1658f23b
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
7 years agoarm64: dts: rockchip: Remove the rk3366-tb build
David Wu [Fri, 14 Jul 2017 09:43:42 +0000 (17:43 +0800)]
arm64: dts: rockchip: Remove the rk3366-tb build

Change-Id: I8260d583da480f49834647ad114f3d1346ef1bbd
Signed-off-by: David Wu <david.wu@rock-chips.com>
7 years agodrm/atomic: export drm_atomic_replace_property_blob_from_id
Mark Yao [Wed, 28 Jun 2017 07:00:51 +0000 (15:00 +0800)]
drm/atomic: export drm_atomic_replace_property_blob_from_id

Change-Id: Iebca91e396f6770b0b2ce588093119ea321f3fb5
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
7 years agoMerge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android
Alex Shi [Tue, 18 Jul 2017 06:31:54 +0000 (14:31 +0800)]
Merge branch 'linux-linaro-lsk-v4.4' into linux-linaro-lsk-v4.4-android

7 years ago Merge tag 'v4.4.77' into linux-linaro-lsk-v4.4
Alex Shi [Tue, 18 Jul 2017 04:05:46 +0000 (12:05 +0800)]
 Merge tag 'v4.4.77' into linux-linaro-lsk-v4.4

 This is the 4.4.77 stable release

7 years agoMerge branch 'v4.4/topic/optee-lsk-mainline' into linux-linaro-lsk-v4.4
Alex Shi [Mon, 17 Jul 2017 14:17:03 +0000 (22:17 +0800)]
Merge branch 'v4.4/topic/optee-lsk-mainline' into linux-linaro-lsk-v4.4

7 years agodt/vendor-prefixes: remove redundant vendor
Alex Shi [Mon, 17 Jul 2017 14:10:16 +0000 (22:10 +0800)]
dt/vendor-prefixes: remove redundant vendor

78668d8100b8b0756f6e7b72d2b90b7e6192db73 dt/bindings: add bindings for optee
introduce a redundant vendor
+licheepi       Lichee Pi
Need to remove it.

Reported-by: Victor Chong <victor.chong@linaro.org>
Signed-off-by: Alex Shi <alex.shi@linaro.org>
7 years agoLinux 4.4.77
Greg Kroah-Hartman [Sat, 15 Jul 2017 09:58:03 +0000 (11:58 +0200)]
Linux 4.4.77

7 years agosaa7134: fix warm Medion 7134 EEPROM read
Maciej S. Szmigiero [Sat, 2 Jul 2016 23:27:46 +0000 (20:27 -0300)]
saa7134: fix warm Medion 7134 EEPROM read

commit 5a91206ff0d0548939f3e85a65fb76b400fb0e89 upstream.

When saa7134 module driving a Medion 7134 card is reloaded reads of this
card EEPROM (required for automatic detection of tuner model) will be
corrupted due to I2C gate in DVB-T demod being left closed.
This sometimes also happens on first saa7134 module load after a warm
reboot.

Fix this by opening this I2C gate before doing EEPROM read during i2c
initialization.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agox86/mm/pat: Don't report PAT on CPUs that don't support it
Mikulas Patocka [Tue, 4 Jul 2017 23:04:23 +0000 (19:04 -0400)]
x86/mm/pat: Don't report PAT on CPUs that don't support it

commit 99c13b8c8896d7bcb92753bf0c63a8de4326e78d upstream.

The pat_enabled() logic is broken on CPUs which do not support PAT and
where the initialization code fails to call pat_init(). Due to that the
enabled flag stays true and pat_enabled() returns true wrongfully.

As a consequence the mappings, e.g. for Xorg, are set up with the wrong
caching mode and the required MTRR setups are omitted.

To cure this the following changes are required:

  1) Make pat_enabled() return true only if PAT initialization was
     invoked and successful.

  2) Invoke init_cache_modes() unconditionally in setup_arch() and
     remove the extra callsites in pat_disable() and the pat disabled
     code path in pat_init().

Also rename __pat_enabled to pat_disabled to reflect the real purpose of
this variable.

Fixes: 9cd25aac1f44 ("x86/mm/pat: Emulate PAT when it is disabled")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bernhard Held <berny156@gmx.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: "Luis R. Rodriguez" <mcgrof@suse.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1707041749300.3456@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoext4: check return value of kstrtoull correctly in reserved_clusters_store
Chao Yu [Fri, 23 Jun 2017 05:08:22 +0000 (01:08 -0400)]
ext4: check return value of kstrtoull correctly in reserved_clusters_store

commit 1ea1516fbbab2b30bf98c534ecaacba579a35208 upstream.

kstrtoull returns 0 on success, however, in reserved_clusters_store we
will return -EINVAL if kstrtoull returns 0, it makes us fail to update
reserved_clusters value through sysfs.

Fixes: 76d33bca5581b1dd5c3157fa168db849a784ada4
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Miao Xie <miaoxie@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: comedi: fix clean-up of comedi_class in comedi_init()
Ian Abbott [Fri, 16 Jun 2017 18:35:34 +0000 (19:35 +0100)]
staging: comedi: fix clean-up of comedi_class in comedi_init()

commit a9332e9ad09c2644c99058fcf6ae2f355e93ce74 upstream.

There is a clean-up bug in the core comedi module initialization
functions, `comedi_init()`.  If the `comedi_num_legacy_minors` module
parameter is non-zero (and valid), it creates that many "legacy" devices
and registers them in SysFS.  A failure causes the function to clean up
and return an error.  Unfortunately, it fails to destroy the "comedi"
class that was created earlier.  Fix it by adding a call to
`class_destroy(comedi_class)` at the appropriate place in the clean-up
sequence.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agostaging: vt6556: vnt_start Fix missing call to vnt_key_init_table.
Malcolm Priestley [Sat, 29 Apr 2017 12:03:44 +0000 (13:03 +0100)]
staging: vt6556: vnt_start Fix missing call to vnt_key_init_table.

commit dc32190f2cd41c7dba25363ea7d618d4f5172b4e upstream.

The key table is not intialized correctly without this call.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agotcp: fix tcp_mark_head_lost to check skb len before fragmenting
Neal Cardwell [Mon, 25 Jan 2016 22:01:53 +0000 (14:01 -0800)]
tcp: fix tcp_mark_head_lost to check skb len before fragmenting

commit d88270eef4b56bd7973841dd1fed387ccfa83709 upstream.

This commit fixes a corner case in tcp_mark_head_lost() which was
causing the WARN_ON(len > skb->len) in tcp_fragment() to fire.

tcp_mark_head_lost() was assuming that if a packet has
tcp_skb_pcount(skb) of N, then it's safe to fragment off a prefix of
M*mss bytes, for any M < N. But with the tricky way TCP pcounts are
maintained, this is not always true.

For example, suppose the sender sends 4 1-byte packets and have the
last 3 packet sacked. It will merge the last 3 packets in the write
queue into an skb with pcount = 3 and len = 3 bytes. If another
recovery happens after a sack reneging event, tcp_mark_head_lost()
may attempt to split the skb assuming it has more than 2*MSS bytes.

This sounds very counterintuitive, but as the commit description for
the related commit c0638c247f55 ("tcp: don't fragment SACKed skbs in
tcp_mark_head_lost()") notes, this is because tcp_shifted_skb()
coalesces adjacent regions of SACKed skbs, and when doing this it
preserves the sum of their packet counts in order to reflect the
real-world dynamics on the wire. The c0638c247f55 commit tried to
avoid problems by not fragmenting SACKed skbs, since SACKed skbs are
where the non-proportionality between pcount and skb->len/mss is known
to be possible. However, that commit did not handle the case where
during a reneging event one of these weird SACKed skbs becomes an
un-SACKed skb, which tcp_mark_head_lost() can then try to fragment.

The fix is to simply mark the entire skb lost when this happens.
This makes the recovery slightly more aggressive in such corner
cases before we detect reordering. But once we detect reordering
this code path is by-passed because FACK is disabled.

Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Vinson Lee <vlee@freedesktop.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomd: fix super_offset endianness in super_1_rdev_size_change
Jason Yan [Fri, 10 Mar 2017 03:27:23 +0000 (11:27 +0800)]
md: fix super_offset endianness in super_1_rdev_size_change

commit 3fb632e40d7667d8bedfabc28850ac06d5493f54 upstream.

The sb->super_offset should be big-endian, but the rdev->sb_start is in
host byte order, so fix this by adding cpu_to_le64.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomd: fix incorrect use of lexx_to_cpu in does_sb_need_changing
Jason Yan [Fri, 10 Mar 2017 03:49:12 +0000 (11:49 +0800)]
md: fix incorrect use of lexx_to_cpu in does_sb_need_changing

commit 1345921393ba23b60d3fcf15933e699232ad25ae upstream.

The sb->layout is of type __le32, so we shoud use le32_to_cpu.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf tools: Use readdir() instead of deprecated readdir_r() again
Arnaldo Carvalho de Melo [Fri, 8 Apr 2016 14:53:02 +0000 (11:53 -0300)]
perf tools: Use readdir() instead of deprecated readdir_r() again

commit 22a9f41b555673e7499b97acf3ffb07bf0af31ad upstream.

The readdir() function is thread safe as long as just one thread uses a
DIR, which is the case when parsing tracepoint event definitions, to
avoid breaking the build with glibc-2.23.90 (upcoming 2.24), use it
instead of readdir_r().

See: http://man7.org/linux/man-pages/man3/readdir.3.html

"However, in modern implementations (including the glibc implementation),
concurrent calls to readdir() that specify different directory streams
are thread-safe.  In cases where multiple threads must read from the
same directory stream, using readdir() with external synchronization is
still preferable to the use of the deprecated readdir_r(3) function."

Noticed while building on a Fedora Rawhide docker container.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-wddn49r6bz6wq4ee3dxbl7lo@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf tests: Remove wrong semicolon in while loop in CQM test
Markus Trippelsdorf [Mon, 14 Dec 2015 15:43:35 +0000 (16:43 +0100)]
perf tests: Remove wrong semicolon in while loop in CQM test

commit cf89813a5b514bff9b3b5e7eaf2090f22fba62e0 upstream.

The while loop was spinning. Fix by removing a semicolon.

The issue was pointed out by gcc-6's -Wmisleading-indentation.

Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: 035827e9f2bd ("perf tests: Add Intel CQM test")
Link: http://lkml.kernel.org/r/20151214154335.GA1409@x4
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf trace: Do not process PERF_RECORD_LOST twice
Arnaldo Carvalho de Melo [Wed, 30 Mar 2016 19:51:17 +0000 (16:51 -0300)]
perf trace: Do not process PERF_RECORD_LOST twice

commit 3ed5ca2efff70e9f589087c2013789572901112d upstream.

We catch this record to provide a visual indication that events are
getting lost, then call the default method to allow extra logging shared
with the other tools to take place.

This extra logging was done twice because we were continuing to the
"default" clause where machine__process_event() will end up calling
machine__process_lost_event() again, fix it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-wus2zlhw3qo24ye84ewu4aqw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf dwarf: Guard !x86_64 definitions under #ifdef else clause
Arnaldo Carvalho de Melo [Fri, 8 Apr 2016 15:04:29 +0000 (12:04 -0300)]
perf dwarf: Guard !x86_64 definitions under #ifdef else clause

commit 62aa0e177d278462145a29c30d3c8501ae57e200 upstream.

To fix the build on Fedora Rawhide (gcc 6.0.0 20160311 (Red Hat 6.0.0-0.17):

    CC       /tmp/build/perf/arch/x86/util/dwarf-regs.o
  arch/x86/util/dwarf-regs.c:66:36: error: 'x86_32_regoffset_table' defined but not used [-Werror=unused-const-variable=]
   static const struct pt_regs_offset x86_32_regoffset_table[] = {
                                      ^~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-fghuksc1u8ln82bof4lwcj0o@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf pmu: Fix misleadingly indented assignment (whitespace)
Markus Trippelsdorf [Mon, 14 Dec 2015 15:44:40 +0000 (16:44 +0100)]
perf pmu: Fix misleadingly indented assignment (whitespace)

commit d85ce830eef6c10d1e9617172dea4681f02b8424 upstream.

One line in perf_pmu__parse_unit() is indented wrongly, leading to a
warning (=> error) from gcc 6:

  util/pmu.c:156:3: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]

    sret = read(fd, alias->unit, UNIT_MAX_LEN);
    ^~~~

  util/pmu.c:153:2: note: ...this 'if' clause, but it is not
    if (fd == -1)
    ^~

Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: 410136f5dd96 ("tools/perf/stat: Add event unit and scale support")
Link: http://lkml.kernel.org/r/20151214154440.GC1409@x4
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf annotate browser: Fix behaviour of Shift-Tab with nothing focussed
Markus Trippelsdorf [Mon, 14 Dec 2015 15:44:03 +0000 (16:44 +0100)]
perf annotate browser: Fix behaviour of Shift-Tab with nothing focussed

commit d4913cbd05bab685e49c8174896e563b2487d054 upstream.

The issue was pointed out by gcc-6's -Wmisleading-indentation.

Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: c97cf42219b7 ("perf top: Live TUI Annotation")
Link: http://lkml.kernel.org/r/20151214154403.GB1409@x4
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf tools: Remove duplicate const qualifier
Eric Engestrom [Mon, 25 Apr 2016 09:47:54 +0000 (10:47 +0100)]
perf tools: Remove duplicate const qualifier

commit 3b556bced46aa6b1873da7faa18eff235e896adc upstream.

Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1461577678-29517-1-git-send-email-eric.engestrom@imgtec.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf script: Use readdir() instead of deprecated readdir_r()
Arnaldo Carvalho de Melo [Fri, 8 Apr 2016 14:25:59 +0000 (11:25 -0300)]
perf script: Use readdir() instead of deprecated readdir_r()

commit a5e8e825bd1704c488bf6a46936aaf3b9f203d6a upstream.

The readdir() function is thread safe as long as just one thread uses a
DIR, which is the case in 'perf script', so, to avoid breaking the build
with glibc-2.23.90 (upcoming 2.24), use it instead of readdir_r().

See: http://man7.org/linux/man-pages/man3/readdir.3.html

"However, in modern implementations (including the glibc implementation),
concurrent calls to readdir() that specify different directory streams
are thread-safe.  In cases where multiple threads must read from the
same directory stream, using readdir() with external synchronization is
still preferable to the use of the deprecated readdir_r(3) function."

Noticed while building on a Fedora Rawhide docker container.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-mt3xz7n2hl49ni2vx7kuq74g@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf thread_map: Use readdir() instead of deprecated readdir_r()
Arnaldo Carvalho de Melo [Fri, 8 Apr 2016 14:31:24 +0000 (11:31 -0300)]
perf thread_map: Use readdir() instead of deprecated readdir_r()

commit 3354cf71104de49326d19d2f9bdb1f66eea52ef4 upstream.

The readdir() function is thread safe as long as just one thread uses a
DIR, which is the case in thread_map, so, to avoid breaking the build
with glibc-2.23.90 (upcoming 2.24), use it instead of readdir_r().

See: http://man7.org/linux/man-pages/man3/readdir.3.html

"However, in modern implementations (including the glibc implementation),
concurrent calls to readdir() that specify different directory streams
are thread-safe.  In cases where multiple threads must read from the
same directory stream, using readdir() with external synchronization is
still preferable to the use of the deprecated readdir_r(3) function."

Noticed while building on a Fedora Rawhide docker container.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-del8h2a0f40z75j4r42l96l0@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf tools: Use readdir() instead of deprecated readdir_r()
Arnaldo Carvalho de Melo [Fri, 8 Apr 2016 14:32:15 +0000 (11:32 -0300)]
perf tools: Use readdir() instead of deprecated readdir_r()

commit 7093b4c963cc4e344e490c774924a180602a7092 upstream.

The readdir() function is thread safe as long as just one thread uses a
DIR, which is the case when synthesizing events for pre-existing threads
by traversing /proc, so, to avoid breaking the build with glibc-2.23.90
(upcoming 2.24), use it instead of readdir_r().

See: http://man7.org/linux/man-pages/man3/readdir.3.html

"However, in modern implementations (including the glibc implementation),
concurrent calls to readdir() that specify different directory streams
are thread-safe.  In cases where multiple threads must read from the
same directory stream, using readdir() with external synchronization is
still preferable to the use of the deprecated readdir_r(3) function."

Noticed while building on a Fedora Rawhide docker container.

   CC       /tmp/build/perf/util/event.o
  util/event.c: In function '__event__synthesize_thread':
  util/event.c:466:2: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations]
    while (!readdir_r(tasks, &dirent, &next) && next) {
    ^~~~~
  In file included from /usr/include/features.h:368:0,
                   from /usr/include/stdint.h:25,
                   from /usr/lib/gcc/x86_64-redhat-linux/6.0.0/include/stdint.h:9,
                   from /git/linux/tools/include/linux/types.h:6,
                   from util/event.c:1:
  /usr/include/dirent.h:189:12: note: declared here

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-i1vj7nyjp2p750rirxgrfd3c@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf bench numa: Avoid possible truncation when using snprintf()
Arnaldo Carvalho de Melo [Thu, 9 Feb 2017 17:39:42 +0000 (14:39 -0300)]
perf bench numa: Avoid possible truncation when using snprintf()

commit 3aff8ba0a4c9c9191bb788171a1c54778e1246a2 upstream.

Addressing this warning from gcc 7:

    CC       /tmp/build/perf/bench/numa.o
  bench/numa.c: In function '__bench_numa':
  bench/numa.c:1582:42: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size between 8 and 17 [-Werror=format-truncation=]
       snprintf(tname, 32, "process%d:thread%d", p, t);
                                            ^~
  bench/numa.c:1582:25: note: directive argument in the range [0, 2147483647]
       snprintf(tname, 32, "process%d:thread%d", p, t);
                           ^~~~~~~~~~~~~~~~~~~~
  In file included from /usr/include/stdio.h:939:0,
                   from bench/../util/util.h:47,
                   from bench/../builtin.h:4,
                   from bench/numa.c:11:
  /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 17 and 35 bytes into a destination of size 32
     return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          __bos (__s), __fmt, __va_arg_pack ());
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Petr Holasek <pholasek@redhat.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-twa37vsfqcie5gwpqwnjuuz9@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf tests: Avoid possible truncation with dirent->d_name + snprintf
Arnaldo Carvalho de Melo [Thu, 9 Feb 2017 17:48:46 +0000 (14:48 -0300)]
perf tests: Avoid possible truncation with dirent->d_name + snprintf

commit 2e2bbc039fad9eabad6c4c1a473c8b2554cdd2d4 upstream.

Addressing a few cases spotted by a new warning in gcc 7:

  tests/parse-events.c: In function 'test_pmu_events':
  tests/parse-events.c:1790:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 90 [-Werror=format-truncation=]
     snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
                                       ^~
  In file included from /usr/include/stdio.h:939:0,
                   from /git/linux/tools/perf/util/map.h:9,
                   from /git/linux/tools/perf/util/symbol.h:7,
                   from /git/linux/tools/perf/util/evsel.h:10,
                   from tests/parse-events.c:3:
  /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 13 and 268 bytes into a destination of size 100
     return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          __bos (__s), __fmt, __va_arg_pack ());
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  tests/parse-events.c:1798:29: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 100 [-Werror=format-truncation=]
     snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 945aea220bb8 ("perf tests: Move test objects into 'tests' directory")
Link: http://lkml.kernel.org/n/tip-ty4q2p8zp1dp3mskvubxskm5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf scripting perl: Fix compile error with some perl5 versions
Wang YanQing [Sun, 12 Feb 2017 02:46:55 +0000 (10:46 +0800)]
perf scripting perl: Fix compile error with some perl5 versions

commit d7dd112ea5cacf91ae72c0714c3b911eb6016fea upstream.

Fix below compile error:

  CC       util/scripting-engines/trace-event-perl.o
  In file included from /usr/lib/perl5/5.22.2/i686-linux/CORE/perl.h:5673:0,
                   from util/scripting-engines/trace-event-perl.c:31:
  /usr/lib/perl5/5.22.2/i686-linux/CORE/inline.h: In function 'S__is_utf8_char_slow':
  /usr/lib/perl5/5.22.2/i686-linux/CORE/inline.h:270:5: error: nested extern declaration of 'Perl___notused' [-Werror=nested-externs]
          dTHX;   /* The function called below requires thread context */
     ^
  cc1: all warnings being treated as errors

After digging perl5 repository, I find out that we will meet this
compile error with perl from v5.21.1 to v5.25.4

Signed-off-by: Wang YanQing <udknight@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20170212024655.GA15997@udknight
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf thread_map: Correctly size buffer used with dirent->dt_name
Arnaldo Carvalho de Melo [Wed, 8 Feb 2017 20:01:46 +0000 (17:01 -0300)]
perf thread_map: Correctly size buffer used with dirent->dt_name

commit bdf23a9a190d7ecea092fd5c4aabb7d4bd0a9980 upstream.

The size of dirent->dt_name is NAME_MAX + 1, but the size for the 'path'
buffer is hard coded at 256, which may truncate it because we also
prepend "/proc/", so that all that into account and thank gcc 7 for this
warning:

  /git/linux/tools/perf/util/thread_map.c: In function 'thread_map__new_by_uid':
  /git/linux/tools/perf/util/thread_map.c:119:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 250 [-Werror=format-truncation=]
     snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
                                         ^~
  In file included from /usr/include/stdio.h:939:0,
                   from /git/linux/tools/perf/util/thread_map.c:5:
  /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 7 and 262 bytes into a destination of size 256
     return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          __bos (__s), __fmt, __va_arg_pack ());
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-csy0r8zrvz5efccgd4k12c82@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf intel-pt: Use __fallthrough
Arnaldo Carvalho de Melo [Thu, 9 Feb 2017 18:22:22 +0000 (15:22 -0300)]
perf intel-pt: Use __fallthrough

commit 7ea6856d6f5629d742edc23b8b76e6263371ef45 upstream.

To address new warnings emmited by gcc 7, e.g.::

    CC       /tmp/build/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.o
    CC       /tmp/build/perf/tests/parse-events.o
  util/intel-pt-decoder/intel-pt-pkt-decoder.c: In function 'intel_pt_pkt_desc':
  util/intel-pt-decoder/intel-pt-pkt-decoder.c:499:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
     if (!(packet->count))
        ^
  util/intel-pt-decoder/intel-pt-pkt-decoder.c:501:2: note: here
    case INTEL_PT_CYC:
    ^~~~
    CC       /tmp/build/perf/util/intel-pt-decoder/intel-pt-decoder.o
  cc1: all warnings being treated as errors

Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-mf0hw789pu9x855us5l32c83@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoperf top: Use __fallthrough
Arnaldo Carvalho de Melo [Wed, 8 Feb 2017 20:01:46 +0000 (17:01 -0300)]
perf top: Use __fallthrough

commit 7b0214b702ad8e124e039a317beeebb3f020d125 upstream.

The implicit fall through case label here is intended, so let us inform
that to gcc >= 7:

    CC       /tmp/build/perf/builtin-top.o
  builtin-top.c: In function 'display_thread':
  builtin-top.c:644:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
      if (errno == EINTR)
         ^
  builtin-top.c:647:3: note: here
     default:
   ^~~~~~~

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-lmcfnnyx9ic0m6j0aud98p4e@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agotools strfilter: Use __fallthrough
Arnaldo Carvalho de Melo [Wed, 8 Feb 2017 20:01:46 +0000 (17:01 -0300)]
tools strfilter: Use __fallthrough

commit d64b721d27aef3fbeb16ecda9dd22ee34818ff70 upstream.

The implicit fall through case label here is intended, so let us inform
that to gcc >= 7:

  util/strfilter.c: In function 'strfilter_node__sprint':
  util/strfilter.c:270:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
     if (len < 0)
        ^
  util/strfilter.c:272:2: note: here
    case '!':
    ^~~~
  cc1: all warnings being treated as errors

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-z2dpywg7u8fim000hjfbpyfm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agotools string: Use __fallthrough in perf_atoll()
Arnaldo Carvalho de Melo [Wed, 8 Feb 2017 20:01:46 +0000 (17:01 -0300)]
tools string: Use __fallthrough in perf_atoll()

commit 94bdd5edb34e472980d1e18b4600d6fb92bd6b0a upstream.

The implicit fall through case label here is intended, so let us inform
that to gcc >= 7:

    CC       /tmp/build/perf/util/string.o
  util/string.c: In function 'perf_atoll':
  util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
      if (*p)
         ^
  util/string.c:24:3: note: here
     case '\0':
     ^~~~

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-0ophb30v9apkk6o95el0rqlq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agotools include: Add a __fallthrough statement
Arnaldo Carvalho de Melo [Wed, 8 Feb 2017 20:01:46 +0000 (17:01 -0300)]
tools include: Add a __fallthrough statement

commit b5bf1733d6a391c4e90ea8f8468d83023be74a2a upstream.

For cases where implicit fall through case labels are intended,
to let us inform that to gcc >= 7:

    CC       /tmp/build/perf/util/string.o
  util/string.c: In function 'perf_atoll':
  util/string.c:22:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
      if (*p)
         ^
  util/string.c:24:3: note: here
     case '\0':
     ^~~~

So we introduce:

  #define __fallthrough __attribute__ ((fallthrough))

And use it in such cases.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/n/tip-qnpig0xfop4hwv6k4mv1wts5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agomqueue: fix a use-after-free in sys_mq_notify()
Cong Wang [Sun, 9 Jul 2017 20:19:55 +0000 (13:19 -0700)]
mqueue: fix a use-after-free in sys_mq_notify()

commit f991af3daabaecff34684fd51fac80319d1baad1 upstream.

The retry logic for netlink_attachskb() inside sys_mq_notify()
is nasty and vulnerable:

1) The sock refcnt is already released when retry is needed
2) The fd is controllable by user-space because we already
   release the file refcnt

so we when retry but the fd has been just closed by user-space
during this small window, we end up calling netlink_detachskb()
on the error path which releases the sock again, later when
the user-space closes this socket a use-after-free could be
triggered.

Setting 'sock' to NULL here should be sufficient to fix it.

Reported-by: GeneBlue <geneblue.mail@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoRDMA/uverbs: Check port number supplied by user verbs cmds
Boris Pismenny [Tue, 27 Jun 2017 12:09:13 +0000 (15:09 +0300)]
RDMA/uverbs: Check port number supplied by user verbs cmds

commit 5ecce4c9b17bed4dc9cb58bfb10447307569b77b upstream.

The ib_uverbs_create_ah() ind ib_uverbs_modify_qp() calls receive
the port number from user input as part of its attributes and assumes
it is valid. Down on the stack, that parameter is used to access kernel
data structures.  If the value is invalid, the kernel accesses memory
it should not.  To prevent this, verify the port number before using it.

BUG: KASAN: use-after-free in ib_uverbs_create_ah+0x6d5/0x7b0
Read of size 4 at addr ffff880018d67ab8 by task syz-executor/313

BUG: KASAN: slab-out-of-bounds in modify_qp.isra.4+0x19d0/0x1ef0
Read of size 4 at addr ffff88006c40ec58 by task syz-executor/819

Fixes: 67cdb40ca444 ("[IB] uverbs: Implement more commands")
Cc: Yevgeny Kliteynik <kliteyn@mellanox.com>
Cc: Tziporet Koren <tziporet@mellanox.com>
Cc: Alex Polak <alexpo@mellanox.com>
Signed-off-by: Boris Pismenny <borisp@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7 years agoKEYS: Fix an error code in request_master_key()
Dan Carpenter [Thu, 9 Feb 2017 17:17:52 +0000 (17:17 +0000)]
KEYS: Fix an error code in request_master_key()

commit 57cb17e764ba0aaa169d07796acce54ccfbc6cae upstream.

This function has two callers and neither are able to handle a NULL
return.  Really, -EINVAL is the correct thing return here anyway.  This
fixes some static checker warnings like:

security/keys/encrypted-keys/encrypted.c:709 encrypted_key_decrypt()
error: uninitialized symbol 'master_key'.

Fixes: 7e70cb497850 ("keys: add new key-type encrypted")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>