linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
@ 2020-06-10 17:47 Tom Seewald
  2020-06-10 17:50 ` Jason Gunthorpe
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Tom Seewald @ 2020-06-10 17:47 UTC (permalink / raw)
  To: linux-rdma; +Cc: tseewald, Bernard Metzler, Doug Ledford, Jason Gunthorpe

The variable buf_addr is type dma_addr_t, which may not be the same size
as a pointer.  To ensure it is the correct size, cast to a uintptr_t.

Signed-off-by: Tom Seewald <tseewald@gmail.com>
---
 drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
index 650520244ed0..7271d705f4b0 100644
--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
@@ -139,7 +139,8 @@ static int siw_rx_pbl(struct siw_rx_stream *srx, int *pbl_idx,
 			break;
 
 		bytes = min(bytes, len);
-		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
+		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
+		    bytes) {
 			copied += bytes;
 			offset += bytes;
 			len -= bytes;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-10 17:47 [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl() Tom Seewald
@ 2020-06-10 17:50 ` Jason Gunthorpe
  2020-06-10 18:21   ` Tom Seewald
  2020-06-11 10:21 ` Bernard Metzler
  2020-06-16 14:03 ` Jason Gunthorpe
  2 siblings, 1 reply; 11+ messages in thread
From: Jason Gunthorpe @ 2020-06-10 17:50 UTC (permalink / raw)
  To: Tom Seewald; +Cc: linux-rdma, Bernard Metzler, Doug Ledford

On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
> The variable buf_addr is type dma_addr_t, which may not be the same size
> as a pointer.  To ensure it is the correct size, cast to a uintptr_t.
> 
> Signed-off-by: Tom Seewald <tseewald@gmail.com>
>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
> index 650520244ed0..7271d705f4b0 100644
> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
> @@ -139,7 +139,8 @@ static int siw_rx_pbl(struct siw_rx_stream *srx, int *pbl_idx,
>  			break;
>  
>  		bytes = min(bytes, len);
> -		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
> +		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
> +		    bytes) {

How is a dma_addr_t being cast to a void *? That can't be right?
Bernard??

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-10 17:50 ` Jason Gunthorpe
@ 2020-06-10 18:21   ` Tom Seewald
  0 siblings, 0 replies; 11+ messages in thread
From: Tom Seewald @ 2020-06-10 18:21 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: linux-rdma, Bernard Metzler, Doug Ledford

On Wed, Jun 10, 2020 at 12:50 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
> How is a dma_addr_t being cast to a void *? That can't be right?
> Bernard??

I was also confused about that, as I couldn't tell how/if it is able
to guarantee the bus address is the same as the cpu address. I just
assumed it was my lack of familiarity with the codebase.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-10 17:47 [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl() Tom Seewald
  2020-06-10 17:50 ` Jason Gunthorpe
@ 2020-06-11 10:21 ` Bernard Metzler
  2020-06-11 11:35   ` Jason Gunthorpe
  2020-06-11 14:11   ` Bernard Metzler
  2020-06-16 14:03 ` Jason Gunthorpe
  2 siblings, 2 replies; 11+ messages in thread
From: Bernard Metzler @ 2020-06-11 10:21 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Tom Seewald, linux-rdma, Doug Ledford

-----"Jason Gunthorpe" <jgg@ziepe.ca> wrote: -----

>To: "Tom Seewald" <tseewald@gmail.com>
>From: "Jason Gunthorpe" <jgg@ziepe.ca>
>Date: 06/10/2020 07:50PM
>Cc: linux-rdma@vger.kernel.org, "Bernard Metzler"
><bmt@zurich.ibm.com>, "Doug Ledford" <dledford@redhat.com>
>Subject: [EXTERNAL] Re: [PATCH next] siw: Fix pointer-to-int-cast
>warning in siw_rx_pbl()
>
>On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
>> The variable buf_addr is type dma_addr_t, which may not be the same
>size
>> as a pointer.  To ensure it is the correct size, cast to a
>uintptr_t.
>> 
>> Signed-off-by: Tom Seewald <tseewald@gmail.com>
>>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
>b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> index 650520244ed0..7271d705f4b0 100644
>> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> @@ -139,7 +139,8 @@ static int siw_rx_pbl(struct siw_rx_stream
>*srx, int *pbl_idx,
>>  			break;
>>  
>>  		bytes = min(bytes, len);
>> -		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
>> +		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
>> +		    bytes) {
>
>How is a dma_addr_t being cast to a void *? That can't be right?
>Bernard??
>
>Jason
>
Hi Tom, Hi Jason,

Thanks for looking into that.

siw_rx_kva() calls skb_copy_bits() to move data to its
kernel clients destination.  It expects a void * target
address. This is why I chose it for siw_rx_kva() as well.
One could say siw_rx_kva() should better get an uintptr_t
as target argument, which would probably make it look
more clean. And we rename it to siw_rx_kbuf(), and we
cast from uintptr_t to (void *) just for
 skb_copy_bits(skb *, off, (void *)dest, len)

This would avoid all those nasty (void *) casting at all (!)
the places we are calling siw_rx_kva().

Makes sense?

Thanks,
Bernard.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-11 10:21 ` Bernard Metzler
@ 2020-06-11 11:35   ` Jason Gunthorpe
  2020-06-11 14:11   ` Bernard Metzler
  1 sibling, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2020-06-11 11:35 UTC (permalink / raw)
  To: Bernard Metzler; +Cc: Tom Seewald, linux-rdma, Doug Ledford

On Thu, Jun 11, 2020 at 10:21:49AM +0000, Bernard Metzler wrote:
> 
> >To: "Tom Seewald" <tseewald@gmail.com>
> >From: "Jason Gunthorpe" <jgg@ziepe.ca>
> >Date: 06/10/2020 07:50PM
> >Cc: linux-rdma@vger.kernel.org, "Bernard Metzler"
> ><bmt@zurich.ibm.com>, "Doug Ledford" <dledford@redhat.com>
> >Subject: [EXTERNAL] Re: [PATCH next] siw: Fix pointer-to-int-cast
> >warning in siw_rx_pbl()
> >
> >On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
> >> The variable buf_addr is type dma_addr_t, which may not be the same
> >size
> >> as a pointer.  To ensure it is the correct size, cast to a
> >uintptr_t.
> >> 
> >> Signed-off-by: Tom Seewald <tseewald@gmail.com>
> >>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
> >b/drivers/infiniband/sw/siw/siw_qp_rx.c
> >> index 650520244ed0..7271d705f4b0 100644
> >> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
> >> @@ -139,7 +139,8 @@ static int siw_rx_pbl(struct siw_rx_stream
> >*srx, int *pbl_idx,
> >>  			break;
> >>  
> >>  		bytes = min(bytes, len);
> >> -		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
> >> +		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
> >> +		    bytes) {
> >
> >How is a dma_addr_t being cast to a void *? That can't be right?
> >Bernard??
> >
> >Jason
> >
> Hi Tom, Hi Jason,
> 
> Thanks for looking into that.
> 
> siw_rx_kva() calls skb_copy_bits() to move data to its
> kernel clients destination.  It expects a void * target
> address. This is why I chose it for siw_rx_kva() as well.
> One could say siw_rx_kva() should better get an uintptr_t
> as target argument, which would probably make it look
> more clean. And we rename it to siw_rx_kbuf(), and we
> cast from uintptr_t to (void *) just for
>  skb_copy_bits(skb *, off, (void *)dest, len)
> 
> This would avoid all those nasty (void *) casting at all (!)
> the places we are calling siw_rx_kva().

But where did the dma_addr_t come from?

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-11 10:21 ` Bernard Metzler
  2020-06-11 11:35   ` Jason Gunthorpe
@ 2020-06-11 14:11   ` Bernard Metzler
  2020-06-11 14:23     ` Jason Gunthorpe
  2020-06-11 15:06     ` Bernard Metzler
  1 sibling, 2 replies; 11+ messages in thread
From: Bernard Metzler @ 2020-06-11 14:11 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Tom Seewald, linux-rdma, Doug Ledford

-----"Jason Gunthorpe" <jgg@ziepe.ca> wrote: -----

>To: "Bernard Metzler" <BMT@zurich.ibm.com>
>From: "Jason Gunthorpe" <jgg@ziepe.ca>
>Date: 06/11/2020 01:35PM
>Cc: "Tom Seewald" <tseewald@gmail.com>, linux-rdma@vger.kernel.org,
>"Doug Ledford" <dledford@redhat.com>
>Subject: [EXTERNAL] Re: Re: [PATCH next] siw: Fix pointer-to-int-cast
>warning in siw_rx_pbl()
>
>On Thu, Jun 11, 2020 at 10:21:49AM +0000, Bernard Metzler wrote:
>> 
>> >To: "Tom Seewald" <tseewald@gmail.com>
>> >From: "Jason Gunthorpe" <jgg@ziepe.ca>
>> >Date: 06/10/2020 07:50PM
>> >Cc: linux-rdma@vger.kernel.org, "Bernard Metzler"
>> ><bmt@zurich.ibm.com>, "Doug Ledford" <dledford@redhat.com>
>> >Subject: [EXTERNAL] Re: [PATCH next] siw: Fix pointer-to-int-cast
>> >warning in siw_rx_pbl()
>> >
>> >On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
>> >> The variable buf_addr is type dma_addr_t, which may not be the
>same
>> >size
>> >> as a pointer.  To ensure it is the correct size, cast to a
>> >uintptr_t.
>> >> 
>> >> Signed-off-by: Tom Seewald <tseewald@gmail.com>
>> >>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
>> >>  1 file changed, 2 insertions(+), 1 deletion(-)
>> >> 
>> >> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
>> >b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> >> index 650520244ed0..7271d705f4b0 100644
>> >> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> >> @@ -139,7 +139,8 @@ static int siw_rx_pbl(struct siw_rx_stream
>> >*srx, int *pbl_idx,
>> >>  			break;
>> >>  
>> >>  		bytes = min(bytes, len);
>> >> -		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
>> >> +		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
>> >> +		    bytes) {
>> >
>> >How is a dma_addr_t being cast to a void *? That can't be right?
>> >Bernard??
>> >
>> >Jason
>> >
>> Hi Tom, Hi Jason,
>> 
>> Thanks for looking into that.
>> 
>> siw_rx_kva() calls skb_copy_bits() to move data to its
>> kernel clients destination.  It expects a void * target
>> address. This is why I chose it for siw_rx_kva() as well.
>> One could say siw_rx_kva() should better get an uintptr_t
>> as target argument, which would probably make it look
>> more clean. And we rename it to siw_rx_kbuf(), and we
>> cast from uintptr_t to (void *) just for
>>  skb_copy_bits(skb *, off, (void *)dest, len)
>> 
>> This would avoid all those nasty (void *) casting at all (!)
>> the places we are calling siw_rx_kva().
>
>But where did the dma_addr_t come from?
>
It initially comes from the scatterlist provided by the
kernel user via drivers .map_mr_sg() method. There we get a
dma_addr_t describing the users buffer.

Thanks,
Bernard.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-11 14:11   ` Bernard Metzler
@ 2020-06-11 14:23     ` Jason Gunthorpe
  2020-06-11 15:06     ` Bernard Metzler
  1 sibling, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2020-06-11 14:23 UTC (permalink / raw)
  To: Bernard Metzler; +Cc: Tom Seewald, linux-rdma, Doug Ledford

On Thu, Jun 11, 2020 at 02:11:51PM +0000, Bernard Metzler wrote:
> 
> >To: "Bernard Metzler" <BMT@zurich.ibm.com>
> >From: "Jason Gunthorpe" <jgg@ziepe.ca>
> >Date: 06/11/2020 01:35PM
> >Cc: "Tom Seewald" <tseewald@gmail.com>, linux-rdma@vger.kernel.org,
> >"Doug Ledford" <dledford@redhat.com>
> >Subject: [EXTERNAL] Re: Re: [PATCH next] siw: Fix pointer-to-int-cast
> >warning in siw_rx_pbl()
> >
> >On Thu, Jun 11, 2020 at 10:21:49AM +0000, Bernard Metzler wrote:
> >> 
> >> >To: "Tom Seewald" <tseewald@gmail.com>
> >> >From: "Jason Gunthorpe" <jgg@ziepe.ca>
> >> >Date: 06/10/2020 07:50PM
> >> >Cc: linux-rdma@vger.kernel.org, "Bernard Metzler"
> >> ><bmt@zurich.ibm.com>, "Doug Ledford" <dledford@redhat.com>
> >> >Subject: [EXTERNAL] Re: [PATCH next] siw: Fix pointer-to-int-cast
> >> >warning in siw_rx_pbl()
> >> >
> >> >On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
> >> >> The variable buf_addr is type dma_addr_t, which may not be the
> >same
> >> >size
> >> >> as a pointer.  To ensure it is the correct size, cast to a
> >> >uintptr_t.
> >> >> 
> >> >> Signed-off-by: Tom Seewald <tseewald@gmail.com>
> >> >>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
> >> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >> >> 
> >> >> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
> >> >b/drivers/infiniband/sw/siw/siw_qp_rx.c
> >> >> index 650520244ed0..7271d705f4b0 100644
> >> >> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
> >> >> @@ -139,7 +139,8 @@ static int siw_rx_pbl(struct siw_rx_stream
> >> >*srx, int *pbl_idx,
> >> >>  			break;
> >> >>  
> >> >>  		bytes = min(bytes, len);
> >> >> -		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
> >> >> +		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
> >> >> +		    bytes) {
> >> >
> >> >How is a dma_addr_t being cast to a void *? That can't be right?
> >> >Bernard??
> >> >
> >> >Jason
> >> >
> >> Hi Tom, Hi Jason,
> >> 
> >> Thanks for looking into that.
> >> 
> >> siw_rx_kva() calls skb_copy_bits() to move data to its
> >> kernel clients destination.  It expects a void * target
> >> address. This is why I chose it for siw_rx_kva() as well.
> >> One could say siw_rx_kva() should better get an uintptr_t
> >> as target argument, which would probably make it look
> >> more clean. And we rename it to siw_rx_kbuf(), and we
> >> cast from uintptr_t to (void *) just for
> >>  skb_copy_bits(skb *, off, (void *)dest, len)
> >> 
> >> This would avoid all those nasty (void *) casting at all (!)
> >> the places we are calling siw_rx_kva().
> >
> >But where did the dma_addr_t come from?
> >
> It initially comes from the scatterlist provided by the
> kernel user via drivers .map_mr_sg() method. There we get a
> dma_addr_t describing the users buffer.

For the SW dma maps you have to convert the dma_addr_t to a kva using
kmap, it cannot just be casted.

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-11 14:11   ` Bernard Metzler
  2020-06-11 14:23     ` Jason Gunthorpe
@ 2020-06-11 15:06     ` Bernard Metzler
  2020-06-11 17:05       ` Jason Gunthorpe
  2020-06-12 15:56       ` Bernard Metzler
  1 sibling, 2 replies; 11+ messages in thread
From: Bernard Metzler @ 2020-06-11 15:06 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Tom Seewald, linux-rdma, Doug Ledford

-----"Jason Gunthorpe" <jgg@ziepe.ca> wrote: -----

>To: "Bernard Metzler" <BMT@zurich.ibm.com>
>From: "Jason Gunthorpe" <jgg@ziepe.ca>
>Date: 06/11/2020 04:24PM
>Cc: "Tom Seewald" <tseewald@gmail.com>, linux-rdma@vger.kernel.org,
>"Doug Ledford" <dledford@redhat.com>
>Subject: [EXTERNAL] Re: Re: [PATCH next] siw: Fix pointer-to-int-cast
>warning in siw_rx_pbl()
>
>On Thu, Jun 11, 2020 at 02:11:51PM +0000, Bernard Metzler wrote:
>> 
>> >To: "Bernard Metzler" <BMT@zurich.ibm.com>
>> >From: "Jason Gunthorpe" <jgg@ziepe.ca>
>> >Date: 06/11/2020 01:35PM
>> >Cc: "Tom Seewald" <tseewald@gmail.com>,
>linux-rdma@vger.kernel.org,
>> >"Doug Ledford" <dledford@redhat.com>
>> >Subject: [EXTERNAL] Re: Re: [PATCH next] siw: Fix
>pointer-to-int-cast
>> >warning in siw_rx_pbl()
>> >
>> >On Thu, Jun 11, 2020 at 10:21:49AM +0000, Bernard Metzler wrote:
>> >> 
>> >> >To: "Tom Seewald" <tseewald@gmail.com>
>> >> >From: "Jason Gunthorpe" <jgg@ziepe.ca>
>> >> >Date: 06/10/2020 07:50PM
>> >> >Cc: linux-rdma@vger.kernel.org, "Bernard Metzler"
>> >> ><bmt@zurich.ibm.com>, "Doug Ledford" <dledford@redhat.com>
>> >> >Subject: [EXTERNAL] Re: [PATCH next] siw: Fix
>pointer-to-int-cast
>> >> >warning in siw_rx_pbl()
>> >> >
>> >> >On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
>> >> >> The variable buf_addr is type dma_addr_t, which may not be
>the
>> >same
>> >> >size
>> >> >> as a pointer.  To ensure it is the correct size, cast to a
>> >> >uintptr_t.
>> >> >> 
>> >> >> Signed-off-by: Tom Seewald <tseewald@gmail.com>
>> >> >>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
>> >> >>  1 file changed, 2 insertions(+), 1 deletion(-)
>> >> >> 
>> >> >> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c
>> >> >b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> >> >> index 650520244ed0..7271d705f4b0 100644
>> >> >> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
>> >> >> @@ -139,7 +139,8 @@ static int siw_rx_pbl(struct
>siw_rx_stream
>> >> >*srx, int *pbl_idx,
>> >> >>  			break;
>> >> >>  
>> >> >>  		bytes = min(bytes, len);
>> >> >> -		if (siw_rx_kva(srx, (void *)buf_addr, bytes) == bytes) {
>> >> >> +		if (siw_rx_kva(srx, (void *)(uintptr_t)buf_addr, bytes) ==
>> >> >> +		    bytes) {
>> >> >
>> >> >How is a dma_addr_t being cast to a void *? That can't be
>right?
>> >> >Bernard??
>> >> >
>> >> >Jason
>> >> >
>> >> Hi Tom, Hi Jason,
>> >> 
>> >> Thanks for looking into that.
>> >> 
>> >> siw_rx_kva() calls skb_copy_bits() to move data to its
>> >> kernel clients destination.  It expects a void * target
>> >> address. This is why I chose it for siw_rx_kva() as well.
>> >> One could say siw_rx_kva() should better get an uintptr_t
>> >> as target argument, which would probably make it look
>> >> more clean. And we rename it to siw_rx_kbuf(), and we
>> >> cast from uintptr_t to (void *) just for
>> >>  skb_copy_bits(skb *, off, (void *)dest, len)
>> >> 
>> >> This would avoid all those nasty (void *) casting at all (!)
>> >> the places we are calling siw_rx_kva().
>> >
>> >But where did the dma_addr_t come from?
>> >
>> It initially comes from the scatterlist provided by the
>> kernel user via drivers .map_mr_sg() method. There we get a
>> dma_addr_t describing the users buffer.
>
>For the SW dma maps you have to convert the dma_addr_t to a kva using
>kmap, it cannot just be casted.
>

True for a real dma addr. But here the user initially came
with an address it got from dma_virt_ops.dma_virt_map_page(),
which provides the virtual address of the page referenced,
casted to dma_addr_t. So we mimic some great dma_addr_t stuff
we do not need for a SW driver and in the end we even have
to call heavy kmap_atomic() to just get the very same addr again.
This I don't want. It's why I just casted it back to void *.
hmmm.

Thanks,
Bernard.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-11 15:06     ` Bernard Metzler
@ 2020-06-11 17:05       ` Jason Gunthorpe
  2020-06-12 15:56       ` Bernard Metzler
  1 sibling, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2020-06-11 17:05 UTC (permalink / raw)
  To: Bernard Metzler; +Cc: Tom Seewald, linux-rdma, Doug Ledford

On Thu, Jun 11, 2020 at 03:06:12PM +0000, Bernard Metzler wrote:
> >> It initially comes from the scatterlist provided by the
> >> kernel user via drivers .map_mr_sg() method. There we get a
> >> dma_addr_t describing the users buffer.
> >
> >For the SW dma maps you have to convert the dma_addr_t to a kva using
> >kmap, it cannot just be casted.
> >
> True for a real dma addr. But here the user initially came
> with an address it got from dma_virt_ops.dma_virt_map_page(),
> which provides the virtual address of the page referenced,
> casted to dma_addr_t.

Oh, that's curiously broken on highmem systems, but OK siw is fine
with it like that, though I think it would have been better to have
some helper function connected to dma_virt do this cast.

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-11 15:06     ` Bernard Metzler
  2020-06-11 17:05       ` Jason Gunthorpe
@ 2020-06-12 15:56       ` Bernard Metzler
  1 sibling, 0 replies; 11+ messages in thread
From: Bernard Metzler @ 2020-06-12 15:56 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Tom Seewald, linux-rdma, Doug Ledford

-----"Jason Gunthorpe" <jgg@ziepe.ca> wrote: -----

>To: "Bernard Metzler" <BMT@zurich.ibm.com>
>From: "Jason Gunthorpe" <jgg@ziepe.ca>
>Date: 06/11/2020 07:05PM
>Cc: "Tom Seewald" <tseewald@gmail.com>, linux-rdma@vger.kernel.org,
>"Doug Ledford" <dledford@redhat.com>
>Subject: [EXTERNAL] Re: Re: [PATCH next] siw: Fix pointer-to-int-cast
>warning in siw_rx_pbl()
>
>On Thu, Jun 11, 2020 at 03:06:12PM +0000, Bernard Metzler wrote:
>> >> It initially comes from the scatterlist provided by the
>> >> kernel user via drivers .map_mr_sg() method. There we get a
>> >> dma_addr_t describing the users buffer.
>> >
>> >For the SW dma maps you have to convert the dma_addr_t to a kva
>using
>> >kmap, it cannot just be casted.
>> >
>> True for a real dma addr. But here the user initially came
>> with an address it got from dma_virt_ops.dma_virt_map_page(),
>> which provides the virtual address of the page referenced,
>> casted to dma_addr_t.
>
>Oh, that's curiously broken on highmem systems, but OK siw is fine
>with it like that, though I think it would have been better to have
>some helper function connected to dma_virt do this cast.
>
>Jason
>
With that, lets take Tom's simple patch for now.

Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl()
  2020-06-10 17:47 [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl() Tom Seewald
  2020-06-10 17:50 ` Jason Gunthorpe
  2020-06-11 10:21 ` Bernard Metzler
@ 2020-06-16 14:03 ` Jason Gunthorpe
  2 siblings, 0 replies; 11+ messages in thread
From: Jason Gunthorpe @ 2020-06-16 14:03 UTC (permalink / raw)
  To: Tom Seewald; +Cc: linux-rdma, Bernard Metzler, Doug Ledford

On Wed, Jun 10, 2020 at 12:47:17PM -0500, Tom Seewald wrote:
> The variable buf_addr is type dma_addr_t, which may not be the same size
> as a pointer.  To ensure it is the correct size, cast to a uintptr_t.
> 
> Signed-off-by: Tom Seewald <tseewald@gmail.com>
> Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
>  drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied to for-rc, thanks

Jason

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-16 14:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 17:47 [PATCH next] siw: Fix pointer-to-int-cast warning in siw_rx_pbl() Tom Seewald
2020-06-10 17:50 ` Jason Gunthorpe
2020-06-10 18:21   ` Tom Seewald
2020-06-11 10:21 ` Bernard Metzler
2020-06-11 11:35   ` Jason Gunthorpe
2020-06-11 14:11   ` Bernard Metzler
2020-06-11 14:23     ` Jason Gunthorpe
2020-06-11 15:06     ` Bernard Metzler
2020-06-11 17:05       ` Jason Gunthorpe
2020-06-12 15:56       ` Bernard Metzler
2020-06-16 14:03 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).