From patchwork Tue Aug 15 18:13:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 801707 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="ppirSxit"; 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 3xX0xP3kq2z9t3w for ; Wed, 16 Aug 2017 04:14:33 +1000 (AEST) 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=ppirSxitV8txJeF9zRaUaU2ipB tW63XvUk4Zec/jL18pQ++uE1s3AT+pFewyjqWT31CYLow3mVuzfDyYUwHDOG+FRCVhi6YcClxcQBx MtomCHWii3BHyXNes3sCkdF2BrlR2DM+/4VUtO0ohZ+QTAFEJB/8hyQJQyXsnN9yAAry7irB156be 4+00GRTttDfgCaA3vJt7/dONwKOSfvdeOGM44HczPRbLdUrvF1ULWA3RBFupcwPg36vJbzTQlC2w+ 1fgKdFGxISIP8PKu7aqDDu4VKhoanL39itpQj6EWlG6Y/rHBTQgcNqKjsV/wFrrSVH9K/lFR/cVbT ksJixj8Q==; 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 1dhgMK-0007Me-5U; Tue, 15 Aug 2017 18:14:32 +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 1dhgMF-0007Hy-Ss for linux-snps-arc@lists.infradead.org; Tue, 15 Aug 2017 18:14:30 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 4F86124E0F9B; Tue, 15 Aug 2017 11:14:06 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 33A651F2; Tue, 15 Aug 2017 11:14:06 -0700 (PDT) Received: from localhost.internal.synopsys.com (unknown [10.121.8.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 58EA01AB; Tue, 15 Aug 2017 11:14:04 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH 1/3] ARC: Set IO-coherency aperture base to LINUX_LINK_BASE Date: Tue, 15 Aug 2017 21:13:53 +0300 Message-Id: <20170815181355.29937-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170815181355.29937-1-Eugeniy.Paltsev@synopsys.com> References: <20170815181355.29937-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170815_111428_083303_7F21F3DC X-CRM114-Status: GOOD ( 11.66 ) 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 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.182.47.9 listed in wl.mailspike.net] -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] -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: 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);