Re: [linus:master] [file] 0ede61d858: will-it-scale.per_thread_ops -2.9% regression

2023-11-19 Thread Mateusz Guzik
On Mon, Nov 20, 2023 at 03:11:31PM +0800, kernel test robot wrote:
> 
> 
> Hello,
> 
> kernel test robot noticed a -2.9% regression of will-it-scale.per_thread_ops 
> on:
> 
> 
> commit: 0ede61d8589cc2d93aa78230d74ac58b5b8d0244 ("file: convert to 
> SLAB_TYPESAFE_BY_RCU")
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
> 
> 93faf426e3cc000c 0ede61d8589cc2d93aa78230d74 
>  --- 
>  %stddev %change %stddev
>  \  |\  
[snip]
>  30.90 ±  4% -20.6   10.35 ±  2%  
> perf-profile.self.cycles-pp.__fget_light
>   0.00   +26.5   26.48
> perf-profile.self.cycles-pp.__get_file_rcu
[snip]

So __fget_light now got a func call.

I don't know if this is worth patching (and benchmarking after), but I
if sorting this out is of interest, triviality below is probably the
easiest way out:

diff --git a/fs/file.c b/fs/file.c
index 5fb0b146e79e..d8d3e18800c4 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -856,14 +856,14 @@ void do_close_on_exec(struct files_struct *files)
spin_unlock(>file_lock);
 }
 
-static struct file *__get_file_rcu(struct file __rcu **f)
+static __always_inline struct file *__get_file_rcu(struct file __rcu **f)
 {
struct file __rcu *file;
struct file __rcu *file_reloaded;
struct file __rcu *file_reloaded_cmp;
 
file = rcu_dereference_raw(*f);
-   if (!file)
+   if (unlikely(!file))
return NULL;
 
if (unlikely(!atomic_long_inc_not_zero(>f_count)))
@@ -891,7 +891,7 @@ static struct file *__get_file_rcu(struct file __rcu **f)
 * If the pointers don't match the file has been reallocated by
 * SLAB_TYPESAFE_BY_RCU.
 */
-   if (file == file_reloaded_cmp)
+   if (likely(file == file_reloaded_cmp))
return file_reloaded;
 
fput(file);


Re: [PATCH v4 4/5] tty: Add SBI debug console support to HVC SBI driver

2023-11-19 Thread Jiri Slaby

On 18. 11. 23, 4:38, Anup Patel wrote:

diff --git a/drivers/tty/hvc/hvc_riscv_sbi.c b/drivers/tty/hvc/hvc_riscv_sbi.c
index 31f53fa77e4a..697c981221b5 100644
--- a/drivers/tty/hvc/hvc_riscv_sbi.c
+++ b/drivers/tty/hvc/hvc_riscv_sbi.c

...

-static int __init hvc_sbi_console_init(void)
+static int hvc_sbi_dbcn_tty_get(uint32_t vtermno, char *buf, int count)
  {
-   hvc_instantiate(0, 0, _sbi_ops);
+   phys_addr_t pa;
+
+   if (is_vmalloc_addr(buf)) {


I wonder, where does this buf come from, so that you have to check for 
vmalloc?



+   pa = page_to_phys(vmalloc_to_page(buf)) + offset_in_page(buf);
+   if (PAGE_SIZE < (offset_in_page(buf) + count))


Am I the only one who would prefer:
  if (count + offset_in_page(buf) > PAGE_SIZE)
?


+   count = PAGE_SIZE - offset_in_page(buf);
+   } else {
+   pa = __pa(buf);
+   }
+
+   return sbi_debug_console_read(count, pa);
+}



thanks,
--
js
suse labs



[linus:master] [file] 0ede61d858: will-it-scale.per_thread_ops -2.9% regression

2023-11-19 Thread kernel test robot



Hello,

kernel test robot noticed a -2.9% regression of will-it-scale.per_thread_ops on:


commit: 0ede61d8589cc2d93aa78230d74ac58b5b8d0244 ("file: convert to 
SLAB_TYPESAFE_BY_RCU")
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

testcase: will-it-scale
test machine: 224 threads 4 sockets Intel(R) Xeon(R) Platinum 8380H CPU @ 
2.90GHz (Cooper Lake) with 192G memory
parameters:

nr_task: 16
mode: thread
test: poll2
cpufreq_governor: performance




If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-lkp/202311201406.2022ca3f-oliver.s...@intel.com


Details are as below:
-->


The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20231120/202311201406.2022ca3f-oliver.s...@intel.com

=
compiler/cpufreq_governor/kconfig/mode/nr_task/rootfs/tbox_group/test/testcase:
  
gcc-12/performance/x86_64-rhel-8.3/thread/16/debian-11.1-x86_64-20220510.cgz/lkp-cpl-4sp2/poll2/will-it-scale

commit: 
  93faf426e3 ("vfs: shave work on failed file open")
  0ede61d858 ("file: convert to SLAB_TYPESAFE_BY_RCU")

93faf426e3cc000c 0ede61d8589cc2d93aa78230d74 
 --- 
 %stddev %change %stddev
 \  |\  
  0.01 ±  9%  +58125.6%   4.17 ±175%  
perf-sched.sch_delay.max.ms.schedule_timeout.rcu_gp_fqs_loop.rcu_gp_kthread.kthread
 89056-2.0%  87309proc-vmstat.nr_slab_unreclaimable
 97958 ±  7%  -9.7%  88449 ±  4%  sched_debug.cpu.avg_idle.stddev
  0.00 ± 12% +24.2%   0.00 ± 17%  
sched_debug.cpu.next_balance.stddev
   6391048-2.9%6208584will-it-scale.16.threads
399440-2.9% 388036will-it-scale.per_thread_ops
   6391048-2.9%6208584will-it-scale.workload
 19.99 ±  4%  -2.2   17.74
perf-profile.calltrace.cycles-pp.fput.do_poll.do_sys_poll.__x64_sys_poll.do_syscall_64
  1.27 ±  5%  +0.82.11 ±  3%  
perf-profile.calltrace.cycles-pp.__fdget.do_poll.do_sys_poll.__x64_sys_poll.do_syscall_64
 32.69 ±  4%  +5.0   37.70
perf-profile.calltrace.cycles-pp.__fget_light.do_poll.do_sys_poll.__x64_sys_poll.do_syscall_64
  0.00   +27.9   27.85
perf-profile.calltrace.cycles-pp.__get_file_rcu.__fget_light.do_poll.do_sys_poll.__x64_sys_poll
 20.00 ±  4%  -2.3   17.75
perf-profile.children.cycles-pp.fput
  0.24 ± 10%  -0.10.18 ±  2%  
perf-profile.children.cycles-pp.syscall_return_via_sysret
  1.48 ±  5%  +0.51.98 ±  3%  
perf-profile.children.cycles-pp.__fdget
 31.85 ±  4%  +6.0   37.86
perf-profile.children.cycles-pp.__fget_light
  0.00   +27.7   27.67
perf-profile.children.cycles-pp.__get_file_rcu
 30.90 ±  4% -20.6   10.35 ±  2%  
perf-profile.self.cycles-pp.__fget_light
 19.94 ±  4%  -2.4   17.53perf-profile.self.cycles-pp.fput
  9.81 ±  4%  -2.47.42 ±  2%  
perf-profile.self.cycles-pp.do_poll
  0.23 ± 11%  -0.10.17 ±  4%  
perf-profile.self.cycles-pp.syscall_return_via_sysret
  0.00   +26.5   26.48
perf-profile.self.cycles-pp.__get_file_rcu
 2.146e+10 ±  2%  +8.5%  2.329e+10 ±  2%  perf-stat.i.branch-instructions
  0.22 ± 14%  -0.00.19 ± 14%  perf-stat.i.branch-miss-rate%
 1.404e+10 ±  2%  +8.7%  1.526e+10 ±  2%  perf-stat.i.dTLB-stores
 70.87-2.3   68.59perf-stat.i.iTLB-load-miss-rate%
   5267608-5.5%4979133 ±  2%  perf-stat.i.iTLB-load-misses
   2102507+5.4%2215725perf-stat.i.iTLB-loads
 18791 ±  3% +10.5%  20757 ±  2%  
perf-stat.i.instructions-per-iTLB-miss
266.67 ±  2%  +6.8% 284.75 ±  2%  perf-stat.i.metric.M/sec
  0.01 ± 10% -10.5%   0.01 ±  5%  perf-stat.overall.MPKI
  0.19-0.00.17
perf-stat.overall.branch-miss-rate%
  0.65-3.1%   0.63perf-stat.overall.cpi
  0.00 ±  4%  -0.00.00 ±  4%  
perf-stat.overall.dTLB-store-miss-rate%
 71.48-2.3   69.21
perf-stat.overall.iTLB-load-miss-rate%
 18757   +10.0%  20629
perf-stat.overall.instructions-per-iTLB-miss
  1.54+3.2%   1.59perf-stat.overall.ipc
   4795147+6.4%5100406perf-stat.overall.path-length
  2.14e+10 ±  2%  +8.5%  2.322e+10 ±  2%  perf-stat.ps.branch-instructions
   1.4e+10 

Re: [PATCH v2] powerpc: Don't clobber fr0/vs0 during fp|altivec register save

2023-11-19 Thread Michael Ellerman
Hi Timothy,

Great work debugging this. I think your fix is good, but I want to understand it
a bit more to make sure I can explain why we haven't seen it outside of 
io-uring.
If this can be triggered outside of io-uring then I have even more backporting
in my future :}

Typically save_fpu() is called from __giveup_fpu() which saves the FP regs and
also *turns off FP* in the tasks MSR, meaning the kernel will reload the FP regs
from the thread struct before letting the task use FP again. So in that case
save_fpu() is free to clobber fr0 because the FP regs no longer hold live values
for the task.

There is another case though, which is the path via:
  copy_process()
dup_task_struct()
  arch_dup_task_struct()
flush_all_to_thread()
  save_all()

That path saves the FP regs but leaves them live. That's meant as an
optimisation for a process that's using FP/VSX and then calls fork(), leaving
the regs live means the parent process doesn't have to take a fault after the
fork to get its FP regs back.

That path does clobber fr0, but fr0 is volatile across a syscall, and the only
way to reach copy_process() from userspace is via a syscall. So in normal usage
fr0 being clobbered across a syscall shouldn't cause data corruption.

Even if we handle a signal on the return from the fork() syscall, the worst that
happens is that the task's thread struct holds the clobbered fr0, but the task
doesn't care (because fr0 is volatile across the syscall anyway).

That path is something like:

system_call_vectored_common()
  system_call_exception()
sys_fork()
  kernel_clone()
copy_process()
  dup_task_struct()
arch_dup_task_struct()
  flush_all_to_thread()
save_all()
  if (tsk->thread.regs->msr & MSR_FP)
save_fpu()
# does not clear MSR_FP from regs->msr
  syscall_exit_prepare()
interrupt_exit_user_prepare_main()
  do_notify_resume()
get_signal()
handle_rt_signal64()
  prepare_setup_sigcontext()
flush_fp_to_thread()
  if (tsk->thread.regs->msr & MSR_FP)
giveup_fpu()
  __giveup_fpu
save_fpu()
# clobbered fr0 is saved, but task considers it volatile
# across syscall anyway


But we now have a new path, because io-uring can call copy_process() via
create_io_thread() from the signal handling path. That's OK if the signal is
handled as we return from a syscall, but it's not OK if the signal is handled
due to some other interrupt.

Which is:

interrupt_return_srr_user()
  interrupt_exit_user_prepare()
interrupt_exit_user_prepare_main()
  do_notify_resume()
get_signal()
  task_work_run()
create_worker_cb()
  create_io_worker()
copy_process()
  dup_task_struct()
arch_dup_task_struct()
  flush_all_to_thread()
save_all()
  if (tsk->thread.regs->msr & MSR_FP)
save_fpu()
# fr0 is clobbered and potentially live in userspace


So tldr I think the corruption is only an issue since io-uring started doing
the clone via signal, which I think matches the observed timeline of this bug
appearing.

Gotta run home, will have a closer look at the actual patch later on.

cheers


Timothy Pearson  writes:
> During floating point and vector save to thread data fr0/vs0 are clobbered
> by the FPSCR/VSCR store routine.  This leads to userspace register corruption
> and application data corruption / crash under the following rare condition:
>
>  * A userspace thread is executing with VSX/FP mode enabled
>  * The userspace thread is making active use of fr0 and/or vs0
>  * An IPI is taken in kernel mode, forcing the userspace thread to reschedule
>  * The userspace thread is interrupted by the IPI before accessing data it
>previously stored in fr0/vs0
>  * The thread being switched in by the IPI has a pending signal
>
> If these exact criteria are met, then the following sequence happens:
>
>  * The existing thread FP storage is still valid before the IPI, due to a
>prior call to save_fpu() or store_fp_state().  Note that the current
>fr0/vs0 registers have been clobbered, so the FP/VSX state in registers
>is now invalid pending a call to restore_fp()/restore_altivec().
>  * IPI -- FP/VSX register state remains invalid
>  * interrupt_exit_user_prepare_main() calls do_notify_resume(),
>due to the pending signal
>  * do_notify_resume() eventually calls save_fpu() via giveup_fpu(), which
>merrily reads and saves the invalid FP/VSX state to thread local storage.
>  * interrupt_exit_user_prepare_main() calls restore_math(), writing the 
> invalid
>FP/VSX state back to registers.
>  * Execution is released to userspace, and the 

Re: [PATCH] asm/io: remove unnecessary xlate_dev_mem_ptr() and unxlate_dev_mem_ptr()

2023-11-19 Thread Kefeng Wang




On 2023/11/20 14:40, Arnd Bergmann wrote:

On Mon, Nov 20, 2023, at 01:39, Kefeng Wang wrote:

On 2023/11/20 3:34, Geert Uytterhoeven wrote:

On Sat, Nov 18, 2023 at 11:09 AM Kefeng Wang  wrote:


-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-#define unxlate_dev_mem_ptr(p, v) do { } while (0)
-
   void __ioread64_copy(void *to, const void __iomem *from, size_t count);


Missing #include , according to the build bot report.


Will check the bot report.


I had planned to pick up the series from

https://lore.kernel.org/lkml/20230921110424.215592-3-...@redhat.com/


Good to see it.



for v6.7 but didn't make it in the end. I'll try to do it now
for v6.8 and apply your v1 patch with the Acks on top.


Thanks.



 Arnd


Re: [PATCH] asm/io: remove unnecessary xlate_dev_mem_ptr() and unxlate_dev_mem_ptr()

2023-11-19 Thread Arnd Bergmann
On Mon, Nov 20, 2023, at 01:39, Kefeng Wang wrote:
> On 2023/11/20 3:34, Geert Uytterhoeven wrote:
>> On Sat, Nov 18, 2023 at 11:09 AM Kefeng Wang  
>> wrote:
>>>
>>> -/*
>>> - * Convert a physical pointer to a virtual kernel pointer for /dev/mem
>>> - * access
>>> - */
>>> -#define xlate_dev_mem_ptr(p)   __va(p)
>>> -#define unxlate_dev_mem_ptr(p, v) do { } while (0)
>>> -
>>>   void __ioread64_copy(void *to, const void __iomem *from, size_t count);
>> 
>> Missing #include , according to the build bot report.
>
> Will check the bot report.

I had planned to pick up the series from 

https://lore.kernel.org/lkml/20230921110424.215592-3-...@redhat.com/

for v6.7 but didn't make it in the end. I'll try to do it now
for v6.8 and apply your v1 patch with the Acks on top.

Arnd


Re: [PATCH] misc: ocxl: main: Remove unnecessary ‘0’ values from rc

2023-11-19 Thread Andrew Donnellan
On Mon, 2023-11-13 at 09:52 +0800, Li kunyu wrote:
> rc is assigned first, so it does not need to initialize the
> assignment.
> 
> Signed-off-by: Li kunyu 

I don't have strong feelings about whether to get rid of unnecessary
initialisations, but most of the code doesn't do it, so for
consistency:

Acked-by: Andrew Donnellan 

> ---
>  drivers/misc/ocxl/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/main.c b/drivers/misc/ocxl/main.c
> index ef73cf35dda2b..658974143c3cc 100644
> --- a/drivers/misc/ocxl/main.c
> +++ b/drivers/misc/ocxl/main.c
> @@ -7,7 +7,7 @@
>  
>  static int __init init_ocxl(void)
>  {
> - int rc = 0;
> + int rc;
>  
>   if (!tlbie_capable)
>   return -EINVAL;

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH] misc: ocxl: link: Remove unnecessary (void*) conversions

2023-11-19 Thread Andrew Donnellan
On Mon, 2023-11-13 at 09:45 +0800, Li zeming wrote:
> The link pointer does not need to cast the type.
> 
> Signed-off-by: Li zeming 

Acked-by: Andrew Donnellan 

> ---
>  drivers/misc/ocxl/link.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index c06c699c0e7b1..03402203cacdb 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -188,7 +188,7 @@ static void xsl_fault_handler_bh(struct
> work_struct *fault_work)
>  
>  static irqreturn_t xsl_fault_handler(int irq, void *data)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) data;
> + struct ocxl_link *link = data;
>   struct spa *spa = link->spa;
>   u64 dsisr, dar, pe_handle;
>   struct pe_data *pe_data;
> @@ -483,7 +483,7 @@ static void release_xsl(struct kref *ref)
>  
>  void ocxl_link_release(struct pci_dev *dev, void *link_handle)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) link_handle;
> + struct ocxl_link *link = link_handle;
>  
>   mutex_lock(_list_lock);
>   kref_put(>ref, release_xsl);
> @@ -540,7 +540,7 @@ int ocxl_link_add_pe(void *link_handle, int
> pasid, u32 pidr, u32 tidr,
>   void (*xsl_err_cb)(void *data, u64 addr, u64 dsisr),
>   void *xsl_err_data)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) link_handle;
> + struct ocxl_link *link = link_handle;
>   struct spa *spa = link->spa;
>   struct ocxl_process_element *pe;
>   int pe_handle, rc = 0;
> @@ -630,7 +630,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_add_pe);
>  
>  int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) link_handle;
> + struct ocxl_link *link = link_handle;
>   struct spa *spa = link->spa;
>   struct ocxl_process_element *pe;
>   int pe_handle, rc;
> @@ -666,7 +666,7 @@ int ocxl_link_update_pe(void *link_handle, int
> pasid, __u16 tid)
>  
>  int ocxl_link_remove_pe(void *link_handle, int pasid)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) link_handle;
> + struct ocxl_link *link = link_handle;
>   struct spa *spa = link->spa;
>   struct ocxl_process_element *pe;
>   struct pe_data *pe_data;
> @@ -752,7 +752,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_remove_pe);
>  
>  int ocxl_link_irq_alloc(void *link_handle, int *hw_irq)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) link_handle;
> + struct ocxl_link *link = link_handle;
>   int irq;
>  
>   if (atomic_dec_if_positive(>irq_available) < 0)
> @@ -771,7 +771,7 @@ EXPORT_SYMBOL_GPL(ocxl_link_irq_alloc);
>  
>  void ocxl_link_free_irq(void *link_handle, int hw_irq)
>  {
> - struct ocxl_link *link = (struct ocxl_link *) link_handle;
> + struct ocxl_link *link = link_handle;
>  
>   xive_native_free_irq(hw_irq);
>   atomic_inc(>irq_available);

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH] misc: ocxl: afu_irq: Remove unnecessary (void*) conversions

2023-11-19 Thread Andrew Donnellan
On Mon, 2023-11-13 at 09:22 +0800, Li zeming wrote:
> The irq pointer does not need to cast the type.
> 
> Signed-off-by: Li zeming 

Acked-by: Andrew Donnellan 

> ---
>  drivers/misc/ocxl/afu_irq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/afu_irq.c
> b/drivers/misc/ocxl/afu_irq.c
> index a06920b7e049a..36f7379b8e2de 100644
> --- a/drivers/misc/ocxl/afu_irq.c
> +++ b/drivers/misc/ocxl/afu_irq.c
> @@ -57,7 +57,7 @@ EXPORT_SYMBOL_GPL(ocxl_irq_set_handler);
>  
>  static irqreturn_t afu_irq_handler(int virq, void *data)
>  {
> - struct afu_irq *irq = (struct afu_irq *) data;
> + struct afu_irq *irq = data;
>  
>   trace_ocxl_afu_irq_receive(virq);
>  

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH] misc: ocxl: context: Remove unnecessary (void*) conversions

2023-11-19 Thread Andrew Donnellan
On Mon, 2023-11-13 at 09:15 +0800, Li zeming wrote:
> The ctx pointer does not need to cast the type.
> 
> Signed-off-by: Li zeming 

Acked-by: Andrew Donnellan 

> ---
>  drivers/misc/ocxl/context.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/context.c
> b/drivers/misc/ocxl/context.c
> index 7f83116ae11a6..cded7d1caf328 100644
> --- a/drivers/misc/ocxl/context.c
> +++ b/drivers/misc/ocxl/context.c
> @@ -55,7 +55,7 @@ EXPORT_SYMBOL_GPL(ocxl_context_alloc);
>   */
>  static void xsl_fault_error(void *data, u64 addr, u64 dsisr)
>  {
> - struct ocxl_context *ctx = (struct ocxl_context *) data;
> + struct ocxl_context *ctx = data;
>  
>   mutex_lock(>xsl_error_lock);
>   ctx->xsl_error.addr = addr;

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH v2 5/5] powerpc/rtas: Remove 'extern' from function declarations in rtas.h

2023-11-19 Thread Andrew Donnellan
On Tue, 2023-11-14 at 11:22 -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch 
> 
> This header occasionally gains new function declarations without the
> leading extern in accordance with current style rules. Leaving the
> legacy externs in place is making the header more difficult to read
> over time because of the inconsistency. Remove them, fixing up
> checkpatch issues with unnamed parameters (rtas_call) and bracket
> alignment (early_init_dt_scan_rtas) that get raised as a result of
> touching the code.
> 
> Signed-off-by: Nathan Lynch '

LGTM

Reviewed-by: Andrew Donnellan 

> ---
>  arch/powerpc/include/asm/rtas.h | 53 ---
> --
>  1 file changed, 26 insertions(+), 27 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/rtas.h
> b/arch/powerpc/include/asm/rtas.h
> index 1bed6be8ada3..a7110ed52e25 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -408,42 +408,41 @@ static inline bool
> rtas_function_implemented(const rtas_fn_handle_t handle)
>  {
>   return rtas_function_token(handle) != RTAS_UNKNOWN_SERVICE;
>  }
> -extern int rtas_token(const char *service);
> -extern int rtas_call(int token, int, int, int *, ...);
> +int rtas_token(const char *service);
> +int rtas_call(int token, int nargs, int nret, int *outputs, ...);
>  void rtas_call_unlocked(struct rtas_args *args, int token, int
> nargs,
>   int nret, ...);
> -extern void __noreturn rtas_restart(char *cmd);
> -extern void rtas_power_off(void);
> -extern void __noreturn rtas_halt(void);
> -extern void rtas_os_term(char *str);
> +void __noreturn rtas_restart(char *cmd);
> +void rtas_power_off(void);
> +void __noreturn rtas_halt(void);
> +void rtas_os_term(char *str);
>  void rtas_activate_firmware(void);
> -extern int rtas_get_sensor(int sensor, int index, int *state);
> -extern int rtas_get_sensor_fast(int sensor, int index, int *state);
> -extern int rtas_get_power_level(int powerdomain, int *level);
> -extern int rtas_set_power_level(int powerdomain, int level, int
> *setlevel);
> -extern bool rtas_indicator_present(int token, int *maxindex);
> -extern int rtas_set_indicator(int indicator, int index, int
> new_value);
> -extern int rtas_set_indicator_fast(int indicator, int index, int
> new_value);
> -extern void rtas_progress(char *s, unsigned short hex);
> +int rtas_get_sensor(int sensor, int index, int *state);
> +int rtas_get_sensor_fast(int sensor, int index, int *state);
> +int rtas_get_power_level(int powerdomain, int *level);
> +int rtas_set_power_level(int powerdomain, int level, int *setlevel);
> +bool rtas_indicator_present(int token, int *maxindex);
> +int rtas_set_indicator(int indicator, int index, int new_value);
> +int rtas_set_indicator_fast(int indicator, int index, int
> new_value);
> +void rtas_progress(char *s, unsigned short hex);
>  int rtas_ibm_suspend_me(int *fw_status);
>  int rtas_error_rc(int rtas_rc);
>  
>  struct rtc_time;
> -extern time64_t rtas_get_boot_time(void);
> -extern void rtas_get_rtc_time(struct rtc_time *rtc_time);
> -extern int rtas_set_rtc_time(struct rtc_time *rtc_time);
> +time64_t rtas_get_boot_time(void);
> +void rtas_get_rtc_time(struct rtc_time *rtc_time);
> +int rtas_set_rtc_time(struct rtc_time *rtc_time);
>  
> -extern unsigned int rtas_busy_delay_time(int status);
> +unsigned int rtas_busy_delay_time(int status);
>  bool rtas_busy_delay(int status);
>  
> -extern int early_init_dt_scan_rtas(unsigned long node,
> - const char *uname, int depth, void *data);
> +int early_init_dt_scan_rtas(unsigned long node, const char *uname,
> int depth, void *data);
>  
> -extern void pSeries_log_error(char *buf, unsigned int err_type, int
> fatal);
> +void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
>  
>  #ifdef CONFIG_PPC_PSERIES
>  extern time64_t last_rtas_event;
> -extern int clobbering_unread_rtas_event(void);
> +int clobbering_unread_rtas_event(void);
>  int rtas_syscall_dispatch_ibm_suspend_me(u64 handle);
>  #else
>  static inline int clobbering_unread_rtas_event(void) { return 0; }
> @@ -454,7 +453,7 @@ static inline int
> rtas_syscall_dispatch_ibm_suspend_me(u64 handle)
>  #endif
>  
>  #ifdef CONFIG_PPC_RTAS_DAEMON
> -extern void rtas_cancel_event_scan(void);
> +void rtas_cancel_event_scan(void);
>  #else
>  static inline void rtas_cancel_event_scan(void) { }
>  #endif
> @@ -479,7 +478,7 @@ static inline void rtas_cancel_event_scan(void) {
> }
>   *  for all rtas calls that require an error buffer argument.
>   *  This includes 'check-exception' and 'rtas-last-error'.
>   */
> -extern int rtas_get_error_log_max(void);
> +int rtas_get_error_log_max(void);
>  
>  /* Event Scan Parameters */
>  #define EVENT_SCAN_ALL_EVENTS0xf000
> @@ -518,8 +517,8 @@ static inline u32 rtas_config_addr(int busno, int
> devfn, int reg)
>   (devfn << 8) | (reg & 0xff);
>  }
>  
> -extern void rtas_give_timebase(void);
> -extern void 

Re: [PATCH v2 4/5] powerpc/rtas: Remove trailing space

2023-11-19 Thread Andrew Donnellan
On Tue, 2023-11-14 at 11:22 -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch 
> 
> Use scripts/cleanfile to remove instances of trailing space in the
> core RTAS code and header.
> 
> Signed-off-by: Nathan Lynch 

Thanks for the cleanup, LGTM.

Reviewed-by: Andrew Donnellan 

> ---
>  arch/powerpc/include/asm/rtas.h |  6 +++---
>  arch/powerpc/kernel/rtas.c  | 18 +-
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/rtas.h
> b/arch/powerpc/include/asm/rtas.h
> index 2365668fc13e..1bed6be8ada3 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -268,7 +268,7 @@ typedef struct {
>  #define RTAS_TYPE_DEALLOC0xE3
>  #define RTAS_TYPE_DUMP   0xE4
>  #define RTAS_TYPE_HOTPLUG0xE5
> -/* I don't add PowerMGM events right now, this is a different topic
> */ 
> +/* I don't add PowerMGM events right now, this is a different topic
> */
>  #define RTAS_TYPE_PMGM_POWER_SW_ON   0x60
>  #define RTAS_TYPE_PMGM_POWER_SW_OFF  0x61
>  #define RTAS_TYPE_PMGM_LID_OPEN  0x62
> @@ -461,7 +461,7 @@ static inline void rtas_cancel_event_scan(void) {
> }
>  
>  /* Error types logged.  */
>  #define ERR_FLAG_ALREADY_LOGGED  0x0
> -#define ERR_FLAG_BOOT0x1 /* log was pulled from NVRAM
> on boot */
> +#define ERR_FLAG_BOOT0x1 /* log was pulled from NVRAM
> on boot */
>  #define ERR_TYPE_RTAS_LOG0x2 /* from rtas event-scan */
>  #define ERR_TYPE_KERNEL_PANIC0x4 /* from die()/panic() */
>  #define ERR_TYPE_KERNEL_PANIC_GZ 0x8 /* ditto, compressed */
> @@ -471,7 +471,7 @@ static inline void rtas_cancel_event_scan(void) {
> }
>   (ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC |
> ERR_TYPE_KERNEL_PANIC_GZ)
>  
>  #define RTAS_DEBUG KERN_DEBUG "RTAS: "
> - 
> +
>  #define RTAS_ERROR_LOG_MAX 2048
>  
>  /*
> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
> index b5b340a91157..c49f078382a9 100644
> --- a/arch/powerpc/kernel/rtas.c
> +++ b/arch/powerpc/kernel/rtas.c
> @@ -670,7 +670,7 @@ static void call_rtas_display_status_delay(char
> c)
>   static int pending_newline = 0;  /* did last write end with
> unprinted newline? */
>   static int width = 16;
>  
> - if (c == '\n') {
> + if (c == '\n') {
>   while (width-- > 0)
>   call_rtas_display_status(' ');
>   width = 16;
> @@ -680,7 +680,7 @@ static void call_rtas_display_status_delay(char
> c)
>   if (pending_newline) {
>   call_rtas_display_status('\r');
>   call_rtas_display_status('\n');
> - } 
> + }
>   pending_newline = 0;
>   if (width--) {
>   call_rtas_display_status(c);
> @@ -820,7 +820,7 @@ void rtas_progress(char *s, unsigned short hex)
>   else
>   rtas_call(display_character, 1, 1, NULL,
> '\r');
>   }
> - 
> +
>   if (row_width)
>   width = row_width[current_line];
>   else
> @@ -840,9 +840,9 @@ void rtas_progress(char *s, unsigned short hex)
>   spin_unlock(_lock);
>   return;
>   }
> - 
> +
>   /* RTAS wants CR-LF, not just LF */
> - 
> +
>   if (*os == '\n') {
>   rtas_call(display_character, 1, 1,
> NULL, '\r');
>   rtas_call(display_character, 1, 1,
> NULL, '\n');
> @@ -852,7 +852,7 @@ void rtas_progress(char *s, unsigned short hex)
>    */
>   rtas_call(display_character, 1, 1,
> NULL, *os);
>   }
> - 
> +
>   if (row_width)
>   width = row_width[current_line];
>   else
> @@ -861,15 +861,15 @@ void rtas_progress(char *s, unsigned short hex)
>   width--;
>   rtas_call(display_character, 1, 1, NULL,
> *os);
>   }
> - 
> +
>   os++;
> - 
> +
>   /* if we overwrite the screen length */
>   if (width <= 0)
>   while ((*os != 0) && (*os != '\n') && (*os
> != '\r'))
>   os++;
>   }
> - 
> +
>   spin_unlock(_lock);
>  }
>  EXPORT_SYMBOL_GPL(rtas_progress);/* needed by
> rtas_flash module */
> 

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH v2 3/5] powerpc/rtas: Move post_mobility_fixup() declaration to pseries

2023-11-19 Thread Andrew Donnellan
On Tue, 2023-11-14 at 11:22 -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch 
> 
> This is a pseries-specific function declaration that doesn't belong
> in
> rtas.h. Move it to the pseries platform code and adjust
> pseries/suspend.c accordingly.
> 
> Signed-off-by: Nathan Lynch 

This looks correct to me (the other user is in mobility.c which already
has the header file included).

Reviewed-by: Andrew Donnellan 

> ---
>  arch/powerpc/include/asm/rtas.h  | 1 -
>  arch/powerpc/platforms/pseries/pseries.h | 1 +
>  arch/powerpc/platforms/pseries/suspend.c | 1 +
>  3 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/include/asm/rtas.h
> b/arch/powerpc/include/asm/rtas.h
> index c6568a647cd0..2365668fc13e 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -444,7 +444,6 @@ extern void pSeries_log_error(char *buf, unsigned
> int err_type, int fatal);
>  #ifdef CONFIG_PPC_PSERIES
>  extern time64_t last_rtas_event;
>  extern int clobbering_unread_rtas_event(void);
> -extern void post_mobility_fixup(void);
>  int rtas_syscall_dispatch_ibm_suspend_me(u64 handle);
>  #else
>  static inline int clobbering_unread_rtas_event(void) { return 0; }
> diff --git a/arch/powerpc/platforms/pseries/pseries.h
> b/arch/powerpc/platforms/pseries/pseries.h
> index 8376f03f932a..1c2d736f600d 100644
> --- a/arch/powerpc/platforms/pseries/pseries.h
> +++ b/arch/powerpc/platforms/pseries/pseries.h
> @@ -55,6 +55,7 @@ extern int dlpar_detach_node(struct device_node *);
>  extern int dlpar_acquire_drc(u32 drc_index);
>  extern int dlpar_release_drc(u32 drc_index);
>  extern int dlpar_unisolate_drc(u32 drc_index);
> +void post_mobility_fixup(void);
>  
>  void queue_hotplug_event(struct pseries_hp_errorlog *hp_errlog);
>  int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_errlog);
> diff --git a/arch/powerpc/platforms/pseries/suspend.c
> b/arch/powerpc/platforms/pseries/suspend.c
> index 5c43435472cc..382003dfdb9a 100644
> --- a/arch/powerpc/platforms/pseries/suspend.c
> +++ b/arch/powerpc/platforms/pseries/suspend.c
> @@ -13,6 +13,7 @@
>  #include 
>  #include 
>  #include 
> +#include "pseries.h"
>  
>  static struct device suspend_dev;
>  
> 

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH v2 2/5] powerpc/rtas: Remove unused rtas_service_present()

2023-11-19 Thread Andrew Donnellan
On Tue, 2023-11-14 at 11:22 -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch 
> 
> rtas_service_present() has no more users.
> 
> rtas_function_implemented() is now the appropriate API for
> determining
> whether a given RTAS function is available to call.
> 
> Signed-off-by: Nathan Lynch 

grep confirms this.

Reviewed-by: Andrew Donnellan 

> ---
>  arch/powerpc/include/asm/rtas.h | 1 -
>  arch/powerpc/kernel/rtas.c  | 5 -
>  2 files changed, 6 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/rtas.h
> b/arch/powerpc/include/asm/rtas.h
> index 3bf7f0a4b07e..c6568a647cd0 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -409,7 +409,6 @@ static inline bool
> rtas_function_implemented(const rtas_fn_handle_t handle)
>   return rtas_function_token(handle) != RTAS_UNKNOWN_SERVICE;
>  }
>  extern int rtas_token(const char *service);
> -extern int rtas_service_present(const char *service);
>  extern int rtas_call(int token, int, int, int *, ...);
>  void rtas_call_unlocked(struct rtas_args *args, int token, int
> nargs,
>   int nret, ...);
> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
> index eddc031c4b95..b5b340a91157 100644
> --- a/arch/powerpc/kernel/rtas.c
> +++ b/arch/powerpc/kernel/rtas.c
> @@ -900,11 +900,6 @@ int rtas_token(const char *service)
>  }
>  EXPORT_SYMBOL_GPL(rtas_token);
>  
> -int rtas_service_present(const char *service)
> -{
> - return rtas_token(service) != RTAS_UNKNOWN_SERVICE;
> -}
> -
>  #ifdef CONFIG_RTAS_ERROR_LOGGING
>  
>  static u32 rtas_error_log_max __ro_after_init = RTAS_ERROR_LOG_MAX;
> 

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


Re: [PATCH v2 1/5] powerpc/rtas: Drop declaration of undefined call_rtas() function

2023-11-19 Thread Andrew Donnellan
On Tue, 2023-11-14 at 11:22 -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch 
> 
> The call_rtas() function has never been a part of arch/powerpc, and
> its implementation was removed from arch/ppc by commit 0a26b1364f14
> ("ppc: Remove CHRP, POWER3 and POWER4 support from arch/ppc").
> 
> Signed-off-by: Nathan Lynch 

grep confirms this.

Reviewed-by: Andrew Donnellan 

> ---
>  arch/powerpc/include/asm/rtas.h | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/rtas.h
> b/arch/powerpc/include/asm/rtas.h
> index c697c3c74694..3bf7f0a4b07e 100644
> --- a/arch/powerpc/include/asm/rtas.h
> +++ b/arch/powerpc/include/asm/rtas.h
> @@ -542,8 +542,6 @@ static inline void pSeries_coalesce_init(void) {
> }
>  static inline void rtas_initialize(void) { }
>  #endif
>  
> -extern int call_rtas(const char *, int, int, unsigned long *, ...);
> -
>  #ifdef CONFIG_HV_PERF_CTRS
>  void read_24x7_sys_info(void);
>  #else
> 

-- 
Andrew DonnellanOzLabs, ADL Canberra
a...@linux.ibm.com   IBM Australia Limited


[PATCH v2] asm/io: remove unnecessary xlate_dev_mem_ptr() and unxlate_dev_mem_ptr()

2023-11-19 Thread Kefeng Wang
The asm-generic/io.h already has default define, remove unnecessary
arch's defination.

Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Russell King 
Cc: Brian Cain 
Cc: "James E.J. Bottomley" 
Cc: Nicholas Piggin 
Cc: Christophe Leroy 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: "David S. Miller" 
Cc: Stanislav Kinsburskii 
Reviewed-by: Geert Uytterhoeven   [m68k]
Acked-by: Geert Uytterhoeven  [m68k]
Reviewed-by: Geert Uytterhoeven[sh]
Signed-off-by: Kefeng Wang 
---
v2:
- remove mips change, since it needs more extra works for enable
  
 arch/alpha/include/asm/io.h| 6 --
 arch/arm/include/asm/io.h  | 6 --
 arch/hexagon/include/asm/io.h  | 6 --
 arch/m68k/include/asm/io_mm.h  | 6 --
 arch/parisc/include/asm/io.h   | 6 --
 arch/powerpc/include/asm/io.h  | 6 --
 arch/sh/include/asm/io.h   | 7 ---
 arch/sparc/include/asm/io_64.h | 6 --
 8 files changed, 49 deletions(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 7aeaf7c30a6f..5e5d21ebc584 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -651,12 +651,6 @@ extern void outsl (unsigned long port, const void *src, 
unsigned long count);
 #endif
 #define RTC_ALWAYS_BCD 0
 
-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-
 /*
  * These get provided from  since alpha does not
  * select GENERIC_IOMAP.
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 56b08ed6cc3b..1815748f5d2a 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -407,12 +407,6 @@ struct pci_dev;
 #define pci_iounmap pci_iounmap
 extern void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
 
-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-
 #include 
 
 #ifdef CONFIG_MMU
diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h
index e2b308e32a37..97d57751ce3b 100644
--- a/arch/hexagon/include/asm/io.h
+++ b/arch/hexagon/include/asm/io.h
@@ -58,12 +58,6 @@ static inline void *phys_to_virt(unsigned long address)
return __va(address);
 }
 
-/*
- * convert a physical pointer to a virtual kernel pointer for
- * /dev/mem access.
- */
-#define xlate_dev_mem_ptr(p)__va(p)
-
 /*
  * IO port access primitives.  Hexagon doesn't have special IO access
  * instructions; all I/O is memory mapped.
diff --git a/arch/m68k/include/asm/io_mm.h b/arch/m68k/include/asm/io_mm.h
index 47525f2a57e1..090aec54b8fa 100644
--- a/arch/m68k/include/asm/io_mm.h
+++ b/arch/m68k/include/asm/io_mm.h
@@ -389,12 +389,6 @@ static inline void isa_delay(void)
 
 #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
 
-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-
 #define readb_relaxed(addr)readb(addr)
 #define readw_relaxed(addr)readw(addr)
 #define readl_relaxed(addr)readl(addr)
diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h
index 366537042465..9c06cafb0e70 100644
--- a/arch/parisc/include/asm/io.h
+++ b/arch/parisc/include/asm/io.h
@@ -267,12 +267,6 @@ extern void iowrite64be(u64 val, void __iomem *addr);
 #define iowrite16_rep iowrite16_rep
 #define iowrite32_rep iowrite32_rep
 
-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-
 extern int devmem_is_allowed(unsigned long pfn);
 
 #include 
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 5220274a6277..79421c285066 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -709,12 +709,6 @@ static inline void name at 
\
 #define memcpy_fromio memcpy_fromio
 #define memcpy_toio memcpy_toio
 
-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-
 /*
  * We don't do relaxed operations yet, at least not with this semantic
  */
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index ac521f287fa5..be7ac06423a9 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -304,13 +304,6 @@ unsigned long long poke_real_address_q(unsigned long long 
addr,
 
 #define ioremap_uc ioremap
 
-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-#define unxlate_dev_mem_ptr(p, v) do { } while (0)
-
 #include 
 
 #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
index 9303270b22f3..75ae9bf3bb7b 100644
--- a/arch/sparc/include/asm/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
@@ -470,12 +470,6 @@ static inline int sbus_can_burst64(void)
 struct device;
 void sbus_set_sbus64(struct device *, 

Re: [PATCH] asm/io: remove unnecessary xlate_dev_mem_ptr() and unxlate_dev_mem_ptr()

2023-11-19 Thread Kefeng Wang




On 2023/11/20 3:34, Geert Uytterhoeven wrote:

On Sat, Nov 18, 2023 at 11:09 AM Kefeng Wang  wrote:

The asm-generic/io.h already has default definition, remove unnecessary
arch's defination.

Cc: Richard Henderson 
Cc: Ivan Kokshaysky 
Cc: Russell King 
Cc: Brian Cain 
Cc: "James E.J. Bottomley" 
Cc: Nicholas Piggin 
Cc: Christophe Leroy 
Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: "David S. Miller" 
Cc: Stanislav Kinsburskii 
Signed-off-by: Kefeng Wang 



  arch/m68k/include/asm/io_mm.h  | 6 --


Reviewed-by: Geert Uytterhoeven 
Acked-by: Geert Uytterhoeven 


  arch/sh/include/asm/io.h   | 7 ---


Reviewed-by: Geert Uytterhoeven 



Thanks,



--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -548,13 +548,6 @@ extern void (*_dma_cache_inv)(unsigned long start, 
unsigned long size);
  #define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + 
__CSR_32_ADJUST) = (v))
  #define csr_in32(a)(*(volatile u32 *)((unsigned long)(a) + 
__CSR_32_ADJUST))

-/*
- * Convert a physical pointer to a virtual kernel pointer for /dev/mem
- * access
- */
-#define xlate_dev_mem_ptr(p)   __va(p)
-#define unxlate_dev_mem_ptr(p, v) do { } while (0)
-
  void __ioread64_copy(void *to, const void __iomem *from, size_t count);


Missing #include , according to the build bot report.


Will check the bot report.




  #endif /* _ASM_IO_H */


Gr{oetje,eeting}s,

 Geert



Please backport feea65a338e5 ("powerpc/powernv: Fix fortify source warnings in opal-prd.c")

2023-11-19 Thread Michael Ellerman
Hi,

Please backport feea65a338e5 ("powerpc/powernv: Fix fortify source
warnings in opal-prd.c") to the 6.5, 6.1, 5.15, 5.10 stable trees.

cheers


Re: [PATCH] asm/io: remove unnecessary xlate_dev_mem_ptr() and unxlate_dev_mem_ptr()

2023-11-19 Thread Geert Uytterhoeven
On Sat, Nov 18, 2023 at 11:09 AM Kefeng Wang  wrote:
> The asm-generic/io.h already has default definition, remove unnecessary
> arch's defination.
>
> Cc: Richard Henderson 
> Cc: Ivan Kokshaysky 
> Cc: Russell King 
> Cc: Brian Cain 
> Cc: "James E.J. Bottomley" 
> Cc: Nicholas Piggin 
> Cc: Christophe Leroy 
> Cc: Yoshinori Sato 
> Cc: Rich Felker 
> Cc: "David S. Miller" 
> Cc: Stanislav Kinsburskii 
> Signed-off-by: Kefeng Wang 

>  arch/m68k/include/asm/io_mm.h  | 6 --

Reviewed-by: Geert Uytterhoeven 
Acked-by: Geert Uytterhoeven 

>  arch/sh/include/asm/io.h   | 7 ---

Reviewed-by: Geert Uytterhoeven 

> --- a/arch/mips/include/asm/io.h
> +++ b/arch/mips/include/asm/io.h
> @@ -548,13 +548,6 @@ extern void (*_dma_cache_inv)(unsigned long start, 
> unsigned long size);
>  #define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + 
> __CSR_32_ADJUST) = (v))
>  #define csr_in32(a)(*(volatile u32 *)((unsigned long)(a) + 
> __CSR_32_ADJUST))
>
> -/*
> - * Convert a physical pointer to a virtual kernel pointer for /dev/mem
> - * access
> - */
> -#define xlate_dev_mem_ptr(p)   __va(p)
> -#define unxlate_dev_mem_ptr(p, v) do { } while (0)
> -
>  void __ioread64_copy(void *to, const void __iomem *from, size_t count);

Missing #include , according to the build bot report.

>  #endif /* _ASM_IO_H */

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


[PATCH v2] powerpc: Don't clobber fr0/vs0 during fp|altivec register save

2023-11-19 Thread Timothy Pearson
During floating point and vector save to thread data fr0/vs0 are clobbered
by the FPSCR/VSCR store routine.  This leads to userspace register corruption
and application data corruption / crash under the following rare condition:

 * A userspace thread is executing with VSX/FP mode enabled
 * The userspace thread is making active use of fr0 and/or vs0
 * An IPI is taken in kernel mode, forcing the userspace thread to reschedule
 * The userspace thread is interrupted by the IPI before accessing data it
   previously stored in fr0/vs0
 * The thread being switched in by the IPI has a pending signal

If these exact criteria are met, then the following sequence happens:

 * The existing thread FP storage is still valid before the IPI, due to a
   prior call to save_fpu() or store_fp_state().  Note that the current
   fr0/vs0 registers have been clobbered, so the FP/VSX state in registers
   is now invalid pending a call to restore_fp()/restore_altivec().
 * IPI -- FP/VSX register state remains invalid
 * interrupt_exit_user_prepare_main() calls do_notify_resume(),
   due to the pending signal
 * do_notify_resume() eventually calls save_fpu() via giveup_fpu(), which
   merrily reads and saves the invalid FP/VSX state to thread local storage.
 * interrupt_exit_user_prepare_main() calls restore_math(), writing the invalid
   FP/VSX state back to registers.
 * Execution is released to userspace, and the application crashes or corrupts
   data.

Without the pending signal, do_notify_resume() is never called, therefore the
invalid register state does't matter as it is overwritten nearly immediately
by interrupt_exit_user_prepare_main() calling restore_math() before return
to userspace.

Restore fr0/vs0 after FPSCR/VSCR store has completed for both the fp and
altivec register save paths.

Tested under QEMU in kvm mode, running on a Talos II workstation with dual
POWER9 DD2.2 CPUs.

Closes: 
https://lore.kernel.org/all/480932026.45576726.1699374859845.javamail.zim...@raptorengineeringinc.com/
Closes: 
https://lore.kernel.org/linuxppc-dev/480221078.47953493.1700206777956.javamail.zim...@raptorengineeringinc.com/
Tested-by: Timothy Pearson 
Tested-by: Jens Axboe 
Signed-off-by: Timothy Pearson 
---
 arch/powerpc/kernel/fpu.S| 13 +
 arch/powerpc/kernel/vector.S |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index 6a9acfb690c9..2f8f3f93cbb6 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -23,6 +23,15 @@
 #include 
 
 #ifdef CONFIG_VSX
+#define __REST_1FPVSR(n,c,base)
\
+BEGIN_FTR_SECTION  \
+   b   2f; \
+END_FTR_SECTION_IFSET(CPU_FTR_VSX);\
+   REST_FPR(n,base);   \
+   b   3f; \
+2: REST_VSR(n,c,base); \
+3:
+
 #define __REST_32FPVSRS(n,c,base)  \
 BEGIN_FTR_SECTION  \
b   2f; \
@@ -41,9 +50,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX);  
\
 2: SAVE_32VSRS(n,c,base);  \
 3:
 #else
+#define __REST_1FPVSR(n,b,base)REST_FPR(n, base)
 #define __REST_32FPVSRS(n,b,base)  REST_32FPRS(n, base)
 #define __SAVE_32FPVSRS(n,b,base)  SAVE_32FPRS(n, base)
 #endif
+#define REST_1FPVSR(n,c,base)   __REST_1FPVSR(n,__REG_##c,__REG_##base)
 #define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base)
 #define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
 
@@ -67,6 +78,7 @@ _GLOBAL(store_fp_state)
SAVE_32FPVSRS(0, R4, R3)
mffsfr0
stfdfr0,FPSTATE_FPSCR(r3)
+   REST_1FPVSR(0, R4, R3)
blr
 EXPORT_SYMBOL(store_fp_state)
 
@@ -138,4 +150,5 @@ _GLOBAL(save_fpu)
 2: SAVE_32FPVSRS(0, R4, R6)
mffsfr0
stfdfr0,FPSTATE_FPSCR(r6)
+   REST_1FPVSR(0, R4, R6)
blr
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index 4094e4c4c77a..80b3f6e476b6 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -33,6 +33,7 @@ _GLOBAL(store_vr_state)
mfvscr  v0
li  r4, VRSTATE_VSCR
stvxv0, r4, r3
+   lvx v0, 0, r3
blr
 EXPORT_SYMBOL(store_vr_state)
 
@@ -109,6 +110,7 @@ _GLOBAL(save_altivec)
mfvscr  v0
li  r4,VRSTATE_VSCR
stvxv0,r4,r7
+   lvx v0,0,r7
blr
 
 #ifdef CONFIG_VSX
-- 
2.39.2


Re: [PATCH] powerpc: Don't clobber fr0/vs0 during fp|altivec register save

2023-11-19 Thread Jens Axboe
On 11/18/23 4:45 PM, Timothy Pearson wrote:
> During floating point and vector save to thread data fr0/vs0 are clobbered
> by the FPSCR/VSCR store routine.  This leads to userspace register corruption
> and application data corruption / crash under the following rare condition:
> 
>  * A userspace thread is executing with VSX/FP mode enabled
>  * The userspace thread is making active use of fr0 and/or vs0
>  * An IPI is taken in kernel mode, forcing the userspace thread to reschedule
>  * The userspace thread is interrupted by the IPI before accessing data it
>previously stored in fr0/vs0
>  * The thread being switched in by the IPI has a pending signal
> 
> If these exact criteria are met, then the following sequence happens:
> 
>  * The existing thread FP storage is still valid before the IPI, due to a
>prior call to save_fpu() or store_fp_state().  Note that the current
>fr0/vs0 registers have been clobbered, so the FP/VSX state in registers
>is now invalid pending a call to restore_fp()/restore_altivec().
>  * IPI -- FP/VSX register state remains invalid
>  * interrupt_exit_user_prepare_main() calls do_notify_resume(),
>due to the pending signal
>  * do_notify_resume() eventually calls save_fpu() via giveup_fpu(), which
>merrily reads and saves the invalid FP/VSX state to thread local storage.
>  * interrupt_exit_user_prepare_main() calls restore_math(), writing the 
> invalid
>FP/VSX state back to registers.
>  * Execution is released to userspace, and the application crashes or corrupts
>data.

What an epic bug hunt! Hats off to you for seeing it through and getting
to the bottom of it. Particularly difficult as the commit that made it
easier to trigger was in no way related to where the actual bug was.

I ran this on the vm I have access to, and it survived 2x500 iterations.
Happy to call that good:

Tested-by: Jens Axboe 

-- 
Jens Axboe



[PATCH] ASoC: fsl_mqs: Remove duplicate linux/of.h header

2023-11-19 Thread Lucas Tanure
Remove linux/of.h as is included more than once.
Reported by make includecheck.

Signed-off-by: Lucas Tanure 
---
 sound/soc/fsl/fsl_mqs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_mqs.c b/sound/soc/fsl/fsl_mqs.c
index f2d74ec05cdf..86704ba5f6f0 100644
--- a/sound/soc/fsl/fsl_mqs.c
+++ b/sound/soc/fsl/fsl_mqs.c
@@ -10,7 +10,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.42.1



Re: [PATCH v9 23/27] net: wan: framer: Add support for the Lantiq PEF2256 framer

2023-11-19 Thread kernel test robot
Hi Herve,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on linusw-pinctrl/devel linusw-pinctrl/for-next 
robh/for-next linus/master v6.7-rc1 next-20231117]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Herve-Codina/soc-fsl-cpm1-tsa-Fix-__iomem-addresses-declaration/20231115-224517
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 
for-next
patch link:
https://lore.kernel.org/r/20231115144007.478111-24-herve.codina%40bootlin.com
patch subject: [PATCH v9 23/27] net: wan: framer: Add support for the Lantiq 
PEF2256 framer
config: s390-kismet-CONFIG_MFD_CORE-CONFIG_FRAMER_PEF2256-0-0 
(https://download.01.org/0day-ci/archive/20231119/202311191651.ayfggtmd-...@intel.com/config)
reproduce: 
(https://download.01.org/0day-ci/archive/20231119/202311191651.ayfggtmd-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202311191651.ayfggtmd-...@intel.com/

kismet warnings: (new ones prefixed by >>)
>> kismet: WARNING: unmet direct dependencies detected for MFD_CORE when 
>> selected by FRAMER_PEF2256
   
   WARNING: unmet direct dependencies detected for MFD_CORE
 Depends on [n]: HAS_IOMEM [=n]
 Selected by [y]:
 - FRAMER_PEF2256 [=y] && NETDEVICES [=y] && WAN [=y] && FRAMER [=y] && OF 
[=y]

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki