From patchwork Fri Jun 23 14:31:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 780043 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 3wvLWQ4d4zz9sR8 for ; Sat, 24 Jun 2017 00:32:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZtGhA2TB"; 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=ZtGhA2TBmWfizCs8U2PWvY0sXl V+SfhehkVt4RxEJ0SlLkTQgGppK2MrZiwZEoBHBTMbaMeukC1EOHR1mU4S2wFnF7eZYxDto9uBR1A uu7d+9vQkxaRCkZb71puwX1TXLTh6sAMhjWm+4iRrxBHTjqLQ8NLYi9367j+gXJDAQb2v2qbp9pCG oO8an+mk+BuY7EYCswPUsT41SHvbMC1KLC9lnbBp0OQKzuuabcUIGspd6UtwcCuWxrnanmWSoe1vT OD4b1Rmbst9jTdGTNooVR18tlMkSa28cKudm3R3qTw5Hzrjerz+yXSboulvbhI+gPIkjmn76XXM6f Bgy+B07w==; 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 1dOPdB-0001To-7Q; Fri, 23 Jun 2017 14:32:17 +0000 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dOPd9-0001Qw-1D for linux-snps-arc@lists.infradead.org; Fri, 23 Jun 2017 14:32:16 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id E789C24E20A9; Fri, 23 Jun 2017 07:31:53 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id CA030C65; Fri, 23 Jun 2017 07:31:53 -0700 (PDT) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 99FB5C42; Fri, 23 Jun 2017 07:31:51 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/3 v5] ARC: Set IO-coherency aperture base to LINUX_LINK_BASE Date: Fri, 23 Jun 2017 17:31:44 +0300 Message-Id: <20170623143146.14281-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170623143146.14281-1-Eugeniy.Paltsev@synopsys.com> References: <20170623143146.14281-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170623_073215_075599_A30FA48C X-CRM114-Status: GOOD ( 10.98 ) 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 -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);