Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1619129pxf; Fri, 12 Mar 2021 14:30:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxsbt0MeYvQ19G9zU2kdAAy7ATSwFuadXVergfO4SjRolHFx3GUlwFJioKrjjFCW5jdKwwe X-Received: by 2002:a17:906:2ed1:: with SMTP id s17mr11010423eji.153.1615588229116; Fri, 12 Mar 2021 14:30:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615588229; cv=none; d=google.com; s=arc-20160816; b=a1DGK9oEZFLlfvnGkexUjKUWbnz2KvG60c0A9mE044R8xCQJwEcW8ZizlsgA8wyRIg sHoVemc55ZegW5gGH8RUNydzRNuY5Esv64vMV4xVEPP2zEs68KTGpo0mNH71w4IHXN34 aGIjaTABEqHoCDlBvP1FSjloLKGWiCDWmd3saGE6RyNhUue1zC/uoM1Vk35hPb/ebHtU DXGC3uE35FLWIHvrxjNRD0MsPwzPrrxpiDxJVqfi9vSqGApSr+ha0bomK8GT7u59E+60 +jU0j2Zh01iknckMWauXPV1NAeNofRk6J1dpqoeUYu88bevWujA+OTrkyjWp6jgD2ZsV zURA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=P18jgZ7eS9bUH2AeICrvPCqkPbS4aOBP1BC3aWydqks=; b=yOhkxfd3JD5TetU9nNTtRxBhnBk5Fs4I7s6xv0cmg69BuVFhWst3+dU40BpjA/eYdu BYANHnmW+/0Awu1M1QDvcT9iEQiX81ICRXfHn+PbzP4adOCSpttDOh/wMZygMWd2+6ti 0QsbOCaqq7kMddWaEEGPfI2DuIkEDiT8RHljjGnWj+om8/xpvoOiN3ifXxvkNUrniC/y nt81MsZkX73XRg1NQzgr2JWs9IKRxqwCY4xI/fBcn19u6YxnW+bQnBjRuSo1+8kxFZJl QgvBqa89U/l6TnbSO7gilIiHkyt3kpjH4Drzvk1GgPPXnuWGGCnt3yLHcIjvTrV/JFH0 XhlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b26si3383122eds.574.2021.03.12.14.30.06; Fri, 12 Mar 2021 14:30:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235569AbhCLW1v (ORCPT + 99 others); Fri, 12 Mar 2021 17:27:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235560AbhCLW1i (ORCPT ); Fri, 12 Mar 2021 17:27:38 -0500 Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 054A4C061574; Fri, 12 Mar 2021 14:27:38 -0800 (PST) Received: by sf.home (Postfix, from userid 1000) id 9FDD95A22061; Fri, 12 Mar 2021 22:27:32 +0000 (GMT) From: Sergei Trofimovich To: linux-kernel@vger.kernel.org Cc: Sergei Trofimovich , linux-ia64@vger.kernel.org, storagedev@microchip.com, linux-scsi@vger.kernel.org, Joe Szczypek , Scott Benesh , Scott Teel , Tomas Henzl , "Martin K. Petersen" , Don Brace , John Paul Adrian Glaubitz Subject: [PATCH] hpsa: fix boot on ia64 (atomic_t alignment) Date: Fri, 12 Mar 2021 22:27:18 +0000 Message-Id: <20210312222718.4117508-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <5532f9ab-7555-d51b-f4d5-f9b72a61f248@redhat.com> References: <5532f9ab-7555-d51b-f4d5-f9b72a61f248@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 CC: Scott Benesh CC: Scott Teel CC: Tomas Henzl CC: "Martin K. Petersen" CC: Don Brace Reported-by: John Paul Adrian Glaubitz Suggested-by: Don Brace Fixes: f749d8b7a "scsi: hpsa: Correct dev cmds outstanding for retried cmds" Signed-off-by: Sergei Trofimovich --- 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 /* static_assert */ +#include /* 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 -- 2.30.2