lkml.org 
[lkml]   [2021]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH] hpsa: fix boot on ia64 (atomic_t alignment)
    From
    Date
    Hello!

    On 3/12/21 11:27 PM, Sergei Trofimovich wrote:
    > The failure initially observed as boot failure on rx3600 ia64 machine
    > with RAID bus controller: Hewlett-Packard Company Smart Array P600:
    >
    > kernel unaligned access to 0xe000000105dd8b95, ip=0xa000000100b87551
    > kernel unaligned access to 0xe000000105dd8e95, ip=0xa000000100b87551
    > hpsa 0000:14:01.0: Controller reports max supported commands of 0 Using 16 instead. Ensure that firmware is up to date.
    > swapper/0[1]: error during unaligned kernel access
    >
    > Here unaligned access comes from 'struct CommandList' that happens
    > to be packed. The change f749d8b7a ("scsi: hpsa: Correct dev cmds
    > outstanding for retried cmds") introduced unexpected padding and
    > un-aligned atomic_t from natural alignment to something else.
    >
    > This change does not remove packing annotation from struct but only
    > restores alignment of atomic variable.
    >
    > The change is tested on the same rx3600 machine.
    >
    > CC: linux-ia64@vger.kernel.org
    > CC: storagedev@microchip.com
    > CC: linux-scsi@vger.kernel.org
    > CC: Joe Szczypek <jszczype@redhat.com>
    > CC: Scott Benesh <scott.benesh@microchip.com>
    > CC: Scott Teel <scott.teel@microchip.com>
    > CC: Tomas Henzl <thenzl@redhat.com>
    > CC: "Martin K. Petersen" <martin.petersen@oracle.com>
    > CC: Don Brace <don.brace@microchip.com>
    > Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    > Suggested-by: Don Brace <don.brace@microchip.com>
    > Fixes: f749d8b7a "scsi: hpsa: Correct dev cmds outstanding for retried cmds"
    > Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
    > ---
    > drivers/scsi/hpsa_cmd.h | 14 +++++++++++++-
    > 1 file changed, 13 insertions(+), 1 deletion(-)
    >
    > diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
    > index d126bb877250..617bdae9a7de 100644
    > --- a/drivers/scsi/hpsa_cmd.h
    > +++ b/drivers/scsi/hpsa_cmd.h
    > @@ -20,6 +20,9 @@
    > #ifndef HPSA_CMD_H
    > #define HPSA_CMD_H
    >
    > +#include <linux/build_bug.h> /* static_assert */
    > +#include <linux/stddef.h> /* offsetof */
    > +
    > /* general boundary defintions */
    > #define SENSEINFOBYTES 32 /* may vary between hbas */
    > #define SG_ENTRIES_IN_CMD 32 /* Max SG entries excluding chain blocks */
    > @@ -448,11 +451,20 @@ struct CommandList {
    > */
    > struct hpsa_scsi_dev_t *phys_disk;
    >
    > - bool retry_pending;
    > + int retry_pending;
    > struct hpsa_scsi_dev_t *device;
    > atomic_t refcount; /* Must be last to avoid memset in hpsa_cmd_init() */
    > } __aligned(COMMANDLIST_ALIGNMENT);
    >
    > +/*
    > + * Make sure our embedded atomic variable is aligned. Otherwise we break atomic
    > + * operations on architectures that don't support unaligned atomics like IA64.
    > + *
    > + * Ideally this header should be cleaned up to only mark individual structs as
    > + * packed.
    > + */
    > +static_assert(offsetof(struct CommandList, refcount) % __alignof__(atomic_t) == 0);
    > +
    > /* Max S/G elements in I/O accelerator command */
    > #define IOACCEL1_MAXSGENTRIES 24
    > #define IOACCEL2_MAXSGENTRIES 28

    I'm seeing this issue as well and without the patch, the kernel won't boot on multiple
    ia64 servers. Is there anything that speaks against fixing this?

    Thanks,
    Adrian

    --
    .''`. John Paul Adrian Glaubitz
    : :' : Debian Developer - glaubitz@debian.org
    `. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
    `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

    \
     
     \ /
      Last update: 2021-03-24 08:11    [W:2.940 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site