From patchwork Mon Jun 26 15:11:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 780754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wxCFg3H37z9s81 for ; Tue, 27 Jun 2017 01:11:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uSBd90AF"; dkim-atps=neutral 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=MokmrnfrERFUq/5toP2YZNOD1wS6quWsDWmuUK6KilM=; b=uSBd90AFGkCm05h+Q4JUphylgE 9MkmY3hLM8lfC4ygw+iNADhO7XGJ/gV4LtsSgvq8TqJatPNMlGXWtLmEeIiUSiWYc862Rozx07buN JGfy9Gnn5ly8YDnGI8+TzLSMgCANWTkSQclZIHDs/cykRB/kZmrdovvLTXU/Zx+UAFHARFr3s0KT0 h/4nUTzhEanHQ4QQoG94G6GZXLVessQ1qFq9YQnoIZPM5g3raOirVOgN7WtbOyPZp1uKzMayCayl2 1HYXEyjE1ufdtEydf1yWmA4JKnykz9WYAbQx+fp3aoIxIFYGwlaMkS6r0picxYYdLS+fdYu+fI1U4 FWveGIag==; 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 1dPVg6-0008Az-3l; Mon, 26 Jun 2017 15:11:50 +0000 Received: from smtprelay.synopsys.com ([198.182.60.111]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dPVg3-00088j-0P for linux-snps-arc@lists.infradead.org; Mon, 26 Jun 2017 15:11:48 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 52D4210C162F; Mon, 26 Jun 2017 08:11:26 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 3C342459; Mon, 26 Jun 2017 08:11:26 -0700 (PDT) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 6A8E341C; Mon, 26 Jun 2017 08:11:24 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/3 v6] ARC: Set IO-coherency aperture base to LINUX_LINK_BASE Date: Mon, 26 Jun 2017 18:11:16 +0300 Message-Id: <20170626151118.19507-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170626151118.19507-1-Eugeniy.Paltsev@synopsys.com> References: <20170626151118.19507-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170626_081147_096874_96820733 X-CRM114-Status: GOOD ( 11.14 ) 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 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: devicetree@vger.kernel.org, Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org, Rob Herring , Eugeniy Paltsev MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Most of the time we indeed use the one and only LINUX_LINK_BASE set to 0x8000_0000. But there might be good reasons to move the kernel to another location like 0x9z etc. And we want IOC aperture to cover entire area used by the kernel, so let's make its base matching link base and add required asserts: checking IOC aperture base address and size to be supported by IOC. Signed-off-by: Eugeniy Paltsev --- arch/arc/mm/cache.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index a867575..383ff77 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c @@ -1083,7 +1083,8 @@ SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, sz, uint32_t, flags) */ noinline void __init arc_ioc_setup(void) { - unsigned int ap_sz; + unsigned int ap_base; + long ap_size; /* Flush + invalidate + disable L1 dcache */ __dc_disable(); @@ -1092,18 +1093,32 @@ noinline void __init arc_ioc_setup(void) if (read_aux_reg(ARC_REG_SLC_BCR)) slc_entire_op(OP_FLUSH_N_INV); - /* IOC Aperture start: TDB: handle non default CONFIG_LINUX_LINK_BASE */ - write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000); - /* - * IOC Aperture size: - * decoded as 2 ^ (SIZE + 2) KB: so setting 0x11 implies 512M - * TBD: fix for PGU + 1GB of low mem + * IOC Aperture size is equal to memory size. + * TBD: fix for PGU + 1GiB of low mem * TBD: fix for PAE */ - ap_sz = order_base_2(arc_get_mem_sz()/1024) - 2; - write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, ap_sz); + ap_size = arc_get_mem_sz(); + + if (!is_power_of_2(ap_size) || ap_size < 4096) + panic("IOC Aperture size must be power of 2 larger than 4KiB"); + + /* + * IOC Aperture size decoded as 2 ^ (SIZE + 2) KiB, + * so setting 0x11 implies 512MiB, 0x12 implies 1G... + */ + write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, order_base_2(ap_size / 1024) - 2); + + /* + * For now we assume IOC aperture to cover all the memory used by the + * kernel. + */ + ap_base = CONFIG_LINUX_LINK_BASE; + + if (ap_base % ap_size != 0) + panic("IOC Aperture start must be aligned to the size of the aperture"); + write_aux_reg(ARC_REG_IO_COH_AP0_BASE, ap_base >> 12); write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1); write_aux_reg(ARC_REG_IO_COH_ENABLE, 1);