Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linux-6.6.y] Fix built errors of Zhaoxin DMA patches for i386 #391

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/x86/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ ifeq ($(CONFIG_X86_64),y)

obj-$(CONFIG_MMCONF_FAM10H) += mmconf-fam10h_64.o
obj-y += vsmp_64.o
obj-$(CONFIG_PCI) += zhaoxin_kh40000.o
obj-$(CONFIG_INTEL_IOMMU) += zhaoxin_kh40000.o
endif
2 changes: 1 addition & 1 deletion arch/x86/kernel/early-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ static void quirk_zhaoxin_dma_patch(int num, int slot, int func)
revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID);
if (revision == 0x10) {
is_zhaoxin_kh40000 = true;
dma_ops = &kh40000_dma_direct_ops;
kh40000_get_direct_dma_ops();
pr_info("zhaoxin direct dma patch enabled\n");
}
}
Expand Down
5 changes: 5 additions & 0 deletions arch/x86/kernel/zhaoxin_kh40000.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ const struct dma_map_ops kh40000_dma_direct_ops = {
.map_resource = dma_direct_map_resource,
};

void kh40000_get_direct_dma_ops(void)
{
dma_ops = &kh40000_dma_direct_ops;
}

/* zhaoxin kh-40000 iommu dma ops */
static const struct dma_map_ops *iommu_dma_ops;

Expand Down
11 changes: 8 additions & 3 deletions include/linux/dma-map-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,25 @@ pci_p2pdma_map_segment(struct pci_p2pdma_map_state *state, struct device *dev,
}
#endif /* CONFIG_PCI_P2PDMA */

#if defined CONFIG_PCI && defined CONFIG_X86
#if IS_BUILTIN(CONFIG_INTEL_IOMMU) && IS_BUILTIN(CONFIG_X86_64)

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

#else

bool __weak is_zhaoxin_kh40000;
static inline void kh40000_set_iommu_dma_ops(struct device *dev)

static inline void kh40000_get_direct_dma_ops(void)
{

}

static inline void kh40000_set_iommu_dma_ops(struct device *dev)
{

}

#endif

Expand Down
Loading