diff mbox

[1/8] IB/cxgb4: Fix formatting of physical address

Message ID 1382910645.2994.45.camel@deadeye.wl.decadent.org.uk (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Ben Hutchings Oct. 27, 2013, 9:50 p.m. UTC
Physical addresses may be wider than virtual addresses (e.g. on i386
with PAE) and must not be formatted with %p.

Compile-tested only.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
The resource could also be printed using '%pR' or '%pr', but that makes
a bigger change to the output.

Ben.

 drivers/infiniband/hw/cxgb4/device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joe Perches Oct. 27, 2013, 9:58 p.m. UTC | #1
On Sun, 2013-10-27 at 21:50 +0000, Ben Hutchings wrote:
> Physical addresses may be wider than virtual addresses (e.g. on i386
> with PAE) and must not be formatted with %p.

%pa works.  %pa also prefixes with 0x.

> diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
[]
> @@ -602,10 +602,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
>  	     rdev->lldi.vr->qp.size,
>  	     rdev->lldi.vr->cq.start,
>  	     rdev->lldi.vr->cq.size);
> -	PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu "
> +	PDBG("udb len 0x%x udb base %llx db_reg %p gts_reg %p qpshift %lu "
>  	     "qpmask 0x%x cqshift %lu cqmask 0x%x\n",
>  	     (unsigned)pci_resource_len(rdev->lldi.pdev, 2),
> -	     (void *)(unsigned long)pci_resource_start(rdev->lldi.pdev, 2),
> +	     (u64)pci_resource_start(rdev->lldi.pdev, 2),
>  	     rdev->lldi.db_reg,
>  	     rdev->lldi.gts_reg,
>  	     rdev->qpshift, rdev->qpmask,
> 
> 



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings Oct. 27, 2013, 10:02 p.m. UTC | #2
On Sun, 2013-10-27 at 14:58 -0700, Joe Perches wrote:
> On Sun, 2013-10-27 at 21:50 +0000, Ben Hutchings wrote:
> > Physical addresses may be wider than virtual addresses (e.g. on i386
> > with PAE) and must not be formatted with %p.
> 
> %pa works.  %pa also prefixes with 0x.

Only as long as pci_resource_start() happens to be an lvalue.  I'd
rather not introduce that assumption.

Ben.

> > diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
> []
> > @@ -602,10 +602,10 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
> >  	     rdev->lldi.vr->qp.size,
> >  	     rdev->lldi.vr->cq.start,
> >  	     rdev->lldi.vr->cq.size);
> > -	PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu "
> > +	PDBG("udb len 0x%x udb base %llx db_reg %p gts_reg %p qpshift %lu "
> >  	     "qpmask 0x%x cqshift %lu cqmask 0x%x\n",
> >  	     (unsigned)pci_resource_len(rdev->lldi.pdev, 2),
> > -	     (void *)(unsigned long)pci_resource_start(rdev->lldi.pdev, 2),
> > +	     (u64)pci_resource_start(rdev->lldi.pdev, 2),
> >  	     rdev->lldi.db_reg,
> >  	     rdev->lldi.gts_reg,
> >  	     rdev->qpshift, rdev->qpmask,
> > 
> > 
> 
> 
>
Joe Perches Oct. 27, 2013, 10:14 p.m. UTC | #3
On Sun, 2013-10-27 at 22:02 +0000, Ben Hutchings wrote:
> On Sun, 2013-10-27 at 14:58 -0700, Joe Perches wrote:
> > On Sun, 2013-10-27 at 21:50 +0000, Ben Hutchings wrote:
> > > Physical addresses may be wider than virtual addresses (e.g. on i386
> > > with PAE) and must not be formatted with %p.
> > 
> > %pa works.  %pa also prefixes with 0x.
> 
> Only as long as pci_resource_start() happens to be an lvalue.  I'd
> rather not introduce that assumption.

pci_resource_start returns a resource_size_t which is a phys_addr_t.

Changing that from an lvalue would cause a _lot_ of breakage.


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings Oct. 27, 2013, 10:26 p.m. UTC | #4
On Sun, 2013-10-27 at 15:14 -0700, Joe Perches wrote:
> On Sun, 2013-10-27 at 22:02 +0000, Ben Hutchings wrote:
> > On Sun, 2013-10-27 at 14:58 -0700, Joe Perches wrote:
> > > On Sun, 2013-10-27 at 21:50 +0000, Ben Hutchings wrote:
> > > > Physical addresses may be wider than virtual addresses (e.g. on i386
> > > > with PAE) and must not be formatted with %p.
> > > 
> > > %pa works.  %pa also prefixes with 0x.
> > 
> > Only as long as pci_resource_start() happens to be an lvalue.  I'd
> > rather not introduce that assumption.
> 
> pci_resource_start returns a resource_size_t which is a phys_addr_t.
> 
> Changing that from an lvalue would cause a _lot_ of breakage.

I don't think so.  This doesn't find anything:
    git grep '&[ (]*pci_resource_start'

and I was able to build drivers/{net,pci,scsi}/ successfully with
pci_resource_start() changed to an inline function.

Ben.
Joe Perches Oct. 27, 2013, 10:54 p.m. UTC | #5
On Sun, 2013-10-27 at 22:26 +0000, Ben Hutchings wrote:
> I don't think so.  This doesn't find anything:
>     git grep '&[ (]*pci_resource_start'
> and I was able to build drivers/{net,pci,scsi}/ successfully with
> pci_resource_start() changed to an inline function.

Hi again Ben.  You're right.

It could be nice though to have some mechanism to get from
a pci_resource_start/end that could be emitted via %pa
without an intermediate or casting like
(unsigned long long)pci_resource_<foo>(struct resource *)

There are at least a few dozen uses of dmesg/seq_printf with
%llx or %lx and (some_cast)pci_resource_<foo> that could be
converted.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 33d2cc6..4a03385 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -602,10 +602,10 @@  static int c4iw_rdev_open(struct c4iw_rdev *rdev)
 	     rdev->lldi.vr->qp.size,
 	     rdev->lldi.vr->cq.start,
 	     rdev->lldi.vr->cq.size);
-	PDBG("udb len 0x%x udb base %p db_reg %p gts_reg %p qpshift %lu "
+	PDBG("udb len 0x%x udb base %llx db_reg %p gts_reg %p qpshift %lu "
 	     "qpmask 0x%x cqshift %lu cqmask 0x%x\n",
 	     (unsigned)pci_resource_len(rdev->lldi.pdev, 2),
-	     (void *)(unsigned long)pci_resource_start(rdev->lldi.pdev, 2),
+	     (u64)pci_resource_start(rdev->lldi.pdev, 2),
 	     rdev->lldi.db_reg,
 	     rdev->lldi.gts_reg,
 	     rdev->qpshift, rdev->qpmask,