From: Kyle Moffett <mrmacman_g4@mac.com>
To: Arjan van de Ven <arjan@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>, Greg KH <greg@kroah.com>,
linux-kernel@vger.kernel.org, linas@austin.ibm.com
Subject: Re: [RFC/PATCH] Add pci_walk_bus function to PCI core
Date: Wed, 10 Aug 2005 02:47:03 -0400 [thread overview]
Message-ID: <11FC83FD-AAF5-49A0-9C89-1AFB9FC55B2E@mac.com> (raw)
In-Reply-To: <1123654250.3217.5.camel@laptopd505.fenrus.org>
On Aug 10, 2005, at 02:10:49, Arjan van de Ven wrote:
> On Wed, 2005-08-10 at 11:36 +1000, Paul Mackerras wrote:
>
>> Greg,
>>
>> Any comments on this patch? Would you be amenable to it going in
>> post
>> 2.6.13?
>>
>> The PCI error recovery infrastructure needs to be able to contact all
>> the drivers affected by a PCI error event, which may mean traversing
>> all the devices under a given PCI-PCI bridge. This patch adds a
>> function to the PCI core that traverses all the PCI devices on a PCI
>> bus and under any PCI-PCI bridges on that bus (recursively),
>> calling a
>> given function for each device.
>
> is there a way to avoid the recursion somehow? Recursion is "not fun"
> stack usage wise, esp if you have really deep hierarchies....
Hmm, it looks like PCI error recovery wants breadth-first recursion, so
you should be able to do some sort of tail-recursion or something. If
only one error-recovery action on a given subtree can be going at a
time,
you should be able to add an "error_recovery" linked-list to the device
structure and do something like this:
void recover(...) {
struct list_head recovery_list = LIST_HEAD_INIT(recovery_list);
list_add(&dev->error_recovery, &recovery_list);
while(!list_empty(&recovery_list)) {
struct some_device_type *dev =
list_entry(recovery_list->next, struct some_device_type,
error_recovery);
dev->some_recovery_function(dev, [...]);
list_del(&dev->error_recovery);
}
}
Then each PCI-PCI bridge's some_recovery_function could do this:
void some_recovery_function(struct some_device_type *dev, [...]) {
struct some_device_type *child;
actually_do_my_recovery();
list_for_each_entry(child, dev->some_pci_subdev_list,
some_pci_list) {
if (needs_recovery(child))
list_add_tail(&child->error_recovery,&dev->error_recovery);
}
}
With such an arrangement, the callstack is as shallow as possible:
recover
some_recovery_function
actually_do_my_recovery
needs_recovery
childs_recovery_function
[...]
If you can have multiple simultaneous error-recovery actions per
subtree,
that wouldn't properly work unless they were exclusive-blocking, IE:
an error recovery action triggers an error on a subtree which must
recover itself. In that case, with some extra state saved in the
recover
function and passed to the "some_recovery_function", you could allow the
other recovery to continue before resuming.
If you can have two CPUs recovering the same device tree, I'd be
inclined
to wonder what kind of strange errors you're causing on the PCI bus :-D,
and I'd be interested in an example of how that could work in any
sane way.
Cheers,
Kyle Moffett
--
Premature optimization is the root of all evil in programming
-- C.A.R. Hoare
next prev parent reply other threads:[~2005-08-10 6:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-10 1:36 Paul Mackerras
2005-08-10 6:10 ` Arjan van de Ven
2005-08-10 6:47 ` Kyle Moffett [this message]
2005-08-10 7:32 ` Paul Mackerras
2005-08-10 20:49 ` Greg KH
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=11FC83FD-AAF5-49A0-9C89-1AFB9FC55B2E@mac.com \
--to=mrmacman_g4@mac.com \
--cc=arjan@infradead.org \
--cc=greg@kroah.com \
--cc=linas@austin.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.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
all inboxes | Powered by JetHome®