From: daniel@ffwll.ch
Cc: emil.l.velikov@gmail.com, dri-devel@lists.freedesktop.org,
kraxel@redhat.com, airlied@redhat.com, sam@ravnborg.org
Subject: Re: [PATCH 12/13] drm/ast: Manage release of firmware backup memory
Date: Tue, 28 Jul 2020 11:18:26 +0200 [thread overview]
Message-ID: <20200728091826.GC6419@phenom.ffwll.local> (raw)
In-Reply-To: <20200728074425.2749-13-tzimmermann@suse.de>
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@suse.de>
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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-07-28 9:18 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 7:44 [PATCH 00/13] drm/ast: Convert to managed initialization Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 01/13] drm/ast: Move I2C code within ast_mode.c Thomas Zimmermann
2020-07-28 18:04 ` Sam Ravnborg
2020-07-30 9:18 ` Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 02/13] drm/ast: Test if I2C support has been initialized Thomas Zimmermann
2020-07-28 17:38 ` Sam Ravnborg
2020-07-28 7:44 ` [PATCH 03/13] drm/ast: Embed I2C fields in struct ast_connector Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 04/13] drm/ast: Managed release of I2C adapter Thomas Zimmermann
2020-07-28 9:23 ` daniel
2020-07-28 9:33 ` Thomas Zimmermann
2020-07-30 9:19 ` Thomas Zimmermann
2020-07-28 18:06 ` Sam Ravnborg
2020-07-30 9:23 ` Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 05/13] drm/ast: Embed CRTC and connector in struct ast_private Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 06/13] drm/ast: Separate DRM driver from PCI code Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 07/13] drm/ast: Replace driver load/unload functions with device create/destroy Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 08/13] drm/ast: Replace struct_drm_device.dev_private with to_ast_private() Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 09/13] drm/ast: Don't use ast->dev if dev is available Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 10/13] drm/ast: Embed struct drm_device in struct ast_private Thomas Zimmermann
2020-07-28 7:44 ` [PATCH 11/13] drm/ast: Managed release of ast firmware Thomas Zimmermann
2020-07-28 9:17 ` daniel
2020-07-28 9:32 ` Thomas Zimmermann
2020-07-28 9:34 ` daniel
2020-07-28 7:44 ` [PATCH 12/13] drm/ast: Manage release of firmware backup memory Thomas Zimmermann
2020-07-28 9:18 ` daniel [this message]
2020-07-28 7:44 ` [PATCH 13/13] drm/ast: Managed device release Thomas Zimmermann
2020-07-28 18:10 ` [PATCH 00/13] drm/ast: Convert to managed initialization Sam Ravnborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200728091826.GC6419@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=kraxel@redhat.com \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.