Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp958423imm; Thu, 4 Oct 2018 06:12:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV60kFIwcSnhuG/Z03HmD/n6OqJ864v8dP1YpPzHYzW1ObFuz3ncj7F7Ap5PMKsUJKbdn6KY9 X-Received: by 2002:a62:6c4:: with SMTP id 187-v6mr6605985pfg.109.1538658761529; Thu, 04 Oct 2018 06:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538658761; cv=none; d=google.com; s=arc-20160816; b=k0QF4gTzsuI+fhIAj39/ODpHdL4t6yS6y6aMqsJgmPTZE0pX4IDMljvYmJJQXFkk+C YXKovkeQf/DVMuc8zAdDSE9xfhp9IGh3v+IngSm0VWQDPdQNQLSb/EZ/sua5x+BsF0Nv sxrbvD5tdZLFmcIJhDVUeGENYDRSeTS8+3h7Cup5UQZ14XK6BSy8+QGmpwa5WTJvvnAc L7RsYoJaUGyI5epNGd1SlAktnbhE0IEOGsIdWdDAzxAeEt4rvL7zbwZQS6+YAa+N5Oxt R1zNap+BFLWzMYnxOf79c3jolVMQWJnBwQEkANTv0b63I5mT1TmR8lfTDUXRoWZDsErJ CNlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=zkaCxCsDgcw9oAHKihD6/PW4Kcp5XxMuB183RgISQtA=; b=tQTAteWVJbCHvAewxxNm6EJy+d64rtzjGYKR5B37O803S7ABetOPM00lHaEs/pJkQj 24e/xhfDxDec9RjvewphLwEzr0/hTUygArNpsrrCMcIsncGa2t5eiQ4Lo1ep7eoG2DA/ 4stq3D9j0jc+GvAjvw9jwM7UZfob/AfeiKD7QuGorNfSODBxgqs+5BFmvHorA2bbhau9 Wc45Ao1E11Os47PjiSRrDWsHZlOr5/iFWh0cyivS+GlMr8zPKJuYFBpj73xM/oq4soVC +H16gbyoko+gyeBWBU36TjpOqlKwFR5G2J02fDD7LVzV2Z4e4nXyhMN39HAqTqGLU5Lk WVDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=Ju+WIRWK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si4721021pgb.301.2018.10.04.06.12.25; Thu, 04 Oct 2018 06:12:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=Ju+WIRWK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbeJDUFc (ORCPT + 99 others); Thu, 4 Oct 2018 16:05:32 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:51766 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727367AbeJDUFc (ORCPT ); Thu, 4 Oct 2018 16:05:32 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2900F10C10F2; Thu, 4 Oct 2018 06:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1538658738; bh=ffFfKjvXLhwMBz9vQszTfQrsKaTWUPMSjOutmKrMllg=; h=From:To:Cc:Subject:Date:From; b=Ju+WIRWKl8R+U0QcySkk/Blbw1V555Z33ZvkB9Hp9cJwHdi4LL41XCp4W3lhAamD7 yJxzxzUBBt/MRdt9FEH6CscaH941rcuQrkiFMSAUs3dyan+Dn8ckVe4H4PO2DL7iwr 8dwYSY+UhAg5xqnPkM5d3lF73OcQKihZ48CJUug/LaReW6Sx66PiTRkKos/gyPHBI7 AAWt5EzfwX62bieEnNYyWmv/8GjNSHqyPWNWnb+A2MoC4i4A7gdl5O08K5ZoK/sbyo 4bzqnqM/nPYABpIXojiEvU7zDkD8DmKxwh+QYxTplTvv9dkZgUoYqFytdqcLmCt59B P2Slk+LmjJ7yg== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.3.38]) by mailhost.synopsys.com (Postfix) with ESMTP id B9E6B382B; Thu, 4 Oct 2018 06:12:14 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Cc: linux-kernel@vger.kernel.org, Alexey Brodkin , Eugeniy Paltsev Subject: [PATCH] ARC: IOC: panic if kernel was started with previously enabled IOC Date: Thu, 4 Oct 2018 16:12:12 +0300 Message-Id: <20181004131212.16405-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Disabling and reconfiguring of IOC are quite a tricky actions 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 Linux kernel. As we can build u-boot with IOC support (mostly for debugging purposes) let's check that kernel was started with disabled IOC regardless of our plans to use it or not. Also while I'm at it, replace hardcoded bits in ARC_REG_IO_COH_PARTIAL and ARC_REG_IO_COH_ENABLE registers by definitions. Inspired by: https://lkml.org/lkml/2018/1/19/557 Signed-off-by: Eugeniy Paltsev --- arch/arc/include/asm/cache.h | 2 ++ arch/arc/mm/cache.c | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index ff7d3232764a..f393b663413e 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h @@ -113,7 +113,9 @@ extern unsigned long perip_base, perip_end; /* IO coherency related Auxiliary registers */ #define ARC_REG_IO_COH_ENABLE 0x500 +#define ARC_IO_COH_ENABLE_BIT BIT(0) #define ARC_REG_IO_COH_PARTIAL 0x501 +#define ARC_IO_COH_PARTIAL_BIT BIT(0) #define ARC_REG_IO_COH_AP0_BASE 0x508 #define ARC_REG_IO_COH_AP0_SIZE 0x509 diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index f2701c13a66b..ee7b63e9c5e3 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c @@ -1144,6 +1144,25 @@ noinline void __init arc_ioc_setup(void) { unsigned int ioc_base, mem_sz; + /* + * Disabling and reconfiguring of IOC are quite a tricky actions 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 + * Linux kernel. + */ + if (read_aux_reg(ARC_REG_IO_COH_ENABLE) & ARC_IO_COH_ENABLE_BIT) + panic("kernel was started with previously enabled IOC!\n"); + + if (!ioc_enable) + return; + /* * As for today we don't support both IOC and ZONE_HIGHMEM enabled * simultaneously. This happens because as of today IOC aperture covers @@ -1187,8 +1206,8 @@ noinline void __init arc_ioc_setup(void) panic("IOC Aperture start must be aligned to the size of the aperture"); write_aux_reg(ARC_REG_IO_COH_AP0_BASE, ioc_base >> 12); - write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1); - write_aux_reg(ARC_REG_IO_COH_ENABLE, 1); + write_aux_reg(ARC_REG_IO_COH_PARTIAL, ARC_IO_COH_PARTIAL_BIT); + write_aux_reg(ARC_REG_IO_COH_ENABLE, ARC_IO_COH_ENABLE_BIT); /* Re-enable L1 dcache */ __dc_enable(); @@ -1265,7 +1284,7 @@ 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) + if (is_isa_arcv2()) arc_ioc_setup(); if (is_isa_arcv2() && l2_line_sz && slc_enable) { -- 2.14.4