intel_scu_ipc: move error check out of the loop
This is small performance optimization of the busy_loop(). While here, use BIT() macro instead of plain integers when check the status. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
This commit is contained in:
parent
7c2e3c7476
commit
f0295a36dc
|
@ -176,21 +176,21 @@ static inline u32 ipc_data_readl(u32 offset) /* Read ipc u32 data */
|
||||||
/* Wait till scu status is busy */
|
/* Wait till scu status is busy */
|
||||||
static inline int busy_loop(void)
|
static inline int busy_loop(void)
|
||||||
{
|
{
|
||||||
u32 status = 0;
|
u32 status = ipc_read_status();
|
||||||
u32 loop_count = 0;
|
u32 loop_count = 100000;
|
||||||
|
|
||||||
status = ipc_read_status();
|
/* break if scu doesn't reset busy bit after huge retry */
|
||||||
while (status & 1) {
|
while ((status & BIT(0)) && --loop_count) {
|
||||||
udelay(1); /* scu processing time is in few u secods */
|
udelay(1); /* scu processing time is in few u secods */
|
||||||
status = ipc_read_status();
|
status = ipc_read_status();
|
||||||
loop_count++;
|
}
|
||||||
/* break if scu doesn't reset busy bit after huge retry */
|
|
||||||
if (loop_count > 100000) {
|
if (status & BIT(0)) {
|
||||||
dev_err(&ipcdev.pdev->dev, "IPC timed out");
|
dev_err(&ipcdev.pdev->dev, "IPC timed out");
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ((status >> 1) & 1)
|
if (status & BIT(1))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -208,8 +208,7 @@ static inline int ipc_wait_for_interrupt(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ipc_read_status();
|
status = ipc_read_status();
|
||||||
|
if (status & BIT(1))
|
||||||
if ((status >> 1) & 1)
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue