From: Nathan Lynch <ntl@pobox.com>
To: Mohan Kumar M <mohan@in.ibm.com>
Cc: linuxppc-dev@ozlabs.org, fastboot@lists.osdl.org, anton@samba.org
Subject: Re: [RFC] Fix for interrupt distribution
Date: Mon, 6 Nov 2006 16:46:03 -0600 [thread overview]
Message-ID: <20061106224603.GG6848@localdomain> (raw)
In-Reply-To: <20061031110515.GB7884@in.ibm.com>
Mohan Kumar M wrote:
>
> Index: linux-2.6.19-rc3/arch/powerpc/platforms/pseries/xics.c
> ===================================================================
> --- linux-2.6.19-rc3.orig/arch/powerpc/platforms/pseries/xics.c
> +++ linux-2.6.19-rc3/arch/powerpc/platforms/pseries/xics.c
> @@ -658,7 +658,7 @@ static void __init xics_setup_8259_casca
>
> void __init xics_init_IRQ(void)
> {
> - int i;
> + int i, j;
> struct device_node *np;
> u32 ilen, indx = 0;
> const u32 *ireg;
> @@ -686,23 +686,23 @@ void __init xics_init_IRQ(void)
> for (np = of_find_node_by_type(NULL, "cpu");
> np;
> np = of_find_node_by_type(np, "cpu")) {
> - ireg = get_property(np, "reg", &ilen);
> - if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) {
> - ireg = get_property(np,
> - "ibm,ppc-interrupt-gserver#s", &ilen);
> - i = ilen / sizeof(int);
> - if (ireg && i > 0) {
> - default_server = ireg[0];
> - /* take last element */
> - default_distrib_server = ireg[i-1];
> - }
> - ireg = get_property(np,
> + ireg = get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
> + i = ilen / sizeof(int);
> + for (j = 0; ireg[j] && j < i; j+=2) {
^^^^^^
I don't understand this condition in the loop -- zero is a valid (and
common) value for interrupt servers:
# xxd /proc/device-tree/cpus/PowerPC,POWER5@0/ibm,ppc-interrupt-server#s
0000000: 0000 0000 0000 0001
# xxd /proc/device-tree/cpus/PowerPC,POWER5@0/ibm,ppc-interrupt-gserver#s
0000000: 0000 0000 0000 00ff 0000 0001 0000 00ff
So I think this patch wouldn't always work.
> + if (ireg[j] == get_hard_smp_processor_id(boot_cpuid)) {
> + if ( j + 1 < i) {
> + default_server = ireg[j];
> + default_distrib_server = ireg[j+1];
> + }
> + ireg = get_property(np,
> "ibm,interrupt-server#-size", NULL);
> - if (ireg)
> - interrupt_server_size = *ireg;
> - break;
> + if (ireg)
> + interrupt_server_size = *ireg;
> + goto out;
> + }
> }
> }
> +out:
> of_node_put(np);
I think we need a helper function or two to make this easier to do
correctly and readably, e.g.
/* Returns the device node (with refcount incremented)
* corresponding to the given logical cpu id */
struct device_node * cpuid_to_of_node(int cpu) {
struct device_node *np;
u32 hcpuid = get_hard_smp_processor_id(cpu);
for_each_node_by_type(np, "cpu") {
int len, i;
u32 *intserv = get_property(np,
"ibm,ppc-interrupt-server#s", &len);
if (!intserv)
intserv = get_property(np, "reg", &len);
i = len / sizeof(u32);
while (i--)
if (intserv[i] == hcpuid)
return np;
}
return NULL;
}
And then the loop in xics_init_IRQ can be replaced with something like:
np = cpuid_to_of_node(boot_cpuid);
BUG_ON(!np);
ireg = get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
hcpuid = get_hard_smp_processor_id(boot_cpuid);
if (ireg[0] == hcpuid)
default_distrib_server = ireg[1];
else
default_distrib_server = ireg[3];
default_server = hcpuid;
...
next prev parent reply other threads:[~2006-11-06 22:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-30 18:04 [RFC] Fix for interrupt distribution Mohan Kumar M
2006-10-30 18:17 ` Nathan Lynch
2006-10-31 11:05 ` Mohan Kumar M
2006-11-06 22:46 ` Nathan Lynch [this message]
2006-11-16 12:56 ` Mohan Kumar M
2006-11-16 15:36 ` Anton Blanchard
2006-11-17 4:57 ` Mohan Kumar M
2006-11-17 12:12 ` Mohan Kumar M
2006-11-29 9:10 ` [PATCH] " Mohan Kumar M
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=20061106224603.GG6848@localdomain \
--to=ntl@pobox.com \
--cc=anton@samba.org \
--cc=fastboot@lists.osdl.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mohan@in.ibm.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