From: Sam Ravnborg <sam@ravnborg.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
DRI Development <dri-devel@lists.freedesktop.org>,
virtualization@lists.linux-foundation.org,
Thomas Zimmermann <tzimmermann@suse.de>,
Daniel Vetter <daniel.vetter@intel.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH 28/51] drm/bochs: Drop explicit drm_mode_config_cleanup
Date: Fri, 6 Mar 2020 21:14:57 +0100 [thread overview]
Message-ID: <20200306201457.GC13014@ravnborg.org> (raw)
In-Reply-To: <20200302222631.3861340-29-daniel.vetter@ffwll.ch>
On Mon, Mar 02, 2020 at 11:26:08PM +0100, Daniel Vetter wrote:
> Instead rely on the automatic clean, for which we just need to check
> that drm_mode_config_init succeeded. To avoid an inversion in the
> cleanup we also have to move the dev_private allocation over to
> drmm_kzalloc.
>
> This is made possible by a preceeding patch which added a drmm_
> cleanup action to drm_mode_config_init(), hence all we need to do to
> ensure that drm_mode_config_cleanup() is run on final drm_device
> cleanup is check the new error code for _init().
>
> v2: Explain why this cleanup is possible (Laurent).
>
> v3: Use drmm_mode_config_init() for more clarity (Sam, Thomas)
>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
Acked-by: Sam Ravnborg <sam@ravnborg.org>
> ---
> drivers/gpu/drm/bochs/bochs.h | 1 -
> drivers/gpu/drm/bochs/bochs_drv.c | 6 ++----
> drivers/gpu/drm/bochs/bochs_kms.c | 14 +++++---------
> 3 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index 917767173ee6..e5bd1d517a18 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -92,7 +92,6 @@ void bochs_mm_fini(struct bochs_device *bochs);
>
> /* bochs_kms.c */
> int bochs_kms_init(struct bochs_device *bochs);
> -void bochs_kms_fini(struct bochs_device *bochs);
>
> /* bochs_fbdev.c */
> extern const struct drm_mode_config_funcs bochs_mode_funcs;
> diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
> index addb0568c1af..e18c51de1196 100644
> --- a/drivers/gpu/drm/bochs/bochs_drv.c
> +++ b/drivers/gpu/drm/bochs/bochs_drv.c
> @@ -7,6 +7,7 @@
>
> #include <drm/drm_drv.h>
> #include <drm/drm_atomic_helper.h>
> +#include <drm/drm_managed.h>
>
> #include "bochs.h"
>
> @@ -21,10 +22,7 @@ static void bochs_unload(struct drm_device *dev)
> {
> struct bochs_device *bochs = dev->dev_private;
>
> - bochs_kms_fini(bochs);
> bochs_mm_fini(bochs);
> - kfree(bochs);
> - dev->dev_private = NULL;
> }
>
> static int bochs_load(struct drm_device *dev)
> @@ -32,7 +30,7 @@ static int bochs_load(struct drm_device *dev)
> struct bochs_device *bochs;
> int ret;
>
> - bochs = kzalloc(sizeof(*bochs), GFP_KERNEL);
> + bochs = drmm_kzalloc(dev, sizeof(*bochs), GFP_KERNEL);
> if (bochs == NULL)
> return -ENOMEM;
> dev->dev_private = bochs;
> diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
> index e8cc8156d773..7f4bcfad87e9 100644
> --- a/drivers/gpu/drm/bochs/bochs_kms.c
> +++ b/drivers/gpu/drm/bochs/bochs_kms.c
> @@ -134,7 +134,11 @@ const struct drm_mode_config_funcs bochs_mode_funcs = {
>
> int bochs_kms_init(struct bochs_device *bochs)
> {
> - drm_mode_config_init(bochs->dev);
> + int ret;
> +
> + ret = drmm_mode_config_init(bochs->dev);
> + if (ret)
> + return ret;
>
> bochs->dev->mode_config.max_width = 8192;
> bochs->dev->mode_config.max_height = 8192;
> @@ -160,11 +164,3 @@ int bochs_kms_init(struct bochs_device *bochs)
>
> return 0;
> }
> -
> -void bochs_kms_fini(struct bochs_device *bochs)
> -{
> - if (!bochs->dev->mode_config.num_connector)
> - return;
> -
> - drm_mode_config_cleanup(bochs->dev);
> -}
> --
> 2.24.1
next prev parent reply other threads:[~2020-03-06 20:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200302222631.3861340-1-daniel.vetter@ffwll.ch>
2020-03-02 22:25 ` [PATCH 07/51] drm/qxl: Use drmm_add_final_kfree Daniel Vetter
2020-03-03 7:44 ` Gerd Hoffmann
2020-03-02 22:25 ` [PATCH 09/51] drm/cirrus: " Daniel Vetter
2020-03-03 7:49 ` Gerd Hoffmann
2020-03-03 8:27 ` Daniel Vetter
2020-03-02 22:26 ` [PATCH 28/51] drm/bochs: Drop explicit drm_mode_config_cleanup Daniel Vetter
2020-03-03 7:50 ` Gerd Hoffmann
2020-03-06 20:14 ` Sam Ravnborg [this message]
2020-03-02 22:26 ` [PATCH 29/51] drm/cirrus: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-03-03 7:51 ` Gerd Hoffmann
2020-03-02 22:26 ` [PATCH 30/51] drm/cirrus: Fully embrace devm_ Daniel Vetter
2020-03-03 7:51 ` Gerd Hoffmann
[not found] <20200323144950.3018436-1-daniel.vetter@ffwll.ch>
2020-03-23 14:49 ` [PATCH 28/51] drm/bochs: Drop explicit drm_mode_config_cleanup Daniel Vetter
[not found] <20200227181522.2711142-1-daniel.vetter@ffwll.ch>
2020-02-27 18:14 ` Daniel Vetter
[not found] <20200221210319.2245170-1-daniel.vetter@ffwll.ch>
2020-02-21 21:02 ` Daniel Vetter
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=20200306201457.GC13014@ravnborg.org \
--to=sam@ravnborg.org \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=tzimmermann@suse.de \
--cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).