History

Merge tag 'iommu-fixes-v3.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel: - fix VT-d regression with handling multiple RMRR entries per device - fix a small race that was left in the mmu_notifier handling in the AMD IOMMUv2 driver * tag 'iommu-fixes-v3.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: iommu/amd: Fix small race between invalidate_range_end/start iommu/vt-d: fix bug in handling multiple RMRRs for the same PCI device

Linus Torvalds committed 12 years ago

Commit 3e7b2562 parents d1fc98b d73a6d72 files · +16 −11Browse files

Unified · Split

2 files
  1. drivers/iommu/amd_iommu_v2.c +13 −5
  2. drivers/iommu/intel-iommu.c +3 −6
drivers/iommu/amd_iommu_v2.c+13−5
@@ -45,7 +45,7 @@ struct pri_queue { · 44 unmodified lines
4545 struct pasid_state {
4646 struct list_head list; /* For global state-list */
4747 atomic_t count; /* Reference count */
48− atomic_t mmu_notifier_count; /* Counting nested mmu_notifier
48+ unsigned mmu_notifier_count; /* Counting nested mmu_notifier
4949 calls */
5050 struct task_struct *task; /* Task bound to this PASID */
5151 struct mm_struct *mm; /* mm_struct for the faults */
@@ -53,7 +53,8 @@ struct pasid_state { · 1 unmodified line
5353 struct pri_queue pri[PRI_QUEUE_SIZE]; /* PRI tag states */
5454 struct device_state *device_state; /* Link to our device_state */
5555 int pasid; /* PASID index */
56− spinlock_t lock; /* Protect pri_queues */
56+ spinlock_t lock; /* Protect pri_queues and
57+ mmu_notifer_count */
5758 wait_queue_head_t wq; /* To wait for count == 0 */
5859 };
5960
@@ -431,15 +432,19 @@ static void mn_invalidate_range_start(struct mmu_notifier *mn, · 371 unmodified lines
431432 {
432433 struct pasid_state *pasid_state;
433434 struct device_state *dev_state;
435+ unsigned long flags;
434436
435437 pasid_state = mn_to_state(mn);
436438 dev_state = pasid_state->device_state;
437439
438− if (atomic_add_return(1, &pasid_state->mmu_notifier_count) == 1) {
440+ spin_lock_irqsave(&pasid_state->lock, flags);
441+ if (pasid_state->mmu_notifier_count == 0) {
439442 amd_iommu_domain_set_gcr3(dev_state->domain,
440443 pasid_state->pasid,
441444 __pa(empty_page_table));
442445 }
446+ pasid_state->mmu_notifier_count += 1;
447+ spin_unlock_irqrestore(&pasid_state->lock, flags);
443448 }
444449
445450 static void mn_invalidate_range_end(struct mmu_notifier *mn,
@@ -448,15 +453,19 @@ static void mn_invalidate_range_end(struct mmu_notifier *mn, · 2 unmodified lines
448453 {
449454 struct pasid_state *pasid_state;
450455 struct device_state *dev_state;
456+ unsigned long flags;
451457
452458 pasid_state = mn_to_state(mn);
453459 dev_state = pasid_state->device_state;
454460
455− if (atomic_dec_and_test(&pasid_state->mmu_notifier_count)) {
461+ spin_lock_irqsave(&pasid_state->lock, flags);
462+ pasid_state->mmu_notifier_count -= 1;
463+ if (pasid_state->mmu_notifier_count == 0) {
456464 amd_iommu_domain_set_gcr3(dev_state->domain,
457465 pasid_state->pasid,
458466 __pa(pasid_state->mm->pgd));
459467 }
468+ spin_unlock_irqrestore(&pasid_state->lock, flags);
460469 }
461470
462471 static void mn_release(struct mmu_notifier *mn, struct mm_struct *mm)
@@ -650,7 +659,6 @@ int amd_iommu_bind_pasid(struct pci_dev *pdev, int pasid, · 187 unmodified lines
650659 goto out;
651660
652661 atomic_set(&pasid_state->count, 1);
653− atomic_set(&pasid_state->mmu_notifier_count, 0);
654662 init_waitqueue_head(&pasid_state->wq);
655663 spin_lock_init(&pasid_state->lock);
656664
drivers/iommu/intel-iommu.c+3−6
@@ -3816,14 +3816,11 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info) · 3815 unmodified lines
38163816 ((void *)rmrr) + rmrr->header.length,
38173817 rmrr->segment, rmrru->devices,
38183818 rmrru->devices_cnt);
3819− if (ret > 0)
3820− break;
3821− else if(ret < 0)
3819+ if(ret < 0)
38223820 return ret;
38233821 } else if (info->event == BUS_NOTIFY_DEL_DEVICE) {
3824− if (dmar_remove_dev_scope(info, rmrr->segment,
3825− rmrru->devices, rmrru->devices_cnt))
3826− break;
3822+ dmar_remove_dev_scope(info, rmrr->segment,
3823+ rmrru->devices, rmrru->devices_cnt);
38273824 }
38283825 }
38293826

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t