From patchwork Tue Jan 19 10:17: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: 59974 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2485582lbb; Tue, 19 Jan 2016 02:25:26 -0800 (PST) X-Received: by 10.55.74.9 with SMTP id x9mr37498624qka.81.1453199126677; Tue, 19 Jan 2016 02:25:26 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e110si36820838qge.8.2016.01.19.02.25.26; Tue, 19 Jan 2016 02:25:26 -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 420C261780; Tue, 19 Jan 2016 10:25:26 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=Vjmw3JAD; 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_H2,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 00620615CB; Tue, 19 Jan 2016 10:19:24 +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 8DED961779; Tue, 19 Jan 2016 10:19:20 +0000 (UTC) Received: from mail-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) by lists.linaro.org (Postfix) with ESMTPS id EF64861779 for ; Tue, 19 Jan 2016 10:17:54 +0000 (UTC) Received: by mail-pf0-f170.google.com with SMTP id n128so173053966pfn.3 for ; Tue, 19 Jan 2016 02:17:54 -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=qRJj0oZ9ZFpSuUZMWMg/tWhxzLXeUu+wD+tNHQDIMag=; b=Vjmw3JADsoDx0QM+W/KhZzBNiVSacO2G8m86APrSyLVgyLsVkRy0cr4buPTcvdUkjC ZEZ+qUZpXXPdYKXXnXHB4nFmNJRDrsJ4W7khGZZbkC2UorR5oaX2QI9aQUAImjJQPkrr BBWc8Hm65TpGm9OywHDUS8Rfc72jJbi4rHRjw= 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=qRJj0oZ9ZFpSuUZMWMg/tWhxzLXeUu+wD+tNHQDIMag=; b=EMNDakM8qBo9AVg7lVsilKO74fKbZLRFNWOEiOkfCjBfXXo7QcoPCjEJmSwzNkvJQX A9i23w28fHztcuDHP8DhXgZUPBOwn8IZn8PE1P4AFNoWgRgQ6Sh1qwqrFalFbOTo3Efj vaPwpmtlUOvp0ScTkz9Vk8zJ3bzoJLF9ZjuJZ+BTnKWKw/PstBBJ+a31m/gm5EmufugX hl/mD88oTggJFxLhPbTBgDXot/n7oTtFdcJr2+FebuZyDCC8Yq6AGaS+3GVwUGKp+Zl+ Yj+RQB1zaGW4aj83dkd9fSdwGD/PVZ3BYtU8V7W5Yi///J/QEgyuZFsUpBNAdyn2BU1W iLtg== X-Gm-Message-State: ALoCoQl464Td0YWqkke4xkX8WZHXa9WjP8zrt20BQj4Z1BfUwIRQFiAnlAKkW5K7fJLlECNNjLOVJviA302OOlIeALbJuPkKHQ== X-Received: by 10.98.44.195 with SMTP id s186mr43799726pfs.0.1453198674351; Tue, 19 Jan 2016 02:17:54 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id k74sm40313374pfb.30.2016.01.19.02.17.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jan 2016 02:17:53 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Tue, 19 Jan 2016 18:17:12 +0800 Message-Id: <1453198633-24365-12-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453198633-24365-1-git-send-email-hongbo.zhang@linaro.org> References: <1453198633-24365-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v6 API-NEXT 11/12] linux-generic: sysinfo: apply per-CPU implementation to PowerPC 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 PowerPC platform. Signed-off-by: Hongbo Zhang --- .../linux-generic/arch/powerpc/odp_sysinfo_parse.c | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c index d8bc5e7..a3734cf 100644 --- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c @@ -12,17 +12,22 @@ 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, "powerpc"); - 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, "clock"); if (pos) - if (sscanf(pos, "clock : %lf", &mhz) == 1) + if (sscanf(pos, "clock : %lf", &mhz) == 1) { + hz = (uint64_t)(mhz * 1000000.0); + sysinfo->cpu_hz[id] = hz; count--; + } } if (!model) { @@ -32,16 +37,21 @@ 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--; } } - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0); + if (count == 0) { + mhz = 0.0; + model = 0; + count = 2; + id++; + } } return 0;