From patchwork Sun Jul 8 17:56:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 941050 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=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="V9EM9Luv"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hqOtFrxk"; 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 41Nx6V3G93z9s3R for ; Mon, 9 Jul 2018 03:58:58 +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=dNwYku+6NPNru0x7goEwUebVJUMOQy9jg9zEjQ0txAM=; b=V9E M9LuvogZd1SHiZhfPOd9cQzne5ghz58QOf+twZCmGefy4zIgEV1yZm+nO/sBIlpkn/AvHXlsdH4ny CgTVZBFoqhz/fERhRJ8Vrs6j0azslCRKrPYCreKd9RPlhxgIKWpDijseho6a6f8gZwkjju1tbY654 XV6MB9gGygWrBca6Zde1UjxO07vqJ7LAZmxGfLVl2mc7wcQ+Wo+PQsEk3UVMtYHEXjezgptVkZahR vaG2GKMg4OC9yextra02RqdWk6Jajto7+sGAk1LJaVwOvspHyb6WpmpfbdKeQBqMr4eBZSt7kuUPg xESIYnDZTDQo67ktssHnX5y45sxWIWQ==; 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 1fcDxY-0008TM-Az; Sun, 08 Jul 2018 17:58:56 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcDxV-0008RO-Av for linux-snps-arc@lists.infradead.org; Sun, 08 Jul 2018 17:58:54 +0000 Received: by mail-lj1-x242.google.com with SMTP id p6-v6so12439425ljc.5 for ; Sun, 08 Jul 2018 10:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=C3ewxTalH0Xjzs4mLGQ5RRfJQ7855pQzE7NHTdIYvgk=; b=hqOtFrxk3hJPa/8DPu0GYEMFeF+hCGr7dQi7A1Rzz7gh6pDYNNFlTQBK6ACCNyS6Qa qCTpU2qLcoXZ52s/RVkXLf1k7qd90nR95I/IssN5b+0KmAcMaQnOXQ1ZNafuJJ3Yei94 DmISwkBjKDqc1aOLyEEmO98eue2ZuJ9/vrgYY/A22/uEjgFEllWa67VnL00jAn40q7Bo 06Grc0QDDmsS1EcjMiItc2xpVTPpoD2/y4cX+LzyMWlfKct+s28ED0Lo2//vzgmuL/fi mLU6tRLueZYWy8pKzFEfGFqLxElOuqPf3iFmMTl+IsXt3e9KRbA106dH+E5qqQ9PWbYN LdyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=C3ewxTalH0Xjzs4mLGQ5RRfJQ7855pQzE7NHTdIYvgk=; b=cJe6GPjQ5l0cEe+8pDlnXvJjkmUl2Oti7EjfqWxo0Qt52yc5tEbYyOtn4dgHEG+riH 9rb6WSe3O165xeXglne4J7okqEBVFPdvU+JdmiqmKkT85Xh/fYKfl5WP2cjnHIV0UfPX Qf0l84GTUxBhVWy853uq2sINHuOkMKEdXtrORn1IsznsegCa+11NHgyQRnVk7q9n5kBs PBZIhHChbSBuJIIW1XCSJLQvxhUyLPNKtfqupH/yR7J2qdWNBt/xsiLdMJdJtSk+h5lq gC5kwk08bany1A9ksYy6HihfaSqCcM2Akbi2QJiQ/zlcEvpORBehOyVcvAGU8LnGwKkY 8/zQ== X-Gm-Message-State: APt69E2XJc23LOuIVc35IU4X42pEoUJA7R2BpX5GQ9iGrClvqun5ZHUe Rpi8g57hPWbcaP1hfuyAGH0= X-Google-Smtp-Source: AAOMgpdGq8qqEhBua4PD3sG87A2Ec1eI+71gXN61dvj/lpMCb7HlUp0UF0Yxuap7reDngL/QU4j/AA== X-Received: by 2002:a2e:9d0e:: with SMTP id t14-v6mr6668189lji.112.1531072720998; Sun, 08 Jul 2018 10:58:40 -0700 (PDT) Received: from abrodkin-7480l.local ([91.237.150.126]) by smtp.gmail.com with ESMTPSA id a26-v6sm2033171ljd.12.2018.07.08.10.58.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Jul 2018 10:58:39 -0700 (PDT) From: Alexey Brodkin X-Google-Original-From: Alexey Brodkin To: linux-kernel@vger.kernel.org Subject: [PATCH v2] devres: Really align data field to unsigned long long Date: Sun, 8 Jul 2018 20:56:21 +0300 Message-Id: <20180708175621.6951-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_105853_403601_1B739FEB X-CRM114-Status: UNSURE ( 9.57 ) X-CRM114-Notice: Please train this message. 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 [2a00:1450:4864:20:0:0:0:242 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alexey.brodkin[at]gmail.com) -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, Thomas Gleixner , linux-snps-arc@lists.infradead.org, Alexey Brodkin , stable@vger.kernel.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: 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 {