From patchwork Thu Jul 26 11:08:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 949595 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="u6pSR3rB"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="Z5/QwCe2"; 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 41bq9D6C5Gz9ryl for ; Thu, 26 Jul 2018 21:09:04 +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=iqk6ngRM7NnO8mSEBH3EJ+WW2mMcT+/6yNVyrj2u/us=; b=u6p SR3rBnXcIJPCt3IZ/4Dd/Iom7LfxWa/LMfreM+FXfqLI6SWWCEzs8+VqLVWQXaIa+q5rv7OxjmKUR abmrLCgRUKG1ghqKvA2B2JIebjbwWL36KO0DgWVS6Z4wCo+fXuYkGZ5cMzuWaNeCEm7LR+zCOsq+Y bMdZz4IsfuFjtAPeqUKgWRn7svHoNPixA3eydYJ5Ii7+XYFt6J+0UYq1kMn7dzcY1qTfGACZS+lQC 2zRTQBvoL5ftPkSKB+ax3ShMvz7QeIhBQmVc+KYM1EtgsIsEgEU9S6zm+JktzMwta2pN1Ohc5LJtR dQ4sTfciPQfD/yRnDh+d97ntJhOsBFQ==; 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 1fie8k-0000zx-TK; Thu, 26 Jul 2018 11:09:02 +0000 Received: from smtprelay.synopsys.com ([198.182.60.111]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fie8h-0000yr-M6 for linux-snps-arc@lists.infradead.org; Thu, 26 Jul 2018 11:09:01 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 9570F10C0F95; Thu, 26 Jul 2018 04:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1532603327; bh=ZWG07Ezt5C69b52/CtcMWRzjtnzxyoJmNpqveGyasIg=; h=From:To:Cc:Subject:Date:From; b=Z5/QwCe21g7tfuJlRRFJ3V4sUenYYXqWKGnUFVEjZIfjcWlfIUpAUxGL3/bpSalaf N/ZGa9XKaNxHr0mlAa6svxBMiloD0UwT9YwOcRe5szR92FXKI2p1ZJauSwRMzn+kWM qQ+axv/eaQCye8P2eHDFfnhrgBMUAl11IuvhKJaCNtw3tN88+1QnjrlI9aN22KPkyw zLLF1TNflsmyBfJ2yuFN7CRn8ZkcDm7xMUG7qtJEfi0XDxKYikE9dPAIJjPQcQre1U Ub25ICvDKn8d0WIZxM381eKi6Dp/YitC4+R96U5GazSZwbM0kKkvDho4KhWQWsndqO sy0+T1L60n9kQ== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id 0C9715249; Thu, 26 Jul 2018 04:08:45 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/2] ARC: setup SMP_CACHE_BYTES and cache_line_size Date: Thu, 26 Jul 2018 14:08:38 +0300 Message-Id: <20180726110839.1915-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180726_040859_734857_35FB35D2 X-CRM114-Status: GOOD ( 10.04 ) 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.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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, Vineet Gupta , Alexey Brodkin , Eugeniy Paltsev , 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 As for today we don't setup SMP_CACHE_BYTESi and cache_line_size for ARC, so they are set to L1_CACHE_BYTES by default. L1 line length (L1_CACHE_BYTES) might be easily smaller than L2 line (which is usually the case BTW). This breaks code. For example this breaks ethernet infrastructure on HSDK/AXS103 boards with IOC disabled: Functions which alloc and manage sk_buff packet data area rely on SMP_CACHE_BYTES define. In the result we can share last L2 cache line in sk_buff linear packet data area between DMA buffer and some useful data in other structure. So we can lose this data when we invalidate DMA buffer. sk_buff linear packet data area | | | skb->end skb->tail V | | V V ----------------------------------------------. packet data | | ----------------------------------------------. ---------------------.--------------------------------------------------. SLC line | SLC (L2 cache) line (128B) | ---------------------.--------------------------------------------------. ^ ^ | | These cache lines will be invalidated when we invalidate skb linear packet data area before DMA transaction starting. This leads to issues painful to debug as it reproduces only if (sk_buff->end - sk_buff->tail) < SLC_LINE_SIZE and if we have some useful data right after sk_buff->end. Fix that by hardcode SMP_CACHE_BYTES to max line length we may have. Signed-off-by: Eugeniy Paltsev Signed-off-by: Eugeniy Paltsev --- arch/arc/Kconfig | 1 + arch/arc/include/asm/cache.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 9cf59fc60eab..ee1a38c99197 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -9,6 +9,7 @@ config ARC def_bool y select ARC_TIMERS + select ARCH_HAS_CACHE_LINE_SIZE select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_SG_CHAIN diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index 8486f328cc5d..ff7d3232764a 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h @@ -48,7 +48,9 @@ }) /* Largest line length for either L1 or L2 is 128 bytes */ -#define ARCH_DMA_MINALIGN 128 +#define SMP_CACHE_BYTES 128 +#define cache_line_size() SMP_CACHE_BYTES +#define ARCH_DMA_MINALIGN SMP_CACHE_BYTES extern void arc_cache_init(void); extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len); From patchwork Thu Jul 26 11:08:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 949596 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="nwYKP2tq"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="MmCFWUrl"; 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 41bq9G13Jlz9ryt for ; Thu, 26 Jul 2018 21:09:06 +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:References: In-Reply-To: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:List-Owner; bh=Dpz3DtlbJGh9M9E7+qgOX/QeFbI/iYZpPJsKa5n/MSQ=; b=nwYKP2tqdm69NYANxGz9PLkSuW qJghwQ1G5vNs/FR9SNikNNzRRRyJ9lmKRlVioFAfOVM4m6IwRRY/gb4JhXCeAn0VUXm8F/TvQkgoo eRY2+7+a6Qp19SpU8kzCWEdFHEkqHoy0iRLJpcxSXQGHE0XU/rwJ1c1dO2uS8i4TKstq4qiq6BXDx K540QoeLiNGpXxQjUSuvrZUQ2alkZLHkylCCstR1o4nCDccBXJTMODyJrOgh/lGmbmJBF4Woun9X6 lcf/C7/LkJ7ComrIqsjWTm87bFyayIoRGlMKaF2py2JE0XJKXfVIw580U1viJAr4sdZypEY+oDCNZ TMLMZWHg==; 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 1fie8m-00010J-3A; Thu, 26 Jul 2018 11:09:04 +0000 Received: from smtprelay4.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 1fie8j-0000z5-5a for linux-snps-arc@lists.infradead.org; Thu, 26 Jul 2018 11:09:02 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 95D6424E1260; Thu, 26 Jul 2018 04:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1532603329; bh=KMtM9l4/iOD6HkzJItyrJuwiy2ZLwIaDJEQTEhwJPMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmCFWUrlJhMvx4RHaz6cBBkKRZXQl718tr0IninDSpsxEqlfG1Q1J4KR39kW3oDlx Qujx9vkpaIbTdyOmlgVOUISKxIoRB+jsCJdltQ3N96QoPWR9/E1DcEew/0QXdXYi+4 Zhbo1vRSLdOuAnDCgHG1wvu09Jzz9S7oi0nDQF0RAWmh1HZoVGGxm5FzpIl4EyigN1 SJSEg8b2EXQJor8QJu92mikaxkkngWZqXmhx5LzFrhalneInRFQFpS+cHe0ZJQZc3t hEN9bNwLrMWQeU6w4LxhdwKmT38bwMFHxbl0QXsV3JDQ3o+ydQ8fEWOek0A/9INYir 1krPNGRcTR57g== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id EA25352D0; Thu, 26 Jul 2018 04:08:47 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 2/2] ARC: add SMP_CACHE_BYTES value validate Date: Thu, 26 Jul 2018 14:08:39 +0300 Message-Id: <20180726110839.1915-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180726110839.1915-1-Eugeniy.Paltsev@synopsys.com> References: <20180726110839.1915-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180726_040901_220219_DF9D9E89 X-CRM114-Status: UNSURE ( 9.62 ) 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 [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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, Vineet Gupta , Alexey Brodkin , Eugeniy Paltsev , 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 Check that SMP_CACHE_BYTES (and hence ARCH_DMA_MINALIGN) is larger or equal to any cache line length by comparing it with values previously read from ARC cache BCR registers. Signed-off-by: Eugeniy Paltsev --- arch/arc/mm/cache.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index 9dbe645ee127..b95365e1253a 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c @@ -1246,6 +1246,16 @@ void __init arc_cache_init_master(void) } } + /* + * Check that SMP_CACHE_BYTES (and hence ARCH_DMA_MINALIGN) is larger + * or equal to any cache line length. + */ + BUILD_BUG_ON_MSG(L1_CACHE_BYTES > SMP_CACHE_BYTES, + "SMP_CACHE_BYTES must be >= any cache line length"); + if (is_isa_arcv2() && (l2_line_sz > SMP_CACHE_BYTES)) + panic("L2 Cache line [%d] > kernel Config [%d]\n", + l2_line_sz, SMP_CACHE_BYTES); + /* Note that SLC disable not formally supported till HS 3.0 */ if (is_isa_arcv2() && l2_line_sz && !slc_enable) arc_slc_disable();