From: Todd Poynor <toddpoynor@xxxxxxxxxx> Return -ETIMEDOUT on timeouts. Don't need 64-bit sized retry count. Use msleep(). Return immediately when condition hit. Reported-by: Dmitry Torokhov <dtor@xxxxxxxxxxxx> Signed-off-by: Zhongze Hu <frankhu@xxxxxxxxxxxx> Signed-off-by: Todd Poynor <toddpoynor@xxxxxxxxxx> --- drivers/staging/gasket/apex_driver.c | 8 ++++---- drivers/staging/gasket/gasket_core.c | 11 ++++++----- drivers/staging/gasket/gasket_core.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c index f2d082c06c98..b1318482ba65 100644 --- a/drivers/staging/gasket/apex_driver.c +++ b/drivers/staging/gasket/apex_driver.c @@ -502,7 +502,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) gasket_log_error(gasket_dev, "DMAs did not quiesce within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } /* - Enable GCB reset (0x1 to rg_rst_gcb) */ @@ -525,7 +525,7 @@ static int apex_enter_reset(struct gasket_dev *gasket_dev, uint type) gasket_dev, "RAM did not shut down within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } return 0; @@ -576,7 +576,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) gasket_dev, "RAM did not enable within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } /* - Wait for Reset complete. */ @@ -588,7 +588,7 @@ static int apex_quit_reset(struct gasket_dev *gasket_dev, uint type) gasket_dev, "GCB did not leave reset within timeout (%d ms)", APEX_RESET_RETRY * APEX_RESET_DELAY); - return -EINVAL; + return -ETIMEDOUT; } if (!allow_hw_clock_gating) { diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 155c69446f0b..6316e6c800ba 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -21,6 +21,7 @@ #include "gasket_page_table.h" #include "gasket_sysfs.h" +#include <linux/delay.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/of.h> @@ -2135,16 +2136,16 @@ EXPORT_SYMBOL(gasket_wait_sync); **/ int gasket_wait_with_reschedule( struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - u64 max_retries, u64 delay_ms) + uint max_retries, u64 delay_ms) { - u64 retries = 0; + uint retries = 0; u64 tmp; while (retries < max_retries) { tmp = gasket_dev_read_64(gasket_dev, bar, offset); if ((tmp & mask) == val) - break; - schedule_timeout(msecs_to_jiffies(delay_ms)); + return 0; + msleep(delay_ms); retries++; } if (retries == max_retries) { @@ -2152,7 +2153,7 @@ int gasket_wait_with_reschedule( gasket_dev, "gasket_wait_with_reschedule timeout: reg %llx timeout (%llu ms)", offset, max_retries * delay_ms); - return -EINVAL; + return -ETIMEDOUT; } return 0; } diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 77d08c1265ca..16bee478dce6 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -714,6 +714,6 @@ int gasket_wait_sync( /* Helper function, Asynchronous waits on a given set of bits. */ int gasket_wait_with_reschedule( struct gasket_dev *gasket_dev, int bar, u64 offset, u64 mask, u64 val, - u64 max_retries, u64 delay_ms); + uint max_retries, u64 delay_ms); #endif /* __GASKET_CORE_H__ */ -- 2.18.0.203.gfac676dfb9-goog _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel