[tip:core/mm] BUILD SUCCESS a0e169978303ee5873142599c8c9660b2d296243

2020-11-19 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git  
core/mm
branch HEAD: a0e169978303ee5873142599c8c9660b2d296243  microblaze/mm/highmem: 
Add dropped #ifdef back

elapsed time: 725m

configs tested: 123
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
powerpc mpc5200_defconfig
arm davinci_all_defconfig
arm hackkit_defconfig
sparc   sparc64_defconfig
m68kmvme147_defconfig
xtensa   alldefconfig
powerpc  obs600_defconfig
m68k  atari_defconfig
sh   se7712_defconfig
arm   multi_v4t_defconfig
mips tb0287_defconfig
m68kq40_defconfig
sh   sh2007_defconfig
powerpc ppa8548_defconfig
arcnsimosci_defconfig
mips cu1830-neo_defconfig
arm bcm2835_defconfig
mips  rm200_defconfig
powerpc rainier_defconfig
powerpc tqm8540_defconfig
armtrizeps4_defconfig
powerpc powernv_defconfig
m68k  sun3x_defconfig
arm  exynos_defconfig
mips  pistachio_defconfig
mipsnlm_xlp_defconfig
powerpcfsp2_defconfig
arm s5pv210_defconfig
arm  tango4_defconfig
arm  badge4_defconfig
arm  alldefconfig
armzeus_defconfig
parisc  defconfig
mips cu1000-neo_defconfig
arm  pcm027_defconfig
arm am200epdkit_defconfig
sh   se7721_defconfig
powerpc mpc836x_rdk_defconfig
h8300 edosk2674_defconfig
powerpc  storcenter_defconfig
mips  bmips_stb_defconfig
shtitan_defconfig
powerpc mpc85xx_cds_defconfig
ia64defconfig
powerpcsam440ep_defconfig
arm eseries_pxa_defconfig
m68km5307c3_defconfig
powerpc tqm8555_defconfig
mips tb0226_defconfig
arc haps_hs_defconfig
powerpc   eiger_defconfig
powerpc   allnoconfig
ia64 allmodconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
c6x  allyesconfig
nds32   defconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
s390 allyesconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
i386 randconfig-a006-20201119
i386 randconfig-a005-20201119
i386 randconfig-a002-20201119
i386 randconfig-a001-20201119
i386 randconfig-a003-20201119
i386 randconfig-a004-20201119
x86_64   randconfig-a015-20201119
x86_64   randconfig-a014-20201119
x86_64   randconfig-a011-20201119
x86_64   randconfig-a013-20201119
x86_64   randconfig-a016-20201119
x86_64   randconfig-a012-20201119
i386 randconfig-a012-20201119
i386 randconfig-a014-20201119
i386 randconfig

[PATCH 1/2] uio: uio_dmem_genirq: convert simple allocations to device-managed

2020-11-19 Thread Alexandru Ardelean
This change converts the simple allocations in the driver to used
device-managed allocation functions.
This removes the error path entirely in the probe function, and reduces
some code in the remove function.

Signed-off-by: Alexandru Ardelean 
---
 drivers/uio/uio_dmem_genirq.c | 34 --
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index ec7f66f4555a..72aa372d6ba6 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -154,11 +154,10 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
 
if (pdev->dev.of_node) {
/* alloc uioinfo for one device */
-   uioinfo = kzalloc(sizeof(*uioinfo), GFP_KERNEL);
+   uioinfo = devm_kzalloc(>dev, sizeof(*uioinfo), 
GFP_KERNEL);
if (!uioinfo) {
-   ret = -ENOMEM;
dev_err(>dev, "unable to kmalloc\n");
-   goto bad2;
+   return -ENOMEM;
}
uioinfo->name = devm_kasprintf(>dev, GFP_KERNEL, "%pOFn",
   pdev->dev.of_node);
@@ -167,20 +166,19 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
 
if (!uioinfo || !uioinfo->name || !uioinfo->version) {
dev_err(>dev, "missing platform_data\n");
-   goto bad0;
+   return -EINVAL;
}
 
if (uioinfo->handler || uioinfo->irqcontrol ||
uioinfo->irq_flags & IRQF_SHARED) {
dev_err(>dev, "interrupt configuration error\n");
-   goto bad0;
+   return -EINVAL;
}
 
-   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+   priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
-   ret = -ENOMEM;
dev_err(>dev, "unable to kmalloc\n");
-   goto bad0;
+   return -ENOMEM;
}
 
dma_set_coherent_mask(>dev, DMA_BIT_MASK(32));
@@ -197,7 +195,7 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
if (ret == -ENXIO && pdev->dev.of_node)
ret = UIO_IRQ_NONE;
else if (ret < 0)
-   goto bad1;
+   return ret;
uioinfo->irq = ret;
}
 
@@ -286,19 +284,11 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
if (ret) {
dev_err(>dev, "unable to register uio device\n");
pm_runtime_disable(>dev);
-   goto bad1;
+   return ret;
}
 
platform_set_drvdata(pdev, priv);
return 0;
- bad1:
-   kfree(priv);
- bad0:
-   /* kfree uioinfo for OF */
-   if (pdev->dev.of_node)
-   kfree(uioinfo);
- bad2:
-   return ret;
 }
 
 static int uio_dmem_genirq_remove(struct platform_device *pdev)
@@ -308,14 +298,6 @@ static int uio_dmem_genirq_remove(struct platform_device 
*pdev)
uio_unregister_device(priv->uioinfo);
pm_runtime_disable(>dev);
 
-   priv->uioinfo->handler = NULL;
-   priv->uioinfo->irqcontrol = NULL;
-
-   /* kfree uioinfo for OF */
-   if (pdev->dev.of_node)
-   kfree(priv->uioinfo);
-
-   kfree(priv);
return 0;
 }
 
-- 
2.27.0



[PATCH 2/2] uio: uio_dmem_genirq: finalize conversion of probe to devm_ handlers

2020-11-19 Thread Alexandru Ardelean
This moves move pm_runtime_disable on a devm_add_action_or_reset() handler.
And with the use of the devm_uio_register_device() function, the remove
hook is no longer required.

Signed-off-by: Alexandru Ardelean 
---
 drivers/uio/uio_dmem_genirq.c | 28 ++--
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index 72aa372d6ba6..6b5cfa5b0673 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -143,6 +143,13 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info 
*dev_info, s32 irq_on)
return 0;
 }
 
+static void uio_dmem_genirq_pm_disable(void *data)
+{
+   struct device *dev = data;
+
+   pm_runtime_disable(dev);
+}
+
 static int uio_dmem_genirq_probe(struct platform_device *pdev)
 {
struct uio_dmem_genirq_pdata *pdata = dev_get_platdata(>dev);
@@ -280,25 +287,11 @@ static int uio_dmem_genirq_probe(struct platform_device 
*pdev)
 */
pm_runtime_enable(>dev);
 
-   ret = uio_register_device(>dev, priv->uioinfo);
-   if (ret) {
-   dev_err(>dev, "unable to register uio device\n");
-   pm_runtime_disable(>dev);
+   ret = devm_add_action_or_reset(>dev, uio_dmem_genirq_pm_disable, 
>dev);
+   if (ret)
return ret;
-   }
-
-   platform_set_drvdata(pdev, priv);
-   return 0;
-}
-
-static int uio_dmem_genirq_remove(struct platform_device *pdev)
-{
-   struct uio_dmem_genirq_platdata *priv = platform_get_drvdata(pdev);
-
-   uio_unregister_device(priv->uioinfo);
-   pm_runtime_disable(>dev);
 
-   return 0;
+   return devm_uio_register_device(>dev, priv->uioinfo);
 }
 
 static int uio_dmem_genirq_runtime_nop(struct device *dev)
@@ -332,7 +325,6 @@ MODULE_DEVICE_TABLE(of, uio_of_genirq_match);
 
 static struct platform_driver uio_dmem_genirq = {
.probe = uio_dmem_genirq_probe,
-   .remove = uio_dmem_genirq_remove,
.driver = {
.name = DRIVER_NAME,
.pm = _dmem_genirq_dev_pm_ops,
-- 
2.27.0



Re: [PATCH] m68k/mac: Refactor iop_preinit() and iop_init()

2020-11-19 Thread Geert Uytterhoeven
On Fri, Nov 20, 2020 at 5:51 AM Finn Thain  wrote:
> The idea behind iop_preinit() was to put the SCC IOP into bypass mode.
> However, that remains unimplemented and implementing it would be
> difficult. Let the comments and code reflect this. Even if iop_preinit()
> worked as described in the comments, it gets called immediately before
> iop_init() so it might as well part of iop_init().
>
> Cc: Joshua Thompson 
> Tested-by: Stan Johnson 
> Signed-off-by: Finn Thain 

Reviewed-by: Geert Uytterhoeven 
i.e. will queue in the m68k for-v5.11 branch.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[RFC] Documentation/scheduler/schedutil.txt

2020-11-19 Thread Peter Zijlstra
Hi,

I was recently asked to explain how schedutil works, the below write-up
is the result of that and I figured we might as well stick it in the
tree.

Not as a patch for easy reading and commenting.

---

NOTE; all this assumes a linear relation between frequency and work capacity,
we know this is flawed, but it is the best workable approximation.


PELT (Per Entity Load Tracking)
---

With PELT we track some metrics across the various entities, from individual
tasks to task-group slices to CPU runqueues. As the basis for this we use an
EWMA, each period (1024us) is decayed such that y^32 = 0.5. That is, the
most recent 32ms contribute half, while the rest of history contribute the
other half.

Specifically:

  ewma_sum(u) := u_0 + u_1*y + u_2*y^2 + ...

  ewma(u) = ewma_sum(u) / ewma_sum(1)

Since this is essentially a progression of an infinite geometric series, the
results are composable, that is ewma(A) + ewma(B) = ewma(A+B). This property
is key, since it gives the ability to recompose the averages when tasks move
around.

Note that blocked tasks still contribute to the aggregates (task-group slices
and CPU runqueues), which reflects their expected contribution when they
resume running.

Using this we track 2 key metrics: 'running' and 'runnable'. 'Running'
reflects the time an entity spends on the CPU, while 'runnable' reflects the
time an entity spends on the runqueue. When there is only a single task these
two metrics are the same, but once there is contention for the CPU 'running'
will decrease to reflect the fraction of time each task spends on the CPU
while 'runnable' will increase to reflect the amount of contention.

For more detail see: kernel/sched/pelt.c


Frequency- / Heterogeneous Invariance
-

Because consuming the CPU for 50% at 1GHz is not the same as consuming the CPU
for 50% at 2GHz, nor is running 50% on a LITTLE CPU the same as running 50% on
a big CPU, we allow architectures to scale the time delta with two ratios, one
DVFS ratio and one microarch ratio.

For simple DVFS architectures (where software is in full control) we trivially
compute the ratio as:

f_cur
  r_dvfs := -
f_max

For more dynamic systems where the hardware is in control of DVFS (Intel,
ARMv8.4-AMU) we use hardware counters to provide us this ratio. In specific,
for Intel, we use:

   APERF
  f_cur := - * P0
   MPERF

 4C-turbo;  if available and turbo enabled
  f_max := { 1C-turbo;  if turbo enabled
 P0;otherwise

f_cur
  r_dvfs := min( 1, - )
f_max

We pick 4C turbo over 1C turbo to make it slightly more sustainable.

r_het is determined as the average performance difference between a big and
LITTLE core when running at max frequency over 'relevant' benchmarks.

The result is that the above 'running' and 'runnable' metrics become invariant
of DVFS and Heterogenous state. IOW. we can transfer and compare them between
CPUs.

For more detail see:

 - kernel/sched/pelt.h:update_rq_clock_pelt()
 - arch/x86/kernel/smpboot.c:"APERF/MPERF frequency ratio computation."


UTIL_EST / UTIL_EST_FASTUP
--

Because periodic tasks have their averages decayed while they sleep, even
though when running their expected utilization will be the same, they suffer a
(DVFS) ramp-up after they become runnable again.

To alleviate this (a default enabled option) UTIL_EST drives an (IIR) EWMA
with the 'running' value on dequeue -- when it is highest. A further default
enabled option UTIL_EST_FASTUP modifies the IIR filter to instantly increase
and only decay on decrease.

A further runqueue wide sum (of runnable tasks) is maintained of:

  util_est := \Sum_t max( t_running, t_util_est_ewma )

For more detail see: kernel/sched/fair.h:util_est_dequeue()


UCLAMP
--

It is possible to set effective u_min and u_max clamps on each task; the
runqueue keeps an max aggregate of these clamps for all running tasks.

For more detail see: include/uapi/linux/sched/types.h


Schedutil / DVFS


Every time the scheduler load tracking is updated (task wakeup, task
migration, time progression) we call out to schedutil to update the hardware
DVFS state.

The basis is the CPU runqueue's 'running' metric, which per the above it is
the frequency invariant utilization estimate of the CPU. From this we compute
a desired frequency like:

 max( running, util_est );  if UTIL_EST
  u_cfs := { running;   otherwise

  u_clamp := clamp( u_cfs, u_min, u_max )

  u := u_cfs + u_rt + u_irq + u_dl; [approx. see source for more detail]

  f_des := min( f_max, 1.25 u * f_max )

XXX IO-wait; when the update is due to a task wakeup from IO-completion we
boost 'u' above.

This frequency is then used to select a P-state/OPP or directly munged into a
CPPC style request to the hardware.

XXX: deadline tasks (Sporadic 

Re: [PATCH] s390: cio: fix two use-after-free bugs in device.c

2020-11-19 Thread Cornelia Huck
On Fri, 20 Nov 2020 15:48:49 +0800
Qinglang Miao  wrote:

> put_device calls release function which do kfree() inside.
> So following use of sch would cause use-after-free bugs.
> 
> Fix these by simply adjusting the position of put_device.
> 
> Fixes: 37db8985b211 ("s390/cio: add basic protected virtualization support")
> Fixes: 74bd0d859dc3 ("s390/cio: fix unlocked access of online member")
> Reported-by: Hulk Robot 
> Signed-off-by: Qinglang Miao 
> ---
>  drivers/s390/cio/device.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
> index b29fe8d50..69492417b 100644
> --- a/drivers/s390/cio/device.c
> +++ b/drivers/s390/cio/device.c
> @@ -1664,10 +1664,10 @@ void __init ccw_device_destroy_console(struct 
> ccw_device *cdev)
>   struct io_subchannel_private *io_priv = to_io_private(sch);
>  
>   set_io_private(sch, NULL);
> - put_device(>dev);
> - put_device(>dev);
>   dma_free_coherent(>dev, sizeof(*io_priv->dma_area),
> io_priv->dma_area, io_priv->dma_area_dma);
> + put_device(>dev);
> + put_device(>dev);

That change looks reasonable.

>   kfree(io_priv);
>  }
>  
> @@ -1774,8 +1774,8 @@ static int ccw_device_remove(struct device *dev)
> ret, cdev->private->dev_id.ssid,
> cdev->private->dev_id.devno);
>   /* Give up reference obtained in ccw_device_set_online(). */
> - put_device(>dev);
>   spin_lock_irq(cdev->ccwlock);
> + put_device(>dev);

As the comment above states, the put_device() gives up the reference
obtained in ccw_device_set_online(). There's at least one more
reference remaining (held by the caller of the remove function). Moving
the put_device() does not fix anything here.

>   }
>   ccw_device_set_timeout(cdev, 0);
>   cdev->drv = NULL;



Re: [EXT] Re: [PATCH v3 1/4] dt-bindings: soc: imx8m: add DT Binding doc for soc unique ID

2020-11-19 Thread Krzysztof Kozlowski
On Fri, Nov 20, 2020 at 06:21:55AM +, Alice Guo wrote:
> > > +  soc:
> > > +type: object
> > > +properties:
> > > +  compatible:
> > > +oneOf:
> > > +  - description: new version DTS for i.MX8M SoCs
> > > +items:
> > > +  - enum:
> > > +  - fsl,imx8mm-soc
> > > +  - fsl,imx8mn-soc
> > > +  - fsl,imx8mp-soc
> > > +  - fsl,imx8mq-soc
> > > +  - const: simple-bus
> > > +
> > > +  - description: other SoCs and old version DTS for i.MX8M SoCs
> > > +items:
> > > +  - const: simple-bus
> > > +
> > > +  nvmem-cells:
> > > +maxItems: 1
> > > +description: Phandle to the SOC Unique ID provided by a nvmem
> > > + node
> > > +
> > > +  nvmem-cells-names:
> > > +const: soc_unique_id
> > > +
> > > +allOf:
> > > +  - if:
> > > +  properties:
> > > +compatible:
> > > +  contains:
> > > +enum:
> > > +  - fsl,imx8mm-soc
> > > +  - fsl,imx8mn-soc
> > > +  - fsl,imx8mp-soc
> > > +  - fsl,imx8mq-soc
> > > +const: simple-bus
> > > +
> > > +then:
> > > +  required:
> > > +- nvmem-cells
> > > +- nvmem-cells-names
> > >
> > > The above is my modification. Is that ok?
> > 
> > Does not look like solving anything.
> 
> If restrict that the newly added DTS file must have "fsl,imx8mX-soc" 
> attributes, it cannot pass make dtbs_check because
> there are other DTS files which have soc node but are not used for i.mx8m 
> family SoCs.

You need to check whether boards with i.MX 8M compatible have the SoC
node with one of above compatibles and nvmem-cells.  Since the top
select choses root node, then just check whether child exists with
specific pattern and compatibles (for given root compatibles).

Best regards,
Krzysztof



[PATCH] net: adaptec: remove dead code in set_vlan_mode

2020-11-19 Thread xiakaixu1987
From: Kaixu Xia 

The body of the if statement can be executed only when the variable
vlan_count equals to 32, so the condition of the while statement can
not be true and the while statement is dead code. Remove it.

Reported-by: Tosk Robot 
Signed-off-by: Kaixu Xia 
---
 drivers/net/ethernet/adaptec/starfire.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/adaptec/starfire.c 
b/drivers/net/ethernet/adaptec/starfire.c
index 555299737b51..ad27a9fa5e95 100644
--- a/drivers/net/ethernet/adaptec/starfire.c
+++ b/drivers/net/ethernet/adaptec/starfire.c
@@ -1754,14 +1754,9 @@ static u32 set_vlan_mode(struct netdev_private *np)
filter_addr += 16;
vlan_count++;
}
-   if (vlan_count == 32) {
+   if (vlan_count == 32)
ret |= PerfectFilterVlan;
-   while (vlan_count < 32) {
-   writew(0, filter_addr);
-   filter_addr += 16;
-   vlan_count++;
-   }
-   }
+
return ret;
 }
 #endif /* VLAN_SUPPORT */
-- 
2.20.0



Re: [PATCH v3 23/23] mtd: devices: powernv_flash: Add function names to headers and fix 'dev'

2020-11-19 Thread Lee Jones
On Thu, 19 Nov 2020, Miquel Raynal wrote:

> On Mon, 2020-11-09 at 18:22:06 UTC, Lee Jones wrote:
> > Fixes the following W=1 kernel build warning(s):
> > 
> >  drivers/mtd/devices/powernv_flash.c:129: warning: Cannot understand  * 
> > @mtd: the device
> >  drivers/mtd/devices/powernv_flash.c:145: warning: Cannot understand  * 
> > @mtd: the device
> >  drivers/mtd/devices/powernv_flash.c:161: warning: Cannot understand  * 
> > @mtd: the device
> >  drivers/mtd/devices/powernv_flash.c:184: warning: Function parameter or 
> > member 'dev' not described in 'powernv_flash_set_driver_info'
> > 
> > Cc: Miquel Raynal 
> > Cc: Richard Weinberger 
> > Cc: Vignesh Raghavendra 
> > Cc: Michael Ellerman 
> > Cc: Benjamin Herrenschmidt 
> > Cc: Paul Mackerras 
> > Cc: linux-...@lists.infradead.org
> > Cc: linuxppc-...@lists.ozlabs.org
> > Signed-off-by: Lee Jones 
> 
> Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git 
> nand/next, thanks.

Superstar.  Thanks for your help Miquel.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog


Re: [PATCH v5 03/21] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP

2020-11-19 Thread Michal Hocko
On Fri 20-11-20 14:43:07, Muchun Song wrote:
> The purpose of introducing HUGETLB_PAGE_FREE_VMEMMAP is to configure
> whether to enable the feature of freeing unused vmemmap associated
> with HugeTLB pages. Now only support x86.

Why is the config option necessary? Are code savings with the feature
disabled really worth it? I can see that your later patch adds a kernel
command line option. I believe that is a more reasonable way to control
the feature. I would argue that this should be an opt-in rather than
opt-out though. Think of users of pre-built (e.g. distribution kernels)
who might be interested in the feature. Yet you cannot assume that such
a kernel would enable the feature with its overhead to all hugetlb
users.

That being said, unless there are huge advantages to introduce a
config option I would rather not add it because our config space is huge
already and the more we add the more future code maintainance that will
add. If you want the config just for dependency checks then fine by me.
 
> Signed-off-by: Muchun Song 
> ---
>  arch/x86/mm/init_64.c |  2 +-
>  fs/Kconfig| 14 ++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 0a45f062826e..0435bee2e172 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1225,7 +1225,7 @@ static struct kcore_list kcore_vsyscall;
>  
>  static void __init register_page_bootmem_info(void)
>  {
> -#ifdef CONFIG_NUMA
> +#if defined(CONFIG_NUMA) || defined(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP)
>   int i;
>  
>   for_each_online_node(i)
> diff --git a/fs/Kconfig b/fs/Kconfig
> index 976e8b9033c4..4961dd488444 100644
> --- a/fs/Kconfig
> +++ b/fs/Kconfig
> @@ -245,6 +245,20 @@ config HUGETLBFS
>  config HUGETLB_PAGE
>   def_bool HUGETLBFS
>  
> +config HUGETLB_PAGE_FREE_VMEMMAP
> + def_bool HUGETLB_PAGE
> + depends on X86
> + depends on SPARSEMEM_VMEMMAP
> + depends on HAVE_BOOTMEM_INFO_NODE
> + help
> +   When using HUGETLB_PAGE_FREE_VMEMMAP, the system can save up some
> +   memory from pre-allocated HugeTLB pages when they are not used.
> +   6 pages per 2MB HugeTLB page and 4094 per 1GB HugeTLB page.
> +
> +   When the pages are going to be used or freed up, the vmemmap array
> +   representing that range needs to be remapped again and the pages
> +   we discarded earlier need to be rellocated again.
> +
>  config MEMFD_CREATE
>   def_bool TMPFS || HUGETLBFS
>  
> -- 
> 2.11.0

-- 
Michal Hocko
SUSE Labs


Re: [PATCH] m68k: Fix WARNING splat in pmac_zilog driver

2020-11-19 Thread Geert Uytterhoeven
Hi Finn,

On Fri, Nov 20, 2020 at 5:51 AM Finn Thain  wrote:
> Don't add platform resources that won't be used. This avoids a
> recently-added warning from the driver core, that can show up on a
> multi-platform kernel when !MACH_IS_MAC.
>
> [ cut here ]
> WARNING: CPU: 0 PID: 0 at drivers/base/platform.c:224 
> platform_get_irq_optional+0x8e/0xce
> 0 is an invalid IRQ number
> Modules linked in:
> CPU: 0 PID: 0 Comm: swapper Not tainted 5.9.0-multi #1
> Stack from 004b3f04:
> 004b3f04 00462c2f 00462c2f 004b3f20 0002e128 004754db 004b6ad4 
> 004b3f4c
> 0002e19c 004754f7 00e0 00285ba0 0009  004b3f44 
> 
> 004754db 004b3f64 004b3f74 00285ba0 004754f7 00e0 0009 
> 004754db
> 004fdf0c 005269e2 004fdf0c  004b3f88 00285cae 004b6964 
> 
> 004fdf0c 004b3fac 0051cc68 004b6964  004b6964 0200 
> 
> 0051cc3e 0023c18a 004b3fc0 0051cd8a 004fdf0c 0002 0052b43c 
> 004b3fc8
> Call Trace: [<0002e128>] __warn+0xa6/0xd6
>  [<0002e19c>] warn_slowpath_fmt+0x44/0x76
>  [<00285ba0>] platform_get_irq_optional+0x8e/0xce
>  [<00285ba0>] platform_get_irq_optional+0x8e/0xce
>  [<00285cae>] platform_get_irq+0x12/0x4c
>  [<0051cc68>] pmz_init_port+0x2a/0xa6
>  [<0051cc3e>] pmz_init_port+0x0/0xa6
>  [<0023c18a>] strlen+0x0/0x22
>  [<0051cd8a>] pmz_probe+0x34/0x88
>  [<0051cde6>] pmz_console_init+0x8/0x28
>  [<00511776>] console_init+0x1e/0x28
>  [<0005a3bc>] printk+0x0/0x16
>  [<0050a8a6>] start_kernel+0x368/0x4ce
>  [<005094f8>] _sinittext+0x4f8/0xc48
> random: get_random_bytes called from print_oops_end_marker+0x56/0x80 with 
> crng_init=0
> ---[ end trace 392d8e82eed68d6c ]---
>
> Cc: Michael Ellerman 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Joshua Thompson 
> Cc: Greg Kroah-Hartman 
> Cc: Jiri Slaby 
> Cc: sta...@vger.kernel.org # v5.8+
> References: commit a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 
> is invalid")
> Reported-by: Laurent Vivier 
> Signed-off-by: Finn Thain 
> ---
> The global platform_device structs provide the equivalent of a direct
> search of the OpenFirmware tree, for platforms that don't have OF.
> The purpose of that search is discussed in the comments in pmac_zilog.c:
>
>  * First, we need to do a direct OF-based probe pass. We
>  * do that because we want serial console up before the
>  * macio stuffs calls us back
>
> The actual platform bus matching takes place later, with a module_initcall,
> following the usual pattern.

I think it would be good for this explanation to be part of the
actual patch description above.

> --- a/arch/m68k/mac/config.c
> +++ b/arch/m68k/mac/config.c
> @@ -777,16 +777,12 @@ static struct resource scc_b_rsrcs[] = {
>  struct platform_device scc_a_pdev = {
> .name   = "scc",
> .id = 0,
> -   .num_resources  = ARRAY_SIZE(scc_a_rsrcs),
> -   .resource   = scc_a_rsrcs,
>  };
>  EXPORT_SYMBOL(scc_a_pdev);
>
>  struct platform_device scc_b_pdev = {
> .name   = "scc",
> .id = 1,
> -   .num_resources  = ARRAY_SIZE(scc_b_rsrcs),
> -   .resource   = scc_b_rsrcs,
>  };
>  EXPORT_SYMBOL(scc_b_pdev);
>
> @@ -813,10 +809,15 @@ static void __init mac_identify(void)
>
> /* Set up serial port resources for the console initcall. */
>
> -   scc_a_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase + 2;
> -   scc_a_rsrcs[0].end   = scc_a_rsrcs[0].start;
> -   scc_b_rsrcs[0].start = (resource_size_t) mac_bi_data.sccbase;
> -   scc_b_rsrcs[0].end   = scc_b_rsrcs[0].start;
> +   scc_a_rsrcs[0].start = (resource_size_t)mac_bi_data.sccbase + 2;
> +   scc_a_rsrcs[0].end   = scc_a_rsrcs[0].start;
> +   scc_a_pdev.num_resources = ARRAY_SIZE(scc_a_rsrcs);
> +   scc_a_pdev.resource  = scc_a_rsrcs;
> +
> +   scc_b_rsrcs[0].start = (resource_size_t)mac_bi_data.sccbase;
> +   scc_b_rsrcs[0].end   = scc_b_rsrcs[0].start;
> +   scc_b_pdev.num_resources = ARRAY_SIZE(scc_b_rsrcs);
> +   scc_b_pdev.resource  = scc_b_rsrcs;
>
> switch (macintosh_config->scc_type) {
> case MAC_SCC_PSC:
> diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
> index 96e7aa479961..95abdb305d67 100644
> --- a/drivers/tty/serial/pmac_zilog.c
> +++ b/drivers/tty/serial/pmac_zilog.c
> @@ -1697,18 +1697,17 @@ extern struct platform_device scc_a_pdev, scc_b_pdev;
>
>  static int __init pmz_init_port(struct uart_pmac_port *uap)
>  {
> -   struct resource *r_ports;
> -   int irq;
> +   struct resource *r_ports, *r_irq;
>
> r_ports = platform_get_resource(uap->pdev, IORESOURCE_MEM, 0);
> -   irq = platform_get_irq(uap->pdev, 0);
> -   if (!r_ports || irq <= 0)
> +   r_irq = platform_get_resource(uap->pdev, IORESOURCE_IRQ, 0);
> +   if (!r_ports || !r_irq)
> return -ENODEV;
>
>   

[PATCH] staging: olpc_dcon: Do not call platform_device_unregister() in dcon_probe()

2020-11-19 Thread Jing Xiangfeng
In dcon_probe(), when platform_device_add() failes to add the device,
it jumps to call platform_device_unregister() to remove the device,
which is unnecessary. So use platform_device_put() instead.

Fixes: 53c43c5ca133 ("Revert "Staging: olpc_dcon: Remove obsolete driver"")
Signed-off-by: Jing Xiangfeng 
---
 drivers/staging/olpc_dcon/olpc_dcon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c 
b/drivers/staging/olpc_dcon/olpc_dcon.c
index a0d6d90f4cc8..e7281212db5b 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -659,8 +659,9 @@ static int dcon_probe(struct i2c_client *client, const 
struct i2c_device_id *id)
  ecreate:
for (j = 0; j < i; j++)
device_remove_file(_device->dev, _device_files[j]);
+   platform_device_del(dcon_device);
  edev:
-   platform_device_unregister(dcon_device);
+   platform_device_put(dcon_device);
dcon_device = NULL;
  eirq:
free_irq(DCON_IRQ, dcon);
-- 
2.17.1



[PATCH v2] arm64: dts: qcom: sc7180: Add prox sensor to LTE sku Lazor boards

2020-11-19 Thread Stephen Boyd
There's a proximity sensor on Lazor devices, but only for LTE SKUs.
Enable it only on the LTE SKUs and also configure it properly so it
works.

Cc: Douglas Anderson 
Cc: Matthias Kaehlcke 
Signed-off-by: Stephen Boyd 
---

Changes from v1 
(https://lore.kernel.org/r/20201118045454.2503325-1-swb...@chromium.org):
 * Fixed startup-sensor property to be 0 instead of 1
 * Fixed proxraw-strength to be 8 instead of 2

 arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r1-lte.dts | 8 
 arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r3-lte.dts | 8 
 arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi   | 7 ++-
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r1-lte.dts 
b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r1-lte.dts
index 5a67e5baafec..e16ba7b01f25 100644
--- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r1-lte.dts
+++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r1-lte.dts
@@ -13,6 +13,14 @@ / {
compatible = "google,lazor-rev1-sku0", "google,lazor-rev2-sku0", 
"qcom,sc7180";
 };
 
+_sar_sensor {
+   status = "okay";
+};
+
+_sar_sensor_i2c {
+   status = "okay";
+};
+
 _backlight {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r3-lte.dts 
b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r3-lte.dts
index 43836fc4d403..0881f8dd02c9 100644
--- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r3-lte.dts
+++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor-r3-lte.dts
@@ -13,6 +13,14 @@ / {
compatible = "google,lazor-sku0", "qcom,sc7180";
 };
 
+_sar_sensor {
+   status = "okay";
+};
+
+_sar_sensor_i2c {
+   status = "okay";
+};
+
 _backlight {
status = "okay";
 };
diff --git a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi
index 180ef9e04306..89e5cd29ec09 100644
--- a/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180-trogdor-lazor.dtsi
@@ -30,7 +30,12 @@ panel_in_edp: endpoint {
 };
 
 _sar_sensor {
-   status = "okay";
+   semtech,cs0-ground;
+   semtech,combined-sensors = <3>;
+   semtech,resolution = "fine";
+   semtech,startup-sensor = <0>;
+   semtech,proxraw-strength = <8>;
+   semtech,avg-pos-strength = <64>;
 };
 
 ap_ts_pen_1v8:  {

base-commit: ead9f7d7ea9e20843e29e688b53859cea20044ee
-- 
https://chromeos.dev



Re: [PATCH 06/15] input: touchscreen: melfas_mip4: Remove a bunch of unused variables

2020-11-19 Thread Lee Jones
On Thu, 19 Nov 2020, Dmitry Torokhov wrote:

> On Fri, Nov 13, 2020 at 07:55:25AM +, Lee Jones wrote:
> > On Thu, 12 Nov 2020, Dmitry Torokhov wrote:
> > 
> > > On Thu, Nov 12, 2020 at 11:01:55AM +, Lee Jones wrote:
> > > > Fixes the following W=1 kernel build warning(s):
> > > > 
> > > >  drivers/input/touchscreen/melfas_mip4.c: In function 
> > > > ‘mip4_report_touch’:
> > > >  drivers/input/touchscreen/melfas_mip4.c:474:5: warning: variable 
> > > > ‘size’ set but not used [-Wunused-but-set-variable]
> > > >  drivers/input/touchscreen/melfas_mip4.c:472:5: warning: variable 
> > > > ‘pressure_stage’ set but not used [-Wunused-but-set-variable]
> > > >  drivers/input/touchscreen/melfas_mip4.c:469:7: warning: variable 
> > > > ‘palm’ set but not used [-Wunused-but-set-variable]
> > > >  drivers/input/touchscreen/melfas_mip4.c:468:7: warning: variable 
> > > > ‘hover’ set but not used [-Wunused-but-set-variable]
> > > > 
> > > > Cc: Sangwon Jee 
> > > > Cc: Dmitry Torokhov 
> > > > Cc: Henrik Rydberg 
> > > > Cc: linux-in...@vger.kernel.org
> > > > Signed-off-by: Lee Jones 
> > > > ---
> > > >  drivers/input/touchscreen/melfas_mip4.c | 11 ---
> > > >  1 file changed, 11 deletions(-)
> > > > 
> > > > diff --git a/drivers/input/touchscreen/melfas_mip4.c 
> > > > b/drivers/input/touchscreen/melfas_mip4.c
> > > > index f67efdd040b24..9c98759098c7a 100644
> > > > --- a/drivers/input/touchscreen/melfas_mip4.c
> > > > +++ b/drivers/input/touchscreen/melfas_mip4.c
> > > > @@ -465,13 +465,9 @@ static void mip4_report_keys(struct mip4_ts *ts, 
> > > > u8 *packet)
> > > >  static void mip4_report_touch(struct mip4_ts *ts, u8 *packet)
> > > >  {
> > > > int id;
> > > > -   bool hover;
> > > > -   bool palm;
> > > > bool state;
> > > > u16 x, y;
> > > > -   u8 pressure_stage = 0;
> > > > u8 pressure;
> > > > -   u8 size;
> > > > u8 touch_major;
> > > > u8 touch_minor;
> > > >  
> > > > @@ -480,14 +476,11 @@ static void mip4_report_touch(struct mip4_ts *ts, 
> > > > u8 *packet)
> > > > case 1:
> > > > /* Touch only */
> > > > state = packet[0] & BIT(7);
> > > > -   hover = packet[0] & BIT(5);
> > > > -   palm = packet[0] & BIT(4);
> > > 
> > > No really happy that we'd be losing information about protocol. Is there
> > > a better way to suppress the warning while keeping this info?
> > 
> > Yes.  We can either convert the information to comments, or mark the
> > variables as __always_unused.
> 
> If __always unused suppresses this warning that would be my preference.

No problem.  Will fix.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog


[PATCH] s390: cmf: fix use-after-free in enable_cmf

2020-11-19 Thread Qinglang Miao
kfree(cdev) is called in put_device in the error branch. So that
device_unlock(>dev) would raise a use-after-free bug. In fact,
there's no need to call device_unlock after put_device.

Fix it by adding simply return after put_device.

Fixes: a6ef15652d26 ("s390/cio: fix use after free in cmb processing")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/s390/cio/cmf.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 72dd2471e..e95ca476f 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1149,9 +1149,12 @@ int enable_cmf(struct ccw_device *cdev)
sysfs_remove_group(>dev.kobj, cmbops->attr_group);
cmbops->free(cdev);
}
+
 out:
-   if (ret)
+   if (ret) {
put_device(>dev);
+   return ret;
+   }
 out_unlock:
device_unlock(>dev);
return ret;
-- 
2.23.0



[PATCH] PCI: fix use-after-free in pci_register_host_bridge

2020-11-19 Thread Qinglang Miao
When put_device(>dev) being called, kfree(bridge) is inside
of release function, so the following device_del would cause a
use-after-free bug.

Fixes: 37d6a0a6f470 ("PCI: Add pci_register_host_bridge() interface")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/pci/probe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4289030b0..82292e87e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -991,8 +991,8 @@ static int pci_register_host_bridge(struct pci_host_bridge 
*bridge)
return 0;
 
 unregister:
-   put_device(>dev);
device_del(>dev);
+   put_device(>dev);
 
 free:
kfree(bus);
-- 
2.23.0



[PATCH] memstick: fix a double-free bug in memstick_check

2020-11-19 Thread Qinglang Miao
kfree(host->card) has been called in put_device so that
another kfree would raise cause a double-free bug.

Fixes: 0193383a5833 ("memstick: core: fix device_register() error handling")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/memstick/core/memstick.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index ef03d6faf..12bc3f5a6 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -468,7 +468,6 @@ static void memstick_check(struct work_struct *work)
host->card = card;
if (device_register(>dev)) {
put_device(>dev);
-   kfree(host->card);
host->card = NULL;
}
} else
-- 
2.23.0



[PATCH] s390: cio: fix two use-after-free bugs in device.c

2020-11-19 Thread Qinglang Miao
put_device calls release function which do kfree() inside.
So following use of sch would cause use-after-free bugs.

Fix these by simply adjusting the position of put_device.

Fixes: 37db8985b211 ("s390/cio: add basic protected virtualization support")
Fixes: 74bd0d859dc3 ("s390/cio: fix unlocked access of online member")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/s390/cio/device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index b29fe8d50..69492417b 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1664,10 +1664,10 @@ void __init ccw_device_destroy_console(struct 
ccw_device *cdev)
struct io_subchannel_private *io_priv = to_io_private(sch);
 
set_io_private(sch, NULL);
-   put_device(>dev);
-   put_device(>dev);
dma_free_coherent(>dev, sizeof(*io_priv->dma_area),
  io_priv->dma_area, io_priv->dma_area_dma);
+   put_device(>dev);
+   put_device(>dev);
kfree(io_priv);
 }
 
@@ -1774,8 +1774,8 @@ static int ccw_device_remove(struct device *dev)
  ret, cdev->private->dev_id.ssid,
  cdev->private->dev_id.devno);
/* Give up reference obtained in ccw_device_set_online(). */
-   put_device(>dev);
spin_lock_irq(cdev->ccwlock);
+   put_device(>dev);
}
ccw_device_set_timeout(cdev, 0);
cdev->drv = NULL;
-- 
2.23.0



Re: [PATCH] drivers: fpga: Specify HAS_IOMEM dependency for FPGA_DFL

2020-11-19 Thread Xu Yilun
On Fri, Nov 20, 2020 at 03:30:35PM +0800, David Gow wrote:
> On Fri, Nov 20, 2020 at 2:27 PM Moritz Fischer  wrote:
> >
> > Hi David,
> >
> > On Thu, Nov 19, 2020 at 12:22:09AM -0800, David Gow wrote:
> > > Because dfl.c uses the 'devm_ioremap', 'devm_iounmap',
> > > 'devm_ioremap_resource', and 'devm_platform_ioremap_resource'
> > > functions, it should depend on HAS_IOMEM.
> > >
> > > This fixes make allyesconfig under UML (ARCH=um), which doesn't provide
> > > HAS_IOMEM.
> > >
> > > Signed-off-by: David Gow 
> > > ---
> > >  drivers/fpga/Kconfig | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> > > index 7cd5a29fc437..5645226ca3ce 100644
> > > --- a/drivers/fpga/Kconfig
> > > +++ b/drivers/fpga/Kconfig
> > > @@ -142,6 +142,7 @@ config FPGA_DFL
> > >   tristate "FPGA Device Feature List (DFL) support"
> > >   select FPGA_BRIDGE
> > >   select FPGA_REGION
> > > + depends on HAS_IOMEM
> > >   help
> > > Device Feature List (DFL) defines a feature list structure that
> > > creates a linked list of feature headers within the MMIO space
> > > --
> > > 2.29.2.454.gaff20da3a2-goog
> > >
> > Do you think we can add a Fixes: tag for this?
> 
> Sure. I think it should be:
> 
> Fixes: 543be3d ("fpga: add device feature list support")

I think it should be:

Fixes: 89eb35e810a8 ("fpga: dfl: map feature mmio resources in their own 
feature drivers")

Thanks,
Yilun

> 
> Let me know if you want me to re-send the patch with that included.
> 
> Cheers,
> -- David


[PATCH] scsi: zfcp: fix use-after-free in zfcp_unit_remove

2020-11-19 Thread Qinglang Miao
kfree(port) is called in put_device(>dev) so that following
use would cause use-after-free bug.

The former put_device is redundant for device_unregister contains
put_device already. So just remove it to fix this.

Fixes: 86bdf218a717 ("[SCSI] zfcp: cleanup unit sysfs attribute usage")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/s390/scsi/zfcp_unit.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_unit.c b/drivers/s390/scsi/zfcp_unit.c
index e67bf7388..664b77853 100644
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -255,8 +255,6 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)
scsi_device_put(sdev);
}
 
-   put_device(>dev);
-
device_unregister(>dev);
 
return 0;
-- 
2.23.0



[PATCH] scsi: zfcp: fix use-after-free in zfcp_sysfs_port_remove_store

2020-11-19 Thread Qinglang Miao
kfree(port) is called in put_device(>dev) so that following
use would cause use-after-free bug.

the former put_device is redundant for device_unregister contains
put_device already. So just remove it to fix this.

Fixes: 83d4e1c33d93 ("[SCSI] zfcp: cleanup port sysfs attribute usage")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/s390/scsi/zfcp_sysfs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 8d9662e8b..06285e452 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -327,8 +327,6 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device 
*dev,
list_del(>list);
write_unlock_irq(>port_list_lock);
 
-   put_device(>dev);
-
zfcp_erp_port_shutdown(port, 0, "syprs_1");
device_unregister(>dev);
  out:
-- 
2.23.0



[PATCH] mips: cdmm: fix use-after-free in mips_cdmm_bus_discover

2020-11-19 Thread Qinglang Miao
kfree(dev) has been called inside put_device so anther
kfree would cause a use-after-free bug/

Fixes: 8286ae03308c ("MIPS: Add CDMM bus support")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/bus/mips_cdmm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/bus/mips_cdmm.c b/drivers/bus/mips_cdmm.c
index 9f7ed1fcd..e43786c67 100644
--- a/drivers/bus/mips_cdmm.c
+++ b/drivers/bus/mips_cdmm.c
@@ -561,7 +561,6 @@ static void mips_cdmm_bus_discover(struct mips_cdmm_bus 
*bus)
ret = device_register(>dev);
if (ret) {
put_device(>dev);
-   kfree(dev);
}
}
 }
-- 
2.23.0



[PATCH] scsi: iscsi: fix inappropriate use of put_device

2020-11-19 Thread Qinglang Miao
kfree(conn) is called inside put_device(>dev) so that
another one would cause use-after-free. Besides, device_unregister
should be used here rather than put_device.

Fixes: f3c893e3dbb5 ("scsi: iscsi: Fail session and connection on transport 
registration failure")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/scsi/scsi_transport_iscsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 2eb3e4f93..2e68c0a87 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2313,7 +2313,9 @@ iscsi_create_conn(struct iscsi_cls_session *session, int 
dd_size, uint32_t cid)
return conn;
 
 release_conn_ref:
-   put_device(>dev);
+   device_unregister(>dev);
+   put_device(>dev);
+   return NULL;
 release_parent_ref:
put_device(>dev);
 free_conn:
-- 
2.23.0



[PATCH] drivers: visorbus: fix use-after free bugs

2020-11-19 Thread Qinglang Miao
kfree(dev) is called in put_device(>device) so that following
use would cause use-after-free bug.

There are two inappropriate use of put_device:

1. In create_visor_device, put dev_err before put_device to fix this.

2. In remove_visor_device, the former put_device is redundant because
   device_unregister contains put_device already.

Fixes: 93d3ad90c2d4 ("drivers: visorbus: move driver out of staging")
Reported-by: Hulk Robot 
Signed-off-by: Qinglang Miao 
---
 drivers/visorbus/visorbus_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c
index 152fd29f0..031349baf 100644
--- a/drivers/visorbus/visorbus_main.c
+++ b/drivers/visorbus/visorbus_main.c
@@ -695,15 +695,14 @@ int create_visor_device(struct visor_device *dev)
return 0;
 
 err_put:
-   put_device(>device);
dev_err(>device, "Creating visor device failed. %d\n", err);
+   put_device(>device);
return err;
 }
 
 void remove_visor_device(struct visor_device *dev)
 {
list_del(>list_all);
-   put_device(>device);
if (dev->pending_msg_hdr)
visorbus_response(dev, 0, CONTROLVM_DEVICE_DESTROY);
device_unregister(>device);
-- 
2.23.0



Re: [PATCH] usb: musb: remove unused variable 'devctl'

2020-11-19 Thread Min Guo
On Fri, 2020-11-20 at 07:54 +0100, Greg Kroah-Hartman wrote:
> On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> > Hi greg k-h:
> > On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min@mediatek.com wrote:
> > > > From: Min Guo 
> > > > 
> > > > Remove unused 'devctl' variable to fix compile warnings:
> > > > 
> > > > drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > > drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > > but not used [-Wunused-but-set-variable]
> > > > 
> > > > Signed-off-by: Min Guo 
> > > > ---
> > > >  drivers/usb/musb/musbhsdma.c | 4 
> > > >  1 file changed, 4 deletions(-)
> > > > 
> > > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > > index 0aacfc8be5a1..7acd1635850d 100644
> > > > --- a/drivers/usb/musb/musbhsdma.c
> > > > +++ b/drivers/usb/musb/musbhsdma.c
> > > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void 
> > > > *private_data)
> > > > musb_channel->channel.status =
> > > > MUSB_DMA_STATUS_BUS_ABORT;
> > > > } else {
> > > > -   u8 devctl;
> > > > -
> > > > addr = musb_read_hsdma_addr(mbase,
> > > > bchannel);
> > > > channel->actual_len = addr
> > > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void 
> > > > *private_data)
> > > > < musb_channel->len) ?
> > > > "=> reconfig 0" : "=> 
> > > > complete");
> > > >  
> > > > -   devctl = musb_readb(mbase, MUSB_DEVCTL);
> > > 
> > > Are you sure that the hardware does not require this read to complete
> > > the command?  Lots of hardware is that way, so be very careful about
> > > this.  Did you test it?
> > 
> > I have tested this patch on Mediatek's platform, and not sure if it
> > will affect other vendors' platforms.
> > 
> > Dear Bin:
> > 
> > Does this patch will affect other vendors' platforms?
> 
> The hardware specs will answer this question, what do they say about
> this read?

Sorry, I didn't seen the comment on the hardware specs indicate that
devctl register needs to read once to take effect.

> thanks,
> 
> greg k-h



[PATCH 1/2] Input: adp5589 - do not unconditionally configure as wakeup source

2020-11-19 Thread Dmitry Torokhov
We should not be configuring the controller as a wakeup source in the
driver, but rather rely on I2C core to mark it as such by either
instantiating as I2C_CLIENT_WAKEUP or specifying "wakeup-source" device
property.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/keyboard/adp5589-keys.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/input/keyboard/adp5589-keys.c 
b/drivers/input/keyboard/adp5589-keys.c
index e2cdf14d90cd..d76b0e4e67c4 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -930,8 +930,6 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, 
unsigned int revid)
return error;
}
 
-   device_init_wakeup(>dev, 1);
-
return 0;
 }
 
-- 
2.29.2.454.gaff20da3a2-goog



[PATCH v2 1/2] arm64: dts: ti: k3-j7200-som-p0: main_i2c0 have an ioexpander on the SOM

2020-11-19 Thread Peter Ujfalusi
The J7200 SOM have additional io expander which is used to control several
SOM level muxes to make sure that the correct signals are routed to the
correct pin on the SOM <-> CPB connectors.

Signed-off-by: Peter Ujfalusi 
Reviewed-by: Vignesh Raghavendra 
---
 .../dts/ti/k3-j7200-common-proc-board.dts | 11 
 arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi   | 26 +++
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 6b3863108571..2721137d8943 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -43,13 +43,6 @@ J721E_WKUP_IOPAD(0x0098, PIN_INPUT, 0) /* (L4) 
MCU_MDIO0_MDIO */
 };
 
 _pmx0 {
-   main_i2c0_pins_default: main-i2c0-pins-default {
-   pinctrl-single,pins = <
-   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
-   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
-   >;
-   };
-
main_i2c1_pins_default: main-i2c1-pins-default {
pinctrl-single,pins = <
J721E_IOPAD(0xdc, PIN_INPUT_PULLUP, 3) /* (U3) 
ECAP0_IN_APWM_OUT.I2C1_SCL */
@@ -146,10 +139,6 @@ _port1 {
 };
 
 _i2c0 {
-   pinctrl-names = "default";
-   pinctrl-0 = <_i2c0_pins_default>;
-   clock-frequency = <40>;
-
exp1: gpio@20 {
compatible = "ti,tca6416";
reg = <0x20>;
diff --git a/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi 
b/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi
index fbd17d38f6b6..7b5e9aa0324e 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi
@@ -48,6 +48,15 @@ J721E_WKUP_IOPAD(0x28, PIN_INPUT, 1) /* (A7) 
MCU_OSPI0_D7.MCU_HYPERBUS0_DQ7 */
};
 };
 
+_pmx0 {
+   main_i2c0_pins_default: main-i2c0-pins-default {
+   pinctrl-single,pins = <
+   J721E_IOPAD(0xd4, PIN_INPUT_PULLUP, 0) /* (V3) I2C0_SCL 
*/
+   J721E_IOPAD(0xd8, PIN_INPUT_PULLUP, 0) /* (W2) I2C0_SDA 
*/
+   >;
+   };
+};
+
  {
/* OSPI and HBMC are muxed inside FSS, Bootloader will enable
 * appropriate node based on board detection
@@ -131,3 +140,20 @@ _cluster10 {
 _cluster11 {
status = "disabled";
 };
+
+_i2c0 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_i2c0_pins_default>;
+   clock-frequency = <40>;
+
+   exp_som: gpio@21 {
+   compatible = "ti,tca6408";
+   reg = <0x21>;
+   gpio-controller;
+   #gpio-cells = <2>;
+   gpio-line-names = "USB2.0_MUX_SEL", "CANUART_MUX1_SEL0",
+ "CANUART_MUX2_SEL0", "CANUART_MUX_SEL1",
+ "UART/LIN_MUX_SEL", 
"TRC_D17/AUDIO_REFCLK_SEL",
+ "GPIO_LIN_EN", "CAN_STB";
+   };
+};
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki



[PATCH 2/2] Input: adp5589-keys - do not explicitly control IRQ for wakeup

2020-11-19 Thread Dmitry Torokhov
If device is set up as a wakeup source, I2C core configures the interrupt
line as wake IRQ and PM core automatically configures it for waking up the
system on system suspend transition, so we do not have to explicitly call
enable_irq_wake() and disable_irq_wake() in suspend/resume.

Signed-off-by: Dmitry Torokhov 
---
 drivers/input/keyboard/adp5589-keys.c | 27 +--
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/input/keyboard/adp5589-keys.c 
b/drivers/input/keyboard/adp5589-keys.c
index d76b0e4e67c4..654e0476406b 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1017,32 +1018,22 @@ static int adp5589_probe(struct i2c_client *client,
 
 static int __maybe_unused adp5589_suspend(struct device *dev)
 {
-   struct adp5589_kpad *kpad = dev_get_drvdata(dev);
-   struct i2c_client *client = kpad->client;
-
-   if (!kpad->input)
-   return 0;
-
-   disable_irq(client->irq);
+   struct i2c_client *client = to_i2c_client(dev);
+   struct adp5589_kpad *kpad = i2c_get_clientdata(client);
 
-   if (device_may_wakeup(>dev))
-   enable_irq_wake(client->irq);
+   if (kpad->input)
+   disable_irq(client->irq);
 
return 0;
 }
 
 static int __maybe_unused adp5589_resume(struct device *dev)
 {
-   struct adp5589_kpad *kpad = dev_get_drvdata(dev);
-   struct i2c_client *client = kpad->client;
-
-   if (!kpad->input)
-   return 0;
-
-   if (device_may_wakeup(>dev))
-   disable_irq_wake(client->irq);
+   struct i2c_client *client = to_i2c_client(dev);
+   struct adp5589_kpad *kpad = i2c_get_clientdata(client);
 
-   enable_irq(client->irq);
+   if (kpad->input)
+   enable_irq(client->irq);
 
return 0;
 }
-- 
2.29.2.454.gaff20da3a2-goog



[PATCH] iio: sx9310: Fix semtech,avg-pos-strength setting when > 16

2020-11-19 Thread Stephen Boyd
This DT property can be 0, 16, and then 64, but not 32. The math here
doesn't recognize this slight bump in the power of 2 numbers and
translates a DT property of 64 into the register value '3' when it
really should be '2'. Fix it by subtracting one more if the number being
translated is larger than 16.

Cc: Daniel Campello 
Cc: Lars-Peter Clausen 
Cc: Peter Meerwald-Stadler 
Cc: Douglas Anderson 
Cc: Gwendal Grignou 
Cc: Evan Green 
Signed-off-by: Stephen Boyd 
---

This fixes commit 5b19ca2c78a0 ("iio: sx9310: Set various settings from
DT") in the togreg branch.

 drivers/iio/proximity/sx9310.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
index a2f820997afc..5d8387ed9301 100644
--- a/drivers/iio/proximity/sx9310.c
+++ b/drivers/iio/proximity/sx9310.c
@@ -1305,7 +1305,7 @@ sx9310_get_default_reg(struct sx9310_data *data, int i,
if (ret)
break;
 
-   pos = min(max(ilog2(pos), 3), 10) - 3;
+   pos = min(max(ilog2(pos), 3), 11) - (pos > 16 ? 4 : 3);
reg_def->def &= ~SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK;
reg_def->def |= 
FIELD_PREP(SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK,
   pos);

base-commit: 5b19ca2c78a0838976064c0347e46a2c859b541d
-- 
https://chromeos.dev



Re: [PATCH] m68k/mac: Remove dead code

2020-11-19 Thread Geert Uytterhoeven
On Fri, Nov 20, 2020 at 5:51 AM Finn Thain  wrote:
> Cc: Joshua Thompson 
> Signed-off-by: Finn Thain 

Reviewed-by: Geert Uytterhoeven 
i.e. will queue in the m68k for-v5.11 branch.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v2 2/2] arm64: dts: ti: k3-j7200-common-proc-board: Correct the name of io expander on main_i2c1

2020-11-19 Thread Peter Ujfalusi
J7200 main_i2c1 is connected to the i2c bus on the CPB marked as main_i2c3

The i2c1 devices on the CPB are _not_ connected to the SoC, they are not
usable with the J7200 SOM.

Correct the expander name from exp4 to exp3 and at the same time add the
line names as well.

Signed-off-by: Peter Ujfalusi 
Reviewed-by: Vignesh Raghavendra 
---
 .../arm64/boot/dts/ti/k3-j7200-common-proc-board.dts | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
index 2721137d8943..7110ef3e4092 100644
--- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
+++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
@@ -154,16 +154,26 @@ exp2: gpio@22 {
};
 };
 
+/*
+ * The j7200 CPB board is identical to the CPB used for J721E, the SOMs can be
+ * swapped on the CPB.
+ *
+ * main_i2c1 of J7200 is connected to the CPB i2c bus labeled as i2c3.
+ * The i2c1 of the CPB (as it is labeled) is not connected to j7200.
+ */
 _i2c1 {
pinctrl-names = "default";
pinctrl-0 = <_i2c1_pins_default>;
clock-frequency = <40>;
 
-   exp4: gpio@20 {
+   exp3: gpio@20 {
compatible = "ti,tca6408";
reg = <0x20>;
gpio-controller;
#gpio-cells = <2>;
+   gpio-line-names = "CODEC_RSTz", "CODEC_SPARE1", "UB926_RESETn",
+ "UB926_LOCK", "UB926_PWR_SW_CNTRL",
+ "UB926_TUNER_RESET", "UB926_GPIO_SPARE", "";
};
 };
 
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki



Re: [PATCH] m68k/mac: Update Kconfig help

2020-11-19 Thread Geert Uytterhoeven
On Fri, Nov 20, 2020 at 5:51 AM Finn Thain  wrote:
> There is still some missing hardware support that affects all models,
> such as sound chip and localtalk support. However, many models are well
> supported, including the Quadra 800 emulated by QEMU. Missing hardware
> support is mostly documented at the web site, so add the URL.
>
> Cc: Joshua Thompson 
> Signed-off-by: Finn Thain 

Reviewed-by: Geert Uytterhoeven 
i.e. will queue in the m68k for-v5.11 branch.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v2 0/2] arm64: dts: ti: k3-j7200-som/cpb: Correct i2c bus representations

2020-11-19 Thread Peter Ujfalusi
Hi,

Changes since v1:
- Added REviewed-by from Vignesh
- Comment block to explain main_i2c1 connection to CPB

The main_i2c0 missed the ioexpander present on the SOM itself to control muxes
to route signals to CPB connectors.

The main_i2c1 of J7200 is _not_ connected to the i2c1 of CPB, it is connected to
i2c3, so the devices on the CPB's i2c1 bus are not avalible, but the ones on the
CPB i2c3 are available under the main_i2c1.

Add nice line names at the same time to these.

Regards,
Peter
---
Peter Ujfalusi (2):
  arm64: dts: ti: k3-j7200-som-p0: main_i2c0 have an ioexpander on the
SOM
  arm64: dts: ti: k3-j7200-common-proc-board: Correct the name of io
expander on main_i2c1

 .../dts/ti/k3-j7200-common-proc-board.dts | 23 
 arch/arm64/boot/dts/ti/k3-j7200-som-p0.dtsi   | 26 +++
 2 files changed, 37 insertions(+), 12 deletions(-)

-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki



Re: [PATCH] scsi/atari_scsi: Fix race condition between .queuecommand and EH

2020-11-19 Thread Michael Schmitz

Hi Finn,

thanks for your patch!

Tested on Atari Falcon (with falconide, and pata_falcon modules).

Reviewed-by: Michael Schmitz 
Tested-by: Michael Schmitz 

Am 20.11.2020 um 17:39 schrieb Finn Thain:

It is possible that bus_reset_cleanup() or .eh_abort_handler could
be invoked during NCR5380_queuecommand(). If that takes place before
the new command is enqueued and after the ST-DMA "lock" has been
acquired, the ST-DMA "lock" will be released again. This will result
in a lost DMA interrupt and a command timeout. Fix this by excluding
EH and interrupt handlers while the new command is enqueued.

Signed-off-by: Finn Thain 
---
Michael, would you please send your Acked-by or Reviewed-and-tested-by?
These two patches taken together should be equivalent to the one you tested
recently. I've split it into two as that seemed to make more sense.
---
 drivers/scsi/NCR5380.c|  9 ++---
 drivers/scsi/atari_scsi.c | 10 +++---
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index d654a6cc4162..ea4b5749e7da 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -580,11 +580,14 @@ static int NCR5380_queue_command(struct Scsi_Host 
*instance,

cmd->result = 0;

-   if (!NCR5380_acquire_dma_irq(instance))
-   return SCSI_MLQUEUE_HOST_BUSY;
-
spin_lock_irqsave(>lock, flags);

+   if (!NCR5380_acquire_dma_irq(instance)) {
+   spin_unlock_irqrestore(>lock, flags);
+
+   return SCSI_MLQUEUE_HOST_BUSY;
+   }
+
/*
 * Insert the cmd into the issue queue. Note that REQUEST SENSE
 * commands are added to the head of the queue since any command will
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index a82b63a66635..95d7a3586083 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -376,15 +376,11 @@ static int falcon_get_lock(struct Scsi_Host *instance)
if (IS_A_TT())
return 1;

-   if (stdma_is_locked_by(scsi_falcon_intr) &&
-   instance->hostt->can_queue > 1)
+   if (stdma_is_locked_by(scsi_falcon_intr))
return 1;

-   if (in_interrupt())
-   return stdma_try_lock(scsi_falcon_intr, instance);
-
-   stdma_lock(scsi_falcon_intr, instance);
-   return 1;
+   /* stdma_lock() may sleep which means it can't be used here */
+   return stdma_try_lock(scsi_falcon_intr, instance);
 }

 #ifndef MODULE



Re: [PATCH] usb: typec: Fix num_altmodes kernel-doc error

2020-11-19 Thread Heikki Krogerus
On Thu, Nov 19, 2020 at 10:35:22PM -0800, Prashant Malani wrote:
> The commit to introduce the num_altmodes attribute for partner had an
> error where one of the parameters was named differently in the comment
> and the function signature. Fix the version in the comment to align with
> what is in the function signature.
> 
> This fixes the following htmldocs warning:
> 
> drivers/usb/typec/class.c:632: warning: Excess function parameter
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> 
> Fixes: a0ccdc4a77a1 ("usb: typec: Add number of altmodes partner attr")
> Signed-off-by: Prashant Malani 

Reviewed-by: Heikki Krogerus 

> ---
>  drivers/usb/typec/class.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index e68798599ca8..cb1362187a7c 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -618,7 +618,7 @@ EXPORT_SYMBOL_GPL(typec_partner_set_identity);
>  /**
>   * typec_partner_set_num_altmodes - Set the number of available partner 
> altmodes
>   * @partner: The partner to be updated.
> - * @num_alt_modes: The number of altmodes we want to specify as available.
> + * @num_altmodes: The number of altmodes we want to specify as available.
>   *
>   * This routine is used to report the number of alternate modes supported by 
> the
>   * partner. This value is *not* enforced in alternate mode registration 
> routines.
> -- 
> 2.29.2.454.gaff20da3a2-goog

thanks,

-- 
heikki


Re: [PATCH] scsi/NCR5380: Reduce NCR5380_maybe_release_dma_irq() call sites

2020-11-19 Thread Michael Schmitz

Hi Finn,

thanks for your patch!

Tested on Atari Falcon (with falconide, and pata_falcon modules).

Reviewed-by: Michael Schmitz 
Tested-by: Michael Schmitz 

Am 20.11.2020 um 17:39 schrieb Finn Thain:

Refactor to avoid needless calls to NCR5380_maybe_release_dma_irq().
This makes the machine code smaller and the source more readable.

Signed-off-by: Finn Thain 
---
 drivers/scsi/NCR5380.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index ea4b5749e7da..d597d7493a62 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -725,7 +725,6 @@ static void NCR5380_main(struct work_struct *work)

if (!NCR5380_select(instance, cmd)) {
dsprintk(NDEBUG_MAIN, instance, "main: select 
complete\n");
-   maybe_release_dma_irq(instance);
} else {
dsprintk(NDEBUG_MAIN | NDEBUG_QUEUES, instance,
 "main: select failed, returning %p to 
queue\n", cmd);
@@ -737,8 +736,10 @@ static void NCR5380_main(struct work_struct *work)
NCR5380_information_transfer(instance);
done = 0;
}
-   if (!hostdata->connected)
+   if (!hostdata->connected) {
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+   maybe_release_dma_irq(instance);
+   }
spin_unlock_irq(>lock);
if (!done)
cond_resched();
@@ -1844,7 +1845,6 @@ static void NCR5380_information_transfer(struct Scsi_Host 
*instance)
 */
NCR5380_write(TARGET_COMMAND_REG, 0);

-   maybe_release_dma_irq(instance);
return;
case MESSAGE_REJECT:
/* Accept message by clearing ACK */
@@ -1976,7 +1976,6 @@ static void NCR5380_information_transfer(struct Scsi_Host 
*instance)
hostdata->busy[scmd_id(cmd)] &= ~(1 << 
cmd->device->lun);
cmd->result = DID_ERROR << 16;
complete_cmd(instance, cmd);
-   maybe_release_dma_irq(instance);
return;
}
msgout = NOP;
@@ -2312,7 +2311,6 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
}

queue_work(hostdata->work_q, >main_task);
-   maybe_release_dma_irq(instance);
spin_unlock_irqrestore(>lock, flags);

return result;
@@ -2368,7 +2366,6 @@ static void bus_reset_cleanup(struct Scsi_Host *instance)
hostdata->dma_len = 0;

queue_work(hostdata->work_q, >main_task);
-   maybe_release_dma_irq(instance);
 }

 /**



Re: [PATCH] platform/chrome: cros_ec_typec: Tolerate unrecognized mux flags

2020-11-19 Thread Heikki Krogerus
On Thu, Nov 05, 2020 at 06:03:05PM -0800, Prashant Malani wrote:
> On occasion, the Chrome Embedded Controller (EC) can send a mux
> configuration which doesn't map to a particular data mode. For instance,
> dedicated Type C chargers, when connected, may cause only
> USB_PD_MUX_POLARITY_INVERTED to be set. This is a valid flag combination
> and should not lead to a driver abort.
> 
> Modify the mux configuration handling to not return an error when an
> unrecognized mux flag combination is encountered. Concordantly, make the
> ensuing print a debug level print so as to not pollute the kernel logs.
> 
> Cc: Keith Short 
> Signed-off-by: Prashant Malani 

FWIW:

Acked-by: Heikki Krogerus 

> ---
>  drivers/platform/chrome/cros_ec_typec.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c 
> b/drivers/platform/chrome/cros_ec_typec.c
> index ce031a10eb1b..5b8db02ab84a 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -537,10 +537,9 @@ static int cros_typec_configure_mux(struct 
> cros_typec_data *typec, int port_num,
>   port->state.mode = TYPEC_STATE_USB;
>   ret = typec_mux_set(port->mux, >state);
>   } else {
> - dev_info(typec->dev,
> -  "Unsupported mode requested, mux flags: %x\n",
> -  mux_flags);
> - ret = -ENOTSUPP;
> + dev_dbg(typec->dev,
> + "Unrecognized mode requested, mux flags: %x\n",
> + mux_flags);
>   }
>  
>   return ret;
> -- 
> 2.29.1.341.ge80a0c044ae-goog

thanks,

-- 
heikki


Re: [PATCH] drivers: fpga: Specify HAS_IOMEM dependency for FPGA_DFL

2020-11-19 Thread David Gow
On Fri, Nov 20, 2020 at 2:27 PM Moritz Fischer  wrote:
>
> Hi David,
>
> On Thu, Nov 19, 2020 at 12:22:09AM -0800, David Gow wrote:
> > Because dfl.c uses the 'devm_ioremap', 'devm_iounmap',
> > 'devm_ioremap_resource', and 'devm_platform_ioremap_resource'
> > functions, it should depend on HAS_IOMEM.
> >
> > This fixes make allyesconfig under UML (ARCH=um), which doesn't provide
> > HAS_IOMEM.
> >
> > Signed-off-by: David Gow 
> > ---
> >  drivers/fpga/Kconfig | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> > index 7cd5a29fc437..5645226ca3ce 100644
> > --- a/drivers/fpga/Kconfig
> > +++ b/drivers/fpga/Kconfig
> > @@ -142,6 +142,7 @@ config FPGA_DFL
> >   tristate "FPGA Device Feature List (DFL) support"
> >   select FPGA_BRIDGE
> >   select FPGA_REGION
> > + depends on HAS_IOMEM
> >   help
> > Device Feature List (DFL) defines a feature list structure that
> > creates a linked list of feature headers within the MMIO space
> > --
> > 2.29.2.454.gaff20da3a2-goog
> >
> Do you think we can add a Fixes: tag for this?

Sure. I think it should be:

Fixes: 543be3d ("fpga: add device feature list support")

Let me know if you want me to re-send the patch with that included.

Cheers,
-- David


general protection fault in drm_atomic_set_crtc_for_connector

2020-11-19 Thread syzbot
Hello,

syzbot found the following issue on:

HEAD commit:03430750 Add linux-next specific files for 20201116
git tree:   linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=123c946a50
kernel config:  https://syzkaller.appspot.com/x/.config?x=a1c4c3f27041fdb8
dashboard link: https://syzkaller.appspot.com/bug?extid=1aec08e752387f55c449
compiler:   gcc (GCC) 10.1.0-syz 20200507
syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=1521398150
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1659041650

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+1aec08e752387f55c...@syzkaller.appspotmail.com

general protection fault, probably for non-canonical address 
0xdc00:  [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x-0x0007]
CPU: 1 PID: 8503 Comm: syz-executor619 Not tainted 
5.10.0-rc3-next-20201116-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 
01/01/2011
RIP: 0010:drm_atomic_set_crtc_for_connector+0x426/0x5f0 
drivers/gpu/drm/drm_atomic_uapi.c:342
Code: 00 00 fc ff df 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e 
a6 00 00 00 48 b8 00 00 00 00 00 fc ff df 41 8b 4d 28 <80> 38 00 0f 85 83 01 00 
00 48 8b 2c 25 00 00 00 00 48 b8 00 00 00
RSP: 0018:c900018bf938 EFLAGS: 00010246
RAX: dc00 RBX: 8880116b0100 RCX: 0022
RDX: 111003019a66 RSI: 84302d10 RDI: 8880180cd330
RBP:  R08: 888018051900 R09: 8880180cd343
R10:  R11:  R12: 88801a024800
R13: 8880180cd308 R14: 8880116b0108 R15: 88801cd1b700
FS:  () GS:8880b9f0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 006cf0a0 CR3: 0b08e000 CR4: 001506e0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 update_output_state drivers/gpu/drm/drm_atomic.c:1454 [inline]
 __drm_atomic_helper_set_config+0x72a/0xe80 drivers/gpu/drm/drm_atomic.c:1568
 drm_client_modeset_commit_atomic+0x527/0x7c0 
drivers/gpu/drm/drm_client_modeset.c:1023
 drm_client_modeset_commit_locked+0x145/0x580 
drivers/gpu/drm/drm_client_modeset.c:1145
 drm_client_modeset_commit+0x4d/0x80 drivers/gpu/drm/drm_client_modeset.c:1171
 __drm_fb_helper_restore_fbdev_mode_unlocked 
drivers/gpu/drm/drm_fb_helper.c:252 [inline]
 __drm_fb_helper_restore_fbdev_mode_unlocked 
drivers/gpu/drm/drm_fb_helper.c:231 [inline]
 drm_fb_helper_restore_fbdev_mode_unlocked drivers/gpu/drm/drm_fb_helper.c:279 
[inline]
 drm_fb_helper_lastclose drivers/gpu/drm/drm_fb_helper.c:1942 [inline]
 drm_fbdev_client_restore+0xe3/0x1a0 drivers/gpu/drm/drm_fb_helper.c:2334
 drm_client_dev_restore+0x17f/0x270 drivers/gpu/drm/drm_client.c:226
 drm_lastclose drivers/gpu/drm/drm_file.c:468 [inline]
 drm_release+0x441/0x530 drivers/gpu/drm/drm_file.c:499
 __fput+0x283/0x920 fs/file_table.c:280
 task_work_run+0xdd/0x190 kernel/task_work.c:140
 exit_task_work include/linux/task_work.h:30 [inline]
 do_exit+0xb9b/0x29f0 kernel/exit.c:823
 do_group_exit+0x125/0x310 kernel/exit.c:920
 __do_sys_exit_group kernel/exit.c:931 [inline]
 __se_sys_exit_group kernel/exit.c:929 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:929
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x443b18
Code: Unable to access opcode bytes at RIP 0x443aee.
RSP: 002b:7fff6ec2d738 EFLAGS: 0246 ORIG_RAX: 00e7
RAX: ffda RBX:  RCX: 00443b18
RDX:  RSI: 003c RDI: 
RBP: 004c34f0 R08: 00e7 R09: ffd0
R10:  R11: 0246 R12: 0001
R13: 006d5180 R14:  R15: 
Modules linked in:
---[ end trace f24317b9689e8a7a ]---
RIP: 0010:drm_atomic_set_crtc_for_connector+0x426/0x5f0 
drivers/gpu/drm/drm_atomic_uapi.c:342
Code: 00 00 fc ff df 48 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e 
a6 00 00 00 48 b8 00 00 00 00 00 fc ff df 41 8b 4d 28 <80> 38 00 0f 85 83 01 00 
00 48 8b 2c 25 00 00 00 00 48 b8 00 00 00
RSP: 0018:c900018bf938 EFLAGS: 00010246
RAX: dc00 RBX: 8880116b0100 RCX: 0022
RDX: 111003019a66 RSI: 84302d10 RDI: 8880180cd330
RBP:  R08: 888018051900 R09: 8880180cd343
R10:  R11:  R12: 88801a024800
R13: 8880180cd308 R14: 8880116b0108 R15: 88801cd1b700
FS:  () GS:8880b9f0() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 55ee32e491f8 CR3: 18634000 CR4: 001506e0
DR0:  DR1:  DR2: 

Re: [RFC net-next 1/2] ethtool: add support for controling the type of adaptive coalescing

2020-11-19 Thread Michal Kubecek
On Fri, Nov 20, 2020 at 10:59:59AM +0800, tanhuazhong wrote:
> On 2020/11/20 6:02, Michal Kubecek wrote:
> > 
> > We could use a similar approach as struct ethtool_link_ksettings, e.g.
> > 
> > struct kernel_ethtool_coalesce {
> > struct ethtool_coalesce base;
> > /* new members which are not part of UAPI */
> > }
> > 
> > get_coalesce() and set_coalesce() would get pointer to struct
> > kernel_ethtool_coalesce and ioctl code would be modified to only touch
> > the base (legacy?) part.
> >  > While already changing the ops arguments, we could also add extack
> > pointer, either as a separate argument or as struct member (I slightly
> > prefer the former).
> 
> If changing the ops arguments, each driver who implement
> set_coalesce/get_coalesce of ethtool_ops need to be updated. Is it
> acceptable adding two new ops to get/set ext_coalesce info (like
> ecc31c60240b ("ethtool: Add link extended state") does)? Maybe i can send V2
> in this way, and then could you help to see which one is more suitable?

If it were just this one case, adding an extra op would be perfectly
fine. But from long term point of view, we should expect extending also
other existing ethtool requests and going this way for all of them would
essentially double the number of callbacks in struct ethtool_ops.

Michal


RE: [PATCH v2] Input: st1232 - add support resolution reading

2020-11-19 Thread Valek, Andrej
Hello again Dimitry,

I haven't received any response yet, so I will ask again.

I would like to know, the current status about my other patches for goodix and 
atmel input.
Are there any problems, or what I have to do, to be applied?

Thanks,
Andrej

> Hello Dimitry,
> 
> Thank you for that.
> What about the other patches?
>
> Regards,
> Andrej
>
>> -Original Message-
>> From: Dmitry Torokhov 
>> Sent: Thursday, November 12, 2020 2:54 AM>
>> To: Valek, Andrej (ADV D EU SK SI-BP1) 
>> Cc: linux-in...@vger.kernel.org; linux-kernel@vger.kernel.org; 
>> kbuild-...@lists.01.org
>> Subject: Re: [PATCH v2] Input: st1232 - add support resolution reading
>> 
>> On Tue, Nov 03, 2020 at 08:39:49AM +0100, Andrej Valek wrote:
>>> Hard-coding resolution for st1633 device was wrong. Some of LCDs like 
>>> YTS700TLBC-02-100C has assembled Sitronix st1633 touchcontroller too.
>>> But the resolution is not 320x480 as was hard-coded.
>>> Add new function which reads correct resolution directly from register.
>>> 
>>> Signed-off-by: Andrej Valek 
>>
>> Applied, thank you.
>>
> --
>> Dmitry


Re: [PATCH net] bnxt_en: fix error return code in bnxt_init_board()

2020-11-19 Thread Michael Chan
On Thu, Nov 19, 2020 at 9:53 PM Jakub Kicinski  wrote:
>
> On Thu, 19 Nov 2020 10:53:23 -0800 Edwin Peer wrote:
> > > Fix to return a negative error code from the error handling
> > > case instead of 0, as done elsewhere in this function.
> > >
> > > Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.")
> > > Reported-by: Hulk Robot 
> > > Signed-off-by: Zhang Changzhong 
>
> > > if (dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64)) != 0 
> > > &&
> > > dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32)) != 0) 
> > > {
> > > dev_err(>dev, "System does not support DMA, 
> > > aborting\n");
> > > +   rc = -EIO;
> > > goto init_err_disable;
>
> Edwin, please double check if this shouldn't jump to
> pci_release_regions() (or maybe it's harmless 'cause
> PCI likes to magically release things on its own).

Good point.  We definitely should call pci_release_regions() for correctness.

I will send out the patch shortly.  Thanks.


smime.p7s
Description: S/MIME Cryptographic Signature


nouveau: WARNING: CPU: 0 PID: 20957 at drivers/gpu/drm/nouveau/nvif/vmm.c:71

2020-11-19 Thread Mike Galbraith
[15561.391527] [ cut here ]
[15561.391560] WARNING: CPU: 0 PID: 20957 at 
drivers/gpu/drm/nouveau/nvif/vmm.c:71 nvif_vmm_put+0x4a/0x50 [nouveau]
[15561.391562] Modules linked in: nls_utf8(E) isofs(E) fuse(E) msr(E) 
xt_comment(E) br_netfilter(E) xt_physdev(E) nfnetlink_cthelper(E) nfnetlink(E) 
ebtable_filter(E) ebtables(E) af_packet(E) bridge(E) stp(E) llc(E) 
iscsi_ibft(E) iscsi_boot_sysfs(E) rfkill(E) xt_pkttype(E) xt_tcpudp(E) 
ip6t_REJECT(E) nf_reject_ipv6(E) ipt_REJECT(E) nf_reject_ipv4(E) 
iptable_filter(E) bpfilter(E) ip6table_mangle(E) ip_tables(E) xt_conntrack(E) 
nf_conntrack(E) nf_defrag_ipv6(E) nf_defrag_ipv4(E) libcrc32c(E) 
ip6table_filter(E) ip6_tables(E) x_tables(E) hid_logitech_hidpp(E) sr_mod(E) 
usblp(E) cdrom(E) hid_logitech_dj(E) joydev(E) intel_rapl_msr(E) 
intel_rapl_common(E) at24(E) mei_hdcp(E) iTCO_wdt(E) regmap_i2c(E) 
intel_pmc_bxt(E) iTCO_vendor_support(E) snd_hda_codec_realtek(E) 
snd_hda_codec_generic(E) ledtrig_audio(E) snd_hda_codec_hdmi(E) 
x86_pkg_temp_thermal(E) intel_powerclamp(E) snd_hda_intel(E) coretemp(E) 
snd_intel_dspcfg(E) kvm_intel(E) snd_hda_codec(E) snd_hwdep(E) snd_hda_core(E) 
kvm(E)
[15561.391586]  nls_iso8859_1(E) nls_cp437(E) snd_pcm(E) irqbypass(E) 
crct10dif_pclmul(E) snd_timer(E) crc32_pclmul(E) r8169(E) 
ghash_clmulni_intel(E) snd(E) aesni_intel(E) realtek(E) crypto_simd(E) 
i2c_i801(E) mei_me(E) mdio_devres(E) cryptd(E) pcspkr(E) soundcore(E) 
i2c_smbus(E) lpc_ich(E) glue_helper(E) mfd_core(E) libphy(E) mei(E) fan(E) 
thermal(E) intel_smartconnect(E) nfsd(E) auth_rpcgss(E) nfs_acl(E) lockd(E) 
grace(E) sch_fq_codel(E) sunrpc(E) nfs_ssc(E) uas(E) usb_storage(E) 
hid_generic(E) usbhid(E) nouveau(E) wmi(E) i2c_algo_bit(E) drm_kms_helper(E) 
syscopyarea(E) sysfillrect(E) sysimgblt(E) fb_sys_fops(E) xhci_pci(E) cec(E) 
ahci(E) rc_core(E) ehci_pci(E) xhci_hcd(E) ttm(E) libahci(E) ehci_hcd(E) 
libata(E) drm(E) usbcore(E) video(E) button(E) sd_mod(E) t10_pi(E) vfat(E) 
fat(E) virtio_blk(E) virtio_mmio(E) virtio_ring(E) virtio(E) ext4(E) 
crc32c_intel(E) crc16(E) mbcache(E) jbd2(E) loop(E) sg(E) dm_multipath(E) 
dm_mod(E) scsi_dh_rdac(E) scsi_dh_emc(E) scsi_dh_alua(E) scsi_mod(E)
[15561.391626]  efivarfs(E) autofs4(E)
[15561.391637] CPU: 0 PID: 20957 Comm: kworker/0:4 Kdump: loaded Tainted: G S   
   E 5.10.0.g9c87c9f-master #3
[15561.391640] Hardware name: MEDION MS-7848/MS-7848, BIOS M7848W08.20C 
09/23/2013
[15561.391667] Workqueue: events nouveau_cli_work [nouveau]
[15561.391682] RIP: 0010:nvif_vmm_put+0x4a/0x50 [nouveau]
[15561.391684] Code: 00 00 00 48 89 e2 48 c7 04 24 00 00 00 00 48 89 44 24 08 
e8 48 e7 ff ff 85 c0 75 0e 48 c7 43 08 00 00 00 00 48 83 c4 10 5b c3 <0f> 0b eb 
ee 66 90 0f 1f 44 00 00 53 48 83 ec 18 83 fe 01 48 8b 5c
[15561.391686] RSP: :8881feca7e08 EFLAGS: 00010282
[15561.391688] RAX: fffe RBX: 8881feca7e28 RCX: 
[15561.391690] RDX: 0010 RSI: 8881feca7d80 RDI: 8881feca7e18
[15561.391692] RBP: 8881feca7e50 R08: 01dc5000 R09: 
[15561.391693] R10: 82003de8 R11: fefefefefefefeff R12: dead0122
[15561.391695] R13: dead0100 R14: 888102fa9328 R15: 888102fa9308
[15561.391697] FS:  () GS:88841ec0() 
knlGS:
[15561.391698] CS:  0010 DS:  ES:  CR0: 80050033
[15561.391700] CR2: 7fd692058000 CR3: 03c10002 CR4: 001706f0
[15561.391701] Call Trace:
[15561.391729]  nouveau_vma_del+0x58/0xa0 [nouveau]
[15561.391755]  nouveau_gem_object_delete_work+0x26/0x40 [nouveau]
[15561.391782]  nouveau_cli_work+0x76/0x120 [nouveau]
[15561.391786]  ? __schedule+0x35c/0x770
[15561.391790]  process_one_work+0x1f5/0x3c0
[15561.391792]  ? process_one_work+0x3c0/0x3c0
[15561.391794]  worker_thread+0x2d/0x3d0
[15561.391796]  ? process_one_work+0x3c0/0x3c0
[15561.391798]  kthread+0x117/0x130
[15561.391800]  ? kthread_park+0x90/0x90
[15561.391803]  ret_from_fork+0x1f/0x30
[15561.391806] ---[ end trace 1f8ba448e97e64e0 ]---



Re: [PATCH] lib: stackdepot: Add support to configure STACK_HASH_SIZE

2020-11-19 Thread Zhenhua Huang
On Fri, Nov 20, 2020 at 01:04:23PM +0800, Minchan Kim wrote:
> On Thu, Nov 19, 2020 at 11:34:32AM +0800, Zhenhua Huang wrote:
> > On Wed, Nov 04, 2020 at 07:27:03AM +0800, Minchan Kim wrote:
> > > Sorry if this mail corrupts the mail thread or had heavy mangling
> > > since I lost this mail from my mailbox so I am sending this mail by
> > > web gmail.
> > > 
> > > On Thu, Oct 22, 2020 at 10:18 AM  wrote:
> > > >
> > > > From: Yogesh Lal 
> > > >
> > > > Use STACK_HASH_ORDER_SHIFT to configure STACK_HASH_SIZE.
> > > >
> > > > Aim is to have configurable value for  STACK_HASH_SIZE,
> > > > so depend on use case one can configure it.
> > > >
> > > > One example is of Page Owner, default value of
> > > > STACK_HASH_SIZE lead stack depot to consume 8MB of static memory.
> > > > Making it configurable and use lower value helps to enable features
> like
> > > > CONFIG_PAGE_OWNER without any significant overhead.
> > > >
> > > > Signed-off-by: Yogesh Lal 
> > > > Signed-off-by: Vinayak Menon 
> > > > Signed-off-by: Vijayanand Jitta 
> > > > ---
> > > >  lib/Kconfig  | 9 +
> > > >  lib/stackdepot.c | 3 +--
> > > >  2 files changed, 10 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/lib/Kconfig b/lib/Kconfig
> > > > index 18d76b6..b3f8259 100644
> > > > --- a/lib/Kconfig
> > > > +++ b/lib/Kconfig
> > > > @@ -651,6 +651,15 @@ config STACKDEPOT
> > > > bool
> > > > select STACKTRACE
> > > >
> > > > +config STACK_HASH_ORDER_SHIFT
> > > > +   int "stack depot hash size (12 => 4KB, 20 => 1024KB)"
> > > > +   range 12 20
> > > > +   default 20
> > > > +   depends on STACKDEPOT
> > > > +   help
> > > > +Select the hash size as a power of 2 for the stackdepot
> hash 
> > > > table.
> > > > +Choose a lower value to reduce the memory impact.
> > > > +
> > > >  config SBITMAP
> > > > bool
> > > >
> > > > diff --git a/lib/stackdepot.c b/lib/stackdepot.c
> > > > index 2caffc6..413c20b 100644
> > > > --- a/lib/stackdepot.c
> > > > +++ b/lib/stackdepot.c
> > > > @@ -142,8 +142,7 @@ static struct stack_record
> *depot_alloc_stack(unsigned 
> > > > long *entries, int size,
> > > > return stack;
> > > >  }
> > > >
> > > > -#define STACK_HASH_ORDER 20
> > > > -#define STACK_HASH_SIZE (1L << STACK_HASH_ORDER)
> > > > +#define STACK_HASH_SIZE (1L << CONFIG_STACK_HASH_ORDER_SHIFT)
> > > >  #define STACK_HASH_MASK (STACK_HASH_SIZE - 1)
> > > >  #define STACK_HASH_SEED 0x9747b28c
> > > >
> > > > --
> > > > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
> member 
> > > > of Code Aurora Forum, hosted by The Linux Foundation
> > > > 2.7.4
> > > >
> > > 
> > > 1. When we don't use page_owner, we don't want to waste any memory for
> > > stackdepot hash array.
> > > 2. When we use page_owner, we want to have reasonable stackdeport hash
> array
> > > 
> > > With this configuration, it couldn't meet since we always need to
> > > reserve a reasonable size for the array.
> > > Can't we make the hash size as a kernel parameter?
> > > With it, we could use it like this.
> > > 
> > > 1. page_owner=off, stackdepot_stack_hash=0 -> no more wasted memory
> > > when we don't use page_owner
> > > 2. page_owner=on, stackdepot_stack_hash=8M -> reasonable hash size
> > > when we use page_owner.
> > Seems we have other users like kasan, and dma_buf_ref which we
> introduced.
> > Also we can't guarantee there will not be any other users for
> stackdepot, so
> > it's better we not depend on only page owner?
> 
> I didn't mean to make it page_owner dependent. What I suggested is just
> to define kernel parameter for stackdeport hash size so admin could
> override it at right size when we really need it.
OK, Thanks Minchan for explanation. It's a good idea then, admin needs to
consider all users but, especailly when setting it to 0...

Thanks,
Zhenhua


Re: [PATCH 2/2] arm64: dts: ti: k3-j7200-common-proc-board: Correct the name of io expander on main_i2c1

2020-11-19 Thread Peter Ujfalusi



On 19/11/2020 18.10, Vignesh Raghavendra wrote:
> 
> 
> On 11/19/20 6:56 PM, Peter Ujfalusi wrote:
>> J7200 main_i2c1 is connected to the i2c bus on the CPB marked as main_i2c3
>>
>> The i2c1 devices on the CPB are _not_ connected to the SoC, they are not
>> usable with the J7200 SOM.
>>
>> Correct the expander name from exp4 to exp3 and at the same time add the
>> line names as well.
>>
>> Signed-off-by: Peter Ujfalusi 
>> ---
> 
> Yes, the schematics call this expander as exp3. Thanks for the fix

The CPB is the same for both j721e and j7200 SOMs.
I'll send v2 with a small comment block to explain this.

> Reviewed-by: Vignesh Raghavendra 
> 
>>  arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts 
>> b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> index 2721137d8943..83e043c65f81 100644
>> --- a/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> +++ b/arch/arm64/boot/dts/ti/k3-j7200-common-proc-board.dts
>> @@ -159,11 +159,14 @@ _i2c1 {
>>  pinctrl-0 = <_i2c1_pins_default>;
>>  clock-frequency = <40>;
>>  
>> -exp4: gpio@20 {
>> +exp3: gpio@20 {
>>  compatible = "ti,tca6408";
>>  reg = <0x20>;
>>  gpio-controller;
>>  #gpio-cells = <2>;
>> +gpio-line-names = "CODEC_RSTz", "CODEC_SPARE1", "UB926_RESETn",
>> +  "UB926_LOCK", "UB926_PWR_SW_CNTRL",
>> +  "UB926_TUNER_RESET", "UB926_GPIO_SPARE", "";
> 
> I assume these lines have same meaning in J721e and J7200? If so, then
> no issues.
> 
>>  };
>>  };
>>  
>>

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


Re: [PATCH v2] mdio_bus: suppress err message for reset gpio EPROBE_DEFER

2020-11-19 Thread Joe Perches
On Thu, 2020-11-19 at 21:21 -0800, Jakub Kicinski wrote:
> We do have our own comment style rule in networking since the beginning
> of time, and reverse xmas tree, so it's not completely crazy.

reverse xmas tree is completely crazy.

But I posted a patch to checkpatch to suggest it for net/
and drivers/net/ once

https://lkml.org/lkml/2016/11/4/54




Re: Wifi hangs

2020-11-19 Thread Coelho, Luciano
Adding Guy Damary

Guy, can you help with this one? I believe there is a bugzilla issue
for this already...

--
Cheers,
Luca.


On Thu, 2020-11-19 at 17:42 +0100, Gonsolo wrote:
> Hi!
> 
> Sporadically my wifi hangs. Any idea why?
> This is on a 5.10.0-051000rc2-lowlatency kernel from
> https://kernel.ubuntu.com/~kernel-ppa/mainline.
> I have to stop and start the device to make it work again.
> From dmesg:
> 
> [  +0,000101] [ cut here ]
> [  +0,02] TX on unused queue 5
> [  +0,49] WARNING: CPU: 2 PID: 20577 at
> drivers/net/wireless/intel/iwlwifi/pcie/tx.c:1927
> iwl_trans_pcie_tx+0x676/0x7f0 [iwlwifi]
> [  +0,03] Modules linked in: dvb_usb_af9035 uas usb_storage
> dvb_usb_v2 dvb_core rfcomm ccm snd_seq_dummy snd_hrtimer cmac
> algif_hash algif_skcipher af_alg bnep binfmt_misc nls_iso8859_1
> snd_hda_codec_hdmi intel_rapl_msr snd_hda_codec_realtek
> snd_hda_codec_generic snd_hda_intel snd_intel_dspcfg snd_hda_codec
> snd_hda_core snd_hwdep pn544_mei mei_phy pn544 cdc_mbim
> intel_rapl_common snd_pcm x86_pkg_temp_thermal intel_powerclamp
> coretemp hci snd_seq_midi cdc_wdm qcserial kvm_intel nfc
> snd_seq_midi_event usb_wwan mei_hdcp dell_laptop kvm ledtrig_audio
> cdc_ncm usbserial snd_rawmidi cdc_ether crct10dif_pclmul usbnet
> ghash_clmulni_intel mii dell_smm_hwmon iwlmvm mac80211 libarc4
> aesni_intel crypto_simd uvcvideo videobuf2_vmalloc iwlwifi cryptd
> glue_helper rapl intel_cstate snd_seq btusb btrtl btbcm
> videobuf2_memops i915 btintel bluetooth videobuf2_v4l2
> videobuf2_common snd_seq_device videodev dell_wmi snd_timer input_leds
> joydev dell_smbios mc dcdbas ecdh_generic ecc sparse_keymap cfg80211
> [  +0,79]  serio_raw at24 wmi_bmof dell_wmi_descriptor efi_pstore
> snd drm_kms_helper cec rc_core mei_me i2c_algo_bit fb_sys_fops
> syscopyarea sysfillrect mei soundcore sysimgblt dell_rbtn mac_hid
> sch_fq_codel parport_pc ppdev lp drm parport ip_tables x_tables
> autofs4 hid_logitech_hidpp hid_logitech_dj hid_generic usbhid hid
> sdhci_pci crc32_pclmul i2c_i801 psmouse cqhci i2c_smbus sdhci ahci
> libahci lpc_ich e1000e xhci_pci wmi xhci_pci_renesas video [last
> unloaded: dvb_usb_af9035]
> [  +0,49] CPU: 2 PID: 20577 Comm: kworker/2:1 Not tainted
> 5.10.0-051000rc2-lowlatency #202011012330
> [  +0,01] Hardware name: Dell Inc. Latitude E7240/0R6F3F, BIOS A29
> 06/13/2019
> [  +0,29] Workqueue: events cfg80211_rfkill_block_work [cfg80211]
> [  +0,13] RIP: 0010:iwl_trans_pcie_tx+0x676/0x7f0 [iwlwifi]
> [  +0,05] Code: 3d 03 5e 03 00 00 b8 ea ff ff ff 0f 85 eb fc ff ff
> 44 89 fe 48 c7 c7 5d b5 d3 c0 89 45 d0 c6 05 e4 5d 03 00 01 e8 7b 5d
> 4b c4 <0f> 0b 8b 45 d0 e9 c8 fc ff ff 41 0f b6 86 80 00 00 00 83 e0 60
> 3c
> [  +0,02] RSP: 0018:af8f00e1f680 EFLAGS: 00010282
> [  +0,02] RAX:  RBX: 9b8c8d0d0900 RCX: 
> 9b8e96b18988
> [  +0,01] RDX: ffd8 RSI: 0027 RDI: 
> 9b8e96b18980
> [  +0,01] RBP: af8f00e1f6e0 R08:  R09: 
> af8f00e1f470
> [  +0,02] R10: af8f00e1f468 R11: 86353c28 R12: 
> 9b8d823243e8
> [  +0,01] R13: 0037 R14: 0005 R15: 
> 0005
> [  +0,02] FS:  () GS:9b8e96b0()
> knlGS:
> [  +0,02] CS:  0010 DS:  ES:  CR0: 80050033
> [  +0,01] CR2: 3a4e0b5b3080 CR3: 000105a0c002 CR4: 
> 001706e0
> [  +0,02] Call Trace:
> [  +0,20]  iwl_mvm_tx_mpdu+0x1e0/0x590 [iwlmvm]
> [  +0,11]  iwl_mvm_tx_skb_sta+0x153/0x1e0 [iwlmvm]
> [  +0,08]  iwl_mvm_tx_skb+0x1c/0x40 [iwlmvm]
> [  +0,08]  iwl_mvm_mac_itxq_xmit+0x7a/0xe0 [iwlmvm]
> [  +0,10]  iwl_mvm_mac_wake_tx_queue+0x29/0x80 [iwlmvm]
> [  +0,29]  drv_wake_tx_queue+0x51/0xe0 [mac80211]
> [  +0,23]  ieee80211_queue_skb+0x15b/0x220 [mac80211]
> [  +0,35]  ieee80211_tx+0xd6/0x140 [mac80211]
> [  +0,25]  ieee80211_xmit+0xb8/0xf0 [mac80211]
> [  +0,24]  __ieee80211_tx_skb_tid_band+0x6d/0x80 [mac80211]
> [  +0,22]  ieee80211_send_deauth_disassoc+0xff/0x130 [mac80211]
> [  +0,24]  ieee80211_set_disassoc+0x3ae/0x4b0 [mac80211]
> [  +0,27]  ieee80211_mgd_deauth+0x106/0x300 [mac80211]
> [  +0,04]  ? __update_blocked_fair+0xda/0x3f0
> [  +0,04]  ? acpi_ut_delete_object_desc+0xa2/0xa6
> [  +0,22]  ieee80211_deauth+0x18/0x20 [mac80211]
> [  +0,28]  cfg80211_mlme_deauth+0xb2/0x1e0 [cfg80211]
> [  +0,22]  cfg80211_mlme_down+0x64/0x80 [cfg80211]
> [  +0,21]  cfg80211_disconnect+0x157/0x210 [cfg80211]
> [  +0,21]  __cfg80211_leave+0x133/0x1b0 [cfg80211]
> [  +0,20]  cfg80211_netdev_notifier_call+0x1bf/0x5c0 [cfg80211]
> [  +0,09]  ? iwl_mvm_nic_error+0x40/0x40 [iwlmvm]
> [  +0,11]  ? iwl_mvm_send_cmd_pdu+0x54/0x90 [iwlmvm]
> [  +0,09]  ? iwl_mvm_send_cmd+0x1f/0x50 [iwlmvm]
> [  +0,08]  ? iwl_mvm_mc_iface_iterator+0xb9/0xe0 [iwlmvm]
> [  +0,23]  ? 

Re: [PATCH] crypto: allwinner: sun8i-ce: fix two error path's memory leak

2020-11-19 Thread Herbert Xu
On Sun, Nov 15, 2020 at 07:08:07PM +, Corentin Labbe wrote:
> This patch fixes the following smatch warnings:
> drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c:412
> sun8i_ce_hash_run() warn: possible memory leak of 'result'
> Note: "buf" is leaked as well.
> 
> Furthermore, in case of ENOMEM, crypto_finalize_hash_request() was not
> called which was an error.
> 
> Fixes: 56f6d5aee88d ("crypto: sun8i-ce - support hash algorithms")
> Reported-by: kernel test robot 
> Reported-by: Dan Carpenter 
> Signed-off-by: Corentin Labbe 
> ---
>  .../crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 20 +++
>  1 file changed, 12 insertions(+), 8 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] crypto: hisilicon/zip - add a work_queue for zip irq

2020-11-19 Thread Herbert Xu
On Fri, Nov 13, 2020 at 05:32:35PM +0800, Yang Shen wrote:
> The patch 'irqchip/gic-v3-its: Balance initial LPI affinity across CPUs'
> set the IRQ to an uncentain CPU. If an IRQ is bound to the CPU used by the
> thread which is sending request, the throughput will be just half.
> 
> So allocate a 'work_queue' and set as 'WQ_UNBOUND' to do the back half work
> on some different CPUS.
> 
> Signed-off-by: Yang Shen 
> Reviewed-by: Zaibo Xu 
> ---
>  drivers/crypto/hisilicon/zip/zip_main.c | 26 +++---
>  1 file changed, 23 insertions(+), 3 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] crypto: crypto4xx - Replace bitwise OR with logical OR in crypto4xx_build_pd

2020-11-19 Thread Herbert Xu
On Thu, Nov 12, 2020 at 01:07:02PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/crypto/amcc/crypto4xx_core.c:921:60: warning: operator '?:' has
> lower precedence than '|'; '|' will be evaluated first
> [-Wbitwise-conditional-parentheses]
>  (crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
>  ~~~ ^
> drivers/crypto/amcc/crypto4xx_core.c:921:60: note: place parentheses
> around the '|' expression to silence this warning
>  (crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
>  ^
> )
> drivers/crypto/amcc/crypto4xx_core.c:921:60: note: place parentheses
> around the '?:' expression to evaluate it first
>  (crypto_tfm_alg_type(req->tfm) == CRYPTO_ALG_TYPE_AEAD) ?
>  ^
>  (
> 1 warning generated.
> 
> It looks like this should have been a logical OR so that
> PD_CTL_HASH_FINAL gets added to the w bitmask if crypto_tfm_alg_type
> is either CRYPTO_ALG_TYPE_AHASH or CRYPTO_ALG_TYPE_AEAD. Change the
> operator so that everything works properly.
> 
> Fixes: 4b5b79998af6 ("crypto: crypto4xx - fix stalls under heavy load")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1198
> Signed-off-by: Nathan Chancellor 
> ---
>  drivers/crypto/amcc/crypto4xx_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: crypto: caam/qi - simplify error path for context allocation

2020-11-19 Thread Herbert Xu
On Thu, Nov 12, 2020 at 11:21:46AM +0200, Horia Geantă wrote:
> 
> Wang Qing reports that IS_ERR_OR_NULL() should be matched with
> PTR_ERR_OR_ZERO(), not PTR_ERR().
> 
> As it turns out, the error path always returns an error code,
> i.e. NULL is never returned.
> Update the code accordingly - s/IS_ERR_OR_NULL/IS_ERR.
> 
> Reported-by: Wang Qing 
> Signed-off-by: Horia Geantă 
> ---
>  drivers/crypto/caam/caamalg_qi.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH] usb: musb: remove unused variable 'devctl'

2020-11-19 Thread Greg Kroah-Hartman
On Fri, Nov 20, 2020 at 02:48:50PM +0800, Min Guo wrote:
> Hi greg k-h:
> On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> > On Tue, Nov 17, 2020 at 04:21:25PM +0800, min@mediatek.com wrote:
> > > From: Min Guo 
> > > 
> > > Remove unused 'devctl' variable to fix compile warnings:
> > > 
> > > drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > > drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > > but not used [-Wunused-but-set-variable]
> > > 
> > > Signed-off-by: Min Guo 
> > > ---
> > >  drivers/usb/musb/musbhsdma.c | 4 
> > >  1 file changed, 4 deletions(-)
> > > 
> > > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > > index 0aacfc8be5a1..7acd1635850d 100644
> > > --- a/drivers/usb/musb/musbhsdma.c
> > > +++ b/drivers/usb/musb/musbhsdma.c
> > > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void 
> > > *private_data)
> > >   musb_channel->channel.status =
> > >   MUSB_DMA_STATUS_BUS_ABORT;
> > >   } else {
> > > - u8 devctl;
> > > -
> > >   addr = musb_read_hsdma_addr(mbase,
> > >   bchannel);
> > >   channel->actual_len = addr
> > > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void 
> > > *private_data)
> > >   < musb_channel->len) ?
> > >   "=> reconfig 0" : "=> complete");
> > >  
> > > - devctl = musb_readb(mbase, MUSB_DEVCTL);
> > 
> > Are you sure that the hardware does not require this read to complete
> > the command?  Lots of hardware is that way, so be very careful about
> > this.  Did you test it?
> 
> I have tested this patch on Mediatek's platform, and not sure if it
> will affect other vendors' platforms.
> 
> Dear Bin:
> 
> Does this patch will affect other vendors' platforms?

The hardware specs will answer this question, what do they say about
this read?

thanks,

greg k-h


[PATCH] drm/ttm: remove unused varibles

2020-11-19 Thread Tian Tao
fixed the following warnings
drivers/gpu/drm/nouveau/nouveau_bo.c:1227:17: warning: variable ‘dev’
set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/nouveau/nouveau_bo.c:1251:17: warning: variable ‘dev’
set but not used [-Wunused-but-set-variable]

Signed-off-by: Tian Tao 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7aa4286..9465f56 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1228,7 +1228,6 @@ nouveau_ttm_tt_populate(struct ttm_bo_device *bdev,
 {
struct ttm_tt *ttm_dma = (void *)ttm;
struct nouveau_drm *drm;
-   struct device *dev;
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
 
if (ttm_tt_is_populated(ttm))
@@ -1242,7 +1241,6 @@ nouveau_ttm_tt_populate(struct ttm_bo_device *bdev,
}
 
drm = nouveau_bdev(bdev);
-   dev = drm->dev->dev;
 
return ttm_pool_alloc(>ttm.bdev.pool, ttm, ctx);
 }
-- 
2.7.4



[PATCH v5 21/21] mm/hugetlb: Disable freeing vmemmap if struct page size is not power of two

2020-11-19 Thread Muchun Song
We only can free the unused vmemmap to the buddy system when the
size of struct page is a power of two.

Signed-off-by: Muchun Song 
---
 mm/hugetlb_vmemmap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index c3b3fc041903..7bb749a3eea2 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -671,7 +671,8 @@ void __init hugetlb_vmemmap_init(struct hstate *h)
unsigned int order = huge_page_order(h);
unsigned int vmemmap_pages;
 
-   if (hugetlb_free_vmemmap_disabled) {
+   if (hugetlb_free_vmemmap_disabled ||
+   !is_power_of_2(sizeof(struct page))) {
pr_info("disable free vmemmap pages for %s\n", h->name);
return;
}
-- 
2.11.0



[PATCH v5 20/21] mm/hugetlb: Add BUILD_BUG_ON to catch invalid usage of tail struct page

2020-11-19 Thread Muchun Song
There are only `RESERVE_VMEMMAP_SIZE / sizeof(struct page)` struct pages
can be used when CONFIG_HUGETLB_PAGE_FREE_VMEMMAP, so add a BUILD_BUG_ON
to catch this invalid usage of tail struct page.

Signed-off-by: Muchun Song 
---
 mm/hugetlb_vmemmap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index bf2b6b3e75af..c3b3fc041903 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -750,6 +750,9 @@ static int __init vmemmap_ptlock_init(void)
 {
int nid;
 
+   BUILD_BUG_ON(NR_USED_SUBPAGE >=
+RESERVE_VMEMMAP_SIZE / sizeof(struct page));
+
if (!hugepages_supported())
return 0;
 
-- 
2.11.0



Re: [PATCH] usb: musb: remove unused variable 'devctl'

2020-11-19 Thread Min Guo
Hi greg k-h:
On Wed, 2020-11-18 at 12:48 +0100, Greg Kroah-Hartman wrote:
> On Tue, Nov 17, 2020 at 04:21:25PM +0800, min@mediatek.com wrote:
> > From: Min Guo 
> > 
> > Remove unused 'devctl' variable to fix compile warnings:
> > 
> > drivers/usb/musb/musbhsdma.c: In function 'dma_controller_irq':
> > drivers/usb/musb/musbhsdma.c:324:8: warning: variable 'devctl' set
> > but not used [-Wunused-but-set-variable]
> > 
> > Signed-off-by: Min Guo 
> > ---
> >  drivers/usb/musb/musbhsdma.c | 4 
> >  1 file changed, 4 deletions(-)
> > 
> > diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
> > index 0aacfc8be5a1..7acd1635850d 100644
> > --- a/drivers/usb/musb/musbhsdma.c
> > +++ b/drivers/usb/musb/musbhsdma.c
> > @@ -321,8 +321,6 @@ irqreturn_t dma_controller_irq(int irq, void 
> > *private_data)
> > musb_channel->channel.status =
> > MUSB_DMA_STATUS_BUS_ABORT;
> > } else {
> > -   u8 devctl;
> > -
> > addr = musb_read_hsdma_addr(mbase,
> > bchannel);
> > channel->actual_len = addr
> > @@ -336,8 +334,6 @@ irqreturn_t dma_controller_irq(int irq, void 
> > *private_data)
> > < musb_channel->len) ?
> > "=> reconfig 0" : "=> complete");
> >  
> > -   devctl = musb_readb(mbase, MUSB_DEVCTL);
> 
> Are you sure that the hardware does not require this read to complete
> the command?  Lots of hardware is that way, so be very careful about
> this.  Did you test it?

I have tested this patch on Mediatek's platform, and not sure if it
will affect other vendors' platforms.

Dear Bin:

Does this patch will affect other vendors' platforms?

Best Regards,
Min

> thanks,
> 
> greg k-h



[PATCH v5 19/21] mm/hugetlb: Gather discrete indexes of tail page

2020-11-19 Thread Muchun Song
For hugetlb page, there are more metadata to save in the struct
page. But the head struct page cannot meet our needs, so we have
to abuse other tail struct page to store the metadata. In order
to avoid conflicts caused by subsequent use of more tail struct
pages, we can gather these discrete indexes of tail struct page
In this case, it will be easier to add a new tail page index later.

Signed-off-by: Muchun Song 
---
 include/linux/hugetlb.h| 13 +
 include/linux/hugetlb_cgroup.h | 15 +--
 mm/hugetlb.c   | 12 ++--
 mm/hugetlb_vmemmap.h   |  4 ++--
 4 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index da18fc9ed152..fa9d38a3ac6f 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -28,6 +28,19 @@ typedef struct { unsigned long pd; } hugepd_t;
 #include 
 #include 
 
+enum {
+   SUBPAGE_INDEX_ACTIVE = 1,   /* reuse page flags of PG_private */
+   SUBPAGE_INDEX_TEMPORARY,/* reuse page->mapping */
+#ifdef CONFIG_CGROUP_HUGETLB
+   SUBPAGE_INDEX_CGROUP = SUBPAGE_INDEX_TEMPORARY,/* reuse page->private */
+   SUBPAGE_INDEX_CGROUP_RSVD,  /* reuse page->private */
+#endif
+#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
+   SUBPAGE_INDEX_HWPOISON, /* reuse page->private */
+#endif
+   NR_USED_SUBPAGE,
+};
+
 struct hugepage_subpool {
spinlock_t lock;
long count;
diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h
index 2ad6e92f124a..3d3c1c49efe4 100644
--- a/include/linux/hugetlb_cgroup.h
+++ b/include/linux/hugetlb_cgroup.h
@@ -24,8 +24,9 @@ struct file_region;
 /*
  * Minimum page order trackable by hugetlb cgroup.
  * At least 4 pages are necessary for all the tracking information.
- * The second tail page (hpage[2]) is the fault usage cgroup.
- * The third tail page (hpage[3]) is the reservation usage cgroup.
+ * The second tail page (hpage[SUBPAGE_INDEX_CGROUP]) is the fault
+ * usage cgroup. The third tail page (hpage[SUBPAGE_INDEX_CGROUP_RSVD])
+ * is the reservation usage cgroup.
  */
 #define HUGETLB_CGROUP_MIN_ORDER   2
 
@@ -66,9 +67,9 @@ __hugetlb_cgroup_from_page(struct page *page, bool rsvd)
if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
return NULL;
if (rsvd)
-   return (struct hugetlb_cgroup *)page[3].private;
+   return (void *)page_private(page + SUBPAGE_INDEX_CGROUP_RSVD);
else
-   return (struct hugetlb_cgroup *)page[2].private;
+   return (void *)page_private(page + SUBPAGE_INDEX_CGROUP);
 }
 
 static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page 
*page)
@@ -90,9 +91,11 @@ static inline int __set_hugetlb_cgroup(struct page *page,
if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER)
return -1;
if (rsvd)
-   page[3].private = (unsigned long)h_cg;
+   set_page_private(page + SUBPAGE_INDEX_CGROUP_RSVD,
+(unsigned long)h_cg);
else
-   page[2].private = (unsigned long)h_cg;
+   set_page_private(page + SUBPAGE_INDEX_CGROUP,
+(unsigned long)h_cg);
return 0;
 }
 
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9aad0b63d369..dfa982f4b525 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1429,20 +1429,20 @@ struct hstate *size_to_hstate(unsigned long size)
 bool page_huge_active(struct page *page)
 {
VM_BUG_ON_PAGE(!PageHuge(page), page);
-   return PageHead(page) && PagePrivate([1]);
+   return PageHead(page) && PagePrivate([SUBPAGE_INDEX_ACTIVE]);
 }
 
 /* never called for tail page */
 static void set_page_huge_active(struct page *page)
 {
VM_BUG_ON_PAGE(!PageHeadHuge(page), page);
-   SetPagePrivate([1]);
+   SetPagePrivate([SUBPAGE_INDEX_ACTIVE]);
 }
 
 static void clear_page_huge_active(struct page *page)
 {
VM_BUG_ON_PAGE(!PageHeadHuge(page), page);
-   ClearPagePrivate([1]);
+   ClearPagePrivate([SUBPAGE_INDEX_ACTIVE]);
 }
 
 /*
@@ -1454,17 +1454,17 @@ static inline bool PageHugeTemporary(struct page *page)
if (!PageHuge(page))
return false;
 
-   return (unsigned long)page[2].mapping == -1U;
+   return (unsigned long)page[SUBPAGE_INDEX_TEMPORARY].mapping == -1U;
 }
 
 static inline void SetPageHugeTemporary(struct page *page)
 {
-   page[2].mapping = (void *)-1U;
+   page[SUBPAGE_INDEX_TEMPORARY].mapping = (void *)-1U;
 }
 
 static inline void ClearPageHugeTemporary(struct page *page)
 {
-   page[2].mapping = NULL;
+   page[SUBPAGE_INDEX_TEMPORARY].mapping = NULL;
 }
 
 static void __free_huge_page(struct page *page)
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 65e94436..d9c1f45e93ae 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -25,7 +25,7 @@ static inline void 

[PATCH v5 18/21] mm/hugetlb: Merge pte to huge pmd only for gigantic page

2020-11-19 Thread Muchun Song
Merge pte to huge pmd if it has ever been split. Now only support
gigantic page which's vmemmap pages size is an integer multiple of
PMD_SIZE. This is the simplest case to handle.

Signed-off-by: Muchun Song 
---
 arch/x86/include/asm/hugetlb.h |   8 +++
 mm/hugetlb_vmemmap.c   | 118 -
 2 files changed, 124 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index c601fe042832..1de1c519a84a 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -12,6 +12,14 @@ static inline bool vmemmap_pmd_huge(pmd_t *pmd)
 {
return pmd_large(*pmd);
 }
+
+#define vmemmap_pmd_mkhuge vmemmap_pmd_mkhuge
+static inline pmd_t vmemmap_pmd_mkhuge(struct page *page)
+{
+   pte_t entry = pfn_pte(page_to_pfn(page), PAGE_KERNEL_LARGE);
+
+   return __pmd(pte_val(entry));
+}
 #endif
 
 #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE)
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index c958699d1393..bf2b6b3e75af 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -144,6 +144,14 @@ static inline bool vmemmap_pmd_huge(pmd_t *pmd)
 }
 #endif
 
+#ifndef vmemmap_pmd_mkhuge
+#define vmemmap_pmd_mkhuge vmemmap_pmd_mkhuge
+static inline pmd_t vmemmap_pmd_mkhuge(struct page *page)
+{
+   return pmd_mkhuge(mk_pmd(page, PAGE_KERNEL));
+}
+#endif
+
 static bool hugetlb_free_vmemmap_disabled __initdata;
 
 static int __init early_hugetlb_free_vmemmap_param(char *buf)
@@ -422,6 +430,104 @@ static void __remap_huge_page_pte_vmemmap(struct page 
*reuse, pte_t *ptep,
}
 }
 
+static void __replace_huge_page_pte_vmemmap(pte_t *ptep, unsigned long start,
+   unsigned int nr, struct page *huge,
+   struct list_head *free_pages)
+{
+   unsigned long addr;
+   unsigned long end = start + (nr << PAGE_SHIFT);
+   pgprot_t pgprot = PAGE_KERNEL;
+
+   for (addr = start; addr < end; addr += PAGE_SIZE, ptep++) {
+   struct page *page;
+   pte_t old = *ptep;
+   pte_t entry;
+
+   prepare_vmemmap_page(huge);
+
+   entry = mk_pte(huge++, pgprot);
+   VM_WARN_ON(!pte_present(old));
+   page = pte_page(old);
+   list_add(>lru, free_pages);
+
+   set_pte_at(_mm, addr, ptep, entry);
+   }
+}
+
+static void replace_huge_page_pmd_vmemmap(pmd_t *pmd, unsigned long start,
+ struct page *huge,
+ struct list_head *free_pages)
+{
+   unsigned long end = start + VMEMMAP_HPAGE_SIZE;
+
+   flush_cache_vunmap(start, end);
+   __replace_huge_page_pte_vmemmap(pte_offset_kernel(pmd, start), start,
+   VMEMMAP_HPAGE_NR, huge, free_pages);
+   flush_tlb_kernel_range(start, end);
+}
+
+static pte_t *merge_vmemmap_pte(pmd_t *pmdp, unsigned long addr)
+{
+   pte_t *pte;
+   struct page *page;
+
+   pte = pte_offset_kernel(pmdp, addr);
+   page = pte_page(*pte);
+   set_pmd(pmdp, vmemmap_pmd_mkhuge(page));
+
+   return pte;
+}
+
+static void merge_huge_page_pmd_vmemmap(pmd_t *pmd, unsigned long start,
+   struct page *huge,
+   struct list_head *free_pages)
+{
+   replace_huge_page_pmd_vmemmap(pmd, start, huge, free_pages);
+   pte_free_kernel(_mm, merge_vmemmap_pte(pmd, start));
+   flush_tlb_kernel_range(start, start + VMEMMAP_HPAGE_SIZE);
+}
+
+static inline void dissolve_compound_page(struct page *page, unsigned int 
order)
+{
+   int i;
+   unsigned int nr_pages = 1 << order;
+
+   for (i = 1; i < nr_pages; i++)
+   set_page_count(page + i, 1);
+}
+
+static void merge_gigantic_page_vmemmap(struct hstate *h, struct page *head,
+   pmd_t *pmd)
+{
+   LIST_HEAD(free_pages);
+   unsigned long addr = (unsigned long)head;
+   unsigned long end = addr + vmemmap_pages_size_per_hpage(h);
+
+   for (; addr < end; addr += VMEMMAP_HPAGE_SIZE) {
+   void *to;
+   struct page *page;
+
+   page = alloc_pages(GFP_VMEMMAP_PAGE & ~__GFP_NOFAIL,
+  VMEMMAP_HPAGE_ORDER);
+   if (!page)
+   goto out;
+
+   dissolve_compound_page(page, VMEMMAP_HPAGE_ORDER);
+   to = page_to_virt(page);
+   memcpy(to, (void *)addr, VMEMMAP_HPAGE_SIZE);
+
+   /*
+* Make sure that any data that writes to the
+* @to is made visible to the physical page.
+*/
+   flush_kernel_vmap_range(to, VMEMMAP_HPAGE_SIZE);
+
+   merge_huge_page_pmd_vmemmap(pmd++, addr, page, _pages);
+   }
+out:
+   

[PATCH v5 16/21] mm/hugetlb: Flush work when dissolving hugetlb page

2020-11-19 Thread Muchun Song
We should flush work when dissolving a hugetlb page to make sure that
the hugetlb page is freed to the buddy.

Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b853aacd5c16..9aad0b63d369 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1328,6 +1328,12 @@ static void update_hpage_vmemmap_workfn(struct 
work_struct *work)
 }
 static DECLARE_WORK(hpage_update_work, update_hpage_vmemmap_workfn);
 
+static inline void flush_hpage_update_work(struct hstate *h)
+{
+   if (free_vmemmap_pages_per_hpage(h))
+   flush_work(_update_work);
+}
+
 static inline void __update_and_free_page(struct hstate *h, struct page *page)
 {
/* No need to allocate vmemmap pages */
@@ -1928,6 +1934,7 @@ static int free_pool_huge_page(struct hstate *h, 
nodemask_t *nodes_allowed,
 int dissolve_free_huge_page(struct page *page)
 {
int rc = -EBUSY;
+   struct hstate *h = NULL;
 
/* Not to disrupt normal path by vainly holding hugetlb_lock */
if (!PageHuge(page))
@@ -1941,8 +1948,9 @@ int dissolve_free_huge_page(struct page *page)
 
if (!page_count(page)) {
struct page *head = compound_head(page);
-   struct hstate *h = page_hstate(head);
int nid = page_to_nid(head);
+
+   h = page_hstate(head);
if (h->free_huge_pages - h->resv_huge_pages == 0)
goto out;
 
@@ -1956,6 +1964,14 @@ int dissolve_free_huge_page(struct page *page)
}
 out:
spin_unlock(_lock);
+
+   /*
+* We should flush work before return to make sure that
+* the HugeTLB page is freed to the buddy.
+*/
+   if (!rc && h)
+   flush_hpage_update_work(h);
+
return rc;
 }
 
-- 
2.11.0



[PATCH v5 17/21] mm/hugetlb: Add a kernel parameter hugetlb_free_vmemmap

2020-11-19 Thread Muchun Song
Add a kernel parameter hugetlb_free_vmemmap to disable the feature of
freeing unused vmemmap pages associated with each hugetlb page on boot.

Signed-off-by: Muchun Song 
---
 Documentation/admin-guide/kernel-parameters.txt |  9 +
 Documentation/admin-guide/mm/hugetlbpage.rst|  3 +++
 mm/hugetlb_vmemmap.c| 21 +
 3 files changed, 33 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 5debfe238027..ccf07293cb63 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1551,6 +1551,15 @@
Documentation/admin-guide/mm/hugetlbpage.rst.
Format: size[KMG]
 
+   hugetlb_free_vmemmap=
+   [KNL] When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set,
+   this controls freeing unused vmemmap pages associated
+   with each HugeTLB page.
+   Format: { on (default) | off }
+
+   on:  enable the feature
+   off: disable the feature
+
hung_task_panic=
[KNL] Should the hung task detector generate panics.
Format: 0 | 1
diff --git a/Documentation/admin-guide/mm/hugetlbpage.rst 
b/Documentation/admin-guide/mm/hugetlbpage.rst
index f7b1c7462991..7d6129ee97dd 100644
--- a/Documentation/admin-guide/mm/hugetlbpage.rst
+++ b/Documentation/admin-guide/mm/hugetlbpage.rst
@@ -145,6 +145,9 @@ default_hugepagesz
 
will all result in 256 2M huge pages being allocated.  Valid default
huge page size is architecture dependent.
+hugetlb_free_vmemmap
+   When CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set, this disables freeing
+   unused vmemmap pages associated each HugeTLB page.
 
 When multiple huge page sizes are supported, ``/proc/sys/vm/nr_hugepages``
 indicates the current number of pre-allocated huge pages of the default size.
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 3629165d8158..c958699d1393 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -144,6 +144,22 @@ static inline bool vmemmap_pmd_huge(pmd_t *pmd)
 }
 #endif
 
+static bool hugetlb_free_vmemmap_disabled __initdata;
+
+static int __init early_hugetlb_free_vmemmap_param(char *buf)
+{
+   if (!buf)
+   return -EINVAL;
+
+   if (!strcmp(buf, "off"))
+   hugetlb_free_vmemmap_disabled = true;
+   else if (strcmp(buf, "on"))
+   return -EINVAL;
+
+   return 0;
+}
+early_param("hugetlb_free_vmemmap", early_hugetlb_free_vmemmap_param);
+
 static inline unsigned int vmemmap_pages_per_hpage(struct hstate *h)
 {
return free_vmemmap_pages_per_hpage(h) + RESERVE_VMEMMAP_NR;
@@ -541,6 +557,11 @@ void __init hugetlb_vmemmap_init(struct hstate *h)
unsigned int order = huge_page_order(h);
unsigned int vmemmap_pages;
 
+   if (hugetlb_free_vmemmap_disabled) {
+   pr_info("disable free vmemmap pages for %s\n", h->name);
+   return;
+   }
+
vmemmap_pages = ((1 << order) * sizeof(struct page)) >> PAGE_SHIFT;
/*
 * The head page and the first tail page are not to be freed to buddy
-- 
2.11.0



[PATCH v5 13/21] mm/hugetlb: Use PG_slab to indicate split pmd

2020-11-19 Thread Muchun Song
When we allocate hugetlb page from buddy, we may need split huge pmd
to pte. When we free the hugetlb page, we can merge pte to pmd. So
we need to distinguish whether the previous pmd has been split. The
page table is not allocated from slab. So we can reuse the PG_slab
to indicate that the pmd has been split.

Signed-off-by: Muchun Song 
---
 mm/hugetlb_vmemmap.c | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 06e2b8a7b7c8..e2ddc73ce25f 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -293,6 +293,25 @@ static void remap_huge_page_pmd_vmemmap(struct hstate *h, 
pmd_t *pmd,
flush_tlb_kernel_range(start, end);
 }
 
+static inline bool pmd_split(pmd_t *pmd)
+{
+   return PageSlab(pmd_page(*pmd));
+}
+
+static inline void set_pmd_split(pmd_t *pmd)
+{
+   /*
+* We should not use slab for page table allocation. So we can set
+* PG_slab to indicate that the pmd has been split.
+*/
+   __SetPageSlab(pmd_page(*pmd));
+}
+
+static inline void clear_pmd_split(pmd_t *pmd)
+{
+   __ClearPageSlab(pmd_page(*pmd));
+}
+
 static void __remap_huge_page_pte_vmemmap(struct page *reuse, pte_t *ptep,
  unsigned long start,
  unsigned long end,
@@ -357,11 +376,12 @@ void alloc_huge_page_vmemmap(struct hstate *h, struct 
page *head)
ptl = vmemmap_pmd_lock(pmd);
remap_huge_page_pmd_vmemmap(h, pmd, (unsigned long)head, _pages,
__remap_huge_page_pte_vmemmap);
-   if (!freed_vmemmap_hpage_dec(pmd_page(*pmd))) {
+   if (!freed_vmemmap_hpage_dec(pmd_page(*pmd)) && pmd_split(pmd)) {
/*
 * Todo:
 * Merge pte to huge pmd if it has ever been split.
 */
+   clear_pmd_split(pmd);
}
spin_unlock(ptl);
 }
@@ -443,8 +463,10 @@ void free_huge_page_vmemmap(struct hstate *h, struct page 
*head)
BUG_ON(!pmd);
 
ptl = vmemmap_pmd_lock(pmd);
-   if (vmemmap_pmd_huge(pmd))
+   if (vmemmap_pmd_huge(pmd)) {
split_vmemmap_huge_page(head, pmd);
+   set_pmd_split(pmd);
+   }
 
remap_huge_page_pmd_vmemmap(h, pmd, (unsigned long)head, _pages,
__free_huge_page_pte_vmemmap);
-- 
2.11.0



[PATCH v5 15/21] mm/hugetlb: Set the PageHWPoison to the raw error page

2020-11-19 Thread Muchun Song
Because we reuse the first tail page, if we set PageHWPosion on a
tail page. It indicates that we may set PageHWPoison on a series
of pages. So we can use the head[4].mapping to record the real
error page index and set the raw error page PageHWPoison later.

Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 11 +++
 mm/hugetlb_vmemmap.h | 39 +++
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 055604d07046..b853aacd5c16 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1383,6 +1383,7 @@ static void __free_hugepage(struct hstate *h, struct page 
*page)
int i;
 
alloc_huge_page_vmemmap(h, page);
+   subpage_hwpoison_deliver(page);
 
for (i = 0; i < pages_per_huge_page(h); i++) {
page[i].flags &= ~(1 << PG_locked | 1 << PG_error |
@@ -1944,14 +1945,8 @@ int dissolve_free_huge_page(struct page *page)
int nid = page_to_nid(head);
if (h->free_huge_pages - h->resv_huge_pages == 0)
goto out;
-   /*
-* Move PageHWPoison flag from head page to the raw error page,
-* which makes any subpages rather than the error page reusable.
-*/
-   if (PageHWPoison(head) && page != head) {
-   SetPageHWPoison(page);
-   ClearPageHWPoison(head);
-   }
+
+   set_subpage_hwpoison(head, page);
list_del(>lru);
h->free_huge_pages--;
h->free_huge_pages_node[nid]--;
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 779d3cb9333f..65e94436 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -20,6 +20,29 @@ void __init gather_vmemmap_pgtable_init(struct 
huge_bootmem_page *m,
 void alloc_huge_page_vmemmap(struct hstate *h, struct page *head);
 void free_huge_page_vmemmap(struct hstate *h, struct page *head);
 
+static inline void subpage_hwpoison_deliver(struct page *head)
+{
+   struct page *page = head;
+
+   if (PageHWPoison(head))
+   page = head + page_private(head + 4);
+
+   /*
+* Move PageHWPoison flag from head page to the raw error page,
+* which makes any subpages rather than the error page reusable.
+*/
+   if (page != head) {
+   SetPageHWPoison(page);
+   ClearPageHWPoison(head);
+   }
+}
+
+static inline void set_subpage_hwpoison(struct page *head, struct page *page)
+{
+   if (PageHWPoison(head))
+   set_page_private(head + 4, page - head);
+}
+
 static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
 {
return h->nr_free_vmemmap_pages;
@@ -56,6 +79,22 @@ static inline void free_huge_page_vmemmap(struct hstate *h, 
struct page *head)
 {
 }
 
+static inline void subpage_hwpoison_deliver(struct page *head)
+{
+}
+
+static inline void set_subpage_hwpoison(struct page *head, struct page *page)
+{
+   /*
+* Move PageHWPoison flag from head page to the raw error page,
+* which makes any subpages rather than the error page reusable.
+*/
+   if (PageHWPoison(head) && page != head) {
+   SetPageHWPoison(page);
+   ClearPageHWPoison(head);
+   }
+}
+
 static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
 {
return 0;
-- 
2.11.0



[PATCH v5 14/21] mm/hugetlb: Support freeing vmemmap pages of gigantic page

2020-11-19 Thread Muchun Song
The gigantic page is allocated by bootmem, if we want to free the
unused vmemmap pages. We also should allocate the page table. So
we also allocate page tables from bootmem.

Signed-off-by: Muchun Song 
---
 include/linux/hugetlb.h |  3 +++
 mm/hugetlb.c|  5 +
 mm/hugetlb_vmemmap.c| 60 +
 mm/hugetlb_vmemmap.h| 13 +++
 4 files changed, 81 insertions(+)

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index eed3dd3bd626..da18fc9ed152 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -506,6 +506,9 @@ struct hstate {
 struct huge_bootmem_page {
struct list_head list;
struct hstate *hstate;
+#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
+   pte_t *vmemmap_pte;
+#endif
 };
 
 struct page *alloc_huge_page(struct vm_area_struct *vma,
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ba927ae7f9bd..055604d07046 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2607,6 +2607,7 @@ static void __init gather_bootmem_prealloc(void)
WARN_ON(page_count(page) != 1);
prep_compound_huge_page(page, h->order);
WARN_ON(PageReserved(page));
+   gather_vmemmap_pgtable_init(m, page);
prep_new_huge_page(h, page, page_to_nid(page));
put_page(page); /* free it into the hugepage allocator */
 
@@ -2659,6 +2660,10 @@ static void __init hugetlb_hstate_alloc_pages(struct 
hstate *h)
break;
cond_resched();
}
+
+   if (hstate_is_gigantic(h))
+   i -= gather_vmemmap_pgtable_prealloc();
+
if (i < h->max_huge_pages) {
char buf[32];
 
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index e2ddc73ce25f..3629165d8158 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -103,6 +103,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "hugetlb_vmemmap.h"
 
@@ -204,6 +205,65 @@ int vmemmap_pgtable_prealloc(struct hstate *h, struct page 
*page)
return -ENOMEM;
 }
 
+unsigned long __init gather_vmemmap_pgtable_prealloc(void)
+{
+   struct huge_bootmem_page *m, *tmp;
+   unsigned long nr_free = 0;
+
+   list_for_each_entry_safe(m, tmp, _boot_pages, list) {
+   struct hstate *h = m->hstate;
+   unsigned int nr = pgtable_pages_to_prealloc_per_hpage(h);
+   unsigned int pgtable_size;
+
+   if (!nr)
+   continue;
+
+   pgtable_size = nr << PAGE_SHIFT;
+   m->vmemmap_pte = memblock_alloc_try_nid(pgtable_size,
+   PAGE_SIZE, 0, MEMBLOCK_ALLOC_ACCESSIBLE,
+   NUMA_NO_NODE);
+   if (!m->vmemmap_pte) {
+   nr_free++;
+   list_del(>list);
+   memblock_free_early(__pa(m), huge_page_size(h));
+   }
+   }
+
+   return nr_free;
+}
+
+void __init gather_vmemmap_pgtable_init(struct huge_bootmem_page *m,
+   struct page *page)
+{
+   struct hstate *h = m->hstate;
+   unsigned long pte = (unsigned long)m->vmemmap_pte;
+   unsigned int nr = pgtable_pages_to_prealloc_per_hpage(h);
+
+   /*
+* Use the huge page lru list to temporarily store the preallocated
+* pages. The preallocated pages are used and the list is emptied
+* before the huge page is put into use. When the huge page is put
+* into use by prep_new_huge_page() the list will be reinitialized.
+*/
+   INIT_LIST_HEAD(>lru);
+
+   while (nr--) {
+   struct page *pte_page = virt_to_page(pte);
+
+   __ClearPageReserved(pte_page);
+   list_add(_page->lru, >lru);
+   pte += PAGE_SIZE;
+   }
+
+   /*
+* If we had gigantic hugepages allocated at boot time, we need
+* to restore the 'stolen' pages to totalram_pages in order to
+* fix confusing memory reports from free(1) and another
+* side-effects, like CommitLimit going negative.
+*/
+   adjust_managed_page_count(page, nr);
+}
+
 /*
  * Walk a vmemmap address to the pmd it maps.
  */
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 6dfa7ed6f88a..779d3cb9333f 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -14,6 +14,9 @@
 void __init hugetlb_vmemmap_init(struct hstate *h);
 int vmemmap_pgtable_prealloc(struct hstate *h, struct page *page);
 void vmemmap_pgtable_free(struct page *page);
+unsigned long __init gather_vmemmap_pgtable_prealloc(void);
+void __init gather_vmemmap_pgtable_init(struct huge_bootmem_page *m,
+   struct page *page);
 void alloc_huge_page_vmemmap(struct hstate *h, struct page *head);
 void free_huge_page_vmemmap(struct hstate *h, struct page *head);
 
@@ -35,6 +38,16 @@ static inline void 

[PATCH v5 12/21] mm/hugetlb: Introduce remap_huge_page_pmd_vmemmap helper

2020-11-19 Thread Muchun Song
The __free_huge_page_pmd_vmemmap and __remap_huge_page_pmd_vmemmap are
almost the same code. So introduce remap_free_huge_page_pmd_vmemmap
helper to simplify the code.

Signed-off-by: Muchun Song 
---
 mm/hugetlb_vmemmap.c | 108 +--
 1 file changed, 45 insertions(+), 63 deletions(-)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 361c4174e222..06e2b8a7b7c8 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -252,6 +252,47 @@ static inline int freed_vmemmap_hpage_dec(struct page 
*page)
return atomic_dec_return_relaxed(>_mapcount) + 1;
 }
 
+static inline void free_vmemmap_page_list(struct list_head *list)
+{
+   struct page *page, *next;
+
+   list_for_each_entry_safe(page, next, list, lru) {
+   list_del(>lru);
+   free_vmemmap_page(page);
+   }
+}
+
+typedef void (*remap_pte_fn)(struct page *reuse, pte_t *ptep,
+unsigned long start, unsigned long end,
+struct list_head *pages);
+
+static void remap_huge_page_pmd_vmemmap(struct hstate *h, pmd_t *pmd,
+   unsigned long addr,
+   struct list_head *pages,
+   remap_pte_fn remap_fn)
+{
+   unsigned long next;
+   unsigned long start = addr + RESERVE_VMEMMAP_SIZE;
+   unsigned long end = addr + vmemmap_pages_size_per_hpage(h);
+   struct page *reuse = NULL;
+
+   flush_cache_vunmap(start, end);
+
+   addr = start;
+   do {
+   pte_t *ptep;
+
+   ptep = pte_offset_kernel(pmd, addr);
+   if (!reuse)
+   reuse = pte_page(ptep[TAIL_PAGE_REUSE]);
+
+   next = vmemmap_hpage_addr_end(addr, end);
+   remap_fn(reuse, ptep, addr, next, pages);
+   } while (pmd++, addr = next, addr != end);
+
+   flush_tlb_kernel_range(start, end);
+}
+
 static void __remap_huge_page_pte_vmemmap(struct page *reuse, pte_t *ptep,
  unsigned long start,
  unsigned long end,
@@ -286,31 +327,6 @@ static void __remap_huge_page_pte_vmemmap(struct page 
*reuse, pte_t *ptep,
}
 }
 
-static void __remap_huge_page_pmd_vmemmap(struct hstate *h, pmd_t *pmd,
- unsigned long addr,
- struct list_head *remap_pages)
-{
-   unsigned long next;
-   unsigned long start = addr + RESERVE_VMEMMAP_SIZE;
-   unsigned long end = addr + vmemmap_pages_size_per_hpage(h);
-   struct page *reuse = NULL;
-
-   addr = start;
-   do {
-   pte_t *ptep;
-
-   ptep = pte_offset_kernel(pmd, addr);
-   if (!reuse)
-   reuse = pte_page(ptep[TAIL_PAGE_REUSE]);
-
-   next = vmemmap_hpage_addr_end(addr, end);
-   __remap_huge_page_pte_vmemmap(reuse, ptep, addr, next,
- remap_pages);
-   } while (pmd++, addr = next, addr != end);
-
-   flush_tlb_kernel_range(start, end);
-}
-
 static inline void alloc_vmemmap_pages(struct hstate *h, struct list_head 
*list)
 {
int i;
@@ -339,8 +355,8 @@ void alloc_huge_page_vmemmap(struct hstate *h, struct page 
*head)
BUG_ON(!pmd);
 
ptl = vmemmap_pmd_lock(pmd);
-   __remap_huge_page_pmd_vmemmap(h, pmd, (unsigned long)head,
- _pages);
+   remap_huge_page_pmd_vmemmap(h, pmd, (unsigned long)head, _pages,
+   __remap_huge_page_pte_vmemmap);
if (!freed_vmemmap_hpage_dec(pmd_page(*pmd))) {
/*
 * Todo:
@@ -350,16 +366,6 @@ void alloc_huge_page_vmemmap(struct hstate *h, struct page 
*head)
spin_unlock(ptl);
 }
 
-static inline void free_vmemmap_page_list(struct list_head *list)
-{
-   struct page *page, *next;
-
-   list_for_each_entry_safe(page, next, list, lru) {
-   list_del(>lru);
-   free_vmemmap_page(page);
-   }
-}
-
 static void __free_huge_page_pte_vmemmap(struct page *reuse, pte_t *ptep,
 unsigned long start,
 unsigned long end,
@@ -382,31 +388,6 @@ static void __free_huge_page_pte_vmemmap(struct page 
*reuse, pte_t *ptep,
}
 }
 
-static void __free_huge_page_pmd_vmemmap(struct hstate *h, pmd_t *pmd,
-unsigned long addr,
-struct list_head *free_pages)
-{
-   unsigned long next;
-   unsigned long start = addr + RESERVE_VMEMMAP_SIZE;
-   unsigned long end = addr + vmemmap_pages_size_per_hpage(h);
-   struct page *reuse = NULL;
-
-   addr = start;
-   do {
-   pte_t *ptep;
-
-   ptep = 

[PATCH v5 10/21] mm/hugetlb: Defer freeing of hugetlb pages

2020-11-19 Thread Muchun Song
In the subsequent patch, we will allocate the vmemmap pages when free
huge pages. But update_and_free_page() is be called from a non-task
context(and hold hugetlb_lock), we can defer the actual freeing in
a workqueue to prevent use GFP_ATOMIC to allocate the vmemmap pages.

Signed-off-by: Muchun Song 
---
 mm/hugetlb.c | 98 +---
 mm/hugetlb_vmemmap.c |  5 ---
 mm/hugetlb_vmemmap.h | 10 ++
 3 files changed, 96 insertions(+), 17 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a0ce6f33a717..4aabf12aca9b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1221,7 +1221,7 @@ static void destroy_compound_gigantic_page(struct page 
*page,
__ClearPageHead(page);
 }
 
-static void free_gigantic_page(struct page *page, unsigned int order)
+static void __free_gigantic_page(struct page *page, unsigned int order)
 {
/*
 * If the page isn't allocated using the cma allocator,
@@ -1288,20 +1288,100 @@ static struct page *alloc_gigantic_page(struct hstate 
*h, gfp_t gfp_mask,
 {
return NULL;
 }
-static inline void free_gigantic_page(struct page *page, unsigned int order) { 
}
+static inline void __free_gigantic_page(struct page *page,
+   unsigned int order) { }
 static inline void destroy_compound_gigantic_page(struct page *page,
unsigned int order) { }
 #endif
 
-static void update_and_free_page(struct hstate *h, struct page *page)
+static void __free_hugepage(struct hstate *h, struct page *page);
+
+/*
+ * As update_and_free_page() is be called from a non-task context(and hold
+ * hugetlb_lock), we can defer the actual freeing in a workqueue to prevent
+ * use GFP_ATOMIC to allocate a lot of vmemmap pages.
+ *
+ * update_hpage_vmemmap_workfn() locklessly retrieves the linked list of
+ * pages to be freed and frees them one-by-one. As the page->mapping pointer
+ * is going to be cleared in update_hpage_vmemmap_workfn() anyway, it is
+ * reused as the llist_node structure of a lockless linked list of huge
+ * pages to be freed.
+ */
+static LLIST_HEAD(hpage_update_freelist);
+
+static void update_hpage_vmemmap_workfn(struct work_struct *work)
 {
-   int i;
+   struct llist_node *node;
+   struct page *page;
+
+   node = llist_del_all(_update_freelist);
+
+   while (node) {
+   page = container_of((struct address_space **)node,
+struct page, mapping);
+   node = node->next;
+   page->mapping = NULL;
+   __free_hugepage(page_hstate(page), page);
 
+   cond_resched();
+   }
+}
+static DECLARE_WORK(hpage_update_work, update_hpage_vmemmap_workfn);
+
+static inline void __update_and_free_page(struct hstate *h, struct page *page)
+{
+   /* No need to allocate vmemmap pages */
+   if (!free_vmemmap_pages_per_hpage(h)) {
+   __free_hugepage(h, page);
+   return;
+   }
+
+   /*
+* Defer freeing to avoid using GFP_ATOMIC to allocate vmemmap
+* pages.
+*
+* Only call schedule_work() if hpage_update_freelist is previously
+* empty. Otherwise, schedule_work() had been called but the workfn
+* hasn't retrieved the list yet.
+*/
+   if (llist_add((struct llist_node *)>mapping,
+ _update_freelist))
+   schedule_work(_update_work);
+}
+
+#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
+static inline void free_gigantic_page(struct hstate *h, struct page *page)
+{
+   __free_gigantic_page(page, huge_page_order(h));
+}
+#else
+static inline void free_gigantic_page(struct hstate *h, struct page *page)
+{
+   /*
+* Temporarily drop the hugetlb_lock, because
+* we might block in __free_gigantic_page().
+*/
+   spin_unlock(_lock);
+   __free_gigantic_page(page, huge_page_order(h));
+   spin_lock(_lock);
+}
+#endif
+
+static void update_and_free_page(struct hstate *h, struct page *page)
+{
if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported())
return;
 
h->nr_huge_pages--;
h->nr_huge_pages_node[page_to_nid(page)]--;
+
+   __update_and_free_page(h, page);
+}
+
+static void __free_hugepage(struct hstate *h, struct page *page)
+{
+   int i;
+
for (i = 0; i < pages_per_huge_page(h); i++) {
page[i].flags &= ~(1 << PG_locked | 1 << PG_error |
1 << PG_referenced | 1 << PG_dirty |
@@ -1313,14 +1393,8 @@ static void update_and_free_page(struct hstate *h, 
struct page *page)
set_compound_page_dtor(page, NULL_COMPOUND_DTOR);
set_page_refcounted(page);
if (hstate_is_gigantic(h)) {
-   /*
-* Temporarily drop the hugetlb_lock, because
-* we might block in free_gigantic_page().
-*/
-   

[PATCH v5 09/21] mm/hugetlb: Free the vmemmap pages associated with each hugetlb page

2020-11-19 Thread Muchun Song
When we allocate a hugetlb page from the buddy, we should free the
unused vmemmap pages associated with it. We can do that in the
prep_new_huge_page().

Signed-off-by: Muchun Song 
---
 arch/x86/include/asm/hugetlb.h  |   9 ++
 arch/x86/include/asm/pgtable_64_types.h |   8 ++
 mm/hugetlb.c|  16 +++
 mm/hugetlb_vmemmap.c| 188 
 mm/hugetlb_vmemmap.h|   5 +
 5 files changed, 226 insertions(+)

diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h
index 1721b1aadeb1..c601fe042832 100644
--- a/arch/x86/include/asm/hugetlb.h
+++ b/arch/x86/include/asm/hugetlb.h
@@ -4,6 +4,15 @@
 
 #include 
 #include 
+#include 
+
+#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
+#define vmemmap_pmd_huge vmemmap_pmd_huge
+static inline bool vmemmap_pmd_huge(pmd_t *pmd)
+{
+   return pmd_large(*pmd);
+}
+#endif
 
 #define hugepages_supported() boot_cpu_has(X86_FEATURE_PSE)
 
diff --git a/arch/x86/include/asm/pgtable_64_types.h 
b/arch/x86/include/asm/pgtable_64_types.h
index 52e5f5f2240d..bedbd2e7d06c 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -139,6 +139,14 @@ extern unsigned int ptrs_per_p4d;
 # define VMEMMAP_START __VMEMMAP_BASE_L4
 #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */
 
+/*
+ * VMEMMAP_SIZE - allows the whole linear region to be covered by
+ *a struct page array.
+ */
+#define VMEMMAP_SIZE   (1UL << (__VIRTUAL_MASK_SHIFT - PAGE_SHIFT - \
+1 + ilog2(sizeof(struct page
+#define VMEMMAP_END(VMEMMAP_START + VMEMMAP_SIZE)
+
 #define VMALLOC_END(VMALLOC_START + (VMALLOC_SIZE_TB << 40) - 1)
 
 #define MODULES_VADDR  (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f88032c24667..a0ce6f33a717 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1499,6 +1499,14 @@ void free_huge_page(struct page *page)
 
 static void prep_new_huge_page(struct hstate *h, struct page *page, int nid)
 {
+   free_huge_page_vmemmap(h, page);
+   /*
+* Because we store preallocated pages on @page->lru,
+* vmemmap_pgtable_free() must be called before the
+* initialization of @page->lru in INIT_LIST_HEAD().
+*/
+   vmemmap_pgtable_free(page);
+
INIT_LIST_HEAD(>lru);
set_compound_page_dtor(page, HUGETLB_PAGE_DTOR);
set_hugetlb_cgroup(page, NULL);
@@ -1751,6 +1759,14 @@ static struct page *alloc_fresh_huge_page(struct hstate 
*h,
if (!page)
return NULL;
 
+   if (vmemmap_pgtable_prealloc(h, page)) {
+   if (hstate_is_gigantic(h))
+   free_gigantic_page(page, huge_page_order(h));
+   else
+   put_page(page);
+   return NULL;
+   }
+
if (hstate_is_gigantic(h))
prep_compound_gigantic_page(page, huge_page_order(h));
prep_new_huge_page(h, page, page_to_nid(page));
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index bc8546df4a51..6f8a735e0dd3 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -102,6 +102,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "hugetlb_vmemmap.h"
 
@@ -114,6 +115,8 @@
  * these page frames. Therefore, we need to reserve two pages as vmemmap areas.
  */
 #define RESERVE_VMEMMAP_NR 2U
+#define RESERVE_VMEMMAP_SIZE   (RESERVE_VMEMMAP_NR << PAGE_SHIFT)
+#define TAIL_PAGE_REUSE-1
 
 #ifndef VMEMMAP_HPAGE_SHIFT
 #define VMEMMAP_HPAGE_SHIFTHPAGE_SHIFT
@@ -123,6 +126,21 @@
 #define VMEMMAP_HPAGE_SIZE ((1UL) << VMEMMAP_HPAGE_SHIFT)
 #define VMEMMAP_HPAGE_MASK (~(VMEMMAP_HPAGE_SIZE - 1))
 
+#define vmemmap_hpage_addr_end(addr, end)   \
+({  \
+   unsigned long __boundary;\
+   __boundary = ((addr) + VMEMMAP_HPAGE_SIZE) & VMEMMAP_HPAGE_MASK; \
+   (__boundary - 1 < (end) - 1) ? __boundary : (end);   \
+})
+
+#ifndef vmemmap_pmd_huge
+#define vmemmap_pmd_huge vmemmap_pmd_huge
+static inline bool vmemmap_pmd_huge(pmd_t *pmd)
+{
+   return pmd_huge(*pmd);
+}
+#endif
+
 static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
 {
return h->nr_free_vmemmap_pages;
@@ -189,6 +207,176 @@ int vmemmap_pgtable_prealloc(struct hstate *h, struct 
page *page)
return -ENOMEM;
 }
 
+/*
+ * Walk a vmemmap address to the pmd it maps.
+ */
+static pmd_t *vmemmap_to_pmd(unsigned long page)
+{
+   pgd_t *pgd;
+   p4d_t *p4d;
+   pud_t *pud;
+   pmd_t *pmd;
+
+   if (page < VMEMMAP_START || page >= VMEMMAP_END)
+   return NULL;
+
+   pgd = pgd_offset_k(page);
+   if (pgd_none(*pgd))
+

[PATCH v5 11/21] mm/hugetlb: Allocate the vmemmap pages associated with each hugetlb page

2020-11-19 Thread Muchun Song
When we free a hugetlb page to the buddy, we should allocate the vmemmap
pages associated with it. We can do that in the __free_hugepage().

Signed-off-by: Muchun Song 
---
 mm/hugetlb.c |   2 ++
 mm/hugetlb_vmemmap.c | 100 +++
 mm/hugetlb_vmemmap.h |   5 +++
 3 files changed, 107 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 4aabf12aca9b..ba927ae7f9bd 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1382,6 +1382,8 @@ static void __free_hugepage(struct hstate *h, struct page 
*page)
 {
int i;
 
+   alloc_huge_page_vmemmap(h, page);
+
for (i = 0; i < pages_per_huge_page(h); i++) {
page[i].flags &= ~(1 << PG_locked | 1 << PG_error |
1 << PG_referenced | 1 << PG_dirty |
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index eda7e3a0b67c..361c4174e222 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -117,6 +117,8 @@
 #define RESERVE_VMEMMAP_NR 2U
 #define RESERVE_VMEMMAP_SIZE   (RESERVE_VMEMMAP_NR << PAGE_SHIFT)
 #define TAIL_PAGE_REUSE-1
+#define GFP_VMEMMAP_PAGE   \
+   (GFP_KERNEL | __GFP_NOFAIL | __GFP_MEMALLOC)
 
 #ifndef VMEMMAP_HPAGE_SHIFT
 #define VMEMMAP_HPAGE_SHIFTHPAGE_SHIFT
@@ -250,6 +252,104 @@ static inline int freed_vmemmap_hpage_dec(struct page 
*page)
return atomic_dec_return_relaxed(>_mapcount) + 1;
 }
 
+static void __remap_huge_page_pte_vmemmap(struct page *reuse, pte_t *ptep,
+ unsigned long start,
+ unsigned long end,
+ struct list_head *remap_pages)
+{
+   pgprot_t pgprot = PAGE_KERNEL;
+   void *from = page_to_virt(reuse);
+   unsigned long addr;
+
+   for (addr = start; addr < end; addr += PAGE_SIZE) {
+   void *to;
+   struct page *page;
+   pte_t entry, old = *ptep;
+
+   page = list_first_entry_or_null(remap_pages, struct page, lru);
+   list_del(>lru);
+   to = page_to_virt(page);
+   copy_page(to, from);
+
+   /*
+* Make sure that any data that writes to the @to is made
+* visible to the physical page.
+*/
+   flush_kernel_vmap_range(to, PAGE_SIZE);
+
+   prepare_vmemmap_page(page);
+
+   entry = mk_pte(page, pgprot);
+   set_pte_at(_mm, addr, ptep++, entry);
+
+   VM_BUG_ON(!pte_present(old) || pte_page(old) != reuse);
+   }
+}
+
+static void __remap_huge_page_pmd_vmemmap(struct hstate *h, pmd_t *pmd,
+ unsigned long addr,
+ struct list_head *remap_pages)
+{
+   unsigned long next;
+   unsigned long start = addr + RESERVE_VMEMMAP_SIZE;
+   unsigned long end = addr + vmemmap_pages_size_per_hpage(h);
+   struct page *reuse = NULL;
+
+   addr = start;
+   do {
+   pte_t *ptep;
+
+   ptep = pte_offset_kernel(pmd, addr);
+   if (!reuse)
+   reuse = pte_page(ptep[TAIL_PAGE_REUSE]);
+
+   next = vmemmap_hpage_addr_end(addr, end);
+   __remap_huge_page_pte_vmemmap(reuse, ptep, addr, next,
+ remap_pages);
+   } while (pmd++, addr = next, addr != end);
+
+   flush_tlb_kernel_range(start, end);
+}
+
+static inline void alloc_vmemmap_pages(struct hstate *h, struct list_head 
*list)
+{
+   int i;
+
+   for (i = 0; i < free_vmemmap_pages_per_hpage(h); i++) {
+   struct page *page;
+
+   /* This should not fail */
+   page = alloc_page(GFP_VMEMMAP_PAGE);
+   list_add_tail(>lru, list);
+   }
+}
+
+void alloc_huge_page_vmemmap(struct hstate *h, struct page *head)
+{
+   pmd_t *pmd;
+   spinlock_t *ptl;
+   LIST_HEAD(remap_pages);
+
+   if (!free_vmemmap_pages_per_hpage(h))
+   return;
+
+   alloc_vmemmap_pages(h, _pages);
+
+   pmd = vmemmap_to_pmd((unsigned long)head);
+   BUG_ON(!pmd);
+
+   ptl = vmemmap_pmd_lock(pmd);
+   __remap_huge_page_pmd_vmemmap(h, pmd, (unsigned long)head,
+ _pages);
+   if (!freed_vmemmap_hpage_dec(pmd_page(*pmd))) {
+   /*
+* Todo:
+* Merge pte to huge pmd if it has ever been split.
+*/
+   }
+   spin_unlock(ptl);
+}
+
 static inline void free_vmemmap_page_list(struct list_head *list)
 {
struct page *page, *next;
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 4175b44f88bc..6dfa7ed6f88a 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -14,6 +14,7 @@
 void __init hugetlb_vmemmap_init(struct hstate *h);
 int 

[PATCH v5 08/21] mm/hugetlb: Initialize page table lock for vmemmap

2020-11-19 Thread Muchun Song
In the later patch, we will use the vmemmap page table lock to
guard the splitting of the vmemmap PMD. So initialize the vmemmap
page table lock.

Signed-off-by: Muchun Song 
---
 mm/hugetlb_vmemmap.c | 69 
 1 file changed, 69 insertions(+)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index ec7098d8..bc8546df4a51 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -99,6 +99,8 @@
  */
 #define pr_fmt(fmt)"HugeTLB Vmemmap: " fmt
 
+#include 
+#include 
 #include 
 #include 
 #include "hugetlb_vmemmap.h"
@@ -208,3 +210,70 @@ void __init hugetlb_vmemmap_init(struct hstate *h)
pr_debug("can free %d vmemmap pages for %s\n", h->nr_free_vmemmap_pages,
 h->name);
 }
+
+static int __init vmemmap_pud_entry(pud_t *pud, unsigned long addr,
+   unsigned long next, struct mm_walk *walk)
+{
+   struct page *page = pud_page(*pud);
+
+   /*
+* The page->private shares storage with page->ptl. So make sure
+* that the PG_private is not set and initialize page->private to
+* zero.
+*/
+   VM_BUG_ON_PAGE(PagePrivate(page), page);
+   set_page_private(page, 0);
+
+   BUG_ON(!pmd_ptlock_init(page));
+
+   return 0;
+}
+
+static void __init vmemmap_ptlock_init_section(unsigned long start_pfn)
+{
+   unsigned long section_nr;
+   struct mem_section *ms;
+   struct page *memmap, *memmap_end;
+   struct mm_struct *mm = _mm;
+
+   const struct mm_walk_ops ops = {
+   .pud_entry  = vmemmap_pud_entry,
+   };
+
+   section_nr = pfn_to_section_nr(start_pfn);
+   ms = __nr_to_section(section_nr);
+   memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr);
+   memmap_end = memmap + PAGES_PER_SECTION;
+
+   mmap_read_lock(mm);
+   BUG_ON(walk_page_range_novma(mm, (unsigned long)memmap,
+(unsigned long)memmap_end,
+, NULL, NULL));
+   mmap_read_unlock(mm);
+}
+
+static void __init vmemmap_ptlock_init_node(int nid)
+{
+   unsigned long pfn, end_pfn;
+   struct pglist_data *pgdat = NODE_DATA(nid);
+
+   pfn = pgdat->node_start_pfn;
+   end_pfn = pgdat_end_pfn(pgdat);
+
+   for (; pfn < end_pfn; pfn += PAGES_PER_SECTION)
+   vmemmap_ptlock_init_section(pfn);
+}
+
+static int __init vmemmap_ptlock_init(void)
+{
+   int nid;
+
+   if (!hugepages_supported())
+   return 0;
+
+   for_each_online_node(nid)
+   vmemmap_ptlock_init_node(nid);
+
+   return 0;
+}
+core_initcall(vmemmap_ptlock_init);
-- 
2.11.0



[PATCH v5 07/21] mm/bootmem_info: Combine bootmem info and type into page->freelist

2020-11-19 Thread Muchun Song
The page->private shares storage with page->ptl. In the later patch,
we will use the page->ptl. So here we combine bootmem info and type
into page->freelist so that we can do not use page->private.

Signed-off-by: Muchun Song 
---
 arch/x86/mm/init_64.c|  2 +-
 include/linux/bootmem_info.h | 18 --
 mm/bootmem_info.c| 12 ++--
 mm/sparse.c  |  4 ++--
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0435bee2e172..9b738c6cb659 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -883,7 +883,7 @@ static void __meminit free_pagetable(struct page *page, int 
order)
if (PageReserved(page)) {
__ClearPageReserved(page);
 
-   magic = (unsigned long)page->freelist;
+   magic = page_bootmem_type(page);
if (magic == SECTION_INFO || magic == MIX_SECTION_INFO) {
while (nr_pages--)
put_page_bootmem(page++);
diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h
index 239e3cc8f86c..95ae80838680 100644
--- a/include/linux/bootmem_info.h
+++ b/include/linux/bootmem_info.h
@@ -6,7 +6,7 @@
 #include 
 
 /*
- * Types for free bootmem stored in page->lru.next. These have to be in
+ * Types for free bootmem stored in page->freelist. These have to be in
  * some random range in unsigned long space for debugging purposes.
  */
 enum {
@@ -17,6 +17,20 @@ enum {
MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
 };
 
+#define BOOTMEM_TYPE_BITS  (ilog2(MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE) + 1)
+#define BOOTMEM_TYPE_MAX   ((1UL << BOOTMEM_TYPE_BITS) - 1)
+#define BOOTMEM_INFO_MAX   (ULONG_MAX >> BOOTMEM_TYPE_BITS)
+
+static inline unsigned long page_bootmem_type(struct page *page)
+{
+   return (unsigned long)page->freelist & BOOTMEM_TYPE_MAX;
+}
+
+static inline unsigned long page_bootmem_info(struct page *page)
+{
+   return (unsigned long)page->freelist >> BOOTMEM_TYPE_BITS;
+}
+
 #ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
 void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
 
@@ -30,7 +44,7 @@ static inline void free_vmemmap_page(struct page *page)
 
/* bootmem page has reserved flag in the reserve_bootmem_region */
if (PageReserved(page)) {
-   unsigned long magic = (unsigned long)page->freelist;
+   unsigned long magic = page_bootmem_type(page);
 
if (magic == SECTION_INFO || magic == MIX_SECTION_INFO)
put_page_bootmem(page);
diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c
index fcab5a3f8cc0..9baf163965fd 100644
--- a/mm/bootmem_info.c
+++ b/mm/bootmem_info.c
@@ -12,9 +12,9 @@
 
 void get_page_bootmem(unsigned long info, struct page *page, unsigned long 
type)
 {
-   page->freelist = (void *)type;
-   SetPagePrivate(page);
-   set_page_private(page, info);
+   BUG_ON(info > BOOTMEM_INFO_MAX);
+   BUG_ON(type > BOOTMEM_TYPE_MAX);
+   page->freelist = (void *)((info << BOOTMEM_TYPE_BITS) | type);
page_ref_inc(page);
 }
 
@@ -22,14 +22,12 @@ void put_page_bootmem(struct page *page)
 {
unsigned long type;
 
-   type = (unsigned long) page->freelist;
+   type = page_bootmem_type(page);
BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
   type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE);
 
if (page_ref_dec_return(page) == 1) {
page->freelist = NULL;
-   ClearPagePrivate(page);
-   set_page_private(page, 0);
INIT_LIST_HEAD(>lru);
free_reserved_page(page);
}
@@ -101,6 +99,8 @@ void __init register_page_bootmem_info_node(struct 
pglist_data *pgdat)
int node = pgdat->node_id;
struct page *page;
 
+   BUILD_BUG_ON(MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE > BOOTMEM_TYPE_MAX);
+
nr_pages = PAGE_ALIGN(sizeof(struct pglist_data)) >> PAGE_SHIFT;
page = virt_to_page(pgdat);
 
diff --git a/mm/sparse.c b/mm/sparse.c
index a4138410d890..fca5fa38c2bc 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -740,12 +740,12 @@ static void free_map_bootmem(struct page *memmap)
>> PAGE_SHIFT;
 
for (i = 0; i < nr_pages; i++, page++) {
-   magic = (unsigned long) page->freelist;
+   magic = page_bootmem_type(page);
 
BUG_ON(magic == NODE_INFO);
 
maps_section_nr = pfn_to_section_nr(page_to_pfn(page));
-   removing_section_nr = page_private(page);
+   removing_section_nr = page_bootmem_info(page);
 
/*
 * When this function is called, the removing section is
-- 
2.11.0



[PATCH v5 06/21] mm/bootmem_info: Introduce {free,prepare}_vmemmap_page()

2020-11-19 Thread Muchun Song
In the later patch, we can use the free_vmemmap_page() to free the
unused vmemmap pages and initialize a page for vmemmap page using
via prepare_vmemmap_page().

Signed-off-by: Muchun Song 
---
 include/linux/bootmem_info.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h
index 4ed6dee1adc9..239e3cc8f86c 100644
--- a/include/linux/bootmem_info.h
+++ b/include/linux/bootmem_info.h
@@ -3,6 +3,7 @@
 #define __LINUX_BOOTMEM_INFO_H
 
 #include 
+#include 
 
 /*
  * Types for free bootmem stored in page->lru.next. These have to be in
@@ -22,6 +23,29 @@ void __init register_page_bootmem_info_node(struct 
pglist_data *pgdat);
 void get_page_bootmem(unsigned long info, struct page *page,
  unsigned long type);
 void put_page_bootmem(struct page *page);
+
+static inline void free_vmemmap_page(struct page *page)
+{
+   VM_WARN_ON(!PageReserved(page) || page_ref_count(page) != 2);
+
+   /* bootmem page has reserved flag in the reserve_bootmem_region */
+   if (PageReserved(page)) {
+   unsigned long magic = (unsigned long)page->freelist;
+
+   if (magic == SECTION_INFO || magic == MIX_SECTION_INFO)
+   put_page_bootmem(page);
+   else
+   WARN_ON(1);
+   }
+}
+
+static inline void prepare_vmemmap_page(struct page *page)
+{
+   unsigned long section_nr = pfn_to_section_nr(page_to_pfn(page));
+
+   get_page_bootmem(section_nr, page, SECTION_INFO);
+   mark_page_reserved(page);
+}
 #else
 static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
 {
-- 
2.11.0



[PATCH v5 05/21] mm/hugetlb: Introduce pgtable allocation/freeing helpers

2020-11-19 Thread Muchun Song
On x86_64, vmemmap is always PMD mapped if the machine has hugepages
support and if we have 2MB contiguous pages and PMD alignment. If we
want to free the unused vmemmap pages, we have to split the huge PMD
firstly. So we should pre-allocate pgtable to split PMD to PTE.

Signed-off-by: Muchun Song 
Suggested-by: Oscar Salvador 
Acked-by: Mike Kravetz 
---
 mm/hugetlb_vmemmap.c | 76 
 mm/hugetlb_vmemmap.h | 11 
 2 files changed, 87 insertions(+)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 1afe245395e5..ec7098d8 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -99,6 +99,8 @@
  */
 #define pr_fmt(fmt)"HugeTLB Vmemmap: " fmt
 
+#include 
+#include 
 #include "hugetlb_vmemmap.h"
 
 /*
@@ -111,6 +113,80 @@
  */
 #define RESERVE_VMEMMAP_NR 2U
 
+#ifndef VMEMMAP_HPAGE_SHIFT
+#define VMEMMAP_HPAGE_SHIFTHPAGE_SHIFT
+#endif
+#define VMEMMAP_HPAGE_ORDER(VMEMMAP_HPAGE_SHIFT - PAGE_SHIFT)
+#define VMEMMAP_HPAGE_NR   (1 << VMEMMAP_HPAGE_ORDER)
+#define VMEMMAP_HPAGE_SIZE ((1UL) << VMEMMAP_HPAGE_SHIFT)
+#define VMEMMAP_HPAGE_MASK (~(VMEMMAP_HPAGE_SIZE - 1))
+
+static inline unsigned int free_vmemmap_pages_per_hpage(struct hstate *h)
+{
+   return h->nr_free_vmemmap_pages;
+}
+
+static inline unsigned int vmemmap_pages_per_hpage(struct hstate *h)
+{
+   return free_vmemmap_pages_per_hpage(h) + RESERVE_VMEMMAP_NR;
+}
+
+static inline unsigned long vmemmap_pages_size_per_hpage(struct hstate *h)
+{
+   return (unsigned long)vmemmap_pages_per_hpage(h) << PAGE_SHIFT;
+}
+
+static inline unsigned int pgtable_pages_to_prealloc_per_hpage(struct hstate 
*h)
+{
+   unsigned long vmemmap_size = vmemmap_pages_size_per_hpage(h);
+
+   /*
+* No need pre-allocate page tables when there is no vmemmap pages
+* to free.
+*/
+   if (!free_vmemmap_pages_per_hpage(h))
+   return 0;
+
+   return ALIGN(vmemmap_size, VMEMMAP_HPAGE_SIZE) >> VMEMMAP_HPAGE_SHIFT;
+}
+
+void vmemmap_pgtable_free(struct page *page)
+{
+   struct page *pte_page, *t_page;
+
+   list_for_each_entry_safe(pte_page, t_page, >lru, lru) {
+   list_del(_page->lru);
+   pte_free_kernel(_mm, page_to_virt(pte_page));
+   }
+}
+
+int vmemmap_pgtable_prealloc(struct hstate *h, struct page *page)
+{
+   unsigned int nr = pgtable_pages_to_prealloc_per_hpage(h);
+
+   /*
+* Use the huge page lru list to temporarily store the preallocated
+* pages. The preallocated pages are used and the list is emptied
+* before the huge page is put into use. When the huge page is put
+* into use by prep_new_huge_page() the list will be reinitialized.
+*/
+   INIT_LIST_HEAD(>lru);
+
+   while (nr--) {
+   pte_t *pte_p;
+
+   pte_p = pte_alloc_one_kernel(_mm);
+   if (!pte_p)
+   goto out;
+   list_add(_to_page(pte_p)->lru, >lru);
+   }
+
+   return 0;
+out:
+   vmemmap_pgtable_free(page);
+   return -ENOMEM;
+}
+
 void __init hugetlb_vmemmap_init(struct hstate *h)
 {
unsigned int order = huge_page_order(h);
diff --git a/mm/hugetlb_vmemmap.h b/mm/hugetlb_vmemmap.h
index 40c0c7dfb60d..9eca6879c0a4 100644
--- a/mm/hugetlb_vmemmap.h
+++ b/mm/hugetlb_vmemmap.h
@@ -12,9 +12,20 @@
 
 #ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
 void __init hugetlb_vmemmap_init(struct hstate *h);
+int vmemmap_pgtable_prealloc(struct hstate *h, struct page *page);
+void vmemmap_pgtable_free(struct page *page);
 #else
 static inline void hugetlb_vmemmap_init(struct hstate *h)
 {
 }
+
+static inline int vmemmap_pgtable_prealloc(struct hstate *h, struct page *page)
+{
+   return 0;
+}
+
+static inline void vmemmap_pgtable_free(struct page *page)
+{
+}
 #endif /* CONFIG_HUGETLB_PAGE_FREE_VMEMMAP */
 #endif /* _LINUX_HUGETLB_VMEMMAP_H */
-- 
2.11.0



[PATCH v5 04/21] mm/hugetlb: Introduce nr_free_vmemmap_pages in the struct hstate

2020-11-19 Thread Muchun Song
Every HugeTLB has more than one struct page structure. The 2M HugeTLB
has 512 struct page structure and 1G HugeTLB has 4096 struct page
structures. We __know__ that we only use the first 4(HUGETLB_CGROUP_MIN_ORDER)
struct page structures to store metadata associated with each HugeTLB.

There are a lot of struct page structures(8 page frames for 2MB HugeTLB
page and 4096 page frames for 1GB HugeTLB page) associated with each
HugeTLB page. For tail pages, the value of compound_head is the same.
So we can reuse first page of tail page structures. We map the virtual
addresses of the remaining pages of tail page structures to the first
tail page struct, and then free these page frames. Therefore, we need
to reserve two pages as vmemmap areas.

So we introduce a new nr_free_vmemmap_pages field in the hstate to
indicate how many vmemmap pages associated with a HugeTLB page that we
can free to buddy system.

Signed-off-by: Muchun Song 
Acked-by: Mike Kravetz 
---
 include/linux/hugetlb.h |   3 ++
 mm/Makefile |   1 +
 mm/hugetlb.c|   3 ++
 mm/hugetlb_vmemmap.c| 134 
 mm/hugetlb_vmemmap.h|  20 
 5 files changed, 161 insertions(+)
 create mode 100644 mm/hugetlb_vmemmap.c
 create mode 100644 mm/hugetlb_vmemmap.h

diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index d5cc5f802dd4..eed3dd3bd626 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -492,6 +492,9 @@ struct hstate {
unsigned int nr_huge_pages_node[MAX_NUMNODES];
unsigned int free_huge_pages_node[MAX_NUMNODES];
unsigned int surplus_huge_pages_node[MAX_NUMNODES];
+#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
+   unsigned int nr_free_vmemmap_pages;
+#endif
 #ifdef CONFIG_CGROUP_HUGETLB
/* cgroup control files */
struct cftype cgroup_files_dfl[7];
diff --git a/mm/Makefile b/mm/Makefile
index 752111587c99..2a734576bbc0 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -71,6 +71,7 @@ obj-$(CONFIG_FRONTSWAP)   += frontswap.o
 obj-$(CONFIG_ZSWAP)+= zswap.o
 obj-$(CONFIG_HAS_DMA)  += dmapool.o
 obj-$(CONFIG_HUGETLBFS)+= hugetlb.o
+obj-$(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP)+= hugetlb_vmemmap.o
 obj-$(CONFIG_NUMA) += mempolicy.o
 obj-$(CONFIG_SPARSEMEM)+= sparse.o
 obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 81a41aa080a5..f88032c24667 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 #include "internal.h"
+#include "hugetlb_vmemmap.h"
 
 int hugetlb_max_hstate __read_mostly;
 unsigned int default_hstate_idx;
@@ -3285,6 +3286,8 @@ void __init hugetlb_add_hstate(unsigned int order)
snprintf(h->name, HSTATE_NAME_LEN, "hugepages-%lukB",
huge_page_size(h)/1024);
 
+   hugetlb_vmemmap_init(h);
+
parsed_hstate = h;
 }
 
diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
new file mode 100644
index ..1afe245395e5
--- /dev/null
+++ b/mm/hugetlb_vmemmap.c
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Free some vmemmap pages of HugeTLB
+ *
+ * Copyright (c) 2020, Bytedance. All rights reserved.
+ *
+ * Author: Muchun Song 
+ *
+ * The struct page structures (page structs) are used to describe a physical
+ * page frame. By default, there is a one-to-one mapping from a page frame to
+ * it's corresponding page struct.
+ *
+ * The HugeTLB pages consist of multiple base page size pages and is supported
+ * by many architectures. See hugetlbpage.rst in the Documentation directory
+ * for more details. On the x86 architecture, HugeTLB pages of size 2MB and 1GB
+ * are currently supported. Since the base page size on x86 is 4KB, a 2MB
+ * HugeTLB page consists of 512 base pages and a 1GB HugeTLB page consists of
+ * 4096 base pages. For each base page, there is a corresponding page struct.
+ *
+ * Within the HugeTLB subsystem, only the first 4 page structs are used to
+ * contain unique information about a HugeTLB page. HUGETLB_CGROUP_MIN_ORDER
+ * provides this upper limit. The only 'useful' information in the remaining
+ * page structs is the compound_head field, and this field is the same for all
+ * tail pages.
+ *
+ * By removing redundant page structs for HugeTLB pages, memory can returned to
+ * the buddy allocator for other uses.
+ *
+ * When the system boot up, every 2M HugeTLB has 512 struct page structs which
+ * size is 8 pages(sizeof(struct page) * 512 / PAGE_SIZE).
+ *
+ *HugeTLB  struct pages(8 pages) page frame(8 
pages)
+ * +---+ ---virt_to_page---> +---+   mapping to   +---+
+ * |   | | 0 | -> | 0 |
+ * |   | +---++---+
+ * |   | | 1 | -> | 1 |
+ * |   |

[PATCH v5 02/21] mm/memory_hotplug: Move {get,put}_page_bootmem() to bootmem_info.c

2020-11-19 Thread Muchun Song
In the later patch, we will use {get,put}_page_bootmem() to initialize
the page for vmemmap or free vmemmap page to buddy. So move them out of
CONFIG_MEMORY_HOTPLUG_SPARSE. This is just code movement without any
functional change.

Signed-off-by: Muchun Song 
Acked-by: Mike Kravetz 
Reviewed-by: Oscar Salvador 
---
 arch/x86/mm/init_64.c  |  2 +-
 include/linux/bootmem_info.h   | 13 +
 include/linux/memory_hotplug.h |  4 
 mm/bootmem_info.c  | 25 +
 mm/memory_hotplug.c| 27 ---
 mm/sparse.c|  1 +
 6 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index c7f7ad55b625..0a45f062826e 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1572,7 +1572,7 @@ int __meminit vmemmap_populate(unsigned long start, 
unsigned long end, int node,
return err;
 }
 
-#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && 
defined(CONFIG_HAVE_BOOTMEM_INFO_NODE)
+#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
 void register_page_bootmem_memmap(unsigned long section_nr,
  struct page *start_page, unsigned long 
nr_pages)
 {
diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h
index 65bb9b23140f..4ed6dee1adc9 100644
--- a/include/linux/bootmem_info.h
+++ b/include/linux/bootmem_info.h
@@ -18,10 +18,23 @@ enum {
 
 #ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
 void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
+
+void get_page_bootmem(unsigned long info, struct page *page,
+ unsigned long type);
+void put_page_bootmem(struct page *page);
 #else
 static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
 {
 }
+
+static inline void put_page_bootmem(struct page *page)
+{
+}
+
+static inline void get_page_bootmem(unsigned long info, struct page *page,
+   unsigned long type)
+{
+}
 #endif
 
 #endif /* __LINUX_BOOTMEM_INFO_H */
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 19e5d067294c..c9f3361fe84b 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -197,10 +197,6 @@ static inline void arch_refresh_nodedata(int nid, 
pg_data_t *pgdat)
 #endif /* CONFIG_NUMA */
 #endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */
 
-extern void put_page_bootmem(struct page *page);
-extern void get_page_bootmem(unsigned long ingo, struct page *page,
-unsigned long type);
-
 void get_online_mems(void);
 void put_online_mems(void);
 
diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c
index 39fa8fc120bc..fcab5a3f8cc0 100644
--- a/mm/bootmem_info.c
+++ b/mm/bootmem_info.c
@@ -10,6 +10,31 @@
 #include 
 #include 
 
+void get_page_bootmem(unsigned long info, struct page *page, unsigned long 
type)
+{
+   page->freelist = (void *)type;
+   SetPagePrivate(page);
+   set_page_private(page, info);
+   page_ref_inc(page);
+}
+
+void put_page_bootmem(struct page *page)
+{
+   unsigned long type;
+
+   type = (unsigned long) page->freelist;
+   BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
+  type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE);
+
+   if (page_ref_dec_return(page) == 1) {
+   page->freelist = NULL;
+   ClearPagePrivate(page);
+   set_page_private(page, 0);
+   INIT_LIST_HEAD(>lru);
+   free_reserved_page(page);
+   }
+}
+
 #ifndef CONFIG_SPARSEMEM_VMEMMAP
 static void register_page_bootmem_info_section(unsigned long start_pfn)
 {
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 2da4ad071456..ae57eedc341f 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -142,32 +141,6 @@ static void release_memory_resource(struct resource *res)
 }
 
 #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
-void get_page_bootmem(unsigned long info,  struct page *page,
- unsigned long type)
-{
-   page->freelist = (void *)type;
-   SetPagePrivate(page);
-   set_page_private(page, info);
-   page_ref_inc(page);
-}
-
-void put_page_bootmem(struct page *page)
-{
-   unsigned long type;
-
-   type = (unsigned long) page->freelist;
-   BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
-  type > MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE);
-
-   if (page_ref_dec_return(page) == 1) {
-   page->freelist = NULL;
-   ClearPagePrivate(page);
-   set_page_private(page, 0);
-   INIT_LIST_HEAD(>lru);
-   free_reserved_page(page);
-   }
-}
-
 static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
const char *reason)
 {
diff --git a/mm/sparse.c b/mm/sparse.c
index b25ad8e64839..a4138410d890 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -13,6 

[PATCH v5 00/21] Free some vmemmap pages of hugetlb page

2020-11-19 Thread Muchun Song
Hi all,

This patch series will free some vmemmap pages(struct page structures)
associated with each hugetlbpage when preallocated to save memory.

The struct page structures (page structs) are used to describe a physical
page frame. By default, there is a one-to-one mapping from a page frame to
it's corresponding page struct.

The HugeTLB pages consist of multiple base page size pages and is supported
by many architectures. See hugetlbpage.rst in the Documentation directory
for more details. On the x86 architecture, HugeTLB pages of size 2MB and 1GB
are currently supported. Since the base page size on x86 is 4KB, a 2MB
HugeTLB page consists of 512 base pages and a 1GB HugeTLB page consists of
4096 base pages. For each base page, there is a corresponding page struct.

Within the HugeTLB subsystem, only the first 4 page structs are used to
contain unique information about a HugeTLB page. HUGETLB_CGROUP_MIN_ORDER
provides this upper limit. The only 'useful' information in the remaining
page structs is the compound_head field, and this field is the same for all
tail pages.

By removing redundant page structs for HugeTLB pages, memory can returned to
the buddy allocator for other uses.

When the system boot up, every 2M HugeTLB has 512 struct page structs which
size is 8 pages(sizeof(struct page) * 512 / PAGE_SIZE).

HugeTLB  struct pages(8 pages) page frame(8 pages)
 +---+ ---virt_to_page---> +---+   mapping to   +---+
 |   | | 0 | -> | 0 |
 |   | +---++---+
 |   | | 1 | -> | 1 |
 |   | +---++---+
 |   | | 2 | -> | 2 |
 |   | +---++---+
 |   | | 3 | -> | 3 |
 |   | +---++---+
 |   | | 4 | -> | 4 |
 |2MB| +---++---+
 |   | | 5 | -> | 5 |
 |   | +---++---+
 |   | | 6 | -> | 6 |
 |   | +---++---+
 |   | | 7 | -> | 7 |
 |   | +---++---+
 |   |
 |   |
 |   |
 +---+

The value of page->compound_head is the same for all tail pages. The first
page of page structs (page 0) associated with the HugeTLB page contains the 4
page structs necessary to describe the HugeTLB. The only use of the remaining
pages of page structs (page 1 to page 7) is to point to page->compound_head.
Therefore, we can remap pages 2 to 7 to page 1. Only 2 pages of page structs
will be used for each HugeTLB page. This will allow us to free the remaining
6 pages to the buddy allocator.

Here is how things look after remapping.

HugeTLB  struct pages(8 pages) page frame(8 pages)
 +---+ ---virt_to_page---> +---+   mapping to   +---+
 |   | | 0 | -> | 0 |
 |   | +---++---+
 |   | | 1 | -> | 1 |
 |   | +---++---+
 |   | | 2 | ^ ^ ^ ^ ^ ^
 |   | +---+   | | | | |
 |   | | 3 | --+ | | | |
 |   | +---+ | | | |
 |   | | 4 | + | | |
 |2MB| +---+   | | |
 |   | | 5 | --+ | |
 |   | +---+ | |
 |   | | 6 | + |
 |   | +---+   |
 |   | | 7 | --+
 |   | +---+
 |   |
 |   |
 |   |
 +---+

When a HugeTLB is freed to the buddy system, we should allocate 6 pages for
vmemmap pages and restore the previous mapping relationship.

Apart from 2MB HugeTLB page, we also have 1GB HugeTLB page. It is similar
to the 2MB HugeTLB 

[PATCH v5 03/21] mm/hugetlb: Introduce a new config HUGETLB_PAGE_FREE_VMEMMAP

2020-11-19 Thread Muchun Song
The purpose of introducing HUGETLB_PAGE_FREE_VMEMMAP is to configure
whether to enable the feature of freeing unused vmemmap associated
with HugeTLB pages. Now only support x86.

Signed-off-by: Muchun Song 
---
 arch/x86/mm/init_64.c |  2 +-
 fs/Kconfig| 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0a45f062826e..0435bee2e172 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1225,7 +1225,7 @@ static struct kcore_list kcore_vsyscall;
 
 static void __init register_page_bootmem_info(void)
 {
-#ifdef CONFIG_NUMA
+#if defined(CONFIG_NUMA) || defined(CONFIG_HUGETLB_PAGE_FREE_VMEMMAP)
int i;
 
for_each_online_node(i)
diff --git a/fs/Kconfig b/fs/Kconfig
index 976e8b9033c4..4961dd488444 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -245,6 +245,20 @@ config HUGETLBFS
 config HUGETLB_PAGE
def_bool HUGETLBFS
 
+config HUGETLB_PAGE_FREE_VMEMMAP
+   def_bool HUGETLB_PAGE
+   depends on X86
+   depends on SPARSEMEM_VMEMMAP
+   depends on HAVE_BOOTMEM_INFO_NODE
+   help
+ When using HUGETLB_PAGE_FREE_VMEMMAP, the system can save up some
+ memory from pre-allocated HugeTLB pages when they are not used.
+ 6 pages per 2MB HugeTLB page and 4094 per 1GB HugeTLB page.
+
+ When the pages are going to be used or freed up, the vmemmap array
+ representing that range needs to be remapped again and the pages
+ we discarded earlier need to be rellocated again.
+
 config MEMFD_CREATE
def_bool TMPFS || HUGETLBFS
 
-- 
2.11.0



[PATCH v5 01/21] mm/memory_hotplug: Move bootmem info registration API to bootmem_info.c

2020-11-19 Thread Muchun Song
Move bootmem info registration common API to individual bootmem_info.c
for later patch use. This is just code movement without any functional
change.

Signed-off-by: Muchun Song 
Acked-by: Mike Kravetz 
Reviewed-by: Oscar Salvador 
---
 arch/x86/mm/init_64.c  |  1 +
 include/linux/bootmem_info.h   | 27 
 include/linux/memory_hotplug.h | 23 --
 mm/Makefile|  1 +
 mm/bootmem_info.c  | 99 ++
 mm/memory_hotplug.c| 91 +-
 6 files changed, 129 insertions(+), 113 deletions(-)
 create mode 100644 include/linux/bootmem_info.h
 create mode 100644 mm/bootmem_info.c

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index b5a3fa4033d3..c7f7ad55b625 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h
new file mode 100644
index ..65bb9b23140f
--- /dev/null
+++ b/include/linux/bootmem_info.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_BOOTMEM_INFO_H
+#define __LINUX_BOOTMEM_INFO_H
+
+#include 
+
+/*
+ * Types for free bootmem stored in page->lru.next. These have to be in
+ * some random range in unsigned long space for debugging purposes.
+ */
+enum {
+   MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 12,
+   SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
+   MIX_SECTION_INFO,
+   NODE_INFO,
+   MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
+};
+
+#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
+void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
+#else
+static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
+{
+}
+#endif
+
+#endif /* __LINUX_BOOTMEM_INFO_H */
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 51a877fec8da..19e5d067294c 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -33,18 +33,6 @@ struct vmem_altmap;
___page;   \
 })
 
-/*
- * Types for free bootmem stored in page->lru.next. These have to be in
- * some random range in unsigned long space for debugging purposes.
- */
-enum {
-   MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 12,
-   SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
-   MIX_SECTION_INFO,
-   NODE_INFO,
-   MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
-};
-
 /* Types for control the zone type of onlined and offlined memory */
 enum {
/* Offline the memory. */
@@ -209,13 +197,6 @@ static inline void arch_refresh_nodedata(int nid, 
pg_data_t *pgdat)
 #endif /* CONFIG_NUMA */
 #endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */
 
-#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
-extern void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
-#else
-static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
-{
-}
-#endif
 extern void put_page_bootmem(struct page *page);
 extern void get_page_bootmem(unsigned long ingo, struct page *page,
 unsigned long type);
@@ -254,10 +235,6 @@ static inline int mhp_notimplemented(const char *func)
return -ENOSYS;
 }
 
-static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
-{
-}
-
 static inline int try_online_node(int nid)
 {
return 0;
diff --git a/mm/Makefile b/mm/Makefile
index d5649f1c12c0..752111587c99 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -82,6 +82,7 @@ obj-$(CONFIG_SLAB) += slab.o
 obj-$(CONFIG_SLUB) += slub.o
 obj-$(CONFIG_KASAN)+= kasan/
 obj-$(CONFIG_FAILSLAB) += failslab.o
+obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o
 obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
 obj-$(CONFIG_MEMTEST)  += memtest.o
 obj-$(CONFIG_MIGRATION) += migrate.o
diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c
new file mode 100644
index ..39fa8fc120bc
--- /dev/null
+++ b/mm/bootmem_info.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *  linux/mm/bootmem_info.c
+ *
+ *  Copyright (C)
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef CONFIG_SPARSEMEM_VMEMMAP
+static void register_page_bootmem_info_section(unsigned long start_pfn)
+{
+   unsigned long mapsize, section_nr, i;
+   struct mem_section *ms;
+   struct page *page, *memmap;
+   struct mem_section_usage *usage;
+
+   section_nr = pfn_to_section_nr(start_pfn);
+   ms = __nr_to_section(section_nr);
+
+   /* Get section's memmap address */
+   memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr);
+
+   /*
+* Get page for the memmap's phys address
+* XXX: need more consideration for sparse_vmemmap...
+*/
+   page = virt_to_page(memmap);
+   mapsize = sizeof(struct page) * PAGES_PER_SECTION;
+   mapsize = PAGE_ALIGN(mapsize) >> 

Re: linux-next: build warning after merge of the usb tree

2020-11-19 Thread Prashant Malani
Hi Stephen,

On Fri, Nov 20, 2020 at 04:15:06PM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the usb tree, today's linux-next build (htmldocs) produced
> this warning:
> 
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> drivers/usb/typec/class.c:632: warning: Excess function parameter 
> 'num_alt_modes' description in 'typec_partner_set_num_altmodes'
> 
> Introduced by commit
> 
>   a0ccdc4a77a1 ("usb: typec: Add number of altmodes partner attr")


Thank you for the email, and my apologies about the warning. I've sent a
patch the mailing lists which should hopefully fix this [1].

Please let me know if there is further action required from my side.

Best regards,

[1]:
https://lore.kernel.org/linux-usb/20201120063523.4159877-1-pmal...@chromium.org/
> 
> -- 
> Cheers,
> Stephen Rothwell




[PATCH] usb: typec: Fix num_altmodes kernel-doc error

2020-11-19 Thread Prashant Malani
The commit to introduce the num_altmodes attribute for partner had an
error where one of the parameters was named differently in the comment
and the function signature. Fix the version in the comment to align with
what is in the function signature.

This fixes the following htmldocs warning:

drivers/usb/typec/class.c:632: warning: Excess function parameter
'num_alt_modes' description in 'typec_partner_set_num_altmodes'

Fixes: a0ccdc4a77a1 ("usb: typec: Add number of altmodes partner attr")
Signed-off-by: Prashant Malani 
---
 drivers/usb/typec/class.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index e68798599ca8..cb1362187a7c 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -618,7 +618,7 @@ EXPORT_SYMBOL_GPL(typec_partner_set_identity);
 /**
  * typec_partner_set_num_altmodes - Set the number of available partner 
altmodes
  * @partner: The partner to be updated.
- * @num_alt_modes: The number of altmodes we want to specify as available.
+ * @num_altmodes: The number of altmodes we want to specify as available.
  *
  * This routine is used to report the number of alternate modes supported by 
the
  * partner. This value is *not* enforced in alternate mode registration 
routines.
-- 
2.29.2.454.gaff20da3a2-goog



Re: [PATCH v5 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation

2020-11-19 Thread Sumit Semwal
Hi Daniel,


On Wed, 18 Nov 2020 at 13:16, Daniel Vetter  wrote:
>
> On Wed, Nov 18, 2020 at 3:40 AM John Stultz  wrote:
> > On Fri, Nov 13, 2020 at 12:39 PM Daniel Vetter  wrote:
> > > On Thu, Nov 12, 2020 at 08:11:02PM -0800, John Stultz wrote:
> > > > On Thu, Nov 12, 2020 at 1:32 AM Daniel Vetter  wrote:
> > > > > On Thu, Nov 12, 2020 at 11:09:04AM +0530, Sumit Semwal wrote:
> > > > > > On Tue, 10 Nov 2020 at 09:19, John Stultz  
> > > > > > wrote:
> > > > > > >
> > > > > > > Hey All,
> > > > > > >   So just wanted to send my last revision of my patch series
> > > > > > > of performance optimizations to the dma-buf system heap.
> > > > > >
> > > > > > Thanks very much for your patches - I think the first 5 patches 
> > > > > > look good to me.
> > > > > >
> > > > > > I know there was a bit of discussion over adding a new 
> > > > > > system-uncached
> > > > > > heap v/s using a flag to identify that; I think I prefer the 
> > > > > > separate
> > > > > > heap idea, but lets ask one last time if any one else has any real
> > > > > > objections to it.
> > > > > >
> > > > > > Daniel, Christian: any comments from your side on this?
> > > > >
> > > > > I do wonder a bit where the userspace stack for this all is, since 
> > > > > tuning
> > > > > allocators without a full stack is fairly pointless. dma-buf heaps is 
> > > > > a
> > > > > bit in a limbo situation here it feels like.
> > > >
> > > > As mentioned in the system-uncached patch:
> > > > Pending opensource users of this code include:
> > > > * AOSP HiKey960 gralloc:
> > > >   - 
> > > > https://android-review.googlesource.com/c/device/linaro/hikey/+/1399519
> > > >   - Visibly improves performance over the system heap
> > > > * AOSP Codec2 (possibly, needs more review):
> > > >   - 
> > > > https://android-review.googlesource.com/c/platform/frameworks/av/+/1360640/17/media/codec2/vndk/C2DmaBufAllocator.cpp#325
> > > >
> > > > Additionally both the HiKey, HiKey960 grallocs  and Codec2 are already
> > > > able to use the current dmabuf heaps instead of ION.
> > > >
> > > > So I'm not sure what you mean by limbo, other than it being in a
> > > > transition state where the interface is upstream and we're working on
> > > > moving vendors to it from ION (which is staged to be dropped in 5.11).
> > > > Part of that work is making sure we don't regress the performance
> > > > expectations.
> > >
> > > The mesa thing below, since if we test this with some downstream kernel
> > > drivers or at least non-mesa userspace I'm somewhat worried we're just
> > > creating a nice split world between the android gfx world and the
> > > mesa/linux desktop gfx world.
> > >
> > > But then that's kinda how android rolls, so *shrug*
> > >
> > > > > Plus I'm vary of anything related to leaking this kind of stuff 
> > > > > beyond the
> > > > > dma-api because dma api maintainers don't like us doing that. But
> > > > > personally no concern on that front really, gpus need this. It's just 
> > > > > that
> > > > > we do need solid justification I think if we land this. Hence back to
> > > > > first point.
> > > > >
> > > > > Ideally first point comes in the form of benchmarking on android 
> > > > > together
> > > > > with a mesa driver (or mesa + some v4l driver or whatever it takes to
> > > > > actually show the benefits, I have no idea).
> > > >
> > > > Tying it with mesa is a little tough as the grallocs for mesa devices
> > > > usually use gbm (gralloc.gbm or gralloc.minigbm). Swapping the
> > > > allocation path for dmabuf heaps there gets a little complex as last I
> > > > tried that (when trying to get HiKey working with Lima graphics, as
> > > > gbm wouldn't allocate the contiguous buffers required by the display),
> > > > I ran into issues with the drm_hwcomposer and mesa expecting the gbm
> > > > private handle metadata in the buffer when it was passed in.
> > > >
> > > > But I might take a look at it again. I got a bit lost digging through
> > > > the mesa gbm allocation paths last time.
> > > >
> > > > I'll also try to see if I can find a benchmark for the codec2 code
> > > > (using dmabuf heaps with and without the uncached heap) on on db845c
> > > > (w/ mesa), as that is already working and I suspect that might be
> > > > close to what you're looking for.
> > >
> > > tbh I think trying to push for this long term is the best we can hope for.
> > >
> > > Media is also a lot more *meh* since it's deeply fragmented and a lot less
> > > of it upstream than on the gles/display side.
> > >
> > > I think confirming that this at least doesn't horrible blow up on a
> > > gralloc/gbm+mesa stack would be useful I think.
> >
> > Sorry, I'm still a little foggy on precisely what you're suggesting here.
> >
> > The patch stack I have has already been used with db845c (mesa +
> > gbm_grallloc), with the codec2 (sw decoders) using dmabuf heaps.
> > So no blowing up there. And I'm working with Hridya to find a
> > benchmark for codec2 so we can try to show the performance 

[PATCH v2] perf docs: Add man pages to see also

2020-11-19 Thread Ian Rogers
Add all other man pages to the "see also" list except for
perf-script-perl and perf-script-python that are linked to from
perf-script.

v2. Fix accidentally listing perf-top twice.

Signed-off-by: Ian Rogers 
---
 tools/perf/Documentation/perf.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/Documentation/perf.txt 
b/tools/perf/Documentation/perf.txt
index c130a3c46a90..9c330cdfa973 100644
--- a/tools/perf/Documentation/perf.txt
+++ b/tools/perf/Documentation/perf.txt
@@ -76,3 +76,15 @@ SEE ALSO
 linkperf:perf-stat[1], linkperf:perf-top[1],
 linkperf:perf-record[1], linkperf:perf-report[1],
 linkperf:perf-list[1]
+
+linkperf:perf-annotate[1],linkperf:perf-archive[1],
+linkperf:perf-bench[1], linkperf:perf-buildid-cache[1],
+linkperf:perf-buildid-list[1], linkperf:perf-c2c[1],
+linkperf:perf-config[1], linkperf:perf-data[1], linkperf:perf-diff[1],
+linkperf:perf-evlist[1], linkperf:perf-ftrace[1],
+linkperf:perf-help[1], linkperf:perf-inject[1],
+linkperf:perf-intel-pt[1], linkperf:perf-kallsyms[1],
+linkperf:perf-kmem[1], linkperf:perf-kvm[1], linkperf:perf-lock[1],
+linkperf:perf-mem[1], linkperf:perf-probe[1], linkperf:perf-sched[1],
+linkperf:perf-script[1], linkperf:perf-test[1],
+linkperf:perf-trace[1], linkperf:perf-version[1]
-- 
2.29.2.454.gaff20da3a2-goog



[PATCHv3 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-19 Thread George Cherian
Add health reporters for RVU NPA block.
NPA Health reporters handle following HW event groups
 - GENERAL events
 - ERROR events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # devlink health
 pci/0002:01:00.0:
   reporter npa
 state healthy error 0 recover 0
 # devlink  health dump show pci/0002:01:00.0 reporter npa
 NPA_AF_GENERAL:
Unmap PF Error: 0
Free Disabled for NIX0 RX: 0
Free Disabled for NIX0 TX: 0
Free Disabled for NIX1 RX: 0
Free Disabled for NIX1 TX: 0
Free Disabled for SSO: 0
Free Disabled for TIM: 0
Free Disabled for DPI: 0
Free Disabled for AURA: 0
Alloc Disabled for Resvd: 0
  NPA_AF_ERR:
Memory Fault on NPA_AQ_INST_S read: 0
Memory Fault on NPA_AQ_RES_S write: 0
AQ Doorbell Error: 0
Poisoned data on NPA_AQ_INST_S read: 0
Poisoned data on NPA_AQ_RES_S write: 0
Poisoned data on HW context read: 0
  NPA_AF_RVU:
Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 492 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  23 +
 3 files changed, 545 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 04ef945e7e75..b7f0691d86b0 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -5,10 +5,498 @@
  *
  */
 
+#include
+
 #include "rvu.h"
+#include "rvu_reg.h"
+#include "rvu_struct.h"
 
 #define DRV_NAME "octeontx2-af"
 
+static int rvu_report_pair_start(struct devlink_fmsg *fmsg, const char *name)
+{
+   int err;
+
+   err = devlink_fmsg_pair_nest_start(fmsg, name);
+   if (err)
+   return err;
+
+   return  devlink_fmsg_obj_nest_start(fmsg);
+}
+
+static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
+{
+   int err;
+
+   err = devlink_fmsg_obj_nest_end(fmsg);
+   if (err)
+   return err;
+
+   return devlink_fmsg_pair_nest_end(fmsg);
+}
+
+static bool rvu_common_request_irq(struct rvu *rvu, int offset,
+  const char *name, irq_handler_t fn)
+{
+   struct rvu_devlink *rvu_dl = rvu->rvu_dl;
+   int rc;
+
+   sprintf(>irq_name[offset * NAME_SIZE], name);
+   rc = request_irq(pci_irq_vector(rvu->pdev, offset), fn, 0,
+>irq_name[offset * NAME_SIZE], rvu_dl);
+   if (rc)
+   dev_warn(rvu->dev, "Failed to register %s irq\n", name);
+   else
+   rvu->irq_allocated[offset] = true;
+
+   return rvu->irq_allocated[offset];
+}
+
+static irqreturn_t rvu_npa_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_npa_event_ctx *npa_event_context;
+   struct rvu_npa_event_cnt *npa_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   npa_event_context = rvu_dl->npa_event_ctx;
+   npa_event_count = _event_context->npa_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NPA_AF_RVU_INT);
+   npa_event_context->npa_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   npa_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_npa_health_reporter, "NPA_AF_RVU 
Error",
+ npa_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static int rvu_npa_inpq_to_cnt(u16 in,
+  struct rvu_npa_event_cnt *npa_event_count)
+{
+   switch (in) {
+   case 0:
+   return 0;
+   case BIT(NPA_INPQ_NIX0_RX):
+   return npa_event_count->free_dis_nix0_rx_count++;
+   case BIT(NPA_INPQ_NIX0_TX):
+   return npa_event_count->free_dis_nix0_tx_count++;
+   case BIT(NPA_INPQ_NIX1_RX):
+   return npa_event_count->free_dis_nix1_rx_count++;
+   case BIT(NPA_INPQ_NIX1_TX):
+   return npa_event_count->free_dis_nix1_tx_count++;
+   case BIT(NPA_INPQ_SSO):
+   return npa_event_count->free_dis_sso_count++;
+   case BIT(NPA_INPQ_TIM):
+   return npa_event_count->free_dis_tim_count++;
+   case BIT(NPA_INPQ_DPI):
+   return npa_event_count->free_dis_dpi_count++;
+   case BIT(NPA_INPQ_AURA_OP):
+   return npa_event_count->free_dis_aura_count++;
+   case BIT(NPA_INPQ_INTERNAL_RSV):
+   return 

[PATCHv3 net-next 3/3] octeontx2-af: Add devlink health reporters for NIX

2020-11-19 Thread George Cherian
Add health reporters for RVU NIX block.
NIX Health reporter handle following HW event groups
 - GENERAL events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # ./devlink health
 pci/0002:01:00.0:
   reporter npa
 state healthy error 0 recover 0
   reporter nix
 state healthy error 0 recover 0
 # ./devlink  health dump show pci/0002:01:00.0 reporter nix
  NIX_AF_GENERAL:
 Memory Fault on NIX_AQ_INST_S read: 0
 Memory Fault on NIX_AQ_RES_S write: 0
 AQ Doorbell error: 0
 Rx on unmapped PF_FUNC: 0
 Rx multicast replication error: 0
 Memory fault on NIX_RX_MCE_S read: 0
 Memory fault on multicast WQE read: 0
 Memory fault on mirror WQE read: 0
 Memory fault on mirror pkt write: 0
 Memory fault on multicast pkt write: 0
   NIX_AF_RAS:
 Poisoned data on NIX_AQ_INST_S read: 0
 Poisoned data on NIX_AQ_RES_S write: 0
 Poisoned data on HW context read: 0
 Poisoned data on packet read from mirror buffer: 0
 Poisoned data on packet read from mcast buffer: 0
 Poisoned data on WQE read from mirror buffer: 0
 Poisoned data on WQE read from multicast buffer: 0
 Poisoned data on NIX_RX_MCE_S read: 0
   NIX_AF_RVU:
 Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 414 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  10 +
 3 files changed, 453 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index b7f0691d86b0..c02d0f56ae7a 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -35,6 +35,131 @@ static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
return devlink_fmsg_pair_nest_end(fmsg);
 }
 
+static irqreturn_t rvu_nix_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_RVU_INT);
+   nix_event_context->nix_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   nix_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_nix_health_reporter, "NIX_AF_RVU 
Error",
+ nix_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t rvu_nix_af_err_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_ERR_INT);
+   nix_event_context->nix_af_rvu_err = intr;
+
+   if (intr & BIT_ULL(14))
+   nix_event_count->aq_inst_count++;
+   if (intr & BIT_ULL(13))
+   nix_event_count->aq_res_count++;
+   if (intr & BIT_ULL(12))
+   nix_event_count->aq_db_count++;
+   if (intr & BIT_ULL(6))
+   nix_event_count->rx_on_unmap_pf_count++;
+   if (intr & BIT_ULL(5))
+   nix_event_count->rx_mcast_repl_count++;
+   if (intr & BIT_ULL(4))
+   nix_event_count->rx_mcast_memfault_count++;
+   if (intr & BIT_ULL(3))
+   nix_event_count->rx_mcast_wqe_memfault_count++;
+   if (intr & BIT_ULL(2))
+   nix_event_count->rx_mirror_wqe_memfault_count++;
+   if (intr & BIT_ULL(1))
+   nix_event_count->rx_mirror_pktw_memfault_count++;
+   if (intr & BIT_ULL(0))
+   nix_event_count->rx_mcast_pktw_memfault_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_nix_health_reporter, "NIX_AF_ERR 
Error",
+ nix_event_context);
+
+  

[PATCH] perf docs: Add man pages to see also

2020-11-19 Thread Ian Rogers
Add all other man pages to the "see also" list except for
perf-script-perl and perf-script-python that are linked to from
perf-script.

Signed-off-by: Ian Rogers 
---
 tools/perf/Documentation/perf.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/Documentation/perf.txt 
b/tools/perf/Documentation/perf.txt
index c130a3c46a90..c18b5872277e 100644
--- a/tools/perf/Documentation/perf.txt
+++ b/tools/perf/Documentation/perf.txt
@@ -76,3 +76,15 @@ SEE ALSO
 linkperf:perf-stat[1], linkperf:perf-top[1],
 linkperf:perf-record[1], linkperf:perf-report[1],
 linkperf:perf-list[1]
+
+linkperf:perf-annotate[1],linkperf:perf-archive[1],
+linkperf:perf-bench[1], linkperf:perf-buildid-cache[1],
+linkperf:perf-buildid-list[1], linkperf:perf-c2c[1],
+linkperf:perf-config[1], linkperf:perf-data[1], linkperf:perf-diff[1],
+linkperf:perf-evlist[1], linkperf:perf-ftrace[1],
+linkperf:perf-help[1], linkperf:perf-inject[1],
+linkperf:perf-intel-pt[1], linkperf:perf-kallsyms[1],
+linkperf:perf-kmem[1], linkperf:perf-kvm[1], linkperf:perf-lock[1],
+linkperf:perf-mem[1], linkperf:perf-probe[1], linkperf:perf-sched[1],
+linkperf:perf-script[1], linkperf:perf-test[1], linkperf:perf-top[1],
+linkperf:perf-trace[1], linkperf:perf-version[1]
-- 
2.29.2.454.gaff20da3a2-goog



[PATCHv3 net-next 0/3] Add devlink and devlink health reporters to

2020-11-19 Thread George Cherian
Add basic devlink and devlink health reporters.
Devlink health reporters are added for NPA and NIX blocks.
These reporters report the error count in respective blocks.

Address Jakub's comment to add devlink support for error reporting.
https://www.spinics.net/lists/netdev/msg670712.html

Change-log:
v3
 - Address Saeed's comments on v2.
 - Renamed the reporter name as hw_*.
 - Call devlink_health_report() when an event is raised.
 - Added recover op too.

v2
 - Address Willem's comments on v1.
 - Fixed the sparse issues, reported by Jakub.

George Cherian (3):
  octeontx2-af: Add devlink suppoort to af driver
  octeontx2-af: Add devlink health reporters for NPA
  octeontx2-af: Add devlink health reporters for NIX

 .../net/ethernet/marvell/octeontx2/Kconfig|   1 +
 .../ethernet/marvell/octeontx2/af/Makefile|   3 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |   9 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   4 +
 .../marvell/octeontx2/af/rvu_devlink.c| 972 ++
 .../marvell/octeontx2/af/rvu_devlink.h|  82 ++
 .../marvell/octeontx2/af/rvu_struct.h |  33 +
 7 files changed, 1102 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

-- 
2.25.1



[PATCHv3 net-next 1/3] octeontx2-af: Add devlink suppoort to af driver

2020-11-19 Thread George Cherian
Add devlink support to AF driver. Basic devlink support is added.
Currently info_get is the only supported devlink ops.

devlink ouptput looks like this
 # devlink dev
 pci/0002:01:00.0
 # devlink dev info
 pci/0002:01:00.0:
  driver octeontx2-af
  versions:
  fixed:
mbox version: 9

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../net/ethernet/marvell/octeontx2/Kconfig|  1 +
 .../ethernet/marvell/octeontx2/af/Makefile|  3 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  9 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  4 ++
 .../marvell/octeontx2/af/rvu_devlink.c| 72 +++
 .../marvell/octeontx2/af/rvu_devlink.h| 20 ++
 6 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

diff --git a/drivers/net/ethernet/marvell/octeontx2/Kconfig 
b/drivers/net/ethernet/marvell/octeontx2/Kconfig
index 543a1d047567..16caa02095fe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/Kconfig
+++ b/drivers/net/ethernet/marvell/octeontx2/Kconfig
@@ -9,6 +9,7 @@ config OCTEONTX2_MBOX
 config OCTEONTX2_AF
tristate "Marvell OcteonTX2 RVU Admin Function driver"
select OCTEONTX2_MBOX
+   select NET_DEVLINK
depends on (64BIT && COMPILE_TEST) || ARM64
depends on PCI
help
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/Makefile 
b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
index 2f7a861d0c7b..20135f1d3387 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/Makefile
+++ b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
@@ -9,4 +9,5 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
 octeontx2_mbox-y := mbox.o rvu_trace.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
- rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o
+ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o \
+ rvu_devlink.o
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index a28a518c0eae..67d6e05d1037 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -2816,17 +2816,23 @@ static int rvu_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (err)
goto err_flr;
 
+   err = rvu_register_dl(rvu);
+   if (err)
+   goto err_irq;
+
rvu_setup_rvum_blk_revid(rvu);
 
/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err)
-   goto err_irq;
+   goto err_dl;
 
/* Initialize debugfs */
rvu_dbg_init(rvu);
 
return 0;
+err_dl:
+   rvu_unregister_dl(rvu);
 err_irq:
rvu_unregister_interrupts(rvu);
 err_flr:
@@ -2858,6 +2864,7 @@ static void rvu_remove(struct pci_dev *pdev)
 
rvu_dbg_exit(rvu);
rvu_unregister_interrupts(rvu);
+   rvu_unregister_dl(rvu);
rvu_flr_wq_destroy(rvu);
rvu_cgx_exit(rvu);
rvu_fwdata_exit(rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 5ac9bb12415f..282566235918 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -12,7 +12,10 @@
 #define RVU_H
 
 #include 
+#include 
+
 #include "rvu_struct.h"
+#include "rvu_devlink.h"
 #include "common.h"
 #include "mbox.h"
 
@@ -376,6 +379,7 @@ struct rvu {
 #ifdef CONFIG_DEBUG_FS
struct rvu_debugfs  rvu_dbg;
 #endif
+   struct rvu_devlink  *rvu_dl;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
new file mode 100644
index ..04ef945e7e75
--- /dev/null
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell OcteonTx2 RVU Devlink
+ *
+ * Copyright (C) 2020 Marvell.
+ *
+ */
+
+#include "rvu.h"
+
+#define DRV_NAME "octeontx2-af"
+
+static int rvu_devlink_info_get(struct devlink *devlink, struct 
devlink_info_req *req,
+   struct netlink_ext_ack *extack)
+{
+   char buf[10];
+   int err;
+
+   err = devlink_info_driver_name_put(req, DRV_NAME);
+   if (err)
+   return err;
+
+   sprintf(buf, "%X", OTX2_MBOX_VERSION);
+   return devlink_info_version_fixed_put(req, "mbox version:", buf);
+}
+
+static const struct devlink_ops rvu_devlink_ops = {
+   .info_get = rvu_devlink_info_get,
+};
+
+int rvu_register_dl(struct rvu *rvu)
+{
+   struct rvu_devlink *rvu_dl;
+   struct devlink *dl;
+   int err;
+
+   rvu_dl = kzalloc(sizeof(*rvu_dl), GFP_KERNEL);
+ 

Re: [PATCH] drivers: fpga: Specify HAS_IOMEM dependency for FPGA_DFL

2020-11-19 Thread Moritz Fischer
Hi David,

On Thu, Nov 19, 2020 at 12:22:09AM -0800, David Gow wrote:
> Because dfl.c uses the 'devm_ioremap', 'devm_iounmap',
> 'devm_ioremap_resource', and 'devm_platform_ioremap_resource'
> functions, it should depend on HAS_IOMEM.
> 
> This fixes make allyesconfig under UML (ARCH=um), which doesn't provide
> HAS_IOMEM.
> 
> Signed-off-by: David Gow 
> ---
>  drivers/fpga/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
> index 7cd5a29fc437..5645226ca3ce 100644
> --- a/drivers/fpga/Kconfig
> +++ b/drivers/fpga/Kconfig
> @@ -142,6 +142,7 @@ config FPGA_DFL
>   tristate "FPGA Device Feature List (DFL) support"
>   select FPGA_BRIDGE
>   select FPGA_REGION
> + depends on HAS_IOMEM
>   help
> Device Feature List (DFL) defines a feature list structure that
> creates a linked list of feature headers within the MMIO space
> -- 
> 2.29.2.454.gaff20da3a2-goog
> 
Do you think we can add a Fixes: tag for this?

Thanks,
Moritz


Re: [PATCH v6 1/7] fpga: sec-mgr: fpga security manager class driver

2020-11-19 Thread Moritz Fischer
Hi Russ,

On Thu, Nov 19, 2020 at 06:39:44PM -0800, Russ Weight wrote:
> 
> 
> On 11/15/20 3:03 PM, Moritz Fischer wrote:
> > Hi Russ,
> >
> > On Thu, Nov 05, 2020 at 05:08:59PM -0800, Russ Weight wrote:
> >> Create the FPGA Security Manager class driver. The security
> >> manager provides interfaces to manage secure updates for the
> >> FPGA and BMC images that are stored in FLASH. The driver can
> >> also be used to update root entry hashes and to cancel code
> >> signing keys. The image type is encoded in the image file
> >> and is decoded by the HW/FW secure update engine.
> >>
> >> Signed-off-by: Russ Weight 
> >> Signed-off-by: Xu Yilun 
> >> Reviewed-by: Tom Rix 
> >> ---
> >> v6:
> >>   - Removed sysfs support and documentation for the display of the
> >> flash count, root entry hashes, and code-signing-key cancelation
> >> vectors.
> >> v5:
> >>   - Added the devm_fpga_sec_mgr_unregister() function, following recent
> >> changes to the fpga_manager() implementation.
> >>   - Changed some *_show() functions to use sysfs_emit() instead of sprintf(
> >> v4:
> >>   - Changed from "Intel FPGA Security Manager" to FPGA Security Manager"
> >> and removed unnecessary references to "Intel".
> >>   - Changed: iops -> sops, imgr -> smgr, IFPGA_ -> FPGA_, ifpga_ to fpga_
> >> v3:
> >>   - Modified sysfs handler check in check_sysfs_handler() to make
> >> it more readable.
> >> v2:
> >>   - Bumped documentation dates and versions
> >>   - Added Documentation/fpga/ifpga-sec-mgr.rst 
> >>   - Removed references to bmc_flash_count & smbus_flash_count (not 
> >> supported)
> >>   - Split ifpga_sec_mgr_register() into create() and register() functions
> >>   - Added devm_ifpga_sec_mgr_create()
> >>   - Removed typedefs for imgr ops
> >> ---
> >>  .../ABI/testing/sysfs-class-fpga-sec-mgr  |   5 +
> >>  Documentation/fpga/fpga-sec-mgr.rst   |  44 +++
> >>  Documentation/fpga/index.rst  |   1 +
> >>  MAINTAINERS   |   9 +
> >>  drivers/fpga/Kconfig  |   9 +
> >>  drivers/fpga/Makefile |   3 +
> >>  drivers/fpga/fpga-sec-mgr.c   | 296 ++
> >>  include/linux/fpga/fpga-sec-mgr.h |  44 +++
> >>  8 files changed, 411 insertions(+)
> >>  create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-sec-mgr
> >>  create mode 100644 Documentation/fpga/fpga-sec-mgr.rst
> >>  create mode 100644 drivers/fpga/fpga-sec-mgr.c
> >>  create mode 100644 include/linux/fpga/fpga-sec-mgr.h
> >>
> >> diff --git a/Documentation/ABI/testing/sysfs-class-fpga-sec-mgr 
> >> b/Documentation/ABI/testing/sysfs-class-fpga-sec-mgr
> >> new file mode 100644
> >> index ..ecda22a3ff3b
> >> --- /dev/null
> >> +++ b/Documentation/ABI/testing/sysfs-class-fpga-sec-mgr
> >> @@ -0,0 +1,5 @@
> >> +What: /sys/class/fpga_sec_mgr/fpga_secX/name
> >> +Date: Oct 2020
> >> +KernelVersion:  5.11
> >> +Contact:  Russ Weight 
> >> +Description:  Name of low level fpga security manager driver.
> >> diff --git a/Documentation/fpga/fpga-sec-mgr.rst 
> >> b/Documentation/fpga/fpga-sec-mgr.rst
> >> new file mode 100644
> >> index ..26dac599ead7
> >> --- /dev/null
> >> +++ b/Documentation/fpga/fpga-sec-mgr.rst
> >> @@ -0,0 +1,44 @@
> >> +.. SPDX-License-Identifier: GPL-2.0
> >> +
> >> +
> >> +FPGA Security Manager Class Driver
> >> +
> >> +
> >> +The FPGA Security Manager class driver provides a common
> >> +API for user-space tools to manage updates for secure FPGA
> >> +devices. Device drivers that instantiate the Security
> >> +Manager class driver will interact with a HW secure update
> >> +engine in order to transfer new FPGA and BMC images to FLASH so
> >> +that they will be automatically loaded when the FPGA card reboots.
> >> +
> >> +A significant difference between the FPGA Manager and the FPGA
> >> +Security Manager is that the FPGA Manager does a live update (Partial
> >> +Reconfiguration) to a device, whereas the FPGA Security Manager
> >> +updates the FLASH images for the Static Region and the BMC so that
> >> +they will be loaded the next time the FPGA card boots. Security is
> >> +enforced by hardware and firmware. The security manager interacts
> >> +with the firmware to initiate an update, pass in the necessary data,
> >> +and collect status on the update.
> > I've always wondered if we could've made this a functionality of an FPGA
> > manager 'non-volatile' node or something.
> >
> > I guess there might be cases where you can only do either of them, i.e.
> > only update flash or only update at runtime.
> 
> Today, in light of Richard Gong's recent patch set, I took another look at
> the fpga manager, trying to determine what changes would need to be made in
> the fpga manager order to support secure updates. These are my observations:
> 
> (1) For the 

[RFC V2 net-next 1/2] ethtool: add support for controling the type of adaptive coalescing

2020-11-19 Thread Huazhong Tan
Since the information whether the adaptive behavior is implemented
by DIM or driver custom is useful, so add new attribute to
ETHTOOL_MSG_COALESCE_GET/ETHTOOL_MSG_COALESCE_SET commands to control
the type of adaptive coalescing.

In order to compatible with ioctl code, add a extended coalescing
handler to deal with it in the netlink API, then other new extended
coalescing parameters can utiliaze it as well.

Suggested-by: Jakub Kicinski 
Signed-off-by: Huazhong Tan 
---
 Documentation/networking/ethtool-netlink.rst |  1 +
 include/linux/ethtool.h  | 14 +++
 include/uapi/linux/ethtool_netlink.h |  1 +
 net/ethtool/coalesce.c   | 35 ++--
 net/ethtool/netlink.h|  2 +-
 5 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/Documentation/networking/ethtool-netlink.rst 
b/Documentation/networking/ethtool-netlink.rst
index 30b9824..dae7145 100644
--- a/Documentation/networking/ethtool-netlink.rst
+++ b/Documentation/networking/ethtool-netlink.rst
@@ -928,6 +928,7 @@ Kernel response contents:
   ``ETHTOOL_A_COALESCE_TX_USECS_HIGH`` u32 delay (us), high Tx
   ``ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH``u32 max packets, high Tx
   ``ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL``  u32 rate sampling interval
+  ``ETHTOOL_A_COALESCE_USE_DIM``   boolusing DIM adaptive
   ===  ==  ===
 
 Attributes are only included in reply if their value is not zero or the
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 6408b44..4426d65 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -215,6 +215,7 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 
*legacy_u32,
 #define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19)
 #define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGHBIT(20)
 #define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL  BIT(21)
+#define ETHTOOL_COALESCE_USE_DIM   BIT(22)
 
 #define ETHTOOL_COALESCE_USECS \
(ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
@@ -241,6 +242,10 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 
*legacy_u32,
 ETHTOOL_COALESCE_PKT_RATE_LOW | ETHTOOL_COALESCE_PKT_RATE_HIGH | \
 ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
 
+struct ethtool_ext_coalesce {
+   __u32 use_dim;
+};
+
 #define ETHTOOL_STAT_NOT_SET   (~0ULL)
 
 /**
@@ -298,9 +303,14 @@ struct ethtool_pause_stats {
  * or zero.
  * @get_coalesce: Get interrupt coalescing parameters.  Returns a negative
  * error code or zero.
+ * @get_ext_coalesce: Get extended interrupt coalescing parameters.
+ * Returns a negative error code or zero.
  * @set_coalesce: Set interrupt coalescing parameters.  Supported coalescing
  * types should be set in @supported_coalesce_params.
  * Returns a negative error code or zero.
+ * @set_ext_coalesce: Set extended interrupt coalescing parameters.  Supported
+ * extended coalescing types should be set in @supported_coalesce_params.
+ * Returns a negative error code or zero.
  * @get_ringparam: Report ring sizes
  * @set_ringparam: Set ring sizes.  Returns a negative error code or zero.
  * @get_pause_stats: Report pause frame statistics. Drivers must not zero
@@ -437,7 +447,11 @@ struct ethtool_ops {
int (*set_eeprom)(struct net_device *,
  struct ethtool_eeprom *, u8 *);
int (*get_coalesce)(struct net_device *, struct ethtool_coalesce *);
+   int (*get_ext_coalesce)(struct net_device *,
+   struct ethtool_ext_coalesce *);
int (*set_coalesce)(struct net_device *, struct ethtool_coalesce *);
+   int (*set_ext_coalesce)(struct net_device *,
+   struct ethtool_ext_coalesce *);
void(*get_ringparam)(struct net_device *,
 struct ethtool_ringparam *);
int (*set_ringparam)(struct net_device *,
diff --git a/include/uapi/linux/ethtool_netlink.h 
b/include/uapi/linux/ethtool_netlink.h
index e2bf36e..e3458d9 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -366,6 +366,7 @@ enum {
ETHTOOL_A_COALESCE_TX_USECS_HIGH,   /* u32 */
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH,  /* u32 */
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL,/* u32 */
+   ETHTOOL_A_COALESCE_USE_DIM, /* u8 */
 
/* add new constants above here */
__ETHTOOL_A_COALESCE_CNT,
diff --git a/net/ethtool/coalesce.c b/net/ethtool/coalesce.c
index 1d6bc13..d4d8901 100644
--- a/net/ethtool/coalesce.c
+++ b/net/ethtool/coalesce.c
@@ -11,6 +11,7 @@ struct coalesce_reply_data {
struct ethnl_reply_data base;
struct ethtool_coalesce coalesce;
u32 

[RFC V2 net-next 2/2] net: hns3: add support for dynamic interrupt moderation

2020-11-19 Thread Huazhong Tan
Add dynamic interrupt moderation support for the HNS3 driver,
and add ethtool support for controlling the type of adaptive.

Signed-off-by: Huazhong Tan 
---
 drivers/net/ethernet/hisilicon/Kconfig |  1 +
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 87 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h|  4 +
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 25 ++-
 4 files changed, 115 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/Kconfig 
b/drivers/net/ethernet/hisilicon/Kconfig
index 44f9279..fa6025d 100644
--- a/drivers/net/ethernet/hisilicon/Kconfig
+++ b/drivers/net/ethernet/hisilicon/Kconfig
@@ -130,6 +130,7 @@ config HNS3_ENET
default m
depends on 64BIT && PCI
depends on INET
+   select DIMLIB
help
  This selects the Ethernet Driver for Hisilicon Network Subsystem 3 
for hip08
  family of SoCs. This module depends upon HNAE3 driver to access the 
HNAE3
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c 
b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 999a2aa..b08aea7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -96,6 +96,7 @@ static irqreturn_t hns3_irq_handle(int irq, void *vector)
struct hns3_enet_tqp_vector *tqp_vector = vector;
 
napi_schedule_irqoff(_vector->napi);
+   tqp_vector->event_cnt++;
 
return IRQ_HANDLED;
 }
@@ -199,6 +200,8 @@ static void hns3_vector_disable(struct hns3_enet_tqp_vector 
*tqp_vector)
 
disable_irq(tqp_vector->vector_irq);
napi_disable(_vector->napi);
+   cancel_work_sync(_vector->rx_group.dim.work);
+   cancel_work_sync(_vector->tx_group.dim.work);
 }
 
 void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
@@ -3401,6 +3404,32 @@ static void hns3_update_new_int_gl(struct 
hns3_enet_tqp_vector *tqp_vector)
tqp_vector->last_jiffies = jiffies;
 }
 
+static void hns3_update_rx_int_coalesce(struct hns3_enet_tqp_vector 
*tqp_vector)
+{
+   struct hns3_enet_ring_group *rx_group = _vector->rx_group;
+   struct dim_sample sample = {};
+
+   if (!rx_group->coal.adapt_enable)
+   return;
+
+   dim_update_sample(tqp_vector->event_cnt, rx_group->total_packets,
+ rx_group->total_bytes, );
+   net_dim(_group->dim, sample);
+}
+
+static void hns3_update_tx_int_coalesce(struct hns3_enet_tqp_vector 
*tqp_vector)
+{
+   struct hns3_enet_ring_group *tx_group = _vector->tx_group;
+   struct dim_sample sample = {};
+
+   if (!tx_group->coal.adapt_enable)
+   return;
+
+   dim_update_sample(tqp_vector->event_cnt, tx_group->total_packets,
+ tx_group->total_bytes, );
+   net_dim(_group->dim, sample);
+}
+
 static int hns3_nic_common_poll(struct napi_struct *napi, int budget)
 {
struct hns3_nic_priv *priv = netdev_priv(napi->dev);
@@ -3444,7 +3473,13 @@ static int hns3_nic_common_poll(struct napi_struct 
*napi, int budget)
 
if (napi_complete(napi) &&
likely(!test_bit(HNS3_NIC_STATE_DOWN, >state))) {
-   hns3_update_new_int_gl(tqp_vector);
+   if (priv->dim_enable) {
+   hns3_update_rx_int_coalesce(tqp_vector);
+   hns3_update_tx_int_coalesce(tqp_vector);
+   } else {
+   hns3_update_new_int_gl(tqp_vector);
+   }
+
hns3_mask_vector_irq(tqp_vector, 1);
}
 
@@ -3575,6 +3610,54 @@ static void hns3_nic_set_cpumask(struct hns3_nic_priv 
*priv)
}
 }
 
+static void hns3_rx_dim_work(struct work_struct *work)
+{
+   struct dim *dim = container_of(work, struct dim, work);
+   struct hns3_enet_ring_group *group = container_of(dim,
+   struct hns3_enet_ring_group, dim);
+   struct hns3_enet_tqp_vector *tqp_vector = group->ring->tqp_vector;
+   struct dim_cq_moder cur_moder =
+   net_dim_get_rx_moderation(dim->mode, dim->profile_ix);
+
+   hns3_set_vector_coalesce_rx_gl(group->ring->tqp_vector, cur_moder.usec);
+   tqp_vector->rx_group.coal.int_gl = cur_moder.usec;
+
+   if (cur_moder.pkts < tqp_vector->rx_group.coal.int_ql_max) {
+   hns3_set_vector_coalesce_rx_ql(tqp_vector, cur_moder.pkts);
+   tqp_vector->rx_group.coal.int_ql = cur_moder.pkts;
+   }
+
+   dim->state = DIM_START_MEASURE;
+}
+
+static void hns3_tx_dim_work(struct work_struct *work)
+{
+   struct dim *dim = container_of(work, struct dim, work);
+   struct hns3_enet_ring_group *group = container_of(dim,
+   struct hns3_enet_ring_group, dim);
+   struct hns3_enet_tqp_vector *tqp_vector = group->ring->tqp_vector;
+   struct dim_cq_moder cur_moder =
+   net_dim_get_tx_moderation(dim->mode, dim->profile_ix);
+
+   

[RFC V2 net-next 0/2] net: updates for -next

2020-11-19 Thread Huazhong Tan
#2 will add DIM for the HNS3 ethernet driver, then there will
be two implemation of IRQ adaptive coalescing (DIM and driver
custiom, so #1 adds a new netlink attribute to the
ETHTOOL_MSG_COALESCE_GET/ETHTOOL_MSG_COALESCE_SET commands
which controls the type of adaptive coalescing.

change log:
V2: fixes some problems in #1 reported by Andrew Lunn & Michal Kubecek.

previous version:
V1: 
https://patchwork.ozlabs.org/project/netdev/cover/1605758050-21061-1-git-send-email-tanhuazh...@huawei.com/

Huazhong Tan (2):
  ethtool: add support for controling the type of adaptive coalescing
  net: hns3: add support for dynamic interrupt moderation

 Documentation/networking/ethtool-netlink.rst   |  1 +
 drivers/net/ethernet/hisilicon/Kconfig |  1 +
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 87 +-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h|  4 +
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 25 ++-
 include/linux/ethtool.h| 14 
 include/uapi/linux/ethtool_netlink.h   |  1 +
 net/ethtool/coalesce.c | 35 -
 net/ethtool/netlink.h  |  2 +-
 9 files changed, 165 insertions(+), 5 deletions(-)

-- 
2.7.4



Re: [PATCH] net: qrtr: Unprepare MHI channels during remove

2020-11-19 Thread Manivannan Sadhasivam
On Thu, Nov 19, 2020 at 10:18:28PM -0800, Jakub Kicinski wrote:
> On Fri, 20 Nov 2020 11:45:12 +0530 Manivannan Sadhasivam wrote:
> > Jakub, can you please provide your ack so that I can take it?
> 
> Sure:
> 
> Acked-by: Jakub Kicinski 

Patch applied to mhi-ath11k-immutable.

Thanks,
Mani


RE: [EXT] Re: [PATCH v3 1/4] dt-bindings: soc: imx8m: add DT Binding doc for soc unique ID

2020-11-19 Thread Alice Guo


> -Original Message-
> From: Krzysztof Kozlowski 
> Sent: 2020年11月17日 15:36
> To: Alice Guo 
> Cc: robh...@kernel.org; shawn...@kernel.org; s.ha...@pengutronix.de;
> dl-linux-imx ; Peng Fan ;
> devicet...@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-arm-ker...@lists.infradead.org
> Subject: Re: [EXT] Re: [PATCH v3 1/4] dt-bindings: soc: imx8m: add DT Binding
> doc for soc unique ID
> 
> Caution: EXT Email
> 
> On Tue, Nov 17, 2020 at 07:10:28AM +, Alice Guo wrote:
> >
> >
> > > -Original Message-
> > > From: Krzysztof Kozlowski 
> > > Sent: 2020年11月17日 0:03
> > > To: Alice Guo 
> > > Cc: robh...@kernel.org; shawn...@kernel.org; s.ha...@pengutronix.de;
> > > dl-linux-imx ; Peng Fan ;
> > > devicet...@vger.kernel.org; linux-kernel@vger.kernel.org;
> > > linux-arm-ker...@lists.infradead.org
> > > Subject: Re: [EXT] Re: [PATCH v3 1/4] dt-bindings: soc: imx8m: add
> > > DT Binding doc for soc unique ID
> > >
> > > Caution: EXT Email
> > >
> > > On Mon, Nov 16, 2020 at 07:04:13AM +, Alice Guo wrote:
> > > >
> > > > > -Original Message-
> > > > > From: Krzysztof Kozlowski 
> > > > > Sent: 2020年11月15日 0:50
> > > > > To: Alice Guo 
> > > > > Cc: robh...@kernel.org; shawn...@kernel.org;
> > > > > s.ha...@pengutronix.de; dl-linux-imx ; Peng
> > > > > Fan ; devicet...@vger.kernel.org;
> > > > > linux-kernel@vger.kernel.org;
> > > > > linux-arm-ker...@lists.infradead.org
> > > > > Subject: [EXT] Re: [PATCH v3 1/4] dt-bindings: soc: imx8m: add
> > > > > DT Binding doc for soc unique ID
> > > > >
> > > > > Caution: EXT Email
> > > > >
> > > > > On Fri, Nov 13, 2020 at 07:04:06PM +0800, Alice Guo wrote:
> > > > > > Add DT Binding doc for the Unique ID of i.MX 8M series.
> > > > > >
> > > > > > Signed-off-by: Alice Guo 
> > > > > > ---
> > > > > >  .../devicetree/bindings/arm/fsl.yaml  | 25
> > > > > +++
> > > > > >  1 file changed, 25 insertions(+)
> > > > > >
> > > > > > diff --git a/Documentation/devicetree/bindings/arm/fsl.yaml
> > > > > > b/Documentation/devicetree/bindings/arm/fsl.yaml
> > > > > > index e4db0f9ed664..f4faebbb57da 100644
> > > > > > --- a/Documentation/devicetree/bindings/arm/fsl.yaml
> > > > > > +++ b/Documentation/devicetree/bindings/arm/fsl.yaml
> > > > > > @@ -901,6 +901,31 @@ properties:
> > > > > >- fsl,s32v234-evb   # S32V234-EVB2
> > > Customer
> > > > > Evaluation Board
> > > > > >- const: fsl,s32v234
> > > > > >
> > > > > > +  soc:
> > > > > > +type: object
> > > > > > +properties:
> > > > > > +  compatible:
> > > > > > +oneOf:
> > > > > > +  - description: i.MX8M SoCs
> > > > > > +items:
> > > > > > +  - enum:
> > > > > > +  - fsl,imx8mm-soc
> > > > > > +  - fsl,imx8mn-soc
> > > > > > +  - fsl,imx8mp-soc
> > > > > > +  - fsl,imx8mq-soc
> > > > > > +  - const: simple-bus
> > > > > > +
> > > > > > +  - description: Other SoCs
> > > > > > +items:
> > > > > > +  - const: simple-bus
> > > > > > +
> > > > > > +  nvmem-cells:
> > > > > > +maxItems: 1
> > > > > > +description: Phandle to the SOC Unique ID provided by
> > > > > > + a nvmem node
> > > > > > +
> > > > > > +  nvmem-cells-names:
> > > > > > +const: soc_unique_id
> > > > > > +
> > > > > >  additionalProperties: true
> > > > >
> > > > > The "soc" node should be required for these compatibles.
> > > > > Otherwise you will have to stay with this
> > > > > backwards-compatible-DTB-device-initcall-glue for many years...
> > > > > I think you
> > > can achieve it with allOf.
> > > > >
> > > > [Alice Guo]Hi,
> > > > I find that my description for compatible is ambiguous. There are
> > > > two kinds of
> > > compatible of the "soc" node:
> > > > 1. For dtsi files used for SoCs other than imx8m series SoCs and
> > > > old version dtsi files used for imx8m series SoCs, compatible of
> > > > the "soc" node is
> > > "simple-bus".
> > > > 2. For new version dtsi files used for imx8m series SoCs,
> > > > compatible of the
> > > "soc" node is {"fsl,imx8mX-soc","simple-bus"}.
> > > >
> > > > "nvmem-cell" is an optional property.
> > > >
> > > > I do not understand what you mean. You mean that limit the
> > > > compatible of
> > > "soc" node must include " fsl,imx8mX-soc" in new version dts files.
> > > Is my understanding correct?
> > >
> > > All new DTS files should have soc node with "fsl,imx8mX-soc" and
> > > this should be required by dtschema. The nvmem-cells and related
> > > properties do not look like optional. From the hardware perspective
> > > - they are always present. From the driver point of view: they are 
> > > required
> and driver will fail to work.
> >
> > [Alice Guo]
> > +  soc:
> > +type: object
> > +properties:
> > +  compatible:
> > +oneOf:
> > +  - description: new version DTS for i.MX8M SoCs
> > +

回复: [PATCH] srcu: Remove srcu_cblist_invoking member from sdp

2020-11-19 Thread Zhang, Qiang



发件人: Paul E. McKenney 
发送时间: 2020年11月20日 2:12
收件人: Zhang, Qiang
抄送: jiangshan...@gmail.com; rost...@goodmis.org; j...@joshtriplett.org; 
r...@vger.kernel.org; linux-kernel@vger.kernel.org
主题: Re: [PATCH] srcu: Remove srcu_cblist_invoking member from sdp

[Please note this e-mail is from an EXTERNAL e-mail address]

On Thu, Nov 19, 2020 at 01:34:11PM +0800, qiang.zh...@windriver.com wrote:
> From: Zqiang 
>
> Workqueue can ensure the multiple same sdp->work sequential
> execution in rcu_gp_wq, not need srcu_cblist_invoking to
> prevent concurrent execution, so remove it.
>
> Signed-off-by: Zqiang 

>Good job analyzing the code, which is very good to see!!!
>
>But these do have a potential purpose.  Right now, it is OK to invoke
>synchronize_srcu() during early boot, that is, before the scheduler
>has started.  But there is a gap from the time that the scheduler has
>initialized (so that preemption and blocking are possible) and the time
>that workqueues are initialized and fully functional.  Only after that
>is it once again OK to use synchronize_srcu().
>
>If synchronize_srcu() is ever required to work correctly during that
>time period, it will need to directly invoke the functions that are
>currently run in workqueue context.  Which means that there will then be
>the possibility of two instances of these functions running just after
>workqueues are available.
>
>   Thanx, Paul

Thanks Paul.

> ---
>  include/linux/srcutree.h | 1 -
>  kernel/rcu/srcutree.c| 8 ++--
>  2 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
> index 9cfcc8a756ae..62d8312b5451 100644
> --- a/include/linux/srcutree.h
> +++ b/include/linux/srcutree.h
> @@ -31,7 +31,6 @@ struct srcu_data {
>   struct rcu_segcblist srcu_cblist;   /* List of callbacks.*/
>   unsigned long srcu_gp_seq_needed;   /* Furthest future GP needed. */
>   unsigned long srcu_gp_seq_needed_exp;   /* Furthest future exp GP. */
> - bool srcu_cblist_invoking;  /* Invoking these CBs? */
>   struct timer_list delay_work;   /* Delay for CB invoking */
>   struct work_struct work;/* Context for CB invoking. */
>   struct rcu_head srcu_barrier_head;  /* For srcu_barrier() use. */
> diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
> index 3c5e2806e0b9..c4d5cd2567a6 100644
> --- a/kernel/rcu/srcutree.c
> +++ b/kernel/rcu/srcutree.c
> @@ -134,7 +134,6 @@ static void init_srcu_struct_nodes(struct srcu_struct 
> *ssp, bool is_static)
>   sdp = per_cpu_ptr(ssp->sda, cpu);
>   spin_lock_init(_PRIVATE(sdp, lock));
>   rcu_segcblist_init(>srcu_cblist);
> - sdp->srcu_cblist_invoking = false;
>   sdp->srcu_gp_seq_needed = ssp->srcu_gp_seq;
>   sdp->srcu_gp_seq_needed_exp = ssp->srcu_gp_seq;
>   sdp->mynode = _first[cpu / levelspread[level]];
> @@ -1254,14 +1253,11 @@ static void srcu_invoke_callbacks(struct work_struct 
> *work)
>   spin_lock_irq_rcu_node(sdp);
>   rcu_segcblist_advance(>srcu_cblist,
> rcu_seq_current(>srcu_gp_seq));
> - if (sdp->srcu_cblist_invoking ||
> - !rcu_segcblist_ready_cbs(>srcu_cblist)) {
> + if (!rcu_segcblist_ready_cbs(>srcu_cblist)) {
>   spin_unlock_irq_rcu_node(sdp);
>   return;  /* Someone else on the job or nothing to do. */
>   }
>
> - /* We are on the job!  Extract and invoke ready callbacks. */
> - sdp->srcu_cblist_invoking = true;
>   rcu_segcblist_extract_done_cbs(>srcu_cblist, _cbs);
>   len = ready_cbs.len;
>   spin_unlock_irq_rcu_node(sdp);
> @@ -1282,7 +1278,7 @@ static void srcu_invoke_callbacks(struct work_struct 
> *work)
>   rcu_segcblist_add_len(>srcu_cblist, -len);
>   (void)rcu_segcblist_accelerate(>srcu_cblist,
>  rcu_seq_snap(>srcu_gp_seq));
> - sdp->srcu_cblist_invoking = false;
> +
>   more = rcu_segcblist_ready_cbs(>srcu_cblist);
>   spin_unlock_irq_rcu_node(sdp);
>   if (more)
> --
> 2.17.1
>


Re: [f2fs-dev] [PATCH] f2fs: remove writeback_inodes_sb in f2fs_remount

2020-11-19 Thread Chao Yu

On 2020/11/18 22:01, Liu Song via Linux-f2fs-devel wrote:

From: Liu Song 

Since sync_inodes_sb has been used, there is no need to
use writeback_inodes_sb, so remove it.

Signed-off-by: Liu Song 


Reviewed-by: Chao Yu 

Thanks,


Re: [PATCH] net: qrtr: Unprepare MHI channels during remove

2020-11-19 Thread Jakub Kicinski
On Fri, 20 Nov 2020 11:45:12 +0530 Manivannan Sadhasivam wrote:
> Jakub, can you please provide your ack so that I can take it?

Sure:

Acked-by: Jakub Kicinski 


Re: [PATCH] net: qrtr: Unprepare MHI channels during remove

2020-11-19 Thread Manivannan Sadhasivam
On Thu, Nov 19, 2020 at 09:10:46PM -0800, Jakub Kicinski wrote:
> On Wed, 18 Nov 2020 10:20:25 -0800 Bhaumik Bhatt wrote:
> > Reset MHI device channels when driver remove is called due to
> > module unload or any crash scenario. This will make sure that
> > MHI channels no longer remain enabled for transfers since the
> > MHI stack does not take care of this anymore after the auto-start
> > channels feature was removed.
> > 
> > Signed-off-by: Bhaumik Bhatt 
> 
> Patch seems reasonable, Mani are you taking it or should I?
> 

Since I already picked up one qrtr patch, makese sense to pick this
also.

> Bhaumik would you mind adding a Fixes tag to be clear where 
> the issue was introduced?

This is due to the MHI auto-start change which just got queued into
mhi-next. I don't think we need a Fixes tag.

Jakub, can you please provide your ack so that I can take it?

Thanks,
Mani


[PATCH 2/2] m68k: Add a missing ELF_DETAILS in link script

2020-11-19 Thread Youling Tang
Commit c604abc3f6e3 ("vmlinux.lds.h: Split ELF_DETAILS from STABS_DEBUG")
after should add a missing ELF_DETAILS, at the same time, the .comment
section has been included in the ELF_DETAILS.

Signed-off-by: Youling Tang 
---
 arch/m68k/kernel/vmlinux-nommu.lds | 2 +-
 arch/m68k/kernel/vmlinux-std.lds   | 2 +-
 arch/m68k/kernel/vmlinux-sun3.lds  | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/kernel/vmlinux-nommu.lds 
b/arch/m68k/kernel/vmlinux-nommu.lds
index 247e19f..396e126 100644
--- a/arch/m68k/kernel/vmlinux-nommu.lds
+++ b/arch/m68k/kernel/vmlinux-nommu.lds
@@ -86,7 +86,7 @@ SECTIONS {
_end = .;
 
STABS_DEBUG
-   .comment 0 : { *(.comment) }
+   ELF_DETAILS
 
/* Sections to be discarded */
DISCARDS
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 1511346..ed1d9ed 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -59,7 +59,7 @@ SECTIONS
   _end = . ;
 
   STABS_DEBUG
-  .comment 0 : { *(.comment) }
+  ELF_DETAILS
 
   /* Sections to be discarded */
   DISCARDS
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds 
b/arch/m68k/kernel/vmlinux-sun3.lds
index 90ff8e5..4a52f44 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -52,6 +52,7 @@ __init_begin = .;
   _end = . ;
 
   STABS_DEBUG
+  ELF_DETAILS
 
   /* Sections to be discarded */
   DISCARDS
-- 
2.1.0



Re: [PATCH v12 5/5] selftest: mhi: Add support to test MHI LOOPBACK channel

2020-11-19 Thread Manivannan Sadhasivam
On Mon, Nov 16, 2020 at 02:46:22PM -0800, Hemant Kumar wrote:
> Loopback test opens the MHI device file node and writes
> a data buffer to it. MHI UCI kernel space driver copies
> the data and sends it to MHI uplink (Tx) LOOPBACK channel.
> MHI device loops back the same data to MHI downlink (Rx)
> LOOPBACK channel. This data is read by test application
> and compared against the data sent. Test passes if data
> buffer matches between Tx and Rx. Test application performs
> open(), poll(), write(), read() and close() file operations.
> 
> Signed-off-by: Hemant Kumar 

One nitpick below, with that addressed:

Reviewed-by: Manivannan Sadhasivam 

> ---
>  Documentation/mhi/uci.rst  |  32 +
>  tools/testing/selftests/Makefile   |   1 +
>  tools/testing/selftests/drivers/.gitignore |   1 +
>  tools/testing/selftests/drivers/mhi/Makefile   |   8 +
>  tools/testing/selftests/drivers/mhi/config |   2 +
>  .../testing/selftests/drivers/mhi/loopback_test.c  | 802 
> +
>  6 files changed, 846 insertions(+)
>  create mode 100644 tools/testing/selftests/drivers/mhi/Makefile
>  create mode 100644 tools/testing/selftests/drivers/mhi/config
>  create mode 100644 tools/testing/selftests/drivers/mhi/loopback_test.c
> 
> diff --git a/Documentation/mhi/uci.rst b/Documentation/mhi/uci.rst
> index ce8740e..0a04afe 100644
> --- a/Documentation/mhi/uci.rst
> +++ b/Documentation/mhi/uci.rst
> @@ -79,6 +79,38 @@ MHI client driver performs read operation, same data gets 
> looped back to MHI
>  host using LOOPBACK channel 1. LOOPBACK channel is used to verify data path
>  and data integrity between MHI Host and MHI device.
>  
> +Loopback Test
> +~
> +
> +Loopback test application is used to verify data integrity between MHI host 
> and
> +MHI device over LOOPBACK channel. This also confirms that basic MHI data path
> +is working properly. Test performs write() to send tx buffer to MHI device 
> file
> +node for LOOPBACK uplink channel. MHI LOOPBACK downlink channel loops back
> +transmit data to MHI Host. Test application receives data in receive buffer 
> as
> +part of read(). It verifies if tx buffer matches rx buffer. Test application
> +performs poll() before making write() and read() system calls. Test passes if
> +match is found.
> +
> +Test is present under tools/testing/selftests/drivers/mhi. It is compiled 
> using
> +following command in same dir:-
> +
> +make loopback_test
> +
> +Test is run using following command arguments:-
> +
> +loopback_test -c  -b  -l  -i
> +
> +
> +Required argument:
> +-c : loopback chardev node
> +
> +Optional argument:
> +-b : transmit buffer size. If not present 1024 bytes size transmit buffer
> + is sent.
> +-i : Number of iterations to perform, If not present only one transmit buffer
> + is sent.
> +-l : Log level. If not present defaults to DBG_LVL_INFO.
> +
>  Other Use Cases
>  ---
>  
> diff --git a/tools/testing/selftests/Makefile 
> b/tools/testing/selftests/Makefile
> index d9c2835..084bc1e 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -10,6 +10,7 @@ TARGETS += core
>  TARGETS += cpufreq
>  TARGETS += cpu-hotplug
>  TARGETS += drivers/dma-buf
> +TARGETS += drivers/mhi
>  TARGETS += efivarfs
>  TARGETS += exec
>  TARGETS += filesystems
> diff --git a/tools/testing/selftests/drivers/.gitignore 
> b/tools/testing/selftests/drivers/.gitignore
> index ca74f2e..e4806d5 100644
> --- a/tools/testing/selftests/drivers/.gitignore
> +++ b/tools/testing/selftests/drivers/.gitignore
> @@ -1,2 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  /dma-buf/udmabuf
> +/mhi/loopback_test
> diff --git a/tools/testing/selftests/drivers/mhi/Makefile 
> b/tools/testing/selftests/drivers/mhi/Makefile
> new file mode 100644
> index 000..c06c925
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/mhi/Makefile
> @@ -0,0 +1,8 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +CFLAGS += -I../../../../../usr/include/ -g -Wall
> +
> +LDLIBS = -lpthread
> +TEST_GEN_PROGS := loopback_test
> +
> +include ../../lib.mk
> +
> diff --git a/tools/testing/selftests/drivers/mhi/config 
> b/tools/testing/selftests/drivers/mhi/config
> new file mode 100644
> index 000..471dc92
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/mhi/config
> @@ -0,0 +1,2 @@
> +CONFIG_MHI_BUS=y
> +CONFIG_MHi_UCI=y
> diff --git a/tools/testing/selftests/drivers/mhi/loopback_test.c 
> b/tools/testing/selftests/drivers/mhi/loopback_test.c
> new file mode 100644
> index 000..99b7712
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/mhi/loopback_test.c
> @@ -0,0 +1,802 @@
> +

[...]

> +int main(int argc, char *argv[])
> +{
> + int ret = 0;
> +
> + loopback_test_set_defaults();
> + test_log(DBG_LVL_INFO, "MHI Loopback test App\n");
> +
> + if (argc > 1)
> + ret = loopback_test_parse(argc, argv);

Effectively this functions does parse and 

[PATCH 1/2] m68k: Drop redundant NOTES in link script

2020-11-19 Thread Youling Tang
Commit eaf937075c9a ("vmlinux.lds.h: Move NOTES into RO_DATA") after
should remove redundant NOTES.

Signed-off-by: Youling Tang 
---
 arch/m68k/kernel/vmlinux-nommu.lds | 1 -
 arch/m68k/kernel/vmlinux-std.lds   | 1 -
 arch/m68k/kernel/vmlinux-sun3.lds  | 1 -
 3 files changed, 3 deletions(-)

diff --git a/arch/m68k/kernel/vmlinux-nommu.lds 
b/arch/m68k/kernel/vmlinux-nommu.lds
index 7b97542..247e19f 100644
--- a/arch/m68k/kernel/vmlinux-nommu.lds
+++ b/arch/m68k/kernel/vmlinux-nommu.lds
@@ -65,7 +65,6 @@ SECTIONS {
_edata = .;
 
EXCEPTION_TABLE(16)
-   NOTES
 
. = ALIGN(PAGE_SIZE);
__init_begin = .;
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 4d33da4..1511346 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -49,7 +49,6 @@ SECTIONS
*(.m68k_fixup)
__stop_fixup = .;
   }
-  NOTES
   .init_end : {
/* This ALIGN be in a section so that _end is at the end of the
   load segment. */
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds 
b/arch/m68k/kernel/vmlinux-sun3.lds
index 87d9f4d0..90ff8e5 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -33,7 +33,6 @@ SECTIONS
   RW_DATA(16, PAGE_SIZE, THREAD_SIZE) :data
   /* End of data goes *here* so that freeing init code works properly. */
   _edata = .;
-  NOTES
 
   /* will be freed after init */
   . = ALIGN(PAGE_SIZE);/* Init code and data */
-- 
2.1.0



[GIT PULL] xen: branch for v5.10-rc5

2020-11-19 Thread Juergen Gross
Linus,

Please git pull the following tag:

 git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git 
for-linus-5.10b-rc5-tag

xen: branch for v5.10-rc5

It contains a single fix for avoiding WARN splats when booting a Xen
guest with nosmt.

Thanks.

Juergen

 arch/x86/xen/spinlock.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Brian Masney (1):
  x86/xen: don't unbind uninitialized lock_kicker_irq


  1   2   3   4   5   6   7   8   9   10   >