* [PATCH] ipath: use time_before()/_after()
@ 2014-05-25 13:26 Manuel Schölling
2014-05-25 14:17 ` Dongsheng Yang
0 siblings, 1 reply; 3+ messages in thread
From: Manuel Schölling @ 2014-05-25 13:26 UTC (permalink / raw)
To: infinipath
Cc: roland, sean.hefty, hal.rosenstock, linux-rdma, linux-kernel,
kernel-janitors, Manuel Schölling
To be future-proof and for better readability the time comparisons are
modified to use time_before/_after() instead of plain, error-prone math.
Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
---
drivers/infiniband/hw/ipath/ipath_intr.c | 4 ++--
drivers/infiniband/hw/ipath/ipath_sdma.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index 26dfbc8..01ba792 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -70,7 +70,7 @@ void ipath_disarm_senderrbufs(struct ipath_devdata *dd)
if (sbuf[0] || sbuf[1] || (piobcnt > 128 && (sbuf[2] || sbuf[3]))) {
int i;
if (ipath_debug & (__IPATH_PKTDBG|__IPATH_DBG) &&
- dd->ipath_lastcancel > jiffies) {
+ time_after(dd->ipath_lastcancel, jiffies)) {
__IPATH_DBG_WHICH(__IPATH_PKTDBG|__IPATH_DBG,
"SendbufErrs %lx %lx", sbuf[0],
sbuf[1]);
@@ -755,7 +755,7 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
/* likely due to cancel; so suppress message unless verbose */
if ((errs & (INFINIPATH_E_SPKTLEN | INFINIPATH_E_SPIOARMLAUNCH)) &&
- dd->ipath_lastcancel > jiffies) {
+ time_after(dd->ipath_lastcancel, jiffies)) {
/* armlaunch takes precedence; it often causes both. */
ipath_cdbg(VERBOSE,
"Suppressed %s error (%llx) after sendbuf cancel\n",
diff --git a/drivers/infiniband/hw/ipath/ipath_sdma.c b/drivers/infiniband/hw/ipath/ipath_sdma.c
index 98ac18e..17a5177 100644
--- a/drivers/infiniband/hw/ipath/ipath_sdma.c
+++ b/drivers/infiniband/hw/ipath/ipath_sdma.c
@@ -247,7 +247,7 @@ static void sdma_abort_task(unsigned long opaque)
/* ipath_sdma_abort() is done, waiting for interrupt */
if (status = IPATH_SDMA_ABORT_DISARMED) {
- if (jiffies < dd->ipath_sdma_abort_intr_timeout)
+ if (time_before(jiffies, dd->ipath_sdma_abort_intr_timeout))
goto resched_noprint;
/* give up, intr got lost somewhere */
ipath_dbg("give up waiting for SDMADISABLED intr\n");
@@ -341,7 +341,7 @@ resched:
* JAG - this is bad to just have default be a loop without
* state change
*/
- if (jiffies > dd->ipath_sdma_abort_jiffies) {
+ if (time_after(jiffies, dd->ipath_sdma_abort_jiffies)) {
ipath_dbg("looping with status 0x%08lx\n",
dd->ipath_sdma_status);
dd->ipath_sdma_abort_jiffies = jiffies + 5 * HZ;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ipath: use time_before()/_after()
2014-05-25 13:26 [PATCH] ipath: use time_before()/_after() Manuel Schölling
@ 2014-05-25 14:17 ` Dongsheng Yang
2014-05-25 17:29 ` Manuel Schoelling
0 siblings, 1 reply; 3+ messages in thread
From: Dongsheng Yang @ 2014-05-25 14:17 UTC (permalink / raw)
To: Manuel Schölling
Cc: infinipath, roland, sean.hefty, hal.rosenstock, linux-rdma,
linux-kernel, kernel-janitors
On Sun, May 25, 2014 at 9:26 PM, Manuel Schölling
<manuel.schoelling@gmx.de> wrote:
> To be future-proof and for better readability the time comparisons are
> modified to use time_before/_after() instead of plain, error-prone math.
>
> Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
> ---
> drivers/infiniband/hw/ipath/ipath_intr.c | 4 ++--
> drivers/infiniband/hw/ipath/ipath_sdma.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
> index 26dfbc8..01ba792 100644
> --- a/drivers/infiniband/hw/ipath/ipath_intr.c
> +++ b/drivers/infiniband/hw/ipath/ipath_intr.c
> @@ -70,7 +70,7 @@ void ipath_disarm_senderrbufs(struct ipath_devdata *dd)
> if (sbuf[0] || sbuf[1] || (piobcnt > 128 && (sbuf[2] || sbuf[3]))) {
> int i;
> if (ipath_debug & (__IPATH_PKTDBG|__IPATH_DBG) &&
> - dd->ipath_lastcancel > jiffies) {
> + time_after(dd->ipath_lastcancel, jiffies)) {
Why not time_is_after_jiffies()?
> __IPATH_DBG_WHICH(__IPATH_PKTDBG|__IPATH_DBG,
> "SendbufErrs %lx %lx", sbuf[0],
> sbuf[1]);
> @@ -755,7 +755,7 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
>
> /* likely due to cancel; so suppress message unless verbose */
> if ((errs & (INFINIPATH_E_SPKTLEN | INFINIPATH_E_SPIOARMLAUNCH)) &&
> - dd->ipath_lastcancel > jiffies) {
> + time_after(dd->ipath_lastcancel, jiffies)) {
> /* armlaunch takes precedence; it often causes both. */
> ipath_cdbg(VERBOSE,
> "Suppressed %s error (%llx) after sendbuf cancel\n",
> diff --git a/drivers/infiniband/hw/ipath/ipath_sdma.c b/drivers/infiniband/hw/ipath/ipath_sdma.c
> index 98ac18e..17a5177 100644
> --- a/drivers/infiniband/hw/ipath/ipath_sdma.c
> +++ b/drivers/infiniband/hw/ipath/ipath_sdma.c
> @@ -247,7 +247,7 @@ static void sdma_abort_task(unsigned long opaque)
>
> /* ipath_sdma_abort() is done, waiting for interrupt */
> if (status = IPATH_SDMA_ABORT_DISARMED) {
> - if (jiffies < dd->ipath_sdma_abort_intr_timeout)
> + if (time_before(jiffies, dd->ipath_sdma_abort_intr_timeout))
> goto resched_noprint;
> /* give up, intr got lost somewhere */
> ipath_dbg("give up waiting for SDMADISABLED intr\n");
> @@ -341,7 +341,7 @@ resched:
> * JAG - this is bad to just have default be a loop without
> * state change
> */
> - if (jiffies > dd->ipath_sdma_abort_jiffies) {
> + if (time_after(jiffies, dd->ipath_sdma_abort_jiffies)) {
> ipath_dbg("looping with status 0x%08lx\n",
> dd->ipath_sdma_status);
> dd->ipath_sdma_abort_jiffies = jiffies + 5 * HZ;
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ipath: use time_before()/_after()
2014-05-25 14:17 ` Dongsheng Yang
@ 2014-05-25 17:29 ` Manuel Schoelling
0 siblings, 0 replies; 3+ messages in thread
From: Manuel Schoelling @ 2014-05-25 17:29 UTC (permalink / raw)
To: Dongsheng Yang
Cc: infinipath, roland, sean.hefty, hal.rosenstock, linux-rdma,
linux-kernel, kernel-janitors
On So, 2014-05-25 at 22:17 +0800, Dongsheng Yang wrote:
> On Sun, May 25, 2014 at 9:26 PM, Manuel Schölling
> <manuel.schoelling@gmx.de> wrote:
> > To be future-proof and for better readability the time comparisons are
> > modified to use time_before/_after() instead of plain, error-prone math.
> >
> > Signed-off-by: Manuel Schölling <manuel.schoelling@gmx.de>
> > ---
> > drivers/infiniband/hw/ipath/ipath_intr.c | 4 ++--
> > drivers/infiniband/hw/ipath/ipath_sdma.c | 4 ++--
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
> > index 26dfbc8..01ba792 100644
> > --- a/drivers/infiniband/hw/ipath/ipath_intr.c
> > +++ b/drivers/infiniband/hw/ipath/ipath_intr.c
> > @@ -70,7 +70,7 @@ void ipath_disarm_senderrbufs(struct ipath_devdata *dd)
> > if (sbuf[0] || sbuf[1] || (piobcnt > 128 && (sbuf[2] || sbuf[3]))) {
> > int i;
> > if (ipath_debug & (__IPATH_PKTDBG|__IPATH_DBG) &&
> > - dd->ipath_lastcancel > jiffies) {
> > + time_after(dd->ipath_lastcancel, jiffies)) {
>
> Why not time_is_after_jiffies()?
According to Joe Perches [1], time_after() is used much more often than
time_is_after_jiffies() and should be preferred.
[1] http://www.spinics.net/lists/netdev/msg283219.html
>
> > __IPATH_DBG_WHICH(__IPATH_PKTDBG|__IPATH_DBG,
> > "SendbufErrs %lx %lx", sbuf[0],
> > sbuf[1]);
> > @@ -755,7 +755,7 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
> >
> > /* likely due to cancel; so suppress message unless verbose */
> > if ((errs & (INFINIPATH_E_SPKTLEN | INFINIPATH_E_SPIOARMLAUNCH)) &&
> > - dd->ipath_lastcancel > jiffies) {
> > + time_after(dd->ipath_lastcancel, jiffies)) {
> > /* armlaunch takes precedence; it often causes both. */
> > ipath_cdbg(VERBOSE,
> > "Suppressed %s error (%llx) after sendbuf cancel\n",
> > diff --git a/drivers/infiniband/hw/ipath/ipath_sdma.c b/drivers/infiniband/hw/ipath/ipath_sdma.c
> > index 98ac18e..17a5177 100644
> > --- a/drivers/infiniband/hw/ipath/ipath_sdma.c
> > +++ b/drivers/infiniband/hw/ipath/ipath_sdma.c
> > @@ -247,7 +247,7 @@ static void sdma_abort_task(unsigned long opaque)
> >
> > /* ipath_sdma_abort() is done, waiting for interrupt */
> > if (status = IPATH_SDMA_ABORT_DISARMED) {
> > - if (jiffies < dd->ipath_sdma_abort_intr_timeout)
> > + if (time_before(jiffies, dd->ipath_sdma_abort_intr_timeout))
> > goto resched_noprint;
> > /* give up, intr got lost somewhere */
> > ipath_dbg("give up waiting for SDMADISABLED intr\n");
> > @@ -341,7 +341,7 @@ resched:
> > * JAG - this is bad to just have default be a loop without
> > * state change
> > */
> > - if (jiffies > dd->ipath_sdma_abort_jiffies) {
> > + if (time_after(jiffies, dd->ipath_sdma_abort_jiffies)) {
> > ipath_dbg("looping with status 0x%08lx\n",
> > dd->ipath_sdma_status);
> > dd->ipath_sdma_abort_jiffies = jiffies + 5 * HZ;
> > --
> > 1.7.10.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-25 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-25 13:26 [PATCH] ipath: use time_before()/_after() Manuel Schölling
2014-05-25 14:17 ` Dongsheng Yang
2014-05-25 17:29 ` Manuel Schoelling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox