* [PATCH drm/hisilicon 0/2] Add the new api to enable msi @ 2020-12-15 11:48 Tian Tao 2020-12-15 11:48 ` [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi Tian Tao 2020-12-15 11:48 ` [PATCH drm/hisilicon 2/2] drm/hisilicon: Use the new api devm_drm_msi_install Tian Tao 0 siblings, 2 replies; 4+ messages in thread From: Tian Tao @ 2020-12-15 11:48 UTC (permalink / raw) To: airlied, daniel, tzimmermann, kraxel, alexander.deucher, tglx, dri-devel, xinliang.liu, linux-kernel Cc: Tian Tao 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(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi 2020-12-15 11:48 [PATCH drm/hisilicon 0/2] Add the new api to enable msi Tian Tao @ 2020-12-15 11:48 ` Tian Tao 2020-12-15 11:57 ` Daniel Vetter 2020-12-15 11:48 ` [PATCH drm/hisilicon 2/2] drm/hisilicon: Use the new api devm_drm_msi_install Tian Tao 1 sibling, 1 reply; 4+ messages in thread From: Tian Tao @ 2020-12-15 11:48 UTC (permalink / raw) To: airlied, daniel, tzimmermann, kraxel, alexander.deucher, tglx, dri-devel, xinliang.liu, linux-kernel Cc: Tian Tao 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 -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi 2020-12-15 11:48 ` [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi Tian Tao @ 2020-12-15 11:57 ` Daniel Vetter 0 siblings, 0 replies; 4+ messages in thread From: Daniel Vetter @ 2020-12-15 11:57 UTC (permalink / raw) To: Tian Tao Cc: airlied, daniel, tzimmermann, kraxel, alexander.deucher, tglx, dri-devel, xinliang.liu, linux-kernel 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 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH drm/hisilicon 2/2] drm/hisilicon: Use the new api devm_drm_msi_install 2020-12-15 11:48 [PATCH drm/hisilicon 0/2] Add the new api to enable msi Tian Tao 2020-12-15 11:48 ` [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi Tian Tao @ 2020-12-15 11:48 ` Tian Tao 1 sibling, 0 replies; 4+ messages in thread From: Tian Tao @ 2020-12-15 11:48 UTC (permalink / raw) To: airlied, daniel, tzimmermann, kraxel, alexander.deucher, tglx, dri-devel, xinliang.liu, linux-kernel Cc: Tian Tao 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 { -- 2.7.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-15 11:58 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-12-15 11:48 [PATCH drm/hisilicon 0/2] Add the new api to enable msi Tian Tao 2020-12-15 11:48 ` [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci msi Tian Tao 2020-12-15 11:57 ` Daniel Vetter 2020-12-15 11:48 ` [PATCH drm/hisilicon 2/2] drm/hisilicon: Use the new api devm_drm_msi_install Tian Tao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox