From: Thomas Gleixner <tglx@linutronix.de>
To: John Garry <john.garry@huawei.com>
Cc: Marc Zyngier <maz@kernel.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
chenxiang <chenxiang66@hisilicon.com>
Subject: Re: About irq_create_affinity_masks() for a platform device driver
Date: Tue, 04 Feb 2020 09:20:02 +0000 [thread overview]
Message-ID: <871rrazp31.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <2b381b20-512a-27a5-38d7-2f6a673bb621@huawei.com>
John,
John Garry <john.garry@huawei.com> writes:
>> I wouldn't mind to expose a function which allows you to switch the
>> allocated interrupts to managed. The reason why we do it in one go in
>> the PCI code is that we get automatically the irq descriptors allocated
>> on the correct node. So if the node aware allocation is not a
>> showstopper
>
> I wouldn't say so for now.
Good.
> for this then your function would do:
>>
>> ...
>> for (i = 0; i < count; i++) {
>> pirqs[i] = platform_get_irq(dev, i);
>>
>> irq_update_affinity_desc(pirqs[i], affdescs + i);
>>
>> }
>>
>> int irq_update_affinity_desc(unsigned int irq, irq_affinity_desc *affinity)
>> {
>> unsigned long flags;
>> struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
>>
>> if (!desc)
>> return -EINVAL;
>>
>> if (affinity->is_managed) {
>> irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
>> irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
>
> Are these correct? I assume we want to follow alloc_descs() here.
Yeah, copied the wrong chunk :)
>> }
>> cpumask_copy(desc->irq_common_data.affinity, affinity);
>> return 0;
>> }
>
> I see. So I made a couple of changes and it did work:
>
> int irq_update_affinity_desc(unsigned int irq, struct irq_affinity_desc
> *affinity)
> {
> unsigned long flags;
> struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
>
> if (!desc)
> return -EINVAL;
>
> if (affinity->is_managed) {
> irqd_set(&desc->irq_data, IRQD_AFFINITY_MANAGED);
> irqd_set(&desc->irq_data, IRQD_MANAGED_SHUTDOWN);
> }
>
> cpumask_copy(desc->irq_common_data.affinity, &affinity->mask);
> irq_put_desc_unlock(desc, flags);
> return 0;
> }
Looks correct.
> And if we were to go this way, then we don't need to add the pointer in
> struct platform_device to hold affinity mask descriptors as we're using
> them immediately. Or even have a single function to do it all in the irq
> code (create the masks and update the affinity desc).
>
> And since we're just updating the masks, I figure we shouldn't need to
> add acpi_irq_get_count(), which I invented to get the irq count (without
> creating the IRQ mapping).
Yes, you can create and apply the masks after setting up the interrupts.
Thanks,
tglx
next prev parent reply other threads:[~2020-02-04 9:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 10:09 About irq_create_affinity_masks() for a platform device driver John Garry
2020-01-22 10:59 ` Thomas Gleixner
2020-01-22 11:27 ` John Garry
2020-01-31 14:25 ` John Garry
2020-01-31 21:41 ` Thomas Gleixner
2020-02-03 15:00 ` John Garry
2020-02-04 9:20 ` Thomas Gleixner [this message]
2020-02-04 9:55 ` John Garry
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=871rrazp31.fsf@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=chenxiang66@hisilicon.com \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@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 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).