From patchwork Wed Mar 2 19:29:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 63416 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2560664lbc; Wed, 2 Mar 2016 11:35:31 -0800 (PST) X-Received: by 10.140.107.182 with SMTP id h51mr35214422qgf.53.1456947331380; Wed, 02 Mar 2016 11:35:31 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f125si6466602qkb.95.2016.03.02.11.35.30; Wed, 02 Mar 2016 11:35:31 -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 Received: by lists.linaro.org (Postfix, from userid 109) id D893B650C9; Wed, 2 Mar 2016 19:35:30 +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 72B1965104; Wed, 2 Mar 2016 19:31:31 +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 8D9A4650C9; Wed, 2 Mar 2016 19:31:22 +0000 (UTC) Received: from mail-qg0-f50.google.com (mail-qg0-f50.google.com [209.85.192.50]) by lists.linaro.org (Postfix) with ESMTPS id 3A3DB62FF3 for ; Wed, 2 Mar 2016 19:30:21 +0000 (UTC) Received: by mail-qg0-f50.google.com with SMTP id w104so16838303qge.1 for ; Wed, 02 Mar 2016 11:30:21 -0800 (PST) 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=SHWJVbFlJWAAcUHqz09/VeLcJXQcd3irBO1BprGU9PU=; b=K1EUmmUKURl3pdhcPOwD0AX0uoWEwuFjWvjZK48ukh6eSBuvAfhU3tBdTXHjVAr9on EqIgSYzOu/67kW2QbAKG5bdQk7j/hhxgZDNRCxn1ipFijtD7/vbR+F9AYeL/PZjfAsbG QvGhLDbHHWTRPTkq5iPzwGhtISiw/GsJBIVfVzN9IoYypDtcvjK6NCMIBtPThdKNcXkb 6hKn3jEmM9cfr4nlKP4aA8eFro0i0elOLLzmHU1CCxpKth86CBkTRKd4a03mFnx5IrLe v2QoH6Q+WLvh2yGMN2RcB4XXhjU++1D64fxn5o98f/ty8Zgp37IrpHrvnhnNKT9p8PA1 6VWA== X-Gm-Message-State: AD7BkJJomrfdiQCBh5MklI5886uhMjUKBV5kPP/LTUdJUpf+W8JmHtVs8mnXiEx4EeB/tB8eB6U= X-Received: by 10.140.94.176 with SMTP id g45mr35264648qge.59.1456947021007; Wed, 02 Mar 2016 11:30:21 -0800 (PST) Received: from localhost.localdomain (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by smtp.gmail.com with ESMTPSA id a129sm15527538qkb.45.2016.03.02.11.30.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 11:30:20 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 2 Mar 2016 14:29:51 -0500 Message-Id: <1456946992-19251-8-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456946992-19251-1-git-send-email-mike.holmes@linaro.org> References: <1456946992-19251-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v5 7/8] linux-generic: use one uniform call systemcpu() 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 Currently there are two systemcpu() functions, one is for some specific platforms and the other is for default dummy, but most of the contents are same except for sysinfo->cache_line_size: one is true data from calling systemcpu_cache_line_size() and another is dummy data. In such a situation we can create another systemcpu_cache_line_size() to return dummy data for platforms which are lack of it, then only one function systemcpu() is enough. Signed-off-by: Hongbo Zhang Reviewed-and-tested-by: Bill Fischofer --- platform/linux-generic/odp_system_info.c | 40 +++++++------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 2d202a0..6f9fb6e 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -73,6 +73,15 @@ static int systemcpu_cache_line_size(void) return size; } + +#else +/* + * Use dummy data if not available from /sys/devices/system/cpu/ + */ +static int systemcpu_cache_line_size(void) +{ + return 64; +} #endif @@ -105,9 +114,6 @@ static int huge_page_size(void) } -#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ -defined __powerpc__ - /* * Analysis of /sys/devices/system/cpu/ files */ @@ -142,34 +148,6 @@ static int systemcpu(odp_system_info_t *sysinfo) return 0; } -#else - -/* - * Use sysconf and dummy values in generic case - */ - - -static int systemcpu(odp_system_info_t *sysinfo) -{ - int ret; - - ret = sysconf_cpu_count(); - if (ret == 0) { - ODP_ERR("sysconf_cpu_count failed.\n"); - return -1; - } - - sysinfo->cpu_count = ret; - - sysinfo->huge_page_size = huge_page_size(); - - /* Dummy values */ - sysinfo->cache_line_size = 64; - - return 0; -} - -#endif /* * System info initialisation