Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'iommu-fix-v4.11-rc0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:
"Fix an issue introduced this merge window into the AMD and Intel IOMMU
drivers that causes an oops when the vendor-specific sysfs-entries are
accessed.

The reason for this issue is that I forgot to update the sysfs code in
the drivers when moving the iommu 'struct device' to the iommu-core"

* tag 'iommu-fix-v4.11-rc0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
iommu/amd: Fix crash when accessing AMD-Vi sysfs entries
iommu/vt-d: Fix crash when accessing VT-d sysfs entries

+18 -8
+2 -2
drivers/iommu/amd_iommu_init.c
··· 1507 1507 struct device_attribute *attr, 1508 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 1511 return sprintf(buf, "%x\n", iommu->cap); 1512 1512 } 1513 1513 static DEVICE_ATTR(cap, S_IRUGO, amd_iommu_show_cap, NULL); ··· 1516 1516 struct device_attribute *attr, 1517 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 1520 return sprintf(buf, "%llx\n", iommu->features); 1521 1521 } 1522 1522 static DEVICE_ATTR(features, S_IRUGO, amd_iommu_show_features, NULL);
+5
drivers/iommu/amd_iommu_types.h
··· 569 569 volatile u64 __aligned(8) cmd_sem; 570 570 }; 571 571 572 + static 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 577 #define ACPIHID_UID_LEN 256 573 578 #define ACPIHID_HID_LEN 9 574 579
+11 -6
drivers/iommu/intel-iommu.c
··· 4730 4730 return 0; 4731 4731 } 4732 4732 4733 + static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev) 4734 + { 4735 + return container_of(dev, struct intel_iommu, iommu.dev); 4736 + } 4737 + 4733 4738 static ssize_t intel_iommu_show_version(struct device *dev, 4734 4739 struct device_attribute *attr, 4735 4740 char *buf) 4736 4741 { 4737 - struct intel_iommu *iommu = dev_get_drvdata(dev); 4742 + struct intel_iommu *iommu = dev_to_intel_iommu(dev); 4738 4743 u32 ver = readl(iommu->reg + DMAR_VER_REG); 4739 4744 return sprintf(buf, "%d:%d\n", 4740 4745 DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver)); ··· 4750 4745 struct device_attribute *attr, 4751 4746 char *buf) 4752 4747 { 4753 - struct intel_iommu *iommu = dev_get_drvdata(dev); 4748 + struct intel_iommu *iommu = dev_to_intel_iommu(dev); 4754 4749 return sprintf(buf, "%llx\n", iommu->reg_phys); 4755 4750 } 4756 4751 static DEVICE_ATTR(address, S_IRUGO, intel_iommu_show_address, NULL); ··· 4759 4754 struct device_attribute *attr, 4760 4755 char *buf) 4761 4756 { 4762 - struct intel_iommu *iommu = dev_get_drvdata(dev); 4757 + struct intel_iommu *iommu = dev_to_intel_iommu(dev); 4763 4758 return sprintf(buf, "%llx\n", iommu->cap); 4764 4759 } 4765 4760 static DEVICE_ATTR(cap, S_IRUGO, intel_iommu_show_cap, NULL); ··· 4768 4763 struct device_attribute *attr, 4769 4764 char *buf) 4770 4765 { 4771 - struct intel_iommu *iommu = dev_get_drvdata(dev); 4766 + struct intel_iommu *iommu = dev_to_intel_iommu(dev); 4772 4767 return sprintf(buf, "%llx\n", iommu->ecap); 4773 4768 } 4774 4769 static DEVICE_ATTR(ecap, S_IRUGO, intel_iommu_show_ecap, NULL); ··· 4777 4772 struct device_attribute *attr, 4778 4773 char *buf) 4779 4774 { 4780 - struct intel_iommu *iommu = dev_get_drvdata(dev); 4775 + struct intel_iommu *iommu = dev_to_intel_iommu(dev); 4781 4776 return sprintf(buf, "%ld\n", cap_ndoms(iommu->cap)); 4782 4777 } 4783 4778 static DEVICE_ATTR(domains_supported, S_IRUGO, intel_iommu_show_ndoms, NULL); ··· 4786 4781 struct device_attribute *attr, 4787 4782 char *buf) 4788 4783 { 4789 - struct intel_iommu *iommu = dev_get_drvdata(dev); 4784 + struct intel_iommu *iommu = dev_to_intel_iommu(dev); 4790 4785 return sprintf(buf, "%d\n", bitmap_weight(iommu->domain_ids, 4791 4786 cap_ndoms(iommu->cap))); 4792 4787 }