From patchwork Fri Aug 2 08:27:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhou Yanjie X-Patchwork-Id: 11072981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5BA41395 for ; Fri, 2 Aug 2019 08:28:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B434628774 for ; Fri, 2 Aug 2019 08:28:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A845A287D4; Fri, 2 Aug 2019 08:28:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54918287BE for ; Fri, 2 Aug 2019 08:28:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404153AbfHBI2p (ORCPT ); Fri, 2 Aug 2019 04:28:45 -0400 Received: from sender4-pp-o95.zoho.com ([136.143.188.95]:25588 "EHLO sender4-pp-o95.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404152AbfHBI2p (ORCPT ); Fri, 2 Aug 2019 04:28:45 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1564734480; cv=none; d=zoho.com; s=zohoarc; b=K4YPf8BbkekWzsJBdqypN0JZO8w45AMEuh9V8fVUwzAqJ7p4MdlbbgsYlJfOMAjEuwy7JuKOXuTnpqbxCtRxT2SBzxffXac93nR4i7CP156U1TTigSzsYrzwd4X/iX/cX7qJdFqxullm05LvzBKyvRBOGRw6INK6bJbhbegjX+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564734480; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=PCPvMtgwI7YymWHtU3P5pq3i16qnpFDI6NTvI4dHUbE=; b=f50TVeGSAd4g8pHsriPTF45D61qPoZyn7qy3+eAcuOgNDrzVx1SrTIWS8jn3Wuvyr2DOK/Vb0NEyhWfhvC9eX00cCz5jOHy3KCBAuMUjXYW4KD4N2gJUBBCyoRCMI5Vscqi1Sn82Rin/byljm6hF2FC3Fvi6UJ9/+9/iOY86DDQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=zhouyanjie@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=PGwKfdJsDr8ibKz4W65JzVC2iLb/RfdjvLQUH6ALxaIm9sJsYdX2p8ZBq/MFCfMOQHUX/xjyV/BV SCrgD0rTJEaqsFAs/S71VGaXvLOVn1JMNscy96q8WQ9Z5Vb5uOpx DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1564734480; s=zm2019; d=zoho.com; i=zhouyanjie@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=1305; bh=PCPvMtgwI7YymWHtU3P5pq3i16qnpFDI6NTvI4dHUbE=; b=lIroAuI1pb1MaEYLeQX6Ho8fHAM7qCU/sldk+/0/1bq43Y4y9hysjbbRlHavRIkg skamL/sibLO/2rHbRvzqfd6bCa4mTXVXm8lZwhQHD9GLraxk68xk6T3G0NVb96tlY4F 2AfM35JOrHbeM4tjVjIDzVhDmmZEVjUB+uSUqAOQ= Received: from localhost.localdomain (125.71.5.36 [125.71.5.36]) by mx.zohomail.com with SMTPS id 1564734479346989.5209055678341; Fri, 2 Aug 2019 01:27:59 -0700 (PDT) From: Zhou Yanjie To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, ralf@linux-mips.org, paul@crapouillou.net, paul.burton@mips.com, jhogan@kernel.org, malat@debian.org, gregkh@linuxfoundation.org, tglx@linutronix.de, allison@lohutok.net, syq@debian.org, chenhc@lemote.com, jiaxun.yang@flygoat.com Subject: [PATCH 1/2 v4] MIPS: Ingenic: Fix bugs when detecting X1000's L2 cache. Date: Fri, 2 Aug 2019 16:27:36 +0800 Message-Id: <1564734457-48801-2-git-send-email-zhouyanjie@zoho.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564734457-48801-1-git-send-email-zhouyanjie@zoho.com> References: <1564498510-3751-1-git-send-email-zhouyanjie@zoho.com> <1564734457-48801-1-git-send-email-zhouyanjie@zoho.com> X-ZohoMailClient: External Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1.fix bugs when detecting L2 cache sets value. 2.fix bugs when detecting L2 cache ways value. Signed-off-by: Zhou Yanjie --- arch/mips/mm/sc-mips.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c index 9385ddb..dbdbfe5 100644 --- a/arch/mips/mm/sc-mips.c +++ b/arch/mips/mm/sc-mips.c @@ -221,13 +221,26 @@ static inline int __init mips_sc_probe(void) else return 0; - /* - * According to config2 it would be 5-ways, but that is contradicted - * by all documentation. - */ - if (current_cpu_type() == CPU_XBURST && - mips_machtype == MACH_INGENIC_JZ4770) - c->scache.ways = 4; + if (current_cpu_type() == CPU_XBURST) { + switch (mips_machtype) { + /* + * According to config2 it would be 5-ways, but that is + * contradicted by all documentation. + */ + case MACH_INGENIC_JZ4770: + c->scache.ways = 4; + break; + + /* + * According to config2 it would be 5-ways and 512-sets, + * but that is contradicted by all documentation. + */ + case MACH_INGENIC_X1000: + c->scache.sets = 256; + c->scache.ways = 4; + break; + } + } c->scache.waysize = c->scache.sets * c->scache.linesz; c->scache.waybit = __ffs(c->scache.waysize); From patchwork Fri Aug 2 08:27:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhou Yanjie X-Patchwork-Id: 11072983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B90E61395 for ; Fri, 2 Aug 2019 08:29:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A746E28774 for ; Fri, 2 Aug 2019 08:29:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B8C6287D4; Fri, 2 Aug 2019 08:29:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4038428774 for ; Fri, 2 Aug 2019 08:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731823AbfHBI3H (ORCPT ); Fri, 2 Aug 2019 04:29:07 -0400 Received: from sender-pp-o92.zoho.com ([135.84.80.237]:25402 "EHLO sender-pp-o92.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731576AbfHBI3H (ORCPT ); Fri, 2 Aug 2019 04:29:07 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1564734486; cv=none; d=zoho.com; s=zohoarc; b=Rko2+rMWSy68EF5M0q1Ehmsk7cY9OZoEtn7ImthRZJbcl+kwKAkb1Oo7lfPfgNl9ny5E/UOuBHksuHxmXyjfIej0HvN4Gp5IKcJbGRT/AFPZLuv2p3PENxkOcEvW/ob7t0u/qOo3kT8MfOY86Aq5IRyfaic3+yCg5deMqlQNMZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564734486; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=XInzzMgiWJcFkaRBKjAqwD6Ji5EqOMk9SfoHZu+8Meo=; b=mryTHn8MZ46YJqr3jnaF7YcuUMWZBR2xuYirGcXxTrF43oTtrOg2zhvsr3iSsnZT/UIDtimhOWt0u5BxgJGdbwulNGZ98ooDlhY87WsQMQrkV8kWncRgfKXGx0TnpfUC+iPFmK6boR9m9VfFxjpF9rQmp4E7ieJFfoqz2fP3+BU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=zhouyanjie@zoho.com; dmarc=pass header.from= header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:in-reply-to:references; b=ZjBpQvo/tw8NGuUcwJgoAXY0goXCCYRVtPUnr9Q5yMfCj1zWbJC+kAK+tybO7qvql2ZPEFB5CIal m+q+c9ehlricXdCEPvxzirH3+6O8JwA3P2Rm+wIFo2qxJE694QhP DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1564734486; s=zm2019; d=zoho.com; i=zhouyanjie@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=1930; bh=XInzzMgiWJcFkaRBKjAqwD6Ji5EqOMk9SfoHZu+8Meo=; b=Ot84g6lqLoc1OjB+B0Bud8/mCMBuhjWliMItYKSR3TixWIs6pcbxnFAnOrI20gPD 1cTh56Y8sXOXqG5pMJtcm8P/1PDRc06+xlmOVPutADpwOGVeC/Nr4Jce+09ifNJh38x 2qmpR9bhnZBZoF1Pz6fXJrp9bySJ02tb8cx258OE= Received: from localhost.localdomain (125.71.5.36 [125.71.5.36]) by mx.zohomail.com with SMTPS id 1564734483932104.33420675435002; Fri, 2 Aug 2019 01:28:03 -0700 (PDT) From: Zhou Yanjie To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, ralf@linux-mips.org, paul@crapouillou.net, paul.burton@mips.com, jhogan@kernel.org, malat@debian.org, gregkh@linuxfoundation.org, tglx@linutronix.de, allison@lohutok.net, syq@debian.org, chenhc@lemote.com, jiaxun.yang@flygoat.com Subject: [PATCH 2/2 v4] MIPS: Ingenic: Disable broken BTB lookup optimization. Date: Fri, 2 Aug 2019 16:27:37 +0800 Message-Id: <1564734457-48801-3-git-send-email-zhouyanjie@zoho.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564734457-48801-1-git-send-email-zhouyanjie@zoho.com> References: <1564498510-3751-1-git-send-email-zhouyanjie@zoho.com> <1564734457-48801-1-git-send-email-zhouyanjie@zoho.com> X-ZohoMailClient: External Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to further reduce power consumption, the XBurst core by default attempts to avoid branch target buffer lookups by detecting & special casing loops. This feature will cause BogoMIPS and lpj calculate in error. Set cp0 config7 bit 4 to disable this feature. Signed-off-by: Zhou Yanjie --- arch/mips/include/asm/mipsregs.h | 4 ++++ arch/mips/kernel/cpu-probe.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h index 1e6966e..bdbdc19 100644 --- a/arch/mips/include/asm/mipsregs.h +++ b/arch/mips/include/asm/mipsregs.h @@ -689,6 +689,9 @@ #define MIPS_CONF7_IAR (_ULCAST_(1) << 10) #define MIPS_CONF7_AR (_ULCAST_(1) << 16) +/* Ingenic Config7 bits */ +#define MIPS_CONF7_BTB_LOOP_EN (_ULCAST_(1) << 4) + /* Config7 Bits specific to MIPS Technologies. */ /* Performance counters implemented Per TC */ @@ -2813,6 +2816,7 @@ __BUILD_SET_C0(status) __BUILD_SET_C0(cause) __BUILD_SET_C0(config) __BUILD_SET_C0(config5) +__BUILD_SET_C0(config7) __BUILD_SET_C0(intcontrol) __BUILD_SET_C0(intctl) __BUILD_SET_C0(srsmap) diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index eb527a1..2bdd3e1 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -1964,6 +1964,13 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu) c->cputype = CPU_XBURST; c->writecombine = _CACHE_UNCACHED_ACCELERATED; __cpu_name[cpu] = "Ingenic XBurst"; + /* + * The XBurst core by default attempts to avoid branch target + * buffer lookups by detecting & special casing loops. This + * feature will cause BogoMIPS and lpj calculate in error. + * Set cp0 config7 bit 4 to disable this feature. + */ + set_c0_config7(MIPS_CONF7_BTB_LOOP_EN); break; default: panic("Unknown Ingenic Processor ID!");