From patchwork Tue Jul 26 02:56:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Brooks X-Patchwork-Id: 72761 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1456296qga; Mon, 25 Jul 2016 20:02:25 -0700 (PDT) X-Received: by 10.200.57.34 with SMTP id s31mr34697003qtb.49.1469502144941; Mon, 25 Jul 2016 20:02:24 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z25si19719130qtz.88.2016.07.25.20.02.24; Mon, 25 Jul 2016 20:02:24 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 7DA4F68515; Tue, 26 Jul 2016 03:02:24 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 085F768521; Tue, 26 Jul 2016 02:58:10 +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 A65D3686D6; Tue, 26 Jul 2016 02:58:04 +0000 (UTC) Received: from mail-io0-f169.google.com (mail-io0-f169.google.com [209.85.223.169]) by lists.linaro.org (Postfix) with ESMTPS id 1B9B2686D6 for ; Tue, 26 Jul 2016 02:56:42 +0000 (UTC) Received: by mail-io0-f169.google.com with SMTP id b62so190395641iod.3 for ; Mon, 25 Jul 2016 19:56:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R8LqeJUcND6zBA9HGphze+WGnJOhnpcjAoTn0agSBms=; b=Y+BcHV+rD8qH7QuDwMVhLhL9GDWRyEjnii8AAs7SHCnV0REkW4NhbWn2NF8NwO6PRu I5o0j/H6NvsPwQYCepbAcUazJ0iir66uM/dmZcET0cJ1FqyqlpplmD2lT+F3ntcGEg72 Pji7TdrtbCVYITLfX3e0+0lRQnUQmc6YI2DbMlWDE5Ef01rA1RFbyY8dWi/+e0rm2Xmp Af+vc2RKEXaqTh8CeduDavkiOE7vrM7rhXzL/bW1ZlHMzhvewpXyu5dG8n7gbfMtXK5o FmZttIkkKpxV1yt9Q9jrjVgX9t9Hxmd/KbHipsWfzWzvRReiBk8Xa8Uk3T2A0ddDgp6t kfRg== X-Gm-Message-State: AEkoout/iVFTtsTsCF+h9aNxV/ssXJ09LCjyQZhcV/pCwMYg+G4EwP5xraJRm8Vl1KU3Y/syx4E= X-Received: by 10.202.170.209 with SMTP id t200mr10319926oie.170.1469501801692; Mon, 25 Jul 2016 19:56:41 -0700 (PDT) Received: from localhost.localdomain (68-248-140-212.lightspeed.austtx.sbcglobal.net. [68.248.140.212]) by smtp.gmail.com with ESMTPSA id z189sm12624679oig.29.2016.07.25.19.56.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jul 2016 19:56:40 -0700 (PDT) From: Brian Brooks To: lng-odp@lists.linaro.org Date: Mon, 25 Jul 2016 21:56:22 -0500 Message-Id: <20160726025625.7343-10-brian.brooks@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160726025625.7343-1-brian.brooks@linaro.org> References: <20160726025625.7343-1-brian.brooks@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 09/12] ppc: odp_cpu_cycles() for ppc 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" Signed-off-by: Brian Brooks --- platform/linux-generic/arch/powerpc/odp_cpu_arch.c | 26 ++++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) -- 2.9.0 diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c index 109dd93..346c170 100644 --- a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c +++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c @@ -14,25 +14,17 @@ #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; +#if defined(__powerpc__) || defined(__ppc__) + uint64_t tbl, tbu0, tbu1; - cycles = sec * hz; - cycles += (ns * hz) / GIGA; + do { + __asm__ volatile("mftbu %0" : "=r"(tbu0)); + __asm__ volatile("mftb %0" : "=r"(tbl)); + __asm__ volatile("mftbu %0" : "=r"(tbu1)); + } while (tbu0 != tbu1); - return cycles; + return (tbu0 << 32) | tbl; +#endif }