From: Julien Grall <julien.grall@linaro.org>
To: vijay.kilari@gmail.com
Cc: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com,
Prasun.Kapoor@caviumnetworks.com,
vijaya.kumar@caviumnetworks.com, xen-devel@lists.xen.org,
stefano.stabellini@citrix.com
Subject: Re: [PATCH v3 07/16] xen/arm: segregate and split GIC low level functionality
Date: Tue, 15 Apr 2014 19:35:08 +0100 [thread overview]
Message-ID: <534D7BDC.1010308@linaro.org> (raw)
In-Reply-To: <1397560675-29861-8-git-send-email-vijay.kilari@gmail.com>
Hello Vijaya,
Thank you for the patch.
On 04/15/2014 12:17 PM, vijay.kilari@gmail.com wrote:
> +/* Access to the GIC Distributor registers through the fixmap */
> +#define GICD ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_GICD))
> +#define GICC ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_GICC1))
> +#define GICH ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_GICH))
> +
> +/* Global state */
> +static struct {
> + paddr_t dbase; /* Address of distributor registers */
> + paddr_t cbase; /* Address of CPU interface registers */
> + paddr_t hbase; /* Address of virtual interface registers */
> + paddr_t vbase; /* Address of virtual cpu interface registers */
> + unsigned int lines; /* Number of interrupts (SPIs + PPIs + SGIs) */
> + struct dt_irq maintenance; /* IRQ maintenance */
> + unsigned int cpus;
> +} gic;
> +
> +static struct gic_hw_operations gic_ops;
> +
> +static uint8_t nr_lrs;
As the number of LRs is store in gic_hw_operations, you don't need this one.
> +
> +/* The GIC mapping of CPU interfaces does not necessarily match the
> + * logical CPU numbering. Let's use mapping as returned by the GIC
> + * itself
> + */
> +static DEFINE_PER_CPU(u8, gic_cpu_id);
> +
> +/* Maximum cpu interface per GIC */
> +#define NR_GIC_CPU_IF 8
> +
> +static unsigned int gicv2_cpu_mask(const cpumask_t *cpumask)
> +{
> + unsigned int cpu;
> + unsigned int mask = 0;
> + cpumask_t possible_mask;
> +
> + cpumask_and(&possible_mask, cpumask, &cpu_possible_map);
> + for_each_cpu(cpu, &possible_mask)
I know that coding style error was there before ... can you change it to
for_each_cpu( ... )
> + {
> + ASSERT(cpu < NR_GIC_CPU_IF);
> + mask |= per_cpu(gic_cpu_id, cpu);
> + }
> +
> + return mask;
> +}
[..]
> +static void gicv2_dump_state(struct vcpu *v)
> +{
> + int i;
> + if ( v == current )
> + {
> + for ( i = 0; i < nr_lrs; i++ )
> + printk(" HW_LR[%d]=%x\n", i, GICH[GICH_LR + i]);
> + } else {
}
else
{
[..]
> +static struct dt_irq * gicv2_maintenance_irq(void)
> +{
> + return &gic.maintenance;
> +}
I have a serie which drop dt_struct and changes IRQW routing. It would
be nice if you can rebase your code on top of it now. I don't think it
will change heavily.
See git://xenbits.xen.org/people/julieng/xen-unstable.git branch
interrupt-mgmt-v3
[..]
> static void gic_irq_enable(struct irq_desc *desc)
> {
> - int irq = desc->irq;
> unsigned long flags;
>
> spin_lock_irqsave(&desc->lock, flags);
> @@ -147,20 +112,19 @@ static void gic_irq_enable(struct irq_desc *desc)
> desc->status &= ~IRQ_DISABLED;
> dsb();
> /* Enable routing */
> - GICD[GICD_ISENABLER + irq / 32] = (1u << (irq % 32));
> + gic_hw_ops->gic_irq_ops->enable(desc);
This is not the right way to use gic_irq_ops. You should directly
assigned this structure to desc->handler.
I guess you don't do it because you have the desc->status and gic_lock
locking which is common.
IHMO, you have to let the GICv{2,3} drivers handling their own lock for
the hardware access.
> spin_unlock(&gic_lock);
> spin_unlock_irqrestore(&desc->lock, flags);
> }
>
> static void gic_irq_disable(struct irq_desc *desc)
> {
> - int irq = desc->irq;
> unsigned long flags;
>
> spin_lock_irqsave(&desc->lock, flags);
> spin_lock(&gic_lock);
> /* Disable routing */
> - GICD[GICD_ICENABLER + irq / 32] = (1u << (irq % 32));
> + gic_hw_ops->gic_irq_ops->disable(desc);
> desc->status |= IRQ_DISABLED;
> spin_unlock(&gic_lock);
> spin_unlock_irqrestore(&desc->lock, flags);
Same here.
> @@ -186,16 +150,15 @@ static void gic_host_irq_end(struct irq_desc *desc)
> {
> int irq = desc->irq;
> /* Lower the priority */
> - GICC[GICC_EOIR] = irq;
> + gic_hw_ops->gic_irq_ops->end(desc);
> /* Deactivate */
> - GICC[GICC_DIR] = irq;
> + gic_hw_ops->deactivate_irq(irq);
> }
> static void gic_guest_irq_end(struct irq_desc *desc)
> {
> - int irq = desc->irq;
> /* Lower the priority of the IRQ */
> - GICC[GICC_EOIR] = irq;
> + gic_hw_ops->gic_irq_ops->end(desc);
> /* Deactivation happens in maintenance interrupt / via GICV */
> }
Same here.
> @@ -215,6 +178,7 @@ static hw_irq_controller gic_host_irq_type = {
> .end = gic_host_irq_end,
> .set_affinity = gic_irq_set_affinity,
> };
> +
Spurious change?
> static hw_irq_controller gic_guest_irq_type = {
> .typename = "gic",
> .startup = gic_irq_startup,
> @@ -235,27 +199,7 @@ static void gic_set_irq_properties(unsigned int irq, bool_t level,
> const cpumask_t *cpu_mask,
> unsigned int priority)
> {
> - volatile unsigned char *bytereg;
> - uint32_t cfg, edgebit;
> - unsigned int mask = gic_cpu_mask(cpu_mask);
> -
> - /* Set edge / level */
> - cfg = GICD[GICD_ICFGR + irq / 16];
> - edgebit = 2u << (2 * (irq % 16));
> - if ( level )
> - cfg &= ~edgebit;
> - else
> - cfg |= edgebit;
> - GICD[GICD_ICFGR + irq / 16] = cfg;
> -
> - /* Set target CPU mask (RAZ/WI on uniprocessor) */
> - bytereg = (unsigned char *) (GICD + GICD_ITARGETSR);
> - bytereg[irq] = mask;
> -
> - /* Set priority */
> - bytereg = (unsigned char *) (GICD + GICD_IPRIORITYR);
> - bytereg[irq] = priority;
> -
> + return gic_hw_ops->set_irq_property(irq, level, cpu_mask, priority);
You don't need to return as gic_set_irq_properties is a void function.
Also why did you drop in plural in the callback name? It should be name
set_irq_properties.
[..]
> diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h
> index eba41ee..2387e38 100644
> --- a/xen/include/asm-arm/gic.h
> +++ b/xen/include/asm-arm/gic.h
> @@ -43,12 +43,41 @@
> #define SGI_TARGET_OTHERS 1
> #define SGI_TARGET_SELF 2
>
> +#define GICH_LR_PENDING 1
> +#define GICH_LR_ACTIVE 2
> +
Prefixing by GICH_ is confusing. I though we were using it for to set
the value in the hardware. Can you rename it?
> +#define GICH_HCR_EN (1 << 0)
> +#define GICH_HCR_UIE (1 << 1)
> +#define GICH_HCR_LRENPIE (1 << 2)
> +#define GICH_HCR_NPIE (1 << 3)
> +#define GICH_HCR_VGRP0EIE (1 << 4)
> +#define GICH_HCR_VGRP0DIE (1 << 5)
> +#define GICH_HCR_VGRP1EIE (1 << 6)
> +#define GICH_HCR_VGRP1DIE (1 << 7)
> +
You dropped this lines in patch #5 and re-add here.
Please don't drop them on patch #5.
> #ifndef __ASSEMBLY__
> #include <xen/device_tree.h>
> +#include <xen/irq.h>
>
> #define DT_MATCH_GIC DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), \
> DT_MATCH_COMPATIBLE("arm,cortex-a7-gic")
>
> +/*
> + * Decode LR register content and populate below struct.
IHMO, the second part of the description (after the "and") is not useful.
[..]
> +struct gic_hw_operations {
> + /* GIC version */
> + enum gic_version hw_version;
> + /* Number of GIC lines supported */
> + unsigned int nr_lines;
> + /* Number of LR registers */
> + unsigned int nr_lrs;
> + /* Maintenance irq is derived from dt node. Fetch from gic driver */
> + struct dt_irq * (*get_maintenance_irq)(void);
> + /* Save GIC registers */
> + void (*save_state)(struct vcpu *);
> + /* Restore GIC registers */
> + void (*restore_state)(struct vcpu *);
Does restore state will modify the content of vcpu? If not, please add
const.
> + /* Dump GIC LR register information */
> + void (*dump_state)(struct vcpu *);
Same question here.
> + /* Map MMIO region of GIC and get GIC address information */
> + int (*gicv_setup)(struct domain *);
> +
> + /* hw_irq_controller for enable/disable/eoi irq */
The hw_irq_controller should contains every callbacks. (see my previous
remark on it).
> + hw_irq_controller *gic_irq_ops;
const hw_irq_controller *gic_irq_ops;
> +
> + /* Deactivate/reduce priority of irq */
> + void (*deactivate_irq)(int);
> + /* Ack IRQ and return irq id */
> + unsigned int (*ack_irq)(void);
> + /* Set IRQ property */
> + void (*set_irq_property)(unsigned int irq, bool_t level,
> + const cpumask_t *cpu_mask,
> + unsigned int priority);
> + /* Send SGI */
> + void (*send_sgi)(const cpumask_t *online_mask,
> + enum gic_sgi sgi, uint8_t irqmode);
Misaligned?
> + /* Disable CPU physical and virtual interfaces */
> + void (*disable_interface)(void);
> + /* Update LR with state and priority */
> + void (*update_lr)(int lr, struct pending_irq *, unsigned int state);
Update LR won't modify pending_irq, right? If so, please add const.
Also you are mixing named and unamed argument. Can you name every arguments?
> + /* Update HCR status register */
> + void (*update_hcr_status)(uint32_t flag, bool_t set);
> + /* Clear LR register */
> + void (*clear_lr)(int lr);
> + /* Read LR register and populate gic_lr structure */
> + void (*read_lr)(int lr, struct gic_lr *);
> + /* Write LR register from gic_lr structure */
> + void (*write_lr)(int lr, struct gic_lr *);
write_lr won't modify pending_irq, right? If so, please add const.
Regards,
--
Julien Grall
next prev parent reply other threads:[~2014-04-15 18:35 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 11:17 [PATCH v3 00/16] xen/arm: Add GICv3 support vijay.kilari
2014-04-15 11:17 ` [PATCH v3 01/16] xen/arm: move io.h as mmio.h to include folder vijay.kilari
2014-04-15 16:36 ` Julien Grall
2014-04-23 14:16 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 02/16] xen/arm: make mmio handlers domain specific vijay.kilari
2014-04-15 17:07 ` Julien Grall
2014-04-23 14:27 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 03/16] xen/arm: make sgi handling generic vijay.kilari
2014-04-15 17:51 ` Julien Grall
2014-04-15 17:57 ` Julien Grall
2014-04-23 14:31 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 04/16] xen/arm: remove unused parameter in do_sgi call vijay.kilari
2014-04-15 17:52 ` Julien Grall
2014-04-23 14:32 ` Ian Campbell
2014-04-25 9:28 ` Vijay Kilari
2014-04-15 11:17 ` [PATCH v3 05/16] xen/arm: move gic definitions to seperate file vijay.kilari
2014-04-23 14:34 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 06/16] xen/arm: move gic lock out of gic data structure vijay.kilari
2014-04-23 14:35 ` Ian Campbell
2014-05-12 13:49 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 07/16] xen/arm: segregate and split GIC low level functionality vijay.kilari
2014-04-15 18:35 ` Julien Grall [this message]
2014-04-23 14:55 ` Ian Campbell
2014-04-23 15:01 ` Julien Grall
2014-04-23 16:47 ` Julien Grall
2014-04-23 17:03 ` Ian Campbell
2014-04-23 17:09 ` Julien Grall
2014-04-24 8:58 ` Ian Campbell
2014-04-24 8:19 ` Ian Campbell
2014-04-28 11:48 ` Vijay Kilari
2014-04-28 12:06 ` Julien Grall
2014-04-28 13:10 ` Vijay Kilari
2014-04-28 13:12 ` Julien Grall
2014-04-15 21:00 ` Julien Grall
2014-04-23 14:52 ` Ian Campbell
2014-04-28 14:41 ` Vijay Kilari
2014-04-28 14:58 ` Ian Campbell
2014-04-28 15:10 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 08/16] arm/xen: move GIC context data structure to gic driver vijay.kilari
2014-04-15 18:41 ` Julien Grall
2014-04-23 14:57 ` Ian Campbell
2014-04-23 14:58 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 09/16] xen/arm: use device api to detect GIC version vijay.kilari
2014-04-15 18:49 ` Julien Grall
2014-04-23 15:01 ` Ian Campbell
2014-04-29 7:07 ` Vijay Kilari
2014-04-29 8:55 ` Ian Campbell
2014-04-29 10:13 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 10/16] xen/arm: move vgic rank data to gic header file vijay.kilari
2014-04-15 19:10 ` Julien Grall
2014-04-17 6:48 ` Vijay Kilari
2014-05-07 15:03 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 11/16] xen/arm: move vgic defines to vgic " vijay.kilari
2014-04-16 17:01 ` Julien Grall
2014-04-23 15:07 ` Ian Campbell
2014-04-23 15:11 ` Julien Grall
2014-04-23 15:15 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 12/16] xen/arm: split vgic driver into generic and vgic-v2 driver vijay.kilari
2014-04-15 20:05 ` Julien Grall
2014-04-23 15:12 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 13/16] xen/arm: Add support for GIC v3 vijay.kilari
2014-04-15 20:43 ` Julien Grall
2014-04-17 7:09 ` Vijay Kilari
2014-04-17 8:58 ` Ian Campbell
2014-04-17 9:02 ` Julien Grall
2014-04-17 9:57 ` Julien Grall
2014-04-17 11:00 ` Vijay Kilari
2014-04-17 11:17 ` Julien Grall
2014-04-17 14:54 ` Vijay Kilari
2014-04-17 15:12 ` Julien Grall
2014-04-23 17:01 ` Ian Campbell
2014-04-23 17:24 ` Julien Grall
2014-04-29 12:35 ` Vijay Kilari
2014-05-05 12:08 ` Vijay Kilari
2014-05-06 8:55 ` Ian Campbell
2014-05-06 14:11 ` Vijay Kilari
2014-05-06 14:18 ` Julien Grall
2014-05-06 15:47 ` Julien Grall
2014-05-22 5:58 ` Vijay Kilari
2014-05-22 9:26 ` Julien Grall
2014-05-22 12:36 ` Stefano Stabellini
2014-05-07 16:30 ` Ian Campbell
2014-05-27 18:17 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 14/16] xen/arm: Add virtual GICv3 support vijay.kilari
2014-04-17 9:27 ` Julien Grall
2014-04-24 10:37 ` Ian Campbell
2014-04-24 11:39 ` Julien Grall
2014-04-24 10:30 ` Ian Campbell
2014-05-02 9:43 ` Vijay Kilari
2014-05-02 9:56 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 15/16] xen/arm: Update Dom0 GIC dt node with GICv3 information vijay.kilari
2014-04-18 19:57 ` Julien Grall
2014-04-24 10:46 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 16/16] xen/arm: add SGI handling for GICv3 vijay.kilari
2014-04-18 20:20 ` Julien Grall
2014-05-02 12:57 ` Vijay Kilari
2014-05-02 14:26 ` Julien Grall
2014-05-02 15:18 ` Ian Campbell
2014-05-02 15:24 ` Julien Grall
2014-05-05 6:53 ` Vijay Kilari
2014-05-05 18:40 ` Julien Grall
2014-05-06 8:58 ` Ian Campbell
2014-05-06 9:42 ` Julien Grall
2014-05-06 10:10 ` Ian Campbell
2014-05-06 16:06 ` Julien Grall
2014-04-24 10:57 ` Ian Campbell
2014-04-24 11:43 ` Julien Grall
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=534D7BDC.1010308@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=Prasun.Kapoor@caviumnetworks.com \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=vijay.kilari@gmail.com \
--cc=vijaya.kumar@caviumnetworks.com \
--cc=xen-devel@lists.xen.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).