0112-drm-Put-an-optional-field-in-the-driver-struct-for-G.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 997e91885e700a7b175c98f0e64670ed4fd57bc0 Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Wed, 19 Nov 2014 12:06:38 -0800
  4. Subject: [PATCH] drm: Put an optional field in the driver struct for GEM obj
  5. struct size.
  6. This allows a driver to derive from the CMA object without copying all
  7. of the code.
  8. Signed-off-by: Eric Anholt <eric@anholt.net>
  9. ---
  10. drivers/gpu/drm/drm_gem_cma_helper.c | 5 ++++-
  11. include/drm/drmP.h | 1 +
  12. 2 files changed, 5 insertions(+), 1 deletion(-)
  13. --- a/drivers/gpu/drm/drm_gem_cma_helper.c
  14. +++ b/drivers/gpu/drm/drm_gem_cma_helper.c
  15. @@ -58,8 +58,11 @@ __drm_gem_cma_create(struct drm_device *
  16. struct drm_gem_cma_object *cma_obj;
  17. struct drm_gem_object *gem_obj;
  18. int ret;
  19. + size_t obj_size = (drm->driver->gem_obj_size ?
  20. + drm->driver->gem_obj_size :
  21. + sizeof(*cma_obj));
  22. - cma_obj = kzalloc(sizeof(*cma_obj), GFP_KERNEL);
  23. + cma_obj = kzalloc(obj_size, GFP_KERNEL);
  24. if (!cma_obj)
  25. return ERR_PTR(-ENOMEM);
  26. --- a/include/drm/drmP.h
  27. +++ b/include/drm/drmP.h
  28. @@ -653,6 +653,7 @@ struct drm_driver {
  29. u32 driver_features;
  30. int dev_priv_size;
  31. + size_t gem_obj_size;
  32. const struct drm_ioctl_desc *ioctls;
  33. int num_ioctls;
  34. const struct file_operations *fops;