RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
Subsystems (2)
PATCH 1/1 RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify ionic_prep_reg(). No functional changes.
--- drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ionic/ionic_datapath.c +1 -1
@@ -1105,7 +1105,7 @@ static int ionic_prep_reg(struct ionic_qp *qp, wqe->reg_mr.length =cpu_to_be64 (mr->ibmr.length); wqe->reg_mr.offset =ionic_pgtbl_off (&mr->buf, mr->ibmr.iova); dma_addr =ionic_pgtbl_dma (&mr->buf, mr->ibmr.iova); - wqe->reg_mr.dma_addr =cpu_to_be64 (le64_to_cpu (dma_addr)); + wqe->reg_mr.dma_addr =swab64 (dma_addr); wqe->reg_mr.map_count =cpu_to_be32 (mr->buf.tbl_pages); wqe->reg_mr.flags =cpu_to_be16 (flags);
Signature · 2 lines
Thorsten Blum <[email protected]> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
Quoted 13 lines · Thorsten Blum
Replace cpu_to_be64(le64_to_cpu()) with
swab64()to simplifyionic_prep_reg(). No functional changes.Signed-off-by Thorsten Blum <[email protected]>--- drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ionic/ionic_datapath.c +0
-0
drivers/infiniband/hw/ionic/ionic_datapath.c static int ionic_prep_reg(struct ionic_qp *qp, · line 1108
Quoted 5 lines
drivers/infiniband/hw/ionic/ionic_datapath.c +1
-1@@ -1105,7 +1105,7 @@ static int ionic_prep_reg(struct ionic_qp *qp, wqe->reg_mr.length =cpu_to_be64 (mr->ibmr.length); wqe->reg_mr.offset =ionic_pgtbl_off (&mr->buf, mr->ibmr.iova); dma_addr =ionic_pgtbl_dma (&mr->buf, mr->ibmr.iova); - wqe->reg_mr.dma_addr =cpu_to_be64 (le64_to_cpu (dma_addr)); + wqe->reg_mr.dma_addr =swab64 (dma_addr);
This doesn't make any sense to me. The original code looks wrong and would fail sparse, switching to swab just highlights how nonsense it is, there is no way that is right on BE and LE.
Pensando guys what is the right thing to do here??
Jason
Abhijit Gangurde
maintainerQuoted 23 lines · Jason Gunthorpe
Quoted 13 lines · Thorsten Blum
Replace cpu_to_be64(le64_to_cpu()) with
swab64()to simplifyionic_prep_reg(). No functional changes.Signed-off-by Thorsten Blum <[email protected]>--- drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ionic/ionic_datapath.c +0
-0drivers/infiniband/hw/ionic/ionic_datapath.c static int ionic_prep_reg(struct ionic_qp *qp, · line 1108
Quoted 5 lines
drivers/infiniband/hw/ionic/ionic_datapath.c +1
-1@@ -1105,7 +1105,7 @@ static int ionic_prep_reg(struct ionic_qp *qp, wqe->reg_mr.length =cpu_to_be64 (mr->ibmr.length); wqe->reg_mr.offset =ionic_pgtbl_off (&mr->buf, mr->ibmr.iova); dma_addr =ionic_pgtbl_dma (&mr->buf, mr->ibmr.iova); - wqe->reg_mr.dma_addr =cpu_to_be64 (le64_to_cpu (dma_addr)); + wqe->reg_mr.dma_addr =swab64 (dma_addr);This doesn't make any sense to me. The original code looks wrong and would fail sparse, switching to swab just highlights how nonsense it is, there is no way that is right on BE and LE.
Quoted 3 lines
Pensando guys what is the right thing to do here??
Jason
The original code does not have sparse failure. ionic_pgtbl_dma() is returning __le64, which is what swapped to __be64 for wqe->reg_me.dma_addr. However the proposed fix is definitely going to throw sparse warning.
Thanks,
Abhijit
Quoted 25 lines · Abhijit Gangurde
Quoted 23 lines · Jason Gunthorpe
Quoted 13 lines · Thorsten Blum
Replace cpu_to_be64(le64_to_cpu()) with
swab64()to simplifyionic_prep_reg(). No functional changes.Signed-off-by Thorsten Blum <[email protected]>--- drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ionic/ionic_datapath.c +0
-0drivers/infiniband/hw/ionic/ionic_datapath.c static int ionic_prep_reg(struct ionic_qp *qp, · line 1108
Quoted 5 lines
drivers/infiniband/hw/ionic/ionic_datapath.c +1
-1@@ -1105,7 +1105,7 @@ static int ionic_prep_reg(struct ionic_qp *qp, wqe->reg_mr.length =cpu_to_be64 (mr->ibmr.length); wqe->reg_mr.offset =ionic_pgtbl_off (&mr->buf, mr->ibmr.iova); dma_addr =ionic_pgtbl_dma (&mr->buf, mr->ibmr.iova); - wqe->reg_mr.dma_addr =cpu_to_be64 (le64_to_cpu (dma_addr)); + wqe->reg_mr.dma_addr =swab64 (dma_addr);This doesn't make any sense to me. The original code looks wrong and would fail sparse, switching to swab just highlights how nonsense it is, there is no way that is right on BE and LE.
Quoted 5 lines
Quoted 1 line
Pensando guys what is the right thing to do here??
The original code does not have sparse failure.
ionic_pgtbl_dma()is returning__le64, which is what swapped to__be64forwqe->reg_me.dma_addr. However the proposed fix is definitely going to throw sparse warning.
Okay, so Throsten, please don't send patches for changing to swab.
If you want to improve it then the primitive should be
le64_to_be64(x)
(and maybe vice versa) With proper sparse annotations.
Jason
Quoted 1 line · Jason Gunthorpe
Okay, so Throsten, please don't send patches for changing to swab.
Yeah sorry, I didn't know about the sparse warnings before.
Quoted 3 lines
If you want to improve it then the primitive should be
le64_to_be64(x)
le64_to_be64() or a similar helper doesn't seem to exist.
Thanks,
Thorsten
Quoted 10 lines · Thorsten Blum
Quoted 1 line · Jason Gunthorpe
Okay, so Throsten, please don't send patches for changing to swab.
Yeah sorry, I didn't know about the sparse warnings before.
Quoted 3 lines
If you want to improve it then the primitive should be
le64_to_be64(x)
le64_to_be64()or a similar helper doesn't seem to exist.
You can add it.
Thanks
Quoted 4 lines
Thanks,
Thorsten