linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Muni Sekhar <munisekharrms@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: PCIe: readl()
Date: Thu, 6 Jan 2022 16:18:56 -0600	[thread overview]
Message-ID: <20220106221856.GA328650@bhelgaas> (raw)
In-Reply-To: <CAHhAz+jFFqD=M=F8y6V_M1f6HDnBnzZDhOJt-G-pzWLHC4idFA@mail.gmail.com>

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

      reply	other threads:[~2022-01-06 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 17:13 PCIe: readl() Muni Sekhar
2022-01-06 22:18 ` Bjorn Helgaas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220106221856.GA328650@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=munisekharrms@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).