aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2017-02-28 07:57:18 -0500
committerJoerg Roedel <jroedel@suse.de>2017-02-28 09:48:23 -0500
commitb7a42b9d38063e58cdf201c575da75943f71051e (patch)
treefef44bb620a0a59c7de196a26f04b14df33c0ca0 /drivers
parenta7fdb6e648fb10a4174483b5fc4dac9c25bd2093 (diff)
iommu/amd: Fix crash when accessing AMD-Vi sysfs entries
The link between the iommu sysfs-device and the struct amd_iommu is no longer stored as driver-data. Update the code to the new correct way of getting from device to amd_iommu. Reported-by: Dave Jones <davej@codemonkey.org.uk> Fixes: 39ab9555c241 ('iommu: Add sysfs bindings for struct iommu_device') Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/amd_iommu_init.c4
-rw-r--r--drivers/iommu/amd_iommu_types.h5
2 files changed, 7 insertions, 2 deletions
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 04cdac7ab3e3..6130278c5d71 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1507,7 +1507,7 @@ static ssize_t amd_iommu_show_cap(struct device *dev,
1507 struct device_attribute *attr, 1507 struct device_attribute *attr,
1508 char *buf) 1508 char *buf)
1509{ 1509{
1510 struct amd_iommu *iommu = dev_get_drvdata(dev); 1510 struct amd_iommu *iommu = dev_to_amd_iommu(dev);
1511 return sprintf(buf, "%x\n", iommu->cap); 1511 return sprintf(buf, "%x\n", iommu->cap);
1512} 1512}
1513static DEVICE_ATTR(cap, S_IRUGO, amd_iommu_show_cap, NULL); 1513static DEVICE_ATTR(cap, S_IRUGO, amd_iommu_show_cap, NULL);
@@ -1516,7 +1516,7 @@ static ssize_t amd_iommu_show_features(struct device *dev,
1516 struct device_attribute *attr, 1516 struct device_attribute *attr,
1517 char *buf) 1517 char *buf)
1518{ 1518{
1519 struct amd_iommu *iommu = dev_get_drvdata(dev); 1519 struct amd_iommu *iommu = dev_to_amd_iommu(dev);
1520 return sprintf(buf, "%llx\n", iommu->features); 1520 return sprintf(buf, "%llx\n", iommu->features);
1521} 1521}
1522static DEVICE_ATTR(features, S_IRUGO, amd_iommu_show_features, NULL); 1522static DEVICE_ATTR(features, S_IRUGO, amd_iommu_show_features, NULL);
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
index af00f381a7b1..003f3ceb2661 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -569,6 +569,11 @@ struct amd_iommu {
569 volatile u64 __aligned(8) cmd_sem; 569 volatile u64 __aligned(8) cmd_sem;
570}; 570};
571 571
572static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)
573{
574 return container_of(dev, struct amd_iommu, iommu.dev);
575}
576
572#define ACPIHID_UID_LEN 256 577#define ACPIHID_UID_LEN 256
573#define ACPIHID_HID_LEN 9 578#define ACPIHID_HID_LEN 9
574 579