From patchwork Wed Jun 15 10:29:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9178123 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 33E2460776 for ; Wed, 15 Jun 2016 10:31:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2023A280E0 for ; Wed, 15 Jun 2016 10:31:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14D772821D; Wed, 15 Jun 2016 10:31:22 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 87DD7280E0 for ; Wed, 15 Jun 2016 10:31:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bD84j-0007qn-6l; Wed, 15 Jun 2016 10:29:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bD84h-0007qR-JG for xen-devel@lists.xenproject.org; Wed, 15 Jun 2016 10:29:31 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 7D/7B-08636-A0E21675; Wed, 15 Jun 2016 10:29:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsXS6fjDS5dLLzH c4FifoMX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvFg5gLGgovaFXvPP2VrYGxU6WLk5BASyJPY OXcVUxcjBwevgJ3ExdPxIGEJAUOJffNXsYHYLAKqEpsO7mMFsdkE1CXanm1nBSkXETCQOHc0q YuRi4NZoJtRYsems0wgNcICDhL7Gw6yQoy3k1j+dwuYzSlgL3H3y0M2iFWCEn93CIOYzEAljS 06Exh5ZiEkZiEkZgG1MgtoSTz8dYsFwtaWWLbwNTNEibTE8n8cEGEziYkbDrChKgGxHSWmNd9 jX8DIsYpRvTi1qCy1SNdIL6koMz2jJDcxM0fX0MBULze1uDgxPTUnMalYLzk/dxMjMEwZgGAH 4/c/TocYJTmYlER5PeQSw4X4kvJTKjMSizPii0pzUosPMcpwcChJ8DLoAuUEi1LTUyvSMnOAE QOTluDgURLh/aMDlOYtLkjMLc5Mh0idYlSUEuf9CZIQAElklObBtcGi9BKjrJQwLyPQIUI8Ba lFuZklqPKvGMU5GJWEeQVAtvNk5pXATX8FtJgJaLHN9HiQxSWJCCmpBsYac849D4Xiz1e0dHE 0xx/qsL0UM7uq/79K8nMeN4vIxI4f+68vPaoktOipYumbBdwrzxQU+W/cNlkr/Z2T3FbnabN9 Jd7f2nArN3hSp/esd/0ai90/Smn/0eRK474V4fXqTQNHxbnEC9nqQq2Ovc9U2bRSlYo3nusWi BPdvfh4wZxovxU6N5RYijMSDbWYi4oTAWzNKoXNAgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1465986567!28940390!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16367 invoked from network); 15 Jun 2016 10:29:29 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-2.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Jun 2016 10:29:29 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Wed, 15 Jun 2016 04:29:27 -0600 Message-Id: <57614A2702000078000F53A9@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 15 Jun 2016 04:29:27 -0600 From: "Jan Beulich" To: "xen-devel" References: <576140F302000078000F52FE@prv-mh.provo.novell.com> In-Reply-To: <576140F302000078000F52FE@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper , Dario Faggioli , Joao Martins Subject: [Xen-devel] [PATCH 6/8] x86/time: support 32-bit wide ACPI PM timer X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP I have no idea why we didn't do so from the beginning. Signed-off-by: Jan Beulich x86/time: support 32-bit wide ACPI PM timer I have no idea why we didn't do so from the beginning. Signed-off-by: Jan Beulich --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -481,22 +481,23 @@ static int __init acpi_parse_fadt(struct if (fadt->header.revision >= FADT2_REVISION_ID) { /* FADT rev. 2 */ if (fadt->xpm_timer_block.space_id == - ACPI_ADR_SPACE_SYSTEM_IO) + ACPI_ADR_SPACE_SYSTEM_IO) { pmtmr_ioport = fadt->xpm_timer_block.address; - /* - * "X" fields are optional extensions to the original V1.0 - * fields, so we must selectively expand V1.0 fields if the - * corresponding X field is zero. - */ - if (!pmtmr_ioport) - pmtmr_ioport = fadt->pm_timer_block; - } else { - /* FADT rev. 1 */ + pmtmr_width = fadt->xpm_timer_block.bit_width; + } + } + /* + * "X" fields are optional extensions to the original V1.0 + * fields, so we must selectively expand V1.0 fields if the + * corresponding X field is zero. + */ + if (!pmtmr_ioport) { pmtmr_ioport = fadt->pm_timer_block; + pmtmr_width = fadt->pm_timer_length == 4 ? 24 : 0; } if (pmtmr_ioport) - printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", - pmtmr_ioport); + printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x (%u bits)\n", + pmtmr_ioport, pmtmr_width); #endif acpi_smi_cmd = fadt->smi_command; --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -403,6 +403,7 @@ static struct platform_timesource __init */ u32 __read_mostly pmtmr_ioport; +unsigned int __initdata pmtmr_width; /* ACPI PM timer ticks at 3.579545 MHz. */ #define ACPI_PM_FREQUENCY 3579545 @@ -417,9 +418,15 @@ static s64 __init init_pmtimer(struct pl u64 start; u32 count, target, mask = 0xffffff; - if ( pmtmr_ioport == 0 ) + if ( !pmtmr_ioport || !pmtmr_width ) return 0; + if ( pmtmr_width == 32 ) + { + pts->counter_bits = 32; + mask = 0xffffffff; + } + count = inl(pmtmr_ioport) & mask; start = rdtsc_ordered(); target = count + CALIBRATE_VALUE(ACPI_PM_FREQUENCY); --- a/xen/include/asm-x86/acpi.h +++ b/xen/include/asm-x86/acpi.h @@ -146,6 +146,7 @@ extern u32 x86_acpiid_to_apicid[]; #define INVALID_ACPIID (-1U) extern u32 pmtmr_ioport; +extern unsigned int pmtmr_width; int acpi_dmar_init(void); void acpi_mmcfg_init(void); Reviewed-by: Andrew Cooper --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -481,22 +481,23 @@ static int __init acpi_parse_fadt(struct if (fadt->header.revision >= FADT2_REVISION_ID) { /* FADT rev. 2 */ if (fadt->xpm_timer_block.space_id == - ACPI_ADR_SPACE_SYSTEM_IO) + ACPI_ADR_SPACE_SYSTEM_IO) { pmtmr_ioport = fadt->xpm_timer_block.address; - /* - * "X" fields are optional extensions to the original V1.0 - * fields, so we must selectively expand V1.0 fields if the - * corresponding X field is zero. - */ - if (!pmtmr_ioport) - pmtmr_ioport = fadt->pm_timer_block; - } else { - /* FADT rev. 1 */ + pmtmr_width = fadt->xpm_timer_block.bit_width; + } + } + /* + * "X" fields are optional extensions to the original V1.0 + * fields, so we must selectively expand V1.0 fields if the + * corresponding X field is zero. + */ + if (!pmtmr_ioport) { pmtmr_ioport = fadt->pm_timer_block; + pmtmr_width = fadt->pm_timer_length == 4 ? 24 : 0; } if (pmtmr_ioport) - printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x\n", - pmtmr_ioport); + printk(KERN_INFO PREFIX "PM-Timer IO Port: %#x (%u bits)\n", + pmtmr_ioport, pmtmr_width); #endif acpi_smi_cmd = fadt->smi_command; --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -403,6 +403,7 @@ static struct platform_timesource __init */ u32 __read_mostly pmtmr_ioport; +unsigned int __initdata pmtmr_width; /* ACPI PM timer ticks at 3.579545 MHz. */ #define ACPI_PM_FREQUENCY 3579545 @@ -417,9 +418,15 @@ static s64 __init init_pmtimer(struct pl u64 start; u32 count, target, mask = 0xffffff; - if ( pmtmr_ioport == 0 ) + if ( !pmtmr_ioport || !pmtmr_width ) return 0; + if ( pmtmr_width == 32 ) + { + pts->counter_bits = 32; + mask = 0xffffffff; + } + count = inl(pmtmr_ioport) & mask; start = rdtsc_ordered(); target = count + CALIBRATE_VALUE(ACPI_PM_FREQUENCY); --- a/xen/include/asm-x86/acpi.h +++ b/xen/include/asm-x86/acpi.h @@ -146,6 +146,7 @@ extern u32 x86_acpiid_to_apicid[]; #define INVALID_ACPIID (-1U) extern u32 pmtmr_ioport; +extern unsigned int pmtmr_width; int acpi_dmar_init(void); void acpi_mmcfg_init(void);