From: Timur Tabi <timur@freescale•com>
To: linuxppc-dev@ozlabs•org, benh@kernel•crashing.org,
grant.likely@secretlab•ca, smaclennan@pikatech•com
Subject: [PATCH 2/2] qe: add polling timeout to qe_issue_cmd()
Date: Tue, 19 May 2009 14:26:39 -0500 [thread overview]
Message-ID: <1242761199-17875-3-git-send-email-timur@freescale.com> (raw)
In-Reply-To: <1242761199-17875-2-git-send-email-timur@freescale.com>
The qe_issue_cmd() function (Freescale PowerPC QUICC Engine library) polls on
a register until a status bit changes, but does not include a timeout to
handle the situation if the bit never changes. Change the code to use the new
spin_event_timeout() macro, which simplifies polling on a register without
a timeout.
Signed-off-by: Timur Tabi <timur@freescale•com>
---
This patch depends on my previous patch, "powerpc: introduce macro
spin_event_timeout()".
arch/powerpc/sysdev/qe_lib/qe.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 01bce37..810e1df 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -111,6 +111,7 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
{
unsigned long flags;
u8 mcn_shift = 0, dev_shift = 0;
+ int ret;
spin_lock_irqsave(&qe_lock, flags);
if (cmd == QE_RESET) {
@@ -138,11 +139,13 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
}
/* wait for the QE_CR_FLG to clear */
- while(in_be32(&qe_immr->cp.cecr) & QE_CR_FLG)
- cpu_relax();
+ spin_event_timeout((in_be32(&qe_immr->cp.cecr) & QE_CR_FLG) == 0,
+ 100, 0, ret);
+ /* On timeout (e.g. failure), the expression will be false (ret == 0),
+ otherwise it will be true (ret == 1). */
spin_unlock_irqrestore(&qe_lock, flags);
- return 0;
+ return ret == 1;
}
EXPORT_SYMBOL(qe_issue_cmd);
--
1.6.0.6
next prev parent reply other threads:[~2009-05-19 19:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-19 19:26 [PATCH 0/2] introduce macro spin_event_timeout() Timur Tabi
2009-05-19 19:26 ` [PATCH 1/2 v8] powerpc: " Timur Tabi
2009-05-19 19:26 ` Timur Tabi [this message]
2009-05-19 20:10 ` [PATCH 2/2] qe: add polling timeout to qe_issue_cmd() Grant Likely
2009-05-19 21:09 ` Timur Tabi
2009-05-25 17:46 ` [PATCH 1/2 v8] powerpc: introduce macro spin_event_timeout() Jon Smirl
2009-05-26 3:27 ` Timur Tabi
2009-05-26 16:20 ` Geoff Thorpe
2009-05-26 16:27 ` Jon Smirl
2009-05-26 17:03 ` Timur Tabi
2009-05-26 17:56 ` Jon Smirl
2009-05-26 18:01 ` Timur Tabi
2009-05-26 18:09 ` Geoff Thorpe
2009-05-26 18:17 ` Timur Tabi
2009-05-26 19:04 ` Jon Smirl
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=1242761199-17875-3-git-send-email-timur@freescale.com \
--to=timur@freescale$(echo .)com \
--cc=benh@kernel$(echo .)crashing.org \
--cc=grant.likely@secretlab$(echo .)ca \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=smaclennan@pikatech$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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