All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats
@ 2013-11-27  0:29 Laurent Pinchart
  2013-11-27 12:27 ` Shevchenko, Andriy
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Laurent Pinchart @ 2013-11-27  0:29 UTC (permalink / raw)
  To: linux-sh

Use the %zu printk specifier to print size_t variables, and cast
pointers to unsigned long instead of unsigned int where applicable. This
fixes warnings on platforms where pointers and/or dma_addr_t have a
different size than int.

Cc: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: dmaengine@vger.kernel.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/dma/sh/shdma-base.c | 10 +++++-----
 drivers/dma/sh/shdma-of.c   |  3 ++-
 drivers/dma/sh/sudmac.c     |  4 ++--
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index 2e7b394..b37d584 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void *arg)
 	struct shdma_chan *schan = to_shdma_chan(chan);
 	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
 	const struct shdma_ops *ops = sdev->ops;
-	int match = (int)arg;
+	int match = (long)arg;
 	int ret;
 
 	if (match < 0)
@@ -491,9 +491,9 @@ static struct shdma_desc *shdma_add_desc(struct shdma_chan *schan,
 	}
 
 	dev_dbg(schan->dev,
-		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
-		copy_size, *len, *src, *dst, &new->async_tx,
-		new->async_tx.cookie);
+		"chaining (%zu/%zu)@%lx -> %lx with %p, cookie %d\n",
+		copy_size, *len, (unsigned long)*src, (unsigned long)*dst,
+		&new->async_tx, new->async_tx.cookie);
 
 	new->mark = DESC_PREPARED;
 	new->async_tx.flags = flags;
@@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,
 			goto err_get_desc;
 
 		do {
-			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
+			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
 				i, sg, len, (unsigned long long)sg_addr);
 
 			if (direction = DMA_DEV_TO_MEM)
diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
index 06473a0..7fdb67b 100644
--- a/drivers/dma/sh/shdma-of.c
+++ b/drivers/dma/sh/shdma-of.c
@@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec,
 	/* Only slave DMA channels can be allocated via DT */
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
+	chan = dma_request_channel(mask, shdma_chan_filter,
+				   (void *)(unsigned long)id);
 	if (chan)
 		to_shdma_chan(chan)->hw_req = id;
 
diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
index c7e9cdf..2112ed2 100644
--- a/drivers/dma/sh/sudmac.c
+++ b/drivers/dma/sh/sudmac.c
@@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan *schan,
 	struct sudmac_chan *sc = to_chan(schan);
 	struct sudmac_desc *sd = to_desc(sdesc);
 
-	dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
-		__func__, src, dst, *len);
+	dev_dbg(sc->shdma_chan.dev, "%s: src=%lx, dst=%lx, len=%zu\n",
+		__func__, (unsigned long)src, (unsigned long)dst, *len);
 
 	if (*len > schan->max_xfer_len)
 		*len = schan->max_xfer_len;
-- 
1.8.3.2


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

* Re: [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats
  2013-11-27  0:29 [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Laurent Pinchart
@ 2013-11-27 12:27 ` Shevchenko, Andriy
  2013-11-27 16:03 ` Laurent Pinchart
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Shevchenko, Andriy @ 2013-11-27 12:27 UTC (permalink / raw)
  To: linux-sh

T24gV2VkLCAyMDEzLTExLTI3IGF0IDAxOjI5ICswMTAwLCBMYXVyZW50IFBpbmNoYXJ0IHdyb3Rl
Og0KPiBVc2UgdGhlICV6dSBwcmludGsgc3BlY2lmaWVyIHRvIHByaW50IHNpemVfdCB2YXJpYWJs
ZXMsIGFuZCBjYXN0DQo+IHBvaW50ZXJzIHRvIHVuc2lnbmVkIGxvbmcgaW5zdGVhZCBvZiB1bnNp
Z25lZCBpbnQgd2hlcmUgYXBwbGljYWJsZS4gVGhpcw0KPiBmaXhlcyB3YXJuaW5ncyBvbiBwbGF0
Zm9ybXMgd2hlcmUgcG9pbnRlcnMgYW5kL29yIGRtYV9hZGRyX3QgaGF2ZSBhDQo+IGRpZmZlcmVu
dCBzaXplIHRoYW4gaW50Lg0KDQpGZXcgY29tbWVudHMgYmVsb3cuDQoNCj4gZGlmZiAtLWdpdCBh
L2RyaXZlcnMvZG1hL3NoL3NoZG1hLWJhc2UuYyBiL2RyaXZlcnMvZG1hL3NoL3NoZG1hLWJhc2Uu
Yw0KPiBpbmRleCAyZTdiMzk0Li5iMzdkNTg0IDEwMDY0NA0KPiAtLS0gYS9kcml2ZXJzL2RtYS9z
aC9zaGRtYS1iYXNlLmMNCj4gKysrIGIvZHJpdmVycy9kbWEvc2gvc2hkbWEtYmFzZS5jDQo+IEBA
IC0yMjcsNyArMjI3LDcgQEAgYm9vbCBzaGRtYV9jaGFuX2ZpbHRlcihzdHJ1Y3QgZG1hX2NoYW4g
KmNoYW4sIHZvaWQgKmFyZykNCj4gIAlzdHJ1Y3Qgc2hkbWFfY2hhbiAqc2NoYW4gPSB0b19zaGRt
YV9jaGFuKGNoYW4p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2YgdGhlIGludGVuZGVk
IHJlY2lwaWVudChzKS4gQW55IHJldmlldyBvciBkaXN0cmlidXRpb24KYnkgb3RoZXJzIGlzIHN0
cmljdGx5IHByb2hpYml0ZWQuIElmIHlvdSBhcmUgbm90IHRoZSBpbnRlbmRlZApyZWNpcGllbnQs
IHBsZWFzZSBjb250YWN0IHRoZSBzZW5kZXIgYW5kIGRlbGV0ZSBhbGwgY29waWVzLgo

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

* Re: [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats
  2013-11-27  0:29 [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Laurent Pinchart
  2013-11-27 12:27 ` Shevchenko, Andriy
@ 2013-11-27 16:03 ` Laurent Pinchart
  2013-11-27 16:24 ` Laurent Pinchart
  2013-11-28  9:25 ` Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2013-11-27 16:03 UTC (permalink / raw)
  To: linux-sh

Hi Andy,

On Wednesday 27 November 2013 12:27:41 Shevchenko, Andriy wrote:
> On Wed, 2013-11-27 at 01:29 +0100, Laurent Pinchart wrote:
> 
> > Use the %zu printk specifier to print size_t variables, and cast
> > pointers to unsigned long instead of unsigned int where applicable. This
> > fixes warnings on platforms where pointers and/or dma_addr_t have a
> > different size than int.
> 
> Few comments below.
> 
> > diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
> > index 2e7b394..b37d584 100644
> > --- a/drivers/dma/sh/shdma-base.c
> > +++ b/drivers/dma/sh/shdma-base.c
> > @@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void
> > *arg)
> >  	struct shdma_chan *schan = to_shdma_chan(chan);
> >  	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
> >  	const struct shdma_ops *ops = sdev->ops;
> > -	int match = (int)arg;
> > +	int match = (long)arg;
> 
> As far as I understand this will lose data on 64bit platforms.
> Are you aware of it? Otherwise I don't see the advantage of such
> conversion. As far as I understand you may cast void * easily to long
> and back, otherwise you lost data.

That's correct, but shouldn't be an issue here. The match value is a small 
integer. The reason why I cast it to long is to avoid compilation warnings

> >  	int ret;
> >  
> >  	if (match < 0)
> > @@ -491,9 +491,9 @@ static struct shdma_desc *shdma_add_desc(struct
> > shdma_chan *schan,
> >  	}
> >  
> >  	dev_dbg(schan->dev,
> > -		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
> > -		copy_size, *len, *src, *dst, &new->async_tx,
> > -		new->async_tx.cookie);
> > +		"chaining (%zu/%zu)@%lx -> %lx with %p, cookie %d\n",
> > +		copy_size, *len, (unsigned long)*src, (unsigned long)*dst,
> > +		&new->async_tx, new->async_tx.cookie);
> 
> Instead of dancing with casting (actually for dma_addr_t it should be
> ULL type), we can extend %pa to do this job for us:

That sounds good to me. Do you plan to submit a patch ? I'd like to get this 
series upstream in v3.14.

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 10909c5..0806bf0 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1354,10 +1354,17 @@ char *pointer(const char *fmt, char *buf, char
> *end, void *ptr,
>  		break;
>  	case 'a':
>  		spec.flags |= SPECIAL | SMALL | ZEROPAD;
> -		spec.field_width = sizeof(phys_addr_t) * 2 + 2;
>  		spec.base = 16;
> -		return number(buf, end,
> -			      (unsigned long long) *((phys_addr_t *)ptr), spec);
> +		switch (fmt[1]) {
> +		case 'D':
> +			spec.field_width = sizeof(dma_addr_t) * 2 + 2;
> +			return number(buf, end,
> +				(unsigned long long)*((dma_addr_t *)ptr), spec);
> +		default:
> +			spec.field_width = sizeof(phys_addr_t) * 2 + 2;
> +			return number(buf, end,
> +				(unsigned long long)*((phys_addr_t *)ptr), spec);
> +		}
>  	case 'd':
>  		return dentry_name(buf, end, ptr, spec, fmt);
>  	case 'D':
> 
> Thus, use %paD.
> 
> 
> >  	new->mark = DESC_PREPARED;
> >  	new->async_tx.flags = flags;
> > 
> > @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor
> > *shdma_prep_sg(struct shdma_chan *schan,
> >  			goto err_get_desc;
> >  
> >  		do {
> > -			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
> > +			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
> >  				i, sg, len, (unsigned long long)sg_addr);
> >  
> >  			if (direction = DMA_DEV_TO_MEM)
> > diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
> > index 06473a0..7fdb67b 100644
> > --- a/drivers/dma/sh/shdma-of.c
> > +++ b/drivers/dma/sh/shdma-of.c
> > @@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct
> > of_phandle_args *dma_spec,
> >  	/* Only slave DMA channels can be allocated via DT */
> >  	dma_cap_set(DMA_SLAVE, mask);
> >  
> > -	chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
> > +	chan = dma_request_channel(mask, shdma_chan_filter,
> > +				   (void *)(unsigned long)id);
> >  	if (chan)
> >  		to_shdma_chan(chan)->hw_req = id;
> >  
> > diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
> > index c7e9cdf..2112ed2 100644
> > --- a/drivers/dma/sh/sudmac.c
> > +++ b/drivers/dma/sh/sudmac.c
> > @@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan
> > *schan,
> >  	struct sudmac_chan *sc = to_chan(schan);
> >  	struct sudmac_desc *sd = to_desc(sdesc);
> > 
> > -	dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
> > -		__func__, src, dst, *len);
> > +	dev_dbg(sc->shdma_chan.dev, "%s: src=%lx, dst=%lx, len=%zu\n",
> > +		__func__, (unsigned long)src, (unsigned long)dst, *len);
> >  
> >  	if (*len > schan->max_xfer_len)
> >  		*len = schan->max_xfer_len;
-- 
Regards,

Laurent Pinchart


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

* Re: [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats
  2013-11-27  0:29 [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Laurent Pinchart
  2013-11-27 12:27 ` Shevchenko, Andriy
  2013-11-27 16:03 ` Laurent Pinchart
@ 2013-11-27 16:24 ` Laurent Pinchart
  2013-11-28  9:25 ` Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2013-11-27 16:24 UTC (permalink / raw)
  To: linux-sh

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

Hi Andriy,

On Wednesday 27 November 2013 17:03:25 Laurent Pinchart wrote:
> Hi Andy,

Sorry for the misspelling.

> On Wednesday 27 November 2013 12:27:41 Shevchenko, Andriy wrote:
> > On Wed, 2013-11-27 at 01:29 +0100, Laurent Pinchart wrote:
> > > Use the %zu printk specifier to print size_t variables, and cast
> > > pointers to unsigned long instead of unsigned int where applicable. This
> > > fixes warnings on platforms where pointers and/or dma_addr_t have a
> > > different size than int.
> > 
> > Few comments below.
> > 
> > > diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
> > > index 2e7b394..b37d584 100644
> > > --- a/drivers/dma/sh/shdma-base.c
> > > +++ b/drivers/dma/sh/shdma-base.c
> > > @@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void
> > > *arg)
> > > 
> > >  	struct shdma_chan *schan = to_shdma_chan(chan);
> > >  	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
> > >  	const struct shdma_ops *ops = sdev->ops;
> > > 
> > > -	int match = (int)arg;
> > > +	int match = (long)arg;
> > 
> > As far as I understand this will lose data on 64bit platforms.
> > Are you aware of it? Otherwise I don't see the advantage of such
> > conversion. As far as I understand you may cast void * easily to long
> > and back, otherwise you lost data.
> 
> That's correct, but shouldn't be an issue here. The match value is a small
> integer. The reason why I cast it to long is to avoid compilation warnings
> 
> > >  	int ret;
> > >  	
> > >  	if (match < 0)
> > > 
> > > @@ -491,9 +491,9 @@ static struct shdma_desc *shdma_add_desc(struct
> > > shdma_chan *schan,
> > > 
> > >  	}
> > >  	
> > >  	dev_dbg(schan->dev,
> > > 
> > > -		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
> > > -		copy_size, *len, *src, *dst, &new->async_tx,
> > > -		new->async_tx.cookie);
> > > +		"chaining (%zu/%zu)@%lx -> %lx with %p, cookie %d\n",
> > > +		copy_size, *len, (unsigned long)*src, (unsigned long)*dst,
> > > +		&new->async_tx, new->async_tx.cookie);
> > 
> > Instead of dancing with casting (actually for dma_addr_t it should be
> > ULL type), we can extend %pa to do this job for us:
>
> That sounds good to me. Do you plan to submit a patch ? I'd like to get this
> series upstream in v3.14.

Please use the attached patch if it can help speeding things up, and replace 
the author and SoB line with your name and address.

-- 
Regards,

Laurent Pinchart

[-- Attachment #2: 0001-lib-vsprintf.c-add-paD-format-specifier-for-dma_addr.patch --]
[-- Type: text/x-patch, Size: 2594 bytes --]

From df335f75387fcb57bc81259ff6893f4458d47747 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Date: Wed, 27 Nov 2013 17:19:04 +0100
Subject: [PATCH] lib/vsprintf.c: add %paD format specifier for dma_addr_t
 types

Add the %paD format specifier for printing a dma_addr_t type, since the
DMA address size on some platforms can vary based on build options,
regardless of the native integer type.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 Documentation/printk-formats.txt |  7 +++++++
 lib/vsprintf.c                   | 14 +++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 445ad74..3344ca9 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -63,6 +63,13 @@ Physical addresses:
 	resource_size_t) which can vary based on build options, regardless of
 	the width of the CPU data path. Passed by reference.
 
+DMA addresses:
+
+	%paD	0x01234567 or 0x0123456789abcdef
+
+	For printing a dma_addr_t type which can vary based on build options,
+	regardless of the width of the CPU data path. Passed by reference.
+
 Raw buffer as a hex string:
 	%*ph	00 01 02  ...  3f
 	%*phC	00:01:02: ... :3f
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 10909c5..2e3f7ea 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1219,6 +1219,7 @@ int kptr_restrict __read_mostly;
  *            The maximum supported length is 64 bytes of the input. Consider
  *            to use print_hex_dump() for the larger input.
  * - 'a' For a phys_addr_t type and its derivative types (passed by reference)
+ * - 'aD' For a dma_addr_t type (passed by reference)
  * - 'd[234]' For a dentry name (optionally 2-4 last components)
  * - 'D[234]' Same as 'd' but for a struct file
  *
@@ -1354,10 +1355,17 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
 		break;
 	case 'a':
 		spec.flags |= SPECIAL | SMALL | ZEROPAD;
-		spec.field_width = sizeof(phys_addr_t) * 2 + 2;
 		spec.base = 16;
-		return number(buf, end,
-			      (unsigned long long) *((phys_addr_t *)ptr), spec);
+		switch (fmt[1]) {
+		case 'D':
+			spec.field_width = sizeof(dma_addr_t) * 2 + 2;
+			return number(buf, end,
+				(unsigned long long)*((dma_addr_t *)ptr), spec);
+		default:
+			spec.field_width = sizeof(phys_addr_t) * 2 + 2;
+			return number(buf, end,
+				(unsigned long long)*((phys_addr_t *)ptr), spec);
+		}
 	case 'd':
 		return dentry_name(buf, end, ptr, spec, fmt);
 	case 'D':
-- 
1.8.3.2


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

* Re: [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats
  2013-11-27  0:29 [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Laurent Pinchart
                   ` (2 preceding siblings ...)
  2013-11-27 16:24 ` Laurent Pinchart
@ 2013-11-28  9:25 ` Andy Shevchenko
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2013-11-28  9:25 UTC (permalink / raw)
  To: linux-sh

On Wed, 2013-11-27 at 17:24 +0100, Laurent Pinchart wrote:
> Hi Andriy,
> 
> On Wednesday 27 November 2013 17:03:25 Laurent Pinchart wrote:
> > Hi Andy,
> 
> Sorry for the misspelling.

Nothing to sorry for. Andy is better recognizable name of me in virtual
world, though Andriy is an official one. I forgot to use
@linux.intel.com address in the message, that's why you got it with
different name. Please, continue to use Andy.

[]

> > > > +		"chaining (%zu/%zu)@%lx -> %lx with %p, cookie %d\n",
> > > > +		copy_size, *len, (unsigned long)*src, (unsigned long)*dst,
> > > > +		&new->async_tx, new->async_tx.cookie);
> > > 
> > > Instead of dancing with casting (actually for dma_addr_t it should be
> > > ULL type), we can extend %pa to do this job for us:
> >
> > That sounds good to me. Do you plan to submit a patch ? I'd like to get this
> > series upstream in v3.14.
> 
> Please use the attached patch if it can help speeding things up, and replace 
> the author and SoB line with your name and address.

Okay, will do right now. Thanks.


-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy


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

end of thread, other threads:[~2013-11-28  9:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-27  0:29 [PATCH 1/3] DMA: shdma: Fix warnings due to improper casts and printk formats Laurent Pinchart
2013-11-27 12:27 ` Shevchenko, Andriy
2013-11-27 16:03 ` Laurent Pinchart
2013-11-27 16:24 ` Laurent Pinchart
2013-11-28  9:25 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.