Received: by 10.213.65.68 with SMTP id h4csp459824imn; Tue, 20 Mar 2018 07:25:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELvgdtBhbtzRWwcOWGYvjpGRwhbyKyDJ68FJrnAtB6uUMnybcbL6shnQfF0q12oFy/+ubk4r X-Received: by 2002:a17:902:5845:: with SMTP id f5-v6mr17149417plj.164.1521555932877; Tue, 20 Mar 2018 07:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521555932; cv=none; d=google.com; s=arc-20160816; b=sHpWHhxcgryEgSw2VyHV0silfENw2wMDyXufg6RpinD1qHruiWIxYJuDVjjUZhhgFD APBii+nu8/kZ6onv9rBIOYVh3GCNaL4ekkG/pgWeQrYnmuHz19+RtIT395jHR/BXJPxO 76FcJfsDjDhvyx8MWPj10UvH9RvQRjhSbHIljyie1gXDL6EL/7vg+0FkelYstqQKGT+s XjzPn31bWxKqXygPguIwXzqBkKpBTFlAfS77/t9xlclQrDbtNTmGUGNkw1LHNxRPOWtK fTfj0VpVDcj5mRyE94X8XVH7sL7n2LXFbz8Fra8qsmEYKYyyQ8H1Y00S9zU27JcRU8uV QvgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=gjQTHugMb5NoGDOKEw386wRERJULa0Q6WF5cLXpBWJE=; b=XxBYWfO2QgX2fcmKcB+s3yELbbhrck4puEHIkK754LpirSXA5FCW2IVkP8ZkCNQbQK 5dEq59meXOrhG6gH/sNgJrPXqySO6b7L2i7ddBbjWeowa4dnClU4iPiDQIdCX+fvbnEn Mh3JiSbbTp/KQEYRso/KOlrdCA2jZY23TaqNVInjEJ7TNrNnzV34oNxfQ/jUeVhYvx6p qgX9VX6AZZw40K/KaClZp3URJEF7yhgTdKuArgnAFMAtoGhgff0lVBvSIZCv4yOPhy/6 27F3L6jfso59bNX6J/vjGHBmABaTmCgtIdph2WiOO3HCZPxFd9Fq46J8wIBgpv2+5c0N Jh0w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 197si1254662pge.78.2018.03.20.07.25.18; Tue, 20 Mar 2018 07:25:32 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394AbeCTOYJ (ORCPT + 99 others); Tue, 20 Mar 2018 10:24:09 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:35423 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbeCTOYH (ORCPT ); Tue, 20 Mar 2018 10:24:07 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.02444233|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03273;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.BNZf0PH_1521555831; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:223.93.147.148) by smtp.aliyun-inc.com(10.147.40.7); Tue, 20 Mar 2018 22:23:51 +0800 Date: Tue, 20 Mar 2018 22:23:51 +0800 From: Guo Ren To: Thomas Gleixner Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, daniel.lezcano@linaro.org, jason@lakedaemon.net, arnd@arndb.de, c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, thomas.petazzoni@bootlin.com, wbx@uclibc-ng.org Subject: Re: [PATCH 19/19] irqchip: add irq-nationalchip.c and irq-csky.c Message-ID: <20180320142350.GA13892@guoren> References: <62e687d3eb67505aa6f4d4d01ce268fd432bf58e.1521399976.git.ren_guo@c-sky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, On Mon, Mar 19, 2018 at 02:30:42PM +0100, Thomas Gleixner wrote: > > +static struct irq_chip ck_irq_chip = { > > + .name = "csky_intc_v1", > > + .irq_mask = ck_irq_mask, > > + .irq_unmask = ck_irq_unmask, > > +}; > > Please use the generic interrupt chip infrastructure for this. Ok, I will learn it. > > +static unsigned int ck_get_irqno(void) > > +{ > > + unsigned int temp; > > newline between declaration and code. Ok > > + temp = __raw_readl(CK_VA_INTC_ISR); > > + return temp & 0x3f; > > +}; > > + > > +static int __init > > +__intc_init(struct device_node *np, struct device_node *parent, bool ave) > > What is 'ave'? Ave means the irq-controller works on auto-vector-handler mode, it will cause 10 exception number and it need read intc-reg to get irq-num. > No magic numbers. Please use proper defines. Ok > > + else > > + __raw_writel( 0x0, CK_VA_INTC_ICR); > > + /* > > + * csky irq ctrl has 64 sources. > > + */ > > + #define INTC_IRQS 64 > > No defines in code. Ok > > > + for (i=0; i > checkpatch.pl would have told you what's wrong with the above Ok, Thx > > + __raw_writel((i+3)|((i+2)<<8)|((i+1)<<16)|(i<<24), > > Eew. Tons of magic numbers and a unreadable coding style. Please use an > inline function with proper comments to calculate that value Ok > > + CK_VA_INTC_SOURCE + i); > > + > > + root_domain = irq_domain_add_legacy(np, INTC_IRQS, 0, 0, &ck_irq_ops, NULL); > > + if (!root_domain) > > + panic("root irq domain not available\n"); > > + > > + irq_set_default_host(root_domain); > > + > > + return 0; > > +} > > + > > +static int __init > > +intc_init(struct device_node *np, struct device_node *parent) > > +{ > > + > > Stray newline I'll remove, Thx. > > + return __intc_init(np, parent, false); > > +} > > +IRQCHIP_DECLARE(csky_intc_v1, "csky,intc-v1", intc_init); > > + > > +/* > > + * use auto vector exceptions 10 for interrupt. > > + */ > > +static int __init > > +intc_init_ave(struct device_node *np, struct device_node *parent) > > +{ > > + return __intc_init(np, parent, true); > > Why is that 'ave' thing not a property of device tree? I'll change it to a property. > > +struct irq_chip nc_irq_chip = { > > + .name = "nationalchip_intc_v1", > > + .irq_mask = nc_irq_mask, > > + .irq_unmask = nc_irq_unmask, > > + .irq_enable = nc_irq_en, > > + .irq_disable = nc_irq_dis, > > +}; > > Again. This all can use the generic interrupt chip. I'll learn the generic interrupt chip. > > +inline int ff1_64(unsigned int hi, unsigned int lo) > > What on earth means ff1_64? Find the first high bit '1' of the reg :P > > + asm volatile( > > + "ff1 %0\n" > > + :"=r"(lo) > > + :"r"(lo) > > + : > > + ); > > So you want to decode the interrupt number from a bitfield. What's wrong > with ffs()? There is no wrong with ffs(). Ok, I will use the ffs(). > > + if( lo != 32 ) > > + result = 31-lo; > > Why is this subtracted? ff1 find from high bit, so we need reverse it to get the right num. > That code makes no sense w/o comments. Sorry, I will add. > > + else if( hi != 32 ) result = 31-hi + 32; > > + else { > > + printk("nc_get_irqno error hi:%x, lo:%x.\n", hi, lo); > > + result = NR_IRQS; > > + } > > Pleas use braces consistently. Ok > > +unsigned int nc_get_irqno(void) > > static? Yes > Same comments as for the other variant. Ok Best Regards Guo Ren