Re: [PATCH 12/13] drm/ast: Manage release of firmware backup memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 28, 2020 at 09:44:24AM +0200, Thomas Zimmermann wrote:
> The ast driver keeps a backup copy of the DP501 encoder's firmware. This
> patch adds managed release of the allocated memory.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>

We can't really do anything with the firmware after the device is gone, so
I think this is one of the very rare exceptions where devm_kzalloc is the
right thing to do! Totally minor nit though, since either way it gets
cleaned up. But I think conceptually cleaner.
-Daniel
> ---
>  drivers/gpu/drm/ast/ast_main.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
> index e3b7748335a3..67e20727d82d 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -33,6 +33,7 @@
>  #include <drm/drm_drv.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_vram_helper.h>
> +#include <drm/drm_managed.h>
>  
>  #include "ast_drv.h"
>  
> @@ -231,11 +232,11 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
>  			ast->tx_chip_type = AST_TX_SIL164;
>  			break;
>  		case 0x08:
> -			ast->dp501_fw_addr = kzalloc(32*1024, GFP_KERNEL);
> +			ast->dp501_fw_addr = drmm_kzalloc(dev, 32*1024, GFP_KERNEL);
>  			if (ast->dp501_fw_addr) {
>  				/* backup firmware */
>  				if (ast_backup_fw(dev, ast->dp501_fw_addr, 32*1024)) {
> -					kfree(ast->dp501_fw_addr);
> +					drmm_kfree(dev, ast->dp501_fw_addr);
>  					ast->dp501_fw_addr = NULL;
>  				}
>  			}
> @@ -444,6 +445,4 @@ void ast_device_destroy(struct ast_private *ast)
>  {
>  	/* enable standard VGA decode */
>  	ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa1, 0x04);
> -
> -	kfree(ast->dp501_fw_addr);
>  }
> -- 
> 2.27.0
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux