• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscaphegui翻訳comegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

external/gbm_gralloc


Commit MetaInfo

Revisionfd87c76a2f0b07308112dc2e286d29238eec38f3 (tree)
Zeit2017-09-11 23:59:44
AutorRob Herring <robh@kern...>
CommiterRob Herring

Log Message

Rework handle register/unregister calls

What validate_handle() did was ambiguous and broken for binderized
gralloc. Reusing the existing BO pointer for gralloc_gbm_handle_register
is broken because the BO may get freed. It is necessary to always import
the buffer. So split validate handle into separate functions to retrieve
the BO ptr and import the buffer.

Change-Id: I4ea18aa0ded2d201c8f71f4e33a8fc893240d109
Signed-off-by: Rob Herring <robh@kernel.org>

Ändern Zusammenfassung

Diff

--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -310,42 +310,24 @@ static int gralloc_gbm_get_pid(void)
310310 }
311311
312312 /*
313- * Validate a buffer handle and return the associated bo.
313+ * Register a buffer handle.
314314 */
315-static struct gralloc_gbm_bo_t *validate_handle(buffer_handle_t _handle,
316- struct gbm_device *gbm)
315+int gralloc_gbm_handle_register(buffer_handle_t _handle, struct gbm_device *gbm)
317316 {
318317 struct gralloc_gbm_bo_t *bo;
319318 struct gralloc_gbm_handle_t *handle = gralloc_gbm_handle(_handle);
320319
321320 if (!handle)
322- return NULL;
323-
324- /* the buffer handle is passed to a new process */
325- //ALOGE("data_owner=%d gralloc_pid=%d data=%p\n", handle->data_owner, gralloc_gbm_get_pid(), handle->data);
326- if (handle->data_owner == gralloc_gbm_get_pid())
327- return (struct gralloc_gbm_bo_t *)handle->data;
328-
329- /* check only */
330- if (!gbm)
331- return NULL;
332-
333- ALOGV("handle: pfd=%d\n", handle->prime_fd);
321+ return -EINVAL;
334322
335323 bo = gbm_import(gbm, handle);
324+ if (!bo)
325+ return -EINVAL;
336326
337327 handle->data_owner = gralloc_gbm_get_pid();
338328 handle->data = bo;
339329
340- return bo;
341-}
342-
343-/*
344- * Register a buffer handle.
345- */
346-int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm)
347-{
348- return (validate_handle(handle, gbm)) ? 0 : -EINVAL;
330+ return 0;
349331 }
350332
351333 /*
@@ -354,15 +336,14 @@ int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm)
354336 int gralloc_gbm_handle_unregister(buffer_handle_t handle)
355337 {
356338 struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
357- struct gralloc_gbm_bo_t *bo;
339+ struct gralloc_gbm_bo_t *bo = gralloc_gbm_bo_from_handle(handle);
358340
359- bo = validate_handle(handle, NULL);
360341 if (!bo)
361342 return -EINVAL;
362343
363344 gbm_free(bo);
364345 gbm_handle->data_owner = 0;
365- gbm_handle->data = 0;
346+ gbm_handle->data = NULL;
366347
367348 return 0;
368349 }