[PATCH] ASoC: fsl_sai: initialize is_dsp_mode flag

2023-01-15 Thread Shengjiu Wang
Initialize is_dsp_mode flag in the beginning of function
fsl_sai_set_dai_fmt_tr().

When the DAIFMT is DAIFMT_DSP_B the first time, is_dsp_mode is
true, then the second time DAIFMT is DAIFMT_I2S, is_dsp_mode
still true, which is a wrong state. So need to initialize
is_dsp_mode flag every time.

Fixes: a3f7dcc9cc03 ("ASoC: fsl-sai: Add SND_SOC_DAIFMT_DSP_A/B support.")
Signed-off-by: Shengjiu Wang 
---
 sound/soc/fsl/fsl_sai.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 1c9be8a5dcb1..355ef29af48c 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -281,6 +281,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai 
*cpu_dai,
val_cr4 |= FSL_SAI_CR4_MF;
 
sai->is_pdm_mode = false;
+   sai->is_dsp_mode = false;
/* DAI mode */
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
-- 
2.34.1



Re: [PATCH 1/2] tools/perf/tests: Fix string substitutions in build id test

2023-01-15 Thread Ian Rogers
On Sun, Jan 15, 2023 at 9:03 PM Athira Rajeev
 wrote:
>
>
>
> > On 28-Sep-2022, at 10:24 AM, Athira Rajeev  
> > wrote:
> >
> > Hi All,
> >
> > Looking for what direction we can take here.
> > Do we want to change all tests in tools/perf/tests/shell except 
> > test_intel_pt.sh to use "bash" or go with
> > the approach in the patch ? Please share your comments
> >
> > Thanks
> > Athira
> >
>
> Hi All,
>
> Looking for what direction we can take here.
> Do we want to change all tests in tools/perf/tests/shell except 
> test_intel_pt.sh to use "bash" or go with
> the approach in the patch ? Please share your comments
>
> Thanks
> Athira

I think some of what the patch is doing is good, some of it the
readability becomes a little harder by not being bash. I'm agnostic as
to which approach to take for the fix.

An aside, I noticed that we do run some tests at build time:
https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/lib/Makefile?h=perf/core#n390
So perhaps we can have a shellcheck build option, defaulted off but
enabled as part of Arnaldo's regular test scripts. The shellcheck
build option would run shellcheck to make sure that there weren't
errors in the shell code, which it is far too easy to introduce.

Thanks,
Ian

> >> On 23-Sep-2022, at 11:54 AM, Adrian Hunter  wrote:
> >>
> >> On 22/09/22 22:15, Arnaldo Carvalho de Melo wrote:
> >>> Em Wed, Sep 21, 2022 at 10:38:38PM +0530, Athira Rajeev escreveu:
>  The perf test named “build id cache operations” skips with below
>  error on some distros:
> >>>
> >>> I wonder if we shouldn't instead state that bash is needed?
> >>>
> >>> ⬢[acme@toolbox perf-urgent]$ head -1 tools/perf/tests/shell/*.sh | grep ^#
> >>> #!/bin/sh
> >>> #!/bin/bash
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/bash
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/bash
> >>> #!/bin/sh
> >>> #!/bin/bash
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> #!/bin/sh
> >>> ⬢[acme@toolbox perf-urgent]$
> >>>
> >>> Opinions?
> >>>
> >>
> >> Please don't change tools/perf/tests/shell/test_intel_pt.sh
> >>
> >> I started using shellcheck on that with the "perf test:
> >> test_intel_pt.sh: Add per-thread test" patch set that I sent.
> >>
> >> FYI, if you use shellcheck on buildid.sh, it shows up issues even
> >> after changing to bash:
> >>
> >> *** Before ***
> >>
> >> $ shellcheck -S warning tools/perf/tests/shell/buildid.sh
> >>
> >> In tools/perf/tests/shell/buildid.sh line 69:
> >>   link=${build_id_dir}/.build-id/${id:0:2}/${id:2}
> >>  ^---^ SC2039: In POSIX sh, string 
> >> indexing is undefined.
> >>^-^ SC2039: In POSIX 
> >> sh, string indexing is undefined.
> >>
> >>
> >> In tools/perf/tests/shell/buildid.sh line 77:
> >>   file=${build_id_dir}/.build-id/${id:0:2}/`readlink ${link}`/elf
> >>  ^---^ SC2039: In POSIX sh, string 
> >> indexing is undefined.
> >>
> >>
> >> In tools/perf/tests/shell/buildid.sh line 123:
> >>   echo "running: perf record $@"
> >>  ^-- SC2145: Argument mixes string and 
> >> array. Use * or separate argument.
> >>
> >>
> >> In tools/perf/tests/shell/buildid.sh line 124:
> >>   ${perf} record --buildid-all -o ${data} $@ &> ${log}
> >>   ^-- SC2068: Double quote 
> >> array expansions to avoid re-splitting elements.
> >>  ^---^ SC2039: In 
> >> POSIX sh, &> is undefined.
> >>
> >>
> >> In tools/perf/tests/shell/buildid.sh line 126:
> >>   echo "failed: record $@"
> >>^-- SC2145: Argument mixes string and 
> >> array. Use * or separate argument.
> >>
> >>
> >> In tools/perf/tests/shell/buildid.sh line 131:
> >>   check ${@: -1}
> >> ^--^ SC2068: Double quote array expansions to avoid 
> >> re-splitting elements.
> >> ^--^ SC2039: In POSIX sh, string indexing is undefined.
> >>
> >>
> >> In tools/perf/tests/shell/buildid.sh line 158:
> >> exit ${err}
> >>^^ SC2154: err is referenced but not assigned.
> >>
> >> For more information:
> >> https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to 
> >> ...
> >> https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. 
> >> ...
> >> https://www.shellcheck.net/wiki/SC2039 -- In POSIX sh, &> is undefined.
> >>
> >> *** After ***
> >>
> >> $ shellcheck -S warning tools/perf/tests/shell/buildid.sh
> >>
> >> In tools/perf/tests/shell/buildid.sh line 123:
> >>   echo "running: perf record $@"
> >>  ^-- SC2145: Argument mixes string and 
> >> array. Use * or separate argument.
> >>

Re: [PATCH 1/2] tools/perf/tests: Fix string substitutions in build id test

2023-01-15 Thread Athira Rajeev



> On 28-Sep-2022, at 10:24 AM, Athira Rajeev  
> wrote:
> 
> Hi All,
> 
> Looking for what direction we can take here.
> Do we want to change all tests in tools/perf/tests/shell except 
> test_intel_pt.sh to use "bash" or go with
> the approach in the patch ? Please share your comments
> 
> Thanks
> Athira
> 

Hi All,

Looking for what direction we can take here.
Do we want to change all tests in tools/perf/tests/shell except 
test_intel_pt.sh to use "bash" or go with
the approach in the patch ? Please share your comments

Thanks
Athira

>> On 23-Sep-2022, at 11:54 AM, Adrian Hunter  wrote:
>> 
>> On 22/09/22 22:15, Arnaldo Carvalho de Melo wrote:
>>> Em Wed, Sep 21, 2022 at 10:38:38PM +0530, Athira Rajeev escreveu:
 The perf test named “build id cache operations” skips with below
 error on some distros:
>>> 
>>> I wonder if we shouldn't instead state that bash is needed?
>>> 
>>> ⬢[acme@toolbox perf-urgent]$ head -1 tools/perf/tests/shell/*.sh | grep ^#
>>> #!/bin/sh
>>> #!/bin/bash
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/bash
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/bash
>>> #!/bin/sh
>>> #!/bin/bash
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> #!/bin/sh
>>> ⬢[acme@toolbox perf-urgent]$
>>> 
>>> Opinions?
>>> 
>> 
>> Please don't change tools/perf/tests/shell/test_intel_pt.sh
>> 
>> I started using shellcheck on that with the "perf test: 
>> test_intel_pt.sh: Add per-thread test" patch set that I sent.
>> 
>> FYI, if you use shellcheck on buildid.sh, it shows up issues even
>> after changing to bash:
>> 
>> *** Before ***
>> 
>> $ shellcheck -S warning tools/perf/tests/shell/buildid.sh 
>> 
>> In tools/perf/tests/shell/buildid.sh line 69:
>>   link=${build_id_dir}/.build-id/${id:0:2}/${id:2}
>>  ^---^ SC2039: In POSIX sh, string 
>> indexing is undefined.
>>^-^ SC2039: In POSIX sh, 
>> string indexing is undefined.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 77:
>>   file=${build_id_dir}/.build-id/${id:0:2}/`readlink ${link}`/elf
>>  ^---^ SC2039: In POSIX sh, string 
>> indexing is undefined.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 123:
>>   echo "running: perf record $@"
>>  ^-- SC2145: Argument mixes string and 
>> array. Use * or separate argument.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 124:
>>   ${perf} record --buildid-all -o ${data} $@ &> ${log}
>>   ^-- SC2068: Double quote array 
>> expansions to avoid re-splitting elements.
>>  ^---^ SC2039: In POSIX 
>> sh, &> is undefined.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 126:
>>   echo "failed: record $@"
>>^-- SC2145: Argument mixes string and 
>> array. Use * or separate argument.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 131:
>>   check ${@: -1}
>> ^--^ SC2068: Double quote array expansions to avoid 
>> re-splitting elements.
>> ^--^ SC2039: In POSIX sh, string indexing is undefined.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 158:
>> exit ${err}
>>^^ SC2154: err is referenced but not assigned.
>> 
>> For more information:
>> https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to 
>> ...
>> https://www.shellcheck.net/wiki/SC2145 -- Argument mixes string and array. 
>> ...
>> https://www.shellcheck.net/wiki/SC2039 -- In POSIX sh, &> is undefined.
>> 
>> *** After ***
>> 
>> $ shellcheck -S warning tools/perf/tests/shell/buildid.sh 
>> 
>> In tools/perf/tests/shell/buildid.sh line 123:
>>   echo "running: perf record $@"
>>  ^-- SC2145: Argument mixes string and 
>> array. Use * or separate argument.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 124:
>>   ${perf} record --buildid-all -o ${data} $@ &> ${log}
>>   ^-- SC2068: Double quote array 
>> expansions to avoid re-splitting elements.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 126:
>>   echo "failed: record $@"
>>^-- SC2145: Argument mixes string and 
>> array. Use * or separate argument.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 131:
>>   check ${@: -1}
>> ^--^ SC2068: Double quote array expansions to avoid 
>> re-splitting elements.
>> 
>> 
>> In tools/perf/tests/shell/buildid.sh line 158:
>> exit ${err}
>>^^ SC2154: err is referenced but not assigned.
>> 
>> For more information:
>> https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to 
>> ...
>> https://www.shellche

[PATCH 1/2] tools/perf: Fix the file mode with copyfile while adding file to build-id cache

2023-01-15 Thread Athira Rajeev
The test "build id cache operations" fails on powerpc
As below:

Adding 5a0fd882b53084224ba47b624c55a469 ./tests/shell/../pe-file.exe: Ok
build id: 5a0fd882b53084224ba47b624c55a469
link: /tmp/perf.debug.ZTu/.build-id/5a/0fd882b53084224ba47b624c55a469
file: 
/tmp/perf.debug.ZTu/.build-id/5a/../../root/linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf
failed: file 
/tmp/perf.debug.ZTu/.build-id/5a/../../root/linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf
 does not exist
test child finished with -1
 end 
build id cache operations: FAILED!

The failing test is when trying to add pe-file.exe to
build id cache.

Perf buildid-cache can be used to add/remove/manage
files from the build-id cache. "-a" option is used to
add a file to the build-id cache.

Simple command to do so for a PE exe file:
 # ls -ltr tests/pe-file.exe
 -rw-r--r--. 1 root root 75595 Jan 10 23:35 tests/pe-file.exe
 The file is in home directory.

 # mkdir  /tmp/perf.debug.TeY1
 # perf --buildid-dir /tmp/perf.debug.TeY1 buildid-cache -v
   -a tests/pe-file.exe

The above will create ".build-id" folder in build id
directory, which is /tmp/perf.debug.TeY1. Also adds file
to this folder under build id. Example:

 # ls -ltr /tmp/perf.debug.TeY1/.build-id/5a/0fd882b53084224ba47b624c55a469/
 total 76
 -rw-r--r--. 1 root root 0 Jan 11 00:38 probes
 -rwxr-xr-x. 1 root root 75595 Jan 11 00:38 elf

We can see in the results that file mode for original
file and file in build id directory is different. ie,
build id file has executable permission whereas original
file doesn’t have.

The code path and function ( build_id_cache__add ) to
add file to cache is in "util/build-id.c". In
build_id_cache__add() function, it first attempts to link
the original file to destination cache folder. If linking
the file fails ( which can happen if the destination and
source is on a different mount points ), it will copy the
file to destination. Here copyfile() routine explicitly uses
mode as "755" and hence file in the destination will have
executable permission.

Code snippet:

 if (link(realname, filename) && errno != EEXIST &&
   copyfile(name, filename))

Strace logs:

172285 link("/home//linux/tools/perf/tests/pe-file.exe", 
"/tmp/perf.debug.TeY1/home//linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf")
 = -1 EXDEV (Invalid cross-device link)
172285 newfstatat(AT_FDCWD, "tests/pe-file.exe", {st_mode=S_IFREG|0644, 
st_size=75595, ...}, 0) = 0
172285 openat(AT_FDCWD, 
"/tmp/perf.debug.TeY1/home//linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/.elf.KbAnsl",
 O_RDWR|O_CREAT|O_EXCL, 0600) = 3
172285 fchmod(3, 0755)  = 0
172285 openat(AT_FDCWD, "tests/pe-file.exe", O_RDONLY) = 4
172285 mmap(NULL, 75595, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7fffa5cd
172285 pwrite64(3, 
"MZ\220\0\3\0\0\0\4\0\0\0\377\377\0\0\270\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 
75595, 0) = 75595

Whereas if the link succeeds, it succeeds in the first
attempt itself and the file in the build-id dir will
have same permission as original file.

Example, above uses /tmp. Instead if we use
"--buildid-dir /home/build", linking will work here
since mount points are same. Hence the destination file
will not have executable permission.

Since the testcase "tests/shell/buildid.sh" always looks
for executable file, test fails in powerpc environment
when test is run from /root.

The patch adds a change in build_id_cache__add to use
copyfile_mode which also passes the file’s original mode as
argument. This way the destination file mode also will
be same as original file.

Signed-off-by: Athira Rajeev 
---
 tools/perf/util/build-id.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index a839b30c981b..ea9c083ab1e3 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -715,9 +715,13 @@ build_id_cache__add(const char *sbuild_id, const char 
*name, const char *realnam
} else if (nsi && nsinfo__need_setns(nsi)) {
if (copyfile_ns(name, filename, nsi))
goto out_free;
-   } else if (link(realname, filename) && errno != EEXIST &&
-   copyfile(name, filename))
-   goto out_free;
+   } else if (link(realname, filename) && errno != EEXIST) {
+   struct stat f_stat;
+
+   if (!(stat(name, &f_stat) < 0) &&
+   copyfile_mode(name, filename, 
f_stat.st_mode))
+   goto out_free;
+   }
}
 
/* Some binaries are stripped, but have .debug files with their symbol
-- 
2.31.1



[PATCH 2/2] tools/perf/tests: Fix build id test check for PE file

2023-01-15 Thread Athira Rajeev
Perf test "build id cache operations" fails for PE
executable.  Logs below from powerpc system.
Same is observed on x86 as well.

<<>>
Adding 5a0fd882b53084224ba47b624c55a469 ./tests/shell/../pe-file.exe: Ok
build id: 5a0fd882b53084224ba47b624c55a469
link: /tmp/perf.debug.w0V/.build-id/5a/0fd882b53084224ba47b624c55a469
file: 
/tmp/perf.debug.w0V/.build-id/5a/../../root//linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf
failed: file 
/tmp/perf.debug.w0V/.build-id/5a/../../root//linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf
 does not exist
test child finished with -1
 end 
build id cache operations: FAILED!
<<>>

The test tries to do:

<<>>
mkdir /tmp/perf.debug.TeY1
perf --buildid-dir /tmp/perf.debug.TeY1 buildid-cache -v -a 
./tests/shell/../pe-file.exe
<<>>

The option "--buildid-dir" sets the build id cache
directory as /tmp/perf.debug.TeY1. The option given
to buildid-cahe, ie "-a ./tests/shell/../pe-file.exe",
is to add the pe-file.exe to the cache. The testcase,
sets buildid-dir and adds the file: pe-file.exe to build
id cache. To check if the command is run successfully,
"check" function looks for presence of the file in buildid
cache directory. But the check here expects the added
file to be executable. Snippet below:

<<>>
if [ ! -x $file ]; then
echo "failed: file ${file} does not exist"
exit 1
fi
<<>>

Buildid test is done for sha1 binary, md5 binary and also
for PE file. The firt two binaries are created at runtime
by compiling with "--build-id" option and hence the check
for sha1/md5 test should use [ ! -x ]. But in case of PE
file, the permission for this input file is rw-r--r--
Hence the file added to build id cache has same permissoin

Original file:
ls tests/pe-file.exe | xargs stat --printf "%n %A \n"
tests/pe-file.exe -rw-r--r--

buildid cache file:

ls 
/tmp/perf.debug.w0V/.build-id/5a/../../root//linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf
 | xargs stat --printf "%n %A \n"
/tmp/perf.debug.w0V/.build-id/5a/../../root//linux/tools/perf/tests/pe-file.exe/5a0fd882b53084224ba47b624c55a469/elf
 -rw-r--r--

Fix the test to match with the permission of original file in
case of FE file. ie if the "tests/pe-file.exe" file is not
having exec permission, just check for existence of the buildid
file using [ ! -e  ]

Signed-off-by: Athira Rajeev 
---
 tools/perf/tests/shell/buildid.sh | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/buildid.sh 
b/tools/perf/tests/shell/buildid.sh
index f05670d1e39e..22e5b2225abe 100755
--- a/tools/perf/tests/shell/buildid.sh
+++ b/tools/perf/tests/shell/buildid.sh
@@ -77,7 +77,20 @@ check()
file=${build_id_dir}/.build-id/${id:0:2}/`readlink ${link}`/elf
echo "file: ${file}"
 
-   if [ ! -x $file ]; then
+   # Check for file permission of orginal file
+   # in case of pe-file.exe file
+   echo $1 | grep ".exe"
+   if [ $? -eq 0 ]; then
+   if [ -x $1  -a ! -x $file ]; then
+   echo "failed: file ${file} executable does not exist"
+   exit 1
+   fi
+
+   if [ ! -x $file -a ! -e $file ]; then
+   echo "failed: file ${file} does not exist"
+   exit 1
+   fi
+   elif [ ! -x $file ]; then
echo "failed: file ${file} does not exist"
exit 1
fi
-- 
2.31.1



[PATCH] powerpc/imc-pmu: use GFP_ATOMIC under spin_lock()

2023-01-15 Thread Yang Yingliang
After commit 76d588dddc45 ("powerpc/imc-pmu: Fix use of mutex
in IRQs disabled section"), init_nest_pmu_ref() is called under
spin_lock(), use GFP_ATOMIC while calling kcalloc().

Fixes: 76d588dddc45 ("powerpc/imc-pmu: Fix use of mutex in IRQs disabled 
section")
Signed-off-by: Yang Yingliang 
---
 arch/powerpc/perf/imc-pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c
index 100e97daf76b..a9094835e648 100644
--- a/arch/powerpc/perf/imc-pmu.c
+++ b/arch/powerpc/perf/imc-pmu.c
@@ -1521,7 +1521,7 @@ static int init_nest_pmu_ref(void)
int nid, i, cpu;
 
nest_imc_refc = kcalloc(num_possible_nodes(), sizeof(*nest_imc_refc),
-   GFP_KERNEL);
+   GFP_ATOMIC);
 
if (!nest_imc_refc)
return -ENOMEM;
-- 
2.25.1



Re: [PATCH -next] powerpc/64s/hash: change stress_hpt_timer_fn to static

2023-01-15 Thread Michael Ellerman
On Wed, 28 Dec 2022 17:36:03 +0800, Yang Yingliang wrote:
> stress_hpt_timer_fn is only used in hash_utils.c now,
> change it to static.
> 
> 

Applied to powerpc/fixes.

[1/1] powerpc/64s/hash: change stress_hpt_timer_fn to static
  https://git.kernel.org/powerpc/c/f12cd06109f47c2fb4b23a45ab55404c47ef7fae

cheers


Re: [PATCH] powerpc/rtas: upgrade internal arch spinlocks

2023-01-15 Thread Michael Ellerman
Nathan Lynch  writes:
> Laurent Dufour  writes:
>> On 10/01/2023 05:42:55, Nathan Lynch wrote:
>>> --- a/arch/powerpc/include/asm/rtas-types.h
>>> +++ b/arch/powerpc/include/asm/rtas-types.h
>>> @@ -18,7 +18,7 @@ struct rtas_t {
>>> unsigned long entry;/* physical address pointer */
>>> unsigned long base; /* physical address pointer */
>>> unsigned long size;
>>> -   arch_spinlock_t lock;
>>> +   raw_spinlock_t lock;
>>> struct rtas_args args;
>>> struct device_node *dev;/* virtual address pointer */
>>>  };
>>> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
>>> index deded51a7978..a834726f18e3 100644
>>> --- a/arch/powerpc/kernel/rtas.c
>>> +++ b/arch/powerpc/kernel/rtas.c
>>> @@ -61,7 +61,7 @@ static inline void do_enter_rtas(unsigned long args)
>>>  }
>>>  
>>>  struct rtas_t rtas = {
>>> -   .lock = __ARCH_SPIN_LOCK_UNLOCKED
>>> +   .lock = __RAW_SPIN_LOCK_UNLOCKED(rtas.lock),
>>>  };
>>>  EXPORT_SYMBOL(rtas);
>>
>> This is not the scope of this patch, but the RTAS's lock is externalized
>> through the structure rtas_t, while it is only used in that file.
>>
>> I think, this would be good, in case of future change about that lock, and
>> in order to not break KABI, to move it out of that structure, and to define
>> it statically in that file.
>
> Thanks for pointing this out.
>
> /* rtas-types.h */
> struct rtas_t {
>   unsigned long entry;/* physical address pointer */
>   unsigned long base; /* physical address pointer */
>   unsigned long size;
>   raw_spinlock_t lock;
>   struct rtas_args args;
>   struct device_node *dev;/* virtual address pointer */
> };
>
> /* rtas.h */
> extern struct rtas_t rtas;
>
> There's C and asm code outside of rtas.c that accesses rtas.entry,
> rtas.base, rtas.size, and rtas.dev. But as you say, rtas.lock is used
> only in rtas.c, and it's hard to imagine any legitimate external
> use. This applies to the args member as well, since accesses must occur
> under the lock.
>
> Making the lock and args private to rtas.c seems desirable on its own,
> so I think that should be done first as a cleanup, followed by the
> riskier arch -> raw lock conversion.

I don't see any reason why `rtas` is exported at all.

There might have been in the past, but I don't see one any more.

So I'd be happy if we removed the EXPORT entirely. If it breaks
something we can always put it back.

cheers


Re: [PATCH v2 1/2] powerpc/ps3: Change updateboltedpp panic to info

2023-01-15 Thread Michael Ellerman
Geoff Levand  writes:
> On 1/9/23 09:41, Christophe Leroy wrote:
>> 
>> 
>> Le 03/01/2023 à 18:51, Geoff Levand a écrit :
>>> Commit fdacae8a84024474afff234bdd1dbe19ad597a10 (powerpc: Activate
>>> CONFIG_STRICT_KERNEL_RWX by default) causes ps3_hpte_updateboltedpp()
>>> to be called.  Change the panic statment in ps3_hpte_updateboltedpp()
>>> to a pr_info statement so that bootup can continue.
>> 
>> But if I understand correctly, it means that CONFIG_STRICT_KERNEL_RWX 
>> won't work then.
>> 
>> So, shouldn't we keep the panic and forbid CONFIG_STRICT_KERNEL_RWX on PS3 ?
>
> mmu_hash_ops.updateboltedpp returns void, so I can't return an error code to
> indicate the feature is not supported.

We could change that in the medium term.

> I could do something like this in arch/powerpc/Kconfig:
>
> -   select ARCH_HAS_STRICT_KERNEL_RWX   if (PPC_BOOK3S || PPC_8xx || 
> 40x) && !HIBERNATION
> +   select ARCH_HAS_STRICT_KERNEL_RWX   if (PPC_BOOK3S || PPC_8xx || 
> 40x) && !PPC_PS3 && !HIBERNATION
>
> But then the ppc64_defconfig would be built without STRICT_KERNEL_RWX.

Yeah that would be a pity.

We could do the above and disable PS3 in ppc64_defconfig, allowing
ppc64_defconfig to still have STRICT_KERNEL_RWX.

I assume actual PS3 users would use a ps3_defconfig anyway right?

Relatedly are there any actual PS3 users left? ;)

> I could do this in ps3_defconfig:
>
> +# CONFIG_STRICT_KERNEL_RWX is not set
> +# CONFIG_STRICT_MODULE_RWX is not set
>
> But I don't like that way because it seems too easy for users to not add those
> into a custom kernel config, and then they need to figure out what to do after
> their kernel panics on startup.

Yep agreed.

> What other 'clean' way is there?

If we want to have a multi-platform kernel image that can boot on PS3
and other platforms, and have strict kernel RWX, then we need some
runtime logic to deal with that.

I'd rather not do that though, because it adds complexity to deal with a
pretty obscure corner case, and I suspect no one really boots a
ppc64_defconfig on actual PS3 hardware these days.

So my preference is we disable PS3 in ppc64_defconfig, and make PS3
incompatible with STRICT_KERNEL_RWX.

cheers


[PATCH] x86/xen: Set MSI_FLAG_PCI_MSIX support in Xen MSI domain

2023-01-15 Thread David Woodhouse
The Xen MSI → PIRQ magic does support MSI-X, so advertise it.

(In fact it's better off with MSI-X than MSI, because it's actually
broken by design for 32-bit MSI, since it puts the high bits of the
PIRQ# into the high 32 bits of the MSI message address, instead of the
Extended Destination ID field which is in bits 4-11.

Strictly speaking, this really fixes a much older commit 2e4386eba0c0
("x86/xen: Wrap XEN MSI management into irqdomain") which failed to set
the flag. But that never really mattered until __pci_enable_msix_range()
started to check and bail out early. So in 6.2-rc we see failures e.g.
to bring up networking on an Amazon EC2 m4.16xlarge instance:

[   41.498694] ena :00:03.0 (unnamed net_device) (uninitialized): Failed to 
enable MSI-X. irq_cnt -524
[   41.498705] ena :00:03.0: Can not reserve msix vectors
[   41.498712] ena :00:03.0: Failed to enable and set the admin interrupts

Side note: This is the first bug found, and first patch tested, by running
Xen guests under QEMU/KVM instead of running under actual Xen.

Fixes: 99f3d2797657 ("PCI/MSI: Reject MSI-X early")
Signed-off-by: David Woodhouse 
---
 arch/x86/pci/xen.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index b94f727251b6..790550479831 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -433,6 +433,7 @@ static struct msi_domain_ops xen_pci_msi_domain_ops = {
 };
 
 static struct msi_domain_info xen_pci_msi_domain_info = {
+   .flags  = MSI_FLAG_PCI_MSIX,
.ops= &xen_pci_msi_domain_ops,
 };
 
-- 
2.34.1




smime.p7s
Description: S/MIME cryptographic signature


[PATCH v1 1/1] hvc_console: Allow backends to set I/O buffer size

2023-01-15 Thread Geoff Levand
To allow HVC backends to set the I/O buffer sizes to values that are most
efficient for the backend, change the macro definitions where the buffer sizes
are set to be conditional on whether or not the macros are already defined.
Also, rename the macros from N_OUTBUF to HVC_N_OUBUF and from N_INBUF to
HVC_N_INBUF.

Typical usage in the backend source file would be:

  #define HVC_N_OUTBUF 32
  #define HVC_N_INBUF 32
  #include "hvc_console.h"

Signed-off-by: Geoff Levand 
---

Hi,

With this patch the buffer sizes are set by defining preprocessor macros before
including the hvc_console.h header file.  Another way would be to have Kconfig
options for the buffer sizes.  Since the optimal buffer size is so closely tied
to the backend implementation I thought that using these preprocessor macros
would be the better way.

-Geoff

The following changes since commit 5dc4c995db9eb45f6373a956eb1f69460e69e6d4:

  Linux 6.2-rc4 (2023-01-15 09:22:43 -0600)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-linux.git 
for-merge-hvc-v1

for you to fetch changes up to 8f3cd1e0589f134380f80a1f551c8232ed0bc1f2:

  hvc_console: Allow backends to set I/O buffer size (2023-01-15 09:36:22 -0800)


 drivers/tty/hvc/hvc_console.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index a683e21df19c..f7809d19e2cd 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -42,12 +42,15 @@
 #define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
 
 /*
- * These sizes are most efficient for vio, because they are the
- * native transfer size. We could make them selectable in the
- * future to better deal with backends that want other buffer sizes.
+ * These default sizes are most efficient for vio, because they are
+ * the native transfer size.
  */
-#define N_OUTBUF   16
-#define N_INBUF16
+#if !defined(HVC_N_OUTBUF)
+# define HVC_N_OUTBUF  16
+#endif
+#if !defined(HVC_N_INBUF)
+# define HVC_N_INBUF   16
+#endif
 
 #define __ALIGNED__ __attribute__((__aligned__(L1_CACHE_BYTES)))
 
@@ -151,7 +154,7 @@ static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
 static void hvc_console_print(struct console *co, const char *b,
  unsigned count)
 {
-   char c[N_OUTBUF] __ALIGNED__;
+   char c[HVC_N_OUTBUF] __ALIGNED__;
unsigned i = 0, n = 0;
int r, donecr = 0, index = co->index;
 
@@ -633,7 +636,7 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep)
 {
struct tty_struct *tty;
int i, n, count, poll_mask = 0;
-   char buf[N_INBUF] __ALIGNED__;
+   char buf[HVC_N_INBUF] __ALIGNED__;
unsigned long flags;
int read_total = 0;
int written_total = 0;
@@ -674,7 +677,7 @@ static int __hvc_poll(struct hvc_struct *hp, bool may_sleep)
 
  read_again:
/* Read data if any */
-   count = tty_buffer_request_room(&hp->port, N_INBUF);
+   count = tty_buffer_request_room(&hp->port, HVC_N_INBUF);
 
/* If flip is full, just reschedule a later read */
if (count == 0) {
-- 
2.34.1



[PATCH v7 8/8] powerpc/kexec: add crash memory hotplug support

2023-01-15 Thread Sourabh Jain
Extend PowerPC arch crash hotplug handler to support memory hotplug
events. Since elfcorehdr is used to exchange the memory info between the
kernels hence it needs to be recreated to reflect the changes due to
memory hotplug events.

The way memory hotplug events are handled on PowerPC and the notifier call
chain used in generic code to trigger the arch crash handler, the process
to recreate the elfcorehdr is different for memory add and remove events.

In the hot remove case, the memory region is first marked offline then the
notifier call chain is triggered (same is used to initiate arch crash
hotplug handler) and at last the memblock structure is updated. Whereas
in the hot add case, memblock structure is updated before the notifier
call chain is triggered.

On PowerPC, memblock structure is used to identify the memory ranges for
elfcorehdr. In case of memory hot remove the memblock structure is updated
after the arch crash hotplug handler is triggered, hence an additional
step is taken to ensure that memory ranges used to build elfcorehdr do
not include hot removed memory. Whereas no such extra steps are needed
for the hot add case because memblock structure is updated before the
arch crash hotplug handler is triggered.

The hot removed memory is explicitly removed from the memory ranges list
before creating elfcorehdr for the hot remove case.

To accommodate a growing number of memory regions, elfcorehdr is built
with additional buffer space to hold max memory regions.

The changes done here will also work for the kexec_load system call given
that the kexec tool builds the elfcoredhr with additional space to
accommodate future memory regions as it is done for kexec_file_load
system call.

Signed-off-by: Sourabh Jain 
---
 arch/powerpc/include/asm/kexec_ranges.h |  1 +
 arch/powerpc/kexec/core_64.c| 59 ++--
 arch/powerpc/kexec/file_load_64.c   | 12 -
 arch/powerpc/kexec/ranges.c | 60 +
 4 files changed, 127 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec_ranges.h 
b/arch/powerpc/include/asm/kexec_ranges.h
index f83866a19e870..802abf580cf0f 100644
--- a/arch/powerpc/include/asm/kexec_ranges.h
+++ b/arch/powerpc/include/asm/kexec_ranges.h
@@ -7,6 +7,7 @@
 void sort_memory_ranges(struct crash_mem *mrngs, bool merge);
 struct crash_mem *realloc_mem_ranges(struct crash_mem **mem_ranges);
 int add_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size);
+int remove_mem_range(struct crash_mem **mem_ranges, u64 base, u64 size);
 int add_tce_mem_ranges(struct crash_mem **mem_ranges);
 int add_initrd_mem_range(struct crash_mem **mem_ranges);
 #ifdef CONFIG_PPC_64S_HASH_MMU
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 1f807b29db93f..0516fb5dd543f 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -571,6 +572,60 @@ int update_cpus_node(void *fdt)
 }
 
 #if defined(CONFIG_CRASH_HOTPLUG)
+int update_crash_elfcorehdr(struct kimage *image, unsigned int hp_action, void 
*arg)
+{
+   int ret;
+   struct crash_mem *cmem = NULL;
+   struct kexec_segment *ksegment;
+   unsigned long elfsz;
+   void *elfbuf = NULL;
+   void *mem;
+   unsigned long memsz;
+   char *ptr;
+   struct memory_notify *mn = (struct memory_notify *) arg;
+   unsigned long base_addr;
+   unsigned long size;
+
+   ksegment = &image->segment[image->elfcorehdr_index];
+   mem = (void *) ksegment->mem;
+   memsz = ksegment->memsz;
+
+   ret = get_crash_memory_ranges(&cmem);
+   if (ret) {
+   pr_err("crash hp: failed to get crash mem range\n");
+   return -1;
+   }
+
+   if (hp_action == KEXEC_CRASH_HP_REMOVE_MEMORY) {
+   base_addr = PFN_PHYS(mn->start_pfn);
+   size = mn->nr_pages * PAGE_SIZE;
+   ret = remove_mem_range(&cmem, base_addr, size);
+   if (ret)
+   return -1;
+   }
+
+   ret = crash_prepare_elf64_headers(image, cmem, false, &elfbuf, &elfsz);
+   if (ret) {
+   pr_err("crash hp: failed to prepare elf header\n");
+   return -1;
+   }
+
+   if (elfsz > memsz) {
+   pr_err("crash hp: updated crash elfcorehdr elfsz %lu > memsz 
%lu", elfsz, memsz);
+   return -1;
+   }
+
+   ptr = __va(mem);
+   if (ptr) {
+   xchg(&kexec_crash_image, NULL);
+   memcpy((void *)ptr, elfbuf, elfsz);
+   xchg(&kexec_crash_image, image);
+   }
+
+   vfree(elfbuf);
+   return 0;
+}
+
 /**
  * arch_crash_hotplug_handler() - Handle hotplug kexec segements changes FDT, 
elfcorehdr
  * @image: the active struct kimage
@@ -588,9 +643,8 @@ void arch_crash_handle_hotplug_event(struct kimage *image, 
unsigned int hp_actio
if (h

[PATCH v7 7/8] crash: forward memory_notify args to arch crash hotplug handler

2023-01-15 Thread Sourabh Jain
The way memory hot remove is handled on PowerPC, it is hard to update
the elfcorehdr without memory_notify args.

On PowePC memblock data structure is used to prepare elfcorehdr for kdump.
Since the notifier used for memory hotplug crash handler get initiated
before the memblock data structure update happens (as depicted below),
the newly prepared elfcorehdr still holds the old memory regions. So if
the system crash with obsolete elfcorehdr, makedumpfile failed to collect
vmcore.

Sequence of actions done on PowerPC to serve the memory hot remove:

 Initiate memory hot remove
  |
  v
 offline pages
  |
  v
 initiate memory notify call chain
 for MEM_OFFLINE event.
 (same is used for crash update)
  |
  v
 prepare new elfcorehdr for kdump using
 memblock data structure
  |
  v
 update memblock data structure

How passing memory_notify to arch crash hotplug handler will help?

memory_notify holds the start PFN and page count, with that base address
and size of hot unplugged memory can calculated and same can be use to
avoid hot unplugged memory region to get added in the elfcorehdr.

Signed-off-by: Sourabh Jain 
---
 arch/powerpc/include/asm/kexec.h |  2 +-
 arch/powerpc/kexec/core_64.c |  3 ++-
 arch/x86/include/asm/kexec.h |  3 ++-
 arch/x86/kernel/crash.c  |  4 +++-
 include/linux/kexec.h|  6 +-
 kernel/crash_core.c  | 14 +++---
 6 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index e7cd4fd2becf5..743056f0bedf2 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -107,7 +107,7 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges);
 int machine_kexec_post_load(struct kimage *image);
 #define machine_kexec_post_load machine_kexec_post_load
 
-void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action);
+void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action, void *arg);
 #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
 
 #endif
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 7748b633c20fa..1f807b29db93f 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -575,11 +575,12 @@ int update_cpus_node(void *fdt)
  * arch_crash_hotplug_handler() - Handle hotplug kexec segements changes FDT, 
elfcorehdr
  * @image: the active struct kimage
  * @hp_action: the hot un/plug action being handled
+ * @arg: struct memory_notify data handler
  *
  * To accurately reflect CPU hot un/plug changes, the FDT must be updated with 
the
  * new list of CPUs.
  */
-void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action)
+void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action, void *arg)
 {
void *fdt;
 
diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
index ec33a592a2ddd..171edb8167a12 100644
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -213,7 +213,8 @@ extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss;
 extern void kdump_nmi_shootdown_cpus(void);
 
 #ifdef CONFIG_CRASH_HOTPLUG
-void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action);
+void arch_crash_handle_hotplug_event(struct kimage *image,
+unsigned int hp_action, void *arg);
 #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 0026c5ad828d7..6bdfefebdd27c 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -466,12 +466,14 @@ int crash_load_segments(struct kimage *image)
  * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes
  * @image: the active struct kimage
  * @hp_action: the hot un/plug action being handled
+ * @arg: struct memory_notify data handler
  *
  * To accurately reflect hot un/plug changes, the new elfcorehdr
  * is prepared in a kernel buffer, and then it is written on top
  * of the existing/old elfcorehdr.
  */
-void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action)
+void arch_crash_handle_hotplug_event(struct kimage *image,
+unsigned int hp_action, void *arg)
 {
void *elfbuf = NULL, *old_elfcorehdr;
unsigned long mem, memsz;
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index ea8ff85b0b436..f640d3c30f41c 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -509,7 +509,11 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, 
unsigned int pages) {
 #endif
 
 #ifndef arch_crash_handle_hotplug_event
-static inline void arch_crash_handle_hotplug_event(struct kimage *image, 
unsigned int hp_action) { }
+static inline void arch_crash_handle_hotpl

[PATCH v7 6/8] powerpc/crash: add crash CPU hotplug support

2023-01-15 Thread Sourabh Jain
Introduce powerpc crash hotplug handler to update the necessary kexec
segments on CPU/Memory hotplug events. A common crash hotplug handler is
triggered from generic infrastructure for both CPU/Memory hot un/plugged
events but in this patch, only CPU hot un/plugged events are introduced.
The memory hotplug support is added in upcoming patches.

The elfcorehdr segment is used to exchange the CPU and other dump related
information between the kernels. Ideally, the elfcorehdr segment needs to
be recreated on CPU hotplug events to reflect the changes. But on PowerPC
elfcorehdr is built with all possible CPUs instead of just online CPUs
hence no elfcorehdr segment update/recreation is needed.

In addition to elfcorehdr there is one more kexec segment that holds CPU
data FDT (Flattened Device Tree). To boot the PowerPC kernel the crashing
CPU has to be part of the FDT segment. If the kdump kernel doesn't find
the crashing CPU in the FDT segment, it fails to boot.

The only action needed on PowerPC to handle the crash CPU hotplug event
is to add hot added CPUs in the FDT segment to avoid kdump kernel boot
failure in case the system crashes on hot added CPU.

So for the CPU hot add events, the FDT segment is updated with hot added
CPU and Since there is no need to remove the hot unplugged CPUs from the
FDT segment hence no action taken on CPU hot remove event in PowerPC arch
crash hotplug handler.

To accommodate a growing number of CPUs, FDT is built with additional
buffer space to ensure that it can hold all possible CPUs.

The changes done here will also work for kexec_load system call given
that the kexec tool builds the FDT segment with additional space to
accommodate all possible CPUs as it is done for kexec_file_load system
call in the kernel.

Since memory crash hotplug support is not there yet the crash hotplug
handler simply warns the user and returns.

Signed-off-by: Sourabh Jain 
---
 arch/powerpc/include/asm/kexec.h |  4 ++
 arch/powerpc/kexec/core_64.c | 43 
 arch/powerpc/kexec/elf_64.c  | 69 +++-
 3 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 5a322c1737661..e7cd4fd2becf5 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -106,6 +106,10 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges);
 #if defined(CONFIG_CRASH_HOTPLUG)
 int machine_kexec_post_load(struct kimage *image);
 #define machine_kexec_post_load machine_kexec_post_load
+
+void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action);
+#define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
+
 #endif
 #endif
 
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 3d4fe1aa6f761..7748b633c20fa 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -570,6 +570,49 @@ int update_cpus_node(void *fdt)
return ret;
 }
 
+#if defined(CONFIG_CRASH_HOTPLUG)
+/**
+ * arch_crash_hotplug_handler() - Handle hotplug kexec segements changes FDT, 
elfcorehdr
+ * @image: the active struct kimage
+ * @hp_action: the hot un/plug action being handled
+ *
+ * To accurately reflect CPU hot un/plug changes, the FDT must be updated with 
the
+ * new list of CPUs.
+ */
+void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action)
+{
+   void *fdt;
+
+   /* No action needed for CPU hot-unplug */
+   if (hp_action == KEXEC_CRASH_HP_REMOVE_CPU)
+   return;
+
+   /* crash update on memory hotplug is not support yet */
+   if (hp_action == KEXEC_CRASH_HP_REMOVE_MEMORY || hp_action == 
KEXEC_CRASH_HP_ADD_MEMORY) {
+   pr_info_once("crash hp: crash update is not supported with 
memory hotplug\n");
+   return;
+   }
+
+   /* Must have valid FDT index */
+   if (image->arch.fdt_index < 0) {
+   pr_err("crash hp: unable to locate FDT segment");
+   return;
+   }
+
+   fdt = __va((void *)image->segment[image->arch.fdt_index].mem);
+
+   /* Temporarily invalidate the crash image while it is replaced */
+   xchg(&kexec_crash_image, NULL);
+
+   /* update FDT to refelect changes to CPU resrouces */
+   if (update_cpus_node(fdt))
+   pr_err("crash hp: failed to update crash FDT");
+
+   /* The crash image is now valid once again */
+   xchg(&kexec_crash_image, image);
+}
+#endif
+
 #ifdef CONFIG_PPC_64S_HASH_MMU
 /* Values we need to export to the second kernel via the device tree. */
 static unsigned long htab_base;
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index 2a17f171661f1..c9dfd6d7660ed 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -24,6 +24,64 @@
 #include 
 #include 
 
+#include 
+
+#if defined(CONFIG_CRASH_HOTPLUG)
+/**
+ * get_cpu_node_sz() - Calculate the space needed t

[PATCH v7 5/8] crash: pass hotplug action type to arch crash hotplug handler

2023-01-15 Thread Sourabh Jain
On PowerPC, the crash update action for CPU and Memory hotplug events
is not the same. Since arch_crash_handle_hotplug_event is a common
crash hotplug handler for both CPU and Memory hot un/plug events,
it is hard to differentiate which hotplug event triggered the arch
crash hotplug handler and decide the crash update action accordingly.

Pass the hotplug action type to arch specific crash hotplug handler
so that corresponding crash update action can be taken based on the
hotplug action type.

Signed-off-by: Sourabh Jain 
---
 arch/x86/include/asm/kexec.h | 2 +-
 arch/x86/kernel/crash.c  | 3 ++-
 include/linux/kexec.h| 2 +-
 kernel/crash_core.c  | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
index 1bc852ce347d4..ec33a592a2ddd 100644
--- a/arch/x86/include/asm/kexec.h
+++ b/arch/x86/include/asm/kexec.h
@@ -213,7 +213,7 @@ extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss;
 extern void kdump_nmi_shootdown_cpus(void);
 
 #ifdef CONFIG_CRASH_HOTPLUG
-void arch_crash_handle_hotplug_event(struct kimage *image);
+void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action);
 #define arch_crash_handle_hotplug_event arch_crash_handle_hotplug_event
 
 #ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 5186df48ce6c6..0026c5ad828d7 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -465,12 +465,13 @@ int crash_load_segments(struct kimage *image)
 /**
  * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes
  * @image: the active struct kimage
+ * @hp_action: the hot un/plug action being handled
  *
  * To accurately reflect hot un/plug changes, the new elfcorehdr
  * is prepared in a kernel buffer, and then it is written on top
  * of the existing/old elfcorehdr.
  */
-void arch_crash_handle_hotplug_event(struct kimage *image)
+void arch_crash_handle_hotplug_event(struct kimage *image, unsigned int 
hp_action)
 {
void *elfbuf = NULL, *old_elfcorehdr;
unsigned long mem, memsz;
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 0b1ad1ac06e37..ea8ff85b0b436 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -509,7 +509,7 @@ static inline void arch_kexec_pre_free_pages(void *vaddr, 
unsigned int pages) {
 #endif
 
 #ifndef arch_crash_handle_hotplug_event
-static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
+static inline void arch_crash_handle_hotplug_event(struct kimage *image, 
unsigned int hp_action) { }
 #endif
 
 #ifndef crash_hotplug_cpu_support
diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 19f987b3851e8..bdf8c363a90aa 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -707,7 +707,7 @@ static void handle_hotplug_event(unsigned int hp_action, 
unsigned int cpu)
cpu : KEXEC_CRASH_HP_INVALID_CPU;
 
/* Now invoke arch-specific update handler */
-   arch_crash_handle_hotplug_event(image);
+   arch_crash_handle_hotplug_event(image, hp_action);
 
/* No longer handling a hotplug event */
image->hotplug_event = false;
-- 
2.39.0



[PATCH v7 4/8] crash: add phdr for possible CPUs in elfcorehdr

2023-01-15 Thread Sourabh Jain
On architectures like PowerPC the crash notes are available for all
possible CPUs. So let's populate the elfcorehdr for all possible
CPUs having crash notes to avoid updating elfcorehdr during in-kernel
crash update on CPU hotplug events.

The similar technique is used in kexec-tool for kexec_load case.

Signed-off-by: Sourabh Jain 
---
 kernel/crash_core.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 910d377ea317e..19f987b3851e8 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -364,8 +364,8 @@ int crash_prepare_elf64_headers(struct kimage *image, 
struct crash_mem *mem,
ehdr->e_ehsize = sizeof(Elf64_Ehdr);
ehdr->e_phentsize = sizeof(Elf64_Phdr);
 
-   /* Prepare one phdr of type PT_NOTE for each present CPU */
-   for_each_present_cpu(cpu) {
+   /* Prepare one phdr of type PT_NOTE for possible CPU with crash note. */
+   for_each_possible_cpu(cpu) {
 #ifdef CONFIG_CRASH_HOTPLUG
if (IS_ENABLED(CONFIG_HOTPLUG_CPU)) {
/* Skip the soon-to-be offlined cpu */
@@ -373,8 +373,11 @@ int crash_prepare_elf64_headers(struct kimage *image, 
struct crash_mem *mem,
continue;
}
 #endif
-   phdr->p_type = PT_NOTE;
notes_addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpu));
+   if (!notes_addr)
+   continue;
+
+   phdr->p_type = PT_NOTE;
phdr->p_offset = phdr->p_paddr = notes_addr;
phdr->p_filesz = phdr->p_memsz = sizeof(note_buf_t);
(ehdr->e_phnum)++;
-- 
2.39.0



[PATCH v7 3/8] powerpc/crash: update kimage_arch struct

2023-01-15 Thread Sourabh Jain
Add a new member "fdt_index" to kimage_arch struct to hold the index of
the FDT (Flattened Device Tree) segment in the kexec segment array.

Having direct access to FDT segment will help arch crash hotplug handler
to avoid looping kexec segment array to identify the FDT segment index
for every FDT update on hotplug events.

The fdt_index is initialized during the kexec load for both kexec_load and
kexec_file_load system call.

Signed-off-by: Sourabh Jain 
---
 arch/powerpc/include/asm/kexec.h  |  7 +++
 arch/powerpc/kexec/core_64.c  | 27 +++
 arch/powerpc/kexec/elf_64.c   |  6 ++
 arch/powerpc/kexec/file_load_64.c |  5 +
 4 files changed, 45 insertions(+)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 8090ad7d97d9d..5a322c1737661 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -103,6 +103,10 @@ void kexec_copy_flush(struct kimage *image);
 struct crash_mem;
 int update_cpus_node(void *fdt);
 int get_crash_memory_ranges(struct crash_mem **mem_ranges);
+#if defined(CONFIG_CRASH_HOTPLUG)
+int machine_kexec_post_load(struct kimage *image);
+#define machine_kexec_post_load machine_kexec_post_load
+#endif
 #endif
 
 #if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_PPC_RTAS)
@@ -118,6 +122,9 @@ extern const struct kexec_file_ops kexec_elf64_ops;
 struct kimage_arch {
struct crash_mem *exclude_ranges;
 
+#if defined(CONFIG_CRASH_HOTPLUG)
+   int fdt_index;
+#endif
unsigned long backup_start;
void *backup_buf;
void *fdt;
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 0b292f93a74cc..3d4fe1aa6f761 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -77,6 +77,33 @@ int machine_kexec_prepare(struct kimage *image)
return 0;
 }
 
+#if defined(CONFIG_CRASH_HOTPLUG)
+int machine_kexec_post_load(struct kimage *kimage)
+{
+   int i;
+   void *ptr;
+   unsigned long mem;
+
+   /* Mark fdt_index invalid */
+   kimage->arch.fdt_index = -1;
+
+   if (kimage->type != KEXEC_TYPE_CRASH)
+   return 0;
+
+   for (i = 0; i < kimage->nr_segments; i++) {
+   mem = kimage->segment[i].mem;
+   ptr = __va(mem);
+
+   if (ptr && fdt_magic(ptr) == FDT_MAGIC) {
+   kimage->arch.fdt_index = i;
+   break;
+   }
+   }
+
+   return 0;
+}
+#endif
+
 /* Called during kexec sequence with MMU off */
 static notrace void copy_segments(unsigned long ind)
 {
diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index eeb258002d1e0..2a17f171661f1 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -123,6 +123,12 @@ static void *elf64_load(struct kimage *image, char 
*kernel_buf,
kbuf.buf_align = PAGE_SIZE;
kbuf.top_down = true;
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
+
+#if defined(CONFIG_CRASH_HOTPLUG)
+   image->arch.fdt_index = image->nr_segments;
+#endif
+   kbuf.memsz = fdt_totalsize(fdt);
+
ret = kexec_add_buffer(&kbuf);
if (ret)
goto out_free_fdt;
diff --git a/arch/powerpc/kexec/file_load_64.c 
b/arch/powerpc/kexec/file_load_64.c
index 9bc70b4d8eafc..725f74d1b928c 100644
--- a/arch/powerpc/kexec/file_load_64.c
+++ b/arch/powerpc/kexec/file_load_64.c
@@ -1153,6 +1153,11 @@ int arch_kexec_kernel_image_probe(struct kimage *image, 
void *buf,
return ret;
}
 
+#if defined(CONFIG_CRASH_HOTPLUG)
+   /* Mark fdt_index invalid */
+   image->arch.fdt_index = -1;
+#endif
+
return kexec_image_probe_default(image, buf, buf_len);
 }
 
-- 
2.39.0



[PATCH v7 0/8] In kernel handling of CPU hotplug events for crash kernel

2023-01-15 Thread Sourabh Jain
This patch series implements the crash hotplug handler on PowerPC introduced
by https://lkml.org/lkml/2022/12/9/520 patch series.

The Problem:

Post hotplug/DLPAR events the capture kernel holds stale information about the
system. Dump collection with stale capture kernel might end up in dump capture
failure or an inaccurate dump collection.

Existing solution:
==
The existing solution to keep the capture kernel up-to-date by monitoring
hotplug event via udev rule and trigger a full capture kernel reload for
every hotplug event.

Shortcomings:

- Leaves a window where kernel crash might not lead to a successful dump
  collection.
- Reloading all kexec components for each hotplug is inefficient.
- udev rules are prone to races if hotplug events are frequent.

More about issues with an existing solution is posted here:
 - https://lkml.org/lkml/2020/12/14/532
 - https://lists.ozlabs.org/pipermail/linuxppc-dev/2022-February/240254.html

Proposed Solution:
==
Instead of reloading all kexec segments on hotplug event, this patch series
focuses on updating only the relevant kexec segment. Once the kexec segments
are loaded in the kernel reserved area then an arch-specific hotplug handler
will update the relevant kexec segment based on hotplug event type.

---
Changelog:

v6 -> v7
  - added a new config to configure this feature
  - pass hotplug action type to arch specific handler

v5 -> v6
  - Added crash memory hotplug support

v4 -> v5:
  - Replace COFNIG_CRASH_HOTPLUG with CONFIG_HOTPLUG_CPU.
  - Move fdt segment identification for kexec_load case to load path
instead of crash hotplug handler
  - Keep new attribute defined under kimage_arch to track FDT segment
under CONFIG_HOTPLUG_CPU config.

v3 -> v4:
  - Update the logic to find the additional space needed for hotadd CPUs post
kexec load. Refer "[RFC v4 PATCH 4/5] powerpc/crash hp: add crash hotplug
support for kexec_file_load" patch to know more about the change.
  - Fix a couple of typo.
  - Replace pr_err to pr_info_once to warn user about memory hotplug
support.
  - In crash hotplug handle exit the for loop if FDT segment is found.

v2 -> v3
  - Move fdt_index and fdt_index_vaild variables to kimage_arch struct.
  - Rebase patche on top of https://lkml.org/lkml/2022/3/3/674 [v5]
  - Fixed warning reported by checpatch script

v1 -> v2:
  - Use generic hotplug handler introduced by 
https://lkml.org/lkml/2022/2/9/1406, a
significant change from v1.
---

Sourabh Jain (8):
  powerpc/kexec: turn some static helper functions public
  powerpc/crash hp: introduce a new config option CRASH_HOTPLUG
  powerpc/crash: update kimage_arch struct
  crash: add phdr for possible CPUs in elfcorehdr
  crash: pass hotplug action type to arch crash hotplug handler
  powerpc/crash: add crash CPU hotplug support
  crash: forward memory_notify args to arch crash hotplug handler
  powerpc/kexec: add crash memory hotplug support

 arch/powerpc/Kconfig|  12 +
 arch/powerpc/include/asm/kexec.h|  17 ++
 arch/powerpc/include/asm/kexec_ranges.h |   1 +
 arch/powerpc/kexec/core_64.c| 290 
 arch/powerpc/kexec/elf_64.c |  73 +-
 arch/powerpc/kexec/file_load_64.c   | 179 ++-
 arch/powerpc/kexec/ranges.c |  60 +
 arch/x86/include/asm/kexec.h|   3 +-
 arch/x86/kernel/crash.c |   5 +-
 include/linux/kexec.h   |   6 +-
 kernel/crash_core.c |  23 +-
 11 files changed, 491 insertions(+), 178 deletions(-)

-- 
2.39.0



[PATCH v7 2/8] powerpc/crash hp: introduce a new config option CRASH_HOTPLUG

2023-01-15 Thread Sourabh Jain
The config option CRASH_HOTPLUG enables in kernel update to kexec
segments due to CPU/Memory hotplug events. By default it is disabled.

Signed-off-by: Sourabh Jain 
---
 arch/powerpc/Kconfig | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b8c4ac56bddc5..57d18cc5d27c5 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -668,6 +668,18 @@ config CRASH_DUMP
  The same kernel binary can be used as production kernel and dump
  capture kernel.
 
+config CRASH_HOTPLUG
+   bool "Update crash capture system on CPU/Memory hotplug event"
+   default n
+   depends on CRASH_DUMP && (HOTPLUG_CPU || MEMORY_HOTPLUG)
+   help
+ In kernel update to relevant kexec segments due to change
+ in system configuration, rather reloading all the kexec
+ segments again from userspace by monitoring CPU/Memory
+ hotplug event in userspace using udev.
+
+ If unsure, say Y.
+
 config FA_DUMP
bool "Firmware-assisted dump"
depends on PPC64 && (PPC_RTAS || PPC_POWERNV)
-- 
2.39.0



[PATCH v7 1/8] powerpc/kexec: turn some static helper functions public

2023-01-15 Thread Sourabh Jain
Move update_cpus_node and get_crash_memory_ranges functions from
kexec/file_load.c to kexec/core_64.c to make these functions usable
by other kexec compoenets.

Later in the series, both functions are used for in-kernel updates to
kexec segments in the event of CPU/Memory hotplug for both kexec_load
and kexec_file_load system call.

No functional change intended.

Signed-off-by: Sourabh Jain 
---
 arch/powerpc/include/asm/kexec.h  |   6 ++
 arch/powerpc/kexec/core_64.c  | 166 ++
 arch/powerpc/kexec/file_load_64.c | 162 -
 3 files changed, 172 insertions(+), 162 deletions(-)

diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index a1ddba01e7d13..8090ad7d97d9d 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -99,6 +99,12 @@ void relocate_new_kernel(unsigned long indirection_page, 
unsigned long reboot_co
 
 void kexec_copy_flush(struct kimage *image);
 
+#ifdef CONFIG_PPC64
+struct crash_mem;
+int update_cpus_node(void *fdt);
+int get_crash_memory_ranges(struct crash_mem **mem_ranges);
+#endif
+
 #if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_PPC_RTAS)
 void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
 #define crash_free_reserved_phys_range crash_free_reserved_phys_range
diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index a79e28c91e2be..0b292f93a74cc 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -17,6 +17,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -30,6 +32,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 int machine_kexec_prepare(struct kimage *image)
 {
@@ -377,6 +381,168 @@ void default_machine_kexec(struct kimage *image)
/* NOTREACHED */
 }
 
+/**
+ * get_crash_memory_ranges - Get crash memory ranges. This list includes
+ *   first/crashing kernel's memory regions that
+ *   would be exported via an elfcore.
+ * @mem_ranges:  Range list to add the memory ranges to.
+ *
+ * Returns 0 on success, negative errno on error.
+ */
+int get_crash_memory_ranges(struct crash_mem **mem_ranges)
+{
+   phys_addr_t base, end;
+   struct crash_mem *tmem;
+   u64 i;
+   int ret;
+
+   for_each_mem_range(i, &base, &end) {
+   u64 size = end - base;
+
+   /* Skip backup memory region, which needs a separate entry */
+   if (base == BACKUP_SRC_START) {
+   if (size > BACKUP_SRC_SIZE) {
+   base = BACKUP_SRC_END + 1;
+   size -= BACKUP_SRC_SIZE;
+   } else
+   continue;
+   }
+
+   ret = add_mem_range(mem_ranges, base, size);
+   if (ret)
+   goto out;
+
+   /* Try merging adjacent ranges before reallocation attempt */
+   if ((*mem_ranges)->nr_ranges == (*mem_ranges)->max_nr_ranges)
+   sort_memory_ranges(*mem_ranges, true);
+   }
+
+   /* Reallocate memory ranges if there is no space to split ranges */
+   tmem = *mem_ranges;
+   if (tmem && (tmem->nr_ranges == tmem->max_nr_ranges)) {
+   tmem = realloc_mem_ranges(mem_ranges);
+   if (!tmem)
+   goto out;
+   }
+
+   /* Exclude crashkernel region */
+   ret = crash_exclude_mem_range(tmem, crashk_res.start, crashk_res.end);
+   if (ret)
+   goto out;
+
+   /*
+* FIXME: For now, stay in parity with kexec-tools but if RTAS/OPAL
+*regions are exported to save their context at the time of
+*crash, they should actually be backed up just like the
+*first 64K bytes of memory.
+*/
+   ret = add_rtas_mem_range(mem_ranges);
+   if (ret)
+   goto out;
+
+   ret = add_opal_mem_range(mem_ranges);
+   if (ret)
+   goto out;
+
+   /* create a separate program header for the backup region */
+   ret = add_mem_range(mem_ranges, BACKUP_SRC_START, BACKUP_SRC_SIZE);
+   if (ret)
+   goto out;
+
+   sort_memory_ranges(*mem_ranges, false);
+out:
+   if (ret)
+   pr_err("Failed to setup crash memory ranges\n");
+   return ret;
+}
+
+/**
+ * add_node_props - Reads node properties from device node structure and add
+ *  them to fdt.
+ * @fdt:Flattened device tree of the kernel
+ * @node_offset:offset of the node to add a property at
+ * @dn: device node pointer
+ *
+ * Returns 0 on success, negative errno on error.
+ */
+static int add_node_props(void *fdt, int node_offset, const struct device_node 
*dn)
+{
+   int ret = 0;
+   struct property *pp;
+
+   if (!dn)
+   return -E

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

2023-01-15 Thread pr-tracker-bot
The pull request you sent on Sun, 15 Jan 2023 21:56:46 +1100:

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

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

Thank you!

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


[PATCH v2] powerpc: macio: Make remove callback of macio driver void returned

2023-01-15 Thread Dawei Li
Commit fc7a6209d571 ("bus: Make remove callback return void") forces
bus_type::remove be void-returned, it doesn't make much sense for any
bus based driver implementing remove callbalk to return non-void to
its caller.

This change is for macio bus based drivers.

Signed-off-by: Dawei Li 
---
v1 -> v2
- Revert unneeded changes.
- Rebased on latest powerpc/next.

v1
- 
https://lore.kernel.org/all/tycp286mb2323fcdc7ecd87f8d97cb74bca...@tycp286mb2323.jpnp286.prod.outlook.com/
---
 arch/powerpc/include/asm/macio.h| 2 +-
 drivers/ata/pata_macio.c| 4 +---
 drivers/macintosh/rack-meter.c  | 4 +---
 drivers/net/ethernet/apple/bmac.c   | 4 +---
 drivers/net/ethernet/apple/mace.c   | 4 +---
 drivers/net/wireless/intersil/orinoco/airport.c | 4 +---
 drivers/scsi/mac53c94.c | 5 +
 drivers/scsi/mesh.c | 5 +
 drivers/tty/serial/pmac_zilog.c | 7 ++-
 sound/aoa/soundbus/i2sbus/core.c| 4 +---
 10 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/arch/powerpc/include/asm/macio.h b/arch/powerpc/include/asm/macio.h
index ff5fd82d9ff0..cb9c386dacf8 100644
--- a/arch/powerpc/include/asm/macio.h
+++ b/arch/powerpc/include/asm/macio.h
@@ -125,7 +125,7 @@ static inline struct pci_dev *macio_get_pci_dev(struct 
macio_dev *mdev)
 struct macio_driver
 {
int (*probe)(struct macio_dev* dev, const struct of_device_id 
*match);
-   int (*remove)(struct macio_dev* dev);
+   void(*remove)(struct macio_dev *dev);
 
int (*suspend)(struct macio_dev* dev, pm_message_t state);
int (*resume)(struct macio_dev* dev);
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 9ccaac9e2bc3..653106716a4b 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -1187,7 +1187,7 @@ static int pata_macio_attach(struct macio_dev *mdev,
return rc;
 }
 
-static int pata_macio_detach(struct macio_dev *mdev)
+static void pata_macio_detach(struct macio_dev *mdev)
 {
struct ata_host *host = macio_get_drvdata(mdev);
struct pata_macio_priv *priv = host->private_data;
@@ -1202,8 +1202,6 @@ static int pata_macio_detach(struct macio_dev *mdev)
ata_host_detach(host);
 
unlock_media_bay(priv->mdev->media_bay);
-
-   return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index c28893e41a8b..f2f83c4f3af5 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -523,7 +523,7 @@ static int rackmeter_probe(struct macio_dev* mdev,
return rc;
 }
 
-static int rackmeter_remove(struct macio_dev* mdev)
+static void rackmeter_remove(struct macio_dev *mdev)
 {
struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
 
@@ -558,8 +558,6 @@ static int rackmeter_remove(struct macio_dev* mdev)
 
/* Get rid of me */
kfree(rm);
-
-   return 0;
 }
 
 static int rackmeter_shutdown(struct macio_dev* mdev)
diff --git a/drivers/net/ethernet/apple/bmac.c 
b/drivers/net/ethernet/apple/bmac.c
index 9e653e2925f7..292b1f9cd9e7 100644
--- a/drivers/net/ethernet/apple/bmac.c
+++ b/drivers/net/ethernet/apple/bmac.c
@@ -1591,7 +1591,7 @@ bmac_proc_info(char *buffer, char **start, off_t offset, 
int length)
 }
 #endif
 
-static int bmac_remove(struct macio_dev *mdev)
+static void bmac_remove(struct macio_dev *mdev)
 {
struct net_device *dev = macio_get_drvdata(mdev);
struct bmac_data *bp = netdev_priv(dev);
@@ -1609,8 +1609,6 @@ static int bmac_remove(struct macio_dev *mdev)
macio_release_resources(mdev);
 
free_netdev(dev);
-
-   return 0;
 }
 
 static const struct of_device_id bmac_match[] =
diff --git a/drivers/net/ethernet/apple/mace.c 
b/drivers/net/ethernet/apple/mace.c
index fd1b008b7208..e6350971c707 100644
--- a/drivers/net/ethernet/apple/mace.c
+++ b/drivers/net/ethernet/apple/mace.c
@@ -272,7 +272,7 @@ static int mace_probe(struct macio_dev *mdev, const struct 
of_device_id *match)
return rc;
 }
 
-static int mace_remove(struct macio_dev *mdev)
+static void mace_remove(struct macio_dev *mdev)
 {
struct net_device *dev = macio_get_drvdata(mdev);
struct mace_data *mp;
@@ -296,8 +296,6 @@ static int mace_remove(struct macio_dev *mdev)
free_netdev(dev);
 
macio_release_resources(mdev);
-
-   return 0;
 }
 
 static void dbdma_reset(volatile struct dbdma_regs __iomem *dma)
diff --git a/drivers/net/wireless/intersil/orinoco/airport.c 
b/drivers/net/wireless/intersil/orinoco/airport.c
index a890bfa0d5cc..276a06cdd1f5 100644
--- a/drivers/net/wireless/intersil/orinoco/airport.c
+++ b/drivers/net/wireless/intersil/orinoco/airport.c
@@ -85,7 +85,7 @@ airport_resume(struct macio_dev *mdev)
return err;
 }
 
-static int
+static void
 airport_detach(struct macio_dev *mdev)
 {
struct

Re: ia64 removal (was: Re: lockref scalability on x86-64 vs cpu_relax)

2023-01-15 Thread Sedat Dilek
On Sun, Jan 15, 2023 at 1:27 AM Matthew Wilcox  wrote:
>
> On Sat, Jan 14, 2023 at 12:28:30PM +0100, Sedat Dilek wrote:
> > [ ... ]
> >
> > > Best is to ask the Debian release-team or (if there exist) maintainers
> > > or responsibles for the IA64 port - which is an ***unofficial*** port.
> > >
> >
> > Here we go:
> >
> > https://lists.debian.org/debian-ia64/
> >
> > Posting address: debian-i...@lists.debian.org
> >
> > Found via 
>
> More useful perhaps is to look at https://popcon.debian.org/
>
> There are three machines reporting popcon results.  It's dead.

Exactly, Debian Popularity Contest was what I was looking for yesterday.

Thanks Matthew.

[1] says in Inst (204701):

Name  || Number  || %
==
binutils-x86-64-linux-gnu || 101548  || 49.61%
binutils-ia64-linux-gnu ||  11  || 0.01%

HELP: Inst. is the number of people who installed this package (sum of
the four categories below)

There may be more popular packages than binutils.
( binutils might tell something about development happening or not. )

Anyway, I am not a popcon expert and never participated in Debian's
Popularity Contest.

-Sedat-

[1] https://qa.debian.org/popcon.php?package=binutils


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

2023-01-15 Thread Michael Ellerman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hi Linus,

Please pull some more powerpc fixes for 6.2:

The following changes since commit be5f95c8779e19779dd81927c8574fec5aaba36c:

  powerpc/vmlinux.lds: Don't discard .comment (2023-01-06 00:25:12 +1100)

are available in the git repository at:

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

for you to fetch changes up to f12cd06109f47c2fb4b23a45ab55404c47ef7fae:

  powerpc/64s/hash: Make stress_hpt_timer_fn() static (2023-01-12 10:53:37 
+1100)

- --
powerpc fixes for 6.2 #3

 - Fix a build failure with some versions of ld that have an odd version string.

 - Fix incorrect use of mutex in the IMC PMU driver.

Thanks to: Kajol Jain, Michael Petlan, Ojaswin Mujoo, Peter Zijlstra, Yang 
Yingliang.

- --
Kajol Jain (1):
  powerpc/imc-pmu: Fix use of mutex in IRQs disabled section

Ojaswin Mujoo (1):
  powerpc/boot: Fix incorrect version calculation issue in ld_version

Yang Yingliang (1):
  powerpc/64s/hash: Make stress_hpt_timer_fn() static


 arch/powerpc/boot/wrapper |   4 +
 arch/powerpc/include/asm/imc-pmu.h|   2 +-
 arch/powerpc/mm/book3s64/hash_utils.c |   2 +-
 arch/powerpc/perf/imc-pmu.c   | 136 ++--
 4 files changed, 72 insertions(+), 72 deletions(-)
-BEGIN PGP SIGNATURE-

iQIzBAEBCAAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmPD2sYACgkQUevqPMjh
pYDoDQ/9Gl0mGDGQGjbOz4iYKHhlqEB9vWq7NH+++tTSTIUHHuKOPHRWHgZKM+FI
6wxBpc0yU013oyqr+CcVP7NGYSry8pNG5kjC/GxyXcHBNcrmV9QEAYRs4Uo8qTU/
g1IZjrzhaxb3wlKNp0GiwEupGh428CkyziFXKndR9i5uryyzZnupmuQjig3fc4dt
ZyqHcK6LKzlgvKgSI+iMijBKvI2hDszlIp+/lkB2H3+9/ORSid/bVhfRuVIzJeum
B5cwN3BFnVZuRPtJMSIpdyHrDV5Yak6rkWdWB00NiHptZb13/wgytJwUuBPwnDRU
qQYYJwMC9vKTmFGB8h0crC3MapxSVWeXb6OfJGtgdKieLdaFrVV343n699KiqWJD
/pjBROJg+kvoR+YKgLVGvef/Nqu0cFI6wVB2JhjRJyuFuq81kXe4Va/CB6HeFKOJ
cgr4fBPuxoSY6JRSGJ767ISrRM5K6pKSUUBDtLX2B9Qbyfq9+klu7tlU7cnsEzYr
OuM90BE3XrrrquhCLYH7SO5QBbDiUSFP18Dp8ZizhyYjj4GmY8lmKlk/pQAAlwgw
udDABrN1gFl4iAGkSAN1pd4YYfHyWOwo+FATkHhvqO1Jg8VbEZQyy8jBCwgKFTYg
wHhUVYTnF4dEVUTTADbGpoYNppMzW/6yazZCBC8e2EaGq+o8+/Y=
=Qdd5
-END PGP SIGNATURE-


Re: [PATCH v2] powerpc: Fix a wrong version calculation issue in ld_version

2023-01-15 Thread Michael Ellerman
On Thu, 5 Jan 2023 01:54:37 +0530, Ojaswin Mujoo wrote:
> ** The Issue **
> 
> The ld_version() function seems to compute the wrong version value for
> certain ld versions like the following:
> 
> $ ld --version GNU ld (GNU Binutils; SUSE Linux Enterprise 15)
> 2.37.20211103-150100.7.37
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc: Fix a wrong version calculation issue in ld_version
  https://git.kernel.org/powerpc/c/3287ebd7fd01e853ca4da8be675322429400e2bd

cheers


Re: [PATCH] powerpc/imc-pmu: Fix IMC PMU code of using mutex in IRQs disabled section

2023-01-15 Thread Michael Ellerman
On Fri, 6 Jan 2023 12:21:57 +0530, Kajol Jain wrote:
> Current imc-pmu code triggers a WARNING with CONFIG_DEBUG_ATOMIC_SLEEP and
> CONFIG_PROVE_LOCKING enabled, while running a thread_imc event.
> 
> Command to trigger the warning:
> [command]# perf stat -e thread_imc/CPM_CS_FROM_L4_MEM_X_DPTEG/ sleep 5
> 
>  Performance counter stats for 'sleep 5':
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/imc-pmu: Fix IMC PMU code of using mutex in IRQs disabled section
  https://git.kernel.org/powerpc/c/76d588dddc459fefa1da96e0a081a397c5c8e216

cheers