Prashanth Prakash wrote:
+static int check_pcc_chan(void) +{
- int ret = -EIO;
- struct acpi_pcct_shared_memory __iomem *generic_comm_base = pcc_comm_addr;
- ktime_t next_deadline = ktime_add(ktime_get(), deadline);
- /* Retry in case the remote processor was too slow to catch up. */
- while (!ktime_after(ktime_get(), next_deadline)) {
if (readw_relaxed(&generic_comm_base->status) & PCC_CMD_COMPLETE) {
ret = 0;
break;
}
/*
* Reducing the bus traffic in case this loop takes longer than
* a few retries.
*/
udelay(3);
- }
Like I said last time, you really should use readq_relaxed_poll_timeout(), which does exactly the same thing as this loop, but more elegantly. I think this will work:
u32 status; ret = readq_relaxed_poll_timeout(&generic_comm_base->status, status, status & PCC_CMD_COMPLETE, 3, deadline); return ret ? -EIO : 0; ... deadline = NUM_RETRIES * cppc_ss->latency;
This lets you completely eliminate all usage of ktime. You can eliminate the global variable 'deadline' also, if you can figure out how to pass the cppc_ss object to check_pcc_chan().
- /* Wait for a nominal time to let platform process command. */
- udelay(cmd_latency);
- /* Retry in case the remote processor was too slow to catch up. */
- for (retries = NUM_RETRIES; retries > 0; retries--) {
if (readw_relaxed(&generic_comm_base->status) & PCC_CMD_COMPLETE) {
result = 0;
break;
}
- }
- /*
* For READs we need to ensure the cmd completed to ensure
* the ensuing read()s can proceed. For WRITEs we dont care
"don't"