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

drm/tegra: Implement syncpoint wait UAPI

Implement new syncpoint wait UAPI. This is different from the
legacy one in taking an absolute timestamp in line with modern
DRM conventions.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Mikko Perttunen and committed by
Thierry Reding
44e96138 fc348336

+15 -28
+2
drivers/gpu/drm/tegra/drm.c
··· 732 732 DRM_RENDER_ALLOW), 733 733 DRM_IOCTL_DEF_DRV(TEGRA_SYNCPOINT_FREE, tegra_drm_ioctl_syncpoint_free, 734 734 DRM_RENDER_ALLOW), 735 + DRM_IOCTL_DEF_DRV(TEGRA_SYNCPOINT_WAIT, tegra_drm_ioctl_syncpoint_wait, 736 + DRM_RENDER_ALLOW), 735 737 736 738 DRM_IOCTL_DEF_DRV(TEGRA_GEM_CREATE, tegra_gem_create, DRM_RENDER_ALLOW), 737 739 DRM_IOCTL_DEF_DRV(TEGRA_GEM_MMAP, tegra_gem_mmap, DRM_RENDER_ALLOW),
+11 -28
drivers/gpu/drm/tegra/uapi.c
··· 7 7 8 8 #include <drm/drm_drv.h> 9 9 #include <drm/drm_file.h> 10 + #include <drm/drm_utils.h> 10 11 11 12 #include "drm.h" 12 13 #include "uapi.h" ··· 318 317 return 0; 319 318 } 320 319 321 - int tegra_drm_ioctl_gem_create(struct drm_device *drm, void *data, 322 - struct drm_file *file) 320 + int tegra_drm_ioctl_syncpoint_wait(struct drm_device *drm, void *data, struct drm_file *file) 323 321 { 324 - struct drm_tegra_gem_create *args = data; 325 - struct tegra_bo *bo; 322 + struct host1x *host1x = tegra_drm_to_host1x(drm->dev_private); 323 + struct drm_tegra_syncpoint_wait *args = data; 324 + signed long timeout_jiffies; 325 + struct host1x_syncpt *sp; 326 326 327 - if (args->flags) 327 + if (args->padding != 0) 328 328 return -EINVAL; 329 329 330 - bo = tegra_bo_create_with_handle(file, drm, args->size, args->flags, 331 - &args->handle); 332 - if (IS_ERR(bo)) 333 - return PTR_ERR(bo); 334 - 335 - return 0; 336 - } 337 - 338 - int tegra_drm_ioctl_gem_mmap(struct drm_device *drm, void *data, 339 - struct drm_file *file) 340 - { 341 - struct drm_tegra_gem_mmap *args = data; 342 - struct drm_gem_object *gem; 343 - struct tegra_bo *bo; 344 - 345 - gem = drm_gem_object_lookup(file, args->handle); 346 - if (!gem) 330 + sp = host1x_syncpt_get_by_id_noref(host1x, args->id); 331 + if (!sp) 347 332 return -EINVAL; 348 333 349 - bo = to_tegra_bo(gem); 334 + timeout_jiffies = drm_timeout_abs_to_jiffies(args->timeout_ns); 350 335 351 - args->offset = drm_vma_node_offset_addr(&bo->gem.vma_node); 352 - 353 - drm_gem_object_put(gem); 354 - 355 - return 0; 336 + return host1x_syncpt_wait(sp, args->threshold, timeout_jiffies, &args->value); 356 337 }
+2
drivers/gpu/drm/tegra/uapi.h
··· 49 49 struct drm_file *file); 50 50 int tegra_drm_ioctl_syncpoint_free(struct drm_device *drm, void *data, 51 51 struct drm_file *file); 52 + int tegra_drm_ioctl_syncpoint_wait(struct drm_device *drm, void *data, 53 + struct drm_file *file); 52 54 53 55 void tegra_drm_uapi_close_file(struct tegra_drm_file *file); 54 56 void tegra_drm_mapping_put(struct tegra_drm_mapping *mapping);