From patchwork Wed Jan 27 08:56:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 60604 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2468251lbb; Wed, 27 Jan 2016 01:21:53 -0800 (PST) X-Received: by 10.140.140.6 with SMTP id 6mr2158879qhm.29.1453886512930; Wed, 27 Jan 2016 01:21:52 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 62si3248775qkz.111.2016.01.27.01.21.52; Wed, 27 Jan 2016 01:21:52 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 84B7E617AA; Wed, 27 Jan 2016 09:21:52 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=O9Ms1Hsk; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 A414361941; Wed, 27 Jan 2016 09:17:37 +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 D2C0761941; Wed, 27 Jan 2016 09:17:33 +0000 (UTC) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by lists.linaro.org (Postfix) with ESMTPS id A14F861941 for ; Wed, 27 Jan 2016 09:16:05 +0000 (UTC) Received: by mail-pa0-f45.google.com with SMTP id ho8so1756584pac.2 for ; Wed, 27 Jan 2016 01:16:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MjjXJrXz5lcWAiPzFybgUeNBKy8AZd5fs8GMoAIQabs=; b=O9Ms1HskI5ENyqku2BOlkEyINN4BDKc4LXJR7pMZ3hzJiEqFN8i0FPqYDD+EoxpmKv Tg/gTIdHwCpeunc5XkTPlySqSJXZS/GHyPKNSP6a0EIsTf356nrvN79P0DKEHGOoYkLI WsmPRwF2B9uAtdszuR2sUnLJISegaAOEgdnGc= 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=MjjXJrXz5lcWAiPzFybgUeNBKy8AZd5fs8GMoAIQabs=; b=GsAqpXe6RRBBTN5mBb2mHiQAmtk/pqKowIg8g931lUuTnkIGEzMcPpMTpkWa4P2lkY CUSsidfPLELxnWFRw45lNNik7Ouy/TcOInFHr9C2GJtiW40KVWMqi1cXztxOt/M6B+fj jV0WOhtOk6GWiHRxqfA9vv573dG0oiYCiHKpavbl2u5lfoodbJSE9sr+5aiYr70efI+2 xDDMTtcHoNc6oGESVk3LTLvJijT+Sd/cO9vTagIw30TN3sZ+nWbgdiE0pzXxvX7Gkhul LotJVNbUNMSqVTb+plWbE6sljn30T8ieDwTGqNCv9GBbGx85Y8T1iM8APcnBz0lWhsOZ Wnug== X-Gm-Message-State: AG10YORHa1qqVZUF45Ax+Iy9qRRRBh8KcXPIoDoSsLql3IDYk5IJje05IcPVf3pF0z/NVjbNk9E= X-Received: by 10.66.147.136 with SMTP id tk8mr41319299pab.157.1453886165025; Wed, 27 Jan 2016 01:16:05 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id f27sm7407314pfj.0.2016.01.27.01.16.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jan 2016 01:16:04 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Wed, 27 Jan 2016 16:56:12 +0800 Message-Id: <1453884974-24724-11-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453884974-24724-1-git-send-email-hongbo.zhang@linaro.org> References: <1453884974-24724-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v8 API-NEXT 10/12] linux-generic: sysinfo: apply per-CPU implementation to MIPS 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Hongbo Zhang When per-CPU framework was introduced, it was only implemented on x86, for other platforms, only the model_str[0] and cpu_hz[0] are set to pass compile, this patch set all values for model_str[] and cpu_hz[] on the MIPS platform. Signed-off-by: Hongbo Zhang --- .../linux-generic/arch/mips64/odp_sysinfo_parse.c | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c index dcecbb9..64d65d2 100644 --- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c @@ -12,17 +12,23 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) char str[1024]; char *pos; double mhz = 0.0; + uint64_t hz; int model = 0; int count = 2; + int id = 0; strcpy(sysinfo->cpu_arch_str, "mips64"); - while (fgets(str, sizeof(str), file) != NULL && count > 0) { + while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) { if (!mhz) { pos = strstr(str, "BogoMIPS"); if (pos) - if (sscanf(pos, "BogoMIPS : %lf", &mhz) == 1) + if (sscanf(pos, "BogoMIPS : %lf", &mhz) == 1) { + /* bogomips seems to be 2x freq */ + hz = (uint64_t)(mhz * 1000000.0 / 2.0); + sysinfo->cpu_hz[id] = hz; count--; + } } if (!model) { @@ -32,18 +38,22 @@ int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) 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; + strncpy(sysinfo->model_str[id], pos + 2, + sizeof(sysinfo->model_str[id])); + len = strlen(sysinfo->model_str[id]); + sysinfo->model_str[id][len - 1] = 0; model = 1; count--; } } - } - /* bogomips seems to be 2x freq */ - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0 / 2.0); + if (count == 0) { + mhz = 0.0; + model = 0; + count = 2; + id++; + } + } return 0; }