From patchwork Fri Jan 29 11:30:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 60790 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1057837lbb; Fri, 29 Jan 2016 03:40:02 -0800 (PST) X-Received: by 10.55.75.144 with SMTP id y138mr10012460qka.96.1454067601914; Fri, 29 Jan 2016 03:40:01 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s9si16670677qhc.72.2016.01.29.03.40.00; Fri, 29 Jan 2016 03:40:01 -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 F07BB6171F; Fri, 29 Jan 2016 11:39:59 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=eZF8q+Ue; 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 DFC0061A0A; Fri, 29 Jan 2016 11:39:04 +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 78E2D6171F; Fri, 29 Jan 2016 11:38:59 +0000 (UTC) Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by lists.linaro.org (Postfix) with ESMTPS id 38E816171F for ; Fri, 29 Jan 2016 11:38:34 +0000 (UTC) Received: by mail-pf0-f176.google.com with SMTP id o185so36323712pfb.1 for ; Fri, 29 Jan 2016 03:38:34 -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=OqZqgrV2eZ3P9yjNYzq3sERpGLlRHvi/tkDcEvbOk4c=; b=eZF8q+UeP+2kBARDEigmpTV6RapQN/2IC6zMU/pmH3XObSxJfbndCd2CMoYqLYt4Ov J3tdigv9S6msIDaozJMO9CYIwzygr8VxYJra7KwPptCIwNVyPbN88yOAAfB05kWSwVo3 6V2jlEzzRjx6GbhPL/DOxRyNg0vujQnN3cECg= 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=OqZqgrV2eZ3P9yjNYzq3sERpGLlRHvi/tkDcEvbOk4c=; b=dEWFP/sVfD0kTix63NKx51p3+Tz2scto2wom1BaaEObMUd2L3QCLuxdWacFdajhaVh UKxwPtjlQXAMnc2RSMZDm7vZGMkKhD1WLRxQ6vCQlXyCB2EeICG9VFo4NJWKKY8n4pxB ewMYniQP/m2EcLjbrvHOUX5BmpmsTmj21755+w/cHmKWyY7zwso/33IqfOwMRUNtVeeP tUeiuG/IwGHu3Mow94VvHErraPhvaKplZ2sxIK0Zl7KM+Cyh6ByVeK+OVaN8UJuJWTEO 5jMWFJLnzU2M6iU7HunWb7sklTeL7GRJYkgRSQQ0YF4EEk0f8IO7EuhQRQkM7aH4ixRU 5VIA== X-Gm-Message-State: AG10YOREyjqxaKqiy7oppRYwlEhQx7fLgfOTsTxe8wUDGvuoIswOumRWJwwNTBAugp8HgYu4RRE= X-Received: by 10.98.66.212 with SMTP id h81mr8911209pfd.89.1454067513621; Fri, 29 Jan 2016 03:38:33 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id f21sm23063753pfd.6.2016.01.29.03.38.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jan 2016 03:38:33 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Fri, 29 Jan 2016 19:30:46 +0800 Message-Id: <1454067047-381-4-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454067047-381-1-git-send-email-hongbo.zhang@linaro.org> References: <1454067047-381-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH API-NEXT 3/4] 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 --- 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