diff mbox series

[1/3] include: sbi: No need to pack struct sbi_trap_regs

Message ID 20210113100657.809754-2-anup.patel@wdc.com
State Accepted
Headers show
Series Avoid using packed structures | expand

Commit Message

Anup Patel Jan. 13, 2021, 10:06 a.m. UTC
All members in struct sbi_trap_regs are of machine word size so
no need to pack this structure. This also allows GCC to generate
more optimized instruction sequence when accessing members of
struct sbi_trap_regs.

Reported-by: Paul Campbell <taniwha@gmail.com>
Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
 include/sbi/sbi_trap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alistair Francis Jan. 13, 2021, 7:44 p.m. UTC | #1
On Wed, 2021-01-13 at 15:36 +0530, Anup Patel wrote:
> All members in struct sbi_trap_regs are of machine word size so
> no need to pack this structure. This also allows GCC to generate
> more optimized instruction sequence when accessing members of
> struct sbi_trap_regs.
> 
> Reported-by: Paul Campbell <taniwha@gmail.com>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  include/sbi/sbi_trap.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h
> index 04001df..5fb94f9 100644
> --- a/include/sbi/sbi_trap.h
> +++ b/include/sbi/sbi_trap.h
> @@ -186,7 +186,7 @@ struct sbi_trap_regs {
>         unsigned long mstatus;
>         /** mstatusH register state (only for 32-bit) */
>         unsigned long mstatusH;
> -} __packed;
> +};
>  
>  /** Representation of trap details */
>  struct sbi_trap_info {
Anup Patel Jan. 15, 2021, 5:16 a.m. UTC | #2
> -----Original Message-----
> From: Alistair Francis <Alistair.Francis@wdc.com>
> Sent: 14 January 2021 01:14
> To: Atish Patra <Atish.Patra@wdc.com>; Anup Patel
> <Anup.Patel@wdc.com>
> Cc: anup@brainfault.org; opensbi@lists.infradead.org; taniwha@gmail.com
> Subject: Re: [PATCH 1/3] include: sbi: No need to pack struct sbi_trap_regs
> 
> On Wed, 2021-01-13 at 15:36 +0530, Anup Patel wrote:
> > All members in struct sbi_trap_regs are of machine word size so no
> > need to pack this structure. This also allows GCC to generate more
> > optimized instruction sequence when accessing members of struct
> > sbi_trap_regs.
> >
> > Reported-by: Paul Campbell <taniwha@gmail.com>
> > Signed-off-by: Anup Patel <anup.patel@wdc.com>
> 
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
> 
> Alistair
> 
> > ---
> >  include/sbi/sbi_trap.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index
> > 04001df..5fb94f9 100644
> > --- a/include/sbi/sbi_trap.h
> > +++ b/include/sbi/sbi_trap.h
> > @@ -186,7 +186,7 @@ struct sbi_trap_regs {
> >         unsigned long mstatus;
> >         /** mstatusH register state (only for 32-bit) */
> >         unsigned long mstatusH;
> > -} __packed;
> > +};
> >
> >  /** Representation of trap details */
> >  struct sbi_trap_info {

Applied this patch to the riscv/opensbi repo

Regards,
Anup
diff mbox series

Patch

diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h
index 04001df..5fb94f9 100644
--- a/include/sbi/sbi_trap.h
+++ b/include/sbi/sbi_trap.h
@@ -186,7 +186,7 @@  struct sbi_trap_regs {
 	unsigned long mstatus;
 	/** mstatusH register state (only for 32-bit) */
 	unsigned long mstatusH;
-} __packed;
+};
 
 /** Representation of trap details */
 struct sbi_trap_info {