diff mbox series

[06/59] drm/vboxvideo: Use devm_gen_pool_create

Message ID 20200415074034.175360-7-daniel.vetter@ffwll.ch
State New, archived
Headers show
Series devm_drm_dev_alloc, v2 | expand

Commit Message

Daniel Vetter April 15, 2020, 7:39 a.m. UTC
Aside from deleting all the cleanup code we're now also setting a name
for the pool

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/vboxvideo/vbox_main.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

Hans de Goede April 15, 2020, 3:04 p.m. UTC | #1
Hi,

On 4/15/20 9:39 AM, Daniel Vetter wrote:
> Aside from deleting all the cleanup code we're now also setting a name
> for the pool
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

LGTM:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>   drivers/gpu/drm/vboxvideo/vbox_main.c | 22 ++++++++--------------
>   1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
> index 1336ab9795fc..d68d9bad7674 100644
> --- a/drivers/gpu/drm/vboxvideo/vbox_main.c
> +++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
> @@ -121,7 +121,8 @@ int vbox_hw_init(struct vbox_private *vbox)
>   		return -ENOMEM;
>   
>   	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
> -	vbox->guest_pool = gen_pool_create(4, -1);
> +	vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,
> +						"vboxvideo-accel");
>   	if (!vbox->guest_pool)
>   		return -ENOMEM;
>   
> @@ -130,12 +131,12 @@ int vbox_hw_init(struct vbox_private *vbox)
>   				GUEST_HEAP_OFFSET(vbox),
>   				GUEST_HEAP_USABLE_SIZE, -1);
>   	if (ret)
> -		goto err_destroy_guest_pool;
> +		return ret;
>   
>   	ret = hgsmi_test_query_conf(vbox->guest_pool);
>   	if (ret) {
>   		DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
> -		goto err_destroy_guest_pool;
> +		return ret;
>   	}
>   
>   	/* Reduce available VRAM size to reflect the guest heap. */
> @@ -147,30 +148,23 @@ int vbox_hw_init(struct vbox_private *vbox)
>   
>   	if (!have_hgsmi_mode_hints(vbox)) {
>   		ret = -ENOTSUPP;
> -		goto err_destroy_guest_pool;
> +		return ret;
>   	}
>   
>   	vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
>   					     sizeof(struct vbva_modehint),
>   					     GFP_KERNEL);
> -	if (!vbox->last_mode_hints) {
> -		ret = -ENOMEM;
> -		goto err_destroy_guest_pool;
> -	}
> +	if (!vbox->last_mode_hints)
> +		return -ENOMEM;
>   
>   	ret = vbox_accel_init(vbox);
>   	if (ret)
> -		goto err_destroy_guest_pool;
> +		return ret;
>   
>   	return 0;
> -
> -err_destroy_guest_pool:
> -	gen_pool_destroy(vbox->guest_pool);
> -	return ret;
>   }
>   
>   void vbox_hw_fini(struct vbox_private *vbox)
>   {
>   	vbox_accel_fini(vbox);
> -	gen_pool_destroy(vbox->guest_pool);
>   }
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vboxvideo/vbox_main.c b/drivers/gpu/drm/vboxvideo/vbox_main.c
index 1336ab9795fc..d68d9bad7674 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_main.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_main.c
@@ -121,7 +121,8 @@  int vbox_hw_init(struct vbox_private *vbox)
 		return -ENOMEM;
 
 	/* Create guest-heap mem-pool use 2^4 = 16 byte chunks */
-	vbox->guest_pool = gen_pool_create(4, -1);
+	vbox->guest_pool = devm_gen_pool_create(vbox->ddev.dev, 4, -1,
+						"vboxvideo-accel");
 	if (!vbox->guest_pool)
 		return -ENOMEM;
 
@@ -130,12 +131,12 @@  int vbox_hw_init(struct vbox_private *vbox)
 				GUEST_HEAP_OFFSET(vbox),
 				GUEST_HEAP_USABLE_SIZE, -1);
 	if (ret)
-		goto err_destroy_guest_pool;
+		return ret;
 
 	ret = hgsmi_test_query_conf(vbox->guest_pool);
 	if (ret) {
 		DRM_ERROR("vboxvideo: hgsmi_test_query_conf failed\n");
-		goto err_destroy_guest_pool;
+		return ret;
 	}
 
 	/* Reduce available VRAM size to reflect the guest heap. */
@@ -147,30 +148,23 @@  int vbox_hw_init(struct vbox_private *vbox)
 
 	if (!have_hgsmi_mode_hints(vbox)) {
 		ret = -ENOTSUPP;
-		goto err_destroy_guest_pool;
+		return ret;
 	}
 
 	vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
 					     sizeof(struct vbva_modehint),
 					     GFP_KERNEL);
-	if (!vbox->last_mode_hints) {
-		ret = -ENOMEM;
-		goto err_destroy_guest_pool;
-	}
+	if (!vbox->last_mode_hints)
+		return -ENOMEM;
 
 	ret = vbox_accel_init(vbox);
 	if (ret)
-		goto err_destroy_guest_pool;
+		return ret;
 
 	return 0;
-
-err_destroy_guest_pool:
-	gen_pool_destroy(vbox->guest_pool);
-	return ret;
 }
 
 void vbox_hw_fini(struct vbox_private *vbox)
 {
 	vbox_accel_fini(vbox);
-	gen_pool_destroy(vbox->guest_pool);
 }