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.

drm/panthor: Add an ioctl to query BO flags

This is useful when importing BOs, so we can know about cacheability
and flush the caches when needed.

We can also know when the buffer comes from a different subsystem and
take proper actions (avoid CPU mappings, or do kernel-based syncs
instead of userland cache flushes).

v2:
- New commit

v3:
- Add Steve's R-b

v4:
- No changes

v5:
- No changes

v6:
- No changes

v7:
- No changes

v8:
- No changes

Reviewed-by: Steven Price <steven.price@arm.com>
Link: https://patch.msgid.link/20251208100841.730527-6-boris.brezillon@collabora.com
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>

+81
+24
drivers/gpu/drm/panthor/panthor_drv.c
··· 1434 1434 return ret; 1435 1435 } 1436 1436 1437 + static int panthor_ioctl_bo_query_info(struct drm_device *ddev, void *data, 1438 + struct drm_file *file) 1439 + { 1440 + struct drm_panthor_bo_query_info *args = data; 1441 + struct panthor_gem_object *bo; 1442 + struct drm_gem_object *obj; 1443 + 1444 + obj = drm_gem_object_lookup(file, args->handle); 1445 + if (!obj) 1446 + return -ENOENT; 1447 + 1448 + bo = to_panthor_bo(obj); 1449 + args->pad = 0; 1450 + args->create_flags = bo->flags; 1451 + 1452 + args->extra_flags = 0; 1453 + if (drm_gem_is_imported(&bo->base.base)) 1454 + args->extra_flags |= DRM_PANTHOR_BO_IS_IMPORTED; 1455 + 1456 + drm_gem_object_put(obj); 1457 + return 0; 1458 + } 1459 + 1437 1460 static int 1438 1461 panthor_open(struct drm_device *ddev, struct drm_file *file) 1439 1462 { ··· 1532 1509 PANTHOR_IOCTL(BO_SET_LABEL, bo_set_label, DRM_RENDER_ALLOW), 1533 1510 PANTHOR_IOCTL(SET_USER_MMIO_OFFSET, set_user_mmio_offset, DRM_RENDER_ALLOW), 1534 1511 PANTHOR_IOCTL(BO_SYNC, bo_sync, DRM_RENDER_ALLOW), 1512 + PANTHOR_IOCTL(BO_QUERY_INFO, bo_query_info, DRM_RENDER_ALLOW), 1535 1513 }; 1536 1514 1537 1515 static int panthor_mmap(struct file *filp, struct vm_area_struct *vma)
+57
include/uapi/drm/panthor_drm.h
··· 147 147 148 148 /** @DRM_PANTHOR_BO_SYNC: Sync BO data to/from the device */ 149 149 DRM_PANTHOR_BO_SYNC, 150 + 151 + /** 152 + * @DRM_PANTHOR_BO_QUERY_INFO: Query information about a BO. 153 + * 154 + * This is useful for imported BOs. 155 + */ 156 + DRM_PANTHOR_BO_QUERY_INFO, 150 157 }; 151 158 152 159 /** ··· 1131 1124 }; 1132 1125 1133 1126 /** 1127 + * enum drm_panthor_bo_extra_flags - Set of flags returned on a BO_QUERY_INFO request 1128 + * 1129 + * Those are flags reflecting BO properties that are not directly coming from the flags 1130 + * passed are creation time, or information on BOs that were imported from other drivers. 1131 + */ 1132 + enum drm_panthor_bo_extra_flags { 1133 + /** 1134 + * @DRM_PANTHOR_BO_IS_IMPORTED: BO has been imported from an external driver. 1135 + * 1136 + * Note that imported dma-buf handles are not flagged as imported if they 1137 + * where exported by panthor. Only buffers that are coming from other drivers 1138 + * (dma heaps, other GPUs, display controllers, V4L, ...). 1139 + * 1140 + * It's also important to note that all imported BOs are mapped cached and can't 1141 + * be considered IO-coherent even if the GPU is. This means they require explicit 1142 + * syncs that must go through the DRM_PANTHOR_BO_SYNC ioctl (userland cache 1143 + * maintenance is not allowed in that case, because extra operations might be 1144 + * needed to make changes visible to the CPU/device, like buffer migration when the 1145 + * exporter is a GPU with its own VRAM). 1146 + */ 1147 + DRM_PANTHOR_BO_IS_IMPORTED = (1 << 0), 1148 + }; 1149 + 1150 + /** 1151 + * struct drm_panthor_bo_query_info - Query BO info 1152 + */ 1153 + struct drm_panthor_bo_query_info { 1154 + /** @handle: Handle of the buffer object to query flags on. */ 1155 + __u32 handle; 1156 + 1157 + /** 1158 + * @extra_flags: Combination of enum drm_panthor_bo_extra_flags flags. 1159 + */ 1160 + __u32 extra_flags; 1161 + 1162 + /** 1163 + * @create_flags: Flags passed at creation time. 1164 + * 1165 + * Combination of enum drm_panthor_bo_flags flags. 1166 + * Will be zero if the buffer comes from a different driver. 1167 + */ 1168 + __u32 create_flags; 1169 + 1170 + /** @pad: Will be zero on return. */ 1171 + __u32 pad; 1172 + }; 1173 + 1174 + /** 1134 1175 * DRM_IOCTL_PANTHOR() - Build a Panthor IOCTL number 1135 1176 * @__access: Access type. Must be R, W or RW. 1136 1177 * @__id: One of the DRM_PANTHOR_xxx id. ··· 1226 1171 DRM_IOCTL_PANTHOR(WR, SET_USER_MMIO_OFFSET, set_user_mmio_offset), 1227 1172 DRM_IOCTL_PANTHOR_BO_SYNC = 1228 1173 DRM_IOCTL_PANTHOR(WR, BO_SYNC, bo_sync), 1174 + DRM_IOCTL_PANTHOR_BO_QUERY_INFO = 1175 + DRM_IOCTL_PANTHOR(WR, BO_QUERY_INFO, bo_query_info), 1229 1176 }; 1230 1177 1231 1178 #if defined(__cplusplus)