From patchwork Wed Oct 31 15:25:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 991508 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="YS2jiKas"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="XAKBqT+u"; 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 42lXHJ57v3z9s4s for ; Thu, 1 Nov 2018 02:26:20 +1100 (AEDT) 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=1U1WXzuPuZXLiqBg2l/PK6hXbm7xW1LgvT3LG3KSQ+A=; b=YS2 jiKasYWlqU8djnQOBNeIzBQ9IlUxgCMILKn3jbeiAc/xFG2DaelkD5nd0XDr52l0doXHtTB3cjw8K uGxhvPPrX1UG/anJC0AsrWsO8pItMqy41caJfpz2FDdOBV064WRc7tmHcIY2ZIRalV4eeYo1NGQum 9GW/DaGzAZ7OVtovp31IGrhRBySEyvSucJz5jKfZWESeyV07U4k/JAbrmuI+JcxtclPg3m6ph5Kw2 uNkoJnqLhQMvVo+Sf7yxjzj0RcvA6U3FKlyj3fYHulw/8/olEQPplwiwS2za++DXTh7QXrJh9n4p1 CDH5aL+B/zo+MLTMUQ7N6wa/c5KtOZA==; 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 1gHsNu-0008M9-Fc; Wed, 31 Oct 2018 15:26:18 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHsNq-0008Jp-L1 for linux-snps-arc@lists.infradead.org; Wed, 31 Oct 2018 15:26:16 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 4799524E1044; Wed, 31 Oct 2018 08:26:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1540999561; bh=U8VffSoUo3TdgUfR1xBBMWutGmz0vyVgbyJpt2oHIg4=; h=From:To:Cc:Subject:Date:From; b=XAKBqT+u9glgu2kPlPYTYxTXzrvtR5bEMaF00R9oN9HQab8rsRBzgCsJUS6jLe8KJ nMUMJ+0Pnk1eQgbOfgRj72FmGPtGG/kkeqlsUXKfHCmJoT6b3fbIA5OAq9wpx9Ii5w 0/RRu6WiYsIGTjVHLH+hCzOaHgnsPuXBGvRKERPZQz2X4MFJRc2sc2TO1iv1v76PfF xnA8IXhiRA+QjJf43O1JQQ1u/MO0IiTX9u5wZ+v1s6tj8Cd3mbQ7gtPE+rhy0QjvHS lmqGH+asgAmIvAcwYpVA88pIp4ioycbhVus+USZ4Oakkap3c0iqkCZv5Zt5BybL++n ZMkGLi8vCjQ1w== Received: from abrodkin-7480l.internal.synopsys.com (unknown [10.225.15.87]) by mailhost.synopsys.com (Postfix) with ESMTP id A05C452E2; Wed, 31 Oct 2018 08:25:55 -0700 (PDT) From: Alexey Brodkin To: linux-kernel@vger.kernel.org Subject: [PATCH v4] devres: Align data[] to ARCH_KMALLOC_MINALIGN Date: Wed, 31 Oct 2018 18:25:47 +0300 Message-Id: <20181031152547.9066-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.17.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181031_082614_694964_6DD827F4 X-CRM114-Status: GOOD ( 11.13 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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, Peter Zijlstra , Greg Kroah-Hartman , Vineet Gupta , Alexey Brodkin , Will Deacon , stable@vger.kernel.org, David Laight , Geert Uytterhoeven , Greg KH , 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 Initially we bumped into problem with 32-bit aligned atomic64_t on ARC, see [1]. And then during quite lengthly discussion Peter Z. mentioned ARCH_KMALLOC_MINALIGN which IMHO makes perfect sense. If allocation is done by plain kmalloc() obtained buffer will be ARCH_KMALLOC_MINALIGN aligned and then why buffer obtained via devm_kmalloc() should have any other alignment? This way we at least get the same behavior for both types of allocation. [1] http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004009.html [2] http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004036.html Signed-off-by: Alexey Brodkin Cc: Greg Kroah-Hartman Cc: Geert Uytterhoeven Cc: David Laight Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vineet Gupta Cc: Will Deacon Cc: Greg KH Cc: # 4.8+ --- Changes v3 -> v4: * Use ARCH_KMALLOC_MINALIGN for alignment instead of "8" [Peter] Changes v2 -> v3: * Align explicitly to 8 bytes [David] * Rephrased in-line comment [David] * Added more techinical details to commit message [Greg] * Mention more alignment options in commit message [Geert] Changes v1 -> v2: * Reworded commit message * Inserted comment right in source [Thomas] drivers/base/devres.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 4aaf00d2098b..e038e2b3b7ea 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -26,8 +26,14 @@ struct devres_node { struct devres { struct devres_node node; - /* -- 3 pointers */ - unsigned long long data[]; /* guarantee ull alignment */ + /* + * Some archs want to perform DMA into kmalloc caches + * and need a guaranteed alignment larger than + * the alignment of a 64-bit integer. + * Thus we use ARCH_KMALLOC_MINALIGN here and get exactly the same + * buffer alignment as if it was allocated by plain kmalloc(). + */ + u8 __aligned(ARCH_KMALLOC_MINALIGN) data[]; }; struct devres_group {