From patchwork Sun Jan 8 10:01:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9503391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6839D6071A for ; Sun, 8 Jan 2017 10:02:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B06528210 for ; Sun, 8 Jan 2017 10:02:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DF9D2832B; Sun, 8 Jan 2017 10:02:46 +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=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 9161028210 for ; Sun, 8 Jan 2017 10:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937355AbdAHKBj (ORCPT ); Sun, 8 Jan 2017 05:01:39 -0500 Received: from mout.gmx.net ([212.227.15.18]:64645 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754254AbdAHKBY (ORCPT ); Sun, 8 Jan 2017 05:01:24 -0500 Received: from p100.box ([92.203.45.134]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M3igT-1ciF8V3AZt-00rISR; Sun, 08 Jan 2017 11:01:14 +0100 Date: Sun, 8 Jan 2017 11:01:11 +0100 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc: Enhance detection if cr16 clocksources are synchronous Message-ID: <20170108100111.GA5340@p100.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:s103ca+JDcihota7ag4Iz/uZOYdRQ1HRdFZYUbzZoJxlrM36d+3 V8vMRn1etRAEVMrExkNdzuHk42MAL3uFHLWlNo4di1fQs4oEaQAuLtRJq3lh8o4MPp2C6Cm 5FfAC9Nx1RPSTwScj9IVXFee3EKU+yJvqbqHbVYimdSsgkNx1gmZmSy3miAoSr1QN+0ZCXK ATK4h5npGYuQdtTOFipNg== X-UI-Out-Filterresults: notjunk:1; V01:K0:+y6fYRrtNKI=:NAEdrnk+7nWid7MWn25Z79 ltdQ0FIKO8muSbzMP0FgOdKtUeLpYtYn0iYigj0sZlBV+zu07yi+Jf79YjR/fvT6Me3GnL87a fWmLB0FzDHCTGeD+eoYN8pimjCCzJDA7Xo/JIhy93zNmJNnzYQH3vK1LpLgCcqMK0Y/K0olRa Ih/Auxr/hzOMt5maoFo87utiuEV4aMznrd5/coEng8mp/IM/ObhL10NUzETwf3i+sQBx2Ddf7 5Lq5X6tp74s1yxTu29wLinBdkvqg9HYhO7QkXmjq/Ga5q+6DBwXnzlcjHDfrFWuh6bNcph6b9 bqVrYqy59/sEGMOxAe4q9ijTU2s9fm5ytRxS6tqkDxqexjm6fYIz5WaGpQMAw0lKW/x0DXw8p Lsvoh1/eLVxSdJPQSSkigmg6dUNGeVZcp7V4QE8CZdjN4dKRYrNLJ0GANKdZ4a95xkHFYAwML X4NSNlk2btyTe1+4ekxVGXKvpmDj5MzCv3Eaq+TKiVjBatDMhTI/XgUBfEapTgt2jjCCohJke 036pm7/ecI1t/1a7XTUadhV0ANsPVVbi/q6GPsB+1ZmJEKyCbmm9K7xg6I0e7RMCm3oHzLL8Y p+ebfzkLg2G9qBnM/RcztV/c80asWXRmDGgU/Mz8pLLWwx21eiCV0VvRa14yXtTwE18G6bAQJ /pY4+dmd6H/J7kQJJWHtQekuglXf1eUbxAPLfgWH8T7QupExkZ5Pw4AUGu6SQ8BrF5+8lY3D4 q1VFejyejl+DHK9JRKmtGCNh0seeCkarxTCsn7qbKScY1FAZuS+OzM1yYws= Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The cr16 clocks of the CPUs are usually not synchron. Nevertheless, it seems that each socket (with two cores) of a C8000 workstation is fed by the same clock source, which makes the cr16 clocks of each socket syncron. Let's try to detect such situations and mark the cr16 clocksource and the sched_clock stable on single-socket and single-core machines. Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h index a3661ee..ea4e6ae 100644 --- a/arch/parisc/include/asm/processor.h +++ b/arch/parisc/include/asm/processor.h @@ -103,6 +103,8 @@ struct cpuinfo_parisc { unsigned long bh_count; /* number of times bh was invoked */ unsigned long fp_rev; unsigned long fp_model; + unsigned long cpu_num; /* CPU number from PAT firmware */ + unsigned long cpu_loc; /* CPU location from PAT firmware */ unsigned int state; struct parisc_device *dev; unsigned long loops_per_jiffy; diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c index 85de47f..b1f33d7 100644 --- a/arch/parisc/kernel/processor.c +++ b/arch/parisc/kernel/processor.c @@ -94,7 +94,7 @@ static int processor_probe(struct parisc_device *dev) unsigned long txn_addr; unsigned long cpuid; struct cpuinfo_parisc *p; - struct pdc_pat_cpu_num cpu_info __maybe_unused; + struct pdc_pat_cpu_num cpu_info = { }; #ifdef CONFIG_SMP if (num_online_cpus() >= nr_cpu_ids) { @@ -180,6 +180,8 @@ static int processor_probe(struct parisc_device *dev) p->hpa = dev->hpa.start; /* save CPU hpa */ p->cpuid = cpuid; /* save CPU id */ p->txn_addr = txn_addr; /* save CPU IRQ address */ + p->cpu_num = cpu_info.cpu_num; + p->cpu_loc = cpu_info.cpu_loc; #ifdef CONFIG_SMP /* ** FIXME: review if any other initialization is clobbered diff --git a/arch/parisc/kernel/time.c b/arch/parisc/kernel/time.c index 1e22f98..3138de7 100644 --- a/arch/parisc/kernel/time.c +++ b/arch/parisc/kernel/time.c @@ -242,14 +242,30 @@ void __init time_init(void) static int __init init_cr16_clocksource(void) { /* - * The cr16 interval timers are not syncronized across CPUs, so mark - * them unstable and lower rating on SMP systems. + * The cr16 interval timers are not syncronized across CPUs on + * different sockets, so mark them unstable and lower rating on + * multi-socket SMP systems. */ if (num_online_cpus() > 1) { - clocksource_cr16.flags = CLOCK_SOURCE_UNSTABLE; - clocksource_cr16.rating = 0; + int cpu; + unsigned long cpu0_loc; + cpu0_loc = per_cpu(cpu_data, 0).cpu_loc; + + for_each_online_cpu(cpu) { + if (cpu0_loc && + cpu0_loc == per_cpu(cpu_data, cpu).cpu_loc) + continue; + + clocksource_cr16.flags = CLOCK_SOURCE_UNSTABLE; + clocksource_cr16.rating = 0; + break; + } } + /* mark sched_clock stable if cr16 clocks are in sync */ + if (clocksource_cr16.flags == CLOCK_SOURCE_IS_CONTINUOUS) + set_sched_clock_stable(); + /* register at clocksource framework */ clocksource_register_hz(&clocksource_cr16, 100 * PAGE0->mem_10msec);