[dpdk-dev] eal: fix set_tsc_freq

Message ID 1437999475-32438-1-git-send-email-sergio.gonzalez.monroy@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Sergio Gonzalez Monroy July 27, 2015, 12:17 p.m. UTC
  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(-)
  

Comments

Thomas Monjalon July 27, 2015, 12:41 p.m. UTC | #1
2015-07-27 13:17, Sergio Gonzalez Monroy:
> 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>

Applied, thanks for the quick test and fix, and sorry for the trivial error.
  
John McNamara July 27, 2015, 12:42 p.m. UTC | #2
> -----Original Message-----
> From: Gonzalez Monroy, Sergio
> Sent: Monday, July 27, 2015 1:07 PM
> To: Mcnamara, John
> Subject: [PATCH] eal: fix set_tsc_freq
> 
> The logical OR operator evaluates to 1 if any of its operands is different
> than 0.
> 
> Fixes: 040cf8a41187 ("eal: deduplicate timer functions")
> 
> Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>

Acked-by: John McNamara <john.mcnamara@intel.com>
  

Patch

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;
 }