From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <smonroy@ecsmtp.ir.intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 93617C4C4
 for <dev@dpdk.org>; Mon, 27 Jul 2015 14:17:58 +0200 (CEST)
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga101.fm.intel.com with ESMTP; 27 Jul 2015 05:17:57 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.15,553,1432623600"; d="scan'208";a="736287512"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by orsmga001.jf.intel.com with ESMTP; 27 Jul 2015 05:17:58 -0700
Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com
 [10.237.217.46])
 by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id
 t6RCHtWq007442 for <dev@dpdk.org>; Mon, 27 Jul 2015 13:17:56 +0100
Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1])
 by sivswdev02.ir.intel.com with ESMTP id t6RCHtgD032476
 for <dev@dpdk.org>; Mon, 27 Jul 2015 13:17:55 +0100
Received: (from smonroy@localhost)
 by sivswdev02.ir.intel.com with  id t6RCHtGt032472
 for dev@dpdk.org; Mon, 27 Jul 2015 13:17:55 +0100
From: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
To: dev@dpdk.org
Date: Mon, 27 Jul 2015 13:17:55 +0100
Message-Id: <1437999475-32438-1-git-send-email-sergio.gonzalez.monroy@intel.com>
X-Mailer: git-send-email 1.8.5.4
Subject: [dpdk-dev] [PATCH] eal: fix set_tsc_freq
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 27 Jul 2015 12:17:59 -0000

Fix error where TSC freq is 0.

The logical OR operator evaluates to 1 if any of its operands is
different than 0.

Error showed later while initializing PMD:
EAL: TSC frequency is ~0 KHz
<snip>
PMD: eth_ixgbe_dev_init(): Hardware Initialization Failure: -30
EAL: Error - exiting with code: 1
  Cause: Requested device 0000:84:00.0 cannot be used

Fixes: 040cf8a41187 ("eal: deduplicate timer functions")

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 lib/librte_eal/common/eal_common_timer.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c
index 2956703..255f995 100644
--- a/lib/librte_eal/common/eal_common_timer.c
+++ b/lib/librte_eal/common/eal_common_timer.c
@@ -77,7 +77,11 @@ estimate_tsc_freq(void)
 void
 set_tsc_freq(void)
 {
-	uint64_t freq = get_tsc_freq() || estimate_tsc_freq();
+	uint64_t freq = get_tsc_freq();
+
+	if (!freq)
+		freq = estimate_tsc_freq();
+
 	RTE_LOG(INFO, EAL, "TSC frequency is ~%" PRIu64 " KHz\n", freq / 1000);
 	eal_tsc_resolution_hz = freq;
 }
-- 
1.9.3