From patchwork Mon Jul 9 04:44:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 941092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mwJKLZ1n"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="iqfyenw2"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41PCSD2Y2Lz9s00 for ; Mon, 9 Jul 2018 14:45:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=RsrI74MyBu67lfGumyV+5I8pu7gNXYpdWws6j9bUsi8=; b=mwJ KLZ1nTRxJZbWwfVb2IAVjLWWAvrGeAxZWOZsSkd/S4ET+pOngv/yKQhZ70b2a0m1HYAPEV+njfHnU P3BhH/Ys9Lt8OIG+mSexPp3U5V2qhnjC8C7+C3FRvN1QKQZ3tLWFXn5Kctfdpsgh49cNXlR/I3YNU YSM9y6pGQclGo7eC2wO1GZy3+Cl4h6mbZR8uYIpKsGnTBb2ifbZ7JLYebP/UQXQY++NWghzK60z6E MjQqJpDbMN+D+87F+mqcmZDmvNtWbH+T76nwb4HPy8WLeBu/rDV9ZnKF1D3dQUNZj/LkER3WNaCK9 YqL13uMIkuOLt6fFsQG3MwRrQyE9qKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcO30-0003Sv-3v; Mon, 09 Jul 2018 04:45:14 +0000 Received: from smtprelay.synopsys.com ([198.182.47.9]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcO2x-00024s-3X for linux-snps-arc@lists.infradead.org; Mon, 09 Jul 2018 04:45:12 +0000 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 5AB5C24E229D; Sun, 8 Jul 2018 21:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1531111498; bh=yaiz/OMXY4OwQyCA8PAtPxBmZBM6Ex7xnI+AEj7QvtY=; h=From:To:Cc:Subject:Date:From; b=iqfyenw2syKVZszXl3odcpRkjkNAtl78WF3wvvQqSvjQE4UM7HlNaDuvXQAUnKYUS ZFFTrtMpMs8GV78gGLupiiun8CYPco/QrtPyAs7Zn2xLmcP4RtS4zRNxUozkuReIIJ CHs9KIN1gVts2gk4rZrfxBt2Q8gtRKHNOiCrVX7nknJvAoCozk3J0W68GyTR8DipCe JMittQNX0LA+ZfQPibFnNYN+4gJfgN9XnCVnnfWY2BW4lAlu04WrXhtFS0twD9prL6 Mg7D1EcdlTcnECliG7PMNjKfNnP/6Ti7FinzbtGf76O+/da3EZD2M8llPuO4PiU+A4 RM09ZxD0HPyHg== Received: from abrodkin-7480l.internal.synopsys.com (unknown [10.121.8.87]) by mailhost.synopsys.com (Postfix) with ESMTP id 939EC3A2B; Sun, 8 Jul 2018 21:44:54 -0700 (PDT) From: Alexey Brodkin To: linux-kernel@vger.kernel.org Subject: [RESEND PATCH v2] devres: Really align data field to unsigned long long Date: Mon, 9 Jul 2018 07:44:44 +0300 Message-Id: <20180709044444.6397-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180708_214511_182970_B9AA7F6C X-CRM114-Status: GOOD ( 10.25 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Greg KH , Alexey Brodkin , stable@vger.kernel.org, Greg Kroah-Hartman , Thomas Gleixner , linux-snps-arc@lists.infradead.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Depending on ABI "long long" type of a particular 32-bit CPU might be aligned by either word (32-bits) or double word (64-bits). Make sure "data" is really 64-bit aligned for any 32-bit CPU. At least for 32-bit ARC cores ABI requires "long long" types to be aligned by normal 32-bit word. This makes "data" field aligned to 12 bytes. Which is still OK as long as we use 32-bit data only. But once we want to use native atomic64_t type (i.e. when we use special instructions LLOCKD/SCONDD for accessing 64-bit data) we easily hit misaligned access exception. That's because even on CPUs capable of non-aligned data access LL/SC instructions require strict alignment. Signed-off-by: Alexey Brodkin Cc: Greg Kroah-Hartman Cc: Thomas Gleixner Cc: stable@vger.kernel.org --- Changes v1 -> v2: * Reworded commit message * Inserted comment right in source [Thomas] drivers/base/devres.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index f98a097e73f2..466fa59c866a 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -24,8 +24,12 @@ struct devres_node { struct devres { struct devres_node node; - /* -- 3 pointers */ - unsigned long long data[]; /* guarantee ull alignment */ + /* + * Depending on ABI "long long" type of a particular 32-bit CPU + * might be aligned by either word (32-bits) or double word (64-bits). + * Make sure "data" is really 64-bit aligned for any 32-bit CPU. + */ + unsigned long long data[] __aligned(sizeof(unsigned long long)); }; struct devres_group {