[v2] eal/x86: add AMD vendor check to choose TSC calibration
Checks
Commit Message
AMD Epyc processors doesn't support get_tsc_freq_arch().
The patch allows graceful return to allow fallback to
alternate TSC calibration.
Fixes: 3dbc565e81a0 ("timer: honor arch-specific TSC frequency query")
Cc: jerin.jacob@caviumnetworks.com
Cc: stable@dpdk.org
Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
---
lib/eal/x86/rte_cycles.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Comments
On 11/23/2023 7:27 AM, Sivaprasad Tummala wrote:
> AMD Epyc processors doesn't support get_tsc_freq_arch().
> The patch allows graceful return to allow fallback to
> alternate TSC calibration.
>
> Fixes: 3dbc565e81a0 ("timer: honor arch-specific TSC frequency query")
> Cc: jerin.jacob@caviumnetworks.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
23/11/2023 11:29, Ferruh Yigit:
> On 11/23/2023 7:27 AM, Sivaprasad Tummala wrote:
> > AMD Epyc processors doesn't support get_tsc_freq_arch().
> > The patch allows graceful return to allow fallback to
> > alternate TSC calibration.
> >
> > Fixes: 3dbc565e81a0 ("timer: honor arch-specific TSC frequency query")
> > Cc: jerin.jacob@caviumnetworks.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
>
> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
Applied
I don't want to block longer this fix,
but I am not satisfied with the implementation.
David, Ferruh, Bruce and Morten were proposing some abstractions
for CPU features identification.
I think we should start a new enum in rte_cpuflags.h defining some
common CPU features, example is timer calibration here.
The function get_tsc_freq_arch() was already doing some __cpuid calls,
so it's one more, but please could you work on abstracting it in EAL?
Thank you
@@ -10,6 +10,10 @@
#include <cpuid.h>
#endif
+#define x86_vendor_amd(t1, t2, t3) \
+ ((t1 == 0x68747541) && /* htuA */ \
+ (t2 == 0x444d4163) && /* DMAc */ \
+ (t3 == 0x69746e65)) /* itne */
#include "eal_private.h"
@@ -110,6 +114,18 @@ get_tsc_freq_arch(void)
uint8_t mult, model;
int32_t ret;
+#ifdef RTE_TOOLCHAIN_MSVC
+ __cpuid(cpuinfo, 0);
+ a = cpuinfo[0];
+ b = cpuinfo[1];
+ c = cpuinfo[2];
+ d = cpuinfo[3];
+#else
+ __cpuid(0, a, b, c, d);
+#endif
+ if (x86_vendor_amd(b, c, d))
+ return 0;
+
/*
* Time Stamp Counter and Nominal Core Crystal Clock
* Information Leaf