Re: [GIT PULL] Networking

2020-10-15 Thread patchwork-bot+netdevbpf
Hello:

This pull request was applied to netdev/net.git (refs/heads/master):

On Thu, 15 Oct 2020 14:13:02 -0700 you wrote:
> Hi!
> 
> The following changes since commit 3fdd47c3b40ac48e6e6e5904cf24d12e6e073a96:
> 
>   Merge tag 'for_linus' of 
> git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost (2020-10-08 14:25:46 
> -0700)
> 
> are available in the Git repository at:
> 
> [...]

Here is the summary with links:
  - [GIT,PULL] Networking
https://git.kernel.org/netdev/net/c/9ff9b0d392ea

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




linux-next: Tree for Oct 16

2020-10-15 Thread Stephen Rothwell
Hi all,

Since the merge window is open, please do not add any v5.11 material to
your linux-next included branches until after v5.10-rc1 has been released.

News: there will be no linux-next releases next Monday or Tuesday.

Changes since 20201015:

Undropped tree: btrfs

The wireless-drivers tree gained a conflict against the net tree.

The djw-vfs tree gained a conflict against Linus' tree.

The amdgpu tree gained a conflict against Linus' tree.

The rpmsg tree still had its build failure.

The akpm-current tree gained a semantic conflict against the block tree.

Non-merge commits (relative to Linus' tree): 6624
 6894 files changed, 518038 insertions(+), 123774 deletions(-)



I have created today's linux-next tree at
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
(patches at http://www.kernel.org/pub/linux/kernel/next/ ).  If you
are tracking the linux-next tree using git, you should not use "git pull"
to do so as that will try to merge the new linux-next release with the
old one.  You should use "git fetch" and checkout or reset to the new
master.

You can see which trees have been included by looking in the Next/Trees
file in the source.  There are also quilt-import.log and merge.log
files in the Next directory.  Between each merge, the tree was built
with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a
multi_v7_defconfig for arm and a native build of tools/perf. After
the final fixups (if any), I do an x86_64 modules_install followed by
builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit),
ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc
and sparc64 defconfig and htmldocs. And finally, a simple boot test
of the powerpc pseries_le_defconfig kernel in qemu (with and without
kvm enabled).

Below is a summary of the state of the merge.

I am currently merging 329 trees (counting Linus' and 86 trees of bug
fix patches pending for the current merge release).

Stats about the size of the tree over time can be seen at
http://neuling.org/linux-next-size.html .

Status of my local build tests will be at
http://kisskb.ellerman.id.au/linux-next .  If maintainers want to give
advice about cross compilers/configs that work, we are always open to add
more builds.

Thanks to Randy Dunlap for doing many randconfig builds.  And to Paul
Gortmaker for triage and bug fixes.

-- 
Cheers,
Stephen Rothwell

$ git checkout master
$ git reset --hard stable
Merging origin/master (c48b75b7271d Merge tag 'sound-5.10-rc1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound)
Merging fixes/fixes (9123e3a74ec7 Linux 5.9-rc1)
Merging kbuild-current/fixes (e30d694c3381 Documentation/llvm: Fix clang target 
examples)
Merging arc-current/for-curr (6364d1b41cc3 arc: include/asm: fix typos of 
"themselves")
Merging arm-current/fixes (9123e3a74ec7 Linux 5.9-rc1)
Merging arm64-fixes/for-next/fixes (39e4716caa59 crypto: arm64: Use x16 with 
indirect branch to bti_c)
Merging arm-soc-fixes/arm/fixes (6869f774b1cd Merge tag 
'omap-for-v5.9/fixes-rc7' of 
git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into arm/fixes)
Merging uniphier-fixes/fixes (48778464bb7d Linux 5.8-rc2)
Merging drivers-memory-fixes/fixes (7ff3a2a626f7 memory: jz4780_nemc: Fix an 
error pointer vs NULL check in probe())
Merging m68k-current/for-linus (50c5feeea0af ide/macide: Convert Mac IDE driver 
to platform driver)
Merging powerpc-fixes/fixes (0460534b532e powerpc/papr_scm: Limit the 
readability of 'perf_stats' sysfs attribute)
Merging s390-fixes/fixes (549738f15da0 Linux 5.9-rc8)
Merging sparc/master (0a95a6d1a4cd sparc: use for_each_child_of_node() macro)
Merging fscrypt-current/for-stable (2b4eae95c736 fscrypt: don't evict dirty 
inodes after removing key)
Merging net/master (2ecbc1f68448 Revert "bpfilter: Fix build error with 
CONFIG_BPFILTER_UMH")
Merging bpf/master (28802e7c0c99 net: usb: qmi_wwan: add Cellient MPL200 card)
Merging ipsec/master (7fe94612dd4c xfrm: interface: fix the priorities for ipip 
and ipv6 tunnels)
Merging netfilter/master (15f0d2922dce Merge branch 'ibmveth-gso-fix')
Merging ipvs/master (48d072c4e8cd selftests: netfilter: add time counter check)
Merging wireless-drivers/master (df41c19abbea drivers/net/wan/hdlc_fr: Move the 
skb_headroom check out of fr_hard_header)
CONFLICT (content): Merge conflict in tools/testing/selftests/net/Makefile
CONFLICT (content): Merge conflict in net/mptcp/protocol.h
Merging mac80211/master (3fdd47c3b40a Merge tag 'for_linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost)
Merging rdma-fixes/for-rc (a1b8638ba132 Linux 5.9-rc7)
Merging sound-current/for-linus (ce1558c285f9 ALSA: hda/hdmi: fix incorrect 
locking in hdmi_pcm_close)
Merging sound-asoc-fixes/for-linus (2ebefde9de62 Merge remote-tracking branch 
'asoc/for-5.10' into asoc-linus)
Merging regmap-fixes/for-linus (549738f15da

[RFC] PCI: allow sysfs file owner to read the config space with CAP_SYS_RAWIO

2020-10-15 Thread Allen Pais
From: Allen Pais 

 Access to pci config space is explictly checked with CAP_SYS_ADMIN
in order to read configuration space past the frist 64B.

 Since the path is only for reading, could we use CAP_SYS_RAWIO?
This patch contains a simpler fix, I would love to hear from the
Maintainers on the approach.

 The other approach that I considered was to introduce and API
which would check for multiple capabilities, something similar to
perfmon_capable()/bpf_capable(). But I could not find more users
for the API and hence dropped it.

 The problem I am trying to solve is to avoid handing out
CAP_SYS_ADMIN for extended reads of the PCI config space.

Signed-off-by: Allen Pais 
---
 drivers/pci/pci-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6d78df981d41..6574c0203475 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -666,7 +666,8 @@ static ssize_t pci_read_config(struct file *filp, struct 
kobject *kobj,
u8 *data = (u8 *) buf;
 
/* Several chips lock up trying to read undefined config space */
-   if (file_ns_capable(filp, _user_ns, CAP_SYS_ADMIN))
+   if (file_ns_capable(filp, _user_ns, CAP_SYS_ADMIN) ||
+   file_ns_capable(filp, _user_ns, CAP_SYS_RAWIO))
size = dev->cfg_size;
else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
size = 128;
-- 
2.25.1



Re: WARNING: at drivers/opp/core.c:678 dev_pm_opp_set_rate+0x4cc/0x5d4 - on arm x15

2020-10-15 Thread Viresh Kumar
+Dave,

On 15-10-20, 15:26, Naresh Kamboju wrote:
> The arm x15 boot failed on Linus 's mainline version 5.9.0.

Don't mention the version as this doesn't give the right information.
You tested it over 5.9 + 5.10-rc1 material.

> I have listed the latest commits on drivers/opp/ .
> 
> metadata:
>   git branch: master
>   git repo: https://gitlab.com/Linaro/lkft/mirrors/torvalds/linux-mainline
>   git commit: 3e4fb4346c781068610d03c12b16c0cfb0fd24a3
>   git describe: v5.9-4105-g3e4fb4346c78
>   make_kernelversion: 5.9.0
>   kernel-config:
> https://builds.tuxbuild.com/2BB2g61t29VaadVLXEl4cQ/kernel.config
> 
> 
> [ cut here ]
> [   13.530971] sdhci-omap 4809c000.mmc: Got CD GPIO
> [   13.535647] WARNING: CPU: 0 PID: 137 at drivers/opp/core.c:678
> dev_pm_opp_set_rate+0x4cc/0x5d4

Looks like the stuff from drivers/opp/ti-opp-supply.c supply didn't
work as expected.

One of the major changes came with these patches:

dc279ac6e5b4 cpufreq: dt: Refactor initialization to handle probe deferral 
properly
dd461cd9183f opp: Allow dev_pm_opp_get_opp_table() to return -EPROBE_DEFER

And that's where I think it may have gone wrong.

Dave: Will you (or someone else from TI) can have a look at it as well
?

-- 
viresh


[rcu:dev.2020.10.14a] BUILD SUCCESS 87fb0cc38d2583d4084e2ddaa937625fd2d876e0

2020-10-15 Thread kernel test robot
-20201014
x86_64   randconfig-a013-20201014
x86_64   randconfig-a014-20201014
x86_64   randconfig-a011-20201014
i386 randconfig-a016-20201014
i386 randconfig-a013-20201014
i386 randconfig-a015-20201014
i386 randconfig-a011-20201014
i386 randconfig-a012-20201014
i386 randconfig-a014-20201014
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
x86_64   rhel
x86_64   allyesconfig
x86_64rhel-7.6-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  kexec

clang tested configs:
x86_64   randconfig-a004-20201014
x86_64   randconfig-a002-20201014
x86_64   randconfig-a006-20201014
x86_64   randconfig-a001-20201014
x86_64   randconfig-a005-20201014
x86_64   randconfig-a003-20201014
x86_64   randconfig-a016-20201015
x86_64   randconfig-a012-20201015
x86_64   randconfig-a015-20201015
x86_64   randconfig-a013-20201015
x86_64   randconfig-a014-20201015
x86_64   randconfig-a011-20201015

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: autofs crash with latest linux-next

2020-10-15 Thread Sven Schnelle
Kees Cook  writes:

> On Wed, Oct 14, 2020 at 09:15:47AM +0200, Krzysztof Kozlowski wrote:
>> I hit this since few days as well. Although the bisect points to the
>> merge, the issue looks like a result of mentioned commit 4d03e3cc5982
>> ("fs: don't allow kernel reads and writes without iter ops").
>> 
>> The __kernel_read() last argument 'pos' can be NULL and it is
>> dereferenced here (added by the commit):
>> 
>>  525 ssize_t __kernel_write(struct file *file, const void *buf, size_t 
>> count, loff_t *pos)
>> ...
>>  547 kiocb.ki_pos = *pos;
>>  548 iov_iter_kvec(, WRITE, , 1, iov.iov_len);
>> 
>> 
>> The __kernel_read() is called with NULL in fs/autofs/waitq.c:
>> 
>>  45 static int autofs_write(struct autofs_sb_info *sbi,
>>  46 struct file *file, const void *addr, int bytes)
>> 
>> ...
>>  54 mutex_lock(>pipe_mutex);
>>  55 while (bytes) {
>>  56 wr = __kernel_write(file, data, bytes, NULL);
>
> I think the thread here is the same thing, but you've found it in
> autofs...
> https://lore.kernel.org/lkml/CAHk-=wgj=mken-efv5tkwjnehplg0dybq+r5zyguc4weunq...@mail.gmail.com/

Indeed. Thanks, missed that.

Sven


[PATCH 4/6] can: flexcan: rename macro FLEXCAN_QUIRK_SETUP_STOP_MODE -> FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR

2020-10-15 Thread Joakim Zhang
This patch intends to rename FLEXCAN_QUIRK_SETUP_STOP_MODE quirk
to FLEXCAN_QUIRK_SETUP_STOP_MODE_GRP for non-scu SoCs, coming patch will
add quirk for scu SoCs.

For non-scu SoCs, setup stop mode with GPR register.
For scu SoCs, setup stop mode with SCU firmware.

Signed-off-by: Joakim Zhang 
---
 drivers/net/can/flexcan.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 4d594e977497..e708e7bf28db 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -236,8 +236,8 @@
 #define FLEXCAN_QUIRK_BROKEN_PERR_STATE BIT(6)
 /* default to BE register access */
 #define FLEXCAN_QUIRK_DEFAULT_BIG_ENDIAN BIT(7)
-/* Setup stop mode to support wakeup */
-#define FLEXCAN_QUIRK_SETUP_STOP_MODE BIT(8)
+/* Setup stop mode with GPR to support wakeup */
+#define FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR BIT(8)
 /* Support CAN-FD mode */
 #define FLEXCAN_QUIRK_SUPPORT_FD BIT(9)
 /* support memory detection and correction */
@@ -381,7 +381,7 @@ static const struct flexcan_devtype_data 
fsl_imx28_devtype_data = {
 static const struct flexcan_devtype_data fsl_imx6q_devtype_data = {
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | 
FLEXCAN_QUIRK_BROKEN_PERR_STATE |
-   FLEXCAN_QUIRK_SETUP_STOP_MODE,
+   FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR,
 };
 
 static const struct flexcan_devtype_data fsl_imx8qm_devtype_data = {
@@ -393,7 +393,7 @@ static const struct flexcan_devtype_data 
fsl_imx8qm_devtype_data = {
 static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
-   FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SETUP_STOP_MODE 
|
+   FLEXCAN_QUIRK_BROKEN_PERR_STATE | 
FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR |
FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SUPPORT_ECC,
 };
 
@@ -2043,7 +2043,7 @@ static int flexcan_probe(struct platform_device *pdev)
of_can_transceiver(dev);
devm_can_led_init(dev);
 
-   if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE) {
+   if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR) {
err = flexcan_setup_stop_mode(pdev);
if (err)
dev_dbg(>dev, "failed to setup stop-mode\n");
-- 
2.17.1



[PATCH 6/6] can: flexcan: fix ECC function on LS1021A/LX2160A

2020-10-15 Thread Joakim Zhang
After double check with Layerscape CAN owner (Pankaj Bansal), confirm
that LS1021A doesn't support ECC, and LX2160A indeed supports ECC.

For SoCs with ECC supported, even use FLEXCAN_QUIRK_DISABLE_MECR quirk to
disable non-correctable errors interrupt and freeze mode, had better use
FLEXCAN_QUIRK_SUPPORT_ECC quirk to initialize all memory.

Signed-off-by: Joakim Zhang 
---
 drivers/net/can/flexcan.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index a55ea8f27f7c..7b0eb608fc9d 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -219,7 +219,7 @@
  *   MX8MP FlexCAN3  03.00.17.01yes   yesno  yes   yes 
 yes
  *   VF610 FlexCAN3  ?   no   yesno  yes   
yes?  no
  * LS1021A FlexCAN2  03.00.04.00 no   yesno   no   yes 
  no
- * LX2160A FlexCAN3  03.00.23.00 no   yesno   no   yes 
 yes
+ * LX2160A FlexCAN3  03.00.23.00 no   yesno  yes   yes 
 yes
  *
  * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
  */
@@ -408,19 +408,19 @@ static struct flexcan_devtype_data 
fsl_imx8mp_devtype_data = {
 static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
-   FLEXCAN_QUIRK_BROKEN_PERR_STATE,
+   FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SUPPORT_ECC,
 };
 
 static const struct flexcan_devtype_data fsl_ls1021a_r2_devtype_data = {
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
-   FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_BROKEN_PERR_STATE |
-   FLEXCAN_QUIRK_USE_OFF_TIMESTAMP,
+   FLEXCAN_QUIRK_BROKEN_PERR_STATE | 
FLEXCAN_QUIRK_USE_OFF_TIMESTAMP,
 };
 
 static const struct flexcan_devtype_data fsl_lx2160a_r1_devtype_data = {
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_BROKEN_PERR_STATE |
-   FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_SUPPORT_FD,
+   FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_SUPPORT_FD |
+   FLEXCAN_QUIRK_SUPPORT_ECC,
 };
 
 static const struct can_bittiming_const flexcan_bittiming_const = {
-- 
2.17.1



[PATCH 5/6] can: flexcan: add CAN wakeup function for i.MX8QM

2020-10-15 Thread Joakim Zhang
The System Controller Firmware (SCFW) is a low-level system function
which runs on a dedicated Cortex-M core to provide power, clock, and
resource management. It exists on some i.MX8 processors. e.g. i.MX8QM
(QM, QP), and i.MX8QX (QXP, DX). SCU driver manages the IPC interface
between host CPU and the SCU firmware running on M4.

For i.MX8QM, stop mode request is controlled by System Controller Unit(SCU)
firmware, this patch introduces FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW quirk
for this function.

Signed-off-by: Joakim Zhang 
---
 drivers/net/can/flexcan.c | 125 --
 1 file changed, 107 insertions(+), 18 deletions(-)

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index e708e7bf28db..a55ea8f27f7c 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -9,6 +9,7 @@
 //
 // Based on code originally by Andrey Volkov 
 
+#include 
 #include 
 #include 
 #include 
@@ -17,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -242,6 +244,8 @@
 #define FLEXCAN_QUIRK_SUPPORT_FD BIT(9)
 /* support memory detection and correction */
 #define FLEXCAN_QUIRK_SUPPORT_ECC BIT(10)
+/* Setup stop mode with SCU firmware to support wakeup */
+#define FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW BIT(11)
 
 /* Structure of the message buffer */
 struct flexcan_mb {
@@ -347,6 +351,7 @@ struct flexcan_priv {
u8 mb_count;
u8 mb_size;
u8 clk_src; /* clock source of CAN Protocol Engine */
+   u8 can_idx;
 
u64 rx_mask;
u64 tx_mask;
@@ -358,6 +363,9 @@ struct flexcan_priv {
struct regulator *reg_xceiver;
struct flexcan_stop_mode stm;
 
+   /* IPC handle when setup stop mode by System Controller firmware(scfw) 
*/
+   struct imx_sc_ipc *sc_ipc_handle;
+
/* Read and Write APIs */
u32 (*read)(void __iomem *addr);
void (*write)(u32 val, void __iomem *addr);
@@ -387,7 +395,7 @@ static const struct flexcan_devtype_data 
fsl_imx6q_devtype_data = {
 static const struct flexcan_devtype_data fsl_imx8qm_devtype_data = {
.quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | 
FLEXCAN_QUIRK_BROKEN_PERR_STATE |
-   FLEXCAN_QUIRK_SUPPORT_FD,
+   FLEXCAN_QUIRK_SUPPORT_FD | FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW,
 };
 
 static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
@@ -546,18 +554,46 @@ static void flexcan_enable_wakeup_irq(struct flexcan_priv 
*priv, bool enable)
priv->write(reg_mcr, >mcr);
 }
 
+static int flexcan_stop_mode_enable_scfw(struct flexcan_priv *priv, bool 
enabled)
+{
+   u8 idx = priv->can_idx;
+   u32 rsrc_id, val;
+
+   if (idx == 0)
+   rsrc_id = IMX_SC_R_CAN_0;
+   else if (idx == 1)
+   rsrc_id = IMX_SC_R_CAN_1;
+   else
+   rsrc_id = IMX_SC_R_CAN_2;
+
+   if (enabled)
+   val = 1;
+   else
+   val = 0;
+
+   /* stop mode request via scu firmware */
+   return imx_sc_misc_set_control(priv->sc_ipc_handle, rsrc_id, 
IMX_SC_C_IPG_STOP, val);
+}
+
 static inline int flexcan_enter_stop_mode(struct flexcan_priv *priv)
 {
struct flexcan_regs __iomem *regs = priv->regs;
u32 reg_mcr;
+   int ret;
 
reg_mcr = priv->read(>mcr);
reg_mcr |= FLEXCAN_MCR_SLF_WAK;
priv->write(reg_mcr, >mcr);
 
/* enable stop request */
-   regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
-  1 << priv->stm.req_bit, 1 << priv->stm.req_bit);
+   if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW) {
+   ret = flexcan_stop_mode_enable_scfw(priv, true);
+   if (ret < 0)
+   return ret;
+   } else {
+   regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
+  1 << priv->stm.req_bit, 1 << 
priv->stm.req_bit);
+   }
 
return flexcan_low_power_enter_ack(priv);
 }
@@ -566,10 +602,17 @@ static inline int flexcan_exit_stop_mode(struct 
flexcan_priv *priv)
 {
struct flexcan_regs __iomem *regs = priv->regs;
u32 reg_mcr;
+   int ret;
 
/* remove stop request */
-   regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
-  1 << priv->stm.req_bit, 0);
+   if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SETUP_STOP_MODE_SCFW) {
+   ret = flexcan_stop_mode_enable_scfw(priv, false);
+   if (ret < 0)
+   return ret;
+   } else {
+   regmap_update_bits(priv->stm.gpr, priv->stm.req_gpr,
+  1 << priv->stm.req_bit, 0);
+   }
 
reg_mcr = priv->read(>mcr);
reg_mcr &= ~FLEXCAN_MCR_SLF_WAK;
@@ -1838,7 +1881,7 @@ static void unregister_flexcandev(struct net_device *dev)
unregister_candev(dev);
 }
 
-static int 

Re: [PATCH] power: suspend: Add suspend timeout handler

2020-10-15 Thread Greg Kroah-Hartman
On Fri, Oct 16, 2020 at 11:51:09AM +0800, Joseph Jang wrote:
> From: josephjang 

Please use your name as spelled out like you did above in the email
header.

> 
> Add suspend timeout handler to prevent device stuck during suspend/
> resume process. Suspend timeout handler will dump disk sleep task
> at first round timeout and trigger kernel panic at second round timeout.
> The default timer for each round is 30 seconds.
> 
> Note: Can use following command to simulate suspend hang for testing.
> adb shell echo 1 > /sys/power/pm_hang
> adb shell echo mem > /sys/power/state
> Signed-off-by: josephjang 

Need a blank line before the signed-off-by: and again, spell your name
the same way.



> ---
>  include/linux/console.h |   1 +
>  kernel/power/Kconfig|   9 +++
>  kernel/power/main.c |  66 
>  kernel/power/suspend.c  | 162 
>  kernel/printk/printk.c  |   5 ++
>  5 files changed, 243 insertions(+)
> 
> diff --git a/include/linux/console.h b/include/linux/console.h
> index 0670d3491e0e..ac468c602c0b 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -192,6 +192,7 @@ static inline void console_sysfs_notify(void)
>  { }
>  #endif
>  extern bool console_suspend_enabled;
> +extern int is_console_suspended(void);

For global functions, how about:
bool console_is_suspended(void);
?

>  
>  /* Suspend and resume console messages over PM events */
>  extern void suspend_console(void);
> diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
> index a7320f07689d..52b7a181b6d8 100644
> --- a/kernel/power/Kconfig
> +++ b/kernel/power/Kconfig
> @@ -207,6 +207,15 @@ config PM_SLEEP_DEBUG
>   def_bool y
>   depends on PM_DEBUG && PM_SLEEP
>  
> +config PM_SLEEP_MONITOR
> + bool "Linux kernel suspend/resume process monitor"
> + depends on PM_SLEEP
> + help
> + This option will enable suspend/resume monitor to prevent device
> + stuck during suspend/resume process. Suspend timeout handler will
> + dump disk sleep task at first round timeout and trigger kernel panic
> + at second round timeout. The default timer for each round is 30 seconds.

Ouch, are you sure you want to panic?


> +
>  config DPM_WATCHDOG
>   bool "Device suspend/resume watchdog"
>   depends on PM_DEBUG && PSTORE && EXPERT
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index 40f86ec4ab30..f25b8a47583e 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -575,6 +575,69 @@ void __pm_pr_dbg(bool defer, const char *fmt, ...)
>  static inline void pm_print_times_init(void) {}
>  #endif /* CONFIG_PM_SLEEP_DEBUG */
>  
> +#ifdef CONFIG_PM_SLEEP_MONITOR
> +/* If set, devices will stuck at suspend for verification */
> +static bool pm_hang_enabled;
> +
> +static int pm_notify_test(struct notifier_block *nb,
> +  unsigned long mode, void *_unused)
> +{
> + pr_info("Jump into infinite loop now\n");

Why do you have debugging code still enabled?

> +
> + /* Suspend thread stuck at a loop forever */
> + for (;;)
> + ;
> +

Don't busy spin, that will burn power.


> + pr_info("Fail to stuck at loop\n");

And how can this happen?

> +
> + return 0;
> +}
> +
> +static struct notifier_block pm_notify_nb = {
> + .notifier_call = pm_notify_test,
> +};
> +
> +static ssize_t pm_hang_show(struct kobject *kobj, struct kobj_attribute 
> *attr,
> +  char *buf)
> +{
> + return snprintf(buf, 10, "%d\n", pm_hang_enabled);
> +}
> +
> +static ssize_t pm_hang_store(struct kobject *kobj, struct kobj_attribute 
> *attr,
> +   const char *buf, size_t n)
> +{
> + unsigned long val;
> + int result;
> +
> + if (kstrtoul(buf, 10, ))
> + return -EINVAL;
> +
> + if (val > 1)
> + return -EINVAL;
> +
> + pm_hang_enabled = !!val;
> +
> + if (pm_hang_enabled == true) {
> +
> + result = register_pm_notifier(_notify_nb);
> + if (result)
> + pr_warn("Can not register suspend notifier, return 
> %d\n",
> + result);
> +
> + } else {
> +
> + result = unregister_pm_notifier(_notify_nb);
> + if (result)
> + pr_warn("Can not unregister suspend notifier, return 
> %d\n",
> + result);
> + }
> +
> + return n;
> +}
> +
> +power_attr(pm_hang);
> +#endif
> +
>  struct kobject *power_kobj;
>  
>  /**
> @@ -909,6 +972,9 @@ static struct attribute * g[] = {
>   _wakeup_irq_attr.attr,
>   _debug_messages_attr.attr,
>  #endif
> +#ifdef CONFIG_PM_SLEEP_MONITOR
> + _hang_attr.attr,

You added a sysfs file, but no Documentation/ABI/ update?  That's not
ok.


> +#endif
>  #endif
>  #ifdef CONFIG_FREEZER
>   _freeze_timeout_attr.attr,
> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
> index 

[PATCH 2/6] dt-bindings: can: flexcan: fix fsl,clk-source property

2020-10-15 Thread Joakim Zhang
Correct fsl,clk-source example since flexcan driver uses "of_property_read_u8"
to get this property.

Fixes: 9d733992772d ("dt-bindings: can: flexcan: add PE clock source property 
to device tree")
Signed-off-by: Joakim Zhang 
---
 Documentation/devicetree/bindings/net/can/fsl-flexcan.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt 
b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
index e10b6eb955e1..6af67f5e581c 100644
--- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
+++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
@@ -53,5 +53,5 @@ Example:
interrupts = <48 0x2>;
interrupt-parent = <>;
clock-frequency = <2>; // filled in by bootloader
-   fsl,clk-source = <0>; // select clock source 0 for PE
+   fsl,clk-source = /bits/ 8 <0>; // select clock source 0 for PE
};
-- 
2.17.1



[PATCH 3/6] dt-bindings: can: flexcan: add fsl,can-index property to indicate a resource

2020-10-15 Thread Joakim Zhang
For SoCs with SCU support, need setup stop mode via SCU firmware,
so this property can help indicate a resource.

Signed-off-by: Joakim Zhang 
---
 Documentation/devicetree/bindings/net/can/fsl-flexcan.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt 
b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
index 6af67f5e581c..839c0c0064a2 100644
--- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
+++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
@@ -43,6 +43,10 @@ Optional properties:
  0: clock source 0 (oscillator clock)
  1: clock source 1 (peripheral clock)
 
+- fsl,can-index: The index of CAN instance.
+ For SoCs with SCU support, need setup stop mode via SCU 
firmware,
+ so this property can help indicate a resource.
+
 - wakeup-source: enable CAN remote wakeup
 
 Example:
@@ -54,4 +58,5 @@ Example:
interrupt-parent = <>;
clock-frequency = <2>; // filled in by bootloader
fsl,clk-source = /bits/ 8 <0>; // select clock source 0 for PE
+   fsl,can-index = /bits/ 8 <1>; // the second CAN instance
};
-- 
2.17.1



[PATCH 1/6] firmware: imx: always export SCU symbols

2020-10-15 Thread Joakim Zhang
From: Liu Ying 

Always export SCU symbols for both SCU SoCs and non-SCU SoCs to avoid
build error.

Signed-off-by: Liu Ying 
Signed-off-by: Peng Fan 
Signed-off-by: Joakim Zhang 
---
 include/linux/firmware/imx/ipc.h  | 15 +++
 include/linux/firmware/imx/svc/misc.h | 23 +++
 2 files changed, 38 insertions(+)

diff --git a/include/linux/firmware/imx/ipc.h b/include/linux/firmware/imx/ipc.h
index 891057434858..300fa253fc30 100644
--- a/include/linux/firmware/imx/ipc.h
+++ b/include/linux/firmware/imx/ipc.h
@@ -34,6 +34,7 @@ struct imx_sc_rpc_msg {
uint8_t func;
 };
 
+#if IS_ENABLED(CONFIG_IMX_SCU)
 /*
  * This is an function to send an RPC message over an IPC channel.
  * It is called by client-side SCFW API function shims.
@@ -55,4 +56,18 @@ int imx_scu_call_rpc(struct imx_sc_ipc *ipc, void *msg, bool 
have_resp);
  * @return Returns an error code (0 = success, failed if < 0)
  */
 int imx_scu_get_handle(struct imx_sc_ipc **ipc);
+
+#else
+static inline int
+imx_scu_call_rpc(struct imx_sc_ipc *ipc, void *msg, bool have_resp)
+{
+   return -EIO;
+}
+
+static inline int imx_scu_get_handle(struct imx_sc_ipc **ipc)
+{
+   return -EIO;
+}
+#endif
+
 #endif /* _SC_IPC_H */
diff --git a/include/linux/firmware/imx/svc/misc.h 
b/include/linux/firmware/imx/svc/misc.h
index 031dd4d3c766..d255048f17de 100644
--- a/include/linux/firmware/imx/svc/misc.h
+++ b/include/linux/firmware/imx/svc/misc.h
@@ -46,6 +46,7 @@ enum imx_misc_func {
  * Control Functions
  */
 
+#if IS_ENABLED(CONFIG_IMX_SCU)
 int imx_sc_misc_set_control(struct imx_sc_ipc *ipc, u32 resource,
u8 ctrl, u32 val);
 
@@ -55,4 +56,26 @@ int imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 
resource,
 int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
bool enable, u64 phys_addr);
 
+#else
+static inline int
+imx_sc_misc_set_control(struct imx_sc_ipc *ipc, u32 resource,
+   u8 ctrl, u32 val)
+{
+   return -EIO;
+}
+
+static inline int
+imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 resource,
+   u8 ctrl, u32 *val)
+{
+   return -EIO;
+}
+
+static inline int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
+ bool enable, u64 phys_addr)
+{
+   return -EIO;
+}
+#endif
+
 #endif /* _SC_MISC_API_H */
-- 
2.17.1



[PATCH 0/6] can: flexcan: add stop mode support for i.MX8QM

2020-10-15 Thread Joakim Zhang
The first patch from Liu Ying aims to export SCU symbols for SoCs w/wo
SCU, so that no need to check CONFIG_IMX_SCU in the specific driver.

The following patches are for flexcan to add stop mode support for
i.MX8QM.

Joakim Zhang (5):
  dt-bindings: can: flexcan: fix fsl,clk-source property
  dt-bindings: can: flexcan: add fsl,can-index property to indicate a
resource
  can: flexcan: rename macro FLEXCAN_QUIRK_SETUP_STOP_MODE ->
FLEXCAN_QUIRK_SETUP_STOP_MODE_GPR
  can: flexcan: add CAN wakeup function for i.MX8QM
  can: flexcan: fix ECC function on LS1021A/LX2160A

Liu Ying (1):
  firmware: imx: always export SCU symbols

 .../bindings/net/can/fsl-flexcan.txt  |   7 +-
 drivers/net/can/flexcan.c | 143 ++
 include/linux/firmware/imx/ipc.h  |  15 ++
 include/linux/firmware/imx/svc/misc.h |  23 +++
 4 files changed, 160 insertions(+), 28 deletions(-)

-- 
2.17.1



Re: [RFC PATCH] mm: memcg/slab: Stop reparented obj_cgroups from charging root

2020-10-15 Thread Richard Palethorpe
Hello Roman,

Roman Gushchin  writes:

> Hi Richard!
>
>> SLAB objects which outlive their memcg are moved to their parent
>> memcg where they may be uncharged. However if they are moved to the
>> root memcg, uncharging will result in negative page counter values as
>> root has no page counters.
>> 
>> To prevent this, we check whether we are about to uncharge the root
>> memcg and skip it if we are. Possibly instead; the obj_cgroups should
>> be removed from their slabs and any per cpu stocks instead of
>> reparenting them to root?
>
> It would be really complex. I think your fix is totally fine.
> We have similar checks in cancel_charge(), uncharge_batch(),
> mem_cgroup_swapout(), mem_cgroup_uncharge_swap() etc.
>
>
> Acked-by: Roman Gushchin 
>
> Thanks!

Great I will respin.

-- 
Thank you,
Richard.


Re: [PATCH] Staging: android: ashmem: changed struct file_operations to const file_operations

2020-10-15 Thread Greg KH
On Fri, Oct 16, 2020 at 01:11:11AM -0400, kiransu...@osuosl.org wrote:
> From: kiransuren 

This does not match your signed-off-by line :(

> 
> Fixed a coding style issue.

What issue?  Always be specific.

> 
> Signed-off-by: Kiran Surendran 
> ---
>  drivers/staging/android/ashmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ashmem.c 
> b/drivers/staging/android/ashmem.c
> index 10b4be1f3e78..f2b67c4fe8d2 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -376,7 +376,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, 
> unsigned long addr,
>  
>  static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
>  {
> - static struct file_operations vmfile_fops;
> + static const file_operations vmfile_fops;

Why did you not test-build your patch before sending it out?

Don't you think that is a big rude?

Please be more careful.

greg k-h


Re: [PATCH] Staging: android: ashmem: changed struct file_operations to const file_operations

2020-10-15 Thread Randy Dunlap
On 10/15/20 10:11 PM, kiransu...@osuosl.org wrote:
> From: kiransuren 
> 
> Fixed a coding style issue.
> 
> Signed-off-by: Kiran Surendran 
> ---
>  drivers/staging/android/ashmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ashmem.c 
> b/drivers/staging/android/ashmem.c
> index 10b4be1f3e78..f2b67c4fe8d2 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -376,7 +376,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, 
> unsigned long addr,
>  
>  static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
>  {
> - static struct file_operations vmfile_fops;
> + static const file_operations vmfile_fops;
>   struct ashmem_area *asma = file->private_data;
>   int ret = 0;
>  
> 

Did you build/compile this change?  My brain syntax checker doesn't like it.

and what coding style issue?

-- 
~Randy



Re: [PATCH v3 09/13] ASoC: dt-bindings: tegra: Add schema for audio graph card

2020-10-15 Thread Sameer Pujar



Add YAML schema for Tegra audio graph sound card DT bindings. It 
uses the
same DT bindings provided by generic audio graph driver. Along with 
this
few standard clock DT bindings are added which are specifically 
required

for Tegra audio.

Signed-off-by: Sameer Pujar 
---
  .../sound/nvidia,tegra-audio-graph-card.yaml | 70 
++

  1 file changed, 70 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml


diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml 


new file mode 100644
index 000..b73fbe5
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml

@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: 
http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#

+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Audio Graph based Tegra sound card driver
+
+description: |
+  This is based on generic audio graph card driver along with 
additional

+  customizations for Tegra platforms. It uses the same bindings with
+  additional standard clock DT bindings required for Tegra.
+
+ 
See{LINUX}/Documentation/devicetree/bindings/sound/audio-graph-card.txt

+
+maintainers:
+  - Jon Hunter 
+  - Sameer Pujar 
+
+properties:
+  compatible:
+    oneOf:
+  - const: nvidia,tegra210-audio-graph-card
+  - const: nvidia,tegra186-audio-graph-card
+
+  clocks:
+   minItems: 2
+
+  clock-names:
+   minItems: 2
+   items:
+ - const: pll_a
+ - const: plla_out0
+
+  assigned-clocks:
+    minItems: 1
+    maxItems: 3
+
+  assigned-clock-parents:
+    minItems: 1
+    maxItems: 3
+
+  assigned-clock-rates:
+    minItems: 1
+    maxItems: 3
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents

Where's the graph? You need to define the ports and reference the common
schema.


I am looking to reference the bindings used in below doc which is not 
yet in YAML format. Only additional properties I listed here.

{LINUX}/Documentation/devicetree/bindings/sound/audio-graph-card.txt

Should I keep this doc to *.txt format as well and later move to YAML 
or is there a way to reference *.txt doc here?


The dependency here is like below,
Tegra audio graph card -> generic audio graph card 
(audio-graph-card.txt) -> graph (graph.txt)


I plan to convert dependencies to json-schema in next revision and then 
refer these for Tegra audio graph card.




[PATCH] f2fs: add compr_inode and compr_blocks sysfs nodes

2020-10-15 Thread Daeho Jeong
From: Daeho Jeong 

Added compr_inode to show compressed inode count and compr_blocks to
show compressed block count in sysfs.

Signed-off-by: Daeho Jeong 
---
 Documentation/ABI/testing/sysfs-fs-f2fs | 10 ++
 fs/f2fs/sysfs.c | 17 +
 2 files changed, 27 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs 
b/Documentation/ABI/testing/sysfs-fs-f2fs
index 834d0becae6d..a01c26484c69 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -350,3 +350,13 @@ Date:  April 2020
 Contact:   "Daeho Jeong" 
 Description:   Give a way to change iostat_period time. 3secs by default.
The new iostat trace gives stats gap given the period.
+
+What:  /sys/fs/f2fs//compr_inode
+Date:  October 2020
+Contact:   "Daeho Jeong" 
+Description:   Show compressed inode count
+
+What:  /sys/fs/f2fs//compr_blocks
+Date:  October 2020
+Contact:   "Daeho Jeong" 
+Description:   Show compressed block count
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 94c98e412aa1..7139a29a00d3 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -223,6 +223,19 @@ static ssize_t avg_vblocks_show(struct f2fs_attr *a,
f2fs_update_sit_info(sbi);
return sprintf(buf, "%llu\n", (unsigned long long)(si->avg_vblocks));
 }
+
+static ssize_t compr_inode_show(struct f2fs_attr *a,
+   struct f2fs_sb_info *sbi, char *buf)
+{
+   return sprintf(buf, "%u\n", atomic_read(>compr_inode));
+}
+
+static ssize_t compr_blocks_show(struct f2fs_attr *a,
+   struct f2fs_sb_info *sbi, char *buf)
+{
+   return sprintf(buf, "%llu\n", atomic64_read(>compr_blocks));
+}
+
 #endif
 
 static ssize_t main_blkaddr_show(struct f2fs_attr *a,
@@ -591,6 +604,8 @@ F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, 
gc_background_calls, bg_gc);
 F2FS_GENERAL_RO_ATTR(moved_blocks_background);
 F2FS_GENERAL_RO_ATTR(moved_blocks_foreground);
 F2FS_GENERAL_RO_ATTR(avg_vblocks);
+F2FS_GENERAL_RO_ATTR(compr_inode);
+F2FS_GENERAL_RO_ATTR(compr_blocks);
 #endif
 
 #ifdef CONFIG_FS_ENCRYPTION
@@ -675,6 +690,8 @@ static struct attribute *f2fs_attrs[] = {
ATTR_LIST(moved_blocks_foreground),
ATTR_LIST(moved_blocks_background),
ATTR_LIST(avg_vblocks),
+   ATTR_LIST(compr_inode),
+   ATTR_LIST(compr_blocks),
 #endif
NULL,
 };
-- 
2.29.0.rc1.297.gfa9743e501-goog



Re: [PATCH V2 2/2] cpufreq: dt: Refactor initialization to handle probe deferral properly

2020-10-15 Thread Viresh Kumar
On 14-10-20, 18:40, Geert Uytterhoeven wrote:
> On this platform (r8a7791-koelsch.dts), there is no opp table in DT.
> 
>   Before:

I assume this means before this patchset came in..

> boot:
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:362
>   cpu cpu0: resources_available:95
>   cpu cpu0: resources_available:102: clk_get() returned z
>   cpu cpu0: resources_available:120:
> dev_pm_opp_of_find_icc_paths() returned 0
>   cpu cpu0: resources_available:125: find_supply_name() returned cpu0
>   cpu cpu0: resources_available:132: regulator_get_optional()
> returned -EPROBE_DEFER
>   cpu cpu0: cpu0 regulator not ready, retry
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:371:
> resources_available() returned -517

we deferred probe once.

>   ...
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:362
>   cpu cpu0: resources_available:95
>   cpu cpu0: resources_available:102: clk_get() returned z
>   cpu cpu0: resources_available:120:
> dev_pm_opp_of_find_icc_paths() returned 0
>   cpu cpu0: resources_available:125: find_supply_name() returned cpu0
>   cpu cpu0: resources_available:132: regulator_get_optional()
> returned (ptrval)

found regulator next time.

>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:371:
> resources_available() returned 0
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:375
>   cpufreq_dt: cpufreq_init:162
>   cpu cpu0: cpufreq_init:170: clk_get() returned z
>   cpu cpu0: cpufreq_init:179: dev_pm_opp_of_get_sharing_cpus() returned -2
>   cpu cpu0: cpufreq_init:198: find_supply_name() returned cpu0
>   
>   cpu cpu0: cpufreq_init:201: dev_pm_opp_set_regulators() returned 
> (ptrval)
>   
>   cpu cpu0: cpufreq_init:230: dev_pm_opp_of_cpumask_add_table() returned 0
>   cpu cpu0: cpufreq_init:239: dev_pm_opp_get_opp_count() returned 0
>   cpu cpu0: OPP table is not ready, deferring probe

This failed, as we couldn't have deferred probe from cpufreq_init.
Which means that cpufreq didn't work here.

>   cpufreq_dt: cpufreq_init:162
>   cpu cpu1: cpufreq_init:170: clk_get() returned z
>   cpu cpu1: cpufreq_init:179: dev_pm_opp_of_get_sharing_cpus() returned -2
>   cpu cpu1: no regulator for cpu1
>   cpu cpu1: cpufreq_init:198: find_supply_name() returned (null)
>   cpu cpu1: cpufreq_init:230: dev_pm_opp_of_cpumask_add_table() returned 0
>   cpu cpu1: cpufreq_init:239: dev_pm_opp_get_opp_count() returned 0
>   cpu cpu1: OPP table is not ready, deferring probe

Same for CPU1.

> 
> s2ram:
>   cpufreq_dt: cpufreq_init:162
>   cpu cpu1: cpufreq_init:170: clk_get() returned z
>   cpu cpu1: cpufreq_init:179: dev_pm_opp_of_get_sharing_cpus() returned -2
>   cpu cpu1: no regulator for cpu1
>   cpu cpu1: cpufreq_init:198: find_supply_name() returned (null)
>   cpu cpu1: cpufreq_init:230: dev_pm_opp_of_cpumask_add_table() returned 0
>   cpu cpu1: cpufreq_init:239: dev_pm_opp_get_opp_count() returned 0
>   cpu cpu1: OPP table is not ready, deferring probe

And same here.

>   CPU1 is up
> 
>   After:
> boot:
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:356
>   cpufreq_dt: dt_cpufreq_early_init:251
>   cpu cpu0: dt_cpufreq_early_init:256
>   cpu cpu0: dt_cpufreq_early_init:271: dev_pm_opp_get_opp_table()
> returned (ptrval)
>   cpu cpu0: dt_cpufreq_early_init:284: find_supply_name() returned cpu0
>   cpu cpu0: dt_cpufreq_early_init:288: dev_pm_opp_set_regulators()
> returned -EPROBE_DEFER
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:360:
> dt_cpufreq_early_init() returned -517
>   ...
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:356
>   cpufreq_dt: dt_cpufreq_early_init:251
>   cpu cpu0: dt_cpufreq_early_init:256
>   cpu cpu0: dt_cpufreq_early_init:271: dev_pm_opp_get_opp_table()
> returned (ptrval)
>   cpu cpu0: dt_cpufreq_early_init:284: find_supply_name() returned cpu0
>   cpu cpu0: dt_cpufreq_early_init:288: dev_pm_opp_set_regulators()
> returned (ptrval)
>   cpu cpu0: dt_cpufreq_early_init:301:
> dev_pm_opp_of_get_sharing_cpus() returned -2
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:360:
> dt_cpufreq_early_init() returned 0
>   cpufreq_dt: dt_cpufreq_early_init:251
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:360:
> dt_cpufreq_early_init() returned 0
>   cpufreq-dt cpufreq-dt: dt_cpufreq_probe:365
>   cpufreq_dt: cpufreq_init:114
>   cpu cpu0: cpufreq_init:124: clk_get() returned z
>   cpu cpu0: cpufreq_init:142: dev_pm_opp_of_cpumask_add_table() returned 0
>   cpu cpu0: cpufreq_init:151: dev_pm_opp_get_opp_count() returned 0
>   cpu cpu0: OPP table can't be empty

Same issue here.

>   cpufreq_dt: cpufreq_init:114
>   cpu cpu0: cpufreq_init:124: clk_get() returned z
>   
>   cpu cpu0: cpufreq_init:142: dev_pm_opp_of_cpumask_add_table() returned 0
>   cpu cpu0: cpufreq_init:151: dev_pm_opp_get_opp_count() returned 0
> 
> 

[PATCH 3/4] scatterlist: add sgl_compare_sgl() function

2020-10-15 Thread Douglas Gilbert
After enabling copies between scatter gather lists (sgl_s),
another storage related operation is to compare two sgl_s.
This new function is modelled on NVMe's Compare command and
the SCSI VERIFY(BYTCHK=1) command. Like memcmp() this function
returns false on the first miscompare and stop comparing.

Signed-off-by: Douglas Gilbert 
---
 include/linux/scatterlist.h |  4 ++
 lib/scatterlist.c   | 84 -
 2 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 6649414c0749..ae260dc5fedb 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -325,6 +325,10 @@ size_t sgl_copy_sgl(struct scatterlist *d_sgl, unsigned 
int d_nents, off_t d_ski
struct scatterlist *s_sgl, unsigned int s_nents, off_t 
s_skip,
size_t n_bytes);
 
+bool sgl_compare_sgl(struct scatterlist *x_sgl, unsigned int x_nents, off_t 
x_skip,
+struct scatterlist *y_sgl, unsigned int y_nents, off_t 
y_skip,
+size_t n_bytes);
+
 /*
  * Maximum number of entries that will be allocated in one piece, if
  * a list larger than this is required then chaining will be utilized.
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 1ec2c909c8d4..344725990b9d 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -979,10 +979,10 @@ EXPORT_SYMBOL(sg_zero_buffer);
  * sgl_copy_sgl - Copy over a destination sgl from a source sgl
  * @d_sgl:  Destination sgl
  * @d_nents:Number of SG entries in destination sgl
- * @d_skip: Number of bytes to skip in destination before copying
+ * @d_skip: Number of bytes to skip in destination before starting
  * @s_sgl:  Source sgl
  * @s_nents:Number of SG entries in source sgl
- * @s_skip: Number of bytes to skip in source before copying
+ * @s_skip: Number of bytes to skip in source before starting
  * @n_bytes:The number of bytes to copy
  *
  * Returns the number of copied bytes.
@@ -1060,3 +1060,83 @@ size_t sgl_copy_sgl(struct scatterlist *d_sgl, unsigned 
int d_nents, off_t d_ski
 }
 EXPORT_SYMBOL(sgl_copy_sgl);
 
+/**
+ * sgl_compare_sgl - Compare x and y (both sgl_s)
+ * @x_sgl:  x (left) sgl
+ * @x_nents:Number of SG entries in x (left) sgl
+ * @x_skip: Number of bytes to skip in x (left) before starting
+ * @y_sgl:  y (right) sgl
+ * @y_nents:Number of SG entries in y (right) sgl
+ * @y_skip: Number of bytes to skip in y (right) before starting
+ * @n_bytes:The number of bytes to compare
+ *
+ * Returns true if x and y compare equal before x, y or n_bytes is exhausted.
+ * Otherwise on a miscompare, returns false (and stops comparing).
+ *
+ * Notes:
+ *   x and y are symmetrical: they can be swapped and the result is the same.
+ *
+ *   Implementation is based on memcmp(). x and y segments may overlap.
+ *
+ *   Same comment from sgl_copy_sgl() about large _skip arguments applies here
+ *   as well.
+ *
+ **/
+bool sgl_compare_sgl(struct scatterlist *x_sgl, unsigned int x_nents, off_t 
x_skip,
+struct scatterlist *y_sgl, unsigned int y_nents, off_t 
y_skip,
+size_t n_bytes)
+{
+   bool equ = true;
+   size_t x_off, y_off, len, x_len, y_len;
+   size_t offset = 0;
+   struct sg_mapping_iter x_iter;
+   struct sg_mapping_iter y_iter;
+
+   if (n_bytes == 0)
+   return true;
+   sg_miter_start(_iter, x_sgl, x_nents, SG_MITER_ATOMIC | 
SG_MITER_TO_SG);
+   sg_miter_start(_iter, y_sgl, y_nents, SG_MITER_ATOMIC | 
SG_MITER_FROM_SG);
+   if (!sg_miter_skip(_iter, x_skip))
+   goto fini;
+   if (!sg_miter_skip(_iter, y_skip))
+   goto fini;
+
+   for (x_off = 0, y_off = 0; true ; ) {
+   /* Assume x_iter.length and y_iter.length can never be 0 */
+   if (x_off == 0) {
+   if (!sg_miter_next(_iter))
+   break;
+   x_len = x_iter.length;
+   } else {
+   x_len = x_iter.length - x_off;
+   }
+   if (y_off == 0) {
+   if (!sg_miter_next(_iter))
+   break;
+   y_len = y_iter.length;
+   } else {
+   y_len = y_iter.length - y_off;
+   }
+   len = min3(x_len, y_len, n_bytes - offset);
+
+   equ = memcmp(x_iter.addr + x_off, y_iter.addr + y_off, len) == 
0;
+   offset += len;
+   if (!equ || offset >= n_bytes)
+   break;
+   if (x_len == y_len) {
+   x_off = 0;
+   y_off = 0;
+   } else if (x_len < y_len) {
+  

[PATCH 4/4] scatterlist: add sgl_memset()

2020-10-15 Thread Douglas Gilbert
The existing sg_zero_buffer() function is a bit restrictive.
For example protection information (PI) blocks are usually
initialized to 0xff bytes. As its name suggests sgl_memset()
is modelled on memset(). One difference is the type of the
val argument which is u8 rather than int.

Signed-off-by: Douglas Gilbert 
---
 include/linux/scatterlist.h |  3 +++
 lib/scatterlist.c   | 39 +++--
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index ae260dc5fedb..e50dc9a6d887 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -329,6 +329,9 @@ bool sgl_compare_sgl(struct scatterlist *x_sgl, unsigned 
int x_nents, off_t x_sk
 struct scatterlist *y_sgl, unsigned int y_nents, off_t 
y_skip,
 size_t n_bytes);
 
+void sgl_memset(struct scatterlist *sgl, unsigned int nents, off_t skip,
+   u8 val, size_t n_bytes);
+
 /*
  * Maximum number of entries that will be allocated in one piece, if
  * a list larger than this is required then chaining will be utilized.
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 344725990b9d..3ca66f0c949f 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -1083,8 +1083,8 @@ EXPORT_SYMBOL(sgl_copy_sgl);
  *
  **/
 bool sgl_compare_sgl(struct scatterlist *x_sgl, unsigned int x_nents, off_t 
x_skip,
-struct scatterlist *y_sgl, unsigned int y_nents, off_t 
y_skip,
-size_t n_bytes)
+   struct scatterlist *y_sgl, unsigned int y_nents, off_t 
y_skip,
+   size_t n_bytes)
 {
bool equ = true;
size_t x_off, y_off, len, x_len, y_len;
@@ -1140,3 +1140,38 @@ bool sgl_compare_sgl(struct scatterlist *x_sgl, unsigned 
int x_nents, off_t x_sk
return equ;
 }
 EXPORT_SYMBOL(sgl_compare_sgl);
+
+/**
+ * sgl_memset - set byte 'val' n_bytes times on SG list
+ * @sgl:The SG list
+ * @nents:  Number of SG entries in sgl
+ * @skip:   Number of bytes to skip before starting
+ * @val:byte value to write to sgl
+ * @n_bytes:The number of bytes to modify
+ *
+ * Notes:
+ *   Writes val n_bytes times or until sgl is exhausted.
+ *
+ **/
+void sgl_memset(struct scatterlist *sgl, unsigned int nents, off_t skip,
+   u8 val, size_t n_bytes)
+{
+   size_t offset = 0;
+   size_t len;
+   struct sg_mapping_iter miter;
+   unsigned int sg_flags = SG_MITER_ATOMIC | SG_MITER_TO_SG;
+
+   if (n_bytes == 0)
+   return;
+   sg_miter_start(, sgl, nents, sg_flags);
+   if (!sg_miter_skip(, skip))
+   goto fini;
+
+   while ((offset < n_bytes) && sg_miter_next()) {
+   len = min(miter.length, n_bytes - offset);
+   memset(miter.addr, val, len);
+   offset += len;
+   }
+fini:
+   sg_miter_stop();
+}
-- 
2.25.1



[PATCH 0/4] scatterlist: add new capabilities

2020-10-15 Thread Douglas Gilbert
Scatter-gather lists (sgl_s) are frequently used as data
carriers in the block layer. For example the SCSI and NVMe
subsystems interchange data with the block layer using
sgl_s. The sgl API is declared in 

The author has extended these transient sgl use cases to
a store (i.e. ramdisk) in the scsi_debug driver. Other new
potential uses of sgl_s could be for caches. When this extra
step is taken, the need to copy between sgl_s becomes apparent.
The patchset adds sgl_copy_sgl() and a few other sgl
operations.

The existing sgl_alloc_order() function can be seen as a
replacement for vmalloc() for large, long-term allocations.
For what seems like no good reason, sgl_alloc_order()
currently restricts its total allocation to less than or
equal to 4 GiB. vmalloc() has no such restriction.

This patchset is against lk 5.9.0

Douglas Gilbert (4):
  sgl_alloc_order: remove 4 GiB limit, sgl_free() warning
  scatterlist: add sgl_copy_sgl() function
  scatterlist: add sgl_compare_sgl() function
  scatterlist: add sgl_memset()

 include/linux/scatterlist.h |  12 +++
 lib/scatterlist.c   | 204 +++-
 2 files changed, 213 insertions(+), 3 deletions(-)

-- 
2.25.1



[PATCH 1/4] sgl_alloc_order: remove 4 GiB limit, sgl_free() warning

2020-10-15 Thread Douglas Gilbert
This patch removes a check done by sgl_alloc_order() before it starts
any allocations. The comment before the removed code says: "Check for
integer overflow" arguably gives a false sense of security. The right
hand side of the expression in the condition is resolved as u32 so
cannot exceed UINT32_MAX (4 GiB) which means 'length' cannot exceed
that amount. If that was the intention then the comment above it
could be dropped and the condition rewritten more clearly as:
 if (length > UINT32_MAX) <>;

The author's intention is to use sgl_alloc_order() to replace
vmalloc(unsigned long) for a large allocation (debug ramdisk).
vmalloc has no limit at 4 GiB so its seems unreasonable that:
sgl_alloc_order(unsigned long long length, )
does. sgl_s made with sgl_alloc_order(chainable=false) have equally
sized segments placed in a scatter gather array. That allows O(1)
navigation around a big sgl using some simple integer maths.

Having previously sent a patch to fix a memory leak in
sg_alloc_order() take the opportunity to put a one line comment above
sgl_free()'s declaration that it is not suitable when order > 0 . The
mis-use of sgl_free() when order > 0 was the reason for the memory
leak. The other users of sgl_alloc_order() in the kernel where
checked and found to handle free-ing properly.

Signed-off-by: Douglas Gilbert 
---
 include/linux/scatterlist.h | 1 +
 lib/scatterlist.c   | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 45cf7b69d852..80178afc2a4a 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -302,6 +302,7 @@ struct scatterlist *sgl_alloc(unsigned long long length, 
gfp_t gfp,
  unsigned int *nent_p);
 void sgl_free_n_order(struct scatterlist *sgl, int nents, int order);
 void sgl_free_order(struct scatterlist *sgl, int order);
+/* Only use sgl_free() when order is 0 */
 void sgl_free(struct scatterlist *sgl);
 #endif /* CONFIG_SGL_ALLOC */
 
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index c448642e0f78..d5770e7f1030 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -493,9 +493,6 @@ struct scatterlist *sgl_alloc_order(unsigned long long 
length,
u32 elem_len;
 
nent = round_up(length, PAGE_SIZE << order) >> (PAGE_SHIFT + order);
-   /* Check for integer overflow */
-   if (length > (nent << (PAGE_SHIFT + order)))
-   return NULL;
nalloc = nent;
if (chainable) {
/* Check for integer overflow */
-- 
2.25.1



[PATCH 2/4] scatterlist: add sgl_copy_sgl() function

2020-10-15 Thread Douglas Gilbert
Both the SCSI and NVMe subsystems receive user data from the block
layer in scatterlist_s (aka scatter gather lists (sgl) which are
often arrays). If drivers in those subsystems represent storage
(e.g. a ramdisk) or cache "hot" user data then they may also
choose to use scatterlist_s. Currently there are no sgl to sgl
operations in the kernel. Start with a copy.

Signed-off-by: Douglas Gilbert 
---
 include/linux/scatterlist.h |  4 ++
 lib/scatterlist.c   | 86 +
 2 files changed, 90 insertions(+)

diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 80178afc2a4a..6649414c0749 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -321,6 +321,10 @@ size_t sg_pcopy_to_buffer(struct scatterlist *sgl, 
unsigned int nents,
 size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents,
   size_t buflen, off_t skip);
 
+size_t sgl_copy_sgl(struct scatterlist *d_sgl, unsigned int d_nents, off_t 
d_skip,
+   struct scatterlist *s_sgl, unsigned int s_nents, off_t 
s_skip,
+   size_t n_bytes);
+
 /*
  * Maximum number of entries that will be allocated in one piece, if
  * a list larger than this is required then chaining will be utilized.
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index d5770e7f1030..1ec2c909c8d4 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -974,3 +974,89 @@ size_t sg_zero_buffer(struct scatterlist *sgl, unsigned 
int nents,
return offset;
 }
 EXPORT_SYMBOL(sg_zero_buffer);
+
+/**
+ * sgl_copy_sgl - Copy over a destination sgl from a source sgl
+ * @d_sgl:  Destination sgl
+ * @d_nents:Number of SG entries in destination sgl
+ * @d_skip: Number of bytes to skip in destination before copying
+ * @s_sgl:  Source sgl
+ * @s_nents:Number of SG entries in source sgl
+ * @s_skip: Number of bytes to skip in source before copying
+ * @n_bytes:The number of bytes to copy
+ *
+ * Returns the number of copied bytes.
+ *
+ * Notes:
+ *   Destination arguments appear before the source arguments, as with 
memcpy().
+ *
+ *   Stops copying if the end of d_sgl or s_sgl is reached.
+ *
+ *   Since memcpy() is used, overlapping copies (where d_sgl and s_sgl belong
+ *   to the same sgl and the copy regions overlap) are not supported.
+ *
+ *   If d_skip is large, potentially spanning multiple d_nents then some
+ *   integer arithmetic to adjust d_sgl may improve performance. For example
+ *   if d_sgl is built using sgl_alloc_order(chainable=false) then the sgl
+ *   will be an array with equally sized segments facilitating that
+ *   arithmetic. The suggestion applies to s_skip, s_sgl and s_nents as well.
+ *
+ **/
+size_t sgl_copy_sgl(struct scatterlist *d_sgl, unsigned int d_nents, off_t 
d_skip,
+   struct scatterlist *s_sgl, unsigned int s_nents, off_t 
s_skip,
+   size_t n_bytes)
+{
+   size_t d_off, s_off, len, d_len, s_len;
+   size_t offset = 0;
+   struct sg_mapping_iter d_iter;
+   struct sg_mapping_iter s_iter;
+
+   if (n_bytes == 0)
+   return 0;
+   sg_miter_start(_iter, d_sgl, d_nents, SG_MITER_ATOMIC | 
SG_MITER_TO_SG);
+   sg_miter_start(_iter, s_sgl, s_nents, SG_MITER_ATOMIC | 
SG_MITER_FROM_SG);
+   if (!sg_miter_skip(_iter, d_skip))
+   goto fini;
+   if (!sg_miter_skip(_iter, s_skip))
+   goto fini;
+
+   for (d_off = 0, s_off = 0; true ; ) {
+   /* Assume d_iter.length and s_iter.length can never be 0 */
+   if (d_off == 0) {
+   if (!sg_miter_next(_iter))
+   break;
+   d_len = d_iter.length;
+   } else {
+   d_len = d_iter.length - d_off;
+   }
+   if (s_off == 0) {
+   if (!sg_miter_next(_iter))
+   break;
+   s_len = s_iter.length;
+   } else {
+   s_len = s_iter.length - s_off;
+   }
+   len = min3(d_len, s_len, n_bytes - offset);
+
+   memcpy(d_iter.addr + d_off, s_iter.addr + s_off, len);
+   offset += len;
+   if (offset >= n_bytes)
+   break;
+   if (d_len == s_len) {
+   d_off = 0;
+   s_off = 0;
+   } else if (d_len < s_len) {
+   d_off = 0;
+   s_off += len;
+   } else {
+   d_off += len;
+   s_off = 0;
+   }
+   }
+fini:
+   sg_miter_stop(_iter);
+   sg_miter_stop(_iter);
+   return offset;
+}
+EXPORT_SYMBOL(sgl_copy_sgl);
+
-- 
2.25.1



linux-next: build failure after merge of the akpm-current tree

2020-10-15 Thread Stephen Rothwell
Hi all,

After merging the akpm-current tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

mm/readahead.c: In function 'page_cache_sync_ra':
mm/readahead.c:565:8: error: 'filp' undeclared (first use in this function); 
did you mean 'file'?
  565 |   if (!filp)
  |^~~~
  |file

Caused by commit

  f65bd470e7ed ("mm/readahead: add page_cache_sync_ra and page_cache_async_ra")

interacting with commit

  09d008e3868e ("readahead: use limited read-ahead to satisfy read")

from the block tree.

I have added the following merge fix patch.

From: Stephen Rothwell 
Date: Fri, 16 Oct 2020 15:39:09 +1100
Subject: [PATCH] mm/readahead: fix up for "readahead: use limited read-ahead to 
satisfy read"

Signed-off-by: Stephen Rothwell 
---
 mm/readahead.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/readahead.c b/mm/readahead.c
index a673ec53de37..b4d162b38bd6 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -562,7 +562,7 @@ void page_cache_sync_ra(struct readahead_control *ractl,
 * we're congested or tight on memory.
 */
if (!ra->ra_pages || blk_cgroup_congested()) {
-   if (!filp)
+   if (!ractl->file)
return;
req_count = 1;
do_forced_ra = true;
-- 
2.28.0

-- 
Cheers,
Stephen Rothwell


pgpzFDPUF8rD4.pgp
Description: OpenPGP digital signature


[PATCH] usb: gadget: fsl: fix null pointer checking

2020-10-15 Thread Ran Wang
fsl_ep_fifo_status() should return error if _ep->desc is null.

Fixes: 75eaa498c99e (“usb: gadget: Correct NULL pointer checking in fsl gadget”)
Signed-off-by: Ran Wang 
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index de528e3..ad6ff9c 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -1051,7 +1051,7 @@ static int fsl_ep_fifo_status(struct usb_ep *_ep)
u32 bitmask;
struct ep_queue_head *qh;
 
-   if (!_ep || _ep->desc || !(_ep->desc->bEndpointAddress&0xF))
+   if (!_ep || !_ep->desc || !(_ep->desc->bEndpointAddress&0xF))
return -ENODEV;
 
ep = container_of(_ep, struct fsl_ep, ep);
-- 
2.7.4



[PATCH 2/2] ARM: dts: tacoma: Add reserved memory for ramoops

2020-10-15 Thread Andrew Jeffery
Reserve a 1.5MiB region of memory to record kmsg dumps, console and
userspace message state into 16kiB ring-buffer slots. The sizing allows
for up to 32 dumps to be captured and read out.

Set max-reason to KMSG_DUMP_EMERG to capture bad-path reboots.

Signed-off-by: Andrew Jeffery 
---
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts 
b/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
index 46f2f538baba..4f7e9b490e1a 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts
@@ -26,6 +26,15 @@ reserved-memory {
#size-cells = <1>;
ranges;
 
+   ramoops@b9e8 {
+   compatible = "ramoops";
+   reg = <0xb9e8 0x18>;
+   record-size = <0x4000>;
+   console-size = <0x4000>;
+   pmsg-size = <0x4000>;
+   max-reason = <3>; /* KMSG_DUMP_EMERG */
+   };
+
flash_memory: region@ba00 {
no-map;
reg = <0xb800 0x400>; /* 64M */
-- 
2.25.1



[PATCH 1/2] ARM: dts: rainier: Add reserved memory for ramoops

2020-10-15 Thread Andrew Jeffery
Reserve a 1.5MiB region of memory to record kmsg dumps, console and
userspace message state into 16kiB ring-buffer slots. The sizing allows
for up to 32 dumps to be captured and read out.

Set max-reason to KMSG_DUMP_EMERG to capture bad-path reboots.

Signed-off-by: Andrew Jeffery 
---
 arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts 
b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts
index 183e1a4dcc65..89729ee698c5 100644
--- a/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts
@@ -47,6 +47,15 @@ reserved-memory {
#size-cells = <1>;
ranges;
 
+   ramoops@b7e8 {
+   compatible = "ramoops";
+   reg = <0xb7e8 0x18>;
+   record-size = <0x4000>;
+   console-size = <0x4000>;
+   pmsg-size = <0x4000>;
+   max-reason = <3>; /* KMSG_DUMP_EMERG */
+   };
+
flash_memory: region@b800 {
no-map;
reg = <0xb800 0x0400>; /* 64M */
-- 
2.25.1



[PATCH 0/2] ARM: dts: Enable ramoops for Rainier and Tacoma

2020-10-15 Thread Andrew Jeffery
Hi,

We're looking to improve our crash data capture for the BMC on some IBM
platforms. This small series enables ramoops for Rainier and Tacoma.

Please review.

Andrew

Andrew Jeffery (2):
  ARM: dts: rainier: Add reserved memory for ramoops
  ARM: dts: tacoma: Add reserved memory for ramoops

 arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 9 +
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts  | 9 +
 2 files changed, 18 insertions(+)

-- 
2.25.1



Re: [PATCH V2 1/2] opp: Allow dev_pm_opp_get_opp_table() to return -EPROBE_DEFER

2020-10-15 Thread Viresh Kumar
On 15-10-20, 19:05, Sudeep Holla wrote:
> OK, this breaks with SCMI which doesn't provide clocks but manage OPPs
> directly. Before this change clk_get(dev..) was allowed to fail and
> --EPROBE_DEFER was not an error.

I think the change in itself is fine. We should be returning from
there if we get EPROBE_DEFER. The question is rather why are you
getting EPROBE_DEFER here ?

> We use dev_pm_opp_add to add OPPs
> read from the firmware and this change is preventing that.
> 
> Sorry for checking this so late, but noticed only when this hit mainline.
> 
> -- 
> Regards,
> Sudeep

-- 
viresh


RE: [PATCH v3 1/1] i2c: ocores: fix polling mode workaround on FU540-C000 SoC

2020-10-15 Thread Sagar Kadam
Hello Peter,

> -Original Message-
> From: Peter Korsgaard  On Behalf Of Peter Korsgaard
> Sent: Thursday, October 15, 2020 8:19 PM
> To: Sagar Kadam 
> Cc: linux-kernel@vger.kernel.org; linux-ri...@lists.infradead.org; linux-
> i...@vger.kernel.org; and...@lunn.ch; Paul Walmsley ( Sifive)
> ; pal...@dabbelt.com;
> a...@eecs.berkeley.edu
> Subject: Re: [PATCH v3 1/1] i2c: ocores: fix polling mode workaround on
> FU540-C000 SoC
> 
> [External Email] Do not click links or attachments unless you recognize the
> sender and know the content is safe
> 
> > "Sagar" == Sagar Shrikant Kadam  writes:
> 
>  > The FU540-C000 has a broken IRQ and support was added earlier
>  > so that it will operate in polling mode, but seems to work only
>  > in case interrupts property is missing from the i2c0 dt-node.
>  > This should not be the case and the driver should handle polling
>  > mode with the interrupt property present in i2c0 node of the
>  > device tree.
>  > So check if it's the FU540-C000 soc and enable polling mode master
>  > xfers, as the IRQ for this chip is broken.
> 
>  > Fixes commit c45d4ba86731 ("i2c: ocores: add polling mode workaround
>  > for Sifive FU540-C000 SoC")
> 
>  > Signed-off-by: Sagar Shrikant Kadam 
>  > ---
>  >  drivers/i2c/busses/i2c-ocores.c | 22 +-
>  >  1 file changed, 13 insertions(+), 9 deletions(-)
> 
>  > diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-
> ocores.c
>  > index f5fc75b..1dab02d 100644
>  > --- a/drivers/i2c/busses/i2c-ocores.c
>  > +++ b/drivers/i2c/busses/i2c-ocores.c
>  > @@ -686,17 +686,21 @@ static int ocores_i2c_probe(struct
> platform_device *pdev)
> 
>  >  init_waitqueue_head(>wait);
> 
>  > +/*
>  > + * Set OCORES_FLAG_BROKEN_IRQ to enable workaround for
>  > + * FU540-C000 SoC in polling mode.
>  > + * Since the SoC does have interrupt its dt has the interrupt
>  > + * defined but it should be bypassed in driver as this SoC has
> 
> NIT: Looks like there some commas missing and the wording sounds a bit
> odd to me. What about E.G.:
> 
Sorry for the confusing wordings here.
>  /*
>   * Since the SoC does have an interrupt, its DT has an interrupt
>   * property - But this should be bypassed as the IRQ logic in this
>   * SoC is broken.
>   */
> 
I will replace mine with your suggested one.

>  > + * a broken IRQ, hence update the master_xfer to use polling
>  > + * transfers.
>  > + */
>  > +if (of_device_is_compatible(pdev->dev.of_node,
>  > +"sifive,fu540-c000-i2c"))
>  > +i2c->flags |= OCORES_FLAG_BROKEN_IRQ;
>  > +
>  >  irq = platform_get_irq(pdev, 0);
>  > -if (irq == -ENXIO) {
>  > +if (i2c->flags & OCORES_FLAG_BROKEN_IRQ || irq == -ENXIO) {
> 
> 
> Alternatively you can move it after the irq = platform_get_irq(pdev, 0)
> line and just clear irq, E.G.:
> 
> irq = platform_get_irq(pdev, 0);
> 
> if (of_device_is_compatible(..)) {
>i2c->flags |= OCORES_FLAG_BROKEN_IRQ;
>irq = -ENXIO;
> }
> 
Yeah..
This is a better alternative implementation.
I will push v4 with this.

Thanks & BR,
Sagar

> if (irq == -ENXIO) {
> ..
> 
> --
> Bye, Peter Korsgaard


[PATCH] tracing: Remove __init from __trace_early_add_new_event()

2020-10-15 Thread Masami Hiramatsu
The commit 720dee53ad8d ("tracing/boot: Initialize per-instance event
list in early boot") removes __init from __trace_early_add_events()
but __trace_early_add_new_event() still has __init and will cause a
section mismatch.

Remove __init from __trace_early_add_new_event() as same as
__trace_early_add_events().

Reported-by: Linus Torvalds 
Signed-off-by: Masami Hiramatsu 
---
 kernel/trace/trace_events.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 851ab37058dd..e705f06c68c6 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2498,7 +2498,7 @@ __trace_add_new_event(struct trace_event_call *call, 
struct trace_array *tr)
  * for enabling events at boot. We want to enable events before
  * the filesystem is initialized.
  */
-static __init int
+static int
 __trace_early_add_new_event(struct trace_event_call *call,
struct trace_array *tr)
 {



[PATCHv4] selftests: rtnetlink: load fou module for kci_test_encap_fou() test

2020-10-15 Thread Po-Hsu Lin
The kci_test_encap_fou() test from kci_test_encap() in rtnetlink.sh
needs the fou module to work. Otherwise it will fail with:

  $ ip netns exec "$testns" ip fou add port  ipproto 47
  RTNETLINK answers: No such file or directory
  Error talking to the kernel

Add the CONFIG_NET_FOU into the config file as well. Which needs at
least to be set as a loadable module.

Signed-off-by: Po-Hsu Lin 
---
 tools/testing/selftests/net/config   | 1 +
 tools/testing/selftests/net/rtnetlink.sh | 5 +
 2 files changed, 6 insertions(+)

diff --git a/tools/testing/selftests/net/config 
b/tools/testing/selftests/net/config
index 3b42c06b..c5e50ab 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -31,3 +31,4 @@ CONFIG_NET_SCH_ETF=m
 CONFIG_NET_SCH_NETEM=y
 CONFIG_TEST_BLACKHOLE_DEV=m
 CONFIG_KALLSYMS=y
+CONFIG_NET_FOU=m
diff --git a/tools/testing/selftests/net/rtnetlink.sh 
b/tools/testing/selftests/net/rtnetlink.sh
index 7c38a90..6f8f159 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -520,6 +520,11 @@ kci_test_encap_fou()
return $ksft_skip
fi
 
+   if ! /sbin/modprobe -q -n fou; then
+   echo "SKIP: module fou is not found"
+   return $ksft_skip
+   fi
+   /sbin/modprobe -q fou
ip -netns "$testns" fou add port  ipproto 47 2>/dev/null
if [ $? -ne 0 ];then
echo "FAIL: can't add fou port , skipping test"
-- 
2.7.4



Re: [PATCH V2] cpufreq: tegra186: Fix initial frequency

2020-10-15 Thread Viresh Kumar
On 15-10-20, 15:03, Jon Hunter wrote:
> If not too late, would you mind dropping this patch for v5.10?

It is already part of Linus's master now.

-- 
viresh


Re: [GIT PULL] tracing: Updates for 5.10

2020-10-15 Thread Masami Hiramatsu
On Thu, 15 Oct 2020 23:54:44 -0400
Steven Rostedt  wrote:

> On Fri, 16 Oct 2020 11:53:23 +0900
> Masami Hiramatsu  wrote:
> 
> > > 
> > > I'll have to think about how to untangle this. Is there some kind of
> > > annotation that makes it show that a path can only be called at boot up 
> > > and
> > > not later?  
> > 
> > What happen if we use Peter's static_call() and update it after boot up? 
> 
> I think that's a bit over engineering ;-)
> 
> > Or, we might need to break apart the trace_array_create() and restruct
> > it as __init trace_array_early_create() and trace_array_create().
> 
> That will likely make the code a bit more complex and possibly add as much
> code as we save from the __init sections.
> 
> I think the best solution is what you proposed, and removing the __init,
> and possibly making that function inline as well.
> 
> Care to send an official patch?

Sure, I'll send it.

Thank you,

-- 
Masami Hiramatsu 


Re: [PATCH v1 09/29] virtio-mem: don't always trigger the workqueue when offlining memory

2020-10-15 Thread Wei Yang
On Mon, Oct 12, 2020 at 02:53:03PM +0200, David Hildenbrand wrote:
>Let's trigger from offlining code when we're not allowed to touch online
>memory.

This describes the change in virtio_mem_memory_notifier_cb()?

>
>Handle the other case (memmap possibly freeing up another memory block)
>when actually removing memory. When removing via virtio_mem_remove(),
>virtio_mem_retry() is a NOP and safe to use.
>
>While at it, move retry handling when offlining out of
>virtio_mem_notify_offline(), to share it with Device Block Mode (DBM)
>soon.

I may not understand the logic fully. Here is my understanding of current
logic:


  virtio_mem_run_wq()
  virtio_mem_unplug_request()
  virtio_mem_mb_unplug_any_sb_offline()
  virtio_mem_mb_remove() --- 1
  virtio_mem_mb_unplug_any_sb_online()
  virtio_mem_mb_offline_and_remove() --- 2

This patch tries to trigger the wq at 1 and 2. And these two functions are
only valid during this code flow.

These two functions actually remove some memory from the system. So I am not
sure where extra unplug-able memory comes from. I guess those memory is from
memory block device and mem_sectioin, memmap? While those memory is still
marked as online, right?

In case we can gather extra memory at 1 and form a whole memory block. So that
we can unplug an online memory block (by moving data to a new place), this
just affect the process at 2. This means there is no need to trigger the wq at
1, and we can leave it at 2.

>
>Cc: "Michael S. Tsirkin" 
>Cc: Jason Wang 
>Cc: Pankaj Gupta 
>Signed-off-by: David Hildenbrand 
>---
> drivers/virtio/virtio_mem.c | 40 ++---
> 1 file changed, 28 insertions(+), 12 deletions(-)
>
>diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
>index 5c93f8a65eba..8ea00f0b2ecd 100644
>--- a/drivers/virtio/virtio_mem.c
>+++ b/drivers/virtio/virtio_mem.c
>@@ -158,6 +158,7 @@ static DEFINE_MUTEX(virtio_mem_mutex);
> static LIST_HEAD(virtio_mem_devices);
> 
> static void virtio_mem_online_page_cb(struct page *page, unsigned int order);
>+static void virtio_mem_retry(struct virtio_mem *vm);
> 
> /*
>  * Register a virtio-mem device so it will be considered for the online_page
>@@ -435,9 +436,17 @@ static int virtio_mem_mb_add(struct virtio_mem *vm, 
>unsigned long mb_id)
> static int virtio_mem_mb_remove(struct virtio_mem *vm, unsigned long mb_id)
> {
>   const uint64_t addr = virtio_mem_mb_id_to_phys(mb_id);
>+  int rc;
> 
>   dev_dbg(>vdev->dev, "removing memory block: %lu\n", mb_id);
>-  return remove_memory(vm->nid, addr, memory_block_size_bytes());
>+  rc = remove_memory(vm->nid, addr, memory_block_size_bytes());
>+  if (!rc)
>+  /*
>+   * We might have freed up memory we can now unplug, retry
>+   * immediately instead of waiting.
>+   */
>+  virtio_mem_retry(vm);
>+  return rc;
> }
> 
> /*
>@@ -452,11 +461,19 @@ static int virtio_mem_mb_offline_and_remove(struct 
>virtio_mem *vm,
>   unsigned long mb_id)
> {
>   const uint64_t addr = virtio_mem_mb_id_to_phys(mb_id);
>+  int rc;
> 
>   dev_dbg(>vdev->dev, "offlining and removing memory block: %lu\n",
>   mb_id);
>-  return offline_and_remove_memory(vm->nid, addr,
>-   memory_block_size_bytes());
>+  rc = offline_and_remove_memory(vm->nid, addr,
>+ memory_block_size_bytes());
>+  if (!rc)
>+  /*
>+   * We might have freed up memory we can now unplug, retry
>+   * immediately instead of waiting.
>+   */
>+  virtio_mem_retry(vm);
>+  return rc;
> }
> 
> /*
>@@ -534,15 +551,6 @@ static void virtio_mem_notify_offline(struct virtio_mem 
>*vm,
>   BUG();
>   break;
>   }
>-
>-  /*
>-   * Trigger the workqueue, maybe we can now unplug memory. Also,
>-   * when we offline and remove a memory block, this will re-trigger
>-   * us immediately - which is often nice because the removal of
>-   * the memory block (e.g., memmap) might have freed up memory
>-   * on other memory blocks we manage.
>-   */
>-  virtio_mem_retry(vm);
> }
> 
> static void virtio_mem_notify_online(struct virtio_mem *vm, unsigned long 
> mb_id)
>@@ -679,6 +687,14 @@ static int virtio_mem_memory_notifier_cb(struct 
>notifier_block *nb,
>   break;
>   case MEM_OFFLINE:
>   virtio_mem_notify_offline(vm, mb_id);
>+
>+  /*
>+   * Trigger the workqueue. Now that we have some offline memory,
>+   * maybe we can handle pending unplug requests.
>+   */
>+  if (!unplug_online)
>+  virtio_mem_retry(vm);
>+
>   vm->hotplug_active = false;
>   mutex_unlock(>hotplug_mutex);
>  

Re: [PATCH v7 3/3] iommu/tegra-smmu: Add PCI support

2020-10-15 Thread Nicolin Chen
On Thu, Oct 15, 2020 at 10:55:52AM +0100, Robin Murphy wrote:
> On 2020-10-15 05:13, Nicolin Chen wrote:
> > On Wed, Oct 14, 2020 at 06:42:36PM +0100, Robin Murphy wrote:
> > > On 2020-10-09 17:19, Nicolin Chen wrote:
> > > > This patch simply adds support for PCI devices.
> > > > 
> > > > Reviewed-by: Dmitry Osipenko 
> > > > Tested-by: Dmitry Osipenko 
> > > > Signed-off-by: Nicolin Chen 
> > > > ---
> > > > 
> > > > Changelog
> > > > v6->v7
> > > >* Renamed goto labels, suggested by Thierry.
> > > > v5->v6
> > > >* Added Dmitry's Reviewed-by and Tested-by.
> > > > v4->v5
> > > >* Added Dmitry's Reviewed-by
> > > > v3->v4
> > > >* Dropped !iommu_present() check
> > > >* Added CONFIG_PCI check in the exit path
> > > > v2->v3
> > > >* Replaced ternary conditional operator with if-else in 
> > > > .device_group()
> > > >* Dropped change in tegra_smmu_remove()
> > > > v1->v2
> > > >* Added error-out labels in tegra_smmu_probe()
> > > >* Dropped pci_request_acs() since IOMMU core would call it.
> > > > 
> > > >drivers/iommu/tegra-smmu.c | 35 +--
> > > >1 file changed, 25 insertions(+), 10 deletions(-)
> > > > 
> > > > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> > > > index be29f5977145..2941d6459076 100644
> > > > --- a/drivers/iommu/tegra-smmu.c
> > > > +++ b/drivers/iommu/tegra-smmu.c
> > > > @@ -10,6 +10,7 @@
> > > >#include 
> > > >#include 
> > > >#include 
> > > > +#include 
> > > >#include 
> > > >#include 
> > > >#include 
> > > > @@ -865,7 +866,11 @@ static struct iommu_group 
> > > > *tegra_smmu_device_group(struct device *dev)
> > > > group->smmu = smmu;
> > > > group->soc = soc;
> > > > -   group->group = iommu_group_alloc();
> > > > +   if (dev_is_pci(dev))
> > > > +   group->group = pci_device_group(dev);
> > > 
> > > Just to check, is it OK to have two or more swgroups "owning" the same
> > > iommu_group if an existing one gets returned here? It looks like that 
> > > might
> > > not play nice with the use of iommu_group_set_iommudata().
> > 
> > Do you mean by "gets returned here" the "IS_ERR" check below?
> 
> I mean that unlike iommu_group_alloc()/generic_device_group(),
> pci_device_group() may give you back a group that already contains another
> device and has already been set up from that device's perspective. This can
> happen for topological reasons like requester ID aliasing through a PCI-PCIe
> bridge or lack of isolation between functions.

Okay..but we don't really have two swgroups owning the same groups
in case of PCI devices. For Tegra210, all PCI devices inherit the
same swgroup from the PCI controller. And I'd think previous chips
do the same. The only use case currently of 2+ swgroups owning the
same iommu_group is for display controller.

Or do you suggest we need an additional check for pci_device_group?


Re: [RFC PATCH 2/3] hugetlbfs: introduce hinode_rwsem for pmd sharing synchronization

2020-10-15 Thread Mike Kravetz
On 10/15/20 4:05 PM, HORIGUCHI NAOYA(堀口 直也) wrote:
> On Tue, Oct 13, 2020 at 04:10:59PM -0700, Mike Kravetz wrote:
>> Due to pmd sharing, the huge PTE pointer returned by huge_pte_alloc
>> may not be valid.  This can happen if a call to huge_pmd_unshare for
>> the same pmd is made in another thread.
>>
>> To address this issue, add a rw_semaphore (hinode_rwsem) to the hugetlbfs
>> inode.
>> - hinode_rwsem is taken in read mode before calling huge_pte_alloc, and
>>   held until finished with the returned pte pointer.
>> - hinode_rwsem is held in write mode whenever huge_pmd_unshare is called.
>>
>> In the locking hierarchy, hinode_rwsem must be taken before a page lock.
>>
>> In an effort to minimize performance impacts, hinode_rwsem is not taken
>> if the caller knows the target can not possibly be part of a shared pmd.
>> lockdep_assert calls are added to huge_pmd_share and huge_pmd_unshare to
>> help catch callers not using the proper locking.
>>
>> Signed-off-by: Mike Kravetz 
> 
> Hi Mike,
> 
> I didn't find a problem on main idea of introducing hinode_rwsem, so
> I'm fine if the known problems are fixed.

Thank you for taking a look Naoya!

I have been trying to address these race issues for some time.  The issues
have been there since the pmd sharing code was introduced.  Fortunately,
it is not easy to hit the issue.  However, targeted test programs can cause
BUGs.

> I have one question. This patch seems to make sure that huge_pmd_unshare()
> are called under holding hinode_rwsem in write mode for some case. Some
> callers of try_to_unmap() seem not to hold it like shrink_page_list(),
> unmap_page(), which is OK because they never call try_to_unmap() for hugetlb
> pages.  And unmap_ref_private() doesn't takes hinode_rwsem either, and
> that's also OK because this function never handles pmd sharing case.  So
> what about unmap_single_vma()?  It seems that this generic function could
> reach huge_pmd_unshare() without hinode_rwsem, so what prevents the race here?
> (Maybe I might miss some assumption or condition over this race...)

You are not missing anything.  I mistakingly left out the locking code in
of unmap_single_vma().  If I would have run some tests with lockdep enabled,
the new lock checking code would have noticed.

> 
> I left a few other minor comments below ...

I will address the below issues in the next revision.

Thanks again for taking a look.
-- 
Mike Kravetz

> 
>> @@ -4424,6 +4442,11 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct 
>> vm_area_struct *vma,
>>  
>>  ptep = huge_pte_offset(mm, haddr, huge_page_size(h));
>>  if (ptep) {
>> +/*
>> + * Since we hold no locks, ptep could be stale.  That is
>> + * OK as we are only making decisions based on content and
>> + * not actually modifying content here.
>> + */
> 
> nice comment, thank you.
> 
>>  entry = huge_ptep_get(ptep);
>>  if (unlikely(is_hugetlb_entry_migration(entry))) {
>>  migration_entry_wait_huge(vma, mm, ptep);
>> @@ -4431,20 +4454,32 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, 
>> struct vm_area_struct *vma,
>>  } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry)))
>>  return VM_FAULT_HWPOISON_LARGE |
>>  VM_FAULT_SET_HINDEX(hstate_index(h));
>> -} else {
>> -ptep = huge_pte_alloc(mm, haddr, huge_page_size(h));
>> -if (!ptep)
>> -return VM_FAULT_OOM;
>>  }
>>  
>> +/*
>> + * Acquire hinode_sem before calling huge_pte_alloc and hold
> 
>hinode_rwsem?
> 
>> + * until finished with ptep.  This prevents huge_pmd_unshare from
>> + * being called elsewhere and making the ptep no longer valid.
>> + *
>> + * ptep could have already be assigned via huge_pte_offset.  That
>> + * is OK, as huge_pte_alloc will return the same value unless
>> + * something has changed.
>> + */
> 
> ... 
> 
>> @@ -278,10 +278,14 @@ static __always_inline ssize_t 
>> __mcopy_atomic_hugetlb(struct mm_struct *dst_mm,
>>  BUG_ON(dst_addr >= dst_start + len);
>>  
>>  /*
>> - * Serialize via hugetlb_fault_mutex
>> + * Serialize via hinode_rwsem hugetlb_fault_mutex.
>  ^ "and" here?
> 
>> + * hinode_rwsem ensures the dst_pte remains valid even
>> + * in the case of shared pmds.  fault mutex prevents
>> + * races with other faulting threads.
>>   */
>>  idx = linear_page_index(dst_vma, dst_addr);
>>  mapping = dst_vma->vm_file->f_mapping;
>> +hinode_lock_read(mapping, dst_vma, dst_addr);
>>  hash = hugetlb_fault_mutex_hash(mapping, idx);
>>  mutex_lock(_fault_mutex_table[hash]);
> 
> 
> Thanks,
> Naoya Horiguchi
> 


Re: [PATCH v4 00/32] Make charlcd device independent

2020-10-15 Thread Miguel Ojeda
On Fri, Oct 16, 2020 at 4:33 AM Miguel Ojeda
 wrote:
>
> Picking these for linux-next (including Rob's Reviewed-by). I have
> spotted a few typos that I corrected -- I will note them by email.

Hmm, I think we should do another round instead, since I found what
looks to be an unintended revert of a previous commit in patch 24.
Lars, can you please take a look?

Also, please take the chance to apply my comments given we have a new
round (and Rob's Reviewed-by too).

By the way, I think you could simplify by squashing the "implement
hd44780_*" commits together (i.e. from 15 to 22 except 20), and the
two cleanups together too (i.e. 20 and 23). I know we asked you to
split things up before, but those two sets are quite similar
(including in their commit message) and easy to understand all
together.

Cheers,
Miguel


Re: [PATCH v4 08/32] auxdisplay: hd44780_common_print

2020-10-15 Thread Miguel Ojeda
On Mon, Oct 5, 2020 at 2:27 PM  wrote:
>
> We create a hd44780_common_print function. It is derived from the
> original charlcd_print. charlcd_print becomes a device independent print
> function, that then only calles via it's ops function pointers, into the

Typos: calles -> calls, it's -> its

> + * @clear_fast: Clear the whole display and set cursor to position 0, 0.

This one is optional, but the comment seems to say it isn't (it is
later removed, so in the end it doesn't matter, but probably we should
write "Optional." here too).

> + * @backlight: Turn backlight on or off. Optional.
> + * @print: just Print one character to the display at current cursor 
> position.

Typo: remove "just"

Cheers,
Miguel


Re: [GIT PULL] tracing: Updates for 5.10

2020-10-15 Thread Steven Rostedt
On Fri, 16 Oct 2020 11:53:23 +0900
Masami Hiramatsu  wrote:

> > 
> > I'll have to think about how to untangle this. Is there some kind of
> > annotation that makes it show that a path can only be called at boot up and
> > not later?  
> 
> What happen if we use Peter's static_call() and update it after boot up? 

I think that's a bit over engineering ;-)

> Or, we might need to break apart the trace_array_create() and restruct
> it as __init trace_array_early_create() and trace_array_create().

That will likely make the code a bit more complex and possibly add as much
code as we save from the __init sections.

I think the best solution is what you proposed, and removing the __init,
and possibly making that function inline as well.

Care to send an official patch?

Thanks!

-- Steve


[PATCH] power: suspend: Add suspend timeout handler

2020-10-15 Thread Joseph Jang
From: josephjang 

Add suspend timeout handler to prevent device stuck during suspend/
resume process. Suspend timeout handler will dump disk sleep task
at first round timeout and trigger kernel panic at second round timeout.
The default timer for each round is 30 seconds.

Note: Can use following command to simulate suspend hang for testing.
adb shell echo 1 > /sys/power/pm_hang
adb shell echo mem > /sys/power/state
Signed-off-by: josephjang 
---
 include/linux/console.h |   1 +
 kernel/power/Kconfig|   9 +++
 kernel/power/main.c |  66 
 kernel/power/suspend.c  | 162 
 kernel/printk/printk.c  |   5 ++
 5 files changed, 243 insertions(+)

diff --git a/include/linux/console.h b/include/linux/console.h
index 0670d3491e0e..ac468c602c0b 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -192,6 +192,7 @@ static inline void console_sysfs_notify(void)
 { }
 #endif
 extern bool console_suspend_enabled;
+extern int is_console_suspended(void);
 
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index a7320f07689d..52b7a181b6d8 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -207,6 +207,15 @@ config PM_SLEEP_DEBUG
def_bool y
depends on PM_DEBUG && PM_SLEEP
 
+config PM_SLEEP_MONITOR
+   bool "Linux kernel suspend/resume process monitor"
+   depends on PM_SLEEP
+   help
+   This option will enable suspend/resume monitor to prevent device
+   stuck during suspend/resume process. Suspend timeout handler will
+   dump disk sleep task at first round timeout and trigger kernel panic
+   at second round timeout. The default timer for each round is 30 seconds.
+
 config DPM_WATCHDOG
bool "Device suspend/resume watchdog"
depends on PM_DEBUG && PSTORE && EXPERT
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 40f86ec4ab30..f25b8a47583e 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -575,6 +575,69 @@ void __pm_pr_dbg(bool defer, const char *fmt, ...)
 static inline void pm_print_times_init(void) {}
 #endif /* CONFIG_PM_SLEEP_DEBUG */
 
+#ifdef CONFIG_PM_SLEEP_MONITOR
+/* If set, devices will stuck at suspend for verification */
+static bool pm_hang_enabled;
+
+static int pm_notify_test(struct notifier_block *nb,
+unsigned long mode, void *_unused)
+{
+   pr_info("Jump into infinite loop now\n");
+
+   /* Suspend thread stuck at a loop forever */
+   for (;;)
+   ;
+
+   pr_info("Fail to stuck at loop\n");
+
+   return 0;
+}
+
+static struct notifier_block pm_notify_nb = {
+   .notifier_call = pm_notify_test,
+};
+
+static ssize_t pm_hang_show(struct kobject *kobj, struct kobj_attribute *attr,
+char *buf)
+{
+   return snprintf(buf, 10, "%d\n", pm_hang_enabled);
+}
+
+static ssize_t pm_hang_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buf, size_t n)
+{
+   unsigned long val;
+   int result;
+
+   if (kstrtoul(buf, 10, ))
+   return -EINVAL;
+
+   if (val > 1)
+   return -EINVAL;
+
+   pm_hang_enabled = !!val;
+
+   if (pm_hang_enabled == true) {
+
+   result = register_pm_notifier(_notify_nb);
+   if (result)
+   pr_warn("Can not register suspend notifier, return 
%d\n",
+   result);
+
+   } else {
+
+   result = unregister_pm_notifier(_notify_nb);
+   if (result)
+   pr_warn("Can not unregister suspend notifier, return 
%d\n",
+   result);
+   }
+
+   return n;
+}
+
+power_attr(pm_hang);
+#endif
+
 struct kobject *power_kobj;
 
 /**
@@ -909,6 +972,9 @@ static struct attribute * g[] = {
_wakeup_irq_attr.attr,
_debug_messages_attr.attr,
 #endif
+#ifdef CONFIG_PM_SLEEP_MONITOR
+   _hang_attr.attr,
+#endif
 #endif
 #ifdef CONFIG_FREEZER
_freeze_timeout_attr.attr,
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 8b1bb5ee7e5d..6f2679cfd9d1 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -30,6 +30,12 @@
 #include 
 #include 
 #include 
+#ifdef CONFIG_PM_SLEEP_MONITOR
+#include 
+#include 
+#include 
+#include 
+#endif
 
 #include "power.h"
 
@@ -61,6 +67,133 @@ static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
 enum s2idle_states __read_mostly s2idle_state;
 static DEFINE_RAW_SPINLOCK(s2idle_lock);
 
+#ifdef CONFIG_PM_SLEEP_MONITOR
+/* Suspend monitor thread toggle reason */
+enum toggle_reason {
+   TOGGLE_NONE,
+   TOGGLE_START,
+   TOGGLE_STOP,
+};
+
+#define SUSPEND_TIMER_TIMEOUT_MS 3
+static struct task_struct *ksuspend_mon_tsk;
+static DECLARE_WAIT_QUEUE_HEAD(power_suspend_waitqueue);
+static enum 

[PATCH] mm: vmscan: avoid a unnecessary reschedule in shrink_slab()

2020-10-15 Thread Xianting Tian
In shrink_slab(), it directly goes to 'out' label only when it
can't get the lock of shrinker_rwsew. In this case, it doesn't
do the real work of shrinking slab, so we don't need trigger a
reschedule by cond_resched().

Signed-off-by: Xianting Tian 
---
 mm/vmscan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 466fc3144..676e97b28 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -687,8 +687,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
}
 
up_read(_rwsem);
-out:
+
cond_resched();
+out:
return freed;
 }
 
-- 
2.17.1



Re: [PATCH V2] scripts: spelling: Remove space in the entry memry to memory

2020-10-15 Thread Bhaskar Chowdhury

On 20:19 Thu 15 Oct 2020, Joe Perches wrote:

On Fri, 2020-10-16 at 04:38 +0530, Bhaskar Chowdhury wrote:

On 16:06 Thu 15 Oct 2020, Joe Perches wrote:
> On Fri, 2020-10-16 at 04:25 +0530, Bhaskar Chowdhury wrote:
> > You have all flawed understanding...please stay away ..
> > if you don't understand something...
>
>   You're funny.
>
> You're wrong, but you're still funny.
>
>
ROFL ..you too...what a waste of time ...shame that I am engage this kind of
conversation ...heck


Your tone doesn't become you.

Same  goes you too...


Please try to be polite next time.


Please stop sending unnecessary "reviews" too. Thanks. If I need ,I will ask.

Well, didn't I appreciate your feedback first time?? It the following that
stupid and garbage .


I'm rather familiar with the appropriate process.

$ git shortlog -n -s --author="Joe Perches" --author="Bhaskar Chowdhury"
 3227  Joe Perches
8  Bhaskar Chowdhury
1  Joe Perches via samba-technical


Never doubt that ..but you clinging on something not true is surprise me...I
believe you do better next time.

This is the most "useless" thread I have ever been...

Stop propagating it ...>


signature.asc
Description: PGP signature


Re: fw_devlink on will break all snps,dw-apb-gpio users

2020-10-15 Thread Jisheng Zhang
On Thu, 15 Oct 2020 15:08:33 +0100
Robin Murphy  wrote:

> 
> 
> On 2020-10-15 10:52, Jisheng Zhang wrote:
> > On Thu, 15 Oct 2020 01:48:13 -0700
> > Saravana Kannan  wrote:
> >  
> >> On Thu, Oct 15, 2020 at 1:15 AM Jisheng Zhang
> >>  wrote:  
> >>>
> >>> On Wed, 14 Oct 2020 22:04:24 -0700 Saravana Kannan wrote:
> >>>  
> 
> 
>  On Wed, Oct 14, 2020 at 9:02 PM Jisheng Zhang
>   wrote:  
> >
> > On Wed, 14 Oct 2020 10:29:36 -0700
> > Saravana Kannan  wrote:
> >  
> >>
> >>
> >> On Wed, Oct 14, 2020 at 4:12 AM Jisheng Zhang
> >>  wrote:  
> >>>
> >>> Hi,
> >>>
> >>> If set fw_devlink as on, any consumers of dw apb gpio won't probe.
> >>>
> >>> The related dts looks like:
> >>>
> >>> gpio0: gpio@2400 {
> >>> compatible = "snps,dw-apb-gpio";
> >>> #address-cells = <1>;
> >>> #size-cells = <0>;
> >>>
> >>> porta: gpio-port@0 {
> >>>compatible = "snps,dw-apb-gpio-port";
> >>>gpio-controller;
> >>>#gpio-cells = <2>;
> >>>ngpios = <32>;
> >>>reg = <0>;
> >>> };
> >>> };
> >>>
> >>> device_foo {
> >>>  status = "okay"
> >>>  ...;
> >>>  reset-gpio = <, 0, GPIO_ACTIVE_HIGH>;
> >>> };
> >>>
> >>> If I change the reset-gpio property to use another kind of gpio 
> >>> phandle,
> >>> e.g gpio expander, then device_foo can be probed successfully.
> >>>
> >>> The gpio expander dt node looks like:
> >>>
> >>>  expander3: gpio@44 {
> >>>  compatible = "fcs,fxl6408";
> >>>  pinctrl-names = "default";
> >>>  pinctrl-0 = <_pmux>;
> >>>  reg = <0x44>;
> >>>  gpio-controller;
> >>>  #gpio-cells = <2>;
> >>>  interrupt-parent = <>;
> >>>  interrupts = <23 IRQ_TYPE_NONE>;
> >>>  interrupt-controller;
> >>>  #interrupt-cells = <2>;
> >>>  };
> >>>
> >>> The common pattern looks like the devlink can't cope with suppliers 
> >>> from
> >>> child dt node.  
> >>
> >> fw_devlink doesn't have any problem dealing with child devices being
> >> suppliers. The problem with your case is that the
> >> drivers/gpio/gpio-dwapb.c driver directly parses the child nodes and
> >> never creates struct devices for them. If you have a node with
> >> compatible string, fw_devlink expects you to create and probe a struct
> >> device for it. So change your driver to add the child devices as
> >> devices instead of just parsing the node directly and doing stuff with
> >> it.
> >>
> >> Either that, or stop putting "compatible" string in a node if you
> >> don't plan to actually treat it as a device -- but that's too late for
> >> this driver (it needs to be backward compatible). So change the driver
> >> to add of_platform_populate() and write a driver that probes
> >> "snps,dw-apb-gpio-port".
> >>  
> >
> > Thanks for the information. The "snps,dw-apb-gpio-port" is never used,
> > so I just sent out a series to remove it.  
> 
>  I'd actually prefer that you fix the kernel code to actually use it.
>  So that fw_devlink can be backward compatible (Older DT + new kernel).
>  The change is pretty trivial (I just have time to do it for you).
>   
> >>>
> >>> I agree the change is trivial, but it will add some useless LoCs like 
> >>> below.  
> >>
> >> It's not useless if it preserves backward compatibility with DT.
> >>  
> >>> I'm not sure whether this is acceptable.So add GPIO and DT maintainers to 
> >>> comment.
> >>>
> >>> Hi Linus, Rob,
> >>>
> >>> Could you please comment? A simple introduction of the problem:
> >>>
> >>> As pointed out by Saravana, "gpio-dwapb.c driver directly parses the child
> >>> nodes and never creates struct devices for them. If you have a node with
> >>> compatible string, fw_devlink expects you to create and probe a struct
> >>> device for it", so once we set fw_devlink=on, then any users of gpio-dwapb
> >>> as below won't be probed.
> >>>
> >>> device_foo {
> >>>   status = "okay"
> >>>   ...;
> >>>   reset-gpio = <, 0, GPIO_ACTIVE_HIGH>;
> >>> };
> >>>
> >>> The compatible string "snps,dw-apb-gpio-port" is never used, but it's in
> >>> the dt-binding since the dw gpio mainlined. I believe the every dw apb
> >>> users just copy the compatible string in to soc dtsi. So I submit a series
> >>> to remove the unused "snps,dw-apb-gpio-port" 
> >>> But this will break Older DT + new kernel with fw_devlink on. Which 
> >>> solution
> >>> is better?
> >>>
> >>> If the following patch is acceptable, I can submit it once 5.10-rc1 is 
> >>> out.
> >>>
> >>> 

Re: Dts for eth network based on marvell's mv88e6390x crashes Xilinx's linux-kernel v5.4

2020-10-15 Thread Andrew Lunn
On Sun, Oct 11, 2020 at 03:31:52PM +0300, michael alayev wrote:
> Hello,
> 
> This is my system's network topology. It relies on Xilinx's Zynq-7000 soc.
> 
> zynq-7000  switch1   switch2
>  (cpu)   mv88e6390xmv88e6390x
> ---  - -
> | |  |   | |   |
> | gem0|--|p0  p10|-|p10|
> | |  |   | |   |
> | |  - -
> | | |mdio_addr=2   | mdio_addr=3
> | | |  |
> | |-
> | ||
> | ||  mv88e1510(phy)
> | ||  mdio_addr=1 
> | |---|  |
> | |   |  |
> | gem1|---|  |
> | |   |  |
> | |   
> ---
> 
> I have built a v5.4 linux kernel for it and its ethernet network defined in 
> the device-tree as follows
> 
> (arch/arm/boot/dts/zynq-zed.dts gem0 and gem1)   :
> 
>  {
> status = "okay";
> phy-mode = "rgmii-id";
> phy-handle = <>;
> 
> 
> mdio {
> #address-cells = <1>;
> #size-cells = <0>;
> 
> phy0: ethernet-phy@0 {
> compatible = "marvell";
> reg = <0>;
> device_type = "ethernet-phy";
> fixed-link {
> speed = <1000>;
> full-duplex;
> };
> };
> 
> debug_phy: ethernet-phy@1 {
> compatible = "marvell";
> reg = <1>;
> device_type = "ethernet-phy";
> label = "debug-phy";
> };

Hi Michael

This is pretty unreadable with all the white space removed. Please
could you post again with the white space.

> 
> Starting kernel ...
> ...
> [   40.953876] [] (dsa_unregister_switch) from [] 
> (mv88e6xxx_remove+0x1c/0x6c)
> [   40.962602] [] (mv88e6xxx_remove) from [] 
> (mdio_remove+0x1c/0x38)
> [   40.970457] [] (mdio_remove) from [] 
> (device_release_driver_internal+0xf0/0x194)
> [   40.979612] [] (device_release_driver_internal) from 
> [] (bus_remove_device+0xcc/0xdc)
> [   40.989201] [] (bus_remove_device) from [] 
> (device_del+0x170/0x288)
> [   40.997227] [] (device_del) from [] 
> (mdio_device_remove+0xc/0x18)
> [   41.005073] [] (mdio_device_remove) from [] 
> (mdiobus_unregister+0x50/0x84)
> [   41.013714] [] (mdiobus_unregister) from [] 
> (macb_probe+0x88c/0xa68)
> [   41.021834] [] (macb_probe) from [] 
> (platform_drv_probe+0x48/0x98)
> [   41.029771] [] (platform_drv_probe) from [] 
> (really_probe+0x140/0x2f8)
> [   41.038060] [] (really_probe) from [] 
> (driver_probe_device+0x10c/0x154)
> [   41.046427] [] (driver_probe_device) from [] 
> (device_driver_attach+0x44/0x5c)
> [   41.055316] [] (device_driver_attach) from [] 
> (__driver_attach+0xac/0xb8)
> [   41.063856] [] (__driver_attach) from [] 
> (bus_for_each_dev+0x64/0xa0)
> [   41.072049] [] (bus_for_each_dev) from [] 
> (bus_add_driver+0xdc/0x1bc)
> [   41.080244] [] (bus_add_driver) from [] 
> (driver_register+0xb0/0xf8)
> [   41.088266] [] (driver_register) from [] 
> (do_one_initcall+0x74/0x164)
> [   41.096469] [] (do_one_initcall) from [] 
> (kernel_init_freeable+0x108/0x1d8)
> [   41.105192] [] (kernel_init_freeable) from [] 
> (kernel_init+0x8/0x110)
> [   41.113391] [] (kernel_init) from [] 
> (ret_from_fork+0x14/0x2c)

This looks like the classic first time probe -EPROBE_DEFER. You expect
this path to happen, but not the invalid access. macb_probe will
register the mdio bus which causes the switches to probe. But because
macb_probe has not got so far as to call register_netdev, the gem
interface is not available, so DSA ends up returning
EPROBE_DEFER. What normally happens is that macb_probe continues, and
registers the network interface. The switches get probed again later
and it all works.

The real question is, why does the unroll go wrong when -EPROBE_DEFER
is returned?

   Andrew


Re: [PATCH v6 02/11] mm/gup: Use functions to track lockless pgtbl walks on gup_pgd_range

2020-10-15 Thread Aneesh Kumar K.V

Hi Michal,

On 10/15/20 8:16 PM, Michal Suchánek wrote:

Hello,

On Thu, Feb 06, 2020 at 12:25:18AM -0300, Leonardo Bras wrote:

On Thu, 2020-02-06 at 00:08 -0300, Leonardo Bras wrote:

 gup_pgd_range(addr, end, gup_flags, pages, );
-   local_irq_enable();
+   end_lockless_pgtbl_walk(IRQS_ENABLED);
 ret = nr;
 }
  


Just noticed IRQS_ENABLED is not available on other archs than ppc64.
I will fix this for v7.


Has threre been v7?

I cannot find it.

Thanks

Michal



https://lore.kernel.org/linuxppc-dev/20200505071729.54912-1-aneesh.ku...@linux.ibm.com

This series should help here.

-aneesh


Re: [PATCH v4 32/32] auxdisplay: add a driver for lcd2s character display

2020-10-15 Thread Miguel Ojeda
On Mon, Oct 5, 2020 at 3:01 PM  wrote:
>
> +   while (*esc && i < LCD2S_CHARACTER_SIZE + 2) {
> +   shift ^= 4;
> +   if (*esc >= '0' && *esc <= '9') {
> +   value |= (*esc - '0') << shift;
> +   } else if (*esc >= 'A' && *esc <= 'Z') {
> +   value |= (*esc - 'A' + 10) << shift;
> +   } else if (*esc >= 'a' && *esc <= 'z') {
> +   value |= (*esc - 'a' + 10) << shift;

This should also probably use hex_to_bin() or similar (see my other
comment on patch 24) and/or share the implementation as much as
possible.

Cheers,
Miguel


[GIT PULL] Please pull powerpc/linux.git powerpc-5.10-1 tag

2020-10-15 Thread Michael Ellerman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hi Linus,

Please pull powerpc updates for 5.10.

Just two minor conflicts I'm aware of. The only slight subtlety is the conflict
in kasan_init() where "int ret" needs to move out of the for_each_mem_range()
and up to the function scope.

Notable out of area changes:
  arch/sparc/kernel/smp_64.c# bafb056ce279 sparc64: remove mm_cpumask 
clearing to fix kthread_use_mm race
  fs/exec.c # d53c3dfb23c4 mm: fix exec activate_mm vs TLB 
shootdown and lazy tlb switching race
  include/uapi/linux/mman.h # e47168f3d1b1 powerpc/8xx: Support 16k 
hugepages with 4k pages
  include/uapi/asm-generic/hugetlb_encode.h # as above

cheers


The following changes since commit d012a7190fc1fd72ed48911e77ca97ba4521bccd:

  Linux 5.9-rc2 (2020-08-23 14:08:43 -0700)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
tags/powerpc-5.10-1

for you to fetch changes up to ffd0b25ca049a477cb757e5bcf2d5e1664d12e5d:

  Revert "powerpc/pci: unmap legacy INTx interrupts when a PHB is removed" 
(2020-10-15 13:42:49 +1100)


- --
powerpc updates for 5.10

 - A series from Nick adding ARCH_WANT_IRQS_OFF_ACTIVATE_MM & selecting it for
   powerpc, as well as a related fix for sparc.

 - Remove support for PowerPC 601.

 - Some fixes for watchpoints & addition of a new ptrace flag for detecting ISA
   v3.1 (Power10) watchpoint features.

 - A fix for kernels using 4K pages and the hash MMU on bare metal Power9
   systems with > 16TB of RAM, or RAM on the 2nd node.

 - A basic idle driver for shallow stop states on Power10.

 - Tweaks to our sched domains code to better inform the scheduler about the
   hardware topology on Power9/10, where two SMT4 cores can be presented by
   firmware as an SMT8 core.

 - A series doing further reworks & cleanups of our EEH code.

 - Addition of a filter for RTAS (firmware) calls done via sys_rtas(), to
   prevent root from overwriting kernel memory.

 - Other smaller features, fixes & cleanups.

Thanks to:
  Alexey Kardashevskiy, Andrew Donnellan, Aneesh Kumar K.V, Athira Rajeev, Biwen
  Li, Cameron Berkenpas, Cédric Le Goater, Christophe Leroy, Christoph Hellwig,
  Colin Ian King, Daniel Axtens, David Dai, Finn Thain, Frederic Barrat, Gautham
  R. Shenoy, Greg Kurz, Gustavo Romero, Ira Weiny, Jason Yan, Joel Stanley,
  Jordan Niethe, Kajol Jain, Konrad Rzeszutek Wilk, Laurent Dufour, Leonardo
  Bras, Liu Shixin, Luca Ceresoli, Madhavan Srinivasan, Mahesh Salgaonkar,
  Nathan Lynch, Nicholas Mc Guire, Nicholas Piggin, Nick Desaulniers, Oliver
  O'Halloran, Pedro Miraglia Franco de Carvalho, Pratik Rajesh Sampat, Qian Cai,
  Qinglang Miao, Ravi Bangoria, Russell Currey, Satheesh Rajendran, Scott
  Cheloha, Segher Boessenkool, Srikar Dronamraju, Stan Johnson, Stephen Kitt,
  Stephen Rothwell, Thiago Jung Bauermann, Tyrel Datwyler, Vaibhav Jain,
  Vaidyanathan Srinivasan, Vasant Hegde, Wang Wensheng, Wolfram Sang, Yang
  Yingliang, zhengbin.

- --
Andrew Donnellan (2):
  powerpc/rtas: Restrict RTAS requests from userspace
  selftests/powerpc: Add a rtas_filter selftest

Aneesh Kumar K.V (11):
  powerpc/vmemmap: Fix memory leak with vmemmap list allocation failures.
  powerpc/vmemmap: Don't warn if we don't find a mapping vmemmap list entry
  powerpc/percpu: Update percpu bootmem allocator
  powerpc/64/mm: implement page mapping percpu first chunk allocator
  powerpc/book3s64/hash/4k: Support large linear mapping range with 4K
  powerpc/mm/book3s: Split radix and hash MAX_PHYSMEM limit
  powerepc/book3s64/hash: Align start/end address correctly with bolt 
mapping
  powerpc/drmem: Make lmb_size 64 bit
  powerpc/memhotplug: Make lmb size 64bit
  powerpc/book3s64/radix: Make radix_mem_block_size 64bit
  powerpc/lmb-size: Use addr #size-cells value when fetching lmb-size

Athira Rajeev (1):
  powerpc/perf: Exclude pmc5/6 from the irrelevant PMU group constraints

Biwen Li (2):
  powerpc/dts/t4240rdb: remove interrupts property
  powerc/dtc/t1024rdb: remove interrupts property

Christoph Hellwig (1):
  powerpc: switch 85xx defconfigs from legacy ide to libata

Christophe Leroy (52):
  powerpc/32s: Fix assembler warning about r0
  powerpc/hwirq: Remove stale forward irq_chip declaration
  powerpc/irq: Drop forward declaration of struct irqaction
  powerpc/fpu: Drop cvt_fd() and cvt_df()
  powerpc: drop hard_reset_now() and poweroff_now() declaration
  powerpc: Drop _nmask_and_or_msr()
  powerpc: Remove flush_instruction_cache for book3s/32
  powerpc: Move flush_instruction_cache() prototype in asm/cacheflush.h
  powerpc: Rewrite 4xx flush_cache_instruction() in C
  powerpc: Rewrite FSL_BOOKE flush_cache_instruction() in C
  powerpc: Remove 

Re: [PATCH V2] scripts: spelling: Remove space in the entry memry to memory

2020-10-15 Thread Joe Perches
On Fri, 2020-10-16 at 04:38 +0530, Bhaskar Chowdhury wrote:
> On 16:06 Thu 15 Oct 2020, Joe Perches wrote:
> > On Fri, 2020-10-16 at 04:25 +0530, Bhaskar Chowdhury wrote:
> > > You have all flawed understanding...please stay away ..
> > > if you don't understand something...
> > 
> >   You're funny.
> > 
> > You're wrong, but you're still funny.
> > 
> > 
> ROFL ..you too...what a waste of time ...shame that I am engage this kind of
> conversation ...heck

Your tone doesn't become you.
Please try to be polite next time.
I'm rather familiar with the appropriate process.

$ git shortlog -n -s --author="Joe Perches" --author="Bhaskar Chowdhury"
  3227  Joe Perches
 8  Bhaskar Chowdhury
 1  Joe Perches via samba-technical



Re: [PATCH v4 24/32] auxdisplay: Move char redefine code to hd44780_common

2020-10-15 Thread Miguel Ojeda
On Mon, Oct 5, 2020 at 3:01 PM  wrote:
>
> +   while (*esc && cgoffset < 8) {
> +   shift ^= 4;
> +   if (*esc >= '0' && *esc <= '9') {
> +   value |= (*esc - '0') << shift;
> +   } else if (*esc >= 'A' && *esc <= 'F') {
> +   value |= (*esc - 'A' + 10) << shift;
> +   } else if (*esc >= 'a' && *esc <= 'f') {
> +   value |= (*esc - 'a' + 10) << shift;

I just noticed this is undoing commit 3f03b6498 ("auxdisplay: charlcd:
Reuse hex_to_bin() instead of custom code"). Lars?

Cheers,
Miguel


Re: [PATCH v4 3/3] clk: qcom: lpasscc-sc7180: Re-configure the PLL in case lost

2020-10-15 Thread Stephen Boyd
Quoting Douglas Anderson (2020-10-14 17:13:29)
> From: Taniya Das 
> 
> In the case where the PLL configuration is lost, then the pm runtime
> resume will reconfigure before usage.

Taniya, this commit needs a lot more describing than one sentence. I see
that the PLL's L value is reset at boot, but only once. That seems to be
because the bootloader I have doesn't set bit 11 for the RETAIN_FF bit
on the lpass_core_hm_gdsc. Once the gdsc is turned off the first time,
the PLL settings are lost and the L val is reset to 0. That makes sense
because RETAIN_FF isn't set. This also means the other register writes
during probe are lost during the first suspend of the lpass core clk
controller. Then when the GDSC is turned on the next time for this clk
controller  being runtime resumed we will set the retain bit and then
configure the PLL again. BTW, I see that runtime PM is called for this
clk controller for all the clk operations. Maybe there should be some
auto suspend timeout so that we're not toggling the gdsc constantly?

I hacked up the GDSC code to set the bit at gdsc registration time and
it seems to fix the problem I'm seeing (i.e. that the PLL is stuck,
which should also be in the commit text here). When I try to set the bit
in the bootloader though my kernel won't boot. I guess something is
hanging the system if I enable the retain bit in the GDSC?

> 
> Fixes: edab812d802d ("clk: qcom: lpass: Add support for LPASS clock 
> controller for SC7180")
> Signed-off-by: Taniya Das 
> Signed-off-by: Douglas Anderson 


Re: [PATCH v4 14/32] auxdisplay: Move init_display to hd44780_common

2020-10-15 Thread Miguel Ojeda
On Mon, Oct 5, 2020 at 3:01 PM  wrote:
>
> The init_display function is moved over to hd44780_common. charlcd uses
> it via it's ops function pointer and drivers initialize the ops with the

it's -> its

(Already corrected in my queue)

Cheers,
Miguel


Re: [PATCH] Bluetooth: Use lock_sock() when acquiring lock in sco_conn_del

2020-10-15 Thread Xu, Yanfei




On 10/14/20 8:31 PM, Hillf Danton wrote:


On Wed, 14 Oct 2020 15:17:31 +0800

From: Yanfei Xu 

Locking slock-AF_BLUETOOTH-BTPROTO_SCO may happen in process context or
BH context. If in process context, we should use lock_sock(). As blow
warning, sco_conn_del() is called in process context, so let's use
lock_sock() instead of bh_lock_sock().


Sounds opposite because blocking BH in BH context provides no extra
protection while it makes sense in the less critical context particularly
wrt sock lock.



WARNING: inconsistent lock state
5.9.0-rc4-syzkaller #0 Not tainted

inconsistent {IN-SOFTIRQ-W} -> {SOFTIRQ-ON-W} usage.
syz-executor675/31233 [HC0[0]:SC0[0]:HE1:SE1] takes:
8880a75c50a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at:
spin_lock include/linux/spinlock.h:354 [inline]
8880a75c50a0 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.?.}-{2:2}, at:
sco_conn_del+0x128/0x270 net/bluetooth/sco.c:176
{IN-SOFTIRQ-W} state was registered at:
   lock_acquire+0x1f3/0xae0 kernel/locking/lockdep.c:5006
   __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
   _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
   spin_lock include/linux/spinlock.h:354 [inline]
   sco_sock_timeout+0x24/0x140 net/bluetooth/sco.c:83
   call_timer_fn+0x1ac/0x760 kernel/time/timer.c:1413
   expire_timers kernel/time/timer.c:1458 [inline]
   __run_timers.part.0+0x67c/0xaa0 kernel/time/timer.c:1755
   __run_timers kernel/time/timer.c:1736 [inline]
   run_timer_softirq+0xae/0x1a0 kernel/time/timer.c:1768
   __do_softirq+0x1f7/0xa91 kernel/softirq.c:298
   asm_call_on_stack+0xf/0x20 arch/x86/entry/entry_64.S:706
   __run_on_irqstack arch/x86/include/asm/irq_stack.h:22 [inline]
   run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:48 [inline]
   do_softirq_own_stack+0x9d/0xd0 arch/x86/kernel/irq_64.c:77
   invoke_softirq kernel/softirq.c:393 [inline]
   __irq_exit_rcu kernel/softirq.c:423 [inline]
   irq_exit_rcu+0x235/0x280 kernel/softirq.c:435
   sysvec_apic_timer_interrupt+0x51/0xf0 arch/x86/kernel/apic/apic.c:1091
   asm_sysvec_apic_timer_interrupt+0x12/0x20
   arch/x86/include/asm/idtentry.h:581
   unwind_next_frame+0x139a/0x1f90 arch/x86/kernel/unwind_orc.c:607
   arch_stack_walk+0x81/0xf0 arch/x86/kernel/stacktrace.c:25
   stack_trace_save+0x8c/0xc0 kernel/stacktrace.c:123
   kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
   kasan_set_track mm/kasan/common.c:56 [inline]
   __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
   slab_post_alloc_hook mm/slab.h:518 [inline]
   slab_alloc mm/slab.c:3312 [inline]
   kmem_cache_alloc+0x13a/0x3a0 mm/slab.c:3482
   __d_alloc+0x2a/0x950 fs/dcache.c:1709
   d_alloc+0x4a/0x230 fs/dcache.c:1788
   d_alloc_parallel+0xe9/0x18e0 fs/dcache.c:2540
   lookup_open.isra.0+0x9ac/0x1350 fs/namei.c:3030
   open_last_lookups fs/namei.c:3177 [inline]
   path_openat+0x96d/0x2730 fs/namei.c:3365
   do_filp_open+0x17e/0x3c0 fs/namei.c:3395
   do_sys_openat2+0x16d/0x420 fs/open.c:1168
   do_sys_open fs/open.c:1184 [inline]
   __do_sys_open fs/open.c:1192 [inline]
   __se_sys_open fs/open.c:1188 [inline]
   __x64_sys_open+0x119/0x1c0 fs/open.c:1188
   do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
   entry_SYSCALL_64_after_hwframe+0x44/0xa9
irq event stamp: 853
hardirqs last  enabled at (853): []
__raw_spin_unlock_irq include/linux/spinlock_api_smp.h:168 [inline]
hardirqs last  enabled at (853): []
_raw_spin_unlock_irq+0x1f/0x80 kernel/locking/spinlock.c:199
hardirqs last disabled at (852): []
__raw_spin_lock_irq include/linux/spinlock_api_smp.h:126 [inline]
hardirqs last disabled at (852): []
_raw_spin_lock_irq+0xa4/0xd0 kernel/locking/spinlock.c:167
softirqs last  enabled at (0): []
copy_process+0x1a99/0x6920 kernel/fork.c:2018
softirqs last disabled at (0): [<>] 0x0

other info that might help us debug this:
  Possible unsafe locking scenario:

CPU0

   lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
   
 lock(slock-AF_BLUETOOTH-BTPROTO_SCO);

  *** DEADLOCK ***

3 locks held by syz-executor675/31233:
  #0: 88809f104f40 (>req_lock){+.+.}-{3:3}, at:
hci_dev_do_close+0xf5/0x1080 net/bluetooth/hci_core.c:1720
  #1: 88809f104078 (>lock){+.+.}-{3:3}, at:
hci_dev_do_close+0x253/0x1080 net/bluetooth/hci_core.c:1757
  #2: 8a9188c8 (hci_cb_list_lock){+.+.}-{3:3}, at:
hci_disconn_cfm include/net/bluetooth/hci_core.h:1435 [inline]
  #2: 8a9188c8 (hci_cb_list_lock){+.+.}-{3:3}, at:
hci_conn_hash_flush+0xc7/0x220 net/bluetooth/hci_conn.c:1557

stack backtrace:
CPU: 1 PID: 31233 Comm: syz-executor675 Not tainted 5.9.0-rc4-syzkaller
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0x198/0x1fd lib/dump_stack.c:118
  print_usage_bug kernel/locking/lockdep.c:4020 [inline]
  valid_state kernel/locking/lockdep.c:3361 [inline]
  mark_lock_irq kernel/locking/lockdep.c:3560 

[PATCH] Bluetooth: btusb: Add support for LG LGSBWAC92/TWCM-K505D

2020-10-15 Thread Forest Crossman
The LG LGSBWAC92/TWCM-K505D/EAT64454801/EAT64454802 (it goes by many
names) is a combo WiFi/Bluetooth module that's used in several models of
LG TVs. It uses the MediaTek MT7668AUN, which is already supported in
btusb, but this device has a non-MediaTek USB VID so to get it to work
we just need to add it to the list of devices to probe.

Signed-off-by: Forest Crossman 
---
 drivers/bluetooth/btusb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5f022e9cf667..58259b6a43c7 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -366,6 +366,7 @@ static const struct usb_device_id blacklist_table[] = {
/* MediaTek Bluetooth devices */
{ USB_VENDOR_AND_INTERFACE_INFO(0x0e8d, 0xe0, 0x01, 0x01),
  .driver_info = BTUSB_MEDIATEK },
+   { USB_DEVICE(0x043e, 0x3109), .driver_info = BTUSB_MEDIATEK },
 
/* Additional Realtek 8723AE Bluetooth devices */
{ USB_DEVICE(0x0930, 0x021d), .driver_info = BTUSB_REALTEK },
-- 
2.20.1



Re: [GIT PULL] tracing: Updates for 5.10

2020-10-15 Thread Masami Hiramatsu
On Thu, 15 Oct 2020 22:21:39 -0400
Steven Rostedt  wrote:

> On Thu, 15 Oct 2020 18:54:34 -0700
> Linus Torvalds  wrote:
> 
> > On Thu, Oct 15, 2020 at 10:53 AM Steven Rostedt  wrote:
> > >
> > > Updates for tracing and bootconfig:  
> > 
> > Hmm. I haven't verified that this came from you, but it seems likely..
> > Once again my clang build shows something that I don't see in my
> > allmodconfig gcc build:
> > 
> >WARNING: modpost: vmlinux.o(.text+0x1e5b06): Section mismatch in
> > reference from the function __trace_early_add_events() to the function
> > .init.text:__trace_early_add_new_event()
> >The function __trace_early_add_events() references
> >the function __init __trace_early_add_new_event().
> >This is often because __trace_early_add_events lacks a __init
> >annotation or the annotation of __trace_early_add_new_event is wrong.
> > 
> > Hmm?
> > 
> >Linus
> 
> I see the issue, and I wonder if it has to do with optimization, for gcc
> not to warn.

I also couldn't reproduce it even with CONFIG_DEBUG_SECTION_MISMATCH=y.
It seems that the __trace_early_add_new_event() is inlined in 
__trace_early_add_events(). 

$ eu-readelf -w kernel/trace/trace_events.o
...
 [ 1af20]subprogram   abbrev: 53
 name (strp) "__trace_early_add_new_event"
 decl_file(data1) trace_events.c (1)
 decl_line(data2) 2502
 decl_column  (data1) 1
 prototyped   (flag_present) yes
 type (ref4) [cc]
 inline   (data1) inlined (1)
$ gcc -v
...
gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 

> 
> The issue is that we have:
> 
> trace_array_create() that can be called at any time. And it has:
> 
>   if (trace_instance_dir) {
>   ret = trace_array_create_dir(tr);
>   if (ret)
>   goto out_free_tr;
>   } else
>   __trace_early_add_events(tr);
> 
> 
> Where trace_instance_dir gets set at boot up, and thus the else statement
> will never get called after that.
> 
> The __trace_early_add_events() then calls __trace_early_add_new_events()
> which is __init.
> 
> I don't know how gcc didn't trigger this and clang does.

> 
> I'll have to think about how to untangle this. Is there some kind of
> annotation that makes it show that a path can only be called at boot up and
> not later?

What happen if we use Peter's static_call() and update it after boot up? 
Or, we might need to break apart the trace_array_create() and restruct
it as __init trace_array_early_create() and trace_array_create().

Thank you,

-- 
Masami Hiramatsu 


Re: [PATCH v4 02/32] auxdisplay: Introduce hd44780_common.[ch]

2020-10-15 Thread Miguel Ojeda
On Mon, Oct 5, 2020 at 2:27 PM  wrote:
>
> diff --git a/drivers/auxdisplay/hd44780_common.c 
> b/drivers/auxdisplay/hd44780_common.c
> new file mode 100644
> index ..073f47397f7d
> --- /dev/null
> +++ b/drivers/auxdisplay/hd44780_common.c
> @@ -0,0 +1,21 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +#include 
> +#include 
> +
> +#include "hd44780_common.h"
> +
> +struct hd44780_common *hd44780_common_alloc(void)
> +{
> +   struct hd44780_common *hd;
> +
> +   hd = kzalloc(sizeof(*hd), GFP_KERNEL);
> +   if (!hd)
> +   return NULL;
> +
> +   return hd;
> +

Typo: spurious newline.

> +}
> +EXPORT_SYMBOL_GPL(hd44780_common_alloc);
> +
> +MODULE_LICENSE("GPL");
> +

Spurious EOF newline.

> diff --git a/drivers/auxdisplay/hd44780_common.h 
> b/drivers/auxdisplay/hd44780_common.h
> new file mode 100644
> index ..767bbda91744
> --- /dev/null
> +++ b/drivers/auxdisplay/hd44780_common.h
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +struct hd44780_common {
> +   void *hd44780;
> +};
> +
> +struct hd44780_common *hd44780_common_alloc(void);
> +

Spurious EOF newline.

(All already corrected in my queue).

Cheers,
Miguel


[PATCH v3 net-next] net: stmmac: Enable EEE HW LPI timer with auto SW/HW switching

2020-10-15 Thread Voon Weifeng
From: "Vineetha G. Jaya Kumaran" 

This patch enables the HW LPI Timer which controls the automatic entry
and exit of the LPI state.
The EEE LPI timer value is configured through ethtool. The driver will
auto select the LPI HW timer if the value in the HW timer supported range.
Else, the driver will fallback to SW timer.

Signed-off-by: Vineetha G. Jaya Kumaran 
Signed-off-by: Voon Weifeng 
---
v3 changelog:
-Changed stmmac_lpi_entry_timer_config() to static function

v2 changelog:
-removed #define for LPI_ET_ENABLE and LPI_ET_DISABLE and directly use
 literals
-removed not required function header in stmmac.h
-renamed stmmac_lpi_entry_timer_enable() to stmmac_lpi_entry_timer_config()
-Moved stmmac_lpi_entry_timer_enable() up in the file before
 stmmac_disable_eee_mode()

 drivers/net/ethernet/stmicro/stmmac/common.h  |  1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h  |  2 ++
 .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 24 ++
 drivers/net/ethernet/stmicro/stmmac/hwif.h|  3 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  1 +
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +--
 6 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h 
b/drivers/net/ethernet/stmicro/stmmac/common.h
index df7de50497a0..6f271c46368d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -402,6 +402,7 @@ struct dma_features {
 /* Default LPI timers */
 #define STMMAC_DEFAULT_LIT_LS  0x3E8
 #define STMMAC_DEFAULT_TWT_LS  0x1E
+#define STMMAC_ET_MAX  0xF
 
 #define STMMAC_CHAIN_MODE  0x1
 #define STMMAC_RING_MODE   0x2
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h 
b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 592b043f9676..82df91c130f7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -176,9 +176,11 @@ enum power_event {
  */
 #define GMAC4_LPI_CTRL_STATUS  0xd0
 #define GMAC4_LPI_TIMER_CTRL   0xd4
+#define GMAC4_LPI_ENTRY_TIMER  0xd8
 
 /* LPI control and status defines */
 #define GMAC4_LPI_CTRL_STATUS_LPITCSE  BIT(21) /* LPI Tx Clock Stop Enable */
+#define GMAC4_LPI_CTRL_STATUS_LPIATE   BIT(20) /* LPI Timer Enable */
 #define GMAC4_LPI_CTRL_STATUS_LPITXA   BIT(19) /* Enable LPI TX Automate */
 #define GMAC4_LPI_CTRL_STATUS_PLS  BIT(17) /* PHY Link Status */
 #define GMAC4_LPI_CTRL_STATUS_LPIENBIT(16) /* LPI Enable */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c 
b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 002791b77356..3ed4f4cda7f9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -379,6 +379,27 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, 
int link)
writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
 }
 
+static void dwmac4_set_eee_lpi_entry_timer(struct mac_device_info *hw, int et)
+{
+   void __iomem *ioaddr = hw->pcsr;
+   int value = et & STMMAC_ET_MAX;
+   int regval;
+
+   /* Program LPI entry timer value into register */
+   writel(value, ioaddr + GMAC4_LPI_ENTRY_TIMER);
+
+   /* Enable/disable LPI entry timer */
+   regval = readl(ioaddr + GMAC4_LPI_CTRL_STATUS);
+   regval |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA;
+
+   if (et)
+   regval |= GMAC4_LPI_CTRL_STATUS_LPIATE;
+   else
+   regval &= ~GMAC4_LPI_CTRL_STATUS_LPIATE;
+
+   writel(regval, ioaddr + GMAC4_LPI_CTRL_STATUS);
+}
+
 static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw)
 {
void __iomem *ioaddr = hw->pcsr;
@@ -1164,6 +1185,7 @@ const struct stmmac_ops dwmac4_ops = {
.get_umac_addr = dwmac4_get_umac_addr,
.set_eee_mode = dwmac4_set_eee_mode,
.reset_eee_mode = dwmac4_reset_eee_mode,
+   .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer,
.set_eee_timer = dwmac4_set_eee_timer,
.set_eee_pls = dwmac4_set_eee_pls,
.pcs_ctrl_ane = dwmac4_ctrl_ane,
@@ -1206,6 +1228,7 @@ const struct stmmac_ops dwmac410_ops = {
.get_umac_addr = dwmac4_get_umac_addr,
.set_eee_mode = dwmac4_set_eee_mode,
.reset_eee_mode = dwmac4_reset_eee_mode,
+   .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer,
.set_eee_timer = dwmac4_set_eee_timer,
.set_eee_pls = dwmac4_set_eee_pls,
.pcs_ctrl_ane = dwmac4_ctrl_ane,
@@ -1249,6 +1272,7 @@ const struct stmmac_ops dwmac510_ops = {
.get_umac_addr = dwmac4_get_umac_addr,
.set_eee_mode = dwmac4_set_eee_mode,
.reset_eee_mode = dwmac4_reset_eee_mode,
+   .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer,
.set_eee_timer = dwmac4_set_eee_timer,
.set_eee_pls = dwmac4_set_eee_pls,
.pcs_ctrl_ane = dwmac4_ctrl_ane,
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h 

[RFC PATCH 6/6] mm: remove now-unused mmdrop_async()

2020-10-15 Thread Jann Horn
The preceding patches have removed all users of mmdrop_async(); get rid of
it.

Note that on MMU, we still need async_put_work because mmput_async() uses
it, which in turn is used by binder's shrinker callback. We could claw back
those 4 words per mm if we made mmput_async() depend on
CONFIG_ANDROID_BINDER_IPC.

Signed-off-by: Jann Horn 
---
 include/linux/mm_types.h |  2 ++
 kernel/fork.c| 16 
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 764d251966c7..8fde2068bde1 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -560,7 +560,9 @@ struct mm_struct {
 #ifdef CONFIG_HUGETLB_PAGE
atomic_long_t hugetlb_usage;
 #endif
+#ifdef CONFIG_MMU
struct work_struct async_put_work;
+#endif
} __randomize_layout;
 
/*
diff --git a/kernel/fork.c b/kernel/fork.c
index 4383bf055b40..c5f2ec544933 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -666,22 +666,6 @@ void __mmdrop(struct mm_struct *mm)
 }
 EXPORT_SYMBOL_GPL(__mmdrop);
 
-static void mmdrop_async_fn(struct work_struct *work)
-{
-   struct mm_struct *mm;
-
-   mm = container_of(work, struct mm_struct, async_put_work);
-   __mmdrop(mm);
-}
-
-static void mmdrop_async(struct mm_struct *mm)
-{
-   if (unlikely(atomic_dec_and_test(>mm_count))) {
-   INIT_WORK(>async_put_work, mmdrop_async_fn);
-   schedule_work(>async_put_work);
-   }
-}
-
 static inline void free_signal_struct(struct signal_struct *sig)
 {
taskstats_tgid_free(sig);
-- 
2.29.0.rc1.297.gfa9743e501-goog



[RFC PATCH 0/6] mm and ptrace: Track dumpability until task is freed

2020-10-15 Thread Jann Horn
At the moment, there is a lifetime issue (no, not the UAF kind) around
__ptrace_may_access():

__ptrace_may_access() wants to check mm->flags and mm->user_ns to figure
out whether the caller should be allowed to access some target task.
__ptrace_may_access() can be called as long as __put_task_struct()
hasn't happened yet; but __put_task_struct() happens when the task is
about to be freed, which is much later than exit_mm() (which happens
pretty early during task exit).
So we can have a situation where we need to consult the mm for a
security check, but we don't have an mm anymore.

At the moment, this is solved by failing open: If the mm is gone, we
pretend that it was dumpable. That's dubious from a security
perspective - as one example, we drop the mm_struct before the file
descriptor table, so someone might be able to steal file descriptors
from an exiting tasks when dumpability was supposed to prevent that.

The easy fix would be to let __ptrace_may_access() instead always refuse
access to tasks that have lost their mm; but then that would e.g. mean
that the ability to inspect dead tasks in procfs would be restricted.
So while that might work in practice, it'd be a bit ugly, too.

Another option would be to move the dumpability information elsewhere -
but that would have to be the task_struct (the signal_struct can be
shared with dead pre-execve threads, so we can't use it here). So we'd
have to keep dumpability information in sync across threads - that'd
probably be pretty ugly.


So I think the proper fix is to let the task_struct hold a reference on
the mm_struct until the task goes away completely. This is implemented
in patch 1/6, which is also the only patch in this series that I
actually care about (and the only one with a stable backport marking);
the rest of the series are some tweaks in case people dislike the idea
of constantly freeing mm_structs from workqueue context.
Those tweaks should also reduce the memory usage of dead tasks, by
ensuring that they don't keep their PGDs alive.


Patch 1/6 is not particularly pretty, but I can't think of any better
way to do it.

So: Does this series (and in particular patch 1/6) look vaguely sane?
And if not, does anyone have a better approach?


Jann Horn (6):
  ptrace: Keep mm around after exit_mm() for __ptrace_may_access()
  refcount: Move refcount_t definition into linux/types.h
  mm: Add refcount for preserving mm_struct without pgd
  mm, oom: Use mm_ref()/mm_unref() and avoid mmdrop_async()
  ptrace: Use mm_ref() for ->exit_mm
  mm: remove now-unused mmdrop_async()

 arch/x86/kernel/tboot.c|  2 +
 drivers/firmware/efi/efi.c |  2 +
 include/linux/mm_types.h   | 15 ++-
 include/linux/refcount.h   | 13 +-
 include/linux/sched.h  |  8 
 include/linux/sched/mm.h   | 13 ++
 include/linux/types.h  | 12 +
 kernel/exit.c  |  2 +
 kernel/fork.c  | 90 +-
 kernel/ptrace.c| 10 +
 mm/init-mm.c   |  2 +
 mm/oom_kill.c  |  2 +-
 12 files changed, 105 insertions(+), 66 deletions(-)


base-commit: bbf5c979011a099af5dc76498918ed7df445635b
-- 
2.29.0.rc1.297.gfa9743e501-goog



[RFC PATCH 5/6] ptrace: Use mm_ref() for ->exit_mm

2020-10-15 Thread Jann Horn
We only use ->exit_mm to look up dumpability and the ->user_mm; we don't
need to keep the PGD alive for this.
mmgrab() is also inconvenient here, because it means that we need to use
mmdrop_async() when dropping the reference to the mm from an RCU callback.
Use mm_ref() instead of mmgrab() to make things neater.

Signed-off-by: Jann Horn 
---
 kernel/exit.c | 2 +-
 kernel/fork.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 97253ef33486..03ba6d13ef1e 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -476,7 +476,7 @@ static void exit_mm(void)
/* more a memory barrier than a real lock */
task_lock(current);
current->mm = NULL;
-   mmgrab(mm); /* for current->exit_mm */
+   mm_ref(mm); /* for current->exit_mm */
current->exit_mm = mm;
mmap_read_unlock(mm);
enter_lazy_tlb(mm, current);
diff --git a/kernel/fork.c b/kernel/fork.c
index 59c119b03351..4383bf055b40 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -720,7 +720,7 @@ void free_task(struct task_struct *tsk)
if (tsk->flags & PF_KTHREAD)
free_kthread_struct(tsk);
if (tsk->exit_mm)
-   mmdrop_async(tsk->exit_mm);
+   mm_unref(tsk->exit_mm);
free_task_struct(tsk);
 }
 EXPORT_SYMBOL(free_task);
-- 
2.29.0.rc1.297.gfa9743e501-goog



[RFC PATCH 1/6] ptrace: Keep mm around after exit_mm() for __ptrace_may_access()

2020-10-15 Thread Jann Horn
__ptrace_may_access() checks can happen on target tasks that are in the
middle of do_exit(), past exit_mm(). At that point, the ->mm pointer has
been NULLed out, and the mm_struct has been mmput().

Unfortunately, the mm_struct contains the dumpability and the user_ns in
which the task last went through execve(), and we need those for
__ptrace_may_access(). Currently, that problem is handled by failing open:
If the ->mm is gone, we assume that the task was dumpable. In some edge
cases, this could potentially expose access to things like
/proc/$pid/fd/$fd of originally non-dumpable processes.
(exit_files() comes after exit_mm(), so the file descriptor table is still
there when we've gone through exit_mm().)

One way to fix this would be to move mm->user_ns and the dumpability state
over into the task_struct. However, that gets quite ugly if we want to
preserve existing semantics because e.g. PR_SET_DUMPABLE and commit_creds()
would then have to scan through all tasks sharing the mm_struct and keep
them in sync manually - that'd be a bit error-prone and overcomplicated.

(Moving these things into the signal_struct is not an option because that
is kept across executions, and pre-execve co-threads will share the
signal_struct that is also used by the task that has gone through
execve().)

I believe that this patch may be the least bad option to fix this - keep
the mm_struct (but not process memory) around with an mmgrab() reference
from exit_mm() until the task goes away completely.

Note that this moves free_task() down in order to make mmdrop_async()
available without a forward declaration.

Cc: sta...@vger.kernel.org
Fixes: bfedb589252c ("mm: Add a user_ns owner to mm_struct and fix ptrace 
permission checks")
Signed-off-by: Jann Horn 
---
 include/linux/sched.h |  8 +++
 kernel/exit.c |  2 ++
 kernel/fork.c | 54 ++-
 kernel/ptrace.c   | 10 
 4 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index afe01e232935..55bec6ff5626 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -747,6 +747,14 @@ struct task_struct {
 
struct mm_struct*mm;
struct mm_struct*active_mm;
+   /*
+* When we exit and ->mm (the reference pinning ->mm's address space)
+* goes away, we stash a reference to the mm_struct itself (counted via
+* exit_mm->mm_count) in this member.
+* This allows us to continue using the mm_struct for security checks
+* and such even after the task has started exiting.
+*/
+   struct mm_struct*exit_mm;
 
/* Per-thread vma caching: */
struct vmacache vmacache;
diff --git a/kernel/exit.c b/kernel/exit.c
index 733e80f334e7..97253ef33486 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -476,6 +476,8 @@ static void exit_mm(void)
/* more a memory barrier than a real lock */
task_lock(current);
current->mm = NULL;
+   mmgrab(mm); /* for current->exit_mm */
+   current->exit_mm = mm;
mmap_read_unlock(mm);
enter_lazy_tlb(mm, current);
task_unlock(current);
diff --git a/kernel/fork.c b/kernel/fork.c
index da8d360fb032..4942428a217c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -438,32 +438,6 @@ void put_task_stack(struct task_struct *tsk)
 }
 #endif
 
-void free_task(struct task_struct *tsk)
-{
-   scs_release(tsk);
-
-#ifndef CONFIG_THREAD_INFO_IN_TASK
-   /*
-* The task is finally done with both the stack and thread_info,
-* so free both.
-*/
-   release_task_stack(tsk);
-#else
-   /*
-* If the task had a separate stack allocation, it should be gone
-* by now.
-*/
-   WARN_ON_ONCE(refcount_read(>stack_refcount) != 0);
-#endif
-   rt_mutex_debug_task_free(tsk);
-   ftrace_graph_exit_task(tsk);
-   arch_release_task_struct(tsk);
-   if (tsk->flags & PF_KTHREAD)
-   free_kthread_struct(tsk);
-   free_task_struct(tsk);
-}
-EXPORT_SYMBOL(free_task);
-
 #ifdef CONFIG_MMU
 static __latent_entropy int dup_mmap(struct mm_struct *mm,
struct mm_struct *oldmm)
@@ -722,6 +696,34 @@ static inline void put_signal_struct(struct signal_struct 
*sig)
free_signal_struct(sig);
 }
 
+void free_task(struct task_struct *tsk)
+{
+   scs_release(tsk);
+
+#ifndef CONFIG_THREAD_INFO_IN_TASK
+   /*
+* The task is finally done with both the stack and thread_info,
+* so free both.
+*/
+   release_task_stack(tsk);
+#else
+   /*
+* If the task had a separate stack allocation, it should be gone
+* by now.
+*/
+   WARN_ON_ONCE(refcount_read(>stack_refcount) != 0);
+#endif
+   rt_mutex_debug_task_free(tsk);
+   ftrace_graph_exit_task(tsk);
+   

[RFC PATCH 3/6] mm: Add refcount for preserving mm_struct without pgd

2020-10-15 Thread Jann Horn
Currently, mm_struct has two refcounts:

 - mm_users: preserves everything - the mm_struct, the page tables, the
   memory mappings, and so on
 - mm_count: preserves the mm_struct and pgd

However, there are three types of users of mm_struct:

1. users that want page tables, memory mappings and so on
2. users that want to preserve the pgd (for lazy TLB)
3. users that just want to keep the mm_struct itself around (e.g. for
   mmget_not_zero() or __ptrace_may_access())

Dropping mm_count references can be messy because dropping mm_count to
zero deletes the pgd, which takes the pgd_lock on x86, meaning it doesn't
work from RCU callbacks (which run in IRQ context). In those cases,
mmdrop_async() must be used to punt the invocation of __mmdrop() to
workqueue context.

That's fine when mmdrop_async() is a rare case, but the preceding patch
"ptrace: Keep mm around after exit_mm() for __ptrace_may_access()" makes it
the common case; we should probably avoid punting freeing to workqueue
context all the time if we can avoid it?

To resolve this, add a third refcount that just protects the mm_struct and
the user_ns it points to, and which can be dropped with synchronous freeing
from (almost) any context.

Signed-off-by: Jann Horn 
---
 arch/x86/kernel/tboot.c|  2 ++
 drivers/firmware/efi/efi.c |  2 ++
 include/linux/mm_types.h   | 13 +++--
 include/linux/sched/mm.h   | 13 +
 kernel/fork.c  | 14 ++
 mm/init-mm.c   |  2 ++
 6 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index 992fb1415c0f..b92ea1bb3bb9 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -93,6 +94,7 @@ static struct mm_struct tboot_mm = {
.pgd= swapper_pg_dir,
.mm_users   = ATOMIC_INIT(2),
.mm_count   = ATOMIC_INIT(1),
+   .mm_bare_refs   = REFCOUNT_INIT(1),
MMAP_LOCK_INITIALIZER(init_mm)
.page_table_lock =  __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
.mmlist = LIST_HEAD_INIT(init_mm.mmlist),
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 3aa07c3b5136..3b73a0717c6e 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -54,6 +55,7 @@ struct mm_struct efi_mm = {
.mm_rb  = RB_ROOT,
.mm_users   = ATOMIC_INIT(2),
.mm_count   = ATOMIC_INIT(1),
+   .mm_bare_refs   = REFCOUNT_INIT(1),
MMAP_LOCK_INITIALIZER(efi_mm)
.page_table_lock= __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock),
.mmlist = LIST_HEAD_INIT(efi_mm.mmlist),
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index ed028af3cb19..764d251966c7 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -429,13 +429,22 @@ struct mm_struct {
 
/**
 * @mm_count: The number of references to  mm_struct
-* (@mm_users count as 1).
+* including its pgd (@mm_users count as 1).
 *
 * Use mmgrab()/mmdrop() to modify. When this drops to 0, the
-*  mm_struct is freed.
+* pgd is freed.
 */
atomic_t mm_count;
 
+   /**
+* @mm_bare_refs: The number of references to  mm_struct
+* that preserve no page table state whatsoever (@mm_count
+* counts as 1).
+*
+* When this drops to 0, the  mm_struct is freed.
+*/
+   refcount_t mm_bare_refs;
+
/**
 * @has_pinned: Whether this mm has pinned any pages.  This can
 * be either replaced in the future by @pinned_vm when it
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index f889e332912f..e5b236e15757 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -109,6 +109,19 @@ extern void mmput(struct mm_struct *);
 void mmput_async(struct mm_struct *);
 #endif
 
+static inline void mm_ref(struct mm_struct *mm)
+{
+   refcount_inc(>mm_bare_refs);
+}
+
+void __mm_unref(struct mm_struct *mm);
+
+static inline void mm_unref(struct mm_struct *mm)
+{
+   if (refcount_dec_and_test(>mm_bare_refs))
+   __mm_unref(mm);
+}
+
 /* Grab a reference to a task's mm, if it is not already going away */
 extern struct mm_struct *get_task_mm(struct task_struct *task);
 /*
diff --git a/kernel/fork.c b/kernel/fork.c
index 4942428a217c..fcdd1ace79e4 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -642,10 +642,16 @@ static void check_mm(struct mm_struct *mm)
 #define allocate_mm()  (kmem_cache_alloc(mm_cachep, GFP_KERNEL))
 #define 

[RFC PATCH 4/6] mm, oom: Use mm_ref()/mm_unref() and avoid mmdrop_async()

2020-10-15 Thread Jann Horn
The OOM killer uses MMF_OOM_SKIP to avoid running on an mm that has started
__mmput(); it only uses the mmgrab() reference to ensure that the mm_struct
itself stays alive.

This means that we don't need a full mmgrab() reference, which will keep
the pgd (and potentially also some pmd pages) alive and can't be cleaned up
from RCU callback context; we can use an mm_ref() reference instead.

Signed-off-by: Jann Horn 
---
 kernel/fork.c | 6 +-
 mm/oom_kill.c | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index fcdd1ace79e4..59c119b03351 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -686,12 +686,8 @@ static inline void free_signal_struct(struct signal_struct 
*sig)
 {
taskstats_tgid_free(sig);
sched_autogroup_exit(sig);
-   /*
-* __mmdrop is not safe to call from softirq context on x86 due to
-* pgd_dtor so postpone it to the async context
-*/
if (sig->oom_mm)
-   mmdrop_async(sig->oom_mm);
+   mm_unref(sig->oom_mm);
kmem_cache_free(signal_cachep, sig);
 }
 
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index e90f25d6385d..12967f54fbcf 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -704,7 +704,7 @@ static void mark_oom_victim(struct task_struct *tsk)
 
/* oom_mm is bound to the signal struct life time. */
if (!cmpxchg(>signal->oom_mm, NULL, mm)) {
-   mmgrab(tsk->signal->oom_mm);
+   mm_ref(tsk->signal->oom_mm);
set_bit(MMF_OOM_VICTIM, >flags);
}
 
-- 
2.29.0.rc1.297.gfa9743e501-goog



[RFC PATCH 2/6] refcount: Move refcount_t definition into linux/types.h

2020-10-15 Thread Jann Horn
I want to use refcount_t in mm_struct, but if refcount_t is defined in
linux/refcount.h, that header would have to be included in
linux/mm_types.h; that would be wasteful.

Let's move refcount_t over into linux/types.h so that includes can be
written less wastefully.

Signed-off-by: Jann Horn 
---
 include/linux/refcount.h | 13 +
 include/linux/types.h| 12 
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/include/linux/refcount.h b/include/linux/refcount.h
index 0e3ee25eb156..fd8cf65e4e2f 100644
--- a/include/linux/refcount.h
+++ b/include/linux/refcount.h
@@ -96,22 +96,11 @@
 #include 
 #include 
 #include 
+#include  /* refcount_t is defined here */
 #include 
 
 struct mutex;
 
-/**
- * struct refcount_t - variant of atomic_t specialized for reference counts
- * @refs: atomic_t counter field
- *
- * The counter saturates at REFCOUNT_SATURATED and will not move once
- * there. This avoids wrapping the counter and causing 'spurious'
- * use-after-free bugs.
- */
-typedef struct refcount_struct {
-   atomic_t refs;
-} refcount_t;
-
 #define REFCOUNT_INIT(n)   { .refs = ATOMIC_INIT(n), }
 #define REFCOUNT_MAX   INT_MAX
 #define REFCOUNT_SATURATED (INT_MIN / 2)
diff --git a/include/linux/types.h b/include/linux/types.h
index a147977602b5..34e4e779e767 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -175,6 +175,18 @@ typedef struct {
 } atomic64_t;
 #endif
 
+/**
+ * struct refcount_t - variant of atomic_t specialized for reference counts
+ * @refs: atomic_t counter field
+ *
+ * The counter saturates at REFCOUNT_SATURATED and will not move once
+ * there. This avoids wrapping the counter and causing 'spurious'
+ * use-after-free bugs.
+ */
+typedef struct refcount_struct {
+   atomic_t refs;
+} refcount_t;
+
 struct list_head {
struct list_head *next, *prev;
 };
-- 
2.29.0.rc1.297.gfa9743e501-goog



Re: [PATCH v3] Add support for mv88e6393x family of Marvell.

2020-10-15 Thread Florian Fainelli




On 10/15/2020 7:09 PM, Pavana Sharma wrote:

The Marvell 88E6393X device is a single-chip integration of a 11-port
Ethernet switch with eight integrated Gigabit Ethernet (GbE) transceivers
and three 10-Gigabit interfaces.

This patch adds functionalities specific to mv88e6393x family (88E6393X,
88E6193X and 88E6191X)

Signed-off-by: Pavana Sharma 


The subject of your patch should be:

net: dsa: mv88e6xxx: Add support for mv88e6393x family

to be consistent with the previous changes done to these files. I don't 
have the datasheet for that switch so cannot confirm if the changes 
appear to be correct or not, Vivien and Andrew might though.

--
Florian


Re: [PATCH v4 01/32] auxdisplay: Use an enum for charlcd backlight on/off ops

2020-10-15 Thread Miguel Ojeda
On Mon, Oct 5, 2020 at 2:27 PM  wrote:
>
> We use an enum for calling the functions in charlcd, that turn the
> backlight on or off. This enum is generic and can be used for other
> charlcd turn of / turn off operations as well.

Typo: of -> on

(Already corrected in my queue)

Cheers,
Miguel


Re: [GIT PULL] tracing: Updates for 5.10

2020-10-15 Thread Masami Hiramatsu
On Thu, 15 Oct 2020 18:54:34 -0700
Linus Torvalds  wrote:

> On Thu, Oct 15, 2020 at 10:53 AM Steven Rostedt  wrote:
> >
> > Updates for tracing and bootconfig:
> 
> Hmm. I haven't verified that this came from you, but it seems likely..
> Once again my clang build shows something that I don't see in my
> allmodconfig gcc build:
> 
>WARNING: modpost: vmlinux.o(.text+0x1e5b06): Section mismatch in
> reference from the function __trace_early_add_events() to the function
> .init.text:__trace_early_add_new_event()
>The function __trace_early_add_events() references
>the function __init __trace_early_add_new_event().
>This is often because __trace_early_add_events lacks a __init
>annotation or the annotation of __trace_early_add_new_event is wrong.
> 
> Hmm?

Oops, that's my fault.
The commit 720dee53ad8d ("tracing/boot: Initialize per-instance event list
 in early boot") removes __init from __trace_early_add_events() but I
forgot to do same on __trace_early_add_new_event().
Would this work?

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 851ab37058dd..e705f06c68c6 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2498,7 +2498,7 @@ __trace_add_new_event(struct trace_event_call *call, 
struct trace_array *tr)
  * for enabling events at boot. We want to enable events before
  * the filesystem is initialized.
  */
-static __init int
+static int
 __trace_early_add_new_event(struct trace_event_call *call,
struct trace_array *tr)
 {


-- 
Masami Hiramatsu 


Re: [PATCH v4 00/32] Make charlcd device independent

2020-10-15 Thread Miguel Ojeda
Hi Lars,

On Tue, Oct 6, 2020 at 10:38 AM Lars Poeschel  wrote:
>
> Changes in v4:
> - modtronix -> Modtronix in new lcd2s driver
> - Kconfig: remove "default n" in new lcd2s driver
>
> Changes in v3:
> - Fix some typos in Kconfig stuff
> - Fix kernel test robot reported error: Missed EXPORT_SYMBOL_GPL
> - new patch to reduce display timeout
> - better patch description to why not move cursor beyond end of a line
> - Fixed make dt_binding_doc errors

Picking these for linux-next (including Rob's Reviewed-by). I have
spotted a few typos that I corrected -- I will note them by email.

Cheers,
Miguel


[PATCH v2] arm:traps: Don't print stack or raw PC/LR hex values in backtraces

2020-10-15 Thread Xiaoming Ni
Printing raw pointer values in backtraces has potential security
implications and are of questionable value anyway.

This patch follows x86 and arm64's lead and removes the "Exception stack:"
dump from kernel backtraces:
commit a25ffd3a6302a6 ("arm64: traps: Don't print stack or raw
 PC/LR values in backtraces")
commit bb5e5ce545f203 ("x86/dumpstack: Remove kernel text
 addresses from stack dump")

Signed-off-by: Xiaoming Ni 

---
v2:
 Delete [] from the stack according to the email discussion
 in patch V1, Other information processing will be discussed in subsequent
 patches.

v1: https://lore.kernel.org/lkml/20201009075957.110017-1-nixiaom...@huawei.com/
  1. Don't print stack or raw PC/LR hex values in backtraces
  2. Don't print stack mem in backtraces
  3. if (!panic_on_oops), Don't print stack mem in __die()
---
 arch/arm/kernel/process.c | 3 +--
 arch/arm/kernel/traps.c   | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 8e6ace03e960..71c9e5597d39 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -121,8 +121,7 @@ void __show_regs(struct pt_regs *regs)
 
printk("PC is at %pS\n", (void *)instruction_pointer(regs));
printk("LR is at %pS\n", (void *)regs->ARM_lr);
-   printk("pc : [<%08lx>]lr : [<%08lx>]psr: %08lx\n",
-  regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr);
+   printk("psr: %08lx\n", regs->ARM_cpsr);
printk("sp : %08lx  ip : %08lx  fp : %08lx\n",
   regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
printk("r10: %08lx  r9 : %08lx  r8 : %08lx\n",
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 17d5a785df28..911bbf164875 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -68,8 +68,8 @@ void dump_backtrace_entry(unsigned long where, unsigned long 
from,
unsigned long end = frame + 4 + sizeof(struct pt_regs);
 
 #ifdef CONFIG_KALLSYMS
-   printk("%s[<%08lx>] (%ps) from [<%08lx>] (%pS)\n",
-   loglvl, where, (void *)where, from, (void *)from);
+   printk("%s (%ps) from (%pS)\n",
+   loglvl, (void *)where, (void *)from);
 #else
printk("%sFunction entered at [<%08lx>] from [<%08lx>]\n",
loglvl, where, from);
-- 
2.27.0



[PATCH v6] usb-serial:cp210x: add support to software flow control

2020-10-15 Thread Sheng Long Wang
From: Wang Sheng Long 

When data is transmitted between two serial ports,
the phenomenon of data loss often occurs. The two kinds
of flow control commonly used in serial communication
are hardware flow control and software flow control.

In serial communication, If you only use RX/TX/GND Pins, you
can't do hardware flow. So we often used software flow control
and prevent data loss. The user sets the software flow control
through the application program, and the application program
sets the software flow control mode for the serial port
chip through the driver.

For the cp210 serial port chip, its driver lacks the
software flow control setting code, so the user cannot set
the software flow control function through the application
program. This adds the missing software flow control.

Signed-off-by: Wang Sheng Long 

Changes in v3:
- fixed code style, It mainly adjusts the code style acccording
  to kernel specification.

Changes in v4:
- It mainly adjusts the patch based on the last usb-next branch
  of the usb-serial.

Changes in v5:
- Fixes:
  * According to the cp210x specification, use usb_control_msg()
requesttype 'REQTYPE_DEVICE_TO_HOST' is modified to
'REQTYPE_INTERFACE_TO_HOST' in cp210x_get_chars().

  * If modify IXOFF/IXON has been changed, we can call set software
flow control code.

  * If the setting software flow control wrong, do not continue
processing proceed with updating software flow control.

Changes in v6:
- Fix 'result' variable not uninitialized warning in cp210x_set_termios().
---
 drivers/usb/serial/cp210x.c | 128 ++--
 1 file changed, 123 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index d0c05aa8a0d6..2d5e31282599 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -412,6 +412,15 @@ struct cp210x_comm_status {
u8   bReserved;
 } __packed;
 
+struct cp210x_special_chars {
+   u8  bEofChar;
+   u8  bErrorChar;
+   u8  bBreakChar;
+   u8  bEventChar;
+   u8  bXonChar;
+   u8  bXoffChar;
+};
+
 /*
  * CP210X_PURGE - 16 bits passed in wValue of USB request.
  * SiLabs app note AN571 gives a strange description of the 4 bits:
@@ -675,6 +684,70 @@ static int cp210x_read_vendor_block(struct usb_serial 
*serial, u8 type, u16 val,
return result;
 }
 
+static int cp210x_get_chars(struct usb_serial_port *port, void *buf)
+{
+   struct usb_serial *serial = port->serial;
+   struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
+   struct cp210x_special_chars *special_chars;
+   void *dmabuf;
+   int result;
+
+   dmabuf = kmemdup(buf, sizeof(*special_chars), GFP_KERNEL);
+   if (!dmabuf)
+   return -ENOMEM;
+
+   result = usb_control_msg(serial->dev,
+   usb_rcvctrlpipe(serial->dev, 0),
+   CP210X_GET_CHARS, REQTYPE_INTERFACE_TO_HOST, 0,
+   port_priv->bInterfaceNumber,
+   dmabuf, sizeof(*special_chars),
+   USB_CTRL_GET_TIMEOUT);
+
+   if (result == sizeof(*special_chars)) {
+   memcpy(buf, dmabuf, sizeof(*special_chars));
+   result = 0;
+   } else {
+   dev_err(>dev, "failed to get special chars: %d\n", 
result);
+   if (result >= 0)
+   result = -EIO;
+   }
+
+   kfree(dmabuf);
+
+   return result;
+}
+
+static int cp210x_set_chars(struct usb_serial_port *port, void *buf)
+{
+   struct usb_serial *serial = port->serial;
+   struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
+   struct cp210x_special_chars *special_chars;
+   void *dmabuf;
+   int result;
+
+   dmabuf = kmemdup(buf, sizeof(*special_chars), GFP_KERNEL);
+   if (!dmabuf)
+   return -ENOMEM;
+
+   result = usb_control_msg(serial->dev,
+   usb_sndctrlpipe(serial->dev, 0),
+   CP210X_SET_CHARS, REQTYPE_HOST_TO_INTERFACE, 0,
+   port_priv->bInterfaceNumber,
+   dmabuf, sizeof(*special_chars), 
USB_CTRL_SET_TIMEOUT);
+
+   if (result == sizeof(*special_chars)) {
+   result = 0;
+   } else {
+   dev_err(>dev, "failed to set special chars: %d\n", 
result);
+   if (result >= 0)
+   result = -EIO;
+   }
+
+   kfree(dmabuf);
+
+   return result;
+}
+
 /*
  * Writes any 16-bit CP210X_ register (req) whose value is passed
  * entirely in the wValue field of the USB request.
@@ -1356,11 +1429,18 @@ static void cp210x_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios)
 {
struct device *dev = >dev;
-   unsigned int cflag, old_cflag;
+   

Re: [f2fs-dev] [PATCH 2/2] f2fs: add F2FS_IOC_SET_COMPRESS_OPTION ioctl

2020-10-15 Thread Daeho Jeong
> mnt_want_write_file() checks for write permission to the mount, not to the 
> file.
>
> I think this ioctl wants what f2fs_sec_trim_file() does:
>
> if (!(filp->f_mode & FMODE_WRITE))
> return -EBADF;
>
> file_start_write(filp);
> inode_lock(inode);
> ...
> inode_unlock(inode);
> file_end_write(filp);
>
>
> After all you shouldn't be able to change the compression options of a file
> given only read access to it, right?

Yep, this looks more accurate.

> Well, as I said, i_writecount == 1 doesn't guarantee that other threads aren't
> mmap'ing or writing to the file.  It just guarantees that there aren't any 
> other
> writable file descriptors.  (Actually, file descriptions.)  Multiple threads 
> can
> be using the same file descriptor (or the same file description) concurrently.

Yep, I agree this is not a proper way. I think we don't need this
check here, because
compress routine doesn't compress any file data when it detects the
file is mmaped
using f2fs_is_mmap_file().

Thanks~


2020년 10월 15일 (목) 오후 1:04, Eric Biggers 님이 작성:
>
> On Wed, Oct 14, 2020 at 11:27:30AM +0900, Daeho Jeong wrote:
> > > f2fs_readonly() is redundant with mnt_want_write_file().
> > >
> > > Also, shouldn't this require a writable file descriptor?  As-is, this 
> > > ioctl can
> > > be called on a file owned by another user, as long as the caller has read
> > > access.
> > >
> > > Note: if you change this to require a writable file descriptor, then
> > > f2fs_readonly(), mnt_want_write_file(), and IS_IMMUTABLE() all would no 
> > > longer
> > > be needed.
> >
> > I agree that f2fs_readonly() is redundant.
> > But, sorry, I don't get the rest. I thought mnt_want_write_file() is a
> > way to check whether the caller has a proper write permission or not.
> > I think just using mnt_want_write_file() is enough for this ioctl. Am
> > I missing something?
>
> mnt_want_write_file() checks for write permission to the mount, not to the 
> file.
>
> I think this ioctl wants what f2fs_sec_trim_file() does:
>
> if (!(filp->f_mode & FMODE_WRITE))
> return -EBADF;
>
> file_start_write(filp);
> inode_lock(inode);
> ...
> inode_unlock(inode);
> file_end_write(filp);
>
>
> After all you shouldn't be able to change the compression options of a file
> given only read access to it, right?
>
> > > I don't think the check for i_writecount == 1 accomplishes anything 
> > > because it
> > > just means there are no *other* writable file descriptors.  It doesn't 
> > > mean that
> > > some other thread isn't concurrently trying to write to this same file
> > > descriptor.  So the lock needs to be enough.  Is it?
> >
> > This is to detect any possibility of other threads mmap-ing and
> > writing the file.
> > Using only inode lock is not enough to prevent them from making dirty pages.
>
> Well, as I said, i_writecount == 1 doesn't guarantee that other threads aren't
> mmap'ing or writing to the file.  It just guarantees that there aren't any 
> other
> writable file descriptors.  (Actually, file descriptions.)  Multiple threads 
> can
> be using the same file descriptor (or the same file description) concurrently.
>
> - Eric


Re: [GIT PULL] tracing: Updates for 5.10

2020-10-15 Thread Steven Rostedt
On Thu, 15 Oct 2020 18:54:34 -0700
Linus Torvalds  wrote:

> On Thu, Oct 15, 2020 at 10:53 AM Steven Rostedt  wrote:
> >
> > Updates for tracing and bootconfig:  
> 
> Hmm. I haven't verified that this came from you, but it seems likely..
> Once again my clang build shows something that I don't see in my
> allmodconfig gcc build:
> 
>WARNING: modpost: vmlinux.o(.text+0x1e5b06): Section mismatch in
> reference from the function __trace_early_add_events() to the function
> .init.text:__trace_early_add_new_event()
>The function __trace_early_add_events() references
>the function __init __trace_early_add_new_event().
>This is often because __trace_early_add_events lacks a __init
>annotation or the annotation of __trace_early_add_new_event is wrong.
> 
> Hmm?
> 
>Linus

I see the issue, and I wonder if it has to do with optimization, for gcc
not to warn.

The issue is that we have:

trace_array_create() that can be called at any time. And it has:

if (trace_instance_dir) {
ret = trace_array_create_dir(tr);
if (ret)
goto out_free_tr;
} else
__trace_early_add_events(tr);


Where trace_instance_dir gets set at boot up, and thus the else statement
will never get called after that.

The __trace_early_add_events() then calls __trace_early_add_new_events()
which is __init.

I don't know how gcc didn't trigger this and clang does.

I'll have to think about how to untangle this. Is there some kind of
annotation that makes it show that a path can only be called at boot up and
not later?

-- Steve


Re: [PATCH v1 05/29] virtio-mem: generalize check for added memory

2020-10-15 Thread Wei Yang
On Thu, Oct 15, 2020 at 10:50:27AM +0200, David Hildenbrand wrote:
[...]
>> 
>>> dev_warn(>dev, "device still has system memory added\n");
>>> } else {
>>> virtio_mem_delete_resource(vm);
>> 
>> BTW, I got one question during review.
>> 
>> Per my understanding, there are 4 states of a virtio memory block
>> 
>>   * OFFLINE[_PARTIAL]
>>   * ONLINE[_PARTIAL]
>> 
>> While, if my understanding is correct, those two offline states are 
>> transient.
>> If the required range is onlined, the state would be change to
>> ONLINE[_PARTIAL] respectively. If it is not, the state is reverted to UNUSED
>> or PLUGGED.
>
>Very right.
>
>> 
>> What I am lost is why you do virtio_mem_mb_remove() on OFFLINE_PARTIAL memory
>> block? Since we wait for the workqueue finish its job.

I have tried to understand the logic, while still have some confusion.

>
>That's an interesting corner case. Assume you have a 128MB memory block
>but only 64MB are plugged.

Since we just plug a part of memory block, this state is OFFLINE_PARTIAL
first. But then we would add these memory and online it. This means the state
of this memory block is ONLINE_PARTIAL.

When this state is changed to OFFLINE_PARTIAL again?

>
>As long as we have our online_pages callback in place, we can hinder the
>unplugged 64MB from getting exposed to the buddy
>(virtio_mem_online_page_cb()). However, once we unloaded the driver,

Yes,

virtio_mem_set_fake_offline() would __SetPageOffline() to those pages.

>this is no longer the case. If someone would online that memory block,
>we would expose unplugged memory to the buddy - very bad.
>

Per my understanding, at this point of time, the memory block is at online
state. Even part of it is set to *fake* offline.

So how could user trigger another online from sysfs interface?

>So we have to remove these partially plugged, offline memory blocks when
>losing control over them.
>
>I tried to document that via:
>
>"After we unregistered our callbacks, user space can online partially
>plugged offline blocks. Make sure to remove them."
>
>> 
>> Also, during virtio_mem_remove(), we just handle OFFLINE_PARTIAL memory 
>> block.
>> How about memory block in other states? It is not necessary to remove
>> ONLINE[_PARTIAL] memroy blocks?
>
>Blocks that are fully plugged (ONLINE or OFFLINE) can get
>onlined/offlined without us having to care. Works fine - we only have to
>care about partially plugged blocks.
>
>While we *could* unplug OFFLINE blocks, there is no way we can
>deterministically offline+remove ONLINE blocks. So that memory has to
>stay, even after we unloaded the driver (similar to the dax/kmem driver).

For OFFLINE memory blocks, would that leave the situation:

Guest doesn't need those pages, while host still maps them?

>
>ONLINE_PARTIAL is already taken care of: it cannot get offlined anymore,
>as we still hold references to these struct pages
>(virtio_mem_set_fake_offline()), and as we no longer have the memory
>notifier in place, we can no longer agree to offline this memory (when
>going_offline).
>

Ok, I seems to understand the logic now.

But how we prevent ONLINE_PARTIAL memory block get offlined? There are three
calls in virtio_mem_set_fake_offline(), while all of them adjust page's flag.
How they hold reference to struct page?

>I tried to document that via
>
>"After we unregistered our callbacks, user space can no longer offline
>partially plugged online memory blocks. No need to worry about them."
>
>
>> 
>> Thanks in advance, since I may missed some concepts.
>
>(force) driver unloading is a complicated corner case.
>
>Thanks!
>
>-- 
>Thanks,
>
>David / dhildenb

-- 
Wei Yang
Help you, Help me


[PATCH v3] Add support for mv88e6393x family of Marvell.

2020-10-15 Thread Pavana Sharma
The Marvell 88E6393X device is a single-chip integration of a 11-port
Ethernet switch with eight integrated Gigabit Ethernet (GbE) transceivers
and three 10-Gigabit interfaces.

This patch adds functionalities specific to mv88e6393x family (88E6393X,
88E6193X and 88E6191X)

Signed-off-by: Pavana Sharma 
---
Changes in v2:
  - Fix a warning (Reported-by: kernel test robot )
Changes in v3:
  - Fix 'unused function' warning
---
 drivers/net/dsa/mv88e6xxx/chip.c|  90 +
 drivers/net/dsa/mv88e6xxx/chip.h|   2 +
 drivers/net/dsa/mv88e6xxx/global1.h |   2 +
 drivers/net/dsa/mv88e6xxx/global2.h |   8 +
 drivers/net/dsa/mv88e6xxx/port.c| 302 
 drivers/net/dsa/mv88e6xxx/port.h|  39 +++-
 drivers/net/dsa/mv88e6xxx/serdes.c  | 239 ++
 drivers/net/dsa/mv88e6xxx/serdes.h  |  39 
 8 files changed, 720 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index f0dbc05e30a4..241ff788b0b1 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -634,6 +634,23 @@ static void mv88e6390x_phylink_validate(struct 
mv88e6xxx_chip *chip, int port,
mv88e6390_phylink_validate(chip, port, mask, state);
 }
 
+static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
+   unsigned long *mask,
+   struct phylink_link_state *state)
+{
+   if (port == 0 || port >= 9) {
+   phylink_set(mask, 1baseT_Full);
+   phylink_set(mask, 1baseKR_Full);
+   phylink_set(mask, 2500baseX_Full);
+   phylink_set(mask, 2500baseT_Full);
+   }
+
+   phylink_set(mask, 1000baseT_Full);
+   phylink_set(mask, 1000baseX_Full);
+
+   mv88e6065_phylink_validate(chip, port, mask, state);
+}
+
 static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
   unsigned long *supported,
   struct phylink_link_state *state)
@@ -4141,6 +4158,56 @@ static const struct mv88e6xxx_ops mv88e6191_ops = {
.phylink_validate = mv88e6390_phylink_validate,
 };
 
+static const struct mv88e6xxx_ops mv88e6193x_ops = {
+   /* MV88E6XXX_FAMILY_6393X */
+   .setup_errata = mv88e6393x_setup_errata,
+   .irl_init_all = mv88e6390_g2_irl_init_all,
+   .get_eeprom = mv88e6xxx_g2_get_eeprom8,
+   .set_eeprom = mv88e6xxx_g2_set_eeprom8,
+   .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
+   .phy_read = mv88e6xxx_g2_smi_phy_read,
+   .phy_write = mv88e6xxx_g2_smi_phy_write,
+   .port_set_link = mv88e6xxx_port_set_link,
+   .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex,
+   .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
+   .port_tag_remap = mv88e6390_port_tag_remap,
+   .port_set_frame_mode = mv88e6351_port_set_frame_mode,
+   .port_set_egress_floods = mv88e6352_port_set_egress_floods,
+   .port_set_ether_type = mv88e6393x_port_set_ether_type,
+   .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
+   .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
+   .port_pause_limit = mv88e6390_port_pause_limit,
+   .port_set_cmode = mv88e6393x_port_set_cmode,
+   .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
+   .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
+   .port_get_cmode = mv88e6352_port_get_cmode,
+   .stats_snapshot = mv88e6390_g1_stats_snapshot,
+   .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
+   .stats_get_sset_count = mv88e6320_stats_get_sset_count,
+   .stats_get_strings = mv88e6320_stats_get_strings,
+   .stats_get_stats = mv88e6390_stats_get_stats,
+   .set_cpu_port = mv88e6393x_port_set_cpu_dest,
+   .set_egress_port = mv88e6393x_set_egress_port,
+   .watchdog_ops = _watchdog_ops,
+   .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu,
+   .pot_clear = mv88e6xxx_g2_pot_clear,
+   .reset = mv88e6352_g1_reset,
+   .rmu_disable = mv88e6390_g1_rmu_disable,
+   .vtu_getnext = mv88e6390_g1_vtu_getnext,
+   .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
+   .serdes_power = mv88e6393x_serdes_power,
+   .serdes_get_lane = mv88e6393x_serdes_get_lane,
+   /* Check status register pause & lpa register */
+   .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
+   .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
+   .serdes_irq_enable = mv88e6393x_serdes_irq_enable,
+   .serdes_irq_status = mv88e6393x_serdes_irq_status,
+   .gpio_ops = _gpio_ops,
+   .avb_ops = _avb_ops,
+   .ptp_ops = _ptp_ops,
+   .phylink_validate = mv88e6393x_phylink_validate,
+};
+
 static const struct mv88e6xxx_ops mv88e6240_ops = {
/* MV88E6XXX_FAMILY_6352 */
.ieee_pri_map = mv88e6085_g1_ieee_pri_map,
@@ -5073,6 +5140,29 @@ static const 

Re: [GIT PULL] Networking

2020-10-15 Thread pr-tracker-bot
The pull request you sent on Thu, 15 Oct 2020 14:13:02 -0700:

> git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 
> tags/net-next-5.10

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/9ff9b0d392ea08090cd1780fb196f36dbb586529

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


Re: [GIT PULL] tracing: Updates for 5.10

2020-10-15 Thread Linus Torvalds
On Thu, Oct 15, 2020 at 10:53 AM Steven Rostedt  wrote:
>
> Updates for tracing and bootconfig:

Hmm. I haven't verified that this came from you, but it seems likely..
Once again my clang build shows something that I don't see in my
allmodconfig gcc build:

   WARNING: modpost: vmlinux.o(.text+0x1e5b06): Section mismatch in
reference from the function __trace_early_add_events() to the function
.init.text:__trace_early_add_new_event()
   The function __trace_early_add_events() references
   the function __init __trace_early_add_new_event().
   This is often because __trace_early_add_events lacks a __init
   annotation or the annotation of __trace_early_add_new_event is wrong.

Hmm?

   Linus


Re: [PATCH 8/8] staging: wfx: improve robustness of wfx_get_hw_rate()

2020-10-15 Thread Nathan Chancellor
On Fri, Oct 09, 2020 at 07:13:07PM +0200, Jerome Pouiller wrote:
> From: Jérôme Pouiller 
> 
> Smatch complains:
> 
> data_tx.c:37 wfx_get_hw_rate() warn: constraint '(struct 
> ieee80211_supported_band)->bitrates' overflow 'band->bitrates' 0 <= abs_rl 
> '0-127' user_rl '' required = '(struct ieee80211_supported_band)->n_bitrates'
> 23  struct ieee80211_supported_band *band;
> 24
> 25  if (rate->idx < 0)
> 26  return -1;
> 27  if (rate->flags & IEEE80211_TX_RC_MCS) {
> 28  if (rate->idx > 7) {
> 29  WARN(1, "wrong rate->idx value: %d", 
> rate->idx);
> 30  return -1;
> 31  }
> 32  return rate->idx + 14;
> 33  }
> 34  // WFx only support 2GHz, else band information should be 
> retrieved
> 35  // from ieee80211_tx_info
> 36  band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
> 37  return band->bitrates[rate->idx].hw_value;
> 
> Add a simple check to make Smatch happy.
> 
> Reported-by: Dan Carpenter 
> Signed-off-by: Jérôme Pouiller 
> ---
>  drivers/staging/wfx/data_tx.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
> index 8db0be08daf8..41f6a604a697 100644
> --- a/drivers/staging/wfx/data_tx.c
> +++ b/drivers/staging/wfx/data_tx.c
> @@ -31,6 +31,10 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
>   }
>   return rate->idx + 14;
>   }
> + if (rate->idx >= band->n_bitrates) {
> + WARN(1, "wrong rate->idx value: %d", rate->idx);
> + return -1;
> + }
>   // WFx only support 2GHz, else band information should be retrieved
>   // from ieee80211_tx_info
>   band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
> -- 
> 2.28.0
> 

This now causes a clang warning:

drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized 
when used here [-Wuninitialized]
if (rate->idx >= band->n_bitrates) {
 ^~~~
drivers/staging/wfx/data_tx.c:23:39: note: initialize the variable 'band' to 
silence this warning
struct ieee80211_supported_band *band;
 ^
  = NULL
1 warning generated.

Cheers,
Nathan


linux-next: manual merge of the amdgpu tree with Linus' tree

2020-10-15 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the amdgpu tree got a conflict in:

  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c

between commit:

  3cb9d2416ccd ("drm/amd/pm: setup APU dpm clock table in SMU HW 
initialization")

from Linus' tree and commit:

  44d6e160f60a ("drm/amd/pm: setup APU dpm clock table in SMU HW 
initialization")

from the amdgpu tree.

So this is one of the things that can go wrong when you have the same
patch obn both sides of a merge ... due to the context not verying
very much, the chunk of code that is moved into smu_smc_hw_setup()
by these identical patches was inserted twice by the automatic git
mrege resolution.

I fixed it up (I removed the second copy of the code) and can carry the
fix as necessary. This is now fixed as far as linux-next is concerned,
but any non trivial conflicts should be mentioned to your upstream
maintainer when your tree is submitted for merging.  You may also want
to consider cooperating with the maintainer of the conflicting tree to
minimise any particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell


pgpZVn8dcifWA.pgp
Description: OpenPGP digital signature


Re: [PATCH v2] x86/insn, tools/x86: Fix some potential undefined behavior.

2020-10-15 Thread Masami Hiramatsu
On Thu, 15 Oct 2020 09:12:16 -0700
Ian Rogers  wrote:

> From: Numfor Mbiziwo-Tiapo 
> 
> Don't perform unaligned loads in __get_next and __peek_nbyte_next as
> these are forms of undefined behavior.
> 
> These problems were identified using the undefined behavior sanitizer
> (ubsan) with the tools version of the code and perf test. Part of this
> patch was previously posted here:
> https://lore.kernel.org/lkml/20190724184512.162887-4-n...@google.com/
> 
> v2. removes the validate_next check and merges the 2 changes into one as
> requested by Masami Hiramatsu 

Looks good to me. This may be OK on x86, but now this code will be run
on other arches for cross compilation.

Acked-by: Masami Hiramatsu 

Thank you,

> 
> Signed-off-by: Ian Rogers 
> Signed-off-by: Numfor Mbiziwo-Tiapo 
> ---
>  arch/x86/lib/insn.c   | 4 ++--
>  tools/arch/x86/lib/insn.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
> index 404279563891..be88ab250146 100644
> --- a/arch/x86/lib/insn.c
> +++ b/arch/x86/lib/insn.c
> @@ -20,10 +20,10 @@
>   ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr)
>  
>  #define __get_next(t, insn)  \
> - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; })
> + ({ t r; memcpy(, insn->next_byte, sizeof(t)); insn->next_byte += 
> sizeof(t); r; })
>  
>  #define __peek_nbyte_next(t, insn, n)\
> - ({ t r = *(t*)((insn)->next_byte + n); r; })
> + ({ t r; memcpy(, (insn)->next_byte + n, sizeof(t)); r; })
>  
>  #define get_next(t, insn)\
>   ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; 
> __get_next(t, insn); })
> diff --git a/tools/arch/x86/lib/insn.c b/tools/arch/x86/lib/insn.c
> index 0151dfc6da61..92358c71a59e 100644
> --- a/tools/arch/x86/lib/insn.c
> +++ b/tools/arch/x86/lib/insn.c
> @@ -20,10 +20,10 @@
>   ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr)
>  
>  #define __get_next(t, insn)  \
> - ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; })
> + ({ t r; memcpy(, insn->next_byte, sizeof(t)); insn->next_byte += 
> sizeof(t); r; })
>  
>  #define __peek_nbyte_next(t, insn, n)\
> - ({ t r = *(t*)((insn)->next_byte + n); r; })
> + ({ t r; memcpy(, (insn)->next_byte + n, sizeof(t)); r; })
>  
>  #define get_next(t, insn)\
>   ({ if (unlikely(!validate_next(t, insn, 0))) goto err_out; 
> __get_next(t, insn); })
> -- 
> 2.28.0.1011.ga647a8990f-goog
> 


-- 
Masami Hiramatsu 


My Dear in the lord

2020-10-15 Thread Mrs. Mina A. Brunel



My Dear in the lord


My name is Mrs. Mina A. Brunel I am a Norway Citizen who is living in Burkina 
Faso, I am married to Mr. Brunel Patrice, a politicians who owns a small gold 
company in Burkina Faso; He died of Leprosy and Radesyge, in year February 
2010, During his lifetime he deposited the sum of € 8.5 Million Euro) Eight 
million, Five hundred thousand Euros in a bank in Ouagadougou the capital city 
of of Burkina in West Africa. The money was from the sale of his company and 
death benefits payment and entitlements of my deceased husband by his company.

I am sending you this message with heavy tears in my eyes and great sorrow in 
my heart, and also praying that it will reach you in good health because I am 
not in good health, I sleep every night without knowing if I may be alive to 
see the next day. I am suffering from long time cancer and presently I am 
partially suffering from Leprosy, which has become difficult for me to move 
around. I was married to my late husband for more than 6 years without having a 
child and my doctor confided that I have less chance to live, having to know 
when the cup of death will come, I decided to contact you to claim the fund 
since I don't have any relation I grew up from an orphanage home.

I have decided to donate this money for the support of helping Motherless 
babies/Less privileged/Widows and churches also to build the house of God 
because I am dying and diagnosed with cancer for about 3 years ago. I have 
decided to donate from what I have inherited from my late husband to you for 
the good work of Almighty God; I will be going in for an operation surgery soon.

Now I want you to stand as my next of kin to claim the funds for charity 
purposes. Because of this money remains unclaimed after my death, the bank 
executives or the government will take the money as unclaimed fund and maybe 
use it for selfishness and worthless ventures, I need a very honest person who 
can claim this money and use it for Charity works, for orphanages, widows and 
also build schools and churches for less privilege that will be named after my 
late husband and my name.

I need your urgent answer to know if you will be able to execute this project, 
and I will give you more information on how the fund will be transferred to 
your bank account or online banking.

Thanks
Mrs. Mina A. Brunel


[PATCH drm/hisilicon v3 0/2] Use the same style of variable type

2020-10-15 Thread Tian Tao
patch #1 and #2 Use the same style of variable type in hisilicon drm driver
and both are clean up, no actual functional changes.

Changes since v1:
-Change part of unsigned int to size_t.

Changes since v2:
-Modify the type of fb_base and fb_size to resource_size_t. 

Tian Tao (2):
  drm/hisilicon: Use the same style of variable type in hibmc_drm_de
  drm/hisilicon: Use the same style of variable type in hibmc_drm_drv

 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c  | 59 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 13 +++---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h |  8 ++--
 3 files changed, 39 insertions(+), 41 deletions(-)

-- 
2.7.4



[PATCH drm/hisilicon v3 2/2] drm/hisilicon: Use the same style of variable type in hibmc_drm_drv

2020-10-15 Thread Tian Tao
Consistently Use the same style of variable type in hibmc_drm_drv.c and
hibmc_drm_drv.h.

Signed-off-by: Tian Tao 
Acked-by: Thomas Zimmermann 
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 13 ++---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h |  8 
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 5632bce..0c1b40d 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -121,12 +121,11 @@ static void hibmc_kms_fini(struct hibmc_drm_private *priv)
 /*
  * It can operate in one of three modes: 0, 1 or Sleep.
  */
-void hibmc_set_power_mode(struct hibmc_drm_private *priv,
- unsigned int power_mode)
+void hibmc_set_power_mode(struct hibmc_drm_private *priv, u32 power_mode)
 {
-   unsigned int control_value = 0;
+   u32 control_value = 0;
void __iomem   *mmio = priv->mmio;
-   unsigned int input = 1;
+   u32 input = 1;
 
if (power_mode > HIBMC_PW_MODE_CTL_MODE_SLEEP)
return;
@@ -144,8 +143,8 @@ void hibmc_set_power_mode(struct hibmc_drm_private *priv,
 
 void hibmc_set_current_gate(struct hibmc_drm_private *priv, unsigned int gate)
 {
-   unsigned int gate_reg;
-   unsigned int mode;
+   u32 gate_reg;
+   u32 mode;
void __iomem   *mmio = priv->mmio;
 
/* Get current power mode. */
@@ -170,7 +169,7 @@ void hibmc_set_current_gate(struct hibmc_drm_private *priv, 
unsigned int gate)
 
 static void hibmc_hw_config(struct hibmc_drm_private *priv)
 {
-   unsigned int reg;
+   u32 reg;
 
/* On hardware reset, power mode 0 is default. */
hibmc_set_power_mode(priv, HIBMC_PW_MODE_CTL_MODE_MODE0);
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
index 6a63502..f310a83 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h
@@ -33,8 +33,8 @@ struct hibmc_drm_private {
/* hw */
void __iomem   *mmio;
void __iomem   *fb_map;
-   unsigned long  fb_base;
-   unsigned long  fb_size;
+   resource_size_t  fb_base;
+   resource_size_t  fb_size;
 
/* drm */
struct drm_device  *dev;
@@ -56,9 +56,9 @@ static inline struct hibmc_drm_private 
*to_hibmc_drm_private(struct drm_device *
 }
 
 void hibmc_set_power_mode(struct hibmc_drm_private *priv,
- unsigned int power_mode);
+ u32 power_mode);
 void hibmc_set_current_gate(struct hibmc_drm_private *priv,
-   unsigned int gate);
+   u32 gate);
 
 int hibmc_de_init(struct hibmc_drm_private *priv);
 int hibmc_vdac_init(struct hibmc_drm_private *priv);
-- 
2.7.4



[PATCH drm/hisilicon v3 1/2] drm/hisilicon: Use the same style of variable type in hibmc_drm_de

2020-10-15 Thread Tian Tao
Consistently Use the same style of variable type in hibmc_drm_de.c.

Signed-off-by: Tian Tao 
Acked-by: Thomas Zimmermann 
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 59 +-
 1 file changed, 29 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index 8478a84..a1eabad 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -23,15 +23,15 @@
 #include "hibmc_drm_regs.h"
 
 struct hibmc_display_panel_pll {
-   unsigned long M;
-   unsigned long N;
-   unsigned long OD;
-   unsigned long POD;
+   u64 M;
+   u64 N;
+   u64 OD;
+   u64 POD;
 };
 
 struct hibmc_dislay_pll_config {
-   unsigned long hdisplay;
-   unsigned long vdisplay;
+   u64 hdisplay;
+   u64 vdisplay;
u32 pll1_config_value;
u32 pll2_config_value;
 };
@@ -102,7 +102,7 @@ static void hibmc_plane_atomic_update(struct drm_plane 
*plane,
struct drm_plane_state  *state  = plane->state;
u32 reg;
s64 gpu_addr = 0;
-   unsigned int line_l;
+   u32 line_l;
struct hibmc_drm_private *priv = to_hibmc_drm_private(plane->dev);
struct drm_gem_vram_object *gbo;
 
@@ -155,10 +155,10 @@ static const struct drm_plane_helper_funcs 
hibmc_plane_helper_funcs = {
.atomic_update = hibmc_plane_atomic_update,
 };
 
-static void hibmc_crtc_dpms(struct drm_crtc *crtc, int dpms)
+static void hibmc_crtc_dpms(struct drm_crtc *crtc, u32 dpms)
 {
struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
-   unsigned int reg;
+   u32 reg;
 
reg = readl(priv->mmio + HIBMC_CRT_DISP_CTL);
reg &= ~HIBMC_CRT_DISP_CTL_DPMS_MASK;
@@ -172,7 +172,7 @@ static void hibmc_crtc_dpms(struct drm_crtc *crtc, int dpms)
 static void hibmc_crtc_atomic_enable(struct drm_crtc *crtc,
 struct drm_atomic_state *state)
 {
-   unsigned int reg;
+   u32 reg;
struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
 
hibmc_set_power_mode(priv, HIBMC_PW_MODE_CTL_MODE_MODE0);
@@ -191,7 +191,7 @@ static void hibmc_crtc_atomic_enable(struct drm_crtc *crtc,
 static void hibmc_crtc_atomic_disable(struct drm_crtc *crtc,
  struct drm_atomic_state *state)
 {
-   unsigned int reg;
+   u32 reg;
struct hibmc_drm_private *priv = to_hibmc_drm_private(crtc->dev);
 
hibmc_crtc_dpms(crtc, HIBMC_CRT_DPMS_OFF);
@@ -212,7 +212,7 @@ static enum drm_mode_status
 hibmc_crtc_mode_valid(struct drm_crtc *crtc,
  const struct drm_display_mode *mode)
 {
-   int i = 0;
+   size_t i = 0;
int vrefresh = drm_mode_vrefresh(mode);
 
if (vrefresh < 59 || vrefresh > 61)
@@ -227,9 +227,9 @@ hibmc_crtc_mode_valid(struct drm_crtc *crtc,
return MODE_BAD;
 }
 
-static unsigned int format_pll_reg(void)
+static u32 format_pll_reg(void)
 {
-   unsigned int pllreg = 0;
+   u32 pllreg = 0;
struct hibmc_display_panel_pll pll = {0};
 
/*
@@ -249,7 +249,7 @@ static unsigned int format_pll_reg(void)
return pllreg;
 }
 
-static void set_vclock_hisilicon(struct drm_device *dev, unsigned long pll)
+static void set_vclock_hisilicon(struct drm_device *dev, u64 pll)
 {
u32 val;
struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
@@ -279,11 +279,10 @@ static void set_vclock_hisilicon(struct drm_device *dev, 
unsigned long pll)
writel(val, priv->mmio + CRT_PLL1_HS);
 }
 
-static void get_pll_config(unsigned long x, unsigned long y,
-  u32 *pll1, u32 *pll2)
+static void get_pll_config(u64 x, u64 y, u32 *pll1, u32 *pll2)
 {
-   int i;
-   int count = ARRAY_SIZE(hibmc_pll_table);
+   size_t i;
+   size_t count = ARRAY_SIZE(hibmc_pll_table);
 
for (i = 0; i < count; i++) {
if (hibmc_pll_table[i].hdisplay == x &&
@@ -306,11 +305,11 @@ static void get_pll_config(unsigned long x, unsigned long 
y,
  * FPGA only supports 7 predefined pixel clocks, and clock select is
  * in bit 4:0 of new register 0x802a8.
  */
-static unsigned int display_ctrl_adjust(struct drm_device *dev,
-   struct drm_display_mode *mode,
-   unsigned int ctrl)
+static u32 display_ctrl_adjust(struct drm_device *dev,
+  struct drm_display_mode *mode,
+  u32 ctrl)
 {
-   unsigned long x, y;
+   u64 x, y;
u32 pll1; /* bit[31:0] of PLL */
u32 pll2; /* bit[63:32] of PLL */
struct hibmc_drm_private *priv = to_hibmc_drm_private(dev);
@@ -358,12 +357,12 @@ static unsigned int display_ctrl_adjust(struct drm_device 
*dev,
 
 static void hibmc_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
-   unsigned int val;

Re: [PATCH v2 net-next] net: stmmac: Enable EEE HW LPI timer with auto SW/HW switching

2020-10-15 Thread kernel test robot
Hi Voon,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Voon-Weifeng/net-stmmac-Enable-EEE-HW-LPI-timer-with-auto-SW-HW-switching/20201016-000231
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
d25e2e9388eda61b6e298585024ee3355f50c493
config: x86_64-randconfig-a012-20201015 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
e7b4feea8e1bf520b34ad8c116abab6677344b74)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# 
https://github.com/0day-ci/linux/commit/b208a1e7f74a391d1d7c2950e35b97c59af55585
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Voon-Weifeng/net-stmmac-Enable-EEE-HW-LPI-timer-with-auto-SW-HW-switching/20201016-000231
git checkout b208a1e7f74a391d1d7c2950e35b97c59af55585
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:297:6: warning: no 
>> previous prototype for function 'stmmac_lpi_entry_timer_config' 
>> [-Wmissing-prototypes]
   void stmmac_lpi_entry_timer_config(struct stmmac_priv *priv, bool en)
^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:297:1: note: declare 
'static' if the function is not intended to be used outside of this translation 
unit
   void stmmac_lpi_entry_timer_config(struct stmmac_priv *priv, bool en)
   ^
   static 
   1 warning generated.

vim +/stmmac_lpi_entry_timer_config +297 
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

   296  
 > 297  void stmmac_lpi_entry_timer_config(struct stmmac_priv *priv, bool en)
   298  {
   299  int tx_lpi_timer;
   300  
   301  /* Clear/set the SW EEE timer flag based on LPI ET enablement */
   302  priv->eee_sw_timer_en = en ? 0 : 1;
   303  tx_lpi_timer  = en ? priv->tx_lpi_timer : 0;
   304  stmmac_set_eee_lpi_timer(priv, priv->hw, tx_lpi_timer);
   305  }
   306  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


Re: [PATCH] zsmalloc: Rework the list_add code in insert_zspage()

2020-10-15 Thread Sergey Senozhatsky
On (20/10/15 11:51), Minchan Kim wrote:
> On Thu, Oct 15, 2020 at 09:01:07AM -0400, Miaohe Lin wrote:
> > Rework the list_add code to make it more readable and simplicity.
> > 
> > Signed-off-by: Miaohe Lin 
> Acked-by: Minchan Kim 

Reviewed-by: Sergey Senozhatsky 

-ss


Re: [PATCH] zram: support a page writeback

2020-10-15 Thread Sergey Senozhatsky
On (20/10/12 00:14), Minchan Kim wrote:
>  
>  With the command, zram writeback idle pages from memory to the storage.
>  
> +If admin want to write a specific page in zram device to backing device,
> +they could write the page index into the interface.
> +
> + echo 1251 > /sys/block/zramX/writeback
> +

May be we can make it more explicit?

echo "page_index=123" > /sys/block/zramX/writeback

Just in case of future extensions. E.g. someone might want to
have something like

echo "idle_nr=123" > /sys/block/zramX/writeback

which would write_back 123 idle pages max.

-ss


[PATCH v9 02/15] PCI/RCEC: Bind RCEC devices to the Root Port driver

2020-10-15 Thread Sean V Kelley
From: Qiuxu Zhuo 

If a Root Complex Integrated Endpoint (RCiEP) is implemented, it may signal
errors through a Root Complex Event Collector (RCEC).  Each RCiEP must be
associated with no more than one RCEC.

For an RCEC (which is technically not a Bridge), error messages "received"
from associated RCiEPs must be enabled for "transmission" in order to cause
a System Error via the Root Control register or (when the Advanced Error
Reporting Capability is present) reporting via the Root Error Command
register and logging in the Root Error Status register and Error Source
Identification register.

Given the commonality with Root Ports and the need to also support AER and
PME services for RCECs, extend the Root Port driver to support RCEC devices
by adding the RCEC Class ID to the driver structure.

Co-developed-by: Sean V Kelley 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-3-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Qiuxu Zhuo 
Signed-off-by: Bjorn Helgaas 
Reviewed-by: Jonathan Cameron 
---
 drivers/pci/pcie/portdrv_pci.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 3a3ce40ae1ab..4d880679b9b1 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -106,7 +106,8 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
if (!pci_is_pcie(dev) ||
((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
 (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
-(pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM)))
+(pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM) &&
+(pci_pcie_type(dev) != PCI_EXP_TYPE_RC_EC)))
return -ENODEV;
 
status = pcie_port_device_register(dev);
@@ -195,6 +196,8 @@ static const struct pci_device_id port_pci_ids[] = {
{ PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0) },
/* subtractive decode PCI-to-PCI bridge, class type is 060401h */
{ PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x01), ~0) },
+   /* handle any Root Complex Event Collector */
+   { PCI_DEVICE_CLASS(((PCI_CLASS_SYSTEM_RCEC << 8) | 0x00), ~0) },
{ },
 };
 
-- 
2.28.0



[PATCH v9 07/15] PCI/ERR: Use "bridge" for clarity in pcie_do_recovery()

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

pcie_do_recovery() may be called with "dev" being either a bridge (Root
Port or Switch Downstream Port) or an Endpoint.  The bulk of the function
deals with the bridge, so if we start with an Endpoint, we reset "dev" to
be the bridge leading to it.

For clarity, replace "dev" in the body of the function with "bridge".  No
functional change intended.

[bhelgaas: commit log, split pieces out so this is pure rename, also
replace "dev" with "bridge" in messages and pci_uevent_ers()]
Suggested-by: Bjorn Helgaas 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-6-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Acked-by: Jonathan Cameron 
---
 drivers/pci/pcie/err.c | 37 -
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 7a5af873d8bc..46a5b84f8842 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -151,24 +151,27 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev))
 {
int type = pci_pcie_type(dev);
-   pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
+   struct pci_dev *bridge;
struct pci_bus *bus;
+   pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
 
/*
-* Error recovery runs on all subordinates of the first downstream port.
-* If the downstream port detected the error, it is cleared at the end.
+* Error recovery runs on all subordinates of the bridge.  If the
+* bridge detected the error, it is cleared at the end.
 */
if (!(type == PCI_EXP_TYPE_ROOT_PORT ||
  type == PCI_EXP_TYPE_DOWNSTREAM))
-   dev = pci_upstream_bridge(dev);
-   bus = dev->subordinate;
+   bridge = pci_upstream_bridge(dev);
+   else
+   bridge = dev;
 
-   pci_dbg(dev, "broadcast error_detected message\n");
+   bus = bridge->subordinate;
+   pci_dbg(bridge, "broadcast error_detected message\n");
if (state == pci_channel_io_frozen) {
pci_walk_bus(bus, report_frozen_detected, );
-   status = reset_subordinates(dev);
+   status = reset_subordinates(bridge);
if (status != PCI_ERS_RESULT_RECOVERED) {
-   pci_warn(dev, "subordinate device reset failed\n");
+   pci_warn(bridge, "subordinate device reset failed\n");
goto failed;
}
} else {
@@ -177,7 +180,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 
if (status == PCI_ERS_RESULT_CAN_RECOVER) {
status = PCI_ERS_RESULT_RECOVERED;
-   pci_dbg(dev, "broadcast mmio_enabled message\n");
+   pci_dbg(bridge, "broadcast mmio_enabled message\n");
pci_walk_bus(bus, report_mmio_enabled, );
}
 
@@ -188,27 +191,27 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 * drivers' slot_reset callbacks?
 */
status = PCI_ERS_RESULT_RECOVERED;
-   pci_dbg(dev, "broadcast slot_reset message\n");
+   pci_dbg(bridge, "broadcast slot_reset message\n");
pci_walk_bus(bus, report_slot_reset, );
}
 
if (status != PCI_ERS_RESULT_RECOVERED)
goto failed;
 
-   pci_dbg(dev, "broadcast resume message\n");
+   pci_dbg(bridge, "broadcast resume message\n");
pci_walk_bus(bus, report_resume, );
 
-   if (pcie_aer_is_native(dev))
-   pcie_clear_device_status(dev);
-   pci_aer_clear_nonfatal_status(dev);
-   pci_info(dev, "device recovery successful\n");
+   if (pcie_aer_is_native(bridge))
+   pcie_clear_device_status(bridge);
+   pci_aer_clear_nonfatal_status(bridge);
+   pci_info(bridge, "device recovery successful\n");
return status;
 
 failed:
-   pci_uevent_ers(dev, PCI_ERS_RESULT_DISCONNECT);
+   pci_uevent_ers(bridge, PCI_ERS_RESULT_DISCONNECT);
 
/* TODO: Should kernel panic here? */
-   pci_info(dev, "device recovery failed\n");
+   pci_info(bridge, "device recovery failed\n");
 
return status;
 }
-- 
2.28.0



[PATCH v9 05/15] PCI/ERR: Simplify by using pci_upstream_bridge()

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

Use pci_upstream_bridge() in place of dev->bus->self.  No functional change
intended.

[bhelgaas: split to separate patch]
Link: 
https://lore.kernel.org/r/20201002184735.1229220-6-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Acked-by: Jonathan Cameron 
---
 drivers/pci/pcie/err.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index db149c6ce4fb..05f61da5ed9d 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -159,7 +159,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 */
if (!(pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
  pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM))
-   dev = dev->bus->self;
+   dev = pci_upstream_bridge(dev);
bus = dev->subordinate;
 
pci_dbg(dev, "broadcast error_detected message\n");
-- 
2.28.0



[PATCH v9 06/15] PCI/ERR: Simplify by computing pci_pcie_type() once

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

Instead of calling pci_pcie_type(dev) twice, call it once and save the
result.  No functional change intended.

[bhelgaas: split to separate patch]
Link: 
https://lore.kernel.org/r/20201002184735.1229220-6-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Acked-by: Jonathan Cameron 
---
 drivers/pci/pcie/err.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 05f61da5ed9d..7a5af873d8bc 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -150,6 +150,7 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_channel_state_t state,
pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev))
 {
+   int type = pci_pcie_type(dev);
pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
struct pci_bus *bus;
 
@@ -157,8 +158,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 * Error recovery runs on all subordinates of the first downstream port.
 * If the downstream port detected the error, it is cleared at the end.
 */
-   if (!(pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
- pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM))
+   if (!(type == PCI_EXP_TYPE_ROOT_PORT ||
+ type == PCI_EXP_TYPE_DOWNSTREAM))
dev = pci_upstream_bridge(dev);
bus = dev->subordinate;
 
-- 
2.28.0



[PATCH v9 08/15] PCI/ERR: Avoid negated conditional for clarity

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

Reverse the sense of the Root Port/Downstream Port conditional for clarity.
No functional change intended.

[bhelgaas: split to separate patch]
Link: 
https://lore.kernel.org/r/20201002184735.1229220-6-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Acked-by: Jonathan Cameron 
---
 drivers/pci/pcie/err.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 46a5b84f8842..931e75f2549d 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -159,11 +159,11 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 * Error recovery runs on all subordinates of the bridge.  If the
 * bridge detected the error, it is cleared at the end.
 */
-   if (!(type == PCI_EXP_TYPE_ROOT_PORT ||
- type == PCI_EXP_TYPE_DOWNSTREAM))
-   bridge = pci_upstream_bridge(dev);
-   else
+   if (type == PCI_EXP_TYPE_ROOT_PORT ||
+   type == PCI_EXP_TYPE_DOWNSTREAM)
bridge = dev;
+   else
+   bridge = pci_upstream_bridge(dev);
 
bus = bridge->subordinate;
pci_dbg(bridge, "broadcast error_detected message\n");
-- 
2.28.0



[PATCH v9 09/15] PCI/ERR: Add pci_walk_bridge() to pcie_do_recovery()

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

Consolidate subordinate bus checks with pci_walk_bus() into
pci_walk_bridge() for walking below potentially AER affected bridges.

[bhelgaas: fix kerneldoc]
Suggested-by: Bjorn Helgaas 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-7-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
---
 drivers/pci/pcie/err.c | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 931e75f2549d..8b53aecdb43d 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -146,13 +146,30 @@ static int report_resume(struct pci_dev *dev, void *data)
return 0;
 }
 
+/**
+ * pci_walk_bridge - walk bridges potentially AER affected
+ * @bridge:bridge which may be a Port
+ * @cb:callback to be called for each device found
+ * @userdata:  arbitrary pointer to be passed to callback
+ *
+ * If the device provided is a bridge, walk the subordinate bus, including
+ * any bridged devices on buses under this bus.  Call the provided callback
+ * on each device found.
+ */
+static void pci_walk_bridge(struct pci_dev *bridge,
+   int (*cb)(struct pci_dev *, void *),
+   void *userdata)
+{
+   if (bridge->subordinate)
+   pci_walk_bus(bridge->subordinate, cb, userdata);
+}
+
 pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_channel_state_t state,
pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev))
 {
int type = pci_pcie_type(dev);
struct pci_dev *bridge;
-   struct pci_bus *bus;
pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
 
/*
@@ -165,23 +182,22 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
else
bridge = pci_upstream_bridge(dev);
 
-   bus = bridge->subordinate;
pci_dbg(bridge, "broadcast error_detected message\n");
if (state == pci_channel_io_frozen) {
-   pci_walk_bus(bus, report_frozen_detected, );
+   pci_walk_bridge(bridge, report_frozen_detected, );
status = reset_subordinates(bridge);
if (status != PCI_ERS_RESULT_RECOVERED) {
pci_warn(bridge, "subordinate device reset failed\n");
goto failed;
}
} else {
-   pci_walk_bus(bus, report_normal_detected, );
+   pci_walk_bridge(bridge, report_normal_detected, );
}
 
if (status == PCI_ERS_RESULT_CAN_RECOVER) {
status = PCI_ERS_RESULT_RECOVERED;
pci_dbg(bridge, "broadcast mmio_enabled message\n");
-   pci_walk_bus(bus, report_mmio_enabled, );
+   pci_walk_bridge(bridge, report_mmio_enabled, );
}
 
if (status == PCI_ERS_RESULT_NEED_RESET) {
@@ -192,14 +208,14 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 */
status = PCI_ERS_RESULT_RECOVERED;
pci_dbg(bridge, "broadcast slot_reset message\n");
-   pci_walk_bus(bus, report_slot_reset, );
+   pci_walk_bridge(bridge, report_slot_reset, );
}
 
if (status != PCI_ERS_RESULT_RECOVERED)
goto failed;
 
pci_dbg(bridge, "broadcast resume message\n");
-   pci_walk_bus(bus, report_resume, );
+   pci_walk_bridge(bridge, report_resume, );
 
if (pcie_aer_is_native(bridge))
pcie_clear_device_status(bridge);
-- 
2.28.0



[PATCH v9 04/15] PCI/ERR: Rename reset_link() to reset_subordinates()

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

reset_link() appears to be misnamed.  The point is to reset any devices
below a given bridge, so rename it to reset_subordinates() to make it clear
that we are passing a bridge with the intent to reset the devices below it.

[bhelgaas: fix reset_subordinate_device() typo, shorten name]
Suggested-by: Bjorn Helgaas 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-5-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Acked-by: Jonathan Cameron 
---
 drivers/pci/pci.h  | 4 ++--
 drivers/pci/pcie/err.c | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index af98b7d2134b..bc2340971a50 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -573,8 +573,8 @@ static inline int pci_dev_specific_disable_acs_redir(struct 
pci_dev *dev)
 
 /* PCI error reporting and recovery */
 pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
-   pci_channel_state_t state,
-   pci_ers_result_t (*reset_link)(struct pci_dev *pdev));
+   pci_channel_state_t state,
+   pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev));
 
 bool pcie_wait_for_link(struct pci_dev *pdev, bool active);
 #ifdef CONFIG_PCIEASPM
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index c543f419d8f9..db149c6ce4fb 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -147,8 +147,8 @@ static int report_resume(struct pci_dev *dev, void *data)
 }
 
 pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
-   pci_channel_state_t state,
-   pci_ers_result_t (*reset_link)(struct pci_dev *pdev))
+   pci_channel_state_t state,
+   pci_ers_result_t (*reset_subordinates)(struct pci_dev *pdev))
 {
pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
struct pci_bus *bus;
@@ -165,9 +165,9 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_dbg(dev, "broadcast error_detected message\n");
if (state == pci_channel_io_frozen) {
pci_walk_bus(bus, report_frozen_detected, );
-   status = reset_link(dev);
+   status = reset_subordinates(dev);
if (status != PCI_ERS_RESULT_RECOVERED) {
-   pci_warn(dev, "link reset failed\n");
+   pci_warn(dev, "subordinate device reset failed\n");
goto failed;
}
} else {
-- 
2.28.0



[PATCH v9 03/15] PCI/RCEC: Cache RCEC capabilities in pci_init_capabilities()

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

Extend support for Root Complex Event Collectors by decoding and caching
the RCEC Endpoint Association Extended Capabilities when enumerating. Use
that cached information for later error source reporting. See PCIe r5.0,
sec 7.9.10.

[bhelgaas: make pci_rcec_init() void, set dev->rcec_ea after filling it]
Suggested-by: Bjorn Helgaas 
Co-developed-by: Qiuxu Zhuo 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-4-seanvk@oregontracks.org
Signed-off-by: Qiuxu Zhuo 
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Reviewed-by: Jonathan Cameron 
---
 drivers/pci/pci.h | 17 +++
 drivers/pci/pcie/Makefile |  2 +-
 drivers/pci/pcie/rcec.c   | 59 +++
 drivers/pci/probe.c   |  2 ++
 include/linux/pci.h   |  4 +++
 5 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 drivers/pci/pcie/rcec.c

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index fa12f7cbc1a0..af98b7d2134b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -449,6 +449,15 @@ int aer_get_device_error_info(struct pci_dev *dev, struct 
aer_err_info *info);
 void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
 #endif /* CONFIG_PCIEAER */
 
+#ifdef CONFIG_PCIEPORTBUS
+/* Cached RCEC Endpoint Association */
+struct rcec_ea {
+   u8  nextbusn;
+   u8  lastbusn;
+   u32 bitmap;
+};
+#endif
+
 #ifdef CONFIG_PCIE_DPC
 void pci_save_dpc_state(struct pci_dev *dev);
 void pci_restore_dpc_state(struct pci_dev *dev);
@@ -461,6 +470,14 @@ static inline void pci_restore_dpc_state(struct pci_dev 
*dev) {}
 static inline void pci_dpc_init(struct pci_dev *pdev) {}
 #endif
 
+#ifdef CONFIG_PCIEPORTBUS
+void pci_rcec_init(struct pci_dev *dev);
+void pci_rcec_exit(struct pci_dev *dev);
+#else
+static inline void pci_rcec_init(struct pci_dev *dev) {}
+static inline void pci_rcec_exit(struct pci_dev *dev) {}
+#endif
+
 #ifdef CONFIG_PCI_ATS
 /* Address Translation Service */
 void pci_ats_init(struct pci_dev *dev);
diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile
index 68da9280ff11..d9697892fa3e 100644
--- a/drivers/pci/pcie/Makefile
+++ b/drivers/pci/pcie/Makefile
@@ -2,7 +2,7 @@
 #
 # Makefile for PCI Express features and port driver
 
-pcieportdrv-y  := portdrv_core.o portdrv_pci.o err.o
+pcieportdrv-y  := portdrv_core.o portdrv_pci.o err.o rcec.o
 
 obj-$(CONFIG_PCIEPORTBUS)  += pcieportdrv.o
 
diff --git a/drivers/pci/pcie/rcec.c b/drivers/pci/pcie/rcec.c
new file mode 100644
index ..038e9d706d5f
--- /dev/null
+++ b/drivers/pci/pcie/rcec.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Root Complex Event Collector Support
+ *
+ * Authors:
+ *  Sean V Kelley 
+ *  Qiuxu Zhuo 
+ *
+ * Copyright (C) 2020 Intel Corp.
+ */
+
+#include 
+#include 
+#include 
+
+#include "../pci.h"
+
+void pci_rcec_init(struct pci_dev *dev)
+{
+   struct rcec_ea *rcec_ea;
+   u32 rcec, hdr, busn;
+   u8 ver;
+
+   /* Only for Root Complex Event Collectors */
+   if (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_EC)
+   return;
+
+   rcec = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_RCEC);
+   if (!rcec)
+   return;
+
+   rcec_ea = kzalloc(sizeof(*rcec_ea), GFP_KERNEL);
+   if (!rcec_ea)
+   return;
+
+   pci_read_config_dword(dev, rcec + PCI_RCEC_RCIEP_BITMAP,
+ _ea->bitmap);
+
+   /* Check whether RCEC BUSN register is present */
+   pci_read_config_dword(dev, rcec, );
+   ver = PCI_EXT_CAP_VER(hdr);
+   if (ver >= PCI_RCEC_BUSN_REG_VER) {
+   pci_read_config_dword(dev, rcec + PCI_RCEC_BUSN, );
+   rcec_ea->nextbusn = PCI_RCEC_BUSN_NEXT(busn);
+   rcec_ea->lastbusn = PCI_RCEC_BUSN_LAST(busn);
+   } else {
+   /* Avoid later ver check by setting nextbusn */
+   rcec_ea->nextbusn = 0xff;
+   rcec_ea->lastbusn = 0x00;
+   }
+
+   dev->rcec_ea = rcec_ea;
+}
+
+void pci_rcec_exit(struct pci_dev *dev)
+{
+   kfree(dev->rcec_ea);
+   dev->rcec_ea = NULL;
+}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 03d37128a24f..25f01f841f2d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2201,6 +2201,7 @@ static void pci_configure_device(struct pci_dev *dev)
 static void pci_release_capabilities(struct pci_dev *dev)
 {
pci_aer_exit(dev);
+   pci_rcec_exit(dev);
pci_vpd_release(dev);
pci_iov_release(dev);
pci_free_cap_save_buffers(dev);
@@ -2400,6 +2401,7 @@ static void pci_init_capabilities(struct pci_dev *dev)
pci_ptm_init(dev);  /* Precision Time Measurement */
pci_aer_init(dev);  /* Advanced Error Reporting */
pci_dpc_init(dev);  /* Downstream Port Containment */
+   pci_rcec_init(dev); /* Root 

[PATCH v9 10/15] PCI/ERR: Limit AER resets in pcie_do_recovery()

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

In some cases a bridge may not exist as the hardware controlling may be
handled only by firmware and so is not visible to the OS. This scenario is
also possible in future use cases involving non-native use of RCECs by
firmware.

Explicitly apply conditional logic around these resets by limiting them to
Root Ports and Downstream Ports.

Link: 
https://lore.kernel.org/r/20201002184735.1229220-8-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Acked-by: Jonathan Cameron 
---
 drivers/pci/pcie/err.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 8b53aecdb43d..7883c9791562 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -148,13 +148,17 @@ static int report_resume(struct pci_dev *dev, void *data)
 
 /**
  * pci_walk_bridge - walk bridges potentially AER affected
- * @bridge:bridge which may be a Port
+ * @bridge:bridge which may be a Port, an RCEC with associated RCiEPs,
+ * or an RCiEP associated with an RCEC
  * @cb:callback to be called for each device found
  * @userdata:  arbitrary pointer to be passed to callback
  *
  * If the device provided is a bridge, walk the subordinate bus, including
  * any bridged devices on buses under this bus.  Call the provided callback
  * on each device found.
+ *
+ * If the device provided has no subordinate bus, call the callback on the
+ * device itself.
  */
 static void pci_walk_bridge(struct pci_dev *bridge,
int (*cb)(struct pci_dev *, void *),
@@ -162,6 +166,8 @@ static void pci_walk_bridge(struct pci_dev *bridge,
 {
if (bridge->subordinate)
pci_walk_bus(bridge->subordinate, cb, userdata);
+   else
+   cb(bridge, userdata);
 }
 
 pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
@@ -174,10 +180,13 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
 
/*
 * Error recovery runs on all subordinates of the bridge.  If the
-* bridge detected the error, it is cleared at the end.
+* bridge detected the error, it is cleared at the end.  For RCiEPs
+* we should reset just the RCiEP itself.
 */
if (type == PCI_EXP_TYPE_ROOT_PORT ||
-   type == PCI_EXP_TYPE_DOWNSTREAM)
+   type == PCI_EXP_TYPE_DOWNSTREAM ||
+   type == PCI_EXP_TYPE_RC_EC ||
+   type == PCI_EXP_TYPE_RC_END)
bridge = dev;
else
bridge = pci_upstream_bridge(dev);
@@ -185,6 +194,12 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_dbg(bridge, "broadcast error_detected message\n");
if (state == pci_channel_io_frozen) {
pci_walk_bridge(bridge, report_frozen_detected, );
+   if (type == PCI_EXP_TYPE_RC_END) {
+   pci_warn(dev, "subordinate device reset not possible 
for RCiEP\n");
+   status = PCI_ERS_RESULT_NONE;
+   goto failed;
+   }
+
status = reset_subordinates(bridge);
if (status != PCI_ERS_RESULT_RECOVERED) {
pci_warn(bridge, "subordinate device reset failed\n");
@@ -217,9 +232,13 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_dbg(bridge, "broadcast resume message\n");
pci_walk_bridge(bridge, report_resume, );
 
-   if (pcie_aer_is_native(bridge))
-   pcie_clear_device_status(bridge);
-   pci_aer_clear_nonfatal_status(bridge);
+   if (type == PCI_EXP_TYPE_ROOT_PORT ||
+   type == PCI_EXP_TYPE_DOWNSTREAM ||
+   type == PCI_EXP_TYPE_RC_EC) {
+   if (pcie_aer_is_native(bridge))
+   pcie_clear_device_status(bridge);
+   pci_aer_clear_nonfatal_status(bridge);
+   }
pci_info(bridge, "device recovery successful\n");
return status;
 
-- 
2.28.0



[PATCH v9 13/15] PCI/AER: Add pcie_walk_rcec() to RCEC AER handling

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

Root Complex Event Collectors (RCEC) appear as peers to Root Ports and also
have the AER capability. In addition, actions need to be taken for
associated RCiEPs. In such cases the RCECs will need to be walked in order
to find and act upon their respective RCiEPs.

Extend the existing ability to link the RCECs with a walking function
pcie_walk_rcec(). Add RCEC support to the current AER service driver and
attach the AER service driver to the RCEC device.

[bhelgaas: kernel doc, whitespace cleanup]
Co-developed-by: Qiuxu Zhuo 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-13-seanvk@oregontracks.org
Signed-off-by: Qiuxu Zhuo 
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Reviewed-by: Jonathan Cameron 
---
 drivers/pci/pci.h   |  6 ++
 drivers/pci/pcie/aer.c  | 29 ++---
 drivers/pci/pcie/rcec.c | 37 +
 3 files changed, 65 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 9e43a265c006..4090f2f98bf6 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -474,10 +474,16 @@ static inline void pci_dpc_init(struct pci_dev *pdev) {}
 void pci_rcec_init(struct pci_dev *dev);
 void pci_rcec_exit(struct pci_dev *dev);
 void pcie_link_rcec(struct pci_dev *rcec);
+void pcie_walk_rcec(struct pci_dev *rcec,
+   int (*cb)(struct pci_dev *, void *),
+   void *userdata);
 #else
 static inline void pci_rcec_init(struct pci_dev *dev) {}
 static inline void pci_rcec_exit(struct pci_dev *dev) {}
 static inline void pcie_link_rcec(struct pci_dev *rcec) {}
+static inline void pcie_walk_rcec(struct pci_dev *rcec,
+ int (*cb)(struct pci_dev *, void *),
+ void *userdata) {}
 #endif
 
 #ifdef CONFIG_PCI_ATS
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 083f69b67bfd..8244a29ef334 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -300,7 +300,8 @@ int pci_aer_raw_clear_status(struct pci_dev *dev)
return -EIO;
 
port_type = pci_pcie_type(dev);
-   if (port_type == PCI_EXP_TYPE_ROOT_PORT) {
+   if (port_type == PCI_EXP_TYPE_ROOT_PORT ||
+   port_type == PCI_EXP_TYPE_RC_EC) {
pci_read_config_dword(dev, aer + PCI_ERR_ROOT_STATUS, );
pci_write_config_dword(dev, aer + PCI_ERR_ROOT_STATUS, status);
}
@@ -595,7 +596,8 @@ static umode_t aer_stats_attrs_are_visible(struct kobject 
*kobj,
if ((a == _attr_aer_rootport_total_err_cor.attr ||
 a == _attr_aer_rootport_total_err_fatal.attr ||
 a == _attr_aer_rootport_total_err_nonfatal.attr) &&
-   pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT)
+   ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
+(pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_EC)))
return 0;
 
return a->mode;
@@ -916,7 +918,10 @@ static bool find_source_device(struct pci_dev *parent,
if (result)
return true;
 
-   pci_walk_bus(parent->subordinate, find_device_iter, e_info);
+   if (pci_pcie_type(parent) == PCI_EXP_TYPE_RC_EC)
+   pcie_walk_rcec(parent, find_device_iter, e_info);
+   else
+   pci_walk_bus(parent->subordinate, find_device_iter, e_info);
 
if (!e_info->error_dev_num) {
pci_info(parent, "can't find device of ID%04x\n", e_info->id);
@@ -1053,6 +1058,7 @@ int aer_get_device_error_info(struct pci_dev *dev, struct 
aer_err_info *info)
if (!(info->status & ~info->mask))
return 0;
} else if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
+  pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC ||
   pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM ||
   info->severity == AER_NONFATAL) {
 
@@ -1205,6 +1211,7 @@ static int set_device_error_reporting(struct pci_dev 
*dev, void *data)
int type = pci_pcie_type(dev);
 
if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
+   (type == PCI_EXP_TYPE_RC_EC) ||
(type == PCI_EXP_TYPE_UPSTREAM) ||
(type == PCI_EXP_TYPE_DOWNSTREAM)) {
if (enable)
@@ -1229,9 +1236,12 @@ static void 
set_downstream_devices_error_reporting(struct pci_dev *dev,
 {
set_device_error_reporting(dev, );
 
-   if (!dev->subordinate)
-   return;
-   pci_walk_bus(dev->subordinate, set_device_error_reporting, );
+   if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC)
+   pcie_walk_rcec(dev, set_device_error_reporting, );
+   else if (dev->subordinate)
+   pci_walk_bus(dev->subordinate, set_device_error_reporting,
+);
+
 }
 
 /**
@@ -1329,6 +1339,11 @@ static int aer_probe(struct pcie_device *dev)
struct device *device = >device;
struct pci_dev *port = dev->port;
 
+  

[PATCH v9 11/15] PCI/RCEC: Add pcie_link_rcec() to associate RCiEPs

2020-10-15 Thread Sean V Kelley
From: Sean V Kelley 

A Root Complex Event Collector terminates error and PME messages from
associated RCiEPs.

Use the RCEC Endpoint Association Extended Capability to identify
associated RCiEPs. Link the associated RCiEPs as the RCECs are enumerated.

Co-developed-by: Qiuxu Zhuo 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-11-seanvk@oregontracks.org
Signed-off-by: Qiuxu Zhuo 
Signed-off-by: Sean V Kelley 
Signed-off-by: Bjorn Helgaas 
Reviewed-by: Jonathan Cameron 
---
 drivers/pci/pci.h  |  2 +
 drivers/pci/pcie/portdrv_pci.c |  3 ++
 drivers/pci/pcie/rcec.c| 94 ++
 include/linux/pci.h|  1 +
 4 files changed, 100 insertions(+)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index bc2340971a50..9e43a265c006 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -473,9 +473,11 @@ static inline void pci_dpc_init(struct pci_dev *pdev) {}
 #ifdef CONFIG_PCIEPORTBUS
 void pci_rcec_init(struct pci_dev *dev);
 void pci_rcec_exit(struct pci_dev *dev);
+void pcie_link_rcec(struct pci_dev *rcec);
 #else
 static inline void pci_rcec_init(struct pci_dev *dev) {}
 static inline void pci_rcec_exit(struct pci_dev *dev) {}
+static inline void pcie_link_rcec(struct pci_dev *rcec) {}
 #endif
 
 #ifdef CONFIG_PCI_ATS
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 4d880679b9b1..dbeb0155c2c3 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -110,6 +110,9 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
 (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_EC)))
return -ENODEV;
 
+   if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC)
+   pcie_link_rcec(dev);
+
status = pcie_port_device_register(dev);
if (status)
return status;
diff --git a/drivers/pci/pcie/rcec.c b/drivers/pci/pcie/rcec.c
index 038e9d706d5f..cdec277cbd62 100644
--- a/drivers/pci/pcie/rcec.c
+++ b/drivers/pci/pcie/rcec.c
@@ -15,6 +15,100 @@
 
 #include "../pci.h"
 
+struct walk_rcec_data {
+   struct pci_dev *rcec;
+   int (*user_callback)(struct pci_dev *dev, void *data);
+   void *user_data;
+};
+
+static bool rcec_assoc_rciep(struct pci_dev *rcec, struct pci_dev *rciep)
+{
+   unsigned long bitmap = rcec->rcec_ea->bitmap;
+   unsigned int devn;
+
+   /* An RCiEP found on a different bus in range */
+   if (rcec->bus->number != rciep->bus->number)
+   return true;
+
+   /* Same bus, so check bitmap */
+   for_each_set_bit(devn, , 32)
+   if (devn == rciep->devfn)
+   return true;
+
+   return false;
+}
+
+static int link_rcec_helper(struct pci_dev *dev, void *data)
+{
+   struct walk_rcec_data *rcec_data = data;
+   struct pci_dev *rcec = rcec_data->rcec;
+
+   if ((pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END) &&
+   rcec_assoc_rciep(rcec, dev)) {
+   dev->rcec = rcec;
+   pci_dbg(dev, "PME & error events signaled via %s\n",
+   pci_name(rcec));
+   }
+
+   return 0;
+}
+
+static void walk_rcec(int (*cb)(struct pci_dev *dev, void *data),
+ void *userdata)
+{
+   struct walk_rcec_data *rcec_data = userdata;
+   struct pci_dev *rcec = rcec_data->rcec;
+   u8 nextbusn, lastbusn;
+   struct pci_bus *bus;
+   unsigned int bnr;
+
+   if (!rcec->rcec_ea)
+   return;
+
+   /* Walk own bus for bitmap based association */
+   pci_walk_bus(rcec->bus, cb, rcec_data);
+
+   nextbusn = rcec->rcec_ea->nextbusn;
+   lastbusn = rcec->rcec_ea->lastbusn;
+
+   /* All RCiEP devices are on the same bus as the RCEC */
+   if (nextbusn == 0xff && lastbusn == 0x00)
+   return;
+
+   for (bnr = nextbusn; bnr <= lastbusn; bnr++) {
+   /* No association indicated (PCIe 5.0-1, 7.9.10.3) */
+   if (bnr == rcec->bus->number)
+   continue;
+
+   bus = pci_find_bus(pci_domain_nr(rcec->bus), bnr);
+   if (!bus)
+   continue;
+
+   /* Find RCiEP devices on the given bus ranges */
+   pci_walk_bus(bus, cb, rcec_data);
+   }
+}
+
+/**
+ * pcie_link_rcec - Link RCiEP devices associated with RCEC.
+ * @rcec: RCEC whose RCiEP devices should be linked.
+ *
+ * Link the given RCEC to each RCiEP device found.
+ */
+void pcie_link_rcec(struct pci_dev *rcec)
+{
+   struct walk_rcec_data rcec_data;
+
+   if (!rcec->rcec_ea)
+   return;
+
+   rcec_data.rcec = rcec;
+   rcec_data.user_callback = NULL;
+   rcec_data.user_data = NULL;
+
+   walk_rcec(link_rcec_helper, _data);
+}
+
 void pci_rcec_init(struct pci_dev *dev)
 {
struct rcec_ea *rcec_ea;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2290439e8bc0..e546b16b13c1 100644
--- a/include/linux/pci.h
+++ 

[PATCH v9 12/15] PCI/RCEC: Add RCiEP's linked RCEC to AER/ERR

2020-10-15 Thread Sean V Kelley
From: Qiuxu Zhuo 

When attempting error recovery for an RCiEP associated with an RCEC device,
there needs to be a way to update the Root Error Status, the Uncorrectable
Error Status and the Uncorrectable Error Severity of the parent RCEC.  In
some non-native cases in which there is no OS-visible device associated
with the RCiEP, there is nothing to act upon as the firmware is acting
before the OS.

Add handling for the linked RCEC in AER/ERR while taking into account
non-native cases.

Co-developed-by: Sean V Kelley 
Link: 
https://lore.kernel.org/r/20201002184735.1229220-12-seanvk@oregontracks.org
Signed-off-by: Sean V Kelley 
Signed-off-by: Qiuxu Zhuo 
Signed-off-by: Bjorn Helgaas 
Reviewed-by: Jonathan Cameron 
---
 drivers/pci/pcie/aer.c | 53 ++
 drivers/pci/pcie/err.c | 20 
 2 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 65dff5f3457a..083f69b67bfd 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1357,27 +1357,50 @@ static int aer_probe(struct pcie_device *dev)
  */
 static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
 {
-   int aer = dev->aer_cap;
+   int type = pci_pcie_type(dev);
+   struct pci_dev *root;
+   int aer = 0;
+   int rc = 0;
u32 reg32;
-   int rc;
 
+   if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END)
+   /*
+* The reset should only clear the Root Error Status
+* of the RCEC. Only perform this for the
+* native case, i.e., an RCEC is present.
+*/
+   root = dev->rcec;
+   else
+   root = dev;
 
-   /* Disable Root's interrupt in response to error messages */
-   pci_read_config_dword(dev, aer + PCI_ERR_ROOT_COMMAND, );
-   reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
-   pci_write_config_dword(dev, aer + PCI_ERR_ROOT_COMMAND, reg32);
+   if (root)
+   aer = dev->aer_cap;
 
-   rc = pci_bus_error_reset(dev);
-   pci_info(dev, "Root Port link has been reset\n");
+   if (aer) {
+   /* Disable Root's interrupt in response to error messages */
+   pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, );
+   reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
+   pci_write_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, reg32);
 
-   /* Clear Root Error Status */
-   pci_read_config_dword(dev, aer + PCI_ERR_ROOT_STATUS, );
-   pci_write_config_dword(dev, aer + PCI_ERR_ROOT_STATUS, reg32);
+   /* Clear Root Error Status */
+   pci_read_config_dword(root, aer + PCI_ERR_ROOT_STATUS, );
+   pci_write_config_dword(root, aer + PCI_ERR_ROOT_STATUS, reg32);
 
-   /* Enable Root Port's interrupt in response to error messages */
-   pci_read_config_dword(dev, aer + PCI_ERR_ROOT_COMMAND, );
-   reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
-   pci_write_config_dword(dev, aer + PCI_ERR_ROOT_COMMAND, reg32);
+   /* Enable Root Port's interrupt in response to error messages */
+   pci_read_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, );
+   reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
+   pci_write_config_dword(root, aer + PCI_ERR_ROOT_COMMAND, reg32);
+   }
+
+   if ((type == PCI_EXP_TYPE_RC_EC) || (type == PCI_EXP_TYPE_RC_END)) {
+   if (pcie_has_flr(root)) {
+   rc = pcie_flr(root);
+   pci_info(dev, "has been reset (%d)\n", rc);
+   }
+   } else {
+   rc = pci_bus_error_reset(root);
+   pci_info(dev, "Root Port link has been reset (%d)\n", rc);
+   }
 
return rc ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
 }
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 7883c9791562..cbc5abfe767b 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -148,10 +148,10 @@ static int report_resume(struct pci_dev *dev, void *data)
 
 /**
  * pci_walk_bridge - walk bridges potentially AER affected
- * @bridge:bridge which may be a Port, an RCEC with associated RCiEPs,
- * or an RCiEP associated with an RCEC
- * @cb:callback to be called for each device found
- * @userdata:  arbitrary pointer to be passed to callback
+ * @bridge   bridge which may be an RCEC with associated RCiEPs,
+ *   or a Port.
+ * @cb   callback to be called for each device found
+ * @userdata arbitrary pointer to be passed to callback.
  *
  * If the device provided is a bridge, walk the subordinate bus, including
  * any bridged devices on buses under this bus.  Call the provided callback
@@ -164,8 +164,14 @@ static void pci_walk_bridge(struct pci_dev *bridge,
int (*cb)(struct pci_dev *, void *),
void *userdata)
 {
+   /*
+

  1   2   3   4   5   6   7   8   9   10   >