From patchwork Tue Feb 23 08:12:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 62678 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1703577lbl; Tue, 23 Feb 2016 00:17:49 -0800 (PST) X-Received: by 10.140.175.134 with SMTP id v128mr41956524qhv.61.1456215469743; Tue, 23 Feb 2016 00:17:49 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 107si22020630qgo.100.2016.02.23.00.17.49; Tue, 23 Feb 2016 00:17:49 -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 588F462F05; Tue, 23 Feb 2016 08:17:49 +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 D5B3E62F19; Tue, 23 Feb 2016 08:14:56 +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 8BCBA62F0D; Tue, 23 Feb 2016 08:14:49 +0000 (UTC) Received: from mail-pf0-f171.google.com (mail-pf0-f171.google.com [209.85.192.171]) by lists.linaro.org (Postfix) with ESMTPS id D1DFD62F05 for ; Tue, 23 Feb 2016 08:13:30 +0000 (UTC) Received: by mail-pf0-f171.google.com with SMTP id x65so108205040pfb.1 for ; Tue, 23 Feb 2016 00:13:30 -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=LLprDSGgltyvgwOPE+JyKqrIUx9KuFnu5LIlruQlFcM=; b=Ppqi4EWZfuW2I+Ml8zdN9wIs60wWPr9wSTlKxnE52Z/EnFLxUMIHveX2K29hBnKRfh ekcNOiv+DUAEyeL6kQX+x05ixFNtH47U1Hd1Dp8/f6BehJVJyiWusYbwIGZcK3aZ1Laq p/cViP+hRd6YvP179fCFxtAYCj1zjNFP5gP3yLzP8mvgOVSRx9VW4xcSoph1V6STzX2t W7V/TKUVBvVyjeaJnsYaPJQ8f17QZiB+Vs02Rqv6GfE9D4CUDkBqyM50YsaM9p6qqLOI zw7Re69LG0ZAx+OQ1YyFkP6p158rlQps+inBzCvOBGS3dsINweN7iHJJ1UDfNf+9tFFt 30eg== X-Gm-Message-State: AG10YOQFZPxLj/szJonHUlvk4/j8RI1WAaUmXkk1P/fDymfSbo7aPNjQXrBDLQok23OERr9R24Y= X-Received: by 10.98.19.215 with SMTP id 84mr44432783pft.22.1456215210249; Tue, 23 Feb 2016 00:13:30 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 17sm41920352pfp.96.2016.02.23.00.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Feb 2016 00:13:29 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Tue, 23 Feb 2016 16:12:52 +0800 Message-Id: <1456215173-4456-8-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456215173-4456-1-git-send-email-hongbo.zhang@linaro.org> References: <1456215173-4456-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v4 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