RDMA/rxe fixed bug in rxe_requester
Subsystems (2)
PATCH 1/1 RDMA/rxe fixed bug in rxe_requester
The code which limited the number of unacknowledged PSNs was incorrect. The PSNs are limited to 24 bits and wrap back to zero from 0x00ffffff. The test was computing a 32 bit value which wraps at 32 bits so that qp->req.psn can appear smaller than the limit when it is actually larger.
Replace '>' test with psn_compare which is used for other PSN comparisons and correctly handles the 24 bit size.
--- drivers/infiniband/sw/rxe/rxe_req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_req.c +2 -1
@@ -634,7 +634,8 @@ int rxe_requester(void *arg) }if (unlikely (qp_type (qp) ==IB_QPT_RC && - qp->req.psn > (qp->comp.psn +RXE_MAX_UNACKED_PSNS ))) { +psn_compare (qp->req.psn, (qp->comp.psn + +RXE_MAX_UNACKED_PSNS )) >0 )) { qp->req.wait_psn =1 ; goto exit; }
Signature · 1 line
2.25.1
Quoted 1 line · Bob Pearson
Subject: Re: [PATCH for-next] RDMA/rxe fixed bug in
rxe_requester
Missing : and vauge subject, more like:
RDMA/rxe: Compute PSN windows correctly
Quoted 10 lines
The code which limited the number of unacknowledged PSNs was incorrect. The PSNs are limited to 24 bits and wrap back to zero from
0x00ffffff. The test was computing a 32 bit value which wraps at 32 bits so thatqp->req.psncan appear smaller than the limit when it is actually larger.Replace '>' test with
psn_comparewhich is used for other PSN comparisons and correctly handles the 24 bit size.Fixes 8700e3e7c485 ("Soft RoCE (RXE) - The software RoCE driver")Signed-off-by Bob Pearson <[email protected]>
Applied to for-next, thanks
Jason
Quoted 19 lines · Bob Pearson
The code which limited the number of unacknowledged PSNs was incorrect. The PSNs are limited to 24 bits and wrap back to zero from
0x00ffffff. The test was computing a 32 bit value which wraps at 32 bits so thatqp->req.psncan appear smaller than the limit when it is actually larger.Replace '>' test with
psn_comparewhich is used for other PSN comparisons and correctly handles the 24 bit size.Fixes 8700e3e7c485 ("Soft RoCE (RXE) - The software RoCE driver")Signed-off-by Bob Pearson <[email protected]>--- drivers/infiniband/sw/rxe/rxe_req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/infiniband/sw/rxe/rxe_req.c +0
-0
drivers/infiniband/sw/rxe/rxe_req.c int rxe_requester(void *arg) · line 638
Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_req.c +2
-1@@ -634,7 +634,8 @@ int rxe_requester(void *arg) }if (unlikely (qp_type (qp) ==IB_QPT_RC && - qp->req.psn > (qp->comp.psn +RXE_MAX_UNACKED_PSNS ))) { +psn_compare (qp->req.psn, (qp->comp.psn + +RXE_MAX_UNACKED_PSNS )) >0 )) {
qp->comp.psn is u32, so you are checking that qp->comp.psn + RXE_MAX_UNACKED_PSNS != 0, am I right?
Quoted 6 lines
drivers/infiniband/sw/rxe/rxe_req.c +0
-1qp->req.wait_psn =1 ; goto exit; } --2.25.1
Quoted 22 lines · Leon Romanovsky
Quoted 21 lines · Bob Pearson
The code which limited the number of unacknowledged PSNs was incorrect. The PSNs are limited to 24 bits and wrap back to zero from
0x00ffffff. The test was computing a 32 bit value which wraps at 32 bits so thatqp->req.psncan appear smaller than the limit when it is actually larger.Replace '>' test with
psn_comparewhich is used for other PSN comparisons and correctly handles the 24 bit size.Fixes 8700e3e7c485 ("Soft RoCE (RXE) - The software RoCE driver")Signed-off-by Bob Pearson <[email protected]>--- drivers/infiniband/sw/rxe/rxe_req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/infiniband/sw/rxe/rxe_req.c +0
-0@@ -634,7 +634,8 @@ int rxe_requester(void *arg) }
Quoted 13 lines
drivers/infiniband/sw/rxe/rxe_req.c int rxe_requester(void *arg) · line 638
Quoted 4 lines
drivers/infiniband/sw/rxe/rxe_req.c +2
-1if (unlikely (qp_type (qp) ==IB_QPT_RC && - qp->req.psn > (qp->comp.psn +RXE_MAX_UNACKED_PSNS ))) { +psn_compare (qp->req.psn, (qp->comp.psn + +RXE_MAX_UNACKED_PSNS )) >0 )) {
qp->comp.psnis u32, so you are checking thatqp->comp.psn+RXE_MAX_UNACKED_PSNS!= 0, am I right?Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_req.c +0
-1qp->req.wait_psn =1 ; goto exit; } --2.25.1
First, qp->comp.psn is a 24 bit unsigned quantity as is qp->req.psn.
RXE_MAX_UNACKED_PSNS is a reasonably small number e.g. 128 for now.
So qp->comp.psn + RXE_MAX_UNACKED_PSNS which is a 32 bit number never wraps to zero and remains in the range [RXE_MAX_UNACKED_PSNS, RXE_MAX_UNACKED_PSNS + 2^24 -1]. The upper limit will not wrap back zero unless RXE_MAX_UNACKED_PSNS is > 2^32 - 2^24 which would be a grossly unreasonable upper limit. You would have long since run out of memory.
psn_compare(a, b) = (a - b) << 8 and is a signed 32 bit number.
This correctly determines the magnitude and sign of the difference between a and b as long as that difference is less than 2^23.
Bob
Quoted 46 lines · Bob Pearson
Quoted 22 lines · Leon Romanovsky
Quoted 21 lines · Bob Pearson
The code which limited the number of unacknowledged PSNs was incorrect. The PSNs are limited to 24 bits and wrap back to zero from
0x00ffffff. The test was computing a 32 bit value which wraps at 32 bits so thatqp->req.psncan appear smaller than the limit when it is actually larger.Replace '>' test with
psn_comparewhich is used for other PSN comparisons and correctly handles the 24 bit size.Fixes 8700e3e7c485 ("Soft RoCE (RXE) - The software RoCE driver")Signed-off-by Bob Pearson <[email protected]>--- drivers/infiniband/sw/rxe/rxe_req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/infiniband/sw/rxe/rxe_req.c +0
-0@@ -634,7 +634,8 @@ int rxe_requester(void *arg) }Quoted 13 lines
drivers/infiniband/sw/rxe/rxe_req.c int rxe_requester(void *arg) · line 638
Quoted 4 lines
drivers/infiniband/sw/rxe/rxe_req.c +2
-1if (unlikely (qp_type (qp) ==IB_QPT_RC && - qp->req.psn > (qp->comp.psn +RXE_MAX_UNACKED_PSNS ))) { +psn_compare (qp->req.psn, (qp->comp.psn + +RXE_MAX_UNACKED_PSNS )) >0 )) {
qp->comp.psnis u32, so you are checking thatqp->comp.psn+RXE_MAX_UNACKED_PSNS!= 0, am I right?Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_req.c +0
-1qp->req.wait_psn =1 ; goto exit; } --2.25.1
First,
qp->comp.psnis a 24 bit unsigned quantity as isqp->req.psn.
RXE_MAX_UNACKED_PSNSis a reasonably small number e.g. 128 for now.So
qp->comp.psn+RXE_MAX_UNACKED_PSNSwhich is a 32 bit number never wraps to zero and remains in the range [RXE_MAX_UNACKED_PSNS,RXE_MAX_UNACKED_PSNS+ 2^24 -1]. The upper limit will not wrap back zero unlessRXE_MAX_UNACKED_PSNSis > 2^32 - 2^24 which would be a grossly unreasonable upper limit. You would have long since run out of memory.
Quoted 4 lines
psn_compare(a, b)= (a - b) << 8 and is a signed 32 bit number.This correctly determines the magnitude and sign of the difference between a and b as long as that difference is less than 2^23.
Ohh, I see what confused me, missed extra ")".
Thanks
Quoted 2 lines
Bob