Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 282795
b: refs/heads/master
c: bc21662
h: refs/heads/master
i:
  282793: 0ff812c
  282791: b58f73c
v: v3
  • Loading branch information
Joerg Roedel committed Dec 15, 2011
1 parent 5d52253 commit e22e0a3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 52efdb89d60a0f19949129a08af3437a7aab70be
refs/heads/master: bc21662f729cd17d2af93e149f4eccafc7b10181
35 changes: 35 additions & 0 deletions trunk/drivers/iommu/amd_iommu_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct device_state {
int pasid_levels;
int max_pasids;
amd_iommu_invalid_ppr_cb inv_ppr_cb;
amd_iommu_invalidate_ctx inv_ctx_cb;
spinlock_t lock;
wait_queue_head_t wq;
};
Expand Down Expand Up @@ -637,6 +638,9 @@ static int task_exit(struct notifier_block *nb, unsigned long e, void *data)
dev_state = pasid_state->device_state;
pasid = pasid_state->pasid;

if (pasid_state->device_state->inv_ctx_cb)
dev_state->inv_ctx_cb(dev_state->pdev, pasid);

unbind_pasid(dev_state, pasid);

/* Task may be in the list multiple times */
Expand Down Expand Up @@ -881,6 +885,37 @@ int amd_iommu_set_invalid_ppr_cb(struct pci_dev *pdev,
}
EXPORT_SYMBOL(amd_iommu_set_invalid_ppr_cb);

int amd_iommu_set_invalidate_ctx_cb(struct pci_dev *pdev,
amd_iommu_invalidate_ctx cb)
{
struct device_state *dev_state;
unsigned long flags;
u16 devid;
int ret;

if (!amd_iommu_v2_supported())
return -ENODEV;

devid = device_id(pdev);

spin_lock_irqsave(&state_lock, flags);

ret = -EINVAL;
dev_state = state_table[devid];
if (dev_state == NULL)
goto out_unlock;

dev_state->inv_ctx_cb = cb;

ret = 0;

out_unlock:
spin_unlock_irqrestore(&state_lock, flags);

return ret;
}
EXPORT_SYMBOL(amd_iommu_set_invalidate_ctx_cb);

static int __init amd_iommu_v2_init(void)
{
size_t state_table_size;
Expand Down
17 changes: 17 additions & 0 deletions trunk/include/linux/amd-iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ struct amd_iommu_device_info {
extern int amd_iommu_device_info(struct pci_dev *pdev,
struct amd_iommu_device_info *info);

/**
* amd_iommu_set_invalidate_ctx_cb() - Register a call-back for invalidating
* a pasid context. This call-back is
* invoked when the IOMMUv2 driver needs to
* invalidate a PASID context, for example
* because the task that is bound to that
* context is about to exit.
*
* @pdev: The PCI device the call-back should be registered for
* @cb: The call-back function
*/

typedef void (*amd_iommu_invalidate_ctx)(struct pci_dev *pdev, int pasid);

extern int amd_iommu_set_invalidate_ctx_cb(struct pci_dev *pdev,
amd_iommu_invalidate_ctx cb);

#else

static inline int amd_iommu_detect(void) { return -ENODEV; }
Expand Down

0 comments on commit e22e0a3

Please sign in to comment.