aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/amd_iommu_v2.c
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2014-05-20 17:18:22 -0400
committerJoerg Roedel <jroedel@suse.de>2014-05-26 05:28:12 -0400
commitb87d2d7c0b3507b6b17590d741b5be01e8a21b84 (patch)
tree71e653c1702decd937f23ecae64169191d3ac455 /drivers/iommu/amd_iommu_v2.c
parent4b660a7f5c8099d88d1a43d8ae138965112592c7 (diff)
iommu/amd: Don't access IOMMUv2 state_table directly
This is a preparation for converting the state_table into a state_list. Signed-off-by: Joerg Roedel <jroedel@suse.de> Tested-by: Jay Cornwall <Jay.Cornwall@amd.com>
Diffstat (limited to 'drivers/iommu/amd_iommu_v2.c')
-rw-r--r--drivers/iommu/amd_iommu_v2.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 203b2e6a91cf..5db3675cad76 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -111,13 +111,18 @@ static u16 device_id(struct pci_dev *pdev)
111 return devid; 111 return devid;
112} 112}
113 113
114static struct device_state *__get_device_state(u16 devid)
115{
116 return state_table[devid];
117}
118
114static struct device_state *get_device_state(u16 devid) 119static struct device_state *get_device_state(u16 devid)
115{ 120{
116 struct device_state *dev_state; 121 struct device_state *dev_state;
117 unsigned long flags; 122 unsigned long flags;
118 123
119 spin_lock_irqsave(&state_lock, flags); 124 spin_lock_irqsave(&state_lock, flags);
120 dev_state = state_table[devid]; 125 dev_state = __get_device_state(devid);
121 if (dev_state != NULL) 126 if (dev_state != NULL)
122 atomic_inc(&dev_state->count); 127 atomic_inc(&dev_state->count);
123 spin_unlock_irqrestore(&state_lock, flags); 128 spin_unlock_irqrestore(&state_lock, flags);
@@ -841,7 +846,7 @@ void amd_iommu_free_device(struct pci_dev *pdev)
841 846
842 spin_lock_irqsave(&state_lock, flags); 847 spin_lock_irqsave(&state_lock, flags);
843 848
844 dev_state = state_table[devid]; 849 dev_state = __get_device_state(devid);
845 if (dev_state == NULL) { 850 if (dev_state == NULL) {
846 spin_unlock_irqrestore(&state_lock, flags); 851 spin_unlock_irqrestore(&state_lock, flags);
847 return; 852 return;
@@ -874,7 +879,7 @@ int amd_iommu_set_invalid_ppr_cb(struct pci_dev *pdev,
874 spin_lock_irqsave(&state_lock, flags); 879 spin_lock_irqsave(&state_lock, flags);
875 880
876 ret = -EINVAL; 881 ret = -EINVAL;
877 dev_state = state_table[devid]; 882 dev_state = __get_device_state(devid);
878 if (dev_state == NULL) 883 if (dev_state == NULL)
879 goto out_unlock; 884 goto out_unlock;
880 885
@@ -905,7 +910,7 @@ int amd_iommu_set_invalidate_ctx_cb(struct pci_dev *pdev,
905 spin_lock_irqsave(&state_lock, flags); 910 spin_lock_irqsave(&state_lock, flags);
906 911
907 ret = -EINVAL; 912 ret = -EINVAL;
908 dev_state = state_table[devid]; 913 dev_state = __get_device_state(devid);
909 if (dev_state == NULL) 914 if (dev_state == NULL)
910 goto out_unlock; 915 goto out_unlock;
911 916