Re: [PATCH] tracing: Expose CPU physical addresses (resource values) for PCI devices

From: Benjamin Herrenschmidt
Date: Fri Jun 17 2016 - 18:23:49 EST


On Fri, 2016-06-17 at 17:59 -0400, Steven Rostedt wrote:
> Sorry for the late reply, this patch got pushed down in my INBOX.
>
> Could I get someone from PPC to review this patch, just to be safe?

The patch makes sense, I can try getting somebody onto porting
mmiotrace one of these days.

Cheers,
Ben.

> Thanks!
>
> -- Steve
>
>
>
> On Wed, 11 May 2016 14:06:57 -0500
> Bjorn Helgaas <bhelgaas@xxxxxxxxxx> wrote:
>
> > Previously, mmio_print_pcidev() put "user" addresses in the trace
> > buffer.
> > On most architectures, these are the same as CPU physical
> > addresses, but on
> > microblaze, mips, powerpc, and sparc, they may be something else,
> > typically
> > a raw BAR value (a bus address as opposed to a CPU address).
> >
> > Always expose the CPU physical address to avoid this arch-dependent
> > behavior.
> >
> > This change should have no user-visible effect because this file
> > currently
> > depends on CONFIG_HAVE_MMIOTRACE_SUPPORT, which is only defined for
> > x86,
> > and pci_resource_to_user() is a no-op on x86.
> >
> > Signed-off-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> > ---
> > Âkernel/trace/trace_mmiotrace.c |ÂÂÂ10 +++-------
> > Â1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/kernel/trace/trace_mmiotrace.c
> > b/kernel/trace/trace_mmiotrace.c
> > index 68f376c..cd7480d 100644
> > --- a/kernel/trace/trace_mmiotrace.c
> > +++ b/kernel/trace/trace_mmiotrace.c
> > @@ -68,19 +68,15 @@ static void mmio_print_pcidev(struct trace_seq
> > *s, const struct pci_dev *dev)
> > Â trace_seq_printf(s, "PCIDEV %02x%02x %04x%04x %x",
> > Â Âdev->bus->number, dev->devfn,
> > Â Âdev->vendor, dev->device, dev->irq);
> > - /*
> > - Â* XXX: is pci_resource_to_user() appropriate, since we
> > are
> > - Â* supposed to interpret the __ioremap() phys_addr
> > argument based on
> > - Â* these printed values?
> > - Â*/
> > Â for (i = 0; i < 7; i++) {
> > - pci_resource_to_user(dev, i, &dev->resource[i],
> > &start, &end);
> > + start = dev->resource[i].start;
> > Â trace_seq_printf(s, " %llx",
> > Â (unsigned long long)(start |
> > Â (dev->resource[i].flags &
> > PCI_REGION_FLAG_MASK)));
> > Â }
> > Â for (i = 0; i < 7; i++) {
> > - pci_resource_to_user(dev, i, &dev->resource[i],
> > &start, &end);
> > + start = dev->resource[i].start;
> > + end = dev->resource[i].end;
> > Â trace_seq_printf(s, " %llx",
> > Â dev->resource[i].start < dev-
> > >resource[i].end ?
> > Â (unsigned long long)(end - start) + 1 :
> > 0);
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@xxxxxxxxxxxxxxxx
> https://lists.ozlabs.org/listinfo/linuxppc-dev