From patchwork Tue Sep 15 13:55:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hongbo.zhang@freescale.com X-Patchwork-Id: 53665 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 4711D22A0D for ; Tue, 15 Sep 2015 14:07:12 +0000 (UTC) Received: by lagj9 with SMTP id j9sf64546490lag.0 for ; Tue, 15 Sep 2015 07:07:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:mime-version:spamdiagnosticoutput :spamdiagnosticmetadata:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=z7NI7sL6bJNQ1gLnYJ+7812CdhkLVBwFEDauwParV3k=; b=B9tKln/wB1zNYMrGfJ+bvTWIYPaAUgLkXwz+dNmWAfp39FzC74JbyLzhEwFwisUXQZ mzjs2tJnLNRWEl45T12GLk5DWItejUQtQ9TT6DLz59Su7NSSmYgSwV2Rn9NxY9O9xzD5 PqwhZ2GhnUYUhPEOJg773K+l1gTtCc0zqRnz/2sEBshUZ/amQ37nlZo0PyDDdBqEwjpv +9/2db1MPRKJW/vOiH+ME+Oe0VoQ/zFD2nHR0hReKikMGvNErTIrGJjPYSGdxsGZDfGf 2r5aOz07ZOZ1A4Zo2ZpLkP9AdLMyg6JbEhLxt4vs7Y2m67/KQtiiqobJeImlVfT6Nicd 04LQ== X-Gm-Message-State: ALoCoQlg0mAK0PrYPb1YDT8K67yKe1nm/CshVWi3b0x8O0oArIUA/aHKZ9gCeJuV1lQUx9vTZ5b7 X-Received: by 10.112.202.165 with SMTP id kj5mr4308705lbc.5.1442326031221; Tue, 15 Sep 2015 07:07:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.229 with SMTP id z5ls777856lal.8.gmail; Tue, 15 Sep 2015 07:07:11 -0700 (PDT) X-Received: by 10.152.37.105 with SMTP id x9mr21108725laj.91.1442326031080; Tue, 15 Sep 2015 07:07:11 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id x2si282618lad.10.2015.09.15.07.07.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 07:07:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbpo4 with SMTP id o4so86017421lbp.2 for ; Tue, 15 Sep 2015 07:07:10 -0700 (PDT) X-Received: by 10.152.170.225 with SMTP id ap1mr12308206lac.72.1442326030846; Tue, 15 Sep 2015 07:07:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1826814lbq; Tue, 15 Sep 2015 07:07:09 -0700 (PDT) X-Received: by 10.107.169.216 with SMTP id f85mr33387243ioj.73.1442326029336; Tue, 15 Sep 2015 07:07:09 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y9si12297251igl.26.2015.09.15.07.07.08; Tue, 15 Sep 2015 07:07:09 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 496EA62C77; Tue, 15 Sep 2015 14:07:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id DDA7462CE6; Tue, 15 Sep 2015 13:57:51 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id F3719619B3; Tue, 15 Sep 2015 13:57:36 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0107.outbound.protection.outlook.com [207.46.100.107]) by lists.linaro.org (Postfix) with ESMTPS id 89B0961FAE for ; Tue, 15 Sep 2015 13:56:10 +0000 (UTC) Received: from BN3PR0301MB1266.namprd03.prod.outlook.com (10.161.209.146) by BN3PR0301MB1218.namprd03.prod.outlook.com (10.161.207.18) with Microsoft SMTP Server (TLS) id 15.1.268.17; Tue, 15 Sep 2015 13:56:08 +0000 Received: from BLUPR03CA004.namprd03.prod.outlook.com (10.255.124.21) by BN3PR0301MB1266.namprd03.prod.outlook.com (10.161.209.146) with Microsoft SMTP Server (TLS) id 15.1.268.17; Tue, 15 Sep 2015 13:56:06 +0000 Received: from BN1AFFO11FD050.protection.gbl (10.255.124.4) by BLUPR03CA004.outlook.office365.com (10.255.124.21) with Microsoft SMTP Server (TLS) id 15.1.268.17 via Frontend Transport; Tue, 15 Sep 2015 13:56:05 +0000 Received-SPF: TempError (protection.outlook.com: error in processing during lookup of freescale.com: DNS Timeout) Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD050.mail.protection.outlook.com (10.58.53.65) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Tue, 15 Sep 2015 13:56:04 +0000 Received: from hongbo.ap.freescale.net (hongbo.ap.freescale.net [10.193.20.3]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t8FDtiXV031670; Tue, 15 Sep 2015 06:56:00 -0700 From: To: Date: Tue, 15 Sep 2015 21:55:31 +0800 Message-ID: <1442325342-13806-7-git-send-email-hongbo.zhang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442325342-13806-1-git-send-email-hongbo.zhang@freescale.com> References: <1442325342-13806-1-git-send-email-hongbo.zhang@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD050; 1:vZ8SExNtKEXtLK9fkgX3T7R4CD4N6u+I11vSwpX1vJ/yFRykOPT+qwsA8qnr3kAE2iaP6c+upyddm34bUiKqEPdRnEEKDvb3ryWD9MRQtKNsKuukSTwQZQFuRQ+b//ijcG6Mm7XtC8VQ2BNYcq54UXBu2uGI5GgfzsINm9slJEzldtlRMfb7S4FCBRsCMe/ORi7O7vEZf4lFuDe7UEgUTsKM5ALdu6KDBAeEp7qZrev1cBkiAcQUk2vyBNFMIUcM3s/DmYKdPjR7dRP5HSyYmkbs3OUEp/qh1eDaHRHK8lsTJwkMokDv8BgzrdnZNFzO9WZIhHi3L5ZLSFKvPtpdigoYZxjP5tt9tqAjmBmDURmHmJPB3P6s0rYQu8JN88JyOUIO+ouWXxIneVzAfq7uJw== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(979002)(6009001)(2980300002)(189002)(199003)(229853001)(48376002)(2351001)(6806004)(50466002)(5001860100001)(19580395003)(106466001)(104016003)(92566002)(33646002)(36756003)(5007970100001)(76176999)(50986999)(5003940100001)(46102003)(69596002)(77096005)(68736005)(64706001)(5001830100001)(86362001)(19580405001)(5001960100002)(87936001)(50226001)(110136002)(97736004)(47776003)(2950100001)(189998001)(4001540100001)(81156007)(77156002)(105606002)(86152002)(62966003)(217873001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0301MB1266; H:az84smr01.freescale.net; FPR:; SPF:TempError; PTR:InfoDomainNonexistent; MX:1; A:3; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1266; 2:3bu16goM1cGg+hYZHwuU7HgrGa65cB48paH4hPrzTvOjC29JJL6UTtkADANMhas2X0ObQpBacc8tG90FhSmz2kt6CcK9KTfWV8lqwYLaaNoL3bv5K/i54h+LVoD2pvg60HhFxrmGisvZjZZKFxrypwaPXFNEu1nZeGd8rg7Abv0=; 3:Wope0jeU2WwIj0cRA72eUJqCu6ZYMzazGQ4XsSEnWQitga3c9UoAvqpMZ0qNES9fNMYpcwxmS4gHn404VfONZo4R8DvDCbH5NaN2KsmJeoFYl381pqPAyTHtHyszGKh4buFsDBlkllnQ566SRBXuw4ci+JfmmyrOFrHbdHE2w0f0Qn3p54BEymSe/raScC4DPU1VhxJUR9UxxtnYOJjDmXOALeGthBObZ5gDBtRDZSA=; 25:JX9oPiQE0YljeKYlouqMX8GSwzFkvP3Yc3+NRmz6HH2UcUYbujHkLVhSwXWPoGpZpw5DIm+DOJSLhYQV5C4k4dJzMW3U+cvgBogDJuFwRT8NqexdUCmJjUASd6pww1qkDYHEc2AFr7XiCtX/4LqhOiQkDf69zjT71YMol0MMLrtWaJUmnzRHhJNoopYbyyx9oYu0lucXi5S1/ahzaxpsDDGG8QtWqGUTKpzMuKfr03+uQL2Z/PHneJHFsj18mWOZjC/y01bUuxKsk3RuMbeuBA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1266; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1266; 20:0pE51rCY09+FsuokzJc6PCRsMkqhte2iYl2/MwGzet2/9TpA053VQjdiiFDG2Ip+H5tI/LvZipzdZEndzVY/B1jgN6IHnoiYWA45v3LxY9txMXuHgMBAJHeniWYXSQv8HMPaUmqzZhMtSunY0xKFcMZzyfHJkmCQxltXMf713KbEUtg5f3sSv70EWP8Y0rvbithrdY6Dl+FneP/sMt0BG4dj0+Y3R09d0Xbq/eifPsk6RmX67sPuqsBazABSBio0Z8rsyiWgn07LYMCrZoIczewl44nFwRI93hvXy4ccyB+/N7h6xwytERPzKs6ylc/rVR/k4p0RAIlDcrkSeWf9kB8EIOVahzUKDL+okOI2rAg=; 4:jLmTV3WVTQvvR7U8ja48CakX99mLVAcm+4Y5+ch7PF4KWEav/4JCrme2f8h0JYQ8fcvErdVW0xjq+mSx/5g/S1Sg7EoOfB/CIGCS29/YaVJ3buhbVy1hHDHemACmGkeDiz0MTwwPCWIjEfJQppemaxVxC5JU1Fy/ijiM1puLwhlfyj4vhmZmCEQY5vHyJ2wfLpER5mhZhrv2N/g+5iSyCTdnNeoQ9sTe3hkGkLHC7iA3+8Zt2BlUWw/yp0Ex8LAqLB01RW77fuJFEKJkCpXMDV1M+9vQgZWgbBaOPq135dl3TjGlpCrThea6slWF4YdPwpF3qYscajD/2v5eqigjaaUUzl934AAzZtADWHNTGG4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(520075)(520078)(3002001); SRVR:BN3PR0301MB1266; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0301MB1266; X-Forefront-PRVS: 070092A9D3 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0301MB1266; 23:K4Ck0dkj9vVM+HOUY6euci80FC0Jdf3K/EbvmEP?= =?us-ascii?Q?Qmu2blK2V/x2P6dns8RcbMR7BZKhUzm5KiDYyQRJd7/SJaLtPnVpNW9GrH63?= =?us-ascii?Q?Ls8GdxY6iDE6/eFOlxBgINwTnqnhJyyLzpCXz3GItrZHMIIRABUtOMoYB39j?= =?us-ascii?Q?GVOLFrbufIfbDvNAAdFZh25N7piKXb4kUOBeCcgihyRe8ZITVAyHX4h2W9h4?= =?us-ascii?Q?lAY3VAsFL+Sma7b3cbX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2WG?= =?us-ascii?Q?mk/8Dqg6NN2i9mblp3GaY+T1GuHRcAvEg36sMWuU486L85UxV8fDCTmUIf6y?= =?us-ascii?Q?XJk+JEWc1isVtNX4Vh2Thpi0w9AJrTKHarqn5ojp12tw8XDWK8FCrP4ismOZ?= =?us-ascii?Q?o5dzg7RTb9QtxEtMWjsk=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1266; 5:nDOfsS5E7N9UR+DGfoS0WtbVM3ixRUou7kBJJsaUtA3f9Yvp1SdyhSl25OHlbEkHuOqkuTad2SQK4vUHzoElbOfx0OJ7M6ncr7csRMmNY/pUMWGtm2EbrHd+/LqshwVPf8gei585y9X3fua6Z0pOXg==; 24:0WoEzL6pM0PffZrIjQkzg49texE6PzFqoKBf5W1vX1dZ/eN8fB5W+Cla0uNm72OTH3JBoK1/HudDAIG2/S3seB0z5kzK5LL8yL/TqT6RIGM=; 20:2gd4zOny1b6S0EoY2rl6zzkWPOOcErszGDxCM4XpaH+BVRaleCenbeclYRtOgW4yKoQgFoU4urrC8mzJqy239Q== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2015 13:56:04.0626 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1266 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1218; 2:MTiiTBG06M4oQpOBgO51wdnIjxaUN24Y25O4/VLcAeemnS0Tr/IHf8CTLsvyeEW4v3Jk3U5lvnpFSFaTuRoxF89JRe8mDN+O8S96yUpeDgBd4qNLTRG2iR7fwsVsR0KadP5Rvzr37XkflPi5KecEy9Br4BNTLDQ/3PmSsFqRVdk=; 23:cuqhCAbbB50pygrft+AQZXKilQFK9oynp+gOed1U7QL3Gcno39WvNoypYYdnPmX/+o68Qn8qgQ0WMSvnSG2IAn95J5aoGz4TT2cOibXmWtaFd29NSnH5sr8nlL5lzTSa2pXQV6x3eedMw7njGQYjM0nBBseyCCJXbEU3JcEep3NtFbgvMJQsEMLLBBsPbHMw X-OriginatorOrg: freescale.com X-Topics: patch Cc: petri.savolainen@nokia.com, stuart.haslam@arm.com Subject: [lng-odp] [API NEXT PATCH v5 06/17] api: sysinfo: add new API to get CPU max frequency X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Hongbo Zhang This patch adds a new API odp_cpu_hz_max() to get the max frequency of the CPU on which the progeress is running. The previous odp_cpu_hz() should return the current frequency and will be adapted later. Signed-off-by: Hongbo Zhang --- include/odp/api/cpu.h | 9 +++++++++ platform/linux-generic/odp_system_info.c | 25 +++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h index 55f5d23..93d3e7f 100644 --- a/include/odp/api/cpu.h +++ b/include/odp/api/cpu.h @@ -73,6 +73,15 @@ const char *odp_cpu_model_str_id(int id); uint64_t odp_cpu_hz(void); /** + * Maximum CPU frequency in Hz + * + * Returns maximum frequency of this CPU + * + * @return CPU frequency in Hz + */ +uint64_t odp_cpu_hz_max(void); + +/** * @} */ diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index ea1f337..43bfcc0 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -121,35 +121,27 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) { char str[1024]; char *pos; - double mhz = 0.0; + double ghz = 0.0; int model = 0; - int count = 2; + int count = 1; while (fgets(str, sizeof(str), file) != NULL && count > 0) { - if (!mhz) { - pos = strstr(str, "cpu MHz"); - if (pos) { - sscanf(pos, "cpu MHz : %lf", &mhz); - count--; - } - } - if (!model) { pos = strstr(str, "model name"); if (pos) { - int len; pos = strchr(str, ':'); strncpy(sysinfo->model_str[0], pos + 2, sizeof(sysinfo->model_str[0])); - len = strlen(sysinfo->model_str[0]); - sysinfo->model_str[0][len - 1] = 0; + pos = strchr(sysinfo->model_str[0], '@'); + *(pos - 1) = '\0'; + sscanf(pos, "@ %lfGHz", &ghz); model = 1; count--; } } } - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); + sysinfo->cpu_hz[0] = (uint64_t)(ghz * 1000000000.0); return 0; } @@ -379,6 +371,11 @@ uint64_t odp_cpu_hz(void) return odp_global_data.system_info.cpu_hz[0]; } +uint64_t odp_cpu_hz_max(void) +{ + return odp_global_data.system_info.cpu_hz[0]; +} + uint64_t odp_sys_huge_page_size(void) { return odp_global_data.system_info.huge_page_size;