linux.git
4 years agodpaa2-mac: fixup the remove path
Ioana Ciornei [Tue, 9 Feb 2021 14:53:26 +0000 (16:53 +0200)]
dpaa2-mac: fixup the remove path

On the remove path, there is a need to teardown the IRQs and disconnect
from the PHY only if the DPMAC is not in TYPE_FIXED.
Update the remove path so that we do not end up accesing an invalid MC
portal.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
4 years agofsl_qbman: initialize ceetm configuration and query structures
Florinel Iordache [Fri, 26 Feb 2021 12:13:35 +0000 (14:13 +0200)]
fsl_qbman: initialize ceetm configuration and query structures

Initialize to zero all ceetm configuration and query structures in qman_high

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agosdk_fman: fix printf format specifier for phys_addr_t in lnxwrp_sysfs_fm
Florinel Iordache [Mon, 22 Feb 2021 10:26:07 +0000 (12:26 +0200)]
sdk_fman: fix printf format specifier for phys_addr_t in lnxwrp_sysfs_fm

Fix a Coverity issue in lnxwrp_sysfs_fm: invalid type in argument to printf format specifier for phys_addr_t

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agommc: sdhci-esdhc-imx: fix kernel panic when remove module
Frank Li [Wed, 10 Feb 2021 18:19:33 +0000 (12:19 -0600)]
mmc: sdhci-esdhc-imx: fix kernel panic when remove module

In sdhci_esdhc_imx_remove() the SDHCI_INT_STATUS in read. Under some
circumstances, this may be done while the device is runtime suspended,
triggering the below splat.

Fix the problem by adding a pm_runtime_get_sync(), before reading the
register, which will turn on clocks etc making the device accessible again.

[ 1811.323148] mmc1: card aaaa removed
[ 1811.347483] Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP
[ 1811.354988] Modules linked in: sdhci_esdhc_imx(-) sdhci_pltfm sdhci cqhci mmc_block mmc_core [last unloaded: mmc_core]
[ 1811.365726] CPU: 0 PID: 3464 Comm: rmmod Not tainted 5.10.1-sd-99871-g53835a2e8186 #5
[ 1811.373559] Hardware name: Freescale i.MX8DXL EVK (DT)
[ 1811.378705] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
[ 1811.384723] pc : sdhci_esdhc_imx_remove+0x28/0x15c [sdhci_esdhc_imx]
[ 1811.391090] lr : platform_drv_remove+0x2c/0x50
[ 1811.395536] sp : ffff800012c7bcb0
[ 1811.398855] x29: ffff800012c7bcb0 x28: ffff00002c72b900
[ 1811.404181] x27: 0000000000000000 x26: 0000000000000000
[ 1811.409497] x25: 0000000000000000 x24: 0000000000000000
[ 1811.414814] x23: ffff0000042b3890 x22: ffff800009127120
[ 1811.420131] x21: ffff00002c4c9580 x20: ffff0000042d0810
[ 1811.425456] x19: ffff0000042d0800 x18: 0000000000000020
[ 1811.430773] x17: 0000000000000000 x16: 0000000000000000
[ 1811.436089] x15: 0000000000000004 x14: ffff000004019c10
[ 1811.441406] x13: 0000000000000000 x12: 0000000000000020
[ 1811.446723] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f
[ 1811.452040] x9 : fefefeff6364626d x8 : 7f7f7f7f7f7f7f7f
[ 1811.457356] x7 : 78725e6473607372 x6 : 0000000080808080
[ 1811.462673] x5 : 0000000000000000 x4 : 0000000000000000
[ 1811.467990] x3 : ffff800011ac1cb0 x2 : 0000000000000000
[ 1811.473307] x1 : ffff8000091214d4 x0 : ffff8000133a0030
[ 1811.478624] Call trace:
[ 1811.481081]  sdhci_esdhc_imx_remove+0x28/0x15c [sdhci_esdhc_imx]
[ 1811.487098]  platform_drv_remove+0x2c/0x50
[ 1811.491198]  __device_release_driver+0x188/0x230
[ 1811.495818]  driver_detach+0xc0/0x14c
[ 1811.499487]  bus_remove_driver+0x5c/0xb0
[ 1811.503413]  driver_unregister+0x30/0x60
[ 1811.507341]  platform_driver_unregister+0x14/0x20
[ 1811.512048]  sdhci_esdhc_imx_driver_exit+0x1c/0x3a8 [sdhci_esdhc_imx]
[ 1811.518495]  __arm64_sys_delete_module+0x19c/0x230
[ 1811.523291]  el0_svc_common.constprop.0+0x78/0x1a0
[ 1811.528086]  do_el0_svc+0x24/0x90
[ 1811.531405]  el0_svc+0x14/0x20
[ 1811.534461]  el0_sync_handler+0x1a4/0x1b0
[ 1811.538474]  el0_sync+0x174/0x180
[ 1811.541801] Code: a9025bf5 f9403e95 f9400ea0 9100c000 (b9400000)
[ 1811.547902] ---[ end trace 3fb1a3bd48ff7be5 ]---

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Cc: stable@vger.kernel.org # v4.0+
Link: https://lore.kernel.org/r/20210210181933.29263-1-Frank.Li@nxp.com
[Ulf: Clarified the commit message a bit]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
4 years agoMLK-24093 arm64: dts: imx8mn: disable flexspi for rpmsg dts
Peng Fan [Fri, 22 May 2020 07:07:59 +0000 (15:07 +0800)]
MLK-24093 arm64: dts: imx8mn: disable flexspi for rpmsg dts

When M4 boots from flexspi, linux should not use that, otherwise
M4 will hang.

Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit 1f49d90ebaf77492bcb2e9f8a8e5a8d4d7aee58a)
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoLF-3319 net: stmmac: enable rx_clk when killing the vlan
Shenwei Wang [Tue, 9 Feb 2021 17:06:48 +0000 (11:06 -0600)]
LF-3319 net: stmmac: enable rx_clk when killing the vlan

when killing the vlan, the rx_clk from the phy need to be enabled.
The patch checks the phy's status before killing the vlan. If the phy
is stopped, enable it, remove the vlan, and then stop the phy.

Reviewed-by: Frank Li <frank.li@nxp.com>
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoLF-3367-3: drm: mhdp-hdcp: adjust state handle priority
Sandor Yu [Fri, 19 Feb 2021 09:53:54 +0000 (17:53 +0800)]
LF-3367-3: drm: mhdp-hdcp: adjust state handle priority

Handle HDCP_STATE_INACTIVE and HDCP_STATE_DISABLING state priority
to avoid unnecessary HPD state check, drm has check it when hdcp
enable/disable.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoLF-3367-2: drm: mhdp: more time for FW alive check
Sandor Yu [Fri, 19 Feb 2021 08:41:31 +0000 (16:41 +0800)]
LF-3367-2: drm: mhdp: more time for FW alive check

FW alive check function may return false in hdcp enable/disable stress test.
Add more time for FW alive check, make sure get correct state.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoLF-3367-1: drm: cdns_hdmi: HDCP_STATE_DISABLING may missed by check link
Sandor Yu [Thu, 18 Feb 2021 08:25:52 +0000 (16:25 +0800)]
LF-3367-1: drm: cdns_hdmi: HDCP_STATE_DISABLING may missed by check link

Polling thread check_work is designed to handle all hdcp state change.
In HDCP disable function, check_work thread will be stopped after
hdcp.state is set to HDCP_STATE_DISABLING. check_work thread may miss
the state change, call check link function make sure HDCP_STATE_DISABLING
state is properly handled.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agowatchdog: stop wdd when watchdog hw running in reboot_notifier
Zhao Qiang [Thu, 14 Jan 2021 08:09:57 +0000 (16:09 +0800)]
watchdog: stop wdd when watchdog hw running in reboot_notifier

In watchdog_reboot_notifier, wdd should be stopped when the device
is in hw_running state

Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com>
4 years agosdk_fman: fix invalid type in argument to printf format specifier
Florinel Iordache [Tue, 2 Feb 2021 06:32:37 +0000 (08:32 +0200)]
sdk_fman: fix invalid type in argument to printf format specifier

Fix a Coverity issue in fm: invalid type in argument to printf format specifier for dma_max_watchdog

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agoLF-3300 arm64: dts: ls1088a: add pmu node
Li Yang [Fri, 29 Jan 2021 17:46:19 +0000 (11:46 -0600)]
LF-3300 arm64: dts: ls1088a: add pmu node

Add the missing pmu node and also fix the issue with kvm that it
requires pmu node to be present.

Signed-off-by: Li Yang <leoyang.li@nxp.com>
Acked-by: Diana Craciun <diana.craciun@oss.nxp.com>
4 years agoLF-3354 mailbox:imx: Driver cannot timeout while reading/writing messages to SCFW
Ranjani Vaidyanathan [Fri, 29 Jan 2021 21:43:26 +0000 (15:43 -0600)]
LF-3354 mailbox:imx: Driver cannot timeout while reading/writing messages to SCFW

Mailbox driver needs to wait and read all the words in response to a
SCFW API call, else the protocol gets messed up and results in kernel hang.
When the responses are longer than 3 words its possible that SCFW will
take some time to fill up the rest of the words in the MU, a timeout of
100us is arbritrary and too short. While waiting for Linux to consume the
first 3 words of the response SCFW can be busy doing other stuff and hence
Linux needs to wait for the rest of the words.
Similar restriction applies when writing messages that are longer than
3 words.
This patch increases the timeout to 5secs while waiting for response
or writing long messages to SCFW.

Signed-off-by: Ranjani Vaidyanathan <ranjani.vaidyanathan@nxp.com>
4 years agoLF-3353: mxc-jpeg: Don't decode after jpeg parse error
Mirela Rabulea [Thu, 28 Jan 2021 10:14:04 +0000 (12:14 +0200)]
LF-3353: mxc-jpeg: Don't decode after jpeg parse error

Add a new member jpeg_parse_error in mxc_jpeg_src_buf, to indicate
an error while parsing the input jpeg stream.
Do not run the decoder when the source buffer is marked with
jpeg_parse_error, instead mark both the source and destination
buffer with VB2_BUF_STATE_ERROR. This will prevent an application
getting stuck waiting to dequeue the destination buffer.

Signed-off-by: Mirela Rabulea <mirela.rabulea@oss.nxp.com>
4 years agoLF-1571: mxc-jpeg: Fix decoding invalid buffer
Mirela Rabulea [Wed, 27 Jan 2021 18:27:47 +0000 (20:27 +0200)]
LF-1571: mxc-jpeg: Fix decoding invalid buffer

End of buffer was not properly detected in case of an invalid
buffer stream, such as a stream of null bytes, for example.
This was leading to a kernel oups.
Let get_byte return type be int, so it can return an error for
reaching end of stream.

While at it, replace 0 with NULL, for null pointer initialization.

Fixes: 36649dec0eb7 ("mxc-jpeg: Fix result independent of operands")
Signed-off-by: Mirela Rabulea <mirela.rabulea@oss.nxp.com>
4 years agoLF-3218-2 arch: arm64: sof: Remove DSP clocks on i.MX8QXP
Daniel Baluta [Fri, 29 Jan 2021 21:04:30 +0000 (23:04 +0200)]
LF-3218-2 arch: arm64: sof: Remove DSP clocks on i.MX8QXP

Clocks are always on when DSP PD is on. Use dummy clocks
for minimal code impact for now.

This is similar with the approach on i.MX8QM.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
4 years agoLF-3218-1 ASoC: SOF: imx: Fix PM sleep
Daniel Baluta [Fri, 29 Jan 2021 20:32:16 +0000 (22:32 +0200)]
LF-3218-1 ASoC: SOF: imx: Fix PM sleep

This is similar with the refactor for i.MX8MP added in commit
ba2d283f5d9 ("LF-3026-2 ASoC: SOF: imx8m: Remove internal
priv->suspended variable").

Because SOF state machine assumes that even if the DSP wasn't previously
active at a System resume, will re-load the firmware we need to make sure
that all needed resources are active.

Kernel core will take care of enabling the PD, we need to make sure that
we request the MU channels.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
4 years agoLF-3217: media: isi: cap: call streamoff if the process abnormal exit
Guoniu.zhou [Fri, 29 Jan 2021 02:29:11 +0000 (10:29 +0800)]
LF-3217: media: isi: cap: call streamoff if the process abnormal exit

For normal case, userspace should call streamon/streamoff balance, but
for some special case, the process will be killed or terminated and the
streamoff ioctl will be ignored. So driver need to handle the case.

Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3132: dmaengine: imx-sdma: raise up channel0 priority after resume
Robin Gong [Thu, 28 Jan 2021 15:34:19 +0000 (23:34 +0800)]
LF-3132: dmaengine: imx-sdma: raise up channel0 priority after resume

For some tough multi channels test, the default priority of channel0 may
not be scheduled in 500us so that channel context can't be loaded as the
below warning, hence sdma channel transfer will be failed. So raise up
channel0 to the highest one since context load is important to all
channels. Besides, enlarge 500us to 5ms for safe since many highest channel
also may run at the same time like asrc/easrc tough test(8 channel run).

"imx-sdma 30e10000.dma-controller: Timeout waiting for CH0 ready"

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Peng Zhang <peng.zhang_8@nxp.com>
4 years agoMLK-3056-2 drm/panel: rm67191: change clock rate to 121MHz for default mode
Fancy Fang [Thu, 28 Jan 2021 04:19:17 +0000 (12:19 +0800)]
MLK-3056-2 drm/panel: rm67191: change clock rate to 121MHz for default mode

The latest batch of RM67191 panels have an issue that the panel display
will get blurred and have no response to later display actions when read
data from panel through DSI interface.

And decrease the pixel clock rate to 121MHz which means decrease the
panel's frame rate from 60.02Hz to 55.02Hz can solve this issue, so
do this change to make RM67191 display more stable.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoMLK-3056-1 drm/bridge: dsim: correct return value for transfer
Fancy Fang [Wed, 11 Nov 2020 03:17:22 +0000 (11:17 +0800)]
MLK-3056-1 drm/bridge: dsim: correct return value for transfer

According to the .transfer function definition in mipi_dsi_host_ops,
on success it shall return the number of bytes transmitted for write
packets or the number of bytes received for read packets. So correct
the return value in sec_mipi_dsim_host_transfer() implementation.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agosdk_fman: fix extra argument format specifier for dma_max_watchdog
Florinel Iordache [Thu, 28 Jan 2021 06:58:18 +0000 (08:58 +0200)]
sdk_fman: fix extra argument format specifier for dma_max_watchdog

Fix a Coverity issue in fm: extra argument to printf format specifier for dma_max_watchdog

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agoLF-1782-2 Revert "dm crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY"
Horia Geantă [Mon, 11 Jan 2021 15:27:38 +0000 (17:27 +0200)]
LF-1782-2 Revert "dm crypt: don't use drivers that have CRYPTO_ALG_ALLOCATES_MEMORY"

This reverts commit cd74693870fb748d812867ba49af733d689a3604.

This is a workaround for allowing dm-crypt crypto operations to be
offloaded to caam crypto accelerator.
It's needed because crypto algorithms registered by caam are marked with
CRYPTO_ALG_ALLOCATES_MEMORY flag.

Background:
Red Hat reported possible allocation issues in dm-crypt, dm-integrity:
Link: https://lore.kernel.org/linux-crypto/alpine.LRH.2.02.2006091259250.30590@file01.intranet.prod.int.rdu2.redhat.com
The solution found was a mechanism to let dm-crypt, dm-integrity avoid
using crypto algorithms that allocate memory "at runtime" - by specifying
the CRYPTO_ALG_ALLOCATES_MEMORY flag introduced in
commit fbb6cda44190 ("crypto: algapi - introduce the flag CRYPTO_ALG_ALLOCATES_MEMORY")

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Manish Tomar <manish.tomar@nxp.com>
4 years agoLF-1782-1 script: add dm-crypt to crypto/core branch
Horia Geantă [Mon, 11 Jan 2021 15:44:44 +0000 (17:44 +0200)]
LF-1782-1 script: add dm-crypt to crypto/core branch

Add dm-crypt device-mapper target to crypto/core branch,
since this is a crypto offloading use case.

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Manish Tomar <manish.tomar@nxp.com>
4 years agoLF-2949 arm: kernel: hyp-stub: not export __hyp_stub_vectors
Peng Fan [Tue, 24 Nov 2020 09:09:50 +0000 (17:09 +0800)]
LF-2949 arm: kernel: hyp-stub: not export __hyp_stub_vectors

Since we only support Jailhouse on ARM64, so drop this to avoid
build warning on ARM32

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
4 years agoirqchip: ls-extirq: add IRQCHIP_SKIP_SET_WAKE to the irqchip flags
Biwen Li [Tue, 26 Jan 2021 10:14:04 +0000 (18:14 +0800)]
irqchip: ls-extirq: add IRQCHIP_SKIP_SET_WAKE to the irqchip flags

The ls-extirq driver doesn't implement the irq_set_wake()
callback, while being wake-up capable. This results in
ugly behaviours across suspend/resume cycles.

Advertise this by adding IRQCHIP_SKIP_SET_WAKE to
the irqchip flags

Signed-off-by: Biwen Li <biwen.li@nxp.com>
4 years agosdk_dpaa: memset local configuration structures before filling them
Camelia Groza [Wed, 27 Jan 2021 14:03:20 +0000 (16:03 +0200)]
sdk_dpaa: memset local configuration structures before filling them

Zero-out local configuration structures before filling them up and
passing them to the QMan. In most scenarios, there is no need to fill up
all fields so some random data might linger. This avoids sending potentially
random data to the QMan.

Applies to congestions groups, class congestion groups and fq
initialization.

Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
4 years agosdk_dpaa: remove unneeded const type qualifiers
Camelia Groza [Wed, 27 Jan 2021 13:56:15 +0000 (15:56 +0200)]
sdk_dpaa: remove unneeded const type qualifiers

The dpa_fd_length() and dpa_fd_offset() calls return values so
the const qualifier is meaningless in this case.

Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
4 years agoLF-3322: drm: cdns_mhdp: change HDMI hotplug debounce time to 50ms
Sandor Yu [Tue, 26 Jan 2021 03:28:41 +0000 (11:28 +0800)]
LF-3322: drm: cdns_mhdp: change HDMI hotplug debounce time to 50ms

HDCP driver will create a thread to poll hdcp state and cable state
every 50ms. Sync HPD debounce time to 50ms with HDCP driver
in case cable state mismatch in HDCP and HDMI driver.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3321: drm/imx/dcss: fix regression after introducing rotations
Laurentiu Palcu [Mon, 25 Jan 2021 17:25:41 +0000 (17:25 +0000)]
LF-3321: drm/imx/dcss: fix regression after introducing rotations

After rotations were introduced for Vivante tiled/super-tiled formats and these
formats were also allowed for video channels, the tile type was adjusted only
if the framebuffer modifier was linear or belonged to Vivante tiled types. For
tiled video formats, the modifier is none of those and the tiled type remained
unchanged from the previous run.

Tiled video formats are handled by DTRC and DPR always fetches the linear buffers
directly from DTRC.

This patch fixes the regression. Also, add a meaningful error message if a wrong
modifier is passed to DPR for the graphics/video path.

Fixes: 69c833ef382c ("LF-2580: drm/imx/dcss: add 90/270 rotations for Vivante tiled formats.")
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Liu Ying <victor.liu@nxp.com>
4 years agosdk_fman: fix argument format specifier in sdk_fman memcpy
Florinel Iordache [Mon, 25 Jan 2021 17:19:17 +0000 (19:19 +0200)]
sdk_fman: fix argument format specifier in sdk_fman memcpy

Fix a Coverity issue in fm driver: invalid type in argument format specifier

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agosdk_fman: fix resource leak in fm wrapper on fm_probe
Florinel Iordache [Mon, 25 Jan 2021 18:14:53 +0000 (20:14 +0200)]
sdk_fman: fix resource leak in fm wrapper on fm_probe

Fix a Coverity issue in lnxwrp_fm: leaked_storage: Variable p_LnxWrpFmDev going out of scope leaks the storage it points to

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agoLF-3058-2 drm/imx: dcss: kms: Reject unsupported HDR10 pipe configurations
Liu Ying [Mon, 25 Jan 2021 02:44:55 +0000 (10:44 +0800)]
LF-3058-2 drm/imx: dcss: kms: Reject unsupported HDR10 pipe configurations

Some HDR10 pipe configurations are not supported by DCSS.
The general idea is to use atomic check to reject the unsupported cases
by searching the array dcss_cfg_table[] to see if a valid entry can be found
or not.  To do the atomic check correctly, we should track the output pipe
configurations, which is done by the newly introduced struct dcss_crtc_state.
The plane->atomic_check() function would finally check the input and output
pipe configurations by calling the helper function
dcss_plane_hdr10_pipe_cfg_is_supported().

Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
4 years agoLF-3058-1 drm/imx: dcss: crtc: Add to_dcss_crtc() helper
Liu Ying [Mon, 25 Jan 2021 02:34:17 +0000 (10:34 +0800)]
LF-3058-1 drm/imx: dcss: crtc: Add to_dcss_crtc() helper

This patch adds the to_dcss_crtc() helper function to make callers'
life easier.

Tested-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Reviewed-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
4 years agosdk_fman: fix argument format specifier for bmi_max_fifo_size
Florinel Iordache [Mon, 25 Jan 2021 17:54:49 +0000 (19:54 +0200)]
sdk_fman: fix argument format specifier for bmi_max_fifo_size

Fix a Coverity issue in fm: invalid type in argument format specifier for bmi_max_fifo_size

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agosdk_fman: fix argument format specifier in hc
Florinel Iordache [Mon, 25 Jan 2021 17:36:45 +0000 (19:36 +0200)]
sdk_fman: fix argument format specifier in hc

Fix a Coverity issue in hc: invalid type in argument format specifier

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agosdk_fman: fix format string in fm
Florinel Iordache [Mon, 25 Jan 2021 15:27:58 +0000 (17:27 +0200)]
sdk_fman: fix format string in fm

Fix a Coverity issue in fm driver: format string ended in the middle of specifier %

Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
4 years agoMLK-25259 dts: arm64: freescale: imx8mm ab2 fix dac2 i2c addr
Adrian Alonso [Thu, 21 Jan 2021 18:25:46 +0000 (12:25 -0600)]
MLK-25259 dts: arm64: freescale: imx8mm ab2 fix dac2 i2c addr

Fix i2c address for second and third ak4458 dac on Audio
Board 2.0

Signed-off-by: Hongting Dong <hongting.dong@nxp.com>
Reviewed-by: Adrian Alonso <adrian.alonso@nxp.com>
4 years agoLF-3064 Revert "arm64: dts: imx8mq-evk: Add MIPI DSI support"
Fancy Fang [Thu, 21 Jan 2021 06:54:06 +0000 (14:54 +0800)]
LF-3064 Revert "arm64: dts: imx8mq-evk: Add MIPI DSI support"

This reverts commit d367e7d3351edc526133e4bd258dac2dd0b4ef4f.

As designed, the default dtb imx8mq-evk can only support one
display: DCSS + native HDMI, and dtb imx8mq-evk-dual-display
is dedicated for multiple dislay.

And current multiple displays is implemented by two different
DRM devices with two DRI cards generated. But Weston UI cannot
make sure to choose DCSS for UI display device, so revert this
patch to solve this kind of problem.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
4 years agoLF-2653 drm/imx: lcdif: implement mode_valid() for CRTC
Fancy Fang [Sun, 24 Jan 2021 11:08:55 +0000 (19:08 +0800)]
LF-2653 drm/imx: lcdif: implement mode_valid() for CRTC

Add mode_valid() implementation for CRTC to filter out any
mode which cannot be supported by LCDIF. Only check the
CEA and DMT modes for pixel clock round rate is same with
the value from mode.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
4 years agoMLK-24050-3 dt-bindings: phy-imx8mq-usb: add phy tuning for imx8mq/p
Li Jun [Sat, 16 May 2020 05:14:04 +0000 (13:14 +0800)]
MLK-24050-3 dt-bindings: phy-imx8mq-usb: add phy tuning for imx8mq/p

Add USB PHY tuning of imx8mq/p for USB certification, mainly for eye
diagram test.

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
4 years agoMLK-24050-2 arm64: dts: imx8mp-evk: add usb phy tuning for certification
Li Jun [Sat, 16 May 2020 04:36:52 +0000 (12:36 +0800)]
MLK-24050-2 arm64: dts: imx8mp-evk: add usb phy tuning for certification

Add phy tuning result for USB certification, mainly for pass
eye pattern test, details please check its dt binding doc:
Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.txt

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
4 years agoMLK-24050-1 phy: freescale: imx8mq-usb: add phy tuning
Li Jun [Wed, 20 Jan 2021 06:07:30 +0000 (14:07 +0800)]
MLK-24050-1 phy: freescale: imx8mq-usb: add phy tuning

Add USB PHY parameters tuning for USB certifications.

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
4 years agoLF-2854: media: mxc_vadc: fix Coverity Issue: 17396
Sandor Yu [Wed, 20 Jan 2021 06:55:28 +0000 (14:55 +0800)]
LF-2854: media: mxc_vadc: fix Coverity Issue: 17396

Remove less-than-zero comparison of an unsigned value

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3268: drm: cdns-hdmi: fix Coverity Issue: 11566403
Sandor Yu [Wed, 20 Jan 2021 03:07:32 +0000 (11:07 +0800)]
LF-3268: drm: cdns-hdmi: fix Coverity Issue: 11566403

Check return value to fix Coverity Issue: 11566403.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3269: drm: cdns-hdmi: fix coverity Issue: 11566404
Sandor Yu [Wed, 20 Jan 2021 03:04:41 +0000 (11:04 +0800)]
LF-3269: drm: cdns-hdmi: fix coverity Issue: 11566404

Check return value to fix coverity Issue: 11566404.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3270: drm: cdns-hdmi: fix coverity Issue: 11566405
Sandor Yu [Wed, 20 Jan 2021 02:49:13 +0000 (10:49 +0800)]
LF-3270: drm: cdns-hdmi: fix coverity Issue: 11566405

Delete unused code to fix coverity Issue: 11566405.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3271: drm: cdns-hdmi: fix Coverity Issue: 11566407
Sandor Yu [Wed, 20 Jan 2021 02:44:17 +0000 (10:44 +0800)]
LF-3271: drm: cdns-hdmi: fix Coverity Issue: 11566407

Delete dead code to fix Coverity Issue: 11566407.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3272: drm: cdns_mhdp: fix Coverity Issue: 11566406
Sandor Yu [Wed, 20 Jan 2021 02:37:09 +0000 (10:37 +0800)]
LF-3272: drm: cdns_mhdp: fix Coverity Issue: 11566406

Add default access hdcp bus to fix
Coverity Issue: 11566406 Uninitialized scalar variable.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3302: arm64: dts: imx8qm: support scu mailbox channel
Nitin Garg [Thu, 21 Jan 2021 20:06:59 +0000 (14:06 -0600)]
LF-3302: arm64: dts: imx8qm: support scu mailbox channel

With mailbox driver support i.MX8 SCU MU channel, we could
use it to avoid trigger interrupts for each TR/RR registers
in one MU, instead, only one RX interrupt for a recv and
one TX interrupt for a send.

Signed-off-by: Nitin Garg <nitin.garg@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
4 years agoRevert "SSI-87: firmware: imx: scu: Support reception of message of any size"
Nitin Garg [Fri, 22 Jan 2021 03:24:45 +0000 (21:24 -0600)]
Revert "SSI-87: firmware: imx: scu: Support reception of message of any size"

This reverts commit 31997c2be9328bfe82fd7484b8532646de4d4965.
This change isn't needed as the new MU binding is efficient and
can handle messages of any sizes.

Signed-off-by: Nitin Garg <nitin.garg@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
4 years agoRevert "SSI-87: firmware: imx: scu: Support reception of any size message"
Nitin Garg [Fri, 22 Jan 2021 03:24:32 +0000 (21:24 -0600)]
Revert "SSI-87: firmware: imx: scu: Support reception of any size message"

This reverts commit 175fe6289fcb7e13cb5add2b80cdc0e5e049fb95.
This change isn't needed as the new MU binding is efficient and
can handle messages of any sizes.

Signed-off-by: Nitin Garg <nitin.garg@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
4 years agoLF-3256 drm/imx: lcdifv3: destroy dmt to avoid memory leak
Fancy Fang [Fri, 22 Jan 2021 02:00:14 +0000 (10:00 +0800)]
LF-3256 drm/imx: lcdifv3: destroy dmt to avoid memory leak

The 'dmt' is duplicated by 'drm_mode_find_dmt()' and it
should be explicitly freed after it has been used to avoid
memory leak.

This issue is detected by Coverity with CID 1149970.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Reviewed-by: Robby Cai <robby.cai@nxp.com>
4 years agoLF-3093-2 crypto: caam - fix sm_test in case no job rings available
Horia Geantă [Sun, 17 Jan 2021 21:29:34 +0000 (23:29 +0200)]
LF-3093-2 crypto: caam - fix sm_test in case no job rings available

In case no job rings are available, secure memory structures are not
initialized, since caam_jr_probe()->init_misc_func()->caam_sm_startup()
is not called.
This could happen if all job ring devices bind to the jr uio driver
instead of the caam/jr driver.
Running sm_test in this case will lead to a crash.

Add a check to verify that SM has been initialized - if not the tests
will be skipped.

Reported-by: Gaurav Jain <gaurav.jain@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
4 years agoLF-3093-1 crypto: caam/jr - fix caam-keygen exit / clean-up
Horia Geantă [Fri, 15 Jan 2021 09:31:58 +0000 (11:31 +0200)]
LF-3093-1 crypto: caam/jr - fix caam-keygen exit / clean-up

Introduction
===

Currently we are facing some limitations in the caam/jr module lifecycle.
There are some discussion in upstream:
Link: https://lore.kernel.org/linux-crypto/20190904023515.7107-13-andrew.smirnov@gmail.com
Link: https://lore.kernel.org/linux-crypto/20191105151353.6522-1-andrew.smirnov@gmail.com
but in the end it all seems to get down to implementations not being able
to gracefully unregister crypto algorithms from crypto API while there are
users / allocated tfms (cra_refcnt > 1).

[*] OTOH functionalities in caam/jr that don't interact with crypto API
(like Secure Memory or black keys / blobs generation) don't face this
limitation.

Issue at hand
===

When unloading the caam_jr module, the .remove callback for the last JR
device exits with -EBUSY (see "Introduction" above) and doesn't perform
the clean-up (crypto algorithms unregistering etc.).

One side effect of this is leeding to an oops, which occurs due to a
corruption in the linked list of "misc devices"
(drivers/char/misc.c - misc_list):
1. caam_jr module is unloaded without calling unregister_algs()->
caam_keygen_exit()->misc_deregister() for the last job ring device;
this leaves a dangling entry in the misc_list double-linked list
2. rng_core module is unloaded and calls misc_deregister(); this implies
removing the corresponding entry in the misc_list; while doing this the
dangling entry is accessed - which leads to an oops since the address is
no longer valid (address points to the caam_jr module address space,
but caam_jr has been previously unloaded).

Fix this by moving the clean-up of non-crypto related functionalities [*]
before crypto related ones.

Fixes: 3af836d4b311 ("MLK-24420-3 crypto: caam - add ioctl calls for black keys and blobs generation")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com>
4 years agodmaengine: fsl-dpaa2-qdma: Fix the size of dma pools
Guanhua Gao [Tue, 8 Dec 2020 08:14:04 +0000 (16:14 +0800)]
dmaengine: fsl-dpaa2-qdma: Fix the size of dma pools

In case of long format of qDMA command descriptor, there are one frame
descriptor, three entries in the frame list and two data entries. So the
size of dma_pool_create for these three fields should be the same with
the total size of entries respectively, or the contents may be overwritten
by the next allocated descriptor.

Signed-off-by: Guanhua Gao <guanhua.gao@nxp.com>
4 years agoMerge tag 'v5.10.9' into lf-5.10.y
Jason Liu [Wed, 20 Jan 2021 08:16:10 +0000 (16:16 +0800)]
Merge tag 'v5.10.9' into lf-5.10.y

This is the 5.10.9 stable release

* tag 'v5.10.9': (153 commits)
  Linux 5.10.9
  netfilter: nf_nat: Fix memleak in nf_nat_init
  netfilter: conntrack: fix reading nf_conntrack_buckets
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoMerge tag 'v5.10.8' into lf-5.10.y
Jason Liu [Wed, 20 Jan 2021 08:15:27 +0000 (16:15 +0800)]
Merge tag 'v5.10.8' into lf-5.10.y

This is the 5.10.8 stable release

* tag 'v5.10.8': (104 commits)
  Linux 5.10.8
  tools headers UAPI: Sync linux/fscrypt.h with the kernel sources
  drm/panfrost: Remove unused variables in panfrost_job_close()
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoMerge tag 'v5.10.7' into lf-5.10.y
Jason Liu [Thu, 14 Jan 2021 18:19:37 +0000 (02:19 +0800)]
Merge tag 'v5.10.7' into lf-5.10.y

This is the 5.10.7 stable release

* tag 'v5.10.7': (144 commits)
  Linux 5.10.7
  scsi: target: Fix XCOPY NAA identifier lookup
  rtlwifi: rise completion at the last step of firmware callback
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoMerge tag 'v5.10.6' into lf-5.10.y
Jason Liu [Wed, 20 Jan 2021 08:18:34 +0000 (16:18 +0800)]
Merge tag 'v5.10.6' into lf-5.10.y

This is the 5.10.6 stable release

* tag 'v5.10.6': (21 commits)
  Linux 5.10.6
  mwifiex: Fix possible buffer overflows in mwifiex_cmd_802_11_ad_hoc_start
  exec: Transform exec_update_mutex into a rw_semaphore
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
 Conflicts:
drivers/rtc/rtc-pcf2127.c

4 years agoMerge tag 'v5.10.5' into lf-5.10.y
Jason Liu [Thu, 14 Jan 2021 16:41:55 +0000 (00:41 +0800)]
Merge tag 'v5.10.5' into lf-5.10.y

This is the 5.10.5 stable release

* tag 'v5.10.5': (63 commits)
  Linux 5.10.5
  device-dax: Fix range release
  ext4: avoid s_mb_prefetch to be zero in individual scenarios
  ...

Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
4 years agoMLK-25166-2 : arm64: dts: imx8dxl-evk: enable on-board phy for enet0 by default
Shenwei Wang [Tue, 12 Jan 2021 00:51:54 +0000 (18:51 -0600)]
MLK-25166-2 : arm64: dts: imx8dxl-evk: enable on-board phy for enet0 by default

add the gpio-scu node and enable on-board phy for
enet0 by default.

remove "enable-active-high" property from mii_select node to
use the enet module.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
4 years agoMLK-25166-1 gpio: gpio-scu: gpio driver over scu fw misc api
Shenwei Wang [Mon, 11 Jan 2021 23:41:41 +0000 (17:41 -0600)]
MLK-25166-1 gpio: gpio-scu: gpio driver over scu fw misc api

This is a gpio driver to control the PINs which are managed by scu fw.

Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
4 years agoLinux 5.10.9
Greg Kroah-Hartman [Tue, 19 Jan 2021 17:27:34 +0000 (18:27 +0100)]
Linux 5.10.9

Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Pavel Machek (CIP) <pavel@denx.de>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210118113352.764293297@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonetfilter: nf_nat: Fix memleak in nf_nat_init
Dinghao Liu [Sat, 9 Jan 2021 12:01:21 +0000 (20:01 +0800)]
netfilter: nf_nat: Fix memleak in nf_nat_init

commit 869f4fdaf4ca7bb6e0d05caf6fa1108dddc346a7 upstream.

When register_pernet_subsys() fails, nf_nat_bysource
should be freed just like when nf_ct_extend_register()
fails.

Fixes: 1cd472bf036ca ("netfilter: nf_nat: add nat hook register functions to nf_nat")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonetfilter: conntrack: fix reading nf_conntrack_buckets
Jesper Dangaard Brouer [Fri, 8 Jan 2021 11:44:33 +0000 (12:44 +0100)]
netfilter: conntrack: fix reading nf_conntrack_buckets

commit f6351c3f1c27c80535d76cac2299aec44c36291e upstream.

The old way of changing the conntrack hashsize runtime was through changing
the module param via file /sys/module/nf_conntrack/parameters/hashsize. This
was extended to sysctl change in commit 3183ab8997a4 ("netfilter: conntrack:
allow increasing bucket size via sysctl too").

The commit introduced second "user" variable nf_conntrack_htable_size_user
which shadow actual variable nf_conntrack_htable_size. When hashsize is
changed via module param this "user" variable isn't updated. This results in
sysctl net/netfilter/nf_conntrack_buckets shows the wrong value when users
update via the old way.

This patch fix the issue by always updating "user" variable when reading the
proc file. This will take care of changes to the actual variable without
sysctl need to be aware.

Fixes: 3183ab8997a4 ("netfilter: conntrack: allow increasing bucket size via sysctl too")
Reported-by: Yoel Caspersen <yoel@kviknet.dk>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoALSA: firewire-tascam: Fix integer overflow in midi_port_work()
Geert Uytterhoeven [Mon, 11 Jan 2021 13:02:51 +0000 (14:02 +0100)]
ALSA: firewire-tascam: Fix integer overflow in midi_port_work()

commit 9f65df9c589f249435255da37a5dd11f1bc86f4d upstream.

As snd_fw_async_midi_port.consume_bytes is unsigned int, and
NSEC_PER_SEC is 1000000000L, the second multiplication in

    port->consume_bytes * 8 * NSEC_PER_SEC / 31250

always overflows on 32-bit platforms, truncating the result.  Fix this
by precalculating "NSEC_PER_SEC / 31250", which is an integer constant.

Note that this assumes port->consume_bytes <= 16777.

Fixes: 531f471834227d03 ("ALSA: firewire-lib/firewire-tascam: localize async midi port")
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20210111130251.361335-3-geert+renesas@glider.be
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoALSA: fireface: Fix integer overflow in transmit_midi_msg()
Geert Uytterhoeven [Mon, 11 Jan 2021 13:02:50 +0000 (14:02 +0100)]
ALSA: fireface: Fix integer overflow in transmit_midi_msg()

commit e7c22eeaff8565d9a8374f320238c251ca31480b upstream.

As snd_ff.rx_bytes[] is unsigned int, and NSEC_PER_SEC is 1000000000L,
the second multiplication in

    ff->rx_bytes[port] * 8 * NSEC_PER_SEC / 31250

always overflows on 32-bit platforms, truncating the result.  Fix this
by precalculating "NSEC_PER_SEC / 31250", which is an integer constant.

Note that this assumes ff->rx_bytes[port] <= 16777.

Fixes: 19174295788de77d ("ALSA: fireface: add transaction support")
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20210111130251.361335-2-geert+renesas@glider.be
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agodm: eliminate potential source of excessive kernel log noise
Mike Snitzer [Wed, 6 Jan 2021 23:19:05 +0000 (18:19 -0500)]
dm: eliminate potential source of excessive kernel log noise

commit 0378c625afe80eb3f212adae42cc33c9f6f31abf upstream.

There wasn't ever a real need to log an error in the kernel log for
ioctls issued with insufficient permissions. Simply return an error
and if an admin/user is sufficiently motivated they can enable DM's
dynamic debugging to see an explanation for why the ioctls were
disallowed.

Reported-by: Nir Soffer <nsoffer@redhat.com>
Fixes: e980f62353c6 ("dm: don't allow ioctls to targets that don't map to whole devices")
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoselftests: netfilter: Pass family parameter "-f" to conntrack tool
Chen Yi [Tue, 5 Jan 2021 15:31:20 +0000 (23:31 +0800)]
selftests: netfilter: Pass family parameter "-f" to conntrack tool

commit fab336b42441e0b2eb1d81becedb45fbdf99606e upstream.

Fix nft_conntrack_helper.sh false fail report:

1) Conntrack tool need "-f ipv6" parameter to show out ipv6 traffic items.

2) Sleep 1 second after background nc send packet, to make sure check
is after this statement executed.

False report:
FAIL: ns1-lkjUemYw did not show attached helper ip set via ruleset
PASS: ns1-lkjUemYw connection on port 2121 has ftp helper attached
...

After fix:
PASS: ns1-2hUniwU2 connection on port 2121 has ftp helper attached
PASS: ns2-2hUniwU2 connection on port 2121 has ftp helper attached
...

Fixes: 619ae8e0697a6 ("selftests: netfilter: add test case for conntrack helper assignment")
Signed-off-by: Chen Yi <yiche@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonet: sunrpc: interpret the return value of kstrtou32 correctly
j.nixdorf@avm.de [Tue, 5 Jan 2021 14:17:01 +0000 (15:17 +0100)]
net: sunrpc: interpret the return value of kstrtou32 correctly

commit 86b53fbf08f48d353a86a06aef537e78e82ba721 upstream.

A return value of 0 means success. This is documented in lib/kstrtox.c.

This was found by trying to mount an NFS share from a link-local IPv6
address with the interface specified by its index:

  mount("[fe80::1%1]:/srv/nfs", "/mnt", "nfs", 0, "nolock,addr=fe80::1%1")

Before this commit this failed with EINVAL and also caused the following
message in dmesg:

  [...] NFS: bad IP address specified: addr=fe80::1%1

The syscall using the same address based on the interface name instead
of its index succeeds.

Credits for this patch go to my colleague Christian Speich, who traced
the origin of this bug to this line of code.

Signed-off-by: Johannes Nixdorf <j.nixdorf@avm.de>
Fixes: 00cfaa943ec3 ("replace strict_strto calls")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoiommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()
Lu Baolu [Thu, 31 Dec 2020 00:53:20 +0000 (08:53 +0800)]
iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()

commit 2d6ffc63f12417b979955a5b22ad9a76d2af5de9 upstream.

The VT-d hardware will ignore those Addr bits which have been masked by
the AM field in the PASID-based-IOTLB invalidation descriptor. As the
result, if the starting address in the descriptor is not aligned with
the address mask, some IOTLB caches might not invalidate. Hence people
will see below errors.

[ 1093.704661] dmar_fault: 29 callbacks suppressed
[ 1093.704664] DMAR: DRHD: handling fault status reg 3
[ 1093.712738] DMAR: [DMA Read] Request device [7a:02.0] PASID 2
               fault addr 7f81c968d000 [fault reason 113]
               SM: Present bit in first-level paging entry is clear

Fix this by using aligned address for PASID-based-IOTLB invalidation.

Fixes: 1c4f88b7f1f9 ("iommu/vt-d: Shared virtual address in scalable mode")
Reported-and-tested-by: Guo Kaijie <Kaijie.Guo@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20201231005323.2178523-2-baolu.lu@linux.intel.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoriscv: Trace irq on only interrupt is enabled
Atish Patra [Sat, 19 Dec 2020 00:20:51 +0000 (16:20 -0800)]
riscv: Trace irq on only interrupt is enabled

commit 7cd1af107a92eb63b93a96dc07406dcbc5269436 upstream.

We should call irq trace only if interrupt is going to be enabled during
excecption handling. Otherwise, it results in following warning during
boot with lock debugging enabled.

[    0.000000] ------------[ cut here ]------------
[    0.000000] DEBUG_LOCKS_WARN_ON(early_boot_irqs_disabled)
[    0.000000] WARNING: CPU: 0 PID: 0 at kernel/locking/lockdep.c:4085 lockdep_hardirqs_on_prepare+0x22a/0x22e
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.10.0-00022-ge20097fb37e2-dirty #548
[    0.000000] epc: c005d5d4 ra : c005d5d4 sp : c1c01e80
[    0.000000]  gp : c1d456e0 tp : c1c0a980 t0 : 00000000
[    0.000000]  t1 : ffffffff t2 : 00000000 s0 : c1c01ea0
[    0.000000]  s1 : c100f360 a0 : 0000002d a1 : c00666ee
[    0.000000]  a2 : 00000000 a3 : 00000000 a4 : 00000000
[    0.000000]  a5 : 00000000 a6 : c1c6b390 a7 : 3ffff00e
[    0.000000]  s2 : c2384fe8 s3 : 00000000 s4 : 00000001
[    0.000000]  s5 : c1c0a980 s6 : c1d48000 s7 : c1613b4c
[    0.000000]  s8 : 00000fff s9 : 80000200 s10: c1613b40
[    0.000000]  s11: 00000000 t3 : 00000000 t4 : 00000000
[    0.000000]  t5 : 00000001 t6 : 00000000

Fixes: 3c4697982982 ("riscv:Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT")

Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agomm, slub: consider rest of partial list if acquire_slab() fails
Jann Horn [Tue, 12 Jan 2021 23:49:04 +0000 (15:49 -0800)]
mm, slub: consider rest of partial list if acquire_slab() fails

commit 8ff60eb052eeba95cfb3efe16b08c9199f8121cf upstream.

acquire_slab() fails if there is contention on the freelist of the page
(probably because some other CPU is concurrently freeing an object from
the page).  In that case, it might make sense to look for a different page
(since there might be more remote frees to the page from other CPUs, and
we don't want contention on struct page).

However, the current code accidentally stops looking at the partial list
completely in that case.  Especially on kernels without CONFIG_NUMA set,
this means that get_partial() fails and new_slab_objects() falls back to
new_slab(), allocating new pages.  This could lead to an unnecessary
increase in memory fragmentation.

Link: https://lkml.kernel.org/r/20201228130853.1871516-1-jannh@google.com
Fixes: 7ced37197196 ("slub: Acquire_slab() avoid loop")
Signed-off-by: Jann Horn <jannh@google.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agodrm/i915/gt: Restore clear-residual mitigations for Ivybridge, Baytrail
Chris Wilson [Mon, 11 Jan 2021 22:52:19 +0000 (22:52 +0000)]
drm/i915/gt: Restore clear-residual mitigations for Ivybridge, Baytrail

commit 09aa9e45863e9e25dfbf350bae89fc3c2964482c upstream.

The mitigation is required for all gen7 platforms, now that it does not
cause GPU hangs, restore it for Ivybridge and Baytrail.

Fixes: 47f8253d2b89 ("drm/i915/gen7: Clear all EU/L3 residual contexts")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Prathap Kumar Valsan <prathap.kumar.valsan@intel.com>
Cc: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Cc: Bloomfield Jon <jon.bloomfield@intel.com>
Reviewed-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210111225220.3483-2-chris@chris-wilson.co.uk
(cherry picked from commit 008ead6ef8f588a8c832adfe9db201d9be5fd410)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agodrm/i915/icl: Fix initing the DSI DSC power refcount during HW readout
Imre Deak [Wed, 9 Dec 2020 15:39:52 +0000 (17:39 +0200)]
drm/i915/icl: Fix initing the DSI DSC power refcount during HW readout

commit 2af5268180410b874fc06be91a1b2fbb22b1be0c upstream.

For an enabled DSC during HW readout the corresponding power reference
is taken along the CRTC power domain references in
get_crtc_power_domains(). Remove the incorrect get ref from the DSI
encoder hook.

Fixes: 2b68392e638d ("drm/i915/dsi: add support for DSC")
Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201209153952.3397959-1-imre.deak@intel.com
(cherry picked from commit 3a9ec563a4ff770ae647f6ee539810f1866866c9)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agodrm/i915/dsi: Use unconditional msleep for the panel_on_delay when there is no reset...
Hans de Goede [Wed, 18 Nov 2020 12:40:58 +0000 (13:40 +0100)]
drm/i915/dsi: Use unconditional msleep for the panel_on_delay when there is no reset-deassert MIPI-sequence

commit 00cb645fd7e29bdd20967cd20fa8f77bcdf422f9 upstream.

Commit 25b4620ee822 ("drm/i915/dsi: Skip delays for v3 VBTs in vid-mode")
added an intel_dsi_msleep() helper which skips sleeping if the
MIPI-sequences have a version of 3 or newer and the panel is in vid-mode;
and it moved a bunch of msleep-s over to this new helper.

This was based on my reading of the big comment around line 730 which
starts with "Panel enable/disable sequences from the VBT spec.",
where the "v3 video mode seq" column does not have any wait t# entries.

Given that this code has been used on a lot of different devices without
issues until now, it seems that my interpretation of the spec here is
mostly correct.

But now I have encountered one device, an Acer Aspire Switch 10 E
SW3-016, where the panel will not light up unless we do actually honor the
panel_on_delay after exexuting the MIPI_SEQ_PANEL_ON sequence.

What seems to set this model apart is that it is lacking a
MIPI_SEQ_DEASSERT_RESET sequence, which is where the power-on
delay usually happens.

Fix the panel not lighting up on this model by using an unconditional
msleep(panel_on_delay) instead of intel_dsi_msleep() when there is
no MIPI_SEQ_DEASSERT_RESET sequence.

Fixes: 25b4620ee822 ("drm/i915/dsi: Skip delays for v3 VBTs in vid-mode")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201118124058.26021-1-hdegoede@redhat.com
(cherry picked from commit 6fdb335f1c9c0845b50625de1624d8445c4c4a07)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agodm zoned: select CONFIG_CRC32
Arnd Bergmann [Sun, 3 Jan 2021 21:40:51 +0000 (22:40 +0100)]
dm zoned: select CONFIG_CRC32

commit b690bd546b227c32b860dae985a18bed8aa946fe upstream.

Without crc32 support, this driver fails to link:

arm-linux-gnueabi-ld: drivers/md/dm-zoned-metadata.o: in function `dmz_write_sb':
dm-zoned-metadata.c:(.text+0xe98): undefined reference to `crc32_le'
arm-linux-gnueabi-ld: drivers/md/dm-zoned-metadata.o: in function `dmz_check_sb':
dm-zoned-metadata.c:(.text+0x7978): undefined reference to `crc32_le'

Fixes: 3b1a94c88b79 ("dm zoned: drive-managed zoned block device target")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoumount(2): move the flag validity checks first
Al Viro [Mon, 4 Jan 2021 20:25:34 +0000 (15:25 -0500)]
umount(2): move the flag validity checks first

commit a0a6df9afcaf439a6b4c88a3b522e3d05fdef46f upstream.

Unfortunately, there's userland code that used to rely upon these
checks being done before anything else to check for UMOUNT_NOFOLLOW
support.  That broke in 41525f56e256 ("fs: refactor ksys_umount").
Separate those from the rest of checks and move them to ksys_umount();
unlike everything else in there, this can be sanely done there.

Reported-by: Sargun Dhillon <sargun@sargun.me>
Fixes: 41525f56e256 ("fs: refactor ksys_umount")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoIB/mlx5: Fix error unwinding when set_has_smi_cap fails
Parav Pandit [Wed, 13 Jan 2021 12:17:00 +0000 (14:17 +0200)]
IB/mlx5: Fix error unwinding when set_has_smi_cap fails

commit 2cb091f6293df898b47f4e0f2e54324e2bbaf816 upstream.

When set_has_smi_cap() fails, multiport master cleanup is missed. Fix it
by doing the correct error unwinding goto.

Fixes: a989ea01cb10 ("RDMA/mlx5: Move SMI caps logic")
Link: https://lore.kernel.org/r/20210113121703.559778-3-leon@kernel.org
Signed-off-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoRDMA/mlx5: Fix wrong free of blue flame register on error
Mark Bloch [Wed, 13 Jan 2021 12:17:03 +0000 (14:17 +0200)]
RDMA/mlx5: Fix wrong free of blue flame register on error

commit 1c3aa6bd0b823105c2030af85d92d158e815d669 upstream.

If the allocation of the fast path blue flame register fails, the driver
should free the regular blue flame register allocated a statement above,
not the one that it just failed to allocate.

Fixes: 16c1975f1032 ("IB/mlx5: Create profile infrastructure to add and remove stages")
Link: https://lore.kernel.org/r/20210113121703.559778-6-leon@kernel.org
Reported-by: Hans Petter Selasky <hanss@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agobnxt_en: Improve stats context resource accounting with RDMA driver loaded.
Michael Chan [Mon, 11 Jan 2021 09:26:39 +0000 (04:26 -0500)]
bnxt_en: Improve stats context resource accounting with RDMA driver loaded.

commit 869c4d5eb1e6fbda66aa790c48bdb946d71494a0 upstream.

The function bnxt_get_ulp_stat_ctxs() does not count the stats contexts
used by the RDMA driver correctly when the RDMA driver is freeing the
MSIX vectors.  It assumes that if the RDMA driver is registered, the
additional stats contexts will be needed.  This is not true when the
RDMA driver is about to unregister and frees the MSIX vectors.

This slight error leads to over accouting of the stats contexts needed
after the RDMA driver has unloaded.  This will cause some firmware
warning and error messages in dmesg during subsequent config. changes
or ifdown/ifup.

Fix it by properly accouting for extra stats contexts only if the
RDMA driver is registered and MSIX vectors have been successfully
requested.

Fixes: c027c6b4e91f ("bnxt_en: get rid of num_stat_ctxs variable")
Reviewed-by: Yongping Zhang <yongping.zhang@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoRDMA/usnic: Fix memleak in find_free_vf_and_create_qp_grp
Dinghao Liu [Sat, 26 Dec 2020 07:42:48 +0000 (15:42 +0800)]
RDMA/usnic: Fix memleak in find_free_vf_and_create_qp_grp

commit a306aba9c8d869b1fdfc8ad9237f1ed718ea55e6 upstream.

If usnic_ib_qp_grp_create() fails at the first call, dev_list
will not be freed on error, which leads to memleak.

Fixes: e3cf00d0a87f ("IB/usnic: Add Cisco VIC low-level hardware driver")
Link: https://lore.kernel.org/r/20201226074248.2893-1-dinghao.liu@zju.edu.cn
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoRDMA/restrack: Don't treat as an error allocation ID wrapping
Leon Romanovsky [Wed, 16 Dec 2020 10:07:53 +0000 (12:07 +0200)]
RDMA/restrack: Don't treat as an error allocation ID wrapping

commit 3c638cdb8ecc0442552156e0fed8708dd2c7f35b upstream.

xa_alloc_cyclic() call returns positive number if ID allocation
succeeded but wrapped. It is not an error, so normalize the "ret"
variable to zero as marker of not-an-error.

   drivers/infiniband/core/restrack.c:261 rdma_restrack_add()
   warn: 'ret' can be either negative or positive

Fixes: fd47c2f99f04 ("RDMA/restrack: Convert internal DB from hash to XArray")
Link: https://lore.kernel.org/r/20201216100753.1127638-1-leon@kernel.org
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoext4: fix superblock checksum failure when setting password salt
Jan Kara [Wed, 16 Dec 2020 10:18:43 +0000 (11:18 +0100)]
ext4: fix superblock checksum failure when setting password salt

commit dfd56c2c0c0dbb11be939b804ddc8d5395ab3432 upstream.

When setting password salt in the superblock, we forget to recompute the
superblock checksum so it will not match until the next superblock
modification which recomputes the checksum. Fix it.

CC: Michael Halcrow <mhalcrow@google.com>
Reported-by: Andreas Dilger <adilger@dilger.ca>
Fixes: 9bd8212f981e ("ext4 crypto: add encryption policy and password salt support")
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20201216101844.22917-8-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoscsi: ufs: Fix possible power drain during system suspend
Stanley Chu [Tue, 22 Dec 2020 07:29:04 +0000 (15:29 +0800)]
scsi: ufs: Fix possible power drain during system suspend

commit 1d53864c3617f5235f891ca0fbe9347c4cd35d46 upstream.

Currently if device needs to do flush or BKOP operations, the device VCC
power is kept during runtime-suspend period.

However, if system suspend is happening while device is runtime-suspended,
such power may not be disabled successfully.

The reasons may be,

1. If current PM level is the same as SPM level, device will keep
   runtime-suspended by ufshcd_system_suspend().

2. Flush recheck work may not be scheduled successfully during system
   suspend period. If it can wake up the system, this is also not the
   intention of the recheck work.

To fix this issue, simply runtime-resume the device if the flush is allowed
during runtime suspend period. Flush capability will be disabled while
leaving runtime suspend, and also not be allowed in system suspend period.

Link: https://lore.kernel.org/r/20201222072905.32221-2-stanley.chu@mediatek.com
Fixes: 51dd905bd2f6 ("scsi: ufs: Fix WriteBooster flush during runtime suspend")
Reviewed-by: Chaotian Jing <chaotian.jing@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS: nfs_igrab_and_active must first reference the superblock
Trond Myklebust [Sun, 10 Jan 2021 20:58:08 +0000 (15:58 -0500)]
NFS: nfs_igrab_and_active must first reference the superblock

commit 896567ee7f17a8a736cda8a28cc987228410a2ac upstream.

Before referencing the inode, we must ensure that the superblock can be
referenced. Otherwise, we can end up with iput() calling superblock
operations that are no longer valid or accessible.

Fixes: ea7c38fef0b7 ("NFSv4: Ensure we reference the inode for return-on-close in delegreturn")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS: nfs_delegation_find_inode_server must first reference the superblock
Trond Myklebust [Sun, 10 Jan 2021 20:46:06 +0000 (15:46 -0500)]
NFS: nfs_delegation_find_inode_server must first reference the superblock

commit 113aac6d567bda783af36d08f73bfda47d8e9a40 upstream.

Before referencing the inode, we must ensure that the superblock can be
referenced. Otherwise, we can end up with iput() calling superblock
operations that are no longer valid or accessible.

Fixes: e39d8a186ed0 ("NFSv4: Fix an Oops during delegation callbacks")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS/pNFS: Fix a leak of the layout 'plh_outstanding' counter
Trond Myklebust [Wed, 6 Jan 2021 19:13:22 +0000 (14:13 -0500)]
NFS/pNFS: Fix a leak of the layout 'plh_outstanding' counter

commit cb2856c5971723910a86b7d1d0cf623d6919cbc4 upstream.

If we exit _lgopen_prepare_attached() without setting a layout, we will
currently leak the plh_outstanding counter.

Fixes: 411ae722d10a ("pNFS: Wait for stale layoutget calls to complete in pnfs_update_layout()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS/pNFS: Don't leak DS commits in pnfs_generic_retry_commit()
Trond Myklebust [Wed, 6 Jan 2021 16:54:57 +0000 (11:54 -0500)]
NFS/pNFS: Don't leak DS commits in pnfs_generic_retry_commit()

commit 46c9ea1d4fee4cf1f8cc6001b9c14aae61b3d502 upstream.

We must ensure that we pass a layout segment to nfs_retry_commit() when
we're cleaning up after pnfs_bucket_alloc_ds_commits(). Otherwise,
requests that should be committed to the DS will get committed to the
MDS.
Do so by ensuring that pnfs_bucket_get_committing() always tries to
return a layout segment when it returns a non-empty page list.

Fixes: c84bea59449a ("NFS/pNFS: Simplify bucket layout segment reference counting")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS/pNFS: Don't call pnfs_free_bucket_lseg() before removing the request
Trond Myklebust [Wed, 6 Jan 2021 16:28:30 +0000 (11:28 -0500)]
NFS/pNFS: Don't call pnfs_free_bucket_lseg() before removing the request

commit 1757655d780d9d29bc4b60e708342e94924f7ef3 upstream.

In pnfs_generic_clear_request_commit(), we try calling
pnfs_free_bucket_lseg() before we remove the request from the DS bucket.
That will always fail, since the point is to test for whether or not
that bucket is empty.

Fixes: c84bea59449a ("NFS/pNFS: Simplify bucket layout segment reference counting")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS: Adjust fs_context error logging
Scott Mayhew [Tue, 5 Jan 2021 13:54:32 +0000 (08:54 -0500)]
NFS: Adjust fs_context error logging

commit c98e9daa59a611ff4e163689815f40380c912415 upstream.

Several existing dprink()/dfprintk() calls were converted to use the new
mount API logging macros by commit ce8866f0913f ("NFS: Attach
supplementary error information to fs_context").  If the fs_context was
not created using fsopen() then it will not have had a log buffer
allocated for it, and the new mount API logging macros will wind up
calling printk().

This can result in syslog messages being logged where previously there
were none... most notably "NFS4: Couldn't follow remote path", which can
happen if the client is auto-negotiating a protocol version with an NFS
server that doesn't support the higher v4.x versions.

Convert the nfs_errorf(), nfs_invalf(), and nfs_warnf() macros to check
for the existence of the fs_context's log buffer and call dprintk() if
it doesn't exist.  Add nfs_ferrorf(), nfs_finvalf(), and nfs_warnf(),
which do the same thing but take an NFS debug flag as an argument and
call dfprintk().  Finally, modify the "NFS4: Couldn't follow remote
path" message to use nfs_ferrorf().

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207385
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Fixes: ce8866f0913f ("NFS: Attach supplementary error information to fs_context.")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agopNFS: Stricter ordering of layoutget and layoutreturn
Trond Myklebust [Tue, 5 Jan 2021 11:43:45 +0000 (06:43 -0500)]
pNFS: Stricter ordering of layoutget and layoutreturn

commit 2c8d5fc37fe2384a9bdb6965443ab9224d46f704 upstream.

If a layout return is in progress, we should wait for it to complete,
in case the layout segment we are picking up gets returned too.

Fixes: 30cb3ee299cb ("pNFS: Handle NFS4ERR_OLD_STATEID on layoutreturn by bumping the state seqid")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agopNFS: Mark layout for return if return-on-close was not sent
Trond Myklebust [Mon, 4 Jan 2021 18:35:46 +0000 (13:35 -0500)]
pNFS: Mark layout for return if return-on-close was not sent

commit 67bbceedc9bb8ad48993a8bd6486054756d711f4 upstream.

If the layout return-on-close failed because the layoutreturn was never
sent, then we should mark the layout for return again.

Fixes: 9c47b18cf722 ("pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agopNFS: We want return-on-close to complete when evicting the inode
Trond Myklebust [Mon, 4 Jan 2021 18:18:03 +0000 (13:18 -0500)]
pNFS: We want return-on-close to complete when evicting the inode

commit 078000d02d57f02dde61de4901f289672e98c8bc upstream.

If the inode is being evicted, it should be safe to run return-on-close,
so we should do it to ensure we don't inadvertently leak layout segments.

Fixes: 1c5bd76d17cc ("pNFS: Enable layoutreturn operation for return-on-close")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoNFS4: Fix use-after-free in trace_event_raw_event_nfs4_set_lock
Dave Wysochanski [Fri, 11 Dec 2020 10:12:51 +0000 (05:12 -0500)]
NFS4: Fix use-after-free in trace_event_raw_event_nfs4_set_lock

commit 3d1a90ab0ed93362ec8ac85cf291243c87260c21 upstream.

It is only safe to call the tracepoint before rpc_put_task() because
'data' is freed inside nfs4_lock_release (rpc_release).

Fixes: 48c9579a1afe ("Adding stateid information to tracepoints")
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonvme-tcp: Fix warning with CONFIG_DEBUG_PREEMPT
Sagi Grimberg [Wed, 13 Jan 2021 22:03:04 +0000 (14:03 -0800)]
nvme-tcp: Fix warning with CONFIG_DEBUG_PREEMPT

commit ada831772188192243f9ea437c46e37e97a5975d upstream.

We shouldn't call smp_processor_id() in a preemptible
context, but this is advisory at best, so instead
call __smp_processor_id().

Fixes: db5ad6b7f8cd ("nvme-tcp: try to send request in queue_rq context")
Reported-by: Or Gerlitz <gerlitz.or@gmail.com>
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonvme-tcp: fix possible data corruption with bio merges
Sagi Grimberg [Wed, 13 Jan 2021 21:56:57 +0000 (13:56 -0800)]
nvme-tcp: fix possible data corruption with bio merges

commit ca1ff67d0fb14f39cf0cc5102b1fbcc3b14f6fb9 upstream.

When a bio merges, we can get a request that spans multiple
bios, and the overall request payload size is the sum of
all bios. When we calculate how much we need to send
from the existing bio (and bvec), we did not take into
account the iov_iter byte count cap.

Since multipage bvecs support, bvecs can split in the middle
which means that when we account for the last bvec send we
should also take the iov_iter byte count cap as it might be
lower than the last bvec size.

Reported-by: Hao Wang <pkuwangh@gmail.com>
Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
Tested-by: Hao Wang <pkuwangh@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonvme: don't intialize hwmon for discovery controllers
Sagi Grimberg [Thu, 14 Jan 2021 00:00:22 +0000 (16:00 -0800)]
nvme: don't intialize hwmon for discovery controllers

commit 5ab25a32cd90ce561ac28b9302766e565d61304c upstream.

Discovery controllers usually don't support smart log page command.
So when we connect to the discovery controller we see this warning:
nvme nvme0: Failed to read smart log (error 24577)
nvme nvme0: new ctrl: NQN "nqn.2014-08.org.nvmexpress.discovery", addr 192.168.123.1:8009
nvme nvme0: Removing ctrl: NQN "nqn.2014-08.org.nvmexpress.discovery"

Introduce a new helper to understand if the controller is a discovery
controller and use this helper to skip nvme_init_hwmon (also use it in
other places that we check if the controller is a discovery controller).

Fixes: 400b6a7b13a3 ("nvme: Add hardware monitoring support")
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agonvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY
Israel Rukshin [Sun, 10 Jan 2021 12:09:05 +0000 (14:09 +0200)]
nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY

commit 7a84665619bb5da8c8b6517157875a1fd7632014 upstream.

When setting port traddr to INADDR_ANY, the listening cm_id->device
is NULL. The associate IB device is known only when a connect request
event arrives, so checking T10-PI device capability should be done
at this stage.

Fixes: b09160c3996c ("nvmet-rdma: add metadata/T10-PI support")
Signed-off-by: Israel Rukshin <israelr@nvidia.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>