Re: [PATCH] powerpc/kvm: fix repeated words in comments Delete the redundant word 'that'.

2022-07-25 Thread Julia Lawall



On Mon, 25 Jul 2022, Michael Ellerman wrote:

> wangjianli  writes:
> > Signed-off-by: wangjianli 
> > ---
> >  arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c 
> > b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> > index 514fd45c1994..73c6db20cd8a 100644
> > --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> > +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> > @@ -1601,7 +1601,7 @@ long kvm_vm_ioctl_resize_hpt_commit(struct kvm *kvm,
> >   * is valid, it is written to the HPT as if an H_ENTER with the
> >   * exact flag set was done.  When the invalid count is non-zero
> >   * in the header written to the stream, the kernel will make
> > - * sure that that many HPTEs are invalid, and invalidate them
> > + * sure that many HPTEs are invalid, and invalidate them
> >   * if not.
>
> The existing wording is correct:
>
>  "the kernel will make sure that ... that many HPTEs are invalid"

Maybe it would be better as "that the number of invalid HPTEs is the same
as the invalid count"?

julia


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Andy Shevchenko
On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  wrote:
>
> archrandom.h includes  to refer ppc_md. This causes
> circular header dependency, if generic nodemask.h  includes random.h:
>
> In file included from include/linux/cred.h:16,
>  from include/linux/seq_file.h:13,
>  from arch/powerpc/include/asm/machdep.h:6,
>  from arch/powerpc/include/asm/archrandom.h:5,
>  from include/linux/random.h:109,
>  from include/linux/nodemask.h:97,
>  from include/linux/list_lru.h:12,
>  from include/linux/fs.h:13,
>  from include/linux/compat.h:17,
>  from arch/powerpc/kernel/asm-offsets.c:12:
> include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
>  1203 | nodemask_t  mems_allowed;
>   | ^~
>
> Fix it by removing  dependency from archrandom.h

...

>  EXPORT_SYMBOL_GPL(pm_power_off);

^^^ (Note this and read below)

...

> +EXPORT_SYMBOL(arch_get_random_seed_long);

It can't be like this. Brief browsing of the callees shows that.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH linux-next] powerpc: init jump label early in ppc 64

2022-07-25 Thread Michael Ellerman
zhouzho...@gmail.com writes:
> From: Zhouyi Zhou 
>
> In ppc 64, invoke jump_label_init in setup_feature_keys is too late
> because static key will be used in subroutine of early_init_devtree.
>
> So we can invoke jump_label_init earlier in early_setup.
> We can not move setup_feature_keys backward because its subroutine
> cpu_feature_keys_init depend on data structures initialized in
> early_init_devtree.
>
> Signed-off-by: Zhouyi Zhou 
> ---
> Dear PPC developers
>
> I found this bug when trying to do rcutorture tests in ppc VM of
> Open Source Lab of Oregon State University.
>
> qemu-system-ppc64 -nographic -smp cores=8,threads=1 -net none -M pseries 
> -nodefaults -device spapr-vscsi -serial 
> file:/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/console.log
>  -m 512 -kernel 
> /home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/vmlinux
>  -append "debug_boot_weak_hash panic=-1 console=ttyS0 
> rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot 
> rcupdate.rcu_task_stall_timeout=3 rcutorture.onoff_interval=200 
> rcutorture.onoff_holdoff=30 rcutree.gp_preinit_delay=12 
> rcutree.gp_init_delay=3 rcutree.gp_cleanup_delay=3 rcutree.kthread_prio=2 
> threadirqs tree.use_softirq=0 rcutorture.n_barrier_cbs=4 
> rcutorture.stat_interval=15 rcutorture.shutdown_secs=420 
> rcutorture.test_no_idle_hz=1 rcutorture.verbose=1"
>
> console.log report following WARN:
> [0.00][T0] static_key_enable_cpuslocked(): static key 
> '0xc2953260' used before call to jump_label_init()^M
> [0.00][T0] WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 
> static_key_enable_cpuslocked+0xfc/0x120^M
> [0.00][T0] Modules linked in:^M
> [0.00][T0] CPU: 0 PID: 0 Comm: swapper Not tainted 
> 5.19.0-rc5-next-20220708-dirty #131^M
> [0.00][T0] NIP:  c038068c LR: c0380688 CTR: 
> c0186ac0^M
> [0.00][T0] REGS: c2867930 TRAP: 0700   Not tainted  
> (5.19.0-rc5-next-20220708-dirty)^M
> [0.00][T0] MSR:  80022003   CR: 24282224  
> XER: 2004^M
> [0.00][T0] CFAR: 0730 IRQMASK: 1 ^M
> [0.00][T0] GPR00: c0380688 c2867bd0 
> c2868d00 0065 ^M
> [0.00][T0] GPR04: 0001  
> 0080 000d ^M
> [0.00][T0] GPR08:   
> c27fd000 000f ^M
> [0.00][T0] GPR12: c0186ac0 c2082280 
> 0003 000d ^M
> [0.00][T0] GPR16: 02cc00d0  
> c2082280 0001 ^M
> [0.00][T0] GPR20: c2080942  
>   ^M
> [0.00][T0] GPR24:  c10d6168 
>  c20034c8 ^M
> [0.00][T0] GPR28: 0028  
> c2080942 c2953260 ^M
> [0.00][T0] NIP [c038068c] 
> static_key_enable_cpuslocked+0xfc/0x120^M
> [0.00][T0] LR [c0380688] 
> static_key_enable_cpuslocked+0xf8/0x120^M
> [0.00][T0] Call Trace:^M
> [0.00][T0] [c2867bd0] [c0380688] 
> static_key_enable_cpuslocked+0xf8/0x120 (unreliable)^M
> [0.00][T0] [c2867c40] [c0380810] 
> static_key_enable+0x30/0x50^M
> [0.00][T0] [c2867c70] [c2030314] 
> setup_forced_irqthreads+0x28/0x40^M
> [0.00][T0] [c2867c90] [c2003568] 
> do_early_param+0xa0/0x108^M
> [0.00][T0] [c2867d10] [c0175340] 
> parse_args+0x290/0x4e0^M
> [0.00][T0] [c2867e10] [c2003c74] 
> parse_early_options+0x48/0x5c^M
> [0.00][T0] [c2867e30] [c2003ce0] 
> parse_early_param+0x58/0x84^M
> [0.00][T0] [c2867e60] [c2009878] 
> early_init_devtree+0xd4/0x518^M
> [0.00][T0] [c2867f10] [c200aee0] 
> early_setup+0xb4/0x214^M
>
> After this fix, the WARN does not show again.

Hi Zhouyi,

We have hit something like this previously, see the stack trace in
commit e7eb919057c3 ("powerpc/64s: Handle program checks in wrong endian
during early boot").

That was fixed incidentally/accidentally by the page_poison code
changing to not use static keys so early.

There was a similar case recently in the random code too, see
60e5b2886b92 ("random: do not use jump labels before they are
initialized").

But I guess this will keep happening, as generic code authors expect to
be able to use static keys in early_param() handlers.

I think the ideal solution would be to move most early param parsing
later. There's only a few parameters that need to be parsed that early
in e

Re: Regression: Linux v5.15+ does not boot on Freescale P2020

2022-07-25 Thread Michael Ellerman
Pali Rohár  writes:
> On Saturday 23 July 2022 14:42:22 Christophe Leroy wrote:
>> Le 22/07/2022 à 11:09, Pali Rohár a écrit :
>> > Trying to boot mainline Linux kernel v5.15+, including current version
>> > from master branch, on Freescale P2020 does not work. Kernel does not
>> > print anything to serial console, seems that it does not work and after
>> > timeout watchdog reset the board.
>> 
>> Can you provide more information ? Which defconfig or .config, which 
>> version of gcc, etc ... ?
>
> I used default defconfig for mpc85xx with gcc 8, compilation for e500
> cores.
>
> If you need exact .config content I can send it during week.
>
>> > I run git bisect and it found following commit:
>> > 
>> > 9401f4e46cf6965e23738f70e149172344a01eef is the first bad commit
>> > commit 9401f4e46cf6965e23738f70e149172344a01eef
>> > Author: Christophe Leroy 
>> > Date:   Tue Mar 2 08:48:11 2021 +
>> > 
>> >  powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros
>> > 
>> >  Force the eh flag at 0 on PPC32.
>> > 
>> >  Signed-off-by: Christophe Leroy 
>> >  Signed-off-by: Michael Ellerman 
>> >  Link: 
>> > https://lore.kernel.org/r/1fc81f07cabebb875b963e295408cc3dd38c8d85.1614674882.git.christophe.le...@csgroup.eu
>> > 
>> > :04 04 fe6747e45736dfcba74914a9445e5f70f5120600 
>> > 96358d08b65d3200928a973efb5b969b3d45f2b0 M  arch
>> > 
>> > 
>> > If I revert this commit then kernel boots correctly. It also boots fine
>> > if I revert this commit on top of master branch.
>> > 
>> > Freescale P2020 has two 32-bit e500 powerpc cores.
>> > 
>> > Any idea why above commit is causing crash of the kernel? And why it is
>> > needed? Could eh flag set to 0 cause deadlock?
>> 
>> Setting the eh flag to 0 is not supposed to be a change introduced by 
>> that commit. Indeed that commit is not supposed to change anything at 
>> all in the generated code.
>
> My understanding of that commit is that it changed eh flag parameter
> from 1 to 0 for 32-bit powerpc, including also p2020.

Can you compare the disassembly before and after and find a place where
an instruction has changed?

cheers


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Michael Ellerman
Yury Norov  writes:
> archrandom.h includes  to refer ppc_md. This causes
> circular header dependency, if generic nodemask.h  includes random.h:
>
> In file included from include/linux/cred.h:16,
>  from include/linux/seq_file.h:13,
>  from arch/powerpc/include/asm/machdep.h:6,
>  from arch/powerpc/include/asm/archrandom.h:5,
>  from include/linux/random.h:109,
>  from include/linux/nodemask.h:97,
>  from include/linux/list_lru.h:12,
>  from include/linux/fs.h:13,
>  from include/linux/compat.h:17,
>  from arch/powerpc/kernel/asm-offsets.c:12:
> include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
>  1203 | nodemask_t  mems_allowed;
>   | ^~
>
> Fix it by removing  dependency from archrandom.h
>
> Signed-off-by: Yury Norov 
> ---
>  arch/powerpc/include/asm/archrandom.h |  9 +
>  arch/powerpc/kernel/setup-common.c| 11 +++
>  2 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/archrandom.h 
> b/arch/powerpc/include/asm/archrandom.h
> index 9a53e29680f4..21def59ef1a6 100644
> --- a/arch/powerpc/include/asm/archrandom.h
> +++ b/arch/powerpc/include/asm/archrandom.h
> @@ -4,7 +4,7 @@
>  
>  #ifdef CONFIG_ARCH_RANDOM
>  
> -#include 
> +bool __must_check arch_get_random_seed_long(unsigned long *v);
>  
>  static inline bool __must_check arch_get_random_long(unsigned long *v)
>  {
> @@ -16,13 +16,6 @@ static inline bool __must_check 
> arch_get_random_int(unsigned int *v)
>   return false;
>  }
>  
> -static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
> -{
> - if (ppc_md.get_random_seed)
> - return ppc_md.get_random_seed(v);
> -
> - return false;
> -}

I'd rather we didn't have to force this out of line.

I think I see a different way to fix it, I'll just do some more build
tests.

cheers


Re: [PATCH linux-next] powerpc: init jump label early in ppc 64

2022-07-25 Thread Zhouyi Zhou
On Mon, Jul 25, 2022 at 3:55 PM Michael Ellerman  wrote:
>
> zhouzho...@gmail.com writes:
> > From: Zhouyi Zhou 
> >
> > In ppc 64, invoke jump_label_init in setup_feature_keys is too late
> > because static key will be used in subroutine of early_init_devtree.
> >
> > So we can invoke jump_label_init earlier in early_setup.
> > We can not move setup_feature_keys backward because its subroutine
> > cpu_feature_keys_init depend on data structures initialized in
> > early_init_devtree.
> >
> > Signed-off-by: Zhouyi Zhou 
> > ---
> > Dear PPC developers
> >
> > I found this bug when trying to do rcutorture tests in ppc VM of
> > Open Source Lab of Oregon State University.
> >
> > qemu-system-ppc64 -nographic -smp cores=8,threads=1 -net none -M pseries 
> > -nodefaults -device spapr-vscsi -serial 
> > file:/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/console.log
> >  -m 512 -kernel 
> > /home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/vmlinux
> >  -append "debug_boot_weak_hash panic=-1 console=ttyS0 
> > rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot 
> > rcupdate.rcu_task_stall_timeout=3 rcutorture.onoff_interval=200 
> > rcutorture.onoff_holdoff=30 rcutree.gp_preinit_delay=12 
> > rcutree.gp_init_delay=3 rcutree.gp_cleanup_delay=3 rcutree.kthread_prio=2 
> > threadirqs tree.use_softirq=0 rcutorture.n_barrier_cbs=4 
> > rcutorture.stat_interval=15 rcutorture.shutdown_secs=420 
> > rcutorture.test_no_idle_hz=1 rcutorture.verbose=1"
> >
> > console.log report following WARN:
> > [0.00][T0] static_key_enable_cpuslocked(): static key 
> > '0xc2953260' used before call to jump_label_init()^M
> > [0.00][T0] WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 
> > static_key_enable_cpuslocked+0xfc/0x120^M
> > [0.00][T0] Modules linked in:^M
> > [0.00][T0] CPU: 0 PID: 0 Comm: swapper Not tainted 
> > 5.19.0-rc5-next-20220708-dirty #131^M
> > [0.00][T0] NIP:  c038068c LR: c0380688 CTR: 
> > c0186ac0^M
> > [0.00][T0] REGS: c2867930 TRAP: 0700   Not tainted  
> > (5.19.0-rc5-next-20220708-dirty)^M
> > [0.00][T0] MSR:  80022003   CR: 24282224  
> > XER: 2004^M
> > [0.00][T0] CFAR: 0730 IRQMASK: 1 ^M
> > [0.00][T0] GPR00: c0380688 c2867bd0 
> > c2868d00 0065 ^M
> > [0.00][T0] GPR04: 0001  
> > 0080 000d ^M
> > [0.00][T0] GPR08:   
> > c27fd000 000f ^M
> > [0.00][T0] GPR12: c0186ac0 c2082280 
> > 0003 000d ^M
> > [0.00][T0] GPR16: 02cc00d0  
> > c2082280 0001 ^M
> > [0.00][T0] GPR20: c2080942  
> >   ^M
> > [0.00][T0] GPR24:  c10d6168 
> >  c20034c8 ^M
> > [0.00][T0] GPR28: 0028  
> > c2080942 c2953260 ^M
> > [0.00][T0] NIP [c038068c] 
> > static_key_enable_cpuslocked+0xfc/0x120^M
> > [0.00][T0] LR [c0380688] 
> > static_key_enable_cpuslocked+0xf8/0x120^M
> > [0.00][T0] Call Trace:^M
> > [0.00][T0] [c2867bd0] [c0380688] 
> > static_key_enable_cpuslocked+0xf8/0x120 (unreliable)^M
> > [0.00][T0] [c2867c40] [c0380810] 
> > static_key_enable+0x30/0x50^M
> > [0.00][T0] [c2867c70] [c2030314] 
> > setup_forced_irqthreads+0x28/0x40^M
> > [0.00][T0] [c2867c90] [c2003568] 
> > do_early_param+0xa0/0x108^M
> > [0.00][T0] [c2867d10] [c0175340] 
> > parse_args+0x290/0x4e0^M
> > [0.00][T0] [c2867e10] [c2003c74] 
> > parse_early_options+0x48/0x5c^M
> > [0.00][T0] [c2867e30] [c2003ce0] 
> > parse_early_param+0x58/0x84^M
> > [0.00][T0] [c2867e60] [c2009878] 
> > early_init_devtree+0xd4/0x518^M
> > [0.00][T0] [c2867f10] [c200aee0] 
> > early_setup+0xb4/0x214^M
> >
> > After this fix, the WARN does not show again.
>
> Hi Zhouyi,
Thank Michael for your guidance.
>
> We have hit something like this previously, see the stack trace in
> commit e7eb919057c3 ("powerpc/64s: Handle program checks in wrong endian
> during early boot").
I am learning the fantastic work by you (git log -p e7eb919057c3),
e7eb919057c3 provides
a trampoline to detect and correct the wrong endian when handling the
exception caused by the WARN
(static key used before call to jump_label_init)
>
> T

Re: [PATCH v3] random: handle archrandom with multiple longs

2022-07-25 Thread Borislav Petkov
On Tue, Jul 19, 2022 at 03:02:07PM +0200, Jason A. Donenfeld wrote:
> Since callers need to check this return value and loop anyway, each arch
> implementation does not bother implementing its own loop to try again to
> fill the maximum number of longs. Additionally, all existing callers
> pass in a constant max_longs parameter.

Hmm, maybe this has come up already but it reads weird.

If I have a function arch_get_random_longs(), I'd expect it to give me
the number of longs I requested or say, error.

Why do the callers need to loop?

If I have to loop, I'd call the "get me one long" function and loop N
times.

-- 
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
(HRB 36809, AG Nürnberg)


RE: [PATCH v3] random: handle archrandom with multiple longs

2022-07-25 Thread David Laight
...
> More directly, the reason we don't want to error is because the use case
> has fallbacks meant to handle errors. The cascade looks like this
> (quoting from the other email):
> 
> unsigned long array[whatever];
> for (i = 0; i < ARRAY_SIZE(array);) {
> longs = arch_get_random_seed_longs(&array[i], ARRAY_SIZE(array) - i);
> if (longs) {
> i += longs;
> continue;
> }
> longs = arch_get_random_longs(&array[i], ARRAY_SIZE(array) - i);
> if (longs) {
> i += longs;
> continue;
> }
> array[i++] = random_get_entropy();
> }
> 
> It tries to get the best that it can as much as it can, but isn't going
> to block or do anything too nuts for that.

Do you really want to retry the earlier calls that returned no data?

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)


Re: [PATCH] powerpc/kvm: fix repeated words in comments Delete the redundant word 'that'.

2022-07-25 Thread Michael Ellerman
Julia Lawall  writes:
> On Mon, 25 Jul 2022, Michael Ellerman wrote:
>> wangjianli  writes:
>> > diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c 
>> > b/arch/powerpc/kvm/book3s_64_mmu_hv.c
>> > index 514fd45c1994..73c6db20cd8a 100644
>> > --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
>> > +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
>> > @@ -1601,7 +1601,7 @@ long kvm_vm_ioctl_resize_hpt_commit(struct kvm *kvm,
>> >   * is valid, it is written to the HPT as if an H_ENTER with the
>> >   * exact flag set was done.  When the invalid count is non-zero
>> >   * in the header written to the stream, the kernel will make
>> > - * sure that that many HPTEs are invalid, and invalidate them
>> > + * sure that many HPTEs are invalid, and invalidate them
>> >   * if not.
>>
>> The existing wording is correct:
>>
>>  "the kernel will make sure that ... that many HPTEs are invalid"
>
> Maybe it would be better as "that the number of invalid HPTEs is the same
> as the invalid count"?

That doesn't read quite right, I think because if the number of invalid
HPTEs doesn't match the invalid count, the code will invalidate HPTEs so
that the number matches.

So maybe:

  When the invalid count is non-zero in the header written to the stream,
  the kernel will make sure that number of HPTEs are invalid, or
  invalidate them if not.

cheers


Re: [PATCH v3] random: handle archrandom with multiple longs

2022-07-25 Thread Borislav Petkov
On Tue, Jul 19, 2022 at 03:02:07PM +0200, Jason A. Donenfeld wrote:
> The archrandom interface was originally designed for x86, which supplies
> RDRAND/RDSEED for receiving random words into registers, resulting in
> one function to generate an int and another to generate a long. However,
> other architectures don't follow this.
> 
> On arm64, the SMCCC TRNG interface can return between 1 and 3 longs. On
> s390, the CPACF TRNG interface can return arbitrary amounts, with 32
> longs having the same cost as one. On UML, the os_getrandom() interface
> can return arbitrary amounts.
> 
> So change the api signature to take a "max_longs" parameter designating
> the maximum number of longs requested, and then return the number of
> longs generated.
> 
> Since callers need to check this return value and loop anyway, each arch
> implementation does not bother implementing its own loop to try again to
> fill the maximum number of longs. Additionally, all existing callers
> pass in a constant max_longs parameter. Taken together, these two things
> mean that the codegen doesn't really change much for one-word-at-a-time
> platforms, while performance is greatly improved on platforms such as
> s390.
> 
> Cc: Will Deacon 
> Cc: Alexander Gordeev 
> Cc: Thomas Gleixner 
> Cc: H. Peter Anvin 
> Cc: Catalin Marinas 
> Cc: Borislav Petkov 
> Cc: Heiko Carstens 
> Cc: Johannes Berg 
> Cc: Mark Rutland 
> Cc: Harald Freudenberger 
> Acked-by: Michael Ellerman 
> Signed-off-by: Jason A. Donenfeld 
> ---
>  arch/arm64/include/asm/archrandom.h   | 102 --
>  arch/arm64/kernel/kaslr.c |   2 +-
>  arch/powerpc/include/asm/archrandom.h |  30 ++--
>  arch/powerpc/kvm/book3s_hv.c  |   2 +-
>  arch/s390/include/asm/archrandom.h|  29 ++--
>  arch/um/include/asm/archrandom.h  |  21 ++
>  arch/x86/include/asm/archrandom.h |  41 +--
>  arch/x86/kernel/espfix_64.c   |   2 +-
>  drivers/char/random.c |  45 
>  include/asm-generic/archrandom.h  |  18 +
>  include/linux/random.h|  12 +--
>  11 files changed, 116 insertions(+), 188 deletions(-)

Acked-by: Borislav Petkov  # for x86

Thx.

-- 
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
(HRB 36809, AG Nürnberg)


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Michael Ellerman
Michael Ellerman  writes:
> Yury Norov  writes:
>> archrandom.h includes  to refer ppc_md. This causes
>> circular header dependency, if generic nodemask.h  includes random.h:
>>
>> In file included from include/linux/cred.h:16,
>>  from include/linux/seq_file.h:13,
>>  from arch/powerpc/include/asm/machdep.h:6,
>>  from arch/powerpc/include/asm/archrandom.h:5,
>>  from include/linux/random.h:109,
>>  from include/linux/nodemask.h:97,
>>  from include/linux/list_lru.h:12,
>>  from include/linux/fs.h:13,
>>  from include/linux/compat.h:17,
>>  from arch/powerpc/kernel/asm-offsets.c:12:
>> include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
>>  1203 | nodemask_t  mems_allowed;
>>   | ^~
>>
>> Fix it by removing  dependency from archrandom.h
>>
>> Signed-off-by: Yury Norov 
>> ---
>>  arch/powerpc/include/asm/archrandom.h |  9 +
>>  arch/powerpc/kernel/setup-common.c| 11 +++
>>  2 files changed, 12 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/archrandom.h 
>> b/arch/powerpc/include/asm/archrandom.h
>> index 9a53e29680f4..21def59ef1a6 100644
>> --- a/arch/powerpc/include/asm/archrandom.h
>> +++ b/arch/powerpc/include/asm/archrandom.h
>> @@ -4,7 +4,7 @@
>>  
>>  #ifdef CONFIG_ARCH_RANDOM
>>  
>> -#include 
>> +bool __must_check arch_get_random_seed_long(unsigned long *v);
>>  
>>  static inline bool __must_check arch_get_random_long(unsigned long *v)
>>  {
>> @@ -16,13 +16,6 @@ static inline bool __must_check 
>> arch_get_random_int(unsigned int *v)
>>  return false;
>>  }
>>  
>> -static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
>> -{
>> -if (ppc_md.get_random_seed)
>> -return ppc_md.get_random_seed(v);
>> -
>> -return false;
>> -}
>
> I'd rather we didn't have to force this out of line.
>
> I think I see a different way to fix it, I'll just do some more build
> tests.

Of course my idea didn't work :}

So I'll just ack your patch for now, and maybe I can get the headers
cleaned up in future to allow it to be out-of-line again.

cheers


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Michael Ellerman
Yury Norov  writes:
> archrandom.h includes  to refer ppc_md. This causes
> circular header dependency, if generic nodemask.h  includes random.h:
>
> In file included from include/linux/cred.h:16,
>  from include/linux/seq_file.h:13,
>  from arch/powerpc/include/asm/machdep.h:6,
>  from arch/powerpc/include/asm/archrandom.h:5,
>  from include/linux/random.h:109,
>  from include/linux/nodemask.h:97,
>  from include/linux/list_lru.h:12,
>  from include/linux/fs.h:13,
>  from include/linux/compat.h:17,
>  from arch/powerpc/kernel/asm-offsets.c:12:
> include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
>  1203 | nodemask_t  mems_allowed;
>   | ^~
>
> Fix it by removing  dependency from archrandom.h
>
> Signed-off-by: Yury Norov 
> ---
>  arch/powerpc/include/asm/archrandom.h |  9 +
>  arch/powerpc/kernel/setup-common.c| 11 +++
>  2 files changed, 12 insertions(+), 8 deletions(-)

Acked-by: Michael Ellerman 

cheers


Re: [PATCH] powerpc/fsl-pci: Fix Class Code of PCIe Root Port

2022-07-25 Thread Michael Ellerman
Bjorn Helgaas  writes:
> On Wed, Jul 06, 2022 at 12:10:43PM +0200, Pali Rohár wrote:
>> By default old pre-3.0 Freescale PCIe controllers reports invalid PCI Class
>> Code 0x0b20 for PCIe Root Port. It can be seen by lspci -b output on P2020
>> board which has this pre-3.0 controller:
>> 
>>   $ lspci -bvnn
>>   00:00.0 Power PC [0b20]: Freescale Semiconductor Inc P2020E [1957:0070] 
>> (rev 21)
>>   !!! Invalid class 0b20 for header type 01
>>   Capabilities: [4c] Express Root Port (Slot-), MSI 00
>> 
>> Fix this issue by programming correct PCI Class Code 0x0604 for PCIe Root
>> Port to the Freescale specific PCIe register 0x474.
>> 
>> With this change lspci -b output is:
>> 
>>   $ lspci -bvnn
>>   00:00.0 PCI bridge [0604]: Freescale Semiconductor Inc P2020E [1957:0070] 
>> (rev 21) (prog-if 00 [Normal decode])
>>   Capabilities: [4c] Express Root Port (Slot-), MSI 00
>> 
>> Without any "Invalid class" error. So class code was properly reflected
>> into standard (read-only) PCI register 0x08.
>> 
>> Same fix is already implemented in U-Boot pcie_fsl.c driver in commit:
>> http://source.denx.de/u-boot/u-boot/-/commit/d18d06ac35229345a0af80977a408cfbe1d1015b
>> 
>> Fix activated by U-Boot stay active also after booting Linux kernel.
>> But boards which use older U-Boot version without that fix are affected and
>> still require this fix.
>> 
>> So implement this class code fix also in kernel fsl_pci.c driver.
>> 
>> Cc: sta...@vger.kernel.org
>> Signed-off-by: Pali Rohár 
>
> I assume the powerpc folks will take care of this.

Will do.

cheers


Re: [PATCH] amdgpu: re-enable DCN for ppc64le

2022-07-25 Thread Michael Ellerman
Dan Horák  writes:
> On Fri, 22 Jul 2022 22:32:06 +1000
> Michael Ellerman  wrote:
>> Dan Horák  writes:
>> > Commit d11219ad53dc disabled the DCN driver for all platforms that
>> > define PPC64 due long build issues during "make allmodconfig" using
>> > cross-compilation. Cross-compilation defaults to the ppc64_defconfig
>> > and thus big-endian toolchain configuration. The ppc64le platform uses a
>> > different ABI and doesn't suffer from the build issues.
>> 
>> Unfortunately it's a bit messier than that.
>> 
>> The build error occurs when the compiler is built to use a 64-bit long
>> double type.
>> 
>> The ppc64le ABI document says that long double should be 128-bits, but
>> there are ppc64le compilers out there that are configured to use 64-bit
>> long double, notably the kernel.org crosstool compilers.
>> 
>> So just testing for CPU_LITTLE_ENDIAN means we'll still get build errors
>> on those compilers.
>> 
>> But I think we can detect the long double size and key off that. Can you
>> test the patch below works for you?
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 7aa12e88c580..e9f8cd50af99 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -281,6 +281,9 @@ config PPC
>>  # Please keep this list sorted alphabetically.
>>  #
>>  
>> +config PCC_LONG_DOUBLE_128
>> +def_bool $(success,test "$(shell,echo __LONG_DOUBLE_128__ | $(CC) -E -P 
>> -)" = 1)
>
> ^^^ there is a typo s/PCC/PPC/ :-)

Oops, renamed it after testing :}

> with that fixed, it then defines AMD_DC_DCN on Fedora 36 with
> gcc-12.1.1-1.fc36.ppc64le and we should be OK.

Thanks. I'll send a proper patch.

cheers


Re: [PATCH v5 4/4] pseries/mobility: set NMI watchdog factor during an LPM

2022-07-25 Thread Laurent Dufour
Le 13/07/2022 à 22:17, Randy Dunlap a écrit :
> Hi Laurent,
> 
> On 7/13/22 08:47, Laurent Dufour wrote:
>> diff --git a/Documentation/admin-guide/sysctl/kernel.rst 
>> b/Documentation/admin-guide/sysctl/kernel.rst
>> index ddccd1077462..d73faa619c15 100644
>> --- a/Documentation/admin-guide/sysctl/kernel.rst
>> +++ b/Documentation/admin-guide/sysctl/kernel.rst
>> @@ -592,6 +592,18 @@ to the guest kernel command line (see
>>  Documentation/admin-guide/kernel-parameters.rst).
>>  
>>  
>> +nmi_wd_lpm_factor (PPC only)
>> +
>> +
>> +Factor apply to the NMI watchdog timeout (only when ``nmi_watchdog`` is
> 
>Factor to apply to

Thanks, Randy.

Michael, could you fix that when applying the series?

Cheers,
Laurent

> 
>> +set to 1). This factor represents the percentage added to
>> +``watchdog_thresh`` when calculating the NMI watchdog timeout during an
>> +LPM. The soft lockup timeout is not impacted.
>> +
>> +A value of 0 means no change. The default value is 200 meaning the NMI
>> +watchdog is set to 30s (based on ``watchdog_thresh`` equal to 10).
> 



[PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Michael Ellerman
Commit d11219ad53dc ("amdgpu: disable powerpc support for the newer
display engine") disabled the DCN driver for all of powerpc due to
unresolved build failures with some compilers.

Further digging shows that the build failures only occur with compilers
that default to 64-bit long double.

Both the ppc64 and ppc64le ABIs define long double to be 128-bits, but
there are compilers in the wild that default to 64-bits. The compilers
provided by the major distros (Fedora, Ubuntu) default to 128-bits and
are not affected by the build failure.

There is a compiler flag to force 128-bit long double, which may be the
correct long term fix, but as an interim fix only allow building the DCN
driver if long double is 128-bits by default.

The bisection in commit d11219ad53dc must have gone off the rails at
some point, the build failure occurs all the way back to the original
commit that enabled DCN support on powerpc, at least with some
toolchains.

Depends-on: d11219ad53dc ("amdgpu: disable powerpc support for the newer 
display engine")
Fixes: 16a9dea110a6 ("amdgpu: Enable initial DCN support on POWER")
Signed-off-by: Michael Ellerman 
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2100
---
 arch/powerpc/Kconfig| 4 
 drivers/gpu/drm/amd/display/Kconfig | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

Alex, are you OK if I take this via the powerpc tree for v5.19?

cheers

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7aa12e88c580..287cc2d4a4b3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -281,6 +281,10 @@ config PPC
# Please keep this list sorted alphabetically.
#
 
+config PPC_LONG_DOUBLE_128
+   depends on PPC64
+   def_bool $(success,test "$(shell,echo __LONG_DOUBLE_128__ | $(CC) -E -P 
-)" = 1)
+
 config PPC_BARRIER_NOSPEC
bool
default y
diff --git a/drivers/gpu/drm/amd/display/Kconfig 
b/drivers/gpu/drm/amd/display/Kconfig
index 0ba0598eba20..ec6771e87e73 100644
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@ -6,7 +6,7 @@ config DRM_AMD_DC
bool "AMD DC - Enable new display engine"
default y
select SND_HDA_COMPONENT if SND_HDA_CORE
-   select DRM_AMD_DC_DCN if X86 && !(KCOV_INSTRUMENT_ALL && 
KCOV_ENABLE_COMPARISONS)
+   select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128) && 
!(KCOV_INSTRUMENT_ALL && KCOV_ENABLE_COMPARISONS)
help
  Choose this option if you want to use the new display engine
  support for AMDGPU. This adds required support for Vega and
-- 
2.35.3



Re: Regression: Linux v5.15+ does not boot on Freescale P2020

2022-07-25 Thread Pali Rohár
On Monday 25 July 2022 18:20:01 Michael Ellerman wrote:
> Pali Rohár  writes:
> > On Saturday 23 July 2022 14:42:22 Christophe Leroy wrote:
> >> Le 22/07/2022 à 11:09, Pali Rohár a écrit :
> >> > Trying to boot mainline Linux kernel v5.15+, including current version
> >> > from master branch, on Freescale P2020 does not work. Kernel does not
> >> > print anything to serial console, seems that it does not work and after
> >> > timeout watchdog reset the board.
> >> 
> >> Can you provide more information ? Which defconfig or .config, which 
> >> version of gcc, etc ... ?
> >
> > I used default defconfig for mpc85xx with gcc 8, compilation for e500
> > cores.
> >
> > If you need exact .config content I can send it during week.
> >
> >> > I run git bisect and it found following commit:
> >> > 
> >> > 9401f4e46cf6965e23738f70e149172344a01eef is the first bad commit
> >> > commit 9401f4e46cf6965e23738f70e149172344a01eef
> >> > Author: Christophe Leroy 
> >> > Date:   Tue Mar 2 08:48:11 2021 +
> >> > 
> >> >  powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros
> >> > 
> >> >  Force the eh flag at 0 on PPC32.
> >> > 
> >> >  Signed-off-by: Christophe Leroy 
> >> >  Signed-off-by: Michael Ellerman 
> >> >  Link: 
> >> > https://lore.kernel.org/r/1fc81f07cabebb875b963e295408cc3dd38c8d85.1614674882.git.christophe.le...@csgroup.eu
> >> > 
> >> > :04 04 fe6747e45736dfcba74914a9445e5f70f5120600 
> >> > 96358d08b65d3200928a973efb5b969b3d45f2b0 M  arch
> >> > 
> >> > 
> >> > If I revert this commit then kernel boots correctly. It also boots fine
> >> > if I revert this commit on top of master branch.
> >> > 
> >> > Freescale P2020 has two 32-bit e500 powerpc cores.
> >> > 
> >> > Any idea why above commit is causing crash of the kernel? And why it is
> >> > needed? Could eh flag set to 0 cause deadlock?
> >> 
> >> Setting the eh flag to 0 is not supposed to be a change introduced by 
> >> that commit. Indeed that commit is not supposed to change anything at 
> >> all in the generated code.
> >
> > My understanding of that commit is that it changed eh flag parameter
> > from 1 to 0 for 32-bit powerpc, including also p2020.
> 
> Can you compare the disassembly before and after and find a place where
> an instruction has changed?
> 
> cheers

Yes, of course. Here is diff between output from objdump -d vmlinux.
original version --- is from git master branch and modified version +++
is the original version with reverted above problematic commit.
So the +++ version is the one which is working.

--- vmlinux.master.dump 2022-07-25 14:43:45.922239496 +0200
+++ vmlinux.revert.dump 2022-07-25 14:43:49.238259296 +0200
@@ -1,5 +1,5 @@
 
-vmlinux.master: file format elf32-powerpc
+vmlinux.revert: file format elf32-powerpc
 
 
 Disassembly of section .head.text:
@@ -11213,7 +11213,7 @@ c000b850:   3f a0 c1 0f lis r29,-1611
 c000b854:  81 02 00 04 lwz r8,4(r2)
 c000b858:  3b fd 10 68 addir31,r29,4200
 c000b85c:  39 40 00 01 li  r10,1
-c000b860:  7d 20 f8 29 lwarx   r9,0,r31,1
+c000b860:  7d 20 f8 28 lwarx   r9,0,r31
 c000b864:  2c 09 00 00 cmpwi   r9,0
 c000b868:  40 82 00 10 bne c000b878 
 c000b86c:  7d 40 f9 2d stwcx.  r10,0,r31
@@ -11227,7 +11227,7 @@ c000b888:   81 3e 00 1c lwz r9,28(r30
 c000b88c:  7f 88 48 00 cmpwcr7,r8,r9
 c000b890:  41 9e 00 38 beq cr7,c000b8c8 
 c000b894:  39 40 00 01 li  r10,1
-c000b898:  7d 20 f8 29 lwarx   r9,0,r31,1
+c000b898:  7d 20 f8 28 lwarx   r9,0,r31
 c000b89c:  2c 09 00 00 cmpwi   r9,0
 c000b8a0:  40 82 00 10 bne c000b8b0 
 c000b8a4:  7d 40 f9 2d stwcx.  r10,0,r31
@@ -186495,7 +186495,7 @@ c00b173c: 3b 40 00 00 li  r26,0
 c00b1740:  3a e0 00 00 li  r23,0
 c00b1744:  7e c0 00 a6 mfmsr   r22
 c00b1748:  7c 00 01 46 wrteei  0
-c00b174c:  7f a0 c0 29 lwarx   r29,0,r24,1
+c00b174c:  7f a0 c0 28 lwarx   r29,0,r24
 c00b1750:  2c 1d 00 00 cmpwi   r29,0
 c00b1754:  40 82 00 10 bne c00b1764 
 c00b1758:  7f 20 c1 2d stwcx.  r25,0,r24
@@ -187821,7 +187821,7 @@ c00b2b7c: 3f e0 c1 0b lis r31,-1611
 c00b2b80:  38 c0 00 01 li  r6,1
 c00b2b84:  3b ff c5 20 addir31,r31,-15072
 c00b2b88:  38 ff 02 20 addir7,r31,544
-c00b2b8c:  7d 00 38 29 lwarx   r8,0,r7,1
+c00b2b8c:  7d 00 38 28 lwarx   r8,0,r7
 c00b2b90:  2c 08 00 00 cmpwi   r8,0
 c00b2b94:  40 82 00 10 bne c00b2ba4 
 c00b2b98:  7c c0 39 2d stwcx.  r6,0,r7
@@ -187947,7 +187947,7 @@ c00b2d6c: 3f a0 c1 0b lis r29,-1611
 c00b2d70:  39 00 00 01 li  r8,1
 c00b2d74:  3b bd c5 20 addir29,r29,-15072
 c00b2d78:  39 3d 02 20 addir9,r29,544
-c00b2d7c:  7d 40 48 29 lwarx   r10,0,r9,1
+c00b2d7c:  7d 40 48 28  

Re: [PATCH v2 01/10] drm/simpledrm: Remove mem field from device structure

2022-07-25 Thread Javier Martinez Canillas
On 7/20/22 16:27, Thomas Zimmermann wrote:
> Remove the unused mem field from struct simpledrm_device.
> 
> Signed-off-by: Thomas Zimmermann 
> ---

Acked-by: Javier Martinez Canillas 

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat



Re: [PATCH v2 02/10] drm/simpledrm: Inline device-init helpers

2022-07-25 Thread Javier Martinez Canillas
Hello Thomas,

On 7/20/22 16:27, Thomas Zimmermann wrote:
> Inline the helpers for initializing the hardware FB, the memory
> management and the modesetting into the device-creation function.
> No functional changes.
>

Could you please elaborate in the commit message why this change is
desirable?  Without this additional context, this feels like going
backwards, since you are dropping few helpers that have quite self
contained code and making simpledrm_device_create() much larger.

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat



Re: [PATCH v2 03/10] drm/simpledrm: Remove pdev field from device structure

2022-07-25 Thread Javier Martinez Canillas
On 7/20/22 16:27, Thomas Zimmermann wrote:
> Replace the remaining uses of the field pdev by upcasts from the Linux
> device and remove the field.
> 
> Signed-off-by: Thomas Zimmermann 

Much better indeed.

Acked-by: Javier Martinez Canillas 

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat



[PATCH v4 00/25] net: dpaa: Cleanups in preparation for phylink conversion

2022-07-25 Thread Sean Anderson
This series contains several cleanup patches for dpaa/fman. While they
are intended to prepare for a phylink conversion, they stand on their
own. This series was originally submitted as part of [1].

[1] 
https://lore.kernel.org/netdev/20220715215954.1449214-1-sean.ander...@seco.com

Changes in v4:
- Clarify commit message
- weer -> were
- tricy -> tricky
- Use mac_dev for calling change_addr
- qman_cgr_create -> qman_create_cgr

Changes in v3:
- Incorperate some minor changes into the first FMan binding commit

Changes in v2:
- Convert FMan MAC bindings to yaml
- Remove some unused variables
- Fix prototype for dtsec_initialization
- Fix warning if sizeof(void *) != sizeof(resource_size_t)
- Specify type of mac_dev for exception_cb
- Add helper for sanity checking cgr ops
- Add CGR update function
- Adjust queue depth on rate change

Sean Anderson (25):
  dt-bindings: net: Convert FMan MAC bindings to yaml
  net: fman: Convert to SPDX identifiers
  net: fman: Don't pass comm_mode to enable/disable
  net: fman: Store en/disable in mac_device instead of mac_priv_s
  net: fman: dtsec: Always gracefully stop/start
  net: fman: Get PCS node in per-mac init
  net: fman: Store initialization function in match data
  net: fman: Move struct dev to mac_device
  net: fman: Configure fixed link in memac_initialization
  net: fman: Export/rename some common functions
  net: fman: memac: Use params instead of priv for max_speed
  net: fman: Move initialization to mac-specific files
  net: fman: Mark mac methods static
  net: fman: Inline several functions into initialization
  net: fman: Remove internal_phy_node from params
  net: fman: Map the base address once
  net: fman: Pass params directly to mac init
  net: fman: Use mac_dev for some params
  net: fman: Specify type of mac_dev for exception_cb
  net: fman: Clean up error handling
  net: fman: Change return type of disable to void
  net: dpaa: Use mac_dev variable in dpaa_netdev_init
  soc: fsl: qbman: Add helper for sanity checking cgr ops
  soc: fsl: qbman: Add CGR update function
  net: dpaa: Adjust queue depth on rate change

 .../bindings/net/fsl,fman-dtsec.yaml  | 145 +
 .../devicetree/bindings/net/fsl-fman.txt  | 128 +
 .../net/ethernet/freescale/dpaa/dpaa_eth.c|  59 ++-
 .../ethernet/freescale/dpaa/dpaa_eth_sysfs.c  |   2 +-
 drivers/net/ethernet/freescale/fman/fman.c|  31 +-
 drivers/net/ethernet/freescale/fman/fman.h|  31 +-
 .../net/ethernet/freescale/fman/fman_dtsec.c  | 325 ++--
 .../net/ethernet/freescale/fman/fman_dtsec.h  |  58 +-
 .../net/ethernet/freescale/fman/fman_keygen.c |  29 +-
 .../net/ethernet/freescale/fman/fman_keygen.h |  29 +-
 .../net/ethernet/freescale/fman/fman_mac.h|  24 +-
 .../net/ethernet/freescale/fman/fman_memac.c  | 240 +
 .../net/ethernet/freescale/fman/fman_memac.h  |  57 +-
 .../net/ethernet/freescale/fman/fman_muram.c  |  31 +-
 .../net/ethernet/freescale/fman/fman_muram.h  |  32 +-
 .../net/ethernet/freescale/fman/fman_port.c   |  29 +-
 .../net/ethernet/freescale/fman/fman_port.h   |  29 +-
 drivers/net/ethernet/freescale/fman/fman_sp.c |  29 +-
 drivers/net/ethernet/freescale/fman/fman_sp.h |  28 +-
 .../net/ethernet/freescale/fman/fman_tgec.c   | 163 +++---
 .../net/ethernet/freescale/fman/fman_tgec.h   |  54 +-
 drivers/net/ethernet/freescale/fman/mac.c | 497 ++
 drivers/net/ethernet/freescale/fman/mac.h |  45 +-
 drivers/soc/fsl/qbman/qman.c  |  76 ++-
 include/soc/fsl/qman.h|   9 +
 25 files changed, 739 insertions(+), 1441 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/fsl,fman-dtsec.yaml

-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 03/25] net: fman: Don't pass comm_mode to enable/disable

2022-07-25 Thread Sean Anderson
mac_priv_s->enable() and ->disable() are always called with
a comm_mode of COMM_MODE_RX_AND_TX. Remove this parameter, and refactor
the macs appropriately.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
Tested-by: Camelia Groza 
---

(no changes since v1)

 .../net/ethernet/freescale/fman/fman_dtsec.c  | 20 ++-
 .../net/ethernet/freescale/fman/fman_dtsec.h  |  4 ++--
 .../net/ethernet/freescale/fman/fman_memac.c  | 16 ---
 .../net/ethernet/freescale/fman/fman_memac.h  |  4 ++--
 .../net/ethernet/freescale/fman/fman_tgec.c   | 14 -
 .../net/ethernet/freescale/fman/fman_tgec.h   |  4 ++--
 drivers/net/ethernet/freescale/fman/mac.c |  8 
 7 files changed, 24 insertions(+), 46 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index a39d57347d59..167843941fa4 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -879,7 +879,7 @@ static void graceful_stop(struct fman_mac *dtsec, enum 
comm_mode mode)
}
 }
 
-int dtsec_enable(struct fman_mac *dtsec, enum comm_mode mode)
+int dtsec_enable(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
@@ -889,20 +889,16 @@ int dtsec_enable(struct fman_mac *dtsec, enum comm_mode 
mode)
 
/* Enable */
tmp = ioread32be(®s->maccfg1);
-   if (mode & COMM_MODE_RX)
-   tmp |= MACCFG1_RX_EN;
-   if (mode & COMM_MODE_TX)
-   tmp |= MACCFG1_TX_EN;
-
+   tmp |= MACCFG1_RX_EN | MACCFG1_TX_EN;
iowrite32be(tmp, ®s->maccfg1);
 
/* Graceful start - clear the graceful Rx/Tx stop bit */
-   graceful_start(dtsec, mode);
+   graceful_start(dtsec, COMM_MODE_RX_AND_TX);
 
return 0;
 }
 
-int dtsec_disable(struct fman_mac *dtsec, enum comm_mode mode)
+int dtsec_disable(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
@@ -911,14 +907,10 @@ int dtsec_disable(struct fman_mac *dtsec, enum comm_mode 
mode)
return -EINVAL;
 
/* Graceful stop - Assert the graceful Rx/Tx stop bit */
-   graceful_stop(dtsec, mode);
+   graceful_stop(dtsec, COMM_MODE_RX_AND_TX);
 
tmp = ioread32be(®s->maccfg1);
-   if (mode & COMM_MODE_RX)
-   tmp &= ~MACCFG1_RX_EN;
-   if (mode & COMM_MODE_TX)
-   tmp &= ~MACCFG1_TX_EN;
-
+   tmp &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN);
iowrite32be(tmp, ®s->maccfg1);
 
return 0;
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.h 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.h
index 3c26b97f8ced..f072cdc560ba 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.h
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.h
@@ -16,8 +16,8 @@ int dtsec_adjust_link(struct fman_mac *dtsec,
 int dtsec_restart_autoneg(struct fman_mac *dtsec);
 int dtsec_cfg_max_frame_len(struct fman_mac *dtsec, u16 new_val);
 int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool new_val);
-int dtsec_enable(struct fman_mac *dtsec, enum comm_mode mode);
-int dtsec_disable(struct fman_mac *dtsec, enum comm_mode mode);
+int dtsec_enable(struct fman_mac *dtsec);
+int dtsec_disable(struct fman_mac *dtsec);
 int dtsec_init(struct fman_mac *dtsec);
 int dtsec_free(struct fman_mac *dtsec);
 int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, bool en);
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index d47e5d282143..c34da49aed31 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -685,7 +685,7 @@ static bool is_init_done(struct memac_cfg *memac_drv_params)
return false;
 }
 
-int memac_enable(struct fman_mac *memac, enum comm_mode mode)
+int memac_enable(struct fman_mac *memac)
 {
struct memac_regs __iomem *regs = memac->regs;
u32 tmp;
@@ -694,17 +694,13 @@ int memac_enable(struct fman_mac *memac, enum comm_mode 
mode)
return -EINVAL;
 
tmp = ioread32be(®s->command_config);
-   if (mode & COMM_MODE_RX)
-   tmp |= CMD_CFG_RX_EN;
-   if (mode & COMM_MODE_TX)
-   tmp |= CMD_CFG_TX_EN;
-
+   tmp |= CMD_CFG_RX_EN | CMD_CFG_TX_EN;
iowrite32be(tmp, ®s->command_config);
 
return 0;
 }
 
-int memac_disable(struct fman_mac *memac, enum comm_mode mode)
+int memac_disable(struct fman_mac *memac)
 {
struct memac_regs __iomem *regs = memac->regs;
u32 tmp;
@@ -713,11 +709,7 @@ int memac_disable(struct fman_mac *memac, enum comm_mode 
mode)
return -EINVAL;
 
tmp = ioread32be(®s->command_config);
-   if (mode & COMM_MODE_RX)
-   tmp &= ~CMD_CFG_RX_EN;
-   if (mode & COMM_MODE_TX)
-   tmp &= ~CMD_CFG_TX_EN;
-
+   tmp &= ~(CMD_CFG_RX_EN | CM

[PATCH v4 02/25] net: fman: Convert to SPDX identifiers

2022-07-25 Thread Sean Anderson
This converts the license text of files in the fman directory to use
SPDX license identifiers instead.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
Tested-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/fman/fman.c| 31 ++
 drivers/net/ethernet/freescale/fman/fman.h| 31 ++
 .../net/ethernet/freescale/fman/fman_dtsec.c  | 31 ++
 .../net/ethernet/freescale/fman/fman_dtsec.h  | 31 ++
 .../net/ethernet/freescale/fman/fman_keygen.c | 29 +
 .../net/ethernet/freescale/fman/fman_keygen.h | 29 +
 .../net/ethernet/freescale/fman/fman_memac.c  | 31 ++
 .../net/ethernet/freescale/fman/fman_memac.h  | 31 ++
 .../net/ethernet/freescale/fman/fman_muram.c  | 31 ++
 .../net/ethernet/freescale/fman/fman_muram.h  | 32 ++-
 .../net/ethernet/freescale/fman/fman_port.c   | 29 +
 .../net/ethernet/freescale/fman/fman_port.h   | 29 +
 drivers/net/ethernet/freescale/fman/fman_sp.c | 29 +
 drivers/net/ethernet/freescale/fman/fman_sp.h | 28 +---
 .../net/ethernet/freescale/fman/fman_tgec.c   | 31 ++
 .../net/ethernet/freescale/fman/fman_tgec.h   | 31 ++
 drivers/net/ethernet/freescale/fman/mac.c | 32 ++-
 drivers/net/ethernet/freescale/fman/mac.h | 32 ++-
 18 files changed, 33 insertions(+), 515 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index 8f0db61cb1f6..9d85fb136e34 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -1,34 +1,7 @@
+// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later
 /*
- * Copyright 2008-2015 Freescale Semiconductor Inc.
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
  * Copyright 2020 NXP
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * * Neither the name of Freescale Semiconductor nor the
- *   names of its contributors may be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") as published by the Free Software
- * Foundation, either version 2 of that License or (at your option) any
- * later version.
- *
- * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/net/ethernet/freescale/fman/fman.h 
b/drivers/net/ethernet/freescale/fman/fman.h
index f2ede1360f03..2ea575a46675 100644
--- a/drivers/net/ethernet/freescale/fman/fman.h
+++ b/drivers/net/ethernet/freescale/fman/fman.h
@@ -1,34 +1,7 @@
+/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later */
 /*
- * Copyright 2008-2015 Freescale Semiconductor Inc.
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
  * Copyright 2020 NXP
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * * Neither the name of Freescale Semiconductor nor the
- *   names of its contributors may be used to endorse or promote products
- *   derived from this software withou

[PATCH v4 04/25] net: fman: Store en/disable in mac_device instead of mac_priv_s

2022-07-25 Thread Sean Anderson
All macs use the same start/stop functions. The actual mac-specific code
lives in enable/disable. Move these functions to an appropriate struct,
and inline the phy enable/disable calls to the caller of start/stop.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
Tested-by: Camelia Groza 
---

(no changes since v1)

 .../net/ethernet/freescale/dpaa/dpaa_eth.c| 11 +++--
 drivers/net/ethernet/freescale/fman/mac.c | 44 +++
 drivers/net/ethernet/freescale/fman/mac.h |  4 +-
 3 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 45634579adb6..a548598b2e2d 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -288,9 +288,11 @@ static int dpaa_stop(struct net_device *net_dev)
 */
msleep(200);
 
-   err = mac_dev->stop(mac_dev);
+   if (mac_dev->phy_dev)
+   phy_stop(mac_dev->phy_dev);
+   err = mac_dev->disable(mac_dev->fman_mac);
if (err < 0)
-   netif_err(priv, ifdown, net_dev, "mac_dev->stop() = %d\n",
+   netif_err(priv, ifdown, net_dev, "mac_dev->disable() = %d\n",
  err);
 
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -2942,11 +2944,12 @@ static int dpaa_open(struct net_device *net_dev)
goto mac_start_failed;
}
 
-   err = priv->mac_dev->start(mac_dev);
+   err = priv->mac_dev->enable(mac_dev->fman_mac);
if (err < 0) {
-   netif_err(priv, ifup, net_dev, "mac_dev->start() = %d\n", err);
+   netif_err(priv, ifup, net_dev, "mac_dev->enable() = %d\n", err);
goto mac_start_failed;
}
+   phy_start(priv->mac_dev->phy_dev);
 
netif_tx_start_all_queues(net_dev);
 
diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index a8d521760ffc..6a4eaca83700 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -39,9 +39,6 @@ struct mac_priv_s {
struct fixed_phy_status *fixed_link;
u16 speed;
u16 max_speed;
-
-   int (*enable)(struct fman_mac *mac_dev);
-   int (*disable)(struct fman_mac *mac_dev);
 };
 
 struct mac_address {
@@ -241,29 +238,6 @@ static int memac_initialization(struct mac_device *mac_dev)
return err;
 }
 
-static int start(struct mac_device *mac_dev)
-{
-   int  err;
-   struct phy_device *phy_dev = mac_dev->phy_dev;
-   struct mac_priv_s *priv = mac_dev->priv;
-
-   err = priv->enable(mac_dev->fman_mac);
-   if (!err && phy_dev)
-   phy_start(phy_dev);
-
-   return err;
-}
-
-static int stop(struct mac_device *mac_dev)
-{
-   struct mac_priv_s *priv = mac_dev->priv;
-
-   if (mac_dev->phy_dev)
-   phy_stop(mac_dev->phy_dev);
-
-   return priv->disable(mac_dev->fman_mac);
-}
-
 static int set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
 {
struct mac_priv_s   *priv;
@@ -454,11 +428,9 @@ static void setup_dtsec(struct mac_device *mac_dev)
mac_dev->set_allmulti   = dtsec_set_allmulti;
mac_dev->set_tstamp = dtsec_set_tstamp;
mac_dev->set_multi  = set_multi;
-   mac_dev->start  = start;
-   mac_dev->stop   = stop;
mac_dev->adjust_link= adjust_link_dtsec;
-   mac_dev->priv->enable   = dtsec_enable;
-   mac_dev->priv->disable  = dtsec_disable;
+   mac_dev->enable = dtsec_enable;
+   mac_dev->disable= dtsec_disable;
 }
 
 static void setup_tgec(struct mac_device *mac_dev)
@@ -474,11 +446,9 @@ static void setup_tgec(struct mac_device *mac_dev)
mac_dev->set_allmulti   = tgec_set_allmulti;
mac_dev->set_tstamp = tgec_set_tstamp;
mac_dev->set_multi  = set_multi;
-   mac_dev->start  = start;
-   mac_dev->stop   = stop;
mac_dev->adjust_link= adjust_link_void;
-   mac_dev->priv->enable   = tgec_enable;
-   mac_dev->priv->disable  = tgec_disable;
+   mac_dev->enable = tgec_enable;
+   mac_dev->disable= tgec_disable;
 }
 
 static void setup_memac(struct mac_device *mac_dev)
@@ -494,11 +464,9 @@ static void setup_memac(struct mac_device *mac_dev)
mac_dev->set_allmulti   = memac_set_allmulti;
mac_dev->set_tstamp = memac_set_tstamp;
mac_dev->set_multi  = set_multi;
-   mac_dev->start  = start;
-   mac_dev->stop   = stop;
mac_dev->adjust_link= adjust_

[PATCH v4 05/25] net: fman: dtsec: Always gracefully stop/start

2022-07-25 Thread Sean Anderson
There are two ways that GRS can be set: graceful_stop and dtsec_isr. It
is cleared by graceful_start. If it is already set before calling
graceful_stop, then that means that dtsec_isr set it. In that case, we
will not set GRS nor will we clear it (which seems like a bug?). For GTS
the logic is similar, except that there is no one else messing with this
bit (so we will always set and clear it). Simplify the logic by always
setting/clearing GRS/GTS. This is less racy that the previous behavior,
and ensures that we always end up clearing the bits. This can of course
clear GRS while dtsec_isr is waiting, but because we have already done
our own waiting it should be fine.

This is the last user of enum comm_mode, so remove it.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
Tested-by: Camelia Groza 
---
Changes since previous series:
- Fix unused variable warning in dtsec_modify_mac_address

(no changes since v1)

 .../net/ethernet/freescale/fman/fman_dtsec.c  | 94 ++-
 .../net/ethernet/freescale/fman/fman_mac.h| 10 --
 2 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 167843941fa4..7f4f3d797a8d 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -833,49 +833,41 @@ int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool 
new_val)
return 0;
 }
 
-static void graceful_start(struct fman_mac *dtsec, enum comm_mode mode)
+static void graceful_start(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
 
-   if (mode & COMM_MODE_TX)
-   iowrite32be(ioread32be(®s->tctrl) &
-   ~TCTRL_GTS, ®s->tctrl);
-   if (mode & COMM_MODE_RX)
-   iowrite32be(ioread32be(®s->rctrl) &
-   ~RCTRL_GRS, ®s->rctrl);
+   iowrite32be(ioread32be(®s->tctrl) & ~TCTRL_GTS, ®s->tctrl);
+   iowrite32be(ioread32be(®s->rctrl) & ~RCTRL_GRS, ®s->rctrl);
 }
 
-static void graceful_stop(struct fman_mac *dtsec, enum comm_mode mode)
+static void graceful_stop(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
 
/* Graceful stop - Assert the graceful Rx stop bit */
-   if (mode & COMM_MODE_RX) {
-   tmp = ioread32be(®s->rctrl) | RCTRL_GRS;
-   iowrite32be(tmp, ®s->rctrl);
+   tmp = ioread32be(®s->rctrl) | RCTRL_GRS;
+   iowrite32be(tmp, ®s->rctrl);
 
-   if (dtsec->fm_rev_info.major == 2) {
-   /* Workaround for dTSEC Errata A002 */
-   usleep_range(100, 200);
-   } else {
-   /* Workaround for dTSEC Errata A004839 */
-   usleep_range(10, 50);
-   }
+   if (dtsec->fm_rev_info.major == 2) {
+   /* Workaround for dTSEC Errata A002 */
+   usleep_range(100, 200);
+   } else {
+   /* Workaround for dTSEC Errata A004839 */
+   usleep_range(10, 50);
}
 
/* Graceful stop - Assert the graceful Tx stop bit */
-   if (mode & COMM_MODE_TX) {
-   if (dtsec->fm_rev_info.major == 2) {
-   /* dTSEC Errata A004: Do not use TCTRL[GTS]=1 */
-   pr_debug("GTS not supported due to DTSEC_A004 
Errata.\n");
-   } else {
-   tmp = ioread32be(®s->tctrl) | TCTRL_GTS;
-   iowrite32be(tmp, ®s->tctrl);
+   if (dtsec->fm_rev_info.major == 2) {
+   /* dTSEC Errata A004: Do not use TCTRL[GTS]=1 */
+   pr_debug("GTS not supported due to DTSEC_A004 Errata.\n");
+   } else {
+   tmp = ioread32be(®s->tctrl) | TCTRL_GTS;
+   iowrite32be(tmp, ®s->tctrl);
 
-   /* Workaround for dTSEC Errata A0012, A0014 */
-   usleep_range(10, 50);
-   }
+   /* Workaround for dTSEC Errata A0012, A0014 */
+   usleep_range(10, 50);
}
 }
 
@@ -893,7 +885,7 @@ int dtsec_enable(struct fman_mac *dtsec)
iowrite32be(tmp, ®s->maccfg1);
 
/* Graceful start - clear the graceful Rx/Tx stop bit */
-   graceful_start(dtsec, COMM_MODE_RX_AND_TX);
+   graceful_start(dtsec);
 
return 0;
 }
@@ -907,7 +899,7 @@ int dtsec_disable(struct fman_mac *dtsec)
return -EINVAL;
 
/* Graceful stop - Assert the graceful Rx/Tx stop bit */
-   graceful_stop(dtsec, COMM_MODE_RX_AND_TX);
+   graceful_stop(dtsec);
 
tmp = ioread32be(®s->maccfg1);
tmp &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN);
@@ -921,18 +913,12 @@ int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
  u16 pause_time, u16 __maybe_unused thresh_time)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
-   enu

[PATCH v4 06/25] net: fman: Get PCS node in per-mac init

2022-07-25 Thread Sean Anderson
This moves the reading of the PCS property out of the generic probe and
into the mac-specific initialization function. This reduces the
mac-specific jobs done in the top-level probe function.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/fman/mac.c | 19 +--
 drivers/net/ethernet/freescale/fman/mac.h |  2 +-
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 6a4eaca83700..0af6f6c49284 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -32,7 +32,6 @@ struct mac_priv_s {
void __iomem*vaddr;
u8  cell_index;
struct fman *fman;
-   struct device_node  *internal_phy_node;
/* List of multicast addresses */
struct list_headmc_addr_list;
struct platform_device  *eth_dev;
@@ -85,12 +84,12 @@ static int set_fman_mac_params(struct mac_device *mac_dev,
params->exception_cb= mac_exception;
params->event_cb= mac_exception;
params->dev_id  = mac_dev;
-   params->internal_phy_node = priv->internal_phy_node;
 
return 0;
 }
 
-static int tgec_initialization(struct mac_device *mac_dev)
+static int tgec_initialization(struct mac_device *mac_dev,
+  struct device_node *mac_node)
 {
int err;
struct mac_priv_s   *priv;
@@ -138,7 +137,8 @@ static int tgec_initialization(struct mac_device *mac_dev)
return err;
 }
 
-static int dtsec_initialization(struct mac_device *mac_dev)
+static int dtsec_initialization(struct mac_device *mac_dev,
+   struct device_node *mac_node)
 {
int err;
struct mac_priv_s   *priv;
@@ -150,6 +150,7 @@ static int dtsec_initialization(struct mac_device *mac_dev)
err = set_fman_mac_params(mac_dev, ¶ms);
if (err)
goto _return;
+   params.internal_phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);
 
mac_dev->fman_mac = dtsec_config(¶ms);
if (!mac_dev->fman_mac) {
@@ -190,7 +191,8 @@ static int dtsec_initialization(struct mac_device *mac_dev)
return err;
 }
 
-static int memac_initialization(struct mac_device *mac_dev)
+static int memac_initialization(struct mac_device *mac_dev,
+   struct device_node *mac_node)
 {
int  err;
struct mac_priv_s   *priv;
@@ -201,6 +203,7 @@ static int memac_initialization(struct mac_device *mac_dev)
err = set_fman_mac_params(mac_dev, ¶ms);
if (err)
goto _return;
+   params.internal_phy_node = of_parse_phandle(mac_node, "pcsphy-handle", 
0);
 
if (priv->max_speed == SPEED_1)
params.phy_if = PHY_INTERFACE_MODE_XGMII;
@@ -583,14 +586,10 @@ static int mac_probe(struct platform_device *_of_dev)
 
if (of_device_is_compatible(mac_node, "fsl,fman-dtsec")) {
setup_dtsec(mac_dev);
-   priv->internal_phy_node = of_parse_phandle(mac_node,
- "tbi-handle", 0);
} else if (of_device_is_compatible(mac_node, "fsl,fman-xgec")) {
setup_tgec(mac_dev);
} else if (of_device_is_compatible(mac_node, "fsl,fman-memac")) {
setup_memac(mac_dev);
-   priv->internal_phy_node = of_parse_phandle(mac_node,
- "pcsphy-handle", 0);
} else {
dev_err(dev, "MAC node (%pOF) contains unsupported MAC\n",
mac_node);
@@ -783,7 +782,7 @@ static int mac_probe(struct platform_device *_of_dev)
put_device(&phy->mdio.dev);
}
 
-   err = mac_dev->init(mac_dev);
+   err = mac_dev->init(mac_dev, mac_node);
if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node);
diff --git a/drivers/net/ethernet/freescale/fman/mac.h 
b/drivers/net/ethernet/freescale/fman/mac.h
index 95f67b4efb61..e4329c7d5001 100644
--- a/drivers/net/ethernet/freescale/fman/mac.h
+++ b/drivers/net/ethernet/freescale/fman/mac.h
@@ -35,7 +35,7 @@ struct mac_device {
bool promisc;
bool allmulti;
 
-   int (*init)(struct mac_device *mac_dev);
+   int (*init)(struct mac_device *mac_dev, struct device_node *mac_node);
int (*enable)(struct fman_mac *mac_dev);
int (*disable)(struct fman_mac *mac_dev);
void (*adjust_link)(struct mac_device *mac_dev);
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 07/25] net: fman: Store initialization function in match data

2022-07-25 Thread Sean Anderson
Instead of re-matching the compatible string in order to determine the init
function, just store it in the match data. The separate setup functions
aren't needed anymore. Merge their content into init as well. To ensure
everything compiles correctly, we move them to the bottom of the file.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

Changes in v4:
- Clarify commit message

 drivers/net/ethernet/freescale/fman/mac.c | 356 ++
 drivers/net/ethernet/freescale/fman/mac.h |   1 -
 2 files changed, 165 insertions(+), 192 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 0af6f6c49284..8dd6a5b12922 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -88,159 +88,6 @@ static int set_fman_mac_params(struct mac_device *mac_dev,
return 0;
 }
 
-static int tgec_initialization(struct mac_device *mac_dev,
-  struct device_node *mac_node)
-{
-   int err;
-   struct mac_priv_s   *priv;
-   struct fman_mac_params  params;
-   u32 version;
-
-   priv = mac_dev->priv;
-
-   err = set_fman_mac_params(mac_dev, ¶ms);
-   if (err)
-   goto _return;
-
-   mac_dev->fman_mac = tgec_config(¶ms);
-   if (!mac_dev->fman_mac) {
-   err = -EINVAL;
-   goto _return;
-   }
-
-   err = tgec_cfg_max_frame_len(mac_dev->fman_mac, fman_get_max_frm());
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = tgec_init(mac_dev->fman_mac);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   /* For 10G MAC, disable Tx ECC exception */
-   err = mac_dev->set_exception(mac_dev->fman_mac,
-FM_MAC_EX_10G_TX_ECC_ER, false);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = tgec_get_version(mac_dev->fman_mac, &version);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   dev_info(priv->dev, "FMan XGEC version: 0x%08x\n", version);
-
-   goto _return;
-
-_return_fm_mac_free:
-   tgec_free(mac_dev->fman_mac);
-
-_return:
-   return err;
-}
-
-static int dtsec_initialization(struct mac_device *mac_dev,
-   struct device_node *mac_node)
-{
-   int err;
-   struct mac_priv_s   *priv;
-   struct fman_mac_params  params;
-   u32 version;
-
-   priv = mac_dev->priv;
-
-   err = set_fman_mac_params(mac_dev, ¶ms);
-   if (err)
-   goto _return;
-   params.internal_phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);
-
-   mac_dev->fman_mac = dtsec_config(¶ms);
-   if (!mac_dev->fman_mac) {
-   err = -EINVAL;
-   goto _return;
-   }
-
-   err = dtsec_cfg_max_frame_len(mac_dev->fman_mac, fman_get_max_frm());
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = dtsec_cfg_pad_and_crc(mac_dev->fman_mac, true);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = dtsec_init(mac_dev->fman_mac);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   /* For 1G MAC, disable by default the MIB counters overflow interrupt */
-   err = mac_dev->set_exception(mac_dev->fman_mac,
-FM_MAC_EX_1G_RX_MIB_CNT_OVFL, false);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = dtsec_get_version(mac_dev->fman_mac, &version);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   dev_info(priv->dev, "FMan dTSEC version: 0x%08x\n", version);
-
-   goto _return;
-
-_return_fm_mac_free:
-   dtsec_free(mac_dev->fman_mac);
-
-_return:
-   return err;
-}
-
-static int memac_initialization(struct mac_device *mac_dev,
-   struct device_node *mac_node)
-{
-   int  err;
-   struct mac_priv_s   *priv;
-   struct fman_mac_params   params;
-
-   priv = mac_dev->priv;
-
-   err = set_fman_mac_params(mac_dev, ¶ms);
-   if (err)
-   goto _return;
-   params.internal_phy_node = of_parse_phandle(mac_node, "pcsphy-handle", 
0);
-
-   if (priv->max_speed == SPEED_1)
-   params.phy_if = PHY_INTERFACE_MODE_XGMII;
-
-   mac_dev->fman_mac = memac_config(¶ms);
-   if (!mac_dev->fman_mac) {
-   err = -EINVAL;
-   goto _return;
-   }
-
-   err = memac_cfg_max_frame_len(mac_dev->fman_mac, fman_get_max_frm());
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = memac_cfg_reset_on_init(mac_dev->fman_mac, true);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = memac_cfg_fixed_link(mac_dev->fman_mac, priv->fixed_link);
-   if (err < 0)
-   goto 

[PATCH v4 08/25] net: fman: Move struct dev to mac_device

2022-07-25 Thread Sean Anderson
Move the reference to our device to mac_device. This way, macs can use
it in their log messages.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v2)

Changes in v2:
- Remove some unused variables

 drivers/net/ethernet/freescale/fman/mac.c | 31 ---
 drivers/net/ethernet/freescale/fman/mac.h |  1 +
 2 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 8dd6a5b12922..5b3a6ea2d0e2 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -28,7 +28,6 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("FSL FMan MAC API based driver");
 
 struct mac_priv_s {
-   struct device   *dev;
void __iomem*vaddr;
u8  cell_index;
struct fman *fman;
@@ -47,20 +46,16 @@ struct mac_address {
 
 static void mac_exception(void *handle, enum fman_mac_exceptions ex)
 {
-   struct mac_device   *mac_dev;
-   struct mac_priv_s   *priv;
-
-   mac_dev = handle;
-   priv = mac_dev->priv;
+   struct mac_device *mac_dev = handle;
 
if (ex == FM_MAC_EX_10G_RX_FIFO_OVFL) {
/* don't flag RX FIFO after the first */
mac_dev->set_exception(mac_dev->fman_mac,
   FM_MAC_EX_10G_RX_FIFO_OVFL, false);
-   dev_err(priv->dev, "10G MAC got RX FIFO Error = %x\n", ex);
+   dev_err(mac_dev->dev, "10G MAC got RX FIFO Error = %x\n", ex);
}
 
-   dev_dbg(priv->dev, "%s:%s() -> %d\n", KBUILD_BASENAME ".c",
+   dev_dbg(mac_dev->dev, "%s:%s() -> %d\n", KBUILD_BASENAME ".c",
__func__, ex);
 }
 
@@ -70,7 +65,7 @@ static int set_fman_mac_params(struct mac_device *mac_dev,
struct mac_priv_s *priv = mac_dev->priv;
 
params->base_addr = (typeof(params->base_addr))
-   devm_ioremap(priv->dev, mac_dev->res->start,
+   devm_ioremap(mac_dev->dev, mac_dev->res->start,
 resource_size(mac_dev->res));
if (!params->base_addr)
return -ENOMEM;
@@ -244,7 +239,7 @@ static void adjust_link_dtsec(struct mac_device *mac_dev)
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0)
-   dev_err(mac_dev->priv->dev, "fman_set_mac_active_pause() = 
%d\n",
+   dev_err(mac_dev->dev, "fman_set_mac_active_pause() = %d\n",
err);
 }
 
@@ -261,7 +256,7 @@ static void adjust_link_memac(struct mac_device *mac_dev)
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0)
-   dev_err(mac_dev->priv->dev, "fman_set_mac_active_pause() = 
%d\n",
+   dev_err(mac_dev->dev, "fman_set_mac_active_pause() = %d\n",
err);
 }
 
@@ -269,11 +264,9 @@ static int tgec_initialization(struct mac_device *mac_dev,
   struct device_node *mac_node)
 {
int err;
-   struct mac_priv_s   *priv;
struct fman_mac_params  params;
u32 version;
 
-   priv = mac_dev->priv;
mac_dev->set_promisc= tgec_set_promiscuous;
mac_dev->change_addr= tgec_modify_mac_address;
mac_dev->add_hash_mac_addr  = tgec_add_hash_mac_address;
@@ -316,7 +309,7 @@ static int tgec_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;
 
-   dev_info(priv->dev, "FMan XGEC version: 0x%08x\n", version);
+   dev_info(mac_dev->dev, "FMan XGEC version: 0x%08x\n", version);
 
goto _return;
 
@@ -331,11 +324,9 @@ static int dtsec_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
 {
int err;
-   struct mac_priv_s   *priv;
struct fman_mac_params  params;
u32 version;
 
-   priv = mac_dev->priv;
mac_dev->set_promisc= dtsec_set_promiscuous;
mac_dev->change_addr= dtsec_modify_mac_address;
mac_dev->add_hash_mac_addr  = dtsec_add_hash_mac_address;
@@ -383,7 +374,7 @@ static int dtsec_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;
 
-   dev_info(priv->dev, "FMan dTSEC version: 0x%08x\n", version);
+   dev_info(mac_dev->dev, "FMan dTSEC version: 0x%08x\n", version);
 
goto _return;
 
@@ -446,7 +437,7 @@ static int memac_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;
 
-   dev_info(priv->dev, "FMan MEMAC\n");
+   dev_info

[PATCH v4 09/25] net: fman: Configure fixed link in memac_initialization

2022-07-25 Thread Sean Anderson
memac is the only mac which parses fixed links. Move the
parsing/configuring to its initialization function.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/fman/mac.c | 93 +++
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 5b3a6ea2d0e2..af5e5d98e23e 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -34,7 +34,6 @@ struct mac_priv_s {
/* List of multicast addresses */
struct list_headmc_addr_list;
struct platform_device  *eth_dev;
-   struct fixed_phy_status *fixed_link;
u16 speed;
u16 max_speed;
 };
@@ -391,6 +390,7 @@ static int memac_initialization(struct mac_device *mac_dev,
int  err;
struct mac_priv_s   *priv;
struct fman_mac_params   params;
+   struct fixed_phy_status *fixed_link;
 
priv = mac_dev->priv;
mac_dev->set_promisc= memac_set_promiscuous;
@@ -429,21 +429,52 @@ static int memac_initialization(struct mac_device 
*mac_dev,
if (err < 0)
goto _return_fm_mac_free;
 
-   err = memac_cfg_fixed_link(mac_dev->fman_mac, priv->fixed_link);
-   if (err < 0)
-   goto _return_fm_mac_free;
+   if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
+   struct phy_device *phy;
+
+   err = of_phy_register_fixed_link(mac_node);
+   if (err)
+   goto _return_fm_mac_free;
+
+   fixed_link = kzalloc(sizeof(*fixed_link), GFP_KERNEL);
+   if (!fixed_link) {
+   err = -ENOMEM;
+   goto _return_fm_mac_free;
+   }
+
+   mac_dev->phy_node = of_node_get(mac_node);
+   phy = of_phy_find_device(mac_dev->phy_node);
+   if (!phy) {
+   err = -EINVAL;
+   of_node_put(mac_dev->phy_node);
+   goto _return_fixed_link_free;
+   }
+
+   fixed_link->link = phy->link;
+   fixed_link->speed = phy->speed;
+   fixed_link->duplex = phy->duplex;
+   fixed_link->pause = phy->pause;
+   fixed_link->asym_pause = phy->asym_pause;
+
+   put_device(&phy->mdio.dev);
+
+   err = memac_cfg_fixed_link(mac_dev->fman_mac, fixed_link);
+   if (err < 0)
+   goto _return_fixed_link_free;
+   }
 
err = memac_init(mac_dev->fman_mac);
if (err < 0)
-   goto _return_fm_mac_free;
+   goto _return_fixed_link_free;
 
dev_info(mac_dev->dev, "FMan MEMAC\n");
 
goto _return;
 
+_return_fixed_link_free:
+   kfree(fixed_link);
 _return_fm_mac_free:
memac_free(mac_dev->fman_mac);
-
 _return:
return err;
 }
@@ -570,7 +601,7 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node);
err = -EINVAL;
-   goto _return_of_get_parent;
+   goto _return_of_node_put;
}
 
of_dev = of_find_device_by_node(dev_node);
@@ -604,7 +635,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) {
dev_err(dev, "of_address_to_resource(%pOF) = %d\n",
mac_node, err);
-   goto _return_of_get_parent;
+   goto _return_of_node_put;
}
 
mac_dev->res = __devm_request_region(dev,
@@ -614,7 +645,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!mac_dev->res) {
dev_err(dev, "__devm_request_mem_region(mac) failed\n");
err = -EBUSY;
-   goto _return_of_get_parent;
+   goto _return_of_node_put;
}
 
priv->vaddr = devm_ioremap(dev, mac_dev->res->start,
@@ -622,12 +653,12 @@ static int mac_probe(struct platform_device *_of_dev)
if (!priv->vaddr) {
dev_err(dev, "devm_ioremap() failed\n");
err = -EIO;
-   goto _return_of_get_parent;
+   goto _return_of_node_put;
}
 
if (!of_device_is_available(mac_node)) {
err = -ENODEV;
-   goto _return_of_get_parent;
+   goto _return_of_node_put;
}
 
/* Get the cell-index */
@@ -635,7 +666,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
err = -EINVAL;
-   goto _return_of_get_parent;
+   goto _return_of_node_put;
 

[PATCH v4 10/25] net: fman: Export/rename some common functions

2022-07-25 Thread Sean Anderson
In preparation for moving each of the initialization functions to their
own file, export some common functions so they can be re-used. This adds
an fman prefix to set_multi to make it a bit less genericly-named.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/fman/mac.c | 12 ++--
 drivers/net/ethernet/freescale/fman/mac.h |  3 +++
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index af5e5d98e23e..0ac8df87308a 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -58,8 +58,8 @@ static void mac_exception(void *handle, enum 
fman_mac_exceptions ex)
__func__, ex);
 }
 
-static int set_fman_mac_params(struct mac_device *mac_dev,
-  struct fman_mac_params *params)
+int set_fman_mac_params(struct mac_device *mac_dev,
+   struct fman_mac_params *params)
 {
struct mac_priv_s *priv = mac_dev->priv;
 
@@ -82,7 +82,7 @@ static int set_fman_mac_params(struct mac_device *mac_dev,
return 0;
 }
 
-static int set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
+int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
 {
struct mac_priv_s   *priv;
struct mac_address  *old_addr, *tmp;
@@ -275,7 +275,7 @@ static int tgec_initialization(struct mac_device *mac_dev,
mac_dev->set_exception  = tgec_set_exception;
mac_dev->set_allmulti   = tgec_set_allmulti;
mac_dev->set_tstamp = tgec_set_tstamp;
-   mac_dev->set_multi  = set_multi;
+   mac_dev->set_multi  = fman_set_multi;
mac_dev->adjust_link= adjust_link_void;
mac_dev->enable = tgec_enable;
mac_dev->disable= tgec_disable;
@@ -335,7 +335,7 @@ static int dtsec_initialization(struct mac_device *mac_dev,
mac_dev->set_exception  = dtsec_set_exception;
mac_dev->set_allmulti   = dtsec_set_allmulti;
mac_dev->set_tstamp = dtsec_set_tstamp;
-   mac_dev->set_multi  = set_multi;
+   mac_dev->set_multi  = fman_set_multi;
mac_dev->adjust_link= adjust_link_dtsec;
mac_dev->enable = dtsec_enable;
mac_dev->disable= dtsec_disable;
@@ -402,7 +402,7 @@ static int memac_initialization(struct mac_device *mac_dev,
mac_dev->set_exception  = memac_set_exception;
mac_dev->set_allmulti   = memac_set_allmulti;
mac_dev->set_tstamp = memac_set_tstamp;
-   mac_dev->set_multi  = set_multi;
+   mac_dev->set_multi  = fman_set_multi;
mac_dev->adjust_link= adjust_link_memac;
mac_dev->enable = memac_enable;
mac_dev->disable= memac_disable;
diff --git a/drivers/net/ethernet/freescale/fman/mac.h 
b/drivers/net/ethernet/freescale/fman/mac.h
index 05dbb8b5a704..da410a7d00c9 100644
--- a/drivers/net/ethernet/freescale/fman/mac.h
+++ b/drivers/net/ethernet/freescale/fman/mac.h
@@ -71,5 +71,8 @@ int fman_set_mac_active_pause(struct mac_device *mac_dev, 
bool rx, bool tx);
 
 void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
bool *tx_pause);
+int set_fman_mac_params(struct mac_device *mac_dev,
+   struct fman_mac_params *params);
+int fman_set_multi(struct net_device *net_dev, struct mac_device *mac_dev);
 
 #endif /* __MAC_H */
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 14/25] net: fman: Inline several functions into initialization

2022-07-25 Thread Sean Anderson
There are several small functions which were only necessary because the
initialization functions didn't have access to the mac private data. Now
that they do, just do things directly.

Signed-off-by: Sean Anderson 
---

Changes in v4:
- weer -> were

 .../net/ethernet/freescale/fman/fman_dtsec.c  | 59 +++
 .../net/ethernet/freescale/fman/fman_memac.c  | 47 ++-
 .../net/ethernet/freescale/fman/fman_tgec.c   | 43 +++---
 3 files changed, 21 insertions(+), 128 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 6991586165d7..84205be3a817 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -814,26 +814,6 @@ static void free_init_resources(struct fman_mac *dtsec)
dtsec->unicast_addr_hash = NULL;
 }
 
-static int dtsec_cfg_max_frame_len(struct fman_mac *dtsec, u16 new_val)
-{
-   if (is_init_done(dtsec->dtsec_drv_param))
-   return -EINVAL;
-
-   dtsec->dtsec_drv_param->maximum_frame = new_val;
-
-   return 0;
-}
-
-static int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool new_val)
-{
-   if (is_init_done(dtsec->dtsec_drv_param))
-   return -EINVAL;
-
-   dtsec->dtsec_drv_param->tx_pad_crc = new_val;
-
-   return 0;
-}
-
 static void graceful_start(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
@@ -1274,18 +1254,6 @@ static void adjust_link_dtsec(struct mac_device *mac_dev)
err);
 }
 
-static int dtsec_get_version(struct fman_mac *dtsec, u32 *mac_version)
-{
-   struct dtsec_regs __iomem *regs = dtsec->regs;
-
-   if (!is_init_done(dtsec->dtsec_drv_param))
-   return -EINVAL;
-
-   *mac_version = ioread32be(®s->tsec_id);
-
-   return 0;
-}
-
 static int dtsec_set_exception(struct fman_mac *dtsec,
   enum fman_mac_exceptions exception, bool enable)
 {
@@ -1525,7 +1493,7 @@ int dtsec_initialization(struct mac_device *mac_dev,
 {
int err;
struct fman_mac_params  params;
-   u32 version;
+   struct fman_mac *dtsec;
 
mac_dev->set_promisc= dtsec_set_promiscuous;
mac_dev->change_addr= dtsec_modify_mac_address;
@@ -1552,34 +1520,25 @@ int dtsec_initialization(struct mac_device *mac_dev,
goto _return;
}
 
-   err = dtsec_cfg_max_frame_len(mac_dev->fman_mac, fman_get_max_frm());
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = dtsec_cfg_pad_and_crc(mac_dev->fman_mac, true);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   err = dtsec_init(mac_dev->fman_mac);
+   dtsec = mac_dev->fman_mac;
+   dtsec->dtsec_drv_param->maximum_frame = fman_get_max_frm();
+   dtsec->dtsec_drv_param->tx_pad_crc = true;
+   err = dtsec_init(dtsec);
if (err < 0)
goto _return_fm_mac_free;
 
/* For 1G MAC, disable by default the MIB counters overflow interrupt */
-   err = mac_dev->set_exception(mac_dev->fman_mac,
-FM_MAC_EX_1G_RX_MIB_CNT_OVFL, false);
+   err = dtsec_set_exception(dtsec, FM_MAC_EX_1G_RX_MIB_CNT_OVFL, false);
if (err < 0)
goto _return_fm_mac_free;
 
-   err = dtsec_get_version(mac_dev->fman_mac, &version);
-   if (err < 0)
-   goto _return_fm_mac_free;
-
-   dev_info(mac_dev->dev, "FMan dTSEC version: 0x%08x\n", version);
+   dev_info(mac_dev->dev, "FMan dTSEC version: 0x%08x\n",
+ioread32be(&dtsec->regs->tsec_id));
 
goto _return;
 
 _return_fm_mac_free:
-   dtsec_free(mac_dev->fman_mac);
+   dtsec_free(dtsec);
 
 _return:
return err;
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index d3f4c3ec58c5..039f71e31efc 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -792,37 +792,6 @@ static void adjust_link_memac(struct mac_device *mac_dev)
err);
 }
 
-static int memac_cfg_max_frame_len(struct fman_mac *memac, u16 new_val)
-{
-   if (is_init_done(memac->memac_drv_param))
-   return -EINVAL;
-
-   memac->memac_drv_param->max_frame_length = new_val;
-
-   return 0;
-}
-
-static int memac_cfg_reset_on_init(struct fman_mac *memac, bool enable)
-{
-   if (is_init_done(memac->memac_drv_param))
-   return -EINVAL;
-
-   memac->memac_drv_param->reset_on_init = enable;
-
-   return 0;
-}
-
-static int memac_cfg_fixed_link(struct fman_mac *memac,
-   struct fixed_phy_status *fixed_link)
-{
-   if (is_init_done(memac->memac_drv_param))
-   return -EINVAL;
-
-   memac

[PATCH v4 01/25] dt-bindings: net: Convert FMan MAC bindings to yaml

2022-07-25 Thread Sean Anderson
This converts the MAC portion of the FMan MAC bindings to yaml.

Signed-off-by: Sean Anderson 
Reviewed-by: Rob Herring 
---

(no changes since v3)

Changes in v3:
- Incorperate some minor changes into the first FMan binding commit

Changes in v2:
- New

 .../bindings/net/fsl,fman-dtsec.yaml  | 145 ++
 .../devicetree/bindings/net/fsl-fman.txt  | 128 +---
 2 files changed, 146 insertions(+), 127 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/fsl,fman-dtsec.yaml

diff --git a/Documentation/devicetree/bindings/net/fsl,fman-dtsec.yaml 
b/Documentation/devicetree/bindings/net/fsl,fman-dtsec.yaml
new file mode 100644
index ..3a35ac1c260d
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/fsl,fman-dtsec.yaml
@@ -0,0 +1,145 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/fsl,fman-dtsec.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP FMan MAC
+
+maintainers:
+  - Madalin Bucur 
+
+description: |
+  Each FMan has several MACs, each implementing an Ethernet interface. Earlier
+  versions of FMan used the Datapath Three Speed Ethernet Controller (dTSEC) 
for
+  10/100/1000 MBit/s speeds, and the 10-Gigabit Ethernet Media Access 
Controller
+  (10GEC) for 10 Gbit/s speeds. Later versions of FMan use the Multirate
+  Ethernet Media Access Controller (mEMAC) to handle all speeds.
+
+properties:
+  compatible:
+enum:
+  - fsl,fman-dtsec
+  - fsl,fman-xgec
+  - fsl,fman-memac
+
+  cell-index:
+maximum: 64
+description: |
+  FManV2:
+  register[bit]   MAC cell-index
+  
+  FM_EPI[16]  XGEC8
+  FM_EPI[16+n]dTSECn  n-1
+  FM_NPI[11+n]dTSECn  n-1
+  n = 1,..,5
+
+  FManV3:
+  register[bit]   MAC cell-index
+  
+  FM_EPI[16+n]mEMACn  n-1
+  FM_EPI[25]  mEMAC10 9
+
+  FM_NPI[11+n]mEMACn  n-1
+  FM_NPI[10]  mEMAC10 9
+  FM_NPI[11]  mEMAC9  8
+  n = 1,..8
+
+  FM_EPI and FM_NPI are located in the FMan memory map.
+
+  2. SoC registers:
+
+  - P2041, P3041, P4080 P5020, P5040:
+  register[bit]   FManMAC cell
+  Unitindex
+  
+  DCFG_DEVDISR2[7]1   XGEC8
+  DCFG_DEVDISR2[7+n]  1   dTSECn  n-1
+  DCFG_DEVDISR2[15]   2   XGEC8
+  DCFG_DEVDISR2[15+n] 2   dTSECn  n-1
+  n = 1,..5
+
+  - T1040, T2080, T4240, B4860:
+  register[bit]   FManMAC cell
+  Unitindex
+  
+  DCFG_CCSR_DEVDISR2[n-1] 1   mEMACn  n-1
+  DCFG_CCSR_DEVDISR2[11+n]2   mEMACn  n-1
+  n = 1,..6,9,10
+
+  EVDISR, DCFG_DEVDISR2 and DCFG_CCSR_DEVDISR2 are located in
+  the specific SoC "Device Configuration/Pin Control" Memory
+  Map.
+
+  reg:
+maxItems: 1
+
+  fsl,fman-ports:
+$ref: /schemas/types.yaml#/definitions/phandle-array
+maxItems: 2
+description: |
+  An array of two references: the first is the FMan RX port and the second
+  is the TX port used by this MAC.
+
+  ptp-timer:
+$ref: /schemas/types.yaml#/definitions/phandle
+description: A reference to the IEEE1588 timer
+
+  pcsphy-handle:
+$ref: /schemas/types.yaml#/definitions/phandle
+description: A reference to the PCS (typically found on the SerDes)
+
+  tbi-handle:
+$ref: /schemas/types.yaml#/definitions/phandle
+description: A reference to the (TBI-based) PCS
+
+required:
+  - compatible
+  - cell-index
+  - reg
+  - fsl,fman-ports
+  - ptp-timer
+
+allOf:
+  - $ref: ethernet-controller.yaml#
+  - if:
+  properties:
+compatible:
+  contains:
+const: fsl,fman-dtsec
+then:
+  required:
+- tbi-handle
+  - if:
+  properties:
+compatible:
+  contains:
+const: fsl,fman-memac
+then:
+  required:
+- pcsphy-handle
+
+unevaluatedProperties: false
+
+examples:
+  - |
+ethernet@e {
+compatible = "fsl,fman-dtsec";
+cell-index = <0>;
+reg = <0xe 0x1000>;
+fsl,fman-ports = <&fman1_rx8 &fman1_tx28>;
+ptp-timer = <&ptp_timer>;
+tbi-handle = <&tbi0>;
+};
+  - |
+ethernet@e

[PATCH v4 11/25] net: fman: memac: Use params instead of priv for max_speed

2022-07-25 Thread Sean Anderson
This option is present in params, so use it instead of the fman private
version.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/fman/mac.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 0ac8df87308a..c376b9bf657d 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -388,11 +388,9 @@ static int memac_initialization(struct mac_device *mac_dev,
struct device_node *mac_node)
 {
int  err;
-   struct mac_priv_s   *priv;
struct fman_mac_params   params;
struct fixed_phy_status *fixed_link;
 
-   priv = mac_dev->priv;
mac_dev->set_promisc= memac_set_promiscuous;
mac_dev->change_addr= memac_modify_mac_address;
mac_dev->add_hash_mac_addr  = memac_add_hash_mac_address;
@@ -412,7 +410,7 @@ static int memac_initialization(struct mac_device *mac_dev,
goto _return;
params.internal_phy_node = of_parse_phandle(mac_node, "pcsphy-handle", 
0);
 
-   if (priv->max_speed == SPEED_1)
+   if (params.max_speed == SPEED_1)
params.phy_if = PHY_INTERFACE_MODE_XGMII;
 
mac_dev->fman_mac = memac_config(¶ms);
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 13/25] net: fman: Mark mac methods static

2022-07-25 Thread Sean Anderson
These methods are no longer accessed outside of the driver file, so mark
them as static.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 .../net/ethernet/freescale/fman/fman_dtsec.c  | 48 ++-
 .../net/ethernet/freescale/fman/fman_memac.c  | 45 +
 .../net/ethernet/freescale/fman/fman_tgec.c   | 40 +---
 3 files changed, 72 insertions(+), 61 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 92c2e35d3b4f..6991586165d7 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -814,7 +814,7 @@ static void free_init_resources(struct fman_mac *dtsec)
dtsec->unicast_addr_hash = NULL;
 }
 
-int dtsec_cfg_max_frame_len(struct fman_mac *dtsec, u16 new_val)
+static int dtsec_cfg_max_frame_len(struct fman_mac *dtsec, u16 new_val)
 {
if (is_init_done(dtsec->dtsec_drv_param))
return -EINVAL;
@@ -824,7 +824,7 @@ int dtsec_cfg_max_frame_len(struct fman_mac *dtsec, u16 
new_val)
return 0;
 }
 
-int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool new_val)
+static int dtsec_cfg_pad_and_crc(struct fman_mac *dtsec, bool new_val)
 {
if (is_init_done(dtsec->dtsec_drv_param))
return -EINVAL;
@@ -872,7 +872,7 @@ static void graceful_stop(struct fman_mac *dtsec)
}
 }
 
-int dtsec_enable(struct fman_mac *dtsec)
+static int dtsec_enable(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
@@ -891,7 +891,7 @@ int dtsec_enable(struct fman_mac *dtsec)
return 0;
 }
 
-int dtsec_disable(struct fman_mac *dtsec)
+static int dtsec_disable(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
@@ -909,9 +909,10 @@ int dtsec_disable(struct fman_mac *dtsec)
return 0;
 }
 
-int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
- u8 __maybe_unused priority,
- u16 pause_time, u16 __maybe_unused thresh_time)
+static int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
+u8 __maybe_unused priority,
+u16 pause_time,
+u16 __maybe_unused thresh_time)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 ptv = 0;
@@ -946,7 +947,7 @@ int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
return 0;
 }
 
-int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, bool en)
+static int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, bool en)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
@@ -968,7 +969,8 @@ int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, 
bool en)
return 0;
 }
 
-int dtsec_modify_mac_address(struct fman_mac *dtsec, const enet_addr_t 
*enet_addr)
+static int dtsec_modify_mac_address(struct fman_mac *dtsec,
+   const enet_addr_t *enet_addr)
 {
if (!is_init_done(dtsec->dtsec_drv_param))
return -EINVAL;
@@ -986,7 +988,8 @@ int dtsec_modify_mac_address(struct fman_mac *dtsec, const 
enet_addr_t *enet_add
return 0;
 }
 
-int dtsec_add_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
+static int dtsec_add_hash_mac_address(struct fman_mac *dtsec,
+ enet_addr_t *eth_addr)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
struct eth_hash_entry *hash_entry;
@@ -1052,7 +1055,7 @@ int dtsec_add_hash_mac_address(struct fman_mac *dtsec, 
enet_addr_t *eth_addr)
return 0;
 }
 
-int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable)
+static int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable)
 {
u32 tmp;
struct dtsec_regs __iomem *regs = dtsec->regs;
@@ -1071,7 +1074,7 @@ int dtsec_set_allmulti(struct fman_mac *dtsec, bool 
enable)
return 0;
 }
 
-int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable)
+static int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 rctrl, tctrl;
@@ -1096,7 +1099,8 @@ int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable)
return 0;
 }
 
-int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
+static int dtsec_del_hash_mac_address(struct fman_mac *dtsec,
+ enet_addr_t *eth_addr)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
struct list_head *pos;
@@ -1167,7 +1171,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, 
enet_addr_t *eth_addr)
return 0;
 }
 
-int dtsec_set_promiscuous(struct fman_mac *dtsec, bool new_val)
+static int dtsec_set_promiscuous(struct fman_mac *dtsec, bool new_val)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
  

[PATCH v4 15/25] net: fman: Remove internal_phy_node from params

2022-07-25 Thread Sean Anderson
This member was used to pass the phy node between mac_probe and the
mac-specific initialization function. But now that the phy node is
gotten in the initialization function, this parameter does not serve a
purpose. Remove it, and do the grabbing of the node/grabbing of the phy
in the same place.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 .../net/ethernet/freescale/fman/fman_dtsec.c  | 33 +-
 .../net/ethernet/freescale/fman/fman_mac.h|  2 --
 .../net/ethernet/freescale/fman/fman_memac.c  | 34 +--
 3 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 84205be3a817..c2c4677451a9 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1463,26 +1463,11 @@ static struct fman_mac *dtsec_config(struct 
fman_mac_params *params)
dtsec->fm = params->fm;
dtsec->basex_if = params->basex_if;
 
-   if (!params->internal_phy_node) {
-   pr_err("TBI PHY node is not available\n");
-   goto err_dtsec_drv_param;
-   }
-
-   dtsec->tbiphy = of_phy_find_device(params->internal_phy_node);
-   if (!dtsec->tbiphy) {
-   pr_err("of_phy_find_device (TBI PHY) failed\n");
-   goto err_dtsec_drv_param;
-   }
-
-   put_device(&dtsec->tbiphy->mdio.dev);
-
/* Save FMan revision */
fman_get_revision(dtsec->fm, &dtsec->fm_rev_info);
 
return dtsec;
 
-err_dtsec_drv_param:
-   kfree(dtsec_drv_param);
 err_dtsec:
kfree(dtsec);
return NULL;
@@ -1494,6 +1479,7 @@ int dtsec_initialization(struct mac_device *mac_dev,
int err;
struct fman_mac_params  params;
struct fman_mac *dtsec;
+   struct device_node  *phy_node;
 
mac_dev->set_promisc= dtsec_set_promiscuous;
mac_dev->change_addr= dtsec_modify_mac_address;
@@ -1512,7 +1498,6 @@ int dtsec_initialization(struct mac_device *mac_dev,
err = set_fman_mac_params(mac_dev, ¶ms);
if (err)
goto _return;
-   params.internal_phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);
 
mac_dev->fman_mac = dtsec_config(¶ms);
if (!mac_dev->fman_mac) {
@@ -1523,6 +1508,22 @@ int dtsec_initialization(struct mac_device *mac_dev,
dtsec = mac_dev->fman_mac;
dtsec->dtsec_drv_param->maximum_frame = fman_get_max_frm();
dtsec->dtsec_drv_param->tx_pad_crc = true;
+
+   phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);
+   if (!phy_node) {
+   pr_err("TBI PHY node is not available\n");
+   err = -EINVAL;
+   goto _return_fm_mac_free;
+   }
+
+   dtsec->tbiphy = of_phy_find_device(phy_node);
+   if (!dtsec->tbiphy) {
+   pr_err("of_phy_find_device (TBI PHY) failed\n");
+   err = -EINVAL;
+   goto _return_fm_mac_free;
+   }
+   put_device(&dtsec->tbiphy->mdio.dev);
+
err = dtsec_init(dtsec);
if (err < 0)
goto _return_fm_mac_free;
diff --git a/drivers/net/ethernet/freescale/fman/fman_mac.h 
b/drivers/net/ethernet/freescale/fman/fman_mac.h
index 418d1de85702..7774af6463e5 100644
--- a/drivers/net/ethernet/freescale/fman/fman_mac.h
+++ b/drivers/net/ethernet/freescale/fman/fman_mac.h
@@ -190,8 +190,6 @@ struct fman_mac_params {
 * synchronize with far-end phy at 10Mbps, 100Mbps or 1000Mbps
*/
bool basex_if;
-   /* Pointer to TBI/PCS PHY node, used for TBI/PCS PHY access */
-   struct device_node *internal_phy_node;
 };
 
 struct eth_hash_t {
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 039f71e31efc..5c0b837ebcbc 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -1150,22 +1150,6 @@ static struct fman_mac *memac_config(struct 
fman_mac_params *params)
/* Save FMan revision */
fman_get_revision(memac->fm, &memac->fm_rev_info);
 
-   if (memac->phy_if == PHY_INTERFACE_MODE_SGMII ||
-   memac->phy_if == PHY_INTERFACE_MODE_QSGMII) {
-   if (!params->internal_phy_node) {
-   pr_err("PCS PHY node is not available\n");
-   memac_free(memac);
-   return NULL;
-   }
-
-   memac->pcsphy = of_phy_find_device(params->internal_phy_node);
-   if (!memac->pcsphy) {
-   pr_err("of_phy_find_device (PCS PHY) failed\n");
-   memac_free(memac);
-   return NULL;
-   }
-   }
-
return memac;
 }
 
@@ -1173,6 +1157,7 @@ int memac_initialization(struct mac_device *mac_dev,

[PATCH v4 16/25] net: fman: Map the base address once

2022-07-25 Thread Sean Anderson
We don't need to remap the base address from the resource twice (once in
mac_probe() and again in set_fman_mac_params()). We still need the
resource to get the end address, but we can use a single function call
to get both at once.

While we're at it, use platform_get_mem_or_io and devm_request_resource
to map the resource. I think this is the more "correct" way to do things
here, since we use the pdev resource, instead of creating a new one.
It's still a bit tricky, since we need to ensure that the resource is a
child of the fman region when it gets requested.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

Changes in v4:
- tricy -> tricky

Changes in v2:
- Fix warning if sizeof(void *) != sizeof(resource_size_t)

 .../net/ethernet/freescale/dpaa/dpaa_eth.c|  4 +--
 .../ethernet/freescale/dpaa/dpaa_eth_sysfs.c  |  2 +-
 drivers/net/ethernet/freescale/fman/mac.c | 35 +++
 drivers/net/ethernet/freescale/fman/mac.h |  3 +-
 4 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index a548598b2e2d..d443d53c4504 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -218,8 +218,8 @@ static int dpaa_netdev_init(struct net_device *net_dev,
net_dev->netdev_ops = dpaa_ops;
mac_addr = priv->mac_dev->addr;
 
-   net_dev->mem_start = priv->mac_dev->res->start;
-   net_dev->mem_end = priv->mac_dev->res->end;
+   net_dev->mem_start = (unsigned long)priv->mac_dev->vaddr;
+   net_dev->mem_end = (unsigned long)priv->mac_dev->vaddr_end;
 
net_dev->min_mtu = ETH_MIN_MTU;
net_dev->max_mtu = dpaa_get_max_mtu();
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
index 4fee74c024bd..258eb6c8f4c0 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c
@@ -18,7 +18,7 @@ static ssize_t dpaa_eth_show_addr(struct device *dev,
 
if (mac_dev)
return sprintf(buf, "%llx",
-   (unsigned long long)mac_dev->res->start);
+   (unsigned long long)mac_dev->vaddr);
else
return sprintf(buf, "none");
 }
diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 7afedd4995c9..62af81c0c942 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -28,7 +28,6 @@ MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("FSL FMan MAC API based driver");
 
 struct mac_priv_s {
-   void __iomem*vaddr;
u8  cell_index;
struct fman *fman;
/* List of multicast addresses */
@@ -63,12 +62,7 @@ int set_fman_mac_params(struct mac_device *mac_dev,
 {
struct mac_priv_s *priv = mac_dev->priv;
 
-   params->base_addr = (typeof(params->base_addr))
-   devm_ioremap(mac_dev->dev, mac_dev->res->start,
-resource_size(mac_dev->res));
-   if (!params->base_addr)
-   return -ENOMEM;
-
+   params->base_addr = mac_dev->vaddr;
memcpy(¶ms->addr, mac_dev->addr, sizeof(mac_dev->addr));
params->max_speed   = priv->max_speed;
params->phy_if  = mac_dev->phy_if;
@@ -305,7 +299,7 @@ static int mac_probe(struct platform_device *_of_dev)
struct device_node  *mac_node, *dev_node;
struct mac_device   *mac_dev;
struct platform_device  *of_dev;
-   struct resource  res;
+   struct resource *res;
struct mac_priv_s   *priv;
u32  val;
u8  fman_id;
@@ -368,30 +362,25 @@ static int mac_probe(struct platform_device *_of_dev)
of_node_put(dev_node);
 
/* Get the address of the memory mapped registers */
-   err = of_address_to_resource(mac_node, 0, &res);
-   if (err < 0) {
-   dev_err(dev, "of_address_to_resource(%pOF) = %d\n",
-   mac_node, err);
-   goto _return_of_node_put;
+   res = platform_get_mem_or_io(_of_dev, 0);
+   if (!res) {
+   dev_err(dev, "could not get registers\n");
+   return -EINVAL;
}
 
-   mac_dev->res = __devm_request_region(dev,
-fman_get_mem_region(priv->fman),
-res.start, resource_size(&res),
-"mac");
-   if (!mac_dev->res) {
-   dev_err(dev, "__devm_request_mem_region(mac) failed\n");
-   err = -EBUSY;
+   err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res);
+   if (err) {
+ 

[PATCH v4 17/25] net: fman: Pass params directly to mac init

2022-07-25 Thread Sean Anderson
Instead of having the mac init functions call back into the fman core to
get their params, just pass them directly to the init functions.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 .../net/ethernet/freescale/fman/fman_dtsec.c  | 10 ++
 .../net/ethernet/freescale/fman/fman_dtsec.h  |  3 +-
 .../net/ethernet/freescale/fman/fman_memac.c  | 14 +++-
 .../net/ethernet/freescale/fman/fman_memac.h  |  3 +-
 .../net/ethernet/freescale/fman/fman_tgec.c   | 10 ++
 .../net/ethernet/freescale/fman/fman_tgec.h   |  3 +-
 drivers/net/ethernet/freescale/fman/mac.c | 36 ---
 drivers/net/ethernet/freescale/fman/mac.h |  2 --
 8 files changed, 32 insertions(+), 49 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index c2c4677451a9..9fabb2dfc972 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1474,10 +1474,10 @@ static struct fman_mac *dtsec_config(struct 
fman_mac_params *params)
 }
 
 int dtsec_initialization(struct mac_device *mac_dev,
-struct device_node *mac_node)
+struct device_node *mac_node,
+struct fman_mac_params *params)
 {
int err;
-   struct fman_mac_params  params;
struct fman_mac *dtsec;
struct device_node  *phy_node;
 
@@ -1495,11 +1495,7 @@ int dtsec_initialization(struct mac_device *mac_dev,
mac_dev->enable = dtsec_enable;
mac_dev->disable= dtsec_disable;
 
-   err = set_fman_mac_params(mac_dev, ¶ms);
-   if (err)
-   goto _return;
-
-   mac_dev->fman_mac = dtsec_config(¶ms);
+   mac_dev->fman_mac = dtsec_config(params);
if (!mac_dev->fman_mac) {
err = -EINVAL;
goto _return;
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.h 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.h
index cf3e683c089c..8c72d280c51a 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.h
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.h
@@ -11,6 +11,7 @@
 struct mac_device;
 
 int dtsec_initialization(struct mac_device *mac_dev,
-struct device_node *mac_node);
+struct device_node *mac_node,
+struct fman_mac_params *params);
 
 #endif /* __DTSEC_H */
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 5c0b837ebcbc..7121be0f958b 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -1154,11 +1154,11 @@ static struct fman_mac *memac_config(struct 
fman_mac_params *params)
 }
 
 int memac_initialization(struct mac_device *mac_dev,
-struct device_node *mac_node)
+struct device_node *mac_node,
+struct fman_mac_params *params)
 {
int  err;
struct device_node  *phy_node;
-   struct fman_mac_params   params;
struct fixed_phy_status *fixed_link;
struct fman_mac *memac;
 
@@ -1176,14 +1176,10 @@ int memac_initialization(struct mac_device *mac_dev,
mac_dev->enable = memac_enable;
mac_dev->disable= memac_disable;
 
-   err = set_fman_mac_params(mac_dev, ¶ms);
-   if (err)
-   goto _return;
+   if (params->max_speed == SPEED_1)
+   params->phy_if = PHY_INTERFACE_MODE_XGMII;
 
-   if (params.max_speed == SPEED_1)
-   params.phy_if = PHY_INTERFACE_MODE_XGMII;
-
-   mac_dev->fman_mac = memac_config(¶ms);
+   mac_dev->fman_mac = memac_config(params);
if (!mac_dev->fman_mac) {
err = -EINVAL;
goto _return;
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.h 
b/drivers/net/ethernet/freescale/fman/fman_memac.h
index a58215a3b1d9..5a3a14f9684f 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.h
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.h
@@ -14,6 +14,7 @@
 struct mac_device;
 
 int memac_initialization(struct mac_device *mac_dev,
-struct device_node *mac_node);
+struct device_node *mac_node,
+struct fman_mac_params *params);
 
 #endif /* __MEMAC_H */
diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c 
b/drivers/net/ethernet/freescale/fman/fman_tgec.c
index 32ee1674ff2f..f34f89e46a6f 100644
--- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
@@ -783,10 +783,10 @@ static struct fman_mac *tgec_config(struct 
fman_mac_params *params)
 }
 
 int tgec_initialization(struct mac_device *mac_dev,
-   

[PATCH v4 18/25] net: fman: Use mac_dev for some params

2022-07-25 Thread Sean Anderson
Some params are already present in mac_dev. Use them directly instead of
passing them through params.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 .../net/ethernet/freescale/fman/fman_dtsec.c| 16 +++-
 drivers/net/ethernet/freescale/fman/fman_mac.h  |  7 ---
 .../net/ethernet/freescale/fman/fman_memac.c| 17 -
 drivers/net/ethernet/freescale/fman/fman_tgec.c | 12 +---
 drivers/net/ethernet/freescale/fman/mac.c   | 10 ++
 5 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 9fabb2dfc972..09ad1117005a 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1413,13 +1413,11 @@ static int dtsec_free(struct fman_mac *dtsec)
return 0;
 }
 
-static struct fman_mac *dtsec_config(struct fman_mac_params *params)
+static struct fman_mac *dtsec_config(struct mac_device *mac_dev,
+struct fman_mac_params *params)
 {
struct fman_mac *dtsec;
struct dtsec_cfg *dtsec_drv_param;
-   void __iomem *base_addr;
-
-   base_addr = params->base_addr;
 
/* allocate memory for the UCC GETH data structure. */
dtsec = kzalloc(sizeof(*dtsec), GFP_KERNEL);
@@ -1436,10 +1434,10 @@ static struct fman_mac *dtsec_config(struct 
fman_mac_params *params)
 
set_dflts(dtsec_drv_param);
 
-   dtsec->regs = base_addr;
-   dtsec->addr = ENET_ADDR_TO_UINT64(params->addr);
+   dtsec->regs = mac_dev->vaddr;
+   dtsec->addr = ENET_ADDR_TO_UINT64(mac_dev->addr);
dtsec->max_speed = params->max_speed;
-   dtsec->phy_if = params->phy_if;
+   dtsec->phy_if = mac_dev->phy_if;
dtsec->mac_id = params->mac_id;
dtsec->exceptions = (DTSEC_IMASK_BREN   |
 DTSEC_IMASK_RXCEN  |
@@ -1456,7 +1454,7 @@ static struct fman_mac *dtsec_config(struct 
fman_mac_params *params)
 DTSEC_IMASK_RDPEEN);
dtsec->exception_cb = params->exception_cb;
dtsec->event_cb = params->event_cb;
-   dtsec->dev_id = params->dev_id;
+   dtsec->dev_id = mac_dev;
dtsec->ptp_tsu_enabled = dtsec->dtsec_drv_param->ptp_tsu_en;
dtsec->en_tsu_err_exception = dtsec->dtsec_drv_param->ptp_exception_en;
 
@@ -1495,7 +1493,7 @@ int dtsec_initialization(struct mac_device *mac_dev,
mac_dev->enable = dtsec_enable;
mac_dev->disable= dtsec_disable;
 
-   mac_dev->fman_mac = dtsec_config(params);
+   mac_dev->fman_mac = dtsec_config(mac_dev, params);
if (!mac_dev->fman_mac) {
err = -EINVAL;
goto _return;
diff --git a/drivers/net/ethernet/freescale/fman/fman_mac.h 
b/drivers/net/ethernet/freescale/fman/fman_mac.h
index 7774af6463e5..730aae7fed13 100644
--- a/drivers/net/ethernet/freescale/fman/fman_mac.h
+++ b/drivers/net/ethernet/freescale/fman/fman_mac.h
@@ -163,25 +163,18 @@ typedef void (fman_mac_exception_cb)(void *dev_id,
 
 /* FMan MAC config input */
 struct fman_mac_params {
-   /* Base of memory mapped FM MAC registers */
-   void __iomem *base_addr;
-   /* MAC address of device; First octet is sent first */
-   enet_addr_t addr;
/* MAC ID; numbering of dTSEC and 1G-mEMAC:
 * 0 - FM_MAX_NUM_OF_1G_MACS;
 * numbering of 10G-MAC (TGEC) and 10G-mEMAC:
 * 0 - FM_MAX_NUM_OF_10G_MACS
 */
u8 mac_id;
-   /* PHY interface */
-   phy_interface_t  phy_if;
/* Note that the speed should indicate the maximum rate that
 * this MAC should support rather than the actual speed;
 */
u16 max_speed;
/* A handle to the FM object this port related to */
void *fm;
-   void *dev_id; /* device cookie used by the exception cbs */
fman_mac_exception_cb *event_cb;/* MDIO Events Callback Routine */
fman_mac_exception_cb *exception_cb;/* Exception Callback Routine */
/* SGMII/QSGII interface with 1000BaseX auto-negotiation between MAC
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 7121be0f958b..2f3050df5ab9 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -1109,13 +1109,12 @@ static int memac_free(struct fman_mac *memac)
return 0;
 }
 
-static struct fman_mac *memac_config(struct fman_mac_params *params)
+static struct fman_mac *memac_config(struct mac_device *mac_dev,
+struct fman_mac_params *params)
 {
struct fman_mac *memac;
struct memac_cfg *memac_drv_param;
-   void __iomem *base_addr;
 
-   base_addr = params->base_addr;
/* allocate memory for the m_emac data str

[PATCH v4 19/25] net: fman: Specify type of mac_dev for exception_cb

2022-07-25 Thread Sean Anderson
Instead of using a void pointer for mac_dev, specify its type
explicitly.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v2)

Changes in v2:
- New

 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 2 +-
 drivers/net/ethernet/freescale/fman/fman_mac.h   | 5 +++--
 drivers/net/ethernet/freescale/fman/fman_memac.c | 2 +-
 drivers/net/ethernet/freescale/fman/fman_tgec.c  | 2 +-
 drivers/net/ethernet/freescale/fman/mac.c| 5 ++---
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 09ad1117005a..7acd57424034 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -301,7 +301,7 @@ struct fman_mac {
/* Ethernet physical interface */
phy_interface_t phy_if;
u16 max_speed;
-   void *dev_id; /* device cookie used by the exception cbs */
+   struct mac_device *dev_id; /* device cookie used by the exception cbs */
fman_mac_exception_cb *exception_cb;
fman_mac_exception_cb *event_cb;
/* Number of individual addresses in registers for this station */
diff --git a/drivers/net/ethernet/freescale/fman/fman_mac.h 
b/drivers/net/ethernet/freescale/fman/fman_mac.h
index 730aae7fed13..65887a3160d7 100644
--- a/drivers/net/ethernet/freescale/fman/fman_mac.h
+++ b/drivers/net/ethernet/freescale/fman/fman_mac.h
@@ -41,6 +41,7 @@
 #include 
 
 struct fman_mac;
+struct mac_device;
 
 /* Ethernet Address */
 typedef u8 enet_addr_t[ETH_ALEN];
@@ -158,8 +159,8 @@ struct eth_hash_entry {
struct list_head node;
 };
 
-typedef void (fman_mac_exception_cb)(void *dev_id,
-   enum fman_mac_exceptions exceptions);
+typedef void (fman_mac_exception_cb)(struct mac_device *dev_id,
+enum fman_mac_exceptions exceptions);
 
 /* FMan MAC config input */
 struct fman_mac_params {
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 2f3050df5ab9..19619af99f9c 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -311,7 +311,7 @@ struct fman_mac {
/* Ethernet physical interface */
phy_interface_t phy_if;
u16 max_speed;
-   void *dev_id; /* device cookie used by the exception cbs */
+   struct mac_device *dev_id; /* device cookie used by the exception cbs */
fman_mac_exception_cb *exception_cb;
fman_mac_exception_cb *event_cb;
/* Pointer to driver's global address hash table  */
diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c 
b/drivers/net/ethernet/freescale/fman/fman_tgec.c
index 2642a4c27292..010c0e0b57d7 100644
--- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
@@ -180,7 +180,7 @@ struct fman_mac {
/* MAC address of device; */
u64 addr;
u16 max_speed;
-   void *dev_id; /* device cookie used by the exception cbs */
+   struct mac_device *dev_id; /* device cookie used by the exception cbs */
fman_mac_exception_cb *exception_cb;
fman_mac_exception_cb *event_cb;
/* pointer to driver's global address hash table  */
diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 0f9e3e9e60c6..66a3742a862b 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -41,10 +41,9 @@ struct mac_address {
struct list_head list;
 };
 
-static void mac_exception(void *handle, enum fman_mac_exceptions ex)
+static void mac_exception(struct mac_device *mac_dev,
+ enum fman_mac_exceptions ex)
 {
-   struct mac_device *mac_dev = handle;
-
if (ex == FM_MAC_EX_10G_RX_FIFO_OVFL) {
/* don't flag RX FIFO after the first */
mac_dev->set_exception(mac_dev->fman_mac,
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 20/25] net: fman: Clean up error handling

2022-07-25 Thread Sean Anderson
This removes the _return label, since something like

err = -EFOO;
goto _return;

can be replaced by the briefer

return -EFOO;

Additionally, this skips going to _return_of_node_put when dev_node has
already been put (preventing a double put).

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/fman/mac.c | 43 ---
 1 file changed, 15 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/mac.c 
b/drivers/net/ethernet/freescale/fman/mac.c
index 66a3742a862b..7b7526fd7da3 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -291,15 +291,11 @@ static int mac_probe(struct platform_device *_of_dev)
init = of_device_get_match_data(dev);
 
mac_dev = devm_kzalloc(dev, sizeof(*mac_dev), GFP_KERNEL);
-   if (!mac_dev) {
-   err = -ENOMEM;
-   goto _return;
-   }
+   if (!mac_dev)
+   return -ENOMEM;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-   if (!priv) {
-   err = -ENOMEM;
-   goto _return;
-   }
+   if (!priv)
+   return -ENOMEM;
 
/* Save private information */
mac_dev->priv = priv;
@@ -312,8 +308,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!dev_node) {
dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node);
-   err = -EINVAL;
-   goto _return_of_node_put;
+   return -EINVAL;
}
 
of_dev = of_find_device_by_node(dev_node);
@@ -352,28 +347,24 @@ static int mac_probe(struct platform_device *_of_dev)
err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res);
if (err) {
dev_err_probe(dev, err, "could not request resource\n");
-   goto _return_of_node_put;
+   return err;
}
 
mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res));
if (!mac_dev->vaddr) {
dev_err(dev, "devm_ioremap() failed\n");
-   err = -EIO;
-   goto _return_of_node_put;
+   return -EIO;
}
mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res);
 
-   if (!of_device_is_available(mac_node)) {
-   err = -ENODEV;
-   goto _return_of_node_put;
-   }
+   if (!of_device_is_available(mac_node))
+   return -ENODEV;
 
/* Get the cell-index */
err = of_property_read_u32(mac_node, "cell-index", &val);
if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
-   err = -EINVAL;
-   goto _return_of_node_put;
+   return -EINVAL;
}
priv->cell_index = (u8)val;
 
@@ -387,15 +378,13 @@ static int mac_probe(struct platform_device *_of_dev)
if (unlikely(nph < 0)) {
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) 
failed\n",
mac_node);
-   err = nph;
-   goto _return_of_node_put;
+   return nph;
}
 
if (nph != ARRAY_SIZE(mac_dev->port)) {
dev_err(dev, "Not supported number of fman-ports handles of mac 
node %pOF from device tree\n",
mac_node);
-   err = -EINVAL;
-   goto _return_of_node_put;
+   return -EINVAL;
}
 
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -404,8 +393,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!dev_node) {
dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) 
failed\n",
mac_node);
-   err = -EINVAL;
-   goto _return_of_node_put;
+   return -EINVAL;
}
 
of_dev = of_find_device_by_node(dev_node);
@@ -465,7 +453,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node);
-   goto _return_of_node_put;
+   return err;
}
 
/* pause frame autonegotiation enabled */
@@ -492,11 +480,10 @@ static int mac_probe(struct platform_device *_of_dev)
priv->eth_dev = NULL;
}
 
-   goto _return;
+   return err;
 
 _return_of_node_put:
of_node_put(dev_node);
-_return:
return err;
 }
 
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 21/25] net: fman: Change return type of disable to void

2022-07-25 Thread Sean Anderson
When disabling, there is nothing we can do about errors. In fact, the
only error which can occur is misuse of the API. Just warn in the mac
driver instead.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v1)

 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c   | 5 +
 drivers/net/ethernet/freescale/fman/fman_dtsec.c | 7 ++-
 drivers/net/ethernet/freescale/fman/fman_memac.c | 8 +++-
 drivers/net/ethernet/freescale/fman/fman_tgec.c  | 7 ++-
 drivers/net/ethernet/freescale/fman/mac.h| 2 +-
 5 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index d443d53c4504..0ea29f83d0e4 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -290,10 +290,7 @@ static int dpaa_stop(struct net_device *net_dev)
 
if (mac_dev->phy_dev)
phy_stop(mac_dev->phy_dev);
-   err = mac_dev->disable(mac_dev->fman_mac);
-   if (err < 0)
-   netif_err(priv, ifdown, net_dev, "mac_dev->disable() = %d\n",
- err);
+   mac_dev->disable(mac_dev->fman_mac);
 
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
error = fman_port_disable(mac_dev->port[i]);
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 7acd57424034..f2dd07b714ea 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -871,13 +871,12 @@ static int dtsec_enable(struct fman_mac *dtsec)
return 0;
 }
 
-static int dtsec_disable(struct fman_mac *dtsec)
+static void dtsec_disable(struct fman_mac *dtsec)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 tmp;
 
-   if (!is_init_done(dtsec->dtsec_drv_param))
-   return -EINVAL;
+   WARN_ON_ONCE(!is_init_done(dtsec->dtsec_drv_param));
 
/* Graceful stop - Assert the graceful Rx/Tx stop bit */
graceful_stop(dtsec);
@@ -885,8 +884,6 @@ static int dtsec_disable(struct fman_mac *dtsec)
tmp = ioread32be(®s->maccfg1);
tmp &= ~(MACCFG1_RX_EN | MACCFG1_TX_EN);
iowrite32be(tmp, ®s->maccfg1);
-
-   return 0;
 }
 
 static int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 19619af99f9c..8ad93a4c0c21 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -701,19 +701,17 @@ static int memac_enable(struct fman_mac *memac)
return 0;
 }
 
-static int memac_disable(struct fman_mac *memac)
+static void memac_disable(struct fman_mac *memac)
+
 {
struct memac_regs __iomem *regs = memac->regs;
u32 tmp;
 
-   if (!is_init_done(memac->memac_drv_param))
-   return -EINVAL;
+   WARN_ON_ONCE(!is_init_done(memac->memac_drv_param));
 
tmp = ioread32be(®s->command_config);
tmp &= ~(CMD_CFG_RX_EN | CMD_CFG_TX_EN);
iowrite32be(tmp, ®s->command_config);
-
-   return 0;
 }
 
 static int memac_set_promiscuous(struct fman_mac *memac, bool new_val)
diff --git a/drivers/net/ethernet/freescale/fman/fman_tgec.c 
b/drivers/net/ethernet/freescale/fman/fman_tgec.c
index 010c0e0b57d7..f4cdf0cf7c32 100644
--- a/drivers/net/ethernet/freescale/fman/fman_tgec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_tgec.c
@@ -408,19 +408,16 @@ static int tgec_enable(struct fman_mac *tgec)
return 0;
 }
 
-static int tgec_disable(struct fman_mac *tgec)
+static void tgec_disable(struct fman_mac *tgec)
 {
struct tgec_regs __iomem *regs = tgec->regs;
u32 tmp;
 
-   if (!is_init_done(tgec->cfg))
-   return -EINVAL;
+   WARN_ON_ONCE(!is_init_done(tgec->cfg));
 
tmp = ioread32be(®s->command_config);
tmp &= ~(CMD_CFG_RX_EN | CMD_CFG_TX_EN);
iowrite32be(tmp, ®s->command_config);
-
-   return 0;
 }
 
 static int tgec_set_promiscuous(struct fman_mac *tgec, bool new_val)
diff --git a/drivers/net/ethernet/freescale/fman/mac.h 
b/drivers/net/ethernet/freescale/fman/mac.h
index c5fb4d46210f..a55efcb7998c 100644
--- a/drivers/net/ethernet/freescale/fman/mac.h
+++ b/drivers/net/ethernet/freescale/fman/mac.h
@@ -38,7 +38,7 @@ struct mac_device {
bool allmulti;
 
int (*enable)(struct fman_mac *mac_dev);
-   int (*disable)(struct fman_mac *mac_dev);
+   void (*disable)(struct fman_mac *mac_dev);
void (*adjust_link)(struct mac_device *mac_dev);
int (*set_promisc)(struct fman_mac *mac_dev, bool enable);
int (*change_addr)(struct fman_mac *mac_dev, const enet_addr_t 
*enet_addr);
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 22/25] net: dpaa: Use mac_dev variable in dpaa_netdev_init

2022-07-25 Thread Sean Anderson
There are several references to mac_dev in dpaa_netdev_init. Make things a
bit more concise by adding a local variable for it.

Signed-off-by: Sean Anderson 
---

Changes in v4:
- Use mac_dev for calling change_addr

 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 0ea29f83d0e4..b0ebf2ff0d00 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -203,6 +203,7 @@ static int dpaa_netdev_init(struct net_device *net_dev,
 {
struct dpaa_priv *priv = netdev_priv(net_dev);
struct device *dev = net_dev->dev.parent;
+   struct mac_device *mac_dev = priv->mac_dev;
struct dpaa_percpu_priv *percpu_priv;
const u8 *mac_addr;
int i, err;
@@ -216,10 +217,10 @@ static int dpaa_netdev_init(struct net_device *net_dev,
}
 
net_dev->netdev_ops = dpaa_ops;
-   mac_addr = priv->mac_dev->addr;
+   mac_addr = mac_dev->addr;
 
-   net_dev->mem_start = (unsigned long)priv->mac_dev->vaddr;
-   net_dev->mem_end = (unsigned long)priv->mac_dev->vaddr_end;
+   net_dev->mem_start = (unsigned long)mac_dev->vaddr;
+   net_dev->mem_end = (unsigned long)mac_dev->vaddr_end;
 
net_dev->min_mtu = ETH_MIN_MTU;
net_dev->max_mtu = dpaa_get_max_mtu();
@@ -246,7 +247,7 @@ static int dpaa_netdev_init(struct net_device *net_dev,
eth_hw_addr_set(net_dev, mac_addr);
} else {
eth_hw_addr_random(net_dev);
-   err = priv->mac_dev->change_addr(priv->mac_dev->fman_mac,
+   err = mac_dev->change_addr(mac_dev->fman_mac,
(const enet_addr_t *)net_dev->dev_addr);
if (err) {
dev_err(dev, "Failed to set random MAC address\n");
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 23/25] soc: fsl: qbman: Add helper for sanity checking cgr ops

2022-07-25 Thread Sean Anderson
This breaks out/combines get_affine_portal and the cgr sanity check in
preparation for the next commit. No functional change intended.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v2)

Changes in v2:
- New

 drivers/soc/fsl/qbman/qman.c | 29 +++--
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index fde4edd83c14..eb6600aab09b 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2483,13 +2483,8 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,
 }
 EXPORT_SYMBOL(qman_create_cgr);
 
-int qman_delete_cgr(struct qman_cgr *cgr)
+static struct qman_portal *qman_cgr_get_affine_portal(struct qman_cgr *cgr)
 {
-   unsigned long irqflags;
-   struct qm_mcr_querycgr cgr_state;
-   struct qm_mcc_initcgr local_opts;
-   int ret = 0;
-   struct qman_cgr *i;
struct qman_portal *p = get_affine_portal();
 
if (cgr->chan != p->config->channel) {
@@ -2497,10 +2492,25 @@ int qman_delete_cgr(struct qman_cgr *cgr)
dev_err(p->config->dev, "CGR not owned by current portal");
dev_dbg(p->config->dev, " create 0x%x, delete 0x%x\n",
cgr->chan, p->config->channel);
-
-   ret = -EINVAL;
-   goto put_portal;
+   put_affine_portal();
+   return NULL;
}
+
+   return p;
+}
+
+int qman_delete_cgr(struct qman_cgr *cgr)
+{
+   unsigned long irqflags;
+   struct qm_mcr_querycgr cgr_state;
+   struct qm_mcc_initcgr local_opts;
+   int ret = 0;
+   struct qman_cgr *i;
+   struct qman_portal *p = qman_cgr_get_affine_portal(cgr);
+
+   if (!p)
+   return -EINVAL;
+
memset(&local_opts, 0, sizeof(struct qm_mcc_initcgr));
spin_lock_irqsave(&p->cgr_lock, irqflags);
list_del(&cgr->node);
@@ -2528,7 +2538,6 @@ int qman_delete_cgr(struct qman_cgr *cgr)
list_add(&cgr->node, &p->cgr_cbs);
 release_lock:
spin_unlock_irqrestore(&p->cgr_lock, irqflags);
-put_portal:
put_affine_portal();
return ret;
 }
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 24/25] soc: fsl: qbman: Add CGR update function

2022-07-25 Thread Sean Anderson
This adds a function to update a CGR with new parameters. qman_create_cgr
can almost be used for this (with flags=0), but it's not suitable because
it also registers the callback function. The _safe variant was modeled off
of qman_cgr_delete_safe. However, we handle multiple arguments and a return
value.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

Changes in v4:
- qman_cgr_create -> qman_create_cgr

Changes in v2:
- New

 drivers/soc/fsl/qbman/qman.c | 47 
 include/soc/fsl/qman.h   |  9 +++
 2 files changed, 56 insertions(+)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index eb6600aab09b..68b825ea10f1 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -2568,6 +2568,53 @@ void qman_delete_cgr_safe(struct qman_cgr *cgr)
 }
 EXPORT_SYMBOL(qman_delete_cgr_safe);
 
+static int qman_update_cgr(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts)
+{
+   int ret;
+   unsigned long irqflags;
+   struct qman_portal *p = qman_cgr_get_affine_portal(cgr);
+
+   if (!p)
+   return -EINVAL;
+
+   spin_lock_irqsave(&p->cgr_lock, irqflags);
+   ret = qm_modify_cgr(cgr, 0, opts);
+   spin_unlock_irqrestore(&p->cgr_lock, irqflags);
+   put_affine_portal();
+   return ret;
+}
+
+struct update_cgr_params {
+   struct qman_cgr *cgr;
+   struct qm_mcc_initcgr *opts;
+   int ret;
+};
+
+static void qman_update_cgr_smp_call(void *p)
+{
+   struct update_cgr_params *params = p;
+
+   params->ret = qman_update_cgr(params->cgr, params->opts);
+}
+
+int qman_update_cgr_safe(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts)
+{
+   struct update_cgr_params params = {
+   .cgr = cgr,
+   .opts = opts,
+   };
+
+   preempt_disable();
+   if (qman_cgr_cpus[cgr->cgrid] != smp_processor_id())
+   smp_call_function_single(qman_cgr_cpus[cgr->cgrid],
+qman_update_cgr_smp_call, ¶ms, 
true);
+   else
+   params.ret = qman_update_cgr(cgr, opts);
+   preempt_enable();
+   return params.ret;
+}
+EXPORT_SYMBOL(qman_update_cgr_safe);
+
 /* Cleanup FQs */
 
 static int _qm_mr_consume_and_match_verb(struct qm_portal *p, int v)
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index 59eeba31c192..0d3d6beb7fdb 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -1171,6 +1171,15 @@ int qman_delete_cgr(struct qman_cgr *cgr);
  */
 void qman_delete_cgr_safe(struct qman_cgr *cgr);
 
+/**
+ * qman_update_cgr_safe - Modifies a congestion group object from any CPU
+ * @cgr: the 'cgr' object to modify
+ * @opts: state of the CGR settings
+ *
+ * This will select the proper CPU and modify the CGR settings.
+ */
+int qman_update_cgr_safe(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts);
+
 /**
  * qman_query_cgr_congested - Queries CGR's congestion status
  * @cgr: the 'cgr' object to query
-- 
2.35.1.1320.gc452695387.dirty



[PATCH v4 25/25] net: dpaa: Adjust queue depth on rate change

2022-07-25 Thread Sean Anderson
Instead of setting the queue depth once during probe, adjust it on the
fly whenever we configure the link. This is a bit unusal, since usually
the DPAA driver calls into the FMAN driver, but here we do the opposite.
We need to add a netdev to struct mac_device for this, but it will soon
live in the phylink config.

I haven't tested this extensively, but it doesn't seem to break
anything. We could possibly optimize this a bit by keeping track of the
last rate, but for now we just update every time. 10GEC probably doesn't
need to call into this at all, but I've added it for consistency.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v2)

Changes in v2:
- New

 .../net/ethernet/freescale/dpaa/dpaa_eth.c| 38 +--
 .../net/ethernet/freescale/fman/fman_dtsec.c  |  1 +
 .../net/ethernet/freescale/fman/fman_memac.c  |  1 +
 .../net/ethernet/freescale/fman/fman_tgec.c   |  7 +++-
 drivers/net/ethernet/freescale/fman/mac.h |  3 ++
 5 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c 
b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index b0ebf2ff0d00..f643009cac5f 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -197,6 +197,8 @@ static int dpaa_rx_extra_headroom;
 #define dpaa_get_max_mtu() \
(dpaa_max_frm - (VLAN_ETH_HLEN + ETH_FCS_LEN))
 
+static void dpaa_eth_cgr_set_speed(struct mac_device *mac_dev, int speed);
+
 static int dpaa_netdev_init(struct net_device *net_dev,
const struct net_device_ops *dpaa_ops,
u16 tx_timeout)
@@ -262,6 +264,9 @@ static int dpaa_netdev_init(struct net_device *net_dev,
net_dev->needed_headroom = priv->tx_headroom;
net_dev->watchdog_timeo = msecs_to_jiffies(tx_timeout);
 
+   mac_dev->net_dev = net_dev;
+   mac_dev->update_speed = dpaa_eth_cgr_set_speed;
+
/* start without the RUNNING flag, phylib controls it later */
netif_carrier_off(net_dev);
 
@@ -826,10 +831,10 @@ static int dpaa_eth_cgr_init(struct dpaa_priv *priv)
initcgr.we_mask = cpu_to_be16(QM_CGR_WE_CSCN_EN | QM_CGR_WE_CS_THRES);
initcgr.cgr.cscn_en = QM_CGR_EN;
 
-   /* Set different thresholds based on the MAC speed.
-* This may turn suboptimal if the MAC is reconfigured at a speed
-* lower than its max, e.g. if a dTSEC later negotiates a 100Mbps link.
-* In such cases, we ought to reconfigure the threshold, too.
+   /* Set different thresholds based on the configured MAC speed.
+* This may turn suboptimal if the MAC is reconfigured at another
+* speed, so MACs must call dpaa_eth_cgr_set_speed in their adjust_link
+* callback.
 */
if (priv->mac_dev->if_support & SUPPORTED_1baseT_Full)
cs_th = DPAA_CS_THRESHOLD_10G;
@@ -858,6 +863,31 @@ static int dpaa_eth_cgr_init(struct dpaa_priv *priv)
return err;
 }
 
+static void dpaa_eth_cgr_set_speed(struct mac_device *mac_dev, int speed)
+{
+   struct net_device *net_dev = mac_dev->net_dev;
+   struct dpaa_priv *priv = netdev_priv(net_dev);
+   struct qm_mcc_initcgr opts = { };
+   u32 cs_th;
+   int err;
+
+   opts.we_mask = cpu_to_be16(QM_CGR_WE_CS_THRES);
+   switch (speed) {
+   case SPEED_1:
+   cs_th = DPAA_CS_THRESHOLD_10G;
+   break;
+   case SPEED_1000:
+   default:
+   cs_th = DPAA_CS_THRESHOLD_1G;
+   break;
+   }
+   qm_cgr_cs_thres_set64(&opts.cgr.cs_thres, cs_th, 1);
+
+   err = qman_update_cgr_safe(&priv->cgr_data.cgr, &opts);
+   if (err)
+   netdev_err(net_dev, "could not update speed: %d\n", err);
+}
+
 static inline void dpaa_setup_ingress(const struct dpaa_priv *priv,
  struct dpaa_fq *fq,
  const struct qman_fq *template)
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index f2dd07b714ea..6617932fd3fd 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -1244,6 +1244,7 @@ static void adjust_link_dtsec(struct mac_device *mac_dev)
}
 
dtsec_adjust_link(fman_mac, phy_dev->speed);
+   mac_dev->update_speed(mac_dev, phy_dev->speed);
fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
if (err < 0)
diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c 
b/drivers/net/ethernet/freescale/fman/fman_memac.c
index 8ad93a4c0c21..02b3a0a2d5d1 100644
--- a/drivers/net/ethernet/freescale/fman/fman_memac.c
+++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
@@ -782,6 +782,7 @@ static void adjust_link_memac(struct mac_device *mac_dev)
 
fman_

[PATCH v4 12/25] net: fman: Move initialization to mac-specific files

2022-07-25 Thread Sean Anderson
This moves mac-specific initialization to mac-specific files. This will
make it easier to work with individual macs. It will also make it easier
to refactor the initialization to simplify the control flow. No
functional change intended.

Signed-off-by: Sean Anderson 
Acked-by: Camelia Groza 
---

(no changes since v2)

Changes in v2:
- Fix prototype for dtsec_initialization

 .../net/ethernet/freescale/fman/fman_dtsec.c  |  88 ++
 .../net/ethernet/freescale/fman/fman_dtsec.h  |  26 +-
 .../net/ethernet/freescale/fman/fman_memac.c  | 111 
 .../net/ethernet/freescale/fman/fman_memac.h  |  25 +-
 .../net/ethernet/freescale/fman/fman_tgec.c   |  65 +
 .../net/ethernet/freescale/fman/fman_tgec.h   |  22 +-
 drivers/net/ethernet/freescale/fman/mac.c | 261 --
 7 files changed, 276 insertions(+), 322 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
index 7f4f3d797a8d..92c2e35d3b4f 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c
@@ -7,6 +7,7 @@
 
 #include "fman_dtsec.h"
 #include "fman.h"
+#include "mac.h"
 
 #include 
 #include 
@@ -1247,6 +1248,28 @@ int dtsec_restart_autoneg(struct fman_mac *dtsec)
return 0;
 }
 
+static void adjust_link_dtsec(struct mac_device *mac_dev)
+{
+   struct phy_device *phy_dev = mac_dev->phy_dev;
+   struct fman_mac *fman_mac;
+   bool rx_pause, tx_pause;
+   int err;
+
+   fman_mac = mac_dev->fman_mac;
+   if (!phy_dev->link) {
+   dtsec_restart_autoneg(fman_mac);
+
+   return;
+   }
+
+   dtsec_adjust_link(fman_mac, phy_dev->speed);
+   fman_get_pause_cfg(mac_dev, &rx_pause, &tx_pause);
+   err = fman_set_mac_active_pause(mac_dev, rx_pause, tx_pause);
+   if (err < 0)
+   dev_err(mac_dev->dev, "fman_set_mac_active_pause() = %d\n",
+   err);
+}
+
 int dtsec_get_version(struct fman_mac *dtsec, u32 *mac_version)
 {
struct dtsec_regs __iomem *regs = dtsec->regs;
@@ -1492,3 +1515,68 @@ struct fman_mac *dtsec_config(struct fman_mac_params 
*params)
kfree(dtsec);
return NULL;
 }
+
+int dtsec_initialization(struct mac_device *mac_dev,
+struct device_node *mac_node)
+{
+   int err;
+   struct fman_mac_params  params;
+   u32 version;
+
+   mac_dev->set_promisc= dtsec_set_promiscuous;
+   mac_dev->change_addr= dtsec_modify_mac_address;
+   mac_dev->add_hash_mac_addr  = dtsec_add_hash_mac_address;
+   mac_dev->remove_hash_mac_addr   = dtsec_del_hash_mac_address;
+   mac_dev->set_tx_pause   = dtsec_set_tx_pause_frames;
+   mac_dev->set_rx_pause   = dtsec_accept_rx_pause_frames;
+   mac_dev->set_exception  = dtsec_set_exception;
+   mac_dev->set_allmulti   = dtsec_set_allmulti;
+   mac_dev->set_tstamp = dtsec_set_tstamp;
+   mac_dev->set_multi  = fman_set_multi;
+   mac_dev->adjust_link= adjust_link_dtsec;
+   mac_dev->enable = dtsec_enable;
+   mac_dev->disable= dtsec_disable;
+
+   err = set_fman_mac_params(mac_dev, ¶ms);
+   if (err)
+   goto _return;
+   params.internal_phy_node = of_parse_phandle(mac_node, "tbi-handle", 0);
+
+   mac_dev->fman_mac = dtsec_config(¶ms);
+   if (!mac_dev->fman_mac) {
+   err = -EINVAL;
+   goto _return;
+   }
+
+   err = dtsec_cfg_max_frame_len(mac_dev->fman_mac, fman_get_max_frm());
+   if (err < 0)
+   goto _return_fm_mac_free;
+
+   err = dtsec_cfg_pad_and_crc(mac_dev->fman_mac, true);
+   if (err < 0)
+   goto _return_fm_mac_free;
+
+   err = dtsec_init(mac_dev->fman_mac);
+   if (err < 0)
+   goto _return_fm_mac_free;
+
+   /* For 1G MAC, disable by default the MIB counters overflow interrupt */
+   err = mac_dev->set_exception(mac_dev->fman_mac,
+FM_MAC_EX_1G_RX_MIB_CNT_OVFL, false);
+   if (err < 0)
+   goto _return_fm_mac_free;
+
+   err = dtsec_get_version(mac_dev->fman_mac, &version);
+   if (err < 0)
+   goto _return_fm_mac_free;
+
+   dev_info(mac_dev->dev, "FMan dTSEC version: 0x%08x\n", version);
+
+   goto _return;
+
+_return_fm_mac_free:
+   dtsec_free(mac_dev->fman_mac);
+
+_return:
+   return err;
+}
diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.h 
b/drivers/net/ethernet/freescale/fman/fman_dtsec.h
index f072cdc560ba..cf3e683c089c 100644
--- a/drivers/net/ethernet/freescale/fman/fman_dtsec.h
+++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.h
@@ -8,27 +8,9 @@
 
 #include "fman_mac.h"
 
-struct fman_mac *dtsec_config(struct fman_mac_params *params);
-in

Re: [PATCH v2 04/10] drm/simpledrm: Compute framebuffer stride if not set

2022-07-25 Thread Javier Martinez Canillas
Hello Geert,

On 7/21/22 16:46, Geert Uytterhoeven wrote:
> Hi Thomas,
> 
> On Wed, Jul 20, 2022 at 4:27 PM Thomas Zimmermann  wrote:
>> Compute the framebuffer's scanline stride length if not given by
>> the simplefb data.
>>
>> Signed-off-by: Thomas Zimmermann 
> 
> Thanks for your patch!
> 
>> --- a/drivers/gpu/drm/tiny/simpledrm.c
>> +++ b/drivers/gpu/drm/tiny/simpledrm.c
>> @@ -743,6 +743,9 @@ static struct simpledrm_device 
>> *simpledrm_device_create(struct drm_driver *drv,
>> drm_err(dev, "no simplefb configuration found\n");
>> return ERR_PTR(-ENODEV);
>> }
>> +   if (!stride)
>> +   stride = format->cpp[0] * width;
> 
> DIV_ROUND_UP(drm_format_info_bpp(format) * width, 8)
>

I think you meant here:

DIV_ROUND_UP(drm_format_info_bpp(format, 0) * width, 8) ?
 
With that change,

Acked-by: Javier Martinez Canillas 

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat



Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Dan Horák
On Mon, 25 Jul 2022 22:39:18 +1000
Michael Ellerman  wrote:

> Commit d11219ad53dc ("amdgpu: disable powerpc support for the newer
> display engine") disabled the DCN driver for all of powerpc due to
> unresolved build failures with some compilers.
> 
> Further digging shows that the build failures only occur with compilers
> that default to 64-bit long double.
> 
> Both the ppc64 and ppc64le ABIs define long double to be 128-bits, but
> there are compilers in the wild that default to 64-bits. The compilers
> provided by the major distros (Fedora, Ubuntu) default to 128-bits and
> are not affected by the build failure.
> 
> There is a compiler flag to force 128-bit long double, which may be the
> correct long term fix, but as an interim fix only allow building the DCN
> driver if long double is 128-bits by default.
> 
> The bisection in commit d11219ad53dc must have gone off the rails at
> some point, the build failure occurs all the way back to the original
> commit that enabled DCN support on powerpc, at least with some
> toolchains.
> 
> Depends-on: d11219ad53dc ("amdgpu: disable powerpc support for the newer 
> display engine")
> Fixes: 16a9dea110a6 ("amdgpu: Enable initial DCN support on POWER")
> Signed-off-by: Michael Ellerman 
> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2100

LGTM

Reviewed-by: Dan Horák 


Dan

> ---
>  arch/powerpc/Kconfig| 4 
>  drivers/gpu/drm/amd/display/Kconfig | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> Alex, are you OK if I take this via the powerpc tree for v5.19?
> 
> cheers
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 7aa12e88c580..287cc2d4a4b3 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -281,6 +281,10 @@ config PPC
>   # Please keep this list sorted alphabetically.
>   #
>  
> +config PPC_LONG_DOUBLE_128
> + depends on PPC64
> + def_bool $(success,test "$(shell,echo __LONG_DOUBLE_128__ | $(CC) -E -P 
> -)" = 1)
> +
>  config PPC_BARRIER_NOSPEC
>   bool
>   default y
> diff --git a/drivers/gpu/drm/amd/display/Kconfig 
> b/drivers/gpu/drm/amd/display/Kconfig
> index 0ba0598eba20..ec6771e87e73 100644
> --- a/drivers/gpu/drm/amd/display/Kconfig
> +++ b/drivers/gpu/drm/amd/display/Kconfig
> @@ -6,7 +6,7 @@ config DRM_AMD_DC
>   bool "AMD DC - Enable new display engine"
>   default y
>   select SND_HDA_COMPONENT if SND_HDA_CORE
> - select DRM_AMD_DC_DCN if X86 && !(KCOV_INSTRUMENT_ALL && 
> KCOV_ENABLE_COMPARISONS)
> + select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128) && 
> !(KCOV_INSTRUMENT_ALL && KCOV_ENABLE_COMPARISONS)
>   help
> Choose this option if you want to use the new display engine
> support for AMDGPU. This adds required support for Vega and
> -- 
> 2.35.3
> 


Re: [PATCH v2 05/10] drm/simpledrm: Convert to atomic helpers

2022-07-25 Thread Javier Martinez Canillas
On 7/20/22 16:27, Thomas Zimmermann wrote:
> Replace the simple-KMS helpers with the regular atomic helpers. The
> regular helpers are better architectured and therefore allow for easier
> code sharing among drivers. No functional changes.
>

Acked-by: Javier Martinez Canillas 

But I've a question below...
 
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/tiny/simpledrm.c | 283 ---
>  1 file changed, 180 insertions(+), 103 deletions(-)

[...]

> +static void simpledrm_crtc_helper_atomic_enable(struct drm_crtc *crtc,
> + struct drm_atomic_state 
> *old_state)
> +{
> + /*
> +  * Always enabled; screen updates are performed by
> +  * the primary plane's atomic_update function.
> +  */
> +}
> +
> +static void simpledrm_crtc_helper_atomic_disable(struct drm_crtc *crtc,
> +  struct drm_atomic_state 
> *old_state)
> +{
> + /*
> +  * Always enabled; disabling clears the screen in the
> +  * primary plane's atomic_disable function.
> +  */
> +}

...do we really need to have these ? Can't we just not set them ?

> +
> +static const struct drm_crtc_helper_funcs simpledrm_crtc_helper_funcs = {
> + .mode_valid = simpledrm_crtc_helper_mode_valid,
> + .atomic_check = simpledrm_crtc_helper_atomic_check,
> + .atomic_enable = simpledrm_crtc_helper_atomic_enable,
> + .atomic_disable = simpledrm_crtc_helper_atomic_disable,
> +};
> +
looking at 
https://elixir.bootlin.com/linux/latest/source/include/drm/drm_modeset_helper_vtables.h#L703
that says the .atomic_{en,dis}able handlers are optional.

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat



Re: [PATCH v3 4/4] watchdog/pseries-wdt: initial support for H_WATCHDOG-based watchdog timers

2022-07-25 Thread Scott Cheloha
On Wed, Jul 13, 2022 at 01:50:14PM -0700, Guenter Roeck wrote:
> On 7/13/22 13:23, Scott Cheloha wrote:
> > PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> > guest control of one or more virtual watchdog timers.  The timers have
> > millisecond granularity.  The guest is terminated when a timer
> > expires.
> > 
> > This patch adds a watchdog driver for these timers, "pseries-wdt".
> > 
> > pseries_wdt_probe() currently assumes the existence of only one
> > platform device and always assigns it watchdogNumber 1.  If we ever
> > expose more than one timer to userspace we will need to devise a way
> > to assign a distinct watchdogNumber to each platform device at device
> > registration time.
> > 
> > Signed-off-by: Scott Cheloha 
> 
> Acked-by: Guenter Roeck 

Guenter, Michael,

Which tree is taking this series?

watchdog-next or PPC development?

-Scott


Re: [PATCH] powerpc: Remove the static variable initialisations to 0

2022-07-25 Thread Segher Boessenkool
On Mon, Jul 25, 2022 at 01:27:52PM +1000, Michael Ellerman wrote:
> Segher Boessenkool  writes:
> > On Sat, Jul 23, 2022 at 03:34:05PM +0200, Michal Suchánek wrote:
> >> Hello,
> >> 
> >> On Sat, Jul 23, 2022 at 05:24:36PM +0800, Jason Wang wrote:
> >> > Initialise global and static variable to 0 is always unnecessary.
> >> > Remove the unnecessary initialisations.
> >> 
> >> Isn't this change also unnecessary?
> >> 
> >> Initializing to 0 does not affect correctness, or even any kind of
> >> semantics in any way.
> >
> > It did make a difference when the kernel was still compiled with
> > -fcommon (which used to be the GCC default on most configurations, it is
> > traditional on Unix).  No explicit initialiser puts an object in .bss if
> > you use -fcommon.  This matters a bit for data layout.
> 
> The kernel has built with -fno-common since ~2002.

2001, yes (255649c18287).  And before that it was important to
initialise everything with static storage duration explicitly in the
source code.  It was part of the collective memory, I wondered if this
patch originated that way?

> I think the belief is that an explicit initialiser of 0 forces the
> variable into .data, but AFAICS that is not true with any compiler we
> support.

Exactly, you get identical code either way, if you use -fno-common.
People will still see this difference if they use a compiler before
GCC 10 for compiling most other things though.


Segher


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Yury Norov
On Mon, Jul 25, 2022 at 09:28:12AM +0200, Andy Shevchenko wrote:
> On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  wrote:
> >
> > archrandom.h includes  to refer ppc_md. This causes
> > circular header dependency, if generic nodemask.h  includes random.h:
> >
> > In file included from include/linux/cred.h:16,
> >  from include/linux/seq_file.h:13,
> >  from arch/powerpc/include/asm/machdep.h:6,
> >  from arch/powerpc/include/asm/archrandom.h:5,
> >  from include/linux/random.h:109,
> >  from include/linux/nodemask.h:97,
> >  from include/linux/list_lru.h:12,
> >  from include/linux/fs.h:13,
> >  from include/linux/compat.h:17,
> >  from arch/powerpc/kernel/asm-offsets.c:12:
> > include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
> >  1203 | nodemask_t  mems_allowed;
> >   | ^~
> >
> > Fix it by removing  dependency from archrandom.h
> 
> ...
> 
> >  EXPORT_SYMBOL_GPL(pm_power_off);
> 
> ^^^ (Note this and read below)
> 
> ...
> 
> > +EXPORT_SYMBOL(arch_get_random_seed_long);
> 
> It can't be like this. Brief browsing of the callees shows that.

Is my understanding correct that you're suggesting to make it GPL?

ppc_md is exported with EXPORT_SYMBOL(), and the function is in header,
so it's available for non-GPL code now. I don't want to change it.


Re: [PATCH v2 06/10] drm/simpledrm: Move some functionality into fwfb helper library

2022-07-25 Thread Javier Martinez Canillas
On 7/20/22 16:27, Thomas Zimmermann wrote:
> Move some of simpledrm's functionality into a helper library. Other
> drivers for firmware-provided framebuffers will also need functions
> to handle fixed modes and color formats, or update the back buffer.
> 
> Signed-off-by: Thomas Zimmermann 
> ---

Nice patch!

[...]

> +
> +/**
> + * DOC: overview
> + *
> + * The Firmware Framebuffer library FWFB provides helpers for devices with
> + * fixed-mode backing storage. It helps drivers to export a display mode of
> + * te correct size and copy updates to the backing storage.

the

it is "backing storage" or "backing store" ? I always thought that storage was
used for non-volatile media while "store" could be volatile and non-volatile.

[...]

> +/**
> + * drm_fwfb_init - Initializes an fwfb buffer
> + * @fwfb: fwfb buffer
> + * @screen_base: Address of the backing buffer in kernel address space
> + * @width: Number of pixels per scanline
> + * @height: Number of scanlines
> + * @format: Color format
> + * @pitch: Distance between two consecutive scanlines in bytes
> + *
> + * Returns:
> + * 0 on success, or a negative errno code otherwise.
> + */
> +int drm_fwfb_init(struct drm_fwfb *fwfb, struct iosys_map *screen_base,
> +   unsigned int width, unsigned int height,
> +   const struct drm_format_info *format, unsigned int pitch)
> +{
> + fwfb->screen_base = *screen_base;
> + fwfb->mode = drm_fwfb_mode(width, height);
> + fwfb->format = format;

It seems a little bit arbitrary to me that format is the only field that's
a pointer and the other ones are embedded into the struct drm_fwfb. Any
reason for that or is just a consequence of how types were used by the
simpledrm_device_create() function before that code moved into helpers ?

[...]

> +static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, 
> uint32_t fourcc)
> +{
> + const uint32_t *fourccs_end = fourccs + nfourccs;
> +
> + while (fourccs < fourccs_end) {
> + if (*fourccs == fourcc)
> + return true;
> + ++fourccs;
> + }
> + return false;
> +}

This seems a helper that could be useful besides the drm_fwfb_helper.c file.

I believe patches 1-6 shouldn't wait for the others in this series and could
just be merged when ready. Patches 7-10 can follow later.

-- 
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat



Re: Regression: Linux v5.15+ does not boot on Freescale P2020

2022-07-25 Thread Christophe Leroy


Le 25/07/2022 à 14:52, Pali Rohár a écrit :
> On Monday 25 July 2022 18:20:01 Michael Ellerman wrote:
>> Pali Rohár  writes:
>>> On Saturday 23 July 2022 14:42:22 Christophe Leroy wrote:
 Le 22/07/2022 à 11:09, Pali Rohár a écrit :
> Trying to boot mainline Linux kernel v5.15+, including current version
> from master branch, on Freescale P2020 does not work. Kernel does not
> print anything to serial console, seems that it does not work and after
> timeout watchdog reset the board.

 Can you provide more information ? Which defconfig or .config, which
 version of gcc, etc ... ?
>>>
>>> I used default defconfig for mpc85xx with gcc 8, compilation for e500
>>> cores.
>>>
>>> If you need exact .config content I can send it during week.
>>>
> I run git bisect and it found following commit:
>
> 9401f4e46cf6965e23738f70e149172344a01eef is the first bad commit
> commit 9401f4e46cf6965e23738f70e149172344a01eef
> Author: Christophe Leroy 
> Date:   Tue Mar 2 08:48:11 2021 +
>
>   powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX macros
>
>   Force the eh flag at 0 on PPC32.
>
>   Signed-off-by: Christophe Leroy 
>   Signed-off-by: Michael Ellerman 
>   Link: 
> https://lore.kernel.org/r/1fc81f07cabebb875b963e295408cc3dd38c8d85.1614674882.git.christophe.le...@csgroup.eu
>
> :04 04 fe6747e45736dfcba74914a9445e5f70f5120600 
> 96358d08b65d3200928a973efb5b969b3d45f2b0 M  arch
>
>
> If I revert this commit then kernel boots correctly. It also boots fine
> if I revert this commit on top of master branch.
>
> Freescale P2020 has two 32-bit e500 powerpc cores.
>
> Any idea why above commit is causing crash of the kernel? And why it is
> needed? Could eh flag set to 0 cause deadlock?

 Setting the eh flag to 0 is not supposed to be a change introduced by
 that commit. Indeed that commit is not supposed to change anything at
 all in the generated code.
>>>
>>> My understanding of that commit is that it changed eh flag parameter
>>> from 1 to 0 for 32-bit powerpc, including also p2020.
>>
>> Can you compare the disassembly before and after and find a place where
>> an instruction has changed?
>>
>> cheers
> 
> Yes, of course. Here is diff between output from objdump -d vmlinux.
> original version --- is from git master branch and modified version +++
> is the original version with reverted above problematic commit.
> So the +++ version is the one which is working.
> 
> --- vmlinux.master.dump   2022-07-25 14:43:45.922239496 +0200
> +++ vmlinux.revert.dump   2022-07-25 14:43:49.238259296 +0200
> @@ -1,5 +1,5 @@
>   
> -vmlinux.master: file format elf32-powerpc
> +vmlinux.revert: file format elf32-powerpc
>   
>   
>   Disassembly of section .head.text:
> @@ -11213,7 +11213,7 @@ c000b850: 3f a0 c1 0f lis r29,-1611
>   c000b854:   81 02 00 04 lwz r8,4(r2)
>   c000b858:   3b fd 10 68 addir31,r29,4200
>   c000b85c:   39 40 00 01 li  r10,1
> -c000b860:7d 20 f8 29 lwarx   r9,0,r31,1
> +c000b860:7d 20 f8 28 lwarx   r9,0,r31
>   c000b864:   2c 09 00 00 cmpwi   r9,0
>   c000b868:   40 82 00 10 bne c000b878 
>   c000b86c:   7d 40 f9 2d stwcx.  r10,0,r31

That's really strange. I made a try with mpc85xx_defconfig with GCC 11 
and I don't get any such difference.

Does your version of GCC has anything special ?

Can you send you exact .config ?

Thanks
Christophe

Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Yury Norov
On Mon, Jul 25, 2022 at 10:22:13PM +1000, Michael Ellerman wrote:
> Michael Ellerman  writes:
> > Yury Norov  writes:
> >> archrandom.h includes  to refer ppc_md. This causes
> >> circular header dependency, if generic nodemask.h  includes random.h:
> >>
> >> In file included from include/linux/cred.h:16,
> >>  from include/linux/seq_file.h:13,
> >>  from arch/powerpc/include/asm/machdep.h:6,
> >>  from arch/powerpc/include/asm/archrandom.h:5,
> >>  from include/linux/random.h:109,
> >>  from include/linux/nodemask.h:97,
> >>  from include/linux/list_lru.h:12,
> >>  from include/linux/fs.h:13,
> >>  from include/linux/compat.h:17,
> >>  from arch/powerpc/kernel/asm-offsets.c:12:
> >> include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
> >>  1203 | nodemask_t  mems_allowed;
> >>   | ^~
> >>
> >> Fix it by removing  dependency from archrandom.h
> >>
> >> Signed-off-by: Yury Norov 
> >> ---
> >>  arch/powerpc/include/asm/archrandom.h |  9 +
> >>  arch/powerpc/kernel/setup-common.c| 11 +++
> >>  2 files changed, 12 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/arch/powerpc/include/asm/archrandom.h 
> >> b/arch/powerpc/include/asm/archrandom.h
> >> index 9a53e29680f4..21def59ef1a6 100644
> >> --- a/arch/powerpc/include/asm/archrandom.h
> >> +++ b/arch/powerpc/include/asm/archrandom.h
> >> @@ -4,7 +4,7 @@
> >>  
> >>  #ifdef CONFIG_ARCH_RANDOM
> >>  
> >> -#include 
> >> +bool __must_check arch_get_random_seed_long(unsigned long *v);
> >>  
> >>  static inline bool __must_check arch_get_random_long(unsigned long *v)
> >>  {
> >> @@ -16,13 +16,6 @@ static inline bool __must_check 
> >> arch_get_random_int(unsigned int *v)
> >>return false;
> >>  }
> >>  
> >> -static inline bool __must_check arch_get_random_seed_long(unsigned long 
> >> *v)
> >> -{
> >> -  if (ppc_md.get_random_seed)
> >> -  return ppc_md.get_random_seed(v);
> >> -
> >> -  return false;
> >> -}
> >
> > I'd rather we didn't have to force this out of line.
> >
> > I think I see a different way to fix it, I'll just do some more build
> > tests.
> 
> Of course my idea didn't work :}
> 
> So I'll just ack your patch for now, and maybe I can get the headers
> cleaned up in future to allow it to be out-of-line again.

I understand that it looks like a tradeoff - we inline a couple of small
functions with the cost of uninlining an almost innocent victim. 

The complete solution would be probably a splitting ppc_md declaration
out of asm/machdep.h. I wanted to do that, but I'm not a PPC guy, and
just don't know how to split the header correctly.

Anyways, thanks for the ack. Applied on bitmap-for-next.

Thanks,
Yury


RE: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Deucher, Alexander
[Public]

> -Original Message-
> From: amd-gfx  On Behalf Of
> Michael Ellerman
> Sent: Monday, July 25, 2022 8:39 AM
> To: linuxppc-dev@lists.ozlabs.org
> Cc: d...@danny.cz; linux-ker...@vger.kernel.org; amd-
> g...@lists.freedesktop.org; tpear...@raptorengineering.com;
> alexdeuc...@gmail.com; torva...@linux-foundation.org; linux@roeck-
> us.net
> Subject: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc
> 
> Commit d11219ad53dc ("amdgpu: disable powerpc support for the newer
> display engine") disabled the DCN driver for all of powerpc due to unresolved
> build failures with some compilers.
> 
> Further digging shows that the build failures only occur with compilers that
> default to 64-bit long double.
> 
> Both the ppc64 and ppc64le ABIs define long double to be 128-bits, but there
> are compilers in the wild that default to 64-bits. The compilers provided by
> the major distros (Fedora, Ubuntu) default to 128-bits and are not affected
> by the build failure.
> 
> There is a compiler flag to force 128-bit long double, which may be the
> correct long term fix, but as an interim fix only allow building the DCN 
> driver if
> long double is 128-bits by default.
> 
> The bisection in commit d11219ad53dc must have gone off the rails at some
> point, the build failure occurs all the way back to the original commit that
> enabled DCN support on powerpc, at least with some toolchains.
> 
> Depends-on: d11219ad53dc ("amdgpu: disable powerpc support for the
> newer display engine")
> Fixes: 16a9dea110a6 ("amdgpu: Enable initial DCN support on POWER")
> Signed-off-by: Michael Ellerman 
> Link:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
> b.freedesktop.org%2Fdrm%2Famd%2F-
> %2Fissues%2F2100&data=05%7C01%7Calexander.deucher%40amd.com
> %7C3bfc6788a65444cb7ffe08da6e3ee794%7C3dd8961fe4884e608e11a82d994
> e183d%7C0%7C0%7C637943513703402010%7CUnknown%7CTWFpbGZsb3d8
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> D%7C3000%7C%7C%7C&sdata=MTWp8MSgFBltLYbrPHCAyR8VdVEHakp
> KVMkNEBRx%2FrI%3D&reserved=0
> ---
>  arch/powerpc/Kconfig| 4 
>  drivers/gpu/drm/amd/display/Kconfig | 2 +-
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> Alex, are you OK if I take this via the powerpc tree for v5.19?

No problem. 
Acked-by: Alex Deucher 
FWIW, We should have all of this PPC FP stuff cleared up in 5.20.

Alex

> 
> cheers
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index
> 7aa12e88c580..287cc2d4a4b3 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -281,6 +281,10 @@ config PPC
>   # Please keep this list sorted alphabetically.
>   #
> 
> +config PPC_LONG_DOUBLE_128
> + depends on PPC64
> + def_bool $(success,test "$(shell,echo __LONG_DOUBLE_128__ |
> $(CC) -E
> +-P -)" = 1)
> +
>  config PPC_BARRIER_NOSPEC
>   bool
>   default y
> diff --git a/drivers/gpu/drm/amd/display/Kconfig
> b/drivers/gpu/drm/amd/display/Kconfig
> index 0ba0598eba20..ec6771e87e73 100644
> --- a/drivers/gpu/drm/amd/display/Kconfig
> +++ b/drivers/gpu/drm/amd/display/Kconfig
> @@ -6,7 +6,7 @@ config DRM_AMD_DC
>   bool "AMD DC - Enable new display engine"
>   default y
>   select SND_HDA_COMPONENT if SND_HDA_CORE
> - select DRM_AMD_DC_DCN if X86 && !(KCOV_INSTRUMENT_ALL &&
> KCOV_ENABLE_COMPARISONS)
> + select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128) &&
> +!(KCOV_INSTRUMENT_ALL && KCOV_ENABLE_COMPARISONS)
>   help
> Choose this option if you want to use the new display engine
> support for AMDGPU. This adds required support for Vega and
> --
> 2.35.3


Re: [PATCH] PCI/ERR: Use pcie_aer_is_native() to judge whether OS owns AER

2022-07-25 Thread Sathyanarayanan Kuppuswamy



On 7/25/22 9:01 AM, Zhuo Chen wrote:
> After commit 7d7cbeaba5b7 ("PCI/ERR: Clear status of the reporting
> device"), the AER status of the device that reported the error
> rather than the first downstream port is cleared. So the problem
> in commit aa344bc8b727 ("PCI/ERR: Clear AER status only when we
> control AER") is no longer existent, and we change to use
> pcie_aer_is_native() here.
Can you add the details of the problem you are referring to? Also
include details about how this problem relates to your commit.

IIUC, your commit replaces "host->native_aer || pcie_ports_native"
with pcie_aer_is_native(dev, correct? If so, add a note in commit
log that it has no functional changes.

> 
> pci_aer_clear_nonfatal_status() already has pcie_aer_is_native(),
> so we move pci_aer_clear_nonfatal_status() out of
> pcie_aer_is_native().
> 
> Replace statements that judge whether OS owns AER in
> get_port_device_capability() with pcie_aer_is_native().
> 
> Signed-off-by: Zhuo Chen 
> ---
>  drivers/pci/pcie/err.c  | 12 ++--
>  drivers/pci/pcie/portdrv_core.c |  3 +--
>  2 files changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 0c5a143025af..28339c741555 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -184,7 +184,6 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
>   int type = pci_pcie_type(dev);
>   struct pci_dev *bridge;
>   pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
> - struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
>  
>   /*
>* If the error was detected by a Root Port, Downstream Port, RCEC,
> @@ -237,16 +236,9 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
>   pci_dbg(bridge, "broadcast resume message\n");
>   pci_walk_bridge(bridge, report_resume, &status);
>  
> - /*
> -  * If we have native control of AER, clear error status in the device
> -  * that detected the error.  If the platform retained control of AER,
> -  * it is responsible for clearing this status.  In that case, the
> -  * signaling device may not even be visible to the OS.
> -  */
> - if (host->native_aer || pcie_ports_native) {
> + if (pcie_aer_is_native(dev))
>   pcie_clear_device_status(dev);
> - pci_aer_clear_nonfatal_status(dev);
> - }
> + pci_aer_clear_nonfatal_status(dev);
>   pci_info(bridge, "device recovery successful\n");
>   return status;
>  
> diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
> index 604feeb84ee4..98c18f4a01b2 100644
> --- a/drivers/pci/pcie/portdrv_core.c
> +++ b/drivers/pci/pcie/portdrv_core.c
> @@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev)
>   }
>  
>  #ifdef CONFIG_PCIEAER
> - if (dev->aer_cap && pci_aer_available() &&
> - (pcie_ports_native || host->native_aer)) {
> + if (pcie_aer_is_native(dev) && pci_aer_available()) {
>   services |= PCIE_PORT_SERVICE_AER;
>  
>   /*

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Linus Torvalds
On Mon, Jul 25, 2022 at 5:39 AM Michael Ellerman  wrote:
>
> Further digging shows that the build failures only occur with compilers
> that default to 64-bit long double.

Where the heck do we have 'long double' things anywhere in the kernel?

I tried to grep for it, and failed miserably. I found some constants
that would qualify, but they were in the v4l colorspaces-details.rst
doc file.

Strange.

 Linus


Re: [PATCH] profile: setup_profiling_timer() is moslty not implemented

2022-07-25 Thread Andrew Morton
On Thu, 21 Jul 2022 20:55:09 +0100 Ben Dooks  wrote:

> The setup_profiling_timer() is mostly un-implemented by many
> architectures. In many places it isn't guarded by CONFIG_PROFILE
> which is needed for it to be used. Make it a weak symbol in
> kernel/profile.c and remove the 'return -EINVAL' implementations
> from the kenrel.
> 
> There are a couple of architectures which do return 0 from
> the setup_profiling_timer() function but they don't seem to
> do anything else with it. To keep the /proc compatibility for
> now, leave these for a future update or removal.
> 
> On ARM, this fixes the following sparse warning:
> arch/arm/kernel/smp.c:793:5: warning: symbol 'setup_profiling_timer' was not 
> declared. Should it be static?

I'll grab this.

We have had some problems with weak functions lately.  See

https://lore.kernel.org/all/87ee0q7b92@email.froward.int.ebiederm.org/T/#u

Hopefully that was a rare corner case.


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Timothy Pearson



- Original Message -
> From: "Linus Torvalds" 
> To: "Michael Ellerman" 
> Cc: "linuxppc-dev" , "Alex Deucher" 
> , "amd-gfx"
> , li...@roeck-us.net, "linux-kernel" 
> , "Dan Horák"
> , "Timothy Pearson" 
> Sent: Monday, July 25, 2022 2:19:57 PM
> Subject: Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

> On Mon, Jul 25, 2022 at 5:39 AM Michael Ellerman  wrote:
>>
>> Further digging shows that the build failures only occur with compilers
>> that default to 64-bit long double.
> 
> Where the heck do we have 'long double' things anywhere in the kernel?
> 
> I tried to grep for it, and failed miserably. I found some constants
> that would qualify, but they were in the v4l colorspaces-details.rst
> doc file.
> 
> Strange.

We don't, at least not that I can see.  The affected code uses standard doubles.

What I'm wondering is if the compiler is getting confused between standard and 
long doubles when they are both the same bit length...


Re: [PATCH v4 00/25] net: dpaa: Cleanups in preparation for phylink conversion

2022-07-25 Thread Jakub Kicinski
On Mon, 25 Jul 2022 11:10:14 -0400 Sean Anderson wrote:
> This series contains several cleanup patches for dpaa/fman. While they
> are intended to prepare for a phylink conversion, they stand on their
> own. This series was originally submitted as part of [1].

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#tl-dr


Re: Regression: Linux v5.15+ does not boot on Freescale P2020

2022-07-25 Thread Pali Rohár
On Monday 25 July 2022 16:20:49 Christophe Leroy wrote:
> Le 25/07/2022 à 14:52, Pali Rohár a écrit :
> > On Monday 25 July 2022 18:20:01 Michael Ellerman wrote:
> >> Pali Rohár  writes:
> >>> On Saturday 23 July 2022 14:42:22 Christophe Leroy wrote:
>  Le 22/07/2022 à 11:09, Pali Rohár a écrit :
> > Trying to boot mainline Linux kernel v5.15+, including current version
> > from master branch, on Freescale P2020 does not work. Kernel does not
> > print anything to serial console, seems that it does not work and after
> > timeout watchdog reset the board.
> 
>  Can you provide more information ? Which defconfig or .config, which
>  version of gcc, etc ... ?
> >>>
> >>> I used default defconfig for mpc85xx with gcc 8, compilation for e500
> >>> cores.
> >>>
> >>> If you need exact .config content I can send it during week.
> >>>
> > I run git bisect and it found following commit:
> >
> > 9401f4e46cf6965e23738f70e149172344a01eef is the first bad commit
> > commit 9401f4e46cf6965e23738f70e149172344a01eef
> > Author: Christophe Leroy 
> > Date:   Tue Mar 2 08:48:11 2021 +
> >
> >   powerpc: Use lwarx/ldarx directly instead of PPC_LWARX/LDARX 
> > macros
> >
> >   Force the eh flag at 0 on PPC32.
> >
> >   Signed-off-by: Christophe Leroy 
> >   Signed-off-by: Michael Ellerman 
> >   Link: 
> > https://lore.kernel.org/r/1fc81f07cabebb875b963e295408cc3dd38c8d85.1614674882.git.christophe.le...@csgroup.eu
> >
> > :04 04 fe6747e45736dfcba74914a9445e5f70f5120600 
> > 96358d08b65d3200928a973efb5b969b3d45f2b0 M  arch
> >
> >
> > If I revert this commit then kernel boots correctly. It also boots fine
> > if I revert this commit on top of master branch.
> >
> > Freescale P2020 has two 32-bit e500 powerpc cores.
> >
> > Any idea why above commit is causing crash of the kernel? And why it is
> > needed? Could eh flag set to 0 cause deadlock?
> 
>  Setting the eh flag to 0 is not supposed to be a change introduced by
>  that commit. Indeed that commit is not supposed to change anything at
>  all in the generated code.
> >>>
> >>> My understanding of that commit is that it changed eh flag parameter
> >>> from 1 to 0 for 32-bit powerpc, including also p2020.
> >>
> >> Can you compare the disassembly before and after and find a place where
> >> an instruction has changed?
> >>
> >> cheers
> > 
> > Yes, of course. Here is diff between output from objdump -d vmlinux.
> > original version --- is from git master branch and modified version +++
> > is the original version with reverted above problematic commit.
> > So the +++ version is the one which is working.
> > 
> > --- vmlinux.master.dump 2022-07-25 14:43:45.922239496 +0200
> > +++ vmlinux.revert.dump 2022-07-25 14:43:49.238259296 +0200
> > @@ -1,5 +1,5 @@
> >   
> > -vmlinux.master: file format elf32-powerpc
> > +vmlinux.revert: file format elf32-powerpc
> >   
> >   
> >   Disassembly of section .head.text:
> > @@ -11213,7 +11213,7 @@ c000b850:   3f a0 c1 0f lis r29,-1611
> >   c000b854: 81 02 00 04 lwz r8,4(r2)
> >   c000b858: 3b fd 10 68 addir31,r29,4200
> >   c000b85c: 39 40 00 01 li  r10,1
> > -c000b860:  7d 20 f8 29 lwarx   r9,0,r31,1
> > +c000b860:  7d 20 f8 28 lwarx   r9,0,r31
> >   c000b864: 2c 09 00 00 cmpwi   r9,0
> >   c000b868: 40 82 00 10 bne c000b878 
> >   c000b86c: 7d 40 f9 2d stwcx.  r10,0,r31
> 
> That's really strange. I made a try with mpc85xx_defconfig with GCC 11 
> and I don't get any such difference.

Yes, that is strange...

> Does your version of GCC has anything special ?

Nothing. Ordinary Debian 10 amd64 system with cross compiler from
gcc-powerpc-linux-gnuspe package (standard version, part of Debian).

Now I did again clean test with same Debian 10 cross compiler.

$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
&& cd linux
$ git checkout v5.15
$ make mpc85xx_smp_defconfig ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnuspe-
$ make vmlinux ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnuspe-
$ cp -a vmlinux vmlinux.v5.15
$ git revert 9401f4e46cf6965e23738f70e149172344a01eef
$ make vmlinux ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnuspe-
$ cp -a vmlinux vmlinux.revert
$ powerpc-linux-gnuspe-objdump -d vmlinux.revert > vmlinux.revert.dump
$ powerpc-linux-gnuspe-objdump -d vmlinux.v5.15 > vmlinux.v5.15.dump
$ diff -Naurp vmlinux.v5.15.dump vmlinux.revert.dump

And there are:

-c000c304:  7d 20 f8 29 lwarx   r9,0,r31,1
+c000c304:  7d 20 f8 28 lwarx   r9,0,r31

I guess it must be reproducible this issue as I'm using regular
toolchain from distribution.

Just to note that I had to apply Makefile patch for CONFIG_E500
https://lore.kernel.org/linuxppc-dev/20220524093939.30927-1-p...@kernel.org/

But I was told that this issue is reproducible also by 

Re: [PATCH v4 00/25] net: dpaa: Cleanups in preparation for phylink conversion

2022-07-25 Thread Sean Anderson
Hi Jakub,

On 7/25/22 4:09 PM, Jakub Kicinski wrote:
> On Mon, 25 Jul 2022 11:10:14 -0400 Sean Anderson wrote:
>> This series contains several cleanup patches for dpaa/fman. While they
>> are intended to prepare for a phylink conversion, they stand on their
>> own. This series was originally submitted as part of [1].
> 
> https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#tl-dr

> designate your patch to a tree - [PATCH net] or [PATCH net-next]

This should be applied to net-next. Sorry, I forgot to add this when
splitting off the series. It will be added for the next revision.

> don’t post large series (> 15 patches), break them up

These are all fairly small, incremental changes. There's no natural
breaking point, but I suppose it could be arbitrarily limited.

(there are some other notes there, but I think this series is in good
order wrt. them)

--Sean


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Segher Boessenkool
On Mon, Jul 25, 2022 at 02:34:08PM -0500, Timothy Pearson wrote:
> >> Further digging shows that the build failures only occur with compilers
> >> that default to 64-bit long double.
> > 
> > Where the heck do we have 'long double' things anywhere in the kernel?
> > 
> > I tried to grep for it, and failed miserably. I found some constants
> > that would qualify, but they were in the v4l colorspaces-details.rst
> > doc file.
> > 
> > Strange.
> 
> We don't, at least not that I can see.  The affected code uses standard 
> doubles.
> 
> What I'm wondering is if the compiler is getting confused between standard 
> and long doubles when they are both the same bit length...

The compiler emits the same code (DFmode things, double precision float)
in both cases, and it itself does not see any difference anymore fairly
early in the pipeline.  Compare to int and long on most 32-bit targets,
both are SImode, the compiler will not see different types anymore:
there *are* no types, except in the compiler frontend.

It only happens for powerpc64le things, and not for powerpc64 builds.

It is probably a GCC problem.  I don't see what forces the GCC build
here to use 64-bit long double either btw?  Compilers build via buildall
have all kinds of unnecessary things disabled, but not that, not
directly at least.


Segher


Re: Build regressions/improvements in v5.19-rc8

2022-07-25 Thread Geert Uytterhoeven

On Mon, 25 Jul 2022, Geert Uytterhoeven wrote:

JFYI, when comparing v5.19-rc8[1] to v5.19-rc7[3], the summaries are:
 - build errors: +1/-5


  + /kisskb/src/include/ufs/ufshci.h: error: initializer element is not constant:  
=> 245:36

v5.19-rc8/powerpc-gcc5/ppc64_book3e_allmodconfig
v5.19-rc8/powerpc-gcc5/powerpc-allmodconfig
v5.19-rc8/powerpc-gcc5/ppc64le_allmodconfig

Seen before


[1] 
http://kisskb.ellerman.id.au/kisskb/branch/linus/head/e0dccc3b76fb35bb257b4118367a883073d7390e/
 (all 135 configs)
[3] 
http://kisskb.ellerman.id.au/kisskb/branch/linus/head/ff6992735ade75aae3e35d16b17da1008d753d28/
 (all 135 configs)


Gr{oetje,eeting}s,

Geert

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

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


Re: [PATCH] profile: setup_profiling_timer() is moslty not implemented

2022-07-25 Thread Ben Dooks

On 25/07/2022 20:39, Andrew Morton wrote:

On Thu, 21 Jul 2022 20:55:09 +0100 Ben Dooks  wrote:


The setup_profiling_timer() is mostly un-implemented by many
architectures. In many places it isn't guarded by CONFIG_PROFILE
which is needed for it to be used. Make it a weak symbol in
kernel/profile.c and remove the 'return -EINVAL' implementations
from the kenrel.

There are a couple of architectures which do return 0 from
the setup_profiling_timer() function but they don't seem to
do anything else with it. To keep the /proc compatibility for
now, leave these for a future update or removal.

On ARM, this fixes the following sparse warning:
arch/arm/kernel/smp.c:793:5: warning: symbol 'setup_profiling_timer' was not 
declared. Should it be static?


I'll grab this.

We have had some problems with weak functions lately.  See

https://lore.kernel.org/all/87ee0q7b92@email.froward.int.ebiederm.org/T/#u

Hopefully that was a rare corner case.


Great, thanks.

--
Ben Dooks   http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html


Re: [PATCH v3 4/4] watchdog/pseries-wdt: initial support for H_WATCHDOG-based watchdog timers

2022-07-25 Thread Guenter Roeck
On Mon, Jul 25, 2022 at 11:11:41AM -0500, Scott Cheloha wrote:
> On Wed, Jul 13, 2022 at 01:50:14PM -0700, Guenter Roeck wrote:
> > On 7/13/22 13:23, Scott Cheloha wrote:
> > > PAPR v2.12 defines a new hypercall, H_WATCHDOG.  The hypercall permits
> > > guest control of one or more virtual watchdog timers.  The timers have
> > > millisecond granularity.  The guest is terminated when a timer
> > > expires.
> > > 
> > > This patch adds a watchdog driver for these timers, "pseries-wdt".
> > > 
> > > pseries_wdt_probe() currently assumes the existence of only one
> > > platform device and always assigns it watchdogNumber 1.  If we ever
> > > expose more than one timer to userspace we will need to devise a way
> > > to assign a distinct watchdogNumber to each platform device at device
> > > registration time.
> > > 
> > > Signed-off-by: Scott Cheloha 
> > 
> > Acked-by: Guenter Roeck 
> 
> Guenter, Michael,
> 
> Which tree is taking this series?
> 
The series includes non-watchdog changes, so my expectation was that some
other tree would take it.

Guenter

> watchdog-next or PPC development?
> 
> -Scott


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Andy Shevchenko
On Mon, Jul 25, 2022 at 6:19 PM Yury Norov  wrote:
> On Mon, Jul 25, 2022 at 09:28:12AM +0200, Andy Shevchenko wrote:
> > On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  wrote:

...

> > >  EXPORT_SYMBOL_GPL(pm_power_off);
> >
> > ^^^ (Note this and read below)
> >
> > ...
> >
> > > +EXPORT_SYMBOL(arch_get_random_seed_long);
> >
> > It can't be like this. Brief browsing of the callees shows that.
>
> Is my understanding correct that you're suggesting to make it GPL?
>
> ppc_md is exported with EXPORT_SYMBOL(), and the function is in header,
> so it's available for non-GPL code now. I don't want to change it.

The symbols your function calls are GPL. As far as I understand (not a
lawyer!) it logically one may not call GPL and pretend to be non-GPL.

-- 
With Best Regards,
Andy Shevchenko


[PATCH] PCI/ERR: Use pcie_aer_is_native() to judge whether OS owns AER

2022-07-25 Thread Zhuo Chen
After commit 7d7cbeaba5b7 ("PCI/ERR: Clear status of the reporting
device"), the AER status of the device that reported the error
rather than the first downstream port is cleared. So the problem
in commit aa344bc8b727 ("PCI/ERR: Clear AER status only when we
control AER") is no longer existent, and we change to use
pcie_aer_is_native() here.

pci_aer_clear_nonfatal_status() already has pcie_aer_is_native(),
so we move pci_aer_clear_nonfatal_status() out of
pcie_aer_is_native().

Replace statements that judge whether OS owns AER in
get_port_device_capability() with pcie_aer_is_native().

Signed-off-by: Zhuo Chen 
---
 drivers/pci/pcie/err.c  | 12 ++--
 drivers/pci/pcie/portdrv_core.c |  3 +--
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 0c5a143025af..28339c741555 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -184,7 +184,6 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
int type = pci_pcie_type(dev);
struct pci_dev *bridge;
pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
-   struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
 
/*
 * If the error was detected by a Root Port, Downstream Port, RCEC,
@@ -237,16 +236,9 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_dbg(bridge, "broadcast resume message\n");
pci_walk_bridge(bridge, report_resume, &status);
 
-   /*
-* If we have native control of AER, clear error status in the device
-* that detected the error.  If the platform retained control of AER,
-* it is responsible for clearing this status.  In that case, the
-* signaling device may not even be visible to the OS.
-*/
-   if (host->native_aer || pcie_ports_native) {
+   if (pcie_aer_is_native(dev))
pcie_clear_device_status(dev);
-   pci_aer_clear_nonfatal_status(dev);
-   }
+   pci_aer_clear_nonfatal_status(dev);
pci_info(bridge, "device recovery successful\n");
return status;
 
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 604feeb84ee4..98c18f4a01b2 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev)
}
 
 #ifdef CONFIG_PCIEAER
-   if (dev->aer_cap && pci_aer_available() &&
-   (pcie_ports_native || host->native_aer)) {
+   if (pcie_aer_is_native(dev) && pci_aer_available()) {
services |= PCIE_PORT_SERVICE_AER;
 
/*
-- 
2.30.1 (Apple Git-130)



Re: [PATCH 04/36] cpuidle,intel_idle: Fix CPUIDLE_FLAG_IRQ_ENABLE

2022-07-25 Thread Michel Lespinasse
On Wed, Jun 08, 2022 at 04:27:27PM +0200, Peter Zijlstra wrote:
> Commit c227233ad64c ("intel_idle: enable interrupts before C1 on
> Xeons") wrecked intel_idle in two ways:
> 
>  - must not have tracing in idle functions
>  - must return with IRQs disabled
> 
> Additionally, it added a branch for no good reason.
> 
> Fixes: c227233ad64c ("intel_idle: enable interrupts before C1 on Xeons")
> Signed-off-by: Peter Zijlstra (Intel) 

After this change was introduced, I am seeing "WARNING: suspicious RCU
usage" when booting a kernel with debug options compiled in. Please
see the attached dmesg output. The issue starts with commit 32d4fd5751ea
and is still present in v5.19-rc8.

I'm not sure, is this too late to fix or revert in v5.19 final ?

Thanks,

--
Michel "walken" Lespinasse
[0.00] microcode: microcode updated early to revision 0x2006d05, date = 
2021-11-13
[0.00] Linux version 5.19.0-rc8-test-3-ge3a8d97e6a35 (walken@zeus) 
(gcc (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1) #1 SMP 
PREEMPT_DYNAMIC Mon Jul 25 00:32:16 PDT 2022
[0.00] Command line: 
BOOT_IMAGE=/vmlinuz-5.19.0-rc8-test-3-ge3a8d97e6a35 
root=/dev/mapper/budai--vg-root ro consoleblank=600 quiet
[0.00] KERNEL supported cpus:
[0.00]   Intel GenuineIntel
[0.00]   AMD AuthenticAMD
[0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point 
registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x008: 'MPX bounds registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x010: 'MPX CSR'
[0.00] x86/fpu: Supporting XSAVE feature 0x020: 'AVX-512 opmask'
[0.00] x86/fpu: Supporting XSAVE feature 0x040: 'AVX-512 Hi256'
[0.00] x86/fpu: Supporting XSAVE feature 0x080: 'AVX-512 ZMM_Hi256'
[0.00] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[0.00] x86/fpu: xstate_offset[3]:  832, xstate_sizes[3]:   64
[0.00] x86/fpu: xstate_offset[4]:  896, xstate_sizes[4]:   64
[0.00] x86/fpu: xstate_offset[5]:  960, xstate_sizes[5]:   64
[0.00] x86/fpu: xstate_offset[6]: 1024, xstate_sizes[6]:  512
[0.00] x86/fpu: xstate_offset[7]: 1536, xstate_sizes[7]: 1024
[0.00] x86/fpu: Enabled xstate features 0xff, context size is 2560 
bytes, using 'compacted' format.
[0.00] signal: max sigframe size: 3632
[0.00] BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0003efff] usable
[0.00] BIOS-e820: [mem 0x0003f000-0x0003] reserved
[0.00] BIOS-e820: [mem 0x0004-0x0009] usable
[0.00] BIOS-e820: [mem 0x000a-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0x62a8efff] usable
[0.00] BIOS-e820: [mem 0x62a8f000-0x6aef4fff] reserved
[0.00] BIOS-e820: [mem 0x6aef5000-0x6b0c2fff] ACPI data
[0.00] BIOS-e820: [mem 0x6b0c3000-0x6be0dfff] ACPI NVS
[0.00] BIOS-e820: [mem 0x6be0e000-0x6c7f1fff] reserved
[0.00] BIOS-e820: [mem 0x6c7f2000-0x6c8e5fff] type 20
[0.00] BIOS-e820: [mem 0x6c8e6000-0x6c8e6fff] reserved
[0.00] BIOS-e820: [mem 0x6c8e7000-0x6c9a7fff] type 20
[0.00] BIOS-e820: [mem 0x6c9a8000-0x6e6f] usable
[0.00] BIOS-e820: [mem 0x6e70-0x8fff] reserved
[0.00] BIOS-e820: [mem 0xfd00-0xfe010fff] reserved
[0.00] BIOS-e820: [mem 0xfec0-0xfec00fff] reserved
[0.00] BIOS-e820: [mem 0xfed0-0xfed00fff] reserved
[0.00] BIOS-e820: [mem 0xfed2-0xfed44fff] reserved
[0.00] BIOS-e820: [mem 0xfee0-0xfee00fff] reserved
[0.00] BIOS-e820: [mem 0xff00-0x] reserved
[0.00] BIOS-e820: [mem 0x0001-0x00107fff] usable
[0.00] NX (Execute Disable) protection: active
[0.00] efi: EFI v2.70 by American Megatrends
[0.00] efi: TPMFinalLog=0x6bd97000 ACPI=0x6b0c2000 ACPI 2.0=0x6b0c2014 
SMBIOS=0x6c47b000 SMBIOS 3.0=0x6c47a000 MEMATTR=0x5d04d018 ESRT=0x604e0718 
[0.00] SMBIOS 3.0.0 present.
[0.00] DMI: LENOVO 30BFS44D00/1036, BIOS S03KT51A 01/17/2022
[0.00] tsc: Detected 3700.000 MHz processor
[0.00] tsc: Detected 3699.850 MHz TSC
[0.000278] e820: update [mem 0x-0x0fff] usable ==> reserved
[0.000281] e820: remove [mem 0x000a-0x000f] usable
[0.000289] last_pfn = 0x108 max_arch_pfn = 0x4
[0.000397] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT  
[0.001626] e820: update [mem 0x7e00-0xf

Re: Regression: Linux v5.15+ does not boot on Freescale P2020

2022-07-25 Thread Segher Boessenkool
On Mon, Jul 25, 2022 at 10:10:09PM +0200, Pali Rohár wrote:
> On Monday 25 July 2022 16:20:49 Christophe Leroy wrote:
> Now I did again clean test with same Debian 10 cross compiler.
> 
> $ git clone 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git && cd linux
> $ git checkout v5.15
> $ make mpc85xx_smp_defconfig ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnuspe-
> $ make vmlinux ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnuspe-
> $ cp -a vmlinux vmlinux.v5.15
> $ git revert 9401f4e46cf6965e23738f70e149172344a01eef
> $ make vmlinux ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnuspe-
> $ cp -a vmlinux vmlinux.revert
> $ powerpc-linux-gnuspe-objdump -d vmlinux.revert > vmlinux.revert.dump
> $ powerpc-linux-gnuspe-objdump -d vmlinux.v5.15 > vmlinux.v5.15.dump
> $ diff -Naurp vmlinux.v5.15.dump vmlinux.revert.dump
> 
> And there are:
> 
> -c000c304:  7d 20 f8 29 lwarx   r9,0,r31,1
> +c000c304:  7d 20 f8 28 lwarx   r9,0,r31
> 
> I guess it must be reproducible this issue as I'm using regular
> toolchain from distribution.

The kernel had

#define PPC_RAW_LWARX(t, a, b, eh)   (0x7c28 | ___PPC_RT(t) | 
___PPC_RA(a) | ___PPC_RB(b) | __PPC_EH(eh))

and

#define PPC_LWARX(t, a, b, eh) stringify_in_c(.long PPC_RAW_LWARX(t, a, b, eh))

and

#ifdef CONFIG_PPC64
#define __PPC_EH(eh)(((eh) & 0x1) << 0)
#else
#define __PPC_EH(eh)0
#endif

but Christophe's 9401f4e46cf6 changed

-"1:" PPC_LWARX(%0,0,%2,1) "\n\
+"1:lwarx   %0,0,%2,1\n\

no longer checking CONFIG_PPC64.  That appears to be the bug.

The EH field in larx insns is new since ISA 2.05, and some ISA 1.x cpu
implementations actually raise an illegal insn exception on EH=1.  It
appears P2020 is one of those.


Segher


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Guenter Roeck

On 7/25/22 13:42, Segher Boessenkool wrote:

On Mon, Jul 25, 2022 at 02:34:08PM -0500, Timothy Pearson wrote:

Further digging shows that the build failures only occur with compilers
that default to 64-bit long double.


Where the heck do we have 'long double' things anywhere in the kernel?

I tried to grep for it, and failed miserably. I found some constants
that would qualify, but they were in the v4l colorspaces-details.rst
doc file.

Strange.


We don't, at least not that I can see.  The affected code uses standard doubles.

What I'm wondering is if the compiler is getting confused between standard and 
long doubles when they are both the same bit length...


The compiler emits the same code (DFmode things, double precision float)
in both cases, and it itself does not see any difference anymore fairly
early in the pipeline.  Compare to int and long on most 32-bit targets,
both are SImode, the compiler will not see different types anymore:
there *are* no types, except in the compiler frontend.

It only happens for powerpc64le things, and not for powerpc64 builds.

It is probably a GCC problem.  I don't see what forces the GCC build
here to use 64-bit long double either btw?  Compilers build via buildall
have all kinds of unnecessary things disabled, but not that, not
directly at least.



From what little documentation I can find, there appears to be
"--with-long-double-128" and "--with-long-double-format=ieee".
That looks like something that would need to be enabled, not disabled.

FWIW, depending on compiler build options such as the above for kernel
builds seems to be a little odd to me, and I am not sure I'd want to
blame gcc if the kernel wants to be built with 128-bit floating point
as default. At the very least, that should be documented somewhere,
and if possible the kernel should refuse to build if the compiler build
options don't meet the requirements.

Guenter


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Yury Norov
On Mon, Jul 25, 2022 at 11:39:39PM +0200, Andy Shevchenko wrote:
> On Mon, Jul 25, 2022 at 6:19 PM Yury Norov  wrote:
> > On Mon, Jul 25, 2022 at 09:28:12AM +0200, Andy Shevchenko wrote:
> > > On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  wrote:
> 
> ...
> 
> > > >  EXPORT_SYMBOL_GPL(pm_power_off);
> > >
> > > ^^^ (Note this and read below)
> > >
> > > ...
> > >
> > > > +EXPORT_SYMBOL(arch_get_random_seed_long);
> > >
> > > It can't be like this. Brief browsing of the callees shows that.
> >
> > Is my understanding correct that you're suggesting to make it GPL?
> >
> > ppc_md is exported with EXPORT_SYMBOL(), and the function is in header,
> > so it's available for non-GPL code now. I don't want to change it.
> 
> The symbols your function calls are GPL. As far as I understand (not a
> lawyer!) it logically one may not call GPL and pretend to be non-GPL.

Can you explain what you mean in details?

The function is:
static inline bool __must_check arch_get_random_seed_long(unsigned long 
*v)
{
   if (ppc_md.get_random_seed)
   return ppc_md.get_random_seed(v);

   return false;
}

ppc_md is non-GPL:
 77 /* The main machine-dep calls structure
 78  */
 79 struct machdep_calls ppc_md;
 80 EXPORT_SYMBOL(ppc_md);

And get_random_seed is initialized in in arch/powerpc/platforms/powernv/rng.c
with different functions that are static and not exported at all. 

I don't understand where arch_get_random_seed_long calls GPL...


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Segher Boessenkool
Hi!

On Mon, Jul 25, 2022 at 03:40:40PM -0700, Guenter Roeck wrote:
> On 7/25/22 13:42, Segher Boessenkool wrote:
> >>What I'm wondering is if the compiler is getting confused between 
> >>standard and long doubles when they are both the same bit length...
> >
> >The compiler emits the same code (DFmode things, double precision float)
> >in both cases, and it itself does not see any difference anymore fairly
> >early in the pipeline.  Compare to int and long on most 32-bit targets,
> >both are SImode, the compiler will not see different types anymore:
> >there *are* no types, except in the compiler frontend.
> >
> >It only happens for powerpc64le things, and not for powerpc64 builds.
> >
> >It is probably a GCC problem.  I don't see what forces the GCC build
> >here to use 64-bit long double either btw?  Compilers build via buildall
> >have all kinds of unnecessary things disabled, but not that, not
> >directly at least.
> 
> From what little documentation I can find, there appears to be
> "--with-long-double-128" and "--with-long-double-format=ieee".
> That looks like something that would need to be enabled, not disabled.

Look in the GCC toplevel configure.ac for (some of!) the actual rules
(and some more in config.gcc, and there are more at different levels).

If your target is not *-linux* you likely end up with a 64-bit long
double by default, and if it is, you do.  But it depends on various
things configure can determine about your C library.  buildall uses
--without-headers, but something makes GCC still use 128-bit long
double on powerpc64-linux, but it uses 64-bit on powerpc64le-linux.
Curious.  I suppose things work better on Linux userland when you do
not use the spartan build flags buildall uses :-)

If you set it explicitly (--with-long-double-128) it just works.

> FWIW, depending on compiler build options such as the above for kernel
> builds seems to be a little odd to me,

Yes.  It should be (and was!) possible to build the kernel with pretty
much any compiler.  Usual were *-linux* compilers of course, but *-elf
also works, and for powerpc in particular any kind of biarch or not
"just works".

> and I am not sure I'd want to
> blame gcc if the kernel wants to be built with 128-bit floating point
> as default. At the very least, that should be documented somewhere,
> and if possible the kernel should refuse to build if the compiler build
> options don't meet the requirements.

It always was the rule that the kernel did not use floating point at
all.  If that is changed it can no longer be built on targets that use
soft float for example (they need libgcc, which the kernel build is
allergic to for some reason).  It is non-trivial to handle floating
point in the kernel itself as well of course (mostly arch stuff).

The problem here was that some objects are built with soft float and
some with hard float, incompatible ABIs that ld does not want to link
together (without further coercing).


Segher


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Michael Ellerman
Guenter Roeck  writes:
> On 7/25/22 13:42, Segher Boessenkool wrote:
>> On Mon, Jul 25, 2022 at 02:34:08PM -0500, Timothy Pearson wrote:
> Further digging shows that the build failures only occur with compilers
> that default to 64-bit long double.

 Where the heck do we have 'long double' things anywhere in the kernel?

 I tried to grep for it, and failed miserably. I found some constants
 that would qualify, but they were in the v4l colorspaces-details.rst
 doc file.

 Strange.
>>>
>>> We don't, at least not that I can see.  The affected code uses standard 
>>> doubles.
>>>
>>> What I'm wondering is if the compiler is getting confused between standard 
>>> and long doubles when they are both the same bit length...
>> 
>> The compiler emits the same code (DFmode things, double precision float)
>> in both cases, and it itself does not see any difference anymore fairly
>> early in the pipeline.  Compare to int and long on most 32-bit targets,
>> both are SImode, the compiler will not see different types anymore:
>> there *are* no types, except in the compiler frontend.
>> 
>> It only happens for powerpc64le things, and not for powerpc64 builds.
>> 
>> It is probably a GCC problem.  I don't see what forces the GCC build
>> here to use 64-bit long double either btw?  Compilers build via buildall
>> have all kinds of unnecessary things disabled, but not that, not
>> directly at least.
>> 
>
>  From what little documentation I can find, there appears to be
> "--with-long-double-128" and "--with-long-double-format=ieee".
> That looks like something that would need to be enabled, not disabled.
>
> FWIW, depending on compiler build options such as the above for kernel
> builds seems to be a little odd to me, and I am not sure I'd want to
> blame gcc if the kernel wants to be built with 128-bit floating point
> as default.

The kernel doesn't care what the size is, but ld refuses to link objects
built with soft/hard float if the long double size is 64-bits.

> At the very least, that should be documented somewhere,
> and if possible the kernel should refuse to build if the compiler build
> options don't meet the requirements.

The ABI says long double is 128-bits. So it's documented there :)

The kernel expects that passing `-m64 -mlittle-endian -mabi=elfv2` will
produce code that conforms to the 64-bit Little Endian ELFv2 ABI :D

But it seems those flags are not sufficient.

There is an -mlong-double-128 flag, which appears to do the right thing
regardless of how the compiler was built. I will probably add that to
the kernel CFLAGS, but that's not a change I want to do just before the
v5.19 release.

cheers


Re: [PATCH] drm/amdgpu: Re-enable DCN for 64-bit powerpc

2022-07-25 Thread Michael Ellerman
Linus Torvalds  writes:
> On Mon, Jul 25, 2022 at 5:39 AM Michael Ellerman  wrote:
>>
>> Further digging shows that the build failures only occur with compilers
>> that default to 64-bit long double.
>
> Where the heck do we have 'long double' things anywhere in the kernel?

There's one or two uses, but not in any code that's relevant to this
issue AFAICS.

> I tried to grep for it, and failed miserably. I found some constants
> that would qualify, but they were in the v4l colorspaces-details.rst
> doc file.
>
> Strange.

It doesn't seem to matter if you use long double or not. It's just that
if the long double size is 64-bits the linker refuses to link a mixture
of soft/hard-float objects.

The 64-bit ABI says long double is 128-bits, so the compilers that are
using 64-bit long double are either not built correctly, or we are not
passing the correct flags to them.

There's an -mlong-double-128 flag which we can pass at build time which
seems to do the right thing, I will probably add that to the kernel
CFLAGS, but I want that to get a bit more testing.

cheers


[powerpc:merge] BUILD SUCCESS e1b85275d37739ed5d9be41eab1116b759f83391

2022-07-25 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
merge
branch HEAD: e1b85275d37739ed5d9be41eab1116b759f83391  Automatic merge of 
'korg/next' into merge (2022-07-25 22:54)

elapsed time: 722m

configs tested: 63
configs skipped: 2

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

gcc tested configs:
arm defconfig
arm  allyesconfig
arm64allyesconfig
arcvdk_hs38_defconfig
ia64zx1_defconfig
powerpc   currituck_defconfig
ia64 allmodconfig
arc   allnoconfig
alpha allnoconfig
riscv allnoconfig
csky  allnoconfig
arc  allyesconfig
alphaallyesconfig
m68k allmodconfig
m68k allyesconfig
powerpc   allnoconfig
sh   allmodconfig
mips allyesconfig
powerpc  allmodconfig
i386defconfig
i386 allyesconfig
i386  randconfig-a001
i386  randconfig-a003
i386  randconfig-a005
x86_64randconfig-a013
x86_64randconfig-a011
x86_64randconfig-a015
i386  randconfig-a014
i386  randconfig-a012
i386  randconfig-a016
arc  randconfig-r043-20220724
riscvrandconfig-r042-20220724
s390 randconfig-r044-20220724
x86_64randconfig-a002
x86_64randconfig-a004
x86_64randconfig-a006
um i386_defconfig
um   x86_64_defconfig
x86_64   rhel-8.3-kvm
x86_64  rhel-8.3-func
x86_64 rhel-8.3-kunit
x86_64rhel-8.3-kselftests
x86_64   rhel-8.3-syz
x86_64  defconfig
x86_64   allyesconfig
x86_64   rhel-8.3

clang tested configs:
arm  moxart_defconfig
powerpc  walnut_defconfig
powerpc mpc832x_rdb_defconfig
i386  randconfig-a002
i386  randconfig-a004
i386  randconfig-a006
x86_64randconfig-a012
x86_64randconfig-a014
x86_64randconfig-a016
i386  randconfig-a013
i386  randconfig-a011
i386  randconfig-a015
hexagon  randconfig-r041-20220724
hexagon  randconfig-r045-20220724
x86_64randconfig-a001
x86_64randconfig-a003
x86_64randconfig-a005

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


[powerpc:next] BUILD SUCCESS 95288b023d5fdd34f1e7f4a9e2826359f2d4659e

2022-07-25 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
next
branch HEAD: 95288b023d5fdd34f1e7f4a9e2826359f2d4659e  powerpc: dts: 
turris1x.dts: Add CPLD reboot node

elapsed time: 734m

configs tested: 57
configs skipped: 2

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

gcc tested configs:
arm defconfig
arm64allyesconfig
arm  allyesconfig
ia64 allmodconfig
arc   allnoconfig
alpha allnoconfig
riscv allnoconfig
csky  allnoconfig
alphaallyesconfig
m68k allmodconfig
arc  allyesconfig
m68k allyesconfig
sh   allmodconfig
powerpc   allnoconfig
mips allyesconfig
powerpc  allmodconfig
i386defconfig
i386 allyesconfig
x86_64randconfig-a004
i386  randconfig-a001
i386  randconfig-a003
i386  randconfig-a005
x86_64randconfig-a013
x86_64randconfig-a011
x86_64randconfig-a015
i386  randconfig-a012
i386  randconfig-a014
i386  randconfig-a016
x86_64randconfig-a006
x86_64randconfig-a002
s390 randconfig-r044-20220724
riscvrandconfig-r042-20220724
arc  randconfig-r043-20220724
um   x86_64_defconfig
um i386_defconfig
x86_64  defconfig
x86_64   rhel-8.3
x86_64   allyesconfig
x86_64   rhel-8.3-syz
x86_64   rhel-8.3-kvm
x86_64  rhel-8.3-func
x86_64rhel-8.3-kselftests
x86_64 rhel-8.3-kunit

clang tested configs:
x86_64randconfig-a003
x86_64randconfig-a005
i386  randconfig-a002
i386  randconfig-a006
i386  randconfig-a004
x86_64randconfig-a014
x86_64randconfig-a012
x86_64randconfig-a016
i386  randconfig-a013
i386  randconfig-a011
i386  randconfig-a015
x86_64randconfig-a001
hexagon  randconfig-r041-20220724
hexagon  randconfig-r045-20220724

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


[powerpc:topic/ppc-kvm] BUILD SUCCESS 4008d54e29531813e800580f8309133b9b14a921

2022-07-25 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
topic/ppc-kvm
branch HEAD: 4008d54e29531813e800580f8309133b9b14a921  powerpc/kvm: Remove 
comment related to moving PMU code to perf subsystem

elapsed time: 741m

configs tested: 91
configs skipped: 110

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

gcc tested configs:
arm64allyesconfig
arm defconfig
arm  allyesconfig
powerpc  randconfig-c003-20220724
i386  randconfig-c001
armclps711x_defconfig
powerpc mpc85xx_cds_defconfig
parisc64 alldefconfig
arm   imx_v6_v7_defconfig
arm   aspeed_g5_defconfig
sh  rts7751r2d1_defconfig
sh kfr2r09-romimage_defconfig
arm  lpd270_defconfig
powerpcamigaone_defconfig
armcerfcube_defconfig
arc  axs101_defconfig
armshmobile_defconfig
m68k   virt_defconfig
sh espt_defconfig
m68kdefconfig
mips   gcw0_defconfig
sh sh7710voipgw_defconfig
m68k  atari_defconfig
powerpc  tqm8xx_defconfig
powerpc tqm8555_defconfig
mips  fuloong2e_defconfig
armoxnas_v6_defconfig
microblaze  mmu_defconfig
xtensa  cadence_csp_defconfig
mips allmodconfig
armlart_defconfig
xtensageneric_kc705_defconfig
powerpc   ppc64_defconfig
powerpc mpc83xx_defconfig
riscvnommu_virt_defconfig
riscv  rv32_defconfig
riscvnommu_k210_defconfig
riscv allnoconfig
i386   debian-10.3-kselftests
i386  debian-10.3
loongarch   defconfig
loongarch allnoconfig
i386  debian-10.3-kvm
i386debian-10.3-kunit
i386 debian-10.3-func
x86_64randconfig-c001
arm  randconfig-c002-20220724
csky  allnoconfig
alpha allnoconfig
arc   allnoconfig
powerpc   allnoconfig
powerpc  allmodconfig
i386 allyesconfig
i386defconfig
x86_64randconfig-a006
x86_64randconfig-a004
x86_64randconfig-a002
i386  randconfig-a012
i386  randconfig-a014
i386  randconfig-a016
s390 randconfig-r044-20220724
riscvrandconfig-r042-20220724
arc  randconfig-r043-20220724
x86_64rhel-8.3-kselftests
x86_64   allyesconfig
x86_64  defconfig
x86_64   rhel-8.3
x86_64   rhel-8.3-kvm
x86_64  rhel-8.3-func
x86_64   rhel-8.3-syz
x86_64 rhel-8.3-kunit

clang tested configs:
mips   sb1250_swarm_defconfig
powerpc powernv_defconfig
powerpc  ppc44x_defconfig
powerpc mpc5200_defconfig
powerpc  walnut_defconfig
powerpc mpc832x_rdb_defconfig
arm  moxart_defconfig
arm hackkit_defconfig
mips tb0219_defconfig
armmvebu_v5_defconfig
x86_64randconfig-k001
x86_64randconfig-a005
x86_64randconfig-a003
x86_64randconfig-a001
i386  randconfig-a002
i386  randconfig-a006
i386  randconfig-a004
x86_64randconfig-a012
x86_64randconfig-a014
x86_64randconfig-a016

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


[PATCH linux-next v2] powerpc: init jump label early in ppc 64

2022-07-25 Thread zhouzhouyi
From: Zhouyi Zhou 

In ppc 64, invoke jump_label_init in setup_feature_keys is too late
because static key will be used in subroutine of parse_early_param
which is again subroutine of early_init_devtree.

So we invoke jump_label_init just before parse_early_param in
early_init_devtree. 

Suggested-by: Michael Ellerman 
Signed-off-by: Zhouyi Zhou 
---
Dear PPC developers

I found this bug when trying to do rcutorture tests in ppc VM of
Open Source Lab of Oregon State University.

qemu-system-ppc64 -nographic -smp cores=8,threads=1 -net none -M pseries 
-nodefaults -device spapr-vscsi -serial 
file:/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/console.log
 -m 512 -kernel 
/home/ubuntu/linux-next/tools/testing/selftests/rcutorture/res/2022.07.19-01.18.42-torture/results-rcutorture/TREE03/vmlinux
 -append "debug_boot_weak_hash panic=-1 console=ttyS0 
rcupdate.rcu_cpu_stall_suppress_at_boot=1 torture.disable_onoff_at_boot 
rcupdate.rcu_task_stall_timeout=3 rcutorture.onoff_interval=200 
rcutorture.onoff_holdoff=30 rcutree.gp_preinit_delay=12 rcutree.gp_init_delay=3 
rcutree.gp_cleanup_delay=3 rcutree.kthread_prio=2 threadirqs tree.use_softirq=0 
rcutorture.n_barrier_cbs=4 rcutorture.stat_interval=15 
rcutorture.shutdown_secs=420 rcutorture.test_no_idle_hz=1 rcutorture.verbose=1"

console.log report following WARN:
[0.00][T0] static_key_enable_cpuslocked(): static key 
'0xc2953260' used before call to jump_label_init()^M
[0.00][T0] WARNING: CPU: 0 PID: 0 at kernel/jump_label.c:166 
static_key_enable_cpuslocked+0xfc/0x120^M
[0.00][T0] Modules linked in:^M
[0.00][T0] CPU: 0 PID: 0 Comm: swapper Not tainted 
5.19.0-rc5-next-20220708-dirty #131^M
[0.00][T0] NIP:  c038068c LR: c0380688 CTR: 
c0186ac0^M
[0.00][T0] REGS: c2867930 TRAP: 0700   Not tainted  
(5.19.0-rc5-next-20220708-dirty)^M
[0.00][T0] MSR:  80022003   CR: 24282224  XER: 
2004^M
[0.00][T0] CFAR: 0730 IRQMASK: 1 ^M
[0.00][T0] GPR00: c0380688 c2867bd0 
c2868d00 0065 ^M
[0.00][T0] GPR04: 0001  
0080 000d ^M
[0.00][T0] GPR08:   
c27fd000 000f ^M
[0.00][T0] GPR12: c0186ac0 c2082280 
0003 000d ^M
[0.00][T0] GPR16: 02cc00d0  
c2082280 0001 ^M
[0.00][T0] GPR20: c2080942  
  ^M
[0.00][T0] GPR24:  c10d6168 
 c20034c8 ^M
[0.00][T0] GPR28: 0028  
c2080942 c2953260 ^M
[0.00][T0] NIP [c038068c] 
static_key_enable_cpuslocked+0xfc/0x120^M
[0.00][T0] LR [c0380688] 
static_key_enable_cpuslocked+0xf8/0x120^M
[0.00][T0] Call Trace:^M
[0.00][T0] [c2867bd0] [c0380688] 
static_key_enable_cpuslocked+0xf8/0x120 (unreliable)^M
[0.00][T0] [c2867c40] [c0380810] 
static_key_enable+0x30/0x50^M
[0.00][T0] [c2867c70] [c2030314] 
setup_forced_irqthreads+0x28/0x40^M
[0.00][T0] [c2867c90] [c2003568] 
do_early_param+0xa0/0x108^M
[0.00][T0] [c2867d10] [c0175340] 
parse_args+0x290/0x4e0^M
[0.00][T0] [c2867e10] [c2003c74] 
parse_early_options+0x48/0x5c^M
[0.00][T0] [c2867e30] [c2003ce0] 
parse_early_param+0x58/0x84^M
[0.00][T0] [c2867e60] [c2009878] 
early_init_devtree+0xd4/0x518^M
[0.00][T0] [c2867f10] [c200aee0] 
early_setup+0xb4/0x214^M

After this fix, the WARN does not show again.

Kind Regards
Zhouyi
--
 arch/powerpc/kernel/prom.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1066b072db35..bfe170ed6b12 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -751,7 +751,13 @@ void __init early_init_devtree(void *params)
early_init_dt_scan_root();
early_init_dt_scan_memory_ppc();
 
+   /*
+* As generic code authors expect to be able to use static keys
+* in early_param() handlers, we initialize the static keys just
+* before parsing early params (it's fine to call jump_label_init
+* more than once).
+*/
+   jump_label_init();
parse_early_param();
 
/* make sure we've parsed cmdline for mem= before this */
-- 
2.25.1



[PATCH v2] PCI/ERR: Use pcie_aer_is_native() to judge whether OS owns AER

2022-07-25 Thread Zhuo Chen
The AER status of the device that reported the error rather than
the first downstream port is cleared after commit 7d7cbeaba5b7
("PCI/ERR: Clear status of the reporting device"). So "a bridge
may not exist" which commit aa344bc8b727 ("PCI/ERR: Clear AER
status only when we control AER") referring to is no longer
existent, and we just use pcie_aer_is_native() in stead of
"host->native_aer || pcie_ports_native".

pci_aer_clear_nonfatal_status() already has pcie_aer_is_native(),
so we move pci_aer_clear_nonfatal_status() out of
pcie_aer_is_native().

Replace statements that judge whether OS owns AER in
get_port_device_capability() with pcie_aer_is_native(), which has
no functional changes.

Signed-off-by: Zhuo Chen 
---
v2:
- Add details and note in commit log
---
 drivers/pci/pcie/err.c  | 12 ++--
 drivers/pci/pcie/portdrv_core.c |  3 +--
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 0c5a143025af..28339c741555 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -184,7 +184,6 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
int type = pci_pcie_type(dev);
struct pci_dev *bridge;
pci_ers_result_t status = PCI_ERS_RESULT_CAN_RECOVER;
-   struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
 
/*
 * If the error was detected by a Root Port, Downstream Port, RCEC,
@@ -237,16 +236,9 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
pci_dbg(bridge, "broadcast resume message\n");
pci_walk_bridge(bridge, report_resume, &status);
 
-   /*
-* If we have native control of AER, clear error status in the device
-* that detected the error.  If the platform retained control of AER,
-* it is responsible for clearing this status.  In that case, the
-* signaling device may not even be visible to the OS.
-*/
-   if (host->native_aer || pcie_ports_native) {
+   if (pcie_aer_is_native(dev))
pcie_clear_device_status(dev);
-   pci_aer_clear_nonfatal_status(dev);
-   }
+   pci_aer_clear_nonfatal_status(dev);
pci_info(bridge, "device recovery successful\n");
return status;
 
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 604feeb84ee4..98c18f4a01b2 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -221,8 +221,7 @@ static int get_port_device_capability(struct pci_dev *dev)
}
 
 #ifdef CONFIG_PCIEAER
-   if (dev->aer_cap && pci_aer_available() &&
-   (pcie_ports_native || host->native_aer)) {
+   if (pcie_aer_is_native(dev) && pci_aer_available()) {
services |= PCIE_PORT_SERVICE_AER;
 
/*
-- 
2.30.1 (Apple Git-130)



linux-next: manual merge of the amdgpu tree with the powerpc-fixes tree

2022-07-25 Thread Stephen Rothwell
Hi all,

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

  drivers/gpu/drm/amd/display/Kconfig

between commits:

  c653c591789b ("drm/amdgpu: Re-enable DCN for 64-bit powerpc")

from the powerpc-fixes tree and commit:

  3876a8b5e241 ("drm/amd/display: Enable building new display engine with KCOV 
enabled")

from the amdgpu tree.

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

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/gpu/drm/amd/display/Kconfig
index ec6771e87e73,96cbc87f7b6b..
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@@ -6,7 -6,7 +6,7 @@@ config DRM_AMD_D
bool "AMD DC - Enable new display engine"
default y
select SND_HDA_COMPONENT if SND_HDA_CORE
-   select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128) && 
!(KCOV_INSTRUMENT_ALL && KCOV_ENABLE_COMPARISONS)
 -  select DRM_AMD_DC_DCN if (X86 || PPC64)
++  select DRM_AMD_DC_DCN if (X86 || PPC_LONG_DOUBLE_128)
help
  Choose this option if you want to use the new display engine
  support for AMDGPU. This adds required support for Vega and



pgpY7Kmqw2EOj.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Michael Ellerman
Yury Norov  writes:
> On Mon, Jul 25, 2022 at 10:22:13PM +1000, Michael Ellerman wrote:
>> Michael Ellerman  writes:
>> > Yury Norov  writes:
>> >> archrandom.h includes  to refer ppc_md. This causes
>> >> circular header dependency, if generic nodemask.h  includes random.h:
>> >>
>> >> In file included from include/linux/cred.h:16,
>> >>  from include/linux/seq_file.h:13,
>> >>  from arch/powerpc/include/asm/machdep.h:6,
>> >>  from arch/powerpc/include/asm/archrandom.h:5,
>> >>  from include/linux/random.h:109,
>> >>  from include/linux/nodemask.h:97,
>> >>  from include/linux/list_lru.h:12,
>> >>  from include/linux/fs.h:13,
>> >>  from include/linux/compat.h:17,
>> >>  from arch/powerpc/kernel/asm-offsets.c:12:
>> >> include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
>> >>  1203 | nodemask_t  mems_allowed;
>> >>   | ^~
>> >>
>> >> Fix it by removing  dependency from archrandom.h
>> >>
>> >> Signed-off-by: Yury Norov 
>> >> ---
>> >>  arch/powerpc/include/asm/archrandom.h |  9 +
>> >>  arch/powerpc/kernel/setup-common.c| 11 +++
>> >>  2 files changed, 12 insertions(+), 8 deletions(-)
>> >>
>> >> diff --git a/arch/powerpc/include/asm/archrandom.h 
>> >> b/arch/powerpc/include/asm/archrandom.h
>> >> index 9a53e29680f4..21def59ef1a6 100644
>> >> --- a/arch/powerpc/include/asm/archrandom.h
>> >> +++ b/arch/powerpc/include/asm/archrandom.h
>> >> @@ -4,7 +4,7 @@
>> >>  
>> >>  #ifdef CONFIG_ARCH_RANDOM
>> >>  
>> >> -#include 
>> >> +bool __must_check arch_get_random_seed_long(unsigned long *v);
>> >>  
>> >>  static inline bool __must_check arch_get_random_long(unsigned long *v)
>> >>  {
>> >> @@ -16,13 +16,6 @@ static inline bool __must_check 
>> >> arch_get_random_int(unsigned int *v)
>> >>   return false;
>> >>  }
>> >>  
>> >> -static inline bool __must_check arch_get_random_seed_long(unsigned long 
>> >> *v)
>> >> -{
>> >> - if (ppc_md.get_random_seed)
>> >> - return ppc_md.get_random_seed(v);
>> >> -
>> >> - return false;
>> >> -}
>> >
>> > I'd rather we didn't have to force this out of line.
>> >
>> > I think I see a different way to fix it, I'll just do some more build
>> > tests.
>> 
>> Of course my idea didn't work :}
>> 
>> So I'll just ack your patch for now, and maybe I can get the headers
>> cleaned up in future to allow it to be out-of-line again.
>
> I understand that it looks like a tradeoff - we inline a couple of small
> functions with the cost of uninlining an almost innocent victim. 

Yeah. The truth is the cost to access the RNG will far outweigh the cost
of that out-of-line call, so there's no real issue. But it's also such a
small function that it just cries out to be inlined :)

> The complete solution would be probably a splitting ppc_md declaration
> out of asm/machdep.h. I wanted to do that, but I'm not a PPC guy, and
> just don't know how to split the header correctly.

I managed to drop the includes of seq_file.h and dma-mapping.h, which
seemed to fix the circular include problem, but there's a bit of fall
out in unrelated files. I think I can get that sorted though eventually.

> Anyways, thanks for the ack. Applied on bitmap-for-next.

No worries.

cheers


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Andy Shevchenko
On Tue, Jul 26, 2022 at 1:35 AM Yury Norov  wrote:
> On Mon, Jul 25, 2022 at 11:39:39PM +0200, Andy Shevchenko wrote:
> > On Mon, Jul 25, 2022 at 6:19 PM Yury Norov  wrote:
> > > On Mon, Jul 25, 2022 at 09:28:12AM +0200, Andy Shevchenko wrote:
> > > > On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  
> > > > wrote:

...

> > > > >  EXPORT_SYMBOL_GPL(pm_power_off);
> > > >
> > > > ^^^ (Note this and read below)
> > > >
> > > > ...
> > > >
> > > > > +EXPORT_SYMBOL(arch_get_random_seed_long);
> > > >
> > > > It can't be like this. Brief browsing of the callees shows that.
> > >
> > > Is my understanding correct that you're suggesting to make it GPL?
> > >
> > > ppc_md is exported with EXPORT_SYMBOL(), and the function is in header,
> > > so it's available for non-GPL code now. I don't want to change it.
> >
> > The symbols your function calls are GPL. As far as I understand (not a
> > lawyer!) it logically one may not call GPL and pretend to be non-GPL.
>
> Can you explain what you mean in details?
>
> The function is:
> static inline bool __must_check arch_get_random_seed_long(unsigned 
> long *v)
> {
>if (ppc_md.get_random_seed)
>return ppc_md.get_random_seed(v);
>
>return false;
> }
>
> ppc_md is non-GPL:
>  77 /* The main machine-dep calls structure
>  78  */
>  79 struct machdep_calls ppc_md;
>  80 EXPORT_SYMBOL(ppc_md);

What a mess...

> And get_random_seed is initialized in in arch/powerpc/platforms/powernv/rng.c
> with different functions that are static and not exported at all.
>
> I don't understand where arch_get_random_seed_long calls GPL...

The ->get_random_seed() (aka "callees" in my previous mail) are all
GPL (maybe I missed one out of five which is non-GPL, but then it's
even more of a mess).

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Andy Shevchenko
On Tue, Jul 26, 2022 at 8:13 AM Andy Shevchenko
 wrote:
>
> On Tue, Jul 26, 2022 at 1:35 AM Yury Norov  wrote:
> > On Mon, Jul 25, 2022 at 11:39:39PM +0200, Andy Shevchenko wrote:
> > > On Mon, Jul 25, 2022 at 6:19 PM Yury Norov  wrote:
> > > > On Mon, Jul 25, 2022 at 09:28:12AM +0200, Andy Shevchenko wrote:
> > > > > On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  
> > > > > wrote:
>
> ...
>
> > > > > >  EXPORT_SYMBOL_GPL(pm_power_off);
> > > > >
> > > > > ^^^ (Note this and read below)
> > > > >
> > > > > ...
> > > > >
> > > > > > +EXPORT_SYMBOL(arch_get_random_seed_long);
> > > > >
> > > > > It can't be like this. Brief browsing of the callees shows that.
> > > >
> > > > Is my understanding correct that you're suggesting to make it GPL?
> > > >
> > > > ppc_md is exported with EXPORT_SYMBOL(), and the function is in header,
> > > > so it's available for non-GPL code now. I don't want to change it.
> > >
> > > The symbols your function calls are GPL. As far as I understand (not a
> > > lawyer!) it logically one may not call GPL and pretend to be non-GPL.
> >
> > Can you explain what you mean in details?
> >
> > The function is:
> > static inline bool __must_check arch_get_random_seed_long(unsigned 
> > long *v)
> > {
> >if (ppc_md.get_random_seed)
> >return ppc_md.get_random_seed(v);
> >
> >return false;
> > }
> >
> > ppc_md is non-GPL:
> >  77 /* The main machine-dep calls structure
> >  78  */
> >  79 struct machdep_calls ppc_md;
> >  80 EXPORT_SYMBOL(ppc_md);
>
> What a mess...
>
> > And get_random_seed is initialized in in 
> > arch/powerpc/platforms/powernv/rng.c
> > with different functions that are static and not exported at all.

To be clear, their license is defined in the file: "GPL-2.0-or-later".
But again, not a lawyer, just using my common sense.

> > I don't understand where arch_get_random_seed_long calls GPL...
>
> The ->get_random_seed() (aka "callees" in my previous mail) are all
> GPL (maybe I missed one out of five which is non-GPL, but then it's
> even more of a mess).


-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 1/2] powerpc: drop dependency on in archrandom.h

2022-07-25 Thread Michael Ellerman
Yury Norov  writes:
> On Mon, Jul 25, 2022 at 09:28:12AM +0200, Andy Shevchenko wrote:
>> On Sun, Jul 24, 2022 at 12:19 AM Yury Norov  wrote:
>> >
>> > archrandom.h includes  to refer ppc_md. This causes
>> > circular header dependency, if generic nodemask.h  includes random.h:
>> >
>> > In file included from include/linux/cred.h:16,
>> >  from include/linux/seq_file.h:13,
>> >  from arch/powerpc/include/asm/machdep.h:6,
>> >  from arch/powerpc/include/asm/archrandom.h:5,
>> >  from include/linux/random.h:109,
>> >  from include/linux/nodemask.h:97,
>> >  from include/linux/list_lru.h:12,
>> >  from include/linux/fs.h:13,
>> >  from include/linux/compat.h:17,
>> >  from arch/powerpc/kernel/asm-offsets.c:12:
>> > include/linux/sched.h:1203:9: error: unknown type name 'nodemask_t'
>> >  1203 | nodemask_t  mems_allowed;
>> >   | ^~
>> >
>> > Fix it by removing  dependency from archrandom.h
>> 
>> ...
>> 
>> >  EXPORT_SYMBOL_GPL(pm_power_off);
>> 
>> ^^^ (Note this and read below)
>> 
>> ...
>> 
>> > +EXPORT_SYMBOL(arch_get_random_seed_long);
>> 
>> It can't be like this. Brief browsing of the callees shows that.
>
> Is my understanding correct that you're suggesting to make it GPL?
>
> ppc_md is exported with EXPORT_SYMBOL(), and the function is in header,
> so it's available for non-GPL code now. I don't want to change it.

That's true, your change maintains the status quo.

But I think we actually don't need it exported to modules, I think it's
a private detail of the RNG <-> architecture interface, not something
that modules should be calling.

So I think it's OK to drop the EXPORT_SYMBOL, either in this patch or a
subsequent one if you don't want to rebase.

cheers