linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: Fix compiler warning on pr_debug
@ 2013-06-21 15:33 Alex Williamson
  2013-06-23 11:49 ` Joerg Roedel
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Williamson @ 2013-06-21 15:33 UTC (permalink / raw)
  To: joro; +Cc: iommu, linux-kernel

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 drivers/iommu/iommu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 4b0b56b..ab1fa19 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -820,7 +820,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
 		size_t pgsize = iommu_pgsize(domain, iova | paddr, size);
 
 		pr_debug("mapping: iova 0x%lx pa 0x%lx pgsize %lu\n", iova,
-					(unsigned long)paddr, pgsize);
+			 (unsigned long)paddr, (unsigned long)pgsize);
 
 		ret = domain->ops->map(domain, iova, paddr, pgsize, prot);
 		if (ret)


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

* Re: [PATCH] iommu: Fix compiler warning on pr_debug
  2013-06-21 15:33 [PATCH] iommu: Fix compiler warning on pr_debug Alex Williamson
@ 2013-06-23 11:49 ` Joerg Roedel
  2013-06-23 17:43   ` [PATCH] iommu: Use %zx instead %lx and cast to unsigned long Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: Joerg Roedel @ 2013-06-23 11:49 UTC (permalink / raw)
  To: Alex Williamson; +Cc: iommu, linux-kernel

On Fri, Jun 21, 2013 at 09:33:50AM -0600, Alex Williamson wrote:
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>  drivers/iommu/iommu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 4b0b56b..ab1fa19 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -820,7 +820,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
>  		size_t pgsize = iommu_pgsize(domain, iova | paddr, size);
>  
>  		pr_debug("mapping: iova 0x%lx pa 0x%lx pgsize %lu\n", iova,
> -					(unsigned long)paddr, pgsize);
> +			 (unsigned long)paddr, (unsigned long)pgsize);
>  
>  		ret = domain->ops->map(domain, iova, paddr, pgsize, prot);
>  		if (ret)

Applied to core branch, thanks.



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

* [PATCH] iommu: Use %zx instead %lx and cast to unsigned long
  2013-06-23 11:49 ` Joerg Roedel
@ 2013-06-23 17:43   ` Joe Perches
  2013-06-23 19:14     ` Geert Uytterhoeven
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2013-06-23 17:43 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Alex Williamson, iommu, linux-kernel

printf support size_t hex type %zx so use that
instead of %lx and a cast to unsigned long.

Other miscellaneous changes around this:

Always use 0x%zx for size instead of one use of decimal.
Coalesce format and align arguments.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/iommu/iommu.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ab1fa19..7aa98c8 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -807,20 +807,19 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
 	 * size of the smallest page supported by the hardware
 	 */
 	if (!IS_ALIGNED(iova | paddr | size, min_pagesz)) {
-		pr_err("unaligned: iova 0x%lx pa 0x%lx size 0x%lx min_pagesz "
-			"0x%x\n", iova, (unsigned long)paddr,
-			(unsigned long)size, min_pagesz);
+		pr_err("unaligned: iova 0x%lx pa 0x%lx size 0x%zx min_pagesz 0x%x\n",
+		       iova, (unsigned long)paddr, size, min_pagesz);
 		return -EINVAL;
 	}
 
-	pr_debug("map: iova 0x%lx pa 0x%lx size 0x%lx\n", iova,
-				(unsigned long)paddr, (unsigned long)size);
+	pr_debug("map: iova 0x%lx pa 0x%lx size 0x%zx\n",
+		 iova, (unsigned long)paddr, size);
 
 	while (size) {
 		size_t pgsize = iommu_pgsize(domain, iova | paddr, size);
 
-		pr_debug("mapping: iova 0x%lx pa 0x%lx pgsize %lu\n", iova,
-			 (unsigned long)paddr, (unsigned long)pgsize);
+		pr_debug("mapping: iova 0x%lx pa 0x%lx pgsize 0x%zx\n",
+			 iova, (unsigned long)paddr, pgsize);
 
 		ret = domain->ops->map(domain, iova, paddr, pgsize, prot);
 		if (ret)
@@ -857,13 +856,12 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
 	 * by the hardware
 	 */
 	if (!IS_ALIGNED(iova | size, min_pagesz)) {
-		pr_err("unaligned: iova 0x%lx size 0x%lx min_pagesz 0x%x\n",
-					iova, (unsigned long)size, min_pagesz);
+		pr_err("unaligned: iova 0x%lx size 0x%zx min_pagesz 0x%x\n",
+		       iova, size, min_pagesz);
 		return -EINVAL;
 	}
 
-	pr_debug("unmap this: iova 0x%lx size 0x%lx\n", iova,
-							(unsigned long)size);
+	pr_debug("unmap this: iova 0x%lx size 0x%zx\n", iova, size);
 
 	/*
 	 * Keep iterating until we either unmap 'size' bytes (or more)
@@ -876,8 +874,8 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
 		if (!unmapped_page)
 			break;
 
-		pr_debug("unmapped: iova 0x%lx size %lx\n", iova,
-					(unsigned long)unmapped_page);
+		pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
+			 iova, unmapped_page);
 
 		iova += unmapped_page;
 		unmapped += unmapped_page;



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

* Re: [PATCH] iommu: Use %zx instead %lx and cast to unsigned long
  2013-06-23 17:43   ` [PATCH] iommu: Use %zx instead %lx and cast to unsigned long Joe Perches
@ 2013-06-23 19:14     ` Geert Uytterhoeven
  2013-06-23 19:29       ` [PATCH V2] iommu: Use %pa and %zx instead of casting Joe Perches
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2013-06-23 19:14 UTC (permalink / raw)
  To: Joe Perches
  Cc: Joerg Roedel, Alex Williamson, iommu,
	linux-kernel@vger.kernel.org

On Sun, Jun 23, 2013 at 7:43 PM, Joe Perches <joe@perches.com> wrote:
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -807,20 +807,19 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
>          * size of the smallest page supported by the hardware
>          */
>         if (!IS_ALIGNED(iova | paddr | size, min_pagesz)) {
> -               pr_err("unaligned: iova 0x%lx pa 0x%lx size 0x%lx min_pagesz "
> -                       "0x%x\n", iova, (unsigned long)paddr,
> -                       (unsigned long)size, min_pagesz);
> +               pr_err("unaligned: iova 0x%lx pa 0x%lx size 0x%zx min_pagesz 0x%x\n",
> +                      iova, (unsigned long)paddr, size, min_pagesz);

While we're at it, paddr is phys_addr_t (which can be 32-bit or 64-bit),
so it should be cast to unsigned long long (instead of unsigned long),
and printed using %llx (instead of %lx).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* [PATCH V2] iommu: Use %pa and %zx instead of casting
  2013-06-23 19:14     ` Geert Uytterhoeven
@ 2013-06-23 19:29       ` Joe Perches
  2013-06-23 19:38         ` Geert Uytterhoeven
  2013-06-24 10:32         ` Joerg Roedel
  0 siblings, 2 replies; 7+ messages in thread
From: Joe Perches @ 2013-06-23 19:29 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joerg Roedel, Alex Williamson, iommu,
	linux-kernel@vger.kernel.org

printk supports using %pa for phys_addr_t and
%zx for size_t so use those instead of %lx and
casts to unsigned long.

Other miscellaneous changes around this:

Always use 0x%zx for size instead of one use of decimal.
Coalesce format and align arguments.

Signed-off-by: Joe Perches <joe@perches.com>
---
> While we're at it, paddr is phys_addr_t (which can be 32-bit or 64-bit),
> so it should be cast to unsigned long long (instead of unsigned long),
> and printed using %llx (instead of %lx).

Sounds good to me, except using %pa instead is better still.

 drivers/iommu/iommu.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index ab1fa19..fbe9ca7 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -807,20 +807,18 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
 	 * size of the smallest page supported by the hardware
 	 */
 	if (!IS_ALIGNED(iova | paddr | size, min_pagesz)) {
-		pr_err("unaligned: iova 0x%lx pa 0x%lx size 0x%lx min_pagesz "
-			"0x%x\n", iova, (unsigned long)paddr,
-			(unsigned long)size, min_pagesz);
+		pr_err("unaligned: iova 0x%lx pa 0x%pa size 0x%zx min_pagesz 0x%x\n",
+		       iova, &paddr, size, min_pagesz);
 		return -EINVAL;
 	}
 
-	pr_debug("map: iova 0x%lx pa 0x%lx size 0x%lx\n", iova,
-				(unsigned long)paddr, (unsigned long)size);
+	pr_debug("map: iova 0x%lx pa 0x%pa size 0x%zx\n", iova, &paddr, size);
 
 	while (size) {
 		size_t pgsize = iommu_pgsize(domain, iova | paddr, size);
 
-		pr_debug("mapping: iova 0x%lx pa 0x%lx pgsize %lu\n", iova,
-			 (unsigned long)paddr, (unsigned long)pgsize);
+		pr_debug("mapping: iova 0x%lx pa 0x%pa pgsize 0x%zx\n",
+			 iova, &paddr, pgsize);
 
 		ret = domain->ops->map(domain, iova, paddr, pgsize, prot);
 		if (ret)
@@ -857,13 +855,12 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
 	 * by the hardware
 	 */
 	if (!IS_ALIGNED(iova | size, min_pagesz)) {
-		pr_err("unaligned: iova 0x%lx size 0x%lx min_pagesz 0x%x\n",
-					iova, (unsigned long)size, min_pagesz);
+		pr_err("unaligned: iova 0x%lx size 0x%zx min_pagesz 0x%x\n",
+		       iova, size, min_pagesz);
 		return -EINVAL;
 	}
 
-	pr_debug("unmap this: iova 0x%lx size 0x%lx\n", iova,
-							(unsigned long)size);
+	pr_debug("unmap this: iova 0x%lx size 0x%zx\n", iova, size);
 
 	/*
 	 * Keep iterating until we either unmap 'size' bytes (or more)
@@ -876,8 +873,8 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
 		if (!unmapped_page)
 			break;
 
-		pr_debug("unmapped: iova 0x%lx size %lx\n", iova,
-					(unsigned long)unmapped_page);
+		pr_debug("unmapped: iova 0x%lx size 0x%zx\n",
+			 iova, unmapped_page);
 
 		iova += unmapped_page;
 		unmapped += unmapped_page;



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

* Re: [PATCH V2] iommu: Use %pa and %zx instead of casting
  2013-06-23 19:29       ` [PATCH V2] iommu: Use %pa and %zx instead of casting Joe Perches
@ 2013-06-23 19:38         ` Geert Uytterhoeven
  2013-06-24 10:32         ` Joerg Roedel
  1 sibling, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2013-06-23 19:38 UTC (permalink / raw)
  To: Joe Perches
  Cc: Joerg Roedel, Alex Williamson, iommu,
	linux-kernel@vger.kernel.org

On Sun, Jun 23, 2013 at 9:29 PM, Joe Perches <joe@perches.com> wrote:
>> While we're at it, paddr is phys_addr_t (which can be 32-bit or 64-bit),
>> so it should be cast to unsigned long long (instead of unsigned long),
>> and printed using %llx (instead of %lx).
>
> Sounds good to me, except using %pa instead is better still.

Thanks, you're right. Still not used to this newish %pa...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH V2] iommu: Use %pa and %zx instead of casting
  2013-06-23 19:29       ` [PATCH V2] iommu: Use %pa and %zx instead of casting Joe Perches
  2013-06-23 19:38         ` Geert Uytterhoeven
@ 2013-06-24 10:32         ` Joerg Roedel
  1 sibling, 0 replies; 7+ messages in thread
From: Joerg Roedel @ 2013-06-24 10:32 UTC (permalink / raw)
  To: Joe Perches
  Cc: Geert Uytterhoeven, Alex Williamson, iommu,
	linux-kernel@vger.kernel.org

On Sun, Jun 23, 2013 at 12:29:04PM -0700, Joe Perches wrote:
> printk supports using %pa for phys_addr_t and
> %zx for size_t so use those instead of %lx and
> casts to unsigned long.
> 
> Other miscellaneous changes around this:
> 
> Always use 0x%zx for size instead of one use of decimal.
> Coalesce format and align arguments.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied to core, thanks.



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

end of thread, other threads:[~2013-06-24 10:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-21 15:33 [PATCH] iommu: Fix compiler warning on pr_debug Alex Williamson
2013-06-23 11:49 ` Joerg Roedel
2013-06-23 17:43   ` [PATCH] iommu: Use %zx instead %lx and cast to unsigned long Joe Perches
2013-06-23 19:14     ` Geert Uytterhoeven
2013-06-23 19:29       ` [PATCH V2] iommu: Use %pa and %zx instead of casting Joe Perches
2013-06-23 19:38         ` Geert Uytterhoeven
2013-06-24 10:32         ` Joerg Roedel

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