Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 119698
b: refs/heads/master
c: 66a05d6
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Dec 3, 2008
1 parent 75bc2d2 commit fdd5664
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 37 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: 3d337c653c94be50f11a45fb14a2afa8a8a1a618
refs/heads/master: 66a05d6b47a299b6bdeb645bc2d536109cd800b4
24 changes: 12 additions & 12 deletions trunk/arch/x86/include/asm/amd_iommu_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,6 @@ struct amd_iommu {
/* Pointer to PCI device of this IOMMU */
struct pci_dev *dev;

/*
* Capability pointer. There could be more than one IOMMU per PCI
* device function if there are more than one AMD IOMMU capability
* pointers.
*/
u16 cap_ptr;

/* physical address of MMIO space */
u64 mmio_phys;
/* virtual address of MMIO space */
Expand All @@ -266,6 +259,13 @@ struct amd_iommu {
/* capabilities of that IOMMU read from ACPI */
u32 cap;

/*
* Capability pointer. There could be more than one IOMMU per PCI
* device function if there are more than one AMD IOMMU capability
* pointers.
*/
u16 cap_ptr;

/* pci domain of this IOMMU */
u16 pci_seg;

Expand All @@ -284,19 +284,19 @@ struct amd_iommu {
/* size of command buffer */
u32 cmd_buf_size;

/* event buffer virtual address */
u8 *evt_buf;
/* size of event buffer */
u32 evt_buf_size;
/* event buffer virtual address */
u8 *evt_buf;
/* MSI number for event interrupt */
u16 evt_msi_num;

/* if one, we need to send a completion wait command */
int need_sync;

/* true if interrupts for this IOMMU are already enabled */
bool int_enabled;

/* if one, we need to send a completion wait command */
int need_sync;

/* default dma_ops domain for that IOMMU */
struct dma_ops_domain *default_dom;
};
Expand Down
6 changes: 2 additions & 4 deletions trunk/arch/x86/include/asm/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,13 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
/* Make sure we keep the same behaviour */
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
#ifdef CONFIG_X86_32
return 0;
#else
#ifdef CONFIG_X86_64
struct dma_mapping_ops *ops = get_dma_ops(dev);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);

return (dma_addr == bad_dma_address);
#endif
return (dma_addr == bad_dma_address);
}

#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
Expand Down
36 changes: 16 additions & 20 deletions trunk/arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)

spin_lock_irqsave(&iommu->lock, flags);
ret = __iommu_queue_command(iommu, cmd);
if (!ret)
iommu->need_sync = 1;
spin_unlock_irqrestore(&iommu->lock, flags);

return ret;
Expand All @@ -210,10 +212,13 @@ static int iommu_completion_wait(struct amd_iommu *iommu)
cmd.data[0] = CMD_COMPL_WAIT_INT_MASK;
CMD_SET_TYPE(&cmd, CMD_COMPL_WAIT);

iommu->need_sync = 0;

spin_lock_irqsave(&iommu->lock, flags);

if (!iommu->need_sync)
goto out;

iommu->need_sync = 0;

ret = __iommu_queue_command(iommu, &cmd);

if (ret)
Expand Down Expand Up @@ -254,8 +259,6 @@ static int iommu_queue_inv_dev_entry(struct amd_iommu *iommu, u16 devid)

ret = iommu_queue_command(iommu, &cmd);

iommu->need_sync = 1;

return ret;
}

Expand All @@ -281,8 +284,6 @@ static int iommu_queue_inv_iommu_pages(struct amd_iommu *iommu,

ret = iommu_queue_command(iommu, &cmd);

iommu->need_sync = 1;

return ret;
}

Expand Down Expand Up @@ -762,8 +763,6 @@ static void set_device_domain(struct amd_iommu *iommu,
write_unlock_irqrestore(&amd_iommu_devtable_lock, flags);

iommu_queue_inv_dev_entry(iommu, devid);

iommu->need_sync = 1;
}

/*****************************************************************************
Expand Down Expand Up @@ -858,6 +857,9 @@ static int get_device_resources(struct device *dev,
print_devid(_bdf, 1);
}

if (domain_for_device(_bdf) == NULL)
set_device_domain(*iommu, *domain, _bdf);

return 1;
}

Expand Down Expand Up @@ -1031,8 +1033,7 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr,
if (addr == bad_dma_address)
goto out;

if (unlikely(iommu->need_sync))
iommu_completion_wait(iommu);
iommu_completion_wait(iommu);

out:
spin_unlock_irqrestore(&domain->lock, flags);
Expand Down Expand Up @@ -1060,8 +1061,7 @@ static void unmap_single(struct device *dev, dma_addr_t dma_addr,

__unmap_single(iommu, domain->priv, dma_addr, size, dir);

if (unlikely(iommu->need_sync))
iommu_completion_wait(iommu);
iommu_completion_wait(iommu);

spin_unlock_irqrestore(&domain->lock, flags);
}
Expand Down Expand Up @@ -1127,8 +1127,7 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
goto unmap;
}

if (unlikely(iommu->need_sync))
iommu_completion_wait(iommu);
iommu_completion_wait(iommu);

out:
spin_unlock_irqrestore(&domain->lock, flags);
Expand Down Expand Up @@ -1173,8 +1172,7 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist,
s->dma_address = s->dma_length = 0;
}

if (unlikely(iommu->need_sync))
iommu_completion_wait(iommu);
iommu_completion_wait(iommu);

spin_unlock_irqrestore(&domain->lock, flags);
}
Expand Down Expand Up @@ -1225,8 +1223,7 @@ static void *alloc_coherent(struct device *dev, size_t size,
goto out;
}

if (unlikely(iommu->need_sync))
iommu_completion_wait(iommu);
iommu_completion_wait(iommu);

out:
spin_unlock_irqrestore(&domain->lock, flags);
Expand Down Expand Up @@ -1257,8 +1254,7 @@ static void free_coherent(struct device *dev, size_t size,

__unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL);

if (unlikely(iommu->need_sync))
iommu_completion_wait(iommu);
iommu_completion_wait(iommu);

spin_unlock_irqrestore(&domain->lock, flags);

Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/x86/kernel/pci-gart_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ static void free_iommu(unsigned long offset, int size)

spin_lock_irqsave(&iommu_bitmap_lock, flags);
iommu_area_free(iommu_gart_bitmap, offset, size);
if (offset >= next_bit)
next_bit = offset + size;
spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
}

Expand Down

0 comments on commit fdd5664

Please sign in to comment.