From patchwork Tue Jul 18 14:31:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 790315 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=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gpZyoyTb"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PxhbK68T"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3xBjKT5prhz9t2M for ; Wed, 19 Jul 2017 00:31:57 +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=sQX7XYEBS5BGyzG+RgOiyksYsPau1UoYeHhvcvgauOg=; b=gpZ yoyTboRVcEOEW9/o74h71F79tuLoyjwAIGiAMBq/LBglvMWhh+Wf7N8Rwj+LUZ/07U5jpgK7jBVLV uKQBpTYV6q+0kM8tsBy2Fo2/xrhBekz+f+3BEC7+zmpgv2IHWEnjC8CgAzhl3dtPyBkENWB1OTrhI jQY0Z2bPq6uF2mTa5Trl1xJvPXd9CeZsjABRSMvU0UWLt+au8HgeDrMyYSOIp7bxr59On+bDTA7K/ pH9gGJqGs+6tCdwY2hvNlZgyIASQXeO9yx3IWtbWVnQw+Xy1P6ajdT61gAwjN35p9gJh8i8e533TF WQTbN1idI61qpoz9s8cIwyCEYJgXHug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dXTXY-0003ad-Ez; Tue, 18 Jul 2017 14:31:56 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXTXV-0003BL-8D for linux-snps-arc@lists.infradead.org; Tue, 18 Jul 2017 14:31:54 +0000 Received: by mail-wr0-x243.google.com with SMTP id y43so3912623wrd.0 for ; Tue, 18 Jul 2017 07:31:32 -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=eNVFkQBySGvkLjmw77UV8hgLCY3DVOz2tuCkYCE0rsY=; b=PxhbK68TzVOQi97i7Otbk9UsRLviRWmT/enDtQwmEmz+hgfR3X0M2vpYUowZgokfuw CwrOGGeGB64XAY9GpWZ4F/aysR/WYhou5zvFN5t0BegkomYPf3g5APUvxD7RzWRlTxES 1FQTIl8+MNKTq4iz841sT+JdaiL0Cyj7oIybo45JvIQCNFLTldI6Vz8dw4vDr/O5db25 bFYs+sHbFldswSf5MsKt76egsR6BOeSnzlMzzO12J1UJ7vMhhrGuKJUHLy48Ihc4Yjy5 /N8C8PsYggtBWrHHBKnoQWJdTHvj1guhaiiITAZ/fD42Qg3wmQ/S0pwGlr/wEjSpmg4f Y3zw== 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=eNVFkQBySGvkLjmw77UV8hgLCY3DVOz2tuCkYCE0rsY=; b=uRZtYSdEgNNB/Q0/FOSnu3vs8rwzyrLIwk4imblcIt3pKIO4hFCC3spJ++wdb15DHA G327j3AYnrMZoMU6LnTqN7jhrDhfTGWSXl8icVUr0G6Nv2SLIlquxfLV5Ptv9bGPDp/g 9kf6Voo04ZHi9QSaX8FE74//OhTdvOTEishSdS5DePtuAbJhTTD5Rz50CrGyL4GhoUQe 4tX/vhnytS0598c52qn7bcVIeyQX75Yhurozog+I8tLoSHDgy01O38xSf0iV51OA3kni dIk1HtjmOnQOdMgs/lYFfXr2aPWz7LyPHERIWJpCVEVCP6AzWavwaAo+YjhrSY5EdLYx MI1w== X-Gm-Message-State: AIVw110cWqJbAQJRHr/GTxrw/51V+9B+LYM8RPUp5enKSYD60WolVHFV ryRSc6OxZJylCZDYzJU= X-Received: by 10.28.24.81 with SMTP id 78mr2399003wmy.112.1500388290807; Tue, 18 Jul 2017 07:31:30 -0700 (PDT) Received: from localhost.localdomain ([134.191.232.93]) by smtp.gmail.com with ESMTPSA id y84sm13761757wmg.12.2017.07.18.07.31.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jul 2017 07:31:30 -0700 (PDT) From: Alexey Brodkin X-Google-Original-From: Alexey Brodkin To: linux-snps-arc@lists.infradead.org Subject: [PATCH] arc: Hardcode ARCH_DMA_MINALIGN to max line length we may have Date: Tue, 18 Jul 2017 17:31:24 +0300 Message-Id: <1500388284-23466-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 2.7.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170718_073153_480338_5C09F2FB X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (alexey.brodkin[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Current implementation relies on L1 line length which might easily be smaller than L2 line (which is usually the case BTW). Imagine this typical case: L2 line is 128 bytes while L1 line is 64-bytes. Now we want to allocate small buffer and later use it for DMA (consider IOC is not available). kmalloc() allocates small KMALLOC_MIN_SIZE-sized, KMALLOC_MIN_SIZE-aligned That way if buffer happens to be aligned to L1 line and not L2 line we'll be flushing and invalidating extra portions of data from L2 which will cause cache coherency issues. And since KMALLOC_MIN_SIZE is bound to ARCH_DMA_MINALIGN the fix could be simple - set ARCH_DMA_MINALIGN to the largest cache line we may ever get. As of today neither L1 of ARC700 and ARC HS38 nor SLC might not be longer than 128 bytes. Signed-off-by: Alexey Brodkin --- arch/arc/include/asm/cache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index 19ebddffb279..e45eac8c5980 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h @@ -47,7 +47,8 @@ : "r"(data), "r"(ptr)); \ }) -#define ARCH_DMA_MINALIGN L1_CACHE_BYTES +/* Largest line length for either L1 or L2 is 128 bytes */ +#define ARCH_DMA_MINALIGN 128 extern void arc_cache_init(void); extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);