[PATCH v2 22/25] drm/vmwgfx: Compute dumb-buffer sizes with drm_mode_size_dumb()
Zack Rusin
zack.rusin at broadcom.com
Fri Jan 10 18:18:51 UTC 2025
On Thu, Jan 9, 2025 at 10:03 AM Thomas Zimmermann <tzimmermann at suse.de> wrote:
>
> Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch
> and buffer size. No alignment required.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> Cc: Zack Rusin <zack.rusin at broadcom.com>
> Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list at broadcom.com>
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 21 ++++-----------------
> 1 file changed, 4 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index 5721c74da3e0..a3fbd4148f73 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -34,6 +34,7 @@
> #include "vmw_surface_cache.h"
> #include "device_include/svga3d_surfacedefs.h"
>
> +#include <drm/drm_dumb_buffers.h>
> #include <drm/ttm/ttm_placement.h>
>
> #define SVGA3D_FLAGS_64(upper32, lower32) (((uint64_t)upper32 << 32) | lower32)
> @@ -2291,23 +2292,9 @@ int vmw_dumb_create(struct drm_file *file_priv,
> * contents is going to be rendered guest side.
> */
> if (!dev_priv->has_mob || !vmw_supports_3d(dev_priv)) {
> - int cpp = DIV_ROUND_UP(args->bpp, 8);
> -
> - switch (cpp) {
> - case 1: /* DRM_FORMAT_C8 */
> - case 2: /* DRM_FORMAT_RGB565 */
> - case 4: /* DRM_FORMAT_XRGB8888 */
> - break;
> - default:
> - /*
> - * Dumb buffers don't allow anything else.
> - * This is tested via IGT's dumb_buffers
> - */
> - return -EINVAL;
> - }
> -
> - args->pitch = args->width * cpp;
> - args->size = ALIGN(args->pitch * args->height, PAGE_SIZE);
> + ret = drm_mode_size_dumb(dev, args, 0, 0);
> + if (ret)
> + return ret;
>
> ret = vmw_gem_object_create_with_handle(dev_priv, file_priv,
> args->size, &args->handle,
> --
> 2.47.1
>
Ah, that's great. Thanks!
Reviewed-by: Zack Rusin <zack.rusin at broadcom.com>
z
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5427 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20250110/d3755507/attachment-0001.bin>
More information about the Spice-devel
mailing list