From patchwork Thu Dec 21 13:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 122560 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp856051qgn; Thu, 21 Dec 2017 05:03:40 -0800 (PST) X-Google-Smtp-Source: ACJfBosYYGJddzzd/3KQ2eA6hxsyG7EGmPr/nbISPZXWJCDpBXYFScISqHZHdNHLzE4W4pVxPdqo X-Received: by 10.55.151.71 with SMTP id z68mr14237553qkd.83.1513861420285; Thu, 21 Dec 2017 05:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513861420; cv=none; d=google.com; s=arc-20160816; b=rPwACO2NDSexR3dLLelyWdPaRWz5/okp1TdQX2EfRJmMZiOLcaa0ZF8h3nF/zDhE59 pDammM+iTcY2dkL1tn/ukAWzSxrly0L2aS9rMgyQeCE4OCdL9M+4fZ6kEKpNU8acz1Qp orEEOPJNNzYzI/QzpVCx6TxlF1tMmseBTGdqlIv85tBHNGUrT/lOHMTGx6fyaH2yilmz Ka4vFV19XZO9Oc/awzI37e5+A5lb9cNhlt70GMtBjssvxgL1SZzvqXrRlH7jrTn8owHw xG/jRR4Zi1q1RlGn1XYUCdkvW/5Y/QFUVNLJshRX3uJIvHMgGCZeVu5RbvhW7olXK1xe bQDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=9Q+6yk8d76fZfLgOj+I69Y1QBOGHCuXE6w5PR1EIryY=; b=xamXU95bl+sG5b8PilI9WSGbF2TsG9IHA0FdfyRpAZnfNMagSTzJW1uJtulVZNNuih sMYmvQFc0S32O/1Yzfwwwbww7TTsHZB+F82jRZanRmHfSvhek2D9EzE2TVZihAn6L7WW 3gBc3N/O/tbq+Y1DBeUVKq/sQSugdnhGre4/kozAvjmn6lPllmpHniP+hTrH3PPhPE8c Ik+4bVAP/4N5PJfjvBe+yQAvLaNckCCAiCnUqe0GsNNUWlw15M6bnnzATXRIBhjky0cR JdwuFVrxHa6QmUcQUO0xHeoRO1i+B7BSmhrXQwavoCY8eKTy/naXqH86W123borgQiAi Kl6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id e23si1208962qkj.235.2017.12.21.05.03.39; Thu, 21 Dec 2017 05:03:40 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id DD9B06099A; Thu, 21 Dec 2017 13:03:39 +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=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 50291609A2; Thu, 21 Dec 2017 13:01:29 +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 171426096B; Thu, 21 Dec 2017 13:01:12 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 1B1BF60953 for ; Thu, 21 Dec 2017 13:00:39 +0000 (UTC) Received: from mxback13g.mail.yandex.net (mxback13g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:92]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 6A5AE5604456 for ; Thu, 21 Dec 2017 16:00:37 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback13g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OJEykZczuR-0bVasPkZ; Thu, 21 Dec 2017 16:00:37 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id A7lll3EN3S-0amS84Pe; Thu, 21 Dec 2017 16:00:36 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 21 Dec 2017 16:00:09 +0300 Message-Id: <1513861209-18790-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513861209-18790-1-git-send-email-odpbot@yandex.ru> References: <1513861209-18790-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 358 Subject: [lng-odp] [PATCH v1 3/3] linux-gen: arch: single cpu cycles file X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen CPU cycle functions were mixed over odp_cpu_cycles.c and odp_cpu_arch.c files. Implement all three cpu cycle API functions in odp_cpu_cycles.c. odp_cpu_arch.c is deleted. Signed-off-by: Petri Savolainen --- /** Email created from pull request 358 (psavol:master-arch-dir-cleanup) ** https://github.com/Linaro/odp/pull/358 ** Patch: https://github.com/Linaro/odp/pull/358.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 93353441d4d0b5d0d679401db0daaef8f7f26ee1 **/ platform/linux-generic/Makefile.am | 15 +++------ platform/linux-generic/arch/default/odp_cpu_arch.c | 38 ---------------------- .../linux-generic/arch/default/odp_cpu_cycles.c | 29 +++++++++++++++++ .../mips64/{odp_cpu_arch.c => odp_cpu_cycles.c} | 10 ++++++ .../arch/x86/{odp_cpu_arch.c => odp_cpu_cycles.c} | 17 ++++++---- 5 files changed, 54 insertions(+), 55 deletions(-) delete mode 100644 platform/linux-generic/arch/default/odp_cpu_arch.c rename platform/linux-generic/arch/mips64/{odp_cpu_arch.c => odp_cpu_cycles.c} (79%) rename platform/linux-generic/arch/x86/{odp_cpu_arch.c => odp_cpu_cycles.c} (77%) diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index d1b916292..8152ea180 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -224,37 +224,32 @@ __LIB__libodp_linux_la_SOURCES = \ odp_weak.c if ARCH_IS_ARM -__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \ - arch/default/odp_cpu_cycles.c \ +__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \ arch/default/odp_global_time.c \ arch/default/odp_sysinfo_parse.c arch_odp_headers = arch/arm/odp/api/cpu_arch.h endif if ARCH_IS_AARCH64 -__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \ - arch/default/odp_cpu_cycles.c \ +__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \ arch/aarch64/odp_global_time.c \ arch/default/odp_sysinfo_parse.c arch_odp_headers = arch/aarch64/odp/api/cpu_arch.h endif if ARCH_IS_MIPS64 -__LIB__libodp_linux_la_SOURCES += arch/mips64/odp_cpu_arch.c \ - arch/default/odp_cpu_cycles.c \ +__LIB__libodp_linux_la_SOURCES += arch/mips64/odp_cpu_cycles.c \ arch/default/odp_global_time.c \ arch/mips64/odp_sysinfo_parse.c arch_odp_headers = arch/mips64/odp/api/cpu_arch.h endif if ARCH_IS_POWERPC -__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_arch.c \ - arch/default/odp_cpu_cycles.c \ +__LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \ arch/default/odp_global_time.c \ arch/powerpc/odp_sysinfo_parse.c arch_odp_headers = arch/powerpc/odp/api/cpu_arch.h endif if ARCH_IS_X86 __LIB__libodp_linux_la_SOURCES += arch/x86/cpu_flags.c \ - arch/x86/odp_cpu_arch.c \ - arch/default/odp_cpu_cycles.c \ + arch/x86/odp_cpu_cycles.c \ arch/x86/odp_global_time.c \ arch/x86/odp_sysinfo_parse.c arch_odp_headers = arch/x86/odp/api/cpu_arch.h diff --git a/platform/linux-generic/arch/default/odp_cpu_arch.c b/platform/linux-generic/arch/default/odp_cpu_arch.c deleted file mode 100644 index 8a8da7445..000000000 --- a/platform/linux-generic/arch/default/odp_cpu_arch.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#include - -#include -#include - -#include -#include - -#define GIGA 1000000000 - -uint64_t odp_cpu_cycles(void) -{ - struct timespec time; - uint64_t sec, ns, hz, cycles; - int ret; - - ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); - - if (ret != 0) - ODP_ABORT("clock_gettime failed\n"); - - hz = odp_cpu_hz_max(); - sec = (uint64_t)time.tv_sec; - ns = (uint64_t)time.tv_nsec; - - cycles = sec * hz; - cycles += (ns * hz) / GIGA; - - return cycles; -} diff --git a/platform/linux-generic/arch/default/odp_cpu_cycles.c b/platform/linux-generic/arch/default/odp_cpu_cycles.c index ccc588825..548aa8172 100644 --- a/platform/linux-generic/arch/default/odp_cpu_cycles.c +++ b/platform/linux-generic/arch/default/odp_cpu_cycles.c @@ -6,7 +6,36 @@ #include "config.h" +#include + +#include +#include + #include +#include + +#define GIGA 1000000000 + +uint64_t odp_cpu_cycles(void) +{ + struct timespec time; + uint64_t sec, ns, hz, cycles; + int ret; + + ret = clock_gettime(CLOCK_MONOTONIC_RAW, &time); + + if (ret != 0) + ODP_ABORT("clock_gettime failed\n"); + + hz = odp_cpu_hz_max(); + sec = (uint64_t)time.tv_sec; + ns = (uint64_t)time.tv_nsec; + + cycles = sec * hz; + cycles += (ns * hz) / GIGA; + + return cycles; +} uint64_t odp_cpu_cycles_max(void) { diff --git a/platform/linux-generic/arch/mips64/odp_cpu_arch.c b/platform/linux-generic/arch/mips64/odp_cpu_cycles.c similarity index 79% rename from platform/linux-generic/arch/mips64/odp_cpu_arch.c rename to platform/linux-generic/arch/mips64/odp_cpu_cycles.c index 50ffc2e77..85a95f097 100644 --- a/platform/linux-generic/arch/mips64/odp_cpu_arch.c +++ b/platform/linux-generic/arch/mips64/odp_cpu_cycles.c @@ -21,3 +21,13 @@ uint64_t odp_cpu_cycles(void) return cycle; } + +uint64_t odp_cpu_cycles_max(void) +{ + return UINT64_MAX; +} + +uint64_t odp_cpu_cycles_resolution(void) +{ + return 1; +} diff --git a/platform/linux-generic/arch/x86/odp_cpu_arch.c b/platform/linux-generic/arch/x86/odp_cpu_cycles.c similarity index 77% rename from platform/linux-generic/arch/x86/odp_cpu_arch.c rename to platform/linux-generic/arch/x86/odp_cpu_cycles.c index a20d91734..a474ac250 100644 --- a/platform/linux-generic/arch/x86/odp_cpu_arch.c +++ b/platform/linux-generic/arch/x86/odp_cpu_cycles.c @@ -4,14 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "config.h" - -#include - #include -#include - -#include uint64_t odp_cpu_cycles(void) { @@ -29,3 +22,13 @@ uint64_t odp_cpu_cycles(void) return tsc.tsc_64; } + +uint64_t odp_cpu_cycles_max(void) +{ + return UINT64_MAX; +} + +uint64_t odp_cpu_cycles_resolution(void) +{ + return 1; +}