Re: [PATCH] tty/hvc_opal: simplify if-if to if-else

2022-04-24 Thread Jiri Slaby

On 24. 04. 22, 11:25, Wan Jiabing wrote:

Use if and else instead of if(A) and if (!A).

Signed-off-by: Wan Jiabing 
---
  drivers/tty/hvc/hvc_opal.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 84776bc641e6..2dafa0964c2a 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -344,14 +344,15 @@ void __init hvc_opal_init_early(void)
opal = of_find_node_by_path("/ibm,opal/consoles");
if (opal)
pr_devel("hvc_opal: Found consoles in new location\n");
-   if (!opal) {
+   else {


This looks good, except missing braces as noted by Joe.


opal = of_find_node_by_path("/ibm,opal");
if (opal)
pr_devel("hvc_opal: "
 "Found consoles in old location\n");
+   else
+   return;


I am not sure this return is more obvious than the previous one. Rather 
the opposite, IMO.



}
-   if (!opal)
-   return;
+
for_each_child_of_node(opal, np) {
if (of_node_name_eq(np, "serial")) {
stdout_node = np;


thanks,
--
js
suse labs


[PATCH] powerpc/fsl_msi: fix return error value in error handing path

2022-04-24 Thread cgel . zte
From: Lv Ruyi 

This function fsl_msi_setup_hwirq() seems to return zero on success and
non-zero on failure, but it returns zero in error handing path.

Reported-by: Zeal Robot 
Signed-off-by: Lv Ruyi 
---
 arch/powerpc/sysdev/fsl_msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index b3475ae9f236..10f974cfa2f3 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -353,7 +353,7 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct 
platform_device *dev,
if (!virt_msir) {
dev_err(>dev, "%s: Cannot translate IRQ index %d\n",
__func__, irq_index);
-   return 0;
+   return -EINVAL;
}
 
cascade_data = kzalloc(sizeof(struct fsl_msi_cascade_data), GFP_KERNEL);
-- 
2.25.1



[powerpc:next-test] BUILD SUCCESS a9d1c96332a4d9177c3ae1672d948817568d2b84

2022-04-24 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
next-test
branch HEAD: a9d1c96332a4d9177c3ae1672d948817568d2b84  powerpc/85xx: Remove 
FSL_85XX_CACHE_SRAM

elapsed time: 722m

configs tested: 141
configs skipped: 4

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

gcc tested configs:
arm64   defconfig
arm64allyesconfig
arm  allmodconfig
arm defconfig
arm  allyesconfig
i386  randconfig-c001
mips randconfig-c004-20220424
sh   se7751_defconfig
sh   sh7724_generic_defconfig
arc haps_hs_defconfig
mips  maltasmvp_eva_defconfig
arm   multi_v4t_defconfig
sh   se7780_defconfig
arm lpc18xx_defconfig
sh  r7785rp_defconfig
mips  decstation_64_defconfig
powerpc  tqm8xx_defconfig
arm  jornada720_defconfig
arm eseries_pxa_defconfig
sh   sh2007_defconfig
um i386_defconfig
arc nsimosci_hs_defconfig
m68k   m5275evb_defconfig
powerpc wii_defconfig
powerpc  bamboo_defconfig
shapsh4ad0a_defconfig
m68kmvme147_defconfig
arm  exynos_defconfig
x86_64   alldefconfig
microblaze  defconfig
powerpc mpc83xx_defconfig
armlart_defconfig
armzeus_defconfig
arm   corgi_defconfig
mips  maltasmvp_defconfig
arm nhk8815_defconfig
shhp6xx_defconfig
arm  pxa3xx_defconfig
arm   imxrt_defconfig
parisc64defconfig
sh  rts7751r2d1_defconfig
m68km5407c3_defconfig
riscv   defconfig
armrealview_defconfig
mips   capcella_defconfig
arm  randconfig-c002-20220424
x86_64randconfig-c001
ia64 allmodconfig
ia64 allyesconfig
ia64defconfig
m68k allyesconfig
m68k allmodconfig
m68kdefconfig
cskydefconfig
nios2allyesconfig
alpha   defconfig
alphaallyesconfig
h8300allyesconfig
xtensa   allyesconfig
arc defconfig
sh   allmodconfig
s390defconfig
s390 allmodconfig
parisc  defconfig
parisc   allyesconfig
s390 allyesconfig
sparc   defconfig
i386 allyesconfig
sparcallyesconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
nios2   defconfig
arc  allyesconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc   allnoconfig
powerpc  allmodconfig
x86_64randconfig-a004
x86_64randconfig-a002
x86_64randconfig-a006
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-20220424
riscvnommu_virt_defconfig
riscv  rv32_defconfig
riscvnommu_k210_defconfig
riscv allnoconfig
riscvallmodconfig
riscvallyesconfig
x86_64rhel-8.3-kselftests
um   x86_64_defconfig
x86_64

Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.18-3 tag

2022-04-24 Thread pr-tracker-bot
The pull request you sent on Sun, 24 Apr 2022 23:08:48 +1000:

> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
> tags/powerpc-5.18-3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5206548f6e6741fccbce8d95cff8faeba0738c99

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


[PATCH 1/1] powerpc/boot: remove unused function find_node_by_linuxphandle()

2022-04-24 Thread frowand . list
From: Frank Rowand 

The last user of find_node_by_linuxphandle() was removed in v4.18-rc1
by commit 30f4bbe0472a ("powerpc/boot: Remove support for Marvell MPSC serial 
controller")
four years ago.  This function is no longer needed.

Signed-off-by: Frank Rowand 
---
 arch/powerpc/boot/ops.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 6455fc9a244f..8334bc3cbe49 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -200,12 +200,6 @@ void __dt_fixup_mac_addresses(u32 startindex, ...);
__dt_fixup_mac_addresses(0, __VA_ARGS__, NULL)
 
 
-static inline void *find_node_by_linuxphandle(const u32 linuxphandle)
-{
-   return find_node_by_prop_value(NULL, "linux,phandle",
-   (char *), sizeof(u32));
-}
-
 static inline char *get_path(const void *phandle, char *buf, int len)
 {
if (dt_ops.get_path)
-- 
Frank Rowand 



[GIT PULL] Please pull powerpc/linux.git powerpc-5.18-3 tag

2022-04-24 Thread Michael Ellerman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hi Linus,

Please pull some more powerpc fixes for 5.18:

The following changes since commit ce522ba9ef7e2d9fb22a39eb3371c0c64e2a433e:

  Linux 5.18-rc2 (2022-04-10 14:21:36 -1000)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
tags/powerpc-5.18-3

for you to fetch changes up to bb82c574691daf8f7fa9a160264d15c5804cb769:

  powerpc/perf: Fix 32bit compile (2022-04-21 23:26:47 +1000)

- --
powerpc fixes for 5.18 #3

 - Partly revert a change to our timer_interrupt() that caused lockups with 
high res
   timers disabled.

 - Fix a bug in KVM TCE handling that could corrupt kernel memory.

 - Two commits fixing Power9/Power10 perf alternative event selection.

Thanks to: Alexey Kardashevskiy, Athira Rajeev, David Gibson, Frederic Barrat, 
Madhavan
Srinivasan, Miguel Ojeda, Nicholas Piggin.

- --
Alexey Kardashevskiy (2):
  KVM: PPC: Fix TCE handling for VFIO
  powerpc/perf: Fix 32bit compile

Athira Rajeev (2):
  powerpc/perf: Fix power9 event alternatives
  powerpc/perf: Fix power10 event alternatives

Michael Ellerman (1):
  powerpc/time: Always set decrementer in timer_interrupt()


 arch/powerpc/kernel/time.c  | 29 ++---
 arch/powerpc/kvm/book3s_64_vio.c| 45 ++--
 arch/powerpc/kvm/book3s_64_vio_hv.c | 44 +--
 arch/powerpc/perf/Makefile  |  4 +-
 arch/powerpc/perf/power10-pmu.c |  2 +-
 arch/powerpc/perf/power9-pmu.c  |  8 ++--
 6 files changed, 66 insertions(+), 66 deletions(-)
-BEGIN PGP SIGNATURE-

iQIzBAEBCAAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmJlSSoACgkQUevqPMjh
pYDAkA/7BkoLPd4V9VwBu847BkwK6Dd15b2Qu71y0ieF0xzDzG8pkOEjpk5gCVmd
DV17CXSeX8t9ppDcKp82tLtuTnBIDjpZVtoKBALvzxB8tgErTp1CemwRcnlu+ILT
Y5K/tioe+Y6V07HKcDefLIJrtt73IpHUV7GighPtbah0a/HNLB6+zx6HENzR2vKS
G5ccs+FDbVgStRxw1tzWSH9JiAC7AznRJTWjA7XDiMcRva4t4qoZHSVU32H6Tlis
fCQfIwyhyppxS5MizZx45qkumy5oJggdXhb2r7g1Wl7jeSAVPldY/S7Fq3UU8usa
e2k5ZyUGWVSKZxGAlY7v6h6SwAhs28fspA/+tI0pvSH9a8knBkHk8H8bHlnORKkv
j6zx1hx3qdD2BnVstEEwdiZzWrff6LwfaEytNfC1Fri7yVTkZoZVGihMKyCGHftB
7TmRMIg99WsEx8xNNDGelaEePyRhCPGHgrB0oEHrmCzJVi3a4IiVwGcaLZdYUekG
oEFwcyXz4mStftyS5qV/NhFSHMgum9CuTjV8fi2pqN9fFVcPoDEXoGyaSzji9UDf
AOIP1NXJMZZGgXAN5rusjRJ9zfyFkzLcRcLPjMUqRtKaDJD86LyGPgvxh+gR8ky4
8IzPHbwbYt6fMcDXkFjiS5Ks+x0ZfKkL5R7HbHNqyyKYWUSZxK0=
=21WF
-END PGP SIGNATURE-


Re: [PATCH kernel] powerpc/perf: Fix 32bit compile

2022-04-24 Thread Michael Ellerman
On Thu, 21 Apr 2022 12:57:56 +1000, Alexey Kardashevskiy wrote:
> The "read_bhrb" global symbol is only called under CONFIG_PPC64 of
> arch/powerpc/perf/core-book3s.c but it is compiled for both 32 and 64 bit
> anyway (and LLVM fails to link this on 32bit).
> 
> This fixes it by moving bhrb.o to obj64 targets.
> 
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/perf: Fix 32bit compile
  https://git.kernel.org/powerpc/c/bb82c574691daf8f7fa9a160264d15c5804cb769

cheers


Re: [PATCH] powerpc/time: Always set decrementer in timer_interrupt()

2022-04-24 Thread Michael Ellerman
On Thu, 21 Apr 2022 00:16:57 +1000, Michael Ellerman wrote:
> This is a partial revert of commit 0faf20a1ad16 ("powerpc/64s/interrupt:
> Don't enable MSR[EE] in irq handlers unless perf is in use").
> 
> Prior to that commit, we always set the decrementer in
> timer_interrupt(), to clear the timer interrupt. Otherwise we could end
> up continuously taking timer interrupts.
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/time: Always set decrementer in timer_interrupt()
  https://git.kernel.org/powerpc/c/d2b9be1f4af5cabed1ee5bb341f887f64b1c1669

cheers


Re: [PATCH V3 1/2] powerpc/perf: Fix the power9 event alternatives array to have correct sort order

2022-04-24 Thread Michael Ellerman
On Tue, 19 Apr 2022 17:18:27 +0530, Athira Rajeev wrote:
> When scheduling a group of events, there are constraint checks
> done to make sure all events can go in a group. Example, one of
> the criteria is that events in a group cannot use same PMC.
> But platform specific PMU supports alternative event for some
> of the event codes. During perf_event_open, if any event
> group doesn't match constraint check criteria, further lookup
> is done to find alternative event.
> 
> [...]

Applied to powerpc/fixes.

[1/2] powerpc/perf: Fix the power9 event alternatives array to have correct 
sort order
  https://git.kernel.org/powerpc/c/0dcad700bb2776e3886fe0a645a4bf13b1e747cd
[2/2] powerpc/perf: Fix the power10 event alternatives array to have correct 
sort order
  https://git.kernel.org/powerpc/c/c6cc9a852f123301d5271f1484df8e961b2b64f1

cheers


Re: [PATCH kernel v2] KVM: PPC: Fix TCE handling for VFIO

2022-04-24 Thread Michael Ellerman
On Wed, 20 Apr 2022 15:08:40 +1000, Alexey Kardashevskiy wrote:
> The LoPAPR spec defines a guest visible IOMMU with a variable page size.
> Currently QEMU advertises 4K, 64K, 2M, 16MB pages, a Linux VM picks
> the biggest (16MB). In the case of a passed though PCI device, there is
> a hardware IOMMU which does not support all pages sizes from the above -
> P8 cannot do 2MB and P9 cannot do 16MB. So for each emulated
> 16M IOMMU page we may create several smaller mappings ("TCEs") in
> the hardware IOMMU.
> 
> [...]

Applied to powerpc/fixes.

[1/1] KVM: PPC: Fix TCE handling for VFIO
  https://git.kernel.org/powerpc/c/26a62b750a4e6364b0393562f66759b1494c3a01

cheers


Re: [PATCH] tty/hvc_opal: simplify if-if to if-else

2022-04-24 Thread Joe Perches
On Sun, 2022-04-24 at 17:25 +0800, Wan Jiabing wrote:
> Use if and else instead of if(A) and if (!A).
[]
> diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
[]
> @@ -344,14 +344,15 @@ void __init hvc_opal_init_early(void)
>   opal = of_find_node_by_path("/ibm,opal/consoles");
>   if (opal)
>   pr_devel("hvc_opal: Found consoles in new location\n");
> - if (!opal) {
> + else {
>   opal = of_find_node_by_path("/ibm,opal");
>   if (opal)
>   pr_devel("hvc_opal: "
>"Found consoles in old location\n");
> + else
> + return;

A few things:

o add {} braces to first block before else
o see about using pr_fmt to prefix the pr_ output
o reverse the test and unindent the pr_devel

if (!opal)
return;
pr_devel("...);

Maybe a few more just to quiet checkpatch noise.  Something like:
---
 drivers/tty/hvc/hvc_opal.c | 58 +-
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 84776bc641e6b..a42d5697ae198 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -5,6 +5,8 @@
  * Copyright 2011 Benjamin Herrenschmidt , IBM Corp.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #undef DEBUG
 
 #include 
@@ -43,6 +45,7 @@ struct hvc_opal_priv {
hv_protocol_t   proto;  /* Raw data or HVSI packets */
struct hvsi_privhvsi;   /* HVSI specific data */
 };
+
 static struct hvc_opal_priv *hvc_opal_privs[MAX_NR_HVC_CONSOLES];
 
 /* For early boot console */
@@ -124,7 +127,7 @@ static int hvc_opal_hvsi_tiocmget(struct hvc_struct *hp)
 }
 
 static int hvc_opal_hvsi_tiocmset(struct hvc_struct *hp, unsigned int set,
-   unsigned int clear)
+ unsigned int clear)
 {
struct hvc_opal_priv *pv = hvc_opal_privs[hp->vtermno];
 
@@ -167,8 +170,7 @@ static int hvc_opal_probe(struct platform_device *dev)
proto = HV_PROTOCOL_HVSI;
ops = _opal_hvsi_ops;
} else {
-   pr_err("hvc_opal: Unknown protocol for %pOF\n",
-  dev->dev.of_node);
+   pr_err("Unknown protocol for %pOF\n", dev->dev.of_node);
return -ENXIO;
}
 
@@ -195,15 +197,16 @@ static int hvc_opal_probe(struct platform_device *dev)
 termno, 0);
}
 
-   /* Instanciate now to establish a mapping index==vtermno */
+   /* Instantiate now to establish a mapping index==vtermno */
hvc_instantiate(termno, termno, ops);
} else {
-   pr_err("hvc_opal: Device %pOF has duplicate terminal number 
#%d\n",
+   pr_err("Device %pOF has duplicate terminal number #%d\n",
   dev->dev.of_node, termno);
return -ENXIO;
}
 
-   pr_info("hvc%d: %s protocol on %pOF%s\n", termno,
+   pr_info("hvc%d: %s protocol on %pOF%s\n",
+   termno,
proto == HV_PROTOCOL_RAW ? "raw" : "hvsi",
dev->dev.of_node,
boot ? " (boot console)" : "");
@@ -211,13 +214,13 @@ static int hvc_opal_probe(struct platform_device *dev)
irq = irq_of_parse_and_map(dev->dev.of_node, 0);
if (!irq) {
pr_info("hvc%d: No interrupts property, using OPAL event\n",
-   termno);
+   termno);
irq = opal_event_request(ilog2(OPAL_EVENT_CONSOLE_INPUT));
}
 
if (!irq) {
-   pr_err("hvc_opal: Unable to map interrupt for device %pOF\n",
-   dev->dev.of_node);
+   pr_err("Unable to map interrupt for device %pOF\n",
+  dev->dev.of_node);
return irq;
}
 
@@ -275,7 +278,7 @@ static void udbg_opal_putc(char c)
udbg_opal_putc('\r');
 
do {
-   switch(hvc_opal_boot_priv.proto) {
+   switch (hvc_opal_boot_priv.proto) {
case HV_PROTOCOL_RAW:
count = opal_put_chars(termno, , 1);
break;
@@ -288,7 +291,7 @@ static void udbg_opal_putc(char c)
 * when there aren't any interrupts.
 */
opal_flush_console(termno);
-   } while(count == 0 || count == -EAGAIN);
+   } while (count == 0 || count == -EAGAIN);
 }
 
 static int udbg_opal_getc_poll(void)
@@ -297,7 +300,7 @@ static int udbg_opal_getc_poll(void)
int rc = 0;
char c;
 
-   switch(hvc_opal_boot_priv.proto) {
+   switch (hvc_opal_boot_priv.proto) {

[PATCH] tty: hvcs: simplify if-if to if-else

2022-04-24 Thread Wan Jiabing
Use if and else instead of if(A) and if (!A) and fix a coding style.

Signed-off-by: Wan Jiabing 
---
 drivers/tty/hvc/hvcs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index 245da1dfd818..9b7e8246a464 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -581,10 +581,9 @@ static int hvcs_io(struct hvcs_struct *hvcsd)
 
spin_unlock_irqrestore(>lock, flags);
/* This is synch -- FIXME :js: it is not! */
-   if(got)
+   if (got)
tty_flip_buffer_push(>port);
-
-   if (!got) {
+   else {
/* Do this _after_ the flip_buffer_push */
spin_lock_irqsave(>lock, flags);
vio_enable_interrupts(hvcsd->vdev);
-- 
2.35.1



[PATCH] selftests/powerpc/pmu: Fix unsigned function returning negative constant

2022-04-24 Thread Haowen Bai
The function __perf_reg_mask has an unsigned return type, but returns a
negative constant to indicate an error condition. So we change unsigned
to int.

Signed-off-by: Haowen Bai 
---
 tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c 
b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
index fca054bbc094..c01a31d5f4ee 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
@@ -274,7 +274,7 @@ u64 *get_intr_regs(struct event *event, void *sample_buff)
return intr_regs;
 }
 
-static const unsigned int __perf_reg_mask(const char *register_name)
+static const int __perf_reg_mask(const char *register_name)
 {
if (!strcmp(register_name, "R0"))
return 0;
-- 
2.7.4