Re: [PATCH v17 0/6] powerpc/crash: Kernel handling of CPU and memory hotplug

2024-02-29 Thread Sourabh Jain

Hello Baoquan,

On 29/02/24 19:21, Baoquan He wrote:

Hi Sourabh,

On 02/26/24 at 02:11pm, Sourabh Jain wrote:

Commit 247262756121 ("crash: add generic infrastructure for crash
hotplug support") added a generic infrastructure that allows
architectures to selectively update the kdump image component during CPU
or memory add/remove events within the kernel itself.

This patch series adds crash hotplug handler for PowerPC and enable
support to update the kdump image on CPU/Memory add/remove events.

Among the 5 patches in this series, the first two patches make changes
to the generic crash hotplug handler to assist PowerPC in adding support
for this feature. The last three patches add support for this feature.

The whole series looks good to me. I have acked patch 1 and 2. Leave
those three ppc patches to ppc expert to review and approve. Thanks a
lot for your great work.
Thanks for your feedback. I will soon send v18 to fix the two mirror 
document issues
and will look forward to PPC maintainers to provide feedback on the rest 
of the series.


Appreciate your support!

- Sourabh


Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Tasmiya Nalatwad

Greetings,

This is tied to gcc version. Build failure is seen while using gcc-8.5.x

On 2/29/24 20:17, Jakub Kicinski wrote:

On Thu, 29 Feb 2024 09:55:22 +0100 Eric Dumazet wrote:

I do not see other solution than this, otherwise we have to add more
pollution to include/linux/netdevice.h

Right :(


diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 
a9c973b92294bb110cf3cd336485972127b01b58..40797ea80bc6273cae6b7773d0a3e47459a72150
100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2469,7 +2469,7 @@ struct net_device {
 struct devlink_port *devlink_port;

  #if IS_ENABLED(CONFIG_DPLL)
-   struct dpll_pin __rcu   *dpll_pin;
+   void __rcu *dpll_pin;
  #endif

If DPLL wants to hide its type definitions the helpers must live
in dpll? IOW move netdev_dpll_pin() to drivers/dpll/dpll_core.c

BTW Tasmiya, please do tell us what compiler you're using.


--
Regards,
Tasmiya Nalatwad
IBM Linux Technology Center



Re: [kselftests/powerpc] Primitives test build failure with linux-next

2024-02-29 Thread Sachin Sant



> On 01-Mar-2024, at 3:48 AM, Michael Ellerman  wrote:
> 
> Sachin Sant  writes:
>> Powerpc specific selftests (specifically powerpc/primitives) included in 
>> linux-next
>> tree fails to build with following error
>> 
>> gcc -std=gnu99 -O2 -Wall -Werror 
>> -DGIT_VERSION='"next-20240229-0-gf303a3e2bcfb-dirty"' 
>> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/include  
>> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/primitives
>> load_unaligned_zeropad.c ../harness.c  -o 
>> /home/sachin/linux-next/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad
>> In file included from load_unaligned_zeropad.c:26:
>> word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or directory
>>7 | #include 
>>  |  ^~~~
>> compilation terminated.
>> 
>> The header file in question was last changed by following commit
>> 
>> commit 66a5c40f60f5d88ad8d47ba6a4ba05892853fa1f
>>kernel.h: removed REPEAT_BYTE from kernel.h
> 
> Patch below should fix it, can you please confirm?
> 
Thanks Michael. Yes, this fixes the reported problem.

Tested-by: Sachin Sant 


— Sachin

Re: Boot failure with ppc64 port on iMacs G5

2024-02-29 Thread Michael Ellerman
John Paul Adrian Glaubitz  writes:
> Hi Michael,
>
> On Thu, 2024-02-29 at 17:42 +1100, Michael Ellerman wrote:
>> > There seems to be a regression in the kernel which affects PowerPC 970 
>> > machines,
>> > i.e. PowerMac G5 CPUs. The issue needs to be bisected and reported 
>> > upstream.
>> 
>> I have a quad G5 that is booting mainline happily.
>
> it's a really tricky problem because it seems to depend on how the kernel 
> image
> is booted.
>
> It fails when trying to boot the kernel off the installation CD, i.e. like 
> from here:
>
>> https://cdimage.debian.org/cdimage/ports/snapshots/2024-02-25/debian-12.0.0-ppc64-NETINST-1.iso
>
> but the kernel will boot fine when installing in an existing system which was 
> installed
> with an installation CD which uses an older kernel.
>
>> https://cdimage.debian.org/cdimage/ports/snapshots/2023-06-18/debian-12.0.0-ppc64-NETINST-1.iso
>
> I have not really figured out yet what the problem is.

OK.

That second iso boots OK for me in qemu. It boots grub and then the
kernel loads and shows:

  Loading ...
  OF stdout device is: /pci@f000/mac-io@c/escc@13000/ch-a@13020
  Preparing to boot Linux version 6.3.0-1-powerpc64 
(debian-ker...@lists.debian.org) (gcc-12 (Debian 12.3.0-2) 12.3.0, GNU ld (GNU 
Binutils for Debian) 2.40) #1 SMP Debian 6.3.7-1 (2023-06-12)
  Detected machine type: 0400
  command line: BOOT_IMAGE=/install/vmlinux --- quiet
  memory layout at init:
memory_limit :  (16 MB aligned)
alloc_bottom : 05e7
alloc_top: 3000
alloc_top_hi : 8000
rmo_top  : 3000
ram_top  : 8000
  copying OF device tree...
  Building dt strings...
  Building dt structure...
  Device tree strings 0x05e8 -> 0x05e80560
  Device tree struct  0x05e9 -> 0x05ea
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0200 ...
  Hello World !
  smp_core99_probe
  smp_core99_bringup_done
  Starting system log daemon: syslogd, klogd.

And eventually starts the installer.

That's using no VGA, so possibly there's something wrong with the video
setup on real hardware:

  $ qemu-system-ppc64 -nographic -vga none -M mac99,via=pmu -smp 1 -m 2G -nic 
user -drive 
file=$HOME/debian-12.0.0-ppc64-NETINST-1.2023-06-18.iso,format=raw,media=cdrom 
-boot d

I'll try and find time to test it on my actual G5 next week when I'm in
the office.

cheers


Re: [netdev] Build failure on powerpc

2024-02-29 Thread Michael Ellerman
Sachin Sant  writes:
>> On 29-Feb-2024, at 7:52 AM, Michael Ellerman  wrote:
>> Tasmiya Nalatwad  writes:
>>> Greetings,
>>> 
>>> [netdev] Build failure on powerpc
>>> latest netdev 6.8.0-rc5-auto-g1ce7d306ea63 fails to build on powerpc 
>>> below traces
>> 
>> Please include the defconfig you're building, and the toolchain
>> versions, in reports like this.
>> 
>> I wasn't able to reproduce this failure here.
>
> I believe this is tied to gcc version. 
>
> Build failure is seen while using gcc-8.5.x but not with gcc-11.4.x

Thanks. Yes, I see it here with 8.4, and 9.5, but not 10.5.

cheers


Re: [kselftests/powerpc] Primitives test build failure with linux-next

2024-02-29 Thread Michael Ellerman
Andy Shevchenko  writes:
> On Thu, Feb 29, 2024 at 3:53 PM Sachin Sant  wrote:
>>
>> Powerpc specific selftests (specifically powerpc/primitives) included in 
>> linux-next
>> tree fails to build with following error
>>
>> gcc -std=gnu99 -O2 -Wall -Werror 
>> -DGIT_VERSION='"next-20240229-0-gf303a3e2bcfb-dirty"' 
>> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/include  
>> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/primitives
>> load_unaligned_zeropad.c ../harness.c  -o 
>> /home/sachin/linux-next/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad
>> In file included from load_unaligned_zeropad.c:26:
>> word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or directory
>> 7 | #include 
>>   |  ^~~~
>> compilation terminated.
>>
>> The header file in question was last changed by following commit
>>
>> commit 66a5c40f60f5d88ad8d47ba6a4ba05892853fa1f
>> kernel.h: removed REPEAT_BYTE from kernel.h
>
> Thanks for the report.
> What is missing here are the steps to reproduce it here. E.g., I have
> an x86_64 machine, I can use QEMU if required.

The patch I just posted should fix it.

Cross building the selftests is not too hard, you need a cross toolchain
with libc. There's some instructions on our wiki[1], the tldr is:

  cd ~/tmp
  wget 
https://toolchains.bootlin.com/downloads/releases/toolchains/powerpc64le-power8/tarballs/powerpc64le-power8--glibc--stable-2023.11-1.tar.bz2
  tar -xf powerpc64le-power8--glibc--stable-2023.11-1.tar.bz2
  export 
CROSS_COMPILE=$PWD/powerpc64le-power8--glibc--stable-2023.11-1/bin/powerpc64le-linux-
  cd ~/src/linux
  export ARCH=powerpc
  make defconfig
  make headers
  make -C tools/testing/selftests/powerpc

cheers

1: https://github.com/linuxppc/wiki/wiki/Building-powerpc-kernels


Re: [kselftests/powerpc] Primitives test build failure with linux-next

2024-02-29 Thread Michael Ellerman
Sachin Sant  writes:
> Powerpc specific selftests (specifically powerpc/primitives) included in 
> linux-next
> tree fails to build with following error
>
> gcc -std=gnu99 -O2 -Wall -Werror 
> -DGIT_VERSION='"next-20240229-0-gf303a3e2bcfb-dirty"' 
> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/include  
> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/primitives
> load_unaligned_zeropad.c ../harness.c  -o 
> /home/sachin/linux-next/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad
> In file included from load_unaligned_zeropad.c:26:
> word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or directory
> 7 | #include 
>   |  ^~~~
> compilation terminated.
>
> The header file in question was last changed by following commit
>
> commit 66a5c40f60f5d88ad8d47ba6a4ba05892853fa1f
> kernel.h: removed REPEAT_BYTE from kernel.h

Patch below should fix it, can you please confirm?

cheers


>From f165de102de33704a54b892b689630bfa9a79132 Mon Sep 17 00:00:00 2001
From: Michael Ellerman 
Date: Fri, 1 Mar 2024 09:16:31 +1100
Subject: [PATCH] Fix word-at-a-time test failure

---
 tools/testing/selftests/powerpc/primitives/linux/bitops.h   | 0
 tools/testing/selftests/powerpc/primitives/linux/wordpart.h | 1 +
 2 files changed, 1 insertion(+)
 create mode 100644 tools/testing/selftests/powerpc/primitives/linux/bitops.h
 create mode 12 tools/testing/selftests/powerpc/primitives/linux/wordpart.h

diff --git a/tools/testing/selftests/powerpc/primitives/linux/bitops.h 
b/tools/testing/selftests/powerpc/primitives/linux/bitops.h
new file mode 100644
index ..e69de29bb2d1
diff --git a/tools/testing/selftests/powerpc/primitives/linux/wordpart.h 
b/tools/testing/selftests/powerpc/primitives/linux/wordpart.h
new file mode 12
index ..4a74d2cbbc9b
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/linux/wordpart.h
@@ -0,0 +1 @@
+../../../../../../include/linux/wordpart.h
\ No newline at end of file
-- 
2.43.0



[PATCH 1/1] PCI: layerscape(ep): Implement common 'dbi' reg-names for dbi_base

2024-02-29 Thread Frank Li
Apply 'dbi' as the primary name for dbi_base register space in line with
Designware common binding. Attempt resource acquisition using 'dbi' first
via platform_get_resource_byname(). If encountering older device tree
files, gracefully fallback to 'regs', issuing a warning message.

Signed-off-by: Frank Li 
---
 drivers/pci/controller/dwc/pci-layerscape-ep.c | 7 ++-
 drivers/pci/controller/dwc/pci-layerscape.c| 7 ++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c 
b/drivers/pci/controller/dwc/pci-layerscape-ep.c
index 1f6ee1460ec2a..92d4750611d07 100644
--- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
+++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c
@@ -259,7 +259,12 @@ static int __init ls_pcie_ep_probe(struct platform_device 
*pdev)
pcie->pci = pci;
pcie->ls_epc = ls_epc;
 
-   dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+   dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
+   if (!dbi_base) {
+   dev_warn(dev, "Please update your dtb, reg-names 'regs' should 
be 'dbi'");
+   dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, 
"regs");
+   }
+
pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base);
if (IS_ERR(pci->dbi_base))
return PTR_ERR(pci->dbi_base);
diff --git a/drivers/pci/controller/dwc/pci-layerscape.c 
b/drivers/pci/controller/dwc/pci-layerscape.c
index ee6f525681337..1985086f6a1f3 100644
--- a/drivers/pci/controller/dwc/pci-layerscape.c
+++ b/drivers/pci/controller/dwc/pci-layerscape.c
@@ -345,7 +345,12 @@ static int ls_pcie_probe(struct platform_device *pdev)
pcie->pci = pci;
pci->pp.ops = pcie->drvdata->ops;
 
-   dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+   dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
+   if (!dbi_base) {
+   dev_err(dev, "Please update your dtb, reg-names 'regs' should 
be 'dbi'");
+   dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, 
"regs");
+   }
+
pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base);
if (IS_ERR(pci->dbi_base))
return PTR_ERR(pci->dbi_base);
-- 
2.34.1



Re: [PATCH 5/5] powerpc: Remove cpu-as-y completely

2024-02-29 Thread Segher Boessenkool
On Thu, Feb 29, 2024 at 11:25:21PM +1100, Michael Ellerman wrote:
> From: Christophe Leroy 

Acked-by: Segher Boessenkool 


Segher


Re: [PATCH 4/5] powerpc/fsl: Modernise mt/mfpmr

2024-02-29 Thread Segher Boessenkool
On Thu, Feb 29, 2024 at 11:25:20PM +1100, Michael Ellerman wrote:
> With the addition of the machine directives, these are no longer simple
> 1-2 liner macros. So modernise them to be static inlines and use named
> asm parameters.
> 
> Signed-off-by: Michael Ellerman 

You got rid of the __stringify blight as well.  Great :-)

Acked-by: Segher Boessenkool 


Segher


Re: [PATCH 2/5] powerpc/64s: Use .machine power4 around dcbt

2024-02-29 Thread Segher Boessenkool
On Thu, Feb 29, 2024 at 11:25:18PM +1100, Michael Ellerman wrote:
> There are multiple decodings for the "dcbt" mnemonic, so the assembler
> has to pick one.
> 
> That requires passing -many to the assembler, which is not recommended.
> 
> Without -many the clang 14 / binutils 2.38 build fails with:
> 
>   arch/powerpc/kernel/exceptions-64s.S:2976: Error: junk at end of line: 
> `0b01010'
>   clang: error: assembler command failed with exit code 1 (use -v to see 
> invocation)
> 
> Fix it by adding .machine directives around the use of dcbt to specify
> which encoding is desired.
> 
> Signed-off-by: Michael Ellerman 

Looks good, thanks!

Acked-by: Segher Boessenkool 


Segher


Re: [kselftests/powerpc] Primitives test build failure with linux-next

2024-02-29 Thread Andy Shevchenko
On Thu, Feb 29, 2024 at 3:53 PM Sachin Sant  wrote:
>
> Powerpc specific selftests (specifically powerpc/primitives) included in 
> linux-next
> tree fails to build with following error
>
> gcc -std=gnu99 -O2 -Wall -Werror 
> -DGIT_VERSION='"next-20240229-0-gf303a3e2bcfb-dirty"' 
> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/include  
> -I/home/sachin/linux-next/tools/testing/selftests/powerpc/primitives
> load_unaligned_zeropad.c ../harness.c  -o 
> /home/sachin/linux-next/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad
> In file included from load_unaligned_zeropad.c:26:
> word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or directory
> 7 | #include 
>   |  ^~~~
> compilation terminated.
>
> The header file in question was last changed by following commit
>
> commit 66a5c40f60f5d88ad8d47ba6a4ba05892853fa1f
> kernel.h: removed REPEAT_BYTE from kernel.h

Thanks for the report.
What is missing here are the steps to reproduce it here. E.g., I have
an x86_64 machine, I can use QEMU if required.

-- 
With Best Regards,
Andy Shevchenko


Re: BUG: Bad page map in process init pte:c0ab684c pmd:01182000 (on a PowerMac G4 DP)

2024-02-29 Thread Christophe Leroy


Le 29/02/2024 à 02:09, Erhard Furtner a écrit :
> On Mon, 12 Dec 2022 14:31:35 +1000
> "Nicholas Piggin"  wrote:
> 
>> On Thu Dec 1, 2022 at 7:44 AM AEST, Erhard F. wrote:
>>> Getting this at boot sometimes, but not always (PowerMac G4 DP, kernel 
>>> 6.0.9):
>>>
>>> [...]
>>> Freeing unused kernel image (initmem) memory: 1328K
>>> Checked W+X mappings: passed, no W+X pages found
>>> rodata_test: all tests were successful
>>> Run /sbin/init as init process
>>> _swap_info_get: Bad swap file entry 24c0ab68
>>> BUG: Bad page map in process init  pte:c0ab684c pmd:01182000
>>
>> Have you run memtest on the system? Are the messages related to a
>> kernel upgrade? This and your KASAN bugs look possibly like random
>> corruption.
>>
>> Although with that KASAN one it's strange that kernfs_node_cache
>> was involved both times, it's strange that page tables are pointing
>> to that same slab memory. It could be a page table page use-after
>> -free maybe? Maybe with the page table fragment code. I'm sure other
>> people would have hit that before though, so I don't know what to
>> suggest.
>>
>> Thanks,
>> Nick
> 
> Revisited the issue on kernel v6.8-rc6 and I can still reproduce it.
> 
> Short summary as my last post was over a year ago:
>   (x) I get this memory corruption only when CONFIG_VMAP_STACK=y and 
> CONFIG_SMP=y is enabled.
>   (x) I don't get this memory corruption when only one of the above is 
> enabled. ^^
>   (x) memtester says the 2 GiB RAM in my G4 DP are fine.
>   (x) I don't get this issue on my G5 11,2 or Talos II.
>   (x) "stress -m 2 --vm-bytes 965M" provokes the issue in < 10 secs. 
> (https://salsa.debian.org/debian/stress)
> 
> For the test I used CONFIG_KASAN_INLINE=y for v6.8-rc6 and 
> debug_pagealloc=on, page_owner=on and got this dmesg:
> 
> [...]
> pagealloc: memory corruption
> f5fcfff0: 00 00 00 00  
> CPU: 1 PID: 1788 Comm: stress Tainted: GB  6.8.0-rc6-PMacG4 
> #15
> Hardware name: PowerMac3,6 7455 0x80010303 PowerMac
> Call Trace:
> [f3bfbac0] [c162a8e8] dump_stack_lvl+0x60/0x94 (unreliable)
> [f3bfbae0] [c04edf9c] __kernel_unpoison_pages+0x1e0/0x1f0
> [f3bfbb30] [c04a8aa0] post_alloc_hook+0xe0/0x174
> [f3bfbb60] [c04a8b58] prep_new_page+0x24/0xbc
> [f3bfbb80] [c04abcc4] get_page_from_freelist+0xcd0/0xf10
> [f3bfbc50] [c04aecd8] __alloc_pages+0x204/0xe2c
> [f3bfbda0] [c04b07a8] __folio_alloc+0x18/0x88
> [f3bfbdc0] [c0461a10] vma_alloc_zeroed_movable_folio.isra.0+0x2c/0x6c
> [f3bfbde0] [c046bb90] handle_mm_fault+0x91c/0x19ac
> [f3bfbec0] [c0047b8c] ___do_page_fault+0x93c/0xc14
> [f3bfbf10] [c0048278] do_page_fault+0x28/0x60
> [f3bfbf30] [c000433c] DataAccess_virt+0x124/0x17c
> --- interrupt: 300 at 0xbe30d8
> NIP:  00be30d8 LR: 00be30b4 CTR: 
> REGS: f3bfbf40 TRAP: 0300   Tainted: GB   (6.8.0-rc6-PMacG4)
> MSR:  d032   CR: 20882464  XER: 
> DAR: 88c7a010 DSISR: 4200
> GPR00: 00be30b4 af8397d0 a78436c0 6b2ee010 3c50 20224462 fe77f7e1 00b00264
> GPR08: 1d98d000 1d98c000  40ae256a 20882262 00b4  
> GPR16:  0002  005a 40802262 80002262 40002262 00c000a4
> GPR24:   3c50   6b2ee010 00c07d64 1000
> NIP [00be30d8] 0xbe30d8
> LR [00be30b4] 0xbe30b4
> --- interrupt: 300
> page:ef4bd92c refcount:1 mapcount:0 mapping: index:0x1 pfn:0x310b3
> flags: 0x8000(zone=2)
> page_type: 0x()
> raw: 8000 0100 0122  0001   0001
> raw: 
> page dumped because: pagealloc: corrupted page details
> page_owner info is not present (never set?)
> swapper/1: page allocation failure: order:0, mode:0x820(GFP_ATOMIC), 
> nodemask=(null),cpuset=/,mems_allowed=0
> CPU: 1 PID: 0 Comm: swapper/1 Tainted: GB  6.8.0-rc6-PMacG4 
> #15
> Hardware name: PowerMac3,6 7455 0x80010303 PowerMac
> Call Trace:
> [f101b9d0] [c162a8e8] dump_stack_lvl+0x60/0x94 (unreliable)
> [f101b9f0] [c04ae948] warn_alloc+0x154/0x2e0
> [f101bab0] [c04af030] __alloc_pages+0x55c/0xe2c
> SLUB: Unable to allocate memory on node -1, gfp=0x820(GFP_ATOMIC)
>cache: skbuff_head_cache, object size: 176, buffer size: 288, default 
> order: 0, min order: 0
>node 0: slabs: 509, objs: 7126, free: 0
> SLUB: Unable to allocate memory on node -1, gfp=0x820(GFP_ATOMIC)
>cache: skbuff_head_cache, object size: 176, buffer size: 288, default 
> order: 0, min order: 0
>node 0: slabs: 509, objs: 7126, free: 0
> SLUB: Unable to allocate memory on node -1, gfp=0x820(GFP_ATOMIC)
>cache: skbuff_head_cache, object size: 176, buffer size: 288, default 
> order: 0, min order: 0
>node 0: slabs: 509, objs: 7126, free: 0
> SLUB: Unable to allocate memory on node -1, gfp=0x820(GFP_ATOMIC)
>cache: skbuff_head_cache, object size: 176, buffer size: 288, default 
> order: 0, min order: 0
>node 0: slabs: 509, objs: 7126, free: 0
> SLUB: Unable to allocate memory on node -1, 

Re: [PATCH v5 4/5] net: wan: fsl_qmc_hdlc: Add runtime timeslots changes support

2024-02-29 Thread Herve Codina
Hi Andy,

On Thu, 29 Feb 2024 17:20:59 +0200
Andy Shevchenko  wrote:

> On Thu, Feb 29, 2024 at 03:15:52PM +0100, Herve Codina wrote:
> > QMC channels support runtime timeslots changes but nothing is done at
> > the QMC HDLC driver to handle these changes.
> > 
> > Use existing IFACE ioctl in order to configure the timeslots to use.  
> 
> ...
> 
> > +   bitmap_scatter(ts_mask, map, ts_mask_avail, 64);  
> 
> Wondering if we may have returned value more useful and hence having 
> something like
> 
>   n = bitmap_scatter(...);

I thought about it.

In bitmap_{scatter,gather}(dst, src, mask, nbits), only returning the
weight of the third parameter (i.e. mask) can be efficient regarding to the
for_each_set_bit() loop done in the functions.
For dst parameter, we need to add a counter in the loop to count the number
of bit set depending on the test_bit() result. Will this be more efficient
than a call to bitmap_weight() ?

Also, in my case, the third parameter is ts_mask_avail and I don't need
its weight.

I thing users that need to have the dst or src weight should call
bitmap_weight() themselves as this is users context dependent.

bitmap_{scatter,gather}(dst, src, mask, nbits) can be improved later with
no impact to current users (except performance).

That's why I concluded to return nothing from bitmap_{scatter,gather} when
I took the old existing patches.

> 
> > +   if (bitmap_weight(ts_mask, 64) != bitmap_weight(map, 64)) {  
> 
>   if (n != ...) {
> 
> ?
> 
> > +   dev_err(qmc_hdlc->dev, "Cannot translate timeslots %64pb -> 
> > (%64pb, %64pb)\n",
> > +   map, ts_mask_avail, ts_mask);
> > +   return -EINVAL;
> > +   }  
> 
> ...
> 
> > +   bitmap_gather(map, ts_mask, ts_mask_avail, 64);
> > +
> > +   if (bitmap_weight(ts_mask, 64) != bitmap_weight(map, 64)) {
> > +   dev_err(qmc_hdlc->dev, "Cannot translate timeslots (%64pb, 
> > %64pb) -> %64pb\n",
> > +   ts_mask_avail, ts_mask, map);
> > +   return -EINVAL;
> > +   }  
> 
> Ditto.
> 

Best regards,
Hervé


Re: [PATCH] powerpc: Add allmodconfig for all 32-bit sub-arches

2024-02-29 Thread Uwe Kleine-König
On Thu, Feb 29, 2024 at 10:41:08PM +1100, Michael Ellerman wrote:
> 32-bit powerpc kernels can be built for one of 5 sub-arches, see
> Kconfig.cputype:
> 
>   PPC_BOOK3S_32: "512x/52xx/6xx/7xx/74xx/82xx/83xx/86xx"
>   PPC_85xx: "Freescale 85xx"
>   PPC_8xx: "Freescale 8xx"
>   40x: "AMCC 40x"
>   44x: "AMCC 44x, 46x or 47x"
> 
> By default none of these are built for a plain allmodconfig build,
> because it selects PPC64 which builds a 64-bit kernel.
> 
> There is already a ppc32_allmodconfig, which enables PPC_BOOK3S_32.
> 
> Add similar targets for the other 32-bit sub-arches to increase build
> coverage:
>   ppc40x_allmodconfig
>   ppc44x_allmodconfig
>   ppc8xx_allmodconfig
>   ppc85xx_allmodconfig
> 
> Signed-off-by: Michael Ellerman 

\o/

Acked-by: Uwe Kleine-König 

Thanks
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | https://www.pengutronix.de/ |


signature.asc
Description: PGP signature


Re: [PATCH v5 0/5] Add support for QMC HDLC

2024-02-29 Thread Andy Shevchenko
On Thu, Feb 29, 2024 at 03:15:48PM +0100, Herve Codina wrote:
> Hi,
> 
> This series introduces the QMC HDLC support.
> 
> Patches were previously sent as part of a full feature series and were
> previously reviewed in that context:
> "Add support for QMC HDLC, framer infrastructure and PEF2256 framer" [1]
> 
> In order to ease the merge, the full feature series has been split and
> needed parts were merged in v6.8-rc1:
>  - "Prepare the PowerQUICC QMC and TSA for the HDLC QMC driver" [2]
>  - "Add support for framer infrastructure and PEF2256 framer" [3]
> 
> This series contains patches related to the QMC HDLC part (QMC HDLC
> driver):
>  - Introduce the QMC HDLC driver (patches 1 and 2)
>  - Add timeslots change support in QMC HDLC (patch 3)
>  - Add framer support as a framer consumer in QMC HDLC (patch 4)
> 
> Compare to the original full feature series, a modification was done on
> patch 3 in order to use a coherent prefix in the commit title.
> 
> I kept the patches unsquashed as they were previously sent and reviewed.
> Of course, I can squash them if needed.

I think it's a good series and next version will be final. The only question is
possible use of the returned values from bitmap_scatter()/bitmap_gather(), the
rest are minors.

Feel free to add
Reviewed-by: Andy Shevchenko 
to patches 4 and 5.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v5 4/5] net: wan: fsl_qmc_hdlc: Add runtime timeslots changes support

2024-02-29 Thread Andy Shevchenko
On Thu, Feb 29, 2024 at 03:15:52PM +0100, Herve Codina wrote:
> QMC channels support runtime timeslots changes but nothing is done at
> the QMC HDLC driver to handle these changes.
> 
> Use existing IFACE ioctl in order to configure the timeslots to use.

...

> + bitmap_scatter(ts_mask, map, ts_mask_avail, 64);

Wondering if we may have returned value more useful and hence having something 
like

n = bitmap_scatter(...);

> + if (bitmap_weight(ts_mask, 64) != bitmap_weight(map, 64)) {

if (n != ...) {

?

> + dev_err(qmc_hdlc->dev, "Cannot translate timeslots %64pb -> 
> (%64pb, %64pb)\n",
> + map, ts_mask_avail, ts_mask);
> + return -EINVAL;
> + }

...

> + bitmap_gather(map, ts_mask, ts_mask_avail, 64);
> +
> + if (bitmap_weight(ts_mask, 64) != bitmap_weight(map, 64)) {
> + dev_err(qmc_hdlc->dev, "Cannot translate timeslots (%64pb, 
> %64pb) -> %64pb\n",
> + ts_mask_avail, ts_mask, map);
> + return -EINVAL;
> + }

Ditto.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v5 3/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers

2024-02-29 Thread Andy Shevchenko
On Thu, Feb 29, 2024 at 03:15:51PM +0100, Herve Codina wrote:
> From: Andy Shevchenko 
> 
> These helpers scatters or gathers a bitmap with the help of the mask
> position bits parameter.
> 
> bitmap_scatter() does the following:
>   src:  01011010
>   ||
>+--+|
>|  ++
>|  |++|||
>|  ||   +-+||
>|  ||   |  ||
>   mask: ...v..vv...v..vv
> ...0..11...0..10
>   dst:  00110010
> 
> and bitmap_gather() performs this one:
>mask: ...v..vv...v..vv
>src:  00110010
> ^  ^^   ^   0
> |  ||   |  10
> |  ||   > 010
> |  |+--> 1010
> |  +--> 11010
> +> 011010
>dst:  00011010
> 
> bitmap_gather() can the seen as the reverse bitmap_scatter() operation.

> The original work was done by Andy Shevchenko.

As I said, it's too much credit :-)

...

> + * A relationship exists between bitmap_gather() and bitmap_scatter(). See
> + * bitmap_scatter() for the bitmap scatter detailed operations.
> + * Suppose scattered computed using bitmap_scatter(scattered, src, mask, n).
> + * The operation bitmap_gather(result, scattered, mask, n) leads to a result
> + * equal or equivalent to src.
> + *
> + * The result can be 'equivalent' because bitmap_scatter() and 
> bitmap_gather()
> + * are not bijective.
> + * The result and src values are equivalent in that sense that a call to

> + * bitmap_scatter(res, src, mask, n) and a call to bitmap_scatter(res, 
> result,
> + * mask, n) will lead to the same res value.

For better readability I wouldn't break API calls, hence

 The result and src values are equivalent in that sense that a call to
 bitmap_scatter(res, src, mask, n) and a call to
 bitmap_scatter(res, result, mask, n) will lead to the same res value.

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH v5 1/5] net: wan: Add support for QMC HDLC

2024-02-29 Thread Andy Shevchenko
On Thu, Feb 29, 2024 at 03:15:49PM +0100, Herve Codina wrote:
> The QMC HDLC driver provides support for HDLC using the QMC (QUICC
> Multichannel Controller) to transfer the HDLC data.

...

+ array_size.h
+ bug.h

> +#include 
> +#include 

+ device.h
+ err.h

> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

+ spinlock.h
+ types.h

With this fixed (below is up to you),
Reviewed-by: Andy Shevchenko 

...

> +free_desc:
> + qmc_chan_reset(qmc_hdlc->qmc_chan, QMC_CHAN_ALL);
> + for (i = 0; i < ARRAY_SIZE(qmc_hdlc->rx_descs); i++) {

I'm wondering what prevents you from doing

while (i--) {

> + desc = _hdlc->rx_descs[i];

> + if (!desc->skb)
> + continue;

...and probably get rid of this check?

> + dma_unmap_single(qmc_hdlc->dev, desc->dma_addr, desc->dma_size,
> +  DMA_FROM_DEVICE);
> + kfree_skb(desc->skb);
> + desc->skb = NULL;
> + }

-- 
With Best Regards,
Andy Shevchenko




Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Eric Dumazet
On Thu, Feb 29, 2024 at 3:53 PM Eric Dumazet  wrote:
>
> On Thu, Feb 29, 2024 at 3:47 PM Jakub Kicinski  wrote:
> >
> > On Thu, 29 Feb 2024 09:55:22 +0100 Eric Dumazet wrote:
> > > I do not see other solution than this, otherwise we have to add more
> > > pollution to include/linux/netdevice.h
> >
> > Right :(
> >
> > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > > index 
> > > a9c973b92294bb110cf3cd336485972127b01b58..40797ea80bc6273cae6b7773d0a3e47459a72150
> > > 100644
> > > --- a/include/linux/netdevice.h
> > > +++ b/include/linux/netdevice.h
> > > @@ -2469,7 +2469,7 @@ struct net_device {
> > > struct devlink_port *devlink_port;
> > >
> > >  #if IS_ENABLED(CONFIG_DPLL)
> > > -   struct dpll_pin __rcu   *dpll_pin;
> > > +   void __rcu *dpll_pin;
> > >  #endif
> >
> > If DPLL wants to hide its type definitions the helpers must live
> > in dpll? IOW move netdev_dpll_pin() to drivers/dpll/dpll_core.c
>
> Oh for some reason I thought this stuff was a module.
>
> Otherwise, why having dpll 'core' helpers in net/core/dev.c

So, we would have something a bit convoluted like :

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 
4c2bb27c99fe4e517b0d92c4ae3db83a679c7d11..241db366b2c74ae749f49612d86176b2f8f479c1
100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -42,6 +42,11 @@ struct dpll_pin_registration {
void *priv;
 };

+struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
+{
+   return rcu_dereference_rtnl(dev->dpll_pin);
+}
+
 struct dpll_device *dpll_device_get_by_id(int id)
 {
if (xa_get_mark(_device_xa, id, DPLL_REGISTERED))
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 
4ec2fe9caf5a3f284afd0cfe4fc7c2bf42cbbc60..c60591308ae80fb99aa5abb5832b9a228473a916
100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -169,13 +169,13 @@ int dpll_device_change_ntf(struct dpll_device *dpll);

 int dpll_pin_change_ntf(struct dpll_pin *pin);

+#if !IS_ENABLED(CONFIG_DPLL)
 static inline struct dpll_pin *netdev_dpll_pin(const struct net_device *dev)
 {
-#if IS_ENABLED(CONFIG_DPLL)
-   return rcu_dereference_rtnl(dev->dpll_pin);
-#else
return NULL;
-#endif
 }
+#else
+struct dpll_pin *netdev_dpll_pin(const struct net_device *dev);
+#endif

 #endif


Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Eric Dumazet
On Thu, Feb 29, 2024 at 3:47 PM Jakub Kicinski  wrote:
>
> On Thu, 29 Feb 2024 09:55:22 +0100 Eric Dumazet wrote:
> > I do not see other solution than this, otherwise we have to add more
> > pollution to include/linux/netdevice.h
>
> Right :(
>
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index 
> > a9c973b92294bb110cf3cd336485972127b01b58..40797ea80bc6273cae6b7773d0a3e47459a72150
> > 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2469,7 +2469,7 @@ struct net_device {
> > struct devlink_port *devlink_port;
> >
> >  #if IS_ENABLED(CONFIG_DPLL)
> > -   struct dpll_pin __rcu   *dpll_pin;
> > +   void __rcu *dpll_pin;
> >  #endif
>
> If DPLL wants to hide its type definitions the helpers must live
> in dpll? IOW move netdev_dpll_pin() to drivers/dpll/dpll_core.c

Oh for some reason I thought this stuff was a module.

Otherwise, why having dpll 'core' helpers in net/core/dev.c


Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Jakub Kicinski
On Thu, 29 Feb 2024 09:55:22 +0100 Eric Dumazet wrote:
> I do not see other solution than this, otherwise we have to add more
> pollution to include/linux/netdevice.h

Right :(

> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 
> a9c973b92294bb110cf3cd336485972127b01b58..40797ea80bc6273cae6b7773d0a3e47459a72150
> 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2469,7 +2469,7 @@ struct net_device {
> struct devlink_port *devlink_port;
> 
>  #if IS_ENABLED(CONFIG_DPLL)
> -   struct dpll_pin __rcu   *dpll_pin;
> +   void __rcu *dpll_pin;
>  #endif

If DPLL wants to hide its type definitions the helpers must live
in dpll? IOW move netdev_dpll_pin() to drivers/dpll/dpll_core.c

BTW Tasmiya, please do tell us what compiler you're using.


[PATCH v5 5/5] net: wan: fsl_qmc_hdlc: Add framer support

2024-02-29 Thread Herve Codina
Add framer support in the fsl_qmc_hdlc driver in order to be able to
signal carrier changes to the network stack based on the framer status
Also use this framer to provide information related to the E1/T1 line
interface on IF_GET_IFACE and configure the line interface according to
IF_IFACE_{E1,T1} information.

Signed-off-by: Herve Codina 
Reviewed-by: Christophe Leroy 
---
 drivers/net/wan/fsl_qmc_hdlc.c | 239 -
 1 file changed, 234 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wan/fsl_qmc_hdlc.c b/drivers/net/wan/fsl_qmc_hdlc.c
index 80998ad89088..dd6b69a950c9 100644
--- a/drivers/net/wan/fsl_qmc_hdlc.c
+++ b/drivers/net/wan/fsl_qmc_hdlc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -29,6 +30,9 @@ struct qmc_hdlc {
struct device *dev;
struct qmc_chan *qmc_chan;
struct net_device *netdev;
+   struct framer *framer;
+   spinlock_t carrier_lock; /* Protect carrier detection */
+   struct notifier_block nb;
bool is_crc32;
spinlock_t tx_lock; /* Protect tx descriptors */
struct qmc_hdlc_desc tx_descs[8];
@@ -42,6 +46,192 @@ static struct qmc_hdlc *netdev_to_qmc_hdlc(struct 
net_device *netdev)
return dev_to_hdlc(netdev)->priv;
 }
 
+static int qmc_hdlc_framer_set_carrier(struct qmc_hdlc *qmc_hdlc)
+{
+   struct framer_status framer_status;
+   int ret;
+
+   if (!qmc_hdlc->framer)
+   return 0;
+
+   guard(spinlock_irqsave)(_hdlc->carrier_lock);
+
+   ret = framer_get_status(qmc_hdlc->framer, _status);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "get framer status failed (%d)\n", ret);
+   return ret;
+   }
+   if (framer_status.link_is_on)
+   netif_carrier_on(qmc_hdlc->netdev);
+   else
+   netif_carrier_off(qmc_hdlc->netdev);
+
+   return 0;
+}
+
+static int qmc_hdlc_framer_notifier(struct notifier_block *nb, unsigned long 
action,
+   void *data)
+{
+   struct qmc_hdlc *qmc_hdlc = container_of(nb, struct qmc_hdlc, nb);
+   int ret;
+
+   if (action != FRAMER_EVENT_STATUS)
+   return NOTIFY_DONE;
+
+   ret = qmc_hdlc_framer_set_carrier(qmc_hdlc);
+   return ret ? NOTIFY_DONE : NOTIFY_OK;
+}
+
+static int qmc_hdlc_framer_start(struct qmc_hdlc *qmc_hdlc)
+{
+   struct framer_status framer_status;
+   int ret;
+
+   if (!qmc_hdlc->framer)
+   return 0;
+
+   ret = framer_power_on(qmc_hdlc->framer);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "framer power-on failed (%d)\n", ret);
+   return ret;
+   }
+
+   /* Be sure that get_status is supported */
+   ret = framer_get_status(qmc_hdlc->framer, _status);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "get framer status failed (%d)\n", ret);
+   goto framer_power_off;
+   }
+
+   qmc_hdlc->nb.notifier_call = qmc_hdlc_framer_notifier;
+   ret = framer_notifier_register(qmc_hdlc->framer, _hdlc->nb);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "framer notifier register failed 
(%d)\n", ret);
+   goto framer_power_off;
+   }
+
+   return 0;
+
+framer_power_off:
+   framer_power_off(qmc_hdlc->framer);
+   return ret;
+}
+
+static void qmc_hdlc_framer_stop(struct qmc_hdlc *qmc_hdlc)
+{
+   if (!qmc_hdlc->framer)
+   return;
+
+   framer_notifier_unregister(qmc_hdlc->framer, _hdlc->nb);
+   framer_power_off(qmc_hdlc->framer);
+}
+
+static int qmc_hdlc_framer_set_iface(struct qmc_hdlc *qmc_hdlc, int if_iface,
+const te1_settings *te1)
+{
+   struct framer_config config;
+   int ret;
+
+   if (!qmc_hdlc->framer)
+   return 0;
+
+   ret = framer_get_config(qmc_hdlc->framer, );
+   if (ret)
+   return ret;
+
+   switch (if_iface) {
+   case IF_IFACE_E1:
+   config.iface = FRAMER_IFACE_E1;
+   break;
+   case IF_IFACE_T1:
+   config.iface = FRAMER_IFACE_T1;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   switch (te1->clock_type) {
+   case CLOCK_DEFAULT:
+   /* Keep current value */
+   break;
+   case CLOCK_EXT:
+   config.clock_type = FRAMER_CLOCK_EXT;
+   break;
+   case CLOCK_INT:
+   config.clock_type = FRAMER_CLOCK_INT;
+   break;
+   default:
+   return -EINVAL;
+   }
+   config.line_clock_rate = te1->clock_rate;
+
+   return framer_set_config(qmc_hdlc->framer, );
+}
+
+static int qmc_hdlc_framer_get_iface(struct qmc_hdlc *qmc_hdlc, int *if_iface, 
te1_settings *te1)
+{
+   struct framer_config config;
+   int ret;
+
+   if (!qmc_hdlc->framer) {
+   *if_iface = IF_IFACE_E1;
+

[PATCH v5 4/5] net: wan: fsl_qmc_hdlc: Add runtime timeslots changes support

2024-02-29 Thread Herve Codina
QMC channels support runtime timeslots changes but nothing is done at
the QMC HDLC driver to handle these changes.

Use existing IFACE ioctl in order to configure the timeslots to use.

Signed-off-by: Herve Codina 
Reviewed-by: Christophe Leroy 
Acked-by: Jakub Kicinski 
---
 drivers/net/wan/fsl_qmc_hdlc.c | 151 -
 1 file changed, 150 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/fsl_qmc_hdlc.c b/drivers/net/wan/fsl_qmc_hdlc.c
index b9e067101171..80998ad89088 100644
--- a/drivers/net/wan/fsl_qmc_hdlc.c
+++ b/drivers/net/wan/fsl_qmc_hdlc.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,6 +34,7 @@ struct qmc_hdlc {
struct qmc_hdlc_desc tx_descs[8];
unsigned int tx_out;
struct qmc_hdlc_desc rx_descs[4];
+   u32 slot_map;
 };
 
 static struct qmc_hdlc *netdev_to_qmc_hdlc(struct net_device *netdev)
@@ -197,6 +199,144 @@ static netdev_tx_t qmc_hdlc_xmit(struct sk_buff *skb, 
struct net_device *netdev)
return NETDEV_TX_OK;
 }
 
+static int qmc_hdlc_xlate_slot_map(struct qmc_hdlc *qmc_hdlc,
+  u32 slot_map, struct qmc_chan_ts_info 
*ts_info)
+{
+   DECLARE_BITMAP(ts_mask_avail, 64);
+   DECLARE_BITMAP(ts_mask, 64);
+   DECLARE_BITMAP(map, 64);
+
+   /* Tx and Rx available masks must be identical */
+   if (ts_info->rx_ts_mask_avail != ts_info->tx_ts_mask_avail) {
+   dev_err(qmc_hdlc->dev, "tx and rx available timeslots mismatch 
(0x%llx, 0x%llx)\n",
+   ts_info->rx_ts_mask_avail, ts_info->tx_ts_mask_avail);
+   return -EINVAL;
+   }
+
+   bitmap_from_u64(ts_mask_avail, ts_info->rx_ts_mask_avail);
+   bitmap_from_u64(map, slot_map);
+   bitmap_scatter(ts_mask, map, ts_mask_avail, 64);
+
+   if (bitmap_weight(ts_mask, 64) != bitmap_weight(map, 64)) {
+   dev_err(qmc_hdlc->dev, "Cannot translate timeslots %64pb -> 
(%64pb, %64pb)\n",
+   map, ts_mask_avail, ts_mask);
+   return -EINVAL;
+   }
+
+   bitmap_to_arr64(_info->tx_ts_mask, ts_mask, 64);
+   ts_info->rx_ts_mask = ts_info->tx_ts_mask;
+   return 0;
+}
+
+static int qmc_hdlc_xlate_ts_info(struct qmc_hdlc *qmc_hdlc,
+ const struct qmc_chan_ts_info *ts_info, u32 
*slot_map)
+{
+   DECLARE_BITMAP(ts_mask_avail, 64);
+   DECLARE_BITMAP(ts_mask, 64);
+   DECLARE_BITMAP(map, 64);
+   u32 array32[2];
+
+   /* Tx and Rx masks and available masks must be identical */
+   if (ts_info->rx_ts_mask_avail != ts_info->tx_ts_mask_avail) {
+   dev_err(qmc_hdlc->dev, "tx and rx available timeslots mismatch 
(0x%llx, 0x%llx)\n",
+   ts_info->rx_ts_mask_avail, ts_info->tx_ts_mask_avail);
+   return -EINVAL;
+   }
+   if (ts_info->rx_ts_mask != ts_info->tx_ts_mask) {
+   dev_err(qmc_hdlc->dev, "tx and rx timeslots mismatch (0x%llx, 
0x%llx)\n",
+   ts_info->rx_ts_mask, ts_info->tx_ts_mask);
+   return -EINVAL;
+   }
+
+   bitmap_from_u64(ts_mask_avail, ts_info->rx_ts_mask_avail);
+   bitmap_from_u64(ts_mask, ts_info->rx_ts_mask);
+   bitmap_gather(map, ts_mask, ts_mask_avail, 64);
+
+   if (bitmap_weight(ts_mask, 64) != bitmap_weight(map, 64)) {
+   dev_err(qmc_hdlc->dev, "Cannot translate timeslots (%64pb, 
%64pb) -> %64pb\n",
+   ts_mask_avail, ts_mask, map);
+   return -EINVAL;
+   }
+
+   bitmap_to_arr32(array32, map, 64);
+   if (array32[1]) {
+   dev_err(qmc_hdlc->dev, "Slot map out of 32bit (%64pb, %64pb) -> 
%64pb\n",
+   ts_mask_avail, ts_mask, map);
+   return -EINVAL;
+   }
+
+   *slot_map = array32[0];
+   return 0;
+}
+
+static int qmc_hdlc_set_iface(struct qmc_hdlc *qmc_hdlc, int if_iface, const 
te1_settings *te1)
+{
+   struct qmc_chan_ts_info ts_info;
+   int ret;
+
+   ret = qmc_chan_get_ts_info(qmc_hdlc->qmc_chan, _info);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "get QMC channel ts info failed %d\n", 
ret);
+   return ret;
+   }
+   ret = qmc_hdlc_xlate_slot_map(qmc_hdlc, te1->slot_map, _info);
+   if (ret)
+   return ret;
+
+   ret = qmc_chan_set_ts_info(qmc_hdlc->qmc_chan, _info);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "set QMC channel ts info failed %d\n", 
ret);
+   return ret;
+   }
+
+   qmc_hdlc->slot_map = te1->slot_map;
+
+   return 0;
+}
+
+static int qmc_hdlc_ioctl(struct net_device *netdev, struct if_settings *ifs)
+{
+   struct qmc_hdlc *qmc_hdlc = netdev_to_qmc_hdlc(netdev);
+   te1_settings te1;
+
+   switch (ifs->type) {
+   case IF_GET_IFACE:
+   ifs->type = IF_IFACE_E1;
+   if (ifs->size < sizeof(te1)) {
+ 

[PATCH v5 3/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers

2024-02-29 Thread Herve Codina
From: Andy Shevchenko 

These helpers scatters or gathers a bitmap with the help of the mask
position bits parameter.

bitmap_scatter() does the following:
  src:  01011010
  ||
   +--+|
   |  ++
   |  |++|||
   |  ||   +-+||
   |  ||   |  ||
  mask: ...v..vv...v..vv
...0..11...0..10
  dst:  00110010

and bitmap_gather() performs this one:
   mask: ...v..vv...v..vv
   src:  00110010
^  ^^   ^   0
|  ||   |  10
|  ||   > 010
|  |+--> 1010
|  +--> 11010
+> 011010
   dst:  00011010

bitmap_gather() can the seen as the reverse bitmap_scatter() operation.

The original work was done by Andy Shevchenko.

Signed-off-by: Andy Shevchenko 
Link: 
https://lore.kernel.org/lkml/20230926052007.3917389-3-andriy.shevche...@linux.intel.com/
Co-developed-by: Herve Codina 
Signed-off-by: Herve Codina 
---
 include/linux/bitmap.h | 101 +
 lib/test_bitmap.c  |  42 +
 2 files changed, 143 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 99451431e4d6..6d3f6ff1b4d6 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -62,6 +62,8 @@ struct device;
  *  bitmap_shift_left(dst, src, n, nbits)   *dst = *src << n
  *  bitmap_cut(dst, src, first, n, nbits)   Cut n bits from first, copy 
rest
  *  bitmap_replace(dst, old, new, mask, nbits)  *dst = (*old & ~(*mask)) | 
(*new & *mask)
+ *  bitmap_scatter(dst, src, mask, nbits)  *dst = map(dense, sparse)(src)
+ *  bitmap_gather(dst, src, mask, nbits)   *dst = map(sparse, dense)(src)
  *  bitmap_remap(dst, src, old, new, nbits) *dst = map(old, new)(src)
  *  bitmap_bitremap(oldbit, old, new, nbits)newbit = map(old, new)(oldbit)
  *  bitmap_onto(dst, orig, relmap, nbits)   *dst = orig relative to relmap
@@ -487,6 +489,105 @@ static inline void bitmap_replace(unsigned long *dst,
__bitmap_replace(dst, old, new, mask, nbits);
 }
 
+/**
+ * bitmap_scatter - Scatter a bitmap according to the given mask
+ * @dst: scattered bitmap
+ * @src: gathered bitmap
+ * @mask: mask representing bits to assign to in the scattered bitmap
+ * @nbits: number of bits in each of these bitmaps
+ *
+ * Scatters bitmap with sequential bits according to the given @mask.
+ *
+ * Example:
+ * If @src bitmap = 0x005a, with @mask = 0x1313, @dst will be 0x0302.
+ *
+ * Or in binary form
+ * @src@mask   @dst
+ * 01011010000100110001001100110010
+ *
+ * (Bits 0, 1, 2, 3, 4, 5 are copied to the bits 0, 1, 4, 8, 9, 12)
+ *
+ * A more 'visual' description of the operation:
+ * src:  01011010
+ * ||
+ *  +--+|
+ *  |  ++
+ *  |  |++|||
+ *  |  ||   +-+||
+ *  |  ||   |  ||
+ * mask: ...v..vv...v..vv
+ *   ...0..11...0..10
+ * dst:  00110010
+ *
+ * A relationship exists between bitmap_scatter() and bitmap_gather().
+ * bitmap_gather() can be seen as the 'reverse' bitmap_scatter() operation.
+ * See bitmap_scatter() for details related to this relationship.
+ */
+static inline void bitmap_scatter(unsigned long *dst, const unsigned long *src,
+ const unsigned long *mask, unsigned int nbits)
+{
+   unsigned int n = 0;
+   unsigned int bit;
+
+   bitmap_zero(dst, nbits);
+
+   for_each_set_bit(bit, mask, nbits)
+   __assign_bit(bit, dst, test_bit(n++, src));
+}
+
+/**
+ * bitmap_gather - Gather a bitmap according to given mask
+ * @dst: gathered bitmap
+ * @src: scattered bitmap
+ * @mask: mask representing bits to extract from in the scattered bitmap
+ * @nbits: number of bits in each of these bitmaps
+ *
+ * Gathers bitmap with sparse bits according to the given @mask.
+ *
+ * Example:
+ * If @src bitmap = 0x0302, with @mask = 0x1313, @dst will be 0x001a.
+ *
+ * Or in binary form
+ * @src@mask   @dst
+ * 00110010000100110001001100011010
+ *
+ * (Bits 0, 1, 4, 8, 9, 12 are copied to the bits 0, 1, 2, 3, 4, 5)
+ *
+ * A more 'visual' description of the operation:
+ * mask: ...v..vv...v..vv
+ * src:  00110010
+ *  ^  ^^   ^   0
+ *  |  ||   |  10
+ *  |  ||   > 010
+ *  |  |+--> 1010
+ *  |  +--> 11010
+ *  +> 011010
+ * dst:  00011010
+ *
+ * A relationship exists between bitmap_gather() and bitmap_scatter(). See
+ * bitmap_scatter() for the bitmap scatter detailed operations.
+ * Suppose scattered computed using bitmap_scatter(scattered, src, mask, n).
+ * The operation bitmap_gather(result, scattered, mask, n) leads to a result
+ * equal or equivalent to src.
+ *
+ * The result can be 'equivalent' because bitmap_scatter() and 

[PATCH v5 2/5] MAINTAINERS: Add the Freescale QMC HDLC driver entry

2024-02-29 Thread Herve Codina
After contributing the driver, add myself as the maintainer for the
Freescale QMC HDLC driver.

Signed-off-by: Herve Codina 
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 8d1052fa6a69..15cd3a8e5866 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8584,6 +8584,13 @@ F:   
Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,cpm1-scc-qmc.yaml
 F: drivers/soc/fsl/qe/qmc.c
 F: include/soc/fsl/qe/qmc.h
 
+FREESCALE QUICC ENGINE QMC HDLC DRIVER
+M: Herve Codina 
+L: net...@vger.kernel.org
+L: linuxppc-dev@lists.ozlabs.org
+S: Maintained
+F: drivers/net/wan/fsl_qmc_hdlc.c
+
 FREESCALE QUICC ENGINE TSA DRIVER
 M: Herve Codina 
 L: linuxppc-dev@lists.ozlabs.org
-- 
2.43.0



[PATCH v5 1/5] net: wan: Add support for QMC HDLC

2024-02-29 Thread Herve Codina
The QMC HDLC driver provides support for HDLC using the QMC (QUICC
Multichannel Controller) to transfer the HDLC data.

Signed-off-by: Herve Codina 
Reviewed-by: Christophe Leroy 
Acked-by: Jakub Kicinski 
---
 drivers/net/wan/Kconfig|  12 +
 drivers/net/wan/Makefile   |   1 +
 drivers/net/wan/fsl_qmc_hdlc.c | 409 +
 3 files changed, 422 insertions(+)
 create mode 100644 drivers/net/wan/fsl_qmc_hdlc.c

diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 7dda87756d3f..31ab2136cdf1 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -197,6 +197,18 @@ config FARSYNC
  To compile this driver as a module, choose M here: the
  module will be called farsync.
 
+config FSL_QMC_HDLC
+   tristate "Freescale QMC HDLC support"
+   depends on HDLC
+   depends on CPM_QMC
+   help
+ HDLC support using the Freescale QUICC Multichannel Controller (QMC).
+
+ To compile this driver as a module, choose M here: the
+ module will be called fsl_qmc_hdlc.
+
+ If unsure, say N.
+
 config FSL_UCC_HDLC
tristate "Freescale QUICC Engine HDLC support"
depends on HDLC
diff --git a/drivers/net/wan/Makefile b/drivers/net/wan/Makefile
index 8119b49d1da9..00e9b7ee1e01 100644
--- a/drivers/net/wan/Makefile
+++ b/drivers/net/wan/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_WANXL)   += wanxl.o
 obj-$(CONFIG_PCI200SYN)+= pci200syn.o
 obj-$(CONFIG_PC300TOO) += pc300too.o
 obj-$(CONFIG_IXP4XX_HSS)   += ixp4xx_hss.o
+obj-$(CONFIG_FSL_QMC_HDLC) += fsl_qmc_hdlc.o
 obj-$(CONFIG_FSL_UCC_HDLC) += fsl_ucc_hdlc.o
 obj-$(CONFIG_SLIC_DS26522) += slic_ds26522.o
 
diff --git a/drivers/net/wan/fsl_qmc_hdlc.c b/drivers/net/wan/fsl_qmc_hdlc.c
new file mode 100644
index ..b9e067101171
--- /dev/null
+++ b/drivers/net/wan/fsl_qmc_hdlc.c
@@ -0,0 +1,409 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Freescale QMC HDLC Device Driver
+ *
+ * Copyright 2023 CS GROUP France
+ *
+ * Author: Herve Codina 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct qmc_hdlc_desc {
+   struct net_device *netdev;
+   struct sk_buff *skb; /* NULL if the descriptor is not in use */
+   dma_addr_t dma_addr;
+   size_t dma_size;
+};
+
+struct qmc_hdlc {
+   struct device *dev;
+   struct qmc_chan *qmc_chan;
+   struct net_device *netdev;
+   bool is_crc32;
+   spinlock_t tx_lock; /* Protect tx descriptors */
+   struct qmc_hdlc_desc tx_descs[8];
+   unsigned int tx_out;
+   struct qmc_hdlc_desc rx_descs[4];
+};
+
+static struct qmc_hdlc *netdev_to_qmc_hdlc(struct net_device *netdev)
+{
+   return dev_to_hdlc(netdev)->priv;
+}
+
+static int qmc_hdlc_recv_queue(struct qmc_hdlc *qmc_hdlc, struct qmc_hdlc_desc 
*desc, size_t size);
+
+#define QMC_HDLC_RX_ERROR_FLAGS\
+   (QMC_RX_FLAG_HDLC_OVF | QMC_RX_FLAG_HDLC_UNA |  \
+QMC_RX_FLAG_HDLC_CRC | QMC_RX_FLAG_HDLC_ABORT)
+
+static void qmc_hcld_recv_complete(void *context, size_t length, unsigned int 
flags)
+{
+   struct qmc_hdlc_desc *desc = context;
+   struct net_device *netdev = desc->netdev;
+   struct qmc_hdlc *qmc_hdlc = netdev_to_qmc_hdlc(netdev);
+   int ret;
+
+   dma_unmap_single(qmc_hdlc->dev, desc->dma_addr, desc->dma_size, 
DMA_FROM_DEVICE);
+
+   if (flags & QMC_HDLC_RX_ERROR_FLAGS) {
+   netdev->stats.rx_errors++;
+   if (flags & QMC_RX_FLAG_HDLC_OVF) /* Data overflow */
+   netdev->stats.rx_over_errors++;
+   if (flags & QMC_RX_FLAG_HDLC_UNA) /* bits received not multiple 
of 8 */
+   netdev->stats.rx_frame_errors++;
+   if (flags & QMC_RX_FLAG_HDLC_ABORT) /* Received an abort 
sequence */
+   netdev->stats.rx_frame_errors++;
+   if (flags & QMC_RX_FLAG_HDLC_CRC) /* CRC error */
+   netdev->stats.rx_crc_errors++;
+   kfree_skb(desc->skb);
+   } else {
+   netdev->stats.rx_packets++;
+   netdev->stats.rx_bytes += length;
+
+   skb_put(desc->skb, length);
+   desc->skb->protocol = hdlc_type_trans(desc->skb, netdev);
+   netif_rx(desc->skb);
+   }
+
+   /* Re-queue a transfer using the same descriptor */
+   ret = qmc_hdlc_recv_queue(qmc_hdlc, desc, desc->dma_size);
+   if (ret) {
+   dev_err(qmc_hdlc->dev, "queue recv desc failed (%d)\n", ret);
+   netdev->stats.rx_errors++;
+   }
+}
+
+static int qmc_hdlc_recv_queue(struct qmc_hdlc *qmc_hdlc, struct qmc_hdlc_desc 
*desc, size_t size)
+{
+   int ret;
+
+   desc->skb = dev_alloc_skb(size);
+   if (!desc->skb)
+   return -ENOMEM;
+
+   desc->dma_size = size;
+   desc->dma_addr = 

[PATCH v5 0/5] Add support for QMC HDLC

2024-02-29 Thread Herve Codina
Hi,

This series introduces the QMC HDLC support.

Patches were previously sent as part of a full feature series and were
previously reviewed in that context:
"Add support for QMC HDLC, framer infrastructure and PEF2256 framer" [1]

In order to ease the merge, the full feature series has been split and
needed parts were merged in v6.8-rc1:
 - "Prepare the PowerQUICC QMC and TSA for the HDLC QMC driver" [2]
 - "Add support for framer infrastructure and PEF2256 framer" [3]

This series contains patches related to the QMC HDLC part (QMC HDLC
driver):
 - Introduce the QMC HDLC driver (patches 1 and 2)
 - Add timeslots change support in QMC HDLC (patch 3)
 - Add framer support as a framer consumer in QMC HDLC (patch 4)

Compare to the original full feature series, a modification was done on
patch 3 in order to use a coherent prefix in the commit title.

I kept the patches unsquashed as they were previously sent and reviewed.
Of course, I can squash them if needed.

Compared to the previous iteration:
  
https://lore.kernel.org/linux-kernel/20240222142219.441767-1-herve.cod...@bootlin.com/
this v5 series mainly:
- Update some piece of code to improve readability.
- Release resources before printing error messages.
- Use 'struct device *dev' and dev_err_probe() in probe().
- Use guard() and scoped_guard() from cleanup.h for spinlock locking.

Best regards,
Hervé

[1]: 
https://lore.kernel.org/linux-kernel/20231115144007.478111-1-herve.cod...@bootlin.com/
[2]: 
https://lore.kernel.org/linux-kernel/20231205152116.122512-1-herve.cod...@bootlin.com/
[3]: 
https://lore.kernel.org/linux-kernel/20231128132534.258459-1-herve.cod...@bootlin.com/

Changes v4 -> v5
  - Patch 1
Update QMC_HDLC_RX_ERROR_FLAGS to improve readability.
Display an error message after releasing resources instead of
before.
Use 'struct device *dev' in probe().
Use dev_err_probe() in probe().
Do not print a message on -ENOMEM.
Use guard() and scoped_guard().

  - Patch 3
Use '(). See' constructing in kernel-doc instead of '() (See ...'
Add 'Co-developed-by: Herve Codina '

  - Patch 4
Use 'struct device *dev' in probe().
Use dev_err_probe() in probe().
Use '%64pb' instead of '%*pb' in printk formats.

  - Patch 5
Use 'struct device *dev' in probe().
Use guard()

Changes v3 -> v4
  - Patch 1
Remove of.h and of_platform.h includes, add mod_devicetable.h.
Add a blank line in the includes list.

  - Path 2
No changes.

  - v3 patches 3 and 4 removed

  - Patch 3 (new patch in v4)
Introduce bitmap_{scatter,gather}() based on the original patch done
by Andy Shevchenko.
Address comments already done on the original patch:

https://lore.kernel.org/lkml/20230926052007.3917389-3-andriy.shevche...@linux.intel.com/
  - Removed the returned values.
  - Used 'unsigned int' for all indexes.
  - Added a 'visual' description of the operations in kernel-doc.
  - Described the relationship between bitmap_scatter() and
bitmap_gather().
  - Moved bitmap_{scatter,gather}() to the bitmap.h file.
  - Improved bitmap_{scatter,gather}() test.
  - Reworked the commit log.

  - Patch 4 (v3 patch 5)
Use bitmap_{scatter,gather}()

  - Patches 5 (v3 patch 6)
No changes.

Changes v2 -> v3
  - Patch 1
Remove 'inline' function specifier from .c file.
Fix a bug introduced when added WARN_ONCE(). The warn condition must
be desc->skb (descriptor used) instead of !desc->skb.
Remove a lock/unlock section locking the entire qmc_hdlc_xmit()
function.

  - Patch 5
Use bitmap_from_u64() everywhere instead of bitmap_from_arr32() and
bitmap_from_arr64().

Changes v1 -> v2
  - Patch 1
Use the same qmc_hdlc initialisation in qmc_hcld_recv_complete()
than the one present in qmc_hcld_xmit_complete().
Use WARN_ONCE()

  - Patch 3 (new patch in v2)
Make bitmap_onto() available to users

  - Patch 4 (new patch in v2)
Introduce bitmap_off()

  - Patch 5 (patch 3 in v1)
Use bitmap_*() functions

  - Patch 6 (patch 4 in v1)
No changes

Changes compare to the full feature series:
  - Patch 3
Use 'net: wan: fsl_qmc_hdlc:' as commit title prefix

Patches extracted:
  - Patch 1 : full feature series patch 7
  - Patch 2 : full feature series patch 8
  - Patch 3 : full feature series patch 20
  - Patch 4 : full feature series patch 27

Andy Shevchenko (1):
  lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers

Herve Codina (4):
  net: wan: Add support for QMC HDLC
  MAINTAINERS: Add the Freescale QMC HDLC driver entry
  net: wan: fsl_qmc_hdlc: Add runtime timeslots changes support
  net: wan: fsl_qmc_hdlc: Add framer support

 MAINTAINERS|   7 +
 drivers/net/wan/Kconfig|  12 +
 drivers/net/wan/Makefile   |   1 +
 drivers/net/wan/fsl_qmc_hdlc.c | 787 +
 include/linux/bitmap.h | 101 +
 lib/test_bitmap.c  |  42 ++
 6 files 

Re: [PATCH v4 5/5] net: wan: fsl_qmc_hdlc: Add framer support

2024-02-29 Thread Herve Codina
On Thu, 29 Feb 2024 15:58:06 +0200
Andy Shevchenko  wrote:

> On Thu, Feb 29, 2024 at 01:56:05PM +0100, Herve Codina wrote:
> > On Thu, 22 Feb 2024 17:49:40 +0200
> > Andy Shevchenko  wrote:  
> > > On Thu, Feb 22, 2024 at 03:22:18PM +0100, Herve Codina wrote:  
> 
> ...
> 
> > I've got an issue with guard(spinlock_irqsave).  
> 
> No, you got an issue with sparse.
> 
> > I have the following warning (make C=1):
> > drivers/net/wan/fsl_qmc_hdlc.c:49:12: warning: context imbalance in 
> > 'qmc_hdlc_framer_set_carrier' - wrong count at exit
> > 
> > I also tried to call guard(spinlock_irqsave) before 'if (!qmc_hdlc->framer)'
> > but it does not change anything.
> > 
> > Did I miss something in the guard(spinlock_irqsave) usage ?  
> 
> You may ignore that for now. Not your problem, no problem in the code.
> 
> https://lore.kernel.org/linux-sparse/8d596a06-9f25-4d9f-8282-deb2d03a6b0a@moroto.mountain/
> 

Perfect, thanks.

Hervé


Re: [PATCH v4 5/5] net: wan: fsl_qmc_hdlc: Add framer support

2024-02-29 Thread Andy Shevchenko
On Thu, Feb 29, 2024 at 01:56:05PM +0100, Herve Codina wrote:
> On Thu, 22 Feb 2024 17:49:40 +0200
> Andy Shevchenko  wrote:
> > On Thu, Feb 22, 2024 at 03:22:18PM +0100, Herve Codina wrote:

...

> I've got an issue with guard(spinlock_irqsave).

No, you got an issue with sparse.

> I have the following warning (make C=1):
> drivers/net/wan/fsl_qmc_hdlc.c:49:12: warning: context imbalance in 
> 'qmc_hdlc_framer_set_carrier' - wrong count at exit
> 
> I also tried to call guard(spinlock_irqsave) before 'if (!qmc_hdlc->framer)'
> but it does not change anything.
> 
> Did I miss something in the guard(spinlock_irqsave) usage ?

You may ignore that for now. Not your problem, no problem in the code.

https://lore.kernel.org/linux-sparse/8d596a06-9f25-4d9f-8282-deb2d03a6b0a@moroto.mountain/

-- 
With Best Regards,
Andy Shevchenko




[kselftests/powerpc] Primitives test build failure with linux-next

2024-02-29 Thread Sachin Sant
Powerpc specific selftests (specifically powerpc/primitives) included in 
linux-next
tree fails to build with following error

gcc -std=gnu99 -O2 -Wall -Werror 
-DGIT_VERSION='"next-20240229-0-gf303a3e2bcfb-dirty"' 
-I/home/sachin/linux-next/tools/testing/selftests/powerpc/include  
-I/home/sachin/linux-next/tools/testing/selftests/powerpc/primitives
load_unaligned_zeropad.c ../harness.c  -o 
/home/sachin/linux-next/tools/testing/selftests/powerpc/primitives/load_unaligned_zeropad
In file included from load_unaligned_zeropad.c:26:
word-at-a-time.h:7:10: fatal error: linux/bitops.h: No such file or directory
7 | #include 
  |  ^~~~
compilation terminated.

The header file in question was last changed by following commit

commit 66a5c40f60f5d88ad8d47ba6a4ba05892853fa1f
kernel.h: removed REPEAT_BYTE from kernel.h

Thanks
— Sachin

Re: [PATCH v17 0/6] powerpc/crash: Kernel handling of CPU and memory hotplug

2024-02-29 Thread Baoquan He
Hi Sourabh,

On 02/26/24 at 02:11pm, Sourabh Jain wrote:
> Commit 247262756121 ("crash: add generic infrastructure for crash
> hotplug support") added a generic infrastructure that allows
> architectures to selectively update the kdump image component during CPU
> or memory add/remove events within the kernel itself.
> 
> This patch series adds crash hotplug handler for PowerPC and enable
> support to update the kdump image on CPU/Memory add/remove events.
> 
> Among the 5 patches in this series, the first two patches make changes
> to the generic crash hotplug handler to assist PowerPC in adding support
> for this feature. The last three patches add support for this feature.

The whole series looks good to me. I have acked patch 1 and 2. Leave
those three ppc patches to ppc expert to review and approve. Thanks a
lot for your great work.

Thanks
Baoquan



Re: [PATCH 2/3] selftest/powerpc: Add flags.mk to support pmu buildable

2024-02-29 Thread Sachin Sant



> On 29-Feb-2024, at 3:07 PM, Madhavan Srinivasan  wrote:
> 
> When running `make -C powerpc/pmu run_tests` from top level selftests
> directory, currently this error is being reported
> 
> make: Entering directory 
> '/home/maddy/linux/tools/testing/selftests/powerpc/pmu'
> Makefile:40: warning: overriding recipe for target 'emit_tests'
> ../../lib.mk:111: warning: ignoring old recipe for target 'emit_tests'
> gcc -m64count_instructions.c ../harness.c event.c lib.c ../utils.c loop.S 
>  -o /home/maddy/selftest_output//count_instructions
> In file included from count_instructions.c:13:
> event.h:12:10: fatal error: utils.h: No such file or directory
> 12 | #include "utils.h"
>  |  ^
> compilation terminated.
> 
> This is due to missing of include path in CFLAGS. That is, CFLAGS and
> GIT_VERSION macros are defined in the powerpc/ folder Makefile which
> in this case not involved.
> 
> To address the failure incase of executing specific sub-folder test directly,
> a new rule file has been addded by the patch called "flags.mk" under
> selftest/powerpc/ folder and is linked to all the Makefile of powerpc/pmu
> sub-folders.
> 
> Reported-by: Sachin Sant 
> Signed-off-by: Madhavan Srinivasan 
> ---

Fixes the reported problem for me.

Tested-by: Sachin Sant 

While at it, FWIW I have also tested the remaining 2 patches and
no problems were seen.

For the other 2 patches in the series

Tested-by: Sachin Sant 

— Sachin

Re: [netdev] Build failure on powerpc

2024-02-29 Thread Sachin Sant



> On 29-Feb-2024, at 7:52 AM, Michael Ellerman  wrote:
> 
> Tasmiya Nalatwad  writes:
>> Greetings,
>> 
>> [netdev] Build failure on powerpc
>> latest netdev 6.8.0-rc5-auto-g1ce7d306ea63 fails to build on powerpc 
>> below traces
> 
> Please include the defconfig you're building, and the toolchain
> versions, in reports like this.
> 
> I wasn't able to reproduce this failure here.

I believe this is tied to gcc version. 

Build failure is seen while using gcc-8.5.x but not with gcc-11.4.x

— Sachin


Re: [PATCH v8 10/10] PCI: dwc: ep: Add Kernel-doc comments for APIs

2024-02-29 Thread Niklas Cassel
Hello Mani,

On Sat, Feb 24, 2024 at 12:24:16PM +0530, Manivannan Sadhasivam wrote:
> All of the APIs are missing the Kernel-doc comments. Hence, add them.
> 
> Signed-off-by: Manivannan Sadhasivam 
> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 92 
> +
>  1 file changed, 92 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
> b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index fed4c2936c78..cdcb33a279db 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c

(snip)

> @@ -556,6 +606,12 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 
> func_no,
>   return 0;
>  }
>  
> +/**
> + * dw_pcie_ep_cleanup - Cleanup DWC EP resources
> + * @ep: DWC EP device
> + *
> + * Cleans up the DWC EP specific resources like eDMA etc...

I think that you should mention that this is only for glue drivers that
use PERST# handling, so that other glue drivers do no start using it :)


> + */
>  void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
>  {
>   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> @@ -564,6 +620,13 @@ void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
>  }
>  EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup);


Kind regards,
Niklas


Re: [PATCH v4 5/5] net: wan: fsl_qmc_hdlc: Add framer support

2024-02-29 Thread Herve Codina
Hi Andy,

On Thu, 22 Feb 2024 17:49:40 +0200
Andy Shevchenko  wrote:

> On Thu, Feb 22, 2024 at 03:22:18PM +0100, Herve Codina wrote:
> > Add framer support in the fsl_qmc_hdlc driver in order to be able to
> > signal carrier changes to the network stack based on the framer status
> > Also use this framer to provide information related to the E1/T1 line
> > interface on IF_GET_IFACE and configure the line interface according to
> > IF_IFACE_{E1,T1} information.  
> 
> ...
> 
> > +static int qmc_hdlc_framer_set_carrier(struct qmc_hdlc *qmc_hdlc)
> > +{
> > +   struct framer_status framer_status;
> > +   unsigned long flags;
> > +   int ret;
> > +
> > +   if (!qmc_hdlc->framer)
> > +   return 0;  
> 
> > +   spin_lock_irqsave(_hdlc->carrier_lock, flags);  
> 
> cleanup.h ?
> 
> > +   ret = framer_get_status(qmc_hdlc->framer, _status);
> > +   if (ret) {
> > +   dev_err(qmc_hdlc->dev, "get framer status failed (%d)\n", ret);
> > +   goto end;
> > +   }
> > +   if (framer_status.link_is_on)
> > +   netif_carrier_on(qmc_hdlc->netdev);
> > +   else
> > +   netif_carrier_off(qmc_hdlc->netdev);
> > +
> > +end:
> > +   spin_unlock_irqrestore(_hdlc->carrier_lock, flags);
> > +   return ret;
> > +}  
> 

I've got an issue with guard(spinlock_irqsave).

I changed this code to:
--- 8< ---
static int qmc_hdlc_framer_set_carrier(struct qmc_hdlc *qmc_hdlc)
{
struct framer_status framer_status;
int ret;

if (!qmc_hdlc->framer)
return 0;

guard(spinlock_irqsave)(_hdlc->carrier_lock);

ret = framer_get_status(qmc_hdlc->framer, _status);
if (ret) {
dev_err(qmc_hdlc->dev, "get framer status failed (%d)\n", ret);
return ret;
}
if (framer_status.link_is_on)
netif_carrier_on(qmc_hdlc->netdev);
else
netif_carrier_off(qmc_hdlc->netdev);

return 0;
}
--- 8< ---

I have the following warning (make C=1):
drivers/net/wan/fsl_qmc_hdlc.c:49:12: warning: context imbalance in 
'qmc_hdlc_framer_set_carrier' - wrong count at exit

I also tried to call guard(spinlock_irqsave) before 'if (!qmc_hdlc->framer)'
but it does not change anything.

Did I miss something in the guard(spinlock_irqsave) usage ?

Best regards,
Hervé


Re: [PATCH v8 03/10] PCI: dwc: ep: Introduce dw_pcie_ep_cleanup() API for drivers supporting PERST#

2024-02-29 Thread Niklas Cassel
On Sat, Feb 24, 2024 at 12:24:09PM +0530, Manivannan Sadhasivam wrote:
> For DWC glue drivers supporting PERST# (currently Qcom and Tegra194), some
> of the DWC resources like eDMA should be cleaned up during the PERST#
> assert time.
> 
> So let's introduce a dw_pcie_ep_cleanup() API that could be called by these
> drivers to cleanup the DWC specific resources. Currently, it just removes
> eDMA.
> 
> Reported-by: Niklas Cassel 
> Closes: https://lore.kernel.org/linux-pci/ZWYmX8Y%2F7Q9WMxES@x1-carbon
> Signed-off-by: Manivannan Sadhasivam 
> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 11 +--
>  drivers/pci/controller/dwc/pcie-designware.h|  5 +
>  drivers/pci/controller/dwc/pcie-qcom-ep.c   |  1 +
>  drivers/pci/controller/dwc/pcie-tegra194.c  |  2 ++
>  4 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
> b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 2b11290aab4c..1205bfba8310 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -564,12 +564,19 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 
> func_no,
>   return 0;
>  }
>  
> -void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
> +void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
>  {
>   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> - struct pci_epc *epc = ep->epc;
>  
>   dw_pcie_edma_remove(pci);

Hello Mani,

In this message:
https://lore.kernel.org/linux-pci/20240130062938.GB32821@thinkpad/

You mentioned that you were going to clean up the BARs.
(Like I wrote in that thread, I really think that we should merge a fix for
the broken "do we have a saved value from find_first_zero_bit() in the array",
by using a "if (!saved_value[bar])", when find_first_zero_bit() returns zero.)

However, regardless of that, I do not see that this series (neither
dw_pcie_ep_cleanup(), nor dw_pcie_ep_linkdown()), calls any function which
will clean up the BARs.

Since e.g. qcom-ep.c does a reset_control_assert() during perst
assert/deassert, which should clear sticky registers, I think that
you should let dw_pcie_ep_cleanup() clean up the BARs using
dw_pcie_ep_clear_bar().


Kind regards,
Niklas


> +}
> +EXPORT_SYMBOL_GPL(dw_pcie_ep_cleanup);
> +
> +void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
> +{
> + struct pci_epc *epc = ep->epc;
> +
> + dw_pcie_ep_cleanup(ep);
>  
>   pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem,
> epc->mem->window.page_size);
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h 
> b/drivers/pci/controller/dwc/pcie-designware.h
> index 61465203bb60..351d2fe3ea4d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -672,6 +672,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep);
>  int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep);
>  void dw_pcie_ep_init_notify(struct dw_pcie_ep *ep);
>  void dw_pcie_ep_deinit(struct dw_pcie_ep *ep);
> +void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep);
>  int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no);
>  int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
>u8 interrupt_num);
> @@ -705,6 +706,10 @@ static inline void dw_pcie_ep_deinit(struct dw_pcie_ep 
> *ep)
>  {
>  }
>  
> +static inline void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
> +{
> +}
> +
>  static inline int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 
> func_no)
>  {
>   return 0;
> diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c 
> b/drivers/pci/controller/dwc/pcie-qcom-ep.c
> index 36e5e80cd22f..59b1c0110288 100644
> --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c
> @@ -507,6 +507,7 @@ static void qcom_pcie_perst_assert(struct dw_pcie *pci)
>   return;
>   }
>  
> + dw_pcie_ep_cleanup(>ep);
>   qcom_pcie_disable_resources(pcie_ep);
>   pcie_ep->link_status = QCOM_PCIE_EP_LINK_DISABLED;
>  }
> diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c 
> b/drivers/pci/controller/dwc/pcie-tegra194.c
> index 7afa9e9aabe2..68bfeed3429b 100644
> --- a/drivers/pci/controller/dwc/pcie-tegra194.c
> +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
> @@ -1715,6 +1715,8 @@ static void pex_ep_event_pex_rst_assert(struct 
> tegra_pcie_dw *pcie)
>   if (ret)
>   dev_err(pcie->dev, "Failed to go Detect state: %d\n", ret);
>  
> + dw_pcie_ep_cleanup(>pci.ep);
> +
>   reset_control_assert(pcie->core_rst);
>  
>   tegra_pcie_disable_phy(pcie);
> 
> -- 
> 2.25.1
> 


[PATCH v2] powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks

2024-02-29 Thread Kajol Jain
Running event 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/
in one of the system throws below error:

 ---Logs---
 # perf list | grep 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles
  
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=?/[Kernel
 PMU event]

 # perf stat -v -e 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/
 sleep 2
Using CPUID 00800200
Control descriptor is not initialized
Warning:
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/
 event is not supported by the kernel.
failed to read counter 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/

 Performance counter stats for 'system wide':

 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/

   2.000700771 seconds time elapsed

The above error is because of the hcall failure as required
permission "Enable Performance Information Collection" is not set.
Based on current code, single_gpci_request function did not check the
error type incase hcall fails and by default returns EINVAL. But we can
have other reasons for hcall failures like H_AUTHORITY/H_PARAMETER with
detail_rc as GEN_BUF_TOO_SMALL, for which we need to act accordingly.

Fix this issue by adding new checks in the single_gpci_request and
h_gpci_event_init functions.

Result after fix patch changes:

 # perf stat -e 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/
 sleep 2
Error:
No permission to enable 
hv_gpci/dispatch_timebase_by_processor_processor_time_in_timebase_cycles,phys_processor_idx=0/
 event.

Fixes: 220a0c609ad1 ("powerpc/perf: Add support for the hv gpci (get 
performance counter info) interface")
Reported-by: Akanksha J N 
Signed-off-by: Kajol Jain 
---
Changelog:

v1 -> v2
- To make sure the hcall failure with H_PARAMETER is only because of
  buffer size issue, add check for detail_rc value to be
  GEN_BUF_TOO_SMALL(0x1B) as suggested by Michael Ellerman.

 arch/powerpc/perf/hv-gpci.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 27f18119fda1..89bfdc2ce8bc 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -695,6 +695,20 @@ static unsigned long single_gpci_request(u32 req, u32 
starting_index,
 
ret = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO,
virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE);
+
+   /*
+* ret value as 'H_PARAMETER' with detail_rc as 'GEN_BUF_TOO_SMALL',
+* specifies that the current buffer size cannot accommodate
+* all the information and a partial buffer returned.
+* Since in this function we are only accessing data for a given 
starting index,
+* we don't need to accommodate whole data and can get required count by
+* accessing first entry data.
+* Hence hcall fails only incase the ret value is other than H_SUCCESS 
or
+* H_PARAMETER with detail_rc value as GEN_BUF_TOO_SMALL(0x1B).
+*/
+   if (ret == H_PARAMETER && be32_to_cpu(arg->params.detail_rc) == 0x1B)
+   ret = 0;
+
if (ret) {
pr_devel("hcall failed: 0x%lx\n", ret);
goto out;
@@ -759,6 +773,7 @@ static int h_gpci_event_init(struct perf_event *event)
 {
u64 count;
u8 length;
+   unsigned long ret;
 
/* Not our event */
if (event->attr.type != event->pmu->type)
@@ -789,13 +804,23 @@ static int h_gpci_event_init(struct perf_event *event)
}
 
/* check if the request works... */
-   if (single_gpci_request(event_get_request(event),
+   ret = single_gpci_request(event_get_request(event),
event_get_starting_index(event),
event_get_secondary_index(event),
event_get_counter_info_version(event),
event_get_offset(event),
length,
-   )) {
+   );
+
+   /*
+* ret value as H_AUTHORITY implies that partition is not permitted to 
retrieve
+* performance information, and required to set
+* "Enable Performance Information Collection" option.
+*/
+   if (ret == H_AUTHORITY)
+   return -EPERM;
+
+   if (ret) {
pr_devel("gpci hcall failed\n");
return -EINVAL;
}
-- 
2.43.0



[PATCH 5/5] powerpc: Remove cpu-as-y completely

2024-02-29 Thread Michael Ellerman
From: Christophe Leroy 

cpu-as-y is there to force assembler building options. But there is no
need for that. GCC is passed the necessary options and it automatically
pass the appropriate option to GAS.

GCC is given -maltivec when relevant, so no need for -Wa,-maltivec
either.

And -Wa,-many is wrong as it will hide innapropriate instructions.
Better to detect them and handle them on a case by case basis.

The setting of -Wa,-many was added by commit 960e30029863
("powerpc/Makefile: Fix PPC_BOOK3S_64 ASFLAGS") in order to fix an issue
with clang and the passed -Wa,-mpower4 option. But we have now removed
it expecting the compiler to automatically pass the proper options and
instructions based on -mcpu=power4.

Signed-off-by: Christophe Leroy 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/Makefile | 12 
 1 file changed, 12 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 051247027da0..098133b34b68 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -219,18 +219,6 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
 # often slow when they are implemented at all
 KBUILD_CFLAGS  += $(call cc-option,-mno-string)
 
-cpu-as-$(CONFIG_ALTIVEC)   += $(call as-option,-Wa$(comma)-maltivec)
-
-# When using '-many -mpower4' gas will first try and find a matching power4
-# mnemonic and failing that it will allow any valid mnemonic that GAS knows
-# about. GCC will pass -many to GAS when assembling, clang does not.
-# LLVM IAS doesn't understand either flag: 
https://github.com/ClangBuiltLinux/linux/issues/675
-# but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
-cpu-as-$(CONFIG_PPC_BOOK3S_64) += $(call as-option,-Wa$(comma)-mpower4) $(call 
as-option,-Wa$(comma)-many)
-
-KBUILD_AFLAGS += $(cpu-as-y)
-KBUILD_CFLAGS += $(cpu-as-y)
-
 KBUILD_AFLAGS += $(aflags-y)
 KBUILD_CFLAGS += $(cflags-y)
 
-- 
2.43.2



[PATCH 1/5] powerpc/64s: Move dcbt/dcbtst sequence into a macro

2024-02-29 Thread Michael Ellerman
There's an almost identical code sequence to specify load/store access
hints in __copy_tofrom_user_power7(), copypage_power7() and
memcpy_power7().

Move the sequence into a common macro, which is passed the registers to
use as they differ slightly.

There also needs to be a copy in the selftests, it could be shared in
future if the headers are cleaned up / refactored.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/ppc_asm.h   | 12 
 arch/powerpc/lib/copypage_power7.S   | 12 +---
 arch/powerpc/lib/copyuser_power7.S   | 12 +---
 arch/powerpc/lib/memcpy_power7.S | 10 +-
 .../selftests/powerpc/copyloops/asm/ppc_asm.h| 12 
 5 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h 
b/arch/powerpc/include/asm/ppc_asm.h
index 041ee2595520..78c7548eac1e 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -510,6 +510,18 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, 
CPU_FTR_CELL_TB_BUG, 96)
lis scratch,0x6000@h;   \
dcbt0,scratch,0b01010
 
+#define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch)\
+   lis scratch,0x8000; /* GO=1 */  \
+   clrldi  scratch,scratch,32; \
+   /* setup read stream 0 */   \
+   dcbt0,from,0b01000; /* addr from */ \
+   dcbt0,from_parms,0b01010;   /* length and depth from */ \
+   /* setup write stream 1 */  \
+   dcbtst  0,to,0b01000;   /* addr to */   \
+   dcbtst  0,to_parms,0b01010; /* length and depth to */   \
+   eieio;  \
+   dcbt0,scratch,0b01010;  /* all streams GO */
+
 /*
  * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
  * keep the address intact to be compatible with code shared with
diff --git a/arch/powerpc/lib/copypage_power7.S 
b/arch/powerpc/lib/copypage_power7.S
index a783973f1215..07e7cec4d135 100644
--- a/arch/powerpc/lib/copypage_power7.S
+++ b/arch/powerpc/lib/copypage_power7.S
@@ -27,17 +27,7 @@ _GLOBAL(copypage_power7)
 #endif
ori r10,r7,1/* stream=1 */
 
-   lis r8,0x8000   /* GO=1 */
-   clrldi  r8,r8,32
-
-   /* setup read stream 0  */
-   dcbt0,r4,0b01000/* addr from */
-   dcbt0,r7,0b01010   /* length and depth from */
-   /* setup write stream 1 */
-   dcbtst  0,r9,0b01000   /* addr to */
-   dcbtst  0,r10,0b01010  /* length and depth to */
-   eieio
-   dcbt0,r8,0b01010/* all streams GO */
+   DCBT_SETUP_STREAMS(r4, r7, r9, r10, r8)
 
 #ifdef CONFIG_ALTIVEC
mflrr0
diff --git a/arch/powerpc/lib/copyuser_power7.S 
b/arch/powerpc/lib/copyuser_power7.S
index ac41053c3a5a..8474c682a178 100644
--- a/arch/powerpc/lib/copyuser_power7.S
+++ b/arch/powerpc/lib/copyuser_power7.S
@@ -298,17 +298,7 @@ err1;  stb r0,0(r3)
or  r7,r7,r0
ori r10,r7,1/* stream=1 */
 
-   lis r8,0x8000   /* GO=1 */
-   clrldi  r8,r8,32
-
-   /* setup read stream 0 */
-   dcbt0,r6,0b01000   /* addr from */
-   dcbt0,r7,0b01010   /* length and depth from */
-   /* setup write stream 1 */
-   dcbtst  0,r9,0b01000   /* addr to */
-   dcbtst  0,r10,0b01010  /* length and depth to */
-   eieio
-   dcbt0,r8,0b01010/* all streams GO */
+   DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
 
beq cr1,.Lunwind_stack_nonvmx_copy
 
diff --git a/arch/powerpc/lib/memcpy_power7.S b/arch/powerpc/lib/memcpy_power7.S
index 9398b2b746c4..b7c5e7fca8b9 100644
--- a/arch/powerpc/lib/memcpy_power7.S
+++ b/arch/powerpc/lib/memcpy_power7.S
@@ -244,15 +244,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
or  r7,r7,r0
ori r10,r7,1/* stream=1 */
 
-   lis r8,0x8000   /* GO=1 */
-   clrldi  r8,r8,32
-
-   dcbt0,r6,0b01000
-   dcbt0,r7,0b01010
-   dcbtst  0,r9,0b01000
-   dcbtst  0,r10,0b01010
-   eieio
-   dcbt0,r8,0b01010/* GO */
+   DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
 
beq cr1,.Lunwind_stack_nonvmx_copy
 
diff --git a/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h 
b/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h
index a89f1fbf86ec..1d293ab77185 100644
--- a/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h
+++ b/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h
@@ -47,4 +47,16 @@
 /* Default to taking the first of any alternative feature sections */
 test_feature = 1
 
+#define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch)\
+   lis scratch,0x8000; 

[PATCH 4/5] powerpc/fsl: Modernise mt/mfpmr

2024-02-29 Thread Michael Ellerman
With the addition of the machine directives, these are no longer simple
1-2 liner macros. So modernise them to be static inlines and use named
asm parameters.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/reg_fsl_emb.h | 32 +-
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/reg_fsl_emb.h 
b/arch/powerpc/include/asm/reg_fsl_emb.h
index 8359c06d92d9..b0563c30b062 100644
--- a/arch/powerpc/include/asm/reg_fsl_emb.h
+++ b/arch/powerpc/include/asm/reg_fsl_emb.h
@@ -11,17 +11,27 @@
 
 #ifndef __ASSEMBLY__
 /* Performance Monitor Registers */
-#define mfpmr(rn)  ({unsigned int rval; \
-   asm volatile(".machine push; " \
-".machine e300; " \
-"mfpmr %0," __stringify(rn) ";" \
-".machine pop; " \
-: "=r" (rval)); rval;})
-#define mtpmr(rn, v)   asm volatile(".machine push; " \
-".machine e300; " \
-"mtpmr " __stringify(rn) ",%0; " \
-".machine pop; " \
-: : "r" (v))
+static inline unsigned int mfpmr(unsigned int rn)
+{
+   unsigned int rval;
+
+   asm (".machine push; "
+".machine e300; "
+"mfpmr %[rval], %[rn];"
+".machine pop;"
+: [rval] "=r" (rval) : [rn] "i" (rn));
+
+   return rval;
+}
+
+static inline void mtpmr(unsigned int rn, unsigned int val)
+{
+   asm (".machine push; "
+".machine e300; "
+"mtpmr %[rn], %[val];"
+".machine pop;"
+: [val] "=r" (val) : [rn] "i" (rn));
+}
 #endif /* __ASSEMBLY__ */
 
 /* Freescale Book E Performance Monitor APU Registers */
-- 
2.43.2



[PATCH 3/5] powerpc/fsl: Fix mfpmr build errors with newer binutils

2024-02-29 Thread Michael Ellerman
Binutils 2.38 complains about the use of mfpmr when building
ppc6xx_defconfig:

CC  arch/powerpc/kernel/pmc.o
  {standard input}: Assembler messages:
  {standard input}:45: Error: unrecognized opcode: `mfpmr'
  {standard input}:56: Error: unrecognized opcode: `mtpmr'

This is because by default the kernel is built with -mcpu=powerpc, and
the mt/mfpmr instructions are not defined.

It can be avoided by enabling CONFIG_E300C3_CPU, but just adding that to
the defconfig will leave open the possibility of randconfig failures.

So add machine directives around the mt/mfpmr instructions to tell
binutils how to assemble them.

Cc: sta...@vger.kernel.org
Reported-by: Jan-Benedict Glaw 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/reg_fsl_emb.h | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/reg_fsl_emb.h 
b/arch/powerpc/include/asm/reg_fsl_emb.h
index a21f529c43d9..8359c06d92d9 100644
--- a/arch/powerpc/include/asm/reg_fsl_emb.h
+++ b/arch/powerpc/include/asm/reg_fsl_emb.h
@@ -12,9 +12,16 @@
 #ifndef __ASSEMBLY__
 /* Performance Monitor Registers */
 #define mfpmr(rn)  ({unsigned int rval; \
-   asm volatile("mfpmr %0," __stringify(rn) \
+   asm volatile(".machine push; " \
+".machine e300; " \
+"mfpmr %0," __stringify(rn) ";" \
+".machine pop; " \
 : "=r" (rval)); rval;})
-#define mtpmr(rn, v)   asm volatile("mtpmr " __stringify(rn) ",%0" : : "r" (v))
+#define mtpmr(rn, v)   asm volatile(".machine push; " \
+".machine e300; " \
+"mtpmr " __stringify(rn) ",%0; " \
+".machine pop; " \
+: : "r" (v))
 #endif /* __ASSEMBLY__ */
 
 /* Freescale Book E Performance Monitor APU Registers */
-- 
2.43.2



[PATCH 2/5] powerpc/64s: Use .machine power4 around dcbt

2024-02-29 Thread Michael Ellerman
There are multiple decodings for the "dcbt" mnemonic, so the assembler
has to pick one.

That requires passing -many to the assembler, which is not recommended.

Without -many the clang 14 / binutils 2.38 build fails with:

  arch/powerpc/kernel/exceptions-64s.S:2976: Error: junk at end of line: 
`0b01010'
  clang: error: assembler command failed with exit code 1 (use -v to see 
invocation)

Fix it by adding .machine directives around the use of dcbt to specify
which encoding is desired.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/ppc_asm.h | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h 
b/arch/powerpc/include/asm/ppc_asm.h
index 78c7548eac1e..1d1018c1e482 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -508,11 +508,16 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, 
CPU_FTR_CELL_TB_BUG, 96)
  */
 #define DCBT_BOOK3S_STOP_ALL_STREAM_IDS(scratch)   \
lis scratch,0x6000@h;   \
-   dcbt0,scratch,0b01010
+   .machine push;  \
+   .machine power4;\
+   dcbt0,scratch,0b01010;  \
+   .machine pop;
 
 #define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch)\
lis scratch,0x8000; /* GO=1 */  \
clrldi  scratch,scratch,32; \
+   .machine push;  \
+   .machine power4;\
/* setup read stream 0 */   \
dcbt0,from,0b01000; /* addr from */ \
dcbt0,from_parms,0b01010;   /* length and depth from */ \
@@ -520,7 +525,8 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, 
CPU_FTR_CELL_TB_BUG, 96)
dcbtst  0,to,0b01000;   /* addr to */   \
dcbtst  0,to_parms,0b01010; /* length and depth to */   \
eieio;  \
-   dcbt0,scratch,0b01010;  /* all streams GO */
+   dcbt0,scratch,0b01010;  /* all streams GO */\
+   .machine pop;
 
 /*
  * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
-- 
2.43.2



Re: [kvm-unit-tests PATCH 04/13] treewide: lib/stack: Make base_address arch specific

2024-02-29 Thread Andrew Jones
On Thu, Feb 29, 2024 at 01:49:58PM +1000, Nicholas Piggin wrote:
> On Thu Feb 29, 2024 at 1:04 AM AEST, Andrew Jones wrote:
> > Calculating the offset of an address is image specific, which is
> > architecture specific. Until now, all architectures and architecture
> > configurations which select CONFIG_RELOC were able to subtract
> > _etext, but the EFI configuration of riscv cannot (it must subtract
> > ImageBase). Make this function architecture specific, since the
> > architecture's image layout already is.
> 
> arch_base_address()?

Yeah, I should have added that prefix.

> 
> How about a default implementation unlesss HAVE_ARCH_BASE_ADDRESS?

We have a default implementation for !CONFIG_RELOC, but if an arch
selects RELOC it must have an implementation of base_address(), so
I wouldn't introduce a HAVE_ARCH_BASE_ADDRESS type of config since
it would just always be selected when RELOC is selected. It occurred
to me after posting that I probably should have just made the current
base_address() implementation weak and then only introduced the new
riscv one. I'll do that for v2.

Thanks,
drew


[PATCH] powerpc/boot: Only free if realloc() succeeds

2024-02-29 Thread Michael Ellerman
simple_realloc() frees the original buffer (ptr) even if the
reallocation failed.

Fix it to behave like standard realloc() and only free the original
buffer if the reallocation succeeded.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/boot/simple_alloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c
index db9aaa5face3..d07796fdf91a 100644
--- a/arch/powerpc/boot/simple_alloc.c
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -112,10 +112,11 @@ static void *simple_realloc(void *ptr, unsigned long size)
return ptr;
 
new = simple_malloc(size);
-   if (new)
+   if (new) {
memcpy(new, ptr, p->size);
+   simple_free(ptr);
+   }
 
-   simple_free(ptr);
return new;
 }
 
-- 
2.43.2



[PATCH] fbdev/mb862xxfb: Fix defined but not used error

2024-02-29 Thread Michael Ellerman
socrates_gc_mode is defined at the top-level but then only used inside
an #ifdef CONFIG_FB_MB862XX_LIME, leading to an error with some configs:

  drivers/video/fbdev/mb862xx/mb862xxfbdrv.c:36:31: error: ‘socrates_gc_mode’ 
defined but not used
 36 | static struct mb862xx_gc_mode socrates_gc_mode = {

Fix it by moving socrates_gc_mode inside that ifdef, immediately prior
to the only function where it's used.

Signed-off-by: Michael Ellerman 
---
 drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c 
b/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
index 7c402e9fd7a9..baec312d7b33 100644
--- a/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
+++ b/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
@@ -32,15 +32,6 @@
 #define CARMINE_MEM_SIZE   0x800
 #define DRV_NAME   "mb862xxfb"
 
-#if defined(CONFIG_SOCRATES)
-static struct mb862xx_gc_mode socrates_gc_mode = {
-   /* Mode for Prime View PM070WL4 TFT LCD Panel */
-   { "800x480", 45, 800, 480, 4, 86, 42, 33, 10, 128, 2, 0, 0, 0 },
-   /* 16 bits/pixel, 16MB, 133MHz, SDRAM memory mode value */
-   16, 0x100, GC_CCF_COT_133, 0x4157ba63
-};
-#endif
-
 /* Helpers */
 static inline int h_total(struct fb_var_screeninfo *var)
 {
@@ -666,6 +657,15 @@ static int mb862xx_gdc_init(struct mb862xxfb_par *par)
return 0;
 }
 
+#if defined(CONFIG_SOCRATES)
+static struct mb862xx_gc_mode socrates_gc_mode = {
+   /* Mode for Prime View PM070WL4 TFT LCD Panel */
+   { "800x480", 45, 800, 480, 4, 86, 42, 33, 10, 128, 2, 0, 0, 0 },
+   /* 16 bits/pixel, 16MB, 133MHz, SDRAM memory mode value */
+   16, 0x100, GC_CCF_COT_133, 0x4157ba63
+};
+#endif
+
 static int of_platform_mb862xx_probe(struct platform_device *ofdev)
 {
struct device_node *np = ofdev->dev.of_node;
-- 
2.43.2



Re: [kvm-unit-tests PATCH 03/13] treewide: lib/stack: Fix backtrace

2024-02-29 Thread Andrew Jones
On Thu, Feb 29, 2024 at 01:31:52PM +1000, Nicholas Piggin wrote:
> On Thu Feb 29, 2024 at 1:04 AM AEST, Andrew Jones wrote:
...
> > diff --git a/lib/stack.h b/lib/stack.h
> > index 10fc2f793354..6edc84344b51 100644
> > --- a/lib/stack.h
> > +++ b/lib/stack.h
> > @@ -11,17 +11,27 @@
> >  #include 
> >  
> >  #ifdef HAVE_ARCH_BACKTRACE_FRAME
> > -extern int backtrace_frame(const void *frame, const void **return_addrs,
> > -  int max_depth);
> > +extern int arch_backtrace_frame(const void *frame, const void 
> > **return_addrs,
> > +   int max_depth, bool current_frame);
> > +
> > +static inline int backtrace_frame(const void *frame, const void 
> > **return_addrs,
> > + int max_depth)
> > +{
> > +   return arch_backtrace_frame(frame, return_addrs, max_depth, false);
> > +}
> > +
> > +static inline int backtrace(const void **return_addrs, int max_depth)
> > +{
> > +   return arch_backtrace_frame(NULL, return_addrs, max_depth, true);
> > +}
> >  #else
> > -static inline int
> > -backtrace_frame(const void *frame __unused, const void **return_addrs 
> > __unused,
> > -   int max_depth __unused)
> > +extern int backtrace(const void **return_addrs, int max_depth);
> > +
> > +static inline int backtrace_frame(const void *frame, const void 
> > **return_addrs,
> > + int max_depth)
> >  {
> > return 0;
> >  }
> >  #endif
> >  
> > -extern int backtrace(const void **return_addrs, int max_depth);
> > -
> >  #endif
> 
> Is there a reason to add the inline wrappers rather than just externs
> and drop the arch_ prefix?

Only reason is to avoid duplicating the functions in each arch, but
since they're oneliners which won't likely change, then we could
duplicate them instead, if preferred, but I'm not sure what the
benefit of that over the static inlines would be.

> 
> Do we want to just generally have all arch specific functions have an
> arch_ prefix? Fine by me.

We've been slowly doing that over in 'KVM selftests', which has improved
readability, so slowly adopting it here too in kvm-unit-tests would be
nice.

> 
> Reviewed-by: Nicholas Piggin 
> 
> I'm fine to rebase the powerpc patch on top of this if it goes in first.
> Thanks for the heads up.
> 

Thanks,
drew


Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Vadim Fedorenko

On 29/02/2024 08:55, Eric Dumazet wrote:

On Thu, Feb 29, 2024 at 9:04 AM Tasmiya Nalatwad
 wrote:


Greetings,

I have tried the patch provided below. Moving struct to file
"net/core/rtnetlink.c" is not resolving the problem. Please find the
below traces.

--- Traces ---

In file included from ./include/linux/rbtree.h:24,
   from ./include/linux/mm_types.h:11,
   from ./include/linux/mmzone.h:22,
   from ./include/linux/gfp.h:7,
   from ./include/linux/umh.h:4,
   from ./include/linux/kmod.h:9,
   from ./include/linux/module.h:17,
   from net/core/rtnetlink.c:17:
net/core/rtnetlink.c: In function ‘netdev_dpll_pin’:
./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
   ^
./include/linux/rcupdate.h:587:2: note: in expansion of macro
‘__rcu_dereference_check’
__rcu_dereference_check((p), __UNIQUE_ID(rcu), \
^~~
./include/linux/rtnetlink.h:70:2: note: in expansion of macro
‘rcu_dereference_check’
rcu_dereference_check(p, lockdep_rtnl_is_held())
^
net/core/rtnetlink.c:1059:15: note: in expansion of macro
‘rcu_dereference_rtnl’
  return rcu_dereference_rtnl(dev->dpll_pin);
 ^~~~
CC  crypto/algboss.o
net/core/rtnetlink.c:1063:1: error: control reaches end of non-void
function [-Werror=return-type]
   }
   ^
CC  crypto/authenc.o
CC  crypto/authencesn.o
CC  crypto/af_alg.o
CC  crypto/algif_hash.o
CC  crypto/algif_skcipher.o
CC  crypto/algif_rng.o
CC  crypto/algif_aead.o
AR  arch/powerpc/kernel/built-in.a
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:243: net/core/rtnetlink.o] Error 1
make[4]: *** Waiting for unfinished jobs
CC  lib/kobject_uevent.o
AR  drivers/net/mdio/built-in.a
AR  net/802/built-in.a
AR  drivers/connector/built-in.a
CC  lib/vsprintf.o
AR  ipc/built-in.a
AR  net/nsh/built-in.a
CC  lib/dynamic_debug.o
In file included from ./arch/powerpc/include/generated/asm/rwonce.h:1,
   from ./include/linux/compiler.h:251,
   from ./include/linux/instrumented.h:10,
   from ./include/linux/uaccess.h:6,
   from net/core/dev.c:71:
net/core/dev.c: In function ‘netdev_dpll_pin_assign’:
./include/linux/rcupdate.h:462:36: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
   #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
  ^~~~
./include/asm-generic/rwonce.h:55:33: note: in definition of macro
‘__WRITE_ONCE’
*(volatile typeof(x) *)&(x) = (val);\
   ^~~
./arch/powerpc/include/asm/barrier.h:76:2: note: in expansion of macro
‘WRITE_ONCE’
WRITE_ONCE(*p, v);  \
^~
./include/asm-generic/barrier.h:172:55: note: in expansion of macro
‘__smp_store_release’
   #define smp_store_release(p, v) do { kcsan_release();
__smp_store_release(p, v); } while (0)
^~~
./include/linux/rcupdate.h:503:3: note: in expansion of macro
‘smp_store_release’
 smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
 ^
./include/linux/rcupdate.h:503:25: note: in expansion of macro
‘RCU_INITIALIZER’
 smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
   ^~~
net/core/dev.c:9081:2: note: in expansion of macro ‘rcu_assign_pointer’
rcu_assign_pointer(dev->dpll_pin, dpll_pin);
^~

On 2/28/24 20:13, Eric Dumazet wrote:

On Wed, Feb 28, 2024 at 3:07 PM Vadim Fedorenko
 wrote:

On 28/02/2024 11:09, Tasmiya Nalatwad wrote:

Greetings,

[revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

Reverting below commit fixes the issue

commit 0d60d8df6f493bb46bf5db40d39dd60a1bafdd4e
   dpll: rely on rcu for netdev_dpll_pin()

--- Traces ---

./include/linux/dpll.h: In function ‘netdev_dpll_pin’:
./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
 typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
^
./include/linux/rcupdate.h:587:2: note: in expansion of macro
‘__rcu_dereference_check’
 __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
 ^~~
./include/linux/rtnetlink.h:70:2: note: in expansion of macro
‘rcu_dereference_check’
 rcu_dereference_check(p, lockdep_rtnl_is_held())
 ^
./include/linux/dpll.h:175:9: note: in expansion of macro
‘rcu_dereference_rtnl’
 return rcu_dereference_rtnl(dev->dpll_pin);
^~~~
make[4]: *** [scripts/Makefile.build:243: drivers/dpll/dpll_core.o] Error 1
make[4]: *** Waiting for 

[PATCH] powerpc/85xx: Make some pic_init functions static

2024-02-29 Thread Michael Ellerman
These functions can all be static, make them so, which also fixes no
previous prototype warnings.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/platforms/85xx/bsc913x_qds.c | 2 +-
 arch/powerpc/platforms/85xx/bsc913x_rdb.c | 2 +-
 arch/powerpc/platforms/85xx/ge_imp3a.c| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/bsc913x_qds.c 
b/arch/powerpc/platforms/85xx/bsc913x_qds.c
index 2eb62bff86d4..3ad8096fcf16 100644
--- a/arch/powerpc/platforms/85xx/bsc913x_qds.c
+++ b/arch/powerpc/platforms/85xx/bsc913x_qds.c
@@ -19,7 +19,7 @@
 #include "mpc85xx.h"
 #include "smp.h"
 
-void __init bsc913x_qds_pic_init(void)
+static void __init bsc913x_qds_pic_init(void)
 {
struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
  MPIC_SINGLE_DEST_CPU,
diff --git a/arch/powerpc/platforms/85xx/bsc913x_rdb.c 
b/arch/powerpc/platforms/85xx/bsc913x_rdb.c
index 161f006cb3bb..dcd358c28201 100644
--- a/arch/powerpc/platforms/85xx/bsc913x_rdb.c
+++ b/arch/powerpc/platforms/85xx/bsc913x_rdb.c
@@ -15,7 +15,7 @@
 
 #include "mpc85xx.h"
 
-void __init bsc913x_rdb_pic_init(void)
+static void __init bsc913x_rdb_pic_init(void)
 {
struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
  MPIC_SINGLE_DEST_CPU,
diff --git a/arch/powerpc/platforms/85xx/ge_imp3a.c 
b/arch/powerpc/platforms/85xx/ge_imp3a.c
index 9c3b44a1952e..477852f1a726 100644
--- a/arch/powerpc/platforms/85xx/ge_imp3a.c
+++ b/arch/powerpc/platforms/85xx/ge_imp3a.c
@@ -38,7 +38,7 @@
 
 void __iomem *imp3a_regs;
 
-void __init ge_imp3a_pic_init(void)
+static void __init ge_imp3a_pic_init(void)
 {
struct mpic *mpic;
struct device_node *np;
-- 
2.43.2



[PATCH] powerpc: Add allmodconfig for all 32-bit sub-arches

2024-02-29 Thread Michael Ellerman
32-bit powerpc kernels can be built for one of 5 sub-arches, see
Kconfig.cputype:

  PPC_BOOK3S_32: "512x/52xx/6xx/7xx/74xx/82xx/83xx/86xx"
  PPC_85xx: "Freescale 85xx"
  PPC_8xx: "Freescale 8xx"
  40x: "AMCC 40x"
  44x: "AMCC 44x, 46x or 47x"

By default none of these are built for a plain allmodconfig build,
because it selects PPC64 which builds a 64-bit kernel.

There is already a ppc32_allmodconfig, which enables PPC_BOOK3S_32.

Add similar targets for the other 32-bit sub-arches to increase build
coverage:
  ppc40x_allmodconfig
  ppc44x_allmodconfig
  ppc8xx_allmodconfig
  ppc85xx_allmodconfig

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/Makefile  | 20 
 arch/powerpc/configs/40x.config|  2 ++
 arch/powerpc/configs/44x.config|  2 ++
 arch/powerpc/configs/85xx-32bit.config |  1 +
 arch/powerpc/configs/8xx.config|  2 ++
 5 files changed, 27 insertions(+)
 create mode 100644 arch/powerpc/configs/40x.config
 create mode 100644 arch/powerpc/configs/44x.config
 create mode 100644 arch/powerpc/configs/8xx.config

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 051247027da0..4b8c9ff79d0f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -314,6 +314,26 @@ ppc32_allmodconfig:
$(Q)$(MAKE) 
KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
-f $(srctree)/Makefile allmodconfig
 
+generated_configs += ppc40x_allmodconfig
+ppc40x_allmodconfig:
+   $(Q)$(MAKE) 
KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/40x.config \
+   -f $(srctree)/Makefile allmodconfig
+
+generated_configs += ppc44x_allmodconfig
+ppc44x_allmodconfig:
+   $(Q)$(MAKE) 
KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/44x.config \
+   -f $(srctree)/Makefile allmodconfig
+
+generated_configs += ppc8xx_allmodconfig
+ppc8xx_allmodconfig:
+   $(Q)$(MAKE) 
KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/8xx.config \
+   -f $(srctree)/Makefile allmodconfig
+
+generated_configs += ppc85xx_allmodconfig
+ppc85xx_allmodconfig:
+   $(Q)$(MAKE) 
KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-32bit.config \
+   -f $(srctree)/Makefile allmodconfig
+
 generated_configs += ppc_defconfig
 ppc_defconfig:
$(call merge_into_defconfig,book3s_32.config,)
diff --git a/arch/powerpc/configs/40x.config b/arch/powerpc/configs/40x.config
new file mode 100644
index ..82a9d58ddb81
--- /dev/null
+++ b/arch/powerpc/configs/40x.config
@@ -0,0 +1,2 @@
+CONFIG_PPC64=n
+CONFIG_40x=y
diff --git a/arch/powerpc/configs/44x.config b/arch/powerpc/configs/44x.config
new file mode 100644
index ..79b7b1962995
--- /dev/null
+++ b/arch/powerpc/configs/44x.config
@@ -0,0 +1,2 @@
+CONFIG_PPC64=n
+CONFIG_44x=y
diff --git a/arch/powerpc/configs/85xx-32bit.config 
b/arch/powerpc/configs/85xx-32bit.config
index 6b8894d727a2..a85310bcb1fd 100644
--- a/arch/powerpc/configs/85xx-32bit.config
+++ b/arch/powerpc/configs/85xx-32bit.config
@@ -1,3 +1,4 @@
+CONFIG_PPC64=n
 CONFIG_HIGHMEM=y
 CONFIG_KEXEC=y
 CONFIG_PPC_85xx=y
diff --git a/arch/powerpc/configs/8xx.config b/arch/powerpc/configs/8xx.config
new file mode 100644
index ..7eb3ffbbd667
--- /dev/null
+++ b/arch/powerpc/configs/8xx.config
@@ -0,0 +1,2 @@
+CONFIG_PPC64=n
+CONFIG_PPC_8xx=y
-- 
2.43.2



Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Tasmiya Nalatwad

Latest changes suggested below works, and the issue is not seen.

Tested-by: Tasmiya Nalatwad 

On 2/29/24 14:25, Eric Dumazet wrote:

On Thu, Feb 29, 2024 at 9:04 AM Tasmiya Nalatwad
 wrote:

Greetings,

I have tried the patch provided below. Moving struct to file
"net/core/rtnetlink.c" is not resolving the problem. Please find the
below traces.

--- Traces ---

In file included from ./include/linux/rbtree.h:24,
   from ./include/linux/mm_types.h:11,
   from ./include/linux/mmzone.h:22,
   from ./include/linux/gfp.h:7,
   from ./include/linux/umh.h:4,
   from ./include/linux/kmod.h:9,
   from ./include/linux/module.h:17,
   from net/core/rtnetlink.c:17:
net/core/rtnetlink.c: In function ‘netdev_dpll_pin’:
./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
   ^
./include/linux/rcupdate.h:587:2: note: in expansion of macro
‘__rcu_dereference_check’
__rcu_dereference_check((p), __UNIQUE_ID(rcu), \
^~~
./include/linux/rtnetlink.h:70:2: note: in expansion of macro
‘rcu_dereference_check’
rcu_dereference_check(p, lockdep_rtnl_is_held())
^
net/core/rtnetlink.c:1059:15: note: in expansion of macro
‘rcu_dereference_rtnl’
  return rcu_dereference_rtnl(dev->dpll_pin);
 ^~~~
CC  crypto/algboss.o
net/core/rtnetlink.c:1063:1: error: control reaches end of non-void
function [-Werror=return-type]
   }
   ^
CC  crypto/authenc.o
CC  crypto/authencesn.o
CC  crypto/af_alg.o
CC  crypto/algif_hash.o
CC  crypto/algif_skcipher.o
CC  crypto/algif_rng.o
CC  crypto/algif_aead.o
AR  arch/powerpc/kernel/built-in.a
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:243: net/core/rtnetlink.o] Error 1
make[4]: *** Waiting for unfinished jobs
CC  lib/kobject_uevent.o
AR  drivers/net/mdio/built-in.a
AR  net/802/built-in.a
AR  drivers/connector/built-in.a
CC  lib/vsprintf.o
AR  ipc/built-in.a
AR  net/nsh/built-in.a
CC  lib/dynamic_debug.o
In file included from ./arch/powerpc/include/generated/asm/rwonce.h:1,
   from ./include/linux/compiler.h:251,
   from ./include/linux/instrumented.h:10,
   from ./include/linux/uaccess.h:6,
   from net/core/dev.c:71:
net/core/dev.c: In function ‘netdev_dpll_pin_assign’:
./include/linux/rcupdate.h:462:36: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
   #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
  ^~~~
./include/asm-generic/rwonce.h:55:33: note: in definition of macro
‘__WRITE_ONCE’
*(volatile typeof(x) *)&(x) = (val);\
   ^~~
./arch/powerpc/include/asm/barrier.h:76:2: note: in expansion of macro
‘WRITE_ONCE’
WRITE_ONCE(*p, v);  \
^~
./include/asm-generic/barrier.h:172:55: note: in expansion of macro
‘__smp_store_release’
   #define smp_store_release(p, v) do { kcsan_release();
__smp_store_release(p, v); } while (0)
^~~
./include/linux/rcupdate.h:503:3: note: in expansion of macro
‘smp_store_release’
 smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
 ^
./include/linux/rcupdate.h:503:25: note: in expansion of macro
‘RCU_INITIALIZER’
 smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
   ^~~
net/core/dev.c:9081:2: note: in expansion of macro ‘rcu_assign_pointer’
rcu_assign_pointer(dev->dpll_pin, dpll_pin);
^~

On 2/28/24 20:13, Eric Dumazet wrote:

On Wed, Feb 28, 2024 at 3:07 PM Vadim Fedorenko
 wrote:

On 28/02/2024 11:09, Tasmiya Nalatwad wrote:

Greetings,

[revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

Reverting below commit fixes the issue

commit 0d60d8df6f493bb46bf5db40d39dd60a1bafdd4e
   dpll: rely on rcu for netdev_dpll_pin()

--- Traces ---

./include/linux/dpll.h: In function ‘netdev_dpll_pin’:
./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
 typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
^
./include/linux/rcupdate.h:587:2: note: in expansion of macro
‘__rcu_dereference_check’
 __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
 ^~~
./include/linux/rtnetlink.h:70:2: note: in expansion of macro
‘rcu_dereference_check’
 rcu_dereference_check(p, lockdep_rtnl_is_held())
 ^
./include/linux/dpll.h:175:9: note: in expansion of macro
‘rcu_dereference_rtnl’
 return rcu_dereference_rtnl(dev->dpll_pin);
^~~~
make[4]: 

Re: [PATCH v8 07/10] PCI: dwc: ep: Remove "core_init_notifier" flag

2024-02-29 Thread Niklas Cassel
Hello Mani,

On Sat, Feb 24, 2024 at 12:24:13PM +0530, Manivannan Sadhasivam wrote:
> "core_init_notifier" flag is set by the glue drivers requiring refclk from
> the host to complete the DWC core initialization. Also, those drivers will
> send a notification to the EPF drivers once the initialization is fully
> completed using the pci_epc_init_notify() API. Only then, the EPF drivers
> will start functioning.
> 
> For the rest of the drivers generating refclk locally, EPF drivers will
> start functioning post binding with them. EPF drivers rely on the
> 'core_init_notifier' flag to differentiate between the drivers.
> Unfortunately, this creates two different flows for the EPF drivers.
> 
> So to avoid that, let's get rid of the "core_init_notifier" flag and follow
> a single initialization flow for the EPF drivers. This is done by calling
> the dw_pcie_ep_init_notify() from all glue drivers after the completion of
> dw_pcie_ep_init_registers() API. This will allow all the glue drivers to
> send the notification to the EPF drivers once the initialization is fully
> completed.
> 
> Only difference here is that, the drivers requiring refclk from host will
> send the notification once refclk is received, while others will send it
> during probe time itself.
> 
> Signed-off-by: Manivannan Sadhasivam 
> ---
>  drivers/pci/controller/dwc/pci-dra7xx.c   |  2 ++
>  drivers/pci/controller/dwc/pci-imx6.c |  2 ++
>  drivers/pci/controller/dwc/pci-keystone.c |  2 ++
>  drivers/pci/controller/dwc/pci-layerscape-ep.c|  2 ++
>  drivers/pci/controller/dwc/pcie-designware-plat.c |  2 ++
>  drivers/pci/controller/dwc/pcie-qcom-ep.c |  1 -
>  drivers/pci/controller/dwc/pcie-rcar-gen4.c   |  2 ++
>  drivers/pci/controller/dwc/pcie-tegra194.c|  1 -
>  drivers/pci/controller/dwc/pcie-uniphier-ep.c |  2 ++
>  drivers/pci/endpoint/functions/pci-epf-test.c | 18 +-
>  include/linux/pci-epc.h   |  3 ---

pcie-artpec6.c:static const struct dw_pcie_ep_ops pcie_ep_ops = {
pcie-keembay.c:static const struct dw_pcie_ep_ops keembay_pcie_ep_ops = {

Where is the love for these drivers? ;)


Kind regards,
Niklas


[PATCH 3/3] selftest/powerpc: make sub-folders buildable on it own

2024-02-29 Thread Madhavan Srinivasan
Build breaks when executing make with run_tests for sub-folders
under powerpc. This is because, CFLAGS and GIT_VERSION macros are
defined in Makefile of toplevel powerpc folder.

make: Entering directory '/home/maddy/linux/tools/testing/selftests/powerpc/mm'
gcc hugetlb_vs_thp_test.c ../harness.c ../utils.c  -o 
/home/maddy/selftest_output//hugetlb_vs_thp_test
hugetlb_vs_thp_test.c:6:10: fatal error: utils.h: No such file or directory
6 | #include "utils.h"
  |  ^
compilation terminated.

Fix this by adding the flags.mk in each sub-folder Makefile.
Also remove the CFLAGS and GIT_VERSION macros from powerpc/
folder Makefile since the same is definied in flags.mk

Signed-off-by: Madhavan Srinivasan 
---
 tools/testing/selftests/powerpc/Makefile | 7 +--
 tools/testing/selftests/powerpc/alignment/Makefile   | 1 +
 tools/testing/selftests/powerpc/benchmarks/Makefile  | 1 +
 tools/testing/selftests/powerpc/cache_shape/Makefile | 1 +
 tools/testing/selftests/powerpc/copyloops/Makefile   | 1 +
 tools/testing/selftests/powerpc/dexcr/Makefile   | 1 +
 tools/testing/selftests/powerpc/dscr/Makefile| 1 +
 tools/testing/selftests/powerpc/eeh/Makefile | 1 +
 tools/testing/selftests/powerpc/math/Makefile| 1 +
 tools/testing/selftests/powerpc/mce/Makefile | 1 +
 tools/testing/selftests/powerpc/mm/Makefile  | 1 +
 tools/testing/selftests/powerpc/nx-gzip/Makefile | 1 +
 tools/testing/selftests/powerpc/papr_attributes/Makefile | 3 ++-
 tools/testing/selftests/powerpc/papr_sysparm/Makefile| 1 +
 tools/testing/selftests/powerpc/papr_vpd/Makefile| 1 +
 tools/testing/selftests/powerpc/primitives/Makefile  | 1 +
 tools/testing/selftests/powerpc/ptrace/Makefile  | 1 +
 tools/testing/selftests/powerpc/security/Makefile| 1 +
 tools/testing/selftests/powerpc/signal/Makefile  | 1 +
 tools/testing/selftests/powerpc/stringloops/Makefile | 1 +
 tools/testing/selftests/powerpc/switch_endian/Makefile   | 1 +
 tools/testing/selftests/powerpc/syscalls/Makefile| 1 +
 tools/testing/selftests/powerpc/tm/Makefile  | 1 +
 tools/testing/selftests/powerpc/vphn/Makefile| 1 +
 24 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/powerpc/Makefile 
b/tools/testing/selftests/powerpc/Makefile
index c376151982c4..2f299fd04d2d 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -7,12 +7,6 @@ ARCH := $(shell echo $(ARCH) | sed -e s/ppc.*/powerpc/)
 
 ifeq ($(ARCH),powerpc)
 
-GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
-
-CFLAGS := -std=gnu99 -O2 -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' 
-I$(CURDIR)/include $(CFLAGS)
-
-export CFLAGS
-
 SUB_DIRS = alignment   \
   benchmarks   \
   cache_shape  \
@@ -46,6 +40,7 @@ $(SUB_DIRS):
BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) 
OUTPUT=$$BUILD_TARGET -k -C $@ all
 
 include ../lib.mk
+include ./flags.mk
 
 override define RUN_TESTS
+@for TARGET in $(SUB_DIRS); do \
diff --git a/tools/testing/selftests/powerpc/alignment/Makefile 
b/tools/testing/selftests/powerpc/alignment/Makefile
index 93e9af37449d..66d5d7aaeb20 100644
--- a/tools/testing/selftests/powerpc/alignment/Makefile
+++ b/tools/testing/selftests/powerpc/alignment/Makefile
@@ -3,5 +3,6 @@ TEST_GEN_PROGS := copy_first_unaligned alignment_handler
 
 top_srcdir = ../../../../..
 include ../../lib.mk
+include ../flags.mk
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile 
b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 75f5232c3aec..1321922038d0 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -6,6 +6,7 @@ TEST_FILES := settings
 
 top_srcdir = ../../../../..
 include ../../lib.mk
+include ../flags.mk
 
 CFLAGS += -O2
 
diff --git a/tools/testing/selftests/powerpc/cache_shape/Makefile 
b/tools/testing/selftests/powerpc/cache_shape/Makefile
index 689f6c8ebcd8..3a3ca956ac66 100644
--- a/tools/testing/selftests/powerpc/cache_shape/Makefile
+++ b/tools/testing/selftests/powerpc/cache_shape/Makefile
@@ -3,5 +3,6 @@ TEST_GEN_PROGS := cache_shape
 
 top_srcdir = ../../../../..
 include ../../lib.mk
+include ../flags.mk
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile 
b/tools/testing/selftests/powerpc/copyloops/Makefile
index 72684ed589c0..42940f92d832 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -10,6 +10,7 @@ EXTRA_SOURCES := validate.c ../harness.c stubs.S
 
 top_srcdir = ../../../../..
 include ../../lib.mk
+include ../flags.mk
 
 # The loops are all 64-bit code
 CFLAGS 

[PATCH 2/3] selftest/powerpc: Add flags.mk to support pmu buildable

2024-02-29 Thread Madhavan Srinivasan
When running `make -C powerpc/pmu run_tests` from top level selftests
directory, currently this error is being reported

make: Entering directory '/home/maddy/linux/tools/testing/selftests/powerpc/pmu'
Makefile:40: warning: overriding recipe for target 'emit_tests'
../../lib.mk:111: warning: ignoring old recipe for target 'emit_tests'
gcc -m64count_instructions.c ../harness.c event.c lib.c ../utils.c loop.S  
-o /home/maddy/selftest_output//count_instructions
In file included from count_instructions.c:13:
event.h:12:10: fatal error: utils.h: No such file or directory
12 | #include "utils.h"
  |  ^
compilation terminated.

This is due to missing of include path in CFLAGS. That is, CFLAGS and
GIT_VERSION macros are defined in the powerpc/ folder Makefile which
in this case not involved.

To address the failure incase of executing specific sub-folder test directly,
a new rule file has been addded by the patch called "flags.mk" under
selftest/powerpc/ folder and is linked to all the Makefile of powerpc/pmu
sub-folders.

Reported-by: Sachin Sant 
Signed-off-by: Madhavan Srinivasan 
---
Changelog RFC:
- Rename the rule file as flags.mk
- Added additional patches to support other sub-folders
  under powerpc/ to be buildable on it own.
link to RFC:
  
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20240225163926.264286-1-ma...@linux.ibm.com/
  
 tools/testing/selftests/powerpc/flags.mk | 12 
 tools/testing/selftests/powerpc/pmu/Makefile |  1 +
 tools/testing/selftests/powerpc/pmu/ebb/Makefile |  1 +
 .../selftests/powerpc/pmu/event_code_tests/Makefile  |  1 +
 .../selftests/powerpc/pmu/sampling_tests/Makefile|  1 +
 5 files changed, 16 insertions(+)
 create mode 100644 tools/testing/selftests/powerpc/flags.mk

diff --git a/tools/testing/selftests/powerpc/flags.mk 
b/tools/testing/selftests/powerpc/flags.mk
new file mode 100644
index ..28374f470126
--- /dev/null
+++ b/tools/testing/selftests/powerpc/flags.mk
@@ -0,0 +1,12 @@
+#This checks for any ENV variables and add those.
+
+#ifeq ($(GIT_VERSION),)
+GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
+export GIT_VERSION
+#endif
+
+#ifeq ($(CFLAGS),)
+CFLAGS := -std=gnu99 -O2 -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' 
-I$(selfdir)/powerpc/include $(CFLAGS)
+export CFLAGS
+#endif
+
diff --git a/tools/testing/selftests/powerpc/pmu/Makefile 
b/tools/testing/selftests/powerpc/pmu/Makefile
index a284fa874a9f..1fcacae1b188 100644
--- a/tools/testing/selftests/powerpc/pmu/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/Makefile
@@ -7,6 +7,7 @@ EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c
 
 top_srcdir = ../../../../..
 include ../../lib.mk
+include ../flags.mk
 
 all: $(TEST_GEN_PROGS) ebb sampling_tests event_code_tests
 
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile 
b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index b3946ce17e0c..1b39af7c10db 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -18,6 +18,7 @@ TEST_GEN_PROGS := reg_access_test event_attributes_test 
cycles_test   \
 
 top_srcdir = ../../../../../..
 include ../../../lib.mk
+include ../../flags.mk
 
 # The EBB handler is 64-bit code and everything links against it
 CFLAGS += -m64
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/Makefile 
b/tools/testing/selftests/powerpc/pmu/event_code_tests/Makefile
index 509d4b235b9e..fdb080b3fa65 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/Makefile
@@ -9,6 +9,7 @@ TEST_GEN_PROGS := group_constraint_pmc56_test 
group_pmc56_exclude_constraints_te
 
 top_srcdir = ../../../../../..
 include ../../../lib.mk
+include ../../flags.mk
 
 CFLAGS += -m64
 
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile 
b/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
index d45892151e05..9f79bec5fce7 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
@@ -9,6 +9,7 @@ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test 
mmcr0_pmccext_test
 
 top_srcdir = ../../../../../..
 include ../../../lib.mk
+include ../../flags.mk
 
 CFLAGS += -m64
 
-- 
2.43.2



[PATCH 1/3] selftest/powerpc: Re-order *FLAGS to follow lib.mk

2024-02-29 Thread Madhavan Srinivasan
In some powerpc/ sub-folder Makefiles, CFLAGS are
defined before lib.mk include. Clean it up by
re-ordering it to follow after the mk include.
This is needed to support sub-folders in powerpc/
buildable on its own.

Signed-off-by: Madhavan Srinivasan 
---
 .../selftests/powerpc/benchmarks/Makefile |  4 ++--
 .../selftests/powerpc/copyloops/Makefile  | 20 +--
 .../selftests/powerpc/nx-gzip/Makefile|  4 ++--
 .../selftests/powerpc/pmu/ebb/Makefile| 20 +--
 .../powerpc/pmu/event_code_tests/Makefile |  4 ++--
 .../powerpc/pmu/sampling_tests/Makefile   |  4 ++--
 .../selftests/powerpc/primitives/Makefile |  4 ++--
 .../selftests/powerpc/security/Makefile   |  4 ++--
 .../testing/selftests/powerpc/signal/Makefile |  3 ++-
 .../selftests/powerpc/stringloops/Makefile| 10 +-
 .../selftests/powerpc/switch_endian/Makefile  |  4 ++--
 .../selftests/powerpc/syscalls/Makefile   |  4 ++--
 tools/testing/selftests/powerpc/vphn/Makefile |  4 ++--
 13 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile 
b/tools/testing/selftests/powerpc/benchmarks/Makefile
index a32a6ab89914..75f5232c3aec 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -4,11 +4,11 @@ TEST_GEN_FILES := exec_target
 
 TEST_FILES := settings
 
-CFLAGS += -O2
-
 top_srcdir = ../../../../..
 include ../../lib.mk
 
+CFLAGS += -O2
+
 $(TEST_GEN_PROGS): ../harness.c
 
 $(OUTPUT)/context_switch: ../utils.c
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile 
b/tools/testing/selftests/powerpc/copyloops/Makefile
index 77594e697f2f..72684ed589c0 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -1,14 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-# The loops are all 64-bit code
-CFLAGS += -m64
-CFLAGS += -I$(CURDIR)
-CFLAGS += -D SELFTEST
-CFLAGS += -maltivec
-CFLAGS += -mcpu=power4
-
-# Use our CFLAGS for the implicit .S rule & set the asm machine type
-ASFLAGS = $(CFLAGS) -Wa,-mpower4
-
 TEST_GEN_PROGS := copyuser_64_t0 copyuser_64_t1 copyuser_64_t2 \
copyuser_p7_t0 copyuser_p7_t1 \
memcpy_64_t0 memcpy_64_t1 memcpy_64_t2 \
@@ -21,6 +11,16 @@ EXTRA_SOURCES := validate.c ../harness.c stubs.S
 top_srcdir = ../../../../..
 include ../../lib.mk
 
+# The loops are all 64-bit code
+CFLAGS += -m64
+CFLAGS += -I$(CURDIR)
+CFLAGS += -D SELFTEST
+CFLAGS += -maltivec
+CFLAGS += -mcpu=power4
+
+# Use our CFLAGS for the implicit .S rule & set the asm machine type
+ASFLAGS = $(CFLAGS) -Wa,-mpower4
+
 $(OUTPUT)/copyuser_64_t%:  copyuser_64.S $(EXTRA_SOURCES)
$(CC) $(CPPFLAGS) $(CFLAGS) \
-D COPY_LOOP=test___copy_tofrom_user_base \
diff --git a/tools/testing/selftests/powerpc/nx-gzip/Makefile 
b/tools/testing/selftests/powerpc/nx-gzip/Makefile
index 0785c2e99d40..b40991f902b2 100644
--- a/tools/testing/selftests/powerpc/nx-gzip/Makefile
+++ b/tools/testing/selftests/powerpc/nx-gzip/Makefile
@@ -1,8 +1,8 @@
-CFLAGS = -O3 -m64 -I./include -I../include
-
 TEST_GEN_FILES := gzfht_test gunz_test
 TEST_PROGS := nx-gzip-test.sh
 
 include ../../lib.mk
 
+CFLAGS = -O3 -m64 -I./include -I../include
+
 $(TEST_GEN_FILES): gzip_vas.c ../utils.c
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile 
b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
index 010160690227..b3946ce17e0c 100644
--- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile
@@ -4,16 +4,6 @@ include ../../../../../build/Build.include
 noarg:
$(MAKE) -C ../../
 
-# The EBB handler is 64-bit code and everything links against it
-CFLAGS += -m64
-
-TMPOUT = $(OUTPUT)/TMPDIR/
-# Toolchains may build PIE by default which breaks the assembly
-no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
-$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o 
"$$TMP", -no-pie)
-
-LDFLAGS += $(no-pie-option)
-
 TEST_GEN_PROGS := reg_access_test event_attributes_test cycles_test\
 cycles_with_freeze_test pmc56_overflow_test\
 ebb_vs_cpu_event_test cpu_event_vs_ebb_test\
@@ -29,6 +19,16 @@ TEST_GEN_PROGS := reg_access_test event_attributes_test 
cycles_test  \
 top_srcdir = ../../../../../..
 include ../../../lib.mk
 
+# The EBB handler is 64-bit code and everything links against it
+CFLAGS += -m64
+
+TMPOUT = $(OUTPUT)/TMPDIR/
+# Toolchains may build PIE by default which breaks the assembly
+no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \
+$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o 
"$$TMP", -no-pie)
+
+LDFLAGS += $(no-pie-option)
+
 $(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \
   ebb.c ebb_handler.S trace.c busy_loop.S
 
diff --git 

Re: [PATCH] powerpc/mm: Code cleanup for __hash_page_thp

2024-02-29 Thread Kunwu Chan

Thanks all for the reply.
On 2024/2/29 14:18, Michael Ellerman wrote:

Aneesh Kumar K.V  writes:

Michael Ellerman  writes:

Kunwu Chan  writes:

On 2024/2/26 18:49, Michael Ellerman wrote:

Kunwu Chan  writes:

This part was commented from commit 6d492ecc6489
("powerpc/THP: Add code to handle HPTE faults for hugepages")
in about 11 years before.

If there are no plans to enable this part code in the future,
we can remove this dead code.


I agree the code can go. But I'd like it to be replaced with a comment
explaining what the dead code was trying to say.



Thanks, i'll update a new patch with the following comment:
  /*
  * No CPU has hugepages but lacks no execute, so we
  * don't need to worry about cpu no CPU_FTR_COHERENT_ICACHE feature case
  */


Maybe wait until we can get some input from Aneesh. I'm not sure the
code/comment are really up to date.


How about?

modified   arch/powerpc/mm/book3s64/hash_hugepage.c
@@ -58,17 +58,13 @@ int __hash_page_thp(unsigned long ea, unsigned long access, 
unsigned long vsid,
return 0;
  
  	rflags = htab_convert_pte_flags(new_pmd, flags);

+   /*
+* THPs are only supported on platforms that can do mixed page size
+* segments (MPSS) and all such platforms have coherent icache. Hence we
+* don't need to do lazy icache flush (hash_page_do_lazy_icache()) on
+* noexecute fault.
+*/



I'll use this comment in v2 patch.
And add two Suggested-by: label for you.


Yeah thanks that looks good.

It could say "see eg. __hash_page_4K()", but that's probably unnecessary
as it mentions hash_page_do_lazy_icache(), and anyone interested is just
going to grep for that anyway.

cheers

--
Thanks,
  Kunwu



Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Eric Dumazet
On Thu, Feb 29, 2024 at 9:04 AM Tasmiya Nalatwad
 wrote:
>
> Greetings,
>
> I have tried the patch provided below. Moving struct to file
> "net/core/rtnetlink.c" is not resolving the problem. Please find the
> below traces.
>
> --- Traces ---
>
> In file included from ./include/linux/rbtree.h:24,
>   from ./include/linux/mm_types.h:11,
>   from ./include/linux/mmzone.h:22,
>   from ./include/linux/gfp.h:7,
>   from ./include/linux/umh.h:4,
>   from ./include/linux/kmod.h:9,
>   from ./include/linux/module.h:17,
>   from net/core/rtnetlink.c:17:
> net/core/rtnetlink.c: In function ‘netdev_dpll_pin’:
> ./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
> incomplete type ‘struct dpll_pin’
>typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
>   ^
> ./include/linux/rcupdate.h:587:2: note: in expansion of macro
> ‘__rcu_dereference_check’
>__rcu_dereference_check((p), __UNIQUE_ID(rcu), \
>^~~
> ./include/linux/rtnetlink.h:70:2: note: in expansion of macro
> ‘rcu_dereference_check’
>rcu_dereference_check(p, lockdep_rtnl_is_held())
>^
> net/core/rtnetlink.c:1059:15: note: in expansion of macro
> ‘rcu_dereference_rtnl’
>  return rcu_dereference_rtnl(dev->dpll_pin);
> ^~~~
>CC  crypto/algboss.o
> net/core/rtnetlink.c:1063:1: error: control reaches end of non-void
> function [-Werror=return-type]
>   }
>   ^
>CC  crypto/authenc.o
>CC  crypto/authencesn.o
>CC  crypto/af_alg.o
>CC  crypto/algif_hash.o
>CC  crypto/algif_skcipher.o
>CC  crypto/algif_rng.o
>CC  crypto/algif_aead.o
>AR  arch/powerpc/kernel/built-in.a
> cc1: some warnings being treated as errors
> make[4]: *** [scripts/Makefile.build:243: net/core/rtnetlink.o] Error 1
> make[4]: *** Waiting for unfinished jobs
>CC  lib/kobject_uevent.o
>AR  drivers/net/mdio/built-in.a
>AR  net/802/built-in.a
>AR  drivers/connector/built-in.a
>CC  lib/vsprintf.o
>AR  ipc/built-in.a
>AR  net/nsh/built-in.a
>CC  lib/dynamic_debug.o
> In file included from ./arch/powerpc/include/generated/asm/rwonce.h:1,
>   from ./include/linux/compiler.h:251,
>   from ./include/linux/instrumented.h:10,
>   from ./include/linux/uaccess.h:6,
>   from net/core/dev.c:71:
> net/core/dev.c: In function ‘netdev_dpll_pin_assign’:
> ./include/linux/rcupdate.h:462:36: error: dereferencing pointer to
> incomplete type ‘struct dpll_pin’
>   #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
>  ^~~~
> ./include/asm-generic/rwonce.h:55:33: note: in definition of macro
> ‘__WRITE_ONCE’
>*(volatile typeof(x) *)&(x) = (val);\
>   ^~~
> ./arch/powerpc/include/asm/barrier.h:76:2: note: in expansion of macro
> ‘WRITE_ONCE’
>WRITE_ONCE(*p, v);  \
>^~
> ./include/asm-generic/barrier.h:172:55: note: in expansion of macro
> ‘__smp_store_release’
>   #define smp_store_release(p, v) do { kcsan_release();
> __smp_store_release(p, v); } while (0)
> ^~~
> ./include/linux/rcupdate.h:503:3: note: in expansion of macro
> ‘smp_store_release’
> smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
> ^
> ./include/linux/rcupdate.h:503:25: note: in expansion of macro
> ‘RCU_INITIALIZER’
> smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
>   ^~~
> net/core/dev.c:9081:2: note: in expansion of macro ‘rcu_assign_pointer’
>rcu_assign_pointer(dev->dpll_pin, dpll_pin);
>^~
>
> On 2/28/24 20:13, Eric Dumazet wrote:
> > On Wed, Feb 28, 2024 at 3:07 PM Vadim Fedorenko
> >  wrote:
> >> On 28/02/2024 11:09, Tasmiya Nalatwad wrote:
> >>> Greetings,
> >>>
> >>> [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure
> >>>
> >>> Reverting below commit fixes the issue
> >>>
> >>> commit 0d60d8df6f493bb46bf5db40d39dd60a1bafdd4e
> >>>   dpll: rely on rcu for netdev_dpll_pin()
> >>>
> >>> --- Traces ---
> >>>
> >>> ./include/linux/dpll.h: In function ‘netdev_dpll_pin’:
> >>> ./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
> >>> incomplete type ‘struct dpll_pin’
> >>> typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
> >>>^
> >>> ./include/linux/rcupdate.h:587:2: note: in expansion of macro
> >>> ‘__rcu_dereference_check’
> >>> __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
> >>> ^~~
> >>> ./include/linux/rtnetlink.h:70:2: note: in expansion of macro
> >>> ‘rcu_dereference_check’
> >>> rcu_dereference_check(p, lockdep_rtnl_is_held())
> >>> ^
> >>> ./include/linux/dpll.h:175:9: 

[PATCH v2 7/7] mm/treewide: Drop pXd_large()

2024-02-29 Thread peterx
From: Peter Xu 

They're not used anymore, drop all of them.

Signed-off-by: Peter Xu 
---
 arch/arm/include/asm/pgtable-2level.h|  1 -
 arch/arm/include/asm/pgtable-3level.h|  1 -
 arch/powerpc/include/asm/book3s/64/pgtable.h |  4 +---
 arch/powerpc/include/asm/pgtable.h   |  4 
 arch/s390/include/asm/pgtable.h  |  8 
 arch/sparc/include/asm/pgtable_64.h  |  8 
 arch/x86/include/asm/pgtable.h   | 19 +++
 7 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/arch/arm/include/asm/pgtable-2level.h 
b/arch/arm/include/asm/pgtable-2level.h
index ce543cd9380c..b0a262566eb9 100644
--- a/arch/arm/include/asm/pgtable-2level.h
+++ b/arch/arm/include/asm/pgtable-2level.h
@@ -213,7 +213,6 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long 
addr)
 
 #define pmd_pfn(pmd)   (__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
 
-#define pmd_large(pmd) (pmd_val(pmd) & 2)
 #define pmd_leaf(pmd)  (pmd_val(pmd) & 2)
 #define pmd_bad(pmd)   (pmd_val(pmd) & 2)
 #define pmd_present(pmd)   (pmd_val(pmd))
diff --git a/arch/arm/include/asm/pgtable-3level.h 
b/arch/arm/include/asm/pgtable-3level.h
index 71c3add6417f..4b1d9eb3908a 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -118,7 +118,6 @@
 PMD_TYPE_TABLE)
 #define pmd_sect(pmd)  ((pmd_val(pmd) & PMD_TYPE_MASK) == \
 PMD_TYPE_SECT)
-#define pmd_large(pmd) pmd_sect(pmd)
 #define pmd_leaf(pmd)  pmd_sect(pmd)
 
 #define pud_clear(pudp)\
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 3e99e409774a..df66dce8306f 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1437,17 +1437,15 @@ static inline bool is_pte_rw_upgrade(unsigned long 
old_val, unsigned long new_va
 }
 
 /*
- * Like pmd_huge() and pmd_large(), but works regardless of config options
+ * Like pmd_huge(), but works regardless of config options
  */
 #define pmd_leaf pmd_leaf
-#define pmd_large pmd_leaf
 static inline bool pmd_leaf(pmd_t pmd)
 {
return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
 }
 
 #define pud_leaf pud_leaf
-#define pud_large pud_leaf
 static inline bool pud_leaf(pud_t pud)
 {
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
diff --git a/arch/powerpc/include/asm/pgtable.h 
b/arch/powerpc/include/asm/pgtable.h
index e6edf1cdbc5b..239709a2f68e 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -101,10 +101,6 @@ void poking_init(void);
 extern unsigned long ioremap_bot;
 extern const pgprot_t protection_map[16];
 
-#ifndef pmd_large
-#define pmd_large(pmd) 0
-#endif
-
 /* can we use this in kvm */
 unsigned long vmalloc_to_phys(void *vmalloc_addr);
 
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index a5f16a244a64..9e08af5b9247 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -705,16 +705,16 @@ static inline int pud_none(pud_t pud)
return pud_val(pud) == _REGION3_ENTRY_EMPTY;
 }
 
-#define pud_leaf   pud_large
-static inline int pud_large(pud_t pud)
+#define pud_leaf pud_leaf
+static inline int pud_leaf(pud_t pud)
 {
if ((pud_val(pud) & _REGION_ENTRY_TYPE_MASK) != _REGION_ENTRY_TYPE_R3)
return 0;
return !!(pud_val(pud) & _REGION3_ENTRY_LARGE);
 }
 
-#define pmd_leaf   pmd_large
-static inline int pmd_large(pmd_t pmd)
+#define pmd_leaf pmd_leaf
+static inline int pmd_leaf(pmd_t pmd)
 {
return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0;
 }
diff --git a/arch/sparc/include/asm/pgtable_64.h 
b/arch/sparc/include/asm/pgtable_64.h
index 652af9d63fa2..6ff0a28d5fd1 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -680,8 +680,8 @@ static inline unsigned long pte_special(pte_t pte)
return pte_val(pte) & _PAGE_SPECIAL;
 }
 
-#define pmd_leaf   pmd_large
-static inline unsigned long pmd_large(pmd_t pmd)
+#define pmd_leaf pmd_leaf
+static inline unsigned long pmd_leaf(pmd_t pmd)
 {
pte_t pte = __pte(pmd_val(pmd));
 
@@ -867,8 +867,8 @@ static inline pmd_t *pud_pgtable(pud_t pud)
 /* only used by the stubbed out hugetlb gup code, should never be called */
 #define p4d_page(p4d)  NULL
 
-#define pud_leaf   pud_large
-static inline unsigned long pud_large(pud_t pud)
+#define pud_leaf pud_leaf
+static inline unsigned long pud_leaf(pud_t pud)
 {
pte_t pte = __pte(pud_val(pud));
 
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index f884d5162507..6028e5143a00 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -251,8 +251,8 @@ static 

[PATCH v2 6/7] mm/treewide: Replace pud_large() with pud_leaf()

2024-02-29 Thread peterx
From: Peter Xu 

pud_large() is always defined as pud_leaf().  Merge their usages.  Chose
pud_leaf() because pud_leaf() is a global API, while pud_large() is not.

Signed-off-by: Peter Xu 
---
 arch/powerpc/mm/book3s64/pgtable.c | 2 +-
 arch/s390/boot/vmem.c  | 2 +-
 arch/s390/include/asm/pgtable.h| 4 ++--
 arch/s390/mm/gmap.c| 2 +-
 arch/s390/mm/hugetlbpage.c | 4 ++--
 arch/s390/mm/pageattr.c| 2 +-
 arch/s390/mm/pgtable.c | 2 +-
 arch/s390/mm/vmem.c| 6 +++---
 arch/sparc/mm/init_64.c| 2 +-
 arch/x86/kvm/mmu/mmu.c | 2 +-
 arch/x86/mm/fault.c| 4 ++--
 arch/x86/mm/ident_map.c| 2 +-
 arch/x86/mm/init_64.c  | 4 ++--
 arch/x86/mm/kasan_init_64.c| 2 +-
 arch/x86/mm/mem_encrypt_identity.c | 2 +-
 arch/x86/mm/pat/set_memory.c   | 6 +++---
 arch/x86/mm/pgtable.c  | 2 +-
 arch/x86/mm/pti.c  | 2 +-
 arch/x86/power/hibernate.c | 2 +-
 arch/x86/xen/mmu_pv.c  | 4 ++--
 20 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/arch/powerpc/mm/book3s64/pgtable.c 
b/arch/powerpc/mm/book3s64/pgtable.c
index 45f526547b27..83823db3488b 100644
--- a/arch/powerpc/mm/book3s64/pgtable.c
+++ b/arch/powerpc/mm/book3s64/pgtable.c
@@ -130,7 +130,7 @@ void set_pud_at(struct mm_struct *mm, unsigned long addr,
 
WARN_ON(pte_hw_valid(pud_pte(*pudp)));
assert_spin_locked(pud_lockptr(mm, pudp));
-   WARN_ON(!(pud_large(pud)));
+   WARN_ON(!(pud_leaf(pud)));
 #endif
trace_hugepage_set_pud(addr, pud_val(pud));
return set_pte_at(mm, addr, pudp_ptep(pudp), pud_pte(pud));
diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c
index 348ab02b1028..09b10bb6e4d0 100644
--- a/arch/s390/boot/vmem.c
+++ b/arch/s390/boot/vmem.c
@@ -366,7 +366,7 @@ static void pgtable_pud_populate(p4d_t *p4d, unsigned long 
addr, unsigned long e
}
pmd = boot_crst_alloc(_SEGMENT_ENTRY_EMPTY);
pud_populate(_mm, pud, pmd);
-   } else if (pud_large(*pud)) {
+   } else if (pud_leaf(*pud)) {
continue;
}
pgtable_pmd_populate(pud, addr, next, mode);
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index 431d03d5116b..a5f16a244a64 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -730,7 +730,7 @@ static inline int pud_bad(pud_t pud)
 {
unsigned long type = pud_val(pud) & _REGION_ENTRY_TYPE_MASK;
 
-   if (type > _REGION_ENTRY_TYPE_R3 || pud_large(pud))
+   if (type > _REGION_ENTRY_TYPE_R3 || pud_leaf(pud))
return 1;
if (type < _REGION_ENTRY_TYPE_R3)
return 0;
@@ -1400,7 +1400,7 @@ static inline unsigned long pud_deref(pud_t pud)
unsigned long origin_mask;
 
origin_mask = _REGION_ENTRY_ORIGIN;
-   if (pud_large(pud))
+   if (pud_leaf(pud))
origin_mask = _REGION3_ENTRY_ORIGIN_LARGE;
return (unsigned long)__va(pud_val(pud) & origin_mask);
 }
diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
index a4f34c1db3cf..dcb38e351fa6 100644
--- a/arch/s390/mm/gmap.c
+++ b/arch/s390/mm/gmap.c
@@ -596,7 +596,7 @@ int __gmap_link(struct gmap *gmap, unsigned long gaddr, 
unsigned long vmaddr)
pud = pud_offset(p4d, vmaddr);
VM_BUG_ON(pud_none(*pud));
/* large puds cannot yet be handled */
-   if (pud_large(*pud))
+   if (pud_leaf(*pud))
return -EFAULT;
pmd = pmd_offset(pud, vmaddr);
VM_BUG_ON(pmd_none(*pmd));
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
index 1ccb5b40fe92..c2e8242bd15d 100644
--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -224,7 +224,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm,
if (p4d_present(*p4dp)) {
pudp = pud_offset(p4dp, addr);
if (pud_present(*pudp)) {
-   if (pud_large(*pudp))
+   if (pud_leaf(*pudp))
return (pte_t *) pudp;
pmdp = pmd_offset(pudp, addr);
}
@@ -240,7 +240,7 @@ int pmd_huge(pmd_t pmd)
 
 int pud_huge(pud_t pud)
 {
-   return pud_large(pud);
+   return pud_leaf(pud);
 }
 
 bool __init arch_hugetlb_valid_size(unsigned long size)
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index 9f55d5a3210c..01bc8fad64d6 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -274,7 +274,7 @@ static int walk_pud_level(p4d_t *p4d, unsigned long addr, 
unsigned long end,
if (pud_none(*pudp))
return -EINVAL;
next = pud_addr_end(addr, end);
-   if (pud_large(*pudp)) {
+

[PATCH v2 5/7] mm/treewide: Replace pmd_large() with pmd_leaf()

2024-02-29 Thread peterx
From: Peter Xu 

pmd_large() is always defined as pmd_leaf().  Merge their usages.  Chose
pmd_leaf() because pmd_leaf() is a global API, while pmd_large() is not.

Signed-off-by: Peter Xu 
---
 arch/arm/mm/dump.c   |  4 ++--
 arch/powerpc/mm/book3s64/pgtable.c   |  2 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c |  2 +-
 arch/powerpc/mm/pgtable_64.c |  2 +-
 arch/s390/boot/vmem.c|  2 +-
 arch/s390/include/asm/pgtable.h  |  8 
 arch/s390/mm/gmap.c  | 12 ++--
 arch/s390/mm/hugetlbpage.c   |  2 +-
 arch/s390/mm/pageattr.c  |  2 +-
 arch/s390/mm/pgtable.c   |  6 +++---
 arch/s390/mm/vmem.c  |  6 +++---
 arch/sparc/mm/init_64.c  |  4 ++--
 arch/x86/boot/compressed/ident_map_64.c  |  2 +-
 arch/x86/kvm/mmu/mmu.c   |  2 +-
 arch/x86/mm/fault.c  |  8 
 arch/x86/mm/init_32.c|  2 +-
 arch/x86/mm/init_64.c|  8 
 arch/x86/mm/kasan_init_64.c  |  2 +-
 arch/x86/mm/mem_encrypt_identity.c   |  4 ++--
 arch/x86/mm/pat/set_memory.c |  4 ++--
 arch/x86/mm/pgtable.c|  2 +-
 arch/x86/mm/pti.c|  4 ++--
 arch/x86/power/hibernate.c   |  2 +-
 arch/x86/xen/mmu_pv.c|  4 ++--
 drivers/misc/sgi-gru/grufault.c  |  2 +-
 25 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index a9381095ab36..cd032522d902 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -349,12 +349,12 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, 
unsigned long start)
for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
addr = start + i * PMD_SIZE;
domain = get_domain_name(pmd);
-   if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
+   if (pmd_none(*pmd) || pmd_leaf(*pmd) || !pmd_present(*pmd))
note_page(st, addr, 4, pmd_val(*pmd), domain);
else
walk_pte(st, pmd, addr, domain);
 
-   if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1])) {
+   if (SECTION_SIZE < PMD_SIZE && pmd_leaf(pmd[1])) {
addr += SECTION_SIZE;
pmd++;
domain = get_domain_name(pmd);
diff --git a/arch/powerpc/mm/book3s64/pgtable.c 
b/arch/powerpc/mm/book3s64/pgtable.c
index 3438ab72c346..45f526547b27 100644
--- a/arch/powerpc/mm/book3s64/pgtable.c
+++ b/arch/powerpc/mm/book3s64/pgtable.c
@@ -113,7 +113,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
 
WARN_ON(pte_hw_valid(pmd_pte(*pmdp)) && !pte_protnone(pmd_pte(*pmdp)));
assert_spin_locked(pmd_lockptr(mm, pmdp));
-   WARN_ON(!(pmd_large(pmd)));
+   WARN_ON(!(pmd_leaf(pmd)));
 #endif
trace_hugepage_set_pmd(addr, pmd_val(pmd));
return set_pte_at(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd));
diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c 
b/arch/powerpc/mm/book3s64/radix_pgtable.c
index 1f8db10693e3..5cc4008329be 100644
--- a/arch/powerpc/mm/book3s64/radix_pgtable.c
+++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
@@ -924,7 +924,7 @@ bool vmemmap_can_optimize(struct vmem_altmap *altmap, 
struct dev_pagemap *pgmap)
 int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
unsigned long addr, unsigned long next)
 {
-   int large = pmd_large(*pmdp);
+   int large = pmd_leaf(*pmdp);
 
if (large)
vmemmap_verify(pmdp_ptep(pmdp), node, addr, next);
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 386c6b06eab7..9b99113cb51a 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -132,7 +132,7 @@ struct page *pmd_page(pmd_t pmd)
 * enabled so these checks can't be used.
 */
if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP))
-   VM_WARN_ON(!(pmd_large(pmd) || pmd_huge(pmd)));
+   VM_WARN_ON(!(pmd_leaf(pmd) || pmd_huge(pmd)));
return pte_page(pmd_pte(pmd));
}
return virt_to_page(pmd_page_vaddr(pmd));
diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c
index e3a4500a5a75..348ab02b1028 100644
--- a/arch/s390/boot/vmem.c
+++ b/arch/s390/boot/vmem.c
@@ -333,7 +333,7 @@ static void pgtable_pmd_populate(pud_t *pud, unsigned long 
addr, unsigned long e
}
pte = boot_pte_alloc();
pmd_populate(_mm, pmd, pte);
-   } else if (pmd_large(*pmd)) {
+   } else if (pmd_leaf(*pmd)) {
continue;
}
pgtable_pte_populate(pmd, addr, next, mode);
diff --git 

[PATCH v2 4/7] mm/x86: Drop two unnecessary pud_leaf() definitions

2024-02-29 Thread peterx
From: Peter Xu 

pud_leaf() has a fallback macro defined in include/linux/pgtable.h already.
Drop the extra two for x86.

Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: Dave Hansen 
Cc: x...@kernel.org
Signed-off-by: Peter Xu 
---
 arch/x86/include/asm/pgtable.h  | 1 -
 include/asm-generic/pgtable-nopmd.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 69ed0ea0641b..f884d5162507 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1097,7 +1097,6 @@ static inline int pud_bad(pud_t pud)
return (pud_flags(pud) & ~(_KERNPG_TABLE | _PAGE_USER)) != 0;
 }
 #else
-#define pud_leaf   pud_large
 static inline int pud_large(pud_t pud)
 {
return 0;
diff --git a/include/asm-generic/pgtable-nopmd.h 
b/include/asm-generic/pgtable-nopmd.h
index 8ffd64e7a24c..fa27e16bbe1b 100644
--- a/include/asm-generic/pgtable-nopmd.h
+++ b/include/asm-generic/pgtable-nopmd.h
@@ -31,7 +31,6 @@ static inline int pud_none(pud_t pud) { return 0; }
 static inline int pud_bad(pud_t pud)   { return 0; }
 static inline int pud_present(pud_t pud)   { return 1; }
 static inline int pud_user(pud_t pud)  { return 0; }
-static inline int pud_leaf(pud_t pud)  { return 0; }
 static inline void pud_clear(pud_t *pud)   { }
 #define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
 
-- 
2.43.0



[PATCH v2 3/7] mm/x86: Replace p4d_large() with p4d_leaf()

2024-02-29 Thread peterx
From: Peter Xu 

p4d_large() is always defined as p4d_leaf().  Merge their usages.  Chose
p4d_leaf() because p4d_leaf() is a global API, while p4d_large() is not.

Only x86 has p4d_leaf() defined as of now.  So it also means after this
patch we removed all p4d_large() usages.

Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: Dave Hansen 
Cc: x...@kernel.org
Signed-off-by: Peter Xu 
---
 arch/x86/mm/fault.c  | 4 ++--
 arch/x86/mm/init_64.c| 2 +-
 arch/x86/mm/pat/set_memory.c | 4 ++--
 arch/x86/mm/pti.c| 2 +-
 arch/x86/power/hibernate.c   | 2 +-
 arch/x86/xen/mmu_pv.c| 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 679b09cfe241..8b69ce3f4115 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -368,7 +368,7 @@ static void dump_pagetable(unsigned long address)
goto bad;
 
pr_cont("P4D %lx ", p4d_val(*p4d));
-   if (!p4d_present(*p4d) || p4d_large(*p4d))
+   if (!p4d_present(*p4d) || p4d_leaf(*p4d))
goto out;
 
pud = pud_offset(p4d, address);
@@ -1039,7 +1039,7 @@ spurious_kernel_fault(unsigned long error_code, unsigned 
long address)
if (!p4d_present(*p4d))
return 0;
 
-   if (p4d_large(*p4d))
+   if (p4d_leaf(*p4d))
return spurious_kernel_fault_check(error_code, (pte_t *) p4d);
 
pud = pud_offset(p4d, address);
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index ebdbcae48011..d691e7992a9a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1197,7 +1197,7 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, 
unsigned long end,
if (!p4d_present(*p4d))
continue;
 
-   BUILD_BUG_ON(p4d_large(*p4d));
+   BUILD_BUG_ON(p4d_leaf(*p4d));
 
pud_base = pud_offset(p4d, 0);
remove_pud_table(pud_base, addr, next, altmap, direct);
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index e9b448d1b1b7..5359a9c88099 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -676,7 +676,7 @@ pte_t *lookup_address_in_pgd(pgd_t *pgd, unsigned long 
address,
return NULL;
 
*level = PG_LEVEL_512G;
-   if (p4d_large(*p4d) || !p4d_present(*p4d))
+   if (p4d_leaf(*p4d) || !p4d_present(*p4d))
return (pte_t *)p4d;
 
pud = pud_offset(p4d, address);
@@ -739,7 +739,7 @@ pmd_t *lookup_pmd_address(unsigned long address)
return NULL;
 
p4d = p4d_offset(pgd, address);
-   if (p4d_none(*p4d) || p4d_large(*p4d) || !p4d_present(*p4d))
+   if (p4d_none(*p4d) || p4d_leaf(*p4d) || !p4d_present(*p4d))
return NULL;
 
pud = pud_offset(p4d, address);
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 669ba1c345b3..dc0a81f5f60e 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long 
address)
if (!p4d)
return NULL;
 
-   BUILD_BUG_ON(p4d_large(*p4d) != 0);
+   BUILD_BUG_ON(p4d_leaf(*p4d) != 0);
if (p4d_none(*p4d)) {
unsigned long new_pud_page = __get_free_page(gfp);
if (WARN_ON_ONCE(!new_pud_page))
diff --git a/arch/x86/power/hibernate.c b/arch/x86/power/hibernate.c
index 6f955eb1e163..28153789f873 100644
--- a/arch/x86/power/hibernate.c
+++ b/arch/x86/power/hibernate.c
@@ -165,7 +165,7 @@ int relocate_restore_code(void)
pgd = (pgd_t *)__va(read_cr3_pa()) +
pgd_index(relocated_restore_code);
p4d = p4d_offset(pgd, relocated_restore_code);
-   if (p4d_large(*p4d)) {
+   if (p4d_leaf(*p4d)) {
set_p4d(p4d, __p4d(p4d_val(*p4d) & ~_PAGE_NX));
goto out;
}
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index e21974f2cf2d..12a43a4abebf 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -1104,7 +1104,7 @@ static void __init xen_cleanmfnmap_p4d(p4d_t *p4d, bool 
unpin)
pud_t *pud_tbl;
int i;
 
-   if (p4d_large(*p4d)) {
+   if (p4d_leaf(*p4d)) {
pa = p4d_val(*p4d) & PHYSICAL_PAGE_MASK;
xen_free_ro_pages(pa, P4D_SIZE);
return;
-- 
2.43.0



[PATCH v2 2/7] mm/ppc: Replace pXd_is_leaf() with pXd_leaf()

2024-02-29 Thread peterx
From: Peter Xu 

They're the same macros underneath.  Drop pXd_is_leaf(), instead always use
pXd_leaf().

At the meantime, instead of renames, drop the pXd_is_leaf() fallback
definitions directly in arch/powerpc/include/asm/pgtable.h. because similar
fallback macros for pXd_leaf() are already defined in
include/linux/pgtable.h.

Cc: Michael Ellerman 
Cc: Nicholas Piggin 
Cc: "Aneesh Kumar K.V" 
Cc: "Naveen N. Rao" 
Cc: linuxppc-dev@lists.ozlabs.org
Suggested-by: Christophe Leroy 
Signed-off-by: Peter Xu 
---
 arch/powerpc/include/asm/book3s/64/pgtable.h | 10 
 arch/powerpc/include/asm/pgtable.h   | 24 
 arch/powerpc/kvm/book3s_64_mmu_radix.c   | 12 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c | 14 ++--
 arch/powerpc/mm/pgtable.c|  6 ++---
 arch/powerpc/mm/pgtable_64.c |  6 ++---
 arch/powerpc/xmon/xmon.c |  6 ++---
 7 files changed, 26 insertions(+), 52 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index d1318e8582ac..3e99e409774a 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1439,18 +1439,16 @@ static inline bool is_pte_rw_upgrade(unsigned long 
old_val, unsigned long new_va
 /*
  * Like pmd_huge() and pmd_large(), but works regardless of config options
  */
-#define pmd_is_leaf pmd_is_leaf
-#define pmd_leaf pmd_is_leaf
+#define pmd_leaf pmd_leaf
 #define pmd_large pmd_leaf
-static inline bool pmd_is_leaf(pmd_t pmd)
+static inline bool pmd_leaf(pmd_t pmd)
 {
return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
 }
 
-#define pud_is_leaf pud_is_leaf
-#define pud_leaf pud_is_leaf
+#define pud_leaf pud_leaf
 #define pud_large pud_leaf
-static inline bool pud_is_leaf(pud_t pud)
+static inline bool pud_leaf(pud_t pud)
 {
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
 }
diff --git a/arch/powerpc/include/asm/pgtable.h 
b/arch/powerpc/include/asm/pgtable.h
index 5928b3c1458d..e6edf1cdbc5b 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -182,30 +182,6 @@ static inline void pte_frag_set(mm_context_t *ctx, void *p)
 }
 #endif
 
-#ifndef pmd_is_leaf
-#define pmd_is_leaf pmd_is_leaf
-static inline bool pmd_is_leaf(pmd_t pmd)
-{
-   return false;
-}
-#endif
-
-#ifndef pud_is_leaf
-#define pud_is_leaf pud_is_leaf
-static inline bool pud_is_leaf(pud_t pud)
-{
-   return false;
-}
-#endif
-
-#ifndef p4d_is_leaf
-#define p4d_is_leaf p4d_is_leaf
-static inline bool p4d_is_leaf(p4d_t p4d)
-{
-   return false;
-}
-#endif
-
 #define pmd_pgtable pmd_pgtable
 static inline pgtable_t pmd_pgtable(pmd_t pmd)
 {
diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c 
b/arch/powerpc/kvm/book3s_64_mmu_radix.c
index 4a1abb9f7c05..408d98f8a514 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
@@ -503,7 +503,7 @@ static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t 
*pmd, bool full,
for (im = 0; im < PTRS_PER_PMD; ++im, ++p) {
if (!pmd_present(*p))
continue;
-   if (pmd_is_leaf(*p)) {
+   if (pmd_leaf(*p)) {
if (full) {
pmd_clear(p);
} else {
@@ -532,7 +532,7 @@ static void kvmppc_unmap_free_pud(struct kvm *kvm, pud_t 
*pud,
for (iu = 0; iu < PTRS_PER_PUD; ++iu, ++p) {
if (!pud_present(*p))
continue;
-   if (pud_is_leaf(*p)) {
+   if (pud_leaf(*p)) {
pud_clear(p);
} else {
pmd_t *pmd;
@@ -635,12 +635,12 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
pte_t pte,
new_pud = pud_alloc_one(kvm->mm, gpa);
 
pmd = NULL;
-   if (pud && pud_present(*pud) && !pud_is_leaf(*pud))
+   if (pud && pud_present(*pud) && !pud_leaf(*pud))
pmd = pmd_offset(pud, gpa);
else if (level <= 1)
new_pmd = kvmppc_pmd_alloc();
 
-   if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd)))
+   if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_leaf(*pmd)))
new_ptep = kvmppc_pte_alloc();
 
/* Check if we might have been invalidated; let the guest retry if so */
@@ -658,7 +658,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
pte_t pte,
new_pud = NULL;
}
pud = pud_offset(p4d, gpa);
-   if (pud_is_leaf(*pud)) {
+   if (pud_leaf(*pud)) {
unsigned long hgpa = gpa & PUD_MASK;
 
/* Check if we raced and someone else has set the same thing */
@@ -709,7 +709,7 @@ int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, 
pte_t pte,
new_pmd = NULL;
}
pmd = pmd_offset(pud, gpa);
-   if 

[PATCH v2 1/7] mm/ppc: Define pXd_large() with pXd_leaf()

2024-02-29 Thread peterx
From: Peter Xu 

The two definitions are the same.  The only difference is that pXd_large()
is only defined with THP selected, and only on book3s 64bits.

Instead of implementing it twice, make pXd_large() a macro to pXd_leaf().
Define it unconditionally just like pXd_leaf().  This helps to prepare
merging the two APIs.

Cc: Michael Ellerman 
Cc: Nicholas Piggin 
Cc: Christophe Leroy 
Cc: "Aneesh Kumar K.V" 
Cc: "Naveen N. Rao" 
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Peter Xu 
---
 arch/powerpc/include/asm/book3s/64/pgtable.h | 16 ++--
 arch/powerpc/include/asm/pgtable.h   |  2 +-
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h 
b/arch/powerpc/include/asm/book3s/64/pgtable.h
index 927d585652bc..d1318e8582ac 100644
--- a/arch/powerpc/include/asm/book3s/64/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h
@@ -1157,20 +1157,6 @@ pud_hugepage_update(struct mm_struct *mm, unsigned long 
addr, pud_t *pudp,
return pud_val(*pudp);
 }
 
-/*
- * returns true for pmd migration entries, THP, devmap, hugetlb
- * But compile time dependent on THP config
- */
-static inline int pmd_large(pmd_t pmd)
-{
-   return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
-}
-
-static inline int pud_large(pud_t pud)
-{
-   return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
-}
-
 /*
  * For radix we should always find H_PAGE_HASHPTE zero. Hence
  * the below will work for radix too
@@ -1455,6 +1441,7 @@ static inline bool is_pte_rw_upgrade(unsigned long 
old_val, unsigned long new_va
  */
 #define pmd_is_leaf pmd_is_leaf
 #define pmd_leaf pmd_is_leaf
+#define pmd_large pmd_leaf
 static inline bool pmd_is_leaf(pmd_t pmd)
 {
return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
@@ -1462,6 +1449,7 @@ static inline bool pmd_is_leaf(pmd_t pmd)
 
 #define pud_is_leaf pud_is_leaf
 #define pud_leaf pud_is_leaf
+#define pud_large pud_leaf
 static inline bool pud_is_leaf(pud_t pud)
 {
return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
diff --git a/arch/powerpc/include/asm/pgtable.h 
b/arch/powerpc/include/asm/pgtable.h
index 7a1ba8889aea..5928b3c1458d 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -101,7 +101,7 @@ void poking_init(void);
 extern unsigned long ioremap_bot;
 extern const pgprot_t protection_map[16];
 
-#ifndef CONFIG_TRANSPARENT_HUGEPAGE
+#ifndef pmd_large
 #define pmd_large(pmd) 0
 #endif
 
-- 
2.43.0



[PATCH v2 0/7] mm/treewide: Replace pXd_large() with pXd_leaf()

2024-02-29 Thread peterx
From: Peter Xu 

[based on latest akpm/mm-unstable, commit 1274e7646240]

v2:
- Added patch "mm/ppc: Replace pXd_is_leaf() with pXd_leaf()" [Christophe]
- Added patch "mm/x86: Drop two unnecessary pud_leaf() definitions" [syzbot]
- Touched up two more comments which also referenced pmd_large()

These two APIs are mostly always the same.  It's confusing to have both of
them.  Merge them into one.  Here I used pXd_leaf() only because pXd_leaf()
is a global API which is always defined, while pXd_large() is not.

We have yet one more API that is similar which is pXd_huge(), but that's
even trickier, so let's do it step by step.

Some special cares are taken for ppc and x86, they're done as separate
cleanups first.  Only lightly tested on x86.

Please have a look, thanks.

Peter Xu (7):
  mm/ppc: Define pXd_large() with pXd_leaf()
  mm/ppc: Replace pXd_is_leaf() with pXd_leaf()
  mm/x86: Replace p4d_large() with p4d_leaf()
  mm/x86: Drop two unnecessary pud_leaf() definitions
  mm/treewide: Replace pmd_large() with pmd_leaf()
  mm/treewide: Replace pud_large() with pud_leaf()
  mm/treewide: Drop pXd_large()

 arch/arm/include/asm/pgtable-2level.h|  1 -
 arch/arm/include/asm/pgtable-3level.h|  1 -
 arch/arm/mm/dump.c   |  4 +--
 arch/powerpc/include/asm/book3s/64/pgtable.h | 26 --
 arch/powerpc/include/asm/pgtable.h   | 28 
 arch/powerpc/kvm/book3s_64_mmu_radix.c   | 12 -
 arch/powerpc/mm/book3s64/pgtable.c   |  4 +--
 arch/powerpc/mm/book3s64/radix_pgtable.c | 16 +--
 arch/powerpc/mm/pgtable.c|  6 ++---
 arch/powerpc/mm/pgtable_64.c |  8 +++---
 arch/powerpc/xmon/xmon.c |  6 ++---
 arch/s390/boot/vmem.c|  4 +--
 arch/s390/include/asm/pgtable.h  | 20 +++---
 arch/s390/mm/gmap.c  | 14 +-
 arch/s390/mm/hugetlbpage.c   |  6 ++---
 arch/s390/mm/pageattr.c  |  4 +--
 arch/s390/mm/pgtable.c   |  8 +++---
 arch/s390/mm/vmem.c  | 12 -
 arch/sparc/include/asm/pgtable_64.h  |  8 +++---
 arch/sparc/mm/init_64.c  |  6 ++---
 arch/x86/boot/compressed/ident_map_64.c  |  2 +-
 arch/x86/include/asm/pgtable.h   | 20 +-
 arch/x86/kvm/mmu/mmu.c   |  4 +--
 arch/x86/mm/fault.c  | 16 +--
 arch/x86/mm/ident_map.c  |  2 +-
 arch/x86/mm/init_32.c|  2 +-
 arch/x86/mm/init_64.c| 14 +-
 arch/x86/mm/kasan_init_64.c  |  4 +--
 arch/x86/mm/mem_encrypt_identity.c   |  6 ++---
 arch/x86/mm/pat/set_memory.c | 14 +-
 arch/x86/mm/pgtable.c|  4 +--
 arch/x86/mm/pti.c|  8 +++---
 arch/x86/power/hibernate.c   |  6 ++---
 arch/x86/xen/mmu_pv.c| 10 +++
 drivers/misc/sgi-gru/grufault.c  |  2 +-
 include/asm-generic/pgtable-nopmd.h  |  1 -
 36 files changed, 128 insertions(+), 181 deletions(-)

-- 
2.43.0



Re: [PATCH v17 2/6] crash: add a new kexec flag for hotplug support

2024-02-29 Thread Sourabh Jain

Hello

On 29/02/24 12:58, Baoquan He wrote:

On 02/26/24 at 02:11pm, Sourabh Jain wrote:
..snip...

diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 70fa8111a9d6..630c4fd7ea39 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -496,7 +496,7 @@ static DEFINE_MUTEX(__crash_hotplug_lock);
   * It reflects the kernel's ability/permission to update the crash
   * elfcorehdr directly.

  ~ this should be updated too.


   */
-int crash_check_update_elfcorehdr(void)
+int crash_check_hotplug_support(void)
  {
int rc = 0;
  
@@ -508,10 +508,7 @@ int crash_check_update_elfcorehdr(void)

return 0;
}
if (kexec_crash_image) {
-   if (kexec_crash_image->file_mode)
-   rc = 1;
-   else
-   rc = kexec_crash_image->update_elfcorehdr;
+   rc = kexec_crash_image->hotplug_support;
}
/* Release lock now that update complete */
kexec_unlock();
@@ -552,8 +549,8 @@ static void crash_handle_hotplug_event(unsigned int 
hp_action, unsigned int cpu,
  
  	image = kexec_crash_image;
  
-	/* Check that updating elfcorehdr is permitted */

-   if (!(image->file_mode || image->update_elfcorehdr))
+   /* Check that kexec segments update is permitted */
+   if (!image->hotplug_support)
goto out;
  
  	if (hp_action == KEXEC_CRASH_HP_ADD_CPU ||

diff --git a/kernel/kexec.c b/kernel/kexec.c
index bab542fc1463..a6b3f96bb50c 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -135,8 +135,8 @@ static int do_kexec_load(unsigned long entry, unsigned long 
nr_segments,
image->preserve_context = 1;
  
  #ifdef CONFIG_CRASH_HOTPLUG

-   if (flags & KEXEC_UPDATE_ELFCOREHDR)
-   image->update_elfcorehdr = 1;
+   if ((flags & KEXEC_ON_CRASH) && arch_crash_hotplug_support(image, 
flags))
+   image->hotplug_support = 1;
  #endif
  
  	ret = machine_kexec_prepare(image);

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 2d1db05fbf04..3d64290d24c9 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -376,6 +376,11 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, 
initrd_fd,
if (ret)
goto out;
  
+#ifdef CONFIG_CRASH_HOTPLUG

+   if ((flags & KEXEC_FILE_ON_CRASH) && arch_crash_hotplug_support(image, 
flags))
+   image->hotplug_support = 1;
+#endif
+
ret = machine_kexec_prepare(image);
if (ret)
goto out;

Other than the tiny part, the overall looks good to me.

Acked-by: Baoquan He 



Thank you for the review and feedback.

- Sourabh


Re: [PATCH v17 3/6] powerpc/kexec: move *_memory_ranges functions to ranges.c

2024-02-29 Thread Sourabh Jain




On 29/02/24 13:41, Baoquan He wrote:

On 02/26/24 at 02:11pm, Sourabh Jain wrote:

Move the following functions form kexec/{file_load_64.c => ranges.c} and
make them public so that components other KEXEC_FILE can also use these

^
   'than' missed?


Yes, I will update it.

Thanks,
Sourabh Jain


functions.
1. get_exclude_memory_ranges
2. get_reserved_memory_ranges
3. get_crash_memory_ranges
4. get_usable_memory_ranges

Later in the series get_crash_memory_ranges function is utilized for
in-kernel updates to kdump image during CPU/Memory hotplug or
online/offline events for both kexec_load and kexec_file_load syscalls.

Since the above functions are moved to ranges.c, some of the helper
functions in ranges.c are no longer required to be public. Mark them as
static and removed them from kexec_ranges.h header file.

Finally, remove the CONFIG_KEXEC_FILE build dependency for range.c
because it is required for other config, such as CONFIG_CRASH_DUMP.

No functional changes are intended.

..snip





Re: [PATCH v17 2/6] crash: add a new kexec flag for hotplug support

2024-02-29 Thread Sourabh Jain

Hello Baoquan,

On 29/02/24 12:58, Baoquan He wrote:

On 02/26/24 at 02:11pm, Sourabh Jain wrote:
..snip...

diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 70fa8111a9d6..630c4fd7ea39 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -496,7 +496,7 @@ static DEFINE_MUTEX(__crash_hotplug_lock);
   * It reflects the kernel's ability/permission to update the crash
   * elfcorehdr directly.

  ~ this should be updated too.


Yes, it should.

Thanks,
Sourabh



   */
-int crash_check_update_elfcorehdr(void)
+int crash_check_hotplug_support(void)
  {
int rc = 0;
  
@@ -508,10 +508,7 @@ int crash_check_update_elfcorehdr(void)

return 0;
}
if (kexec_crash_image) {
-   if (kexec_crash_image->file_mode)
-   rc = 1;
-   else
-   rc = kexec_crash_image->update_elfcorehdr;
+   rc = kexec_crash_image->hotplug_support;
}
/* Release lock now that update complete */
kexec_unlock();
@@ -552,8 +549,8 @@ static void crash_handle_hotplug_event(unsigned int 
hp_action, unsigned int cpu,
  
  	image = kexec_crash_image;
  
-	/* Check that updating elfcorehdr is permitted */

-   if (!(image->file_mode || image->update_elfcorehdr))
+   /* Check that kexec segments update is permitted */
+   if (!image->hotplug_support)
goto out;
  
  	if (hp_action == KEXEC_CRASH_HP_ADD_CPU ||

diff --git a/kernel/kexec.c b/kernel/kexec.c
index bab542fc1463..a6b3f96bb50c 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -135,8 +135,8 @@ static int do_kexec_load(unsigned long entry, unsigned long 
nr_segments,
image->preserve_context = 1;
  
  #ifdef CONFIG_CRASH_HOTPLUG

-   if (flags & KEXEC_UPDATE_ELFCOREHDR)
-   image->update_elfcorehdr = 1;
+   if ((flags & KEXEC_ON_CRASH) && arch_crash_hotplug_support(image, 
flags))
+   image->hotplug_support = 1;
  #endif
  
  	ret = machine_kexec_prepare(image);

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 2d1db05fbf04..3d64290d24c9 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -376,6 +376,11 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, 
initrd_fd,
if (ret)
goto out;
  
+#ifdef CONFIG_CRASH_HOTPLUG

+   if ((flags & KEXEC_FILE_ON_CRASH) && arch_crash_hotplug_support(image, 
flags))
+   image->hotplug_support = 1;
+#endif
+
ret = machine_kexec_prepare(image);
if (ret)
goto out;

Other than the tiny part, the overall looks good to me.

Acked-by: Baoquan He 





Re: Boot failure with ppc64 port on iMacs G5

2024-02-29 Thread John Paul Adrian Glaubitz
Hi Michael,

On Thu, 2024-02-29 at 17:42 +1100, Michael Ellerman wrote:
> > There seems to be a regression in the kernel which affects PowerPC 970 
> > machines,
> > i.e. PowerMac G5 CPUs. The issue needs to be bisected and reported upstream.
> 
> I have a quad G5 that is booting mainline happily.

it's a really tricky problem because it seems to depend on how the kernel image
is booted.

It fails when trying to boot the kernel off the installation CD, i.e. like from 
here:

> https://cdimage.debian.org/cdimage/ports/snapshots/2024-02-25/debian-12.0.0-ppc64-NETINST-1.iso

but the kernel will boot fine when installing in an existing system which was 
installed
with an installation CD which uses an older kernel.

> https://cdimage.debian.org/cdimage/ports/snapshots/2023-06-18/debian-12.0.0-ppc64-NETINST-1.iso

I have not really figured out yet what the problem is.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Re: [PATCH v17 3/6] powerpc/kexec: move *_memory_ranges functions to ranges.c

2024-02-29 Thread Baoquan He
On 02/26/24 at 02:11pm, Sourabh Jain wrote:
> Move the following functions form kexec/{file_load_64.c => ranges.c} and
> make them public so that components other KEXEC_FILE can also use these
   ^
  'than' missed?
> functions.
> 1. get_exclude_memory_ranges
> 2. get_reserved_memory_ranges
> 3. get_crash_memory_ranges
> 4. get_usable_memory_ranges
> 
> Later in the series get_crash_memory_ranges function is utilized for
> in-kernel updates to kdump image during CPU/Memory hotplug or
> online/offline events for both kexec_load and kexec_file_load syscalls.
> 
> Since the above functions are moved to ranges.c, some of the helper
> functions in ranges.c are no longer required to be public. Mark them as
> static and removed them from kexec_ranges.h header file.
> 
> Finally, remove the CONFIG_KEXEC_FILE build dependency for range.c
> because it is required for other config, such as CONFIG_CRASH_DUMP.
> 
> No functional changes are intended.
..snip



Re: [revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

2024-02-29 Thread Tasmiya Nalatwad

Greetings,

I have tried the patch provided below. Moving struct to file 
"net/core/rtnetlink.c" is not resolving the problem. Please find the 
below traces.


--- Traces ---

In file included from ./include/linux/rbtree.h:24,
 from ./include/linux/mm_types.h:11,
 from ./include/linux/mmzone.h:22,
 from ./include/linux/gfp.h:7,
 from ./include/linux/umh.h:4,
 from ./include/linux/kmod.h:9,
 from ./include/linux/module.h:17,
 from net/core/rtnetlink.c:17:
net/core/rtnetlink.c: In function ‘netdev_dpll_pin’:
./include/linux/rcupdate.h:439:9: error: dereferencing pointer to 
incomplete type ‘struct dpll_pin’

  typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
 ^
./include/linux/rcupdate.h:587:2: note: in expansion of macro 
‘__rcu_dereference_check’

  __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
  ^~~
./include/linux/rtnetlink.h:70:2: note: in expansion of macro 
‘rcu_dereference_check’

  rcu_dereference_check(p, lockdep_rtnl_is_held())
  ^
net/core/rtnetlink.c:1059:15: note: in expansion of macro 
‘rcu_dereference_rtnl’

    return rcu_dereference_rtnl(dev->dpll_pin);
   ^~~~
  CC  crypto/algboss.o
net/core/rtnetlink.c:1063:1: error: control reaches end of non-void 
function [-Werror=return-type]

 }
 ^
  CC  crypto/authenc.o
  CC  crypto/authencesn.o
  CC  crypto/af_alg.o
  CC  crypto/algif_hash.o
  CC  crypto/algif_skcipher.o
  CC  crypto/algif_rng.o
  CC  crypto/algif_aead.o
  AR  arch/powerpc/kernel/built-in.a
cc1: some warnings being treated as errors
make[4]: *** [scripts/Makefile.build:243: net/core/rtnetlink.o] Error 1
make[4]: *** Waiting for unfinished jobs
  CC  lib/kobject_uevent.o
  AR  drivers/net/mdio/built-in.a
  AR  net/802/built-in.a
  AR  drivers/connector/built-in.a
  CC  lib/vsprintf.o
  AR  ipc/built-in.a
  AR  net/nsh/built-in.a
  CC  lib/dynamic_debug.o
In file included from ./arch/powerpc/include/generated/asm/rwonce.h:1,
 from ./include/linux/compiler.h:251,
 from ./include/linux/instrumented.h:10,
 from ./include/linux/uaccess.h:6,
 from net/core/dev.c:71:
net/core/dev.c: In function ‘netdev_dpll_pin_assign’:
./include/linux/rcupdate.h:462:36: error: dereferencing pointer to 
incomplete type ‘struct dpll_pin’

 #define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
    ^~~~
./include/asm-generic/rwonce.h:55:33: note: in definition of macro 
‘__WRITE_ONCE’

  *(volatile typeof(x) *)&(x) = (val);    \
 ^~~
./arch/powerpc/include/asm/barrier.h:76:2: note: in expansion of macro 
‘WRITE_ONCE’

  WRITE_ONCE(*p, v);  \
  ^~
./include/asm-generic/barrier.h:172:55: note: in expansion of macro 
‘__smp_store_release’
 #define smp_store_release(p, v) do { kcsan_release(); 
__smp_store_release(p, v); } while (0)

^~~
./include/linux/rcupdate.h:503:3: note: in expansion of macro 
‘smp_store_release’

   smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
   ^
./include/linux/rcupdate.h:503:25: note: in expansion of macro 
‘RCU_INITIALIZER’

   smp_store_release(, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
 ^~~
net/core/dev.c:9081:2: note: in expansion of macro ‘rcu_assign_pointer’
  rcu_assign_pointer(dev->dpll_pin, dpll_pin);
  ^~

On 2/28/24 20:13, Eric Dumazet wrote:

On Wed, Feb 28, 2024 at 3:07 PM Vadim Fedorenko
 wrote:

On 28/02/2024 11:09, Tasmiya Nalatwad wrote:

Greetings,

[revert 0d60d8df6f49] [net/net-next] [6.8-rc5] Build Failure

Reverting below commit fixes the issue

commit 0d60d8df6f493bb46bf5db40d39dd60a1bafdd4e
  dpll: rely on rcu for netdev_dpll_pin()

--- Traces ---

./include/linux/dpll.h: In function ‘netdev_dpll_pin’:
./include/linux/rcupdate.h:439:9: error: dereferencing pointer to
incomplete type ‘struct dpll_pin’
typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
   ^
./include/linux/rcupdate.h:587:2: note: in expansion of macro
‘__rcu_dereference_check’
__rcu_dereference_check((p), __UNIQUE_ID(rcu), \
^~~
./include/linux/rtnetlink.h:70:2: note: in expansion of macro
‘rcu_dereference_check’
rcu_dereference_check(p, lockdep_rtnl_is_held())
^
./include/linux/dpll.h:175:9: note: in expansion of macro
‘rcu_dereference_rtnl’
return rcu_dereference_rtnl(dev->dpll_pin);
   ^~~~
make[4]: *** [scripts/Makefile.build:243: drivers/dpll/dpll_core.o] Error 1
make[4]: *** Waiting for unfinished jobs
AR  net/mpls/built-in.a
AR  net/l3mdev/built-in.a
In file included from ./include/linux/rbtree.h:24,
   from 

Re: [PATCH] ASoC: soc-card: Fix missing locking in snd_soc_card_get_kcontrol()

2024-02-29 Thread Takashi Iwai
On Wed, 21 Feb 2024 13:37:10 +0100,
Richard Fitzgerald wrote:
> 
> snd_soc_card_get_kcontrol() must be holding a read lock on
> card->controls_rwsem while walking the controls list.
> 
> Compare with snd_ctl_find_numid().
> 
> The existing function is renamed snd_soc_card_get_kcontrol_locked()
> so that it can be called from contexts that are already holding
> card->controls_rwsem (for example, control get/put functions).
> 
> There are few direct or indirect callers of
> snd_soc_card_get_kcontrol(), and most are safe. Three require
> changes, which have been included in this patch:
> 
> codecs/cs35l45.c:
>   cs35l45_activate_ctl() is called from a control put() function so
>   is changed to call snd_soc_card_get_kcontrol_locked().
> 
> codecs/cs35l56.c:
>   cs35l56_sync_asp1_mixer_widgets_with_firmware() is called from
>   control get()/put() functions so is changed to call
>   snd_soc_card_get_kcontrol_locked().
> 
> fsl/fsl_xcvr.c:
>   fsl_xcvr_activate_ctl() is called from three places, one of which
>   already holds card->controls_rwsem:
>   1. fsl_xcvr_mode_put(), a control put function, which will
>  already be holding card->controls_rwsem.
>   2. fsl_xcvr_startup(), a DAI startup function.
>   3. fsl_xcvr_shutdown(), a DAI shutdown function.
> 
>   To fix this, fsl_xcvr_activate_ctl() has been changed to call
>   snd_soc_card_get_kcontrol_locked() so that it is safe to call
>   directly from fsl_xcvr_mode_put().
>   The fsl_xcvr_startup() and fsl_xcvr_shutdown() functions have been
>   changed to take a read lock on card->controls_rsem() around calls
>   to fsl_xcvr_activate_ctl(). While this is not very elegant, it
>   keeps the change small, to avoid this patch creating a large
>   collateral churn in fsl/fsl_xcvr.c.
> 
> Analysis of other callers of snd_soc_card_get_kcontrol() is that
> they do not need any changes, they are not holding card->controls_rwsem
> when they call snd_soc_card_get_kcontrol().
> 
> Direct callers of snd_soc_card_get_kcontrol():
>   fsl/fsl_spdif.c: fsl_spdif_dai_probe() - DAI probe function
>   fsl/fsl_micfil.c: voice_detected_fn() - IRQ handler
> 
> Indirect callers via soc_component_notify_control():
>   codecs/cs42l43: cs42l43_mic_shutter() - IRQ handler
>   codecs/cs42l43: cs42l43_spk_shutter() - IRQ handler
>   codecs/ak4118.c: ak4118_irq_handler() - IRQ handler
>   codecs/wm_adsp.c: wm_adsp_write_ctl() - not currently used
> 
> Indirect callers via snd_soc_limit_volume():
>   qcom/sc8280xp.c: sc8280xp_snd_init() - DAIlink init function
>   ti/rx51.c: rx51_aic34_init() - DAI init function
> 
> I don't have hardware to test the fsl/*, qcom/sc828xp.c, ti/rx51.c
> and ak4118.c changes.
> 
> Backport note:
> The fsl/, qcom/, cs35l45, cs35l56 and cs42l43 callers were added
> since the Fixes commit so won't all be present on older kernels.
> 
> Signed-off-by: Richard Fitzgerald 
> Fixes: 209c6cdfd283 ("ASoC: soc-card: move snd_soc_card_get_kcontrol() to 
> soc-card")
> ---
> It would be great if people could test the fsl/, qcom/, ti/rx51 and ak4418
> drivers.

This fix itself looks correct, and I merged Mark's PR now.

But in general, it'd be better to use snd_ctl_find_id() and
snd_ctl_find_id_unlocked() if possible.  Those standard APIs can use
the fast Xarray lookup, and especially for the case like many ASoC
drivers that expose hundreds of kcontrols, the performance gain
becomes significant.

I see that there is no snd_ctl_find_mixer_id_unlocked() variant, but
it should be trivial to add.


thanks,

Takashi


Re: [PATCH v17 2/6] crash: add a new kexec flag for hotplug support

2024-02-29 Thread Sourabh Jain




On 29/02/24 11:26, Baoquan He wrote:

On 02/29/24 at 10:35am, Sourabh Jain wrote:

Hello Baoquan,

Do you have any comments or suggestions for this patch series, especially
for this patch?

Have applied this series and reviewing, will ack or add comment if any
concern. Thanks.


Thanks, looking forward to your feedback!

- Sourabh




On 26/02/24 14:11, Sourabh Jain wrote:

Commit a72bbec70da2 ("crash: hotplug support for kexec_load()")
introduced a new kexec flag, `KEXEC_UPDATE_ELFCOREHDR`. Kexec tool uses
this flag to indicate to the kernel that it is safe to modify the
elfcorehdr of the kdump image loaded using the kexec_load system call.

However, it is possible that architectures may need to update kexec
segments other then elfcorehdr. For example, FDT (Flatten Device Tree)
on PowerPC. Introducing a new kexec flag for every new kexec segment
may not be a good solution. Hence, a generic kexec flag bit,
`KEXEC_CRASH_HOTPLUG_SUPPORT`, is introduced to share the CPU/Memory
hotplug support intent between the kexec tool and the kernel for the
kexec_load system call.

Now, if the kexec tool sends KEXEC_CRASH_HOTPLUG_SUPPORT kexec flag to
the kernel, it indicates to the kernel that all the required kexec
segment is skipped from SHA calculation and it is safe to update kdump
image loaded using the kexec_load syscall.

While loading the kdump image using the kexec_load syscall, the
@update_elfcorehdr member of struct kimage is set if the kexec tool
sends the KEXEC_UPDATE_ELFCOREHDR kexec flag. This member is later used
to determine whether it is safe to update elfcorehdr on hotplug events.
However, with the introduction of the KEXEC_CRASH_HOTPLUG_SUPPORT kexec
flag, the kexec tool could mark all the required kexec segments on an
architecture as safe to update. So rename the @update_elfcorehdr to
@hotplug_support. If @hotplug_support is set, the kernel can safely
update all the required kexec segments of the kdump image during
CPU/Memory hotplug events.

Introduce an architecture-specific function to process kexec flags for
determining hotplug support. Set the @hotplug_support member of struct
kimage for both kexec_load and kexec_file_load system calls. This
simplifies kernel checks to identify hotplug support for the currently
loaded kdump image by just examining the value of @hotplug_support.

Signed-off-by: Sourabh Jain 
Cc: Akhil Raj 
Cc: Andrew Morton 
Cc: Aneesh Kumar K.V 
Cc: Baoquan He 
Cc: Borislav Petkov (AMD) 
Cc: Boris Ostrovsky 
Cc: Christophe Leroy 
Cc: Dave Hansen 
Cc: Dave Young 
Cc: David Hildenbrand 
Cc: Eric DeVolder 
Cc: Greg Kroah-Hartman 
Cc: Hari Bathini 
Cc: Laurent Dufour 
Cc: Mahesh Salgaonkar 
Cc: Michael Ellerman 
Cc: Mimi Zohar 
Cc: Naveen N Rao 
Cc: Oscar Salvador 
Cc: Thomas Gleixner 
Cc: Valentin Schneider 
Cc: Vivek Goyal 
Cc: ke...@lists.infradead.org
Cc: x...@kernel.org
---
   arch/x86/include/asm/kexec.h | 11 ++-
   arch/x86/kernel/crash.c  | 28 +---
   drivers/base/cpu.c   |  2 +-
   drivers/base/memory.c|  2 +-
   include/linux/crash_core.h   | 13 ++---
   include/linux/kexec.h| 11 +++
   include/uapi/linux/kexec.h   |  1 +
   kernel/crash_core.c  | 11 ---
   kernel/kexec.c   |  4 ++--
   kernel/kexec_file.c  |  5 +
   10 files changed, 46 insertions(+), 42 deletions(-)

diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
index cb1320ebbc23..ae5482a2f0ca 100644
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -210,15 +210,8 @@ extern void kdump_nmi_shootdown_cpus(void);
   void arch_crash_handle_hotplug_event(struct kimage *image, void *arg);
   #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
-#ifdef CONFIG_HOTPLUG_CPU
-int arch_crash_hotplug_cpu_support(void);
-#define crash_hotplug_cpu_support arch_crash_hotplug_cpu_support
-#endif
-
-#ifdef CONFIG_MEMORY_HOTPLUG
-int arch_crash_hotplug_memory_support(void);
-#define crash_hotplug_memory_support arch_crash_hotplug_memory_support
-#endif
+int arch_crash_hotplug_support(struct kimage *image, unsigned long 
kexec_flags);
+#define arch_crash_hotplug_support arch_crash_hotplug_support
   unsigned int arch_crash_get_elfcorehdr_size(void);
   #define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 2a682fe86352..f06501445cd9 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -402,20 +402,26 @@ int crash_load_segments(struct kimage *image)
   #undef pr_fmt
   #define pr_fmt(fmt) "crash hp: " fmt
-/* These functions provide the value for the sysfs crash_hotplug nodes */
-#ifdef CONFIG_HOTPLUG_CPU
-int arch_crash_hotplug_cpu_support(void)
+int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags)
   {
-   return crash_check_update_elfcorehdr();
-}
-#endif
-#ifdef CONFIG_MEMORY_HOTPLUG
-int