[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191028200700.213753-9-bvanassche@acm.org>
Date: Mon, 28 Oct 2019 13:06:59 -0700
From: Bart Van Assche <bvanassche@....org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Christoph Hellwig <hch@....de>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org,
Bart Van Assche <bvanassche@....org>,
Dennis Dalessandro <dennis.dalessandro@...el.com>,
Mike Marciniszyn <mike.marciniszyn@...el.com>,
Jason Gunthorpe <jgg@...lanox.com>,
Doug Ledford <dledford@...hat.com>
Subject: [PATCH 8/9] IB/qib: Sign extend without triggering implementation-defined behavior
>From the C standard: "The result of E1 >> E2 is E1 right-shifted E2 bit
positions. If E1 has an unsigned type or if E1 has a signed type and a
nonnegative value, the value of the result is the integral part of the
quotient of E1 / 2E2 . If E1 has a signed type and a negative value, the
resulting value is implementation-defined."
Hence use sign_extend_24_to_32() instead of "<< 8 >> 8".
Cc: Dennis Dalessandro <dennis.dalessandro@...el.com>
Cc: Mike Marciniszyn <mike.marciniszyn@...el.com>
Cc: Jason Gunthorpe <jgg@...lanox.com>
Cc: Doug Ledford <dledford@...hat.com>
Signed-off-by: Bart Van Assche <bvanassche@....org>
---
drivers/infiniband/hw/qib/qib_rc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/qib/qib_rc.c b/drivers/infiniband/hw/qib/qib_rc.c
index aaf7438258fa..2f1beaab6935 100644
--- a/drivers/infiniband/hw/qib/qib_rc.c
+++ b/drivers/infiniband/hw/qib/qib_rc.c
@@ -566,7 +566,7 @@ int qib_make_rc_req(struct rvt_qp *qp, unsigned long *flags)
break;
}
qp->s_sending_hpsn = bth2;
- delta = (((int) bth2 - (int) wqe->psn) << 8) >> 8;
+ delta = sign_extend_24_to_32(bth2 - wqe->psn);
if (delta && delta % QIB_PSN_CREDIT == 0)
bth2 |= IB_BTH_REQ_ACK;
if (qp->s_flags & RVT_S_SEND_ONE) {
--
2.24.0.rc0.303.g954a862665-goog
Powered by blists - more mailing lists