From: Takao Indoh <indou.takao@jp.fujitsu.com>
To: alex.williamson@redhat.com
Cc: linux-pci@vger.kernel.org, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, hbabu@us.ibm.com,
iommu@lists.linux-foundation.org, ddutile@redhat.com,
bill.sumner@hp.com, ishii.hironobu@jp.fujitsu.com,
bhelgaas@google.com, vgoyal@redhat.com
Subject: Re: [PATCH v2] PCI: Reset PCIe devices to stop ongoing DMA
Date: Wed, 31 Jul 2013 14:50:58 +0900 [thread overview]
Message-ID: <51F8A5C2.1030805@jp.fujitsu.com> (raw)
In-Reply-To: <1375240269.31262.92.camel@ul30vt.home>
(2013/07/31 12:11), Alex Williamson wrote:
> On Wed, 2013-07-31 at 09:35 +0900, Takao Indoh wrote:
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index e37fea6..c595997 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -3392,6 +3392,59 @@ int pci_reset_function(struct pci_dev *dev)
>> EXPORT_SYMBOL_GPL(pci_reset_function);
>>
>> /**
>> + * pci_reset_bus - reset a PCI bus
>> + * @bus: PCI bus to reset
>> + *
>> + * Returns 0 if the bus was successfully reset or negative if failed.
>> + */
>> +int pci_reset_bus(struct pci_bus *bus)
>> +{
>> + struct pci_dev *pdev;
>> + u16 ctrl;
>> +
>> + if (!bus->self)
>> + return -ENOTTY;
>> +
>> + list_for_each_entry(pdev, &bus->devices, bus_list)
>> + if (pdev->subordinate)
>> + return -ENOTTY;
>> +
>> + /* Save config registers of children */
>> + list_for_each_entry(pdev, &bus->devices, bus_list) {
>> + dev_info(&pdev->dev, "Save state\n");
>> + pci_save_state(pdev);
>> + }
>> +
>> + dev_info(&bus->self->dev, "Reset Secondary bus\n");
>> +
>> + /* Assert Secondary Bus Reset */
>> + pci_read_config_word(bus->self, PCI_BRIDGE_CONTROL, &ctrl);
>> + ctrl |= PCI_BRIDGE_CTL_BUS_RESET;
>> + pci_write_config_word(bus->self, PCI_BRIDGE_CONTROL, ctrl);
>> +
>> + /* Read config again to flush previous write */
>> + pci_read_config_word(bus->self, PCI_BRIDGE_CONTROL, &ctrl);
>> +
>> + msleep(2);
>> +
>> + /* De-assert Secondary Bus Reset */
>> + ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET;
>> + pci_write_config_word(bus->self, PCI_BRIDGE_CONTROL, ctrl);
>> +
>> + /* Wait for completion */
>> + msleep(1000);
>
>
> We already have secondary bus reset code in this file, why are we
> duplicating it here? Also, why are these delays different from the
> existing code? I'm also in need of a bus reset interface for when we
> assign all of the devices on a bus to userspace and do not have working
> function level resets per device. I'll post my patch series and perhaps
> we can collaborate on a pci bus reset interface. Thanks,
Good point. Yes, we have already similar functions.
pci_parent_bus_reset()
1. Assert secondary bus reset
2. msleep(100)
3. De-assert secondary bus reset
4. msleep(100)
aer_do_secondary_bus_reset()
1. Assert secondary bus reset
2. msleep(2)
3. De-assert secondary bus reset,
4. msleep(200)
To be honest, I wrote my reset code almost one years ago, so I forgot
the reason why I separated them.
Basically my reset code is based on aer_do_secondary_bus_reset(). The
different is waiting time after reset. My patch has 1000msec waiting
time.
At first my reset code is almost same as aer_do_secondary_bus_reset().
But when I tested the reset code, I found that on certain machine
restoring config registers failed after reset. It failed because 200msec
waiting time was too short. And I found the following description in
PCIe spec. According to this, I thought we should wait at least 1000msec.
6.6.1. Conventional Reset
* The Root Complex and/or system software must allow at least 1.0s
after a Conventional Reset of a device, before it may determine that a
device which fails to return a Successful Completion status for a
valid Configuration Request is a broken device. This period is
independent of how quickly Link training completes.
Note: This delay is analogous to the Trhfa parameter specified for
PCI/PCI-X, and is intended to allow an adequate amount of time for
devices which require self initialization.
* When attempting a Configuration access to devices on a PCI or PCI-X
bus segment behind a PCI Express/PCI(-X) Bridge, the timing parameter
Trhfa must be respected.
And I saw patches you posted today, yes, your patch looks helpful for
my purpose:-)
Thanks,
Takao Indoh
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2013-07-31 5:51 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-14 5:29 [PATCH v2] PCI: Reset PCIe devices to stop ongoing DMA Takao Indoh
2013-05-14 22:04 ` Eric W. Biederman
2013-05-21 23:46 ` Takao Indoh
2013-06-06 7:25 ` Takao Indoh
2013-06-07 4:14 ` Bjorn Helgaas
2013-06-07 8:46 ` Takao Indoh
2013-06-11 2:20 ` Bjorn Helgaas
2013-06-11 6:08 ` Takao Indoh
2013-06-11 23:19 ` Sumner, William
2013-06-12 0:53 ` Bjorn Helgaas
2013-06-12 13:19 ` Don Dutile
2013-06-13 3:25 ` Takao Indoh
2013-06-12 4:45 ` Bjorn Helgaas
2013-06-13 2:44 ` Takao Indoh
2013-06-13 3:41 ` Bjorn Helgaas
2013-06-14 2:11 ` Takao Indoh
2013-07-24 6:29 ` Takao Indoh
2013-07-25 14:24 ` Vivek Goyal
2013-07-29 0:20 ` Takao Indoh
2013-07-25 17:00 ` Bjorn Helgaas
2013-07-29 0:37 ` Takao Indoh
2013-07-29 14:17 ` Bjorn Helgaas
2013-07-30 6:09 ` Takao Indoh
2013-07-30 15:59 ` Bjorn Helgaas
2013-07-31 0:35 ` Takao Indoh
2013-07-31 3:11 ` Alex Williamson
2013-07-31 5:50 ` Takao Indoh [this message]
2013-07-31 21:08 ` Bjorn Helgaas
2013-07-31 21:23 ` Rafael J. Wysocki
2013-08-01 6:34 ` Takao Indoh
2013-08-01 12:42 ` Alex Williamson
2013-08-01 13:20 ` Vivek Goyal
2013-07-31 19:56 ` Vivek Goyal
2013-07-31 16:09 ` Vivek Goyal
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=51F8A5C2.1030805@jp.fujitsu.com \
--to=indou.takao@jp.fujitsu.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=bill.sumner@hp.com \
--cc=ddutile@redhat.com \
--cc=hbabu@us.ibm.com \
--cc=iommu@lists.linux-foundation.org \
--cc=ishii.hironobu@jp.fujitsu.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=vgoyal@redhat.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