public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ftrace use of pci_resource_to_user()
@ 2016-05-04 19:17 Bjorn Helgaas
  2016-05-04 19:34 ` Steven Rostedt
  2016-05-06 10:16 ` Pekka Paalanen
  0 siblings, 2 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2016-05-04 19:17 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar, Pekka Paalanen; +Cc: linux-kernel, Yinghai Lu

138295373ccf ("ftrace: mmiotrace update, #2") added this use of
pci_resource_to_user():

  +static int mmio_print_pcidev(struct trace_seq *s, const struct pci_dev *dev)
  +{
  ...
  +       /*
  +        * 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);
  +               ret += trace_seq_printf(s, " %llx",
  +                       (unsigned long long)(start |
  +                       (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
  +       }

I think it was a mistake to use pci_resource_to_user() here because it
adds unnecessary arch dependencies in whatever consumes this output.

On most arches, pci_resource_to_user() is a no-op and the result is
normal resource addresses, i.e., CPU physical addresses that match
things in /proc/iomem and /sys/devices/pci.../resource.

On microblaze, mips, powerpc, and sparc, the result of
pci_resource_to_user() is something else, usually a PCI bus address (a
raw BAR value).  These values are only useful for using mmap on
files like /proc/bus/pci/....

I don't know what, if anything, consumes this output.  If things parse
it, we shouldn't break them.  But those things likely would need
special cases for microblaze, mips, powerpc, and sparc.

If it's only for human consumption, I think we should consider
removing the use of pci_resource_to_user() and printing
dev->resource[i].start instead.

Bjorn

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

end of thread, other threads:[~2016-05-11 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-04 19:17 ftrace use of pci_resource_to_user() Bjorn Helgaas
2016-05-04 19:34 ` Steven Rostedt
2016-05-06 10:16 ` Pekka Paalanen
2016-05-06 10:33   ` karol herbst
2016-05-11 19:04     ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox