From: jakeo@microsoft.com
To: gregkh@linuxfoundation.org, kys@microsoft.com,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com,
linux-pci@vger.kernel.org, bhelgaas@google.com,
tglx@linutronix.de
Cc: Jake Oshins <jakeo@microsoft.com>
Subject: [PATCH v2 03/12] kernel:irq: Allow for ranked matches on IRQ domains
Date: Fri, 11 Sep 2015 00:01:02 +0000 [thread overview]
Message-ID: <1441929670-10058-4-git-send-email-jakeo@microsoft.com> (raw)
In-Reply-To: <1441929670-10058-1-git-send-email-jakeo@microsoft.com>
From: Jake Oshins <jakeo@microsoft.com>
The existing IRQ domain match code cycles through all the IRQ domains looking
for the first one to return a non-zero value from its match() function. There's
even a comment that says "this isn't a problem so far..."
This patch changes the semantics on the match() function so that the value
returned is a ranking, where zero means "no match." The function now runs the
list of IRQ domains twice, finding the highest ranked matches on the first pass
and returning the first one of those (to preserve existing behavior, where there
might have been multiple matches) on the second pass.
This allows for a situation where a default IRQ domain (specifically the one
for message-signaled interrupts on x86 PCs) is always present, but where it can
be overriden by an IRQ domain implementation that is targeted at specific PCIe
root complexes.
Signed-off-by: Jake Oshins <jakeo@microsoft.com>
---
include/linux/irqdomain.h | 2 +-
kernel/irq/irqdomain.c | 44 ++++++++++++++++++++++++++++++--------------
2 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 12acddb..2d48deb 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -62,7 +62,7 @@ enum irq_domain_bus_token {
/**
* struct irq_domain_ops - Methods for irq_domain objects
* @match: Match an interrupt controller device node to a host, returns
- * 1 on a match
+ * a ranking (non-zero) on a match
* @map: Create or update a mapping between a virtual irq number and a hw
* irq number. This is called only once for a given mapping.
* @unmap: Dispose of such a mapping
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index b4c15af..385c16e 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -197,30 +197,46 @@ struct irq_domain *irq_find_matching_host(struct device_node *node,
void *bus_data)
{
struct irq_domain *h, *found = NULL;
- int rc;
+ int match_rank = 0x7fffffff;
+ int found_rank = 0;
+ int rank;
+ int pass;
/* We might want to match the legacy controller last since
* it might potentially be set to match all interrupts in
- * the absence of a device node. This isn't a problem so far
- * yet though...
+ * the absence of a device node. In this case, the match
+ * of highest rank is returned.
*
* bus_token == DOMAIN_BUS_ANY matches any domain, any other
* values must generate an exact match for the domain to be
* selected.
*/
mutex_lock(&irq_domain_mutex);
- list_for_each_entry(h, &irq_domain_list, link) {
- if (h->ops->match)
- rc = h->ops->match(h, node, bus_token, bus_data);
- else
- rc = ((h->of_node != NULL) && (h->of_node == node) &&
- ((bus_token == DOMAIN_BUS_ANY) ||
- (h->bus_token == bus_token)));
-
- if (rc) {
- found = h;
- break;
+ for (pass = 0; pass < 2; pass++) {
+ list_for_each_entry(h, &irq_domain_list, link) {
+ if (h->ops->match)
+ rank = h->ops->match(h, node, bus_token,
+ bus_data);
+ else
+ if ((h->of_node != NULL) &&
+ (h->of_node == node) &&
+ ((bus_token == DOMAIN_BUS_ANY) ||
+ (h->bus_token == bus_token)))
+ rank = 1;
+ else
+ rank = 0;
+
+ if (rank > found_rank)
+ found_rank = rank;
+
+ if (found_rank == match_rank) {
+ found = h;
+ break;
+ }
}
+
+ if (found_rank != 0)
+ match_rank = found_rank;
}
mutex_unlock(&irq_domain_mutex);
return found;
--
1.9.1
next prev parent reply other threads:[~2015-09-11 0:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-11 0:00 [PATCH v2 00/12] New paravirtual PCI front-end for Hyper-V VMs jakeo
2015-09-11 0:01 ` [PATCH v2 01/12] kernel:irq: Change signature of irq_domain_ops match() method, adding *bus_data jakeo
2015-09-11 0:01 ` [PATCH v2 02/12] kernel:irq: Change signature of irq_find_matching_host() jakeo
2015-09-11 0:01 ` jakeo [this message]
2015-09-11 0:01 ` [PATCH v2 04/12] drivers:pci: Add IRQ domain lookup by PCI domain jakeo
2015-09-21 15:43 ` Bjorn Helgaas
2015-09-11 0:01 ` [PATCH v2 05/12] drivers:hv: Export a function that maps Linux CPU num onto Hyper-V proc num jakeo
2015-09-11 0:01 ` [PATCH v2 06/12] drivers:hv: Export do_hypercall() jakeo
2015-09-15 23:27 ` KY Srinivasan
2015-09-15 23:29 ` Jake Oshins
2015-09-11 0:01 ` [PATCH v2 07/12] drivers:x86:pci: Make it possible to implement a PCI MSI IRQ Domain in a module jakeo
2015-09-11 0:01 ` [PATCH v2 08/12] drivers:pci:msi: Store PCI domain (segment) as part of IRQ domain jakeo
2015-09-11 0:01 ` [PATCH v2 09/11] kernel:irq: Implement msi match function jakeo
2015-09-11 0:01 ` [PATCH v2 10/11] drivers:hv: Define the channel type for Hyper-V PCI Express pass-through jakeo
2015-09-11 0:01 ` [PATCH v2 11/11] drivers:pci:hv: New paravirtual PCI front-end for Hyper-V VMs jakeo
2015-09-14 15:00 ` [PATCH v2 00/12] " Marc Zyngier
2015-09-14 17:59 ` Jake Oshins
2015-09-15 9:57 ` Marc Zyngier
2015-09-15 23:32 ` Jake Oshins
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=1441929670-10058-4-git-send-email-jakeo@microsoft.com \
--to=jakeo@microsoft.com \
--cc=apw@canonical.com \
--cc=bhelgaas@google.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=olaf@aepfle.de \
--cc=tglx@linutronix.de \
--cc=vkuznets@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;
as well as URLs for NNTP newsgroup(s).