lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 15 Dec 2020 12:57:26 +0100
From:   Daniel Vetter <daniel@...ll.ch>
To:     Tian Tao <tiantao6@...ilicon.com>
Cc:     airlied@...ux.ie, daniel@...ll.ch, tzimmermann@...e.de,
        kraxel@...hat.com, alexander.deucher@....com, tglx@...utronix.de,
        dri-devel@...ts.freedesktop.org, xinliang.liu@...aro.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH drm/hisilicon 1/2] drm/irq: Add the new api to enable pci
 msi

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@...ilicon.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

Powered by blists - more mailing lists