From: Andre Przywara <andre.przywara@linaro.org>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org, Julien Grall <julien.grall@linaro.org>
Subject: Re: [PATCH 07/12] ARM: VGIC: split gic.c to observe hardware/virtual GIC separation
Date: Wed, 6 Dec 2017 18:04:51 +0000 [thread overview]
Message-ID: <cb2ced95-b344-ba85-a9e5-5cd32274079f@linaro.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1710251730530.574@sstabellini-ThinkPad-X260>
Hi,
On 26/10/17 01:37, Stefano Stabellini wrote:
> On Thu, 19 Oct 2017, Andre Przywara wrote:
>> Currently gic.c holds code to handle hardware IRQs as well as code to
>> bridge VGIC requests to the GIC virtualization hardware.
>
> That is true, however, I don't necessarely see "the code to bridge VGIC
> requests to the GIC virtualization hardware" as belonging to the VGIC. I
> think is a good abstraction to place in the GIC. That said, see below.
>
>
>> Despite being named gic.c, this file reaches into the VGIC and uses data
>> structures describing virtual IRQs.
>> To improve abstraction, move the VGIC functions into a separate file,
>> so that gic.c does what is says on the tin.
>
> Splitting "the code to bridge VGIC requests to the GIC virtualization
> hardware" is harmless, so I am OK with this patch.
>
> One cosmetic comment below.
>
>
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>> ---
>> xen/arch/arm/Makefile | 1 +
>> xen/arch/arm/gic-vgic.c | 395 ++++++++++++++++++++++++++++++++++++++++++++++++
>> xen/arch/arm/gic.c | 348 +-----------------------------------------
>> 3 files changed, 398 insertions(+), 346 deletions(-)
>> create mode 100644 xen/arch/arm/gic-vgic.c
>>
>> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
>> index 30a2a6500a..41d7366527 100644
>> --- a/xen/arch/arm/Makefile
>> +++ b/xen/arch/arm/Makefile
>> @@ -16,6 +16,7 @@ obj-y += domain_build.o
>> obj-y += domctl.o
>> obj-$(EARLY_PRINTK) += early_printk.o
>> obj-y += gic.o
>> +obj-y += gic-vgic.o
>> obj-y += gic-v2.o
>> obj-$(CONFIG_HAS_GICV3) += gic-v3.o
>> obj-$(CONFIG_HAS_ITS) += gic-v3-its.o
>> diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c
>> new file mode 100644
>> index 0000000000..66cae21e82
>> --- /dev/null
>> +++ b/xen/arch/arm/gic-vgic.c
>> @@ -0,0 +1,395 @@
>> +/*
>> + * xen/arch/arm/gic-vgic.c
>> + *
>> + * ARM Generic Interrupt Controller virtualization support
>> + *
>> + * Tim Deegan <tim@xen.org>
>> + * Copyright (c) 2011 Citrix Systems.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include <xen/lib.h>
>> +#include <xen/init.h>
>> +#include <xen/mm.h>
>> +#include <xen/irq.h>
>> +#include <xen/sched.h>
>> +#include <xen/errno.h>
>> +#include <xen/softirq.h>
>> +#include <xen/list.h>
>> +#include <xen/device_tree.h>
>> +#include <xen/acpi.h>
>> +#include <asm/p2m.h>
>> +#include <asm/domain.h>
>> +#include <asm/platform.h>
>> +#include <asm/device.h>
>> +#include <asm/io.h>
>> +#include <asm/gic.h>
>> +#include <asm/vgic.h>
>> +#include <asm/acpi.h>
>> +
>> +extern uint64_t per_cpu__lr_mask;
>
> This is a bit ugly. Would the macro "get_per_cpu_var" help?
So this could become:
extern uint64_t get_per_cpu_var(lr_mask);
though I am not sure if this is really nicer?
As you found out below yourself, this lr_mask is a bit nasty, as it's
used in both gic-vgic.c and gic.c. I don't think there is much we can do
about it, thus just sharing this variable was by far the easiest and
simplest solution.
>> +extern const struct gic_hw_operations *gic_hw_ops;
>> +
>> +#define lr_all_full() (this_cpu(lr_mask) == ((1 << gic_hw_ops->info->nr_lrs) - 1))
>> +
...
>> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
>> index 58d69955fb..04e6d66b69 100644
>> --- a/xen/arch/arm/gic.c
>> +++ b/xen/arch/arm/gic.c
>> @@ -36,15 +36,11 @@
>> #include <asm/vgic.h>
>> #include <asm/acpi.h>
>>
>> -static DEFINE_PER_CPU(uint64_t, lr_mask);
>> -
>> -#define lr_all_full() (this_cpu(lr_mask) == ((1 << gic_hw_ops->info->nr_lrs) - 1))
>> +DEFINE_PER_CPU(uint64_t, lr_mask);
>
> I didn't look at what's left in gic.c, but would it be possible to move
> the definition of lr_mask to gic-vgic.c?
As mentioned above: not really, we need it in both files, unfortunately.
As in the other mail, I guess it's not worth trying to properly fix this
now, unless you have a really good reason.
Cheers,
Andre.
>> #undef GIC_DEBUG
>>
>> -static void gic_update_one_lr(struct vcpu *v, int i);
>> -
>> -static const struct gic_hw_operations *gic_hw_ops;
>> +const struct gic_hw_operations *gic_hw_ops;
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2017-12-06 18:04 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 12:48 [PATCH 00/12] ARM: VGIC/GIC separation cleanups Andre Przywara
2017-10-19 12:48 ` [PATCH 01/12] ARM: remove unneeded gic.h inclusions Andre Przywara
2017-10-25 23:55 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 02/12] ARM: vGIC: fix nr_irq definition Andre Przywara
2017-10-26 0:00 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 03/12] ARM: VGIC: remove gic_clear_pending_irqs() Andre Przywara
2017-10-26 0:14 ` Stefano Stabellini
2017-11-10 16:42 ` Andre Przywara
2017-11-16 1:17 ` Stefano Stabellini
2017-11-16 14:32 ` Julien Grall
2017-12-06 18:01 ` Andre Przywara
2017-10-19 12:48 ` [PATCH 04/12] ARM: VGIC: move gic_remove_irq_from_queues() Andre Przywara
2017-10-26 0:19 ` Stefano Stabellini
2017-10-26 8:22 ` Julien Grall
2017-11-10 17:14 ` Andre Przywara
2017-11-10 19:04 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 05/12] ARM: VGIC: move gic_remove_from_lr_pending() Andre Przywara
2017-10-26 0:20 ` Stefano Stabellini
2017-12-06 18:02 ` Andre Przywara
2017-10-19 12:48 ` [PATCH 06/12] ARM: VGIC: streamline gic_restore_pending_irqs() Andre Przywara
2017-10-19 12:48 ` [PATCH 07/12] ARM: VGIC: split gic.c to observe hardware/virtual GIC separation Andre Przywara
2017-10-26 0:37 ` Stefano Stabellini
2017-12-06 18:04 ` Andre Przywara [this message]
2017-10-19 12:48 ` [PATCH 08/12] ARM: VGIC: split up gic_dump_info() to cover virtual part separately Andre Przywara
2017-10-26 0:41 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 09/12] ARM: VGIC: rework events_need_delivery() Andre Przywara
2017-10-26 0:47 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 10/12] ARM: VGIC: factor out vgic_connect_hw_irq() Andre Przywara
2017-10-26 0:49 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 11/12] ARM: VGIC: factor out vgic_get_hw_irq_desc() Andre Przywara
2017-10-26 0:50 ` Stefano Stabellini
2017-10-19 12:48 ` [PATCH 12/12] ARM: VGIC: rework gicv[23]_update_lr to not use pending_irq Andre Przywara
2017-10-26 0:51 ` Stefano Stabellini
2017-10-26 8:28 ` Julien Grall
2017-12-07 18:33 ` Andre Przywara
2017-10-19 15:37 ` [PATCH 00/12] ARM: VGIC/GIC separation cleanups Andre Przywara
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=cb2ced95-b344-ba85-a9e5-5cd32274079f@linaro.org \
--to=andre.przywara@linaro.org \
--cc=julien.grall@linaro.org \
--cc=sstabellini@kernel.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 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).