* Re: [PATCH 7/9] riscv: remove duplicate macros from ptrace.h
[not found] ` <20190411115623.5749-8-hch@lst.de>
@ 2019-04-25 19:13 ` Paul Walmsley
2019-04-25 19:54 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Paul Walmsley @ 2019-04-25 19:13 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Palmer Dabbelt, linux-riscv, linux-kernel
On Thu, 11 Apr 2019, Christoph Hellwig wrote:
> No need to have two names for the same thing.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
This is probably worth cleaning up across the entire tree.
asm-{generic,x86,arm64,powerpc}/ptrace.h all define similar GET_IP/SET_IP
macros - although it seems that arch/riscv is the only architecture that
uses them.
- Paul
> ---
> arch/riscv/include/asm/ptrace.h | 21 ++++++---------------
> arch/riscv/kernel/stacktrace.c | 8 ++++----
> arch/riscv/kernel/traps.c | 2 +-
> 3 files changed, 11 insertions(+), 20 deletions(-)
>
> diff --git a/arch/riscv/include/asm/ptrace.h b/arch/riscv/include/asm/ptrace.h
> index d35ec2f41381..9c867a4bac83 100644
> --- a/arch/riscv/include/asm/ptrace.h
> +++ b/arch/riscv/include/asm/ptrace.h
> @@ -70,47 +70,38 @@ struct pt_regs {
>
>
> /* Helpers for working with the instruction pointer */
> -#define GET_IP(regs) ((regs)->sepc)
> -#define SET_IP(regs, val) (GET_IP(regs) = (val))
> -
> static inline unsigned long instruction_pointer(struct pt_regs *regs)
> {
> - return GET_IP(regs);
> + return regs->sepc;
> }
> static inline void instruction_pointer_set(struct pt_regs *regs,
> unsigned long val)
> {
> - SET_IP(regs, val);
> + regs->sepc = val;
> }
>
> #define profile_pc(regs) instruction_pointer(regs)
>
> /* Helpers for working with the user stack pointer */
> -#define GET_USP(regs) ((regs)->sp)
> -#define SET_USP(regs, val) (GET_USP(regs) = (val))
> -
> static inline unsigned long user_stack_pointer(struct pt_regs *regs)
> {
> - return GET_USP(regs);
> + return regs->sp;
> }
> static inline void user_stack_pointer_set(struct pt_regs *regs,
> unsigned long val)
> {
> - SET_USP(regs, val);
> + regs->sp = val;
> }
>
> /* Helpers for working with the frame pointer */
> -#define GET_FP(regs) ((regs)->s0)
> -#define SET_FP(regs, val) (GET_FP(regs) = (val))
> -
> static inline unsigned long frame_pointer(struct pt_regs *regs)
> {
> - return GET_FP(regs);
> + return regs->s0;
> }
> static inline void frame_pointer_set(struct pt_regs *regs,
> unsigned long val)
> {
> - SET_FP(regs, val);
> + regs->s0 = val;
> }
>
> static inline unsigned long regs_return_value(struct pt_regs *regs)
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index a4b1d94371a0..25fe0ff81f9e 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -33,9 +33,9 @@ static void notrace walk_stackframe(struct task_struct *task,
> unsigned long fp, sp, pc;
>
> if (regs) {
> - fp = GET_FP(regs);
> - sp = GET_USP(regs);
> - pc = GET_IP(regs);
> + fp = frame_pointer(regs);
> + sp = user_stack_pointer(regs);
> + pc = instruction_pointer(regs);
> } else if (task == NULL || task == current) {
> const register unsigned long current_sp __asm__ ("sp");
> fp = (unsigned long)__builtin_frame_address(0);
> @@ -83,7 +83,7 @@ static void notrace walk_stackframe(struct task_struct *task,
>
> if (regs) {
> sp = GET_USP(regs);
> - pc = GET_IP(regs);
> + pc = instruction_pointer(regs);
> } else if (task == NULL || task == current) {
> const register unsigned long current_sp __asm__ ("sp");
> sp = current_sp;
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index 24a9333dda2c..86731a2fa218 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -70,7 +70,7 @@ void do_trap(struct pt_regs *regs, int signo, int code,
> && printk_ratelimit()) {
> pr_info("%s[%d]: unhandled signal %d code 0x%x at 0x" REG_FMT,
> tsk->comm, task_pid_nr(tsk), signo, code, addr);
> - print_vma_addr(KERN_CONT " in ", GET_IP(regs));
> + print_vma_addr(KERN_CONT " in ", instruction_pointer(regs));
> pr_cont("\n");
> show_regs(regs);
> }
> --
> 2.20.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 7/9] riscv: remove duplicate macros from ptrace.h
2019-04-25 19:13 ` [PATCH 7/9] riscv: remove duplicate macros from ptrace.h Paul Walmsley
@ 2019-04-25 19:54 ` Christoph Hellwig
2019-04-25 20:05 ` Paul Walmsley
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2019-04-25 19:54 UTC (permalink / raw)
To: Paul Walmsley
Cc: Christoph Hellwig, Palmer Dabbelt, linux-riscv, linux-kernel
On Thu, Apr 25, 2019 at 12:13:18PM -0700, Paul Walmsley wrote:
>
>
> On Thu, 11 Apr 2019, Christoph Hellwig wrote:
>
> > No need to have two names for the same thing.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> This is probably worth cleaning up across the entire tree.
>
> asm-{generic,x86,arm64,powerpc}/ptrace.h all define similar GET_IP/SET_IP
> macros - although it seems that arch/riscv is the only architecture that
> uses them.
Yes, we had that discussion before. I've started on a series for that,
but it is unlikely to touch riscv.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 9/9] riscv: call pm_power_off from machine_halt / machine_power_off
[not found] ` <20190411115623.5749-10-hch@lst.de>
@ 2019-04-25 19:57 ` Paul Walmsley
0 siblings, 0 replies; 4+ messages in thread
From: Paul Walmsley @ 2019-04-25 19:57 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Palmer Dabbelt, linux-riscv, linux-kernel, linux-pm
On Thu, 11 Apr 2019, Christoph Hellwig wrote:
> This way any override of pm_power_off also affects the halt path and
> we don't need additional infrastructure for it.
>
> Also remove the pm_power_off export - at least for now we don't have
> any modular drivers overriding it.
I'd propose that we keep the pm_power_off export - both to align with
other architectures:
$ fgrep -r pm_power_off arch/ | grep EXPORT
arch/s390/kernel/setup.c:EXPORT_SYMBOL_GPL(pm_power_off);
arch/m68k/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/hexagon/kernel/reset.c:EXPORT_SYMBOL(pm_power_off);
arch/ia64/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/sparc/kernel/process_32.c:EXPORT_SYMBOL(pm_power_off);
arch/sparc/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off);
arch/sh/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off);
arch/um/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off);
arch/openrisc/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/nios2/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/arc/kernel/reset.c:EXPORT_SYMBOL(pm_power_off);
arch/arm/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off);
arch/nds32/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/csky/kernel/power.c:EXPORT_SYMBOL(pm_power_off);
arch/alpha/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/arm64/kernel/process.c:EXPORT_SYMBOL_GPL(pm_power_off);
arch/unicore32/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/c6x/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/xtensa/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/h8300/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/powerpc/kernel/setup-common.c:EXPORT_SYMBOL_GPL(pm_power_off);
arch/mips/kernel/reset.c:EXPORT_SYMBOL(pm_power_off);
arch/riscv/kernel/reset.c:EXPORT_SYMBOL(pm_power_off);
arch/microblaze/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
arch/x86/kernel/reboot.c:EXPORT_SYMBOL(pm_power_off);
arch/parisc/kernel/process.c:EXPORT_SYMBOL(pm_power_off);
$
and to make sure there's no hassle with the drivers that expect to assign
something to it:
$ fgrep -r pm_power_off drivers/ | fgrep = | cut -f1 -d: | sort -u | wc -l
39
$
For what it's worth, I agree with the implied criticism that reassigning
pm_power_off is not a good interface. There is the obvious problem that
more than one chunk of independent code could all try to assign to
pm_power_off. However, to avoid creating a RISC-V-specific mess when
someone uses a TI PMIC driver on a RISC-V board, or tries to use ACPI with
RISC-V, fixing that seems best done as a separate tree-wide series.
...
Replacing machine_power_off() with a call to your default_power_off()
looks fine to me. However I think it makes sense to change our existing
machine_halt() (which was not added by your patch). Looking at other
major architectures - x86, ARM64, and ARM - they don't actually try to
power down the system in machine_halt(), instead just entering an
infinite loop, WFI, or calling into firmware or a hypervisor. I'd propose
that we align with that approach.
- Paul
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> arch/riscv/kernel/reset.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
> index 2a53d26ffdd6..ed637aee514b 100644
> --- a/arch/riscv/kernel/reset.c
> +++ b/arch/riscv/kernel/reset.c
> @@ -12,11 +12,15 @@
> */
>
> #include <linux/reboot.h>
> -#include <linux/export.h>
> #include <asm/sbi.h>
>
> -void (*pm_power_off)(void) = machine_power_off;
> -EXPORT_SYMBOL(pm_power_off);
> +static void default_power_off(void)
> +{
> + sbi_shutdown();
> + while (1);
> +}
> +
> +void (*pm_power_off)(void) = default_power_off;
>
> void machine_restart(char *cmd)
> {
> @@ -26,11 +30,10 @@ void machine_restart(char *cmd)
>
> void machine_halt(void)
> {
> - machine_power_off();
> + pm_power_off();
> }
>
> void machine_power_off(void)
> {
> - sbi_shutdown();
> - while (1);
> + pm_power_off();
> }
> --
> 2.20.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 7/9] riscv: remove duplicate macros from ptrace.h
2019-04-25 19:54 ` Christoph Hellwig
@ 2019-04-25 20:05 ` Paul Walmsley
0 siblings, 0 replies; 4+ messages in thread
From: Paul Walmsley @ 2019-04-25 20:05 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Paul Walmsley, Palmer Dabbelt, linux-riscv, linux-kernel
On Thu, 25 Apr 2019, Christoph Hellwig wrote:
> On Thu, Apr 25, 2019 at 12:13:18PM -0700, Paul Walmsley wrote:
> >
> >
> > On Thu, 11 Apr 2019, Christoph Hellwig wrote:
> >
> > > No need to have two names for the same thing.
> > >
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >
> > This is probably worth cleaning up across the entire tree.
> >
> > asm-{generic,x86,arm64,powerpc}/ptrace.h all define similar GET_IP/SET_IP
> > macros - although it seems that arch/riscv is the only architecture that
> > uses them.
>
> Yes, we had that discussion before. I've started on a series for that,
> but it is unlikely to touch riscv.
OK, if you're planning to post a separate series for that across the tree,
then:
Reviewed-by: Paul Walmsley <paul.walmsley@sifive.com>
for this RISC-V patch.
- Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-25 20:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20190411115623.5749-1-hch@lst.de>
[not found] ` <20190411115623.5749-8-hch@lst.de>
2019-04-25 19:13 ` [PATCH 7/9] riscv: remove duplicate macros from ptrace.h Paul Walmsley
2019-04-25 19:54 ` Christoph Hellwig
2019-04-25 20:05 ` Paul Walmsley
[not found] ` <20190411115623.5749-10-hch@lst.de>
2019-04-25 19:57 ` [PATCH 9/9] riscv: call pm_power_off from machine_halt / machine_power_off Paul Walmsley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).