Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7a42b9d authored by Joerg Roedel's avatar Joerg Roedel
Browse files

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: default avatarDave Jones <davej@codemonkey.org.uk>
Fixes: 39ab9555 ('iommu: Add sysfs bindings for struct iommu_device')
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent a7fdb6e6
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1507,7 +1507,7 @@ static ssize_t amd_iommu_show_cap(struct device *dev,
				  struct device_attribute *attr,
				  struct device_attribute *attr,
				  char *buf)
				  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);
	return sprintf(buf, "%x\n", iommu->cap);
}
}
static DEVICE_ATTR(cap, S_IRUGO, amd_iommu_show_cap, NULL);
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,
				       struct device_attribute *attr,
				       char *buf)
				       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);
	return sprintf(buf, "%llx\n", iommu->features);
}
}
static DEVICE_ATTR(features, S_IRUGO, amd_iommu_show_features, NULL);
static DEVICE_ATTR(features, S_IRUGO, amd_iommu_show_features, NULL);
+5 −0
Original line number Original line Diff line number Diff line
@@ -569,6 +569,11 @@ struct amd_iommu {
	volatile u64 __aligned(8) cmd_sem;
	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_UID_LEN 256
#define ACPIHID_HID_LEN 9
#define ACPIHID_HID_LEN 9