From patchwork Wed Jul 12 09:40:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 787088 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 3x6v8R0FMSz9s74 for ; Wed, 12 Jul 2017 19:40:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uqtWE4Fb"; 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=uqtWE4Fb2xS7U+okVKOX/kFBxN B17qBQavqe0VDQX1nn6nK8jHkSVE12O16Q+PH800Jx5jvkJDNQoXcVxWw9zp3i13b7LKZxC1jXQy9 nJ9l7GegZD3CEARBucrr13x+7JX57n/5mkndBmBKCqqdIG1mChSUrq4Q7DfXiqzcnqvcuH05pJ+Hr dyIpA5sEdeUoXYcgFIJTpx9cZTLOIijjtJEaysw61rhZnIsLIKvkkRAGJHQycex95NdmWmEHVwp6H FUEPlHi0daJllJBg71IKqdDOEDja+73TUhbSZmcNeaGyCYiJVz60mRcPu4te5et1nYLDvSfUnk1+Z cveUViDQ==; 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 1dVE8b-0002NJ-Nm; Wed, 12 Jul 2017 09:40:53 +0000 Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dVE8Y-0002La-6i for linux-snps-arc@lists.infradead.org; Wed, 12 Jul 2017 09:40:51 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 710AE10C141A; Wed, 12 Jul 2017 02:40:32 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 5A604798; Wed, 12 Jul 2017 02:40:32 -0700 (PDT) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 851B677B; Wed, 12 Jul 2017 02:40:30 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/3 v8] ARC: Set IO-coherency aperture base to LINUX_LINK_BASE Date: Wed, 12 Jul 2017 12:40:21 +0300 Message-Id: <20170712094023.23226-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170712094023.23226-1-Eugeniy.Paltsev@synopsys.com> References: <20170712094023.23226-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170712_024050_303075_57808F30 X-CRM114-Status: GOOD ( 11.29 ) 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.60.111 listed in list.dnswl.org] -0.0 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);