From: Andrew Jones <drjones@redhat.com>
To: Andre Przywara <andre.przywara@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
peter.maydell@linaro.org, marc.zyngier@arm.com,
eric.auger@redhat.com, pbonzini@redhat.com,
alex.bennee@linaro.org, christoffer.dall@linaro.org
Subject: Re: [Qemu-devel] [PATCH kvm-unit-tests v8 09/10] arm/arm64: gicv3: add an IPI test
Date: Fri, 9 Dec 2016 18:28:27 +0100 [thread overview]
Message-ID: <20161209172827.xmzcxxc7xxvlheia@hawk.localdomain> (raw)
In-Reply-To: <2fc872dd-ee19-f2fb-7444-cf701871fbeb@arm.com>
On Fri, Dec 09, 2016 at 04:08:00PM +0000, Andre Przywara wrote:
> On 08/12/16 17:50, Andrew Jones wrote:
> > +u32 gicv3_iar_irqnr(u32 iar)
> > +{
> > + return iar;
>
> I am probably a bit paranoid here, but the spec says that the interrupt
> ID is in bits[23:0] only (at most).
Indeed, I'll add '& ((1 << 24) - 1' here.
>
> > +}
> > +
> > +void gicv3_ipi_send_mask(int irq, const cpumask_t *dest)
> > +{
> > + u16 tlist;
> > + int cpu;
> > +
> > + assert(irq < 16);
> > +
> > + /*
> > + * For each cpu in the mask collect its peers, which are also in
> > + * the mask, in order to form target lists.
> > + */
> > + for_each_cpu(cpu, dest) {
> > + u64 mpidr = cpus[cpu], sgi1r;
> > + u64 cluster_id;
> > +
> > + /*
> > + * GICv3 can send IPIs to up 16 peer cpus with a single
> > + * write to ICC_SGI1R_EL1 (using the target list). Peers
> > + * are cpus that have nearly identical MPIDRs, the only
> > + * difference being Aff0. The matching upper affinity
> > + * levels form the cluster ID.
> > + */
> > + cluster_id = mpidr & ~0xffUL;
> > + tlist = 0;
> > +
> > + /*
> > + * Sort of open code for_each_cpu in order to have a
> > + * nested for_each_cpu loop.
> > + */
> > + while (cpu < nr_cpus) {
> > + if ((mpidr & 0xff) >= 16) {
> > + printf("cpu%d MPIDR:aff0 is %d (>= 16)!\n",
> > + cpu, (int)(mpidr & 0xff));
> > + break;
> > + }
> > +
> > + tlist |= 1 << (mpidr & 0xf);
> > +
> > + cpu = cpumask_next(cpu, dest);
> > + if (cpu >= nr_cpus)
> > + break;
> > +
> > + mpidr = cpus[cpu];
> > +
> > + if (cluster_id != (mpidr & ~0xffUL)) {
> > + /*
> > + * The next cpu isn't in our cluster. Roll
> > + * back the cpu index allowing the outer
> > + * for_each_cpu to find it again with
> > + * cpumask_next
> > + */
> > + --cpu;
> > + break;
> > + }
> > + }
> > +
> > + /* Send the IPIs for the target list of this cluster */
> > + sgi1r = (MPIDR_TO_SGI_AFFINITY(cluster_id, 3) |
> > + MPIDR_TO_SGI_AFFINITY(cluster_id, 2) |
> > + irq << 24 |
> > + MPIDR_TO_SGI_AFFINITY(cluster_id, 1) |
> > + tlist);
> > +
> > + gicv3_write_sgi1r(sgi1r);
> > + }
> > +
> > + /* Force the above writes to ICC_SGI1R_EL1 to be executed */
> > + isb();
> > +}
>
> Wow, this is really heavy stuff, especially for a Friday afternoon ;-)
> But I convinced myself that it's correct. The only issue is that it's
> sub-optimal if the MPIDRs of the VCPUs are not in order, say: 0x000,
> 0x100, 0x001.
> In this case we do three register writes instead of the minimal two.
> But it's still correct, so it's actually a minor nit just to prove that
> I checked the algorithm ;-)
>
> So apart from the minor comment above:
>
> Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Thanks!
drew
next prev parent reply other threads:[~2016-12-09 17:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-08 17:50 [Qemu-devel] [PATCH kvm-unit-tests v8 00/10] arm/arm64: add gic framework Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 01/10] arm/arm64: yield on cpu_relax Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 02/10] arm/arm64: smp: support more than 8 cpus Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 03/10] arm/arm64: add some delay routines Andrew Jones
2016-12-09 11:41 ` Andre Przywara
2016-12-09 12:15 ` Andrew Jones
2016-12-27 15:27 ` Christopher Covington
2016-12-27 16:27 ` Andrew Jones
2016-12-13 16:41 ` Alex Bennée
2016-12-13 17:09 ` Alex Bennée
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 04/10] arm/arm64: irq enable/disable Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 05/10] arm/arm64: add initial gicv2 support Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 06/10] arm/arm64: gicv2: add an IPI test Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 07/10] libcflat: add IS_ALIGNED() macro, and page sizes Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 08/10] arm/arm64: add initial gicv3 support Andrew Jones
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 09/10] arm/arm64: gicv3: add an IPI test Andrew Jones
2016-12-09 16:08 ` Andre Przywara
2016-12-09 17:28 ` Andrew Jones [this message]
2016-12-08 17:50 ` [Qemu-devel] [PATCH kvm-unit-tests v8 10/10] arm/arm64: gic: don't just use zero Andrew Jones
2016-12-14 13:46 ` [Qemu-devel] [PATCH kvm-unit-tests v8 00/10] arm/arm64: add gic framework Andrew Jones
2016-12-14 15:36 ` Alex Bennée
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=20161209172827.xmzcxxc7xxvlheia@hawk.localdomain \
--to=drjones@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=andre.przywara@arm.com \
--cc=christoffer.dall@linaro.org \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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).