Received: by 10.223.164.202 with SMTP id h10csp4507105wrb; Wed, 29 Nov 2017 07:25:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMZvTgnJuzQ0iWWkuJWHM/Pbhxa2YgMWmoijxXpKUOothQdOucgv+O6DEVMoCKh7x0t8wOO9 X-Received: by 10.101.100.24 with SMTP id a24mr3189225pgv.239.1511969145092; Wed, 29 Nov 2017 07:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511969145; cv=none; d=google.com; s=arc-20160816; b=XhYy+ec+Kb7oIQmPUHPgP5EVUvg4aUrXjuqfvGuzXZrOKtSOquOhy29xcEI50Rnku5 h4wENsI+wUU0DOu6tjk1L8SwQhiBIn/SW2NFxkiQK04q3TU0Hvg1RIwd2tPRBGpbDiT5 vAfKBXl7C9wqPD0P8KMtMy1o2h5OZUDIx4TptzysIoK0+KfSpqpTEp8ndiNO8V/n8+U/ OI/V0sM1Z3d/9n/kVfTBWr5cxYRCPtcM92wxFUv/UNLQY9pTRSZats5aL7Q+wo5bm4z+ bhgXv5ngpbhyW1bBSuDjdzxEgmKKMvyasXgoE3OHfswetNZbjC9jCV0oIUwTHcBCdDo/ pFPA== 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=CVlbRxbNJhh5x4BlU5tI/sAU2PMqKzzNl/ST2sIpePw=; b=LuPlMs9Ko8dagu22H/3w0VJfqiMWOblEcHmEg3Gmv9s8xgGg2un8aUZ8fzLSU35ghL s/PYbkZOrYEEzbaa0UvNg0WiYP+TGZh8Nbh7Qt/7X0sBVwcNsbxKnk5fwhGK8lMyPzDj IahkrupiFQ9thq97dIpJdl4svWIIFJdJcJ1Hp6boKAiaC0jGEEbSjRR9zD0P+2YDR/wu U2DEgdD5AQdhzCxknEfKjSapvxiijm6LIz+scXof1d24TRQ6DCCjbu4Hyed1cqkF5QZP XeGNwrkqpjl4zR44y8DwBDC9FNdQLSaIEE4exFSlQxv2ZRiBB+DRc5trbaez+Cyx7M7D Nf5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VOd1slUO; 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 s59si1431762plb.276.2017.11.29.07.25.34; Wed, 29 Nov 2017 07:25:45 -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=VOd1slUO; 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 S932971AbdK2PYS (ORCPT + 69 others); Wed, 29 Nov 2017 10:24:18 -0500 Received: from mail-vk0-f67.google.com ([209.85.213.67]:42421 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932079AbdK2PYP (ORCPT ); Wed, 29 Nov 2017 10:24:15 -0500 Received: by mail-vk0-f67.google.com with SMTP id o70so1416464vkc.9; Wed, 29 Nov 2017 07:24:15 -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=CVlbRxbNJhh5x4BlU5tI/sAU2PMqKzzNl/ST2sIpePw=; b=VOd1slUOVcP8F7SvUfKuXhoVn8iEGiLTOa6860uMCWh+py6ilwDE55jyqJjkc3VzFb FBXYHYCXdqbOl+knDsVnmiIWKi55aXV6+lneHo4lKLaLf916gLl51FgnezrGI8etCbrH 4i6QmRGwD4PxhGgjZuN4s3NMqPby2P7mwL1aVrRO9PcvFPvSS+pjjMRv6EJXy6r0urbO Dz04voWhraN6r+vvuC7t4h+6NNzXrj8U2RdOGVYEa+w9mambB2Wdzk80vnjRnk8FvGLg FTi4W5rgwXQFgq60DA0lPCjgerFmXCKrf8RYsrwzo2YfdNblZqK+zcYjQEIFAD80z5VQ pINg== 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=CVlbRxbNJhh5x4BlU5tI/sAU2PMqKzzNl/ST2sIpePw=; b=NEneKNEiSxeCTK+Ad4ECO9Z+AoaxSMfNb6C+30AFNGoEVgXey6fF0mNQeXXs4sh/lp B+wt/6RHXOQeWJn9wZXgtrU3ckaRjmxtE2jY1J7t4FTna8hEzXCJxrVUEgW1l0w/5s/y gMEltAUACbYOFEcAjf9Jbxdybglncv985uSfWm2T5Hsp9C80VrCrGzR3Td4Pgt/hNyhp yQeNTZwAr81W0g0G04QzKSHQCYk9G0mNs2iWhBbtrAUNV1FkY3j+7M1ejXwneNdOyf+X Hzt/hmxbU8fiWdlJTx0/YT7+NRDdhPQTWjPD8muEm37vqdk5jOokGPi8Dz0kjRKN1z8Q cnhw== X-Gm-Message-State: AJaThX4h1eLHVqhSm/3RXMQaRjWavcTwXoLe/cL2qWt0+RIzSdRt6pB6 /oVpK1uCd1g3f69mM37St+lt2z5LvfVyA94YszI= X-Received: by 10.31.136.131 with SMTP id k125mr2485601vkd.22.1511969054536; Wed, 29 Nov 2017 07:24:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.27.105 with HTTP; Wed, 29 Nov 2017 07:23:34 -0800 (PST) In-Reply-To: References: From: Greentime Hu Date: Wed, 29 Nov 2017 23:23:34 +0800 Message-ID: Subject: Re: [PATCH v2 27/35] 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 , Vincent Chen , DTML , Al Viro , David Howells , Will Deacon , Daniel Lezcano , linux-serial@vger.kernel.org, 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 Hi, Marc: 2017-11-28 17:37 GMT+08:00 Marc Zyngier : > On 27/11/17 12:28, Greentime Hu wrote: >> +static void ativic32_ack_irq(struct irq_data *data) >> +{ >> + __nds32__mtsr_dsb(1 << data->hwirq, NDS32_SR_INT_PEND2); > > Consider writing (1 << data->hwirq) as BIT(data->hwirq). Thanks for this suggestion. I will modify it in the next version patch. >> +} >> + >> +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); > > Same here. Thanks for this suggestion. I will modify it in the next version patch. >> +} >> + >> +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); > > This is effectively MASK+ACK, so you're better off just writing it as > such. And since there is no advantage in your implementation in having > MASK_ACK over MASK+ACK, I suggest you remove this function completely, > and rely on the core code which will call them in sequence. I think mask_ack is still better than mask + ack because we don't need to do two function call. We can save a prologue and a epilogue. It will benefit interrupt latency. >> + >> +} >> + >> +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); > > Same BIT() here. > Thanks for this suggestion. I will modify it in the next version patch. >> +} >> + >> +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, >> +}; >> + >> +static unsigned int __initdata nivic_map[6] = { 6, 2, 10, 16, 24, 32 }; >> + >> +static struct irq_domain *root_domain; >> +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)) > > And here. > Thanks for this suggestion. I will modify it in the next version patch. >> + irq_set_chip_and_handler(virq, &ativic32_chip, handle_edge_irq); >> + else >> + irq_set_chip_and_handler(virq, &ativic32_chip, handle_level_irq); > > Since you do not express the trigger in DT, you need to tell the core > about it by calling irqd_set_trigger_type() with the right setting. > Since the comments say so, I will add ativic32_set_type() for irq_set_type() in the next version patch. /* * Must only be called inside irq_chip.irq_set_type() functions. */ static inline void irqd_set_trigger_type(struct irq_data *d, u32 type) { __irqd_to_state(d) &= ~IRQD_TRIGGER_MASK; __irqd_to_state(d) |= type & IRQD_TRIGGER_MASK; } It will be like this. static int ativic32_set_type(struct irq_data *data, unsigned int flow_type) { irqd_set_trigger_type(data, flow_type); return IRQ_SET_MASK_OK; } >> + >> + return 0; >> +} >> + >> +static struct irq_domain_ops ativic32_ops = { >> + .map = ativic32_irq_domain_map, >> + .xlate = irq_domain_xlate_onecell >> +}; >> + >> +static int get_intr_src(void) > > I'm not sure "int" is the best return type here. I suspect something > unsigned would be preferable, or even the irq_hw_number_t type. Thanks for this suggestion. I will modify it in the next version patch. >> +{ >> + return ((__nds32__mfsr(NDS32_SR_ITYPE)&ITYPE_mskVECTOR) >> ITYPE_offVECTOR) > > Spaces around '&'. > Thanks for this suggestion. I will modify it in the next version patch. >> + - NDS32_VECTOR_offINTERRUPT; >> +} >> + >> +asmlinkage void asm_do_IRQ(struct pt_regs *regs) >> +{ >> + int hwirq = get_intr_src(); > > irq_hw_number_t. > Thanks for this suggestion. I will modify it in the next version patch. >> + handle_domain_irq(root_domain, hwirq, regs); >> +} >> + >> +int __init ativic32_init_irq(struct device_node *node, struct device_node *parent) >> +{ >> + unsigned long int_vec_base, nivic; >> + >> + 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 atcivic32 for this cpu.\n"); >> + >> + nivic = (int_vec_base & IVB_mskNIVIC) >> IVB_offNIVIC; >> + if (nivic >= (sizeof nivic_map / sizeof nivic_map[0])) > > This should be: > if (nivic >= ARRAY_SIZE(NIVIC_MAP)) > Thanks for this suggestion. I will modify it in the next version patch. >> + panic("The number of input for ativic32 is not supported.\n"); >> + >> + nivic = nivic_map[nivic]; > > I'd rather you use another variable (nr_ints?). > Thanks for this suggestion. I will modify it in the next version patch. >> + >> + 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); >> + >> + return 0; >> +} >> +IRQCHIP_DECLARE(ativic32, "andestech,ativic32", ativic32_init_irq); >> > > Thanks, > > M. > -- > Jazz is not dead. It just smells funny... From 1585302206202379201@xxx Tue Nov 28 09:39:57 +0000 2017 X-GM-THRID: 1585224257694371668 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread