From patchwork Tue Jul 9 19:02:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Park, Aiden" X-Patchwork-Id: 1129965 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45jsFJ1ctzz9s4Y for ; Wed, 10 Jul 2019 05:04:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CB6DBC21DFB; Tue, 9 Jul 2019 19:03:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E44BBC21E2F; Tue, 9 Jul 2019 19:03:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 62BA2C21DCA; Tue, 9 Jul 2019 19:02:35 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lists.denx.de (Postfix) with ESMTPS id 6ADABC21E36 for ; Tue, 9 Jul 2019 19:02:30 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jul 2019 12:02:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,471,1557212400"; d="scan'208";a="188925233" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by fmsmga004.fm.intel.com with ESMTP; 09 Jul 2019 12:02:28 -0700 Received: from orsmsx116.amr.corp.intel.com ([169.254.7.102]) by ORSMSX105.amr.corp.intel.com ([169.254.2.202]) with mapi id 14.03.0439.000; Tue, 9 Jul 2019 12:02:28 -0700 From: "Park, Aiden" To: U-Boot Mailing List , Simon Glass , Bin Meng Thread-Topic: [PATCH v3 5/8] x86: slimbootloader: Set TSC information for timer driver Thread-Index: AdU2iCo43LBlpSmwSB6fRPXxGhuc/A== Date: Tue, 9 Jul 2019 19:02:27 +0000 Message-ID: Accept-Language: ko-KR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjc3NTVhMjYtOTViMi00NWEwLWJlZGUtOWNmNmEzZjM2NjNmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiM0pJRHIzR0pLdzd5UHJaRHU0MklRWUQ4SERrNDFDUHYxOEttZGxPOVg2bU84SjFXZ0xyWisyRzZzRnNMZytKbiJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Subject: [U-Boot] [PATCH v3 5/8] x86: slimbootloader: Set TSC information for timer driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Slim Bootloader provides TSC clock information in its performance info hob. For now, TSC clock information is only used for timer driver from the performance info hob. - Get TSC frequency from performance info hob - Set tsc_base and clock_rate for timer driver Signed-off-by: Aiden Park Reviewed-by: Bin Meng --- Changes in v3: * Use HOB function from the common HOB library arch/x86/cpu/slimbootloader/slimbootloader.c | 34 +++++++++++++++++++ .../asm/arch-slimbootloader/slimbootloader.h | 30 ++++++++++++++++ 2 files changed, 64 insertions(+) -- 2.20.1 diff --git a/arch/x86/cpu/slimbootloader/slimbootloader.c b/arch/x86/cpu/slimbootloader/slimbootloader.c index 9f3a61ec61..2153d2ac66 100644 --- a/arch/x86/cpu/slimbootloader/slimbootloader.c +++ b/arch/x86/cpu/slimbootloader/slimbootloader.c @@ -4,9 +4,43 @@ */ #include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/** + * This sets tsc_base and clock_rate for early_timer and tsc_timer. + * The performance info guid hob has all performance timestamp data, but + * the only tsc frequency info is used for the timer driver for now. + */ +static void tsc_init(void) +{ + struct performance_info *data = NULL; + const struct efi_guid guid = LOADER_PERFORMANCE_INFO_GUID; + + if (!gd->arch.hob_list) + panic("hob list not found!"); + + gd->arch.tsc_base = rdtsc(); + debug("tsc_base=0x%llx\n", gd->arch.tsc_base); + + data = (struct performance_info *) + hob_get_guid_hob_data(gd->arch.hob_list, NULL, &guid); + + if (!data) { + debug("performance info hob not found\n"); + return; + } + + /* frequency is in KHz, so to Hz */ + gd->arch.clock_rate = data->frequency * 1000; + debug("freq=0x%lx\n", gd->arch.clock_rate); +} int arch_cpu_init(void) { + tsc_init(); + return x86_cpu_init_f(); } diff --git a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h index 5a0994544a..e0edbdddf5 100644 --- a/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h +++ b/arch/x86/include/asm/arch-slimbootloader/slimbootloader.h @@ -27,6 +27,15 @@ { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } \ } +/** + * A GUID to get boot performance info hob which is provided by Slim Bootloader + */ +#define LOADER_PERFORMANCE_INFO_GUID \ + { \ + 0x868204be, 0x23d0, 0x4ff9, \ + { 0xac, 0x34, 0xb9, 0x95, 0xac, 0x04, 0xb1, 0xb9 } \ + } + /** * A single entry of memory map information * @@ -71,6 +80,27 @@ struct serial_port_info { u32 rsvd1; } __packed; +/** + * This includes timestamp data which has been collected in Slim Bootloader + * stages from the reset vector. In addition, this has TSC frequency in KHz to + * calculate each timestamp. + * + * @rev : revision of performance_info structure. currently 1. + * @rsvd : padding for alignment + * @count : the number of collected timestamp data + * @flags : only used in Slim Bootloader + * @frequency: tsc frequency in KHz + * @timestamp: the array of timestamp data which has 64-bit tsc value + */ +struct performance_info { + u8 rev; + u8 rsvd[3]; + u16 count; + u16 flags; + u32 frequency; + u64 timestamp[0]; +} __packed; + /** * This includes all memory map entries which is sorted based on physical start * address, from low to high, and carved out reserved, acpi nvs, acpi reclaim