Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1757450imm; Sat, 23 Jun 2018 01:58:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINAAgcvt93uyemzGTmXCrYT9KASUPuESPbLYMsaPsf+k+5DLbZvJcLqNeXeEqSSnB42jPg X-Received: by 2002:a17:902:b604:: with SMTP id b4-v6mr4794287pls.18.1529744290032; Sat, 23 Jun 2018 01:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529744289; cv=none; d=google.com; s=arc-20160816; b=VOuxY/RXKmeJX7PYXerS8naVnqtQmCIQX/9Px0Y84lk685eAKdVFLups/EVwXezovy D3RqL8HZZ90wNyVh3jpqXq9eMr4vxKShda540TMgQbp8ov9JQi6Yc2OfkGBiQ+9/owU7 5qiAIJIMHRS58cTYnAA0t8WOCes+B5aYlgL+/vgjKe4FhXQu1WbZGptpdVYSE1WfjEr0 MH2jjO59eUNZkkoACFf/xIt24NfTX4+ETQNre8TgHhdlx3/YwpUiM84uT0OP9zc/IAhx Cb1WE7qBjURHGQFzSru3bVYvak0rUQh9612E+3JK1D7wdj5RQ9za/QVVU9MyXzarKMel C0Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=bHIC63L91ajxH9hStkVyLs+Lc+LyJ8NUlbs710FJ3iA=; b=x98QWiJDmTySok7NG2c4XsTDFlPziR/w3LE1Sz8QqfJnLCyIAie4S87BgSkgJ0rolk S2gUB0BNvofQRKL5SxVEWa7EjZa2S0/vNDo7I/djF4CrF9WQLf2rhDIfu+rmg9wl/Ea7 zKbnD+kK8UsW3J0x7/qfbGFcldYJS1iaKqh6SVI+HH+ATsVeuYfT/1S5EEd850iArO+n 4Z9yN95zwFRlh52CFEtWSRj3TEEFKp3qYfkBb4awd8T3xscyn9S1d/0EuAegEh3wWiOk HIU5gZEAKiF0nSNqTDqkPASAnXBwnedWjleReUjXX03uTWygA9ObWFDpxP73GjZfwmcI zI7A== 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 v21-v6si486955ply.146.2018.06.23.01.57.42; Sat, 23 Jun 2018 01:58:09 -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 S1751754AbeFWI4n (ORCPT + 99 others); Sat, 23 Jun 2018 04:56:43 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:43164 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751696AbeFWI4l (ORCPT ); Sat, 23 Jun 2018 04:56:41 -0400 Received: from p4fea482e.dip0.t-ipconnect.de ([79.234.72.46] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fWeLQ-0003c7-R3; Sat, 23 Jun 2018 10:56:33 +0200 Date: Sat, 23 Jun 2018 10:56:29 +0200 (CEST) From: Thomas Gleixner To: Palmer Dabbelt cc: jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com, aou@eecs.berkeley.edu, shorne@gmail.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Michael Clark Subject: Re: [PATCH 3/3] irqchip: RISC-V Local Interrupt Controller Driver In-Reply-To: <20180622232006.12158-4-palmer@sifive.com> Message-ID: References: <20180622232006.12158-1-palmer@sifive.com> <20180622232006.12158-4-palmer@sifive.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Jun 2018, Palmer Dabbelt wrote: > +struct riscv_irq_data { > + struct irq_chip chip; > + struct irq_domain *domain; > + int hart; > + char name[20]; > +}; > +DEFINE_PER_CPU(struct riscv_irq_data, riscv_irq_data); static ? > +static void riscv_intc_irq(struct pt_regs *regs) > +{ > + struct pt_regs *old_regs = set_irq_regs(regs); > + struct irq_domain *domain; > + unsigned long cause = csr_read(scause); > + > + /* > + * The high order bit of the trap cause register is always set for > + * interrupts, which allows us to differentiate them from exceptions > + * quickly. The INTERRUPT_CAUSE_* macros don't contain that bit, so we > + * need to mask it off here. > + */ > + WARN_ON((cause & (1UL << (PTR_BITS - 1))) == 0); So what's the point of continuing here? > + cause = cause & ~(1UL << (PTR_BITS - 1)); Please define a proper CAUSE_MASK or such as this is really hard to read. > +/* > + * On RISC-V systems local interrupts are masked or unmasked by writing the SIE > + * (Supervisor Interrupt Enable) CSR. As CSRs can only be written on the local > + * hart, these functions can only be called on the hart that corresponds to the > + * IRQ chip. They are only called internally to this module, so they BUG_ON if > + * this condition is violated rather than attempting to handle the error by > + * forwarding to the target hart, as that's already expected to have been done. > + */ > +static void riscv_irq_mask(struct irq_data *d) > +{ > + struct riscv_irq_data *data = irq_data_get_irq_chip_data(d); > + > + BUG_ON(smp_processor_id() != data->hart); > + csr_clear(sie, 1 << (long)d->hwirq); What's the point of this type cast? Whether you shift by unsigned long or by long does not really matter, right? I'd rather expected to see 1U << d->hwirq > +static int __init riscv_intc_init(struct device_node *node, struct device_node *parent) > +{ > + int hart; > + struct riscv_irq_data *data; Nit. Reverse fir tree ordering please struct riscv_irq_data *data; int hart; Simpler to parse. > + > + if (parent) > + return 0; Hmm, that wants a comment because it's not clear why this is done for the casual reader. > + > + hart = riscv_of_processor_hart(node->parent); > + if (hart < 0) > + return -EIO; > + > + data = &per_cpu(riscv_irq_data, hart); > + snprintf(data->name, sizeof(data->name), "riscv,cpu_intc,%d", hart); > + data->hart = hart; > + data->chip.name = data->name; > + data->chip.irq_mask = riscv_irq_mask; > + data->chip.irq_unmask = riscv_irq_unmask; > + data->chip.irq_enable = riscv_irq_enable; > + data->chip.irq_disable = riscv_irq_disable; > + data->domain = irq_domain_add_linear(node, PTR_BITS, > + &riscv_irqdomain_ops, data); > + if (!data->domain) > + goto error_add_linear; > + > + set_handle_irq(&riscv_intc_irq); > + > + pr_info("%s: %lu local interrupts mapped\n", data->name, PTR_BITS); > + return 0; > + > +error_add_linear: > + pr_warning("%s: unable to add IRQ domain\n", > + data->name); One line please. > + return -ENXIO; Thanks, tglx