From: Daniel Vetter <daniel@ffwll.ch>
To: Danilo Krummrich <dakr@redhat.com>
Cc: airlied@linux.ie, dri-devel@lists.freedesktop.org,
kraxel@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] drm/virtio: kms: use drm managed resources
Date: Thu, 11 Aug 2022 18:16:57 +0200 [thread overview]
Message-ID: <YvUrefus4/EoCV2J@phenom.ffwll.local> (raw)
In-Reply-To: <20220714130028.2127858-3-dakr@redhat.com>
On Thu, Jul 14, 2022 at 03:00:28PM +0200, Danilo Krummrich wrote:
> Allocate driver structures with drm managed resource allocators in order
> to cleanup/simplify the drm driver .release callback.
>
> Signed-off-by: Danilo Krummrich <dakr@redhat.com>
On both patches:
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
I'm assuming you have commits rights or know someone who does :-)
-Daniel
> ---
> drivers/gpu/drm/virtio/virtgpu_kms.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
> index 3313b92db531..63ebe63ef409 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
> @@ -28,6 +28,7 @@
> #include <linux/virtio_ring.h>
>
> #include <drm/drm_file.h>
> +#include <drm/drm_managed.h>
>
> #include "virtgpu_drv.h"
>
> @@ -66,10 +67,11 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
> {
> int i, ret;
> bool invalid_capset_id = false;
> + struct drm_device *drm = vgdev->ddev;
>
> - vgdev->capsets = kcalloc(num_capsets,
> - sizeof(struct virtio_gpu_drv_capset),
> - GFP_KERNEL);
> + vgdev->capsets = drmm_kcalloc(drm, num_capsets,
> + sizeof(struct virtio_gpu_drv_capset),
> + GFP_KERNEL);
> if (!vgdev->capsets) {
> DRM_ERROR("failed to allocate cap sets\n");
> return;
> @@ -94,7 +96,7 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
>
> if (ret == 0 || invalid_capset_id) {
> spin_lock(&vgdev->display_info_lock);
> - kfree(vgdev->capsets);
> + drmm_kfree(drm, vgdev->capsets);
> vgdev->capsets = NULL;
> spin_unlock(&vgdev->display_info_lock);
> return;
> @@ -126,7 +128,7 @@ int virtio_gpu_init(struct drm_device *dev)
> if (!virtio_has_feature(dev_to_virtio(dev->dev), VIRTIO_F_VERSION_1))
> return -ENODEV;
>
> - vgdev = kzalloc(sizeof(struct virtio_gpu_device), GFP_KERNEL);
> + vgdev = drmm_kzalloc(dev, sizeof(struct virtio_gpu_device), GFP_KERNEL);
> if (!vgdev)
> return -ENOMEM;
>
> @@ -257,7 +259,6 @@ int virtio_gpu_init(struct drm_device *dev)
> vgdev->vdev->config->del_vqs(vgdev->vdev);
> err_vqs:
> dev->dev_private = NULL;
> - kfree(vgdev);
> return ret;
> }
>
> @@ -296,9 +297,6 @@ void virtio_gpu_release(struct drm_device *dev)
>
> if (vgdev->has_host_visible)
> drm_mm_takedown(&vgdev->host_visible_mm);
> -
> - kfree(vgdev->capsets);
> - kfree(vgdev);
> }
>
> int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
> --
> 2.36.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Danilo Krummrich <dakr@redhat.com>
Cc: airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] drm/virtio: kms: use drm managed resources
Date: Thu, 11 Aug 2022 18:16:57 +0200 [thread overview]
Message-ID: <YvUrefus4/EoCV2J@phenom.ffwll.local> (raw)
In-Reply-To: <20220714130028.2127858-3-dakr@redhat.com>
On Thu, Jul 14, 2022 at 03:00:28PM +0200, Danilo Krummrich wrote:
> Allocate driver structures with drm managed resource allocators in order
> to cleanup/simplify the drm driver .release callback.
>
> Signed-off-by: Danilo Krummrich <dakr@redhat.com>
On both patches:
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
I'm assuming you have commits rights or know someone who does :-)
-Daniel
> ---
> drivers/gpu/drm/virtio/virtgpu_kms.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
> index 3313b92db531..63ebe63ef409 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
> @@ -28,6 +28,7 @@
> #include <linux/virtio_ring.h>
>
> #include <drm/drm_file.h>
> +#include <drm/drm_managed.h>
>
> #include "virtgpu_drv.h"
>
> @@ -66,10 +67,11 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
> {
> int i, ret;
> bool invalid_capset_id = false;
> + struct drm_device *drm = vgdev->ddev;
>
> - vgdev->capsets = kcalloc(num_capsets,
> - sizeof(struct virtio_gpu_drv_capset),
> - GFP_KERNEL);
> + vgdev->capsets = drmm_kcalloc(drm, num_capsets,
> + sizeof(struct virtio_gpu_drv_capset),
> + GFP_KERNEL);
> if (!vgdev->capsets) {
> DRM_ERROR("failed to allocate cap sets\n");
> return;
> @@ -94,7 +96,7 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
>
> if (ret == 0 || invalid_capset_id) {
> spin_lock(&vgdev->display_info_lock);
> - kfree(vgdev->capsets);
> + drmm_kfree(drm, vgdev->capsets);
> vgdev->capsets = NULL;
> spin_unlock(&vgdev->display_info_lock);
> return;
> @@ -126,7 +128,7 @@ int virtio_gpu_init(struct drm_device *dev)
> if (!virtio_has_feature(dev_to_virtio(dev->dev), VIRTIO_F_VERSION_1))
> return -ENODEV;
>
> - vgdev = kzalloc(sizeof(struct virtio_gpu_device), GFP_KERNEL);
> + vgdev = drmm_kzalloc(dev, sizeof(struct virtio_gpu_device), GFP_KERNEL);
> if (!vgdev)
> return -ENOMEM;
>
> @@ -257,7 +259,6 @@ int virtio_gpu_init(struct drm_device *dev)
> vgdev->vdev->config->del_vqs(vgdev->vdev);
> err_vqs:
> dev->dev_private = NULL;
> - kfree(vgdev);
> return ret;
> }
>
> @@ -296,9 +297,6 @@ void virtio_gpu_release(struct drm_device *dev)
>
> if (vgdev->has_host_visible)
> drm_mm_takedown(&vgdev->host_visible_mm);
> -
> - kfree(vgdev->capsets);
> - kfree(vgdev);
> }
>
> int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
> --
> 2.36.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2022-08-11 16:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-14 13:00 [PATCH 0/2] drm/virtio: use drm managed resources Danilo Krummrich
2022-07-14 13:00 ` Danilo Krummrich
2022-07-14 13:00 ` [PATCH 1/2] drm/virtio: plane: " Danilo Krummrich
2022-07-14 13:00 ` Danilo Krummrich
2022-07-14 13:00 ` [PATCH 2/2] drm/virtio: kms: " Danilo Krummrich
2022-07-14 13:00 ` Danilo Krummrich
2022-08-11 16:16 ` Daniel Vetter [this message]
2022-08-11 16:16 ` 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=YvUrefus4/EoCV2J@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=dakr@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.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.