Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2032759pxa; Sun, 16 Aug 2020 21:06:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiseVf+6665R/59gu/k/EImHx8ApNU8+NFc/Y3Izl3t/Cq8zGEP/jw8PkaQ3mTW1IB5/Sn X-Received: by 2002:a17:907:402b:: with SMTP id nr19mr13152816ejb.123.1597637160490; Sun, 16 Aug 2020 21:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597637160; cv=none; d=google.com; s=arc-20160816; b=BMyShhFny2YUv+uVFbab4q6kOCvI88pCXc+YbofDp0pIbbvJtZVnXH8bic0mjFc1V7 9/3OjKSwYGaNYKhdo8v4DcUYNi3SMEnuDdrHtZ5JaoiniR6K4eSjIJWI9JGNpVZ8vY8M 5pbRWQOPxqubJWDFbLR0e6R5EYfWu91t45CYItLPgkKc82Vc6t9hpzMaEXs0po2jHa1L BKfzVcbtiJ81oMkMXpV1nebDLeJXKp0i0xezNLNt9hI7U0roiyC47tYnGE6P4JkVFKcQ d1SMU54AdZypGEMG3+Vf1jFxPPKxGFlIdol8I14YkXz3Enzxbd7chDhZyxn/CLBPNi0P 6ynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E1wJGWSMagCv0c/txus5C3GLH3P1R8QzmrygyMoWk60=; b=l/9n8Ub31HJ1LTI6tGoDIXcfpAwnS61IvJtircp9281MGmiprveQP4or8VtmPf2P2i H/iYc4sjTkUUt5zEdR4SJiIAvCVXKOE4BAPupq8qwgjZde/R+/GOFnyKX8ykn2v5AMr0 PsiucrdzGhxCjkBRreBeHaT6umzagVCzPTrKm7NYnINTcXiXQJhqSeLuNNf1HyG+ovfW aERw3FrbpnyXc8hif9DEd8Zmsg+0ww4eUGNGecwG2HWwQ23Y6YfinnBgHETOXegIlzKP N7/Rf4r5/GtT7ZxQiXv3CtgLti7YG6e+qclP61ze3a0uhm7rpRJecVfPARhvVWqH1hM5 yqsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@flygoat.com header.s=vultr header.b="r/L8sn/5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si10277807ejx.745.2020.08.16.21.05.38; Sun, 16 Aug 2020 21:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@flygoat.com header.s=vultr header.b="r/L8sn/5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727839AbgHQDtj (ORCPT + 99 others); Sun, 16 Aug 2020 23:49:39 -0400 Received: from vultr.net.flygoat.com ([149.28.68.211]:43784 "EHLO vultr.net.flygoat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727076AbgHQDti (ORCPT ); Sun, 16 Aug 2020 23:49:38 -0400 Received: from localhost.localdomain (unknown [IPv6:2001:da8:20f:4430:250:56ff:fe9a:7470]) by vultr.net.flygoat.com (Postfix) with ESMTPSA id F146C200D0; Mon, 17 Aug 2020 03:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=vultr; t=1597636178; bh=Q5RJ1NIgEccdftXxouCtJty5D3e1oMIrOLeVC8dh9Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/L8sn/53RTqpNEUSf7STc7jzV9+RjbiDLarYZCxsaIzipCI5kb6ug9Yffe8t48su nWaqprhN/TZdSjlToFtqAQ2orJENiKh8Vf5hldy5m9194cREQA+VK3gQTZNqbglJaC akesoJgk5caoqXZl53MxMwlSmSGeWcowMuK/HSDlVuMQoMHs9r/JTXcVSZ5KamUuLh 6W3i1BHH14RgZiKHF977jl6449Y09mh3/eYwyyvoFGsRwt2UGJhpDT/S5QzlIur3A3 awYmntV1GV50L3KPcHQcbAG/v+YZcehD5lK7dWFxq4I6oVbu8vH9jMeJdU+wlZ1F5L R9utB2FS1PW9w== From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: Jiaxun Yang , Thomas Bogendoerfer , Huacai Chen , Aleksandar Markovic , Serge Semin , Paul Burton , WANG Xuerui , =?UTF-8?q?=E5=91=A8=E7=90=B0=E6=9D=B0=20=28Zhou=20Yanjie=29?= , Liangliang Huang , afzal mohammed , Peter Xu , "Peter Zijlstra (Intel)" , Ingo Molnar , Sergey Korolev , Alexey Malahov , Marc Zyngier , Anup Patel , Daniel Jordan , Ulf Hansson , Atish Patra , Steven Price , Mike Leach , Ming Lei , Michael Kelley , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 6/7] MIPS: cevt-r4k: Enable intimer for Loongson CPUs with extimer Date: Mon, 17 Aug 2020 11:46:45 +0800 Message-Id: <20200817034701.3515721-7-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.28.0.rc1 In-Reply-To: <20200817034701.3515721-1-jiaxun.yang@flygoat.com> References: <20200817034701.3515721-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Loongson64C and Loongson64G have extimer feature, which is sharing Cause.TI with intimer (which is cevt-r4k). To ensure the cevt-r4k's usability, we need to add a callback for clock device to ensure intimer is enabled when cevt-r4k is enabled. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/cpu-features.h | 4 ++++ arch/mips/include/asm/cpu.h | 1 + arch/mips/kernel/cevt-r4k.c | 25 +++++++++++++++++++++++++ arch/mips/kernel/cpu-probe.c | 6 +++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 78cf7e300f12..aec458eee2a5 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -576,6 +576,10 @@ # define cpu_has_gsexcex __opt(MIPS_CPU_GSEXCEX) #endif +#ifndef cpu_has_extimer +# define cpu_has_extimer __opt(MIPS_CPU_EXTIMER) +#endif + #ifdef CONFIG_SMP /* * Some systems share FTLB RAMs between threads within a core (siblings in diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h index 388a82f28a87..854e1b44254b 100644 --- a/arch/mips/include/asm/cpu.h +++ b/arch/mips/include/asm/cpu.h @@ -429,6 +429,7 @@ enum cpu_type_enum { #define MIPS_CPU_MAC_2008_ONLY BIT_ULL(60) /* CPU Only support MAC2008 Fused multiply-add instruction */ #define MIPS_CPU_FTLBPAREX BIT_ULL(61) /* CPU has FTLB parity exception */ #define MIPS_CPU_GSEXCEX BIT_ULL(62) /* CPU has GSExc exception */ +#define MIPS_CPU_EXTIMER BIT_ULL(63) /* CPU has External Timer (Loongson) */ /* * CPU ASE encodings diff --git a/arch/mips/kernel/cevt-r4k.c b/arch/mips/kernel/cevt-r4k.c index d396b1011fee..a6e56e9d4e70 100644 --- a/arch/mips/kernel/cevt-r4k.c +++ b/arch/mips/kernel/cevt-r4k.c @@ -15,6 +15,8 @@ #include #include +#include +#include static int mips_next_event(unsigned long delta, struct clock_event_device *evt) @@ -302,6 +304,24 @@ core_initcall(r4k_register_cpufreq_notifier); #endif /* !CONFIG_CPU_FREQ */ +#ifdef CONFIG_CPU_LOONGSON64 +static int c0_compare_int_enable(struct clock_event_device *cd) +{ + if (cpu_has_extimer) + set_c0_config6(LOONGSON_CONF6_INTIMER); + + return 0; +} + +static int c0_compare_int_disable(struct clock_event_device *cd) +{ + if (cpu_has_extimer) + clear_c0_config6(LOONGSON_CONF6_INTIMER); + + return 0; +} +#endif + int r4k_clockevent_percpu_init(int cpu) { struct clock_event_device *cd; @@ -330,6 +350,11 @@ int r4k_clockevent_percpu_init(int cpu) cd->set_next_event = mips_next_event; cd->event_handler = mips_event_handler; +#ifdef CONFIG_CPU_LOONGSON64 + cd->set_state_oneshot = c0_compare_int_enable; + cd->set_state_shutdown = c0_compare_int_disable; +#endif + clockevents_config_and_register(cd, mips_hpt_frequency, min_delta, 0x7fffffff); return 0; diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index e2955f1f6316..f41e8d4f6d84 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -2030,6 +2030,9 @@ static inline void decode_cpucfg(struct cpuinfo_mips *c) if (cfg2 & LOONGSON_CFG2_LEXT2) c->ases |= MIPS_ASE_LOONGSON_EXT2; + if (cfg2 & LOONGSON_CFG2_LLFTP) + c->options |= MIPS_CPU_EXTIMER; + if (cfg2 & LOONGSON_CFG2_LSPW) { c->options |= MIPS_CPU_LDPTE; c->guest.options |= MIPS_CPU_LDPTE; @@ -2088,7 +2091,8 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu) * Also some early Loongson-3A2000 had wrong TLB type in Config * register, we correct it here. */ - c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE; + c->options |= MIPS_CPU_FTLB | MIPS_CPU_TLBINV | MIPS_CPU_LDPTE | + MIPS_CPU_EXTIMER; c->writecombine = _CACHE_UNCACHED_ACCELERATED; c->ases |= (MIPS_ASE_LOONGSON_MMI | MIPS_ASE_LOONGSON_CAM | MIPS_ASE_LOONGSON_EXT | MIPS_ASE_LOONGSON_EXT2); -- 2.28.0.rc1