linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PCIe: readl()
@ 2022-01-06 17:13 Muni Sekhar
  2022-01-06 22:18 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Muni Sekhar @ 2022-01-06 17:13 UTC (permalink / raw)
  To: linux-pci

Hi all,

We have a free-running counter on x86 PCIe bus and plan to use it as a
clocksource. The 'read' field of the clocksource structure reads from
this free-running counter and returns this value.

Since PCIe reads are synchronous, is it safe to use readl() API to
read this free-running counter value in struct clocksource.read()? If
not, what's the best way to read the counter value from the struct
clocksource read field?

Is there any other faster method to read from PCIe device memory?


-- 
Thanks,
Sekhar

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

* Re: PCIe: readl()
  2022-01-06 17:13 PCIe: readl() Muni Sekhar
@ 2022-01-06 22:18 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2022-01-06 22:18 UTC (permalink / raw)
  To: Muni Sekhar; +Cc: linux-pci

On Thu, Jan 06, 2022 at 10:43:52PM +0530, Muni Sekhar wrote:
> Hi all,
> 
> We have a free-running counter on x86 PCIe bus and plan to use it as a
> clocksource. The 'read' field of the clocksource structure reads from
> this free-running counter and returns this value.
> 
> Since PCIe reads are synchronous, is it safe to use readl() API to
> read this free-running counter value in struct clocksource.read()? If
> not, what's the best way to read the counter value from the struct
> clocksource read field?

Yes, you can use readl().  Of course, the driver for your PCIe device
will have to do the usual setup, e.g.,

  probe(struct pci_dev *dev)
  {
    pci_request_regions(dev, "name");
    addr = pci_ioremap_bar(dev, 0);
    readl(addr);

The readl() should give you a single PCIe transaction, which is the
best you can do.

Bjorn

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

end of thread, other threads:[~2022-01-06 22:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06 17:13 PCIe: readl() Muni Sekhar
2022-01-06 22:18 ` Bjorn Helgaas

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