--- zzzz-none-000/linux-3.10.107/drivers/media/dvb-frontends/dib0090.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/dvb-frontends/dib0090.c 2021-02-04 17:41:59.000000000 +0000 @@ -1696,12 +1696,10 @@ if (state->identity.p1g) state->dc = dc_p1g_table; - *tune_state = CT_TUNER_STEP_0; /* fall through */ - case CT_TUNER_STEP_0: - dprintk("Sart/continue DC calibration for %s path", (state->dc->i == 1) ? "I" : "Q"); + dprintk("Start/continue DC calibration for %s path", (state->dc->i == 1) ? "I" : "Q"); dib0090_write_reg(state, 0x01, state->dc->bb1); dib0090_write_reg(state, 0x07, state->bb7 | (state->dc->i << 7)); @@ -2557,10 +2555,19 @@ do { ret = dib0090_tune(fe); - if (ret != FE_CALLBACK_TIME_NEVER) - msleep(ret / 10); - else + if (ret == FE_CALLBACK_TIME_NEVER) break; + + /* + * Despite dib0090_tune returns time at a 0.1 ms range, + * the actual sleep time depends on CONFIG_HZ. The worse case + * is when CONFIG_HZ=100. In such case, the minimum granularity + * is 10ms. On some real field tests, the tuner sometimes don't + * lock when this timer is lower than 10ms. So, enforce a 10ms + * granularity and use usleep_range() instead of msleep(). + */ + ret = 10 * (ret + 99)/100; + usleep_range(ret * 1000, (ret + 1) * 1000); } while (state->tune_state != CT_TUNER_STOP); return 0;