linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Don Dutile <ddutile@redhat.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	indou.takao@jp.fujitsu.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 8/9] pci: Tune secondary bus reset timing
Date: Thu, 01 Aug 2013 15:41:20 -0600	[thread overview]
Message-ID: <1375393280.31262.254.camel@ul30vt.home> (raw)
In-Reply-To: <51FAD338.5000306@redhat.com>

On Thu, 2013-08-01 at 17:29 -0400, Don Dutile wrote:
> On 08/01/2013 12:55 PM, Alex Williamson wrote:
> > The PCI spec indicates that with stable power, reset needs to be
> > asserted for a minimum of 1ms (Trst).  Seems like we should be able
> > to assume power is stable for a runtime secondary bus reset.  The
> > current code has always used 100ms with no explanation where that
> > came from.  The aer_do_secondary_bus_reset() function uses 2ms, but
> > that seems to be a misinterpretation of the PCIe spec, where hot
> > reset is implemented by TS1 ordered sets containing the hot reset
> > command.  After a 2ms delay the state machine enters the detect state,
> > but to generate a link down, only two consecutive TS1 hot reset
> > ordered sets are requred.  1ms should be plenty for that.
> >
> > After reset is de-asserted we must wait for devices to complete
> > initialization.  The specs refer to this as "recovery time" (Trhfa).
> > For PCI this is 2^25 clock cycles or 2^26 for PCI-X.  For minimum
> > bus speeds, both of those come to 1s.  PCIe "softens" this
> > requirement with the Configuration Request Retry Status (CRS)
> > completion status.  Theoretically we could use CRS to shorten the
> > wait time.  We don't make use of that here, using a fixed 1s delay
> > to allow devices to re-initialize.
> Unfortunately, I don't think CRS is widely supported to make it worth
> the additional checking & use, atm.
> 
> >
> > Signed-off-by: Alex Williamson<alex.williamson@redhat.com>
> > ---
> >   drivers/pci/pci.c |   15 +++++++++++++--
> >   1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> > index 3e71887..a5c6a9b 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -3291,11 +3291,22 @@ void pci_reset_bridge_secondary_bus(struct pci_dev *dev)
> >   	pci_read_config_word(dev, PCI_BRIDGE_CONTROL,&ctrl);
> >   	ctrl |= PCI_BRIDGE_CTL_BUS_RESET;
> >   	pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl);
> > -	msleep(100);
> > +	/*
> > +	 * PCI spec v3.0 7.6.4.2 requires minimum Trst of 1ms.
> > +	 */
> > +	msleep(1);
> >
> >   	ctrl&= ~PCI_BRIDGE_CTL_BUS_RESET;
> >   	pci_write_config_word(dev, PCI_BRIDGE_CONTROL, ctrl);
> > -	msleep(100);
> > +
> > +	/*
> > +	 * Trhfa for conventional PCI is 2^25 clock cycles.
> > +	 * Assuming a minimum 33MHz clock this results in a 1s
> > +	 * delay before we can consider subordinate devices to
> > +	 * be re-initialized.  PCIe has some ways to shorten this,
> > +	 * but we don't make use of them yet.
> > +	 */
> > +	ssleep(1);
> Can't bus speed be determined from (config space) status bits, so
> this time can be minimized, esp. on modern, PCIe busses/links ?
> Not too many 33Mhz, legacy PCI busses that this type of
> timing is desired, or will be done to (for device assignment/vfio). :-/

Just like CRS, is it worth it?  The PCIe spec seems to indicate a 1s
Trhfa regardless of bus speed.  Even if it didn't, we'd need to walk
down through all the subordinate buses to find a least common
denominator.  It seems sufficiently complicated to save it for a later
optimization.  Thanks,

Alex

> >   }
> >   EXPORT_SYMBOL_GPL(pci_reset_bridge_secondary_bus);
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 




  reply	other threads:[~2013-08-01 21:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01 16:55 [PATCH v3 0/9] pci: bus and slot reset interfaces Alex Williamson
2013-08-01 16:55 ` [PATCH v3 1/9] pci: Create pci_reset_bridge_secondary_bus() Alex Williamson
2013-08-01 16:55 ` [PATCH v3 2/9] pci: Add hotplug_slot_ops.reset_slot() Alex Williamson
2013-08-01 16:55 ` [PATCH v3 3/9] pci: Implement reset_slot for pciehp Alex Williamson
2013-08-01 16:55 ` [PATCH v3 4/9] pci: Add slot reset option to pci_dev_reset Alex Williamson
2013-08-01 16:55 ` [PATCH v3 5/9] pci: Split out pci_dev lock/unlock and save/restore Alex Williamson
2013-08-01 20:59   ` Don Dutile
2013-08-01 21:04     ` Alex Williamson
2013-08-01 16:55 ` [PATCH v3 6/9] pci: Add slot and bus reset interfaces Alex Williamson
2013-08-01 21:22   ` Don Dutile
2013-08-01 21:32     ` Alex Williamson
2013-08-01 16:55 ` [PATCH v3 7/9] pci: Wake-up devices before save for reset Alex Williamson
2013-08-01 16:55 ` [PATCH v3 8/9] pci: Tune secondary bus reset timing Alex Williamson
2013-08-01 21:29   ` Don Dutile
2013-08-01 21:41     ` Alex Williamson [this message]
2013-08-01 21:55       ` Don Dutile
2013-08-01 16:56 ` [PATCH v3 9/9] pci: Remove aer_do_secondary_bus_reset() Alex Williamson

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=1375393280.31262.254.camel@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=ddutile@redhat.com \
    --cc=indou.takao@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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).