patch #1 add the new api to enable pci mis. patch #2 is hibmc driver uses the newly added api to enable msi.
Tian Tao (2): drm/irq: Add the new api to enable pci msi drm/hisilicon: Use the new api devm_drm_msi_install
drivers/gpu/drm/drm_irq.c | 33 +++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 3 +-- include/drm/drm_irq.h | 1 + 3 files changed, 35 insertions(+), 2 deletions(-)
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); +} + +/** + * 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
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
Use devm_drm_msi_install to enable pci msi so that pci_disable_msi is not called when hibmc is removed.
Signed-off-by: Tian Tao tiantao6@hisilicon.com --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c index 7e91ef1..21f8225 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c @@ -251,7 +251,6 @@ static int hibmc_hw_init(struct hibmc_drm_private *priv) static int hibmc_unload(struct drm_device *dev) { drm_atomic_helper_shutdown(dev); - pci_disable_msi(dev->pdev);
return 0; } @@ -282,7 +281,7 @@ static int hibmc_load(struct drm_device *dev) goto err; }
- ret = pci_enable_msi(dev->pdev); + ret = devm_drm_msi_install(dev); if (ret) { drm_warn(dev, "enabling MSI failed: %d\n", ret); } else {
dri-devel@lists.freedesktop.org