Received: by 10.223.164.202 with SMTP id h10csp32179wrb; Thu, 9 Nov 2017 02:11:51 -0800 (PST) X-Google-Smtp-Source: ABhQp+SAQz8HfXkcCXhJTJTvzU0C+uNlfCvdfSxbNI2iBWABvJ4f6yoIlcwPJxZM8EfV7V0wLVl0 X-Received: by 10.98.74.149 with SMTP id c21mr3635511pfj.200.1510222311416; Thu, 09 Nov 2017 02:11:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510222311; cv=none; d=google.com; s=arc-20160816; b=gDTsjqrUQAfgs/aqh8Pn/kVpph7eYtY4NNjkrq4yF+N+UjGsOn8vzyHGkNu7Q1LE4e f+/RJKnWmmMQLiWOpFCBs4rDcSfx1TLIC6qxK9Mnv73q9KCtmrRJfM8DbKuAY7Fun3AE A43VwIKMDbc7eagWmi6jia0h4DDMicfZ48DC6LmZF/mMjJ8F6Hih6oan8PhMYbOkEJ/u tthYLVwe+qh0qYIydnH2pe5ou3aJimqALWvTsDmJItn215xIigo/E77DJpWbFqw74VI8 Aqvx8mrZnCvfi6mSSLwOLvb18CUO/Izt1GGUhRff3Jd9ZI9eI3O2RRA6tsjoWGfiXi9Q XJ5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=LXxOABd5V613acVbKDC5mhXMC22fgudKPMfE/SYVPwA=; b=LAAMn5lMXusYT4+sum5XkCUXgrqMDRL0Bz5vxskWS5ckr+8jex/K1k+2QEctJQsl2u z1scdspTyk4Ri58UNUGh3kQJl+JrZIa4NgekzatW1v2Bf7zJc1av3JaU80G7vBnZ6bGz 7Z+JnMQK66wBqHwRgRxpY7p/C81SPmRnadF0cKjzFkCFbPRahFdSzpxXiCdbfdD0VzRA EfwMl6w31lAEfImZO0whjqaSSPCZBY5D6+4zVaQ4OWwzki0WZkKVx0xli+0X3oY45wX5 N6dhcDbK5dMmLcJCKEiW6O2VpmvDc3gocxv/2np3pqNKy4VSE3OlMjTmXdf8IaUcv451 nQiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZdJmUmCJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si1886937pgn.217.2017.11.09.02.11.39; Thu, 09 Nov 2017 02:11:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZdJmUmCJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754067AbdKIKK7 (ORCPT + 81 others); Thu, 9 Nov 2017 05:10:59 -0500 Received: from mail-vk0-f65.google.com ([209.85.213.65]:48003 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753184AbdKIKK4 (ORCPT ); Thu, 9 Nov 2017 05:10:56 -0500 Received: by mail-vk0-f65.google.com with SMTP id j2so3612793vki.4; Thu, 09 Nov 2017 02:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LXxOABd5V613acVbKDC5mhXMC22fgudKPMfE/SYVPwA=; b=ZdJmUmCJtJkuUkbr2z69c07XmKGdDiELX7lmrzzHExE/cHKA9Ut4SdEo/jwICu+2V1 ZErba14rszY8N1BD/IzznA3CQULOmZdWKHvwdY8jGEOj4iuuwk7/5urAndV5snWk9yR1 MkUKN3NYMFIGhhN0JV4VVPx9WA50utGSlOJuuQsNEk1cZm2hVqOzWkDiHuWT1Z9uwxPj oytgvdJOwhtGkWPyVGm/gH8ygJ+ELC/RCw6epCHmHpz3BBM7ti6nbqkw4uyXI1NyQHG6 ERyVbRKVnDdYBnTJmWCh3pjvdG8y6kz1IEaTOq1OhGXryenxY6Ancp5KolFJkcJiqPds DMbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LXxOABd5V613acVbKDC5mhXMC22fgudKPMfE/SYVPwA=; b=AetrPKnrNs7Yh86H5WUGNfPjbKvoA97JTZprZMO1IvVKlFreW5kst6EG0RwSVIvqiG U8seIxF+T72Fb9AYPp1zAqQBv4vyOX3Igux9DJV3nC7g5DR5DZLZCwTT3Hth9lmw8gg1 J58haHHFv6P8reCZwNPy5KdCHmh44UYskSv/HOJEpRtvvDOrStO0AMjYiuoRUdT5aj1e u+3gFeiSTrqqsyUOvr0vti9Ewsp2CKIjcQxPmJxkAyT94j7RBh+oXQykJDpO9vTGRGan 1SEHl+UU0+Qlvr7alXZ9iGJI7HEGTClJwAufRMJ7T01RvPV8axu+f90JzZ6jys9lr0KH /+fA== X-Gm-Message-State: AJaThX4wrvUtWwrihsweochOh2SaKnVFCzhhxAzTtZq1WzdODwH9osUH WvJhwlRmFv+KJavGeBhH44yKSA4pW+kj2XO4KYcSeQ== X-Received: by 10.31.170.142 with SMTP id t136mr2761006vke.198.1510222255225; Thu, 09 Nov 2017 02:10:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.62.8 with HTTP; Thu, 9 Nov 2017 02:10:14 -0800 (PST) In-Reply-To: References: <4572b290f40d62876b83328331a17c2343710b20.1510118606.git.green.hu@gmail.com> From: Greentime Hu Date: Thu, 9 Nov 2017 18:10:14 +0800 Message-ID: Subject: Re: [PATCH 28/31] irqchip: Andestech Internal Vector Interrupt Controller driver To: Marc Zyngier Cc: Greentime , Linux Kernel Mailing List , Arnd Bergmann , linux-arch , Thomas Gleixner , Jason Cooper , Rob Herring , netdev , Rick Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-11-08 22:24 GMT+08:00 Marc Zyngier : > On 08/11/17 05:55, Greentime Hu wrote: >> From: Greentime Hu >> > > Please add a commit message, indicating what this does, and potentially > a pointer to some documentation (if publicly available). > Thans. I will add proper commit messages in the next version patch. >> Signed-off-by: Rick Chen >> Signed-off-by: Greentime Hu >> --- >> drivers/irqchip/Makefile | 1 + >> drivers/irqchip/irq-ativic32.c | 149 ++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 150 insertions(+) >> create mode 100644 drivers/irqchip/irq-ativic32.c >> >> diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile >> index b842dfd..201ca9f 100644 >> --- a/drivers/irqchip/Makefile >> +++ b/drivers/irqchip/Makefile >> @@ -80,3 +80,4 @@ obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o >> obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o >> obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o >> obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.o >> +obj-$(CONFIG_NDS32) += irq-ativic32.o >> diff --git a/drivers/irqchip/irq-ativic32.c b/drivers/irqchip/irq-ativic32.c >> new file mode 100644 >> index 0000000..d3dae59 >> --- /dev/null >> +++ b/drivers/irqchip/irq-ativic32.c >> @@ -0,0 +1,149 @@ >> +/* >> + * Copyright (C) 2005-2017 Andes Technology Corporation >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License version 2 as >> + * published by the Free Software Foundation. >> + * >> + * 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 should have received a copy of the GNU General Public License >> + * along with this program. If not, see . >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +static void ativic32_ack_irq(struct irq_data *data) >> +{ >> + __nds32__mtsr_dsb(1 << data->hwirq, NDS32_SR_INT_PEND2); >> +} >> + >> +static void ativic32_mask_irq(struct irq_data *data) >> +{ >> + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2); >> + __nds32__mtsr_dsb(int_mask2 & (~(1 << data->hwirq)), NDS32_SR_INT_MASK2); >> +} >> + >> +static void ativic32_mask_ack_irq(struct irq_data *data) >> +{ >> + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2); >> + __nds32__mtsr_dsb(int_mask2 & (~(1 << data->hwirq)), NDS32_SR_INT_MASK2); >> + __nds32__mtsr_dsb((1 << data->hwirq), NDS32_SR_INT_PEND2); >> + >> +} >> + >> +static void ativic32_unmask_irq(struct irq_data *data) >> +{ >> + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2); >> + __nds32__mtsr_dsb(int_mask2 | (1 << data->hwirq), NDS32_SR_INT_MASK2); >> +} >> + >> +static int ativic32_set_type(struct irq_data *data, unsigned int flow_type) >> +{ >> + printk(KERN_WARNING "interrupt type is not configurable\n"); > > If it is not configurable, what is the point of having each interrupt > carry a trigger type in DT? Make sense. We should remove this function and DT trigger type description. >> + return 0; >> +} >> + >> +static struct irq_chip ativic32_chip = { >> + .name = "ativic32", >> + .irq_ack = ativic32_ack_irq, >> + .irq_mask = ativic32_mask_irq, >> + .irq_mask_ack = ativic32_mask_ack_irq, >> + .irq_unmask = ativic32_unmask_irq, >> + .irq_set_type = ativic32_set_type, >> +}; >> + >> +static unsigned int __initdata nivic_map[6] = { 6, 2, 10, 16, 24, 32 }; >> + >> +struct irq_domain *root_domain; > > Why isn't this static? Is there anything accessing it from outside of > this driver? Thanks. I will check if it is not used outside and add static in the next version patch. >> +static int ativic32_irq_domain_map(struct irq_domain *id, unsigned int virq, >> + irq_hw_number_t hw) >> +{ >> + >> + unsigned long int_trigger_type; >> + int_trigger_type = __nds32__mfsr(NDS32_SR_INT_TRIGGER); >> + if (int_trigger_type & (1 << hw)) >> + irq_set_chip_and_handler(virq, &ativic32_chip, handle_edge_irq); >> + else >> + irq_set_chip_and_handler(virq, &ativic32_chip, handle_level_irq); >> + >> + return 0; >> +} >> + >> +static struct irq_domain_ops ativic32_ops = { >> + .map = ativic32_irq_domain_map, >> + .xlate = irq_domain_xlate_onecell > > Huh... Your DT binding insist on two cells, and yet... Thanks. It is inconsistent. We will fix it in the next version patch. >> +}; >> + >> +static int get_intr_src(void) >> +{ >> + return ((__nds32__mfsr(NDS32_SR_ITYPE)&ITYPE_mskVECTOR) >> ITYPE_offVECTOR) >> + - NDS32_VECTOR_offINTERRUPT; >> +} >> + >> +asmlinkage void asm_do_IRQ(struct pt_regs *regs) >> +{ >> + struct pt_regs *old_regs = set_irq_regs(regs); >> + int virq; >> + int irq = get_intr_src(); >> + >> + /* >> + * Some hardware gives randomly wrong interrupts. Rather >> + * than crashing, do something sensible. >> + */ >> + if (unlikely(irq >= NR_IRQS)) { >> + pr_emerg( "IRQ exceeds NR_IRQS\n"); >> + BUG(); > > Given the above comment, I find this hilarious! Thanks. We will write more proper comments. >> + } >> + >> + irq_enter(); >> + virq = irq_find_mapping(root_domain, irq); >> + generic_handle_irq(virq); >> + irq_exit(); >> + set_irq_regs(old_regs); > > Why can't you use handle_domain_irq() directly instead of what looks > like a copy of it (this is where the comment comes from...)? Thanks. We will try to use handle_domain_irq() in the next version patch. >> + >> +} >> + >> +int __init ativic32_init_irq(struct device_node *node, struct device_node *parent) >> +{ >> + unsigned long int_vec_base, nivic, i; >> + >> + if (WARN(parent, "non-root ativic32 are not supported")) >> + return -EINVAL; >> + >> + int_vec_base = __nds32__mfsr(NDS32_SR_IVB); >> + >> + if (((int_vec_base & IVB_mskIVIC_VER) >> IVB_offIVIC_VER) == 0) { >> + panic("Unable to use NOINTC option to boot on this cpu\n"); >> + } >> + >> + nivic = (int_vec_base & IVB_mskNIVIC) >> IVB_offNIVIC; >> + if (nivic >= (sizeof nivic_map / sizeof nivic_map[0])) { >> + panic >> + ("The number of input for IVIC Controller is not supported on this cpu\n"); > > Irk. Please leave this on a single line... Or better yet, get rid of it > (see below). Thanks. We will fix it in the next version patch. >> + } >> + nivic = nivic_map[nivic]; > > If you have multiple configurations, I'd rather they live in DT, > specially if the IP is easily configurable. Thanks. But this is read from HW register. IMHO it will be more readable if we read this config from HW and do the relative actions. >> + >> + root_domain = irq_domain_add_linear(node, nivic, >> + &ativic32_ops, NULL); >> + >> + if (!root_domain) >> + panic("%s: unable to create IRQ domain\n", node->full_name); >> + >> + for(i = 0; i < nivic; i++) >> + irq_create_mapping(root_domain, i); > > You shouldn't need this, as the core DT code will populate the interrupt > on demand. Thanks. We will fix it in the next version patch. >> + >> + return 0; >> + >> +} >> +IRQCHIP_DECLARE(ativic32, "andestech,ativic32", ativic32_init_irq); >> > > Thanks, > > M. > -- > Jazz is not dead. It just smells funny... From 1583508237582657178@xxx Wed Nov 08 14:25:36 +0000 2017 X-GM-THRID: 1583483378611118279 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread