From: Julien Grall <julien.grall@linaro.org>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: ian.campbell@citrix.com, tim@xen.org,
stefano.stabellini@citrix.com, xen-devel@lists.xenproject.org,
parth.dixit@linaro.org, christoffer.dall@linaro.org
Subject: Re: [PATCH for-4.6 2/4] xen/arm: vgic: Keep track of vIRQ used by a domain
Date: Mon, 15 Dec 2014 16:07:15 +0000 [thread overview]
Message-ID: <548F0733.2020108@linaro.org> (raw)
In-Reply-To: <alpine.DEB.2.02.1412151527310.30971@kaball.uk.xensource.com>
Hi Stefano,
On 15/12/14 15:32, Stefano Stabellini wrote:
> On Fri, 12 Dec 2014, Julien Grall wrote:
>> + spin_lock_init(&d->arch.vgic.lock);
>
> you should probably explain in the commit message the reason why you are
> making changes to the vgic lock
Actually the domain vgic lock was never used. Only the per-vcpu vgic
lock was in used.
So I don't make any change to the vgic lock. If I don't use it, I will
add a patch to drop it.
>> @@ -441,6 +453,70 @@ int vgic_emulate(struct cpu_user_regs *regs, union hsr hsr)
>> return v->domain->arch.vgic.handler->emulate_sysreg(regs, hsr);
>> }
>>
>> +bool_t vgic_reserve_virq(struct domain *d, unsigned int virq)
>> +{
>> + bool_t reserved;
>> +
>> + if ( virq >= vgic_num_irqs(d) )
>> + return 0;
>> +
>> + spin_lock(&d->arch.vgic.lock);
>> + reserved = !test_and_set_bit(virq, d->arch.vgic.allocated_irqs);
>> + spin_unlock(&d->arch.vgic.lock);
>
> test_and_set_bit is atomic, why do you need to take the lock?
To avoid race condition with vgic_allocate_virq.
Anyway, I will dropped it with your suggestion to implement
vgic_allocate_virq without lock.
[..]
>> +int vgic_allocate_virq(struct domain *d, bool_t spi)
>> +{
>> + int ret = -1;
>> + unsigned int virq;
>> +
>> + spin_lock(&d->arch.vgic.lock);
>> + if ( !spi )
>> + {
>> + virq = find_first_zero_bit(d->arch.vgic.allocated_irqs, 32);
>> + if ( virq >= 32 )
>> + goto unlock;
>> + }
>> + else
>> + {
>> + virq = find_next_zero_bit(d->arch.vgic.allocated_irqs,
>> + 32, vgic_num_irqs(d));
>> + if ( virq >= vgic_num_irqs(d) )
>> + goto unlock;
>> + }
>> +
>> + set_bit(virq, d->arch.vgic.allocated_irqs);
>> + ret = virq;
>> +
>> +unlock:
>> + spin_unlock(&d->arch.vgic.lock);
>
> you might be able to write this function without taking the lock too, by
> using test_and_set_bit and retries:
>
> retry:
> virq = find_first_zero_bit;
> if (test_and_set_bit(virq))
> goto retry;
I will give a look to it. I will also to limit the number of retry
(maybe to the number of vIRQ) for safety.
Regards,
--
Julien Grall
next prev parent reply other threads:[~2014-12-15 16:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 14:43 [PATCH for-4.6 0/4] Find automatically a PPI for the DOM0 even channel IRQ Julien Grall
2014-12-12 14:43 ` [PATCH for-4.6 1/4] xen/arm: vgic: Rename nr_lines into nr_spis Julien Grall
2015-01-13 15:38 ` Ian Campbell
2015-01-13 15:52 ` Julien Grall
2015-01-13 15:59 ` Ian Campbell
2014-12-12 14:43 ` [PATCH for-4.6 2/4] xen/arm: vgic: Keep track of vIRQ used by a domain Julien Grall
2014-12-15 15:32 ` Stefano Stabellini
2014-12-15 16:07 ` Julien Grall [this message]
2014-12-17 15:23 ` Julien Grall
2015-01-13 15:51 ` Ian Campbell
2015-01-13 16:27 ` Julien Grall
2015-01-13 16:46 ` Ian Campbell
2015-01-13 16:57 ` Julien Grall
2015-01-13 17:18 ` Ian Campbell
2015-01-13 17:35 ` Julien Grall
2015-01-13 17:22 ` Julien Grall
2015-01-13 17:34 ` Julien Grall
2014-12-12 14:43 ` [PATCH for-4.6 3/4] xen/arm: vgic: notice if the vIRQ is not allocated when the guest enable it Julien Grall
2015-01-13 15:55 ` Ian Campbell
2015-01-13 20:33 ` Julien Grall
2015-01-14 12:28 ` Ian Campbell
2015-01-14 12:42 ` Julien Grall
2015-01-15 13:27 ` Julien Grall
2015-01-15 13:31 ` Ian Campbell
2014-12-12 14:43 ` [PATCH for-4.6 4/4] xen/arm: Find automatically a PPI for the DOM0 event channel interrupt Julien Grall
2014-12-12 17:00 ` Julien Grall
2014-12-15 15:35 ` Stefano Stabellini
2014-12-15 16:09 ` Julien Grall
2015-01-13 15:58 ` Ian Campbell
2015-01-14 12:24 ` Julien Grall
2015-01-14 12:30 ` Ian Campbell
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=548F0733.2020108@linaro.org \
--to=julien.grall@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=parth.dixit@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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.