Add support for Tegra210 AGIC
Subsystems (7)
Jon Hunter
maintainerv2 cover Add support for Tegra210 AGIC
The Tegra210 AGIC interrupt controller is a 2nd level interrupt controller located in a separate power domain to the main GIC interrupt controller. It can route interrupts to the main CPU cluster or an Audio DSP slave. This series only support routing interrupts to the main CPU cluster.
Ideally we would like to re-use the existing ARM GIC driver because the AGIC is a GIC-400. However, in order to do so this requires adding runtime power management support for irqchips and several significant changes to the exisiting GIC driver for power management reasons.
Changes since V1:
- Updated GIC to only WARN and not return an error if configuring a PPI fails but will still return an error if an SPI fails (per discussion with Marc).
- Dropped change to mask sense bits for GIC-v3 (as this is not necessary)
- Split patch to avoid setting interrupt type when mapping the IRQ into two patches per TGLX's feedback.
- Changed name of irqchip device structure to "parent_device"
- Moved call to irq_chip_pm_get() outside of chip_bus_lock().
- Dropped patch to remove clock names from GIC DT documentation and added AGIC clock names.
- Update GIC platform driver to look-up clocks names from static list.
Jon Hunter (14):
irqchip/gic: Don't unnecessarily write the IRQ configuration irqchip/gic: WARN if setting the interrupt type for a PPI fails
irqchip: Mask the non-type/sense bits when translating an IRQ
irqdomain: Fix handling of type settings for existing mappings
genirq: Look-up trigger type if not specified by caller
irqdomain: Don't set type when mapping an IRQ
genirq: Add runtime power management support for IRQ chips irqchip/gic: Don't initialise chip if mapping IO space fails irqchip/gic: Remove static irq_chip definition for eoimode1 irqchip/gic: Return an error if GIC initialisation fails irqchip/gic: Pass GIC pointer to save/restore functions irqchip/gic: Prepare for adding platform driver
dt-bindings: arm-gic: Add documentation for Tegra210 AGIC irqchip/gic: Add support for tegra AGIC interrupt controller
.../bindings/interrupt-controller/arm,gic.txt | 2 + drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-crossbar.c | 2 +- drivers/irqchip/irq-gic-common.c | 19 +- drivers/irqchip/irq-gic.c | 440 ++++++++++++++++----- drivers/irqchip/irq-tegra.c | 2 +- include/linux/irq.h | 4 + include/linux/irqdomain.h | 3 + kernel/irq/chip.c | 35 ++ kernel/irq/internals.h | 1 + kernel/irq/irqdomain.c | 55 ++- kernel/irq/manage.c | 40 +- 12 files changed, 481 insertions(+), 123 deletions(-)
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 1/14 irqchip/gic: Don't unnecessarily write the IRQ configuration
If the interrupt configuration matches the current configuration, then don't bother writing the configuration again.
--- drivers/irqchip/irq-gic-common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-common.c +6 -2
@@ -50,13 +50,17 @@ int gic_configure_irq(unsigned int irq, unsigned int type,else if (type &IRQ_TYPE_EDGE_BOTH ) val |= confmask; +/* If the current configuration is the same, then we are done */ +if (val == oldval) +return 0 ; +/* * Write back the new configuration, and possibly re-enable -* the interrupt. If we tried to write a new configuration and failed, +* the interrupt. If we fail to write a new configuration, * return an error. */ writel_relaxed (val, base +GIC_DIST_CONFIG + confoff); -if (readl_relaxed (base +GIC_DIST_CONFIG + confoff) != val && val != oldval) +if (readl_relaxed (base +GIC_DIST_CONFIG + confoff) != val) ret = -EINVAL ;if (sync_access)
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 2/14 irqchip/gic: WARN if setting the interrupt type for a PPI fails
In reply to Jon HunterSetting the interrupt type for private peripheral interrupts (PPIs) may not be supported by a given GIC because it is IMPLEMENTATION DEFINED whether this is allowed. There is no way to know if setting the type is supported for a given GIC and so the value written is read back to verify it matches the desired configuration. If it does not match then an error is return.
There are cases where the interrupt configuration read from firmware (such as a device-tree blob), has been incorrect and hence gic_configure_irq() has returned an error. This error has gone undetected because the error code returned was ignored but the interrupt still worked fine because the configuration for the interrupt could not be overwritten.
Given that this has done undetected and that failing to set the configuration for a PPI may not be a catastrophic, don't return an error but WARN if we fail to configure a PPI. This will allows us to fix up any places in the kernel where we should be checking the return status and maintain backward compatibility with firmware images that may have incorrect PPI configurations.
--- drivers/irqchip/irq-gic-common.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-common.c +7 -4
@@ -56,12 +56,15 @@ int gic_configure_irq(unsigned int irq, unsigned int type,/* * Write back the new configuration, and possibly re-enable -* the interrupt. If we fail to write a new configuration, -* return an error. +* the interrupt. WARN if we fail to write a new configuration +* and return an error if we failed to write the configuration +* for an SPI. If we fail to write the configuration for a PPI +* this is most likely because the GIC does not allow us to set +* the configuration and so it is not a catastrophic failure. */ writel_relaxed (val, base +GIC_DIST_CONFIG + confoff); -if (readl_relaxed (base +GIC_DIST_CONFIG + confoff) != val) - ret = -EINVAL ; +if (WARN_ON (readl_relaxed (base +GIC_DIST_CONFIG + confoff) != val)) + ret = irq <32 ?0 : -EINVAL ;if (sync_access)sync_access ();
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 3/14 irqchip: Mask the non-type/sense bits when translating an IRQ
In reply to Jon HunterThe firmware parameter that contains the IRQ sense bits may also contain other data. When return the IRQ type, bits outside of these sense bits should be masked. If these bits are not masked and irq_create_fwspec_mapping() is called to map an IRQ, then the comparison of the type returned from irq_domain_translate() will never match that returned by irq_get_trigger_type() (because this function masks the none sense bits) and so we will always call irq_set_irq_type() to program the type even if it was not really necessary.
Currently, the downside to this is unnecessarily re-programmming the type but nevertheless this should be avoided.
The Tegra LIC and TI Crossbar irqchips all have client instances (from reviewing the device-tree sources) where bits outside the IRQ sense bits are set, but do not mask these bits. Therefore, ensure these bits are masked for these irqchips.
--- drivers/irqchip/irq-crossbar.c | 2 +- drivers/irqchip/irq-tegra.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-crossbar.c +1 -1
@@ -183,7 +183,7 @@ static int crossbar_domain_translate(struct irq_domain *d,return -EINVAL ; *hwirq = fwspec->param[1 ]; - *type = fwspec->param[2 ]; + *type = fwspec->param[2 ] &IRQ_TYPE_SENSE_MASK ;return 0 ; }
drivers/irqchip/irq-tegra.c +1 -1
@@ -235,7 +235,7 @@ static int tegra_ictlr_domain_translate(struct irq_domain *d,return -EINVAL ; *hwirq = fwspec->param[1 ]; - *type = fwspec->param[2 ]; + *type = fwspec->param[2 ] &IRQ_TYPE_SENSE_MASK ;return 0 ; }
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 4/14 irqdomain: Fix handling of type settings for existing mappings
In reply to Jon HunterWhen mapping an IRQ, it is possible that a mapping for the IRQ already exists. If mapping does exist then there are the following issues with regard to the handling of the IRQ type settings ...
1. If the domain is part of a hierarchy, then:
a. We do not check that the type settings for the existing mapping
match those of the new mapping.
b. We do not check to see if the type settings have been programmed
yet (and they might not have been) and so we may never set the type.
2. If the domain is NOT part of a hierarchy, we will overwrite the current type settings programmed if they are different from the previous mapping. Please note that irq_create_mapping() calls irq_find_mapping() to check if a mapping already exists.
Although, it may be unlikely that the type settings for a shared interrupt would not match, nonetheless we should check for this. Therefore, to fix this check if a mapping exists (regardless of whether the domain is part of a hierarchy or not) and if it does then:
1. Return the IRQ number if the type settings match or are not specified.
2. Program the type settings and return the IRQ number if the type settings have not been programmed yet.
3. Otherwise if the type setting do not match, then print a warning and don't return the IRQ number.
Furthermore, add a warning if the type return by irq_domain_translate() has bits outside the sense mask set and then clear these bits. If these bits are not cleared then this will cause the comparision of the type settings for an existing mapping to fail with that of the new mapping even if the sense bit themselves match. The reason being is that the existing type settings are read by calling irq_get_trigger_type() which will clear any bits outside the sense mask. This will allow us to detect irqchips that are not correctly clearing these bits and fix them.
--- kernel/irq/irqdomain.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-)
kernel/irq/irqdomain.c +33 -5
@@ -592,15 +592,43 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)if (irq_domain_translate (domain, fwspec, &hwirq, &type))return 0 ; -if (irq_domain_is_hierarchy (domain)) { +/* +* WARN if the irqchip returns a type with bits +* outside the sense mask set and clear these bits. +*/ +if (WARN_ON (type & ~IRQ_TYPE_SENSE_MASK )) + type &=IRQ_TYPE_SENSE_MASK ; + +/* +* If we've already configured this interrupt, +* don't do it again, or hell will break loose. +*/ + virq =irq_find_mapping (domain, hwirq); +if (virq) {/* -* If we've already configured this interrupt, -* don't do it again, or hell will break loose. +* If the trigger type is not specified or matches the +* current trigger type then we are done so return the +* interrupt number. Otherwise, if the trigger type does +* not match return 0. */ - virq =irq_find_mapping (domain, hwirq); -if (virq) +if (type ==IRQ_TYPE_NONE || type ==irq_get_trigger_type (virq))return virq; +/* +* If the trigger type has not been set yet, then set +* it now and return the interrupt number. +*/ +if (irq_get_trigger_type (virq) ==IRQ_TYPE_NONE ) { +irq_set_irq_type (virq, type); +return virq; + } + +pr_warn ("type mismatch, failed to map hwirq-%lu for %s!\n" , + hwirq,of_node_full_name (to_of_node (fwspec->fwnode))); +return 0 ; + } + +if (irq_domain_is_hierarchy (domain)) { virq =irq_domain_alloc_irqs (domain,1 ,NUMA_NO_NODE , fwspec);if (virq <=0 )return 0 ;
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 5/14 genirq: Look-up trigger type if not specified by caller
In reply to Jon HunterFor some devices the IRQ trigger type for a device is read from firmware, such as device-tree. The IRQ trigger type is typically read when the mapping for IRQ is created, which is before the IRQ is requested. Hence, the IRQ trigger type is programmed when mapping the IRQ and not when requesting the IRQ.
Although this works for most cases, in order to support IRQ chips which require runtime power management, which may not be accessible prior to requesting the IRQ, it is desirable to look-up the IRQ trigger type when it is requested. Therefore, if the IRQ trigger type is not specified when __setup_irq() is called, look-up the saved IRQ trigger type. This will allow us to defer the programming of the trigger type from when the IRQ is mapped to when it is actually requested.
--- kernel/irq/manage.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/irq/manage.c +7 -0
@@ -1117,6 +1117,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) new->irq = irq;/* +* If the trigger type is not specified by the caller, +* then use the default for this interrupt. +*/ +if (!(new->flags &IRQF_TRIGGER_MASK )) + new->flags |=irqd_get_trigger_type (&desc->irq_data); + +/* * Check whether the interrupt nests into another interrupt * thread. */
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 6/14 irqdomain: Don't set type when mapping an IRQ
In reply to Jon HunterSome IRQ chips, such as GPIO controllers or secondary level interrupt controllers, may require require additional runtime power management control to ensure they are accessible. For such IRQ chips, it makes sense to enable the IRQ chip when interrupts are requested and disabled them again once all interrupts have been freed.
When mapping an IRQ, the IRQ type settings are read and then programmed. The mapping of the IRQ happens before the IRQ is requested and so the programming of the type settings occurs before the IRQ is requested. This is a problem for IRQ chips that require additional power management control because they may not be accessible yet. Therefore, when mapping the IRQ, don't program the type settings, just save them and then program these saved settings when the IRQ is requested (so long as if they are not overridden via the call to request the IRQ).
Add a stub function for irq_domain_free_irqs() to avoid any compilation errors when CONFIG_IRQ_DOMAIN_HIERARCHY is not selected.
--- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
include/linux/irqdomain.h +3 -0
@@ -440,6 +440,9 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,return -1 ; } +static inline void irq_domain_free_irqs (unsigned int virq, +unsigned int nr_irqs) { } +static inline bool irq_domain_is_hierarchy (struct irq_domain *domain) {return false;
kernel/irq/irqdomain.c +13 -4
@@ -569,6 +569,7 @@ static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,unsigned int irq_create_fwspec_mapping (struct irq_fwspec *fwspec) {struct irq_domain *domain; +struct irq_data *irq_data;irq_hw_number_t hwirq;unsigned int type =IRQ_TYPE_NONE ;int virq;
@@ -639,10 +640,18 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)return virq; } -/* Set type if specified and different than the current one */ -if (type !=IRQ_TYPE_NONE && - type !=irq_get_trigger_type (virq)) -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) { +if (irq_domain_is_hierarchy (domain)) +irq_domain_free_irqs (virq,1 ); +else +irq_dispose_mapping (virq); +return 0 ; + } + +/* Store trigger type */ +irqd_set_trigger_type (irq_data, type); +return virq; }EXPORT_SYMBOL_GPL (irq_create_fwspec_mapping);
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 7/14 genirq: Add runtime power management support for IRQ chips
In reply to Jon HunterSome IRQ chips may be located in a power domain outside of the CPU subsystem and hence will require device specific runtime power management. In order to support such IRQ chips, add a pointer for a device structure to the irq_chip structure, and if this pointer is populated by the IRQ chip driver and CONFIG_PM is selected in the kernel configuration, then the pm_runtime_get/put APIs for this chip will be called when an IRQ is requested/freed, respectively.
--- include/linux/irq.h | 4 ++++ kernel/irq/chip.c | 35 +++++++++++++++++++++++++++++++++++ kernel/irq/internals.h | 1 + kernel/irq/manage.c | 33 +++++++++++++++++++++++++++++++-- 4 files changed, 71 insertions(+), 2 deletions(-)
include/linux/irq.h +4 -0
@@ -315,6 +315,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)/** * struct irq_chip - hardware interrupt chip descriptor * +* @parent_device: pointer to parent device for irqchip * @name: name for /proc/interrupts * @irq_startup: start up the interrupt (defaults to ->enable if NULL) * @irq_shutdown: shut down the interrupt (defaults to ->disable if NULL)
@@ -354,6 +355,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)* @flags: chip specific flags */ struct irq_chip { +struct device *parent_device;const char *name;unsigned int (*irq_startup)(struct irq_data *data);void (*irq_shutdown)(struct irq_data *data);
@@ -488,6 +490,8 @@ extern void handle_bad_irq(struct irq_desc *desc);extern void handle_nested_irq (unsigned int irq);extern int irq_chip_compose_msi_msg (struct irq_data *data,struct msi_msg *msg); +extern int irq_chip_pm_get (struct irq_data *data); +extern int irq_chip_pm_put (struct irq_data *data);#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY extern void irq_chip_enable_parent (struct irq_data *data);extern void irq_chip_disable_parent (struct irq_data *data);
kernel/irq/chip.c +35 -0
@@ -1093,3 +1093,38 @@ int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)return 0 ; } + +/** +* irq_chip_pm_get - Enable power for an IRQ chip +* @data: Pointer to interrupt specific data +* +* Enable the power to the IRQ chip referenced by the interrupt data +* structure. +*/ +int irq_chip_pm_get (struct irq_data *data) +{ +int retval =0 ; + +if (IS_ENABLED (CONFIG_PM ) && data->chip->parent_device) + retval =pm_runtime_get_sync (data->chip->parent_device); + +return (retval <0 ) ? retval :0 ; +} + +/** +* irq_chip_pm_put - Disable power for an IRQ chip +* @data: Pointer to interrupt specific data +* +* Disable the power to the IRQ chip referenced by the interrupt data +* structure, belongs. Note that power will only be disabled, once this +* function has been called for all IRQs that have called irq_chip_pm_get(). +*/ +int irq_chip_pm_put (struct irq_data *data) +{ +int retval =0 ; + +if (IS_ENABLED (CONFIG_PM ) && data->chip->parent_device) + retval =pm_runtime_put (data->chip->parent_device); + +return (retval <0 ) ? retval :0 ; +}
kernel/irq/internals.h +1 -0
@@ -7,6 +7,7 @@*/ #include <linux/irqdesc.h> #include <linux/kernel_stat.h> +#include <linux/pm_runtime.h> #ifdef CONFIG_SPARSE_IRQ # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
kernel/irq/manage.c +31 -2
@@ -1414,12 +1414,20 @@ int setup_irq(unsigned int irq, struct irqaction *act)int retval;struct irq_desc *desc =irq_to_desc (irq); -if (WARN_ON (irq_settings_is_per_cpu_devid (desc))) +if (WARN_ON (!desc ||irq_settings_is_per_cpu_devid (desc)))return -EINVAL ; + + retval =irq_chip_pm_get (&desc->irq_data); +if (retval <0 ) +return retval; +chip_bus_lock (desc); retval =__setup_irq (irq, desc, act);chip_bus_sync_unlock (desc); +if (retval) +irq_chip_pm_put (&desc->irq_data); +return retval; }EXPORT_SYMBOL_GPL (setup_irq);
@@ -1513,6 +1521,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) } } +irq_chip_pm_put (&desc->irq_data);module_put (desc->owner);kfree (action->secondary);return action;
@@ -1655,11 +1664,16 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler, action->name = devname; action->dev_id = dev_id; + retval =irq_chip_pm_get (&desc->irq_data); +if (retval <0 ) +return retval; +chip_bus_lock (desc); retval =__setup_irq (irq, desc, action);chip_bus_sync_unlock (desc);if (retval) { +irq_chip_pm_put (&desc->irq_data);kfree (action->secondary);kfree (action); }
@@ -1829,6 +1843,7 @@ static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_unregister_handler_proc (irq, action); +irq_chip_pm_put (&desc->irq_data);module_put (desc->owner);return action;
@@ -1891,10 +1906,18 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act)if (!desc || !irq_settings_is_per_cpu_devid (desc))return -EINVAL ; + + retval =irq_chip_pm_get (&desc->irq_data); +if (retval <0 ) +return retval; +chip_bus_lock (desc); retval =__setup_irq (irq, desc, act);chip_bus_sync_unlock (desc); +if (retval) +irq_chip_pm_get (&desc->irq_data); +return retval; }
@@ -1938,12 +1961,18 @@ int request_percpu_irq(unsigned int irq, irq_handler_t handler, action->name = devname; action->percpu_dev_id = dev_id; + retval =irq_chip_pm_get (&desc->irq_data); +if (retval <0 ) +return retval; +chip_bus_lock (desc); retval =__setup_irq (irq, desc, action);chip_bus_sync_unlock (desc); -if (retval) +if (retval) { +irq_chip_pm_put (&desc->irq_data);kfree (action); + }return retval; }
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 8/14 irqchip/gic: Don't initialise chip if mapping IO space fails
In reply to Jon HunterIf we fail to map the address space for the GIC distributor or CPU interface, then don't attempt to initialise the chip, just WARN and return.
--- drivers/irqchip/irq-gic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic.c +6 -2
@@ -1201,10 +1201,14 @@ gic_of_init(struct device_node *node, struct device_node *parent)return -ENODEV ; dist_base =of_iomap (node,0 ); -WARN (!dist_base,"unable to map gic dist registers\n" ); +if (WARN (!dist_base,"unable to map gic dist registers\n" )) +return -ENOMEM ; cpu_base =of_iomap (node,1 ); -WARN (!cpu_base,"unable to map gic cpu registers\n" ); +if (WARN (!cpu_base,"unable to map gic cpu registers\n" )) { +iounmap (dist_base); +return -ENOMEM ; + }/* * Disable split EOI/Deactivate if either HYP is not available
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 9/14 irqchip/gic: Remove static irq_chip definition for eoimode1
In reply to Jon HunterThere are only 3 differences (not including the name) in the definitions of the gic_chip and gic_eoimode1_chip structures. Instead of statically defining the gic_eoimode1_chip structure, remove it and populate the eoimode1 functions dynamically for the appropriate GIC irqchips.
--- drivers/irqchip/irq-gic.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/irqchip/irq-gic.c +6 -16
@@ -391,20 +391,6 @@ static struct irq_chip gic_chip = { IRQCHIP_MASK_ON_SUSPEND, }; -static struct irq_chip gic_eoimode1_chip = { - .name ="GICv2" , - .irq_mask = gic_eoimode1_mask_irq, - .irq_unmask = gic_unmask_irq, - .irq_eoi = gic_eoimode1_eoi_irq, - .irq_set_type = gic_set_type, - .irq_get_irqchip_state = gic_irq_get_irqchip_state, - .irq_set_irqchip_state = gic_irq_set_irqchip_state, - .irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity, - .flags =IRQCHIP_SET_TYPE_MASKED | -IRQCHIP_SKIP_SET_WAKE | -IRQCHIP_MASK_ON_SUSPEND , -}; -void __init gic_cascade_irq (unsigned int gic_nr,unsigned int irq) {BUG_ON (gic_nr >=CONFIG_ARM_GIC_MAX_NR );
@@ -1026,10 +1012,14 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, gic = &gic_data[gic_nr];/* Initialize irq_chip */ + gic->chip = gic_chip; +if (static_key_true (&supports_deactivate) && gic_nr ==0 ) { - gic->chip = gic_eoimode1_chip; + gic->chip.irq_mask = gic_eoimode1_mask_irq; + gic->chip.irq_eoi = gic_eoimode1_eoi_irq; + gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity; + gic->chip.name ="GICv2" ; }else { - gic->chip = gic_chip; gic->chip.name =kasprintf (GFP_KERNEL ,"GIC-%d" , gic_nr); }
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 10/14 irqchip/gic: Return an error if GIC initialisation fails
In reply to Jon HunterIf the GIC initialisation fails, then currently we do not return an error or clean-up afterwards. Although for root controllers, this failure may be fatal anyway, for secondary controllers, it may not be fatal and so return an error on failure and clean-up.
For non-banked GIC controllers, make sure that we free any memory allocated if we fail to initialise the IRQ domain. Please note that free_percpu() only frees memory if the pointer passed to it is not NULL and so it is unnecessary to check if both pointers are valid or not.
--- drivers/irqchip/irq-gic.c | 59 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 17 deletions(-)
drivers/irqchip/irq-gic.c +42 -17
@@ -997,13 +997,13 @@ static const struct irq_domain_ops gic_irq_domain_ops = { .unmap = gic_irq_domain_unmap, }; -static void __init __gic_init_bases (unsigned int gic_nr,int irq_start, +static int __init __gic_init_bases (unsigned int gic_nr,int irq_start,void __iomem *dist_base,void __iomem *cpu_base,u32 percpu_offset,struct fwnode_handle *handle) {irq_hw_number_t hwirq_base;struct gic_chip_data *gic; -int gic_irqs, irq_base, i; +int gic_irqs, irq_base, i, ret;BUG_ON (gic_nr >=CONFIG_ARM_GIC_MAX_NR );
@@ -1018,7 +1018,7 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, gic->chip.irq_mask = gic_eoimode1_mask_irq; gic->chip.irq_eoi = gic_eoimode1_eoi_irq; gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity; - gic->chip.name ="GICv2" ; + gic->chip.name =kasprintf (GFP_KERNEL ,"GICv2" ); }else { gic->chip.name =kasprintf (GFP_KERNEL ,"GIC-%d" , gic_nr); }
@@ -1028,17 +1028,16 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, gic->chip.irq_set_affinity = gic_set_affinity;#endif -#ifdef CONFIG_GIC_NON_BANKED -if (percpu_offset) {/* Frankein-GIC without banked registers... */ +if (IS_ENABLED (CONFIG_GIC_NON_BANKED ) && percpu_offset) { +/* Frankein-GIC without banked registers... */ unsigned int cpu; gic->dist_base.percpu_base = alloc_percpu(void __iomem *); gic->cpu_base.percpu_base = alloc_percpu(void __iomem *);if (WARN_ON (!gic->dist_base.percpu_base || !gic->cpu_base.percpu_base)) { -free_percpu (gic->dist_base.percpu_base); -free_percpu (gic->cpu_base.percpu_base); -return ; + ret = -ENOMEM ; + goto error; }for_each_possible_cpu (cpu) {
@@ -1050,9 +1049,8 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, }gic_set_base_accessor (gic, gic_get_percpu_base); - } else -#endif - {/* Normal, sane GIC... */ + }else { +/* Normal, sane GIC... */ WARN (percpu_offset,"GIC_NON_BANKED not enabled, ignoring %08x offset!" , percpu_offset);
@@ -1102,8 +1100,10 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start, hwirq_base, &gic_irq_domain_ops, gic); } -if (WARN_ON (!gic->domain)) -return ; +if (WARN_ON (!gic->domain)) { + ret = -ENODEV ; + goto error; + }if (gic_nr ==0 ) {/*
@@ -1125,6 +1125,18 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start,gic_dist_init (gic);gic_cpu_init (gic);gic_pm_init (gic); + +return 0 ; + +error: +if (IS_ENABLED (CONFIG_GIC_NON_BANKED ) && percpu_offset) { +free_percpu (gic->dist_base.percpu_base); +free_percpu (gic->cpu_base.percpu_base); + } + +kfree (gic->chip.name); + +return ret; } void __init gic_init(unsigned int gic_nr, int irq_start,
@@ -1185,7 +1197,7 @@ gic_of_init(struct device_node *node, struct device_node *parent)void __iomem *cpu_base;void __iomem *dist_base;u32 percpu_offset; -int irq; +int irq, ret;if (WARN_ON (!node))return -ENODEV ;
@@ -1210,8 +1222,14 @@ gic_of_init(struct device_node *node, struct device_node *parent)if (of_property_read_u32 (node,"cpu-offset" , &percpu_offset)) percpu_offset =0 ; -__gic_init_bases (gic_cnt,-1 , dist_base, cpu_base, percpu_offset, + ret =__gic_init_bases (gic_cnt,-1 , dist_base, cpu_base, percpu_offset, &node->fwnode); +if (ret) { +iounmap (dist_base); +iounmap (cpu_base); +return ret; + } +if (!gic_cnt)gic_init_physaddr (node);
@@ -1300,7 +1318,7 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header,struct acpi_madt_generic_distributor *dist;void __iomem *cpu_base, *dist_base;struct fwnode_handle *domain_handle; -int count; +int count, ret;/* Collect CPU base addresses */ count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
@@ -1343,7 +1361,14 @@ static int __init gic_v2_acpi_init(struct acpi_subtable_header *header,return -ENOMEM ; } -__gic_init_bases (0 ,-1 , dist_base, cpu_base,0 , domain_handle); + ret =__gic_init_bases (0 ,-1 , dist_base, cpu_base,0 , domain_handle); +if (ret) { +pr_err ("Failed to initialise GIC\n" ); +irq_domain_free_fwnode (domain_handle); +iounmap (cpu_base); +iounmap (dist_base); +return ret; + }acpi_set_irq_model (ACPI_IRQ_MODEL_GIC , domain_handle);
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 11/14 irqchip/gic: Pass GIC pointer to save/restore functions
In reply to Jon HunterInstead of passing the GIC index to the save/restore functions pass a pointer to the GIC chip data. This will allow these save/restore functions to be re-used by a platform driver where the GIC chip data structure is allocated dynamically and so there is no applicable index for identifying the GIC.
--- drivers/irqchip/irq-gic.c | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-)
drivers/irqchip/irq-gic.c +39 -35
@@ -517,34 +517,35 @@ int gic_cpu_if_down(unsigned int gic_nr)* this function, no interrupts will be delivered by the GIC, and another * platform-specific wakeup source must be enabled. */ -static void gic_dist_save (unsigned int gic_nr) +static void gic_dist_save (struct gic_chip_data *gic) {unsigned int gic_irqs;void __iomem *dist_base;int i; -BUG_ON (gic_nr >=CONFIG_ARM_GIC_MAX_NR ); +if (WARN_ON (!gic)) +return ; - gic_irqs = gic_data[gic_nr].gic_irqs; - dist_base =gic_data_dist_base (&gic_data[gic_nr]); + gic_irqs = gic->gic_irqs; + dist_base =gic_data_dist_base (gic);if (!dist_base)return ;for (i =0 ; i <DIV_ROUND_UP (gic_irqs,16 ); i++) - gic_data[gic_nr].saved_spi_conf[i] = + gic->saved_spi_conf[i] =readl_relaxed (dist_base +GIC_DIST_CONFIG + i *4 );for (i =0 ; i <DIV_ROUND_UP (gic_irqs,4 ); i++) - gic_data[gic_nr].saved_spi_target[i] = + gic->saved_spi_target[i] =readl_relaxed (dist_base +GIC_DIST_TARGET + i *4 );for (i =0 ; i <DIV_ROUND_UP (gic_irqs,32 ); i++) - gic_data[gic_nr].saved_spi_enable[i] = + gic->saved_spi_enable[i] =readl_relaxed (dist_base +GIC_DIST_ENABLE_SET + i *4 );for (i =0 ; i <DIV_ROUND_UP (gic_irqs,32 ); i++) - gic_data[gic_nr].saved_spi_active[i] = + gic->saved_spi_active[i] =readl_relaxed (dist_base +GIC_DIST_ACTIVE_SET + i *4 ); }
@@ -555,16 +556,17 @@ static void gic_dist_save(unsigned int gic_nr)* handled normally, but any edge interrupts that occured will not be seen by * the GIC and need to be handled by the platform-specific wakeup source. */ -static void gic_dist_restore (unsigned int gic_nr) +static void gic_dist_restore (struct gic_chip_data *gic) {unsigned int gic_irqs;unsigned int i;void __iomem *dist_base; -BUG_ON (gic_nr >=CONFIG_ARM_GIC_MAX_NR ); +if (WARN_ON (!gic)) +return ; - gic_irqs = gic_data[gic_nr].gic_irqs; - dist_base =gic_data_dist_base (&gic_data[gic_nr]); + gic_irqs = gic->gic_irqs; + dist_base =gic_data_dist_base (gic);if (!dist_base)return ;
@@ -572,7 +574,7 @@ static void gic_dist_restore(unsigned int gic_nr)writel_relaxed (GICD_DISABLE , dist_base +GIC_DIST_CTRL );for (i =0 ; i <DIV_ROUND_UP (gic_irqs,16 ); i++) -writel_relaxed (gic_data[gic_nr].saved_spi_conf[i], +writel_relaxed (gic->saved_spi_conf[i], dist_base +GIC_DIST_CONFIG + i *4 );for (i =0 ; i <DIV_ROUND_UP (gic_irqs,4 ); i++)
@@ -580,85 +582,87 @@ static void gic_dist_restore(unsigned int gic_nr) dist_base + GIC_DIST_PRI + i * 4);for (i =0 ; i <DIV_ROUND_UP (gic_irqs,4 ); i++) -writel_relaxed (gic_data[gic_nr].saved_spi_target[i], +writel_relaxed (gic->saved_spi_target[i], dist_base +GIC_DIST_TARGET + i *4 );for (i =0 ; i <DIV_ROUND_UP (gic_irqs,32 ); i++) {writel_relaxed (GICD_INT_EN_CLR_X32 , dist_base +GIC_DIST_ENABLE_CLEAR + i *4 ); -writel_relaxed (gic_data[gic_nr].saved_spi_enable[i], +writel_relaxed (gic->saved_spi_enable[i], dist_base +GIC_DIST_ENABLE_SET + i *4 ); }for (i =0 ; i <DIV_ROUND_UP (gic_irqs,32 ); i++) {writel_relaxed (GICD_INT_EN_CLR_X32 , dist_base +GIC_DIST_ACTIVE_CLEAR + i *4 ); -writel_relaxed (gic_data[gic_nr].saved_spi_active[i], +writel_relaxed (gic->saved_spi_active[i], dist_base +GIC_DIST_ACTIVE_SET + i *4 ); }writel_relaxed (GICD_ENABLE , dist_base +GIC_DIST_CTRL ); } -static void gic_cpu_save (unsigned int gic_nr) +static void gic_cpu_save (struct gic_chip_data *gic) {int i;u32 *ptr;void __iomem *dist_base;void __iomem *cpu_base; -BUG_ON (gic_nr >=CONFIG_ARM_GIC_MAX_NR ); +if (WARN_ON (!gic)) +return ; - dist_base =gic_data_dist_base (&gic_data[gic_nr]); - cpu_base =gic_data_cpu_base (&gic_data[gic_nr]); + dist_base =gic_data_dist_base (gic); + cpu_base =gic_data_cpu_base (gic);if (!dist_base || !cpu_base)return ; - ptr =raw_cpu_ptr (gic_data[gic_nr].saved_ppi_enable); + ptr =raw_cpu_ptr (gic->saved_ppi_enable);for (i =0 ; i <DIV_ROUND_UP (32 ,32 ); i++) ptr[i] =readl_relaxed (dist_base +GIC_DIST_ENABLE_SET + i *4 ); - ptr =raw_cpu_ptr (gic_data[gic_nr].saved_ppi_active); + ptr =raw_cpu_ptr (gic->saved_ppi_active);for (i =0 ; i <DIV_ROUND_UP (32 ,32 ); i++) ptr[i] =readl_relaxed (dist_base +GIC_DIST_ACTIVE_SET + i *4 ); - ptr =raw_cpu_ptr (gic_data[gic_nr].saved_ppi_conf); + ptr =raw_cpu_ptr (gic->saved_ppi_conf);for (i =0 ; i <DIV_ROUND_UP (32 ,16 ); i++) ptr[i] =readl_relaxed (dist_base +GIC_DIST_CONFIG + i *4 ); } -static void gic_cpu_restore (unsigned int gic_nr) +static void gic_cpu_restore (struct gic_chip_data *gic) {int i;u32 *ptr;void __iomem *dist_base;void __iomem *cpu_base; -BUG_ON (gic_nr >=CONFIG_ARM_GIC_MAX_NR ); +if (WARN_ON (!gic)) +return ; - dist_base =gic_data_dist_base (&gic_data[gic_nr]); - cpu_base =gic_data_cpu_base (&gic_data[gic_nr]); + dist_base =gic_data_dist_base (gic); + cpu_base =gic_data_cpu_base (gic);if (!dist_base || !cpu_base)return ; - ptr =raw_cpu_ptr (gic_data[gic_nr].saved_ppi_enable); + ptr =raw_cpu_ptr (gic->saved_ppi_enable);for (i =0 ; i <DIV_ROUND_UP (32 ,32 ); i++) {writel_relaxed (GICD_INT_EN_CLR_X32 , dist_base +GIC_DIST_ENABLE_CLEAR + i *4 );writel_relaxed (ptr[i], dist_base +GIC_DIST_ENABLE_SET + i *4 ); } - ptr =raw_cpu_ptr (gic_data[gic_nr].saved_ppi_active); + ptr =raw_cpu_ptr (gic->saved_ppi_active);for (i =0 ; i <DIV_ROUND_UP (32 ,32 ); i++) {writel_relaxed (GICD_INT_EN_CLR_X32 , dist_base +GIC_DIST_ACTIVE_CLEAR + i *4 );writel_relaxed (ptr[i], dist_base +GIC_DIST_ACTIVE_SET + i *4 ); } - ptr =raw_cpu_ptr (gic_data[gic_nr].saved_ppi_conf); + ptr =raw_cpu_ptr (gic->saved_ppi_conf);for (i =0 ; i <DIV_ROUND_UP (32 ,16 ); i++)writel_relaxed (ptr[i], dist_base +GIC_DIST_CONFIG + i *4 );
@@ -667,7 +671,7 @@ static void gic_cpu_restore(unsigned int gic_nr) dist_base + GIC_DIST_PRI + i * 4);writel_relaxed (GICC_INT_PRI_THRESHOLD , cpu_base +GIC_CPU_PRIMASK ); -gic_cpu_if_up (&gic_data[gic_nr]); +gic_cpu_if_up (gic); }static int gic_notifier (struct notifier_block *self,unsigned long cmd,void *v)
@@ -682,18 +686,18 @@ static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v)#endif switch (cmd) {case CPU_PM_ENTER : -gic_cpu_save (i); +gic_cpu_save (&gic_data[i]);break ;case CPU_PM_ENTER_FAILED :case CPU_PM_EXIT : -gic_cpu_restore (i); +gic_cpu_restore (&gic_data[i]);break ;case CPU_CLUSTER_PM_ENTER : -gic_dist_save (i); +gic_dist_save (&gic_data[i]);break ;case CPU_CLUSTER_PM_ENTER_FAILED :case CPU_CLUSTER_PM_EXIT : -gic_dist_restore (i); +gic_dist_restore (&gic_data[i]);break ; } }
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 12/14 irqchip/gic: Prepare for adding platform driver
In reply to Jon HunterTo support GIC chips located in power-domains outside of the CPU subsystem it is necessary to add a platform driver for these chips, so that the probing of the chip can be deferred if resources, such as a power-domain, is not yet available.
To re-use the code that initialises the GIC (found in __gic_init_bases()), from within the platform driver, it is necessary to move the code from the __init section so that it is always present and not removed. Unfortunately, it is not possible to simply drop the __init from the function declaration for __gic_init_bases() because it contains calls to set_smp_cross_call() and set_handle_irq() which are both located in the __init section. Fortunately, these calls are only required for the root controller and because the platform driver will only support non-root controllers that can be initialised later in the boot process, we can move these calls to another function. Move the bulk of the code from __gic_init_bases() to a new function called gic_init_bases() which is not located in the __init section and can be used by the platform driver. Update __gic_init_bases() to call gic_init_bases() and if necessary, set_smp_cross_call() and set_handle_irq().
The function, gic_init_bases(), references the GIC via a pointer to the GIC chip data structure instead of an index so that it can be used by the platform driver and statically declared GICs. This means that the name must be passed to gic_init_bases() as well, because the name will not be passed upon an index for platform devices.
Drop the __init section from the gic_dist_config(), gic_dist_init() and gic_pm_init() so these can be re-used by the platform driver as well.
--- drivers/irqchip/irq-gic-common.c | 4 +- drivers/irqchip/irq-gic.c | 80 +++++++++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 27 deletions(-)
drivers/irqchip/irq-gic-common.c +2 -2
@@ -72,8 +72,8 @@ int gic_configure_irq(unsigned int irq, unsigned int type,return ret; } -void __init gic_dist_config (void __iomem *base,int gic_irqs, -void (*sync_access)(void )) +void gic_dist_config (void __iomem *base,int gic_irqs, +void (*sync_access)(void )) {unsigned int i;
drivers/irqchip/irq-gic.c +55 -25
144 lines not on this page · raw message
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 13/14 dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Jon HunterThe Tegra AGIC interrupt controller is compatible with the ARM GIC-400 interrupt controller. The Tegra AGIC requires two clocks, namely the "ape" (functional) and "apb2ape" (interface) clocks, to operate. Add the compatible string and clock information for the AGIC to the GIC device-tree binding documentation.
---
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt +2 -0
@@ -21,6 +21,7 @@ Main node required properties: "arm,pl390" "arm,tc11mp-gic" "brcm,brahma-b15-gic" + "nvidia,tegra210-agic" "qcom,msm-8660-qgic" "qcom,msm-qgic2" - interrupt-controller : Identifies the node as an interrupt controller
@@ -70,6 +71,7 @@ Optional "PERIPHCLK", "PERIPHCLKEN" (for "arm,cortex-a9-gic") "clk" (for "arm,gic-400") "gclk" (for "arm,pl390") + "ape" and "apb2ape" (for "nvidia,tegra,agic") - power-domains : A phandle and PM domain specifier as defined by bindings of the power controller specified by phandle, used when the GIC
Signature · 1 line
2.1.4
Jon Hunter
maintainerPATCH v2 14/14 irqchip/gic: Add support for tegra AGIC interrupt controller
In reply to Jon HunterAdd a driver for the Tegra-AGIC interrupt controller which is compatible with the ARM GIC-400 interrupt controller.
The Tegra AGIC (Audio GIC) is part of the Audio Processing Engine (APE) on Tegra210 and can route interrupts to either the GIC for the CPU subsystem or the Audio DSP (ADSP) within the APE. The AGIC uses CPU interface 0 to route interrupts to the CPU GIC and CPU interface 1 to route interrupts to the ADSP.
The APE is located within its own power domain on the chip and so the AGIC needs to manage both the power domain and its clocks. Commit afbbd2338176 ("irqchip/gic: Document optional Clock and Power Domain properties") has already added clock and power-domain properties to the GIC binding and so we can make use of these for the AGIC.
With the AGIC being located in a different power domain to the main CPU cluster this means that:
1. The interrupt controller cannot be registered via IRQCHIP_DECLARE() because it needs to be registered as a platform device so that the generic PM domain core will ensure that the power domain is available before probing.
2. The interrupt controller cannot be suspended/restored based upon changes in the CPU power state and needs to use runtime-pm instead.
The GIC platform driver has been implemented by making the following changes to the core GIC driver:
1. Remove the dependency on CONFIG_CPU_PM from PM specific variables and functions so that they can be used by the platform driver even when CONFIG_CPU_PM is not selected.
2. Move the code that maps the GIC registers and parses the device-tree blob into a new function called gic_of_setup() that can be used by both the platform driver as well as the existing driver.
3. Add and register platform driver for the GIC. The platform driver uses the PM_CLK framework for managing the clocks used by the GIC and so select CONFIG_PM_CLK.
Finally, a couple other notes on the implementation are:
1. Currently the GIC platform driver only supports non-root GICs and assumes that the GIC has a parent interrupt. It is assumed that root interrupt controllers need to be initialised early.
2. There is no specific suspend handling for GICs registered as platform devices. Non-wakeup interrupts will be disabled by the kernel during late suspend, however, this alone will not power down the GIC if interrupts have been requested and not freed. Therefore, requestors of non-wakeup interrupts will need to free them on entering suspend in order to power-down the GIC.
---
Please note that so far I have not added all the clock names for the various GIC versions (as described by the DT documentation). I thought we could add these as they are needed.
drivers/irqchip/Kconfig | 1 + drivers/irqchip/irq-gic.c | 225 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 203 insertions(+), 23 deletions(-)
drivers/irqchip/Kconfig +1 -0
@@ -7,6 +7,7 @@ config ARM_GIC select IRQ_DOMAIN select IRQ_DOMAIN_HIERARCHY select MULTI_IRQ_HANDLER + select PM_CLK config ARM_GIC_MAX_NR int
drivers/irqchip/irq-gic.c +202 -23
297 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [PATCH V2 07/14] genirq: Add runtime power management support for IRQ chips
In reply to Jon HunterQuoted 9 lines · Jon Hunter
Some IRQ chips may be located in a power domain outside of the CPU subsystem and hence will require device specific runtime power management. In order to support such IRQ chips, add a pointer for a device structure to the
irq_chipstructure, and if this pointer is populated by the IRQ chip driver andCONFIG_PMis selected in the kernel configuration, then the pm_runtime_get/put APIs for this chip will be called when an IRQ is requested/freed, respectively.Signed-off-by Jon Hunter <[email protected]>
[...]
Quoted 6 lines
kernel/irq/manage.c +2
-0@@ -1891,10 +1906,18 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act)if (!desc || !irq_settings_is_per_cpu_devid (desc))return -EINVAL ; + + retval =irq_chip_pm_get (&desc->irq_data);
kernel/irq/manage.c int setup_percpu_irq(unsigned int irq, struct irqaction *act) · line 1920
Quoted 10 lines
kernel/irq/manage.c +6
-0+if (retval <0 ) +return retval; +chip_bus_lock (desc); retval =__setup_irq (irq, desc, act);chip_bus_sync_unlock (desc); +if (retval) +irq_chip_pm_get (&desc->irq_data); +
Shouldn't this one be a _put() ?
Otherwise, LGTM
Kevin
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jon Hunter
maintainerRe: [PATCH V2 07/14] genirq: Add runtime power management support for IRQ chips
Quoted 27 lines · Kevin Hilman
Quoted 9 lines · Jon Hunter
Some IRQ chips may be located in a power domain outside of the CPU subsystem and hence will require device specific runtime power management. In order to support such IRQ chips, add a pointer for a device structure to the
irq_chipstructure, and if this pointer is populated by the IRQ chip driver andCONFIG_PMis selected in the kernel configuration, then the pm_runtime_get/put APIs for this chip will be called when an IRQ is requested/freed, respectively.Signed-off-by Jon Hunter <[email protected]>[...]
Quoted 13 lines
kernel/irq/manage.c +5
-0@@ -1891,10 +1906,18 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act)if (!desc || !irq_settings_is_per_cpu_devid (desc))return -EINVAL ; + + retval =irq_chip_pm_get (&desc->irq_data); +if (retval <0 ) +return retval; +chip_bus_lock (desc); retval =__setup_irq (irq, desc, act);chip_bus_sync_unlock (desc);
Quoted 5 lines
kernel/irq/manage.c int setup_percpu_irq(unsigned int irq, struct irqaction *act) · line 1920
Quoted 3 lines
kernel/irq/manage.c +3
-0+if (retval) +irq_chip_pm_get (&desc->irq_data); +Shouldn't this one be a
_put()?
Good grief! Yes it should. Sorry, will fix :-(
Quoted 3 lines
Otherwise, LGTM
Reviewed-by Kevin Hilman <[email protected]>
Thanks!
Jon
Jon Hunter
maintainerRe: [PATCH V2 04/14] irqdomain: Fix handling of type settings for existing mappings
In reply to Jon HunterQuoted 58 lines · Jon Hunter
When mapping an IRQ, it is possible that a mapping for the IRQ already exists. If mapping does exist then there are the following issues with regard to the handling of the IRQ type settings ...
1. If the domain is part of a hierarchy, then:
a. We do not check that the type settings for the existing mapping
match those of the new mapping.
b. We do not check to see if the type settings have been programmed
yet (and they might not have been) and so we may never set the type.
2. If the domain is NOT part of a hierarchy, we will overwrite the current type settings programmed if they are different from the previous mapping. Please note thatirq_create_mapping()callsirq_find_mapping()to check if a mapping already exists.Although, it may be unlikely that the type settings for a shared interrupt would not match, nonetheless we should check for this. Therefore, to fix this check if a mapping exists (regardless of whether the domain is part of a hierarchy or not) and if it does then:
1. Return the IRQ number if the type settings match or are not specified.
2. Program the type settings and return the IRQ number if the type settings have not been programmed yet.
3. Otherwise if the type setting do not match, then print a warning and don't return the IRQ number.Furthermore, add a warning if the type return by
irq_domain_translate()has bits outside the sense mask set and then clear these bits. If these bits are not cleared then this will cause the comparision of the type settings for an existing mapping to fail with that of the new mapping even if the sense bit themselves match. The reason being is that the existing type settings are read by callingirq_get_trigger_type()which will clear any bits outside the sense mask. This will allow us to detect irqchips that are not correctly clearing these bits and fix them.Signed-off-by Jon Hunter <[email protected]>--- kernel/irq/irqdomain.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-)kernel/irq/irqdomain.c +10
-1@@ -592,15 +592,43 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)if (irq_domain_translate (domain, fwspec, &hwirq, &type))return 0 ; -if (irq_domain_is_hierarchy (domain)) { +/* +* WARN if the irqchip returns a type with bits +* outside the sense mask set and clear these bits. +*/ +if (WARN_ON (type & ~IRQ_TYPE_SENSE_MASK )) + type &=IRQ_TYPE_SENSE_MASK ; + +/* +* If we've already configured this interrupt, +* don't do it again, or hell will break loose.
kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 612
Quoted 10 lines
kernel/irq/irqdomain.c +7
-2+*/ + virq =irq_find_mapping (domain, hwirq); +if (virq) {/* -* If we've already configured this interrupt, -* don't do it again, or hell will break loose. +* If the trigger type is not specified or matches the +* current trigger type then we are done so return the +* interrupt number. Otherwise, if the trigger type does +* not match return 0.
I think I should have dropped this 'otherwise' sentence from here.
Jon
Jon Hunter
maintainerRe: [PATCH V2 06/14] irqdomain: Don't set type when mapping an IRQ
In reply to Jon HunterQuoted 23 lines · Jon Hunter
Some IRQ chips, such as GPIO controllers or secondary level interrupt controllers, may require require additional runtime power management control to ensure they are accessible. For such IRQ chips, it makes sense to enable the IRQ chip when interrupts are requested and disabled them again once all interrupts have been freed.
When mapping an IRQ, the IRQ type settings are read and then programmed. The mapping of the IRQ happens before the IRQ is requested and so the programming of the type settings occurs before the IRQ is requested. This is a problem for IRQ chips that require additional power management control because they may not be accessible yet. Therefore, when mapping the IRQ, don't program the type settings, just save them and then program these saved settings when the IRQ is requested (so long as if they are not overridden via the call to request the IRQ).
Add a stub function for
irq_domain_free_irqs()to avoid any compilation errors whenCONFIG_IRQ_DOMAIN_HIERARCHYis not selected.Signed-off-by Jon Hunter <[email protected]>--- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
[snip]
Quoted 6 lines
(quoted diff) +2
-4- /* Set type if specified and different than the current one */ - if (type != IRQ_TYPE_NONE && - type != irq_get_trigger_type(virq)) - irq_set_irq_type(virq, type); + irq_data = irq_get_irq_data(virq); + if (!irq_data) {
Review
Quoted 10 lines
(quoted diff) +10
-0+ if (irq_domain_is_hierarchy(domain)) + irq_domain_free_irqs(virq, 1); + else + irq_dispose_mapping(virq); + return 0; + } + + /* Store trigger type */ + irqd_set_trigger_type(irq_data, type); +
I appear to have missed another place for saving the irq type which I had change in this version. Next time I will triple check! Should have been ...
include/linux/irqdomain.h +3 -0
@@ -440,6 +440,9 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,return -1 ; } +static inline void irq_domain_free_irqs (unsigned int virq, +unsigned int nr_irqs) { } +static inline bool irq_domain_is_hierarchy (struct irq_domain *domain) {return false;
kernel/irq/irqdomain.c +18 -5
@@ -569,6 +569,7 @@ static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,unsigned int irq_create_fwspec_mapping (struct irq_fwspec *fwspec) {struct irq_domain *domain; +struct irq_data *irq_data;irq_hw_number_t hwirq;unsigned int type =IRQ_TYPE_NONE ;int virq;
@@ -619,7 +620,11 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)* it now and return the interrupt number. */ if (IRQ_TYPE_NONE ==irq_get_trigger_type (virq)) { -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) +return 0 ; + +irqd_set_trigger_type (irq_data, type);return virq; }
@@ -639,10 +644,18 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)return virq; } -/* Set type if specified and different than the current one */ -if (type !=IRQ_TYPE_NONE && - type !=irq_get_trigger_type (virq)) -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) { +if (irq_domain_is_hierarchy (domain)) +irq_domain_free_irqs (virq,1 ); +else +irq_dispose_mapping (virq); +return 0 ; + } + +/* Store trigger type */ +irqd_set_trigger_type (irq_data, type); +return virq; }EXPORT_SYMBOL_GPL (irq_create_fwspec_mapping);
Re: [PATCH V2 04/14] irqdomain: Fix handling of type settings for existing mappings
In reply to Jon HunterQuoted 34 lines · Jon Hunter
When mapping an IRQ, it is possible that a mapping for the IRQ already exists. If mapping does exist then there are the following issues with regard to the handling of the IRQ type settings ...
1. If the domain is part of a hierarchy, then:
a. We do not check that the type settings for the existing mapping
match those of the new mapping.
b. We do not check to see if the type settings have been programmed
yet (and they might not have been) and so we may never set the type.
2. If the domain is NOT part of a hierarchy, we will overwrite the current type settings programmed if they are different from the previous mapping. Please note thatirq_create_mapping()callsirq_find_mapping()to check if a mapping already exists.Although, it may be unlikely that the type settings for a shared interrupt would not match, nonetheless we should check for this. Therefore, to fix this check if a mapping exists (regardless of whether the domain is part of a hierarchy or not) and if it does then:
1. Return the IRQ number if the type settings match or are not specified.
2. Program the type settings and return the IRQ number if the type settings have not been programmed yet.
3. Otherwise if the type setting do not match, then print a warning and don't return the IRQ number.Furthermore, add a warning if the type return by
irq_domain_translate()has bits outside the sense mask set and then clear these bits. If these bits are not cleared then this will cause the comparision of the type settings for an existing mapping to fail with that of the new mapping even if the sense bit themselves match. The reason being is that the existing type settings are read by callingirq_get_trigger_type()which will clear any bits outside the sense mask. This will allow us to detect irqchips that are not correctly clearing these bits and fix them.
Quoted 1 line
Signed-off-by Jon Hunter <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH V2 06/14] irqdomain: Don't set type when mapping an IRQ
In reply to Jon HunterHi Jon,
Quoted 77 lines · Jon Hunter
Quoted 23 lines · Jon Hunter
Some IRQ chips, such as GPIO controllers or secondary level interrupt controllers, may require require additional runtime power management control to ensure they are accessible. For such IRQ chips, it makes sense to enable the IRQ chip when interrupts are requested and disabled them again once all interrupts have been freed.
When mapping an IRQ, the IRQ type settings are read and then programmed. The mapping of the IRQ happens before the IRQ is requested and so the programming of the type settings occurs before the IRQ is requested. This is a problem for IRQ chips that require additional power management control because they may not be accessible yet. Therefore, when mapping the IRQ, don't program the type settings, just save them and then program these saved settings when the IRQ is requested (so long as if they are not overridden via the call to request the IRQ).
Add a stub function for
irq_domain_free_irqs()to avoid any compilation errors whenCONFIG_IRQ_DOMAIN_HIERARCHYis not selected.Signed-off-by Jon Hunter <[email protected]>--- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)[snip]
Quoted 6 lines
kernel/irq/irqdomain.c +2
-4-/* Set type if specified and different than the current one */ -if (type !=IRQ_TYPE_NONE && - type !=irq_get_trigger_type (virq)) -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) {kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 658
Quoted 10 lines
kernel/irq/irqdomain.c +10
-0+if (irq_domain_is_hierarchy (domain)) +irq_domain_free_irqs (virq,1 ); +else +irq_dispose_mapping (virq); +return 0 ; + } + +/* Store trigger type */ +irqd_set_trigger_type (irq_data, type); +I appear to have missed another place for saving the irq type which I had change in this version. Next time I will triple check! Should have been ...
include/linux/irqdomain.h +3
-0@@ -440,6 +440,9 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,return -1 ; } +static inline void irq_domain_free_irqs (unsigned int virq, +unsigned int nr_irqs) { } +static inline bool irq_domain_is_hierarchy (struct irq_domain *domain) {return false;kernel/irq/irqdomain.c +1
-0@@ -569,6 +569,7 @@ static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,unsigned int irq_create_fwspec_mapping (struct irq_fwspec *fwspec) {struct irq_domain *domain; +struct irq_data *irq_data;irq_hw_number_t hwirq;unsigned int type =IRQ_TYPE_NONE ;int virq;
kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 625
Quoted 7 lines
kernel/irq/irqdomain.c +3
-1@@ -619,7 +620,11 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)* it now and return the interrupt number. */ if (IRQ_TYPE_NONE ==irq_get_trigger_type (virq)) { -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) +return 0 ;
Can you point out in which circumstances irq_data can be NULL? If we can lookup the interrupt in the domain, it'd better exist somewhere. Or am I missing something obvious?
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 03/14] irqchip: Mask the non-type/sense bits when translating an IRQ
In reply to Jon HunterQuoted 12 lines · Jon Hunter
The firmware parameter that contains the IRQ sense bits may also contain other data. When return the IRQ type, bits outside of these sense bits should be masked. If these bits are not masked and
irq_create_fwspec_mapping()is called to map an IRQ, then the comparison of the type returned fromirq_domain_translate()will never match that returned byirq_get_trigger_type()(because this function masks the none sense bits) and so we will always callirq_set_irq_type()to program the type even if it was not really necessary.Currently, the downside to this is unnecessarily re-programmming the type but nevertheless this should be avoided.
Quoted 6 lines
The Tegra LIC and TI Crossbar irqchips all have client instances (from reviewing the device-tree sources) where bits outside the IRQ sense bits are set, but do not mask these bits. Therefore, ensure these bits are masked for these irqchips.
Signed-off-by Jon Hunter <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Jon Hunter
maintainerRe: [PATCH V2 06/14] irqdomain: Don't set type when mapping an IRQ
In reply to Marc ZyngierQuoted 83 lines · Marc Zyngier
Hi Jon,
Quoted 80 lines · Jon Hunter
Quoted 23 lines · Jon Hunter
Some IRQ chips, such as GPIO controllers or secondary level interrupt controllers, may require require additional runtime power management control to ensure they are accessible. For such IRQ chips, it makes sense to enable the IRQ chip when interrupts are requested and disabled them again once all interrupts have been freed.
When mapping an IRQ, the IRQ type settings are read and then programmed. The mapping of the IRQ happens before the IRQ is requested and so the programming of the type settings occurs before the IRQ is requested. This is a problem for IRQ chips that require additional power management control because they may not be accessible yet. Therefore, when mapping the IRQ, don't program the type settings, just save them and then program these saved settings when the IRQ is requested (so long as if they are not overridden via the call to request the IRQ).
Add a stub function for
irq_domain_free_irqs()to avoid any compilation errors whenCONFIG_IRQ_DOMAIN_HIERARCHYis not selected.Signed-off-by Jon Hunter <[email protected]>--- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)[snip]
Quoted 6 lines
kernel/irq/irqdomain.c +2
-4-/* Set type if specified and different than the current one */ -if (type !=IRQ_TYPE_NONE && - type !=irq_get_trigger_type (virq)) -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) {kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 658
Quoted 10 lines
kernel/irq/irqdomain.c +10
-0+if (irq_domain_is_hierarchy (domain)) +irq_domain_free_irqs (virq,1 ); +else +irq_dispose_mapping (virq); +return 0 ; + } + +/* Store trigger type */ +irqd_set_trigger_type (irq_data, type); +I appear to have missed another place for saving the irq type which I had change in this version. Next time I will triple check! Should have been ...
include/linux/irqdomain.h +3
-0@@ -440,6 +440,9 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,return -1 ; } +static inline void irq_domain_free_irqs (unsigned int virq, +unsigned int nr_irqs) { } +static inline bool irq_domain_is_hierarchy (struct irq_domain *domain) {return false;kernel/irq/irqdomain.c +1
-0@@ -569,6 +569,7 @@ static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,unsigned int irq_create_fwspec_mapping (struct irq_fwspec *fwspec) {struct irq_domain *domain; +struct irq_data *irq_data;irq_hw_number_t hwirq;unsigned int type =IRQ_TYPE_NONE ;int virq;@@ -619,7 +620,11 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)* it now and return the interrupt number. */ if (IRQ_TYPE_NONE ==irq_get_trigger_type (virq)) {
Quoted 8 lines
kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 625
Quoted 4 lines
kernel/irq/irqdomain.c +3
-1-irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) +return 0 ;Can you point out in which circumstances
irq_datacan be NULL? If we can lookup the interrupt in the domain, it'd better exist somewhere. Or am I missing something obvious?
To be honest, I was not 100% sure if this could be possible if we find an existing mapping or if there were any paths that could race. So if we can guarantee that it is not NULL here, I can drop this and simplify the change.
By the way, is there any sort of reference count for mapping an IRQ so that if irq_create_fwspec_mapping() is called more than once for an IRQ, it is not freed on the first call to irq_dispose_mapping()? I assume there is but could not see where this is handled.
Cheers
Jon
Re: [PATCH V2 02/14] irqchip/gic: WARN if setting the interrupt type for a PPI fails
In reply to Jon HunterQuoted 14 lines · Jon Hunter
Setting the interrupt type for private peripheral interrupts (PPIs) may not be supported by a given GIC because it is IMPLEMENTATION DEFINED whether this is allowed. There is no way to know if setting the type is supported for a given GIC and so the value written is read back to verify it matches the desired configuration. If it does not match then an error is return.
There are cases where the interrupt configuration read from firmware (such as a device-tree blob), has been incorrect and hence
gic_configure_irq()has returned an error. This error has gone undetected because the error code returned was ignored but the interrupt still worked fine because the configuration for the interrupt could not be overwritten.
Quoted 8 lines
Given that this has done undetected and that failing to set the configuration for a PPI may not be a catastrophic, don't return an error but WARN if we fail to configure a PPI. This will allows us to fix up any places in the kernel where we should be checking the return status and maintain backward compatibility with firmware images that may have incorrect PPI configurations.
Signed-off-by Jon Hunter <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH V2 06/14] irqdomain: Don't set type when mapping an IRQ
In reply to Jon HunterQuoted 94 lines · Jon Hunter
Quoted 83 lines · Marc Zyngier
Hi Jon,
Quoted 80 lines · Jon Hunter
Quoted 23 lines · Jon Hunter
Some IRQ chips, such as GPIO controllers or secondary level interrupt controllers, may require require additional runtime power management control to ensure they are accessible. For such IRQ chips, it makes sense to enable the IRQ chip when interrupts are requested and disabled them again once all interrupts have been freed.
When mapping an IRQ, the IRQ type settings are read and then programmed. The mapping of the IRQ happens before the IRQ is requested and so the programming of the type settings occurs before the IRQ is requested. This is a problem for IRQ chips that require additional power management control because they may not be accessible yet. Therefore, when mapping the IRQ, don't program the type settings, just save them and then program these saved settings when the IRQ is requested (so long as if they are not overridden via the call to request the IRQ).
Add a stub function for
irq_domain_free_irqs()to avoid any compilation errors whenCONFIG_IRQ_DOMAIN_HIERARCHYis not selected.Signed-off-by Jon Hunter <[email protected]>--- include/linux/irqdomain.h | 3 +++ kernel/irq/irqdomain.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)[snip]
Quoted 6 lines
kernel/irq/irqdomain.c +2
-4-/* Set type if specified and different than the current one */ -if (type !=IRQ_TYPE_NONE && - type !=irq_get_trigger_type (virq)) -irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) {kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 658
Quoted 10 lines
kernel/irq/irqdomain.c +10
-0+if (irq_domain_is_hierarchy (domain)) +irq_domain_free_irqs (virq,1 ); +else +irq_dispose_mapping (virq); +return 0 ; + } + +/* Store trigger type */ +irqd_set_trigger_type (irq_data, type); +I appear to have missed another place for saving the irq type which I had change in this version. Next time I will triple check! Should have been ...
include/linux/irqdomain.h +3
-0@@ -440,6 +440,9 @@ static inline int irq_domain_alloc_irqs(struct irq_domain *domain,return -1 ; } +static inline void irq_domain_free_irqs (unsigned int virq, +unsigned int nr_irqs) { } +static inline bool irq_domain_is_hierarchy (struct irq_domain *domain) {return false;kernel/irq/irqdomain.c +1
-0@@ -569,6 +569,7 @@ static void of_phandle_args_to_fwspec(struct of_phandle_args *irq_data,unsigned int irq_create_fwspec_mapping (struct irq_fwspec *fwspec) {struct irq_domain *domain; +struct irq_data *irq_data;irq_hw_number_t hwirq;unsigned int type =IRQ_TYPE_NONE ;int virq;@@ -619,7 +620,11 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec)* it now and return the interrupt number. */ if (IRQ_TYPE_NONE ==irq_get_trigger_type (virq)) {Quoted 8 lines
kernel/irq/irqdomain.c unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · line 625
Quoted 4 lines
kernel/irq/irqdomain.c +3
-1-irq_set_irq_type (virq, type); + irq_data =irq_get_irq_data (virq); +if (!irq_data) +return 0 ;Can you point out in which circumstances
irq_datacan be NULL? If we can lookup the interrupt in the domain, it'd better exist somewhere. Or am I missing something obvious?
Quoted 4 lines
To be honest, I was not 100% sure if this could be possible if we find an existing mapping or if there were any paths that could race. So if we can guarantee that it is not NULL here, I can drop this and simplify the change.
No, you're right. It could very well race against irq_dispose_mapping (and the disassociate method doesn't provide enough guarantee). Unfortunately, most of the irqdomain code still relies on this race not happening. How to fix this is still a bit unclear to me.
Quoted 4 lines
By the way, is there any sort of reference count for mapping an IRQ so that if
irq_create_fwspec_mapping()is called more than once for an IRQ, it is not freed on the first call toirq_dispose_mapping()? I assume there is but could not see where this is handled.
There is none, unfortunately.
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Jon HunterQuoted 6 lines · Jon Hunter
The Tegra AGIC interrupt controller is compatible with the ARM GIC-400 interrupt controller. The Tegra AGIC requires two clocks, namely the "ape" (functional) and "apb2ape" (interface) clocks, to operate. Add the compatible string and clock information for the AGIC to the GIC device-tree binding documentation.
Quoted 8 lines
Signed-off-by Jon Hunter <[email protected]>---
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
Mark, Rob: any input on this? That would work for me, but I'd like an ack from one of you.
Thanks,
M.
Quoted 25 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt +2
-0@@ -21,6 +21,7 @@ Main node required properties: "arm,pl390" "arm,tc11mp-gic" "brcm,brahma-b15-gic" + "nvidia,tegra210-agic" "qcom,msm-8660-qgic" "qcom,msm-qgic2" - interrupt-controller : Identifies the node as an interrupt controller@@ -70,6 +71,7 @@ Optional "PERIPHCLK", "PERIPHCLKEN" (for "arm,cortex-a9-gic") "clk" (for "arm,gic-400") "gclk" (for "arm,pl390") + "ape" and "apb2ape" (for "nvidia,tegra,agic") - power-domains : A phandle and PM domain specifier as defined by bindings of the power controller specified by phandle, used when the GIC
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH V2 14/14] irqchip/gic: Add support for tegra AGIC interrupt controller
In reply to Jon HunterQuoted 47 lines · Jon Hunter
Add a driver for the Tegra-AGIC interrupt controller which is compatible with the ARM GIC-400 interrupt controller.
The Tegra AGIC (Audio GIC) is part of the Audio Processing Engine (APE) on Tegra210 and can route interrupts to either the GIC for the CPU subsystem or the Audio DSP (ADSP) within the APE. The AGIC uses CPU interface 0 to route interrupts to the CPU GIC and CPU interface 1 to route interrupts to the ADSP.
The APE is located within its own power domain on the chip and so the AGIC needs to manage both the power domain and its clocks. Commit
afbbd2338176("irqchip/gic: Document optional Clock and Power Domain properties") has already added clock and power-domain properties to the GIC binding and so we can make use of these for the AGIC.With the AGIC being located in a different power domain to the main CPU cluster this means that:
1. The interrupt controller cannot be registered viaIRQCHIP_DECLARE()because it needs to be registered as a platform device so that the generic PM domain core will ensure that the power domain is available before probing.
2. The interrupt controller cannot be suspended/restored based upon changes in the CPU power state and needs to use runtime-pm instead.The GIC platform driver has been implemented by making the following changes to the core GIC driver:
1. Remove the dependency onCONFIG_CPU_PMfrom PM specific variables and functions so that they can be used by the platform driver even whenCONFIG_CPU_PMis not selected.
2. Move the code that maps the GIC registers and parses the device-tree blob into a new function calledgic_of_setup()that can be used by both the platform driver as well as the existing driver.
3. Add and register platform driver for the GIC. The platform driver uses thePM_CLKframework for managing the clocks used by the GIC and so selectCONFIG_PM_CLK.Finally, a couple other notes on the implementation are:
1. Currently the GIC platform driver only supports non-root GICs and assumes that the GIC has a parent interrupt. It is assumed that root interrupt controllers need to be initialised early.
2. There is no specific suspend handling for GICs registered as platform devices. Non-wakeup interrupts will be disabled by the kernel during late suspend, however, this alone will not power down the GIC if interrupts have been requested and not freed. Therefore, requestors of non-wakeup interrupts will need to free them on entering suspend in order to power-down the GIC.
Quoted 6 lines
Signed-off-by Jon Hunter <[email protected]>---
Please note that so far I have not added all the clock names for the various GIC versions (as described by the DT documentation). I thought we could add these as they are needed.
So while the code looks OK, I'd like to stop adding more code to this poor GIC driver, because it is starting to look like a huge mess.
What is preventing us to move this to a separate irq-gic-pm.c file?
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Jon HunterQuoted 2 lines · Jon Hunter
The Tegra AGIC interrupt controller is compatible with the ARM GIC-400 interrupt controller.
The cover letter says it _is_ a GIC-400, just used in a slightly unusual manner (i.e. not directly connected to CPUs).
Quoted 4 lines
The Tegra AGIC requires two clocks, namely the
"ape" (functional) and "apb2ape" (interface) clocks, to operate. Add the compatible string and clock information for the AGIC to the GIC device-tree binding documentation.
The GIC-400 spec only describes "CLK" (which is what I imagine "ape" is. There isn't an APB clock described, and the manual seems to show GIC-400 directly connected to AXI rather than APB, so that doesn't seem to even be the usual "apb_pclk".
Is there some wrapper logic around a GIC-400 to giove it an APB interface? Or am I misudnerstanding the spec?
Quoted 8 lines
Signed-off-by Jon Hunter <[email protected]>---
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "apb_pclk").
I'm also not certain about the compatible string; if this really is a GIC-400 then I would at least expect "arm,gic-400" as a fallback.
Thanks,
Mark.
Quoted 26 lines
Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/interrupt-controller/arm,gic.txt +2
-0@@ -21,6 +21,7 @@ Main node required properties: "arm,pl390" "arm,tc11mp-gic" "brcm,brahma-b15-gic" + "nvidia,tegra210-agic" "qcom,msm-8660-qgic" "qcom,msm-qgic2" - interrupt-controller : Identifies the node as an interrupt controller@@ -70,6 +71,7 @@ Optional "PERIPHCLK", "PERIPHCLKEN" (for "arm,cortex-a9-gic") "clk" (for "arm,gic-400") "gclk" (for "arm,pl390") + "ape" and "apb2ape" (for "nvidia,tegra,agic") - power-domains : A phandle and PM domain specifier as defined by bindings of the power controller specified by phandle, used when the GICSignature · 1 line
2.1.4
Jon Hunter
maintainerRe: [PATCH V2 14/14] irqchip/gic: Add support for tegra AGIC interrupt controller
In reply to Marc ZyngierQuoted 51 lines · Marc Zyngier
Quoted 50 lines · Jon Hunter
Add a driver for the Tegra-AGIC interrupt controller which is compatible with the ARM GIC-400 interrupt controller.
The Tegra AGIC (Audio GIC) is part of the Audio Processing Engine (APE) on Tegra210 and can route interrupts to either the GIC for the CPU subsystem or the Audio DSP (ADSP) within the APE. The AGIC uses CPU interface 0 to route interrupts to the CPU GIC and CPU interface 1 to route interrupts to the ADSP.
The APE is located within its own power domain on the chip and so the AGIC needs to manage both the power domain and its clocks. Commit
afbbd2338176("irqchip/gic: Document optional Clock and Power Domain properties") has already added clock and power-domain properties to the GIC binding and so we can make use of these for the AGIC.With the AGIC being located in a different power domain to the main CPU cluster this means that:
1. The interrupt controller cannot be registered viaIRQCHIP_DECLARE()because it needs to be registered as a platform device so that the generic PM domain core will ensure that the power domain is available before probing.
2. The interrupt controller cannot be suspended/restored based upon changes in the CPU power state and needs to use runtime-pm instead.The GIC platform driver has been implemented by making the following changes to the core GIC driver:
1. Remove the dependency onCONFIG_CPU_PMfrom PM specific variables and functions so that they can be used by the platform driver even whenCONFIG_CPU_PMis not selected.
2. Move the code that maps the GIC registers and parses the device-tree blob into a new function calledgic_of_setup()that can be used by both the platform driver as well as the existing driver.
3. Add and register platform driver for the GIC. The platform driver uses thePM_CLKframework for managing the clocks used by the GIC and so selectCONFIG_PM_CLK.Finally, a couple other notes on the implementation are:
1. Currently the GIC platform driver only supports non-root GICs and assumes that the GIC has a parent interrupt. It is assumed that root interrupt controllers need to be initialised early.
2. There is no specific suspend handling for GICs registered as platform devices. Non-wakeup interrupts will be disabled by the kernel during late suspend, however, this alone will not power down the GIC if interrupts have been requested and not freed. Therefore, requestors of non-wakeup interrupts will need to free them on entering suspend in order to power-down the GIC.Signed-off-by Jon Hunter <[email protected]>---
Quoted 6 lines
Quoted 3 lines
Please note that so far I have not added all the clock names for the various GIC versions (as described by the DT documentation). I thought we could add these as they are needed.
So while the code looks OK, I'd like to stop adding more code to this poor GIC driver, because it is starting to look like a huge mess.
Agree.
Quoted 1 line
What is preventing us to move this to a separate
irq-gic-pm.cfile?
Absolutely nothing. Once we sort out the clocking, I will do that.
Cheers
Jon
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Mark RutlandQuoted 6 lines · Mark Rutland
Quoted 2 lines · Jon Hunter
The Tegra AGIC interrupt controller is compatible with the ARM GIC-400 interrupt controller.
The cover letter says it _is_ a GIC-400, just used in a slightly unusual manner (i.e. not directly connected to CPUs).
Correct.
Quoted 5 lines
Quoted 4 lines
The Tegra AGIC requires two clocks, namely the
"ape" (functional) and "apb2ape" (interface) clocks, to operate. Add the compatible string and clock information for the AGIC to the GIC device-tree binding documentation.
Quoted 7 lines
The GIC-400 spec only describes "CLK" (which is what I imagine "ape" is. There isn't an APB clock described, and the manual seems to show GIC-400 directly connected to AXI rather than APB, so that doesn't seem to even be the usual "
apb_pclk".Is there some wrapper logic around a GIC-400 to giove it an APB interface? Or am I misudnerstanding the spec?
Looking at the Tegra documentation what we have is ...
APB --> AXI switch --> AGIC (GIC400)
I am not sure how such a switch would typically be modeled in DT but we need the apb clock to interface to the GIC registers. I am not sure if something like simple-pm-bus is appropriate here.
Quoted 9 lines
Quoted 8 lines
Signed-off-by Jon Hunter <[email protected]>---
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
Quoted 3 lines
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").
Yes that would be fine with me.
Quoted 2 lines
I'm also not certain about the compatible string; if this really is a GIC-400 then I would at least expect "arm,gic-400" as a fallback.
OK.
Cheers
Jon
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 24 lines · Jon Hunter
Quoted 6 lines · Mark Rutland
Quoted 2 lines · Jon Hunter
The Tegra AGIC interrupt controller is compatible with the ARM GIC-400 interrupt controller.
The cover letter says it _is_ a GIC-400, just used in a slightly unusual manner (i.e. not directly connected to CPUs).
Correct.
Quoted 5 lines
Quoted 4 lines
The Tegra AGIC requires two clocks, namely the
"ape" (functional) and "apb2ape" (interface) clocks, to operate. Add the compatible string and clock information for the AGIC to the GIC device-tree binding documentation.Quoted 7 lines
The GIC-400 spec only describes "CLK" (which is what I imagine "ape" is. There isn't an APB clock described, and the manual seems to show GIC-400 directly connected to AXI rather than APB, so that doesn't seem to even be the usual "
apb_pclk".Is there some wrapper logic around a GIC-400 to giove it an APB interface? Or am I misudnerstanding the spec?
Quoted 7 lines
Looking at the Tegra documentation what we have is ...
APB --> AXI switch --> AGIC (GIC400)
I am not sure how such a switch would typically be modeled in DT but we need the apb clock to interface to the GIC registers. I am not sure if something like simple-pm-bus is appropriate here.
I think we need some representation of that AXI switch in the DT; whether simple-pm-bus is appropriate is another question. We probably need a specific compatible string / binding regardless.
Thanks,
Mark.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Signed-off-by Jon Hunter <[email protected]>---
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
Quoted 5 lines
Quoted 3 lines
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Yes that would be fine with me.
Ok; if we model the apb_pclk as owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.
Thanks,
Mark.
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 29 lines · Mark Rutland
Quoted 28 lines · Jon Hunter
Quoted 6 lines · Mark Rutland
Quoted 2 lines · Jon Hunter
The Tegra AGIC interrupt controller is compatible with the ARM GIC-400 interrupt controller.
The cover letter says it _is_ a GIC-400, just used in a slightly unusual manner (i.e. not directly connected to CPUs).
Correct.
Quoted 5 lines
Quoted 4 lines
The Tegra AGIC requires two clocks, namely the
"ape" (functional) and "apb2ape" (interface) clocks, to operate. Add the compatible string and clock information for the AGIC to the GIC device-tree binding documentation.Quoted 7 lines
The GIC-400 spec only describes "CLK" (which is what I imagine "ape" is. There isn't an APB clock described, and the manual seems to show GIC-400 directly connected to AXI rather than APB, so that doesn't seem to even be the usual "
apb_pclk".Is there some wrapper logic around a GIC-400 to giove it an APB interface? Or am I misudnerstanding the spec?
Looking at the Tegra documentation what we have is ...
APB --> AXI switch --> AGIC (GIC400)
Quoted 7 lines
Quoted 3 lines
I am not sure how such a switch would typically be modeled in DT but we need the apb clock to interface to the GIC registers. I am not sure if something like simple-pm-bus is appropriate here.
I think we need some representation of that AXI switch in the DT; whether simple-pm-bus is appropriate is another question. We probably need a specific compatible string / binding regardless.
OK, I will have a look at that.
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.
Yes that makes sense.
Thanks
Jon
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Mark RutlandOn 22/04/16 12:22, Mark Rutland wrote:
[snip]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").
Quoted 6 lines
Quoted 1 line
Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.
I have been re-working this based upon the feedback received. In the GIC driver we have the following definitions ...
IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init); IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init); IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init); IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init); IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init); IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init); IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init); IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init); IRQCHIP_DECLARE(pl390, "arm,pl390", gic_of_init);
If I have something like the following in my dts ...
agic: interrupt-controller@702f9000 {
compatible = "nvidia,tegra210-agic", "arm,gic-400";
...
};The problem with this is that it tries to register the interrupt controller early during of_irq_init() before the platform driver has chance to initialise it. To avoid this I got rid of the "nvidia,tegra210-agic" string and added the following for the platform driver ...
static const struct of_device_id gic_match[] = {
{ .compatible = "arm,arm11mp-gic-pm", .data = &arm11mp_gic_data },
{ .compatible = "arm,cortex-a15-gic-pm", .data = &cortexa15_gic_data },
{ .compatible = "arm,cortex-a9-gic-pm", .data = &cortexa9_gic_data },
{ .compatible = "arm,gic400-pm", .data = &gic400_data },
{ .compatible = "arm,pl390-pm", .data = &pl390_data },
{},
};It is not ideal as now we have a *-pm variant of each compatible string :-(
Another option would be to add some code in gic_of_init() to check for the presence of a "clocks" node in the DT binding and bail out of the early initialisation if found but may be that is a bit of a hack.
Mark, what are your thoughts on this?
Cheers
Jon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 38 lines · Jon Hunter
On 22/04/16 12:22, Mark Rutland wrote:
[snip]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Quoted 6 lines
Quoted 1 line
Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.I have been re-working this based upon the feedback received. In the GIC driver we have the following definitions ...
IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init);IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init);IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init);IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);IRQCHIP_DECLARE(pl390, "arm,pl390", gic_of_init);If I have something like the following in my dts ...
Quoted 8 lines
agic: interrupt-controller@702f9000 { compatible = "nvidia,tegra210-agic", "arm,gic-400"; ... };The problem with this is that it tries to register the interrupt controller early during
of_irq_init()before the platform driver has chance to initialise it.
Probe order strikes again...
Quoted 12 lines
To avoid this I got rid of the "nvidia,tegra210-agic" string and added the following for the platform driver ...
static const struct of_device_id gic_match[] = { { .compatible = "arm,arm11mp-gic-pm", .data = &arm11mp_gic_data }, { .compatible = "arm,cortex-a15-gic-pm", .data = &cortexa15_gic_data }, { .compatible = "arm,cortex-a9-gic-pm", .data = &cortexa9_gic_data }, { .compatible = "arm,gic400-pm", .data = &gic400_data }, { .compatible = "arm,pl390-pm", .data = &pl390_data }, {}, };
Quoted 1 line
It is not ideal as now we have a *-pm variant of each compatible string :-(
Yeah, that's a non-starter. :(
Quoted 3 lines
Another option would be to add some code in
gic_of_init()to check for the presence of a "clocks" node in the DT binding and bail out of the early initialisation if found but may be that is a bit of a hack.
I fear that someone may validly have a clocks property in their root GIC node, at which point things would fall apart. I was under the impression this was the case for some Renesas boards (though I didn't find an example in tree).
So I suspect that using the clocks property in that way isn't going to work out well.
Quoted 1 line
Mark, what are your thoughts on this?
Collectively: "aargh", "oh no".
We could instead explicitly match "nvidia,tegra210-agic", bailing out if we see that. Otherwise, if we can't handle it like a GIC-400, then we can just drop the GIC-400 compatible string from the fallback list.
Thanks,
Mark.
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 60 lines · Mark Rutland
Quoted 36 lines · Jon Hunter
On 22/04/16 12:22, Mark Rutland wrote:
[snip]Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Quoted 6 lines
Quoted 1 line
Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.I have been re-working this based upon the feedback received. In the GIC driver we have the following definitions ...
IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init);IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init);IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init);IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);IRQCHIP_DECLARE(pl390, "arm,pl390", gic_of_init);If I have something like the following in my dts ...
Quoted 8 lines
agic: interrupt-controller@702f9000 { compatible = "nvidia,tegra210-agic", "arm,gic-400"; ... };The problem with this is that it tries to register the interrupt controller early during
of_irq_init()before the platform driver has chance to initialise it.Probe order strikes again...
Quoted 12 lines
To avoid this I got rid of the "nvidia,tegra210-agic" string and added the following for the platform driver ...
static const struct of_device_id gic_match[] = { { .compatible = "arm,arm11mp-gic-pm", .data = &arm11mp_gic_data }, { .compatible = "arm,cortex-a15-gic-pm", .data = &cortexa15_gic_data }, { .compatible = "arm,cortex-a9-gic-pm", .data = &cortexa9_gic_data }, { .compatible = "arm,gic400-pm", .data = &gic400_data }, { .compatible = "arm,pl390-pm", .data = &pl390_data }, {}, };
Quoted 7 lines
Quoted 1 line
It is not ideal as now we have a *-pm variant of each compatible string :-(
Yeah, that's a non-starter. :(
Quoted 3 lines
Another option would be to add some code in
gic_of_init()to check for the presence of a "clocks" node in the DT binding and bail out of the early initialisation if found but may be that is a bit of a hack.
Or the presence of a power-domains property...
Quoted 4 lines
I fear that someone may validly have a clocks property in their root GIC node, at which point things would fall apart. I was under the impression this was the case for some Renesas boards (though I didn't find an example in tree).
We don't have the GIC clocks in the GIC nodes yet, as there's no suitable mechanism (e.g. CLK_ENABLE_HAND_OFF) in upstream yet to prevent them from being disabled ("unused" clocks are disabled).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Mark RutlandQuoted 62 lines · Mark Rutland
Quoted 38 lines · Jon Hunter
On 22/04/16 12:22, Mark Rutland wrote:
[snip]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Quoted 6 lines
Quoted 1 line
Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.I have been re-working this based upon the feedback received. In the GIC driver we have the following definitions ...
IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init);IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init);IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init);IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);IRQCHIP_DECLARE(pl390, "arm,pl390", gic_of_init);If I have something like the following in my dts ...
Quoted 8 lines
agic: interrupt-controller@702f9000 { compatible = "nvidia,tegra210-agic", "arm,gic-400"; ... };The problem with this is that it tries to register the interrupt controller early during
of_irq_init()before the platform driver has chance to initialise it.Probe order strikes again...
Quoted 12 lines
To avoid this I got rid of the "nvidia,tegra210-agic" string and added the following for the platform driver ...
static const struct of_device_id gic_match[] = { { .compatible = "arm,arm11mp-gic-pm", .data = &arm11mp_gic_data }, { .compatible = "arm,cortex-a15-gic-pm", .data = &cortexa15_gic_data }, { .compatible = "arm,cortex-a9-gic-pm", .data = &cortexa9_gic_data }, { .compatible = "arm,gic400-pm", .data = &gic400_data }, { .compatible = "arm,pl390-pm", .data = &pl390_data }, {}, };
Quoted 3 lines
Quoted 1 line
It is not ideal as now we have a *-pm variant of each compatible string :-(
Yeah, that's a non-starter. :(
That is what I feared. Understood.
Quoted 9 lines
Quoted 3 lines
Another option would be to add some code in
gic_of_init()to check for the presence of a "clocks" node in the DT binding and bail out of the early initialisation if found but may be that is a bit of a hack.I fear that someone may validly have a clocks property in their root GIC node, at which point things would fall apart. I was under the impression this was the case for some Renesas boards (though I didn't find an example in tree).
Quoted 6 lines
So I suspect that using the clocks property in that way isn't going to work out well.
Quoted 1 line
Mark, what are your thoughts on this?
Collectively: "aargh", "oh no".
Yes, exactly :-(
Quoted 3 lines
We could instead explicitly match "nvidia,tegra210-agic", bailing out if we see that. Otherwise, if we can't handle it like a GIC-400, then we can just drop the GIC-400 compatible string from the fallback list.
Would it also be a none-starter to have "arm,gic-pm" instead of "nvidia,tegra210-agic"? At this point it is not really specific to tegra any more and so I was hoping to get rid of that. For example, ...
compatible = "arm,gic-pm", "arm,gic-400";
Cheers
Jon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Hi Jon,
Quoted 88 lines · Jon Hunter
Quoted 59 lines · Mark Rutland
Quoted 35 lines · Jon Hunter
On 22/04/16 12:22, Mark Rutland wrote:
[snip]Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Quoted 6 lines
Quoted 1 line
Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.I have been re-working this based upon the feedback received. In the GIC driver we have the following definitions ...
IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init);IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init);IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init);IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);IRQCHIP_DECLARE(pl390, "arm,pl390", gic_of_init);If I have something like the following in my dts ...
Quoted 8 lines
agic: interrupt-controller@702f9000 { compatible = "nvidia,tegra210-agic", "arm,gic-400"; ... };The problem with this is that it tries to register the interrupt controller early during
of_irq_init()before the platform driver has chance to initialise it.Probe order strikes again...
Quoted 12 lines
To avoid this I got rid of the "nvidia,tegra210-agic" string and added the following for the platform driver ...
static const struct of_device_id gic_match[] = { { .compatible = "arm,arm11mp-gic-pm", .data = &arm11mp_gic_data }, { .compatible = "arm,cortex-a15-gic-pm", .data = &cortexa15_gic_data }, { .compatible = "arm,cortex-a9-gic-pm", .data = &cortexa9_gic_data }, { .compatible = "arm,gic400-pm", .data = &gic400_data }, { .compatible = "arm,pl390-pm", .data = &pl390_data }, {}, };Quoted 3 lines
Quoted 1 line
It is not ideal as now we have a *-pm variant of each compatible string :-(
Yeah, that's a non-starter. :(
That is what I feared. Understood.
Quoted 9 lines
Quoted 3 lines
Another option would be to add some code in
gic_of_init()to check for the presence of a "clocks" node in the DT binding and bail out of the early initialisation if found but may be that is a bit of a hack.I fear that someone may validly have a clocks property in their root GIC node, at which point things would fall apart. I was under the impression this was the case for some Renesas boards (though I didn't find an example in tree).
Quoted 6 lines
So I suspect that using the clocks property in that way isn't going to work out well.
Quoted 1 line
Mark, what are your thoughts on this?
Collectively: "aargh", "oh no".
Yes, exactly :-(
Quoted 3 lines
We could instead explicitly match "nvidia,tegra210-agic", bailing out if we see that. Otherwise, if we can't handle it like a GIC-400, then we can just drop the GIC-400 compatible string from the fallback list.
Quoted 5 lines
Would it also be a none-starter to have "arm,gic-pm" instead of "nvidia,tegra210-agic"? At this point it is not really specific to tegra any more and so I was hoping to get rid of that. For example, ...
compatible = "arm,gic-pm", "arm,gic-400";
The "-pm" is not a property of the GIC, but of the SoC. So IMHO the compatible value should be plain "arm,gic-400".
If a device node has "clocks", "interrupts", "power-domains"[*], ... properties, and the corresponding providers are not yet available, a driver typically returns -EPROBE_DEFER, and will be retried later by the driver core.
[*] For "power-domains" this is handled by the device core. I.e. .probe()
won't even be called before the dependency has been fulfilled.
With IRQCHIP_DECLARE(), you don't have the retrying, and probe order (w.r.t. to other subsystems) is fixed.
But as you said, gic_of_init() could just bail out if it "clocks" and/or "power-domains" properties are present, but their providers aren't. Later, the remaining GICs can be initialized from the platform driver. You just have to make sure no GIC is initialized twice (I believe that's what was plaguing me last time I tried your series).
That's probably the closest you can get to normal platform_driver behavior, without converting the whole GIC driver to a normal platform_driver, which may cause problems on platforms that are currently working fine.
Gr{oetje,eeting}s,
Geert
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Jon HunterQuoted 49 lines · Jon Hunter
Quoted 47 lines · Mark Rutland
Quoted 46 lines · Jon Hunter
On 22/04/16 12:22, Mark Rutland wrote:
[snip]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
I am not sure if it will be popular to add Tegra specific clock names to the GIC DT docs. However, in that case, then possibly the only alternative is to move the Tegra AGIC driver into its own file and expose the GIC APIs for it to use. Then we could add our own DT doc for the Tegra AGIC as well (based upon the ARM GIC).
The clock-names don't seem right to me, as they sound like provide names or global clock line names rather than consumer-side names ("clk" and "
apb_pclk").Quoted 6 lines
Quoted 1 line
Yes that would be fine with me.
Ok; if we model the
apb_pclkas owned by the AXI switch (which it is), then there's no change for the GIC binding, short of the additional compatible string as an extension of "arm,gic-400", as we already model that clock in the GIC-400 binding.I have been re-working this based upon the feedback received. In the GIC driver we have the following definitions ...
IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init);IRQCHIP_DECLARE(arm11mp_gic, "arm,arm11mp-gic", gic_of_init);IRQCHIP_DECLARE(arm1176jzf_dc_gic, "arm,arm1176jzf-devchip-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init);IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init);IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);IRQCHIP_DECLARE(pl390, "arm,pl390", gic_of_init);If I have something like the following in my dts ...
agic: interrupt-controller@702f9000 { compatible = "nvidia,tegra210-agic", "arm,gic-400"; ... };The problem with this is that it tries to register the interrupt controller early during
of_irq_init()before the platform driver has chance to initialise it.
[...]
Quoted 9 lines
Quoted 3 lines
We could instead explicitly match "nvidia,tegra210-agic", bailing out if we see that. Otherwise, if we can't handle it like a GIC-400, then we can just drop the GIC-400 compatible string from the fallback list.
Would it also be a none-starter to have "arm,gic-pm" instead of "nvidia,tegra210-agic"? At this point it is not really specific to tegra any more and so I was hoping to get rid of that. For example, ...
compatible = "arm,gic-pm", "arm,gic-400";
I'm not keen on the "*-pm" approach, as such compatible strings aren't reall describing HW, but rather the SW policy to apply, and really would only be there to bodge around a structural issue we have in Linux today w.r.t. the device model split and probe ordering.
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
Thanks,
Mark.
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Hi Mark,
On 28/04/16 10:55, Mark Rutland wrote:
[...]
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
drivers/of/irq.c +2 -0
@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
Cheers
Jon
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Hi Jon,
Quoted 21 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
drivers/of/irq.c +0
-0
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 6 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }
That sounds like the right thing to do to me...
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Hi Geert,
Quoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
OK. The more I think about this, it does seem silly to create a device and pdata for a device that has already been instantiated.
Quoted 4 lines
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
No problem. However, there is more work that would be needed to get this to work for root controllers which I think that you want.
Cheers
Jon
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 39 lines · Jon Hunter
Hi Geert,
Quoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
OK. The more I think about this, it does seem silly to create a device and pdata for a device that has already been instantiated.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
No problem. However, there is more work that would be needed to get this to work for root controllers which I think that you want.
All this brings the discussion back to the root of the problem: irqchips (and timers) are not first class devices, because we need them too early for that.
I'd really like to solve this, but the kernel init is incredibly complicated, and the subsystem dependencies completely undocumented. It looks like we need the timer early because the we fork a thread for PID-1, and the scheduler is going to need some form of tick.
So ideally, we'd be able to move the irq/timer stuff *after* the device framework (which itself requires devtmpfs to be up and running, hence dragging the whole VM and VFS), but before the scheduler is initialized. I'm sure there is plenty of other dependencies I haven't worked out yet.
If anyone has some spare time and willing to help, please speak now! ;-)
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Geert UytterhoevenQuoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
Seems fine to me, but it would be a problem since this is a global decision if you wanted to have some hand-off from an "early driver" to a platform driver. I guess setting the flag could move to drivers that need it although I don't think drivers should be touching the flags.
Quoted 4 lines
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
IMO, the plain gic-400 should not have these dependencies and you should use SoC specific compatible strings should you need to deal with this problem.
Rob
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Hi Rob,
Quoted 34 lines · Rob Herring
Quoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
Quoted 4 lines
Seems fine to me, but it would be a problem since this is a global decision if you wanted to have some hand-off from an "early driver" to a platform driver. I guess setting the flag could move to drivers that need it although I don't think drivers should be touching the flags.
Isn't this the other way around? Setting this flag means that I have been populated and so don't bother creating a platform device for this device as it isn't needed. A by-product if this, is that if we did happen to have a platform driver for the irqchip that also has an early driver, then the hand-off would never happen if the early init was successful.
The driver would still have to decide whether to hand-off and to do that it would need to return an error from the early driver [0].
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
IMO, the plain gic-400 should not have these dependencies and you should use SoC specific compatible strings should you need to deal with this problem.
It is fine for my case, but it does mean I cannot say ...
compatible = "tegra210-agic", "gic-400";
... because this will always match the early driver (unless we do something like I have suggested above). So I would have ...
compatible = "tegra210-agic";
Cheers
Jon
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 49 lines · Jon Hunter
Hi Rob,
Quoted 34 lines · Rob Herring
Quoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
Quoted 4 lines
Seems fine to me, but it would be a problem since this is a global decision if you wanted to have some hand-off from an "early driver" to a platform driver. I guess setting the flag could move to drivers that need it although I don't think drivers should be touching the flags.
Isn't this the other way around? Setting this flag means that I have been populated and so don't bother creating a platform device for this device as it isn't needed. A by-product if this, is that if we did happen to have a platform driver for the irqchip that also has an early driver, then the hand-off would never happen if the early init was successful.
Quoted 2 lines
The driver would still have to decide whether to hand-off and to do that it would need to return an error from the early driver [0].
I mean, the "early driver would still have to decide whether to hand-off ..."
Jon
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
In reply to Jon HunterQuoted 61 lines · Jon Hunter
Hi Rob,
Quoted 34 lines · Rob Herring
Quoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
Quoted 4 lines
Seems fine to me, but it would be a problem since this is a global decision if you wanted to have some hand-off from an "early driver" to a platform driver. I guess setting the flag could move to drivers that need it although I don't think drivers should be touching the flags.
Isn't this the other way around? Setting this flag means that I have been populated and so don't bother creating a platform device for this device as it isn't needed. A by-product if this, is that if we did happen to have a platform driver for the irqchip that also has an early driver, then the hand-off would never happen if the early init was successful.
The driver would still have to decide whether to hand-off and to do that it would need to return an error from the early driver [0].
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
IMO, the plain gic-400 should not have these dependencies and you should use SoC specific compatible strings should you need to deal with this problem.
Quoted 6 lines
It is fine for my case, but it does mean I cannot say ...
compatible = "tegra210-agic", "gic-400";... because this will always match the early driver (unless we do something like I have suggested above). So I would have ...
Sorry this is wrong. The above will always match the early driver.
The problem with the above compatibility string is that, if the platform driver matches "gic-400" then it will try to probe all gic-400s even if they have been initialised early and this is definitely not what we want. This could be solved by setting the OF_POPULATED flag.
Jon
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 70 lines · Jon Hunter
Quoted 61 lines · Jon Hunter
Hi Rob,
Quoted 34 lines · Rob Herring
Quoted 19 lines · Geert Uytterhoeven
Hi Jon,
Quoted 16 lines · Jon Hunter
Quoted 10 lines
The "nvidia,tegra210-agic" string can be taken as describing any Tegra-210 specific integration quirks, though I agree that's also not fantastic for extending PM support beyond Tegra 210 and variants thereof.
So maybe the best approach is bailing out in the presence of clocks and/or power domains after all, on the assumption that nothing today has those properties, though I fear we may have problems with that later down the line if/when people describe those for the root GIC to describe those must be hogged, even if not explicitly managed.
On further testing, by bailing out in the presence of clocks and/or power-domains, the problem I now see is that although the primary gic-400 has been registered, we still try to probe it again later as it matches the platform driver. One way to avoid this would be ...
Quoted 13 lines
drivers/of/irq.c void __init of_irq_init(const struct of_device_id *matches) · line 561
Quoted 11 lines
drivers/of/irq.c +2
-0@@ -556,6 +556,8 @@ void __init of_irq_init(const struct of_device_id *matches)* its children can get processed in a subsequent pass. */ list_add_tail (&desc->list, &intc_parent_list); + +of_node_set_flag (desc->dev,OF_POPULATED ); }That sounds like the right thing to do to me...
Quoted 4 lines
Seems fine to me, but it would be a problem since this is a global decision if you wanted to have some hand-off from an "early driver" to a platform driver. I guess setting the flag could move to drivers that need it although I don't think drivers should be touching the flags.
Isn't this the other way around? Setting this flag means that I have been populated and so don't bother creating a platform device for this device as it isn't needed. A by-product if this, is that if we did happen to have a platform driver for the irqchip that also has an early driver, then the hand-off would never happen if the early init was successful.
The driver would still have to decide whether to hand-off and to do that it would need to return an error from the early driver [0].
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
If this is not appropriate then I guess I will just need to use "tegra210-agic" for the compatibility flag.
As I want this for plain gic-400, I'd be unhappy ;-)
IMO, the plain gic-400 should not have these dependencies and you should use SoC specific compatible strings should you need to deal with this problem.
Quoted 6 lines
It is fine for my case, but it does mean I cannot say ...
compatible = "tegra210-agic", "gic-400";... because this will always match the early driver (unless we do something like I have suggested above). So I would have ...
Quoted 6 lines
Sorry this is wrong. The above will always match the early driver.
The problem with the above compatibility string is that, if the platform driver matches "gic-400" then it will try to probe all gic-400s even if they have been initialised early and this is definitely not what we want. This could be solved by setting the
OF_POPULATEDflag.
A platform driver for just gic-400 is wrong IMO until we have platform drivers for all interrupt controllers.
Another reason to set OF_POPULATED flag is we are needlessly creating platform devices for irq controllers that will never have platform drivers. So I'd go with that approach.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Hi Rob, Mark,
Quoted 2 lines · Rob Herring
A platform driver for just gic-400 is wrong IMO until we have platform drivers for all interrupt controllers.
Yes, that is fine with me, but can we decide on whether the platform driver should match "tegra210-agic" or the early driver should bail-out if clocks/power-domains are present?
I am fine with either, but I think that Rob prefers the tegra210-agic compat string and Mark prefers to bail-out of the early driver if clocks/power-domains are present.
Quoted 3 lines
Another reason to set
OF_POPULATEDflag is we are needlessly creating platform devices for irq controllers that will never have platform drivers. So I'd go with that approach.
Yes exactly, that was the point I was trying to make ;-)
Jon
Re: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 6 lines · Jon Hunter
Hi Rob, Mark,
Quoted 2 lines · Rob Herring
A platform driver for just gic-400 is wrong IMO until we have platform drivers for all interrupt controllers.
Quoted 7 lines
Yes, that is fine with me, but can we decide on whether the platform driver should match "tegra210-agic" or the early driver should bail-out if clocks/power-domains are present?
I am fine with either, but I think that Rob prefers the tegra210-agic compat string and Mark prefers to bail-out of the early driver if clocks/power-domains are present.
If anything, I wasn't too keen on bailing out becuase of those properties, as I mentioned for the case of a root interrupt controller.
I am happy to match the "tegra210-agic" string specifically.
Thanks,
Mark.
Jon Hunter
maintainerRe: [PATCH V2 13/14] dt-bindings: arm-gic: Add documentation for Tegra210 AGIC
Quoted 11 lines · Mark Rutland
Quoted 10 lines · Jon Hunter
Hi Rob, Mark,
Quoted 2 lines · Rob Herring
A platform driver for just gic-400 is wrong IMO until we have platform drivers for all interrupt controllers.
Yes, that is fine with me, but can we decide on whether the platform driver should match "tegra210-agic" or the early driver should bail-out if clocks/power-domains are present?
Quoted 8 lines
Quoted 3 lines
I am fine with either, but I think that Rob prefers the tegra210-agic compat string and Mark prefers to bail-out of the early driver if clocks/power-domains are present.
If anything, I wasn't too keen on bailing out becuase of those properties, as I mentioned for the case of a root interrupt controller.
I am happy to match the "tegra210-agic" string specifically.
Thanks guys. I will stick with tegra210-agic for now.
Cheers
Jon