All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Hellstrom <daniel@gaisler.com>
To: sparclinux@vger.kernel.org
Subject: Re: [PATCH 7/7] sparc32,leon: implement genirq CPU affinity
Date: Wed, 20 Apr 2011 07:20:00 +0000	[thread overview]
Message-ID: <4DAE8920.9080702@gaisler.com> (raw)
In-Reply-To: <1303229239-21551-7-git-send-email-daniel@gaisler.com>

Sam Ravnborg wrote:

>On Tue, Apr 19, 2011 at 06:07:19PM +0200, Daniel Hellstrom wrote:
>  
>
>>A simple implementation of CPU affinity, the first CPU in
>>the affinity CPU mask always takes the IRQ.
>>
>>Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
>>---
>> arch/sparc/kernel/leon_kernel.c |   66 +++++++++++++++++++++++++++++++++------
>> 1 files changed, 56 insertions(+), 10 deletions(-)
>>
>>diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
>>index 26acc75..e12f4e8 100644
>>--- a/arch/sparc/kernel/leon_kernel.c
>>+++ b/arch/sparc/kernel/leon_kernel.c
>>@@ -100,25 +100,68 @@ static inline unsigned long get_irqmask(unsigned int irq)
>> 	return mask;
>> }
>> 
>>+#ifdef CONFIG_SMP
>>+static int irq_choose_cpu(const struct cpumask *affinity)
>>+{
>>+	cpumask_t mask;
>>+
>>+	cpus_and(mask, cpu_online_map, *affinity);
>>+	if (cpus_equal(mask, cpu_online_map) || cpus_empty(mask))
>>+		return leon3_boot_cpu;
>>+	else
>>+		return first_cpu(mask);
>>+}
>>+
>>+int leon_set_affinity(struct irq_data *data, const struct cpumask *dest,
>>+		      bool force)
>>+{
>>+	unsigned long mask, oldmask, flags;
>>+	int oldcpu, newcpu;
>>+
>>+	mask = (unsigned long)data->chip_data;
>>+	oldcpu = irq_choose_cpu(data->affinity);
>>+	newcpu = irq_choose_cpu(dest);
>>+
>>+	if (oldcpu = newcpu)
>>+		goto out;
>>+
>>+	/* unmask on old CPU first before enabling on the selected CPU */
>>+	spin_lock_irqsave(&leon_irq_lock, flags);
>>+	oldmask = LEON3_BYPASS_LOAD_PA(LEON_IMASK(oldcpu));
>>+	LEON3_BYPASS_STORE_PA(LEON_IMASK(oldcpu), (oldmask & ~mask));
>>+	oldmask = LEON3_BYPASS_LOAD_PA(LEON_IMASK(newcpu));
>>+	LEON3_BYPASS_STORE_PA(LEON_IMASK(newcpu), (oldmask | mask));
>>+	spin_unlock_irqrestore(&leon_irq_lock, flags);
>>+out:
>>+	return IRQ_SET_MASK_OK;
>>+}
>>+#else
>>+#define irq_choose_cpu(affinity) leon3_boot_cpu
>>+#endif
>>    
>>
>
>We could always define the leon_set_affinity() function
>to avoid ifdeffery in irq_chip definition.
>  
>
Yes, that is what sparc64 does.

>The expense is that we define this function in both the
>UP and SMP case - it is NOT called by the generic irq
>layer in the UP case.
>  
>
Yes, it would increase the footprint to remove one ifdef. I could add a 
"#define leon_set_affinity NULL" in the already present ifdef above to 
avoid the extra ifdef in chip declaration?

Thanks,
Daniel


  parent reply	other threads:[~2011-04-20  7:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 16:07 [PATCH 7/7] sparc32,leon: implement genirq CPU affinity Daniel Hellstrom
2011-04-19 19:27 ` Sam Ravnborg
2011-04-20  7:20 ` Daniel Hellstrom [this message]
2011-04-20  7:34 ` Daniel Hellstrom

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=4DAE8920.9080702@gaisler.com \
    --to=daniel@gaisler.com \
    --cc=sparclinux@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.