LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: linux-next: build warnings in Linus' tree
From: Anatolij Gustschin @ 2021-10-14 12:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Stephen Rothwell, Linux Next Mailing List, Rob Herring, PowerPC,
	Linux Kernel Mailing List
In-Reply-To: <CAK8P3a0yKvZW2-XFJtPORpa=FhG+UJgk=m0O1GiC_yLw+1Pfvw@mail.gmail.com>

On Thu, 14 Oct 2021 10:44:46 +0200
Arnd Bergmann arnd@arndb.de wrote:

>On Thu, Oct 14, 2021 at 12:12 AM Anatolij Gustschin <agust@denx.de> wrote:
>> On Tue, 12 Oct 2021 16:39:56 +0200
>> Arnd Bergmann arnd@arndb.de wrote:
>> ...  
>> >Grant Likely was the original maintainer for MPC52xx until 2011,
>> >Anatolij Gustschin is still listed as maintainer since then but hasn't
>> >been active in it for a while either. Anatolij can probably best judge
>> >which of these boards are still in going to be used with future kernels,
>> >but I suspect once you start removing bits from 52xx, the newer
>> >but less common 512x platform can go away as well.  
>>
>> many of these boards are still used, i.e. o2d*, digsy_mtc, tqm5200.  
>
>Just for clarification, I assume when you say "still used" that implies
>getting updated to new kernels rather than just running the old BSPs,
>right?

yes, at least some of them. I used v5.4 kernel on digsy_mtc and
tqm5200 last year, and v5.10 kernel is also known to work.

>What are the typical distro release cycles for those machines
>you list: do you move from one LTS kernel to the next each year,
>or are they getting more sporadic over time?

these machines are in embedded systems and do not get regular
distro updates, therefore more sporadic over time.

>Do you expect the machines with the lowest memory such as the
>32MB digsy to stop getting kernel updates before the others?

No. There are also digsy variants with 256MiB DRAM.

Thanks,

Anatolij

^ permalink raw reply

* Re: [RFC PATCH] powerpc: dts: Remove MPC5xxx platforms
From: Anatolij Gustschin @ 2021-10-14 12:26 UTC (permalink / raw)
  To: Stephen Rothwell, Rob Herring
  Cc: devicetree, Arnd Bergmann, linux-kernel, Paul Mackerras,
	linuxppc-dev
In-Reply-To: <20211013173808.7ab92035@canb.auug.org.au>

On Wed, 13 Oct 2021 17:38:08 +1100
Stephen Rothwell sfr@canb.auug.org.au wrote:

>Hi Rob,
>
>On Tue, 12 Oct 2021 10:34:56 -0500 Rob Herring <robh@kernel.org> wrote:
>>
>> The mpc5xxx platforms have had dts warnings for some time which no one
>> seems to care to fix, so let's just remove the dts files.
>> 
>> According to Arnd:
>> "Specifically, MPC5200B has a 15 year lifetime, which ends in
>> 11 months from now. The original bplan/Genesi Efika 5K2 was
>> quite popular at the time it came out, and there are probably
>> still some of those hanging around, but they came with Open
>> Firmware rather than relying on the dts files that ship with the
>> kernel.
>> 
>> Grant Likely was the original maintainer for MPC52xx until 2011,
>> Anatolij Gustschin is still listed as maintainer since then but hasn't
>> been active in it for a while either. Anatolij can probably best judge
>> which of these boards are still in going to be used with future kernels,
>> but I suspect once you start removing bits from 52xx, the newer
>> but less common 512x platform can go away as well."
>> 
>> Cc: Anatolij Gustschin <agust@denx.de>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
>> Cc: Michael Ellerman <mpe@ellerman.id.au>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> Cc: Paul Mackerras <paulus@samba.org>
>> Cc: linuxppc-dev@lists.ozlabs.org
>> Signed-off-by: Rob Herring <robh@kernel.org>
>> ---
>> Sending this out as a feeler to see if anyone cares. If anyone does, 
>> please fix the warnings.

I've sent patches to fix the warnings.
  
Thanks,

Anatolij

^ permalink raw reply

* Re: [PATCH] powerpc/mpc512x: dts: fix PSC node warnings
From: Rob Herring @ 2021-10-14 12:33 UTC (permalink / raw)
  To: Anatolij Gustschin; +Cc: devicetree, linuxppc-dev, linux-kernel@vger.kernel.org
In-Reply-To: <20211014113123.2358-1-agust@denx.de>

On Thu, Oct 14, 2021 at 6:31 AM Anatolij Gustschin <agust@denx.de> wrote:
>
> Fix build warnings like:
> mpc5121.dtsi:397.13-406.5: Warning (spi_bus_bridge): /soc@80000000/psc@11400: node name for SPI buses should be 'spi'
> mpc5121.dtsi:409.13-418.5: Warning (spi_bus_bridge): /soc@80000000/psc@11500: node name for SPI buses should be 'spi'
> mpc5121.dtsi:457.13-466.5: Warning (spi_bus_bridge): /soc@80000000/psc@11900: node name for SPI buses should be 'spi'
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  arch/powerpc/boot/dts/ac14xx.dts   | 17 +++++++++++++++--
>  arch/powerpc/boot/dts/pdm360ng.dts | 11 ++++++++++-
>  2 files changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/boot/dts/ac14xx.dts b/arch/powerpc/boot/dts/ac14xx.dts
> index 5d8877e1f4ad..662d7aa2e4e8 100644
> --- a/arch/powerpc/boot/dts/ac14xx.dts
> +++ b/arch/powerpc/boot/dts/ac14xx.dts
> @@ -301,13 +301,21 @@
>                         fsl,tx-fifo-size = <512>;
>                 };
>
> +               /delete-node/ psc@11400;
> +               /delete-node/ psc@11500;

That's an odd way to fix this, and means every user of the .dtsi file
with these nodes will have to repeat the same thing.

> +
>                 /* PSC4 in SPI mode */
> -               spi4: psc@11400 {
> +               spi4: spi@11400 {
>                         compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
> +                       reg = <0x11400 0x100>;
>                         fsl,rx-fifo-size = <768>;
>                         fsl,tx-fifo-size = <768>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> +                       interrupts = <40 0x8>;
> +                       clocks = <&clks MPC512x_CLK_PSC4>,
> +                                <&clks MPC512x_CLK_PSC4_MCLK>;
> +                       clock-names = "ipg", "mclk";
>                         num-cs = <1>;
>                         cs-gpios = <&gpio_pic 25 0>;
>
> @@ -326,13 +334,18 @@
>                 };
>
>                 /* PSC5 in SPI mode */
> -               spi5: psc@11500 {
> +               spi5: spi@11500 {
>                         compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
> +                       reg = <0x11500 0x100>;
>                         fsl,mode = "spi-master";
>                         fsl,rx-fifo-size = <128>;
>                         fsl,tx-fifo-size = <128>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> +                       interrupts = <40 0x8>;
> +                       clocks = <&clks MPC512x_CLK_PSC5>,
> +                                <&clks MPC512x_CLK_PSC5_MCLK>;
> +                       clock-names = "ipg", "mclk";
>
>                         lcd@0 {
>                                 compatible = "ilitek,ili922x";
> diff --git a/arch/powerpc/boot/dts/pdm360ng.dts b/arch/powerpc/boot/dts/pdm360ng.dts
> index 67c3b9db75d7..2733d15079a9 100644
> --- a/arch/powerpc/boot/dts/pdm360ng.dts
> +++ b/arch/powerpc/boot/dts/pdm360ng.dts
> @@ -169,10 +169,19 @@
>                         compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
>                 };
>
> -               psc@11900 {
> +               /delete-node/ psc@11900;
> +
> +               spi@11900 {
>                         compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
> +                       reg = <0x11900 0x100>;
>                         #address-cells = <1>;
>                         #size-cells = <0>;
> +                       interrupts = <40 0x8>;
> +                       fsl,rx-fifo-size = <16>;
> +                       fsl,tx-fifo-size = <16>;
> +                       clocks = <&clks MPC512x_CLK_PSC9>,
> +                                <&clks MPC512x_CLK_PSC9_MCLK>;
> +                       clock-names = "ipg", "mclk";
>
>                         /* ADS7845 touch screen controller */
>                         ts@0 {
> --
> 2.17.1
>

^ permalink raw reply

* Re: [PATCH 1/5] dt-bindings: memory: fsl: convert ifc binding to yaml schema
From: Rob Herring @ 2021-10-14 12:46 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Shawn Guo, lkml, Li Yang, linuxppc-dev,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
In-Reply-To: <e42fa620-810b-fdcc-c827-602a14d10d97@canonical.com>

On Mon, Oct 4, 2021 at 4:31 AM Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
>
> On 01/10/2021 18:17, Li Yang wrote:
> > On Fri, Oct 1, 2021 at 5:01 AM Krzysztof Kozlowski
> > <krzysztof.kozlowski@canonical.com> wrote:
> >>
>
> (...)
>
> >>> +
> >>> +  interrupts:
> >>> +    minItems: 1
> >>> +    maxItems: 2
> >>> +    description: |
> >>> +      IFC may have one or two interrupts.  If two interrupt specifiers are
> >>> +      present, the first is the "common" interrupt (CM_EVTER_STAT), and the
> >>> +      second is the NAND interrupt (NAND_EVTER_STAT).  If there is only one,
> >>> +      that interrupt reports both types of event.
> >>> +
> >>> +  little-endian:
> >>> +    $ref: '/schemas/types.yaml#/definitions/flag'
> >>
> >> type: boolean
> >
> > It will not have a true or false value, but only present or not.  Is
> > the boolean type taking care of this too?
>
> boolean is for a property which does not accept values and true/false
> depends on its presence.
> See:
> Documentation/devicetree/bindings/phy/lantiq,vrx200-pcie-phy.yaml
> Documentation/devicetree/bindings/thermal/qoriq-thermal.yaml

They are equivalent, so either can be used.

Really what is needed here is a common schema for the endianness
properties defining the type once. Then any binding using a property
can just do 'little-endian: true'.

Rob

^ permalink raw reply

* Re: [PATCH v3 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: Steven Rostedt @ 2021-10-14 13:28 UTC (permalink / raw)
  To: Miroslav Benes
  Cc: 王贇, Peter Zijlstra (Intel), Paul Walmsley,
	James E.J. Bottomley, Guo Ren, Jisheng Zhang, H. Peter Anvin,
	live-patching, linux-riscv, Paul Mackerras, Joe Lawrence,
	Helge Deller, x86, linux-csky, Ingo Molnar, Petr Mladek,
	Albert Ou, Jiri Kosina, Nicholas Piggin, Borislav Petkov,
	Josh Poimboeuf, Thomas Gleixner, linux-parisc, linux-kernel,
	Palmer Dabbelt, Masami Hiramatsu, Colin Ian King, linuxppc-dev
In-Reply-To: <alpine.LSU.2.21.2110141108150.23710@pobox.suse.cz>

On Thu, 14 Oct 2021 11:13:13 +0200 (CEST)
Miroslav Benes <mbenes@suse.cz> wrote:

> for the livepatch part of the patch.
> 
> I would also ask you not to submit new versions so often, so that the 
> other reviewers have time to actually review the patch set.
> 
> Quoting from Documentation/process/submitting-patches.rst:
> 
> "Wait for a minimum of one week before resubmitting or pinging reviewers - 
> possibly longer during busy times like merge windows."

Although, for updates on a small patch set, I would say just a couple of
days, instead of a week. It's annoying when you have a 15 patch set series,
that gets updated on a daily basis. But for something with only 2 patches,
wait just two days. At least, that's how I feel.

-- Steve

^ permalink raw reply

* Re: [PATCH v3 1/2] ftrace: disable preemption between ftrace_test_recursion_trylock/unlock()
From: Petr Mladek @ 2021-10-14 15:14 UTC (permalink / raw)
  To: 王贇
  Cc: Peter Zijlstra (Intel), Paul Walmsley, James E.J. Bottomley,
	Guo Ren, Jisheng Zhang, H. Peter Anvin, live-patching,
	linux-riscv, Miroslav Benes, Paul Mackerras, Joe Lawrence,
	Helge Deller, x86, linux-csky, Ingo Molnar, Albert Ou,
	Jiri Kosina, Steven Rostedt, Borislav Petkov, Nicholas Piggin,
	Josh Poimboeuf, Thomas Gleixner, linux-parisc, linux-kernel,
	Palmer Dabbelt, Masami Hiramatsu, Colin Ian King, linuxppc-dev
In-Reply-To: <7e4738b5-21d4-c4d0-3136-a096bbb5cd2c@linux.alibaba.com>

On Wed 2021-10-13 16:51:46, 王贇 wrote:
> As the documentation explained, ftrace_test_recursion_trylock()
> and ftrace_test_recursion_unlock() were supposed to disable and
> enable preemption properly, however currently this work is done
> outside of the function, which could be missing by mistake.
> 
> This path will make sure the preemption was disabled when trylock()
> succeed, and the unlock() will enable the preemption if previously
> enabled.
> 
> diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
> index a9f9c57..58e474c 100644
> --- a/include/linux/trace_recursion.h
> +++ b/include/linux/trace_recursion.h
> @@ -214,7 +214,18 @@ static __always_inline void trace_clear_recursion(int bit)

We should also update the description above the function, for example:

  /**
   * ftrace_test_recursion_trylock - tests for recursion in same context
   *
   * Use this for ftrace callbacks. This will detect if the function
   * tracing recursed in the same context (normal vs interrupt),
   *
   * Returns: -1 if a recursion happened.
-  *           >= 0 if no recursion
+  *           >= 0 if no recursion (success)
+  *
+  * Disables the preemption on success. It is just for a convenience.
+  * Current users needed to disable the preemtion for some reasons.
   */


>  static __always_inline int ftrace_test_recursion_trylock(unsigned long ip,
>  							 unsigned long parent_ip)
>  {
> -	return trace_test_and_set_recursion(ip, parent_ip, TRACE_FTRACE_START, TRACE_FTRACE_MAX);
> +	int bit;
> +
> +	bit = trace_test_and_set_recursion(ip, parent_ip, TRACE_FTRACE_START, TRACE_FTRACE_MAX);
> +	/*
> +	 * The zero bit indicate we are nested
> +	 * in another trylock(), which means the
> +	 * preemption already disabled.
> +	 */
> +	if (bit > 0)
> +		preempt_disable_notrace();

Is this safe? The preemption is disabled only when
trace_test_and_set_recursion() was called by ftrace_test_recursion_trylock().

We must either always disable the preemtion when bit >= 0.
Or we have to disable the preemtion already in
trace_test_and_set_recursion().


Finally, the comment confused me a lot. The difference between nesting and
recursion is far from clear. And the code is tricky liky like hell :-)
I propose to add some comments, see below for a proposal.

> +
> +	return bit;
>  }
>  /**
> @@ -222,9 +233,13 @@ static __always_inline int ftrace_test_recursion_trylock(unsigned long ip,
>   * @bit: The return of a successful ftrace_test_recursion_trylock()
>   *
>   * This is used at the end of a ftrace callback.
> + *
> + * Preemption will be enabled (if it was previously enabled).
>   */
>  static __always_inline void ftrace_test_recursion_unlock(int bit)
>  {
> +	if (bit)

This is not symetric with trylock(). It should be:

	if (bit > 0)

Anyway, trace_clear_recursion() quiently ignores bit != 0


> +		preempt_enable_notrace();
>  	trace_clear_recursion(bit);
>  }


Below is my proposed patch that tries to better explain the recursion
check:

From 20d69f11e2683262fa0043b803999061cbac543f Mon Sep 17 00:00:00 2001
From: Petr Mladek <pmladek@suse.com>
Date: Thu, 14 Oct 2021 16:57:39 +0200
Subject: [PATCH] trace: Better describe the recursion check return values

The trace recursion check might be called recursively by different
layers of the tracing code. It is safe recursion and the check
is even optimized for this case.

The problematic recursion is when the traced function is called
by the tracing code. This is properly detected.

Try to explain this difference a better way.

Signed-off-by: Petr Mladek <pmladek@suse.com>
---
 include/linux/trace_recursion.h | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h
index a9f9c5714e65..b5efb804efdf 100644
--- a/include/linux/trace_recursion.h
+++ b/include/linux/trace_recursion.h
@@ -159,13 +159,27 @@ extern void ftrace_record_recursion(unsigned long ip, unsigned long parent_ip);
 # define do_ftrace_record_recursion(ip, pip)	do { } while (0)
 #endif
 
+/*
+ * trace_test_and_set_recursion() is called on several layers
+ * of the ftrace code when handling the same ftrace entry.
+ * These calls might be nested/recursive.
+ *
+ * It uses TRACE_LIST_*BITs to distinguish between this
+ * internal recursion and recursion caused by calling
+ * the traced function by the ftrace code.
+ *
+ * Returns: > 0 when no recursion
+ *          0 when called recursively internally (safe)
+ *	    -1 when the traced function was called recursively from
+ *             the ftrace handler (unsafe)
+ */
 static __always_inline int trace_test_and_set_recursion(unsigned long ip, unsigned long pip,
 							int start, int max)
 {
 	unsigned int val = READ_ONCE(current->trace_recursion);
 	int bit;
 
-	/* A previous recursion check was made */
+	/* Called recursively internally by different ftrace code layers? */
 	if ((val & TRACE_CONTEXT_MASK) > max)
 		return 0;
 
-- 
2.26.2


^ permalink raw reply related

* Re: [PATCH] powerpc/pseries/iommu: Add of_node_put() before break
From: Leonardo Brás @ 2021-10-14 17:32 UTC (permalink / raw)
  To: Wan Jiabing, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, Alexey Kardashevskiy, Frederic Barrat,
	David Gibson, linuxppc-dev, linux-kernel
  Cc: kael_w
In-Reply-To: <20211014075624.16344-1-wanjiabing@vivo.com>

Hello Wan, thank you for this patch.


On Thu, 2021-10-14 at 03:56 -0400, Wan Jiabing wrote:
> Fix following coccicheck warning:
> 
> ./arch/powerpc/platforms/pseries/iommu.c:924:1-28: WARNING: Function
> for_each_node_with_property should have of_node_put() before break
> 
> Early exits from for_each_node_with_property should decrement the
> node reference counter.

Yeah, it makes sense to me. 

for_each_node_with_property calls of_find_node_with_property() at each
step, which ends up calling of_node_put() after using each node.

Introducing this break caused this of_node_put not to happen to the
last node, so IIUC this patch fixes a possible issue if kzalloc() fails
in ddw_list_new_entry().

Another option would be s/break/continue here, but it does not make
sense to keep trying next nodes if there is no memory to allocate for a
struct dma_win (4 pointers).

On the other hard, failing on allocating such small space should not
happen often (if it will ever happen), so a 'continue' here makes code
simpler.  
 
Anyway, FWIW:
Reviewed-by: Leonardo Bras <leobras.c@gmail.com>


Best regards,
Leo

> 
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
>  arch/powerpc/platforms/pseries/iommu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/iommu.c
> b/arch/powerpc/platforms/pseries/iommu.c
> index 269f61d519c2..c140aa683f66 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -929,8 +929,10 @@ static void find_existing_ddw_windows_named(const
> char *name)
>                 }
>  
>                 window = ddw_list_new_entry(pdn, dma64);
> -               if (!window)
> +               if (!window) {
> +                       of_node_put(pdn);
>                         break;
> +               }
>  
>                 spin_lock(&dma_win_list_lock);
>                 list_add(&window->list, &dma_win_list);



^ permalink raw reply

* Re: [PATCH] powerpc/dcr: Use cmplwi instead of 3-argument cmpli
From: Nick Desaulniers @ 2021-10-14 18:15 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: llvm, linuxppc-dev
In-Reply-To: <20211014024424.528848-1-mpe@ellerman.id.au>

On Wed, Oct 13, 2021 at 7:44 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> In dcr-low.S we use cmpli with three arguments, instead of four
> arguments as defined in the ISA:
>
>         cmpli   cr0,r3,1024
>
> This appears to be a PPC440-ism, looking at the "PPC440x5 CPU Core
> User’s Manual" it shows cmpli having no L field, but implied to be 0 due
> to the core being 32-bit. It mentions that the ISA defines four
> arguments and recommends using cmplwi.
>
> dcr-low.S is only built 32-bit, because it is only built when
> DCR_NATIVE=y, which is only selected by 40x and 44x. Looking at the
> generated code (with gcc/gas) we see cmplwi as expected.
>
> Although gas is happy with the 3-argument version when building for
> 32-bit, the LLVM assembler is not and errors out with:
>
>   arch/powerpc/sysdev/dcr-low.S:27:10: error: invalid operand for instruction
>    cmpli 0,%r3,1024; ...
>            ^
>
> Switching to the four argument version avoids any confusion when reading
> the ISA, fixes the issue with the LLVM assembler, and also means the
> code could be built 64-bit in future (though that's very unlikely).

Thank you Michael.  We've definitely run into a few cases where GAS
allowed for various short-hand forms of various instructions (a fair
amount of recent work was around 32b ARM and THUMB parity in LLVM).
LLVM's assembler is mostly generated from a high level description of
the instruction formats, so it's not always as flexible as a hand
written parser would be. (There is a mix of hand written arch specific
parsing, but most of the parser is arch agnostic, and all of the
instruction descriptions are described in an LLVM specific high level
language called tablegen which generates C++ that is used by the
assembler, but also the disassembler, the compiler, and even the
linker if need be).

Link: https://github.com/ClangBuiltLinux/linux/issues/1419
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/sysdev/dcr-low.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/sysdev/dcr-low.S b/arch/powerpc/sysdev/dcr-low.S
> index efeeb1b885a1..329b9c4ae542 100644
> --- a/arch/powerpc/sysdev/dcr-low.S
> +++ b/arch/powerpc/sysdev/dcr-low.S
> @@ -11,7 +11,7 @@
>  #include <asm/export.h>
>
>  #define DCR_ACCESS_PROLOG(table) \
> -       cmpli   cr0,r3,1024;     \
> +       cmplwi  cr0,r3,1024;     \
>         rlwinm  r3,r3,4,18,27;   \
>         lis     r5,table@h;      \
>         ori     r5,r5,table@l;   \
> --
> 2.25.1
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply

* Re: [PATCH v2] scsi: ibmvscsi: Use dma_alloc_noncoherent() instead of get_zeroed_page/dma_map_single()
From: Nathan Lynch @ 2021-10-14 19:25 UTC (permalink / raw)
  To: Cai Huoqing
  Cc: Tyrel Datwyler, linux-scsi, Martin K. Petersen,
	James E.J. Bottomley, linux-kernel, Paul Mackerras, linuxppc-dev
In-Reply-To: <20211012032317.2360-1-caihuoqing@baidu.com>

Cai Huoqing <caihuoqing@baidu.com> writes:
> @@ -331,18 +329,12 @@ static int ibmvscsi_init_crq_queue(struct crq_queue *queue,
>  	int retrc;
>  	struct vio_dev *vdev = to_vio_dev(hostdata->dev);
>  
> -	queue->msgs = (struct viosrp_crq *)get_zeroed_page(GFP_KERNEL);
> -
> -	if (!queue->msgs)
> -		goto malloc_failed;
>  	queue->size = PAGE_SIZE / sizeof(*queue->msgs);
> -
> -	queue->msg_token = dma_map_single(hostdata->dev, queue->msgs,
> -					  queue->size * sizeof(*queue->msgs),
> -					  DMA_BIDIRECTIONAL);
> -
> -	if (dma_mapping_error(hostdata->dev, queue->msg_token))
> -		goto map_failed;
> +	queue->msgs = dma_alloc_noncoherent(hostdata->dev,
> +					    PAGE_SIZE, &queue->msg_token,
> +					    DMA_BIDIRECTIONAL, GFP_KERNEL);
> +	if (!queue->msg)
> +		goto malloc_failed;


This version appears to retain the build breakage from v1 which was
reported here:

https://lore.kernel.org/linuxppc-dev/202110121452.nWPHZeZg-lkp@intel.com/

   drivers/scsi/ibmvscsi/ibmvscsi.c: In function 'ibmvscsi_init_crq_queue':
>> drivers/scsi/ibmvscsi/ibmvscsi.c:334:21: error: 'struct crq_queue' has no member named 'msg'; did you mean 'msgs'?
     334 |         if (!queue->msg)
         |                     ^~~
         |                     msgs
   drivers/scsi/ibmvscsi/ibmvscsi.c:388:60: error: 'struct crq_queue' has no member named 'msg'; did you mean 'msgs'?
     388 |         dma_free_coherent(hostdata->dev, PAGE_SIZE, queue->msg, queue->msg_token);
         |                                                            ^~~
         |                                                            msgs


^ permalink raw reply

* Re: [PATCH v2 01/13] powerpc: Move 'struct ppc64_opd_entry' back into asm/elf.h
From: Daniel Axtens @ 2021-10-14 21:26 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Andrew Morton, James E.J. Bottomley,
	Helge Deller, Arnd Bergmann, Kees Cook, Greg Kroah-Hartman
  Cc: linux-arch, linux-ia64, linux-parisc, linux-api, linux-kernel,
	linux-mm, linuxppc-dev
In-Reply-To: <42d2a571677e60082c0a5b3e52e855aa58c0b1fc.1634190022.git.christophe.leroy@csgroup.eu>

Hi Christophe,

> 'struct ppc64_opd_entry' doesn't belong to uapi/asm/elf.h
>
> It was initially in module_64.c and commit 2d291e902791 ("Fix compile
> failure with non modular builds") moved it into asm/elf.h
>
> But it was by mistake added outside of __KERNEL__ section,
> therefore commit c3617f72036c ("UAPI: (Scripted) Disintegrate
> arch/powerpc/include/asm") moved it to uapi/asm/elf.h

As Michael said on v1, I'm a little nervous about moving it out of uAPI
after so long, although I do take the points of Arnd and Kees that we're
not breaking compiled binaries, nor should people be using this struct
to begin with...

I've cc:ed the linux-api@ list.

Kind regards,
Daniel

> Move it back into asm/elf.h, this brings it back in line with
> IA64 and PARISC architectures.
>
> Fixes: 2d291e902791 ("Fix compile failure with non modular builds")
> Reviewed-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/include/asm/elf.h      | 6 ++++++
>  arch/powerpc/include/uapi/asm/elf.h | 8 --------
>  2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
> index b8425e3cfd81..a4406714c060 100644
> --- a/arch/powerpc/include/asm/elf.h
> +++ b/arch/powerpc/include/asm/elf.h
> @@ -176,4 +176,10 @@ do {									\
>  /* Relocate the kernel image to @final_address */
>  void relocate(unsigned long final_address);
>  
> +/* There's actually a third entry here, but it's unused */
> +struct ppc64_opd_entry {
> +	unsigned long funcaddr;
> +	unsigned long r2;
> +};
> +
>  #endif /* _ASM_POWERPC_ELF_H */
> diff --git a/arch/powerpc/include/uapi/asm/elf.h b/arch/powerpc/include/uapi/asm/elf.h
> index 860c59291bfc..308857123a08 100644
> --- a/arch/powerpc/include/uapi/asm/elf.h
> +++ b/arch/powerpc/include/uapi/asm/elf.h
> @@ -289,12 +289,4 @@ typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
>  /* Keep this the last entry.  */
>  #define R_PPC64_NUM		253
>  
> -/* There's actually a third entry here, but it's unused */
> -struct ppc64_opd_entry
> -{
> -	unsigned long funcaddr;
> -	unsigned long r2;
> -};
> -
> -
>  #endif /* _UAPI_ASM_POWERPC_ELF_H */
> -- 
> 2.31.1

^ permalink raw reply

* Re: [PATCH v2 00/13] Fix LKDTM for PPC64/IA64/PARISC
From: Daniel Axtens @ 2021-10-14 21:35 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Andrew Morton, James E.J. Bottomley,
	Helge Deller, Arnd Bergmann, Kees Cook, Greg Kroah-Hartman
  Cc: linux-arch, linux-ia64, linux-parisc, linux-kernel, linux-mm,
	linuxppc-dev
In-Reply-To: <cover.1634190022.git.christophe.leroy@csgroup.eu>

Christophe Leroy <christophe.leroy@csgroup.eu> writes:

> PPC64/IA64/PARISC have function descriptors. LKDTM doesn't work
> on those three architectures because LKDTM messes up function
> descriptors with functions.

Just to nitpick, it's powerpc 64-bit using the ELFv1 ABI. [1]

The ELFv2 ABI [2] doesn't use function descriptors. (ELFv2 is used
primarily for ppc64le, but some people like musl support it for BE as
well.)

This doesn't affect the correctness or desirability of your changes, it
was just bugging me when I was reading the commit messages :-)

Kind regards,
Daniel

[1] See e.g. https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html
[2] https://openpowerfoundation.org/wp-content/uploads/2016/03/ABI64BitOpenPOWERv1.1_16July2015_pub4.pdf


> This series does some cleanup in the three architectures and
> refactors function descriptors so that it can then easily use it
> in a generic way in LKDTM.
>
> Patch 8 is not absolutely necessary but it is a good trivial cleanup.
>
> Changes in v2:
> - Addressed received comments
> - Moved dereference_[kernel]_function_descriptor() out of line
> - Added patches to remove func_descr_t and func_desc_t in powerpc
> - Using func_desc_t instead of funct_descr_t
> - Renamed HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR to HAVE_FUNCTION_DESCRIPTORS
> - Added a new lkdtm test to check protection of function descriptors
>
> Christophe Leroy (13):
>   powerpc: Move 'struct ppc64_opd_entry' back into asm/elf.h
>   powerpc: Rename 'funcaddr' to 'addr' in 'struct ppc64_opd_entry'
>   powerpc: Remove func_descr_t
>   powerpc: Prepare func_desc_t for refactorisation
>   ia64: Rename 'ip' to 'addr' in 'struct fdesc'
>   asm-generic: Use HAVE_FUNCTION_DESCRIPTORS to define associated stubs
>   asm-generic: Define 'func_desc_t' to commonly describe function
>     descriptors
>   asm-generic: Refactor dereference_[kernel]_function_descriptor()
>   lkdtm: Force do_nothing() out of line
>   lkdtm: Really write into kernel text in WRITE_KERN
>   lkdtm: Fix lkdtm_EXEC_RODATA()
>   lkdtm: Fix execute_[user]_location()
>   lkdtm: Add a test for function descriptors protection
>
>  arch/ia64/include/asm/elf.h              |  2 +-
>  arch/ia64/include/asm/sections.h         | 25 ++-------
>  arch/ia64/kernel/module.c                |  6 +--
>  arch/parisc/include/asm/sections.h       | 17 +++---
>  arch/parisc/kernel/process.c             | 21 --------
>  arch/powerpc/include/asm/code-patching.h |  2 +-
>  arch/powerpc/include/asm/elf.h           |  6 +++
>  arch/powerpc/include/asm/sections.h      | 30 ++---------
>  arch/powerpc/include/asm/types.h         |  6 ---
>  arch/powerpc/include/uapi/asm/elf.h      |  8 ---
>  arch/powerpc/kernel/module_64.c          | 38 +++++--------
>  arch/powerpc/kernel/signal_64.c          |  8 +--
>  drivers/misc/lkdtm/core.c                |  1 +
>  drivers/misc/lkdtm/lkdtm.h               |  1 +
>  drivers/misc/lkdtm/perms.c               | 68 ++++++++++++++++++++----
>  include/asm-generic/sections.h           | 13 ++++-
>  include/linux/kallsyms.h                 |  2 +-
>  kernel/extable.c                         | 23 +++++++-
>  18 files changed, 138 insertions(+), 139 deletions(-)
>
> -- 
> 2.31.1

^ permalink raw reply

* Re: [PATCH v2 02/13] powerpc: Rename 'funcaddr' to 'addr' in 'struct ppc64_opd_entry'
From: Daniel Axtens @ 2021-10-14 21:45 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Andrew Morton, James E.J. Bottomley,
	Helge Deller, Arnd Bergmann, Kees Cook, Greg Kroah-Hartman
  Cc: linux-arch, linux-ia64, linux-parisc, linux-kernel, linux-mm,
	linuxppc-dev
In-Reply-To: <49f59a8bf2c4d95cfaa03bd3dd3c1569822ad6ba.1634190022.git.christophe.leroy@csgroup.eu>

Christophe Leroy <christophe.leroy@csgroup.eu> writes:

> There are three architectures with function descriptors, try to
> have common names for the address they contain in order to
> refactor some functions into generic functions later.
>
> powerpc has 'funcaddr'
> ia64 has 'ip'
> parisc has 'addr'
>
> Vote for 'addr' and update 'struct ppc64_opd_entry' accordingly.

I would have picked 'funcaddr', but at least 'addr' is better than 'ip'!
And I agree that consistency, and then making things generic is worthwhile.

I grepped the latest powerpc/next for uses of 'funcaddr'. There were 5,
your patch changes all 5.

The series passes build tests and this patch has no checkpatch or other
style concerns.

On that basis:
Reviewed-by: Daniel Axtens <dja@axtens.net>

Kind regards,
Daniel

> Reviewed-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/include/asm/elf.h      | 2 +-
>  arch/powerpc/include/asm/sections.h | 2 +-
>  arch/powerpc/kernel/module_64.c     | 6 +++---
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
> index a4406714c060..bb0f278f9ed4 100644
> --- a/arch/powerpc/include/asm/elf.h
> +++ b/arch/powerpc/include/asm/elf.h
> @@ -178,7 +178,7 @@ void relocate(unsigned long final_address);
>  
>  /* There's actually a third entry here, but it's unused */
>  struct ppc64_opd_entry {
> -	unsigned long funcaddr;
> +	unsigned long addr;
>  	unsigned long r2;
>  };
>  
> diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h
> index 6e4af4492a14..32e7035863ac 100644
> --- a/arch/powerpc/include/asm/sections.h
> +++ b/arch/powerpc/include/asm/sections.h
> @@ -77,7 +77,7 @@ static inline void *dereference_function_descriptor(void *ptr)
>  	struct ppc64_opd_entry *desc = ptr;
>  	void *p;
>  
> -	if (!get_kernel_nofault(p, (void *)&desc->funcaddr))
> +	if (!get_kernel_nofault(p, (void *)&desc->addr))
>  		ptr = p;
>  	return ptr;
>  }
> diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
> index 6baa676e7cb6..82908c9be627 100644
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -72,11 +72,11 @@ static func_desc_t func_desc(unsigned long addr)
>  }
>  static unsigned long func_addr(unsigned long addr)
>  {
> -	return func_desc(addr).funcaddr;
> +	return func_desc(addr).addr;
>  }
>  static unsigned long stub_func_addr(func_desc_t func)
>  {
> -	return func.funcaddr;
> +	return func.addr;
>  }
>  static unsigned int local_entry_offset(const Elf64_Sym *sym)
>  {
> @@ -187,7 +187,7 @@ static int relacmp(const void *_x, const void *_y)
>  static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
>  				    const Elf64_Shdr *sechdrs)
>  {
> -	/* One extra reloc so it's always 0-funcaddr terminated */
> +	/* One extra reloc so it's always 0-addr terminated */
>  	unsigned long relocs = 1;
>  	unsigned i;
>  
> -- 
> 2.31.1

^ permalink raw reply

* Re: [PATCH v2] scsi: ibmvscsi: Use dma_alloc_noncoherent() instead of get_zeroed_page/dma_map_single()
From: Tyrel Datwyler @ 2021-10-14 22:07 UTC (permalink / raw)
  To: Cai Huoqing
  Cc: Martin K. Petersen, linux-scsi, James E.J. Bottomley,
	linux-kernel, Paul Mackerras, linuxppc-dev
In-Reply-To: <20211012032317.2360-1-caihuoqing@baidu.com>

On 10/11/21 8:23 PM, Cai Huoqing wrote:
> Replacing get_zeroed_page/free_page/dma_map_single/dma_unmap_single()
> with dma_alloc_noncoherent/dma_free_noncoherent() helps to reduce
> code size, and simplify the code, and the hardware can keeep DMA
> coherent itsel
Not sure why the switch from coherent in v1 to noncoherent in v2. I think that
was unnecessary and I believe requires explicit synchronization via
dma_sync_single_{for_device|for_cpu} calls.

Further, as both kernel-bot and Nathan have already pointed out this doesn't
even compile.

-Tyrel

> 
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
> ---
> v1->v2:
> 	*Change to dma_alloc/free_noncoherent from dma_alloc/free_coherent.
> 	*Update changelog.
> 
>  drivers/scsi/ibmvscsi/ibmvfc.c   | 16 ++++------------
>  drivers/scsi/ibmvscsi/ibmvscsi.c | 29 +++++++++--------------------
>  2 files changed, 13 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
> index 1f1586ad48fe..6e95fd02fd25 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc.c
> @@ -869,8 +869,8 @@ static void ibmvfc_free_queue(struct ibmvfc_host *vhost,
>  {
>  	struct device *dev = vhost->dev;
>  
> -	dma_unmap_single(dev, queue->msg_token, PAGE_SIZE, DMA_BIDIRECTIONAL);
> -	free_page((unsigned long)queue->msgs.handle);
> +	dma_free_noncoherent(dev, PAGE_SIZE, queue->msgs.handle,
> +			     queue->msg_token, DMA_BIDIRECTIONAL);
>  	queue->msgs.handle = NULL;
>  
>  	ibmvfc_free_event_pool(vhost, queue);
> @@ -5663,19 +5663,11 @@ static int ibmvfc_alloc_queue(struct ibmvfc_host *vhost,
>  		return -ENOMEM;
>  	}
>  
> -	queue->msgs.handle = (void *)get_zeroed_page(GFP_KERNEL);
> +	queue->msgs.handle = dma_alloc_noncoherent(dev, PAGE_SIZE, &queue->msg_token,
> +						   DMA_BIDIRECTIONAL, GFP_KERNEL);
>  	if (!queue->msgs.handle)
>  		return -ENOMEM;
>  
> -	queue->msg_token = dma_map_single(dev, queue->msgs.handle, PAGE_SIZE,
> -					  DMA_BIDIRECTIONAL);
> -
> -	if (dma_mapping_error(dev, queue->msg_token)) {
> -		free_page((unsigned long)queue->msgs.handle);
> -		queue->msgs.handle = NULL;
> -		return -ENOMEM;
> -	}
> -
>  	queue->cur = 0;
>  	queue->fmt = fmt;
>  	queue->size = PAGE_SIZE / fmt_size;
> diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
> index ea8e01f49cba..68409c298c74 100644
> --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
> +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
> @@ -151,10 +151,8 @@ static void ibmvscsi_release_crq_queue(struct crq_queue *queue,
>  			msleep(100);
>  		rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address);
>  	} while ((rc == H_BUSY) || (H_IS_LONG_BUSY(rc)));
> -	dma_unmap_single(hostdata->dev,
> -			 queue->msg_token,
> -			 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
> -	free_page((unsigned long)queue->msgs);
> +	dma_free_noncoherent(hostdata->dev, PAGE_SIZE,
> +			     queue->msgs, queue->msg_token, DMA_BIDIRECTIONAL);
>  }
>  
>  /**
> @@ -331,18 +329,12 @@ static int ibmvscsi_init_crq_queue(struct crq_queue *queue,
>  	int retrc;
>  	struct vio_dev *vdev = to_vio_dev(hostdata->dev);
>  
> -	queue->msgs = (struct viosrp_crq *)get_zeroed_page(GFP_KERNEL);
> -
> -	if (!queue->msgs)
> -		goto malloc_failed;
>  	queue->size = PAGE_SIZE / sizeof(*queue->msgs);
> -
> -	queue->msg_token = dma_map_single(hostdata->dev, queue->msgs,
> -					  queue->size * sizeof(*queue->msgs),
> -					  DMA_BIDIRECTIONAL);
> -
> -	if (dma_mapping_error(hostdata->dev, queue->msg_token))
> -		goto map_failed;
> +	queue->msgs = dma_alloc_noncoherent(hostdata->dev,
> +					    PAGE_SIZE, &queue->msg_token,
> +					    DMA_BIDIRECTIONAL, GFP_KERNEL);
> +	if (!queue->msg)
> +		goto malloc_failed;
>  
>  	gather_partition_info();
>  	set_adapter_info(hostdata);
> @@ -395,11 +387,8 @@ static int ibmvscsi_init_crq_queue(struct crq_queue *queue,
>  		rc = plpar_hcall_norets(H_FREE_CRQ, vdev->unit_address);
>  	} while ((rc == H_BUSY) || (H_IS_LONG_BUSY(rc)));
>        reg_crq_failed:
> -	dma_unmap_single(hostdata->dev,
> -			 queue->msg_token,
> -			 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
> -      map_failed:
> -	free_page((unsigned long)queue->msgs);
> +	dma_free_noncoherent(hostdata->dev, PAGE_SIZE, queue->msg,
> +			     queue->msg_token, DMA_BIDIRECTIONAL);
>        malloc_failed:
>  	return -1;
>  }
> 


^ permalink raw reply

* Re: [PATCH v2 03/13] powerpc: Remove func_descr_t
From: Daniel Axtens @ 2021-10-14 22:17 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Andrew Morton, James E.J. Bottomley,
	Helge Deller, Arnd Bergmann, Kees Cook, Greg Kroah-Hartman
  Cc: linux-arch, linux-ia64, linux-parisc, linux-kernel, linux-mm,
	linuxppc-dev
In-Reply-To: <16eef6afbf7322d0c07760ebf827b8f9f50f7c6e.1634190022.git.christophe.leroy@csgroup.eu>

Christophe Leroy <christophe.leroy@csgroup.eu> writes:

> 'func_descr_t' is redundant with 'struct ppc64_opd_entry'

So, if I understand the overall direction of the series, you're
consolidating powerpc around one single type for function descriptors,
and then you're creating a generic typedef so that generic code can
always do ((func_desc_t)x)->addr to get the address of a function out of
a function descriptor regardless of arch. (And regardless of whether the
arch uses function descriptors or not.)

So:

 - why pick ppc64_opd_entry over func_descr_t?

 - Why not make our struct just called func_desc_t - why have a
   ppc64_opd_entry type or a func_descr_t typedef?

 - Should this patch wait until after you've made the generic
   func_desc_t change and move directly to that new interface? (rather
   than move from func_descr_t -> ppc64_opd_entry -> ...) Or is there a
   particular reason arch specific code should use an arch-specific
   struct or named type?

> Remove it.
>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/include/asm/code-patching.h | 2 +-
>  arch/powerpc/include/asm/types.h         | 6 ------
>  arch/powerpc/kernel/signal_64.c          | 8 ++++----
>  3 files changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h
> index 4ba834599c4d..f3445188d319 100644
> --- a/arch/powerpc/include/asm/code-patching.h
> +++ b/arch/powerpc/include/asm/code-patching.h
> @@ -110,7 +110,7 @@ static inline unsigned long ppc_function_entry(void *func)
>  	 * function's descriptor. The first entry in the descriptor is the
>  	 * address of the function text.
>  	 */
> -	return ((func_descr_t *)func)->entry;
> +	return ((struct ppc64_opd_entry *)func)->addr;
>  #else
>  	return (unsigned long)func;
>  #endif
> diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h
> index f1630c553efe..97da77bc48c9 100644
> --- a/arch/powerpc/include/asm/types.h
> +++ b/arch/powerpc/include/asm/types.h
> @@ -23,12 +23,6 @@
>  
>  typedef __vector128 vector128;
>  
> -typedef struct {
> -	unsigned long entry;
> -	unsigned long toc;
> -	unsigned long env;
> -} func_descr_t;

I was a little concerned about going from a 3-element struct to a
2-element struct (as ppc64_opd_entry doesn't have an element for env) -
but we don't seem to take the sizeof this anywhere, nor do we use env
anywhere, nor do we do funky macro stuff with it in the signal handling
code that might implictly use the 3rd element, so I guess this will
work. Still, func_descr_t seems to describe the underlying ABI better
than ppc64_opd_entry...

>  #endif /* __ASSEMBLY__ */
>  
>  #endif /* _ASM_POWERPC_TYPES_H */
> diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
> index 1831bba0582e..63ddbe7b108c 100644
> --- a/arch/powerpc/kernel/signal_64.c
> +++ b/arch/powerpc/kernel/signal_64.c
> @@ -933,11 +933,11 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set,
>  		 * descriptor is the entry address of signal and the second
>  		 * entry is the TOC value we need to use.
>  		 */
> -		func_descr_t __user *funct_desc_ptr =
> -			(func_descr_t __user *) ksig->ka.sa.sa_handler;
> +		struct ppc64_opd_entry __user *funct_desc_ptr =
> +			(struct ppc64_opd_entry __user *)ksig->ka.sa.sa_handler;
>  
> -		err |= get_user(regs->ctr, &funct_desc_ptr->entry);
> -		err |= get_user(regs->gpr[2], &funct_desc_ptr->toc);
> +		err |= get_user(regs->ctr, &funct_desc_ptr->addr);
> +		err |= get_user(regs->gpr[2], &funct_desc_ptr->r2);

Likewise, r2 seems like a worse name than toc. I guess we could clean
that up another time though.

Kind regards,
Daniel

>  	}
>  
>  	/* enter the signal handler in native-endian mode */
> -- 
> 2.31.1

^ permalink raw reply

* [PATCH v2] powerpc/mpc512x: dts: fix PSC node warnings
From: Anatolij Gustschin @ 2021-10-14 22:42 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: devicetree, Rob Herring, linux-kernel

Rework PSC node description to fix build warnings like:
mpc5121.dtsi:397.13-406.5: Warning (spi_bus_bridge): /soc@80000000/psc@11400: node name for SPI buses should be 'spi'
mpc5121.dtsi:409.13-418.5: Warning (spi_bus_bridge): /soc@80000000/psc@11500: node name for SPI buses should be 'spi'
mpc5121.dtsi:457.13-466.5: Warning (spi_bus_bridge): /soc@80000000/psc@11900: node name for SPI buses should be 'spi'

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
Changes in v2:
 - extract PSC nodes to files which can be included
   separately and extended as needed

 arch/powerpc/boot/dts/ac14xx.dts            | 118 ++++++++--------
 arch/powerpc/boot/dts/mpc5121-psc0.dtsi     |  16 +++
 arch/powerpc/boot/dts/mpc5121-psc1.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc10.dtsi    |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc11.dtsi    |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc2.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc3.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc4-spi.dtsi |  17 +++
 arch/powerpc/boot/dts/mpc5121-psc4.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc5-spi.dtsi |  17 +++
 arch/powerpc/boot/dts/mpc5121-psc5.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc6.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc7.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc8.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121-psc9-spi.dtsi |  17 +++
 arch/powerpc/boot/dts/mpc5121-psc9.dtsi     |  15 ++
 arch/powerpc/boot/dts/mpc5121.dtsi          | 148 +-------------------
 arch/powerpc/boot/dts/mpc5121ads.dts        |  42 +++---
 arch/powerpc/boot/dts/pdm360ng.dts          | 104 +++++++-------
 19 files changed, 371 insertions(+), 273 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc0.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc1.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc10.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc11.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc2.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc3.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc4-spi.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc4.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc5-spi.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc5.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc6.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc7.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc8.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc9-spi.dtsi
 create mode 100644 arch/powerpc/boot/dts/mpc5121-psc9.dtsi

diff --git a/arch/powerpc/boot/dts/ac14xx.dts b/arch/powerpc/boot/dts/ac14xx.dts
index 5d8877e1f4ad..0af3b0ab7550 100644
--- a/arch/powerpc/boot/dts/ac14xx.dts
+++ b/arch/powerpc/boot/dts/ac14xx.dts
@@ -15,8 +15,8 @@
 	#size-cells = <1>;
 
 	aliases {
-		serial0 = &serial0;
-		serial1 = &serial7;
+		serial0 = &psc3;
+		serial1 = &psc7;
 		spi4 = &spi4;
 		spi5 = &spi5;
 	};
@@ -294,62 +294,6 @@
 			status = "disabled";
 		};
 
-		/* PSC3 serial port A, aka ttyPSC0 */
-		serial0: psc@11300 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-			fsl,rx-fifo-size = <512>;
-			fsl,tx-fifo-size = <512>;
-		};
-
-		/* PSC4 in SPI mode */
-		spi4: psc@11400 {
-			compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
-			fsl,rx-fifo-size = <768>;
-			fsl,tx-fifo-size = <768>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			num-cs = <1>;
-			cs-gpios = <&gpio_pic 25 0>;
-
-			flash: m25p128@0 {
-				compatible = "st,m25p128";
-				spi-max-frequency = <20000000>;
-				reg = <0>;
-				#address-cells = <1>;
-				#size-cells = <1>;
-
-				partition@0 {
-					label = "spi-flash0";
-					reg = <0x00000000 0x01000000>;
-				};
-			};
-		};
-
-		/* PSC5 in SPI mode */
-		spi5: psc@11500 {
-			compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
-			fsl,mode = "spi-master";
-			fsl,rx-fifo-size = <128>;
-			fsl,tx-fifo-size = <128>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			lcd@0 {
-				compatible = "ilitek,ili922x";
-				reg = <0>;
-				spi-max-frequency = <100000>;
-				spi-cpol;
-				spi-cpha;
-			};
-		};
-
-		/* PSC7 serial port C, aka ttyPSC2 */
-		serial7: psc@11700 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-			fsl,rx-fifo-size = <512>;
-			fsl,tx-fifo-size = <512>;
-		};
-
 		matrix_keypad@0 {
 			compatible = "gpio-matrix-keypad";
 			debounce-delay-ms = <5>;
@@ -393,3 +337,61 @@
 		};
 	};
 };
+
+/* PSC3 serial port A, aka ttyPSC0 */
+#include "mpc5121-psc3.dtsi"
+&psc3 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	fsl,rx-fifo-size = <512>;
+	fsl,tx-fifo-size = <512>;
+	status = "okay";
+};
+
+/* PSC7 serial port C, aka ttyPSC2 */
+#include "mpc5121-psc7.dtsi"
+&psc7 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	fsl,rx-fifo-size = <512>;
+	fsl,tx-fifo-size = <512>;
+	status = "okay";
+};
+
+/* PSC4 in SPI mode */
+#include "mpc5121-psc4-spi.dtsi"
+&spi4 {
+	status = "okay";
+	fsl,rx-fifo-size = <768>;
+	fsl,tx-fifo-size = <768>;
+	num-cs = <1>;
+	cs-gpios = <&gpio_pic 25 0>;
+
+	flash: m25p128@0 {
+		compatible = "st,m25p128";
+		spi-max-frequency = <20000000>;
+		reg = <0>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "spi-flash0";
+			reg = <0x00000000 0x01000000>;
+		};
+	};
+};
+
+/* PSC5 in SPI mode */
+#include "mpc5121-psc5-spi.dtsi"
+&spi5 {
+	status = "okay";
+	fsl,mode = "spi-master";
+	fsl,rx-fifo-size = <128>;
+	fsl,tx-fifo-size = <128>;
+
+	lcd@0 {
+		compatible = "ilitek,ili922x";
+		reg = <0>;
+		spi-max-frequency = <100000>;
+		spi-cpol;
+		spi-cpha;
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc0.dtsi b/arch/powerpc/boot/dts/mpc5121-psc0.dtsi
new file mode 100644
index 000000000000..a2df388d864c
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc0.dtsi
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	/* 512x PSCs are not 52xx PSC compatible */
+	psc0: psc@11000 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11000 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC0>,
+			 <&clks MPC512x_CLK_PSC0_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc1.dtsi b/arch/powerpc/boot/dts/mpc5121-psc1.dtsi
new file mode 100644
index 000000000000..41848f44c576
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc1.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc1: psc@11100 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11100 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC1>,
+			 <&clks MPC512x_CLK_PSC1_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc10.dtsi b/arch/powerpc/boot/dts/mpc5121-psc10.dtsi
new file mode 100644
index 000000000000..6d004a15baf1
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc10.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc10: psc@11a00 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11a00 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC10>,
+			 <&clks MPC512x_CLK_PSC10_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc11.dtsi b/arch/powerpc/boot/dts/mpc5121-psc11.dtsi
new file mode 100644
index 000000000000..9888ad50afc3
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc11.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc11: psc@11b00 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11b00 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC11>,
+			 <&clks MPC512x_CLK_PSC11_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc2.dtsi b/arch/powerpc/boot/dts/mpc5121-psc2.dtsi
new file mode 100644
index 000000000000..2b229a8cb4cf
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc2.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc2: psc@11200 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11200 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC2>,
+			 <&clks MPC512x_CLK_PSC2_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc3.dtsi b/arch/powerpc/boot/dts/mpc5121-psc3.dtsi
new file mode 100644
index 000000000000..972cd0af2ac7
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc3.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc3: psc@11300 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11300 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC3>,
+			 <&clks MPC512x_CLK_PSC3_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc4-spi.dtsi b/arch/powerpc/boot/dts/mpc5121-psc4-spi.dtsi
new file mode 100644
index 000000000000..d110a89d5e93
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc4-spi.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	spi4: spi@11400 {
+		compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
+		reg = <0x11400 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC9>,
+			 <&clks MPC512x_CLK_PSC9_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc4.dtsi b/arch/powerpc/boot/dts/mpc5121-psc4.dtsi
new file mode 100644
index 000000000000..0a3082318125
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc4.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc4: psc@11400 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11400 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC4>,
+			 <&clks MPC512x_CLK_PSC4_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc5-spi.dtsi b/arch/powerpc/boot/dts/mpc5121-psc5-spi.dtsi
new file mode 100644
index 000000000000..5651ccff02ad
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc5-spi.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	spi5: spi@11500 {
+		compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
+		reg = <0x11500 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC9>,
+			 <&clks MPC512x_CLK_PSC9_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc5.dtsi b/arch/powerpc/boot/dts/mpc5121-psc5.dtsi
new file mode 100644
index 000000000000..880ab45d6985
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc5.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc5: psc@11500 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11500 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC5>,
+			 <&clks MPC512x_CLK_PSC5_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc6.dtsi b/arch/powerpc/boot/dts/mpc5121-psc6.dtsi
new file mode 100644
index 000000000000..7ec67953cffb
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc6.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc6: psc@11600 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11600 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC6>,
+			 <&clks MPC512x_CLK_PSC6_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc7.dtsi b/arch/powerpc/boot/dts/mpc5121-psc7.dtsi
new file mode 100644
index 000000000000..e5ca588e4cfd
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc7.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc7: psc@11700 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11700 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC7>,
+			 <&clks MPC512x_CLK_PSC7_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc8.dtsi b/arch/powerpc/boot/dts/mpc5121-psc8.dtsi
new file mode 100644
index 000000000000..056d6bc019de
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc8.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc8: psc@11800 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11800 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC8>,
+			 <&clks MPC512x_CLK_PSC8_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc9-spi.dtsi b/arch/powerpc/boot/dts/mpc5121-psc9-spi.dtsi
new file mode 100644
index 000000000000..3c82804970eb
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc9-spi.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	spi9: spi@11900 {
+		compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
+		reg = <0x11900 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC9>,
+			 <&clks MPC512x_CLK_PSC9_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121-psc9.dtsi b/arch/powerpc/boot/dts/mpc5121-psc9.dtsi
new file mode 100644
index 000000000000..355190f974bd
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc5121-psc9.dtsi
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+&soc {
+	psc9: psc@11900 {
+		compatible = "fsl,mpc5121-psc";
+		reg = <0x11900 0x100>;
+		interrupts = <40 0x8>;
+		fsl,rx-fifo-size = <16>;
+		fsl,tx-fifo-size = <16>;
+		clocks = <&clks MPC512x_CLK_PSC9>,
+			 <&clks MPC512x_CLK_PSC9_MCLK>;
+		clock-names = "ipg", "mclk";
+		status = "disabled";
+	};
+};
diff --git a/arch/powerpc/boot/dts/mpc5121.dtsi b/arch/powerpc/boot/dts/mpc5121.dtsi
index 3f66b91a8e3c..21674da8beb1 100644
--- a/arch/powerpc/boot/dts/mpc5121.dtsi
+++ b/arch/powerpc/boot/dts/mpc5121.dtsi
@@ -87,7 +87,7 @@
 		};
 	};
 
-	soc@80000000 {
+	soc: soc@80000000 {
 		compatible = "fsl,mpc5121-immr";
 		#address-cells = <1>;
 		#size-cells = <1>;
@@ -343,152 +343,6 @@
 			clock-names = "ipg";
 		};
 
-		/* 512x PSCs are not 52xx PSC compatible */
-
-		/* PSC0 */
-		psc@11000 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11000 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC0>,
-				 <&clks MPC512x_CLK_PSC0_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC1 */
-		psc@11100 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11100 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC1>,
-				 <&clks MPC512x_CLK_PSC1_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC2 */
-		psc@11200 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11200 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC2>,
-				 <&clks MPC512x_CLK_PSC2_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC3 */
-		psc@11300 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-			reg = <0x11300 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC3>,
-				 <&clks MPC512x_CLK_PSC3_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC4 */
-		psc@11400 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-			reg = <0x11400 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC4>,
-				 <&clks MPC512x_CLK_PSC4_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC5 */
-		psc@11500 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11500 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC5>,
-				 <&clks MPC512x_CLK_PSC5_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC6 */
-		psc@11600 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11600 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC6>,
-				 <&clks MPC512x_CLK_PSC6_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC7 */
-		psc@11700 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11700 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC7>,
-				 <&clks MPC512x_CLK_PSC7_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC8 */
-		psc@11800 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11800 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC8>,
-				 <&clks MPC512x_CLK_PSC8_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC9 */
-		psc@11900 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11900 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC9>,
-				 <&clks MPC512x_CLK_PSC9_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC10 */
-		psc@11a00 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11a00 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC10>,
-				 <&clks MPC512x_CLK_PSC10_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
-		/* PSC11 */
-		psc@11b00 {
-			compatible = "fsl,mpc5121-psc";
-			reg = <0x11b00 0x100>;
-			interrupts = <40 0x8>;
-			fsl,rx-fifo-size = <16>;
-			fsl,tx-fifo-size = <16>;
-			clocks = <&clks MPC512x_CLK_PSC11>,
-				 <&clks MPC512x_CLK_PSC11_MCLK>;
-			clock-names = "ipg", "mclk";
-		};
-
 		pscfifo@11f00 {
 			compatible = "fsl,mpc5121-psc-fifo";
 			reg = <0x11f00 0x100>;
diff --git a/arch/powerpc/boot/dts/mpc5121ads.dts b/arch/powerpc/boot/dts/mpc5121ads.dts
index b407a50ee622..c87735ec0730 100644
--- a/arch/powerpc/boot/dts/mpc5121ads.dts
+++ b/arch/powerpc/boot/dts/mpc5121ads.dts
@@ -133,24 +133,6 @@
 			fsl,invert-drvvbus;
 			fsl,invert-pwr-fault;
 		};
-
-		/* PSC3 serial port A aka ttyPSC0 */
-		psc@11300 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
-
-		/* PSC4 serial port B aka ttyPSC1 */
-		psc@11400 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
-
-		/* PSC5 in ac97 mode */
-		ac97: psc@11500 {
-			compatible = "fsl,mpc5121-psc-ac97", "fsl,mpc5121-psc";
-			fsl,mode = "ac97-slave";
-			fsl,rx-fifo-size = <384>;
-			fsl,tx-fifo-size = <384>;
-		};
 	};
 
 	pci: pci@80008500 {
@@ -172,3 +154,27 @@
 				>;
 	};
 };
+
+/* PSC3 serial port A aka ttyPSC0 */
+#include "mpc5121-psc3.dtsi"
+&psc3 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
+
+/* PSC4 serial port B aka ttyPSC1 */
+#include "mpc5121-psc4.dtsi"
+&psc4 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
+
+/* PSC5 in ac97 mode */
+#include "mpc5121-psc5.dtsi"
+&psc5 {
+	compatible = "fsl,mpc5121-psc-ac97", "fsl,mpc5121-psc";
+	status = "okay";
+	fsl,mode = "ac97-slave";
+	fsl,rx-fifo-size = <384>;
+	fsl,tx-fifo-size = <384>;
+};
diff --git a/arch/powerpc/boot/dts/pdm360ng.dts b/arch/powerpc/boot/dts/pdm360ng.dts
index 67c3b9db75d7..23e797d8887e 100644
--- a/arch/powerpc/boot/dts/pdm360ng.dts
+++ b/arch/powerpc/boot/dts/pdm360ng.dts
@@ -132,64 +132,68 @@
 		usb@4000 {
 			fsl,invert-pwr-fault;
 		};
+	};
+};
 
-		psc@11000 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
-
-		psc@11100 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
-
-		psc@11200 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
-
-		psc@11300 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
+#include "mpc5121-psc0.dtsi"
+#include "mpc5121-psc1.dtsi"
+#include "mpc5121-psc2.dtsi"
+#include "mpc5121-psc3.dtsi"
+#include "mpc5121-psc4.dtsi"
+#include "mpc5121-psc6.dtsi"
+#include "mpc5121-psc8.dtsi"
+#include "mpc5121-psc11.dtsi"
+/* Select PSC UART mode */
+&psc0 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11400 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
+&psc1 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11500 {
-			status = "disabled";
-		};
+&psc2 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11600 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
+&psc3 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11700 {
-			status = "disabled";
-		};
+&psc4 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11800 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
+&psc6 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11900 {
-			compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc";
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			/* ADS7845 touch screen controller */
-			ts@0 {
-				compatible = "ti,ads7846";
-				reg = <0x0>;
-				spi-max-frequency = <3000000>;
-				/* pen irq is GPIO25 */
-				interrupts = <78 0x8>;
-			};
-		};
+&psc8 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11a00 {
-			status = "disabled";
-		};
+&psc11 {
+	compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
+	status = "okay";
+};
 
-		psc@11b00 {
-			compatible = "fsl,mpc5121-psc-uart", "fsl,mpc5121-psc";
-		};
+#include "mpc5121-psc9-spi.dtsi"
+&spi9 {
+	status = "okay";
+
+	/* ADS7845 touch screen controller */
+	ts@0 {
+		compatible = "ti,ads7846";
+		reg = <0x0>;
+		spi-max-frequency = <3000000>;
+		/* pen irq is GPIO25 */
+		interrupts = <78 0x8>;
 	};
 };
-- 
2.17.1


^ permalink raw reply related

* Re: [PATCH] powerpc/mpc512x: dts: fix PSC node warnings
From: Anatolij Gustschin @ 2021-10-14 22:45 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linuxppc-dev, linux-kernel@vger.kernel.org
In-Reply-To: <CAL_JsqJQ8_3+pwT0a-gj5iSUSo3kYZXFraejjBGObNHpB+xcTg@mail.gmail.com>

On Thu, 14 Oct 2021 07:33:26 -0500
Rob Herring robh+dt@kernel.org wrote:
...
>> +++ b/arch/powerpc/boot/dts/ac14xx.dts
>> @@ -301,13 +301,21 @@
>>                         fsl,tx-fifo-size = <512>;
>>                 };
>>
>> +               /delete-node/ psc@11400;
>> +               /delete-node/ psc@11500;  
>
>That's an odd way to fix this, and means every user of the .dtsi file
>with these nodes will have to repeat the same thing.

okay, in v2 patch I've extracted the psc nodes to files which
can be included and extended individually.

Anatolij

^ permalink raw reply

* Re: [PATCH] ibmvscsi: use GFP_KERNEL with dma_alloc_coherent in initialize_event_pool
From: Tyrel Datwyler @ 2021-10-14 23:15 UTC (permalink / raw)
  To: tyreld; +Cc: brking, james.bottomley, linuxppc-dev, martin.petersen,
	linux-scsi
In-Reply-To: <1547089149-20577-1-git-send-email-tyreld@linux.vnet.ibm.com>

Just stumbled upon this trivial little patch that looks to have gotten lost in
the shuffle. Seems it even got a reviewed-by from Brian [1].

So, uh I guess after almost 3 years...ping?

-Tyrel

[1]
https://yhbt.net/lore/all/fd33df0e-012b-e437-c6e9-29cd0883808d@linux.vnet.ibm.com/

On 01/09/2019 08:59 PM, Tyrel Datwyler wrote:
> During driver probe we allocate a dma region for our event pool.
> Currently, zero is passed for the gfp_flags parameter. Driver probe
> callbacks run in process context and we hold no locks so we can sleep
> here if necessary.
>
> Fix by passing GFP_KERNEL explicitly to dma_alloc_coherent().
>
> Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
> ---
>  drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
> index cb8535e..10d5e77 100644
> --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
> +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
> @@ -465,7 +465,7 @@ static int initialize_event_pool(struct event_pool *pool,
>  	pool->iu_storage =
>  	    dma_alloc_coherent(hostdata->dev,
>  			       pool->size * sizeof(*pool->iu_storage),
> -			       &pool->iu_token, 0);
> +			       &pool->iu_token, GFP_KERNEL);
>  	if (!pool->iu_storage) {
>  		kfree(pool->events);
>  		return -ENOMEM;
>

^ permalink raw reply

* [PATCH v2] powerpc/64s: Default to 64K pages for 64 bit book3s
From: Joel Stanley @ 2021-10-15  0:16 UTC (permalink / raw)
  To: linuxppc-dev

For 64-bit book3s the default should be 64K as that's what modern CPUs
are designed for.

The following defconfigs already set CONFIG_PPC_64K_PAGES:

 cell_defconfig
 pasemi_defconfig
 powernv_defconfig
 ppc64_defconfig
 pseries_defconfig
 skiroot_defconfig

The have the option removed from the defconfig, as it is now the
default.

The defconfigs that now need to set CONFIG_PPC_4K_PAGES to maintain
their existing behaviour are:

 g5_defconfig
 maple_defconfig
 microwatt_defconfig
 ps3_defconfig

Link: https://github.com/linuxppc/issues/issues/109
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
v2: remove unrelated change from microwatt_defconfig

 arch/powerpc/Kconfig                     | 1 +
 arch/powerpc/configs/cell_defconfig      | 1 -
 arch/powerpc/configs/g5_defconfig        | 1 +
 arch/powerpc/configs/maple_defconfig     | 1 +
 arch/powerpc/configs/microwatt_defconfig | 1 +
 arch/powerpc/configs/pasemi_defconfig    | 1 -
 arch/powerpc/configs/powernv_defconfig   | 1 -
 arch/powerpc/configs/ppc64_defconfig     | 1 -
 arch/powerpc/configs/ps3_defconfig       | 1 +
 arch/powerpc/configs/pseries_defconfig   | 1 -
 arch/powerpc/configs/skiroot_defconfig   | 1 -
 11 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8a584414ef67..e2c220fa91c0 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -708,6 +708,7 @@ config ARCH_MEMORY_PROBE
 
 choice
 	prompt "Page size"
+	default PPC_64K_PAGES if PPC_BOOK3S_64
 	default PPC_4K_PAGES
 	help
 	  Select the kernel logical page size. Increasing the page size
diff --git a/arch/powerpc/configs/cell_defconfig b/arch/powerpc/configs/cell_defconfig
index cc2c0d51f493..7fd9e596ea33 100644
--- a/arch/powerpc/configs/cell_defconfig
+++ b/arch/powerpc/configs/cell_defconfig
@@ -36,7 +36,6 @@ CONFIG_GEN_RTC=y
 CONFIG_BINFMT_MISC=m
 CONFIG_IRQ_ALL_CPUS=y
 CONFIG_NUMA=y
-CONFIG_PPC_64K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_PCIEPORTBUS=y
 CONFIG_NET=y
diff --git a/arch/powerpc/configs/g5_defconfig b/arch/powerpc/configs/g5_defconfig
index 63d611cc160f..9d6212a8b195 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -26,6 +26,7 @@ CONFIG_CPU_FREQ_PMAC64=y
 CONFIG_GEN_RTC=y
 CONFIG_KEXEC=y
 CONFIG_IRQ_ALL_CPUS=y
+CONFIG_PPC_4K_PAGES=y
 CONFIG_PCI_MSI=y
 CONFIG_NET=y
 CONFIG_PACKET=y
diff --git a/arch/powerpc/configs/maple_defconfig b/arch/powerpc/configs/maple_defconfig
index 9424c1e67e1c..c821a97f4a89 100644
--- a/arch/powerpc/configs/maple_defconfig
+++ b/arch/powerpc/configs/maple_defconfig
@@ -25,6 +25,7 @@ CONFIG_UDBG_RTAS_CONSOLE=y
 CONFIG_GEN_RTC=y
 CONFIG_KEXEC=y
 CONFIG_IRQ_ALL_CPUS=y
+CONFIG_PPC_4K_PAGES=y
 CONFIG_PCI_MSI=y
 CONFIG_NET=y
 CONFIG_PACKET=y
diff --git a/arch/powerpc/configs/microwatt_defconfig b/arch/powerpc/configs/microwatt_defconfig
index 9465209b8c5b..07d87a4044b2 100644
--- a/arch/powerpc/configs/microwatt_defconfig
+++ b/arch/powerpc/configs/microwatt_defconfig
@@ -26,6 +26,7 @@ CONFIG_PPC_MICROWATT=y
 # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
 CONFIG_CPU_FREQ=y
 CONFIG_HZ_100=y
+CONFIG_PPC_4K_PAGES=y
 # CONFIG_PPC_MEM_KEYS is not set
 # CONFIG_SECCOMP is not set
 # CONFIG_MQ_IOSCHED_KYBER is not set
diff --git a/arch/powerpc/configs/pasemi_defconfig b/arch/powerpc/configs/pasemi_defconfig
index 78606b7e42df..e00a703581c3 100644
--- a/arch/powerpc/configs/pasemi_defconfig
+++ b/arch/powerpc/configs/pasemi_defconfig
@@ -22,7 +22,6 @@ CONFIG_CPU_FREQ_GOV_POWERSAVE=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_HZ_1000=y
-CONFIG_PPC_64K_PAGES=y
 # CONFIG_SECCOMP is not set
 CONFIG_PCI_MSI=y
 CONFIG_PCCARD=y
diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig
index 8bfeea6c7de7..49f49c263935 100644
--- a/arch/powerpc/configs/powernv_defconfig
+++ b/arch/powerpc/configs/powernv_defconfig
@@ -62,7 +62,6 @@ CONFIG_MEMORY_FAILURE=y
 CONFIG_HWPOISON_INJECT=m
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
-CONFIG_PPC_64K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_PM=y
 CONFIG_HOTPLUG_PCI=y
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 0ad2291337a7..203d0b7f0bb8 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -52,7 +52,6 @@ CONFIG_KEXEC_FILE=y
 CONFIG_CRASH_DUMP=y
 CONFIG_FA_DUMP=y
 CONFIG_IRQ_ALL_CPUS=y
-CONFIG_PPC_64K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_RPA=m
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
index f300dcb937cc..7c95fab4b920 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -30,6 +30,7 @@ CONFIG_PS3_LPM=m
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_BINFMT_MISC=y
 CONFIG_KEXEC=y
+CONFIG_PPC_4K_PAGES=y
 # CONFIG_SPARSEMEM_VMEMMAP is not set
 # CONFIG_COMPACTION is not set
 CONFIG_SCHED_SMT=y
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index b183629f1bcf..de7641adb899 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -56,7 +56,6 @@ CONFIG_MEMORY_HOTPLUG=y
 CONFIG_MEMORY_HOTREMOVE=y
 CONFIG_KSM=y
 CONFIG_TRANSPARENT_HUGEPAGE=y
-CONFIG_PPC_64K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_RPA=m
diff --git a/arch/powerpc/configs/skiroot_defconfig b/arch/powerpc/configs/skiroot_defconfig
index c3ba614c973d..f491875700e8 100644
--- a/arch/powerpc/configs/skiroot_defconfig
+++ b/arch/powerpc/configs/skiroot_defconfig
@@ -43,7 +43,6 @@ CONFIG_KEXEC_FILE=y
 CONFIG_PRESERVE_FA_DUMP=y
 CONFIG_IRQ_ALL_CPUS=y
 CONFIG_NUMA=y
-CONFIG_PPC_64K_PAGES=y
 CONFIG_SCHED_SMT=y
 CONFIG_CMDLINE="console=tty0 console=hvc0 ipr.fast_reboot=1 quiet"
 # CONFIG_SECCOMP is not set
-- 
2.33.0


^ permalink raw reply related

* Re: [PATCH v2] KVM: PPC: Defer vtime accounting 'til after IRQ handling
From: Nicholas Piggin @ 2021-10-15  2:23 UTC (permalink / raw)
  To: kvm-ppc, Laurent Vivier, Michael Ellerman
  Cc: Greg Kurz, stable, linux-kernel, linuxppc-dev
In-Reply-To: <d7f59d0e-eac2-7978-4067-9258c8b1aefe@redhat.com>

Excerpts from Laurent Vivier's message of October 13, 2021 7:30 pm:
> On 13/10/2021 01:18, Michael Ellerman wrote:
>> Laurent Vivier <lvivier@redhat.com> writes:
>>> Commit 112665286d08 moved guest_exit() in the interrupt protected
>>> area to avoid wrong context warning (or worse), but the tick counter
>>> cannot be updated and the guest time is accounted to the system time.
>>>
>>> To fix the problem port to POWER the x86 fix
>>> 160457140187 ("Defer vtime accounting 'til after IRQ handling"):
>>>
>>> "Defer the call to account guest time until after servicing any IRQ(s)
>>>   that happened in the guest or immediately after VM-Exit.  Tick-based
>>>   accounting of vCPU time relies on PF_VCPU being set when the tick IRQ
>>>   handler runs, and IRQs are blocked throughout the main sequence of
>>>   vcpu_enter_guest(), including the call into vendor code to actually
>>>   enter and exit the guest."
>>>
>>> Fixes: 112665286d08 ("KVM: PPC: Book3S HV: Context tracking exit guest context before enabling irqs")
>>> Cc: npiggin@gmail.com
>>> Cc: <stable@vger.kernel.org> # 5.12
>>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>>> ---
>>>
>>> Notes:
>>>      v2: remove reference to commit 61bd0f66ff92
>>>          cc stable 5.12
>>>          add the same comment in the code as for x86
>>>
>>>   arch/powerpc/kvm/book3s_hv.c | 24 ++++++++++++++++++++----
>>>   1 file changed, 20 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
>>> index 2acb1c96cfaf..a694d1a8f6ce 100644
>>> --- a/arch/powerpc/kvm/book3s_hv.c
>>> +++ b/arch/powerpc/kvm/book3s_hv.c
>> ...
>>> @@ -4506,13 +4514,21 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,
>>>   
>>>   	srcu_read_unlock(&kvm->srcu, srcu_idx);
>>>   
>>> +	context_tracking_guest_exit();
>>> +
>>>   	set_irq_happened(trap);
>>>   
>>>   	kvmppc_set_host_core(pcpu);
>>>   
>>> -	guest_exit_irqoff();
>>> -
>>>   	local_irq_enable();
>>> +	/*
>>> +	 * Wait until after servicing IRQs to account guest time so that any
>>> +	 * ticks that occurred while running the guest are properly accounted
>>> +	 * to the guest.  Waiting until IRQs are enabled degrades the accuracy
>>> +	 * of accounting via context tracking, but the loss of accuracy is
>>> +	 * acceptable for all known use cases.
>>> +	 */
>>> +	vtime_account_guest_exit();
>> 
>> This pops a warning for me, running guest(s) on Power8:
>>   
>>    [  270.745303][T16661] ------------[ cut here ]------------
>>    [  270.745374][T16661] WARNING: CPU: 72 PID: 16661 at arch/powerpc/kernel/time.c:311 vtime_account_kernel+0xe0/0xf0
> 
> Thank you, I missed that...
> 
> My patch is wrong, I have to add vtime_account_guest_exit() before the local_irq_enable().

I thought so because if we take an interrupt after exiting the guest that 
should be accounted to kernel not guest.

> 
> arch/powerpc/kernel/time.c
> 
>   305 static unsigned long vtime_delta(struct cpu_accounting_data *acct,
>   306                                  unsigned long *stime_scaled,
>   307                                  unsigned long *steal_time)
>   308 {
>   309         unsigned long now, stime;
>   310
>   311         WARN_ON_ONCE(!irqs_disabled());
> ...
> 
> But I don't understand how ticks can be accounted now if irqs are still disabled.
> 
> Not sure it is as simple as expected...

I don't know all the timer stuff too well. The 
!CONFIG_VIRT_CPU_ACCOUNTING case is relying on PF_VCPU to be set when 
the host timer interrupt runs irqtime_account_process_tick runs so it
can accumulate that tick to the guest?

That probably makes sense then, but it seems like we need that in a
different place. Timer interrupts are not guaranteed to be the first one
to occur when interrupts are enabled.

Maybe a new tick_account_guest_exit() and move PF_VCPU clearing to that
for tick based accounting. Call it after local_irq_enable and call the
vtime accounting before it. Would that work?

Thanks,
Nick

^ permalink raw reply

* [powerpc:fixes-test] BUILD SUCCESS 6f779e1d359b8d5801f677c1d49dcfa10bf95674
From: kernel test robot @ 2021-10-15  2:26 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git fixes-test
branch HEAD: 6f779e1d359b8d5801f677c1d49dcfa10bf95674  powerpc/xive: Discard disabled interrupts in get_irqchip_state()

elapsed time: 728m

configs tested: 99
configs skipped: 94

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

gcc tested configs:
arm                                 defconfig
arm64                            allyesconfig
arm64                               defconfig
i386                 randconfig-c001-20211014
arm                            zeus_defconfig
sh                           se7206_defconfig
sh                         ap325rxa_defconfig
arm                            qcom_defconfig
arc                      axs103_smp_defconfig
powerpc                   currituck_defconfig
mips                  decstation_64_defconfig
powerpc                     skiroot_defconfig
mips                        workpad_defconfig
mips                     loongson2k_defconfig
arc                     haps_hs_smp_defconfig
m68k                          atari_defconfig
um                                  defconfig
powerpc                      tqm8xx_defconfig
powerpc                    adder875_defconfig
arc                        nsim_700_defconfig
powerpc                     tqm8541_defconfig
nios2                         3c120_defconfig
mips                      fuloong2e_defconfig
powerpc                        warp_defconfig
openrisc                    or1ksim_defconfig
powerpc                    ge_imp3a_defconfig
powerpc                   lite5200b_defconfig
powerpc                     sequoia_defconfig
arm                  randconfig-c002-20211014
x86_64               randconfig-c001-20211014
ia64                             allmodconfig
ia64                                defconfig
ia64                             allyesconfig
m68k                             allmodconfig
m68k                                defconfig
m68k                             allyesconfig
nios2                               defconfig
nds32                             allnoconfig
nds32                               defconfig
csky                                defconfig
alpha                               defconfig
alpha                            allyesconfig
nios2                            allyesconfig
h8300                            allyesconfig
arc                                 defconfig
sh                               allmodconfig
parisc                              defconfig
s390                                defconfig
sparc                            allyesconfig
sparc                               defconfig
i386                                defconfig
mips                             allyesconfig
mips                             allmodconfig
powerpc                          allyesconfig
powerpc                          allmodconfig
powerpc                           allnoconfig
i386                 randconfig-a003-20211014
i386                 randconfig-a001-20211014
i386                 randconfig-a005-20211014
i386                 randconfig-a004-20211014
i386                 randconfig-a002-20211014
i386                 randconfig-a006-20211014
x86_64               randconfig-a006-20211014
x86_64               randconfig-a004-20211014
x86_64               randconfig-a001-20211014
x86_64               randconfig-a005-20211014
x86_64               randconfig-a002-20211014
x86_64               randconfig-a003-20211014
riscv                    nommu_k210_defconfig
riscv                    nommu_virt_defconfig
riscv                             allnoconfig
riscv                               defconfig
riscv                          rv32_defconfig
x86_64                    rhel-8.3-kselftests
um                           x86_64_defconfig
um                             i386_defconfig
x86_64                              defconfig
x86_64                               rhel-8.3
x86_64                                  kexec

clang tested configs:
arm                  randconfig-c002-20211014
i386                 randconfig-c001-20211014
s390                 randconfig-c005-20211014
x86_64               randconfig-c007-20211014
powerpc              randconfig-c003-20211014
riscv                randconfig-c006-20211014
x86_64               randconfig-a012-20211014
x86_64               randconfig-a015-20211014
x86_64               randconfig-a016-20211014
x86_64               randconfig-a014-20211014
x86_64               randconfig-a011-20211014
x86_64               randconfig-a013-20211014
i386                 randconfig-a016-20211014
i386                 randconfig-a014-20211014
i386                 randconfig-a011-20211014
i386                 randconfig-a015-20211014
i386                 randconfig-a012-20211014
i386                 randconfig-a013-20211014
hexagon              randconfig-r041-20211014
s390                 randconfig-r044-20211014
riscv                randconfig-r042-20211014
hexagon              randconfig-r045-20211014

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

^ permalink raw reply

* [PATCH v11 1/3] tty: hvc: use correct dma alignment size
From: Xianting Tian @ 2021-10-15  2:46 UTC (permalink / raw)
  To: gregkh, jirislaby, amit, arnd, osandov
  Cc: Xianting Tian, shile.zhang, linuxppc-dev, linux-kernel,
	virtualization
In-Reply-To: <20211015024658.1353987-1-xianting.tian@linux.alibaba.com>

Use L1_CACHE_BYTES as the dma alignment size, use 'sizeof(long)' as
dma alignment is wrong.

Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
---
 drivers/tty/hvc/hvc_console.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 5bb8c4e44..5957ab728 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -49,7 +49,7 @@
 #define N_OUTBUF	16
 #define N_INBUF		16
 
-#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
+#define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))
 
 static struct tty_driver *hvc_driver;
 static struct task_struct *hvc_task;
-- 
2.17.1


^ permalink raw reply related

* [PATCH v11 0/3] make hvc pass dma capable memory to its backend
From: Xianting Tian @ 2021-10-15  2:46 UTC (permalink / raw)
  To: gregkh, jirislaby, amit, arnd, osandov
  Cc: Xianting Tian, shile.zhang, linuxppc-dev, linux-kernel,
	virtualization

Dear all,

This patch series make hvc framework pass DMA capable memory to
put_chars() of hvc backend(eg, virtio-console), and revert commit
c4baad5029 ("virtio-console: avoid DMA from stack”)

V1
virtio-console: avoid DMA from vmalloc area
https://lkml.org/lkml/2021/7/27/494

For v1 patch, Arnd Bergmann suggests to fix the issue in the first
place:
Make hvc pass DMA capable memory to put_chars()
The fix suggestion is included in v2.

V2
[PATCH 1/2] tty: hvc: pass DMA capable memory to put_chars()
https://lkml.org/lkml/2021/8/1/8
[PATCH 2/2] virtio-console: remove unnecessary kmemdup()
https://lkml.org/lkml/2021/8/1/9

For v2 patch, Arnd Bergmann suggests to make new buf part of the
hvc_struct structure, and fix the compile issue.
The fix suggestion is included in v3.

V3
[PATCH v3 1/2] tty: hvc: pass DMA capable memory to put_chars()
https://lkml.org/lkml/2021/8/3/1347
[PATCH v3 2/2] virtio-console: remove unnecessary kmemdup()
https://lkml.org/lkml/2021/8/3/1348

For v3 patch, Jiri Slaby suggests to make 'char c[N_OUTBUF]' part of
hvc_struct, and make 'hp->outbuf' aligned and use struct_size() to
calculate the size of hvc_struct. The fix suggestion is included in
v4.

V4
[PATCH v4 0/2] make hvc pass dma capable memory to its backend
https://lkml.org/lkml/2021/8/5/1350
[PATCH v4 1/2] tty: hvc: pass DMA capable memory to put_chars()
https://lkml.org/lkml/2021/8/5/1351
[PATCH v4 2/2] virtio-console: remove unnecessary kmemdup()
https://lkml.org/lkml/2021/8/5/1352

For v4 patch, Arnd Bergmann suggests to introduce another
array(cons_outbuf[]) for the buffer pointers next to the cons_ops[]
and vtermnos[] arrays. This fix included in this v5 patch.

V5
Arnd Bergmann suggests to use "L1_CACHE_BYTES" as dma alignment,
use 'sizeof(long)' as dma alignment is wrong. fix it in v6.

V6
It contains coding error, fix it in v7 and it worked normally
according to test result.

V7
Greg KH suggests to add test and code review developer,
Jiri Slaby suggests to use lockless buffer and fix dma alignment
in separate patch.
fix above things in v8. 

V8
This contains coding error when switch to use new buffer. fix it in v9.

V9
It didn't make things much clearer, it needs add more comments for new added buf.
Add use lock to protect new added buffer. fix in v10.

V10
Remove 'char outchar' and its lock from hvc_struct, adjust hvc_struct and use
pahole to display the struct layout.
fix it in v11.

********TEST STEPS*********
1, config guest console=hvc0
2, start guest
3, login guest
    Welcome to Buildroot
    buildroot login: root
    # 
    # cat /proc/cmdline 
    console=hvc0 root=/dev/vda rw init=/sbin/init
    #

drivers/tty/hvc/hvc_console.c | 36 ++++++++++++++++++++---------------
drivers/tty/hvc/hvc_console.h | 21 +++++++++++++++++++-
drivers/char/virtio_console.c | 12 ++----------
3 file changed

^ permalink raw reply

* [PATCH v11 3/3] virtio-console: remove unnecessary kmemdup()
From: Xianting Tian @ 2021-10-15  2:46 UTC (permalink / raw)
  To: gregkh, jirislaby, amit, arnd, osandov
  Cc: Xianting Tian, shile.zhang, linuxppc-dev, linux-kernel,
	virtualization
In-Reply-To: <20211015024658.1353987-1-xianting.tian@linux.alibaba.com>

This revert commit c4baad5029 ("virtio-console: avoid DMA from stack")

hvc framework will never pass stack memory to the put_chars() function,
So the calling of kmemdup() is unnecessary, we can remove it.

Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
Reviewed-by: Shile Zhang <shile.zhang@linux.alibaba.com>
---
 drivers/char/virtio_console.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 7eaf303a7..4ed3ffb1d 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1117,8 +1117,6 @@ static int put_chars(u32 vtermno, const char *buf, int count)
 {
 	struct port *port;
 	struct scatterlist sg[1];
-	void *data;
-	int ret;
 
 	if (unlikely(early_put_chars))
 		return early_put_chars(vtermno, buf, count);
@@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const char *buf, int count)
 	if (!port)
 		return -EPIPE;
 
-	data = kmemdup(buf, count, GFP_ATOMIC);
-	if (!data)
-		return -ENOMEM;
-
-	sg_init_one(sg, data, count);
-	ret = __send_to_port(port, sg, 1, count, data, false);
-	kfree(data);
-	return ret;
+	sg_init_one(sg, buf, count);
+	return __send_to_port(port, sg, 1, count, (void *)buf, false);
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related

* [PATCH v11 2/3] tty: hvc: pass DMA capable memory to put_chars()
From: Xianting Tian @ 2021-10-15  2:46 UTC (permalink / raw)
  To: gregkh, jirislaby, amit, arnd, osandov
  Cc: Xianting Tian, shile.zhang, linuxppc-dev, linux-kernel,
	virtualization
In-Reply-To: <20211015024658.1353987-1-xianting.tian@linux.alibaba.com>

As well known, hvc backend can register its opertions to hvc backend.
the operations contain put_chars(), get_chars() and so on.

Some hvc backend may do dma in its operations. eg, put_chars() of
virtio-console. But in the code of hvc framework, it may pass DMA
incapable memory to put_chars() under a specific configuration, which
is explained in commit c4baad5029(virtio-console: avoid DMA from stack):
1, c[] is on stack,
   hvc_console_print():
        char c[N_OUTBUF] __ALIGNED__;
        cons_ops[index]->put_chars(vtermnos[index], c, i);
2, ch is on stack,
   static void hvc_poll_put_char(,,char ch)
   {
        struct tty_struct *tty = driver->ttys[0];
        struct hvc_struct *hp = tty->driver_data;
        int n;

        do {
                n = hp->ops->put_chars(hp->vtermno, &ch, 1);
        } while (n <= 0);
   }

Commit c4baad5029 is just the fix to avoid DMA from stack memory, which
is passed to virtio-console by hvc framework in above code. But I think
the fix is aggressive, it directly uses kmemdup() to alloc new buffer
from kmalloc area and do memcpy no matter the memory is in kmalloc area
or not. But most importantly, it should better be fixed in the hvc
framework, by changing it to never pass stack memory to the put_chars()
function in the first place. Otherwise, we still face the same issue if
a new hvc backend using dma added in the furture.

In this patch, add 'char cons_outbuf[]' as part of 'struct hvc_struct',
so hp->cons_outbuf is no longer the stack memory, we can use it in above
cases safely. We also add lock to protect cons_outbuf instead of using
the global lock of hvc.

Introduce another array(cons_hvcs[]) for hvc pointers next to the
cons_ops[] and vtermnos[] arrays. With the array, we can easily find
hvc's cons_outbuf and its lock.

With the patch, we can revert the fix c4baad5029.

Signed-off-by: Xianting Tian <xianting.tian@linux.alibaba.com>
Signed-off-by: Shile Zhang <shile.zhang@linux.alibaba.com>
---
 drivers/tty/hvc/hvc_console.c | 36 ++++++++++++++++++++---------------
 drivers/tty/hvc/hvc_console.h | 21 +++++++++++++++++++-
 2 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 5957ab728..11f2463a1 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -41,16 +41,6 @@
  */
 #define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
 
-/*
- * These sizes are most efficient for vio, because they are the
- * native transfer size. We could make them selectable in the
- * future to better deal with backends that want other buffer sizes.
- */
-#define N_OUTBUF	16
-#define N_INBUF		16
-
-#define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))
-
 static struct tty_driver *hvc_driver;
 static struct task_struct *hvc_task;
 
@@ -142,6 +132,7 @@ static int hvc_flush(struct hvc_struct *hp)
 static const struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES];
 static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
 	{[0 ... MAX_NR_HVC_CONSOLES - 1] = -1};
+static struct hvc_struct *cons_hvcs[MAX_NR_HVC_CONSOLES];
 
 /*
  * Console APIs, NOT TTY.  These APIs are available immediately when
@@ -151,9 +142,11 @@ static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
 static void hvc_console_print(struct console *co, const char *b,
 			      unsigned count)
 {
-	char c[N_OUTBUF] __ALIGNED__;
+	char *c;
 	unsigned i = 0, n = 0;
 	int r, donecr = 0, index = co->index;
+	unsigned long flags;
+	struct hvc_struct *hp;
 
 	/* Console access attempt outside of acceptable console range. */
 	if (index >= MAX_NR_HVC_CONSOLES)
@@ -163,6 +156,13 @@ static void hvc_console_print(struct console *co, const char *b,
 	if (vtermnos[index] == -1)
 		return;
 
+	hp = cons_hvcs[index];
+	if (!hp)
+		return;
+
+	c = hp->cons_outbuf;
+
+	spin_lock_irqsave(&hp->cons_outbuf_lock, flags);
 	while (count > 0 || i > 0) {
 		if (count > 0 && i < sizeof(c)) {
 			if (b[n] == '\n' && !donecr) {
@@ -191,6 +191,7 @@ static void hvc_console_print(struct console *co, const char *b,
 			}
 		}
 	}
+	spin_unlock_irqrestore(&hp->cons_outbuf_lock, flags);
 	hvc_console_flush(cons_ops[index], vtermnos[index]);
 }
 
@@ -878,9 +879,13 @@ static void hvc_poll_put_char(struct tty_driver *driver, int line, char ch)
 	struct tty_struct *tty = driver->ttys[0];
 	struct hvc_struct *hp = tty->driver_data;
 	int n;
+	unsigned long flags;
 
 	do {
-		n = hp->ops->put_chars(hp->vtermno, &ch, 1);
+		spin_lock_irqsave(&hp->cons_outbuf_lock, flags);
+		hp->cons_outbuf[0] = ch;
+		n = hp->ops->put_chars(hp->vtermno, &hp->cons_outbuf[0], 1);
+		spin_unlock_irqrestore(&hp->cons_outbuf_lock, flags);
 	} while (n <= 0);
 }
 #endif
@@ -922,8 +927,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
 			return ERR_PTR(err);
 	}
 
-	hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
-			GFP_KERNEL);
+	hp = kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL);
 	if (!hp)
 		return ERR_PTR(-ENOMEM);
 
@@ -931,13 +935,13 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
 	hp->data = data;
 	hp->ops = ops;
 	hp->outbuf_size = outbuf_size;
-	hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
 
 	tty_port_init(&hp->port);
 	hp->port.ops = &hvc_port_ops;
 
 	INIT_WORK(&hp->tty_resize, hvc_set_winsz);
 	spin_lock_init(&hp->lock);
+	spin_lock_init(&hp->cons_outbuf_lock);
 	mutex_lock(&hvc_structs_mutex);
 
 	/*
@@ -964,6 +968,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
 	if (i < MAX_NR_HVC_CONSOLES) {
 		cons_ops[i] = ops;
 		vtermnos[i] = vtermno;
+		cons_hvcs[i] = hp;
 	}
 
 	list_add_tail(&(hp->next), &hvc_structs);
@@ -988,6 +993,7 @@ int hvc_remove(struct hvc_struct *hp)
 	if (hp->index < MAX_NR_HVC_CONSOLES) {
 		vtermnos[hp->index] = -1;
 		cons_ops[hp->index] = NULL;
+		cons_hvcs[hp->index] = NULL;
 	}
 
 	/* Don't whack hp->irq because tty_hangup() will need to free the irq. */
diff --git a/drivers/tty/hvc/hvc_console.h b/drivers/tty/hvc/hvc_console.h
index 18d005814..2c32ab67b 100644
--- a/drivers/tty/hvc/hvc_console.h
+++ b/drivers/tty/hvc/hvc_console.h
@@ -32,12 +32,21 @@
  */
 #define HVC_ALLOC_TTY_ADAPTERS	8
 
+/*
+ * These sizes are most efficient for vio, because they are the
+ * native transfer size. We could make them selectable in the
+ * future to better deal with backends that want other buffer sizes.
+ */
+#define N_OUTBUF	16
+#define N_INBUF		16
+
+#define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))
+
 struct hvc_struct {
 	struct tty_port port;
 	spinlock_t lock;
 	int index;
 	int do_wakeup;
-	char *outbuf;
 	int outbuf_size;
 	int n_outbuf;
 	uint32_t vtermno;
@@ -48,6 +57,16 @@ struct hvc_struct {
 	struct work_struct tty_resize;
 	struct list_head next;
 	unsigned long flags;
+
+	/*
+	 * the buf and its lock are used in hvc console api for putting chars,
+	 * and also used in hvc_poll_put_char() for putting single char.
+	 */
+	spinlock_t cons_outbuf_lock;
+	char cons_outbuf[N_OUTBUF] __ALIGNED__;
+
+	/* the buf is used for putting chars to tty */
+	char outbuf[] __ALIGNED__;
 };
 
 /* implemented by a low level driver */
-- 
2.17.1


^ permalink raw reply related

* [powerpc:merge] BUILD SUCCESS 38947529bb05bbb8acfb2fe0ff96c2f1bc3f2c96
From: kernel test robot @ 2021-10-15  3:05 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git merge
branch HEAD: 38947529bb05bbb8acfb2fe0ff96c2f1bc3f2c96  Automatic merge of 'next' into merge (2021-10-11 23:09)

elapsed time: 5150m

configs tested: 276
configs skipped: 3

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

gcc tested configs:
arm                                 defconfig
arm64                            allyesconfig
arm64                               defconfig
arm                              allyesconfig
arm                              allmodconfig
i386                 randconfig-c001-20211012
i386                 randconfig-c001-20211011
i386                 randconfig-c001-20211014
mips                         tb0219_defconfig
arm                        mvebu_v7_defconfig
xtensa                  audio_kc705_defconfig
ia64                            zx1_defconfig
powerpc                     tqm8560_defconfig
sh                           se7705_defconfig
m68k                             alldefconfig
sh                              ul2_defconfig
sh                            hp6xx_defconfig
powerpc                 mpc837x_rdb_defconfig
mips                   sb1250_swarm_defconfig
sh                                  defconfig
powerpc                     mpc83xx_defconfig
sh                     sh7710voipgw_defconfig
m68k                          hp300_defconfig
arm                         at91_dt_defconfig
mips                            ar7_defconfig
arm                       cns3420vb_defconfig
sh                   secureedge5410_defconfig
powerpc                     tqm8540_defconfig
powerpc                   motionpro_defconfig
arm                           corgi_defconfig
arm                        vexpress_defconfig
powerpc                     stx_gp3_defconfig
sh                  sh7785lcr_32bit_defconfig
powerpc                      obs600_defconfig
powerpc                    gamecube_defconfig
mips                       bmips_be_defconfig
sh                           se7619_defconfig
arm                            mps2_defconfig
h8300                            allyesconfig
arm                           tegra_defconfig
mips                       lemote2f_defconfig
xtensa                  cadence_csp_defconfig
powerpc                         ps3_defconfig
powerpc                 xes_mpc85xx_defconfig
sh                ecovec24-romimage_defconfig
sparc                       sparc64_defconfig
sh                        sh7757lcr_defconfig
powerpc                   microwatt_defconfig
mips                           ci20_defconfig
openrisc                    or1ksim_defconfig
powerpc                     akebono_defconfig
arm                            qcom_defconfig
sparc                            alldefconfig
powerpc                        warp_defconfig
sh                 kfr2r09-romimage_defconfig
arm                           u8500_defconfig
powerpc                     tqm8548_defconfig
um                                  defconfig
mips                        maltaup_defconfig
parisc                generic-32bit_defconfig
microblaze                          defconfig
sh                        sh7785lcr_defconfig
mips                           ip22_defconfig
powerpc                  mpc866_ads_defconfig
powerpc                    ge_imp3a_defconfig
xtensa                generic_kc705_defconfig
ia64                             alldefconfig
nios2                         3c120_defconfig
mips                      fuloong2e_defconfig
sh                          sdk7786_defconfig
powerpc                 canyonlands_defconfig
nds32                               defconfig
mips                  cavium_octeon_defconfig
sparc                       sparc32_defconfig
powerpc                 mpc8272_ads_defconfig
powerpc                      cm5200_defconfig
m68k                        m5272c3_defconfig
riscv                    nommu_k210_defconfig
xtensa                    xip_kc705_defconfig
powerpc                 linkstation_defconfig
arc                         haps_hs_defconfig
m68k                       m5249evb_defconfig
mips                        vocore2_defconfig
m68k                       m5208evb_defconfig
ia64                         bigsur_defconfig
arc                     nsimosci_hs_defconfig
arm                      tct_hammer_defconfig
mips                       rbtx49xx_defconfig
powerpc                      pmac32_defconfig
sh                          lboxre2_defconfig
powerpc                      ep88xc_defconfig
sh                          kfr2r09_defconfig
powerpc                      mgcoge_defconfig
arm                          simpad_defconfig
powerpc                       ebony_defconfig
xtensa                           alldefconfig
powerpc                      makalu_defconfig
arm                        multi_v7_defconfig
sh                           se7721_defconfig
arm                          gemini_defconfig
powerpc                      pasemi_defconfig
m68k                         apollo_defconfig
arm                       imx_v6_v7_defconfig
sh                            migor_defconfig
xtensa                         virt_defconfig
xtensa                          iss_defconfig
h8300                               defconfig
m68k                          amiga_defconfig
powerpc                 mpc8560_ads_defconfig
arm                      footbridge_defconfig
m68k                            q40_defconfig
mips                         mpc30x_defconfig
powerpc                      ppc44x_defconfig
powerpc                 mpc832x_rdb_defconfig
powerpc                     tqm5200_defconfig
powerpc                     sequoia_defconfig
powerpc                 mpc8315_rdb_defconfig
mips                      bmips_stb_defconfig
powerpc                       eiger_defconfig
mips                            e55_defconfig
mips                        nlm_xlp_defconfig
powerpc                      tqm8xx_defconfig
powerpc                      chrp32_defconfig
arm                           spitz_defconfig
arc                      axs103_smp_defconfig
um                           x86_64_defconfig
powerpc                    klondike_defconfig
arm                            mmp2_defconfig
powerpc                        fsp2_defconfig
h8300                            alldefconfig
arm                         socfpga_defconfig
arm                          pcm027_defconfig
mips                        qi_lb60_defconfig
arm                           omap1_defconfig
m68k                           sun3_defconfig
powerpc                   bluestone_defconfig
mips                     loongson2k_defconfig
mips                     loongson1b_defconfig
mips                         db1xxx_defconfig
arc                        nsimosci_defconfig
arm                  randconfig-c002-20211014
x86_64               randconfig-c001-20211014
arm                  randconfig-c002-20211011
x86_64               randconfig-c001-20211011
arm                  randconfig-c002-20211012
x86_64               randconfig-c001-20211012
ia64                             allmodconfig
ia64                                defconfig
ia64                             allyesconfig
m68k                             allmodconfig
m68k                                defconfig
m68k                             allyesconfig
nios2                               defconfig
nds32                             allnoconfig
arc                              allyesconfig
nios2                            allyesconfig
csky                                defconfig
alpha                               defconfig
alpha                            allyesconfig
arc                                 defconfig
sh                               allmodconfig
xtensa                           allyesconfig
parisc                              defconfig
s390                                defconfig
parisc                           allyesconfig
s390                             allyesconfig
s390                             allmodconfig
sparc                            allyesconfig
sparc                               defconfig
i386                                defconfig
i386                             allyesconfig
mips                             allyesconfig
mips                             allmodconfig
powerpc                          allyesconfig
powerpc                          allmodconfig
powerpc                           allnoconfig
x86_64               randconfig-a006-20211014
x86_64               randconfig-a004-20211014
x86_64               randconfig-a001-20211014
x86_64               randconfig-a005-20211014
x86_64               randconfig-a002-20211014
x86_64               randconfig-a003-20211014
i386                 randconfig-a003-20211014
i386                 randconfig-a001-20211014
i386                 randconfig-a005-20211014
i386                 randconfig-a004-20211014
i386                 randconfig-a002-20211014
i386                 randconfig-a006-20211014
i386                 randconfig-a001-20211012
i386                 randconfig-a003-20211012
i386                 randconfig-a004-20211012
i386                 randconfig-a005-20211012
i386                 randconfig-a002-20211012
i386                 randconfig-a006-20211012
x86_64               randconfig-a015-20211011
x86_64               randconfig-a012-20211011
x86_64               randconfig-a016-20211011
x86_64               randconfig-a014-20211011
x86_64               randconfig-a013-20211011
x86_64               randconfig-a011-20211011
x86_64               randconfig-a004-20211012
x86_64               randconfig-a006-20211012
x86_64               randconfig-a001-20211012
x86_64               randconfig-a005-20211012
x86_64               randconfig-a002-20211012
x86_64               randconfig-a003-20211012
i386                 randconfig-a016-20211011
i386                 randconfig-a014-20211011
i386                 randconfig-a011-20211011
i386                 randconfig-a015-20211011
i386                 randconfig-a012-20211011
i386                 randconfig-a013-20211011
arc                  randconfig-r043-20211014
riscv                    nommu_virt_defconfig
riscv                             allnoconfig
riscv                               defconfig
riscv                          rv32_defconfig
riscv                            allyesconfig
riscv                            allmodconfig
x86_64                    rhel-8.3-kselftests
um                             i386_defconfig
x86_64                              defconfig
x86_64                               rhel-8.3
x86_64                                  kexec
x86_64                           allyesconfig

clang tested configs:
arm                  randconfig-c002-20211012
mips                 randconfig-c004-20211012
i386                 randconfig-c001-20211012
s390                 randconfig-c005-20211012
x86_64               randconfig-c007-20211012
powerpc              randconfig-c003-20211012
riscv                randconfig-c006-20211012
x86_64               randconfig-a004-20211011
x86_64               randconfig-a006-20211011
x86_64               randconfig-a001-20211011
x86_64               randconfig-a005-20211011
x86_64               randconfig-a002-20211011
x86_64               randconfig-a003-20211011
i386                 randconfig-a001-20211011
i386                 randconfig-a003-20211011
i386                 randconfig-a004-20211011
i386                 randconfig-a005-20211011
i386                 randconfig-a002-20211011
i386                 randconfig-a006-20211011
x86_64               randconfig-a015-20211012
x86_64               randconfig-a012-20211012
x86_64               randconfig-a016-20211012
x86_64               randconfig-a014-20211012
x86_64               randconfig-a013-20211012
x86_64               randconfig-a011-20211012
x86_64               randconfig-a012-20211014
x86_64               randconfig-a015-20211014
x86_64               randconfig-a016-20211014
x86_64               randconfig-a014-20211014
x86_64               randconfig-a011-20211014
x86_64               randconfig-a013-20211014
i386                 randconfig-a016-20211012
i386                 randconfig-a014-20211012
i386                 randconfig-a011-20211012
i386                 randconfig-a015-20211012
i386                 randconfig-a012-20211012
i386                 randconfig-a013-20211012
i386                 randconfig-a016-20211014
i386                 randconfig-a014-20211014
i386                 randconfig-a011-20211014
i386                 randconfig-a015-20211014
i386                 randconfig-a012-20211014
i386                 randconfig-a013-20211014
hexagon              randconfig-r041-20211012
s390                 randconfig-r044-20211012
riscv                randconfig-r042-20211012
hexagon              randconfig-r045-20211012
hexagon              randconfig-r041-20211011
hexagon              randconfig-r045-20211011
hexagon              randconfig-r041-20211014
s390                 randconfig-r044-20211014
riscv                randconfig-r042-20211014
hexagon              randconfig-r045-20211014

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

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox