diff mbox series

[v2] drm/komeda: Make Komeda interrupts shareable

Message ID 20190613151257.32297-1-ayan.halder@arm.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/komeda: Make Komeda interrupts shareable | expand

Commit Message

Ayan Halder June 13, 2019, 3:13 p.m. UTC
Komeda interrupts may be shared with other hardware blocks.
One needs to use devm_request_irq() with IRQF_SHARED to create a shared
 interrupt handler.
As a result of not using drm_irq_install() api, one needs to set
"(struct drm_device *)->irq_enabled = true/false" to enable/disable
vblank interrupts.

Changes from v1:-
1. Squashed the following two patches into one (as the second patch is a
consequence of the first one):-
   drm/komeda: Avoid using DRIVER_IRQ_SHARED
   drm/komeda: Enable/Disable vblank interrupts
2. Fixed the commit message (as pointed by Daniel Vetter)
3. Removed calls to 'drm_irq_uninstall()' as we are no longer using
drm_irq_install()
4. Removed the struct member 'komeda_kms_driver.irq_handler' as it is not
used anywhere.

Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>
---
 drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Liviu Dudau June 13, 2019, 4:29 p.m. UTC | #1
On Thu, Jun 13, 2019 at 04:13:10PM +0100, Ayan Halder wrote:
> Komeda interrupts may be shared with other hardware blocks.
> One needs to use devm_request_irq() with IRQF_SHARED to create a shared
>  interrupt handler.
> As a result of not using drm_irq_install() api, one needs to set
> "(struct drm_device *)->irq_enabled = true/false" to enable/disable
> vblank interrupts.
> 
> Changes from v1:-
> 1. Squashed the following two patches into one (as the second patch is a
> consequence of the first one):-
>    drm/komeda: Avoid using DRIVER_IRQ_SHARED
>    drm/komeda: Enable/Disable vblank interrupts
> 2. Fixed the commit message (as pointed by Daniel Vetter)
> 3. Removed calls to 'drm_irq_uninstall()' as we are no longer using
> drm_irq_install()
> 4. Removed the struct member 'komeda_kms_driver.irq_handler' as it is not
> used anywhere.
> 
> Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> index 86f6542afb40..bb2bffc0e022 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> @@ -58,7 +58,6 @@ static struct drm_driver komeda_kms_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
>  			   DRIVER_PRIME | DRIVER_HAVE_IRQ,
>  	.lastclose			= drm_fb_helper_lastclose,
> -	.irq_handler			= komeda_kms_irq_handler,
>  	.gem_free_object_unlocked	= drm_gem_cma_free_object,
>  	.gem_vm_ops			= &drm_gem_cma_vm_ops,
>  	.dumb_create			= komeda_gem_cma_dumb_create,
> @@ -194,23 +193,26 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  
>  	drm_mode_config_reset(drm);
>  
> -	err = drm_irq_install(drm, mdev->irq);
> +	err = devm_request_irq(drm->dev, mdev->irq,
> +			       komeda_kms_irq_handler, IRQF_SHARED,
> +			       drm->driver->name, drm);
>  	if (err)
>  		goto cleanup_mode_config;
>  
>  	err = mdev->funcs->enable_irq(mdev);
>  	if (err)
> -		goto uninstall_irq;
> +		goto cleanup_mode_config;
> +
> +	drm->irq_enabled = true;
>  
>  	err = drm_dev_register(drm, 0);
>  	if (err)
> -		goto uninstall_irq;
> +		goto cleanup_mode_config;
>  
>  	return kms;
>  
> -uninstall_irq:
> -	drm_irq_uninstall(drm);
>  cleanup_mode_config:
> +	drm->irq_enabled = false;
>  	drm_mode_config_cleanup(drm);
>  	komeda_kms_cleanup_private_objs(kms);
>  free_kms:
> @@ -223,9 +225,9 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
>  	struct drm_device *drm = &kms->base;
>  	struct komeda_dev *mdev = drm->dev_private;
>  
> +	drm->irq_enabled = false;
>  	mdev->funcs->disable_irq(mdev);
>  	drm_dev_unregister(drm);
> -	drm_irq_uninstall(drm);
>  	component_unbind_all(mdev->dev, drm);
>  	komeda_kms_cleanup_private_objs(kms);
>  	drm_mode_config_cleanup(drm);
> -- 
> 2.21.0
>
James Qian Wang June 18, 2019, 5:24 a.m. UTC | #2
On Thu, Jun 13, 2019 at 03:13:10PM +0000, Ayan Halder wrote:
> Komeda interrupts may be shared with other hardware blocks.
> One needs to use devm_request_irq() with IRQF_SHARED to create a shared
>  interrupt handler.
> As a result of not using drm_irq_install() api, one needs to set
> "(struct drm_device *)->irq_enabled = true/false" to enable/disable
> vblank interrupts.
> 
> Changes from v1:-
> 1. Squashed the following two patches into one (as the second patch is a
> consequence of the first one):-
>    drm/komeda: Avoid using DRIVER_IRQ_SHARED
>    drm/komeda: Enable/Disable vblank interrupts
> 2. Fixed the commit message (as pointed by Daniel Vetter)
> 3. Removed calls to 'drm_irq_uninstall()' as we are no longer using
> drm_irq_install()
> 4. Removed the struct member 'komeda_kms_driver.irq_handler' as it is not
> used anywhere.
> 
> Signed-off-by: Ayan Kumar halder <ayan.halder@arm.com>
> ---
>  drivers/gpu/drm/arm/display/komeda/komeda_kms.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> -- 
> 2.21.0
> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> 

looks good to me.

Thank you Ayan.

Reviewed-by: James Qian Wang (Arm Technology China) <james.qian.wang@arm.com>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> index 86f6542afb40..bb2bffc0e022 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
> @@ -58,7 +58,6 @@ static struct drm_driver komeda_kms_driver = {
>  	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
>  			   DRIVER_PRIME | DRIVER_HAVE_IRQ,
>  	.lastclose			= drm_fb_helper_lastclose,
> -	.irq_handler			= komeda_kms_irq_handler,
>  	.gem_free_object_unlocked	= drm_gem_cma_free_object,
>  	.gem_vm_ops			= &drm_gem_cma_vm_ops,
>  	.dumb_create			= komeda_gem_cma_dumb_create,
> @@ -194,23 +193,26 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
>  
>  	drm_mode_config_reset(drm);
>  
> -	err = drm_irq_install(drm, mdev->irq);
> +	err = devm_request_irq(drm->dev, mdev->irq,
> +			       komeda_kms_irq_handler, IRQF_SHARED,
> +			       drm->driver->name, drm);
>  	if (err)
>  		goto cleanup_mode_config;
>  
>  	err = mdev->funcs->enable_irq(mdev);
>  	if (err)
> -		goto uninstall_irq;
> +		goto cleanup_mode_config;
> +
> +	drm->irq_enabled = true;
>  
>  	err = drm_dev_register(drm, 0);
>  	if (err)
> -		goto uninstall_irq;
> +		goto cleanup_mode_config;
>  
>  	return kms;
>  
> -uninstall_irq:
> -	drm_irq_uninstall(drm);
>  cleanup_mode_config:
> +	drm->irq_enabled = false;
>  	drm_mode_config_cleanup(drm);
>  	komeda_kms_cleanup_private_objs(kms);
>  free_kms:
> @@ -223,9 +225,9 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)
>  	struct drm_device *drm = &kms->base;
>  	struct komeda_dev *mdev = drm->dev_private;
>  
> +	drm->irq_enabled = false;
>  	mdev->funcs->disable_irq(mdev);
>  	drm_dev_unregister(drm);
> -	drm_irq_uninstall(drm);
>  	component_unbind_all(mdev->dev, drm);
>  	komeda_kms_cleanup_private_objs(kms);
>  	drm_mode_config_cleanup(drm);
diff mbox series

Patch

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
index 86f6542afb40..bb2bffc0e022 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_kms.c
@@ -58,7 +58,6 @@  static struct drm_driver komeda_kms_driver = {
 	.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
 			   DRIVER_PRIME | DRIVER_HAVE_IRQ,
 	.lastclose			= drm_fb_helper_lastclose,
-	.irq_handler			= komeda_kms_irq_handler,
 	.gem_free_object_unlocked	= drm_gem_cma_free_object,
 	.gem_vm_ops			= &drm_gem_cma_vm_ops,
 	.dumb_create			= komeda_gem_cma_dumb_create,
@@ -194,23 +193,26 @@  struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)
 
 	drm_mode_config_reset(drm);
 
-	err = drm_irq_install(drm, mdev->irq);
+	err = devm_request_irq(drm->dev, mdev->irq,
+			       komeda_kms_irq_handler, IRQF_SHARED,
+			       drm->driver->name, drm);
 	if (err)
 		goto cleanup_mode_config;
 
 	err = mdev->funcs->enable_irq(mdev);
 	if (err)
-		goto uninstall_irq;
+		goto cleanup_mode_config;
+
+	drm->irq_enabled = true;
 
 	err = drm_dev_register(drm, 0);
 	if (err)
-		goto uninstall_irq;
+		goto cleanup_mode_config;
 
 	return kms;
 
-uninstall_irq:
-	drm_irq_uninstall(drm);
 cleanup_mode_config:
+	drm->irq_enabled = false;
 	drm_mode_config_cleanup(drm);
 	komeda_kms_cleanup_private_objs(kms);
 free_kms:
@@ -223,9 +225,9 @@  void komeda_kms_detach(struct komeda_kms_dev *kms)
 	struct drm_device *drm = &kms->base;
 	struct komeda_dev *mdev = drm->dev_private;
 
+	drm->irq_enabled = false;
 	mdev->funcs->disable_irq(mdev);
 	drm_dev_unregister(drm);
-	drm_irq_uninstall(drm);
 	component_unbind_all(mdev->dev, drm);
 	komeda_kms_cleanup_private_objs(kms);
 	drm_mode_config_cleanup(drm);