dt-bindings: irq: Add Qualcomm MSM VIC binding
Subsystems (3)
PATCH 1/5 dt-bindings: irq: Add Qualcomm MSM VIC binding
--- .../interrupt-controller/qcom,msm-vic.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yaml
Documentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yaml new file +72 -0
@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0 +# qualcomm,msm-vic.yaml - Device Tree binding for Qualcomm MSM VIC interrupt controller + +description: > + Qualcomm MSM VIC (Vector Interrupt Controller). This interrupt controller + handles normal and wakeup interrupts and supports mapping to the + Qualcomm SMSM system. + +compatible: ["qcom,msm-vic"] + +properties: + interrupt-controller: + description: "Identifies this node as an interrupt controller" + required: true + type: boolean + + #interrupt-cells: + description: "Specifies the number of cells needed to encode an interrupt" + required: true + type: integer + default: 1 + + reg: + description: "Base address and size of the VIC registers" + required: true + type: reg + + num-irqs: + description: "Total number of interrupts supported by this VIC" + required: true + type: integer + + num-gpio-irqs: + description: "Number of GPIO interrupts routed through this VIC" + required: true + type: integer + + vic-num-regs: + description: "Number of VIC register banks" + required: true + type: integer + + irq-mapping: + description: + Mapping of VIC IRQ numbers to SMSM wakeup channels. Each mapping + consists of two integers: <VIC IRQ> <SMSM channel>. + "SMSM_FAKE_IRQ" can be used for virtual/fake wakeup interrupts. + required: true + type: list + items: + - vic-irq: integer + smsm-channel: integer + +examples: + - | + #include <dt-bindings/interrupt-controller/qcom-vic.h> + intc: interrupt-controller@ac000000 { + compatible = "qcom,msm-vic"; + interrupt-controller; + #interrupt-cells = <1>; + reg = <0xac000000 0x1000>; + num-irqs = <64>; + num-gpio-irqs = <165>; + vic-num-regs = <2>; + irq-mapping = < + 17 1 /* INT_MDDI_EXT -> SMSM 1 */ + 16 2 /* INT_MDDI_PRI -> SMSM 2 */ + 18 3 /* INT_MDDI_CLIENT -> SMSM 3 */ + 15 4 /* INT_USB_OTG -> SMSM 4 */ + 0 SMSM_FAKE_IRQ /* INT_A9_M2A_0 -> SMSM_FAKE_IRQ */ + >; + }
Signature · 1 line
2.51.0
PATCH 2/5 irqchip: Add Qualcomm MSM VIC driver
--- drivers/irqchip/irq-msm-vic.c | 361 ++++++++++++++++++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 drivers/irqchip/irq-msm-vic.c
drivers/irqchip/irq-msm-vic.c new file +361 -0
@@ -0,0 +1,361 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* +* Copyright (C) 2007 Google, Inc. +* Copyright (c) 2009, Code Aurora Forum. All rights reserved. +* Copyright (c) 2024, Htc Leo Revival Project +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/sched.h> +#include <linux/interrupt.h> +#include <linux/ptrace.h> +#include <linux/timer.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> +#include <linux/cacheflush.h> + +#include <asm/exception.h> +#include <asm/irq.h> + +#include <dt-bindings/interrupt-controller/qcom-vic.h> + +static u32 msm_irq_smsm_wake_enable[2 ]; +struct msm_irq_shadow { +u32 int_en[2 ]; +u32 int_type; +u32 int_polarity; +u32 int_select; +}; + +static struct msm_irq_shadow *msm_irq_shadow_reg; +static u32 *msm_irq_idle_disable; + +struct msm_irq_map { +u32 irq; +u8 smsm; +}; + +struct vic_device { +void __iomem *base; +struct irq_domain *domain; +u32 msm_nr_irqs; +u32 nr_vic_irqs; +u32 nr_gpio_irqs; +u32 vic_num_regs; +struct msm_irq_map *irq_map; +int irq_map_count; +}; + +static struct vic_device vic_data; + +static int msm_irq_to_smsm (u32 irq) +{ +int i; + +if (!vic_data.irq_map) +return -EINVAL ; + +for (i =0 ; i < vic_data.irq_map_count; i++) { +if (vic_data.irq_map[i].irq == irq) +return vic_data.irq_map[i].smsm; + } + +return -ENOENT ; +} + +void set_irq_flags (unsigned int irq,unsigned int iflags); + +void set_irq_flags (unsigned int irq,unsigned int iflags) +{ +unsigned long clr =0 , set =IRQ_NOREQUEST |IRQ_NOPROBE |IRQ_NOAUTOEN ; + +if (irq >= vic_data.msm_nr_irqs) { +pr_err ("Trying to set irq flags for IRQ%d\n" , irq); +return ; + } + +if (iflags &IRQF_VALID ) + clr |=IRQ_NOREQUEST ; +if (iflags &IRQF_PROBE ) + clr |=IRQ_NOPROBE ; +if (!(iflags &IRQF_NOAUTOEN )) + clr |=IRQ_NOAUTOEN ; +/* Order is clear bits in "clr" then set bits in "set" */ +irq_modify_status (irq, clr, set & ~clr); +} +EXPORT_SYMBOL_GPL (set_irq_flags); + +static inline void msm_irq_write_all_regs (void __iomem *base,unsigned int val) +{ +for (int i =0 ; i < vic_data.vic_num_regs; i++) +writel (val, base + (i *4 )); +} + +static void msm_irq_ack (struct irq_data *d) +{ +void __iomem *reg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_CLEAR0 , d->irq); + +writel (1 << (d->irq &31 ), reg); +} + +static void msm_irq_mask (struct irq_data *d) +{ +void __iomem *reg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_ENCLEAR0 , d->irq); +unsigned int index =VIC_INT_TO_REG_INDEX (d->irq); +u32 mask =1UL << (d->irq &31 ); +int smsm_irq =msm_irq_to_smsm (d->irq); + + msm_irq_shadow_reg[index].int_en[0 ] &= ~mask; +writel (mask, reg); +if (smsm_irq ==0 ) { + msm_irq_idle_disable[index] &= ~mask; + }else { + mask =1UL << (smsm_irq -1 ); + msm_irq_smsm_wake_enable[0 ] &= ~mask; + } +} + +static void msm_irq_unmask (struct irq_data *d) +{ +void __iomem *reg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_ENSET0 , d->irq); +unsigned int index =VIC_INT_TO_REG_INDEX (d->irq); +u32 mask =1UL << (d->irq &31 ); +int smsm_irq =msm_irq_to_smsm (d->irq); + + msm_irq_shadow_reg[index].int_en[0 ] |= mask; +writel (mask, reg); + +if (smsm_irq ==0 ) { + msm_irq_idle_disable[index] |= mask; + }else { + mask =1UL << (smsm_irq -1 ); + msm_irq_smsm_wake_enable[0 ] |= mask; + } +} + +static int msm_irq_set_wake (struct irq_data *d,unsigned int on) +{ +unsigned int index =VIC_INT_TO_REG_INDEX (d->irq); +u32 mask =1UL << (d->irq &31 ); +int smsm_irq =msm_irq_to_smsm (d->irq); + +if (smsm_irq ==0 ) { +pr_err ("%s: bad wakeup irq %d\n" , __func__, d->irq); +return -EINVAL ; + } +if (on) + msm_irq_shadow_reg[index].int_en[1 ] |= mask; +else + msm_irq_shadow_reg[index].int_en[1 ] &= ~mask; + +if (smsm_irq ==SMSM_FAKE_IRQ ) +return 0 ; + + mask =1UL << (smsm_irq -1 ); +if (on) + msm_irq_smsm_wake_enable[1 ] |= mask; +else + msm_irq_smsm_wake_enable[1 ] &= ~mask; +return 0 ; +} + +static int msm_irq_set_type (struct irq_data *d,unsigned int flow_type) +{ +void __iomem *treg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_TYPE0 , d->irq); +void __iomem *preg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_POLARITY0 , d->irq); +unsigned int index =VIC_INT_TO_REG_INDEX (d->irq); +int b =1 << (d->irq &31 ); +u32 polarity; +u32 type; + + polarity = msm_irq_shadow_reg[index].int_polarity; +if (flow_type & (IRQF_TRIGGER_FALLING |IRQF_TRIGGER_LOW )) + polarity |= b; +if (flow_type & (IRQF_TRIGGER_RISING |IRQF_TRIGGER_HIGH )) + polarity &= ~b; +writel (polarity, preg); + msm_irq_shadow_reg[index].int_polarity = polarity; + + type = msm_irq_shadow_reg[index].int_type; +if (flow_type & (IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING )) { + type |= b; +irq_set_handler_locked (d, handle_edge_irq); + } +if (flow_type & (IRQF_TRIGGER_HIGH |IRQF_TRIGGER_LOW )) { + type &= ~b; +irq_set_handler_locked (d, handle_level_irq); + } +writel (type, treg); + msm_irq_shadow_reg[index].int_type = type; +return 0 ; +} + +static inline void msm_vic_handle_irq (void __iomem *base_addr,struct pt_regs + *regs) +{ +u32 irqnr; + +do { +/* VIC_IRQ_VEC_RD has irq# or old irq# if the irq has been handled +* VIC_IRQ_VEC_PEND_RD has irq# or -1 if none pending *but* if you +* just read VIC_IRQ_VEC_PEND_RD you never get the first irq for some reason +*/ + irqnr =readl_relaxed (base_addr +VIC_IRQ_VEC_RD ); + irqnr =readl_relaxed (base_addr +VIC_IRQ_VEC_PEND_RD ); +if (irqnr ==-1 ) +break ; +handle_IRQ (irqnr, regs); + }while (1 ); +} + +/* enable imprecise aborts */ +static inline void local_cpsie_enable (void ) +{ + asmvolatile ("cpsie a" : : :"memory" ); +} + +static void __exception_irq_entry vic_handle_irq(struct pt_regs *regs) +{ +local_cpsie_enable ();// local_abt_enable()? +msm_vic_handle_irq (vic_data.base, regs); +} + +static struct irq_chip msm_irq_chip = { + .name ="msm" , + .irq_disable = msm_irq_mask, + .irq_ack = msm_irq_ack, + .irq_mask = msm_irq_mask, + .irq_unmask = msm_irq_unmask, + .irq_set_wake = msm_irq_set_wake, + .irq_set_type = msm_irq_set_type, +}; + +static int msm_vic_parse_irq_mapping (struct device_node *np,struct msm_irq_map **map,int *count) +{ +const __be32 *prop; +int len, i; + + prop =of_get_property (np,"irq-mapping" , &len); +if (!prop) { +pr_err ("%s: No irq-mapping property in device tree\n" , __func__); +return -ENODEV ; + } + +/* Each entry is 2 u32 values: irq + smsm */ + *count = len / (2 *sizeof (u32)); + + *map =kzalloc ((*count) *sizeof (**map),GFP_KERNEL ); +if (!*map) { +pr_err ("%s: Failed to allocate memory for irq_map\n" , __func__); +return -ENOMEM ; + } + +for (i =0 ; i < *count; i++) { + (*map)[i].irq =be32_to_cpu (prop[i *2 ]); + (*map)[i].smsm =be32_to_cpu (prop[i *2 +1 ]); + } + +return 0 ; +} + +static int __init msm_init_irq (struct device_node *intc,struct device_node *parent) +{ +int ret; + + vic_data.base =of_iomap (intc,0 ); +if (WARN_ON (!vic_data.base)) +return -EIO ; + ret =of_property_read_u32 (intc,"num-irqs" , &vic_data.nr_vic_irqs); +if (ret) { +pr_err ("%s: failed to read num-irqs ret=%d\n" , __func__, ret); +return ret; + } + + ret =of_property_read_u32 (intc,"num-gpio-irqs" , &vic_data.nr_gpio_irqs); +if (ret) { +pr_err ("%s: failed to read num-gpio-irqs ret=%d\n" , __func__, ret); +return ret; + } + + ret =msm_vic_parse_irq_mapping (intc, &vic_data.irq_map, &vic_data.irq_map_count); +if (ret) { +pr_err ("Failed to parse irq-mapping\n" ); +return ret; + } + + ret =of_property_read_u32 (intc,"vic-num-regs" , &vic_data.vic_num_regs); +if (ret) { +pr_err ("Failed to parse vic-num-regs\n" ); +return ret; + } + + msm_irq_shadow_reg =kcalloc (vic_data.vic_num_regs, +sizeof (*msm_irq_shadow_reg), +GFP_KERNEL ); + + msm_irq_idle_disable =kcalloc (vic_data.vic_num_regs, +sizeof (*msm_irq_idle_disable), +GFP_KERNEL ); + +if (!msm_irq_shadow_reg || !msm_irq_idle_disable) +return -ENOMEM ; + + vic_data.msm_nr_irqs = vic_data.nr_vic_irqs *2 + vic_data.nr_gpio_irqs; + + ret =irq_alloc_descs (-1 ,0 , vic_data.nr_vic_irqs,0 ); +if (ret <0 ) +pr_warn ("Couldn't allocate IRQ numbers\n" ); +/* select level interrupts */ +msm_irq_write_all_regs (vic_data.base +VIC_INT_TYPE0 ,0 ); + +/* select highlevel interrupts */ +msm_irq_write_all_regs (vic_data.base +VIC_INT_POLARITY0 ,0 ); + +/* select IRQ for all INTs */ +msm_irq_write_all_regs (vic_data.base +VIC_INT_SELECT0 ,0 ); + +/* disable all INTs */ +msm_irq_write_all_regs (vic_data.base +VIC_INT_EN0 ,0 ); + +/* don't use vic */ +writel (0 , vic_data.base +VIC_CONFIG ); + +/* enable interrupt controller */ +writel (3 , vic_data.base +VIC_INT_MASTEREN ); + +for (int n =0 ; n < vic_data.msm_nr_irqs; n++) { +irq_set_chip_and_handler (n, &msm_irq_chip, handle_level_irq); +set_irq_flags (n,IRQF_VALID ); + } + +/* Ready to receive interrupts */ +set_handle_irq (vic_handle_irq); + + vic_data.domain =irq_domain_create_legacy + (of_fwnode_handle (intc), + vic_data.nr_vic_irqs, +0 ,0 , + &irq_domain_simple_ops, + &vic_data); +if (!vic_data.domain) +pr_err ("%s: failed to register irq domain\n" , __func__); +return 0 ; +} + +IRQCHIP_DECLARE (qcom_msm_vic,"qcom,msm-vic" , msm_init_irq);
Signature · 1 line
2.51.0
Re: [PATCH 2/5] irqchip: Add Qualcomm MSM VIC driver
Quoted 1 line · On 15/03/2026 12:17, j0sh1x wrote:
Signed-off-by j0sh1x <[email protected]>
You must use full name.
Quoted 15 lines
--- drivers/irqchip/irq-msm-vic.c | 361 ++++++++++++++++++++++++++++++++++ 1 file changed, 361 insertions(+) create mode 100644 drivers/irqchip/irq-msm-vic.cdrivers/irqchip/irq-msm-vic.c new file +4
-0@@ -0,0 +1,361 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* +* Copyright (C) 2007 Google, Inc. +* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
drivers/irqchip/irq-msm-vic.c line 14
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+* Copyright (c) 2024, Htc Leo Revival Project +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details.
We don't take 19 years old code. You need to fix it to match current Linux kernel style, which means most likely all this has to be completely rewritten from scratch. Take latest reviewed drivers as starting point, not something from 2007.
Best regards,
Krzysztof
Thomas Gleixner
maintainerRe: [PATCH 2/5] irqchip: Add Qualcomm MSM VIC driver
In reply to j0sh1xOn Sun, Mar 15 2026 at 12:17, j0sh1x wrote:
That's a lot of void in this change log. And you have to provide a real name.
Quoted 6 lines
+++
b/drivers/irqchip/irq-msm-vic.cdrivers/irqchip/irq-msm-vic.c new file +4
-0@@ -0,0 +1,361 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* +* Copyright (C) 2007 Google, Inc. +* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
drivers/irqchip/irq-msm-vic.c line 14
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+* Copyright (c) 2024, Htc Leo Revival Project +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details.
You have the SPDX license identifier, so no need for the boiler plate.
https://www.kernel.org/doc/Documentation/process/license-rules.rst
Quoted 7 lines
drivers/irqchip/irq-msm-vic.c new file +7
-0+* +*/ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/sched.h> +#include <linux/interrupt.h>
drivers/irqchip/irq-msm-vic.c line 31
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+#include <linux/ptrace.h> +#include <linux/timer.h> +#include <linux/irq.h> +#include <linux/irqchip.h> +#include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> +#include <linux/cacheflush.h>
Please order the includes alphabetically and remove all unneeded ones. There are quite some pointless ones.
drivers/irqchip/irq-msm-vic.c line 39
Quoted 7 lines
drivers/irqchip/irq-msm-vic.c new file +7
-0+#include <asm/exception.h> +#include <asm/irq.h> + +#include <dt-bindings/interrupt-controller/qcom-vic.h> + +static u32 msm_irq_smsm_wake_enable[2 ]; +struct msm_irq_shadow {
Please put a new line between the variable and the structure definition.
Quoted 13 lines
drivers/irqchip/irq-msm-vic.c new file +13
-0+u32 int_en[2 ]; +u32 int_type; +u32 int_polarity; +u32 int_select; +}; + +static struct msm_irq_shadow *msm_irq_shadow_reg; +static u32 *msm_irq_idle_disable; + +struct msm_irq_map { +u32 irq; +u8 smsm; +};
drivers/irqchip/irq-msm-vic.c line 62
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+ +struct vic_device { +void __iomem *base; +struct irq_domain *domain; +u32 msm_nr_irqs; +u32 nr_vic_irqs; +u32 nr_gpio_irqs; +u32 vic_num_regs; +struct msm_irq_map *irq_map; +int irq_map_count;
https://www.kernel.org/doc/html/latest/process/maintainer-tip.html
Please read and follow it.
drivers/irqchip/irq-msm-vic.c line 65
Quoted 3 lines
drivers/irqchip/irq-msm-vic.c new file +3
-0+}; + +static struct vic_device vic_data;
Please have the struct declarations first and then define all the static variables.
drivers/irqchip/irq-msm-vic.c line 74
Quoted 8 lines
drivers/irqchip/irq-msm-vic.c new file +8
-0+static int msm_irq_to_smsm (u32 irq) +{ +int i; + +if (!vic_data.irq_map) +return -EINVAL ; + +for (i =0 ; i < vic_data.irq_map_count; i++) {
for (int i = 0;
drivers/irqchip/irq-msm-vic.c line 82
Quoted 8 lines
drivers/irqchip/irq-msm-vic.c new file +8
-0+if (vic_data.irq_map[i].irq == irq) +return vic_data.irq_map[i].smsm; + } + +return -ENOENT ; +} + +void set_irq_flags (unsigned int irq,unsigned int iflags);
What?
Quoted 9 lines
drivers/irqchip/irq-msm-vic.c new file +9
-0+void set_irq_flags (unsigned int irq,unsigned int iflags) +{ +unsigned long clr =0 , set =IRQ_NOREQUEST |IRQ_NOPROBE |IRQ_NOAUTOEN ; + +if (irq >= vic_data.msm_nr_irqs) { +pr_err ("Trying to set irq flags for IRQ%d\n" , irq); +return ; + } +
drivers/irqchip/irq-msm-vic.c line 102
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+if (iflags &IRQF_VALID ) + clr |=IRQ_NOREQUEST ; +if (iflags &IRQF_PROBE ) + clr |=IRQ_NOPROBE ; +if (!(iflags &IRQF_NOAUTOEN )) + clr |=IRQ_NOAUTOEN ; +/* Order is clear bits in "clr" then set bits in "set" */ +irq_modify_status (irq, clr, set & ~clr); +} +EXPORT_SYMBOL_GPL (set_irq_flags);
Not going to happen. There is existing infrastructure for that and there is nothing VIC specific about this. set_irq_flags() has been removed from the kernel long ago for a reason.
Quoted 9 lines
drivers/irqchip/irq-msm-vic.c new file +9
-0+static inline void msm_irq_write_all_regs (void __iomem *base,unsigned int val) +{ +for (int i =0 ; i < vic_data.vic_num_regs; i++) +writel (val, base + (i *4 )); +} + +static void msm_irq_ack (struct irq_data *d) +{ +void __iomem *reg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_CLEAR0 , d->irq);
drivers/irqchip/irq-msm-vic.c line 122
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+ +writel (1 << (d->irq &31 ), reg); +} + +static void msm_irq_mask (struct irq_data *d) +{ +void __iomem *reg =VIC_INT_TO_REG_ADDR (vic_data.base +VIC_INT_ENCLEAR0 , d->irq); +unsigned int index =VIC_INT_TO_REG_INDEX (d->irq); +u32 mask =1UL << (d->irq &31 ); +int smsm_irq =msm_irq_to_smsm (d->irq);
Variable declaration ordering.
drivers/irqchip/irq-msm-vic.c line 210
Quoted 12 lines
drivers/irqchip/irq-msm-vic.c new file +12
-0+ + msm_irq_shadow_reg[index].int_en[0 ] &= ~mask; +writel (mask, reg); +if (smsm_irq ==0 ) { + msm_irq_idle_disable[index] &= ~mask; + }else { + mask =1UL << (smsm_irq -1 ); + msm_irq_smsm_wake_enable[0 ] &= ~mask; + } +} +static inline void msm_vic_handle_irq (void __iomem *base_addr,struct pt_regs + *regs)
Bogus line break
drivers/irqchip/irq-msm-vic.c line 215
Quoted 5 lines
drivers/irqchip/irq-msm-vic.c new file +5
-0+{ +u32 irqnr; + + do { + /* VIC_IRQ_VEC_RD has irq# or old irq# if the irq has been handled
Bogus comment style.
drivers/irqchip/irq-msm-vic.c line 221
Quoted 6 lines
drivers/irqchip/irq-msm-vic.c new file +6
-0+* VIC_IRQ_VEC_PEND_RD has irq# or -1 if none pending *but* if you +* just read VIC_IRQ_VEC_PEND_RD you never get the first irq for some reason +*/ + irqnr =readl_relaxed (base_addr +VIC_IRQ_VEC_RD ); + irqnr =readl_relaxed (base_addr +VIC_IRQ_VEC_PEND_RD ); +if (irqnr ==-1 )
-1 on a u32? That's just sloppy. Use a proper define like:
#define NO_PENDING_IRQ (~0U)
if (irqnr == NO_PENDING_IRQ)
Quoted 4 lines
drivers/irqchip/irq-msm-vic.c new file +4
-0+break ; +handle_IRQ (irqnr, regs); + }while (1 ); +}
drivers/irqchip/irq-msm-vic.c line 235
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+ +/* enable imprecise aborts */ +static inline void local_cpsie_enable (void ) +{ + asmvolatile ("cpsie a" : : :"memory" ); +} + +static void __exception_irq_entry vic_handle_irq(struct pt_regs *regs) +{ +local_cpsie_enable ();// local_abt_enable()?
No tail comments please.
Quoted 27 lines
drivers/irqchip/irq-msm-vic.c new file +27
-0+msm_vic_handle_irq (vic_data.base, regs); +} + +static struct irq_chip msm_irq_chip = { + .name ="msm" , + .irq_disable = msm_irq_mask, + .irq_ack = msm_irq_ack, + .irq_mask = msm_irq_mask, + .irq_unmask = msm_irq_unmask, + .irq_set_wake = msm_irq_set_wake, + .irq_set_type = msm_irq_set_type, +}; + +static int msm_vic_parse_irq_mapping (struct device_node *np,struct msm_irq_map **map,int *count) +{ +const __be32 *prop; +int len, i; + + prop =of_get_property (np,"irq-mapping" , &len); +if (!prop) { +pr_err ("%s: No irq-mapping property in device tree\n" , __func__); +return -ENODEV ; + } + +/* Each entry is 2 u32 values: irq + smsm */ + *count = len / (2 *sizeof (u32)); +
drivers/irqchip/irq-msm-vic.c line 272
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+ *map =kzalloc ((*count) *sizeof (**map),GFP_KERNEL ); +if (!*map) { +pr_err ("%s: Failed to allocate memory for irq_map\n" , __func__); +return -ENOMEM ; + } + +for (i =0 ; i < *count; i++) { + (*map)[i].irq =be32_to_cpu (prop[i *2 ]); + (*map)[i].smsm =be32_to_cpu (prop[i *2 +1 ]); + }
Why is anything in the device tree big endian on a little endian system?
Also this code is unreadable and incomprehensible.
Quoted 12 lines
drivers/irqchip/irq-msm-vic.c new file +12
-0+ +return 0 ; +} + +static int __init msm_init_irq (struct device_node *intc,struct device_node *parent) +{ +int ret; + + vic_data.base =of_iomap (intc,0 ); +if (WARN_ON (!vic_data.base)) +return -EIO ; + ret =of_property_read_u32 (intc,"num-irqs" , &vic_data.nr_vic_irqs);
drivers/irqchip/irq-msm-vic.c line 294
Quoted 10 lines
drivers/irqchip/irq-msm-vic.c new file +10
-0+if (ret) { +pr_err ("%s: failed to read num-irqs ret=%d\n" , __func__, ret); +return ret; + } + + ret =of_property_read_u32 (intc,"num-gpio-irqs" , &vic_data.nr_gpio_irqs); +if (ret) { +pr_err ("%s: failed to read num-gpio-irqs ret=%d\n" , __func__, ret); +return ret; + }
Read all the required information into local variables first and then allocate the vic_device data including the mapping table in one go.
drivers/irqchip/irq-msm-vic.c line 310
Quoted 3 lines
drivers/irqchip/irq-msm-vic.c new file +3
-0+ msm_irq_shadow_reg =kcalloc (vic_data.vic_num_regs, +sizeof (*msm_irq_shadow_reg), +GFP_KERNEL );
You have 100 characters.
drivers/irqchip/irq-msm-vic.c line 317
Quoted 6 lines
drivers/irqchip/irq-msm-vic.c new file +6
-0+ msm_irq_idle_disable =kcalloc (vic_data.vic_num_regs, +sizeof (*msm_irq_idle_disable), +GFP_KERNEL ); + +if (!msm_irq_shadow_reg || !msm_irq_idle_disable) +return -ENOMEM ;
That leaks the previous allocations.
drivers/irqchip/irq-msm-vic.c line 321
Quoted 3 lines
drivers/irqchip/irq-msm-vic.c new file +3
-0+ vic_data.msm_nr_irqs = vic_data.nr_vic_irqs *2 + vic_data.nr_gpio_irqs; + + ret =irq_alloc_descs (-1 ,0 , vic_data.nr_vic_irqs,0 );
No. That's not how any of this works. A interrupt driver has no business to allocate interrupt descriptors. Use proper interrupt domains and not this cobbled together gunk collected from some out of tree garbage can.
There are enough recent examples of properly written interrupt chip drivers in drivers/irqchip to learn from.
drivers/irqchip/irq-msm-vic.c line 361
Quoted 2 lines
drivers/irqchip/irq-msm-vic.c new file +1
-0+IRQCHIP_DECLARE (qcom_msm_vic,"qcom,msm-vic" , msm_init_irq);
Git gave you a hint right there....
Thanks,
tglx
PATCH 3/5 irqchip: Add Kconfig and Makefile entries for MSM VIC
In reply to j0sh1x--- drivers/irqchip/Kconfig | 6 ++++++ drivers/irqchip/Makefile | 1 + 2 files changed, 7 insertions(+)
drivers/irqchip/Kconfig +6 -0
@@ -522,6 +522,12 @@ config QCOM_MPM MSM Power Manager driver to manage and configure wakeup IRQs for Qualcomm Technologies Inc (QTI) mobile chips. +config ARM_MSM_VIC + tristate "QCOM ARM VIC" + select IRQ_DOMAIN + help + QCOM Vectored Interrupt Controller driver for MSM platforms. + config CSKY_MPINTC bool depends on CSKY
drivers/irqchip/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_ARM_GIC_V5) += irq-gic-v5.o irq-gic-v5-irs.o irq-gic-v5-its.o \ obj-$(CONFIG_HISILICON_IRQ_MBIGEN) += irq-mbigen.o obj-$(CONFIG_ARM_NVIC) += irq-nvic.o obj-$(CONFIG_ARM_VIC) += irq-vic.o +obj-$(CONFIG_ARM_MSM_VIC) += irq-msm-vic.o obj-$(CONFIG_ARMADA_370_XP_IRQ) += irq-armada-370-xp.o obj-$(CONFIG_ATMEL_AIC_IRQ) += irq-atmel-aic-common.o irq-atmel-aic.o obj-$(CONFIG_ATMEL_AIC5_IRQ) += irq-atmel-aic-common.o irq-atmel-aic5.o
Signature · 1 line
2.51.0
kernel test robot
build botRe: [PATCH 3/5] irqchip: Add Kconfig and Makefile entries for MSM VIC
kernel test robot noticed the following build errors:
Hi j0sh1x,
kernel test robot noticed the following build errors:
[auto build test ERROR on tip/irq/core]
[also build test ERROR on linus/master v7.0-rc6 next-20260327] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/j0sh1x/irqchip-Add-Qualcomm-MSM-VIC-driver/20260315-192045 base: tip/irq/core patch link: https://lore.kernel.org/r/20260315111705.118544-3-aljoshua.hell%40gmail.com patch subject: [PATCH 3/5] irqchip: Add Kconfig and Makefile entries for MSM VIC config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20260330/[email protected]/config) compiler: sh4-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260330/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/irqchip/irq-msm-vic.c:33:10: fatal error: asm/exception.h: No such file or directory
33 | #include <asm/exception.h>
| ^~~~~~~~~~~~~~~~~compilation terminated.
vim +33 drivers/irqchip/irq-msm-vic.c
6daa7dfc644629 j0sh1x 2026-03-15 326daa7dfc644629 j0sh1x 2026-03-15 @33 #include <asm/exception.h> 6daa7dfc644629 j0sh1x 2026-03-15 34 #include <asm/irq.h> 6daa7dfc644629 j0sh1x 2026-03-15 35
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 3/5] irqchip: Add Kconfig and Makefile entries for MSM VIC
In reply to j0sh1xkernel test robot noticed the following build errors:
Hi j0sh1x,
kernel test robot noticed the following build errors:
[auto build test ERROR on tip/irq/core]
[also build test ERROR on linus/master v7.0-rc6 next-20260327] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/j0sh1x/irqchip-Add-Qualcomm-MSM-VIC-driver/20260315-192045 base: tip/irq/core patch link: https://lore.kernel.org/r/20260315111705.118544-3-aljoshua.hell%40gmail.com patch subject: [PATCH 3/5] irqchip: Add Kconfig and Makefile entries for MSM VIC config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20260330/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260330/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/irqchip/irq-msm-vic.c:33:10: fatal error: 'asm/exception.h' file not found
33 | #include <asm/exception.h>
| ^~~~~~~~~~~~~~~~~1 error generated.
vim +33 drivers/irqchip/irq-msm-vic.c
6daa7dfc644629e j0sh1x 2026-03-15 326daa7dfc644629e j0sh1x 2026-03-15 @33 #include <asm/exception.h> 6daa7dfc644629e j0sh1x 2026-03-15 34 #include <asm/irq.h> 6daa7dfc644629e j0sh1x 2026-03-15 35
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 4/5 dt-bindings: irq: Add Qualcomm MSM VIC header
In reply to j0sh1xAdd DT binding constants for the Qualcomm MSM VIC interrupt controller.
These constants are used in the irq-mapping and other driver bindings to reference specific interrupts and SMSM wakeup channels.
--- .../interrupt-controller/qcom-vic.h | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 include/dt-bindings/interrupt-controller/qcom-vic.h
include/dt-bindings/interrupt-controller/qcom-vic.h new file +92 -0
@@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* +* This header provides constants for the ARM GIC. +*/ + +#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_QCOM_VIC_H +#define _DT_BINDINGS_INTERRUPT_CONTROLLER_QCOM_VIC_H + +#include <dt-bindings/interrupt-controller/irq.h> + +#define VIC_INT_TO_REG_ADDR (base, irq) (base + ((irq & 32) ? 4 : 0)) +#define VIC_INT_TO_REG_INDEX (irq) ((irq >> 5) & 1) + +#define VIC_INT_SELECT0 0x0000/* 1: FIQ, 0: IRQ */ +#define VIC_INT_SELECT1 0x0004/* 1: FIQ, 0: IRQ */ +#define VIC_INT_SELECT2 0x0008/* 1: FIQ, 0: IRQ */ +#define VIC_INT_SELECT3 0x000C/* 1: FIQ, 0: IRQ */ +#define VIC_INT_EN0 0x0010 +#define VIC_INT_EN1 0x0014 +#define VIC_INT_EN2 0x0018 +#define VIC_INT_EN3 0x001C +#define VIC_INT_ENCLEAR0 0x0020 +#define VIC_INT_ENCLEAR1 0x0024 +#define VIC_INT_ENCLEAR2 0x0028 +#define VIC_INT_ENCLEAR3 0x002C +#define VIC_INT_ENSET0 0x0030 +#define VIC_INT_ENSET1 0x0034 +#define VIC_INT_ENSET2 0x0038 +#define VIC_INT_ENSET3 0x003C +#define VIC_INT_TYPE0 0x0040/* 1: EDGE, 0: LEVEL */ +#define VIC_INT_TYPE1 0x0044/* 1: EDGE, 0: LEVEL */ +#define VIC_INT_TYPE2 0x0048/* 1: EDGE, 0: LEVEL */ +#define VIC_INT_TYPE3 0x004C/* 1: EDGE, 0: LEVEL */ +#define VIC_INT_POLARITY0 0x0050/* 1: NEG, 0: POS */ +#define VIC_INT_POLARITY1 0x0054/* 1: NEG, 0: POS */ +#define VIC_INT_POLARITY2 0x0058/* 1: NEG, 0: POS */ +#define VIC_INT_POLARITY3 0x005C/* 1: NEG, 0: POS */ +#define VIC_NO_PEND_VAL 0x0060 + + +#define VIC_NO_PEND_VAL_FIQ 0x0064 +#define VIC_INT_MASTEREN 0x0068/* 1: IRQ, 2: FIQ */ +#define VIC_CONFIG 0x006C/* 1: USE SC VIC */ + + +#define IRQF_VALID (1 << 0) +#define IRQF_PROBE (1 << 1) +#define IRQF_NOAUTOEN (1 << 2) + +#define VIC_IRQ_STATUS0 0x0080 +#define VIC_IRQ_STATUS1 0x0084 +#define VIC_IRQ_STATUS2 0x0088 +#define VIC_IRQ_STATUS3 0x008C +#define VIC_FIQ_STATUS0 0x0090 +#define VIC_FIQ_STATUS1 0x0094 +#define VIC_FIQ_STATUS2 0x0098 +#define VIC_FIQ_STATUS3 0x009C +#define VIC_RAW_STATUS0 0x00A0 +#define VIC_RAW_STATUS1 0x00A4 +#define VIC_RAW_STATUS2 0x00A8 +#define VIC_RAW_STATUS3 0x00AC +#define VIC_INT_CLEAR0 0x00B0 +#define VIC_INT_CLEAR1 0x00B4 +#define VIC_INT_CLEAR2 0x00B8 +#define VIC_INT_CLEAR3 0x00BC +#define VIC_SOFTINT0 0x00C0 +#define VIC_SOFTINT1 0x00C4 +#define VIC_SOFTINT2 0x00C8 +#define VIC_SOFTINT3 0x00CC +#define VIC_IRQ_VEC_RD 0x00D0/* pending int # */ +#define VIC_IRQ_VEC_PEND_RD 0x00D4/* pending vector addr */ +#define VIC_IRQ_VEC_WR 0x00D8 + + +#define VIC_FIQ_VEC_RD 0x00DC +#define VIC_FIQ_VEC_PEND_RD 0x00E0 +#define VIC_FIQ_VEC_WR 0x00E4 +#define VIC_IRQ_IN_SERVICE 0x00E8 +#define VIC_IRQ_IN_STACK 0x00EC +#define VIC_FIQ_IN_SERVICE 0x00F0 +#define VIC_FIQ_IN_STACK 0x00F4 +#define VIC_TEST_BUS_SEL 0x00F8 +#define VIC_IRQ_CTRL_CONFIG 0x00FC + + +#define VIC_VECTPRIORITY (n) 0x0200+((n) * 4) +#define VIC_VECTADDR (n) 0x0400+((n) * 4) + +#define SMSM_FAKE_IRQ (0xff) + +#define VIC_NUM_REGS 2 +#endif
Signature · 1 line
2.51.0
Re: [PATCH 4/5] dt-bindings: irq: Add Qualcomm MSM VIC header
Quoted 8 lines · On 15/03/2026 12:17, j0sh1x wrote:
Add DT binding constants for the Qualcomm MSM VIC interrupt controller.
These constants are used in the irq-mapping and other driver bindings to reference specific interrupts and SMSM wakeup channels.
Signed-off-by j0sh1x <[email protected]>--- .../interrupt-controller/qcom-vic.h | 92 +++++++++++++++++++
No, not a binding. Don't add such stuff.
Best regards,
Krzysztof
PATCH 5/5 MAINTAINERS: Add Maintainer entry for MSM VIC
In reply to j0sh1x--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -21890,6 +21890,12 @@ S: Supported W: https://wireless.wiki.kernel.org/en/users/Drivers/wcn36xx F: drivers/net/wireless/ath/wcn36xx/ +QUALCOMM VECTORED INTERRUPT CONTROLLER (VIC) DRIVER +M: j0sh1x <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yaml +F: drivers/irqchip/irq-msm-vic.c + QUANTENNA QTNFMAC WIRELESS DRIVER M: Igor Mitsyanko <[email protected]> R: Sergey Matyukevich <[email protected]>
Signature · 1 line
2.51.0
Quoted 1 line · On 15/03/2026 12:17, j0sh1x wrote:
Signed-off-by j0sh1x <[email protected]>
Please run scripts/checkpatch.pl on the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl --strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.
You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.
Please kindly resend and include all necessary To/Cc entries.
Quoted 22 lines
--- .../interrupt-controller/qcom,msm-vic.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yamlDocumentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yaml new file +11
-0@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0 +# qualcomm,msm-vic.yaml - Device Tree binding for Qualcomm MSM VIC interrupt controller + +description: > + Qualcomm MSM VIC (Vector Interrupt Controller). This interrupt controller + handles normal and wakeup interrupts and supports mapping to the + Qualcomm SMSM system. + +compatible: ["qcom,msm-vic"] + +properties:
Documentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yaml line 21
Quoted 10 lines
Documentation/devicetree/bindings/interrupt-controller/qcom,msm-vic.yaml new file +10
-0+ interrupt-controller: + description: "Identifies this node as an interrupt controller" + required: true + type: boolean + + #interrupt-cells: + description: "Specifies the number of cells needed to encode an interrupt" + required: true + type: integer + default: 1
I don't know what you wrote, but this is not a DT binding. Don't send us LLM microslop products. Read first docs guiding you what you have to do.
Also, nothing here was tested.
NAK
Best regards,
Krzysztof
Quoted 21 lines · Krzysztof Kozlowski
Quoted 1 line · On 15/03/2026 12:17, j0sh1x wrote:
Signed-off-by j0sh1x <[email protected]>Please run
scripts/checkpatch.plon the patches and fix reported warnings. After that, run also 'scripts/checkpatch.pl--strict' on the patches and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.Please use
scripts/get_maintainers.plto get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.Tools like b4 or
scripts/get_maintainer.plprovide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember aboutb4 prep --auto-to-ccif you added new patches to the patchset.
Quoted 6 lines
You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.
Please kindly resend and include all necessary To/Cc entries.
Also, please go through comments here:
https://sashiko.dev/#/patchset/20260315111705.118544-1-aljoshua.hell%40gmail.com
At least the one about header was kind of right:
"Headers in include/dt-bindings/ are typically meant to define the stable ABI between device tree sources and the OS. Exposing internal hardware register offsets and software flags here might pollute the globally visible DT namespace."
Best regards,
Krzysztof