Re: [PATCH] powerpc/64e: Tie PPC_BOOK3E_64 to PPC_FSL_BOOK3E

2022-03-07 Thread Arnd Bergmann
On Fri, Mar 4, 2022 at 7:12 AM Michael Ellerman  wrote:
>
> Since the IBM A2 CPU support was removed, see commit
> fb5a515704d7 ("powerpc: Remove platforms/wsp and associated pieces"),
> the only 64-bit Book3E CPUs we support are Freescale (NXP) ones.
>
> However our Kconfig still allows configurating a kernel that has 64-bit
> Book3E support, but no Freescale CPU support enabled. Such a kernel
> would never boot, it doesn't know about any CPUs.
>
> It also causes build errors, as reported by lkp, because
> PPC_BARRIER_NOSPEC is not enabled in such a configuration:
>
>   powerpc64-linux-ld: arch/powerpc/net/bpf_jit_comp64.o:(.toc+0x0):
>   undefined reference to `powerpc_security_features'
>
> To fix this, force PPC_FSL_BOOK3E to be selected whenever we are
> building a 64-bit Book3E kernel.
>
> Reported-by: kernel test robot 
> Reported-by: Naveen N. Rao 
> Suggested-by: Christophe Leroy 
> Signed-off-by: Michael Ellerman 
> ---
>  arch/powerpc/platforms/Kconfig.cputype | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/Kconfig.cputype 
> b/arch/powerpc/platforms/Kconfig.cputype
> index 87bc1929ee5a..e2e1fec91c6e 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -107,6 +107,7 @@ config PPC_BOOK3S_64
>
>  config PPC_BOOK3E_64
> bool "Embedded processors"
> +   select PPC_FSL_BOOK3E
> select PPC_FPU # Make it a choice ?
> select PPC_SMP_MUXED_IPI
> select PPC_DOORBELL
> @@ -295,7 +296,7 @@ config FSL_BOOKE
>  config PPC_FSL_BOOK3E
> bool
> select ARCH_SUPPORTS_HUGETLBFS if PHYS_64BIT || PPC64
> -   select FSL_EMB_PERFMON
> +   imply FSL_EMB_PERFMON
> select PPC_SMP_MUXED_IPI
> select PPC_DOORBELL
> select PPC_KUEP

'Imply' is almost never what you want here, this only has an effect
on the default used in 'defconfig' builds. I think this should be
expressed using a 'default PPC_FSL_BOOK3E' in the
FSL_EMB_PERFMON option if you actually want it to be optional,
better otherwise leave it as 'select'.

Arnd


Re: [RFC PATCH 6/7] serial: General support for multipoint addresses

2022-03-07 Thread Ilpo Järvinen
On Sun, 6 Mar 2022, Lukas Wunner wrote:

> On Wed, Mar 02, 2022 at 11:56:05AM +0200, Ilpo Järvinen wrote:
> 
> > This change is necessary for supporting devices with RS485
> > multipoint addressing [*].
> 
> If this is only used with RS485, why can't we just store the
> addresses in struct serial_rs485 and use the existing TIOCSRS485
> and TIOCGRS485 ioctls?  There's 20 bytes of padding left in
> struct serial_rs485 which you could use.  No need to add more
> user-space ABI.

It could if it is agreed that serial multipoint addressing is just
a thing in RS-485 and nowhere else? In that case, there is no point
in adding more generic support for it.

> > [*] Technically, RS485 is just an electronic spec and does not
> > itself specify the 9th bit addressing mode but 9th bit seems
> > at least "semi-standard" way to do addressing with RS485.
> 
> Is 9th bit addressing actually used by an Intel customer or was
> it implemented just for feature completeness? I think this mode
> isn't used often (I've never seen a use case myself), primarily
> because it requires disabling parity.

On what basis? ...The datasheet I'm looking at has a timing diagram 
with both D8 (9th bit) and parity so I think your information must be
incorrect. I don't have direct contacts with customers but I'm told
it's important for other org's customers.


-- 
 i.

Re: Build regressions/improvements in v5.17-rc7

2022-03-07 Thread Geert Uytterhoeven
On Mon, Mar 7, 2022 at 10:21 AM Geert Uytterhoeven  wrote:
> JFYI, when comparing v5.17-rc7[1] to v5.17-rc6[3], the summaries are:
>   - build errors: +4/-1

  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit
declaration of function 'nmi_cpu_backtrace'
[-Werror=implicit-function-declaration]: 171:2 => 171:9, 171:2
  + /kisskb/src/arch/powerpc/kernel/stacktrace.c: error: implicit
declaration of function 'nmi_trigger_cpumask_backtrace'; did you mean
'arch_trigger_cpumask_backtrace'?
[-Werror=implicit-function-declaration]:  => 226:9

powerpc-gcc11/skiroot_defconfig (this is a new config)
Seen before with powerpc-gcc5/skiroot_defconfig.

  + /kisskb/src/crypto/blake2b_generic.c: error: the frame size of
2288 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]:  =>
109:1

sparc64-gcc11/sparc-allmodconfig

  + error: arch/powerpc/kvm/book3s_64_entry.o: relocation truncated to
fit: R_PPC64_REL14 (stub) against symbol `machine_check_common'
defined in .text section in arch/powerpc/kernel/head_64.o:  =>
(.text+0x3e4)

powerpc-gcc5/powerpc-allyesconfig

> [1] 
> http://kisskb.ellerman.id.au/kisskb/branch/linus/head/ffb217a13a2eaf6d5bd974fc83036a53ca69f1e2/
>  (all 100 configs)
> [3] 
> http://kisskb.ellerman.id.au/kisskb/branch/linus/head/7e57714cd0ad2d5bb90e50b5096a0e671dec1ef3/
>  (99 out of 100 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 -next] powerpc/spufs: Fix build warning when CONFIG_PROC_FS=n

2022-03-07 Thread Arnd Bergmann
On Sun, Mar 6, 2022 at 9:04 PM Christophe Leroy
 wrote:
> Le 05/03/2022 à 13:31, YueHaibing a écrit :
> > arch/powerpc/platforms/cell/spufs/sched.c:1055:12: warning: 
> > ‘show_spu_loadavg’ defined but not used [-Wunused-function]
> >   static int show_spu_loadavg(struct seq_file *s, void *private)
> >  ^~~~
> >
> > Mark this as __maybe_unused to fix this.
>
> Marking it as __maybe_unused doesn't fix it. It just pushes the dust
> under the carpet.
>
> proc_create_single macro should be fix to avoid that warning.

We discussed that when proc_create_single() was introduced, but ended up
not doing it that way because there were already a lot of files using an #ifdef
around the function definitions. To change it back, one would have to audit
every user of proc_create_single() and remove the #ifdefs.

Arnd


Re: [PATCH -next] powerpc/spufs: Fix build warning when CONFIG_PROC_FS=n

2022-03-07 Thread Christophe Leroy


Le 07/03/2022 à 14:10, Arnd Bergmann a écrit :
> On Sun, Mar 6, 2022 at 9:04 PM Christophe Leroy
>  wrote:
>> Le 05/03/2022 à 13:31, YueHaibing a écrit :
>>> arch/powerpc/platforms/cell/spufs/sched.c:1055:12: warning: 
>>> ‘show_spu_loadavg’ defined but not used [-Wunused-function]
>>>static int show_spu_loadavg(struct seq_file *s, void *private)
>>>   ^~~~
>>>
>>> Mark this as __maybe_unused to fix this.
>>
>> Marking it as __maybe_unused doesn't fix it. It just pushes the dust
>> under the carpet.
>>
>> proc_create_single macro should be fix to avoid that warning.
> 
> We discussed that when proc_create_single() was introduced, but ended up
> not doing it that way because there were already a lot of files using an 
> #ifdef
> around the function definitions. To change it back, one would have to audit
> every user of proc_create_single() and remove the #ifdefs.
> 

Fair enough.

In that case, I'd prefer to go for a #ifdef as well for 
show_spu_loadavg() instead of going for a __maybe_unused flag.

Christophe

[PATCH] powerpc/64/interrupt: Fix return to masked context after hard-mask irq becomes pending

2022-03-07 Thread Nicholas Piggin
When a synchronous interrupt[1] is taken in a local_irq_disable() region
which has MSR[EE]=1, the interrupt handler will enable MSR[EE] as part
of enabling MSR[RI], for peformance and profiling reasons.

[1] Typically a hash fault, but in error cases this could be a page
fault or facility unavailable as well.

If an asynchronous interrupt hits here and its masked handler requires
MSR[EE] to be cleared (it is a PACA_IRQ_MUST_HARD_MASK interrupt), then
MSR[EE] must remain disabled until that pending interrupt is replayed.
The problem is that the MSR of the original context has MSR[EE]=1, so
returning directly to that causes MSR[EE] to be enabled while the
interrupt is still pending.

This issue was hacked around in the interrupt return code by just
clearing the hard mask to avoid a warning, and taking the masked
interrupt again immediately in the return context, which would disable
MSR[EE]. However in the case of a pending PMI, it is possible that it is
not maked in the calling context so the full handler will be run while
there is a PMI pending, and this confuses the perf code and causes
warnings with its PMI pending management.

Fix this by removing the hack, and adjusting the return MSR if it has
MSR[EE]=1 and there is a PACA_IRQ_MUST_HARD_MASK interrupt pending.

Fixes: 4423eb5ae32e ("powerpc/64/interrupt: make normal synchronous interrupts 
enable MSR[EE] if possible")
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/kernel/interrupt.c| 10 -
 arch/powerpc/kernel/interrupt_64.S | 34 +++---
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index 7cd6ce3ec423..819d42c0ce9f 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -593,16 +593,6 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct 
pt_regs *regs)
 
if (unlikely(stack_store))
__hard_EE_RI_disable();
-   /*
-* Returning to a kernel context with local irqs disabled.
-* Here, if EE was enabled in the interrupted context, enable
-* it on return as well. A problem exists here where a soft
-* masked interrupt may have cleared MSR[EE] and set HARD_DIS
-* here, and it will still exist on return to the caller. This
-* will be resolved by the masked interrupt firing again.
-*/
-   if (regs->msr & MSR_EE)
-   local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
 #endif /* CONFIG_PPC64 */
}
 
diff --git a/arch/powerpc/kernel/interrupt_64.S 
b/arch/powerpc/kernel/interrupt_64.S
index 7bab2d7de372..2641bbcb6e49 100644
--- a/arch/powerpc/kernel/interrupt_64.S
+++ b/arch/powerpc/kernel/interrupt_64.S
@@ -569,15 +569,43 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return_\srr\()_kernel)
ld  r11,SOFTE(r1)
cmpwi   r11,IRQS_ENABLED
stb r11,PACAIRQSOFTMASK(r13)
-   bne 1f
+   beq .Linterrupt_return_\srr\()_soft_enabled
+
+   /*
+* Returning to soft-disabled context.
+* Check if a MUST_HARD_MASK interrupt has become pending, in which
+* case we need to disable MSR[EE] in the return context.
+*/
+   ld  r12,_MSR(r1)
+   andi.   r10,r12,MSR_EE
+   beq .Lfast_kernel_interrupt_return_\srr\() // EE already disabled
+   lbz r11,PACAIRQHAPPENED(r13)
+   andi.   r10,r11,PACA_IRQ_MUST_HARD_MASK
+   beq 1f // No HARD_MASK pending
+
+   /* Must clear MSR_EE from _MSR */
+#ifdef CONFIG_PPC_BOOK3S
+   li  r10,0
+   /* Clear valid before changing _MSR */
+   .ifc \srr,srr
+   stb r10,PACASRR_VALID(r13)
+   .else
+   stb r10,PACAHSRR_VALID(r13)
+   .endif
+#endif
+   xorir12,r12,MSR_EE
+   std r12,_MSR(r1)
+   b   .Lfast_kernel_interrupt_return_\srr\()
+
+.Linterrupt_return_\srr\()_soft_enabled:
 #ifdef CONFIG_PPC_BOOK3S
lbz r11,PACAIRQHAPPENED(r13)
andi.   r11,r11,(~PACA_IRQ_HARD_DIS)@l
bne-interrupt_return_\srr\()_kernel_restart
 #endif
-   li  r11,0
-   stb r11,PACAIRQHAPPENED(r13) # clear out possible HARD_DIS
 1:
+   li  r11,0
+   stb r11,PACAIRQHAPPENED(r13) // clear the possible HARD_DIS
 
 .Lfast_kernel_interrupt_return_\srr\():
cmpdi   cr1,r3,0
-- 
2.23.0



[5.17.0-rc6][DLPAR][SRIOV/mlx5]EEH errors and WARNING: CPU: 7 PID: 30505 at include/rdma/ib_verbs.h:3688 mlx5_ib_dev_res_cleanup

2022-03-07 Thread Abdul Haleem

Greeting's

HMC DLPAR hotplug of SRIOV logical device backed with Everglade melanox adapter 
results in EEH error messages followed by WARNINGS on my PowerPC P10 LPAR 
running latest 5.17-rc6 kernel


from hmc dlpar remove and than add the SRIOV device
$ chhwres -r sriov -m ltcden11 --rsubtype logport -o r --id 9 -a  
adapter_id=1,logical_port_id=2700400f
$ chhwres -r sriov -m ltcden11 --rsubtype logport -o a --id 9 -a
phys_port_id=0,adapter_id=1,logical_port_id=2700400f,logical_port_type=eth

the above command completed but the console is filled with EEH errors and 
warnings

console messages
PC: Registered rdma backchannel transport module.
mlx5_core 400f:01:00.0 eth1: Link up
IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
mlx5_core 8005:01:00.0 eth2: Link up
IPv6: ADDRCONF(NETDEV_CHANGE): eth2: link becomes ready
rpaphp: RPA HOT Plug PCI Controller Driver version: 0.1
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
mlx5_core 400f:01:00.0: poll_health:800:(pid 0): Fatal error 1 detected
EEH: Recovering PHB#400f-PE#1
EEH: PE location: N/A, PHB location: N/A
mlx5_core 400f:01:00.0: print_health_info:424:(pid 0): PCI slot is unavailable
mlx5_core 400f:01:00.0: mlx5_trigger_health_work:756:(pid 0): new health works 
are not permitted at this stage
EEH: Frozen PHB#400f-PE#1 detected
EEH: Call Trace:
EEH: [c0054d10] __eeh_send_failure_event+0x70/0x150
EEH: [c004df98] eeh_dev_check_failure+0x2e8/0x6c0
EEH: [c004e438] eeh_check_failure+0xc8/0x100
EEH: [c06a04b4] ioread32be+0x114/0x180
EEH: [c00800d42bc0] mlx5_health_check_fatal_sensors+0x28/0x180 [mlx5_core]
EEH: [c00800d43448] poll_health+0x50/0x260 [mlx5_core]
EEH: [c021fed0] call_timer_fn+0x50/0x200
EEH: [c0220e90] run_timer_softirq+0x340/0x7c0
EEH: [c0c9e85c] __do_softirq+0x15c/0x3d0
EEH: [c014f068] irq_exit+0x168/0x1b0
EEH: [c0026f84] timer_interrupt+0x1a4/0x3e0
EEH: [c0009a08] decrementer_common_virt+0x208/0x210
EEH: [c367bdc0] 0xc367bdc0
EEH: [c09bf764] dedicated_cede_loop+0x94/0x1a0
EEH: [c09bc094] cpuidle_enter_state+0x2d4/0x4e0
EEH: [c09bc338] cpuidle_enter+0x48/0x70
EEH: [c019ded4] call_cpuidle+0x44/0x80
EEH: [c019e4b0] do_idle+0x340/0x390
EEH: [c019e730] cpu_startup_entry+0x30/0x40
EEH: [c00605a0] start_secondary+0x290/0x2b0
EEH: [c000d154] start_secondary_prolog+0x10/0x14
EEH: This PCI device has failed 1 times in the last hour and will be 
permanently disabled after 5 failures.
EEH: Notify device drivers to shutdown
EEH: Beginning: 'error_detected(IO frozen)'
mlx5_core 400f:01:00.0: wait_func_handle_exec_timeout:1108:(pid 30505): cmd[0]: 
DESTROY_RMP(0x90e) No done completion
mlx5_core 400f:01:00.0: wait_func:1136:(pid 30505): DESTROY_RMP(0x90e) timeout. 
Will cause a leak of a command resource
[ cut here ]
Destroy of kernel SRQ shouldn't fail
WARNING: CPU: 7 PID: 30505 at include/rdma/ib_verbs.h:3688 
mlx5_ib_dev_res_cleanup+0x104/0x1a0 [mlx5_ib]
Modules linked in: sit tunnel4 ip_tunnel rpadlpar_io rpaphp tcp_diag udp_diag 
inet_diag unix_diag af_packet_diag netlink_diag bonding rfkill rpcrdma sunrpc 
rdma_ucm ib_srpt ib_isert iscsi_target_mod target_core_mod ib_iser ib_umad 
rdma_cm ib_ipoib iw_cm ib_cm libiscsi scsi_transport_iscsi mlx5_ib ib_uverbs 
ib_core xts pseries_rng vmx_crypto gf128mul sch_fq_codel binfmt_misc ip_tables 
ext4 mbcache jbd2 dm_service_time mlx5_core sd_mod t10_pi sg ibmvfc 
scsi_transport_fc ibmveth mlxfw ptp pps_core dm_multipath dm_mirror 
dm_region_hash dm_log dm_mod fuse
CPU: 7 PID: 30505 Comm: drmgr Not tainted 5.17.0-rc6-autotest-g669b258a793d #1
NIP:  c008023cf20c LR: c008023cf208 CTR: c0702790
REGS: c000111b7420 TRAP: 0700   Not tainted  
(5.17.0-rc6-autotest-g669b258a793d)
MSR:  8282b033   CR: 48088224  XER: 
0005
CFAR: c0143c90 IRQMASK: 0
GPR00: c008023cf208 c000111b76c0 c00802438000 0024
GPR04: 7fff c000111b7390 c000111b7388 0027
GPR08: c018fd067e00 0001 0027 c27a68f0
GPR12: 8000 c018ff984e80  000119d902a0
GPR16: 7fffd673e838 000119d90ed0 000119da3070 000106ad1e38
GPR20: 000106acf330 000106acf3d8 000106acd838 000119da3208
GPR24: 0007  c00800e78320 c2818eb8
GPR28: cfd210d0 c008024328a8 c00017808000 c00017808000
NIP [c008023cf20c] mlx5_ib_dev_res_cleanup+0x104/0x1a0 [mlx5_ib]
LR [c008023cf208] mlx5_ib_dev_res_cleanup+0x100/0x1a0 [mlx5_ib]
Call Trace:
[c000111b76c0] [c008023cf208] mlx5_ib_dev_res_cleanup+0x100/0x1a0 
[mlx5_ib] (unreliable)
[c000111b7730] [c008023d4c00] __mlx5_ib_remove+0x78/0xc0 [mlx5_ib]
[c000111b7770] [c082479c] auxiliary_bus_remove+0x3c/0x70
[c000111b77a0] [c0814278] device_r

Re: [PATCH 0/6] Remove usage of list iterator past the loop body

2022-03-07 Thread Dan Carpenter
Updating this API is risky because some places rely on the old behavior
and not all of them have been updated.  Here are some additional places
you might want to change.

drivers/usb/host/uhci-q.c:466 link_async() warn: iterator used outside loop: 
'pqh'
drivers/infiniband/core/mad.c:968 ib_get_rmpp_segment() warn: iterator used 
outside loop: 'mad_send_wr->cur_seg'
drivers/opp/debugfs.c:208 opp_migrate_dentry() warn: iterator used outside 
loop: 'new_dev'
drivers/staging/greybus/audio_codec.c:602 gbcodec_mute_stream() warn: iterator 
used outside loop: 'module'
drivers/staging/media/atomisp/pci/atomisp_acc.c:508 
atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'
drivers/perf/thunderx2_pmu.c:814 tx2_uncore_pmu_init_dev() warn: iterator used 
outside loop: 'rentry'
drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c:111 
nvkm_control_mthd_pstate_attr() warn: iterator used outside loop: 'pstate'
drivers/gpu/drm/panfrost/panfrost_mmu.c:203 panfrost_mmu_as_get() warn: 
iterator used outside loop: 'lru_mmu'
drivers/media/usb/uvc/uvc_v4l2.c:885 uvc_ioctl_enum_input() warn: iterator used 
outside loop: 'iterm'
drivers/media/usb/uvc/uvc_v4l2.c:896 uvc_ioctl_enum_input() warn: iterator used 
outside loop: 'iterm'
drivers/scsi/dc395x.c:3596 device_alloc() warn: iterator used outside loop: 'p'
drivers/net/ethernet/mellanox/mlx4/alloc.c:379 __mlx4_alloc_from_zone() warn: 
iterator used outside loop: 'curr_node'
fs/ocfs2/dlm/dlmdebug.c:573 lockres_seq_start() warn: iterator used outside 
loop: 'res'

This patchset fixes 3 bugs.  Initially when it's merged it's probably
going to introduce some bugs because there are likely other places which
rely on the old behavior.

In an ideal world, with the new API the compiler would warn about
uninitialized variables, but unfortunately that warning is disabled by
default so we still have to rely on kbuild/Clang/Smatch to find the
bugs.

But hopefully the new API encourages people to write clearer code so it
prevents bugs in the long run.

regards,
dan carpenter



Re: [RFC PATCH] KVM: PPC: Book3s HV: Allow setting GTSE for the nested guest

2022-03-07 Thread Fabiano Rosas
"Aneesh Kumar K.V"  writes:

> Fabiano Rosas  writes:
>
>> We're currently getting a Program Interrupt inside the nested guest
>> kernel when running with GTSE disabled in the nested hypervisor. We
>> allow any guest a cmdline override of GTSE for migration purposes. The
>> nested guest does not know it needs to use the option and tries to run
>> 'tlbie' with LPCR_GTSE=0.
>>
>> The details are a bit more intricate:
>>
>> QEMU always sets GTSE=1 in OV5 even before calling KVM. At prom_init,
>> guests use the OV5 value to set MMU_FTR_GTSE. This setting can be
>> overridden by 'radix_hcall_invalidate=on' in the kernel cmdline. The
>> option itself depends on the availability of
>> FW_FEATURE_RPT_INVALIDATE, which it tied to QEMU's cap-rpt-invalidate
>> capability.
>>
>> The MMU_FTR_GTSE flag leads guests to set PROC_TABLE_GTSE in their
>> process tables and after H_REGISTER_PROC_TBL, both QEMU and KVM will
>> set LPCR_GTSE=1 for that guest. Unless the guest uses the cmdline
>> override, in which case:
>>
>>   MMU_FTR_GTSE=0 -> PROC_TABLE_GTSE=0 -> LPCR_GTSE=0
>>
>> We don't allow the nested hypervisor to set some LPCR bits for its
>> nested guests, so if the nested HV has LPCR_GTSE=0, its nested guests
>> will also have LPCR_GTSE=0. But since the only thing that can really
>> flip GTSE is the cmdline override, if a nested guest runs without it,
>> then the sequence goes:
>>
>>   MMU_FTR_GTSE=1 -> PROC_TABLE_GTSE=1 -> LPCR_GTSE=0.
>>
>> With LPCR_GTSE=0 the HW will treat 'tlbie' as HV privileged.
>>
>> This patch allows a nested HV to set LPCR_GTSE for its nested guests
>> so the LPCR setting will match what the nested guest sees in OV5.
>
> This needs a Fixes: tag?

This feature was done in many pieces, I think it will end up being the
commit that enabled the H_RPT_INVALIDATE capability:

Fixes: b87cc116c7e1 ("KVM: PPC: Book3S HV: Add KVM_CAP_PPC_RPT_INVALIDATE 
capability")

> I am not sure what is broken. If L1 doesn't support GTSE, then it should
> publish the same to L2 and L2 should not use tlbie.

L1 cannot set L2's LPCR to the correct value because L0 will not allow
it. That is what this patch is changing.

I looked into having QEMU set the proper values to use with CAS, but
that is done in QEMU too early, before the first dispatch of L2 (which
is when L0 decides that L1 is not allowed to modify some bits). So QEMU
always advertises GTSE=1.

> That was working before? Or is it that the kernel command to disable
> gtse when used with L2 kernel is broken?

The command line works, but it needs to be explicitly given when
starting the L2. There is no link between L1 and L2 when it comes to
GTSE aside from the LPCR value L1 chose to use. So L2 can start with no
command line at all, while L1 had GTSE disabled.

AFAICT, this has always been broken. The stack leading to this is:

NIP [c008615c] radix__flush_tlb_kernel_range+0x13c/0x420
[c0075840] change_page_attr+0xb0/0x240
[c044624c] __apply_to_page_range+0x5ac/0xb90
[c0075bbc] change_memory_attr+0x7c/0x150
[c0350390] bpf_prog_select_runtime+0x200/0x290
[c0d9400c] bpf_migrate_filter+0x18c/0x1e0
[c0d95f38] bpf_prog_create+0x178/0x1d0
[c130e4f4] ptp_classifier_init+0x4c/0x80
[c130d874] sock_init+0xe0/0x100
[c00121e0] do_one_initcall+0x60/0x2c0
[c12b48cc] kernel_init_freeable+0x33c/0x3dc
[c00127c8] kernel_init+0x44/0x18c
[c000ce64] ret_from_kernel_thread+0x5c/0x64

>>
>> Signed-off-by: Fabiano Rosas 
>> ---
>>  arch/powerpc/kvm/book3s_hv_nested.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c 
>> b/arch/powerpc/kvm/book3s_hv_nested.c
>> index 9d373f8963ee..5b9008d89f90 100644
>> --- a/arch/powerpc/kvm/book3s_hv_nested.c
>> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
>> @@ -262,7 +262,7 @@ static void load_l2_hv_regs(struct kvm_vcpu *vcpu,
>>   * Don't let L1 change LPCR bits for the L2 except these:
>>   */
>>  mask = LPCR_DPFD | LPCR_ILE | LPCR_TC | LPCR_AIL | LPCR_LD |
>> -LPCR_LPES | LPCR_MER;
>> +LPCR_LPES | LPCR_MER | LPCR_GTSE;
>>  
>>  /*
>>   * Additional filtering is required depending on hardware
>> -- 
>> 2.34.1


RE: [PATCH 0/6] Remove usage of list iterator past the loop body

2022-03-07 Thread David Laight
From: Dan Carpenter
> Sent: 07 March 2022 15:01
> 
> Updating this API is risky because some places rely on the old behavior
> and not all of them have been updated.  Here are some additional places
> you might want to change.

I really can't help thinking that trying to merge this patch is
actually impossible.
It affects far too many different parts of the tree.

Since (I believe) this is a doubly linked list with forwards and
backwards pointers that point to a 'node' (not that there is a
nice comment to that effect in the header - and there are lots of
ways to do linked lists) the 'head' pretty much has to be a 'node'.

I'd write the following new defines (but I might be using
the old names here):

list_first(head, field) First item, NULL if empty.
list_last(head, field) Last item NULL if empty.
list_next(head, item, field) Item after 'item', NULL if last.
list_prev(head, item. field) Item before 'item', NULL if first.

You get (something like):
#define list_first(head, field) \
head->next == &head ? NULL : list_item(head->next, field)
(probably needs typeof(item) from somewhere).

The iterator loop is then just:
#define loop_iterate(item, head, field) \
for (item = list_first(head, field); item; \
item = list_next(head, item, field)

I'm not sure, but making the 'head' be a structure that contains
a single member that is a 'node' might help type checking.

Then all the code that uses the current defines can slowly be
moved over (probably a couple of releases) before the existing
defines are deleted.

That should simplify all the open-coded search loops that are
just as likely to be buggy (possibly more so).

David

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



Re: [PATCH V7 00/20] riscv: compat: Add COMPAT mode support for rv64

2022-03-07 Thread Heiko Stübner
Hi,

Am Sonntag, 27. Februar 2022, 17:28:11 CET schrieb guo...@kernel.org:
> From: Guo Ren 
> 
> Currently, most 64-bit architectures (x86, parisc, powerpc, arm64,
> s390, mips, sparc) have supported COMPAT mode. But they all have
> history issues and can't use standard linux unistd.h. RISC-V would
> be first standard __SYSCALL_COMPAT user of include/uapi/asm-generic
> /unistd.h.
> 
> The patchset are based on v5.17-rc5, you can compare rv64-compat
> v.s. rv32-native in qemu with following steps:

I've followed your great test-instructions :-) .

Starting a riscv32 userspace with a riscv64-kernel _without_ that series
fails as expected. It wants to find the binfmt module to emulate the
unavailable architecture.

Same userspace and this series applied to the kernel tree makes that
riscv32 userspace boot nicely on the riscv64 kernel.

So the series:
Tested-by: Heiko Stuebner 



>  - Prepare rv32 rootfs & fw_jump.bin by buildroot.org
>$ git clone git://git.busybox.net/buildroot
>$ cd buildroot
>$ make qemu_riscv32_virt_defconfig O=qemu_riscv32_virt_defconfig
>$ make -C qemu_riscv32_virt_defconfig
>$ make qemu_riscv64_virt_defconfig O=qemu_riscv64_virt_defconfig
>$ make -C qemu_riscv64_virt_defconfig
>(Got fw_jump.bin & rootfs.ext2 in qemu_riscvXX_virt_defconfig/images)
> 
>  - Prepare Linux rv32 & rv64 Image
>$ git clone g...@github.com:c-sky/csky-linux.git -b riscv_compat_v6 linux
>$ cd linux
>$ echo "CONFIG_STRICT_KERNEL_RWX=n" >> arch/riscv/configs/defconfig
>$ echo "CONFIG_STRICT_MODULE_RWX=n" >> arch/riscv/configs/defconfig
>$ make ARCH=riscv CROSS_COMPILE=riscv32-buildroot-linux-gnu- 
> O=../build-rv32/ rv32_defconfig
>$ make ARCH=riscv CROSS_COMPILE=riscv32-buildroot-linux-gnu- 
> O=../build-rv32/ Image
>$ make ARCH=riscv CROSS_COMPILE=riscv64-buildroot-linux-gnu- 
> O=../build-rv64/ defconfig
>$ make ARCH=riscv CROSS_COMPILE=riscv64-buildroot-linux-gnu- 
> O=../build-rv64/ Image
> 
>  - Prepare Qemu: (rv32 compat was made by LIU Zhiwei )
>$ git clone g...@github.com:alistair23/qemu.git -b 
> riscv-to-apply.for-upstream linux
>$ cd qemu
>$ ./configure --target-list="riscv64-softmmu riscv32-softmmu"
>$ make
> 
> Now let's compare rv64-compat with rv32-native memory footprint with almost 
> the same
> defconfig, rootfs, opensbi in one qemu.
> 
>  - Run rv64 with rv32 rootfs in compat mode:
>$ ./build/qemu-system-riscv64 -cpu rv64 -M virt -m 64m -nographic -bios 
> qemu_riscv64_virt_defconfig/images/fw_jump.bin -kernel build-rv64/Image 
> -drive file qemu_riscv32_virt_defconfig/images/rootfs.ext2,format=raw,id=hd0 
> -device virtio-blk-device,drive=hd0 -append "rootwait root=/dev/vda ro 
> console=ttyS0 earlycon=sbi" -netdev user,id=net0 -device 
> virtio-net-device,netdev=net0
> 
> QEMU emulator version 6.2.50 (v6.2.0-29-g196d7182c8)
> OpenSBI v0.9
> [0.00] Linux version 5.16.0-rc6-00017-g750f87086bdd-dirty 
> (guoren@guoren-Z87-HD3) (riscv64-unknown-linux-gnu-gcc (GCC) 10.2.0, GNU ld 
> (GNU Binutils) 2.37) #96 SMP Tue Dec 28 21:01:55 CST 2021
> [0.00] OF: fdt: Ignoring memory range 0x8000 - 0x8020
> [0.00] Machine model: riscv-virtio,qemu
> [0.00] earlycon: sbi0 at I/O port 0x0 (options '')
> [0.00] printk: bootconsole [sbi0] enabled
> [0.00] efi: UEFI not found.
> [0.00] Zone ranges:
> [0.00]   DMA32[mem 0x8020-0x83ff]
> [0.00]   Normal   empty
> [0.00] Movable zone start for each node
> [0.00] Early memory node ranges
> [0.00]   node   0: [mem 0x8020-0x83ff]
> [0.00] Initmem setup node 0 [mem 
> 0x8020-0x83ff]
> [0.00] SBI specification v0.2 detected
> [0.00] SBI implementation ID=0x1 Version=0x9
> [0.00] SBI TIME extension detected
> [0.00] SBI IPI extension detected
> [0.00] SBI RFENCE extension detected
> [0.00] SBI v0.2 HSM extension detected
> [0.00] riscv: ISA extensions acdfhimsu
> [0.00] riscv: ELF capabilities acdfim
> [0.00] percpu: Embedded 17 pages/cpu s30696 r8192 d30744 u69632
> [0.00] Built 1 zonelists, mobility grouping on.  Total pages: 15655
> [0.00] Kernel command line: rootwait root=/dev/vda ro console=ttyS0 
> earlycon=sbi
> [0.00] Dentry cache hash table entries: 8192 (order: 4, 65536 bytes, 
> linear)
> [0.00] Inode-cache hash table entries: 4096 (order: 3, 32768 bytes, 
> linear)
> [0.00] mem auto-init: stack:off, heap alloc:off, heap free:off
> [0.00] Virtual kernel memory layout:
> [0.00]   fixmap : 0xffcefee0 - 0xffceff00   (2048 
> kB)
> [0.00]   pci io : 0xffceff00 - 0xffcf   (  16 
> MB)
> [0.00]  vmemmap : 0xffcf - 0xffcf   (4095 
> MB)
> [0.00]  vmalloc : 0xffd0 - 0xfff

Re: [PATCH 3/4] ASoC: wm8904: extend device tree support

2022-03-07 Thread Mark Brown
On Mon, Mar 07, 2022 at 11:10:40AM -0300, Alifer Moraes wrote:

> +  - num-drc-cfgs: Number of available DRC modes from drc-cfg-regs property
> +
> +  - drc-cfg-regs: Default registers value for R40/41/42/43 (DRC)
> +The list must be (4 x num-drc-cfgs) entries long.
> +If absent or incomplete, DRC is disabled.

What is the purpose of having num-drc-cfgs?  We can tell how large
drc-cfg-regs is so it just seems redundant.

> +  - num-retune-mobile-cfgs: Number of retune modes available from
> +retune-mobile-cfg-regs property

Same here.


signature.asc
Description: PGP signature


Re: [PATCH 4/4] ASoC: wm8904: add DMIC support

2022-03-07 Thread Mark Brown
On Mon, Mar 07, 2022 at 11:10:41AM -0300, Alifer Moraes wrote:

> +static const char *cin_text[] = {
> + "ADC", "DMIC"
> +};
> +
> +static SOC_ENUM_SINGLE_DECL(cin_enum,
> + WM8904_DIGITAL_MICROPHONE_0, 12, cin_text);

Why would this be runtime selectable?  I'd expect the decision to use
an analogue or digital microphone to be made in the hardware design.


signature.asc
Description: PGP signature


Re: [PATCH] pkeys: Make pkey unsigned in arch_set_user_pkey_access()

2022-03-07 Thread Ira Weiny
On Mon, Mar 07, 2022 at 12:30:03PM +0530, Aneesh Kumar K.V wrote:
> ira.we...@intel.com writes:
> 
> > From: Ira Weiny 
> >
> > The WARN_ON check in arch_set_user_pkey_access() in the x86 architecture
> > fails to check for an invalid negative value.
> >
> > A simple check for less than 0 would fix this issue however, in the call
> > stack below arch_set_user_pkey_access() the pkey should never be
> > negative on any architecture.  It is always best to use correct types
> > when possible.  x86 only supports 16 keys while ppc supports 32, u8 is
> > therefore large enough for all current architectures and likely those in
> > the future.
> 
> Should we do that as a separate patch? ie, now convert the variable to
> unsigned int and later switch all the variables to u8?

Maybe.

> because what we
> now have is confusing.
> 
> static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
>   unsigned long pkey)
> static inline u64 pkey_to_vmflag_bits(u16 pkey)
> 

This looks like a good cleanup as well.  Why not convert
arch_calc_vm_prot_bits() and pkey_to_vmflag_bits() to u8?  (In another patch.)

This is all a result of this PKS conversation:

https://lore.kernel.org/lkml/Yg8C6UkgfBmQlPSq@iweiny-desk3/

That started me down the path of trying to figure out why 'int' was used for
PKRU and I realized that negative values had meaning there which did not apply
to me with PKS.  So at some point a conversion needs to be made between a
'conceptual pkey' (int) and a real pkey (unsigned) IHMO.

It's no bit deal to split this patch into one which converts to unsigned and
then another to u8 (or u16 if there is some arch which may need it that big).

However, digging more:

Is there a reason u16 was used in pkey_to_vmflag_bits()?  How about in
__pkru_allows_read() in the x86 code?  If possible I think u8 should be
standardized but I'm ok with u16 if that is preferred.

Also, am I missing something in init_amr() and init_iamr()?  I think I could
have gone farther and changed init_amr() and init_iamr() right?

>From what I can see the argument to use unsigned long vs u8 (or u16) is some
expectation that pkeys will grow beyond 256 in number.  From what I can see I
don't think that is going to happen.

So do we need to do this in two steps?

Ira

> 
> >
> > Change the type of the pkey passed to arch_set_user_pkey_access() to u8.
> >
> > To: Dave Hansen 
> > To: Michael Ellerman 
> > Cc: Aneesh Kumar K.V 
> > Signed-off-by: Ira Weiny 
> > ---
> >  arch/powerpc/include/asm/pkeys.h | 4 ++--
> >  arch/powerpc/mm/book3s64/pkeys.c | 2 +-
> >  arch/x86/include/asm/pkeys.h | 4 ++--
> >  arch/x86/kernel/fpu/xstate.c | 2 +-
> >  include/linux/pkeys.h| 2 +-
> >  5 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/pkeys.h 
> > b/arch/powerpc/include/asm/pkeys.h
> > index 59a2c7dbc78f..e70615a1da9b 100644
> > --- a/arch/powerpc/include/asm/pkeys.h
> > +++ b/arch/powerpc/include/asm/pkeys.h
> > @@ -143,9 +143,9 @@ static inline int arch_override_mprotect_pkey(struct 
> > vm_area_struct *vma,
> > return __arch_override_mprotect_pkey(vma, prot, pkey);
> >  }
> >  
> > -extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
> > +extern int __arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey,
> >unsigned long init_val);
> 
> 
> > -static inline int arch_set_user_pkey_access(struct task_struct *tsk, int 
> > pkey,
> > +static inline int arch_set_user_pkey_access(struct task_struct *tsk, u8 
> > pkey,
> > unsigned long init_val)
> >  {
> > if (!mmu_has_feature(MMU_FTR_PKEY))
> > diff --git a/arch/powerpc/mm/book3s64/pkeys.c 
> > b/arch/powerpc/mm/book3s64/pkeys.c
> > index 753e62ba67af..c048467669df 100644
> > --- a/arch/powerpc/mm/book3s64/pkeys.c
> > +++ b/arch/powerpc/mm/book3s64/pkeys.c
> > @@ -333,7 +333,7 @@ static inline void init_iamr(int pkey, u8 init_bits)
> >   * Set the access rights in AMR IAMR and UAMOR registers for @pkey to that
> >   * specified in @init_val.
> >   */
> > -int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
> > +int __arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey,
> > unsigned long init_val)
> >  {
> > u64 new_amr_bits = 0x0ul;
> > diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h
> > index 5292e6dfe2a7..48efb81f6cc6 100644
> > --- a/arch/x86/include/asm/pkeys.h
> > +++ b/arch/x86/include/asm/pkeys.h
> > @@ -9,7 +9,7 @@
> >   */
> >  #define arch_max_pkey() (cpu_feature_enabled(X86_FEATURE_OSPKE) ? 16 : 1)
> >  
> > -extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
> > +extern int arch_set_user_pkey_access(struct task_struct *tsk, u8 pkey,
> > unsigned long init_val);
> >  
> >  static inline bool arch_pkeys_enabled(void)
> > @@ -115,7 +115,7 @@ int mm_pkey_free(struct mm_struct *mm, int pkey)
> > re

[PATCH 2/2] powerpc/signal: Report minimum signal frame size to userspace via AT_MINSIGSTKSZ

2022-03-07 Thread Nicholas Piggin
Implement the AT_MINSIGSTKSZ AUXV entry, allowing userspace to
dynamically size stack allocations in a manner forward-compatible with
new processor state saved in the signal frame

For now these statically find the maximum signal frame size rather than
doing any runtime testing of features to minimise the size.

glibc 2.34 will take advantage of this, as will applications that use
use _SC_MINSIGSTKSZ and _SC_SIGSTKSZ.

Cc: Alan Modra 
Cc: Tulio Magno Quites Machado Filho 
References: 94b07c1f8c39 ("arm64: signal: Report signal frame size to userspace 
via auxv")
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/elf.h | 14 +-
 arch/powerpc/include/asm/signal.h  |  5 +
 arch/powerpc/include/uapi/asm/auxvec.h |  4 +++-
 arch/powerpc/kernel/signal.c   | 15 +++
 arch/powerpc/kernel/signal_32.c|  6 ++
 arch/powerpc/kernel/signal_64.c|  5 +
 6 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index b8425e3cfd81..19d5c798c566 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -160,7 +160,7 @@ extern int arch_setup_additional_pages(struct linux_binprm 
*bprm,
  *   even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
  * update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes
  */
-#define ARCH_DLINFO\
+#define COMMON_ARCH_DLINFO \
 do {   \
/* Handle glibc compatibility. */   \
NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC);\
@@ -173,6 +173,18 @@ do {   
\
ARCH_DLINFO_CACHE_GEOMETRY; \
 } while (0)
 
+#define ARCH_DLINFO\
+do {   \
+   COMMON_ARCH_DLINFO; \
+   NEW_AUX_ENT(AT_MINSIGSTKSZ, get_min_sigframe_size());   \
+} while (0)
+
+#define COMPAT_ARCH_DLINFO \
+do {   \
+   COMMON_ARCH_DLINFO; \
+   NEW_AUX_ENT(AT_MINSIGSTKSZ, get_min_sigframe_size_compat());\
+} while (0)
+
 /* Relocate the kernel image to @final_address */
 void relocate(unsigned long final_address);
 
diff --git a/arch/powerpc/include/asm/signal.h 
b/arch/powerpc/include/asm/signal.h
index 99e1c6de27bc..922d43700fb4 100644
--- a/arch/powerpc/include/asm/signal.h
+++ b/arch/powerpc/include/asm/signal.h
@@ -9,4 +9,9 @@
 struct pt_regs;
 void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags);
 
+unsigned long get_min_sigframe_size_32(void);
+unsigned long get_min_sigframe_size_64(void);
+unsigned long get_min_sigframe_size(void);
+unsigned long get_min_sigframe_size_compat(void);
+
 #endif /* _ASM_POWERPC_SIGNAL_H */
diff --git a/arch/powerpc/include/uapi/asm/auxvec.h 
b/arch/powerpc/include/uapi/asm/auxvec.h
index 7af21dc0e320..aa7c16215453 100644
--- a/arch/powerpc/include/uapi/asm/auxvec.h
+++ b/arch/powerpc/include/uapi/asm/auxvec.h
@@ -48,6 +48,8 @@
 #define AT_L3_CACHESIZE46
 #define AT_L3_CACHEGEOMETRY47
 
-#define AT_VECTOR_SIZE_ARCH14 /* entries in ARCH_DLINFO */
+#define AT_MINSIGSTKSZ 51  /* stack needed for signal delivery */
+
+#define AT_VECTOR_SIZE_ARCH15 /* entries in ARCH_DLINFO */
 
 #endif
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index b93b87df499d..b3c458db2b8d 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -141,6 +141,21 @@ unsigned long copy_ckvsx_from_user(struct task_struct 
*task,
 
 int show_unhandled_signals = 1;
 
+unsigned long get_min_sigframe_size(void)
+{
+   if (IS_ENABLED(CONFIG_PPC64))
+   return get_min_sigframe_size_64();
+   else
+   return get_min_sigframe_size_32();
+}
+
+#ifdef CONFIG_COMPAT
+unsigned long get_min_sigframe_size_compat(void)
+{
+   return get_min_sigframe_size_32();
+}
+#endif
+
 /*
  * Allocate space for the signal frame
  */
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index d84c434b2b78..157a7403e3eb 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -233,6 +233,12 @@ struct rt_sigframe {
int abigap[56];
 };
 
+unsigned long get_min_sigframe_size_32(void)
+{
+   return max(sizeof(struct rt_sigframe) + __SIGNAL_FRAMESIZE + 16,
+  sizeof(struct sigframe) + __SIGNAL_FRAMESIZE);
+}
+
 /*
  * Save the current user registers on the user stack.
  * We

[PATCH 1/2] powerpc/64: Bump SIGSTKSZ and MINSIGSTKSZ

2022-03-07 Thread Nicholas Piggin
The sad tale of SIGSTKSZ and MINSIGSTKSZ is documented in glibc.git
commit f7c399cff5bd ("PowerPC SIGSTKSZ"), which explains why glibc
does not use the kernel defines for these constants. Since then in
fact there has been a further expansion of the signal stack frame size
on little-endian with linux commit 573ebfa6601f ("powerpc: Increase
stack redzone for 64-bit userspace to 512 bytes"), which has caused
it to exceed even the glibc defines.

Increase MINSIGSTKSZ to 8192 which is double the current glibc value
and fits the current stack frame with room to grow. SIGSTKSZ is set
to 4x the minimum as convention.

glibc will have to be updated as well.

Cc: Alan Modra 
Cc: Tulio Magno Quites Machado Filho 
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/uapi/asm/signal.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/powerpc/include/uapi/asm/signal.h 
b/arch/powerpc/include/uapi/asm/signal.h
index 04873dd311c2..81fa9d90be80 100644
--- a/arch/powerpc/include/uapi/asm/signal.h
+++ b/arch/powerpc/include/uapi/asm/signal.h
@@ -62,8 +62,13 @@ typedef struct {
 
 #define SA_RESTORER0x0400U
 
+#ifdef __powerpc64__
+#define MINSIGSTKSZ8192
+#define SIGSTKSZ   32768
+#else
 #define MINSIGSTKSZ2048
 #define SIGSTKSZ   8192
+#endif
 
 #include 
 
-- 
2.23.0



[PATCH 1/4] ASoC: fsl-asoc-card: add WM8904 support

2022-03-07 Thread Alifer Moraes
From: Pierluigi Passaro 

The codec WM8904 can use internal FLL as PLL source.
Whenever the PLL source is not an external MCLK, this source
must be setup during hw_params callback otherwise the BCLK
could be wrongly evaluated.
The SND_SOC_BIAS_PREPARE event is raised after the hw_params
callback, so there is no need to set again PLL and SYSCLK and
actually there's no need at all the set_bias_level function.
Also, when esai is used, a dedicated snd_soc_dai_set_tdm_slot
call is required.

Signed-off-by: Pierluigi Passaro 
Signed-off by: Alifer Moraes 
---
 sound/soc/fsl/fsl-asoc-card.c | 47 +++
 1 file changed, 47 insertions(+)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 5ee945505281..817dbc1ec635 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -23,6 +23,7 @@
 #include "imx-audmux.h"
 
 #include "../codecs/sgtl5000.h"
+#include "../codecs/wm8904.h"
 #include "../codecs/wm8962.h"
 #include "../codecs/wm8960.h"
 #include "../codecs/wm8994.h"
@@ -257,6 +258,38 @@ static int fsl_asoc_card_hw_free(struct snd_pcm_substream 
*substream)
}
}
 
+   if (of_device_is_compatible(dev->of_node, "fsl,imx-audio-wm8904")) {
+   struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+   unsigned int pll_out;
+
+   ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0, 0, 2,
+  params_physical_width(params));
+   if (ret) {
+   dev_err(dev, "failed to set TDM slot for cpu dai\n");
+   return ret;
+   }
+
+   if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE)
+   pll_out = priv->sample_rate * 384;
+   else
+   pll_out = priv->sample_rate * 256;
+
+   ret = snd_soc_dai_set_pll(codec_dai, codec_priv->pll_id,
+ codec_priv->pll_id,
+ codec_priv->mclk_freq, pll_out);
+   if (ret) {
+   dev_err(dev, "failed to start FLL: %d\n", ret);
+   return ret;
+   }
+
+   ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->fll_id,
+pll_out, SND_SOC_CLOCK_IN);
+   if (ret) {
+   dev_err(dev, "failed to set SYSCLK: %d\n", ret);
+   return ret;
+   }
+   }
+
return 0;
 }
 
@@ -651,6 +684,19 @@ static int fsl_asoc_card_probe(struct platform_device 
*pdev)
priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO;
priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO;
priv->dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
+   } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8904")) {
+   codec_dai_name = "wm8904-hifi";
+   priv->card.set_bias_level = NULL;
+   priv->codec_priv.mclk_id = WM8904_CLK_FLL;
+   priv->codec_priv.fll_id = WM8904_CLK_FLL;
+   priv->codec_priv.pll_id = WM8904_FLL_MCLK;
+   priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
+   if (strstr(cpu_np->name, "esai")) {
+   priv->cpu_priv.sysclk_freq[TX] = 
priv->codec_priv.mclk_freq;
+   priv->cpu_priv.sysclk_freq[RX] = 
priv->codec_priv.mclk_freq;
+   priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT;
+   priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT;
+   }
} else if (of_device_is_compatible(np, "fsl,imx-audio-ac97")) {
codec_dai_name = "ac97-hifi";
priv->dai_fmt = SND_SOC_DAIFMT_AC97;
@@ -900,6 +946,7 @@ static const struct of_device_id fsl_asoc_card_dt_ids[] = {
{ .compatible = "fsl,imx-audio-tlv320aic32x4", },
{ .compatible = "fsl,imx-audio-tlv320aic31xx", },
{ .compatible = "fsl,imx-audio-sgtl5000", },
+   { .compatible = "fsl,imx-audio-wm8904", },
{ .compatible = "fsl,imx-audio-wm8962", },
{ .compatible = "fsl,imx-audio-wm8960", },
{ .compatible = "fsl,imx-audio-mqs", },
-- 
2.25.1



[PATCH 2/4] ASoC: bindings: fsl-asoc-card: Add compatible string for wm8904

2022-03-07 Thread Alifer Moraes
Add compatible string for the wm8904 codec.

Signed-off-by: Alifer Moraes 
---
 Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt 
b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
index 23d83fa7609f..edb7837e4963 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
@@ -44,6 +44,8 @@ The compatible list for this generic sound card currently:
 
  "fsl,imx-audio-wm8958"
 
+ "fsl,imx-audio-wm8904"
+
 Required properties:
 
   - compatible : Contains one of entries in the compatible list.
-- 
2.25.1



[PATCH 4/4] ASoC: wm8904: add DMIC support

2022-03-07 Thread Alifer Moraes
From: Pierluigi Passaro 

The WM8904 codec supports both ADC and DMIC inputs.
Add dedicated controls to support the additional routing.

Signed-off-by: Pierluigi Passaro 
Signed-off by: Alifer Moraes 
---
 sound/soc/codecs/wm8904.c | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 4121771db104..c7987dc81e4d 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -837,6 +837,26 @@ static int out_pga_event(struct snd_soc_dapm_widget *w,
return 0;
 }
 
+static const char *dmic_text[] = {
+   "DMIC1", "DMIC2"
+};
+
+static SOC_ENUM_SINGLE_DECL(dmic_enum,
+   WM8904_DIGITAL_MICROPHONE_0, 11, dmic_text);
+
+static const struct snd_kcontrol_new dmic_mux =
+   SOC_DAPM_ENUM("DMIC Mux", dmic_enum);
+
+static const char *cin_text[] = {
+   "ADC", "DMIC"
+};
+
+static SOC_ENUM_SINGLE_DECL(cin_enum,
+   WM8904_DIGITAL_MICROPHONE_0, 12, cin_text);
+
+static const struct snd_kcontrol_new cin_mux =
+   SOC_DAPM_ENUM("Capture Input", cin_enum);
+
 static const char *input_mode_text[] = {
"Single-Ended", "Differential Line", "Differential Mic"
 };
@@ -930,6 +950,10 @@ SND_SOC_DAPM_INPUT("IN2R"),
 SND_SOC_DAPM_INPUT("IN3L"),
 SND_SOC_DAPM_INPUT("IN3R"),
 
+SND_SOC_DAPM_MUX("DMIC Mux", SND_SOC_NOPM, 0, 0, &dmic_mux),
+SND_SOC_DAPM_MUX("Left Capture Input", SND_SOC_NOPM, 0, 0, &cin_mux),
+SND_SOC_DAPM_MUX("Right Capture Input", SND_SOC_NOPM, 0, 0, &cin_mux),
+
 SND_SOC_DAPM_SUPPLY("MICBIAS", WM8904_MIC_BIAS_CONTROL_0, 0, 0, NULL, 0),
 
 SND_SOC_DAPM_MUX("Left Capture Mux", SND_SOC_NOPM, 0, 0, &lin_mux),
@@ -1093,11 +1117,21 @@ static const struct snd_soc_dapm_route adc_intercon[] = 
{
{ "AIFOUTL", NULL, "AIFOUTL Mux" },
{ "AIFOUTR", NULL, "AIFOUTR Mux" },
 
+   { "DMIC Mux", "DMIC1", "IN1L" },
+   { "DMIC Mux", "DMIC2", "IN1R" },
+
+   { "Left Capture Input", "ADC", "Left Capture PGA" },
+   { "Left Capture Input", "DMIC", "DMIC Mux" },
+   { "Right Capture Input", "ADC", "Right Capture PGA" },
+   { "Right Capture Input", "DMIC", "DMIC Mux" },
+
{ "ADCL", NULL, "CLK_DSP" },
{ "ADCL", NULL, "Left Capture PGA" },
+   { "ADCL", NULL, "Left Capture Input" },
 
{ "ADCR", NULL, "CLK_DSP" },
{ "ADCR", NULL, "Right Capture PGA" },
+   { "ADCR", NULL, "Right Capture Input" },
 };
 
 static const struct snd_soc_dapm_route dac_intercon[] = {
-- 
2.25.1



[PATCH 3/4] ASoC: wm8904: extend device tree support

2022-03-07 Thread Alifer Moraes
From: Pierluigi Passaro 

The platform_data structure is not populated when using device trees.
This patch adds optional dts properties to allow populating it:
- gpio-cfg
- mic-cfg
- num-drc-cfgs
- drc-cfg-regs
- drc-cfg-names
- num-retune-mobile-cfgs
- retune-mobile-cfg-regs
- retune-mobile-cfg-names
- retune-mobile-cfg-rates

Signed-off-by: Pierluigi Passaro 
Signed-off-by: Alifer Moraes 
---
 .../devicetree/bindings/sound/wm8904.txt  |  53 
 sound/soc/codecs/wm8904.c | 113 +-
 2 files changed, 164 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/wm8904.txt 
b/Documentation/devicetree/bindings/sound/wm8904.txt
index 66bf261423b9..e3bfd3ec2905 100644
--- a/Documentation/devicetree/bindings/sound/wm8904.txt
+++ b/Documentation/devicetree/bindings/sound/wm8904.txt
@@ -9,6 +9,40 @@ Required properties:
   - clocks: reference to
 
 
+Optional properties:
+
+  - gpio-cfg: Default registers value for R121/122/123/124 (GPIO Control).
+The list must be 4 entries long. If absent, the registers are set to 0.
+If any entry has the value 0x, the related register won't be set.
+
+  - mic-cfg: Default registers value for R6/R7 (Mic Bias Control).
+The list must be 2 entries long. If absent, the registers are set to 0.
+
+  - num-drc-cfgs: Number of available DRC modes from drc-cfg-regs property
+
+  - drc-cfg-regs: Default registers value for R40/41/42/43 (DRC)
+The list must be (4 x num-drc-cfgs) entries long.
+If absent or incomplete, DRC is disabled.
+
+  - drc-cfg-names: List of strings for the available DRC modes.
+The list must be (num-drc-cfgs) entries long.
+If absent or incomplete, DRC is disabled.
+
+  - num-retune-mobile-cfgs: Number of retune modes available from
+retune-mobile-cfg-regs property
+
+  - retune-mobile-cfg-regs: Default registers value for R134/.../157 (EQ)
+The list must be (24 x num-retune-mobile-cfgs) entries long.
+If absent or incomplete, retune is disabled.
+
+  - retune-mobile-cfg-names: List of strings for the available retune modes.
+The list must be (num-retune-mobile-cfgs) entries long.
+If absent or incomplete, retune is disabled.
+
+  - retune-mobile-cfg-rates: List of rates for the available retune modes.
+The list must be (num-retune-mobile-cfgs) entries long.
+If absent or incomplete, retune is disabled.
+
 Pins on the device (for linking into audio routes):
 
   * IN1L
@@ -30,4 +64,23 @@ codec: wm8904@1a {
reg = <0x1a>;
clocks = <&pck0>;
clock-names = "mclk";
+   num-drc-cfgs = <5>;
+   drc-cfg-names = "default", "peaklimiter", "tradition", "soft", "music";
+   drc-cfg-regs =
+   /* coded default: KNEE_IP = KNEE_OP = 0, HI_COMP = 
LO_COMP = 1  */
+   <0x01af 0x3248 0x 0x>,
+   /* coded default: KNEE_IP = -24, KNEE_OP = -6, HI_COMP 
= 1/4, LO_COMP = 1 */
+   <0x04af 0x324b 0x0010 0x0408>,
+   /* coded default: KNEE_IP = -42, KNEE_OP = -3, HI_COMP 
= 0, LO_COMP = 1 */
+   <0x04af 0x324b 0x0028 0x0704>,
+   /* coded default: KNEE_IP = -45, KNEE_OP = -9, HI_COMP 
= 1/8, LO_COMP = 1 */
+   <0x04af 0x324b 0x0018 0x078c>,
+   /* coded default: KNEE_IP = -30, KNEE_OP = -10.5, 
HI_COMP = 1/4, LO_COMP = 1 */
+   <0x04af 0x324b 0x0010 0x050e>;
+   gpio-cfg = <
+   0x0018 /* GPIO1 => DMIC_CLK */
+   0x /* GPIO2 => don't touch */
+   0x /* GPIO3 => don't touch */
+   0x /* GPIO4 => don't touch */
+   >;
 };
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index a02a77fef360..4121771db104 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -2162,6 +2162,110 @@ static const struct of_device_id wm8904_of_match[] = {
 MODULE_DEVICE_TABLE(of, wm8904_of_match);
 #endif
 
+static int wm8904_set_pdata_from_of(struct i2c_client *i2c,
+struct wm8904_priv *wm8904)
+{
+   const struct device_node *np = i2c->dev.of_node;
+   struct wm8904_pdata *pdata;
+   bool drc_cfgs_is_valid = true;
+   bool retune_mobile_cfgs_is_valid = true;
+   int i, j, offset;
+   u32 val32;
+
+   pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);
+   if (!pdata)
+   return -ENOMEM;
+
+   if (of_property_read_u32_array(np, "gpio-cfg", pdata->gpio_cfg,
+   ARRAY_SIZE(pdata->gpio_cfg))) {
+   dev_dbg(&i2c->dev, "No 'gpio-cfg' property found\n");
+   }
+
+   if (of_property_read_u32_array(np, "mic-cfg", pdata->mic_cfg,
+   ARRAY_SIZE(pdata->mic_cfg))) {
+   dev_dbg(&i2c->dev, "No 'mic-cfg' property found\n");
+   }
+
+   if (of_property_r

[powerpc:topic/ppc-kvm] BUILD SUCCESS e40b38a41ce916d6a3a4751d59a01b6c0c03afd0

2022-03-07 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
topic/ppc-kvm
branch HEAD: e40b38a41ce916d6a3a4751d59a01b6c0c03afd0  KVM: PPC: Book3S HV: 
remove unnecessary casts

elapsed time: 761m

configs tested: 74
configs skipped: 113

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

gcc tested configs:
powerpc pq2fads_defconfig
um i386_defconfig
ia64  tiger_defconfig
m68km5272c3_defconfig
armmulti_v7_defconfig
powerpcamigaone_defconfig
sh   se7724_defconfig
arm   tegra_defconfig
xtensa virt_defconfig
mips db1xxx_defconfig
arm  jornada720_defconfig
powerpcklondike_defconfig
arm vf610m4_defconfig
arm  exynos_defconfig
arm  randconfig-c002-20220307
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a006-20220307
x86_64   randconfig-a004-20220307
x86_64   randconfig-a005-20220307
x86_64   randconfig-a001-20220307
x86_64   randconfig-a003-20220307
x86_64   randconfig-a002-20220307
um   x86_64_defconfig
x86_64   allyesconfig
x86_64rhel-8.3-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-func
x86_64 rhel-8.3-kunit
x86_64  kexec

clang tested configs:
x86_64   randconfig-c007-20220307
i386 randconfig-c001-20220307
powerpc  randconfig-c003-20220307
riscvrandconfig-c006-20220307
mips randconfig-c004-20220307
arm  randconfig-c002-20220307
s390 randconfig-c005-20220307
arm   imx_v4_v5_defconfig
x86_64   allyesconfig
mips cu1000-neo_defconfig
powerpc mpc832x_mds_defconfig
powerpc   microwatt_defconfig
powerpc  allmodconfig
mips   rs90_defconfig
powerpc tqm8540_defconfig
powerpc  ppc64e_defconfig
i386 randconfig-a012-20220307
i386 randconfig-a013-20220307
i386 randconfig-a015-20220307
i386 randconfig-a011-20220307
i386 randconfig-a014-20220307
i386 randconfig-a016-20220307
hexagon  randconfig-r045-20220307
riscvrandconfig-r042-20220307
hexagon  randconfig-r041-20220307

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


[powerpc:merge] BUILD SUCCESS 782b30d101f6d0a4bfe76ae2359698cfd91b8fff

2022-03-07 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
merge
branch HEAD: 782b30d101f6d0a4bfe76ae2359698cfd91b8fff  Automatic merge of 
'next' into merge (2022-03-05 20:45)

elapsed time: 943m

configs tested: 102
configs skipped: 3

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

gcc tested configs:
arm defconfig
arm  allmodconfig
arm  allyesconfig
arm64   defconfig
arm64allyesconfig
armclps711x_defconfig
sh   j2_defconfig
m68k  amiga_defconfig
powerpc   ppc64_defconfig
sh  rsk7269_defconfig
arc  axs103_smp_defconfig
arm lubbock_defconfig
armhisi_defconfig
powerpc mpc837x_mds_defconfig
armmvebu_v7_defconfig
mips   capcella_defconfig
powerpcmpc7448_hpc2_defconfig
shsh7757lcr_defconfig
arm   h3600_defconfig
arm  randconfig-c002-20220307
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allyesconfig
m68k allmodconfig
m68kdefconfig
nds32 allnoconfig
arc  allyesconfig
nios2   defconfig
alphaallyesconfig
alpha   defconfig
nds32   defconfig
cskydefconfig
nios2allyesconfig
arc defconfig
h8300allyesconfig
sh   allmodconfig
xtensa   allyesconfig
parisc  defconfig
parisc64defconfig
parisc   allyesconfig
s390 allmodconfig
s390defconfig
s390 allyesconfig
sparcallyesconfig
i386 allyesconfig
i386  debian-10.3
i386defconfig
sparc   defconfig
i386   debian-10.3-kselftests
mips allmodconfig
mips allyesconfig
powerpc   allnoconfig
powerpc  allmodconfig
powerpc  allyesconfig
i386 randconfig-a003-20220307
i386 randconfig-a001-20220307
i386 randconfig-a004-20220307
i386 randconfig-a002-20220307
i386 randconfig-a005-20220307
i386 randconfig-a006-20220307
x86_64   randconfig-a003-20220307
x86_64   randconfig-a001-20220307
x86_64   randconfig-a002-20220307
x86_64   randconfig-a004-20220307
x86_64   randconfig-a005-20220307
x86_64   randconfig-a006-20220307
arc  randconfig-r043-20220307
riscvnommu_k210_defconfig
riscvnommu_virt_defconfig
riscvallyesconfig
riscv allnoconfig
riscv   defconfig
riscvallmodconfig
riscv  rv32_defconfig
um i386_defconfig
um   x86_64_defconfig
x86_64   allyesconfig
x86_64rhel-8.3-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-func
x86_64 rhel-8.3-kunit
x86_64  kexec

clang tested configs:
armneponset_defconfig
powerpc  obs600_defconfig
powerpc  ppc64e_defconfig
arm   netwinder_defconfig
arm   mainstone_defconfig
mips   ip27_defconfig
arm   versatile_defconfig
powerpc  mpc885_ads_defconfig
i386 randconfig-a013-20220307
i386 randconfig-a012-20220307
i386 randconfig-a011-20220307
i386 randconfig-a014-20220307
i386 randconfig-a015-20220307
i386 randconfig-a016-20220307
hexagon  randconfig-r045-20220307
riscvrandc

[PATCH v3] powerpc: declare unmodified attribute_group usages const

2022-03-07 Thread Rohan McLure
Inspired by (bd75b4ef4977: Constify static attribute_group structs),
accepted by linux-next, reported:
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20220210202805.7750-4-rikard.falkeb...@gmail.com/

Nearly all singletons of type struct attribute_group are never
modified, and so
are candidates for being const. Declare them as const.

Signed-off-by: Rohan McLure 
---
 arch/powerpc/include/asm/spu.h  | 4 ++--
 arch/powerpc/perf/generic-compat-pmu.c  | 4 ++--
 arch/powerpc/perf/hv-24x7.c | 6 +++---
 arch/powerpc/perf/hv-gpci.c | 8 
 arch/powerpc/perf/imc-pmu.c | 6 +++---
 arch/powerpc/perf/isa207-common.c   | 2 +-
 arch/powerpc/perf/power10-pmu.c | 6 +++---
 arch/powerpc/perf/power7-pmu.c  | 4 ++--
 arch/powerpc/perf/power8-pmu.c  | 4 ++--
 arch/powerpc/perf/power9-pmu.c  | 6 +++---
 arch/powerpc/platforms/cell/cbe_thermal.c   | 2 +-
 arch/powerpc/platforms/cell/spu_base.c  | 4 ++--
 arch/powerpc/platforms/powernv/opal-core.c  | 2 +-
 arch/powerpc/platforms/powernv/opal-dump.c  | 2 +-
 arch/powerpc/platforms/powernv/opal-flash.c | 2 +-
 arch/powerpc/platforms/pseries/papr_scm.c   | 2 +-
 arch/powerpc/platforms/pseries/power.c  | 2 +-
 17 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/arch/powerpc/include/asm/spu.h b/arch/powerpc/include/asm/spu.h
index 8a2d11ba0dae..96ad4510c895 100644
--- a/arch/powerpc/include/asm/spu.h
+++ b/arch/powerpc/include/asm/spu.h
@@ -249,8 +249,8 @@ void unregister_spu_syscalls(struct spufs_calls *calls);
 int spu_add_dev_attr(struct device_attribute *attr);
 void spu_remove_dev_attr(struct device_attribute *attr);
 
-int spu_add_dev_attr_group(struct attribute_group *attrs);
-void spu_remove_dev_attr_group(struct attribute_group *attrs);
+int spu_add_dev_attr_group(const struct attribute_group *attrs);
+void spu_remove_dev_attr_group(const struct attribute_group *attrs);
 
 extern void notify_spus_active(void);
 extern void do_notify_spus_active(void);
diff --git a/arch/powerpc/perf/generic-compat-pmu.c 
b/arch/powerpc/perf/generic-compat-pmu.c
index b6e25f75109d..f3db88aee4dd 100644
--- a/arch/powerpc/perf/generic-compat-pmu.c
+++ b/arch/powerpc/perf/generic-compat-pmu.c
@@ -130,7 +130,7 @@ static struct attribute *generic_compat_events_attr[] = {
NULL
 };
 
-static struct attribute_group generic_compat_pmu_events_group = {
+static const struct attribute_group generic_compat_pmu_events_group = {
.name = "events",
.attrs = generic_compat_events_attr,
 };
@@ -146,7 +146,7 @@ static struct attribute *generic_compat_pmu_format_attr[] = 
{
NULL,
 };
 
-static struct attribute_group generic_compat_pmu_format_group = {
+static const struct attribute_group generic_compat_pmu_format_group = {
.name = "format",
.attrs = generic_compat_pmu_format_attr,
 };
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 1e8aa934e37e..12c1777187fc 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -204,7 +204,7 @@ static struct attribute *format_attrs[] = {
NULL,
 };
 
-static struct attribute_group format_group = {
+static const struct attribute_group format_group = {
.name = "format",
.attrs = format_attrs,
 };
@@ -1148,7 +1148,7 @@ static struct attribute *cpumask_attrs[] = {
NULL,
 };
 
-static struct attribute_group cpumask_attr_group = {
+static const struct attribute_group cpumask_attr_group = {
.attrs = cpumask_attrs,
 };
 
@@ -1162,7 +1162,7 @@ static struct attribute *if_attrs[] = {
NULL,
 };
 
-static struct attribute_group if_group = {
+static const struct attribute_group if_group = {
.name = "interface",
.bin_attrs = if_bin_attrs,
.attrs = if_attrs,
diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index c756228a081f..5eb60ed5b5e8 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -65,12 +65,12 @@ static struct attribute *format_attrs[] = {
NULL,
 };
 
-static struct attribute_group format_group = {
+static const struct attribute_group format_group = {
.name = "format",
.attrs = format_attrs,
 };
 
-static struct attribute_group event_group = {
+static const struct attribute_group event_group = {
.name  = "events",
.attrs = hv_gpci_event_attrs,
 };
@@ -126,11 +126,11 @@ static struct attribute *cpumask_attrs[] = {
NULL,
 };
 
-static struct attribute_group cpumask_attr_group = {
+static const struct attribute_group cpumask_attr_group = {
.attrs = cpumask_attrs,
 };
 
-static struct attribute_group interface_group = {
+static const struct attribute_group interface_group = {
.name = "interface",
.attrs = interface_attrs,
 };
diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index e7583fbcc8fa..526d4b767534 100644
--- a/arch/po

Re: [PATCH 2/6] KVM: PPC: Book3S HV P9: Inject pending xive interrupts at guest entry

2022-03-07 Thread Fabiano Rosas
Nicholas Piggin  writes:

> If there is a pending xive interrupt, inject it at guest entry (if
> MSR[EE] is enabled) rather than take another interrupt when the guest
> is entered. If xive is enabled then LPCR[LPES] is set so this behaviour
> should be expected.
>
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/kvm/book3s_hv.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index f8c0f1f52a1e..5df359053147 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -4524,9 +4524,14 @@ int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 
> time_limit,
>
>   if (!nested) {
>   kvmppc_core_prepare_to_enter(vcpu);
> - if (test_bit(BOOK3S_IRQPRIO_EXTERNAL,
> -  &vcpu->arch.pending_exceptions))
> + if (vcpu->arch.shregs.msr & MSR_EE) {
> + if (xive_interrupt_pending(vcpu))
> + kvmppc_inject_interrupt_hv(vcpu,
> + BOOK3S_INTERRUPT_EXTERNAL, 0);
> + } else if (test_bit(BOOK3S_IRQPRIO_EXTERNAL,
> +  &vcpu->arch.pending_exceptions)) {
>   lpcr |= LPCR_MER;
> + }
>   } else if (vcpu->arch.pending_exceptions ||
>  vcpu->arch.doorbell_request ||
>  xive_interrupt_pending(vcpu)) {

Reviewed-by: Fabiano Rosas 


[powerpc:fixes-test] BUILD SUCCESS 48015b632f770c401f3816f144499a39f2884677

2022-03-07 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
fixes-test
branch HEAD: 48015b632f770c401f3816f144499a39f2884677  powerpc: Fix 
STACKTRACE=n build

elapsed time: 725m

configs tested: 103
configs skipped: 135

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

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
powerpc  ep88xc_defconfig
powerpc asp8347_defconfig
armrealview_defconfig
sh   se7780_defconfig
powerpcmpc7448_hpc2_defconfig
powerpc  tqm8xx_defconfig
sh   se7750_defconfig
sh sh03_defconfig
sh  r7785rp_defconfig
nios2 3c120_defconfig
powerpc ep8248e_defconfig
powerpcwarp_defconfig
arm  jornada720_defconfig
armshmobile_defconfig
mips tb0226_defconfig
mips  decstation_64_defconfig
arm s3c6400_defconfig
shtitan_defconfig
armxcep_defconfig
xtensa  iss_defconfig
powerpc  iss476-smp_defconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc64defconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
i386 randconfig-a005-20220307
i386 randconfig-a004-20220307
i386 randconfig-a003-20220307
i386 randconfig-a006-20220307
i386 randconfig-a002-20220307
i386 randconfig-a001-20220307
x86_64   randconfig-a006-20220307
x86_64   randconfig-a004-20220307
x86_64   randconfig-a005-20220307
x86_64   randconfig-a001-20220307
x86_64   randconfig-a003-20220307
x86_64   randconfig-a002-20220307
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
x86_64rhel-8.3-kselftests
um   x86_64_defconfig
um i386_defconfig

clang tested configs:
x86_64   randconfig-c007-20220307
i386 randconfig-c001-20220307
powerpc  randconfig-c003-20220307
riscvrandconfig-c006-20220308
riscvrandconfig-c006-20220307
powerpc  randconfig-c003-20220308
arm  randconfig-c002-20220308
mips randconfig-c004-20220308
mips randconfig-c004-20220307
arm  randconfig-c002-20220307
s390 randconfig-c005-20220307
mips   mtx1_defconfig
mips loongson2k_defconfig
arm bcm2835_defconfig
powerpc  ppc44x_defconfig
powerpc ksi8560_defconfig
armvexpress_defconfig
hexagon defconfig
mips   ip22_defconfig
i386 randconfig-a012-20220307
i386 randconfig-a013-20220307
i386 randconfig-a015-20220307
i386

[PATCH] tty: hvc: fix return value of __setup handler

2022-03-07 Thread Randy Dunlap
__setup() handlers should return 1 to indicate that the boot option
has been handled or 0 to indicate that it was not handled.
Add a pr_warn() message if the option value is invalid and then
always return 1.

Fixes: 86b40567b917 ("tty: replace strict_strtoul() with kstrtoul()")
Signed-off-by: Randy Dunlap 
Reported-by: Igor Zhbanov 
Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0de...@omprussia.ru
Cc: Jingoo Han 
Cc: Greg Kroah-Hartman 
Cc: Jiri Slaby 
Cc: Michael Ellerman 
Cc: Julian Wiedmann 
Cc: Vasily Gorbik 
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/tty/hvc/hvc_iucv.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- linux-next-20220307.orig/drivers/tty/hvc/hvc_iucv.c
+++ linux-next-20220307/drivers/tty/hvc/hvc_iucv.c
@@ -1417,7 +1417,9 @@ out_error:
  */
 static int __init hvc_iucv_config(char *val)
 {
-return kstrtoul(val, 10, &hvc_iucv_devices);
+   if (kstrtoul(val, 10, &hvc_iucv_devices))
+   pr_warn("hvc_iucv= invalid parameter value '%s'\n", val);
+   return 1;
 }
 
 


Re: [PATCH v7 0/4] Add perf interface to expose nvdimm

2022-03-07 Thread kajoljain
Hi Dan,
Can you take this patch-set if it looks fine to you.

Thanks,
Kajol Jain

On 2/25/22 20:00, Kajol Jain wrote:
> Patchset adds performance stats reporting support for nvdimm.
> Added interface includes support for pmu register/unregister
> functions. A structure is added called nvdimm_pmu to be used for
> adding arch/platform specific data such as cpumask, nvdimm device
> pointer and pmu event functions like event_init/add/read/del.
> User could use the standard perf tool to access perf events
> exposed via pmu.
> 
> Interface also defines supported event list, config fields for the
> event attributes and their corresponding bit values which are exported
> via sysfs. Patch 3 exposes IBM pseries platform nmem* device
> performance stats using this interface.
> 
> Result from power9 pseries lpar with 2 nvdimm device:
> 
> Ex: List all event by perf list
> 
> command:# perf list nmem
> 
>   nmem0/cache_rh_cnt/[Kernel PMU event]
>   nmem0/cache_wh_cnt/[Kernel PMU event]
>   nmem0/cri_res_util/[Kernel PMU event]
>   nmem0/ctl_res_cnt/ [Kernel PMU event]
>   nmem0/ctl_res_tm/  [Kernel PMU event]
>   nmem0/fast_w_cnt/  [Kernel PMU event]
>   nmem0/host_l_cnt/  [Kernel PMU event]
>   nmem0/host_l_dur/  [Kernel PMU event]
>   nmem0/host_s_cnt/  [Kernel PMU event]
>   nmem0/host_s_dur/  [Kernel PMU event]
>   nmem0/med_r_cnt/   [Kernel PMU event]
>   nmem0/med_r_dur/   [Kernel PMU event]
>   nmem0/med_w_cnt/   [Kernel PMU event]
>   nmem0/med_w_dur/   [Kernel PMU event]
>   nmem0/mem_life/[Kernel PMU event]
>   nmem0/poweron_secs/[Kernel PMU event]
>   ...
>   nmem1/mem_life/[Kernel PMU event]
>   nmem1/poweron_secs/[Kernel PMU event]
> 
> Patch1:
> Introduces the nvdimm_pmu structure
> Patch2:
> Adds common interface to add arch/platform specific data
> includes nvdimm device pointer, pmu data along with
> pmu event functions. It also defines supported event list
> and adds attribute groups for format, events and cpumask.
> It also adds code for cpu hotplug support.
> Patch3:
> Add code in arch/powerpc/platform/pseries/papr_scm.c to expose
> nmem* pmu. It fills in the nvdimm_pmu structure with pmu name,
> capabilities, cpumask and event functions and then registers
> the pmu by adding callbacks to register_nvdimm_pmu.
> Patch4:
> Sysfs documentation patch
> 
> Changelog
> ---
> v6 -> v7
> - Add function call to numa_map_to_online_node function inorder to
>   get online numa node. As the node id returned by function dev_to_node
>   can be offline in some scenarios and can create issue in hotplug code
>   as reported by Nageswara R Sastry.
> 
> - Add function declaration of perf_pmu_register, perf_pmu_unregister
>   and  perf_pmu_migrate_context functions in nd.h file to resolve
>   the implicit-function-declaration warning as reported by kernel test
>   robot.
>   Link: https://lore.kernel.org/all/202202241242.zqzgkguy-...@intel.com/
> 
> - Add Tested-by, Acked-by and Reported-by tags from Peter Zijlstra
>   and Nageswara R Sastry.
> 
> - Link to the patchset v6: https://lkml.org/lkml/2022/2/17/857
> 
> Resend v5 -> v6
> - No logic change, just a rebase to latest upstream and
>   tested the patchset.
> 
> - Link to the patchset Resend v5: https://lkml.org/lkml/2021/11/15/3979
> 
> v5 -> Resend v5
> - Resend the patchset
> 
> - Link to the patchset v5: https://lkml.org/lkml/2021/9/28/643
> 
> v4 -> v5:
> - Remove multiple variables defined in nvdimm_pmu structure include
>   name and pmu functions(event_int/add/del/read) as they are just
>   used to copy them again in pmu variable. Now we are directly doing
>   this step in arch specific code as suggested by Dan Williams.
> 
> - Remove attribute group field from nvdimm pmu structure and
>   defined these attribute groups in common interface which
>   includes format, event list along with cpumask as suggested by
>   Dan Williams.
>   Since we added static defination for attrbute groups needed in
>   common interface, removes corresponding code from papr.
> 
> - Add nvdimm pmu event list with event codes in the common interface.
> 
> - Remove Acked-by/Reviewed-by/Tested-by tags as code is refactored
>   to handle review comments from Dan.
> 
> - Make nvdimm_pmu_free_hotplug_memory function static as reported
>   by kernel test robot, also add corresponding Reported-by tag.
> 
> - Link to the patchs