From: Bjorn Helgaas <helgaas@kernel.org>
To: Oza Oza <oza.oza@broadcom.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>, Ray Jui <rjui@broadcom.com>,
Scott Branden <sbranden@broadcom.com>,
Jon Mason <jonmason@broadcom.com>,
BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>,
Andy Gospodarek <gospo@broadcom.com>,
linux-pci <linux-pci@vger.kernel.org>,
linux-kernel@vger.kernel.org,
Oza Pawandeep <oza.pawandeep@gmail.com>
Subject: Re: [PATCH v6 1/2] PCI: iproc: Retry request when CRS returned from EP
Date: Sat, 19 Aug 2017 15:26:16 -0500 [thread overview]
Message-ID: <20170819202616.GA32411@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <CAMSpPPdvKTtCkv76mMBgqpbjf=T7EnSz6KBmVxVrRRSou-oE3g@mail.gmail.com>
On Sun, Aug 20, 2017 at 01:02:09AM +0530, Oza Oza wrote:
> On Sat, Aug 19, 2017 at 11:56 PM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> > I think you should do something like this instead so you don't do the
> > MMIO read any more times than necessary:
> >
> > static u32 iproc_pcie_cfg_retry(void __iomem *cfg_data_p)
> > {
> > u32 data;
> > int timeout = CFG_RETRY_STATUS_TIMEOUT_US;
> >
> > data = readl(cfg_data_p);
> > while (data == CFG_RETRY_STATUS && timeout--) {
> > udelay(1);
> > data = readl(cfg_data_p);
> > }
> >
> > if (data == CFG_RETRY_STATUS)
> > data = 0xffffffff;
> > return data;
> > }
> >
> > static int iproc_pcie_config_read(...)
> > {
> > u32 data;
> >
> > ...
> > data = iproc_pcie_cfg_retry(cfg_data_p);
> > if (size <= 2)
> > *val = (data >> (8 * (where & 3))) & ((1 << (size * 8)) - 1);
> >
> > In the event of a timeout, this returns PCIBIOS_SUCCESSFUL and
> > 0xffffffff data. That's what most other platforms do, and most
> > callers of the PCI config accessors check for that data instead of
> > checking the return code to see whether the access was successful.
> >
> I see one problem with this.
> we have Samsung NVMe which exposes 64-bit IO BAR.
> 0xffff0001.
>
> and if you see __pci_read_base which does following in sequence.
>
> pci_read_config_dword(dev, pos, &l);
> pci_write_config_dword(dev, pos, l | mask);
> pci_read_config_dword(dev, pos, &sz);
> pci_write_config_dword(dev, pos, l);
>
> returning 0xffffffff would not be correct in that case.
> even if callers retry, they will end up in a loop if caller retries.
>
> hence I was returning 0xffff0001, it is upto the upper layer to treat
> it as data or not.
In your patch, I don't think the upper layer will ever see 0xffff0001.
iproc_pcie_config_read() only updates *data if iproc_pcie_cfg_retry()
returns PCIBIOS_SUCCESSFUL. And iproc_pcie_cfg_retry() only returns
PCIBIOS_SUCCESSFUL if it reads something other than 0xffff0001.
Even if you *did* return 0xffff0001 to upper layers, I think we'd have
a problem. Here's an example scenario. If we do a Function-Level
Reset, pcie_flr() starts the reset, then calls pci_flr_wait() to wait
until the device becomes ready again. pci_flr_wait() thinks that any
PCI_COMMAND value other than 0xffffffff means the device is ready.
If the device returns CRS status and you return 0xffff0001 when
pci_flr_wait() reads PCI_COMMAND, it thinks that means the device is
ready, but it's not.
> let me know if this sounds like a problem to you as well.
>
> so in my opinion returning 0xffffffff is not an option.
>
> > For example, pci_flr_wait() assumes that if a read of PCI_COMMAND
> > returns ~0, it's because the device isn't ready yet, and we should
> > wait and retry.
next prev parent reply other threads:[~2017-08-19 20:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 15:48 [PATCH v6 0/2] PCI: iproc: SOC specific fixes Oza Pawandeep
2017-08-04 15:48 ` [PATCH v6 1/2] PCI: iproc: Retry request when CRS returned from EP Oza Pawandeep
2017-08-19 18:26 ` Bjorn Helgaas
2017-08-19 18:52 ` Oza Oza
2017-08-19 19:32 ` Oza Oza
2017-08-19 20:26 ` Bjorn Helgaas [this message]
2017-08-20 3:42 ` Oza Oza
2017-08-04 15:48 ` [PATCH v6 2/2] PCI: iproc: add device shutdown for PCI RC Oza Pawandeep
2017-08-19 21:04 ` Bjorn Helgaas
2017-08-20 3:36 ` Oza Oza
2017-08-20 21:25 ` Bjorn Helgaas
2017-08-21 3:01 ` Oza Oza
2017-08-19 17:10 ` [PATCH v6 0/2] PCI: iproc: SOC specific fixes Bjorn Helgaas
2017-08-19 18:18 ` Oza Oza
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=20170819202616.GA32411@bhelgaas-glaptop.roam.corp.google.com \
--to=helgaas@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=gospo@broadcom.com \
--cc=jonmason@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=oza.oza@broadcom.com \
--cc=oza.pawandeep@gmail.com \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.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
all inboxes | Powered by JetHome®