* [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs entries
@ 2017-02-28 14:10 Joerg Roedel
[not found] ` <1488291019-13836-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2017-02-28 14:10 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
The link between the iommu sysfs-device and the struct
intel_iommu is no longer stored as driver-data. Update the
code to use the new access method.
Reported-by: Dave Jones <davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL@public.gmane.org>
Fixes: 39ab9555c241 ('iommu: Add sysfs bindings for struct iommu_device')
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/intel-iommu.c | 12 ++++++------
include/linux/intel-iommu.h | 5 +++++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a8f7ae0..54662c8 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4734,7 +4734,7 @@ static ssize_t intel_iommu_show_version(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct intel_iommu *iommu = dev_get_drvdata(dev);
+ struct intel_iommu *iommu = dev_to_intel_iommu(dev);
u32 ver = readl(iommu->reg + DMAR_VER_REG);
return sprintf(buf, "%d:%d\n",
DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver));
@@ -4745,7 +4745,7 @@ static ssize_t intel_iommu_show_address(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct intel_iommu *iommu = dev_get_drvdata(dev);
+ struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%llx\n", iommu->reg_phys);
}
static DEVICE_ATTR(address, S_IRUGO, intel_iommu_show_address, NULL);
@@ -4754,7 +4754,7 @@ static ssize_t intel_iommu_show_cap(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct intel_iommu *iommu = dev_get_drvdata(dev);
+ struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%llx\n", iommu->cap);
}
static DEVICE_ATTR(cap, S_IRUGO, intel_iommu_show_cap, NULL);
@@ -4763,7 +4763,7 @@ static ssize_t intel_iommu_show_ecap(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct intel_iommu *iommu = dev_get_drvdata(dev);
+ struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%llx\n", iommu->ecap);
}
static DEVICE_ATTR(ecap, S_IRUGO, intel_iommu_show_ecap, NULL);
@@ -4772,7 +4772,7 @@ static ssize_t intel_iommu_show_ndoms(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct intel_iommu *iommu = dev_get_drvdata(dev);
+ struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%ld\n", cap_ndoms(iommu->cap));
}
static DEVICE_ATTR(domains_supported, S_IRUGO, intel_iommu_show_ndoms, NULL);
@@ -4781,7 +4781,7 @@ static ssize_t intel_iommu_show_ndoms_used(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct intel_iommu *iommu = dev_get_drvdata(dev);
+ struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%d\n", bitmap_weight(iommu->domain_ids,
cap_ndoms(iommu->cap)));
}
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index c573a52..089e1cb 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -452,6 +452,11 @@ static inline void __iommu_flush_cache(
clflush_cache_range(addr, size);
}
+static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev)
+{
+ return container_of(dev, struct intel_iommu, iommu.dev);
+}
+
extern struct dmar_drhd_unit * dmar_find_matched_drhd_unit(struct pci_dev *dev);
extern int dmar_find_matched_atsr_unit(struct pci_dev *dev);
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1488291019-13836-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* [PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi sysfs entries [not found] ` <1488291019-13836-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-02-28 14:10 ` Joerg Roedel 2017-03-01 0:19 ` [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d " kbuild test robot 2017-03-01 1:06 ` kbuild test robot 2 siblings, 0 replies; 5+ messages in thread From: Joerg Roedel @ 2017-02-28 14:10 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> 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-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL@public.gmane.org> Fixes: 39ab9555c241 ('iommu: Add sysfs bindings for struct iommu_device') Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- 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 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs entries [not found] ` <1488291019-13836-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-02-28 14:10 ` [PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi " Joerg Roedel @ 2017-03-01 0:19 ` kbuild test robot [not found] ` <201703010825.4Q2UVVIO%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2017-03-01 1:06 ` kbuild test robot 2 siblings, 1 reply; 5+ messages in thread From: kbuild test robot @ 2017-03-01 0:19 UTC (permalink / raw) To: Joerg Roedel Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Joerg Roedel, kbuild-all-JC7UmRfGjtg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 3221 bytes --] Hi Joerg, [auto build test ERROR on iommu/next] [also build test ERROR on v4.10 next-20170228] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Joerg-Roedel/iommu-vt-d-Fix-crash-when-accessing-VT-d-sysfs-entries/20170301-074355 base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next config: i386-defconfig (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=i386 All error/warnings (new ones prefixed by >>): In file included from include/linux/list.h:8:0, from include/linux/resource_ext.h:17, from include/linux/acpi.h:26, from drivers/gpu/drm/i915/i915_drv.c:30: include/linux/intel-iommu.h: In function 'dev_to_intel_iommu': >> include/linux/intel-iommu.h:457:52: error: 'struct iommu_device' has no member named 'dev' return container_of(dev, struct intel_iommu, iommu.dev); ^ include/linux/kernel.h:850:29: note: in definition of macro 'container_of' const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ^~~~~~ include/linux/kernel.h:850:48: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] const typeof( ((type *)0)->member ) *__mptr = (ptr); \ ^ >> include/linux/intel-iommu.h:457:9: note: in expansion of macro 'container_of' return container_of(dev, struct intel_iommu, iommu.dev); ^~~~~~~~~~~~ In file included from include/linux/compiler.h:58:0, from include/linux/ioport.h:12, from include/linux/acpi.h:25, from drivers/gpu/drm/i915/i915_drv.c:30: >> include/linux/compiler-gcc.h:159:2: error: 'struct iommu_device' has no member named 'dev' __builtin_offsetof(a, b) ^ include/linux/stddef.h:16:32: note: in expansion of macro '__compiler_offsetof' #define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) ^~~~~~~~~~~~~~~~~~~ include/linux/kernel.h:851:29: note: in expansion of macro 'offsetof' (type *)( (char *)__mptr - offsetof(type,member) );}) ^~~~~~~~ >> include/linux/intel-iommu.h:457:9: note: in expansion of macro 'container_of' return container_of(dev, struct intel_iommu, iommu.dev); ^~~~~~~~~~~~ cc1: some warnings being treated as errors vim +457 include/linux/intel-iommu.h 451 if (!ecap_coherent(iommu->ecap)) 452 clflush_cache_range(addr, size); 453 } 454 455 static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev) 456 { > 457 return container_of(dev, struct intel_iommu, iommu.dev); 458 } 459 460 extern struct dmar_drhd_unit * dmar_find_matched_drhd_unit(struct pci_dev *dev); --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 25409 bytes --] [-- Attachment #3: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <201703010825.4Q2UVVIO%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs entries [not found] ` <201703010825.4Q2UVVIO%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2017-03-01 10:01 ` Joerg Roedel 0 siblings, 0 replies; 5+ messages in thread From: Joerg Roedel @ 2017-03-01 10:01 UTC (permalink / raw) To: kbuild test robot Cc: kbuild-all-JC7UmRfGjtg, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Wed, Mar 01, 2017 at 08:19:30AM +0800, kbuild test robot wrote: > >> include/linux/intel-iommu.h:457:52: error: 'struct iommu_device' has no member named 'dev' > return container_of(dev, struct intel_iommu, iommu.dev); Yeah, I noticed that issue too and fixed it before sending the pull-request. Thanks, Joerg ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs entries [not found] ` <1488291019-13836-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-02-28 14:10 ` [PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi " Joerg Roedel 2017-03-01 0:19 ` [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d " kbuild test robot @ 2017-03-01 1:06 ` kbuild test robot 2 siblings, 0 replies; 5+ messages in thread From: kbuild test robot @ 2017-03-01 1:06 UTC (permalink / raw) To: Joerg Roedel Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Joerg Roedel, kbuild-all-JC7UmRfGjtg, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1791 bytes --] Hi Joerg, [auto build test ERROR on iommu/next] [also build test ERROR on v4.10 next-20170228] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Joerg-Roedel/iommu-vt-d-Fix-crash-when-accessing-VT-d-sysfs-entries/20170301-074355 base: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git next config: x86_64-randconfig-s1-03010801 (attached as .config) compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): In file included from drivers/gpu/drm/i915/i915_drv.h:41, from drivers/gpu/drm/i915/i915_drv.c:48: include/linux/intel-iommu.h: In function 'dev_to_intel_iommu': include/linux/intel-iommu.h:457: error: 'struct iommu_device' has no member named 'dev' >> include/linux/intel-iommu.h:457: error: type defaults to 'int' in declaration of '__mptr' cc1: warnings being treated as errors >> include/linux/intel-iommu.h:457: error: initialization from incompatible pointer type include/linux/intel-iommu.h:457: error: 'struct iommu_device' has no member named 'dev' vim +457 include/linux/intel-iommu.h 451 if (!ecap_coherent(iommu->ecap)) 452 clflush_cache_range(addr, size); 453 } 454 455 static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev) 456 { > 457 return container_of(dev, struct intel_iommu, iommu.dev); 458 } 459 460 extern struct dmar_drhd_unit * dmar_find_matched_drhd_unit(struct pci_dev *dev); --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 21998 bytes --] [-- Attachment #3: Type: text/plain, Size: 0 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-01 10:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-28 14:10 [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d sysfs entries Joerg Roedel
[not found] ` <1488291019-13836-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-02-28 14:10 ` [PATCH 2/2] iommu/amd: Fix crash when accessing AMD-Vi " Joerg Roedel
2017-03-01 0:19 ` [PATCH 1/2] iommu/vt-d: Fix crash when accessing VT-d " kbuild test robot
[not found] ` <201703010825.4Q2UVVIO%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-01 10:01 ` Joerg Roedel
2017-03-01 1:06 ` kbuild test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox