• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

external/gbm_gralloc


Commit MetaInfo

Revision28b45dc78151b791c3815fd8c696feccb5f78e04 (tree)
Zeit2017-09-07 01:45:05
AutorRob Herring <robh@kern...>
CommiterRob Herring

Log Message

Rework unregister/free code

It is not necessary to track imported buffers nor ref count them and
doing so is broken when native handles are cloned. So remove all the
related code and separate the unregister and free code paths.

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

Ändern Zusammenfassung

Diff

--- a/gralloc.cpp
+++ b/gralloc.cpp
@@ -228,7 +228,9 @@ static int gbm_mod_free_gpu0(alloc_device_t *dev, buffer_handle_t handle)
228228 goto unlock;
229229 }
230230
231- gralloc_gbm_bo_decref(bo);
231+ gbm_free(bo);
232+ native_handle_close(handle);
233+ delete handle;
232234
233235 unlock:
234236 pthread_mutex_unlock(&dmod->mutex);
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -52,12 +52,8 @@ struct gralloc_gbm_bo_t {
5252
5353 struct gralloc_gbm_handle_t *handle;
5454
55- int imported; /* the handle is from a remote proces when true */
56-
5755 int lock_count;
5856 int locked_for;
59-
60- unsigned int refcount;
6157 };
6258
6359 static int32_t gralloc_gbm_pid = 0;
@@ -211,7 +207,7 @@ static struct gralloc_gbm_bo_t *gbm_alloc(struct gbm_device *gbm,
211207 return buf;
212208 }
213209
214-static void gbm_free(struct gralloc_gbm_bo_t *bo)
210+void gbm_free(struct gralloc_gbm_bo_t *bo)
215211 {
216212 gbm_bo_destroy(bo->bo);
217213 delete bo;
@@ -318,11 +314,8 @@ static struct gralloc_gbm_bo_t *validate_handle(buffer_handle_t _handle,
318314 ALOGV("handle: pfd=%d\n", handle->prime_fd);
319315
320316 bo = gbm_import(gbm, handle);
321- if (bo) {
322- bo->imported = 1;
317+ if (bo)
323318 bo->handle = handle;
324- bo->refcount = 1;
325- }
326319
327320 handle->data_owner = gralloc_gbm_get_pid();
328321 handle->data = bo;
@@ -343,14 +336,16 @@ int gralloc_gbm_handle_register(buffer_handle_t handle, struct gbm_device *gbm)
343336 */
344337 int gralloc_gbm_handle_unregister(buffer_handle_t handle)
345338 {
339+ struct gralloc_gbm_handle_t *gbm_handle = gralloc_gbm_handle(handle);
346340 struct gralloc_gbm_bo_t *bo;
347341
348342 bo = validate_handle(handle, NULL);
349343 if (!bo)
350344 return -EINVAL;
351345
352- if (bo->imported)
353- gralloc_gbm_bo_decref(bo);
346+ gbm_free(bo);
347+ gbm_handle->data_owner = 0;
348+ gbm_handle->data = 0;
354349
355350 return 0;
356351 }
@@ -400,9 +395,7 @@ struct gralloc_gbm_bo_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
400395 return NULL;
401396 }
402397
403- bo->imported = 0;
404398 bo->handle = handle;
405- bo->refcount = 1;
406399
407400 handle->data_owner = gralloc_gbm_get_pid();
408401 handle->data = bo;
@@ -411,38 +404,6 @@ struct gralloc_gbm_bo_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
411404 }
412405
413406 /*
414- * Destroy a bo.
415- */
416-static void gralloc_gbm_bo_destroy(struct gralloc_gbm_bo_t *bo)
417-{
418- struct gralloc_gbm_handle_t *handle = bo->handle;
419- int imported = bo->imported;
420-
421- /* gralloc still has a reference */
422- if (bo->refcount)
423- return;
424-
425- gbm_free(bo);
426- if (imported) {
427- handle->data_owner = 0;
428- handle->data = 0;
429- }
430- else {
431- native_handle_close(handle);
432- delete handle;
433- }
434-}
435-
436-/*
437- * Decrease refcount, if no refs anymore then destroy.
438- */
439-void gralloc_gbm_bo_decref(struct gralloc_gbm_bo_t *bo)
440-{
441- if (!--bo->refcount)
442- gralloc_gbm_bo_destroy(bo);
443-}
444-
445-/*
446407 * Return the bo of a registered handle.
447408 */
448409 struct gralloc_gbm_bo_t *gralloc_gbm_bo_from_handle(buffer_handle_t handle)
--- a/gralloc_gbm_priv.h
+++ b/gralloc_gbm_priv.h
@@ -40,7 +40,7 @@ int gralloc_gbm_handle_unregister(buffer_handle_t handle);
4040
4141 struct gralloc_gbm_bo_t *gralloc_gbm_bo_create(struct gbm_device *gbm,
4242 int width, int height, int format, int usage);
43-void gralloc_gbm_bo_decref(struct gralloc_gbm_bo_t *bo);
43+void gbm_free(struct gralloc_gbm_bo_t *bo);
4444
4545 struct gralloc_gbm_bo_t *gralloc_gbm_bo_from_handle(buffer_handle_t handle);
4646 buffer_handle_t gralloc_gbm_bo_get_handle(struct gralloc_gbm_bo_t *bo);