Commit 134fac3f authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PCI / Intel IOMMU: Use syscore_ops instead of sysdev class and sysdev

The Intel IOMMU subsystem uses a sysdev class and a sysdev for
executing iommu_suspend() after interrupts have been turned off
on the boot CPU (during system suspend) and for executing
iommu_resume() before turning on interrupts on the boot CPU
(during system resume).  However, since both of these functions
ignore their arguments, the entire mechanism may be replaced with a
struct syscore_ops object which is simpler.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent e1a85b2c
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <linux/iova.h> #include <linux/iova.h>
#include <linux/iommu.h> #include <linux/iommu.h>
#include <linux/intel-iommu.h> #include <linux/intel-iommu.h>
#include <linux/sysdev.h> #include <linux/syscore_ops.h>
#include <linux/tboot.h> #include <linux/tboot.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
...@@ -3135,7 +3135,7 @@ static void iommu_flush_all(void) ...@@ -3135,7 +3135,7 @@ static void iommu_flush_all(void)
} }
} }
static int iommu_suspend(struct sys_device *dev, pm_message_t state) static int iommu_suspend(void)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu = NULL; struct intel_iommu *iommu = NULL;
...@@ -3175,7 +3175,7 @@ static int iommu_suspend(struct sys_device *dev, pm_message_t state) ...@@ -3175,7 +3175,7 @@ static int iommu_suspend(struct sys_device *dev, pm_message_t state)
return -ENOMEM; return -ENOMEM;
} }
static int iommu_resume(struct sys_device *dev) static void iommu_resume(void)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu = NULL; struct intel_iommu *iommu = NULL;
...@@ -3183,7 +3183,7 @@ static int iommu_resume(struct sys_device *dev) ...@@ -3183,7 +3183,7 @@ static int iommu_resume(struct sys_device *dev)
if (init_iommu_hw()) { if (init_iommu_hw()) {
WARN(1, "IOMMU setup failed, DMAR can not resume!\n"); WARN(1, "IOMMU setup failed, DMAR can not resume!\n");
return -EIO; return;
} }
for_each_active_iommu(iommu, drhd) { for_each_active_iommu(iommu, drhd) {
...@@ -3204,40 +3204,20 @@ static int iommu_resume(struct sys_device *dev) ...@@ -3204,40 +3204,20 @@ static int iommu_resume(struct sys_device *dev)
for_each_active_iommu(iommu, drhd) for_each_active_iommu(iommu, drhd)
kfree(iommu->iommu_state); kfree(iommu->iommu_state);
return 0;
} }
static struct sysdev_class iommu_sysclass = { static struct syscore_ops iommu_syscore_ops = {
.name = "iommu",
.resume = iommu_resume, .resume = iommu_resume,
.suspend = iommu_suspend, .suspend = iommu_suspend,
}; };
static struct sys_device device_iommu = { static void __init init_iommu_pm_ops(void)
.cls = &iommu_sysclass,
};
static int __init init_iommu_sysfs(void)
{ {
int error; register_syscore_ops(&iommu_syscore_ops);
error = sysdev_class_register(&iommu_sysclass);
if (error)
return error;
error = sysdev_register(&device_iommu);
if (error)
sysdev_class_unregister(&iommu_sysclass);
return error;
} }
#else #else
static int __init init_iommu_sysfs(void) static inline int init_iommu_pm_ops(void) { }
{
return 0;
}
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
/* /*
...@@ -3320,7 +3300,7 @@ int __init intel_iommu_init(void) ...@@ -3320,7 +3300,7 @@ int __init intel_iommu_init(void)
#endif #endif
dma_ops = &intel_dma_ops; dma_ops = &intel_dma_ops;
init_iommu_sysfs(); init_iommu_pm_ops();
register_iommu(&intel_iommu_ops); register_iommu(&intel_iommu_ops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment