Skip to content

Commit 5d82d8e

Browse files
committed
x86/cpu: Refresh DCA leaf reading code
The DCA leaf number is also hard-coded in the CPUID level dependency table. Move its definition to common code and use it. While at it, fix up the naming and types in the probe code. All CPUID data is provided in 32-bit registers, not 'unsigned long'. Also stop referring to "level_9". Move away from test_bit() because the type is no longer an 'unsigned long'. Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Zhao Liu <[email protected]> Link: https://lore.kernel.org/all/20241213205032.476A30FE%40davehans-spike.ostc.intel.com
1 parent 262fba5 commit 5d82d8e

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

arch/x86/include/asm/cpuid.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ enum cpuid_regs_idx {
2121
CPUID_EDX,
2222
};
2323

24-
#define CPUID_MWAIT_LEAF 5
24+
#define CPUID_MWAIT_LEAF 0x5
25+
#define CPUID_DCA_LEAF 0x9
2526

2627
#ifdef CONFIG_X86_32
2728
bool have_cpuid_p(void);

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ struct cpuid_dependent_feature {
638638
static const struct cpuid_dependent_feature
639639
cpuid_dependent_features[] = {
640640
{ X86_FEATURE_MWAIT, CPUID_MWAIT_LEAF },
641-
{ X86_FEATURE_DCA, 0x00000009 },
641+
{ X86_FEATURE_DCA, CPUID_DCA_LEAF },
642642
{ X86_FEATURE_XSAVE, 0x0000000d },
643643
{ 0, 0 }
644644
};

drivers/dma/ioat/dca.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <linux/interrupt.h>
1111
#include <linux/dca.h>
1212

13+
#include <asm/cpuid.h>
14+
1315
/* either a kernel change is needed, or we need something like this in kernel */
1416
#ifndef CONFIG_SMP
1517
#include <asm/smp.h>
@@ -58,11 +60,11 @@ static int dca_enabled_in_bios(struct pci_dev *pdev)
5860
{
5961
/* CPUID level 9 returns DCA configuration */
6062
/* Bit 0 indicates DCA enabled by the BIOS */
61-
unsigned long cpuid_level_9;
63+
u32 eax;
6264
int res;
6365

64-
cpuid_level_9 = cpuid_eax(9);
65-
res = test_bit(0, &cpuid_level_9);
66+
eax = cpuid_eax(CPUID_DCA_LEAF);
67+
res = eax & BIT(0);
6668
if (!res)
6769
dev_dbg(&pdev->dev, "DCA is disabled in BIOS\n");
6870

0 commit comments

Comments
 (0)