From patchwork Mon Feb 22 06:07:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 8372171 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7F9999F1D4 for ; Mon, 22 Feb 2016 06:09:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65652203A1 for ; Mon, 22 Feb 2016 06:09:58 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3624F201DD for ; Mon, 22 Feb 2016 06:09:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXjf7-0000gb-Jt; Mon, 22 Feb 2016 06:08:01 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aXjf5-0000gO-SQ for xen-devel@lists.xensource.com; Mon, 22 Feb 2016 06:08:00 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 53/D7-04039-FB5AAC65; Mon, 22 Feb 2016 06:07:59 +0000 X-Env-Sender: lurodriguez@suse.de X-Msg-Ref: server-3.tower-31.messagelabs.com!1456121278!24001292!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44654 invoked from network); 22 Feb 2016 06:07:58 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-3.tower-31.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 22 Feb 2016 06:07:58 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 50A10AC51; Mon, 22 Feb 2016 06:07:57 +0000 (UTC) Date: Mon, 22 Feb 2016 07:07:56 +0100 From: "Luis R. Rodriguez" To: Juergen Gross Message-ID: <20160222060756.GB25240@wotan.suse.de> References: <1455887316-9223-1-git-send-email-mcgrof@kernel.org> <1455887316-9223-9-git-send-email-mcgrof@kernel.org> <56C71704.9080404@suse.com> <20160219144841.GP25240@wotan.suse.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160219144841.GP25240@wotan.suse.de> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: x86@kernel.org, rusty@rustcorp.com.au, linux-kernel@vger.kernel.org, luto@amacapital.net, "Luis R. Rodriguez" , xen-devel@lists.xensource.com, bp@alien8.de, david.vrabel@citrix.com, boris.ostrovsky@oracle.com Subject: Re: [Xen-devel] [PATCH 8/9] x86/rtc: replace paravirt_enabled() check with subarch check X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Feb 19, 2016 at 03:48:41PM +0100, Luis R. Rodriguez wrote: > On Fri, Feb 19, 2016 at 02:22:12PM +0100, Juergen Gross wrote: > > On 19/02/16 14:08, Luis R. Rodriguez wrote: > > > The current check is a super long winded way of asking if this > > > is on lguest. The flags is used for legacy features, this is > > > > What about Xen pv-domU? I wouldn't expect those to have PV_SUPPORTED_RTC > > set. > > Hrm, I see -- how do we check for that in a standard more clean way? OK we have 4 types of x86 platforms that disable RTC: * Intel MID * Lguest * Xen dom-U * x86 on legacy systems annotated with an ACPI legacy flag So it would seem its best to just generalize the disabling of the RTC for any x86 platform, we could also fold the ACPI check into the FADT parse table routine, which is called during setup_arch(). So how about this: diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index f6192502149e..c261402340e3 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -19,12 +19,6 @@ static inline int paravirt_enabled(void) return pv_info.paravirt_enabled; } -static inline int paravirt_has_feature(unsigned int feature) -{ - WARN_ON_ONCE(!pv_info.paravirt_enabled); - return (pv_info.features & feature); -} - static inline void load_sp0(struct tss_struct *tss, struct thread_struct *thread) { diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index 77db5616a473..2489d6a08e89 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -70,14 +70,9 @@ struct pv_info { #endif int paravirt_enabled; - unsigned int features; /* valid only if paravirt_enabled is set */ const char *name; }; -#define paravirt_has(x) paravirt_has_feature(PV_SUPPORTED_##x) -/* Supported features */ -#define PV_SUPPORTED_RTC (1<<0) - struct pv_init_ops { /* * Patch may replace one of the defined code sequences with diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 20c11d1aa4cc..10f3614265c1 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -472,7 +472,6 @@ static inline unsigned long current_top_of_stack(void) #else #define __cpuid native_cpuid #define paravirt_enabled() 0 -#define paravirt_has(x) 0 static inline void load_sp0(struct tss_struct *tss, struct thread_struct *thread) diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h index 1ae89a2721d6..fe0d579b63e3 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h @@ -84,11 +84,14 @@ struct x86_init_paging { * boot cpu * @timer_init: initialize the platform timer (default PIT/HPET) * @wallclock_init: init the wallclock device + * @no_cmos_rtc: set when platform has no CMOS real-time clock + * present */ struct x86_init_timers { void (*setup_percpu_clockev)(void); void (*timer_init)(void); void (*wallclock_init)(void); + bool no_cmos_rtc; }; /** diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index e75907601a41..6b2cac0f276b 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -913,6 +913,10 @@ late_initcall(hpet_insert_resource); static int __init acpi_parse_fadt(struct acpi_table_header *table) { + if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { + pr_debug("ACPI: not registering RTC platform device\n"); + x86_init.timers.no_cmos_rtc = true; + } #ifdef CONFIG_X86_PM_TIMER /* detect the location of the ACPI PM Timer */ diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c index 4af8d063fb36..ef92aa84c2e3 100644 --- a/arch/x86/kernel/rtc.c +++ b/arch/x86/kernel/rtc.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef CONFIG_X86_32 /* @@ -188,19 +189,7 @@ static __init int add_rtc_cmos(void) if (of_have_populated_dt()) return 0; - /* Intel MID platforms don't have ioport rtc */ - if (intel_mid_identify_cpu()) - return -ENODEV; - -#ifdef CONFIG_ACPI - if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) { - /* This warning can likely go away again in a year or two. */ - pr_info("ACPI: not registering RTC platform device\n"); - return -ENODEV; - } -#endif - - if (paravirt_enabled() && !paravirt_has(RTC)) + if (x86_init.timers.no_cmos_rtc) return -ENODEV; platform_device_register(&rtc_device); diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index 4ba229ac3f4f..62535a869e06 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c @@ -1414,7 +1414,6 @@ __init void lguest_init(void) pv_info.kernel_rpl = 1; /* Everyone except Xen runs with this set. */ pv_info.shared_kernel_pmd = 1; - pv_info.features = 0; /* * We set up all the lguest overrides for sensitive operations. These @@ -1482,6 +1481,7 @@ __init void lguest_init(void) x86_init.resources.memory_setup = lguest_memory_setup; x86_init.irqs.intr_init = lguest_init_IRQ; x86_init.timers.timer_init = lguest_time_init; + x86_init.timers.no_cmos_rtc = true; x86_platform.calibrate_tsc = lguest_tsc_khz; x86_platform.get_wallclock = lguest_get_wallclock; diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c index 90bb997ed0a2..083369a6b215 100644 --- a/arch/x86/platform/intel-mid/intel-mid.c +++ b/arch/x86/platform/intel-mid/intel-mid.c @@ -175,6 +175,9 @@ void __init x86_intel_mid_early_setup(void) x86_init.timers.timer_init = intel_mid_time_init; x86_init.timers.setup_percpu_clockev = x86_init_noop; + /* Intel MID platforms don't have ioport rtc */ + x86_init.timers.no_cmos_rtc = true; + x86_init.irqs.pre_vector_init = x86_init_noop; x86_init.oem.arch_setup = intel_mid_arch_setup; diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 5b3f1c763806..5c06169bce27 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -1192,7 +1192,6 @@ static const struct pv_info xen_info __initconst = { #ifdef CONFIG_X86_64 .extra_user_64bit_cs = FLAT_USER_CS64, #endif - .features = 0, .name = "Xen", }; @@ -1526,8 +1525,6 @@ asmlinkage __visible void __init xen_start_kernel(void) /* Install Xen paravirt ops */ pv_info = xen_info; - if (xen_initial_domain()) - pv_info.features |= PV_SUPPORTED_RTC; pv_init_ops = xen_init_ops; if (!xen_pvh_domain()) { pv_cpu_ops = xen_cpu_ops; diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index a0a4e554c6f1..963cdaf63496 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -446,8 +446,10 @@ void __init xen_init_time_ops(void) x86_platform.calibrate_tsc = xen_tsc_khz; x86_platform.get_wallclock = xen_get_wallclock; /* Dom0 uses the native method to set the hardware RTC. */ - if (!xen_initial_domain()) + if (!xen_initial_domain()) { + x86_init.timers.no_cmos_rtc = true; x86_platform.set_wallclock = xen_set_wallclock; + } } #ifdef CONFIG_XEN_PVHVM