Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1589502

[PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi sysfs entries

From Joerg Roedel <joro@8bytes.org>
Newsgroups linux.kernel
Subject [PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi sysfs entries
Date 2017-02-28 15:20 +0100
Message-ID <tfQNc-5z5-11@gated-at.bofh.it> (permalink)
References <tfQNc-5z5-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Joerg Roedel <jroedel@suse.de>

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>
---
 drivers/iommu/amd_iommu_init.c  | 4 ++--
 drivers/iommu/amd_iommu_types.h | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 04cdac7..6130278 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,
 				  struct device_attribute *attr,
 				  char *buf)
 {
-	struct amd_iommu *iommu = dev_get_drvdata(dev);
+	struct amd_iommu *iommu = dev_to_amd_iommu(dev);
 	return sprintf(buf, "%x\n", iommu->cap);
 }
 static DEVICE_ATTR(cap, S_IRUGO, amd_iommu_show_cap, NULL);
@@ -1516,7 +1516,7 @@ static ssize_t amd_iommu_show_features(struct device *dev,
 				       struct device_attribute *attr,
 				       char *buf)
 {
-	struct amd_iommu *iommu = dev_get_drvdata(dev);
+	struct amd_iommu *iommu = dev_to_amd_iommu(dev);
 	return sprintf(buf, "%llx\n", iommu->features);
 }
 static 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 af00f38..003f3ce 100644
--- a/drivers/iommu/amd_iommu_types.h
+++ b/drivers/iommu/amd_iommu_types.h
@@ -569,6 +569,11 @@ struct amd_iommu {
 	volatile u64 __aligned(8) cmd_sem;
 };
 
+static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)
+{
+	return container_of(dev, struct amd_iommu, iommu.dev);
+}
+
 #define ACPIHID_UID_LEN 256
 #define ACPIHID_HID_LEN 9
 
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs entries Joerg Roedel <joro@8bytes.org> - 2017-02-28 15:20 +0100
  [PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi sysfs entries Joerg Roedel <joro@8bytes.org> - 2017-02-28 15:20 +0100
  Re: [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs  entries kbuild test robot <lkp@intel.com> - 2017-03-01 01:40 +0100
    Re: [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs  entries Joerg Roedel <jroedel@suse.de> - 2017-03-01 11:40 +0100
  Re: [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs  entries kbuild test robot <lkp@intel.com> - 2017-03-01 02:30 +0100

csiph-web