linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpu: host1x: Fix compiler errors
@ 2018-03-26 14:44 Emil Goode
  2018-03-26 14:57 ` Thierry Reding
  2018-05-14  8:43 ` Thierry Reding
  0 siblings, 2 replies; 5+ messages in thread
From: Emil Goode @ 2018-03-26 14:44 UTC (permalink / raw)
  To: Thierry Reding, Thierry Reding
  Cc: dri-devel, linux-tegra, linux-kernel, kernel-janitors

The compiler is complaining with the following errors:

drivers/gpu/host1x/cdma.c:94:48: error:
	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
	[-Werror=incompatible-pointer-types]

drivers/gpu/host1x/cdma.c:113:48: error:
	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
	[-Werror=incompatible-pointer-types]

The expected pointer type of the third argument to dma_alloc_wc() is
dma_addr_t but phys_addr_t is passed. Fix this by adding casts to the
expected pointer type.

Signed-off-by: Emil Goode <emil.fsw@goode.io>
---
 drivers/gpu/host1x/cdma.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index 28541b280739..5e8b321a751e 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -91,8 +91,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
 
 		size = iova_align(&host1x->iova, size);
 
-		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
-					  GFP_KERNEL);
+		pb->mapped = dma_alloc_wc(host1x->dev, size,
+					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
 		if (!pb->mapped)
 			return -ENOMEM;
 
@@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
 		if (err)
 			goto iommu_free_iova;
 	} else {
-		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
-					  GFP_KERNEL);
+		pb->mapped = dma_alloc_wc(host1x->dev, size,
+					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
 		if (!pb->mapped)
 			return -ENOMEM;
 
-- 
2.11.0

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

* Re: [PATCH] gpu: host1x: Fix compiler errors
  2018-03-26 14:44 [PATCH] gpu: host1x: Fix compiler errors Emil Goode
@ 2018-03-26 14:57 ` Thierry Reding
  2018-03-26 15:47   ` Emil Goode
  2018-05-14  8:43 ` Thierry Reding
  1 sibling, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2018-03-26 14:57 UTC (permalink / raw)
  To: Emil Goode
  Cc: Thierry Reding, dri-devel, linux-tegra, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]

On Mon, Mar 26, 2018 at 04:44:14PM +0200, Emil Goode wrote:
> The compiler is complaining with the following errors:
> 
> drivers/gpu/host1x/cdma.c:94:48: error:
> 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> 	[-Werror=incompatible-pointer-types]
> 
> drivers/gpu/host1x/cdma.c:113:48: error:
> 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> 	[-Werror=incompatible-pointer-types]
> 
> The expected pointer type of the third argument to dma_alloc_wc() is
> dma_addr_t but phys_addr_t is passed. Fix this by adding casts to the
> expected pointer type.
> 
> Signed-off-by: Emil Goode <emil.fsw@goode.io>
> ---
>  drivers/gpu/host1x/cdma.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

What compiler do you use? I do regular builds and check for warnings and
errors, and this one is new to me.

Thierry

> 
> diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
> index 28541b280739..5e8b321a751e 100644
> --- a/drivers/gpu/host1x/cdma.c
> +++ b/drivers/gpu/host1x/cdma.c
> @@ -91,8 +91,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
>  
>  		size = iova_align(&host1x->iova, size);
>  
> -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> -					  GFP_KERNEL);
> +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
>  		if (!pb->mapped)
>  			return -ENOMEM;
>  
> @@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
>  		if (err)
>  			goto iommu_free_iova;
>  	} else {
> -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> -					  GFP_KERNEL);
> +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
>  		if (!pb->mapped)
>  			return -ENOMEM;
>  
> -- 
> 2.11.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] gpu: host1x: Fix compiler errors
  2018-03-26 14:57 ` Thierry Reding
@ 2018-03-26 15:47   ` Emil Goode
  0 siblings, 0 replies; 5+ messages in thread
From: Emil Goode @ 2018-03-26 15:47 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Thierry Reding, dri-devel, linux-tegra, linux-kernel, kernel-janitors

Hello,

On Mon, Mar 26, 2018 at 04:57:34PM +0200, Thierry Reding wrote:
> On Mon, Mar 26, 2018 at 04:44:14PM +0200, Emil Goode wrote:
> > The compiler is complaining with the following errors:
> > 
> > drivers/gpu/host1x/cdma.c:94:48: error:
> > 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> > 	[-Werror=incompatible-pointer-types]
> > 
> > drivers/gpu/host1x/cdma.c:113:48: error:
> > 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> > 	[-Werror=incompatible-pointer-types]
> > 
> > The expected pointer type of the third argument to dma_alloc_wc() is
> > dma_addr_t but phys_addr_t is passed. Fix this by adding casts to the
> > expected pointer type.
> > 
> > Signed-off-by: Emil Goode <emil.fsw@goode.io>
> > ---
> >  drivers/gpu/host1x/cdma.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> What compiler do you use? I do regular builds and check for warnings and
> errors, and this one is new to me.
> 
> Thierry
>

I use gcc version 6.3.0 cross compiler for armhf supplied with Debian Stretch.

Best regards,

Emil

> > 
> > diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
> > index 28541b280739..5e8b321a751e 100644
> > --- a/drivers/gpu/host1x/cdma.c
> > +++ b/drivers/gpu/host1x/cdma.c
> > @@ -91,8 +91,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
> >  
> >  		size = iova_align(&host1x->iova, size);
> >  
> > -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> > -					  GFP_KERNEL);
> > +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> > +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
> >  		if (!pb->mapped)
> >  			return -ENOMEM;
> >  
> > @@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
> >  		if (err)
> >  			goto iommu_free_iova;
> >  	} else {
> > -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> > -					  GFP_KERNEL);
> > +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> > +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
> >  		if (!pb->mapped)
> >  			return -ENOMEM;
> >  
> > -- 
> > 2.11.0
> > 

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

* Re: [PATCH] gpu: host1x: Fix compiler errors
  2018-03-26 14:44 [PATCH] gpu: host1x: Fix compiler errors Emil Goode
  2018-03-26 14:57 ` Thierry Reding
@ 2018-05-14  8:43 ` Thierry Reding
  2018-05-15 21:07   ` Emil Goode
  1 sibling, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2018-05-14  8:43 UTC (permalink / raw)
  To: Emil Goode
  Cc: Thierry Reding, dri-devel, linux-tegra, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2371 bytes --]

On Mon, Mar 26, 2018 at 04:44:14PM +0200, Emil Goode wrote:
> The compiler is complaining with the following errors:
> 
> drivers/gpu/host1x/cdma.c:94:48: error:
> 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> 	[-Werror=incompatible-pointer-types]
> 
> drivers/gpu/host1x/cdma.c:113:48: error:
> 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> 	[-Werror=incompatible-pointer-types]
> 
> The expected pointer type of the third argument to dma_alloc_wc() is
> dma_addr_t but phys_addr_t is passed. Fix this by adding casts to the
> expected pointer type.
> 
> Signed-off-by: Emil Goode <emil.fsw@goode.io>
> ---
>  drivers/gpu/host1x/cdma.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
> index 28541b280739..5e8b321a751e 100644
> --- a/drivers/gpu/host1x/cdma.c
> +++ b/drivers/gpu/host1x/cdma.c
> @@ -91,8 +91,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
>  
>  		size = iova_align(&host1x->iova, size);
>  
> -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> -					  GFP_KERNEL);
> +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
>  		if (!pb->mapped)
>  			return -ENOMEM;
>  
> @@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
>  		if (err)
>  			goto iommu_free_iova;
>  	} else {
> -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> -					  GFP_KERNEL);
> +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
>  		if (!pb->mapped)
>  			return -ENOMEM;
>  

This doesn't seem right. There's no guarantee that phys_addr_t and
dma_addr_t will be compatible, so the above isn't always correct. Also,
I don't see a need for pb->phys to ever be phys_addr_t. It's allocated
through dma_alloc_wc() exclusively, so it should just be dma_addr_t.

Note that the !pb->phys check in host1x_pushbuffer_destroy() becomes
technically wrong if pb->phys is dma_addr_t (0 is a perfectly valid
value for dma_addr_t), so make sure to flip that to !pb->mapped instead.
pb->mapped and pb->phys are always set in tandem, and checking mapped
for non-NULL is the right check to test whether the pair is valid or
not.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] gpu: host1x: Fix compiler errors
  2018-05-14  8:43 ` Thierry Reding
@ 2018-05-15 21:07   ` Emil Goode
  0 siblings, 0 replies; 5+ messages in thread
From: Emil Goode @ 2018-05-15 21:07 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Thierry Reding, dri-devel, linux-tegra, linux-kernel, kernel-janitors

Hello,

On Mon, May 14, 2018 at 10:43:08AM +0200, Thierry Reding wrote:
> On Mon, Mar 26, 2018 at 04:44:14PM +0200, Emil Goode wrote:
> > The compiler is complaining with the following errors:
> > 
> > drivers/gpu/host1x/cdma.c:94:48: error:
> > 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> > 	[-Werror=incompatible-pointer-types]
> > 
> > drivers/gpu/host1x/cdma.c:113:48: error:
> > 	passing argument 3 of ‘dma_alloc_wc’ from incompatible pointer type
> > 	[-Werror=incompatible-pointer-types]
> > 
> > The expected pointer type of the third argument to dma_alloc_wc() is
> > dma_addr_t but phys_addr_t is passed. Fix this by adding casts to the
> > expected pointer type.
> > 
> > Signed-off-by: Emil Goode <emil.fsw@goode.io>
> > ---
> >  drivers/gpu/host1x/cdma.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
> > index 28541b280739..5e8b321a751e 100644
> > --- a/drivers/gpu/host1x/cdma.c
> > +++ b/drivers/gpu/host1x/cdma.c
> > @@ -91,8 +91,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
> >  
> >  		size = iova_align(&host1x->iova, size);
> >  
> > -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> > -					  GFP_KERNEL);
> > +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> > +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
> >  		if (!pb->mapped)
> >  			return -ENOMEM;
> >  
> > @@ -110,8 +110,8 @@ static int host1x_pushbuffer_init(struct push_buffer *pb)
> >  		if (err)
> >  			goto iommu_free_iova;
> >  	} else {
> > -		pb->mapped = dma_alloc_wc(host1x->dev, size, &pb->phys,
> > -					  GFP_KERNEL);
> > +		pb->mapped = dma_alloc_wc(host1x->dev, size,
> > +					  (dma_addr_t *)&pb->phys, GFP_KERNEL);
> >  		if (!pb->mapped)
> >  			return -ENOMEM;
> >  
> 
> This doesn't seem right. There's no guarantee that phys_addr_t and
> dma_addr_t will be compatible, so the above isn't always correct. Also,
> I don't see a need for pb->phys to ever be phys_addr_t. It's allocated
> through dma_alloc_wc() exclusively, so it should just be dma_addr_t.

I agree that this is a better solution, however when changing pb->phys to dma_addr_t
the type will be wrong when it's passed to iommu_map() as phys_addr_t is expected
but that doesn't cause a compilation error.

> Note that the !pb->phys check in host1x_pushbuffer_destroy() becomes
> technically wrong if pb->phys is dma_addr_t (0 is a perfectly valid
> value for dma_addr_t), so make sure to flip that to !pb->mapped instead.
> pb->mapped and pb->phys are always set in tandem, and checking mapped
> for non-NULL is the right check to test whether the pair is valid or
> not.

Ok I will change this as well.

Best regards,

Emil

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

end of thread, other threads:[~2018-05-15 21:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 14:44 [PATCH] gpu: host1x: Fix compiler errors Emil Goode
2018-03-26 14:57 ` Thierry Reding
2018-03-26 15:47   ` Emil Goode
2018-05-14  8:43 ` Thierry Reding
2018-05-15 21:07   ` Emil Goode

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).