On Tue, Dec 15, 2020 at 07:48:52PM +0800, Tian Tao wrote:
Add new api devm_drm_msi_install() to register interrupts, no need to call pci_disable_msi() when the drm module is removed.
Signed-off-by: Tian Tao tiantao6@hisilicon.com
drivers/gpu/drm/drm_irq.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_irq.h | 1 + 2 files changed, 34 insertions(+)
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 803af4b..da58b2c 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -246,6 +246,39 @@ int devm_drm_irq_install(struct drm_device *dev, int irq) } EXPORT_SYMBOL(devm_drm_irq_install);
+static void devm_drm_msi_uninstall(void *data) +{
- struct drm_device *dev = (struct drm_device *)data;
- pci_disable_msi(dev->pdev);
This should be in the pci core, not in drm. -Daniel
+}
+/**
- devm_drm_msi_install - install IRQ handler
- @dev: DRM device
- devm_drm_msi_install is a help function of pci_enable_msi.
- if the driver uses devm_drm_msi_install, there is no need
- to call pci_disable_msi when the drm module get unloaded,
- as this will done automagically.
- Returns:
- Zero on success or a negative error code on failure.
- */
+int devm_drm_msi_install(struct drm_device *dev) +{
- int ret;
- ret = pci_enable_msi(dev->pdev);
- if (ret)
return ret;
- return devm_add_action_or_reset(dev->dev,
devm_drm_msi_uninstall, dev);
+} +EXPORT_SYMBOL(devm_drm_msi_install);
#if IS_ENABLED(CONFIG_DRM_LEGACY) int drm_legacy_irq_control(struct drm_device *dev, void *data, struct drm_file *file_priv) diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h index 631b22f..c8dff45 100644 --- a/include/drm/drm_irq.h +++ b/include/drm/drm_irq.h @@ -29,4 +29,5 @@ struct drm_device; int drm_irq_install(struct drm_device *dev, int irq); int drm_irq_uninstall(struct drm_device *dev); int devm_drm_irq_install(struct drm_device *dev, int irq); +int devm_drm_msi_install(struct drm_device *dev);
#endif
2.7.4