Skip to content

Commit

Permalink
Merge branch 'iommu/fixes' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/joro/linux-2.6-iommu into x86/urgent
  • Loading branch information
Ingo Molnar committed Jan 27, 2010
2 parents b7a0afb + a02b119 commit e0b5f80
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions arch/x86/include/asm/amd_iommu_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern void amd_iommu_reset_cmd_buffer(struct amd_iommu *iommu);
extern int amd_iommu_init_devices(void);
extern void amd_iommu_uninit_devices(void);
extern void amd_iommu_init_notifier(void);
extern void amd_iommu_init_api(void);
#ifndef CONFIG_AMD_IOMMU_STATS

static inline void amd_iommu_stats_init(void) { }
Expand Down
23 changes: 16 additions & 7 deletions arch/x86/kernel/amd_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ static int alloc_new_range(struct dma_ops_domain *dma_dom,
{
int index = dma_dom->aperture_size >> APERTURE_RANGE_SHIFT;
struct amd_iommu *iommu;
int i;
unsigned long i;

#ifdef CONFIG_IOMMU_STRESS
populate = false;
Expand Down Expand Up @@ -1489,11 +1489,14 @@ static void __detach_device(struct device *dev)
{
struct iommu_dev_data *dev_data = get_dev_data(dev);
struct iommu_dev_data *alias_data;
struct protection_domain *domain;
unsigned long flags;

BUG_ON(!dev_data->domain);

spin_lock_irqsave(&dev_data->domain->lock, flags);
domain = dev_data->domain;

spin_lock_irqsave(&domain->lock, flags);

if (dev_data->alias != dev) {
alias_data = get_dev_data(dev_data->alias);
Expand All @@ -1504,13 +1507,15 @@ static void __detach_device(struct device *dev)
if (atomic_dec_and_test(&dev_data->bind))
do_detach(dev);

spin_unlock_irqrestore(&dev_data->domain->lock, flags);
spin_unlock_irqrestore(&domain->lock, flags);

/*
* If we run in passthrough mode the device must be assigned to the
* passthrough domain if it is detached from any other domain
* passthrough domain if it is detached from any other domain.
* Make sure we can deassign from the pt_domain itself.
*/
if (iommu_pass_through && dev_data->domain == NULL)
if (iommu_pass_through &&
(dev_data->domain == NULL && domain != pt_domain))
__attach_device(dev, pt_domain);
}

Expand Down Expand Up @@ -2218,6 +2223,12 @@ static struct dma_map_ops amd_iommu_dma_ops = {
/*
* The function which clues the AMD IOMMU driver into dma_ops.
*/

void __init amd_iommu_init_api(void)
{
register_iommu(&amd_iommu_ops);
}

int __init amd_iommu_init_dma_ops(void)
{
struct amd_iommu *iommu;
Expand Down Expand Up @@ -2253,8 +2264,6 @@ int __init amd_iommu_init_dma_ops(void)
/* Make the driver finally visible to the drivers */
dma_ops = &amd_iommu_dma_ops;

register_iommu(&amd_iommu_ops);

amd_iommu_stats_init();

return 0;
Expand Down
3 changes: 3 additions & 0 deletions arch/x86/kernel/amd_iommu_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,12 @@ static int __init amd_iommu_init(void)
ret = amd_iommu_init_passthrough();
else
ret = amd_iommu_init_dma_ops();

if (ret)
goto free;

amd_iommu_init_api();

amd_iommu_init_notifier();

enable_iommus();
Expand Down
2 changes: 1 addition & 1 deletion lib/dma-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
return count;
}

const struct file_operations filter_fops = {
static const struct file_operations filter_fops = {
.read = filter_read,
.write = filter_write,
};
Expand Down

0 comments on commit e0b5f80

Please sign in to comment.