Commit 8eaba08b authored by leoliu-oc's avatar leoliu-oc
Browse files

x86/cpu/zhaoxin: Encapsulate access to global variables within functions

zhaoxin inclusion
category: other
bugzilla: https://gitee.com/openeuler/kernel/issues/I9RPB1


CVE: NA

-----------------

Encapsulate access to zhaoxin_kh40000 within functions, Avoid compilation
issues caused by undeclared variables.

Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202405202102.9bImbUvA-lkp@intel.com/


Signed-off-by: default avatarleoliu-oc <leoliu-oc@zhaoxin.com>
parent 54e09a5d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ static inline const struct dma_map_ops *get_arch_dma_ops(void)

#if IS_BUILTIN(CONFIG_INTEL_IOMMU) && IS_BUILTIN(CONFIG_X86_64)

extern bool is_zhaoxin_kh40000;
bool is_zhaoxin_kh40000(void);
extern const struct dma_map_ops kh40000_dma_direct_ops;
extern void kh40000_set_iommu_dma_ops(struct device *dev);

+12 −2
Original line number Diff line number Diff line
@@ -717,13 +717,23 @@ static void __init apple_airport_reset(int bus, int slot, int func)
	early_iounmap(mmio, BCM4331_MMIO_SIZE);
}

static void quirk_zhaoxin_dma_patch(int num, int slot, int func)
bool __ro_after_init zhaoxin_kh40000;

bool is_zhaoxin_kh40000(void)
{
	return zhaoxin_kh40000;
}

static void __init quirk_zhaoxin_dma_patch(int num, int slot, int func)
{
	u8 revision;

	if (is_zhaoxin_kh40000())
		return;

	revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID);
	if (revision == 0x10) {
		is_zhaoxin_kh40000 = true;
		zhaoxin_kh40000 = true;
		dma_ops = &kh40000_dma_direct_ops;
		pr_info("zhaoxin direct dma patch enabled\n");
	}
+0 −2
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@

#include "../../../kernel/dma/direct.h"

bool is_zhaoxin_kh40000;

/***
 * usage:
 *  set "zhaoxin_patch_bitmask=<value>" in cmdline
+1 −1
Original line number Diff line number Diff line
@@ -4419,7 +4419,7 @@ static void intel_iommu_probe_finalize(struct device *dev)
	set_dma_ops(dev, NULL);
	iommu_setup_dma_ops(dev, 0, U64_MAX);
#ifdef CONFIG_X86_64
	if (is_zhaoxin_kh40000)
	if (is_zhaoxin_kh40000())
		kh40000_set_iommu_dma_ops(dev);
#endif
}
+7 −3
Original line number Diff line number Diff line
@@ -206,6 +206,11 @@ static inline void __init dma_numa_cma_reserve(void)
}
#endif

bool __weak is_zhaoxin_kh40000(void)
{
	return false;
}

/**
 * dma_contiguous_reserve() - reserve area(s) for contiguous memory handling
 * @limit: End address of the reserved memory (optional, 0 for any).
@@ -224,10 +229,9 @@ void __init dma_contiguous_reserve(phys_addr_t limit)

	dma_numa_cma_reserve();

#if defined(CONFIG_X86_64) && defined(CONFIG_PCI)
	if (is_zhaoxin_kh40000)
	if (is_zhaoxin_kh40000())
		return;
#endif

	pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit);

	if (size_cmdline != -1) {