Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 212237
b: refs/heads/master
c: efa631c
h: refs/heads/master
i:
  212235: 838ef67
v: v3
  • Loading branch information
Konrad Rzeszutek Wilk authored and H. Peter Anvin committed Aug 26, 2010
1 parent 7f711ab commit 7f8e34b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5bef80a4b826b9cee1c6aec7ecc371ec395260cc
refs/heads/master: efa631c26d3bb1162b8f95008801db602217f52b
4 changes: 2 additions & 2 deletions trunk/arch/x86/include/asm/iommu_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ struct iommu_table_entry {
* to stop detecting the other IOMMUs after yours has been detected.
*/
#define IOMMU_INIT_POST(_detect) \
__IOMMU_INIT(_detect, pci_swiotlb_detect, 0, 0, 0)
__IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, 0, 0, 0)

#define IOMMU_INIT_POST_FINISH(detect) \
__IOMMU_INIT(_detect, pci_swiotlb_detect, 0, 0, 1)
__IOMMU_INIT(_detect, pci_swiotlb_detect_4gb, 0, 0, 1)

/*
* A more sophisticated version of IOMMU_INIT. This variant requires:
Expand Down
13 changes: 11 additions & 2 deletions trunk/arch/x86/include/asm/swiotlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@

#ifdef CONFIG_SWIOTLB
extern int swiotlb;
extern int __init pci_swiotlb_detect(void);
extern int __init pci_swiotlb_detect_override(void);
extern int __init pci_swiotlb_detect_4gb(void);
extern void __init pci_swiotlb_init(void);
extern void __init pci_swiotlb_late_init(void);
#else
#define swiotlb 0
static inline int pci_swiotlb_detect(void)
static inline int pci_swiotlb_detect_override(void)
{
return 0;
}
static inline int pci_swiotlb_detect_4gb(void)
{
return 0;
}
static inline void pci_swiotlb_init(void)
{
}
static inline void pci_swiotlb_late_init(void)
{
}
#endif

static inline void dma_mark_clean(void *addr, size_t size) {}
Expand Down
4 changes: 3 additions & 1 deletion trunk/arch/x86/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ void __init pci_iommu_alloc(void)
/* free the range so iommu could get some range less than 4G */
dma32_free_bootmem();

if (pci_xen_swiotlb_detect() || pci_swiotlb_detect())
if (pci_xen_swiotlb_detect() || pci_swiotlb_detect_override())
goto out;

pci_swiotlb_detect_4gb();

gart_iommu_hole_init();

detect_calgary();
Expand Down
33 changes: 27 additions & 6 deletions trunk/arch/x86/kernel/pci-swiotlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,33 @@ static struct dma_map_ops swiotlb_dma_ops = {
};

/*
* pci_swiotlb_detect - set swiotlb to 1 if necessary
* pci_swiotlb_detect_override - set swiotlb to 1 if necessary
*
* This returns non-zero if we are forced to use swiotlb (by the boot
* option).
*/
int __init pci_swiotlb_detect(void)
int __init pci_swiotlb_detect_override(void)
{
int use_swiotlb = swiotlb | swiotlb_force;

if (swiotlb_force)
swiotlb = 1;

return use_swiotlb;
}

/*
* if 4GB or more detected (and iommu=off not set) return 1
* and set swiotlb to 1.
*/
int __init pci_swiotlb_detect_4gb(void)
{
/* don't initialize swiotlb if iommu=off (no_iommu=1) */
#ifdef CONFIG_X86_64
if (!no_iommu && max_pfn > MAX_DMA32_PFN)
swiotlb = 1;
#endif
if (swiotlb_force)
swiotlb = 1;

return use_swiotlb;
return swiotlb;
}

void __init pci_swiotlb_init(void)
Expand All @@ -68,3 +77,15 @@ void __init pci_swiotlb_init(void)
dma_ops = &swiotlb_dma_ops;
}
}

void __init pci_swiotlb_late_init(void)
{
/* An IOMMU turned us off. */
if (!swiotlb)
swiotlb_free();
else {
printk(KERN_INFO "PCI-DMA: "
"Using software bounce buffering for IO (SWIOTLB)\n");
swiotlb_print_info();
}
}

0 comments on commit 7f8e34b

Please sign in to comment.