Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 91027
b: refs/heads/master
c: 8e0c379
h: refs/heads/master
i:
  91025: 5b80601
  91023: e156032
v: v3
  • Loading branch information
Glauber Costa authored and Ingo Molnar committed Apr 19, 2008
1 parent 1378ee5 commit d0828b4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 68 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: bca5c09663030bdd18ab1b3ccb6671f663c3345a
refs/heads/master: 8e0c379718ef32967deea55937895bfc9b493dd8
44 changes: 44 additions & 0 deletions trunk/arch/x86/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ EXPORT_SYMBOL(forbid_dac);
const struct dma_mapping_ops *dma_ops;
EXPORT_SYMBOL(dma_ops);

int iommu_sac_force __read_mostly = 0;

#ifdef CONFIG_IOMMU_DEBUG
int panic_on_overflow __read_mostly = 1;
int force_iommu __read_mostly = 1;
Expand Down Expand Up @@ -103,6 +105,48 @@ void __init pci_iommu_alloc(void)
}
#endif

int dma_supported(struct device *dev, u64 mask)
{
#ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) {
printk(KERN_INFO "PCI: Disallowing DAC for device %s\n",
dev->bus_id);
return 0;
}
#endif

if (dma_ops->dma_supported)
return dma_ops->dma_supported(dev, mask);

/* Copied from i386. Doesn't make much sense, because it will
only work for pci_alloc_coherent.
The caller just has to use GFP_DMA in this case. */
if (mask < DMA_24BIT_MASK)
return 0;

/* Tell the device to use SAC when IOMMU force is on. This
allows the driver to use cheaper accesses in some cases.
Problem with this is that if we overflow the IOMMU area and
return DAC as fallback address the device may not handle it
correctly.
As a special case some controllers have a 39bit address
mode that is as efficient as 32bit (aic79xx). Don't force
SAC for these. Assume all masks <= 40 bits are of this
type. Normally this doesn't make any difference, but gives
more gentle handling of IOMMU overflow. */
if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
printk(KERN_INFO "%s: Force SAC with mask %Lx\n",
dev->bus_id, mask);
return 0;
}

return 1;
}
EXPORT_SYMBOL(dma_supported);


static int __init pci_iommu_init(void)
{
#ifdef CONFIG_CALGARY_IOMMU
Expand Down
24 changes: 0 additions & 24 deletions trunk/arch/x86/kernel/pci-dma_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,6 @@ void *dma_mark_declared_memory_occupied(struct device *dev,
EXPORT_SYMBOL(dma_mark_declared_memory_occupied);

#ifdef CONFIG_PCI
/* Many VIA bridges seem to corrupt data for DAC. Disable it here */

int
dma_supported(struct device *dev, u64 mask)
{
/*
* we fall back to GFP_DMA when the mask isn't all 1s,
* so we can't guarantee allocations that must be
* within a tighter range than GFP_DMA..
*/
if (mask < 0x00ffffff)
return 0;

/* Work around chipset bugs */
if (forbid_dac > 0 && mask > 0xffffffffULL)
return 0;

if (dma_ops->dma_supported)
return dma_ops->dma_supported(dev, mask);

return 1;
}
EXPORT_SYMBOL(dma_supported);

static int check_iommu(char *s)
{
if (!strcmp(s, "usedac")) {
Expand Down
44 changes: 1 addition & 43 deletions trunk/arch/x86/kernel/pci-dma_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ EXPORT_SYMBOL(bad_dma_address);
int iommu_bio_merge __read_mostly = 0;
EXPORT_SYMBOL(iommu_bio_merge);

static int iommu_sac_force __read_mostly = 0;
extern int iommu_sac_force;

int no_iommu __read_mostly;
/* Set this to 1 if there is a HW IOMMU in the system */
Expand Down Expand Up @@ -161,48 +161,6 @@ void dma_free_coherent(struct device *dev, size_t size,
}
EXPORT_SYMBOL(dma_free_coherent);

int dma_supported(struct device *dev, u64 mask)
{
#ifdef CONFIG_PCI
if (mask > 0xffffffff && forbid_dac > 0) {



printk(KERN_INFO "PCI: Disallowing DAC for device %s\n", dev->bus_id);
return 0;
}
#endif

if (dma_ops->dma_supported)
return dma_ops->dma_supported(dev, mask);

/* Copied from i386. Doesn't make much sense, because it will
only work for pci_alloc_coherent.
The caller just has to use GFP_DMA in this case. */
if (mask < DMA_24BIT_MASK)
return 0;

/* Tell the device to use SAC when IOMMU force is on. This
allows the driver to use cheaper accesses in some cases.
Problem with this is that if we overflow the IOMMU area and
return DAC as fallback address the device may not handle it
correctly.
As a special case some controllers have a 39bit address
mode that is as efficient as 32bit (aic79xx). Don't force
SAC for these. Assume all masks <= 40 bits are of this
type. Normally this doesn't make any difference, but gives
more gentle handling of IOMMU overflow. */
if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
printk(KERN_INFO "%s: Force SAC with mask %Lx\n", dev->bus_id,mask);
return 0;
}

return 1;
}
EXPORT_SYMBOL(dma_supported);

/*
* See <Documentation/x86_64/boot-options.txt> for the iommu kernel parameter
* documentation.
Expand Down

0 comments on commit d0828b4

Please sign in to comment.