Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e07ced

Browse files
committed
Add retry for vchiq init. Needed in some cases when using CMA
1 parent d53095f commit 0e07ced

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/misc/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,31 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data,
6868
* vchiq_initialise
6969
*
7070
***************************************************************************/
71-
71+
#define VCHIQ_INIT_RETRIES 10
7272
VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instanceOut)
7373
{
7474
VCHIQ_STATUS_T status = VCHIQ_ERROR;
7575
VCHIQ_STATE_T *state;
7676
VCHIQ_INSTANCE_T instance = NULL;
77+
int i;
7778

7879
vchiq_log_trace(vchiq_core_log_level, "%s called", __func__);
7980

80-
state = vchiq_get_state();
81-
if (!state) {
81+
/* VideoCore may not be ready due to boot up timing.
82+
It may never be ready if kernel and firmware are mismatched, so don't block forever. */
83+
for (i=0; i<VCHIQ_INIT_RETRIES; i++) {
84+
state = vchiq_get_state();
85+
if (state)
86+
break;
87+
udelay(500);
88+
}
89+
if (i==VCHIQ_INIT_RETRIES) {
8290
vchiq_log_error(vchiq_core_log_level,
8391
"%s: videocore not initialized\n", __func__);
8492
goto failed;
93+
} else if (i>0) {
94+
vchiq_log_warning(vchiq_core_log_level,
95+
"%s: videocore initialized after %d retries\n", __func__, i);
8596
}
8697

8798
instance = kzalloc(sizeof(*instance), GFP_KERNEL);

0 commit comments

Comments
 (0)