Re: [PATCH 2/2] dev_ioctl: split out SIOC?IFMAP ioctls

2020-09-18 Thread Christoph Hellwig
> diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
> index 797ba2c1562a..a332d6ae4dc6 100644
> --- a/include/uapi/linux/if.h
> +++ b/include/uapi/linux/if.h
> @@ -247,7 +247,13 @@ struct ifreq {
>   short   ifru_flags;
>   int ifru_ivalue;
>   int ifru_mtu;
> +#ifndef __KERNEL__
> + /*
> +  * ifru_map is rarely used but causes the incompatibility
> +  * between native and compat mode.
> +  */
>   struct  ifmap ifru_map;
> +#endif

Do we need a way to verify that this never changes the struct size?

> +int dev_ifmap(struct net *net, struct ifreq __user *ifr, unsigned int cmd)
> +{
> + struct net_device *dev;
> + char ifname[IFNAMSIZ];
> + char *colon;
> + struct compat_ifmap cifmap;
> + struct ifmap ifmap;
> + int ret;
> +
> + if (copy_from_user(ifname, ifr->ifr_name, sizeof(ifname)))
> + return -EFAULT;
> + ifname[IFNAMSIZ-1] = 0;
> + colon = strchr(ifname, ':');
> + if (colon)
> + *colon = 0;
> + dev_load(net, ifname);
> +
> + switch (cmd) {
> + case SIOCGIFMAP:
> + rcu_read_lock();
> + dev = dev_get_by_name_rcu(net, ifname);
> + if (!dev) {
> + rcu_read_unlock();
> + return -ENODEV;
> + }
> +
> + if (in_compat_syscall()) {
> + cifmap.mem_start = dev->mem_start;
> + cifmap.mem_end   = dev->mem_end;
> + cifmap.base_addr = dev->base_addr;
> + cifmap.irq   = dev->irq;
> + cifmap.dma   = dev->dma;
> + cifmap.port  = dev->if_port;
> + rcu_read_unlock();
> +
> + ret = copy_to_user(>ifr_data,
> +, sizeof(cifmap));
> + } else {
> + ifmap.mem_start  = dev->mem_start;
> + ifmap.mem_end= dev->mem_end;
> + ifmap.base_addr  = dev->base_addr;
> + ifmap.irq= dev->irq;
> + ifmap.dma= dev->dma;
> + ifmap.port   = dev->if_port;
> + rcu_read_unlock();
> +
> + ret = copy_to_user(>ifr_data,
> +, sizeof(ifmap));
> + }
> + ret = ret ? -EFAULT : 0;
> + break;
> +
> + case SIOCSIFMAP:
> + if (!capable(CAP_NET_ADMIN) ||
> + !ns_capable(net->user_ns, CAP_NET_ADMIN))
> + return -EPERM;
> +
> + if (in_compat_syscall()) {
> + if (copy_from_user(, >ifr_data,
> +sizeof(cifmap)))
> + return -EFAULT;
> +
> + ifmap.mem_start  = cifmap.mem_start;
> + ifmap.mem_end= cifmap.mem_end;
> + ifmap.base_addr  = cifmap.base_addr;
> + ifmap.irq= cifmap.irq;
> + ifmap.dma= cifmap.dma;
> + ifmap.port   = cifmap.port;
> + } else {
> + if (copy_from_user(, >ifr_data,
> +sizeof(ifmap)))
> + return -EFAULT;
> + }
> +
> + rtnl_lock();
> + dev = __dev_get_by_name(net, ifname);
> + if (!dev || !netif_device_present(dev))
> + ret = -ENODEV;
> + else if (!dev->netdev_ops->ndo_set_config)
> + ret = -EOPNOTSUPP;
> + else
> + ret = dev->netdev_ops->ndo_set_config(dev, );
> + rtnl_unlock();
> + break;
> + }
> + return ret;

I'd rather split this into a separate hepers for each ioctl command
instead of having anothr multiplexer here, maybe with another helper
for the common code.

I also find the rcu unlock inside the branches rather strange, but
I can't think of a good alternative.


[PATCH v5 1/3] leds: pwm: Remove platform_data support

2020-09-18 Thread Alexander Dahl
Since commit 141f15c66d94 ("leds: pwm: remove header") that platform
interface is not usable from outside and there seems to be no in tree
user anymore.  All in-tree users of the leds-pwm driver seem to use DT
currently.  Getting rid of the old platform interface will allow the
leds-pwm driver to switch over from 'devm_led_classdev_register()' to
'devm_led_classdev_register_ext()' later.

Signed-off-by: Alexander Dahl 
Cc: Denis Osterland-Heim 
Cc: Marek Behún 
---

Notes:
v5:
 * added this patch to series (replacing another patch with a not
   working, different approach)

 drivers/leds/leds-pwm.c | 30 +-
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index e35a97c1d828..4e9954f8f7eb 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -25,11 +25,6 @@ struct led_pwm {
unsigned intmax_brightness;
 };
 
-struct led_pwm_platform_data {
-   int num_leds;
-   struct led_pwm  *leds;
-};
-
 struct led_pwm_data {
struct led_classdev cdev;
struct pwm_device   *pwm;
@@ -61,6 +56,7 @@ static int led_pwm_set(struct led_classdev *led_cdev,
return pwm_apply_state(led_dat->pwm, _dat->pwmstate);
 }
 
+__attribute__((nonnull))
 static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
   struct led_pwm *led, struct fwnode_handle *fwnode)
 {
@@ -74,10 +70,7 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
led_data->cdev.max_brightness = led->max_brightness;
led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
 
-   if (fwnode)
-   led_data->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL);
-   else
-   led_data->pwm = devm_pwm_get(dev, led->name);
+   led_data->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL);
if (IS_ERR(led_data->pwm))
return dev_err_probe(dev, PTR_ERR(led_data->pwm),
 "unable to request PWM for %s\n",
@@ -143,15 +136,11 @@ static int led_pwm_create_fwnode(struct device *dev, 
struct led_pwm_priv *priv)
 
 static int led_pwm_probe(struct platform_device *pdev)
 {
-   struct led_pwm_platform_data *pdata = dev_get_platdata(>dev);
struct led_pwm_priv *priv;
-   int count, i;
int ret = 0;
+   int count;
 
-   if (pdata)
-   count = pdata->num_leds;
-   else
-   count = device_get_child_node_count(>dev);
+   count = device_get_child_node_count(>dev);
 
if (!count)
return -EINVAL;
@@ -161,16 +150,7 @@ static int led_pwm_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
 
-   if (pdata) {
-   for (i = 0; i < count; i++) {
-   ret = led_pwm_add(>dev, priv, >leds[i],
- NULL);
-   if (ret)
-   break;
-   }
-   } else {
-   ret = led_pwm_create_fwnode(>dev, priv);
-   }
+   ret = led_pwm_create_fwnode(>dev, priv);
 
if (ret)
return ret;
-- 
2.20.1



[PATCH v5 0/3] leds: pwm: Make automatic labels work

2020-09-18 Thread Alexander Dahl
Hei hei,

for leds-gpio you can use the properties 'function' and 'color' in the
devicetree node and omit 'label', the label is constructed
automatically.  This is a common feature supposed to be working for all
LED drivers.  However it did not yet work for the 'leds-pwm' driver.

This series removes platform_data support for the leds-pwm driver and
takes the opportunity to update the leds-pwm dt-bindings accordingly.

v5 was tested on a at91 sama5d2 based platform with LEDs connected to
GPIO and PWM.

Greets
Alex

v5:
- replaced patch 1/3 by a new patch removing platform_data support for
  the leds-pwm driver
- little rewording of commit message in patch 2/3
- updated patch 3/3 based on feedback by Rob Herring
- added Marek Behún to Cc, because he also works on removing
  platform_data support
- rebased series on pavel/for-next

v4:
- added led-class patch handling fwnode passing differently (patch 1/3)
- adapted leds-pwm patch to new led-class (patch 2/3)
- contacted original author of leds-pwm dt binding on license issue
  (patch 3/3)

v3:
- series rebased on v5.9-rc4
- changed license of .yaml file to recommended one (patch 2/2)
- added Acked-by to both patches

v2:
- series rebased on v5.9-rc3
- added the dt-bindings update patch (2/2)

v1:
- based on v5.9-rc2
- backport on v5.4.59 tested and working

Alexander Dahl (3):
  leds: pwm: Remove platform_data support
  leds: pwm: Allow automatic labels for DT based devices
  dt-bindings: leds: Convert pwm to yaml

 .../devicetree/bindings/leds/leds-pwm.txt | 50 ---
 .../devicetree/bindings/leds/leds-pwm.yaml| 82 +++
 drivers/leds/leds-pwm.c   | 33 ++--
 3 files changed, 89 insertions(+), 76 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pwm.txt
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pwm.yaml


base-commit: 03eb2ca44a95105d1482d5e7471016cf8b383f97
-- 
2.20.1



Re: [PATCH 1/2] ethtool: improve compat ioctl handling

2020-09-18 Thread Christoph Hellwig
> + if (ethtool_translate_compat()) {
> + struct compat_ethtool_rxnfc crxnfc = {};
> +
> + if (copy_from_user(, useraddr,
> +min(size, sizeof(crxnfc
> + return -EFAULT;
> +
> + *rxnfc = (struct ethtool_rxnfc) {
> + .cmd= crxnfc.cmd,
> + .flow_type  = crxnfc.flow_type,
> + .data   = crxnfc.data,
> + .fs = {
> + .flow_type  = crxnfc.fs.flow_type,
> + .h_u= crxnfc.fs.h_u,
> + .h_ext  = crxnfc.fs.h_ext,
> + .m_u= crxnfc.fs.m_u,
> + .m_ext  = crxnfc.fs.m_ext,
> + .ring_cookie= crxnfc.fs.ring_cookie,
> + .location   = crxnfc.fs.location,
> + },
> + .rule_cnt   = crxnfc.rule_cnt,
> + };

I'd split the compat version into a self-contained noinline helper.
Same for ethtool_rxnfc_copy_to_user.

Otherwise this looks good:

Reviewed-by: Christoph Hellwig 


Re: [PATCH 4/4] mm: remove compat numa syscalls

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 03:24:39PM +0200, Arnd Bergmann wrote:
> The compat implementations for mbind, get_mempolicy, set_mempolicy
> and migrate_pages are just there to handle the subtly different
> layout of bitmaps on 32-bit hosts.
> 
> The compat implementation however lacks some of the checks that
> are present in the native one, in particular for checking that
> the extra bits are all zero when user space has a larger mask
> size than the kernel. Worse, those extra bits do not get cleared
> when copying in or out of the kernel, which can lead to incorrect
> data as well.
> 
> Unify the implementation to handle the compat bitmap layout directly
> in the get_nodes() and copy_nodes_to_user() helpers.  Splitting out
> the get_bitmap() helper from get_nodes() also helps readability of the
> native case.
> 
> On x86, two additional problems are addressed by this: compat tasks can
> pass a bitmap at the end of a mapping, causing a fault when reading
> across the page boundary for a 64-bit word. x32 tasks might also run
> into problems with get_mempolicy corrupting data when an odd number of
> 32-bit words gets passed.
> 
> On parisc the migrate_pages() system call apparently had the wrong
> calling convention, as big-endian architectures expect the words
> inside of a bitmap to be swapped. This is not a problem though
> since parisc has no NUMA support.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm64/include/asm/unistd32.h |   8 +-
>  arch/mips/kernel/syscalls/syscall_n32.tbl |   8 +-
>  arch/mips/kernel/syscalls/syscall_o32.tbl |   8 +-
>  arch/parisc/kernel/syscalls/syscall.tbl   |   6 +-
>  arch/powerpc/kernel/syscalls/syscall.tbl  |   8 +-
>  arch/s390/kernel/syscalls/syscall.tbl |   8 +-
>  arch/sparc/kernel/syscalls/syscall.tbl|   8 +-
>  arch/x86/entry/syscalls/syscall_32.tbl|   2 +-
>  include/linux/compat.h|  15 --
>  include/uapi/asm-generic/unistd.h |   8 +-
>  kernel/kexec.c|   6 +-
>  kernel/sys_ni.c   |   4 -
>  mm/mempolicy.c| 193 +-
>  13 files changed, 79 insertions(+), 203 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/unistd32.h 
> b/arch/arm64/include/asm/unistd32.h
> index af793775ba98..31479f7120a0 100644
> --- a/arch/arm64/include/asm/unistd32.h
> +++ b/arch/arm64/include/asm/unistd32.h
> @@ -649,11 +649,11 @@ __SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch)
>  #define __NR_inotify_rm_watch 318
>  __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch)
>  #define __NR_mbind 319
> -__SYSCALL(__NR_mbind, compat_sys_mbind)
> +__SYSCALL(__NR_mbind, sys_mbind)
>  #define __NR_get_mempolicy 320
> -__SYSCALL(__NR_get_mempolicy, compat_sys_get_mempolicy)
> +__SYSCALL(__NR_get_mempolicy, sys_get_mempolicy)
>  #define __NR_set_mempolicy 321
> -__SYSCALL(__NR_set_mempolicy, compat_sys_set_mempolicy)
> +__SYSCALL(__NR_set_mempolicy, sys_set_mempolicy)
>  #define __NR_openat 322
>  __SYSCALL(__NR_openat, compat_sys_openat)
>  #define __NR_mkdirat 323
> @@ -811,7 +811,7 @@ __SYSCALL(__NR_rseq, sys_rseq)
>  #define __NR_io_pgetevents 399
>  __SYSCALL(__NR_io_pgetevents, compat_sys_io_pgetevents)
>  #define __NR_migrate_pages 400
> -__SYSCALL(__NR_migrate_pages, compat_sys_migrate_pages)
> +__SYSCALL(__NR_migrate_pages, sys_migrate_pages)
>  #define __NR_kexec_file_load 401
>  __SYSCALL(__NR_kexec_file_load, sys_kexec_file_load)
>  /* 402 is unused */
> diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl 
> b/arch/mips/kernel/syscalls/syscall_n32.tbl
> index 7fa1ca45e44c..15fda882d07e 100644
> --- a/arch/mips/kernel/syscalls/syscall_n32.tbl
> +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl
> @@ -239,9 +239,9 @@
>  228  n32 clock_nanosleep sys_clock_nanosleep_time32
>  229  n32 tgkill  sys_tgkill
>  230  n32 utimes  sys_utimes_time32
> -231  n32 mbind   compat_sys_mbind
> -232  n32 get_mempolicy   compat_sys_get_mempolicy
> -233  n32 set_mempolicy   compat_sys_set_mempolicy
> +231  n32 mbind   sys_mbind
> +232  n32 get_mempolicy   sys_get_mempolicy
> +233  n32 set_mempolicy   sys_set_mempolicy
>  234  n32 mq_open compat_sys_mq_open
>  235  n32 mq_unlink   sys_mq_unlink
>  236  n32 mq_timedsendsys_mq_timedsend_time32
> @@ -258,7 +258,7 @@
>  247  n32 inotify_initsys_inotify_init
>  248  n32 inotify_add_watch   sys_inotify_add_watch
>  249  n32 inotify_rm_watchsys_inotify_rm_watch
> -250  n32 migrate_pages   compat_sys_migrate_pages
> +250  n32 migrate_pages   sys_migrate_pages
>  251  n32 openat  sys_openat
>  252  n32 

Re: [PATCH -next] tty: serial: imx: fix link error with CONFIG_SERIAL_CORE_CONSOLE=n

2020-09-18 Thread Greg KH
On Sat, Sep 19, 2020 at 10:26:38AM +0800, Yang Yingliang wrote:
> Hi,
> 
> On 2020/9/18 19:16, Greg KH wrote:
> > On Fri, Sep 18, 2020 at 05:13:05PM +0800, Yang Yingliang wrote:
> > > Fix the link error by selecting SERIAL_CORE_CONSOLE.
> > > 
> > > aarch64-linux-gnu-ld: drivers/tty/serial/imx_earlycon.o: in function 
> > > `imx_uart_console_early_write':
> > > imx_earlycon.c:(.text+0x84): undefined reference to `uart_console_write'
> > > 
> > > Reported-by: Hulk Robot 
> > > Signed-off-by: Yang Yingliang 
> > > ---
> > >   drivers/tty/serial/Kconfig | 1 +
> > >   1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> > > index 9631ccf43378..1044fc387691 100644
> > > --- a/drivers/tty/serial/Kconfig
> > > +++ b/drivers/tty/serial/Kconfig
> > > @@ -521,6 +521,7 @@ config SERIAL_IMX_EARLYCON
> > >   depends on ARCH_MXC || COMPILE_TEST
> > >   depends on OF
> > >   select SERIAL_EARLYCON
> > > + select SERIAL_CORE_CONSOLE
> > >   help
> > > If you have enabled the earlycon on the Freescale IMX
> > > CPU you can make it the earlycon by answering Y to this 
> > > option.
> > > -- 
> > > 2.25.1
> > > 
> > What caused this build error to start happening?  Any pointers to the
> > specific commit?
> 
> It's start from 699cc4dfd140 ("tty: serial: imx: add imx earlycon driver"),
> the driver
> 
> uses the uart_console_write(), but SERIAL_CORE_CONSOLE is not selected, so
> uart_console_write
> 
> is not defined, then we get the error.

Great, can you add a Fixes: line to the patch and resend it with this
information added to the changelog text?

Always include this type of information if at all possible.

thanks,

greg k-h


Re: [PATCH -next] tty: hvc: fix link error with CONFIG_SERIAL_CORE_CONSOLE=n

2020-09-18 Thread Greg KH
On Sat, Sep 19, 2020 at 10:48:41AM +0800, Yang Yingliang wrote:
> 
> On 2020/9/18 19:17, Greg KH wrote:
> > On Fri, Sep 18, 2020 at 05:20:30PM +0800, Yang Yingliang wrote:
> > > Fix the link error by selecting SERIAL_CORE_CONSOLE.
> > > 
> > > aarch64-linux-gnu-ld: drivers/tty/hvc/hvc_dcc.o: in function 
> > > `dcc_early_write':
> > > hvc_dcc.c:(.text+0x164): undefined reference to `uart_console_write'
> > > 
> > > Reported-by: Hulk Robot 
> > > Signed-off-by: Yang Yingliang 
> > > ---
> > >   drivers/tty/hvc/Kconfig | 1 +
> > >   1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig
> > > index d1b27b0522a3..8d60e0ff67b4 100644
> > > --- a/drivers/tty/hvc/Kconfig
> > > +++ b/drivers/tty/hvc/Kconfig
> > > @@ -81,6 +81,7 @@ config HVC_DCC
> > >   bool "ARM JTAG DCC console"
> > >   depends on ARM || ARM64
> > >   select HVC_DRIVER
> > > + select SERIAL_CORE_CONSOLE
> > >   help
> > > This console uses the JTAG DCC on ARM to create a console 
> > > under the HVC
> > > driver. This console is used through a JTAG only on ARM. If 
> > > you don't have
> > > -- 
> > > 2.25.1
> > > 
> > Same question here, what caused this problem to happen?
> Fixes: d1a1af2cdf19 ("hvc: dcc: Add earlycon support")

Great, can you resend with that added please?

thanks,

greg k-h


[PATCH v5 2/3] leds: pwm: Allow automatic labels for DT based devices

2020-09-18 Thread Alexander Dahl
If LEDs are configured through device tree and the property 'label' is
omitted, the label is supposed to be generated from the properties
'function' and 'color' if present.  While this works fine for e.g. the
'leds-gpio' driver, it did not for 'leds-pwm'.

The reason is, you get this label naming magic only if you add a LED
device through 'devm_led_classdev_register_ext()' and pass a pointer to
the current device tree node.

For the following node from dts the LED appeared as 'led-5' in sysfs
before and as 'red:debug' after this change.

pwm_leds {
compatible = "pwm-leds";

led-5 {
function = LED_FUNCTION_DEBUG;
color = ;
pwms = < 2 1000 0>;
max-brightness = <127>;

linux,default-trigger = "heartbeat";
panic-indicator;
};
};

Signed-off-by: Alexander Dahl 
Cc: Marek Behún 
---

Notes:
v4 -> v5:
  * updated commit message

v3 -> v4:
  * simplified implementation based on a new change in led-core
  * removed Acked-by due to changed implementation

v2 -> v3:
  * added Acked-by

v1 -> v2:
  * no change to this patch

 drivers/leds/leds-pwm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 4e9954f8f7eb..8881d465701d 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -61,6 +61,7 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
   struct led_pwm *led, struct fwnode_handle *fwnode)
 {
struct led_pwm_data *led_data = >leds[priv->num_leds];
+   struct led_init_data init_data = { .fwnode = fwnode };
int ret;
 
led_data->active_low = led->active_low;
@@ -80,7 +81,7 @@ static int led_pwm_add(struct device *dev, struct 
led_pwm_priv *priv,
 
pwm_init_state(led_data->pwm, _data->pwmstate);
 
-   ret = devm_led_classdev_register(dev, _data->cdev);
+   ret = devm_led_classdev_register_ext(dev, _data->cdev, _data);
if (ret) {
dev_err(dev, "failed to register PWM led for %s: %d\n",
led->name, ret);
-- 
2.20.1



Re: [PATCH 3/4] mm: remove compat_sys_move_pages

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 03:24:38PM +0200, Arnd Bergmann wrote:
> The compat move_pages() implementation uses compat_alloc_user_space()
> for converting the pointer array. Moving the compat handling into
> the function itself is a bit simpler and lets us avoid the
> compat_alloc_user_space() call.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm64/include/asm/unistd32.h |  2 +-
>  arch/mips/kernel/syscalls/syscall_n32.tbl |  2 +-
>  arch/mips/kernel/syscalls/syscall_o32.tbl |  2 +-
>  arch/parisc/kernel/syscalls/syscall.tbl   |  2 +-
>  arch/powerpc/kernel/syscalls/syscall.tbl  |  2 +-
>  arch/s390/kernel/syscalls/syscall.tbl |  2 +-
>  arch/sparc/kernel/syscalls/syscall.tbl|  2 +-
>  arch/x86/entry/syscalls/syscall_32.tbl|  2 +-
>  arch/x86/entry/syscalls/syscall_64.tbl|  2 +-
>  include/linux/compat.h|  5 ---
>  include/uapi/asm-generic/unistd.h |  2 +-
>  kernel/sys_ni.c   |  1 -
>  mm/migrate.c  | 45 +++
>  13 files changed, 32 insertions(+), 39 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/unistd32.h 
> b/arch/arm64/include/asm/unistd32.h
> index b6517df74037..af793775ba98 100644
> --- a/arch/arm64/include/asm/unistd32.h
> +++ b/arch/arm64/include/asm/unistd32.h
> @@ -699,7 +699,7 @@ __SYSCALL(__NR_tee, sys_tee)
>  #define __NR_vmsplice 343
>  __SYSCALL(__NR_vmsplice, compat_sys_vmsplice)
>  #define __NR_move_pages 344
> -__SYSCALL(__NR_move_pages, compat_sys_move_pages)
> +__SYSCALL(__NR_move_pages, sys_move_pages)
>  #define __NR_getcpu 345
>  __SYSCALL(__NR_getcpu, sys_getcpu)
>  #define __NR_epoll_pwait 346
> diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl 
> b/arch/mips/kernel/syscalls/syscall_n32.tbl
> index ad157aab4c09..7fa1ca45e44c 100644
> --- a/arch/mips/kernel/syscalls/syscall_n32.tbl
> +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl
> @@ -279,7 +279,7 @@
>  268  n32 sync_file_range sys_sync_file_range
>  269  n32 tee sys_tee
>  270  n32 vmsplicecompat_sys_vmsplice
> -271  n32 move_pages  compat_sys_move_pages
> +271  n32 move_pages  sys_move_pages
>  272  n32 set_robust_list compat_sys_set_robust_list
>  273  n32 get_robust_list compat_sys_get_robust_list
>  274  n32 kexec_load  sys_kexec_load
> diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl 
> b/arch/mips/kernel/syscalls/syscall_o32.tbl
> index 57baf6c8008f..194c7fbeedf7 100644
> --- a/arch/mips/kernel/syscalls/syscall_o32.tbl
> +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl
> @@ -319,7 +319,7 @@
>  305  o32 sync_file_range sys_sync_file_range 
> sys32_sync_file_range
>  306  o32 tee sys_tee
>  307  o32 vmsplicesys_vmsplice
> compat_sys_vmsplice
> -308  o32 move_pages  sys_move_pages  
> compat_sys_move_pages
> +308  o32 move_pages  sys_move_pages
>  309  o32 set_robust_list sys_set_robust_list 
> compat_sys_set_robust_list
>  310  o32 get_robust_list sys_get_robust_list 
> compat_sys_get_robust_list
>  311  o32 kexec_load  sys_kexec_load
> diff --git a/arch/parisc/kernel/syscalls/syscall.tbl 
> b/arch/parisc/kernel/syscalls/syscall.tbl
> index 778bf166d7bd..5c17edaffe70 100644
> --- a/arch/parisc/kernel/syscalls/syscall.tbl
> +++ b/arch/parisc/kernel/syscalls/syscall.tbl
> @@ -331,7 +331,7 @@
>  292  64  sync_file_range sys_sync_file_range
>  293  common  tee sys_tee
>  294  common  vmsplicesys_vmsplice
> compat_sys_vmsplice
> -295  common  move_pages  sys_move_pages  
> compat_sys_move_pages
> +295  common  move_pages  sys_move_pages
>  296  common  getcpu  sys_getcpu
>  297  common  epoll_pwait sys_epoll_pwait 
> compat_sys_epoll_pwait
>  298  common  statfs64sys_statfs64
> compat_sys_statfs64
> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl 
> b/arch/powerpc/kernel/syscalls/syscall.tbl
> index f128ba8b9a71..04fb42d7b377 100644
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -389,7 +389,7 @@
>  298  common  faccessat   sys_faccessat
>  299  common  get_robust_list sys_get_robust_list 
> compat_sys_get_robust_list
>  300  common  set_robust_list sys_set_robust_list 
> compat_sys_set_robust_list
> -301  common  move_pages  sys_move_pages  
> compat_sys_move_pages
> +301  common  

[PATCH v5 3/3] dt-bindings: leds: Convert pwm to yaml

2020-09-18 Thread Alexander Dahl
The example was adapted slightly to make use of the 'function' and
'color' properties.  License discussed with the original author.

Suggested-by: Jacek Anaszewski 
Signed-off-by: Alexander Dahl 
Cc: Peter Ujfalusi 
---

Notes:
v4 -> v5:
  * updated based on feedback by Rob Herring
  * removed Acked-by

v3 -> v4:
  * added Cc to original author of the binding

v2 -> v3:
  * changed license identifier to recommended one
  * added Acked-by

v2:
  * added this patch to series (Suggested-by: Jacek Anaszewski)

 .../devicetree/bindings/leds/leds-pwm.txt | 50 ---
 .../devicetree/bindings/leds/leds-pwm.yaml| 82 +++
 2 files changed, 82 insertions(+), 50 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-pwm.txt
 create mode 100644 Documentation/devicetree/bindings/leds/leds-pwm.yaml

diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.txt 
b/Documentation/devicetree/bindings/leds/leds-pwm.txt
deleted file mode 100644
index 6c6583c35f2f..
--- a/Documentation/devicetree/bindings/leds/leds-pwm.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-LED connected to PWM
-
-Required properties:
-- compatible : should be "pwm-leds".
-
-Each LED is represented as a sub-node of the pwm-leds device.  Each
-node's name represents the name of the corresponding LED.
-
-LED sub-node properties:
-- pwms : PWM property to point to the PWM device (phandle)/port (id) and to
-  specify the period time to be used: < id period_ns>;
-- pwm-names : (optional) Name to be used by the PWM subsystem for the PWM 
device
-  For the pwms and pwm-names property please refer to:
-  Documentation/devicetree/bindings/pwm/pwm.txt
-- max-brightness : Maximum brightness possible for the LED
-- active-low : (optional) For PWMs where the LED is wired to supply
-  rather than ground.
-- label :  (optional)
-  see Documentation/devicetree/bindings/leds/common.txt
-- linux,default-trigger :  (optional)
-  see Documentation/devicetree/bindings/leds/common.txt
-
-Example:
-
-twl_pwm: pwm {
-   /* provides two PWMs (id 0, 1 for PWM1 and PWM2) */
-   compatible = "ti,twl6030-pwm";
-   #pwm-cells = <2>;
-};
-
-twl_pwmled: pwmled {
-   /* provides one PWM (id 0 for Charing indicator LED) */
-   compatible = "ti,twl6030-pwmled";
-   #pwm-cells = <2>;
-};
-
-pwmleds {
-   compatible = "pwm-leds";
-   kpad {
-   label = "omap4::keypad";
-   pwms = <_pwm 0 7812500>;
-   max-brightness = <127>;
-   };
-
-   charging {
-   label = "omap4:green:chrg";
-   pwms = <_pwmled 0 7812500>;
-   max-brightness = <255>;
-   };
-};
diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.yaml 
b/Documentation/devicetree/bindings/leds/leds-pwm.yaml
new file mode 100644
index ..c9316811c7f1
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-pwm.yaml
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/leds-pwm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LEDs connected to PWM
+
+maintainers:
+  - Pavel Machek 
+
+description:
+  Each LED is represented as a sub-node of the pwm-leds device.  Each
+  node's name represents the name of the corresponding LED.
+
+properties:
+  compatible:
+const: pwm-leds
+
+patternProperties:
+  "^led(-[0-9a-f]+)?$":
+type: object
+
+$ref: common.yaml#
+
+properties:
+  pwms:
+maxItems: 1
+
+  pwm-names: true
+
+  max-brightness:
+description:
+  Maximum brightness possible for the LED
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  active-low:
+description:
+  For PWMs where the LED is wired to supply rather than ground.
+type: boolean
+
+required:
+  - pwms
+  - max-brightness
+
+additionalProperties: false
+
+examples:
+  - |
+
+#include 
+
+twl_pwm: pwm {
+/* provides two PWMs (id 0, 1 for PWM1 and PWM2) */
+compatible = "ti,twl6030-pwm";
+#pwm-cells = <2>;
+};
+
+twl_pwmled: pwmled {
+/* provides one PWM (id 0 for Charing indicator LED) */
+compatible = "ti,twl6030-pwmled";
+#pwm-cells = <2>;
+};
+
+pwm_leds {
+compatible = "pwm-leds";
+
+led-1 {
+label = "omap4::keypad";
+pwms = <_pwm 0 7812500>;
+max-brightness = <127>;
+};
+
+led-2 {
+color = ;
+function = LED_FUNCTION_CHARGING;
+pwms = <_pwmled 0 7812500>;
+max-brightness = <255>;
+};
+};
+
+...
-- 
2.20.1



Re: [PATCH 2/4] kexec: remove compat_sys_kexec_load syscall

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 03:24:37PM +0200, Arnd Bergmann wrote:
> The compat version of sys_kexec_load() uses compat_alloc_user_space to
> convert the user-provided arguments into the native format.
> 
> Move the conversion into the regular implementation with
> an in_compat_syscall() check to simplify it and avoid the
> compat_alloc_user_space() call.
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  arch/arm64/include/asm/unistd32.h |  2 +-
>  arch/mips/kernel/syscalls/syscall_n32.tbl |  2 +-
>  arch/mips/kernel/syscalls/syscall_o32.tbl |  2 +-
>  arch/parisc/kernel/syscalls/syscall.tbl   |  2 +-
>  arch/powerpc/kernel/syscalls/syscall.tbl  |  2 +-
>  arch/s390/kernel/syscalls/syscall.tbl |  2 +-
>  arch/sparc/kernel/syscalls/syscall.tbl|  2 +-
>  arch/x86/entry/syscalls/syscall_32.tbl|  2 +-
>  arch/x86/entry/syscalls/syscall_64.tbl|  2 +-
>  include/linux/compat.h|  6 --
>  include/uapi/asm-generic/unistd.h |  2 +-
>  kernel/kexec.c| 75 ++-
>  12 files changed, 29 insertions(+), 72 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/unistd32.h 
> b/arch/arm64/include/asm/unistd32.h
> index 734860ac7cf9..b6517df74037 100644
> --- a/arch/arm64/include/asm/unistd32.h
> +++ b/arch/arm64/include/asm/unistd32.h
> @@ -705,7 +705,7 @@ __SYSCALL(__NR_getcpu, sys_getcpu)
>  #define __NR_epoll_pwait 346
>  __SYSCALL(__NR_epoll_pwait, compat_sys_epoll_pwait)
>  #define __NR_kexec_load 347
> -__SYSCALL(__NR_kexec_load, compat_sys_kexec_load)
> +__SYSCALL(__NR_kexec_load, sys_kexec_load)
>  #define __NR_utimensat 348
>  __SYSCALL(__NR_utimensat, sys_utimensat_time32)
>  #define __NR_signalfd 349
> diff --git a/arch/mips/kernel/syscalls/syscall_n32.tbl 
> b/arch/mips/kernel/syscalls/syscall_n32.tbl
> index f9df9edb67a4..ad157aab4c09 100644
> --- a/arch/mips/kernel/syscalls/syscall_n32.tbl
> +++ b/arch/mips/kernel/syscalls/syscall_n32.tbl
> @@ -282,7 +282,7 @@
>  271  n32 move_pages  compat_sys_move_pages
>  272  n32 set_robust_list compat_sys_set_robust_list
>  273  n32 get_robust_list compat_sys_get_robust_list
> -274  n32 kexec_load  compat_sys_kexec_load
> +274  n32 kexec_load  sys_kexec_load
>  275  n32 getcpu  sys_getcpu
>  276  n32 epoll_pwait compat_sys_epoll_pwait
>  277  n32 ioprio_set  sys_ioprio_set
> diff --git a/arch/mips/kernel/syscalls/syscall_o32.tbl 
> b/arch/mips/kernel/syscalls/syscall_o32.tbl
> index 195b43cf27c8..57baf6c8008f 100644
> --- a/arch/mips/kernel/syscalls/syscall_o32.tbl
> +++ b/arch/mips/kernel/syscalls/syscall_o32.tbl
> @@ -322,7 +322,7 @@
>  308  o32 move_pages  sys_move_pages  
> compat_sys_move_pages
>  309  o32 set_robust_list sys_set_robust_list 
> compat_sys_set_robust_list
>  310  o32 get_robust_list sys_get_robust_list 
> compat_sys_get_robust_list
> -311  o32 kexec_load  sys_kexec_load  
> compat_sys_kexec_load
> +311  o32 kexec_load  sys_kexec_load
>  312  o32 getcpu  sys_getcpu
>  313  o32 epoll_pwait sys_epoll_pwait 
> compat_sys_epoll_pwait
>  314  o32 ioprio_set  sys_ioprio_set
> diff --git a/arch/parisc/kernel/syscalls/syscall.tbl 
> b/arch/parisc/kernel/syscalls/syscall.tbl
> index def64d221cd4..778bf166d7bd 100644
> --- a/arch/parisc/kernel/syscalls/syscall.tbl
> +++ b/arch/parisc/kernel/syscalls/syscall.tbl
> @@ -336,7 +336,7 @@
>  297  common  epoll_pwait sys_epoll_pwait 
> compat_sys_epoll_pwait
>  298  common  statfs64sys_statfs64
> compat_sys_statfs64
>  299  common  fstatfs64   sys_fstatfs64   
> compat_sys_fstatfs64
> -300  common  kexec_load  sys_kexec_load  
> compat_sys_kexec_load
> +300  common  kexec_load  sys_kexec_load
>  301  32  utimensat   sys_utimensat_time32
>  301  64  utimensat   sys_utimensat
>  302  common  signalfdsys_signalfd
> compat_sys_signalfd
> diff --git a/arch/powerpc/kernel/syscalls/syscall.tbl 
> b/arch/powerpc/kernel/syscalls/syscall.tbl
> index c2d737ff2e7b..f128ba8b9a71 100644
> --- a/arch/powerpc/kernel/syscalls/syscall.tbl
> +++ b/arch/powerpc/kernel/syscalls/syscall.tbl
> @@ -350,7 +350,7 @@
>  265  64  mq_timedreceive sys_mq_timedreceive
>  266  nospu   mq_notify   sys_mq_notify   
> compat_sys_mq_notify
>  267  nospu   mq_getsetattr   sys_mq_getsetattr   
> compat_sys_mq_getsetattr
> -268  nospu   kexec_load   

Re: [PATCH 1/4] x86: add __X32_COND_SYSCALL() macro

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 03:24:36PM +0200, Arnd Bergmann wrote:
> sys_move_pages() is an optional syscall, and once we remove
> the compat version of it in favor of the native one with an
> in_compat_syscall() check, the x32 syscall table refers to
> a __x32_sys_move_pages symbol that may not exist when the
> syscall is disabled.
> 
> Change the COND_SYSCALL() definition on x86 to also include
> the redirection for x32.
> 
> Signed-off-by: Arnd Bergmann 

Adding the x86 maintainers and Brian Gerst.  Brian proposed another
problem to the mess that most of the compat syscall handlers used by
x32 here:

   https://lkml.org/lkml/2020/6/16/664

hpa didn't particularly like it, but with your and my pending series
we'll soon use more native than compat syscalls for x32, so something
will need to change..

> ---
>  arch/x86/include/asm/syscall_wrapper.h | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/include/asm/syscall_wrapper.h 
> b/arch/x86/include/asm/syscall_wrapper.h
> index a84333adeef2..5eacd35a7f97 100644
> --- a/arch/x86/include/asm/syscall_wrapper.h
> +++ b/arch/x86/include/asm/syscall_wrapper.h
> @@ -171,12 +171,16 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs 
> *regs);
>   __SYS_STUBx(x32, compat_sys##name,  \
>   SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__))
>  
> +#define __X32_COND_SYSCALL(name) \
> + __COND_SYSCALL(x32, sys_##name)
> +
>  #define __X32_COMPAT_COND_SYSCALL(name)  
> \
>   __COND_SYSCALL(x32, compat_sys_##name)
>  
>  #define __X32_COMPAT_SYS_NI(name)\
>   __SYS_NI(x32, compat_sys_##name)
>  #else /* CONFIG_X86_X32 */
> +#define __X32_COND_SYSCALL(name)
>  #define __X32_COMPAT_SYS_STUB0(name)
>  #define __X32_COMPAT_SYS_STUBx(x, name, ...)
>  #define __X32_COMPAT_COND_SYSCALL(name)
> @@ -253,6 +257,7 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs 
> *regs);
>   static long __do_sys_##sname(const struct pt_regs *__unused)
>  
>  #define COND_SYSCALL(name)   \
> + __X32_COND_SYSCALL(name)\
>   __X64_COND_SYSCALL(name)\
>   __IA32_COND_SYSCALL(name)
>  
> -- 
> 2.27.0
> 
---end quoted text---


Re: [PATCH v2 5/9] ARM: oabi-compat: rework epoll_wait/epoll_pwait emulation

2020-09-18 Thread Christoph Hellwig
> index 855aa7cc9b8e..156880943c16 100644
> --- a/arch/arm/include/asm/syscall.h
> +++ b/arch/arm/include/asm/syscall.h
> @@ -28,6 +28,17 @@ static inline int syscall_get_nr(struct task_struct *task,
>   return task_thread_info(task)->syscall & ~__NR_OABI_SYSCALL_BASE;
>  }
>  
> +static inline bool __in_oabi_syscall(struct task_struct *task)
> +{
> + return IS_ENABLED(CONFIG_OABI_COMPAT) &&
> + (task_thread_info(task)->syscall & __NR_OABI_SYSCALL_BASE);
> +}
> +
> +static inline bool in_oabi_syscall(void)
> +{
> + return __in_oabi_syscall(current);
> +}
> +

Maybe split these infrastructure additions into a separate helper?

> +#if !defined(CONFIG_ARM) || !defined(CONFIG_OABI_COMPAT)
> +/* ARM OABI has an incompatible struct layout and needs a special handler */
> +static inline struct epoll_event __user *
> +epoll_put_uevent(__poll_t revents, __u64 data,
> +  struct epoll_event __user *uevent)
> +{
> + if (__put_user(revents, >events) ||
> + __put_user(data, >data))
> + return NULL;
> +
> + return uevent+1;
> +}
> +#else
> +struct epoll_event __user *
> +epoll_put_uevent(__poll_t revents, __u64 data,
> +  struct epoll_event __user *uevent);
> +#endif

So after you argued for this variant I still have minor nitpicks:

I alway find positive ifdefs better where possible, e.g.

#if defined(CONFIG_ARM) && defined(CONFIG_OABI_COMPAT)
external declaration here
#else
the real thing
#endif

but I still find the fact that the native case goes into the arch
helper a little weird.


Re: [PATCH v2] hwmon:Driver for Delta power supplies

2020-09-18 Thread Guenter Roeck
On 9/18/20 12:18 AM, xiao.mx.ma wrote:
> Add delta.rst in Documentation/hwmon
> Tristate "DELTA" in Kconfig is changed to "DELTA_POWER_SUPPLIES"
> Modify code: drop the excessive empty lines, correct the comment content,
> adjust indent, remove extra brackets.
> 
Description goes here.

> Signed-off-by: xiao.mx.ma <734056...@qq.com>
> ---

Change log goes here.

Other than that, this is a patch on top of the previous patch.
Please combine the two patches into one.

>  Documentation/hwmon/delta.rst |  52 ++

delta.rst needs to be added to Documentation/hwmon/index.rst.

>  drivers/hwmon/pmbus/Kconfig   |   2 +-
>  drivers/hwmon/pmbus/delta.c   | 172 --
>  3 files changed, 90 insertions(+), 136 deletions(-)
>  create mode 100644 Documentation/hwmon/delta.rst
> 
> diff --git a/Documentation/hwmon/delta.rst b/Documentation/hwmon/delta.rst
> new file mode 100644
> index ..790701d310e3
> --- /dev/null
> +++ b/Documentation/hwmon/delta.rst
> @@ -0,0 +1,52 @@
> +Kernel driver delta
> +=
> +
> +Supported chips:
> +
> +  * DELTA Q54SJ108A2NCAH, Q54SJ108A2NCDH, Q54SJ108A2NCPG, Q54SJ108A2NCPH
> +
> +Prefix: 'Q54SJ108A2'
> +
> +Addresses scanned: -
> +
> +Datasheet: 
> https://filecenter.delta-china.com.cn/products/download/01/0102/datasheet/DS_Q54SJ108A2.pdf
> +
> +Authors:
> +xiao.mx.ma <734056...@qq.com>
> +
> +
> +Description
> +---
> +
> +This driver implements support for DELTA Q54SJ108A2NCAH, Q54SJ108A2NCDH, 
> +Q54SJ108A2NCPG, and Q54SJ108A2NCPH 1/4 Brick DC/DC Regulated Power Module 
> +with PMBus support.
> +
> +The driver is a client driver to the core PMBus driver.
> +Please see Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
> +
> +
> +Usage Notes
> +---
> +
> +This driver does not auto-detect devices. You will have to instantiate the
> +devices explicitly. Please see Documentation/i2c/instantiating-devices.rst 
> for
> +details.
> +
> +
> +Sysfs entries
> +-
> +
> +=== = 
> ===
> +curr1_alarm ROOutput current alarm
> +curr1_input ROOutput current
> +curr1_label RO'iout1'
> +in1_alarm   ROInput voltage alarm
> +in1_input   ROInput voltage
> +in1_label   RO'vin'
> +in2_alarm   ROOutput voltage alarm
> +in2_input   ROOutput voltage
> +in2_label   RO'vout1'
> +temp1_alarm ROTemeperature alarm
> +temp1_input ROChip temperature
> +=== = 
> ===
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index a9468be10d7e..b03311340add 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -46,7 +46,7 @@ config SENSORS_BEL_PFE
> be called bel-pfe.
>  
>  config SENSORS_DELTA
> - tristate "DELTA"
> + tristate "DELTA_POWER_SUPPLIES"

This can be some text.

>   help
> If you say yes here you get hardware monitoring support for Delta 
> Power Supplies.
>  
> diff --git a/drivers/hwmon/pmbus/delta.c b/drivers/hwmon/pmbus/delta.c
> index 090429881c45..04f09767921c 100644
> --- a/drivers/hwmon/pmbus/delta.c
> +++ b/drivers/hwmon/pmbus/delta.c
> @@ -1,234 +1,136 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
> -
>  /*
> - * Driver for Q54SJ108A2, Q50SN12050, and Q50SN12072 Integrated, Step-Down
> - * Switching Regulators
> + * Driver for Delta modules, Q54SJ108A2 series 1/4 Brick DC/DC
> + * Regulated Power Module
>   *
>   * Copyright 2020 Delta LLC.
>   */
>  
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include 
> -
>  #include "pmbus.h"
>  
>  enum chips {
> -
>   Q54SJ108A2
>  };
>  
>  static const struct pmbus_driver_info delta_info[] = {
> -
> -[Q54SJ108A2] = {
> -
> -.pages = 1,
> -
> -/* Source : Delta Q54SJ108A2 */
> -
> -.format[PSC_TEMPERATURE] = linear,
> -
> -.format[PSC_VOLTAGE_IN] = linear,
> -
> -.format[PSC_CURRENT_OUT] = linear,
> -
> -
> -.func[0] = PMBUS_HAVE_VIN |
> -
> -PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> -
> -PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> -
> -PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
> -
> -PMBUS_HAVE_STATUS_INPUT,
> -
> -},
> -
> + [Q54SJ108A2] = {
> + .pages = 1,
> +
> + /* Source : Delta Q54SJ108A2 */
> + .format[PSC_TEMPERATURE] = linear,
> + .format[PSC_VOLTAGE_IN] = linear,
> + .format[PSC_CURRENT_OUT] = linear,
> +
> + .func[0] = PMBUS_HAVE_VIN |
> + PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
> + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
> + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
> + PMBUS_HAVE_STATUS_INPUT,
> + },
>  };
>  
>  
>  
>  

Re: [PATCH v2 2/9] ARM: traps: use get_kernel_nofault instead of set_fs()

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 02:46:17PM +0200, Arnd Bergmann wrote:
> ARM uses set_fs() and __get_user() to allow the stack dumping code to
> access possibly invalid pointers carefully. These can be changed to the
> simpler get_kernel_nofault(), and allow the eventual removal of set_fs().
> 
> dump_instr() will print either kernel or user space pointers,
> depending on how it was called. For dump_mem(), I assume we are only
> interested in kernel pointers, and the only time that this is called
> with user_mode(regs)==true is when the regs themselves are unreliable
> as a result of the condition that caused the trap.
> 
> Signed-off-by: Arnd Bergmann 

Looks good,

Reviewed-by: Christoph Hellwig 


Re: [PATCH v2 0/9] ARM: remove set_fs callers and implementation

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 02:46:15PM +0200, Arnd Bergmann wrote:
> Hi Christoph, Russell,
> 
> Here is an updated series for removing set_fs() from arch/arm,
> based on the previous feedback.
> 
> I have tested the oabi-compat changes using the LTP tests for the three
> modified syscalls using an Armv7 kernel and a Debian 5 OABI user space,
> and I have lightly tested the get_kernel_nofault infrastructure by
> loading the test_lockup.ko module after setting CONFIG_DEBUG_SPINLOCK.

What is the base line?  Just the base.set_fs branch in Als tree, or do
you need anything from my RISC-V series?


Re: [PATCH v2 3/3] scsi: megaraid_sas: simplify compat_ioctl handling

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 02:15:43PM +0200, Arnd Bergmann wrote:
> There have been several attempts to fix serious problems
> in the compat handling in megasas_mgmt_compat_ioctl_fw(),
> and it also uses the compat_alloc_user_space() function.
> 
> Folding the compat handling into the regular ioctl
> function with in_compat_syscall() simplifies it a lot and
> avoids some of the remaining problems:
> 
> - missing handling of unaligned pointers
> - overflowing the ioc->frame.raw array from
>   invalid input
> - compat_alloc_user_space()
> 
> Signed-off-by: Arnd Bergmann 
> ---
> v2: address review comments from hch
> ---
>  drivers/scsi/megaraid/megaraid_sas.h  |   2 -
>  drivers/scsi/megaraid/megaraid_sas_base.c | 117 +-
>  include/linux/compat.h|  10 +-
>  3 files changed, 50 insertions(+), 79 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
> b/drivers/scsi/megaraid/megaraid_sas.h
> index 5e4137f10e0e..0f808d63580e 100644
> --- a/drivers/scsi/megaraid/megaraid_sas.h
> +++ b/drivers/scsi/megaraid/megaraid_sas.h
> @@ -2605,7 +2605,6 @@ struct megasas_aen {
>   u32 class_locale_word;
>  } __attribute__ ((packed));
>  
> -#ifdef CONFIG_COMPAT
>  struct compat_megasas_iocpacket {
>   u16 host_no;
>   u16 __pad1;
> @@ -2621,7 +2620,6 @@ struct compat_megasas_iocpacket {
>  } __attribute__ ((packed));
>  
>  #define MEGASAS_IOC_FIRMWARE32   _IOWR('M', 1, struct 
> compat_megasas_iocpacket)
> -#endif
>  
>  #define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
>  #define MEGASAS_IOC_GET_AEN  _IOW('M', 3, struct megasas_aen)
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
> b/drivers/scsi/megaraid/megaraid_sas_base.c
> index c3de69f3bee8..d91951ee16ab 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -8279,16 +8279,18 @@ megasas_mgmt_fw_ioctl(struct megasas_instance 
> *instance,
>* copy out the sense
>*/
>   if (ioc->sense_len) {
> + void __user *uptr;
>   /*
>* sense_ptr points to the location that has the user
>* sense buffer address
>*/
> + sense_ptr = (void *)ioc->frame.raw + ioc->sense_off;
> + if (in_compat_syscall())
> + uptr = compat_ptr(get_unaligned((u32 *)sense_ptr));

should the u32 * here by a compat_uptr *? Not tat it would make a
difference, just better document what we are doing.

> + for (i = 0; i < MAX_IOCTL_SGE; i++) {
> + compat_uptr_t iov_base;
> + if (get_user(iov_base, >sgl[i].iov_base) ||
> + get_user(ioc->sgl[i].iov_len, >sgl[i].iov_len)) {
> + goto out;
> + }

I don't think we need the braces here.

> + return ioc;
> +out:
> + kfree(ioc);
> +
> + return ERR_PTR(err);

spurious empty line.

> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -91,6 +91,11 @@
>   static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
>  #endif /* COMPAT_SYSCALL_DEFINEx */
>  
> +struct compat_iovec {
> + compat_uptr_t   iov_base;
> + compat_size_t   iov_len;
> +};
> +
>  #ifdef CONFIG_COMPAT
>  
>  #ifndef compat_user_stack_pointer
> @@ -248,11 +253,6 @@ typedef struct compat_siginfo {
>   } _sifields;
>  } compat_siginfo_t;
>  
> -struct compat_iovec {
> - compat_uptr_t   iov_base;
> - compat_size_t   iov_len;
> -};

This should probably go into a separate patch instead of being hidden
in a driver patch.

But except for these nitpicks the change looks good:

Reviewed-by: Christoph Hellwig 


Re: [PATCH v2 2/3] scsi: megaraid_sas: check user-provided offsets

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 02:15:22PM +0200, Arnd Bergmann wrote:
> It sounds unwise to let user space pass an unchecked 32-bit
> offset into a kernel structure in an ioctl. This is an unsigned
> variable, so checking the upper bound for the size of the structure
> it points into is sufficient to avoid data corruption, but as
> the pointer might also be unaligned, it has to be written carefully
> as well.
> 
> While I stumbled over this problem by reading the code, I did not
> continue checking the function for further problems like it.
> 
> Cc:  # v2.6.15+
> Fixes: c4a3e0a529ab ("[SCSI] MegaRAID SAS RAID: new driver")
> Reviewed-by: Christoph Hellwig 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
> b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 861f7140f52e..c3de69f3bee8 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -8095,7 +8095,7 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
>   int error = 0, i;
>   void *sense = NULL;
>   dma_addr_t sense_handle;
> - unsigned long *sense_ptr;
> + void *sense_ptr;
>   u32 opcode = 0;
>   int ret = DCMD_SUCCESS;
>  
> @@ -8218,6 +8218,12 @@ megasas_mgmt_fw_ioctl(struct megasas_instance 
> *instance,
>   }
>  
>   if (ioc->sense_len) {
> + /* make sure the pointer is part of the frame */
> + if (ioc->sense_off > (sizeof(union megasas_frame) - 
> sizeof(__le64))) {

Add a line break to avoid the overly long line - also the braces
around the arithmetics aren't actually needed.


Re: [PATCH 02/14] block: switch register_disk to use blkdev_get_by_dev

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 11:52:39AM +0300, Sergei Shtylyov wrote:
> Hello!
>
> On 17.09.2020 19:57, Christoph Hellwig wrote:
>
>> Use blkdev_get_by_dev instead of open coding it using bdget_disk +
>> blkdev_get.
>
>I don't see where you are removing bdget_disk() call (situated just before
> the below code?)...

Indeed.  That's what you get for a messy last minute rebase.. :(


Re: [fs] 36e2c7421f: kernel-selftests.splice.short_splice_read.sh.fail

2020-09-18 Thread Christoph Hellwig
On Fri, Sep 18, 2020 at 02:49:19PM -0700, Kees Cook wrote:
> In response to my recent bug fix for splice vs sysfs binary handler[1],
> I added splice testing for other pseudo filesystems[2], for which the
> test output is seen above.
> 
> What is the final verdict on the "should splice have a fallback mode?"
> question[3]? Right now /proc and /sys reject splice attempts (which, as
> I mentioned in the thread, is fine by me, since it would have blocked
> the bug I had to fix from ever being exposed in the first place).

The verdict is: without a set_fs()-like mechanism that allows uaccess
routines to operate on kernel buffers, or even worse a
compat_alloc_user_space-like mechanism we can't have an entirely
generic fallback.

> Should I update the test to _expect_ that splice should fail?

I think so.  We can updated individual file operations to support splice
where actually used applications except it (even when they shouldn't),
but I'd rather not do it just for a test case.


Re: [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios

2020-09-18 Thread Gao Xiang
On Fri, Sep 18, 2020 at 09:54:35PM +0800, Gao Xiang wrote:
> Use more accurate compressed page count
> instead of BIO_MAX_PAGES unconditionally.
> 
> Signed-off-by: Gao Xiang 

Found by ro_fsstress, the submission chain could be extended
by other threads, so this patch wouldn't work with the tail
merging strategy. Please ignore this and I will drop it and
send the next version instead.

Thanks,
Gao Xiang



[PATCH] thermal/drivers/cpuidle_cooling: Change the latency limit

2020-09-18 Thread zhuguangqing83
From: zhuguangqing 

The injected idle duration must be greater than the wake up latency
(entry + exit latency) or the idle state target residency (or  min
residency), otherwise we end up consuming more energy and potentially
invert the mitigation effect.

In function idle_inject_fn(), we call play_idle_precise() to specify
a latency limit which is finally used in find_deepest_state() to find
the deepest idle state. Although the latency limit is compared with
s->exit_latency_ns in find_deepest_state(), it should not be exit
latency, but the idle duraion minus entry latency which can ensure
that the injected idle duration is greater than the wake up latency
(entry + exit latency).

There are two timers in idle inject process, the length of the first
timer (timer_1) is idle duration, and the length of the second timer
(timer_2) is idle duration plus run duration. When timer_2 expires,
it's restarted and idle_inject_timer_fn() is called and it wakes up
idle injection tasks associated with the timer and they, in turn,
invoke play_idle_precise() to inject a specified amount (idle duration)
of CPU idle time. The major functions called are as follows:

play_idle_precise() ->
 do_idle() ->
  cpuidle_idle_call() ->
   cpuidle_find_deepest_state() ->
find_deepest_state()

When we call find_deepest_state(), some time has been consumed from
the beginning of the idle duration which could be considered the
entry latency approximately, so the latency limit should be the idle
duraion minus entry latency which can ensure that the injected idle
duration is greater than the wake up latency (entry + exit latency).

Here are two sample scenes,
scene   entry latency(us)exit latency(us)idle duration(us)
1500 600   1000
2500 600   3000

In scene 1, if we use exit latency (600us) for the latency limit,
we may find a idle state which has a exit latency equal to or less
than 600us, suppose the idle state's exit latency is equal to 600us,
then the wake up latency (entry + exit latency) is greater than idle
duration.

In scene 2, if we use exit latency (600us) for the latency limit,
we may also find a idle state which has a exit latency equal to
600us. But if we use the idle duraion minus entry latency
(3000 - 500 = 2500us), we can find a deeper idle state to save
more power in idle duration.

Signed-off-by: zhuguangqing 
---
 drivers/thermal/cpuidle_cooling.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/cpuidle_cooling.c 
b/drivers/thermal/cpuidle_cooling.c
index 78e3e8238116..6f78c7816fcc 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -174,6 +174,7 @@ static int __cpuidle_cooling_register(struct device_node 
*np,
struct idle_inject_device *ii_dev;
struct cpuidle_cooling_device *idle_cdev;
struct thermal_cooling_device *cdev;
+   unsigned int entry_latency_us;
unsigned int idle_duration_us = TICK_USEC;
unsigned int latency_us = UINT_MAX;
char dev_name[THERMAL_NAME_LENGTH];
@@ -198,7 +199,9 @@ static int __cpuidle_cooling_register(struct device_node 
*np,
}
 
of_property_read_u32(np, "duration-us", _duration_us);
-   of_property_read_u32(np, "exit-latency-us", _us);
+   if (!of_property_read_u32(np, "entry-latency-us", _latency_us) &&
+   idle_duration_us > entry_latency_us)
+   latency_us = idle_duration_us - entry_latency_us;
 
idle_inject_set_duration(ii_dev, TICK_USEC, idle_duration_us);
idle_inject_set_latency(ii_dev, latency_us);
-- 
2.17.1



Re: [PATCH v6 7/7] perf diff: Support hot streams comparison

2020-09-18 Thread Jin, Yao

Hi Arnaldo,

On 9/18/2020 4:26 AM, Arnaldo Carvalho de Melo wrote:

Em Fri, Sep 11, 2020 at 04:03:53PM +0800, Jin Yao escreveu:

This patch enables perf-diff with "--stream" option.

"--stream": Enable hot streams comparison

Now let's see examples.

perf record -b ...  Generate perf.data.old with branch data
perf record -b ...  Generate perf.data with branch data
perf diff --stream

[ Matched hot streams ]

hot chain pair 1:
 cycles: 1, hits: 27.77%  cycles: 1, hits: 9.24%
 ---  --
   main div.c:39   main div.c:39
   main div.c:44   main div.c:44

hot chain pair 2:
cycles: 34, hits: 20.06%cycles: 27, hits: 16.98%
 ---  --
   __random_r random_r.c:360   __random_r random_r.c:360


Would it be interesting to get the associated source code and show right below
these file:number lines?

- Arnaldo



I'm thinking we can implement this function in callchain_list__sym_name(), and then all callchain 
functionality will benefit from it. While that looks to be another patchset. :)


Thanks
Jin Yao


Re: [PATCH] riscv: Add sfence.vma after page table changed

2020-09-18 Thread Palmer Dabbelt

On Mon, 14 Sep 2020 20:58:13 PDT (-0700), greentime...@sifive.com wrote:

Palmer Dabbelt  於 2020年8月5日 週三 上午10:03寫道:


On Mon, 03 Aug 2020 20:29:32 PDT (-0700), a...@brainfault.org wrote:
> On Tue, Aug 4, 2020 at 8:32 AM Greentime Hu  wrote:
>>
>> This patch addes local_flush_tlb_page(addr) to use sfence.vma after the
>
> s/addes/adds
>
>> page table changed. That address will be used immediately in
>> memset(nextp, 0, PAGE_SIZE) to cause this issue so we should add the
>> sfence.vma before we use it.
>
> Alternate version of this commit description can be:
>
> Invalidate local TLB after both set_pet() and clear_pte() because the
> address can be used immediately after page table change.
>
>> Fixes: f2c17aabc917 ("RISC-V: Implement compile-time fixed mappings")
>>
>> Reported-by: Syven Wang 
>> Signed-off-by: Syven Wang 
>> Signed-off-by: Greentime Hu 
>> ---
>>  arch/riscv/mm/init.c | 7 +++
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index f4adb3684f3d..29b0f7108054 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -202,12 +202,11 @@ void __set_fixmap(enum fixed_addresses idx, 
phys_addr_t phys, pgprot_t prot)
>>
>> ptep = _pte[pte_index(addr)];
>>
>> -   if (pgprot_val(prot)) {
>> +   if (pgprot_val(prot))
>> set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot));
>> -   } else {
>> +   else
>> pte_clear(_mm, addr, ptep);
>> -   local_flush_tlb_page(addr);
>> -   }
>> +   local_flush_tlb_page(addr);
>>  }

arm64 appears to be upgrading all set_pte()s on valid kernel mappings to
include the fence.  It looks like the message from 7f0b1bf04511 ("arm64: Fix
barriers used for page table modifications") is out of date, as I can't find
create_mapping() any more.  If that was some generic kernel thing then we
should probably upgrade ours as well, but if it was arch/arm64/ code then this
approach seems fine as __set_fixmap() isn't on the hot path -- I guess this is
fine either way, but there may be other issues that the arm64 approach fixes.

Do you guys happen to remember what was going on here?


Hi Palmer,

Some architectures add cache writeback in set_pte(), just like nds32, csky.

https://github.com/torvalds/linux/blob/master/arch/nds32/include/asm/pgtable.h#L213
https://github.com/torvalds/linux/blob/master/arch/csky/include/asm/pgtable.h#L104

Would you like to pick this patch or should I send another patch to
implement it in set_pte()?


Sorry, I forgot about this.  I'm picking up this patch on fixes, as it clearly
fixes a bug.  We might also have uncovered another bug, but there's no sense in
letting this one hang around until we figure that out.

I've cleaned up the comment text a bit, as Anup pointed out some issuses.

Thanks!


Re: [PATCH v2] powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h

2020-09-18 Thread Tony Ambardar
On Thu, 17 Sep 2020 at 07:34, Andreas Schwab  wrote:
>
> On Sep 17 2020, Arnd Bergmann wrote:
>
> > The errno man page says they are supposed to be synonyms,
> > and glibc defines it that way, while musl uses the numbers
> > from the kernel.
>
> glibc also uses whatever the kernel defines.
>
That's right, and from my investigation this isn't a libc issue. The
various libc flavours simply try to follow POSIX and the PPC ABI and
aren't doing anything wrong.

See errno.h for example (https://man7.org/linux/man-pages/man3/errno.3.html):
  EDEADLK: Resource deadlock avoided (POSIX.1-2001).
  EDEADLOCK: On most architectures, a synonym for EDEADLK.  On some
architectures (e.g., Linux MIPS, PowerPC, SPARC), it is a separate
error code "File locking deadlock error".

The root cause is unique to the Linux PPC code in
arch/powerpc/include/uapi/asm/errno.h:
  >/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  >#ifndef _ASM_POWERPC_ERRNO_H
  >#define _ASM_POWERPC_ERRNO_H
  >
  >#include 
  >
  >#undef  EDEADLOCK
  >#define EDEADLOCK   58  /* File locking deadlock error */
  >
  >#endif  /* _ASM_POWERPC_ERRNO_H */

It includes "" to pull in various definitions but
has the side-effect of redefining EDEADLOCK to a non-ABI value which
conflicts with the libc errno.h, as I outline in the patch
description. Other arches which also use different EDEADLOCK and
EDEADLK values (mips,sparc) do not do this. They define EDEADLOCK
*once*, with an ABI-consistent value, and don't have the same issue.

The problem goes back a ways (as Arnd points out), affecting current
stable and all LTS branches, so would be nice to get this sorted out.
I'm certainly interested if there's a better way than proposed in this
patch.

> Andreas.
>
> --
> Andreas Schwab, sch...@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."


Re: [External] Re: [PATCH] tasklet: Introduce tasklet tracepoints

2020-09-18 Thread Muchun Song
On Sat, Sep 19, 2020 at 12:46 AM Steven Rostedt  wrote:
>
> On Sat,  5 Sep 2020 14:04:12 +0800
> Muchun Song  wrote:
>
> > Introduce tracepoints for tasklets just like softirq does. In this case,
> > we can calculate tasklet latency and know what tasklet run.
> >
> > Signed-off-by: Muchun Song 
> > ---
> >  include/trace/events/irq.h | 44 ++
> >  kernel/softirq.c   |  2 ++
> >  2 files changed, 46 insertions(+)
> >
> > diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
> > index eeceafaaea4c..69a16f3a21c2 100644
> > --- a/include/trace/events/irq.h
> > +++ b/include/trace/events/irq.h
> > @@ -160,6 +160,50 @@ DEFINE_EVENT(softirq, softirq_raise,
> >   TP_ARGS(vec_nr)
> >  );
> >
> > +DECLARE_EVENT_CLASS(tasklet,
> > +
> > + TP_PROTO(struct tasklet_struct *t),
> > +
> > + TP_ARGS(t),
> > +
> > + TP_STRUCT__entry(
> > + __field(void *, callback)
> > + ),
> > +
> > + TP_fast_assign(
> > + __entry->callback = t->callback;
>
> I think you need to replicate the logic in the code:
>
> if (t->use_callback)
> __entry->callback = t->callback;
> else
> __entry->callback = t->func;

The `callback` and `func` is union and `callback` will replace
`func` someday in the feature. So I think that here we use
`t->callback` is enough. Right? Thanks.

>
> -- Steve
>
> > + ),
> > +
> > + TP_printk("callback=%ps", __entry->callback)
> > +);
> > +
> > +/**
> > + * tasklet_entry - called immediately before the tasklet handler
> > + * @t: pointer to struct tasklet_struct
> > + *
> > + * When used in combination with the tasklet_exit tracepoint
> > + * we can determine the tasklet handler routine.
> > + */
> > +DEFINE_EVENT(tasklet, tasklet_entry,
> > +
> > + TP_PROTO(struct tasklet_struct *t),
> > +
> > + TP_ARGS(t)
> > +);
> > +
> > +/**
> > + * tasklet_exit - called immediately after the tasklet handler returns
> > + * @t: pointer to struct tasklet_struct
> > + *
> > + * When used in combination with the tasklet_entry tracepoint
> > + * we can determine the tasklet handler routine.
> > + */
> > +DEFINE_EVENT(tasklet, tasklet_exit,
> > +
> > + TP_PROTO(struct tasklet_struct *t),
> > +
> > + TP_ARGS(t)
> > +);
> >  #endif /*  _TRACE_IRQ_H */
> >
> >  /* This part must be outside protection */
> > diff --git a/kernel/softirq.c b/kernel/softirq.c
> > index bf88d7f62433..0f9f5b2cc3d3 100644
> > --- a/kernel/softirq.c
> > +++ b/kernel/softirq.c
> > @@ -553,10 +553,12 @@ static void tasklet_action_common(struct 
> > softirq_action *a,
> >   if (!test_and_clear_bit(TASKLET_STATE_SCHED,
> >   >state))
> >   BUG();
> > + trace_tasklet_entry(t);
> >   if (t->use_callback)
> >   t->callback(t);
> >   else
> >   t->func(t->data);
> > + trace_tasklet_exit(t);
> >   tasklet_unlock(t);
> >   continue;
> >   }
>


-- 
Yours,
Muchun


Re: [PATCH] MIPS: Loongson64: Add kexec/kdump support

2020-09-18 Thread Huacai Chen
Hi, Jinyang,

On Fri, Sep 18, 2020 at 2:20 PM Jinyang He  wrote:
>
> On 09/17/2020 09:52 PM, Zhou Yanjie wrote:
> > Hello,
> >
> > 在 2020/9/17 下午8:41, Jinyang He 写道:
> >> Hi, Huacai,
> >>
> >>
> >> On 09/16/2020 01:39 PM, Huacai Chen wrote:
> >>> Hi, Jinyang,
> >>>
> >>> On Tue, Sep 15, 2020 at 10:17 PM Jinyang He 
> >>> wrote:
> 
> 
>  On 09/16/2020 09:33 AM, Jiaxun Yang wrote:
> > 于 2020年9月15日 GMT+08:00 下午9:07:43, Jinyang He
> >  写到:
> >> Add loongson_kexec_prepare(), loongson_kexec_shutdown() and
> >> loongson_kexec_crashdown() for passing the parameters of kexec_args.
> >>
> >> To start loongson64, CPU0 needs 3 parameters:
> >> fw_arg0: the number of cmd.
> >> fw_arg1: cmd structure which seems strange, the cmd array[index]'s
> >>   value is cmd string's address, index >= 1.
> >> fw_arg2: environment.
> >>
> >> Secondary CPUs do not need parameter at once. They query their
> >> mailbox to get PC, SP and GP in a loop before CPU0 brings them up
> >> and passes these parameters via mailbox.
> >>
> >> loongson_kexec_prepare(): Alloc new memory to save cmd for kexec.
> >> Combine the kexec append option string as cmd structure, and the cmd
> >> struct will be parsed in fw_init_cmdline() of
> >> arch/mips/fw/lib/cmdline.c.
> >> image->control_code_page need pointing to a safe memory page. In
> >> order to
> >> maintain compatibility for the old firmware the low 2MB is reserverd
> >> and safe for Loongson. So let it points here.
> >>
> >> loongson_kexec_shutdown(): Wake up all present CPUs and let them go
> >> to reboot_code_buffer. Pass the kexec parameters to kexec_args.
> >>
> >> loongson_crash_shutdown(): Pass the kdump parameters to kexec_args.
> >>
> >> The assembly part provide a way like BIOS doing to keep secondary
> >> CPUs in a querying loop.
> >>
> >> This patch referenced [1][2][3].
> >>
> >> [1] arch/mips/cavium-octeon/setup.c
> >> [2] https://patchwork.kernel.org/patch/10799217/
> >> [3]
> >> https://gitee.com/loongsonlab/qemu/blob/master/hw/mips/loongson3a_rom.h
> >>
> >>
> >> Co-developed-by: Youling Tang 
> >> Signed-off-by: Youling Tang 
> >> Signed-off-by: Jinyang He 
> >> ---
> >> arch/mips/kernel/relocate_kernel.S | 19 
> >> arch/mips/loongson64/reset.c   | 88
> >> ++
> >> 2 files changed, 107 insertions(+)
> >>
> >> diff --git a/arch/mips/kernel/relocate_kernel.S
> >> b/arch/mips/kernel/relocate_kernel.S
> >> index ac87089..061cbfb 100644
> >> --- a/arch/mips/kernel/relocate_kernel.S
> >> +++ b/arch/mips/kernel/relocate_kernel.S
> >> @@ -133,6 +133,25 @@ LEAF(kexec_smp_wait)
> >> #else
> >>   sync
> >> #endif
> >> +
> >> +#ifdef CONFIG_CPU_LOONGSON64
> >> +#define MAILBOX_BASE 0x90003ff01000
> > Please avoid hardcoded SMP information. You're breaking Loongson
> > 3B support.
> >
>  Ok, I see. Since my machine is Loongson 3A. I'll send v2
>  after I test it in 3B.
> >>> 1, My original version can work on both Loongson-3A and Loongson-3B,
> >>> why you modify my patch and hadn't discuss with me?
> >>>
> >>> 2, With this single patch both kexec and kdump cannot work reliably,
> >>> because kexec need this patch:
> >>> https://patchwork.kernel.org/patch/11695929/
> >>>
> >>> and kdump need my first patch in my original version:
> >>> https://patchwork.kernel.org/patch/10799215/
> >>>
> >>> You may argue that you have tested. Yes, I believe that, I'm not
> >>> saying that you haven't test, and I'm not saying that your patch
> >>> cannot work, I'm just saying that your patch is not robust.
> >>>
> >>> 3, I'm the original author and paying attention to kexec/kdump
> >>> continuosly, I will send a new version once the above two patches be
> >>> accepted. But you re-send my patch without any communication with me,
> >>> why you so impatient?
> >>>
> >>> Huacai
> >>>
> >>
> >> 1, Your original version:
> >>https://patchwork.kernel.org/patch/10799217/
> >>
> >> This patch can work on Loongson-3A, I tested it.
> >>
> >> But it works wrong after the follow behaviors,
> >>kexec -l vmlinux --append=cmdline_kexec
> >>kexec -p vmlinux --append=cmdline_kdump
> >>kexec -e
> >>
> >
> > What 's wrong with you Loongson guys? Why do you always send patches
> > with the same functions as the original author withou any
> > communication with the original author? Especially the original author
> > of the patch is the maintainer of Loongson64 architecture.
>
> Hi,
>
> Just take it easy, try to keep calm and do not panic.
>
> You do not understand the story, the background, what happened before,
> and what happens next, so please let me express my opinion.
>
> When I use the mainline kernel on the Loongson platform, I find kexec
> can not work well 

[PATCH] ARM: OMAP2+: Remove redundant assignment to variable ret

2020-09-18 Thread Jing Xiangfeng
The variable ret has been initialized with '-ENOMEM'. The assignment
in the if branch is redundant. So remove it.

Signed-off-by: Jing Xiangfeng 
---
 arch/arm/mach-omap2/omap_device.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_device.c 
b/arch/arm/mach-omap2/omap_device.c
index fc7bb2ca1672..f3191704cab9 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -334,10 +334,9 @@ struct omap_device *omap_device_alloc(struct 
platform_device *pdev,
struct omap_hwmod **hwmods;
 
od = kzalloc(sizeof(struct omap_device), GFP_KERNEL);
-   if (!od) {
-   ret = -ENOMEM;
+   if (!od)
goto oda_exit1;
-   }
+
od->hwmods_cnt = oh_cnt;
 
hwmods = kmemdup(ohs, sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
-- 
2.17.1



RE: [External] [PATCH] dm/dax: Fix table reference counts

2020-09-18 Thread Adrian Huang12
> -Original Message-
> From: Dan Williams 
> Sent: Saturday, September 19, 2020 3:51 AM
> To: dm-de...@redhat.com
> Cc: sta...@vger.kernel.org; Jan Kara ; Alasdair Kergon
> ; Mike Snitzer ; Adrian Huang12
> ; linux-nvd...@lists.01.org; linux-
> ker...@vger.kernel.org
> Subject: [External] [PATCH] dm/dax: Fix table reference counts
> 
> A recent fix to the dm_dax_supported() flow uncovered a latent bug. When
> dm_get_live_table() fails it is still required to drop the srcu_read_lock(). 
> Without
> this change the lvm2 test-suite triggers this
> warning:
> 
> # lvm2-testsuite --only pvmove-abort-all.sh
> 
> WARNING: lock held when returning to user space!
> 5.9.0-rc5+ #251 Tainted: G   OE
> 
> lvm/1318 is leaving the kernel with locks still held!
> 1 lock held by lvm/1318:
>  #0: 9372abb5a340 (>io_barrier){}-{0:0}, at:
> dm_get_live_table+0x5/0xb0 [dm_mod]
> 
> ...and later on this hang signature:
> 
> INFO: task lvm:1344 blocked for more than 122 seconds.
>   Tainted: G   OE 5.9.0-rc5+ #251
> "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
> task:lvm state:D stack:0 pid: 1344 ppid: 1 
> flags:0x4000
> Call Trace:
>  __schedule+0x45f/0xa80
>  ? finish_task_switch+0x249/0x2c0
>  ? wait_for_completion+0x86/0x110
>  schedule+0x5f/0xd0
>  schedule_timeout+0x212/0x2a0
>  ? __schedule+0x467/0xa80
>  ? wait_for_completion+0x86/0x110
>  wait_for_completion+0xb0/0x110
>  __synchronize_srcu+0xd1/0x160
>  ? __bpf_trace_rcu_utilization+0x10/0x10
>  __dm_suspend+0x6d/0x210 [dm_mod]
>  dm_suspend+0xf6/0x140 [dm_mod]
> 
> Fixes: 7bf7eac8d648 ("dax: Arrange for dax_supported check to span multiple
> devices")
> Cc: 
> Cc: Jan Kara 
> Cc: Alasdair Kergon 
> Cc: Mike Snitzer 
> Reported-by: Adrian Huang 
> Signed-off-by: Dan Williams 

Cool, thanks for the fix. This solves the issue.

Tested-by: Adrian Huang 

> ---
>  drivers/md/dm.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/dm.c b/drivers/md/dm.c index
> fb0255d25e4b..4a40df8af7d3 100644
> --- a/drivers/md/dm.c
> +++ b/drivers/md/dm.c
> @@ -1136,15 +1136,16 @@ static bool dm_dax_supported(struct dax_device
> *dax_dev, struct block_device *bd  {
>   struct mapped_device *md = dax_get_private(dax_dev);
>   struct dm_table *map;
> + bool ret = false;
>   int srcu_idx;
> - bool ret;
> 
>   map = dm_get_live_table(md, _idx);
>   if (!map)
> - return false;
> + goto out;
> 
>   ret = dm_table_supports_dax(map, device_supports_dax, );
> 
> +out:
>   dm_put_live_table(md, srcu_idx);
> 
>   return ret;



Re: [GIT PULL] percpu fix for v5.9-rc6

2020-09-18 Thread Arvind Sankar
On Sat, Sep 19, 2020 at 03:45:56AM +0100, Matthew Wilcox wrote:
> On Fri, Sep 18, 2020 at 06:39:57PM -0400, Arvind Sankar wrote:
> > On Fri, Sep 18, 2020 at 02:18:20PM -0700, Linus Torvalds wrote:
> > > On Fri, Sep 18, 2020 at 2:00 PM Arvind Sankar  
> > > wrote:
> > > >
> > > > You could just assert that offsetof(typeof(s),flex) == sizeof(s), no?
> > > 
> > > No, because the whole point is that I want that "sizeof(s)" to *WARN*.
> > 
> > Ouch, offsetof() and sizeof() will give different results in the
> > presence of alignment padding.
> > 
> > https://godbolt.org/z/rqnxTK
> 
> We really should be using offsetof() then.  It's harmless because we're
> currently overallocating, not underallocating.  The test case I did was:
> 

I wonder if there are cases where we know the total size, and are
working out the number of elements in the flexible array by doing
size - sizeof(s).

Would a macro to do the inverse of struct_size(), i.e. get the count
knowing the total size be useful?


[PATCH] mm: fix some doc warnings in workingset.c

2020-09-18 Thread Xiaofei Tan
Fix following warnings caused by mismatch bewteen function parameters
and comments.
mm/workingset.c:228: warning: Function parameter or member 'lruvec' not 
described in 'workingset_age_nonresident'
mm/workingset.c:228: warning: Excess function parameter 'memcg' description in 
'workingset_age_nonresident'

Signed-off-by: Xiaofei Tan 
---
 mm/workingset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/workingset.c b/mm/workingset.c
index 92e6611..8ed8e62 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -216,7 +216,7 @@ static void unpack_shadow(void *shadow, int *memcgidp, 
pg_data_t **pgdat,
 
 /**
  * workingset_age_nonresident - age non-resident entries as LRU ages
- * @memcg: the lruvec that was aged
+ * @lruvec: the lruvec that was aged
  * @nr_pages: the number of pages to count
  *
  * As in-memory pages are aged, non-resident pages need to be aged as
-- 
2.8.1



[PATCH] powerpc: Select HAVE_FUTEX_CMPXCHG

2020-09-18 Thread Samuel Holland
On powerpc, access_ok() succeeds for the NULL pointer. This breaks the
dynamic check in futex_detect_cmpxchg(), which expects -EFAULT. As a
result, robust futex operations are not functional on powerpc.

Since the architecture's futex_atomic_cmpxchg_inatomic() implementation
requires no runtime feature detection, we can select HAVE_FUTEX_CMPXCHG
to skip futex_detect_cmpxchg() and enable the use of robust futexes.

Signed-off-by: Samuel Holland 
---
 arch/powerpc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ad620637cbd1..5ad1deb0c669 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -196,6 +196,7 @@ config PPC
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
+   select HAVE_FUTEX_CMPXCHG
select HAVE_GCC_PLUGINS if GCC_VERSION >= 50200   # 
plugin support on gcc <= 5.1 is buggy on PPC
select HAVE_HW_BREAKPOINT   if PERF_EVENTS && (PPC_BOOK3S 
|| PPC_8xx)
select HAVE_IDE
-- 
2.26.2



Re: [PATCH v2 1/2] locktorture: doesn't check nreaders_stress when no readlock support

2020-09-18 Thread Hou Tao
Hi Paul,

On 2020/9/19 1:59, Paul E. McKenney wrote:
> On Fri, Sep 18, 2020 at 07:44:24PM +0800, Hou Tao wrote:
>> When do locktorture for exclusive lock which doesn't have readlock
>> support, the following module parameters will be considered as valid:
>>
>>  torture_type=mutex_lock nwriters_stress=0 nreaders_stress=1
>>
>> But locktorture will do nothing useful, so instead of permitting
>> these useless parameters, let's reject these parameters by returning
>> -EINVAL during module init.
>>
>> Signed-off-by: Hou Tao 
> 
> Much better, much easier for people a year from now to understand.
> Queued for v5.11, thank you!
> 
> I did edit the commit log a bit as shown below, so please let me
> know if I messed anything up.
> 
Thanks for your edit, it looks more clearer.

Regards,
Tao
>   Thanx, Paul
> 
> commit 4985c52e3b5237666265e59f56856f485ee36e71
> Author: Hou Tao 
> Date:   Fri Sep 18 19:44:24 2020 +0800
> 
> locktorture: Ignore nreaders_stress if no readlock support
> 
> Exclusive locks do not have readlock support, which means that a
> locktorture run with the following module parameters will do nothing:
> 
>  torture_type=mutex_lock nwriters_stress=0 nreaders_stress=1
> 
> This commit therefore rejects this combination for exclusive locks by
> returning -EINVAL during module init.
> 
> Signed-off-by: Hou Tao 
> Signed-off-by: Paul E. McKenney 
> 
> diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
> index 316531d..046ea2d 100644
> --- a/kernel/locking/locktorture.c
> +++ b/kernel/locking/locktorture.c
> @@ -870,7 +870,8 @@ static int __init lock_torture_init(void)
>   goto unwind;
>   }
>  
> - if (nwriters_stress == 0 && nreaders_stress == 0) {
> + if (nwriters_stress == 0 &&
> + (!cxt.cur_ops->readlock || nreaders_stress == 0)) {
>   pr_alert("lock-torture: must run at least one locking 
> thread\n");
>   firsterr = -EINVAL;
>   goto unwind;
> .
> 


RE: [PATCH] [v2] nvme: use correct upper limit for tag in nvme_handle_cqe()

2020-09-18 Thread Tianxianting
Hi Keith,
Thanks a lot for your comments,
I will try to figure out a safe fix for this issue, then for you review:) 

-Original Message-
From: Keith Busch [mailto:kbu...@kernel.org] 
Sent: Saturday, September 19, 2020 3:21 AM
To: tianxianting (RD) 
Cc: ax...@fb.com; h...@lst.de; s...@grimberg.me; 
linux-n...@lists.infradead.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] nvme: use correct upper limit for tag in 
nvme_handle_cqe()

On Fri, Sep 18, 2020 at 06:44:20PM +0800, Xianting Tian wrote:
> @@ -940,7 +940,9 @@ static inline void nvme_handle_cqe(struct nvme_queue 
> *nvmeq, u16 idx)
>   struct nvme_completion *cqe = >cqes[idx];
>   struct request *req;
>  
> - if (unlikely(cqe->command_id >= nvmeq->q_depth)) {
> + if (unlikely(cqe->command_id >=
> + nvmeq->qid ? nvmeq->dev->tagset.queue_depth :
> + nvmeq->dev->admin_tagset.queue_depth)) {

Both of these values are set before blk_mq_alloc_tag_set(), so you still have a 
race. The interrupt handler probably just shouldn't be registered with the 
queue before the tagset is initialized since there can't be any work for the 
handler to do before that happens anyway.

The controller is definitely broken, though, and will lead to unavoidable 
corruption if it's really behaving this way.


[PATCH] xen: remove redundant initialization of variable ret

2020-09-18 Thread Jing Xiangfeng
After commit 9f51c05dc41a ("pvcalls-front: Avoid
get_free_pages(GFP_KERNEL) under spinlock"), the variable ret is being
initialized with '-ENOMEM' that is meaningless. So remove it.

Signed-off-by: Jing Xiangfeng 
---
 drivers/xen/pvcalls-front.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
index 72d725a0ab5c..7984645b5956 100644
--- a/drivers/xen/pvcalls-front.c
+++ b/drivers/xen/pvcalls-front.c
@@ -371,7 +371,7 @@ static int alloc_active_ring(struct sock_mapping *map)
 static int create_active(struct sock_mapping *map, evtchn_port_t *evtchn)
 {
void *bytes;
-   int ret = -ENOMEM, irq = -1, i;
+   int ret, irq = -1, i;
 
*evtchn = 0;
init_waitqueue_head(>active.inflight_conn_req);
-- 
2.17.1



[PATCH v2 0/3] crypto: hisilicon/hpre - misc clean up and fixes

2020-09-18 Thread yumeng 00484669
Adjust some tiny coding problems and fix a bug of DH algorithm.

Changes since v1:
Remove 'u64' cast in 'cpu_to_le64';

Meng Yu (3):
  crypto: hisilicon/hpre - remove useless code
  crypto: hisilicon/hpre - adjust some coding style
  crypto: hisilicon/hpre - fix a bug in dh algorithm

 drivers/crypto/hisilicon/hpre/hpre.h|  1 -
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 23 +++
 2 files changed, 11 insertions(+), 13 deletions(-)

-- 
2.8.1



[PATCH v2 1/3] crypto: hisilicon/hpre - remove useless code

2020-09-18 Thread yumeng 00484669
From: Meng Yu 

1. Remove unused member 'debug_root' in 'struct hpre_debug';
2. The u64 cast is redundant in 'cpu_to_le64'.

Fixes: 848974151618("crypto: hisilicon - Add debugfs for HPRE")
Fixes: dadbe4c11753("crypto: hisilicon/hpre - update debugfs ...")
Signed-off-by: Meng Yu 
Reviewed-by: Zaibo Xu 
---
 drivers/crypto/hisilicon/hpre/hpre.h| 1 -
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 8 
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre.h 
b/drivers/crypto/hisilicon/hpre/hpre.h
index ed730d1..f69252b 100644
--- a/drivers/crypto/hisilicon/hpre/hpre.h
+++ b/drivers/crypto/hisilicon/hpre/hpre.h
@@ -56,7 +56,6 @@ struct hpre_dfx {
  * Just relevant for PF.
  */
 struct hpre_debug {
-   struct dentry *debug_root;
struct hpre_dfx dfx[HPRE_DFX_FILE_NUM];
struct hpre_debugfs_file files[HPRE_DEBUGFS_FILE_NUM];
 };
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c 
b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index d685992..678a5ee 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -474,7 +474,7 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, void 
*req, bool is_rsa)
h_req->areq.dh = kreq;
msg = _req->req;
memset(msg, 0, sizeof(*msg));
-   msg->key = cpu_to_le64((u64)ctx->dh.dma_xa_p);
+   msg->key = cpu_to_le64(ctx->dh.dma_xa_p);
}
 
msg->dw0 |= cpu_to_le32(0x1 << HPRE_SQE_DONE_SHIFT);
@@ -740,7 +740,7 @@ static int hpre_rsa_enc(struct akcipher_request *req)
return ret;
 
msg->dw0 |= cpu_to_le32(HPRE_ALG_NC_NCRT);
-   msg->key = cpu_to_le64((u64)ctx->rsa.dma_pubkey);
+   msg->key = cpu_to_le64(ctx->rsa.dma_pubkey);
 
ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 0);
if (unlikely(ret))
@@ -788,11 +788,11 @@ static int hpre_rsa_dec(struct akcipher_request *req)
return ret;
 
if (ctx->crt_g2_mode) {
-   msg->key = cpu_to_le64((u64)ctx->rsa.dma_crt_prikey);
+   msg->key = cpu_to_le64(ctx->rsa.dma_crt_prikey);
msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) |
   HPRE_ALG_NC_CRT);
} else {
-   msg->key = cpu_to_le64((u64)ctx->rsa.dma_prikey);
+   msg->key = cpu_to_le64(ctx->rsa.dma_prikey);
msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) |
   HPRE_ALG_NC_NCRT);
}
-- 
2.8.1



[PATCH v2 3/3] crypto: hisilicon/hpre - fix a bug in dh algorithm

2020-09-18 Thread yumeng 00484669
From: Meng Yu 

Using 'g' not equal to 2 in dh algorithm may cause an error like this:

arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
dh: Party A: generate public key test failed. err -22
11375.065672] dh alg: dh: test failed on vector 1, err=-22
arm-smmu-v3 arm-smmu-v3.1.auto:  0x7910
arm-smmu-v3 arm-smmu-v3.1.auto:  0x12080080
hpre-dh self test failed
arm-smmu-v3 arm-smmu-v3.1.auto:  0x
arm-smmu-v3 arm-smmu-v3.1.auto:  0x
arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
arm-smmu-v3 arm-smmu-v3.1.auto:  0x7910
arm-smmu-v3 arm-smmu-v3.1.auto:  0x12080083
arm-smmu-v3 arm-smmu-v3.1.auto:  0x00c0
arm-smmu-v3 arm-smmu-v3.1.auto:  0x
arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
arm-smmu-v3 arm-smmu-v3.1.auto:  0x7910
arm-smmu-v3 arm-smmu-v3.1.auto:  0x12080081
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0040
arm-smmu-v3 arm-smmu-v3.1.auto:  0x
arm-smmu-v3 arm-smmu-v3.1.auto: event 0x10 received:
arm-smmu-v3 arm-smmu-v3.1.auto:  0x7910
arm-smmu-v3 arm-smmu-v3.1.auto:  0x12080082
arm-smmu-v3 arm-smmu-v3.1.auto:  0x0080
arm-smmu-v3 arm-smmu-v3.1.auto:  0x
hisi_hpre :79:00.0: dat_rd_poison_int_set [error status=0x8] found
hisi_hpre :79:00.0: ooo_rdrsp_err_int_set [error status=0xfc00] found
hisi_hpre :79:00.0: Controller resetting...
hisi_hpre :79:00.0: Controller reset complete
{2}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 0
{2}[Hardware Error]: event severity: recoverable
{2}[Hardware Error]: Error 0, type: recoverable
{2}[Hardware Error]: section type: unknown, c8b328a8-9917-4af6-9a13-2e08ab2e7586
{2}[Hardware Error]: section length: 0x4c

as we missed initiating 'msg->in'.

Fixes: c8b4b477079d("crypto: hisilicon - add HiSilicon HPRE accelerator")
Signed-off-by: Meng Yu 
Reviewed-by: Zaibo Xu 
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c 
b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 8bdaca0..a87f990 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -528,6 +528,8 @@ static int hpre_dh_compute_value(struct kpp_request *req)
ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 1);
if (unlikely(ret))
goto clear_all;
+   } else {
+   msg->in = cpu_to_le64(ctx->dh.dma_g);
}
 
ret = hpre_hw_data_init(hpre_req, req->dst, req->dst_len, 0, 1);
-- 
2.8.1



[PATCH v2 2/3] crypto: hisilicon/hpre - adjust some coding style

2020-09-18 Thread yumeng 00484669
From: Meng Yu 

Adjust some coding style to make code aligned.

Signed-off-by: Meng Yu 
Reviewed-by: Zaibo Xu 
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c 
b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index 678a5ee..8bdaca0 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -188,8 +188,7 @@ static int hpre_get_data_dma_addr(struct hpre_asym_request 
*hpre_req,
hpre_req->dst = NULL;
dma_dir = DMA_FROM_DEVICE;
}
-   *tmp = dma_map_single(dev, sg_virt(data),
- len, dma_dir);
+   *tmp = dma_map_single(dev, sg_virt(data), len, dma_dir);
if (unlikely(dma_mapping_error(dev, *tmp))) {
dev_err(dev, "dma map data err!\n");
return -ENOMEM;
@@ -239,8 +238,8 @@ static int hpre_hw_data_init(struct hpre_asym_request 
*hpre_req,
((is_dh && !is_src) || !is_dh))
ret = hpre_get_data_dma_addr(hpre_req, data, len, is_src, );
else
-   ret = hpre_prepare_dma_buf(hpre_req, data, len,
- is_src, );
+   ret = hpre_prepare_dma_buf(hpre_req, data, len, is_src, );
+
if (unlikely(ret))
return ret;
 
@@ -267,11 +266,9 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx,
 
if (src) {
if (req->src)
-   dma_free_coherent(dev, ctx->key_sz,
- req->src, tmp);
+   dma_free_coherent(dev, ctx->key_sz, req->src, tmp);
else
-   dma_unmap_single(dev, tmp,
-ctx->key_sz, DMA_TO_DEVICE);
+   dma_unmap_single(dev, tmp, ctx->key_sz, DMA_TO_DEVICE);
}
 
tmp = le64_to_cpu(sqe->out);
-- 
2.8.1



答复: [PATCH net-next] net: microchip: Remove set but not used variable

2020-09-18 Thread zhengyongjun
This is the bad patch, my fault, I forget to check patch title, please ignore 
it, thank you very much.

-邮件原件-
发件人: zhengyongjun 
发送时间: 2020年9月19日 10:39
收件人: bryan.whiteh...@microchip.com; unglinuxdri...@microchip.com; 
da...@davemloft.net; k...@kernel.org; net...@vger.kernel.org; 
linux-kernel@vger.kernel.org
抄送: zhengyongjun 
主题: [PATCH net-next] net: microchip: Remove set but not used variable

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/microchip/lan743x_main.c: In function lan743x_pm_suspend:
drivers/net/ethernet/microchip/lan743x_main.c:3041:6: warning: variable ‘ret’ 
set but not used [-Wunused-but-set-variable]

`ret` is set but not used, so check it's value.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index de93cc6ebc1a..56a1b5928f9a 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3053,7 +3053,7 @@ static int lan743x_pm_suspend(struct device *dev)
/* Host sets PME_En, put D3hot */
ret = pci_prepare_to_sleep(pdev);
 
-   return 0;
+   return ret;
 }
 
 static int lan743x_pm_resume(struct device *dev)
-- 
2.17.1



Re: [GIT PULL] s390 updates for 5.9-rc6

2020-09-18 Thread pr-tracker-bot
The pull request you sent on Sat, 19 Sep 2020 01:27:25 +0200:

> git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git tags/s390-5.9-6

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

Thank you!

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


Re: [GIT PULL] percpu fix for v5.9-rc6

2020-09-18 Thread Linus Torvalds
On Fri, Sep 18, 2020 at 7:53 PM Arvind Sankar  wrote:
>
> Is it ever necessary to allocate _at least_ sizeof() even if
> offsetof()+size is smaller?

Not that I can tell.

Obviously all allocators tend to have their own alignment concerns, so
they'll all align things up internally anyway.

But why would the alignment of the earlier members of the structure
have anything to do with the size of it? That's nonsensical outside of
the array situation, I feel.

Of course, maybe somebody has such a case: an "array of structures,
each with the same size of flexible array member". And then you _do_
want to align all those entries.

But honestly, once you start doing things like that, why would you
only have one single structure type, much less just one single size of
that flexible array? If you lay out these variably-sized things in
memory each after each other, maybe you lay out multiple different
_kinds_ of variably sized structures?

So there are lots of reasons to want alignment at the end, but why
would the alignment be the same as the beginning of that particular
type?

That said, in the kernel, this probably practically never really
matters. Because typically, our allocation alignment tends to be
bigger than any individual structure type alignment anyway.

So it's probably all moot. The difference between using "sizeof()" and
"offsetof()" is in the noise and not important per se.

No, the real reason I would advocate using 'offsetof()' is really just
that I'd rather have 'sizeof()' cause a warning.

> I think you can't do this in standard C. It's a GCC extension.
>
> A structure containing a flexible array member, or a union
> containing such a structure (possibly recursively), may not be a
> member of a structure or an element of an array. (However, these
> uses are permitted by GCC as extensions.)

Ahh.

But I'm pretty sure the 'sizeof()' thing is actually the standard, not gcc.

Arrays of those things is odd, and apparently the standard got that
right. Good (but I think it also means that allowing sizeof() makes
even less sense).

Linus


Re: [GIT PULL] percpu fix for v5.9-rc6

2020-09-18 Thread Matthew Wilcox
On Fri, Sep 18, 2020 at 10:53:36PM -0400, Arvind Sankar wrote:
> I think you can't do this in standard C. It's a GCC extension.
> 
>   A structure containing a flexible array member, or a union
>   containing such a structure (possibly recursively), may not be a
>   member of a structure or an element of an array. (However, these
>   uses are permitted by GCC as extensions.)

I actually have a patch in the works which wants to do this.

 struct pagevec {
-   unsigned char nr;
-   bool percpu_pvec_drained;
-   struct page *pages[PAGEVEC_SIZE];
+   union {
+   struct {
+   unsigned char sz;
+   unsigned char nr;
+   bool percpu_pvec_drained;
+   struct page *pages[];
+   };
+   void *__p[PAGEVEC_SIZE + 1];
+   };
 };

I don't think ANSI C permits this, but it's useful to be able to declare
a pagevec on the stack and be guaranteed to get enough memory to hold
a useful sized array of pointers (as well as be able to dynamically
allocate a larger pagevec for the cases which want such a thing).

We could certainly split pagevec into a variable length array version
and have a struct stack_pagevec which had the extra padding, but that
involves changing a lot more code.


答复: [PATCH net-next] net: microchip: Remove set but not used variable

2020-09-18 Thread zhengyongjun
This is the bad patch, please ignore it, thank you very much.

-邮件原件-
发件人: zhengyongjun 
发送时间: 2020年9月19日 10:38
收件人: bryan.whiteh...@microchip.com; unglinuxdri...@microchip.com; 
da...@davemloft.net; k...@kernel.org; net...@vger.kernel.org; 
linux-kernel@vger.kernel.org
抄送: zhengyongjun 
主题: [PATCH net-next] net: microchip: Remove set but not used variable

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/microchip/lan743x_main.c: In function lan743x_pm_suspend:
drivers/net/ethernet/microchip/lan743x_main.c:3041:6: warning: variable ‘ret’ 
set but not used [-Wunused-but-set-variable]

`ret` is never used, so remove it.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index de93cc6ebc1a..56a1b5928f9a 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3053,7 +3053,7 @@ static int lan743x_pm_suspend(struct device *dev)
/* Host sets PME_En, put D3hot */
ret = pci_prepare_to_sleep(pdev);
 
-   return 0;
+   return ret;
 }
 
 static int lan743x_pm_resume(struct device *dev)
-- 
2.17.1



Re: [PATCH v7 11/11] usb: typec: tcpci_maxim: Implemnent set_auto_vbus_discharge_threshold

2020-09-18 Thread Badhri Jagan Sridharan
On Fri, Sep 18, 2020 at 7:20 AM Heikki Krogerus
 wrote:
>
> On Thu, Sep 17, 2020 at 03:18:56AM -0700, Badhri Jagan Sridharan wrote:
> > Programs VBUS_SINK_DISCONNECT_THRESHOLD based on the power_role,
> > voltage requested as sink, mode of operation.
> >
> > The programmed threshold is based on vSinkDisconnect and
> > vSinkDisconnectPD values.
> >
> > Signed-off-by: Badhri Jagan Sridharan 
> > ---
> > Changes since v1:
> > - Changing patch version to v6 to fix version number confusion.
> >
> > Changes since v6:
> > - Rebase on usb-next.
> > ---
> >  drivers/usb/typec/tcpm/tcpci_maxim.c | 48 
> >  1 file changed, 48 insertions(+)
> >
> > diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.c 
> > b/drivers/usb/typec/tcpm/tcpci_maxim.c
> > index 723d7dd38f75..8289b596d2ee 100644
> > --- a/drivers/usb/typec/tcpm/tcpci_maxim.c
> > +++ b/drivers/usb/typec/tcpm/tcpci_maxim.c
> > @@ -137,6 +137,52 @@ static void max_tcpci_init_regs(struct max_tcpci_chip 
> > *chip)
> >   return;
> >  }
> >
> > +static int max_tcpci_set_auto_vbus_discharge_threshold(struct tcpci 
> > *tcpci, struct tcpci_data *data,
> > +enum typec_role 
> > port_role,
> > +enum typec_pwr_opmode 
> > mode, bool pps_active,
> > +u32 
> > requested_vbus_voltage_mv)
> > +{
> > + struct max_tcpci_chip *chip = tdata_to_max_tcpci(data);
> > + u32 threshold = 0;
> > + u8 pwr_ctrl;
> > +
> > + /*
> > +  * Indicates that vbus is going to go away due PR_SWAP, hard reset 
> > etc.
> > +  * Do not discharge vbus here.
> > +  */
> > + if (requested_vbus_voltage_mv == 0)
> > + goto write_thresh;
>
> I would assume that step is the same for every TCPC, no?
I agree so moved to tcpci.c code.
>
> > + if (port_role == TYPEC_SINK) {
> > + max_tcpci_read8(chip, TCPC_POWER_CTRL, _ctrl);
> > + if (pwr_ctrl & TCPC_FAST_ROLE_SWAP_EN) {
> > + /* To prevent disconnect when the source is fast role 
> > swap is capable. */
> > + threshold = 3500;
> > + } else if (mode == TYPEC_PWR_MODE_PD) {
> > + if (pps_active)
> > + threshold = (95 * requested_vbus_voltage_mv / 
> > 100) - 850;
> > + else
> > + threshold = (95 * requested_vbus_voltage_mv / 
> > 100) - 1250;
> > + } else {
> > + /* 3.5V for non-pd sink */
> > + threshold = 3500;
> > + }
> > + } else {
> > + /* 4V for source */
> > + threshold = 4000;
> > + }
> > +
> > + threshold = threshold / TCPC_VBUS_SINK_DISCONNECT_THRESH_LSB;
> > +
> > + if (threshold > TCPC_VBUS_SINK_DISCONNECT_THRESH_MAX) {
> > + dev_err(chip->dev, "VBUS_SINK_DISCONNECT_THRESH out of 
> > range");
> > + return -EINVAL;
> > + }
> > +
> > +write_thresh:
> > + return max_tcpci_write16(chip, TCPC_VBUS_SINK_DISCONNECT_THRESH, 
> > threshold);
>
> So couldn't tcpci.c write that register? This callback would then just
> calculate the value. I just want to avoid boilerplate.
Done !
>
> The threshold has type u32, but you still pass it to
> max_tcpci_write16(). Is that on purpose (doesn't the compiler
> complain)?
I didnt see any warnings ! I don't know why.
It wouldn't overflow though as TCPC_VBUS_SINK_DISCONNECT_THRESH_MAX
has a max value of 0x3ff. Have corrected it though and moved the code
to tcpci.c in v8.

Thanks,
Badhri

>
> thanks,
>
> --
> heikki


Re: [GIT PULL] percpu fix for v5.9-rc6

2020-09-18 Thread Arvind Sankar
On Fri, Sep 18, 2020 at 06:28:30PM -0700, Linus Torvalds wrote:
> On Fri, Sep 18, 2020 at 3:40 PM Arvind Sankar  wrote:
> >
> > Ouch, offsetof() and sizeof() will give different results in the
> > presence of alignment padding.
> 
> Indeed. But from an allocation standpoint, the offsetof()+size is I
> think the correct size. The padding at the end makes very little sense
> for something like "struct_size()".

I just meant that my suggestion doesn't actually work to assert that you
passed in the flexible array member to struct_size(), even outside of
any future warnings on sizeof().

And that it's another source of subtle bugs, although you'll err towards
over-allocating memory rather than under-allocating by using sizeof().

Is it ever necessary to allocate _at least_ sizeof() even if
offsetof()+size is smaller?

> 
> Padding at the end is required for sizeof() for a very simple reason:
> arrays.  The "sizeof()" needs to be aligned to the alignment of the
> entry, because if it isn't, then the standard C array traversal
> doesn't work.
> 
> But you cannot sanely have arrays of these structures of variable size
> entries either - even if standard C cheerfully allows you to declare
> them (again: it will not behave like a variable sized array, it will
> behave like a zero-sized one).

I think you can't do this in standard C. It's a GCC extension.

A structure containing a flexible array member, or a union
containing such a structure (possibly recursively), may not be a
member of a structure or an element of an array. (However, these
uses are permitted by GCC as extensions.)



[PATCH -next v2] mips: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 arch/mips/cavium-octeon/oct_ilm.c | 16 +++-
 arch/mips/kernel/segment.c| 14 ++
 arch/mips/ralink/bootrom.c| 14 ++
 3 files changed, 7 insertions(+), 37 deletions(-)

diff --git a/arch/mips/cavium-octeon/oct_ilm.c 
b/arch/mips/cavium-octeon/oct_ilm.c
index 99e27155b..10ed6ebdb 100644
--- a/arch/mips/cavium-octeon/oct_ilm.c
+++ b/arch/mips/cavium-octeon/oct_ilm.c
@@ -28,7 +28,7 @@ struct latency_info {
 static struct latency_info li;
 static struct dentry *dir;
 
-static int show_latency(struct seq_file *m, void *v)
+static int oct_ilm_show(struct seq_file *m, void *v)
 {
u64 cpuclk, avg, max, min;
struct latency_info curr_li = li;
@@ -44,17 +44,7 @@ static int show_latency(struct seq_file *m, void *v)
return 0;
 }
 
-static int oct_ilm_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, show_latency, NULL);
-}
-
-static const struct file_operations oct_ilm_ops = {
-   .open = oct_ilm_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(oct_ilm);
 
 static int reset_statistics(void *data, u64 value)
 {
@@ -67,7 +57,7 @@ DEFINE_SIMPLE_ATTRIBUTE(reset_statistics_ops, NULL, 
reset_statistics, "%llu\n");
 static void init_debugfs(void)
 {
dir = debugfs_create_dir("oct_ilm", 0);
-   debugfs_create_file("statistics", 0222, dir, NULL, _ilm_ops);
+   debugfs_create_file("statistics", 0222, dir, NULL, _ilm_fops);
debugfs_create_file("reset", 0222, dir, NULL, _statistics_ops);
 }
 
diff --git a/arch/mips/kernel/segment.c b/arch/mips/kernel/segment.c
index 0a9bd7b09..778487bf3 100644
--- a/arch/mips/kernel/segment.c
+++ b/arch/mips/kernel/segment.c
@@ -46,7 +46,7 @@ static void build_segment_config(char *str, unsigned int cfg)
((cfg & MIPS_SEGCFG_EU) >> MIPS_SEGCFG_EU_SHIFT));
 }
 
-static int show_segments(struct seq_file *m, void *v)
+static int segments_show(struct seq_file *m, void *v)
 {
unsigned int segcfg;
char str[42];
@@ -81,17 +81,7 @@ static int show_segments(struct seq_file *m, void *v)
return 0;
 }
 
-static int segments_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, show_segments, NULL);
-}
-
-static const struct file_operations segments_fops = {
-   .open   = segments_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(segments);
 
 static int __init segments_info(void)
 {
diff --git a/arch/mips/ralink/bootrom.c b/arch/mips/ralink/bootrom.c
index 94ca8379b..c57fd38fd 100644
--- a/arch/mips/ralink/bootrom.c
+++ b/arch/mips/ralink/bootrom.c
@@ -19,21 +19,11 @@ static int bootrom_show(struct seq_file *s, void *unused)
return 0;
 }
 
-static int bootrom_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, bootrom_show, NULL);
-}
-
-static const struct file_operations bootrom_file_ops = {
-   .open   = bootrom_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(bootrom);
 
 static int __init bootrom_setup(void)
 {
-   debugfs_create_file("bootrom", 0444, NULL, NULL, _file_ops);
+   debugfs_create_file("bootrom", 0444, NULL, NULL, _fops);
return 0;
 }
 
-- 
2.23.0



[PATCH -next v2] sh: mm: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 arch/sh/mm/asids-debugfs.c | 15 ++-
 arch/sh/mm/cache-debugfs.c | 15 ++-
 arch/sh/mm/pmb.c   | 15 ++-
 3 files changed, 6 insertions(+), 39 deletions(-)

diff --git a/arch/sh/mm/asids-debugfs.c b/arch/sh/mm/asids-debugfs.c
index 4c1ca197e..d16d6f5ec 100644
--- a/arch/sh/mm/asids-debugfs.c
+++ b/arch/sh/mm/asids-debugfs.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 
-static int asids_seq_show(struct seq_file *file, void *iter)
+static int asids_debugfs_show(struct seq_file *file, void *iter)
 {
struct task_struct *p;
 
@@ -48,18 +48,7 @@ static int asids_seq_show(struct seq_file *file, void *iter)
return 0;
 }
 
-static int asids_debugfs_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, asids_seq_show, inode->i_private);
-}
-
-static const struct file_operations asids_debugfs_fops = {
-   .owner  = THIS_MODULE,
-   .open   = asids_debugfs_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(asids_debugfs);
 
 static int __init asids_debugfs_init(void)
 {
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
index 17d780794..b0f185169 100644
--- a/arch/sh/mm/cache-debugfs.c
+++ b/arch/sh/mm/cache-debugfs.c
@@ -22,7 +22,7 @@ enum cache_type {
CACHE_TYPE_UNIFIED,
 };
 
-static int cache_seq_show(struct seq_file *file, void *iter)
+static int cache_debugfs_show(struct seq_file *file, void *iter)
 {
unsigned int cache_type = (unsigned int)file->private;
struct cache_info *cache;
@@ -94,18 +94,7 @@ static int cache_seq_show(struct seq_file *file, void *iter)
return 0;
 }
 
-static int cache_debugfs_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, cache_seq_show, inode->i_private);
-}
-
-static const struct file_operations cache_debugfs_fops = {
-   .owner  = THIS_MODULE,
-   .open   = cache_debugfs_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(cache_debugfs);
 
 static int __init cache_debugfs_init(void)
 {
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index b20aba6e1..68eb7cc6e 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -812,7 +812,7 @@ bool __in_29bit_mode(void)
 return (__raw_readl(PMB_PASCR) & PASCR_SE) == 0;
 }
 
-static int pmb_seq_show(struct seq_file *file, void *iter)
+static int pmb_debugfs_show(struct seq_file *file, void *iter)
 {
int i;
 
@@ -846,18 +846,7 @@ static int pmb_seq_show(struct seq_file *file, void *iter)
return 0;
 }
 
-static int pmb_debugfs_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, pmb_seq_show, NULL);
-}
-
-static const struct file_operations pmb_debugfs_fops = {
-   .owner  = THIS_MODULE,
-   .open   = pmb_debugfs_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(pmb_debugfs);
 
 static int __init pmb_debugfs_init(void)
 {
-- 
2.23.0



[PATCH -next v2] usb: gadget: lpc32xx_udc: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/usb/gadget/udc/lpc32xx_udc.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c 
b/drivers/usb/gadget/udc/lpc32xx_udc.c
index e8a4637a9..3f1c62adc 100644
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -495,7 +495,7 @@ static void proc_ep_show(struct seq_file *s, struct 
lpc32xx_ep *ep)
}
 }
 
-static int proc_udc_show(struct seq_file *s, void *unused)
+static int udc_show(struct seq_file *s, void *unused)
 {
struct lpc32xx_udc *udc = s->private;
struct lpc32xx_ep *ep;
@@ -524,22 +524,11 @@ static int proc_udc_show(struct seq_file *s, void *unused)
return 0;
 }
 
-static int proc_udc_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, proc_udc_show, PDE_DATA(inode));
-}
-
-static const struct file_operations proc_ops = {
-   .owner  = THIS_MODULE,
-   .open   = proc_udc_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(udc);
 
 static void create_debug_file(struct lpc32xx_udc *udc)
 {
-   udc->pde = debugfs_create_file(debug_filename, 0, NULL, udc, _ops);
+   udc->pde = debugfs_create_file(debug_filename, 0, NULL, udc, _fops);
 }
 
 static void remove_debug_file(struct lpc32xx_udc *udc)
-- 
2.23.0



[PATCH -next v2] x86/xen: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 arch/x86/xen/p2m.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index be4151f42..3301875dd 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -795,17 +795,7 @@ static int p2m_dump_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int p2m_dump_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, p2m_dump_show, NULL);
-}
-
-static const struct file_operations p2m_dump_fops = {
-   .open   = p2m_dump_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(p2m_dump);
 
 static struct dentry *d_mmu_debug;
 
-- 
2.23.0



[PATCH -next v2] scsi: qla2xxx: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/scsi/qla2xxx/qla_dfs.c | 68 --
 1 file changed, 8 insertions(+), 60 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index e62b21152..9e49b47f6 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -37,20 +37,7 @@ qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused)
return 0;
 }
 
-static int
-qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file)
-{
-   scsi_qla_host_t *vha = inode->i_private;
-
-   return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
-}
-
-static const struct file_operations dfs_tgt_sess_ops = {
-   .open   = qla2x00_dfs_tgt_sess_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(qla2x00_dfs_tgt_sess);
 
 static int
 qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
@@ -106,20 +93,7 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void 
*unused)
return 0;
 }
 
-static int
-qla2x00_dfs_tgt_port_database_open(struct inode *inode, struct file *file)
-{
-   scsi_qla_host_t *vha = inode->i_private;
-
-   return single_open(file, qla2x00_dfs_tgt_port_database_show, vha);
-}
-
-static const struct file_operations dfs_tgt_port_database_ops = {
-   .open   = qla2x00_dfs_tgt_port_database_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(qla2x00_dfs_tgt_port_database);
 
 static int
 qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)
@@ -154,20 +128,7 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void 
*unused)
return 0;
 }
 
-static int
-qla_dfs_fw_resource_cnt_open(struct inode *inode, struct file *file)
-{
-   struct scsi_qla_host *vha = inode->i_private;
-
-   return single_open(file, qla_dfs_fw_resource_cnt_show, vha);
-}
-
-static const struct file_operations dfs_fw_resource_cnt_ops = {
-   .open   = qla_dfs_fw_resource_cnt_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(qla_dfs_fw_resource_cnt);
 
 static int
 qla_dfs_tgt_counters_show(struct seq_file *s, void *unused)
@@ -244,20 +205,7 @@ qla_dfs_tgt_counters_show(struct seq_file *s, void *unused)
return 0;
 }
 
-static int
-qla_dfs_tgt_counters_open(struct inode *inode, struct file *file)
-{
-   struct scsi_qla_host *vha = inode->i_private;
-
-   return single_open(file, qla_dfs_tgt_counters_show, vha);
-}
-
-static const struct file_operations dfs_tgt_counters_ops = {
-   .open   = qla_dfs_tgt_counters_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(qla_dfs_tgt_counters);
 
 static int
 qla2x00_dfs_fce_show(struct seq_file *s, void *unused)
@@ -459,19 +407,19 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha)
 
 create_nodes:
ha->dfs_fw_resource_cnt = debugfs_create_file("fw_resource_count",
-   S_IRUSR, ha->dfs_dir, vha, _fw_resource_cnt_ops);
+   S_IRUSR, ha->dfs_dir, vha, _dfs_fw_resource_cnt_fops);
 
ha->dfs_tgt_counters = debugfs_create_file("tgt_counters", S_IRUSR,
-   ha->dfs_dir, vha, _tgt_counters_ops);
+   ha->dfs_dir, vha, _dfs_tgt_counters_fops);
 
ha->tgt.dfs_tgt_port_database = debugfs_create_file("tgt_port_database",
-   S_IRUSR,  ha->dfs_dir, vha, _tgt_port_database_ops);
+   S_IRUSR,  ha->dfs_dir, vha, _dfs_tgt_port_database_fops);
 
ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, vha,
_fce_ops);
 
ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
-   S_IRUSR, ha->dfs_dir, vha, _tgt_sess_ops);
+   S_IRUSR, ha->dfs_dir, vha, _dfs_tgt_sess_fops);
 
if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha))
ha->tgt.dfs_naqp = debugfs_create_file("naqp",
-- 
2.23.0



[PATCH -next v2] soc: ti: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/soc/ti/knav_dma.c| 16 +++-
 drivers/soc/ti/knav_qmss_queue.c | 14 ++
 2 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/soc/ti/knav_dma.c b/drivers/soc/ti/knav_dma.c
index 6285cd8ef..8c863ecb1 100644
--- a/drivers/soc/ti/knav_dma.c
+++ b/drivers/soc/ti/knav_dma.c
@@ -355,7 +355,7 @@ static void dma_debug_show_devices(struct seq_file *s,
}
 }
 
-static int dma_debug_show(struct seq_file *s, void *v)
+static int knav_dma_debug_show(struct seq_file *s, void *v)
 {
struct knav_dma_device *dma;
 
@@ -370,17 +370,7 @@ static int dma_debug_show(struct seq_file *s, void *v)
return 0;
 }
 
-static int knav_dma_debug_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, dma_debug_show, NULL);
-}
-
-static const struct file_operations knav_dma_debug_ops = {
-   .open   = knav_dma_debug_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(knav_dma_debug);
 
 static int of_channel_match_helper(struct device_node *np, const char *name,
const char **dma_instance)
@@ -778,7 +768,7 @@ static int knav_dma_probe(struct platform_device *pdev)
}
 
debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
-   _dma_debug_ops);
+   _dma_debug_fops);
 
device_ready = true;
return ret;
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index aa071d96e..a460f201b 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -478,17 +478,7 @@ static int knav_queue_debug_show(struct seq_file *s, void 
*v)
return 0;
 }
 
-static int knav_queue_debug_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, knav_queue_debug_show, NULL);
-}
-
-static const struct file_operations knav_queue_debug_ops = {
-   .open   = knav_queue_debug_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(knav_queue_debug);
 
 static inline int knav_queue_pdsp_wait(u32 * __iomem addr, unsigned timeout,
u32 flags)
@@ -1878,7 +1868,7 @@ static int knav_queue_probe(struct platform_device *pdev)
}
 
debugfs_create_file("qmss", S_IFREG | S_IRUGO, NULL, NULL,
-   _queue_debug_ops);
+   _queue_debug_fops);
device_ready = true;
return 0;
 
-- 
2.23.0



[PATCH -next v2] drivers: visorbus: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/visorbus/visorbus_main.c | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c
index 152fd29f0..b5417f1e7 100644
--- a/drivers/visorbus/visorbus_main.c
+++ b/drivers/visorbus/visorbus_main.c
@@ -471,18 +471,7 @@ static int bus_info_debugfs_show(struct seq_file *seq, 
void *v)
return 0;
 }
 
-static int bus_info_debugfs_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, bus_info_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations bus_info_debugfs_fops = {
-   .owner = THIS_MODULE,
-   .open = bus_info_debugfs_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(bus_info_debugfs);
 
 static void dev_periodic_work(struct timer_list *t)
 {
-- 
2.23.0



[PATCH -next v2] nbd: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/block/nbd.c | 28 
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 15eed210f..ab1242a34 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1543,17 +1543,7 @@ static int nbd_dbg_tasks_show(struct seq_file *s, void 
*unused)
return 0;
 }
 
-static int nbd_dbg_tasks_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, nbd_dbg_tasks_show, inode->i_private);
-}
-
-static const struct file_operations nbd_dbg_tasks_ops = {
-   .open = nbd_dbg_tasks_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(nbd_dbg_tasks);
 
 static int nbd_dbg_flags_show(struct seq_file *s, void *unused)
 {
@@ -1578,17 +1568,7 @@ static int nbd_dbg_flags_show(struct seq_file *s, void 
*unused)
return 0;
 }
 
-static int nbd_dbg_flags_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, nbd_dbg_flags_show, inode->i_private);
-}
-
-static const struct file_operations nbd_dbg_flags_ops = {
-   .open = nbd_dbg_flags_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(nbd_dbg_flags);
 
 static int nbd_dev_dbg_init(struct nbd_device *nbd)
 {
@@ -1606,11 +1586,11 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd)
}
config->dbg_dir = dir;
 
-   debugfs_create_file("tasks", 0444, dir, nbd, _dbg_tasks_ops);
+   debugfs_create_file("tasks", 0444, dir, nbd, _dbg_tasks_fops);
debugfs_create_u64("size_bytes", 0444, dir, >bytesize);
debugfs_create_u32("timeout", 0444, dir, >tag_set.timeout);
debugfs_create_u64("blocksize", 0444, dir, >blksize);
-   debugfs_create_file("flags", 0444, dir, nbd, _dbg_flags_ops);
+   debugfs_create_file("flags", 0444, dir, nbd, _dbg_flags_fops);
 
return 0;
 }
-- 
2.23.0



[PATCH -next v2] arm: dump: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 arch/arm/mm/ptdump_debugfs.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/arch/arm/mm/ptdump_debugfs.c b/arch/arm/mm/ptdump_debugfs.c
index 598b63661..6a62bceab 100644
--- a/arch/arm/mm/ptdump_debugfs.c
+++ b/arch/arm/mm/ptdump_debugfs.c
@@ -12,17 +12,7 @@ static int ptdump_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int ptdump_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, ptdump_show, inode->i_private);
-}
-
-static const struct file_operations ptdump_fops = {
-   .open   = ptdump_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(ptdump);
 
 void ptdump_debugfs_register(struct ptdump_info *info, const char *name)
 {
-- 
2.23.0



[PATCH -next v2] bus: mvebu-mbus: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/bus/mvebu-mbus.c | 24 ++--
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index 2519ceede..4439612b3 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -470,17 +470,7 @@ static int mvebu_sdram_debug_show(struct seq_file *seq, 
void *v)
return mbus->soc->show_cpu_target(mbus, seq, v);
 }
 
-static int mvebu_sdram_debug_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, mvebu_sdram_debug_show, inode->i_private);
-}
-
-static const struct file_operations mvebu_sdram_debug_fops = {
-   .open = mvebu_sdram_debug_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(mvebu_sdram_debug);
 
 static int mvebu_devs_debug_show(struct seq_file *seq, void *v)
 {
@@ -520,17 +510,7 @@ static int mvebu_devs_debug_show(struct seq_file *seq, 
void *v)
return 0;
 }
 
-static int mvebu_devs_debug_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, mvebu_devs_debug_show, inode->i_private);
-}
-
-static const struct file_operations mvebu_devs_debug_fops = {
-   .open = mvebu_devs_debug_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(mvebu_devs_debug);
 
 /*
  * SoC-specific functions and definitions
-- 
2.23.0



[PATCH -next v2] block: aoe: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/block/aoe/aoeblk.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 5ca7216e9..3502a8325 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -110,7 +110,7 @@ static ssize_t aoedisk_show_payload(struct device *dev,
return snprintf(page, PAGE_SIZE, "%lu\n", d->maxbcnt);
 }
 
-static int aoedisk_debugfs_show(struct seq_file *s, void *ignored)
+static int aoe_debugfs_show(struct seq_file *s, void *ignored)
 {
struct aoedev *d;
struct aoetgt **t, **te;
@@ -154,10 +154,7 @@ static int aoedisk_debugfs_show(struct seq_file *s, void 
*ignored)
return 0;
 }
 
-static int aoe_debugfs_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, aoedisk_debugfs_show, inode->i_private);
-}
+DEFINE_SHOW_ATTRIBUTE(aoe_debugfs);
 
 static DEVICE_ATTR(state, 0444, aoedisk_show_state, NULL);
 static DEVICE_ATTR(mac, 0444, aoedisk_show_mac, NULL);
@@ -186,13 +183,6 @@ static const struct attribute_group *aoe_attr_groups[] = {
NULL,
 };
 
-static const struct file_operations aoe_debugfs_fops = {
-   .open = aoe_debugfs_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
-
 static void
 aoedisk_add_debugfs(struct aoedev *d)
 {
-- 
2.23.0



[PATCH -next v2] drm/msm/dpu: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c | 15 +-
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 29 ++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c  | 15 ++
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 17 ++--
 4 files changed, 8 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
index f1bc6a1af..84ea09d96 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
@@ -288,19 +288,6 @@ static void dpu_disable_all_irqs(struct dpu_kms *dpu_kms)
 }
 
 #ifdef CONFIG_DEBUG_FS
-#define DEFINE_DPU_DEBUGFS_SEQ_FOPS(__prefix)  \
-static int __prefix ## _open(struct inode *inode, struct file *file)   \
-{  \
-   return single_open(file, __prefix ## _show, inode->i_private);  \
-}  \
-static const struct file_operations __prefix ## _fops = {  \
-   .owner = THIS_MODULE,   \
-   .open = __prefix ## _open,  \
-   .release = single_release,  \
-   .read = seq_read,   \
-   .llseek = seq_lseek,\
-}
-
 static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v)
 {
struct dpu_irq *irq_obj = s->private;
@@ -328,7 +315,7 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, 
void *v)
return 0;
 }
 
-DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_core_irq);
+DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_core_irq);
 
 void dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,
struct dentry *parent)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index 6169148b3..f56414a06 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -1177,23 +1177,7 @@ static int _dpu_debugfs_status_show(struct seq_file *s, 
void *data)
return 0;
 }
 
-static int _dpu_debugfs_status_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, _dpu_debugfs_status_show, inode->i_private);
-}
-
-#define DEFINE_DPU_DEBUGFS_SEQ_FOPS(__prefix)  \
-static int __prefix ## _open(struct inode *inode, struct file *file)   \
-{  \
-   return single_open(file, __prefix ## _show, inode->i_private);  \
-}  \
-static const struct file_operations __prefix ## _fops = {  \
-   .owner = THIS_MODULE,   \
-   .open = __prefix ## _open,  \
-   .release = single_release,  \
-   .read = seq_read,   \
-   .llseek = seq_lseek,\
-}
+DEFINE_SHOW_ATTRIBUTE(_dpu_debugfs_status);
 
 static int dpu_crtc_debugfs_state_show(struct seq_file *s, void *v)
 {
@@ -1210,25 +1194,18 @@ static int dpu_crtc_debugfs_state_show(struct seq_file 
*s, void *v)
 
return 0;
 }
-DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_crtc_debugfs_state);
+DEFINE_SHOW_ATTRIBUTE(dpu_crtc_debugfs_state);
 
 static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
 {
struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
 
-   static const struct file_operations debugfs_status_fops = {
-   .open = _dpu_debugfs_status_open,
-   .read = seq_read,
-   .llseek =   seq_lseek,
-   .release =  single_release,
-   };
-
dpu_crtc->debugfs_root = debugfs_create_dir(dpu_crtc->name,
crtc->dev->primary->debugfs_root);
 
debugfs_create_file("status", 0400,
dpu_crtc->debugfs_root,
-   dpu_crtc, _status_fops);
+   dpu_crtc, &_dpu_debugfs_status_fops);
debugfs_create_file("state", 0600,
dpu_crtc->debugfs_root,
_crtc->base,
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index bd6def436..da192e275 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -1880,24 +1880,13 @@ static int _dpu_encoder_status_show(struct seq_file *s, 
void *data)
return 0;
 }
 
-static int _dpu_encoder_debugfs_status_open(struct inode 

[PATCH -next v2] scsi: snic: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/scsi/snic/snic_debugfs.c | 20 +---
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c
index 2b3493655..a142e17aa 100644
--- a/drivers/scsi/snic/snic_debugfs.c
+++ b/drivers/scsi/snic/snic_debugfs.c
@@ -334,25 +334,7 @@ snic_stats_show(struct seq_file *sfp, void *data)
return 0;
 }
 
-/*
- * snic_stats_open - Open the stats file for specific host
- *
- * Description:
- * This routine opens a debugfs file stats of specific host
- */
-static int
-snic_stats_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, snic_stats_show, inode->i_private);
-}
-
-static const struct file_operations snic_stats_fops = {
-   .owner  = THIS_MODULE,
-   .open   = snic_stats_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(snic_stats);
 
 static const struct file_operations snic_reset_stats_fops = {
.owner = THIS_MODULE,
-- 
2.23.0



[PATCH -next v2] sh: intc: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/sh/intc/virq-debugfs.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/sh/intc/virq-debugfs.c b/drivers/sh/intc/virq-debugfs.c
index 9e62ba931..939915a07 100644
--- a/drivers/sh/intc/virq-debugfs.c
+++ b/drivers/sh/intc/virq-debugfs.c
@@ -16,7 +16,7 @@
 #include 
 #include "internals.h"
 
-static int intc_irq_xlate_debug(struct seq_file *m, void *priv)
+static int intc_irq_xlate_show(struct seq_file *m, void *priv)
 {
int i;
 
@@ -37,17 +37,7 @@ static int intc_irq_xlate_debug(struct seq_file *m, void 
*priv)
return 0;
 }
 
-static int intc_irq_xlate_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, intc_irq_xlate_debug, inode->i_private);
-}
-
-static const struct file_operations intc_irq_xlate_fops = {
-   .open = intc_irq_xlate_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(intc_irq_xlate);
 
 static int __init intc_irq_xlate_init(void)
 {
-- 
2.23.0



[PATCH -next v2] c6x: pll: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 arch/c6x/platforms/pll.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/arch/c6x/platforms/pll.c b/arch/c6x/platforms/pll.c
index 6fdf20d64..366c9fe6a 100644
--- a/arch/c6x/platforms/pll.c
+++ b/arch/c6x/platforms/pll.c
@@ -417,22 +417,12 @@ static int c6x_ck_show(struct seq_file *m, void *v)
return 0;
 }
 
-static int c6x_ck_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, c6x_ck_show, NULL);
-}
-
-static const struct file_operations c6x_ck_operations = {
-   .open   = c6x_ck_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(c6x_ck);
 
 static int __init c6x_clk_debugfs_init(void)
 {
debugfs_create_file("c6x_clocks", S_IFREG | S_IRUGO, NULL, NULL,
-   _ck_operations);
+   _ck_fops);
 
return 0;
 }
-- 
2.23.0



[PATCH -next v2] pktcdvd: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/block/pktcdvd.c | 19 ---
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 17f2e6ff1..a40c397c7 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -452,23 +452,12 @@ static void pkt_sysfs_cleanup(void)
 
  ***/
 
-static int pkt_debugfs_seq_show(struct seq_file *m, void *p)
+static int pkt_debugfs_show(struct seq_file *m, void *p)
 {
return pkt_seq_show(m, p);
 }
 
-static int pkt_debugfs_fops_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, pkt_debugfs_seq_show, inode->i_private);
-}
-
-static const struct file_operations debug_fops = {
-   .open   = pkt_debugfs_fops_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-   .owner  = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(pkt_debugfs);
 
 static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
 {
@@ -478,8 +467,8 @@ static void pkt_debugfs_dev_new(struct pktcdvd_device *pd)
if (!pd->dfs_d_root)
return;
 
-   pd->dfs_f_info = debugfs_create_file("info", 0444,
-pd->dfs_d_root, pd, _fops);
+   pd->dfs_f_info = debugfs_create_file("info", 0444, pd->dfs_d_root,
+pd, _debugfs_fops);
 }
 
 static void pkt_debugfs_dev_remove(struct pktcdvd_device *pd)
-- 
2.23.0



Re: [PATCH -next] mt7601u: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread miaoqinglang




在 2020/7/16 23:20, Jakub Kicinski 写道:

On Thu, 16 Jul 2020 16:57:49 +0800 Qinglang Miao wrote:

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 


Acked-by: Jakub Kicinski 


Hi Jakub,

I noticed that this patch has been acked by you and not patched into 
linux-next. There's little difference now so resent a new patch against 
linux-next(20200917), and it can be applied to mainline cleanly now.


Thanks.


[PATCH -next v2] mt7601u: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
 .../net/wireless/mediatek/mt7601u/debugfs.c   | 34 ---
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/debugfs.c 
b/drivers/net/wireless/mediatek/mt7601u/debugfs.c
index 300242bce..20669eacb 100644
--- a/drivers/net/wireless/mediatek/mt7601u/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt7601u/debugfs.c
@@ -30,7 +30,7 @@ mt76_reg_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt76_reg_get, mt76_reg_set, 
"0x%08llx\n");
 
 static int
-mt7601u_ampdu_stat_read(struct seq_file *file, void *data)
+mt7601u_ampdu_stat_show(struct seq_file *file, void *data)
 {
struct mt7601u_dev *dev = file->private;
int i, j;
@@ -73,21 +73,10 @@ mt7601u_ampdu_stat_read(struct seq_file *file, void *data)
return 0;
 }
 
-static int
-mt7601u_ampdu_stat_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7601u_ampdu_stat_read, inode->i_private);
-}
-
-static const struct file_operations fops_ampdu_stat = {
-   .open = mt7601u_ampdu_stat_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7601u_ampdu_stat);
 
 static int
-mt7601u_eeprom_param_read(struct seq_file *file, void *data)
+mt7601u_eeprom_param_show(struct seq_file *file, void *data)
 {
struct mt7601u_dev *dev = file->private;
struct mt7601u_rate_power *rp = >ee->power_rate_table;
@@ -131,18 +120,7 @@ mt7601u_eeprom_param_read(struct seq_file *file, void 
*data)
return 0;
 }
 
-static int
-mt7601u_eeprom_param_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7601u_eeprom_param_read, inode->i_private);
-}
-
-static const struct file_operations fops_eeprom_param = {
-   .open = mt7601u_eeprom_param_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7601u_eeprom_param);
 
 void mt7601u_init_debugfs(struct mt7601u_dev *dev)
 {
@@ -157,6 +135,6 @@ void mt7601u_init_debugfs(struct mt7601u_dev *dev)
 
debugfs_create_u32("regidx", 0600, dir, >debugfs_reg);
debugfs_create_file("regval", 0600, dir, dev, _regval);
-   debugfs_create_file("ampdu_stat", 0400, dir, dev, _ampdu_stat);
-   debugfs_create_file("eeprom_param", 0400, dir, dev, _eeprom_param);
+   debugfs_create_file("ampdu_stat", 0400, dir, dev, 
_ampdu_stat_fops);
+   debugfs_create_file("eeprom_param", 0400, dir, dev, 
_eeprom_param_fops);
 }
-- 
2.23.0



Re: [PATCH -next] tty: hvc: fix link error with CONFIG_SERIAL_CORE_CONSOLE=n

2020-09-18 Thread Yang Yingliang



On 2020/9/18 19:17, Greg KH wrote:

On Fri, Sep 18, 2020 at 05:20:30PM +0800, Yang Yingliang wrote:

Fix the link error by selecting SERIAL_CORE_CONSOLE.

aarch64-linux-gnu-ld: drivers/tty/hvc/hvc_dcc.o: in function `dcc_early_write':
hvc_dcc.c:(.text+0x164): undefined reference to `uart_console_write'

Reported-by: Hulk Robot 
Signed-off-by: Yang Yingliang 
---
  drivers/tty/hvc/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/tty/hvc/Kconfig b/drivers/tty/hvc/Kconfig
index d1b27b0522a3..8d60e0ff67b4 100644
--- a/drivers/tty/hvc/Kconfig
+++ b/drivers/tty/hvc/Kconfig
@@ -81,6 +81,7 @@ config HVC_DCC
bool "ARM JTAG DCC console"
depends on ARM || ARM64
select HVC_DRIVER
+   select SERIAL_CORE_CONSOLE
help
  This console uses the JTAG DCC on ARM to create a console under the 
HVC
  driver. This console is used through a JTAG only on ARM. If you don't 
have
--
2.25.1


Same question here, what caused this problem to happen?

Fixes: d1a1af2cdf19 ("hvc: dcc: Add earlycon support")


thanks,

greg k-h
.


Re: [GIT PULL] percpu fix for v5.9-rc6

2020-09-18 Thread Matthew Wilcox
On Fri, Sep 18, 2020 at 06:39:57PM -0400, Arvind Sankar wrote:
> On Fri, Sep 18, 2020 at 02:18:20PM -0700, Linus Torvalds wrote:
> > On Fri, Sep 18, 2020 at 2:00 PM Arvind Sankar  wrote:
> > >
> > > You could just assert that offsetof(typeof(s),flex) == sizeof(s), no?
> > 
> > No, because the whole point is that I want that "sizeof(s)" to *WARN*.
> 
> Ouch, offsetof() and sizeof() will give different results in the
> presence of alignment padding.
> 
> https://godbolt.org/z/rqnxTK

We really should be using offsetof() then.  It's harmless because we're
currently overallocating, not underallocating.  The test case I did was:

struct s {
int count;
char *p[];
};

struct_size(, p, 5); (48 bytes)
struct_size2(, p, 5); (also 48 bytes)

struct_size2 uses offsetof instead of sizeof.

Your case is different because the chars fit in the padding at the end
of the struct.


[PATCH net-next] net: natsemi: Remove set but not used variable

2020-09-18 Thread Zheng Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/natsemi/ns83820.c: In function ns83820_get_link_ksettings:
drivers/net/ethernet/natsemi/ns83820.c:1210:11: warning: variable ‘tanar’ set 
but not used [-Wunused-but-set-variable]

`tanar` is never used, so remove it.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/natsemi/ns83820.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/ns83820.c 
b/drivers/net/ethernet/natsemi/ns83820.c
index 8e24c7acf79b..144feb2d2622 100644
--- a/drivers/net/ethernet/natsemi/ns83820.c
+++ b/drivers/net/ethernet/natsemi/ns83820.c
@@ -1207,7 +1207,7 @@ static int ns83820_get_link_ksettings(struct net_device 
*ndev,
  struct ethtool_link_ksettings *cmd)
 {
struct ns83820 *dev = PRIV(ndev);
-   u32 cfg, tanar, tbicr;
+   u32 cfg, tbicr;
int fullduplex   = 0;
u32 supported;
 
@@ -1226,8 +1226,8 @@ static int ns83820_get_link_ksettings(struct net_device 
*ndev,
 
/* read current configuration */
cfg   = readl(dev->base + CFG) ^ SPDSTS_POLARITY;
-   tanar = readl(dev->base + TANAR);
tbicr = readl(dev->base + TBICR);
+   readl(dev->base + TANAR);
 
fullduplex = (cfg & CFG_DUPSTS) ? 1 : 0;
 
-- 
2.17.1



Re: [PATCH 2/2] vfio/pci: Remove bardirty from vfio_pci_device

2020-09-18 Thread Zenghui Yu

On 2020/9/19 10:11, Alex Williamson wrote:

On Sat, 19 Sep 2020 09:54:00 +0800
Zenghui Yu  wrote:


Hi Alex,

On 2020/9/18 6:07, Alex Williamson wrote:

On Thu, 17 Sep 2020 13:35:37 +0200
Cornelia Huck  wrote:
   

On Thu, 17 Sep 2020 11:31:28 +0800
Zenghui Yu  wrote:
  

It isn't clear what purpose the @bardirty serves. It might be used to avoid
the unnecessary vfio_bar_fixup() invoking on a user-space BAR read, which
is not required when bardirty is unset.

The variable was introduced in commit 89e1f7d4c66d ("vfio: Add PCI device
driver") but never actually used, so it shouldn't be that important. Remove
it.

Signed-off-by: Zenghui Yu 
---
   drivers/vfio/pci/vfio_pci_config.c  | 7 ---
   drivers/vfio/pci/vfio_pci_private.h | 1 -
   2 files changed, 8 deletions(-)


Yes, it seems to have been write-only all the time.


I suspect the intent was that vfio_bar_fixup() could test
vdev->bardirty to avoid doing work if no BARs had been written since
they were last read.  As it is now we regenerate vconfig for all the
BARs every time any offset of any of them are read.  BARs aren't
re-read regularly and config space is not a performance path,


Yes, it seems that Qemu itself emulates all BAR registers and will read
the BAR from the kernel side only at initialization time.


but maybe
we should instead test if we see any regressions from returning without
doing any work in vfio_bar_fixup() if vdev->bardirty is false.  Thanks,


I will test it with the following diff. Please let me know which way do
you prefer.

diff --git a/drivers/vfio/pci/vfio_pci_config.c
b/drivers/vfio/pci/vfio_pci_config.c
index d98843feddce..77c419d536d0 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -515,7 +515,7 @@ static int vfio_basic_config_read(struct
vfio_pci_device *vdev, int pos,
int count, struct perm_bits *perm,
int offset, __le32 *val)
   {
-   if (is_bar(offset)) /* pos == offset for basic config */
+   if (is_bar(offset) && vdev->bardirty) /* pos == offset for basic
config */
  vfio_bar_fixup(vdev);

  count = vfio_default_config_read(vdev, pos, count, perm,
offset, val);



There's only one caller currently, but I'd think it cleaner to put this
in vfio_bar_fixup(), ie. return immediately if !bardirty.  Thanks,


OK, I'll do that in the v2.


Thanks,
Zenghui


[PATCH -next v2] scsi: hisi_sas: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/scsi/hisi_sas/hisi_sas_main.c | 137 ++
 1 file changed, 10 insertions(+), 127 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index afc7ba892..11ad710cb 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -2870,19 +2870,7 @@ static int hisi_sas_debugfs_global_show(struct seq_file 
*s, void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_global_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_global_show,
-  inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_global_fops = {
-   .open = hisi_sas_debugfs_global_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_global);
 
 static int hisi_sas_debugfs_axi_show(struct seq_file *s, void *p)
 {
@@ -2897,19 +2885,7 @@ static int hisi_sas_debugfs_axi_show(struct seq_file *s, 
void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_axi_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_axi_show,
-  inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_axi_fops = {
-   .open = hisi_sas_debugfs_axi_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_axi);
 
 static int hisi_sas_debugfs_ras_show(struct seq_file *s, void *p)
 {
@@ -2924,19 +2900,7 @@ static int hisi_sas_debugfs_ras_show(struct seq_file *s, 
void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_ras_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_ras_show,
-  inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_ras_fops = {
-   .open = hisi_sas_debugfs_ras_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_ras);
 
 static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p)
 {
@@ -2951,18 +2915,7 @@ static int hisi_sas_debugfs_port_show(struct seq_file 
*s, void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_port_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_port_show, inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_port_fops = {
-   .open = hisi_sas_debugfs_port_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_port);
 
 static void hisi_sas_show_row_64(struct seq_file *s, int index,
 int sz, __le64 *ptr)
@@ -3019,18 +2972,7 @@ static int hisi_sas_debugfs_cq_show(struct seq_file *s, 
void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_cq_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_cq_show, inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_cq_fops = {
-   .open = hisi_sas_debugfs_cq_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_cq);
 
 static void hisi_sas_dq_show_slot(struct seq_file *s, int slot, void *dq_ptr)
 {
@@ -3052,18 +2994,7 @@ static int hisi_sas_debugfs_dq_show(struct seq_file *s, 
void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_dq_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_dq_show, inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_dq_fops = {
-   .open = hisi_sas_debugfs_dq_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_dq);
 
 static int hisi_sas_debugfs_iost_show(struct seq_file *s, void *p)
 {
@@ -3080,18 +3011,7 @@ static int hisi_sas_debugfs_iost_show(struct seq_file 
*s, void *p)
return 0;
 }
 
-static int hisi_sas_debugfs_iost_open(struct inode *inode, struct file *filp)
-{
-   return single_open(filp, hisi_sas_debugfs_iost_show, inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_iost_fops = {
-   .open = hisi_sas_debugfs_iost_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};

[PATCH net-next] net: microchip: Remove set but not used variable

2020-09-18 Thread Zheng Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/microchip/lan743x_main.c: In function lan743x_pm_suspend:
drivers/net/ethernet/microchip/lan743x_main.c:3041:6: warning: variable ‘ret’ 
set but not used [-Wunused-but-set-variable]

`ret` is set but not used, so check it's value.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index de93cc6ebc1a..56a1b5928f9a 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3053,7 +3053,7 @@ static int lan743x_pm_suspend(struct device *dev)
/* Host sets PME_En, put D3hot */
ret = pci_prepare_to_sleep(pdev);
 
-   return 0;
+   return ret;
 }
 
 static int lan743x_pm_resume(struct device *dev)
-- 
2.17.1



[PATCH net-next] net: microchip: Remove set but not used variable

2020-09-18 Thread Zheng Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/microchip/lan743x_main.c: In function lan743x_pm_suspend:
drivers/net/ethernet/microchip/lan743x_main.c:3041:6: warning: variable ‘ret’ 
set but not used [-Wunused-but-set-variable]

`ret` is never used, so remove it.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index de93cc6ebc1a..56a1b5928f9a 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -3053,7 +3053,7 @@ static int lan743x_pm_suspend(struct device *dev)
/* Host sets PME_En, put D3hot */
ret = pci_prepare_to_sleep(pdev);
 
-   return 0;
+   return ret;
 }
 
 static int lan743x_pm_resume(struct device *dev)
-- 
2.17.1



Re: bus/mhi/core: Double lock in mhi_device_put() and dev_wake inc/dec

2020-09-18 Thread bbhatt

On 2020-09-17 16:16, Shuah Khan wrote:

While looking at this file for an unrelated issue, I happen to notice
there is a double locking on mhi_cntrl->pm_lock in the mhi_device_put()
when it gets called from mhi_driver_remove()

The other two calls from mhi_driver_probe() don't hold the pm_lock.

In addition, lock holding while dev_wake updates is inconsistent.

dev_wake gets incremented and decremented without holding pm_lock in
mhi_device_get(), mhi_device_get_sync() and mhi_device_put().

Exception are when mhi_device_put() is called from mhi_driver_remove().

The following commit is where all this code is added.

bus: mhi: core: Add support for data transfer
https://github.com/torvalds/linux/commit/189ff97cca53e3fe2d8b38d64105040ce17fc62d

It appears to be real problem. I don't have a way to test this driver,
hence reaching out to let you know about my findings.

thanks,
-- Shuah

Thank you for inputs.

Hemant and I discussed this and we agree that there are inconsistencies 
we need to fix.


We will be uploading a patch to remove the read_lock_bh/read_unlock_bh 
calls from the

mhi_driver_remove().

Thanks,
Bhaumik
'The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum, a Linux Foundation Collaborative Project'


Re: [PATCH -next] scsi: hisi_sas: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread miaoqinglang




在 2020/7/16 20:39, luojiaxing 写道:

Hi, Qinglang

On 2020/7/16 16:47, Qinglang Miao wrote:

From: Yongqiang Liu 

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yongqiang Liu 
---
  drivers/scsi/hisi_sas/hisi_sas_main.c | 137 ++
  1 file changed, 10 insertions(+), 127 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c

index 852d2620e..f50b0c78f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -2870,19 +2870,7 @@ static int hisi_sas_debugfs_global_show(struct 
seq_file *s, void *p)

  return 0;
  }
-static int hisi_sas_debugfs_global_open(struct inode *inode, struct 
file *filp)

-{
-    return single_open(filp, hisi_sas_debugfs_global_show,
-   inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_global_fops = {
-    .open = hisi_sas_debugfs_global_open,
-    .read_iter = seq_read_iter,
-    .llseek = seq_lseek,
-    .release = single_release,
-    .owner = THIS_MODULE,
-};



I saw that your code is different from code in kernel 5.8-rc4, and it 
should be as follow:


static const struct file_operations hisi_sas_debugfs_global_fops = {
     .open = hisi_sas_debugfs_global_open,
     .read = seq_read,
     .llseek = seq_lseek,
     .release = single_release,
     .owner = THIS_MODULE,
};


Plus, if we use this macro directly when we write this code, it really 
makes the code simpler. But if we accept the cleanup now,


we might need to consider evading compilation failures when we merge 
these code back to some older kernel (e.g kernel 4.14 for centOS 7.6).


I think this marco is introduced into kernel 4.16-rc2.


So I don't see much additional benefit to us from this simplification. 
But this marco is quite helpful and I think I will use it somewhere else.


Thanks

Jiaxing

Hi Jiaxing,

I think the 'clean-up' patch means to standardize codes, which can also 
make readers understand codes better.


As for 'merge back', if this situation really exists, evading 
compilation failures should be necessary. But all you need to do is to 
introduce the macro.


I respect your opnion anyhow. But I still resent a new patch based 
against linux-next(20200917) which can be applied to mainline cleanly 
now just in case you need it.


Thanks.




+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_global);
  static int hisi_sas_debugfs_axi_show(struct seq_file *s, void *p)
  {
@@ -2897,19 +2885,7 @@ static int hisi_sas_debugfs_axi_show(struct 
seq_file *s, void *p)

  return 0;
  }
-static int hisi_sas_debugfs_axi_open(struct inode *inode, struct file 
*filp)

-{
-    return single_open(filp, hisi_sas_debugfs_axi_show,
-   inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_axi_fops = {
-    .open = hisi_sas_debugfs_axi_open,
-    .read_iter = seq_read_iter,
-    .llseek = seq_lseek,
-    .release = single_release,
-    .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_axi);
  static int hisi_sas_debugfs_ras_show(struct seq_file *s, void *p)
  {
@@ -2924,19 +2900,7 @@ static int hisi_sas_debugfs_ras_show(struct 
seq_file *s, void *p)

  return 0;
  }
-static int hisi_sas_debugfs_ras_open(struct inode *inode, struct file 
*filp)

-{
-    return single_open(filp, hisi_sas_debugfs_ras_show,
-   inode->i_private);
-}
-
-static const struct file_operations hisi_sas_debugfs_ras_fops = {
-    .open = hisi_sas_debugfs_ras_open,
-    .read_iter = seq_read_iter,
-    .llseek = seq_lseek,
-    .release = single_release,
-    .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_ras);
  static int hisi_sas_debugfs_port_show(struct seq_file *s, void *p)
  {
@@ -2951,18 +2915,7 @@ static int hisi_sas_debugfs_port_show(struct 
seq_file *s, void *p)

  return 0;
  }
-static int hisi_sas_debugfs_port_open(struct inode *inode, struct 
file *filp)

-{
-    return single_open(filp, hisi_sas_debugfs_port_show, 
inode->i_private);

-}
-
-static const struct file_operations hisi_sas_debugfs_port_fops = {
-    .open = hisi_sas_debugfs_port_open,
-    .read_iter = seq_read_iter,
-    .llseek = seq_lseek,
-    .release = single_release,
-    .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_port);
  static void hisi_sas_show_row_64(struct seq_file *s, int index,
   int sz, __le64 *ptr)
@@ -3019,18 +2972,7 @@ static int hisi_sas_debugfs_cq_show(struct 
seq_file *s, void *p)

  return 0;
  }
-static int hisi_sas_debugfs_cq_open(struct inode *inode, struct file 
*filp)

-{
-    return single_open(filp, hisi_sas_debugfs_cq_show, 
inode->i_private);

-}
-
-static const struct file_operations hisi_sas_debugfs_cq_fops = {
-    .open = hisi_sas_debugfs_cq_open,
-    .read_iter = seq_read_iter,
-    .llseek = seq_lseek,
-    .release = single_release,
-    .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(hisi_sas_debugfs_cq);
  static void 

[PATCH net-next] net: micrel: Remove set but not used variable

2020-09-18 Thread Zheng Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/micrel/ksz884x.c: In function rx_proc:
drivers/net/ethernet/micrel/ksz884x.c:4981:6: warning: variable ‘rx_status’ set 
but not used [-Wunused-but-set-variable]

drivers/net/ethernet/micrel/ksz884x.c: In function netdev_get_ethtool_stats:
drivers/net/ethernet/micrel/ksz884x.c:6512:6: warning: variable ‘rc’ set but 
not used [-Wunused-but-set-variable]

these variable is never used, so remove it.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/micrel/ksz884x.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/micrel/ksz884x.c 
b/drivers/net/ethernet/micrel/ksz884x.c
index bb646b65cc95..4fe8810bd06e 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -4978,7 +4978,6 @@ static inline int rx_proc(struct net_device *dev, struct 
ksz_hw* hw,
struct dev_info *hw_priv = priv->adapter;
struct ksz_dma_buf *dma_buf;
struct sk_buff *skb;
-   int rx_status;
 
/* Received length includes 4-byte CRC. */
packet_len = status.rx.frame_len - 4;
@@ -5014,7 +5013,7 @@ static inline int rx_proc(struct net_device *dev, struct 
ksz_hw* hw,
dev->stats.rx_bytes += packet_len;
 
/* Notify upper layer for received packet. */
-   rx_status = netif_rx(skb);
+   netif_rx(skb);
 
return 0;
 }
@@ -6509,7 +6508,6 @@ static void netdev_get_ethtool_stats(struct net_device 
*dev,
int i;
int n;
int p;
-   int rc;
u64 counter[TOTAL_PORT_COUNTER_NUM];
 
mutex_lock(_priv->lock);
@@ -6530,19 +6528,19 @@ static void netdev_get_ethtool_stats(struct net_device 
*dev,
 
if (1 == port->mib_port_cnt && n < SWITCH_PORT_NUM) {
p = n;
-   rc = wait_event_interruptible_timeout(
+   wait_event_interruptible_timeout(
hw_priv->counter[p].counter,
2 == hw_priv->counter[p].read,
HZ * 1);
} else
for (i = 0, p = n; i < port->mib_port_cnt - n; i++, p++) {
if (0 == i) {
-   rc = wait_event_interruptible_timeout(
+   wait_event_interruptible_timeout(
hw_priv->counter[p].counter,
2 == hw_priv->counter[p].read,
HZ * 2);
} else if (hw->port_mib[p].cnt_ptr) {
-   rc = wait_event_interruptible_timeout(
+   wait_event_interruptible_timeout(
hw_priv->counter[p].counter,
2 == hw_priv->counter[p].read,
HZ * 1);
-- 
2.17.1



[PATCH net-next] net: remove unnecessary NULL checking in napi_consume_skb()

2020-09-18 Thread Yunsheng Lin
When budget is non-zero, skb_unref() has already handled the
NULL checking.

When budget is zero, the dev_consume_skb_any() has handled NULL
checking in __dev_kfree_skb_irq(), or dev_kfree_skb() which also
ultimately call skb_unref().

So remove the unnecessary checking in napi_consume_skb().

Signed-off-by: Yunsheng Lin 
---
 net/core/skbuff.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index bfd7483..e077447 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -895,9 +895,6 @@ void __kfree_skb_defer(struct sk_buff *skb)
 
 void napi_consume_skb(struct sk_buff *skb, int budget)
 {
-   if (unlikely(!skb))
-   return;
-
/* Zero budget indicate non-NAPI context called us, like netpoll */
if (unlikely(!budget)) {
dev_consume_skb_any(skb);
-- 
2.8.1



[PATCH net-next] net: mventa: remove unused variable 'dummy' in mvneta_mib_counters_clear()

2020-09-18 Thread Zhang Changzhong
Fixes the following W=1 kernel build warning(s):

drivers/net/ethernet/marvell/mvneta.c:754:6: warning:
 variable 'dummy' set but not used [-Wunused-but-set-variable]
  754 |  u32 dummy;
  |  ^

This variable is not used in function mvneta_mib_counters_clear(), so
remove it to avoid build warning.

Signed-off-by: Zhang Changzhong 
---
 drivers/net/ethernet/marvell/mvneta.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index f75e05e..4694242 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -751,13 +751,12 @@ static void mvneta_txq_inc_put(struct mvneta_tx_queue 
*txq)
 static void mvneta_mib_counters_clear(struct mvneta_port *pp)
 {
int i;
-   u32 dummy;
 
/* Perform dummy reads from MIB counters */
for (i = 0; i < MVNETA_MIB_LATE_COLLISION; i += 4)
-   dummy = mvreg_read(pp, (MVNETA_MIB_COUNTERS_BASE + i));
-   dummy = mvreg_read(pp, MVNETA_RX_DISCARD_FRAME_COUNT);
-   dummy = mvreg_read(pp, MVNETA_OVERRUN_FRAME_COUNT);
+   mvreg_read(pp, (MVNETA_MIB_COUNTERS_BASE + i));
+   mvreg_read(pp, MVNETA_RX_DISCARD_FRAME_COUNT);
+   mvreg_read(pp, MVNETA_OVERRUN_FRAME_COUNT);
 }
 
 /* Get System Network Statistics */
-- 
2.9.5



Re: [PATCH] vt: fix some doc warnings in vt.c

2020-09-18 Thread Xiaofei Tan
Hi Jiri,

On 2020/9/18 15:52, Jiri Slaby wrote:
> On 18. 09. 20, 9:47, Xiaofei Tan wrote:
>> Fix following warnings caused by mismatch bewteen function parameters
>> and comments.
>> drivers/tty/vt/vt.c:3994: warning: Function parameter or member 'vc' not 
>> described in 'con_debug_enter'
>> drivers/tty/vt/vt.c:3994: warning: Excess function parameter 'sw' 
>> description in 'con_debug_enter'
>> drivers/tty/vt/vt.c:4051: warning: Excess function parameter 'sw' 
>> description in 'con_debug_leave'
> 
> It looks like I fixed those in
> https://lore.kernel.org/r/20200818085655.12071-6-jsl...@suse.cz
> too. Could you rebase on the top of tty-next?
> 

Oh, yes, I used a different branch.
Thanks for your remind.


> thanks,
> 

-- 
 thanks
tanxiaofei



Re: [PATCH -next] tty: serial: imx: fix link error with CONFIG_SERIAL_CORE_CONSOLE=n

2020-09-18 Thread Yang Yingliang

Hi,

On 2020/9/18 19:16, Greg KH wrote:

On Fri, Sep 18, 2020 at 05:13:05PM +0800, Yang Yingliang wrote:

Fix the link error by selecting SERIAL_CORE_CONSOLE.

aarch64-linux-gnu-ld: drivers/tty/serial/imx_earlycon.o: in function 
`imx_uart_console_early_write':
imx_earlycon.c:(.text+0x84): undefined reference to `uart_console_write'

Reported-by: Hulk Robot 
Signed-off-by: Yang Yingliang 
---
  drivers/tty/serial/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 9631ccf43378..1044fc387691 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -521,6 +521,7 @@ config SERIAL_IMX_EARLYCON
depends on ARCH_MXC || COMPILE_TEST
depends on OF
select SERIAL_EARLYCON
+   select SERIAL_CORE_CONSOLE
help
  If you have enabled the earlycon on the Freescale IMX
  CPU you can make it the earlycon by answering Y to this option.
--
2.25.1


What caused this build error to start happening?  Any pointers to the
specific commit?


It's start from 699cc4dfd140 ("tty: serial: imx: add imx earlycon 
driver"), the driver


uses the uart_console_write(), but SERIAL_CORE_CONSOLE is not selected, 
so uart_console_write


is not defined, then we get the error.



thanks,

greg k-h
.


Re: [PATCH net-next] net: hns3: remove unnecessary NULL checking in napi_consume_skb()

2020-09-18 Thread Yunsheng Lin
Please ignore this patch, the title is not right, sorry for the noise.

On 2020/9/19 10:16, Yunsheng Lin wrote:
> When budget is non-zero, skb_unref() has already handled the
> NULL checking.
> 
> When budget is zero, the dev_consume_skb_any() has handled NULL
> checking in __dev_kfree_skb_irq(), or dev_kfree_skb() which also
> ultimately call skb_unref().
> 
> So remove the unnecessary checking in napi_consume_skb().
> 
> Signed-off-by: Yunsheng Lin 
> ---
>  net/core/skbuff.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index bfd7483..e077447 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -895,9 +895,6 @@ void __kfree_skb_defer(struct sk_buff *skb)
>  
>  void napi_consume_skb(struct sk_buff *skb, int budget)
>  {
> - if (unlikely(!skb))
> - return;
> -
>   /* Zero budget indicate non-NAPI context called us, like netpoll */
>   if (unlikely(!budget)) {
>   dev_consume_skb_any(skb);
> 


[PATCH net-next] net: hns3: remove unnecessary NULL checking in napi_consume_skb()

2020-09-18 Thread Yunsheng Lin
When budget is non-zero, skb_unref() has already handled the
NULL checking.

When budget is zero, the dev_consume_skb_any() has handled NULL
checking in __dev_kfree_skb_irq(), or dev_kfree_skb() which also
ultimately call skb_unref().

So remove the unnecessary checking in napi_consume_skb().

Signed-off-by: Yunsheng Lin 
---
 net/core/skbuff.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index bfd7483..e077447 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -895,9 +895,6 @@ void __kfree_skb_defer(struct sk_buff *skb)
 
 void napi_consume_skb(struct sk_buff *skb, int budget)
 {
-   if (unlikely(!skb))
-   return;
-
/* Zero budget indicate non-NAPI context called us, like netpoll */
if (unlikely(!budget)) {
dev_consume_skb_any(skb);
-- 
2.8.1



[PATCH -next v2] mfd: ab3100-core: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/mfd/ab3100-core.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index ee71ae04b..4a347d059 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -451,7 +451,7 @@ static irqreturn_t ab3100_irq_handler(int irq, void *data)
 /*
  * Some debugfs entries only exposed if we're using debug
  */
-static int ab3100_registers_print(struct seq_file *s, void *p)
+static int ab3100_registers_show(struct seq_file *s, void *p)
 {
struct ab3100 *ab3100 = s->private;
u8 value;
@@ -466,18 +466,7 @@ static int ab3100_registers_print(struct seq_file *s, void 
*p)
return 0;
 }
 
-static int ab3100_registers_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, ab3100_registers_print, inode->i_private);
-}
-
-static const struct file_operations ab3100_registers_fops = {
-   .open = ab3100_registers_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-   .owner = THIS_MODULE,
-};
+DEFINE_SHOW_ATTRIBUTE(ab3100_registers);
 
 struct ab3100_get_set_reg_priv {
struct ab3100 *ab3100;
-- 
2.23.0



[PATCH -next v2] mfd: ab3100-otp: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/mfd/ab3100-otp.c | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/ab3100-otp.c b/drivers/mfd/ab3100-otp.c
index c393102e3..e5d294805 100644
--- a/drivers/mfd/ab3100-otp.c
+++ b/drivers/mfd/ab3100-otp.c
@@ -96,7 +96,7 @@ static int __init ab3100_otp_read(struct ab3100_otp *otp)
  * the contents of the OTP.
  */
 #ifdef CONFIG_DEBUG_FS
-static int ab3100_show_otp(struct seq_file *s, void *v)
+static int ab3100_otp_show(struct seq_file *s, void *v)
 {
struct ab3100_otp *otp = s->private;
 
@@ -110,23 +110,13 @@ static int ab3100_show_otp(struct seq_file *s, void *v)
return 0;
 }
 
-static int ab3100_otp_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, ab3100_show_otp, inode->i_private);
-}
-
-static const struct file_operations ab3100_otp_operations = {
-   .open   = ab3100_otp_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(ab3100_otp);
 
 static void __init ab3100_otp_init_debugfs(struct device *dev,
   struct ab3100_otp *otp)
 {
otp->debugfs = debugfs_create_file("ab3100_otp", S_IFREG | S_IRUGO,
-  NULL, otp, _otp_operations);
+  NULL, otp, _otp_fops);
 }
 
 static void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp)
-- 
2.23.0



[PATCH -next v2] mfd: tps65010: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/mfd/tps65010.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/tps65010.c b/drivers/mfd/tps65010.c
index 7e7dbee58..f6d6b6c18 100644
--- a/drivers/mfd/tps65010.c
+++ b/drivers/mfd/tps65010.c
@@ -179,7 +179,7 @@ static inline void show_chgconfig(int por, const char 
*label, u8 chgconfig) { }
 
 #ifdef CONFIG_DEBUG_FS
 
-static int dbg_show(struct seq_file *s, void *_)
+static int debug_show(struct seq_file *s, void *_)
 {
struct tps65010 *tps = s->private;
u8  value, v2;
@@ -283,17 +283,7 @@ static int dbg_show(struct seq_file *s, void *_)
return 0;
 }
 
-static int dbg_tps_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, dbg_show, inode->i_private);
-}
-
-static const struct file_operations debug_fops = {
-   .open   = dbg_tps_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(debug);
 
 #defineDEBUG_FOPS  _fops
 
-- 
2.23.0



Re: [PATCH -next] mfd: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread miaoqinglang




在 2020/7/16 21:46, Lee Jones 写道:

On Thu, 16 Jul 2020, Qinglang Miao wrote:


From: Yongqiang Liu 

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yongqiang Liu 
---
  drivers/mfd/ab3100-core.c | 15 ++-
  drivers/mfd/ab3100-otp.c  | 16 +++-
  drivers/mfd/tps65010.c| 14 ++


Can you split this out into different patches please.


Hi Lee,

I've splited this out into three patches.

They are against linux-next(20200917), and can be applied to mainline 
cleanly now.


Thanks.



  3 files changed, 7 insertions(+), 38 deletions(-)




Re: [PATCH -next] rsxx: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread miaoqinglang




在 2020/7/17 10:16, Jens Axboe 写道:

On 7/16/20 7:37 PM, miaoqinglang wrote:


在 2020/7/16 23:45, Jens Axboe 写道:

On 7/16/20 3:04 AM, Qinglang Miao wrote:

From: Liu Shixin 

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

None of these apply against the 5.9 block tree, looks like some
read -> read_iter conversion has happened in another branch that
I'm not privy to.


Hi Jens,

  Sorry I didn't mention it in commit log, but this patch is based
on linux-next where commit <4d4901c6d7> has switched over direct
seq_read method calls to seq_read_iter, this is why there's conflict in
your apply.

  Do you think I should send a new patch based on 5.8rc?


That'll just create a needless conflict. But I don't even know what tree
is carrying the patch that changes it to use seq_read_iter, so hard to
make other suggestions.


Hi Jens,

I resent a new patch against linux-next(20200917), and it can
be applied to mainline cleanly now.

Thanks.


Alternatively, I can hang on to them until the other change hits
mainline, and then queue them up after that.



[PATCH -next v2] rsxx: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
v2: based on linux-next(20200917), and can be applied to
mainline cleanly now.

 drivers/block/rsxx/core.c | 31 ---
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 8799e3bab..7d580965f 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -150,16 +150,6 @@ static int rsxx_attr_stats_show(struct seq_file *m, void 
*p)
return 0;
 }
 
-static int rsxx_attr_stats_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, rsxx_attr_stats_show, inode->i_private);
-}
-
-static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file)
-{
-   return single_open(file, rsxx_attr_pci_regs_show, inode->i_private);
-}
-
 static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
  size_t cnt, loff_t *ppos)
 {
@@ -206,21 +196,8 @@ static const struct file_operations debugfs_cram_fops = {
.write  = rsxx_cram_write,
 };
 
-static const struct file_operations debugfs_stats_fops = {
-   .owner  = THIS_MODULE,
-   .open   = rsxx_attr_stats_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
-
-static const struct file_operations debugfs_pci_regs_fops = {
-   .owner  = THIS_MODULE,
-   .open   = rsxx_attr_pci_regs_open,
-   .read   = seq_read,
-   .llseek = seq_lseek,
-   .release= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(rsxx_attr_stats);
+DEFINE_SHOW_ATTRIBUTE(rsxx_attr_pci_regs);
 
 static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card)
 {
@@ -234,13 +211,13 @@ static void rsxx_debugfs_dev_new(struct rsxx_cardinfo 
*card)
 
debugfs_stats = debugfs_create_file("stats", 0444,
card->debugfs_dir, card,
-   _stats_fops);
+   _attr_stats_fops);
if (IS_ERR_OR_NULL(debugfs_stats))
goto failed_debugfs_stats;
 
debugfs_pci_regs = debugfs_create_file("pci_regs", 0444,
   card->debugfs_dir, card,
-  _pci_regs_fops);
+  _attr_pci_regs_fops);
if (IS_ERR_OR_NULL(debugfs_pci_regs))
goto failed_debugfs_pci_regs;
 
-- 
2.23.0



[PATCH -next v2] mt76: Convert to DEFINE_SHOW_ATTRIBUTE

2020-09-18 Thread Qinglang Miao
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Qinglang Miao 
---
 .../wireless/mediatek/mt76/mt7603/debugfs.c   | 18 +++---
 .../wireless/mediatek/mt76/mt7615/debugfs.c   | 17 ++
 .../wireless/mediatek/mt76/mt76x02_debugfs.c  | 34 ---
 3 files changed, 13 insertions(+), 56 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/debugfs.c 
b/drivers/net/wireless/mediatek/mt76/mt7603/debugfs.c
index 8ce6880b2..f52165dff 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/debugfs.c
@@ -70,7 +70,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt7603_edcca_get,
 mt7603_edcca_set, "%lld\n");
 
 static int
-mt7603_ampdu_stat_read(struct seq_file *file, void *data)
+mt7603_ampdu_stat_show(struct seq_file *file, void *data)
 {
struct mt7603_dev *dev = file->private;
int bound[3], i, range;
@@ -91,18 +91,7 @@ mt7603_ampdu_stat_read(struct seq_file *file, void *data)
return 0;
 }
 
-static int
-mt7603_ampdu_stat_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7603_ampdu_stat_read, inode->i_private);
-}
-
-static const struct file_operations fops_ampdu_stat = {
-   .open = mt7603_ampdu_stat_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7603_ampdu_stat);
 
 void mt7603_init_debugfs(struct mt7603_dev *dev)
 {
@@ -112,7 +101,8 @@ void mt7603_init_debugfs(struct mt7603_dev *dev)
if (!dir)
return;
 
-   debugfs_create_file("ampdu_stat", 0400, dir, dev, _ampdu_stat);
+   debugfs_create_file("ampdu_stat", 0400, dir, dev,
+_ampdu_stat_fops);
debugfs_create_devm_seqfile(dev->mt76.dev, "xmit-queues", dir,
mt76_queues_read);
debugfs_create_file("edcca", 0600, dir, dev, _edcca);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c 
b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
index 88931658a..35f9ed574 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c
@@ -221,7 +221,7 @@ mt7615_ampdu_stat_read_phy(struct mt7615_phy *phy,
 }
 
 static int
-mt7615_ampdu_stat_read(struct seq_file *file, void *data)
+mt7615_ampdu_stat_show(struct seq_file *file, void *data)
 {
struct mt7615_dev *dev = file->private;
 
@@ -235,18 +235,7 @@ mt7615_ampdu_stat_read(struct seq_file *file, void *data)
return 0;
 }
 
-static int
-mt7615_ampdu_stat_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt7615_ampdu_stat_read, inode->i_private);
-}
-
-static const struct file_operations fops_ampdu_stat = {
-   .open = mt7615_ampdu_stat_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(mt7615_ampdu_stat);
 
 static void
 mt7615_radio_read_phy(struct mt7615_phy *phy, struct seq_file *s)
@@ -393,7 +382,7 @@ int mt7615_init_debugfs(struct mt7615_dev *dev)
mt76_queues_read);
debugfs_create_devm_seqfile(dev->mt76.dev, "acq", dir,
mt7615_queues_acq);
-   debugfs_create_file("ampdu_stat", 0400, dir, dev, _ampdu_stat);
+   debugfs_create_file("ampdu_stat", 0400, dir, dev, 
_ampdu_stat_fops);
debugfs_create_file("scs", 0600, dir, dev, _scs);
debugfs_create_file("dbdc", 0600, dir, dev, _dbdc);
debugfs_create_file("fw_debug", 0600, dir, dev, _fw_debug);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c 
b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
index ff448a1ad..c4fe1c436 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
@@ -7,7 +7,7 @@
 #include "mt76x02.h"
 
 static int
-mt76x02_ampdu_stat_read(struct seq_file *file, void *data)
+mt76x02_ampdu_stat_show(struct seq_file *file, void *data)
 {
struct mt76x02_dev *dev = file->private;
int i, j;
@@ -31,11 +31,7 @@ mt76x02_ampdu_stat_read(struct seq_file *file, void *data)
return 0;
 }
 
-static int
-mt76x02_ampdu_stat_open(struct inode *inode, struct file *f)
-{
-   return single_open(f, mt76x02_ampdu_stat_read, inode->i_private);
-}
+DEFINE_SHOW_ATTRIBUTE(mt76x02_ampdu_stat);
 
 static int read_txpower(struct seq_file *file, void *data)
 {
@@ -48,15 +44,8 @@ static int read_txpower(struct seq_file *file, void *data)
return 0;
 }
 
-static const struct file_operations fops_ampdu_stat = {
-   .open = mt76x02_ampdu_stat_open,
-   .read = seq_read,
-   .llseek = seq_lseek,
-   .release = single_release,
-};
-
 static int
-mt76x02_dfs_stat_read(struct seq_file *file, void *data)
+mt76x02_dfs_stat_show(struct seq_file *file, void *data)
 {
struct mt76x02_dev *dev 

Re: [PATCH 2/2] vfio/pci: Remove bardirty from vfio_pci_device

2020-09-18 Thread Alex Williamson
On Sat, 19 Sep 2020 09:54:00 +0800
Zenghui Yu  wrote:

> Hi Alex,
> 
> On 2020/9/18 6:07, Alex Williamson wrote:
> > On Thu, 17 Sep 2020 13:35:37 +0200
> > Cornelia Huck  wrote:
> >   
> >> On Thu, 17 Sep 2020 11:31:28 +0800
> >> Zenghui Yu  wrote:
> >>  
> >>> It isn't clear what purpose the @bardirty serves. It might be used to 
> >>> avoid
> >>> the unnecessary vfio_bar_fixup() invoking on a user-space BAR read, which
> >>> is not required when bardirty is unset.
> >>>
> >>> The variable was introduced in commit 89e1f7d4c66d ("vfio: Add PCI device
> >>> driver") but never actually used, so it shouldn't be that important. 
> >>> Remove
> >>> it.
> >>>
> >>> Signed-off-by: Zenghui Yu 
> >>> ---
> >>>   drivers/vfio/pci/vfio_pci_config.c  | 7 ---
> >>>   drivers/vfio/pci/vfio_pci_private.h | 1 -
> >>>   2 files changed, 8 deletions(-)  
> >>
> >> Yes, it seems to have been write-only all the time.  
> > 
> > I suspect the intent was that vfio_bar_fixup() could test
> > vdev->bardirty to avoid doing work if no BARs had been written since
> > they were last read.  As it is now we regenerate vconfig for all the
> > BARs every time any offset of any of them are read.  BARs aren't
> > re-read regularly and config space is not a performance path,  
> 
> Yes, it seems that Qemu itself emulates all BAR registers and will read
> the BAR from the kernel side only at initialization time.
> 
> > but maybe
> > we should instead test if we see any regressions from returning without
> > doing any work in vfio_bar_fixup() if vdev->bardirty is false.  Thanks,  
> 
> I will test it with the following diff. Please let me know which way do
> you prefer.
> 
> diff --git a/drivers/vfio/pci/vfio_pci_config.c 
> b/drivers/vfio/pci/vfio_pci_config.c
> index d98843feddce..77c419d536d0 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -515,7 +515,7 @@ static int vfio_basic_config_read(struct 
> vfio_pci_device *vdev, int pos,
>int count, struct perm_bits *perm,
>int offset, __le32 *val)
>   {
> -   if (is_bar(offset)) /* pos == offset for basic config */
> +   if (is_bar(offset) && vdev->bardirty) /* pos == offset for basic 
> config */
>  vfio_bar_fixup(vdev);
> 
>  count = vfio_default_config_read(vdev, pos, count, perm, 
> offset, val);


There's only one caller currently, but I'd think it cleaner to put this
in vfio_bar_fixup(), ie. return immediately if !bardirty.  Thanks,

Alex



[PATCH v2] brcmfmac: check return value of driver_for_each_device()

2020-09-18 Thread Zhang Changzhong
Fixes the following W=1 kernel build warning(s):

drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c:1576:6: warning:
 variable 'ret' set but not used [-Wunused-but-set-variable]
  1576 |  int ret;
   |  ^~~

driver_for_each_device() has been declared with __must_check, so the
return value should be checked.

Signed-off-by: Zhang Changzhong 
---
v2:
- cc linux-wireless
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index ac54638..6f67fef 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -1578,6 +1578,9 @@ void brcmf_usb_exit(void)
brcmf_dbg(USB, "Enter\n");
ret = driver_for_each_device(drv, NULL, NULL,
 brcmf_usb_reset_device);
+   if (ret)
+   brcmf_err("failed to reset all usb devices %d\n", ret);
+
usb_deregister(_usbdrvr);
 }
 
-- 
2.9.5



[PATCH net-next] net: marvell: Remove set but not used variable

2020-09-18 Thread Zheng Yongjun
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/ethernet/marvell/pxa168_eth.c: In function pxa168_eth_change_mtu:
drivers/net/ethernet/marvell/pxa168_eth.c:1190:6: warning: variable ‘retval’ 
set but not used [-Wunused-but-set-variable]

`retval` is never used, so remove it.

Signed-off-by: Zheng Yongjun 
---
 drivers/net/ethernet/marvell/pxa168_eth.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c 
b/drivers/net/ethernet/marvell/pxa168_eth.c
index eb8cf60ecf12..0af31ec5dc7d 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1187,11 +1187,10 @@ static int pxa168_eth_stop(struct net_device *dev)
 
 static int pxa168_eth_change_mtu(struct net_device *dev, int mtu)
 {
-   int retval;
struct pxa168_eth_private *pep = netdev_priv(dev);
 
dev->mtu = mtu;
-   retval = set_port_config_ext(pep);
+   set_port_config_ext(pep);
 
if (!netif_running(dev))
return 0;
-- 
2.17.1



[PATCH v1 01/10] bus: mhi: core: Use appropriate names for firmware load functions

2020-09-18 Thread Bhaumik Bhatt
mhi_fw_load_sbl() function is currently used to transfer SBL or EDL
images over BHI (Boot Host Interface). Same goes with mhi_fw_load_amss()
which uses BHIe. However, the contents of these functions do not
indicate support for a specific set of images. Since these can be used
for any image download over BHI or BHIe, rename them based on the
protocol used.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/boot.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
index 24422f5..92b8dd3 100644
--- a/drivers/bus/mhi/core/boot.c
+++ b/drivers/bus/mhi/core/boot.c
@@ -171,7 +171,7 @@ int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, 
bool in_panic)
 }
 EXPORT_SYMBOL_GPL(mhi_download_rddm_img);
 
-static int mhi_fw_load_amss(struct mhi_controller *mhi_cntrl,
+static int mhi_fw_load_bhie(struct mhi_controller *mhi_cntrl,
const struct mhi_buf *mhi_buf)
 {
void __iomem *base = mhi_cntrl->bhie;
@@ -187,7 +187,7 @@ static int mhi_fw_load_amss(struct mhi_controller 
*mhi_cntrl,
}
 
sequence_id = MHI_RANDOM_U32_NONZERO(BHIE_TXVECSTATUS_SEQNUM_BMSK);
-   dev_dbg(dev, "Starting AMSS download via BHIe. Sequence ID:%u\n",
+   dev_dbg(dev, "Starting image download via BHIe. Sequence ID:%u\n",
sequence_id);
mhi_write_reg(mhi_cntrl, base, BHIE_TXVECADDR_HIGH_OFFS,
  upper_32_bits(mhi_buf->dma_addr));
@@ -218,7 +218,7 @@ static int mhi_fw_load_amss(struct mhi_controller 
*mhi_cntrl,
return (!ret) ? -ETIMEDOUT : 0;
 }
 
-static int mhi_fw_load_sbl(struct mhi_controller *mhi_cntrl,
+static int mhi_fw_load_bhi(struct mhi_controller *mhi_cntrl,
   dma_addr_t dma_addr,
   size_t size)
 {
@@ -245,7 +245,7 @@ static int mhi_fw_load_sbl(struct mhi_controller *mhi_cntrl,
}
 
session_id = MHI_RANDOM_U32_NONZERO(BHI_TXDB_SEQNUM_BMSK);
-   dev_dbg(dev, "Starting SBL download via BHI. Session ID:%u\n",
+   dev_dbg(dev, "Starting image download via BHI. Session ID:%u\n",
session_id);
mhi_write_reg(mhi_cntrl, base, BHI_STATUS, 0);
mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_HIGH,
@@ -446,9 +446,9 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
return;
}
 
-   /* Download SBL image */
+   /* Download SBL or EDL image using BHI */
memcpy(buf, firmware->data, size);
-   ret = mhi_fw_load_sbl(mhi_cntrl, dma_addr, size);
+   ret = mhi_fw_load_bhi(mhi_cntrl, dma_addr, size);
mhi_free_coherent(mhi_cntrl, size, buf, dma_addr);
 
if (!mhi_cntrl->fbc_download || ret || mhi_cntrl->ee == MHI_EE_EDL)
@@ -456,7 +456,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 
/* Error or in EDL mode, we're done */
if (ret) {
-   dev_err(dev, "MHI did not load SBL, ret:%d\n", ret);
+   dev_err(dev, "MHI did not load SBL/EDL image, ret:%d\n", ret);
return;
}
 
@@ -506,7 +506,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 
/* Start full firmware image download */
image_info = mhi_cntrl->fbc_image;
-   ret = mhi_fw_load_amss(mhi_cntrl,
+   ret = mhi_fw_load_bhie(mhi_cntrl,
   /* Vector table is the last entry */
   _info->mhi_buf[image_info->entries - 1]);
if (ret)
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 07/10] bus: mhi: core: Move to SYS_ERROR regardless of RDDM capability

2020-09-18 Thread Bhaumik Bhatt
In some cases, the entry of device to RDDM execution environment
can occur after a significant amount of time has elapsed after the
SYS_ERROR state change event has arrived. This can result in scenarios
where users of the MHI bus are unaware of the error state of the
device. Hence, moving the MHI bus to a SYS_ERROR detected state will
prevent further client activity and wait for the RDDM entry.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/main.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index 2cff5dd..1c8e332 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -376,6 +376,7 @@ irqreturn_t mhi_intvec_threaded_handler(int irq_number, 
void *priv)
enum mhi_state state = MHI_STATE_MAX;
enum mhi_pm_state pm_state = 0;
enum mhi_ee_type ee = 0;
+   bool handle_rddm = false;
 
write_lock_irq(_cntrl->pm_lock);
if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) {
@@ -400,6 +401,17 @@ irqreturn_t mhi_intvec_threaded_handler(int irq_number, 
void *priv)
 /* If device supports RDDM don't bother processing SYS error */
if (mhi_cntrl->rddm_image) {
if (mhi_cntrl->ee == MHI_EE_RDDM && mhi_cntrl->ee != ee) {
+   /* prevent clients from queueing any more packets */
+   write_lock_irq(_cntrl->pm_lock);
+   pm_state = mhi_tryset_pm_state(mhi_cntrl,
+  MHI_PM_SYS_ERR_DETECT);
+   if (pm_state == MHI_PM_SYS_ERR_DETECT)
+   handle_rddm = true;
+   write_unlock_irq(_cntrl->pm_lock);
+   }
+
+   if (handle_rddm) {
+   dev_err(dev, "RDDM event occurred!\n");
mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_EE_RDDM);
wake_up_all(_cntrl->state_event);
}
@@ -733,19 +745,15 @@ int mhi_process_ctrl_ev_ring(struct mhi_controller 
*mhi_cntrl,
break;
case MHI_STATE_SYS_ERR:
{
-   enum mhi_pm_state new_state;
-
-   /* skip SYS_ERROR handling if RDDM supported */
-   if (mhi_cntrl->ee == MHI_EE_RDDM ||
-   mhi_cntrl->rddm_image)
-   break;
+   enum mhi_pm_state state = MHI_PM_STATE_MAX;
 
dev_dbg(dev, "System error detected\n");
write_lock_irq(_cntrl->pm_lock);
-   new_state = mhi_tryset_pm_state(mhi_cntrl,
+   if (mhi_cntrl->ee != MHI_EE_RDDM)
+   state = mhi_tryset_pm_state(mhi_cntrl,
MHI_PM_SYS_ERR_DETECT);
write_unlock_irq(_cntrl->pm_lock);
-   if (new_state == MHI_PM_SYS_ERR_DETECT)
+   if (state == MHI_PM_SYS_ERR_DETECT)
mhi_pm_sys_err_handler(mhi_cntrl);
break;
}
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 06/10] bus: mhi: core: Improve shutdown handling after link down detection

2020-09-18 Thread Bhaumik Bhatt
If MHI were to attempt a device shutdown following an assumption
that the device is inaccessible, the host currently moves to a state
where device register accesses are allowed when they should not be.
This would end up allowing accesses to the device register space when
the link is inaccessible and can result in bus errors observed on the
host. Improve shutdown handling to prevent these outcomes and do not
move the MHI PM state to a register accessible state after device is
assumed to be inaccessible.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/init.c |  1 +
 drivers/bus/mhi/core/internal.h |  1 +
 drivers/bus/mhi/core/pm.c   | 18 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 9ae4c19..fa33dde 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -37,6 +37,7 @@ const char * const dev_state_tran_str[DEV_ST_TRANSITION_MAX] 
= {
[DEV_ST_TRANSITION_MISSION_MODE] = "MISSION_MODE",
[DEV_ST_TRANSITION_SYS_ERR] = "SYS_ERR",
[DEV_ST_TRANSITION_DISABLE] = "DISABLE",
+   [DEV_ST_TRANSITION_FATAL] = "FATAL SHUTDOWN",
 };
 
 const char * const mhi_state_str[MHI_STATE_MAX] = {
diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h
index 7989269..f3b9e5a 100644
--- a/drivers/bus/mhi/core/internal.h
+++ b/drivers/bus/mhi/core/internal.h
@@ -388,6 +388,7 @@ enum dev_st_transition {
DEV_ST_TRANSITION_MISSION_MODE,
DEV_ST_TRANSITION_SYS_ERR,
DEV_ST_TRANSITION_DISABLE,
+   DEV_ST_TRANSITION_FATAL,
DEV_ST_TRANSITION_MAX,
 };
 
diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index 3462d82..bce1f62 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -37,9 +37,10 @@
  * M0 -> FW_DL_ERR
  * M0 -> M3_ENTER -> M3 -> M3_EXIT --> M0
  * L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS --> POR
- * L2: SHUTDOWN_PROCESS -> DISABLE
+ * L2: SHUTDOWN_PROCESS -> LD_ERR_FATAL_DETECT
+ * SHUTDOWN_PROCESS -> DISABLE
  * L3: LD_ERR_FATAL_DETECT <--> LD_ERR_FATAL_DETECT
- * LD_ERR_FATAL_DETECT -> SHUTDOWN_PROCESS
+ * LD_ERR_FATAL_DETECT -> DISABLE
  */
 static struct mhi_pm_transitions const dev_state_transitions[] = {
/* L0 States */
@@ -72,7 +73,7 @@ static struct mhi_pm_transitions const 
dev_state_transitions[] = {
{
MHI_PM_M3,
MHI_PM_M3_EXIT | MHI_PM_SYS_ERR_DETECT |
-   MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT
+   MHI_PM_LD_ERR_FATAL_DETECT
},
{
MHI_PM_M3_EXIT,
@@ -103,7 +104,7 @@ static struct mhi_pm_transitions const 
dev_state_transitions[] = {
/* L3 States */
{
MHI_PM_LD_ERR_FATAL_DETECT,
-   MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_SHUTDOWN_PROCESS
+   MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_DISABLE
},
 };
 
@@ -670,6 +671,10 @@ void mhi_pm_st_worker(struct work_struct *work)
mhi_pm_disable_transition
(mhi_cntrl, MHI_PM_SHUTDOWN_PROCESS);
break;
+   case DEV_ST_TRANSITION_FATAL:
+   mhi_pm_disable_transition
+   (mhi_cntrl, MHI_PM_LD_ERR_FATAL_DETECT);
+   break;
default:
break;
}
@@ -1039,6 +1044,7 @@ EXPORT_SYMBOL_GPL(mhi_async_power_up);
 void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful)
 {
enum mhi_pm_state cur_state;
+   enum dev_st_transition next_state = DEV_ST_TRANSITION_DISABLE;
struct device *dev = _cntrl->mhi_dev->dev;
 
/* If it's not a graceful shutdown, force MHI to linkdown state */
@@ -1053,9 +1059,11 @@ void mhi_power_down(struct mhi_controller *mhi_cntrl, 
bool graceful)
dev_dbg(dev, "Failed to move to state: %s from: %s\n",
to_mhi_pm_state_str(MHI_PM_LD_ERR_FATAL_DETECT),
to_mhi_pm_state_str(mhi_cntrl->pm_state));
+   else
+   next_state = DEV_ST_TRANSITION_FATAL;
}
 
-   mhi_queue_state_transition(mhi_cntrl, DEV_ST_TRANSITION_DISABLE);
+   mhi_queue_state_transition(mhi_cntrl, next_state);
 
/* Wait for shutdown to complete */
flush_work(_cntrl->st_worker);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 08/10] bus: mhi: core: Move to an error state on any firmware load failure

2020-09-18 Thread Bhaumik Bhatt
Move MHI to a firmware download error state for a failure to find
the firmware files or to load SBL or EBL image using BHI/BHIe. This
helps detect an error state sooner and shortens the wait for a
synchronous power up timeout.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/boot.c | 43 +--
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/bus/mhi/core/boot.c b/drivers/bus/mhi/core/boot.c
index 92b8dd3..fcc71f2 100644
--- a/drivers/bus/mhi/core/boot.c
+++ b/drivers/bus/mhi/core/boot.c
@@ -425,13 +425,13 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 !mhi_cntrl->seg_len))) {
dev_err(dev,
"No firmware image defined or !sbl_size || !seg_len\n");
-   return;
+   goto error_fw_load;
}
 
ret = request_firmware(, fw_name, dev);
if (ret) {
dev_err(dev, "Error loading firmware: %d\n", ret);
-   return;
+   goto error_fw_load;
}
 
size = (mhi_cntrl->fbc_download) ? mhi_cntrl->sbl_size : firmware->size;
@@ -443,7 +443,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
buf = mhi_alloc_coherent(mhi_cntrl, size, _addr, GFP_KERNEL);
if (!buf) {
release_firmware(firmware);
-   return;
+   goto error_fw_load;
}
 
/* Download SBL or EDL image using BHI */
@@ -451,17 +451,17 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
ret = mhi_fw_load_bhi(mhi_cntrl, dma_addr, size);
mhi_free_coherent(mhi_cntrl, size, buf, dma_addr);
 
-   if (!mhi_cntrl->fbc_download || ret || mhi_cntrl->ee == MHI_EE_EDL)
-   release_firmware(firmware);
-
/* Error or in EDL mode, we're done */
if (ret) {
dev_err(dev, "MHI did not load SBL/EDL image, ret:%d\n", ret);
-   return;
+   release_firmware(firmware);
+   goto error_fw_load;
}
 
-   if (mhi_cntrl->ee == MHI_EE_EDL)
+   if (mhi_cntrl->ee == MHI_EE_EDL) {
+   release_firmware(firmware);
return;
+   }
 
write_lock_irq(_cntrl->pm_lock);
mhi_cntrl->dev_state = MHI_STATE_RESET;
@@ -474,13 +474,17 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
if (mhi_cntrl->fbc_download) {
ret = mhi_alloc_bhie_table(mhi_cntrl, _cntrl->fbc_image,
   firmware->size);
-   if (ret)
-   goto error_alloc_fw_table;
+   if (ret) {
+   release_firmware(firmware);
+   goto error_fw_load;
+   }
 
/* Load the firmware into BHIE vec table */
mhi_firmware_copy(mhi_cntrl, firmware, mhi_cntrl->fbc_image);
}
 
+   release_firmware(firmware);
+
 fw_load_ee_pthru:
/* Transitioning into MHI RESET->READY state */
ret = mhi_ready_state_transition(mhi_cntrl);
@@ -490,7 +494,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 
if (ret) {
dev_err(dev, "MHI did not enter READY state\n");
-   goto error_read;
+   goto error_ready_state;
}
 
/* Wait for the SBL event */
@@ -501,7 +505,7 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
 
if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
dev_err(dev, "MHI did not enter SBL\n");
-   goto error_read;
+   goto error_ready_state;
}
 
/* Start full firmware image download */
@@ -509,17 +513,20 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
ret = mhi_fw_load_bhie(mhi_cntrl,
   /* Vector table is the last entry */
   _info->mhi_buf[image_info->entries - 1]);
-   if (ret)
+   if (ret) {
dev_err(dev, "MHI did not load AMSS, ret:%d\n", ret);
-
-   release_firmware(firmware);
+   goto error_fw_load;
+   }
 
return;
 
-error_read:
+error_ready_state:
mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image);
mhi_cntrl->fbc_image = NULL;
 
-error_alloc_fw_table:
-   release_firmware(firmware);
+error_fw_load:
+   write_lock_irq(_cntrl->pm_lock);
+   mhi_cntrl->pm_state = MHI_PM_FW_DL_ERR;
+   wake_up_all(_cntrl->state_event);
+   write_unlock_irq(_cntrl->pm_lock);
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH] Documentation: filesystems: mount_api: fix headings

2020-09-18 Thread Randy Dunlap
From: Randy Dunlap 

Fix capitalization in two headings, correct one verb, and
demote one heading to a section heading.

Fixes: 791a17ee1973 ("docs: filesystems: convert mount_api.txt to ReST")
Signed-off-by: Randy Dunlap 
Cc: Mauro Carvalho Chehab 
---
 Documentation/filesystems/mount_api.rst |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

--- linux-next-20200917.orig/Documentation/filesystems/mount_api.rst
+++ linux-next-20200917/Documentation/filesystems/mount_api.rst
@@ -1,7 +1,7 @@
 .. SPDX-License-Identifier: GPL-2.0
 
 
-fILESYSTEM Mount API
+Filesystem Mount API
 
 
 .. CONTENTS
@@ -479,7 +479,7 @@ returned.
 int vfs_parse_fs_param(struct fs_context *fc,
   struct fs_parameter *param);
 
- Supply a single mount parameter to the filesystem context.  This include
+ Supply a single mount parameter to the filesystem context.  This includes
  the specification of the source/device which is specified as the "source"
  parameter (which may be specified multiple times if the filesystem
  supports that).
@@ -592,8 +592,7 @@ The following helpers all wrap sget_fc()
one.
 
 
-=
-PARAMETER DESCRIPTION
+Parameter Description
 =
 
 Parameters are described using structures defined in linux/fs_parser.h.



[PATCH v1 03/10] bus: mhi: core: Skip device wake in error or shutdown states

2020-09-18 Thread Bhaumik Bhatt
MHI clients can request a device wake even if the device may be in an
error state or undergoing shutdown. To prevent unnecessary device wake
processing, check for the device state and bail out early so that the
clients are made aware of the device state sooner.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/pm.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index 9d4789d..1862960 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -827,6 +827,10 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl)
 
/* Wake up the device */
read_lock_bh(_cntrl->pm_lock);
+   if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
+   read_unlock_bh(_cntrl->pm_lock);
+   return -EIO;
+   }
mhi_cntrl->wake_get(mhi_cntrl, true);
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_trigger_resume(mhi_cntrl);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 02/10] bus: mhi: core: Move to using high priority workqueue

2020-09-18 Thread Bhaumik Bhatt
MHI work is currently scheduled on the global/system workqueue and can
encounter delays on a stressed system. To avoid those unforeseen
delays which can hamper bootup or shutdown times, use a dedicated high
priority workqueue instead of the global/system workqueue.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/init.c | 7 +++
 drivers/bus/mhi/core/pm.c   | 2 +-
 include/linux/mhi.h | 2 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 1b4161e..ca32563 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -890,6 +890,11 @@ int mhi_register_controller(struct mhi_controller 
*mhi_cntrl,
INIT_WORK(_cntrl->st_worker, mhi_pm_st_worker);
init_waitqueue_head(_cntrl->state_event);
 
+   mhi_cntrl->hiprio_wq = alloc_ordered_workqueue
+   ("mhi_hiprio_wq", WQ_MEM_RECLAIM | WQ_HIGHPRI);
+   if (!mhi_cntrl->hiprio_wq)
+   goto error_alloc_cmd;
+
mhi_cmd = mhi_cntrl->mhi_cmd;
for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++)
spin_lock_init(_cmd->lock);
@@ -977,10 +982,12 @@ int mhi_register_controller(struct mhi_controller 
*mhi_cntrl,
 
 error_alloc_dev:
kfree(mhi_cntrl->mhi_cmd);
+   destroy_workqueue(mhi_cntrl->hiprio_wq);
 
 error_alloc_cmd:
vfree(mhi_cntrl->mhi_chan);
kfree(mhi_cntrl->mhi_event);
+   destroy_workqueue(mhi_cntrl->hiprio_wq);
 
return ret;
 }
diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index ce4d969..9d4789d 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -597,7 +597,7 @@ int mhi_queue_state_transition(struct mhi_controller 
*mhi_cntrl,
list_add_tail(>node, _cntrl->transition_list);
spin_unlock_irqrestore(_cntrl->transition_lock, flags);
 
-   schedule_work(_cntrl->st_worker);
+   queue_work(mhi_cntrl->hiprio_wq, _cntrl->st_worker);
 
return 0;
 }
diff --git a/include/linux/mhi.h b/include/linux/mhi.h
index fb45a0f..7677676 100644
--- a/include/linux/mhi.h
+++ b/include/linux/mhi.h
@@ -338,6 +338,7 @@ struct mhi_controller_config {
  * @wlock: Lock for protecting device wakeup
  * @mhi_link_info: Device bandwidth info
  * @st_worker: State transition worker
+ * @hiprio_wq: High priority workqueue
  * @state_event: State change event
  * @status_cb: CB function to notify power states of the device (required)
  * @wake_get: CB function to assert device wake (optional)
@@ -421,6 +422,7 @@ struct mhi_controller {
spinlock_t wlock;
struct mhi_link_info mhi_link_info;
struct work_struct st_worker;
+   struct workqueue_struct *hiprio_wq;
wait_queue_head_t state_event;
 
void (*status_cb)(struct mhi_controller *mhi_cntrl,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 04/10] bus: mhi: core: Use the IRQF_ONESHOT flag for the BHI interrupt line

2020-09-18 Thread Bhaumik Bhatt
Remove the IRQF_SHARED flag as it is not needed for the BHI interrupt
and replace it with IRQF_ONESHOT so that host can be sure that the
next BHI hard interrupt is triggered only when the threaded interrupt
handler has returned. This is to avoid any race conditions we may run
into if BHI interrupts fire one after another.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index ca32563..9ae4c19 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -167,7 +167,7 @@ int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl)
/* Setup BHI_INTVEC IRQ */
ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handler,
   mhi_intvec_threaded_handler,
-  IRQF_SHARED | IRQF_NO_SUSPEND,
+  IRQF_ONESHOT | IRQF_NO_SUSPEND,
   "bhi", mhi_cntrl);
if (ret)
return ret;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 09/10] bus: mhi: core: Move to an error state on mission mode failure

2020-09-18 Thread Bhaumik Bhatt
If the host receives a mission mode event and by the time it can get
to processing it, the register accesses fail implying a connectivity
error, MHI should move to an error state. This helps avoid longer wait
times from a synchronous power up perspective and accurately reflects
the MHI execution environment and power management states.

Signed-off-by: Bhaumik Bhatt 
---
 drivers/bus/mhi/core/pm.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
index bce1f62..16c04ab 100644
--- a/drivers/bus/mhi/core/pm.c
+++ b/drivers/bus/mhi/core/pm.c
@@ -384,10 +384,14 @@ static int mhi_pm_mission_mode_transition(struct 
mhi_controller *mhi_cntrl)
write_lock_irq(_cntrl->pm_lock);
if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
-   write_unlock_irq(_cntrl->pm_lock);
 
-   if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
+   if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee)) {
+   mhi_cntrl->pm_state = MHI_PM_LD_ERR_FATAL_DETECT;
+   write_unlock_irq(_cntrl->pm_lock);
+   wake_up_all(_cntrl->state_event);
return -EIO;
+   }
+   write_unlock_irq(_cntrl->pm_lock);
 
wake_up_all(_cntrl->state_event);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



[PATCH v1 00/10] Bug fixes and improvements for MHI power operations

2020-09-18 Thread Bhaumik Bhatt
Bug fixes and improvements for MHI powerup and shutdown handling.
Firmware load function names are updated to accurately reflect their purpose.
Closed certain design gaps where the host (MHI bus) would allow clients to
operate after a power down or error detection.
Move to an error state sooner based on different scenarios.

These patches were tested on arm64 and X86_64 architectures.

Bhaumik Bhatt (10):
  bus: mhi: core: Use appropriate names for firmware load functions
  bus: mhi: core: Move to using high priority workqueue
  bus: mhi: core: Skip device wake in error or shutdown states
  bus: mhi: core: Use the IRQF_ONESHOT flag for the BHI interrupt line
  bus: mhi: core: Disable IRQs when powering down
  bus: mhi: core: Improve shutdown handling after link down detection
  bus: mhi: core: Move to SYS_ERROR regardless of RDDM capability
  bus: mhi: core: Move to an error state on any firmware load failure
  bus: mhi: core: Move to an error state on mission mode failure
  bus: mhi: core: Mark device inactive soon after host issues a shutdown

 drivers/bus/mhi/core/boot.c | 59 ++-
 drivers/bus/mhi/core/init.c | 10 ++-
 drivers/bus/mhi/core/internal.h |  1 +
 drivers/bus/mhi/core/main.c | 28 +--
 drivers/bus/mhi/core/pm.c   | 62 -
 include/linux/mhi.h |  2 ++
 6 files changed, 108 insertions(+), 54 deletions(-)

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project



  1   2   3   4   5   6   7   8   9   10   >