Skip to content
Snippets Groups Projects
  1. Sep 16, 2015
  2. Sep 12, 2015
  3. Sep 09, 2015
  4. Sep 04, 2015
  5. Sep 03, 2015
  6. Sep 02, 2015
  7. Aug 31, 2015
  8. Aug 26, 2015
  9. Aug 25, 2015
  10. Aug 24, 2015
  11. Aug 23, 2015
  12. Aug 21, 2015
    • Rafał Sapała's avatar
      intel: Serialize drmPrimeFDToHandle with struct_mutex · cf40cf05
      Rafał Sapała authored
      
      It is possible to hit a race condition in create_from_prime, when trying
      to import a BO that's currently being freed. In case of prime sharing
      we'll succesfully get a handle, but fail on get_tiling call, potentially
      confusing the caller (and requiring different locking scheme than with
      sharing using flink). Wrap fd_to_handle with struct_mutex to force
      a more consistent behaviour between prime/flink, convert fprintf to DBG
      when handling errors.
      
      (From Chris:
        The race is that the kernel returns us the same file-private handle as
        the first thread, but that first thread is about to call gem_close
        (thereby removing the handle from the file completely) and does so
        between us acquiring the handle and taking the mutex. If we take
        the mutex, then we acquire the refcnt on the bo prior to the first
        thread completing its unref (and so preventing the early close). Or we
        acquire the handle after the earlier close, in which case we are the new
        owner.
      )
      
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Testcase: igt/drm_import_export/import-close-race-prime
      Signed-off-by: default avatarRafał Sapała <rafal.a.sapala@intel.com>
      Signed-off-by: default avatarMichał Winiarski <michal.winiarski@intel.com>
      cf40cf05
Loading