From patchwork Mon Dec 18 15:29:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 850138 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="u7Z3ydXF"; 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 3z0lMW4cdxz9sNr for ; Tue, 19 Dec 2017 02:29:43 +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=nYcw+pXbfpiPQM1sjyHAkB3YWnlt/n7zDXHJrE7mhEw=; b=u7Z 3ydXFhK+tqhLO92lsO1hoV3HGF6B/l2RMwiFyYClAlpR+f9RxU/EoGq0/jmaJwnl7BjiHyU4tyRPL yOkZHz89nwaLvnLJn58s+YbkP1EFaNe9Q5WIKAHEAzpaOk9abROOZoNIO9JyjoWqGEKdCrhOF+9bt RjymOhnZxbD4AcaYeFrD9EHw4jWsZha49Fc8sCGxewfg+eEruzZCn8xHF9mxpzlOdd4d4wO5931Rt j6YPV1UAFjXo2pM47hSzNsXrXdDy/zjs5wCBFe8v+iG8BHF5p9cHjgIm+/8oTUEsnZM4CXMDZvHlJ A1Obxi2MJVcLEsO7qITHO73zqmtF9eA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eQxML-0002Rt-AG; Mon, 18 Dec 2017 15:29:41 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eQxMH-0002R5-Gn for linux-snps-arc@lists.infradead.org; Mon, 18 Dec 2017 15:29:39 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 4A67324E2044; Mon, 18 Dec 2017 07:29:25 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 30031AB6; Mon, 18 Dec 2017 07:29:25 -0800 (PST) Received: from abrodkin-7480l.internal.synopsys.com (unknown [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id E78BBAA5; Mon, 18 Dec 2017 07:29:23 -0800 (PST) From: Alexey Brodkin To: linux-snps-arc@lists.infradead.org Subject: [PATCH v2] ARC: Force disable IOC if we don't want to use it Date: Mon, 18 Dec 2017 18:29:20 +0300 Message-Id: <20171218152920.4696-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.14.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171218_072937_570819_2E431422 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 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 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.47.9 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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 If software that was executed before Linux kernel [like boot-ROM or bootloader] enabled IOC but we'd like to not use it [mostly for debugging of weird DMA issues] we essentially need to disable IOC. So we do here. Note we will only disable IOC if "ioc_enable" variable is force set to 0. As of today that's only possible either before building right in arch/arc/mm/cache.c or via debugger on target reght before execution of the kernel starts. We may make "ioc_enable" a boot-parameter later though. Signed-off-by: Alexey Brodkin --- Chnages in v2: * Now disabling really works as in v1 we never entered disabling code if ioc_enable=0. * Do nothing if IOC was not enabled arch/arc/mm/cache.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index 69f77c113875..9cadf7b779ed 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c @@ -1186,6 +1186,40 @@ noinline void __init arc_ioc_setup(void) __dc_enable(); } +/* + * Disabling of IOC is quite a tricky action because + * nobody knows what happens if there're IOC-ahndled tarnsactions in flight + * when we're disabling IOC. + * + * And the problem is external DMA masters [that were initialized and set in a + * bootlaoder that was executed before we got here] might continue to send data + * to memory even at this point and we have no way to prevent that. + * + * That said it's much safer to not enable IOC at all anywhere before + * in boot-ROM, bootloader etc but if we do need to disable it in Linux kernel + * it should be done as early as possible and made by master core while all + * slaves aren't active. + * + */ +noinline void __init arc_ioc_disable(void) +{ + /* Exit if IOC was never enabled */ + if (!read_aux_reg(ARC_REG_IO_COH_ENABLE)) + return; + + /* Flush + invalidate + disable L1 dcache */ + __dc_disable(); + + /* Flush + invalidate SLC */ + if (read_aux_reg(ARC_REG_SLC_BCR)) + slc_entire_op(OP_FLUSH_N_INV); + + write_aux_reg(ARC_REG_IO_COH_ENABLE, 0); + + /* Re-enable L1 dcache */ + __dc_enable(); +} + /* * Cache related boot time checks/setups only needed on master CPU: * - Geometry checks (kernel build and hardware agree: e.g. L1_CACHE_BYTES) @@ -1247,8 +1281,12 @@ void __init arc_cache_init_master(void) if (is_isa_arcv2() && l2_line_sz && !slc_enable) arc_slc_disable(); - if (is_isa_arcv2() && ioc_enable) - arc_ioc_setup(); + if (is_isa_arcv2()) { + if (ioc_enable) + arc_ioc_setup(); + else if (ioc_exists) + arc_ioc_disable(); + } if (is_isa_arcv2() && ioc_enable) { __dma_cache_wback_inv = __dma_cache_wback_inv_ioc;