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

Configure Feed

Select the types of activity you want to include in your feed.

accel/amdxdna: Remove buffer size check when creating command BO

Large command buffers may be used, and they do not always need to be
mapped or accessed by the driver. Performing a size check at command BO
creation time unnecessarily rejects valid use cases.

Remove the buffer size check from command BO creation, and defer vmap
and size validation to the paths where the driver actually needs to map
and access the command buffer.

Fixes: ac49797c1815 ("accel/amdxdna: Add GEM buffer object management")
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20260206060237.4050492-1-lizhi.hou@amd.com

Lizhi Hou 08fe1b51 c17ee635

+19 -19
+19 -19
drivers/accel/amdxdna/amdxdna_gem.c
··· 21 21 #include "amdxdna_pci_drv.h" 22 22 #include "amdxdna_ubuf.h" 23 23 24 - #define XDNA_MAX_CMD_BO_SIZE SZ_32K 25 - 26 24 MODULE_IMPORT_NS("DMA_BUF"); 27 25 28 26 static int ··· 743 745 { 744 746 struct amdxdna_dev *xdna = to_xdna_dev(dev); 745 747 struct amdxdna_gem_obj *abo; 746 - int ret; 747 - 748 - if (args->size > XDNA_MAX_CMD_BO_SIZE) { 749 - XDNA_ERR(xdna, "Command bo size 0x%llx too large", args->size); 750 - return ERR_PTR(-EINVAL); 751 - } 752 748 753 749 if (args->size < sizeof(struct amdxdna_cmd)) { 754 750 XDNA_DBG(xdna, "Command BO size 0x%llx too small", args->size); ··· 756 764 abo->type = AMDXDNA_BO_CMD; 757 765 abo->client = filp->driver_priv; 758 766 759 - ret = amdxdna_gem_obj_vmap(abo, &abo->mem.kva); 760 - if (ret) { 761 - XDNA_ERR(xdna, "Vmap cmd bo failed, ret %d", ret); 762 - goto release_obj; 763 - } 764 - 765 767 return abo; 766 - 767 - release_obj: 768 - drm_gem_object_put(to_gobj(abo)); 769 - return ERR_PTR(ret); 770 768 } 771 769 772 770 int amdxdna_drm_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ··· 853 871 struct amdxdna_dev *xdna = client->xdna; 854 872 struct amdxdna_gem_obj *abo; 855 873 struct drm_gem_object *gobj; 874 + int ret; 856 875 857 876 gobj = drm_gem_object_lookup(client->filp, bo_hdl); 858 877 if (!gobj) { ··· 862 879 } 863 880 864 881 abo = to_xdna_obj(gobj); 865 - if (bo_type == AMDXDNA_BO_INVALID || abo->type == bo_type) 882 + if (bo_type != AMDXDNA_BO_INVALID && abo->type != bo_type) 883 + goto put_obj; 884 + 885 + if (bo_type != AMDXDNA_BO_CMD || abo->mem.kva) 866 886 return abo; 867 887 888 + if (abo->mem.size > SZ_32K) { 889 + XDNA_ERR(xdna, "Cmd bo is too big %ld", abo->mem.size); 890 + goto put_obj; 891 + } 892 + 893 + ret = amdxdna_gem_obj_vmap(abo, &abo->mem.kva); 894 + if (ret) { 895 + XDNA_ERR(xdna, "Vmap cmd bo failed, ret %d", ret); 896 + goto put_obj; 897 + } 898 + 899 + return abo; 900 + 901 + put_obj: 868 902 drm_gem_object_put(gobj); 869 903 return NULL; 870 904 }