* [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
@ 2025-12-10 13:14 Thorsten Blum
2025-12-12 6:49 ` Jason Gunthorpe
0 siblings, 1 reply; 6+ messages in thread
From: Thorsten Blum @ 2025-12-10 13:14 UTC (permalink / raw)
To: Abhijit Gangurde, Allen Hubbe, Jason Gunthorpe, Leon Romanovsky
Cc: Thorsten Blum, linux-rdma, linux-kernel
Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify
ionic_prep_reg(). No functional changes.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/ionic/ionic_datapath.c b/drivers/infiniband/hw/ionic/ionic_datapath.c
index aa2944887f23..1a1cf82d1745 100644
--- a/drivers/infiniband/hw/ionic/ionic_datapath.c
+++ b/drivers/infiniband/hw/ionic/ionic_datapath.c
@@ -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);
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
2025-12-10 13:14 [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64 Thorsten Blum
@ 2025-12-12 6:49 ` Jason Gunthorpe
2025-12-12 8:24 ` Abhijit Gangurde
0 siblings, 1 reply; 6+ messages in thread
From: Jason Gunthorpe @ 2025-12-12 6:49 UTC (permalink / raw)
To: Thorsten Blum
Cc: Abhijit Gangurde, Allen Hubbe, Leon Romanovsky, linux-rdma,
linux-kernel
On Wed, Dec 10, 2025 at 02:14:29PM +0100, Thorsten Blum wrote:
> Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify
> ionic_prep_reg(). No functional changes.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/ionic/ionic_datapath.c b/drivers/infiniband/hw/ionic/ionic_datapath.c
> index aa2944887f23..1a1cf82d1745 100644
> --- a/drivers/infiniband/hw/ionic/ionic_datapath.c
> +++ b/drivers/infiniband/hw/ionic/ionic_datapath.c
> @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
2025-12-12 6:49 ` Jason Gunthorpe
@ 2025-12-12 8:24 ` Abhijit Gangurde
2025-12-16 0:51 ` Jason Gunthorpe
0 siblings, 1 reply; 6+ messages in thread
From: Abhijit Gangurde @ 2025-12-12 8:24 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Allen Hubbe, Leon Romanovsky, linux-rdma, linux-kernel,
Thorsten Blum
On 12/12/25 12:19, Jason Gunthorpe wrote:
> On Wed, Dec 10, 2025 at 02:14:29PM +0100, Thorsten Blum wrote:
>> Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify
>> ionic_prep_reg(). No functional changes.
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>> drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/hw/ionic/ionic_datapath.c b/drivers/infiniband/hw/ionic/ionic_datapath.c
>> index aa2944887f23..1a1cf82d1745 100644
>> --- a/drivers/infiniband/hw/ionic/ionic_datapath.c
>> +++ b/drivers/infiniband/hw/ionic/ionic_datapath.c
>> @@ -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
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
2025-12-12 8:24 ` Abhijit Gangurde
@ 2025-12-16 0:51 ` Jason Gunthorpe
2025-12-16 12:35 ` Thorsten Blum
0 siblings, 1 reply; 6+ messages in thread
From: Jason Gunthorpe @ 2025-12-16 0:51 UTC (permalink / raw)
To: Abhijit Gangurde
Cc: Allen Hubbe, Leon Romanovsky, linux-rdma, linux-kernel,
Thorsten Blum
On Fri, Dec 12, 2025 at 01:54:17PM +0530, Abhijit Gangurde wrote:
>
> On 12/12/25 12:19, Jason Gunthorpe wrote:
> > On Wed, Dec 10, 2025 at 02:14:29PM +0100, Thorsten Blum wrote:
> > > Replace cpu_to_be64(le64_to_cpu()) with swab64() to simplify
> > > ionic_prep_reg(). No functional changes.
> > >
> > > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > > ---
> > > drivers/infiniband/hw/ionic/ionic_datapath.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/infiniband/hw/ionic/ionic_datapath.c b/drivers/infiniband/hw/ionic/ionic_datapath.c
> > > index aa2944887f23..1a1cf82d1745 100644
> > > --- a/drivers/infiniband/hw/ionic/ionic_datapath.c
> > > +++ b/drivers/infiniband/hw/ionic/ionic_datapath.c
> > > @@ -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??
>
> 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.
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
2025-12-16 0:51 ` Jason Gunthorpe
@ 2025-12-16 12:35 ` Thorsten Blum
2025-12-18 16:09 ` Leon Romanovsky
0 siblings, 1 reply; 6+ messages in thread
From: Thorsten Blum @ 2025-12-16 12:35 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Abhijit Gangurde, Allen Hubbe, Leon Romanovsky, linux-rdma,
linux-kernel
On 16. Dec 2025, at 01:51, Jason Gunthorpe wrote:
> Okay, so Throsten, please don't send patches for changing to swab.
Yeah sorry, I didn't know about the sparse warnings before.
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64
2025-12-16 12:35 ` Thorsten Blum
@ 2025-12-18 16:09 ` Leon Romanovsky
0 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2025-12-18 16:09 UTC (permalink / raw)
To: Thorsten Blum
Cc: Jason Gunthorpe, Abhijit Gangurde, Allen Hubbe, linux-rdma,
linux-kernel
On Tue, Dec 16, 2025 at 01:35:02PM +0100, Thorsten Blum wrote:
> On 16. Dec 2025, at 01:51, Jason Gunthorpe wrote:
> > Okay, so Throsten, please don't send patches for changing to swab.
>
> Yeah sorry, I didn't know about the sparse warnings before.
>
> > 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
>
> Thanks,
> Thorsten
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-18 16:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 13:14 [PATCH] RDMA/ionic: Replace cpu_to_be64 + le64_to_cpu with swab64 Thorsten Blum
2025-12-12 6:49 ` Jason Gunthorpe
2025-12-12 8:24 ` Abhijit Gangurde
2025-12-16 0:51 ` Jason Gunthorpe
2025-12-16 12:35 ` Thorsten Blum
2025-12-18 16:09 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox