Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: Make all surfaces shareable

There is no real need to have a separate pool for shareable and
non-shareable surfaces. Make all surfaces shareable, regardless of whether
the drm_vmw_surface_flag_shareable has been specified.

Signed-off-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Reviewed-by: Martin Krastev <martin.krastev@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240126200804.732454-3-zack.rusin@broadcom.com

authored by

Maaz Mombasawala and committed by
Zack Rusin
9840d28f 935f7950

+13 -18
+3 -3
drivers/gpu/drm/vmwgfx/ttm_object.c
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2 2 /************************************************************************** 3 3 * 4 - * Copyright (c) 2009-2022 VMware, Inc., Palo Alto, CA., USA 4 + * Copyright (c) 2009-2023 VMware, Inc., Palo Alto, CA., USA 5 5 * All Rights Reserved. 6 6 * 7 7 * Permission is hereby granted, free of charge, to any person obtaining a ··· 648 648 * @tfile: struct ttm_object_file identifying the caller 649 649 * @size: The size of the dma_bufs we export. 650 650 * @prime: The object to be initialized. 651 - * @shareable: See ttm_base_object_init 652 651 * @type: See ttm_base_object_init 653 652 * @refcount_release: See ttm_base_object_init 654 653 * ··· 655 656 * for data sharing between processes and devices. 656 657 */ 657 658 int ttm_prime_object_init(struct ttm_object_file *tfile, size_t size, 658 - struct ttm_prime_object *prime, bool shareable, 659 + struct ttm_prime_object *prime, 659 660 enum ttm_object_type type, 660 661 void (*refcount_release) (struct ttm_base_object **)) 661 662 { 663 + bool shareable = !!(type == VMW_RES_SURFACE); 662 664 mutex_init(&prime->mutex); 663 665 prime->size = PAGE_ALIGN(size); 664 666 prime->real_type = type;
+1 -2
drivers/gpu/drm/vmwgfx/ttm_object.h
··· 1 1 /************************************************************************** 2 2 * 3 - * Copyright (c) 2006-2022 VMware, Inc., Palo Alto, CA., USA 3 + * Copyright (c) 2006-2023 VMware, Inc., Palo Alto, CA., USA 4 4 * All Rights Reserved. 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a ··· 288 288 extern int ttm_prime_object_init(struct ttm_object_file *tfile, 289 289 size_t size, 290 290 struct ttm_prime_object *prime, 291 - bool shareable, 292 291 enum ttm_object_type type, 293 292 void (*refcount_release) 294 293 (struct ttm_base_object **));
+6 -11
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
··· 832 832 srf->snooper.image = NULL; 833 833 } 834 834 835 - user_srf->prime.base.shareable = false; 836 - user_srf->prime.base.tfile = NULL; 837 835 if (drm_is_primary_client(file_priv)) 838 836 user_srf->master = drm_file_get_master(file_priv); 839 837 ··· 845 847 goto out_unlock; 846 848 847 849 /* 848 - * A gb-aware client referencing a shared surface will 849 - * expect a backup buffer to be present. 850 + * A gb-aware client referencing a surface will expect a backup 851 + * buffer to be present. 850 852 */ 851 - if (dev_priv->has_mob && req->shareable) { 853 + if (dev_priv->has_mob) { 852 854 struct vmw_bo_params params = { 853 855 .domain = VMW_BO_DOMAIN_SYS, 854 856 .busy_domain = VMW_BO_DOMAIN_SYS, ··· 867 869 } 868 870 869 871 tmp = vmw_resource_reference(&srf->res); 870 - ret = ttm_prime_object_init(tfile, res->guest_memory_size, &user_srf->prime, 871 - req->shareable, VMW_RES_SURFACE, 872 + ret = ttm_prime_object_init(tfile, res->guest_memory_size, 873 + &user_srf->prime, 874 + VMW_RES_SURFACE, 872 875 &vmw_user_surface_base_release); 873 876 874 877 if (unlikely(ret != 0)) { ··· 1548 1549 1549 1550 tmp = vmw_resource_reference(res); 1550 1551 ret = ttm_prime_object_init(tfile, res->guest_memory_size, &user_srf->prime, 1551 - req->base.drm_surface_flags & 1552 - drm_vmw_surface_flag_shareable, 1553 1552 VMW_RES_SURFACE, 1554 1553 &vmw_user_surface_base_release); 1555 1554 ··· 2049 2052 } 2050 2053 2051 2054 *srf_out = &user_srf->srf; 2052 - user_srf->prime.base.shareable = false; 2053 - user_srf->prime.base.tfile = NULL; 2054 2055 2055 2056 srf = &user_srf->srf; 2056 2057 srf->metadata = *req;
+3 -2
include/uapi/drm/vmwgfx_drm.h
··· 1 1 /************************************************************************** 2 2 * 3 - * Copyright © 2009-2022 VMware, Inc., Palo Alto, CA., USA 3 + * Copyright © 2009-2023 VMware, Inc., Palo Alto, CA., USA 4 4 * All Rights Reserved. 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a ··· 902 902 /** 903 903 * enum drm_vmw_surface_flags 904 904 * 905 - * @drm_vmw_surface_flag_shareable: Whether the surface is shareable 905 + * @drm_vmw_surface_flag_shareable: Deprecated - all userspace surfaces are 906 + * shareable. 906 907 * @drm_vmw_surface_flag_scanout: Whether the surface is a scanout 907 908 * surface. 908 909 * @drm_vmw_surface_flag_create_buffer: Create a backup buffer if none is