Skip to content

Commit

Permalink
The graphic type should be set before driver init
Browse files Browse the repository at this point in the history
This PR rever the commit b5053aa as it casues the
graphic type set fail.
Android VM boot fail if seperate the drv array init and
drv init before. Now this issue not reproduced. So change
it back.

Tracked-On: OAM-122333
Signed-off-by: HeYue <[email protected]>
  • Loading branch information
yhe39 authored and sysopenci committed Aug 6, 2024
1 parent 33c2926 commit 6876211
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
8 changes: 7 additions & 1 deletion cros_gralloc/cros_gralloc_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ cros_gralloc_driver::cros_gralloc_driver()
}

if (drv_render_) {
drv_init(drv_render_, gpu_grp_type);
if (drv_init(drv_render_, gpu_grp_type)) {
drv_loge("Failed to init driver\n");
fd = drv_get_fd(drv_render_);
drv_destroy(drv_render_);
close(fd);
drv_render_ = nullptr;
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,6 @@ struct driver *drv_create(int fd)
if (!drv->combos)
goto free_mappings;

if (drv->backend->init) {
ret = drv->backend->init(drv);
if (ret) {
drv_array_destroy(drv->combos);
goto free_mappings;
}
}

return drv;

free_mappings:
Expand All @@ -163,13 +155,21 @@ struct driver *drv_create(int fd)
return NULL;
}

void drv_init(struct driver * drv, uint32_t grp_type)
int drv_init(struct driver * drv, uint32_t grp_type)
{
int ret = 0;
assert(drv);
assert(drv->backend);

drv->gpu_grp_type = grp_type;
if (drv->backend->init) {
ret = drv->backend->init(drv);
if (ret) {
drv_array_destroy(drv->combos);
drv_array_destroy(drv->mappings);
}
}
return ret;
}

void drv_destroy(struct driver *drv)
Expand Down
2 changes: 1 addition & 1 deletion drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void drv_preload(bool load);

struct driver *drv_create(int fd);

void drv_init(struct driver * drv, uint32_t grp_type);
int drv_init(struct driver * drv, uint32_t grp_type);

void drv_destroy(struct driver *drv);

Expand Down
6 changes: 5 additions & 1 deletion gbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ PUBLIC struct gbm_device *gbm_create_device(int fd)
return NULL;
}

drv_init(gbm->drv, 0);
if (drv_init(gbm->drv, 0) != 0) {
drv_destroy(gbm->drv);
free(gbm);
return NULL;
}

return gbm;
}
Expand Down

0 comments on commit 6876211

Please sign in to comment.