Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp674603imm; Wed, 25 Jul 2018 04:20:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfmmRuDsnaM3lN1kxt8tedj8Khaula91zOUeer89VnYzRBWCnhjcFzSMEmWD3bqsba/BeK/ X-Received: by 2002:a17:902:7683:: with SMTP id m3-v6mr20397888pll.255.1532517627699; Wed, 25 Jul 2018 04:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532517627; cv=none; d=google.com; s=arc-20160816; b=pIX1CcWXqNvrrv9L997Bgjm50jrPZXlMG9eYtJjCp4ksGRMVLi3pC0jtPbH0HQaYtk FQ0sy5u8qdrcOXJGAEVRlzJ4/oZ5KHVOVot5Y582whMVIovdwfRx1+o6fDRNrF1nW3WU j9D26v/THqPT2f4es3VLAPAYLdzD9xPzXq7frcqjo6nlKKmU9SJsBjfd81X5NIdDdsiH C+bRWOtXsIUlVWuhK346XfTbBGEF6E/brfTBQp2voH5JuisJxMsOeWR4F+QWQX28qxsG JUFcONNpvjEoOXvV/0U5YE5SzKwwxXVxEp47qZFitnp1eUbpsDaDqJJFLverx8n6dwVn 0Y+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=sMIMoP18951YVu6X+3czohprSrpjeBMN/Y4dPN5YEVg=; b=pwaPhxfQT2Anvkuty8RpKCsf1lcVwh6NC/gKiX9xCssMwcfoq42H8yuvBWbykbmJQf OKp/wZ+GytiHI1k2cLekv4m+E8etc4C61uYMxLaujboUYnSiWQXkgTwRpE8/AQkYOCm+ Ob9mhOBEHGC2SWGXhlEPrJphb+cx/wvtuHQdiFi7fdePVc3DJQK9uFQV3RQT8hSFassp gW7pJgTX2uKO5BWz8GvWURAR0wYzhtky7Xtlu2QQqwLRIf6pxevrZpMvebJzxc5W0w0t Zqw90dxhXk9y6yheHeTN3KjMighH0tcNrjewYcH6ujgfW8kj0QQ8po4hM24efx8jRyGl Q59Q== 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 m1-v6si1347391plt.264.2018.07.25.04.20.12; Wed, 25 Jul 2018 04:20:27 -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 S1728809AbeGYM35 (ORCPT + 99 others); Wed, 25 Jul 2018 08:29:57 -0400 Received: from foss.arm.com ([217.140.101.70]:36870 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbeGYM35 (ORCPT ); Wed, 25 Jul 2018 08:29:57 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7845115A2; Wed, 25 Jul 2018 04:18:44 -0700 (PDT) Received: from [10.4.13.119] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E26E3F575; Wed, 25 Jul 2018 04:18:42 -0700 (PDT) Subject: Re: [PATCH 3/6] irqchip: RISC-V Local Interrupt Controller Driver To: Christoph Hellwig , tglx@linutronix.de, palmer@sifive.com, jason@lakedaemon.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: devicetree@vger.kernel.org, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, shorne@gmail.com, Palmer Dabbelt References: <20180725093649.32332-1-hch@lst.de> <20180725093649.32332-4-hch@lst.de> From: Marc Zyngier Organization: ARM Ltd Message-ID: Date: Wed, 25 Jul 2018 12:18:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180725093649.32332-4-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/07/18 10:36, Christoph Hellwig wrote: > From: Palmer Dabbelt > > This patch adds a driver that manages the local interrupts on each > RISC-V hart, as specifiec by the RISC-V supervisor level ISA manual. > The local interrupt controller manages software interrupts, timer > interrupts, and hardware interrupts (which are routed via the > platform level interrupt controller). Per-hart local interrupt > controllers are found on all RISC-V systems. > > Signed-off-by: Palmer Dabbelt > [hch: Kconfig simplifications, various cleanups] > Signed-off-by: Christoph Hellwig > --- > drivers/irqchip/Kconfig | 4 + > drivers/irqchip/Makefile | 1 + > drivers/irqchip/irq-riscv-intc.c | 197 +++++++++++++++++++++++++++++++ > 3 files changed, 202 insertions(+) > create mode 100644 drivers/irqchip/irq-riscv-intc.c > [...] > +/* > + * 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 << d->hwirq); > +} > + > +static void riscv_irq_unmask(struct irq_data *d) > +{ > + struct riscv_irq_data *data = irq_data_get_irq_chip_data(d); > + > + BUG_ON(smp_processor_id() != data->hart); > + csr_set(sie, 1 << d->hwirq); > +} > + > +/* Callbacks for twiddling SIE on another hart. */ > +static void riscv_irq_enable_helper(void *d) > +{ > + riscv_irq_unmask(d); > +} > + > +static void riscv_irq_disable_helper(void *d) > +{ > + riscv_irq_mask(d); > +} > + > +static void riscv_remote_ctrl(unsigned int cpu, void (*fn)(void *d), > + struct irq_data *data) > +{ > + smp_call_function_single(cpu, fn, data, true); > +} > + > +static void riscv_irq_enable(struct irq_data *d) > +{ > + struct riscv_irq_data *data = irq_data_get_irq_chip_data(d); > + > + /* > + * It's only possible to write SIE on the current hart. This jumps > + * over to the target hart if it's not the current one. It's invalid > + * to write SIE on a hart that's not currently running. > + */ > + if (data->hart == smp_processor_id()) > + riscv_irq_unmask(d); > + else if (cpu_online(data->hart)) > + riscv_remote_ctrl(data->hart, riscv_irq_enable_helper, d); This feels odd. It means that you cannot have the following sequence: local_irq_disable(); enable_irq(x); // where x is owned by a remote hart as smp_call_function_single() requires interrupts to be enabled. More fundamentally, why are you trying to make these interrupts look global while they aren't? arm/arm64 have similar restrictions with GICv2 and earlier, and treats these interrupts as per-cpu. Given that the drivers that deal with drivers connected to the per-hart irqchip are themselves likely to be aware of the per-cpu aspect, it would make sense to align things (we've been through that same discussion about the clocksource driver a few weeks back). Thanks, M. -- Jazz is not dead. It just smells funny...