From: Todd Poynor <toddpoynor@gmail.com>
To: Rob Springer <rspringer@google.com>,
John Joseph <jnjoseph@google.com>,
Ben Chan <benchan@chromium.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Zhongze Hu <frankhu@chromium.org>, Simon Que <sque@chromium.org>,
Dmitry Torokhov <dtor@chromium.org>,
Guenter Roeck <groeck@chromium.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
Todd Poynor <toddpoynor@google.com>
Subject: [PATCH 08/18] staging: gasket: gasket_wait_with_reschedule fixups
Date: Fri, 13 Jul 2018 22:58:06 -0700 [thread overview]
Message-ID: <20180714055816.223754-9-toddpoynor@gmail.com> (raw)
In-Reply-To: <20180714055816.223754-1-toddpoynor@gmail.com>
From: Todd Poynor <toddpoynor@google.com>
Return -ETIMEDOUT on timeouts.
Don't need 64-bit sized retry count.
Use msleep().
Return immediately when condition hit.
Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Zhongze Hu <frankhu@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
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
next prev parent reply other threads:[~2018-07-14 5:59 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-14 5:57 [PATCH 00/18] staging: gasket: sundry fixes and fixups Todd Poynor
2018-07-14 5:57 ` [PATCH 01/18] staging: gasket: remove X86 Kconfig restriction Todd Poynor
2018-07-14 5:58 ` [PATCH 02/18] MAINTAINERS: Add maintainer for drivers/staging/gasket Todd Poynor
2018-07-14 6:28 ` Greg Kroah-Hartman
2018-07-14 5:58 ` [PATCH 03/18] staging: gasket: typo and whitespace cleanups Todd Poynor
2018-07-14 6:31 ` Greg Kroah-Hartman
2018-07-14 5:58 ` [PATCH 04/18] staging: gasket: device registration error and unregister fixups Todd Poynor
2018-07-16 13:53 ` Dan Carpenter
2018-07-16 21:15 ` Todd Poynor
2018-07-14 5:58 ` [PATCH 05/18] staging: gasket: sysfs mapping creation fixups Todd Poynor
2018-07-14 6:32 ` Greg Kroah-Hartman
2018-07-16 21:14 ` Todd Poynor
2018-07-17 6:55 ` Greg Kroah-Hartman
2018-07-14 5:58 ` [PATCH 06/18] staging: gasket: fix deadlock in pci driver unregister path Todd Poynor
2018-07-14 6:36 ` Greg Kroah-Hartman
2018-07-14 8:07 ` Dmitry Torokhov
2018-07-14 12:57 ` Greg Kroah-Hartman
2018-07-16 21:16 ` Todd Poynor
2018-07-14 5:58 ` [PATCH 07/18] staging: gasket: convert gasket_mmap_has_permissions to bool return Todd Poynor
2018-07-14 5:58 ` Todd Poynor [this message]
2018-07-14 6:33 ` [PATCH 08/18] staging: gasket: gasket_wait_with_reschedule fixups Greg Kroah-Hartman
2018-07-14 5:58 ` [PATCH 09/18] staging: gasket: bail out of reset sequence on device callback error Todd Poynor
2018-07-14 5:58 ` [PATCH 10/18] staging: gasket: gasket_open use container_of() Todd Poynor
2018-07-14 8:15 ` Dmitry Torokhov
2018-07-16 21:18 ` Todd Poynor
2018-07-14 5:58 ` [PATCH 11/18] staging: gasket: always allow root open for write Todd Poynor
2018-07-14 8:25 ` Dmitry Torokhov
2018-07-16 21:22 ` Todd Poynor
2018-07-15 9:05 ` Greg Kroah-Hartman
2018-07-15 9:11 ` Dmitry Torokhov
2018-07-15 9:32 ` Greg Kroah-Hartman
2018-07-15 9:53 ` Dmitry Torokhov
2018-07-15 10:03 ` Greg Kroah-Hartman
2018-07-15 18:15 ` Todd Poynor
2018-07-15 19:41 ` Greg Kroah-Hartman
2018-07-16 21:26 ` Todd Poynor
2018-07-14 5:58 ` [PATCH 12/18] staging: gasket: annotate ioctl arg with __user Todd Poynor
2018-07-14 6:35 ` Greg Kroah-Hartman
[not found] ` <CAO3upobyf9JpKLSoSPeVfNGOh6R0cud=hT+bhA=U2kNkGEJ-aw@mail.gmail.com>
2018-07-14 7:44 ` Greg Kroah-Hartman
2018-07-14 19:20 ` Todd Poynor
2018-07-15 9:00 ` Greg Kroah-Hartman
2018-07-15 17:38 ` Todd Poynor
2018-07-14 5:58 ` [PATCH 13/18] staging: gasket: gasket_enable_dev fixups Todd Poynor
2018-07-14 6:39 ` Greg Kroah-Hartman
2018-07-16 21:28 ` Todd Poynor
2018-07-14 5:58 ` [PATCH 14/18] staging: gasket: fix class create bug handling Todd Poynor
2018-07-14 8:16 ` Dmitry Torokhov
2018-07-14 5:58 ` [PATCH 15/18] staging: gasket: remove unnecessary code in coherent allocator Todd Poynor
2018-07-14 5:58 ` [PATCH 16/18] staging: gasket: gasket core error handling fixups Todd Poynor
2018-07-14 5:58 ` [PATCH 17/18] staging: gasket: don't release coherent mappings Todd Poynor
2018-07-14 5:58 ` [PATCH 18/18] staging: gasket: various cleanups Todd Poynor
2018-07-14 6:30 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180714055816.223754-9-toddpoynor@gmail.com \
--to=toddpoynor@gmail.com \
--cc=benchan@chromium.org \
--cc=devel@driverdev.osuosl.org \
--cc=dtor@chromium.org \
--cc=frankhu@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=jnjoseph@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rspringer@google.com \
--cc=sque@chromium.org \
--cc=toddpoynor@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome