Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1905006imm; Thu, 2 Aug 2018 03:05:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdO4YeMCDNuBLxpzVq0jLmJ/ndfZ/5DzLCUn3LM9Iu9pX81hE+I//+9XDJrwEx/CbAwSx/O X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr2091128pgd.372.1533204316998; Thu, 02 Aug 2018 03:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533204316; cv=none; d=google.com; s=arc-20160816; b=oYwX2Hw3zrCyinG2up6fz0Jknsw9jBR771QkMMJDsOlcSUvoLZQ2AN9HyRDNN4DHrS ehxv9+HBVAzA3MEj6PFhNUcoYjCyd3oz3WmHMv52T3bzPssUO1Zibm5ukb767byJqL4+ VY0RxW/ofp6+k/zJBdQJFdgIFanwsFwi/CRqiMpiy7wy0cadunEmAyO7S3cqfmAFS5sY sR3VXojyYnyVXe2nbr05aSVQtB4rcKR1ZnTjMd2ksOq2NjDHdj+QA8HniI8iKPdpsLwR B/B19rzV6uEX+24EexDre0JyQjwJmR330hDmFSqLn4sNdbSc6F7C/6Brt4sHeOOtgEYO RMKg== 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=FAI9UR3BRYWjDbwiWR/Oz0S9unz80KHc5jQEKqrpcyw=; b=H7KbBhngkYGctrIyo23m7iI5KrPgL5EqJtg9skc+T6QnckqH83es3qpIfA7mA7UJs9 63f87EnOH8W/gSXaP4wr6j2XtiAh0gkCRdj+b7PNvACP9+cjHi0SX6K5O3IeHjpNRW6/ VkyZL2FWzOFaxBGijbR5E52qK92wwMV2GnZQUpxV7JxlQJMm8mwL5w4JVydKHVAGutoH NdCDFeZSZYeZQgpMWLyvGB+uethuU8+Af+CMjWEqbNzw0Mb4Cr1OydHcq4hGSyB/wueP z1WrBNiTPG1/KNASDayXjNBOh38Sx5maeocsehOOgL2azpgH8LnDc8Je9dijn+Emdr8O zjng== 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 t8-v6si1143473plo.319.2018.08.02.03.05.02; Thu, 02 Aug 2018 03:05:16 -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 S1731895AbeHBLyk (ORCPT + 99 others); Thu, 2 Aug 2018 07:54:40 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:36299 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbeHBLyk (ORCPT ); Thu, 2 Aug 2018 07:54:40 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1flASi-0003G4-Ff; Thu, 02 Aug 2018 12:04:04 +0200 Date: Thu, 2 Aug 2018 12:04:04 +0200 (CEST) From: Thomas Gleixner To: Christoph Hellwig cc: palmer@sifive.com, jason@lakedaemon.net, marc.zyngier@arm.com, robh+dt@kernel.org, mark.rutland@arm.com, anup@brainfault.org, atish.patra@wdc.com, devicetree@vger.kernel.org, aou@eecs.berkeley.edu, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, shorne@gmail.com Subject: Re: [PATCH 7/9] irqchip: add a RISC-V PLIC driver In-Reply-To: <20180726143723.16585-8-hch@lst.de> Message-ID: References: <20180726143723.16585-1-hch@lst.de> <20180726143723.16585-8-hch@lst.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Jul 2018, Christoph Hellwig wrote: > This patch adds a driver for the Platform Level Interrupt Controller (PLIC) See Documentation/process/submitting-patches.rst and search for 'This patch' > +static inline void __iomem *plic_hart_offset(int ctxid) > +{ > + return plic_regs + CONTEXT_BASE + ctxid * CONTEXT_PER_HART; > +} > + > +/* > + * Protect mask operations on the registers given that we can't assume that > + * atomic memory operations work on them. > + */ > +static DEFINE_SPINLOCK(plic_toggle_lock); RAW_SPINLOCK please. > + > +static inline void plic_toggle(int ctxid, int hwirq, int enable) > +{ > + u32 __iomem *reg = plic_regs + ENABLE_BASE + ctxid * ENABLE_PER_HART; > + u32 hwirq_mask = 1 << (hwirq % 32); > + > + spin_lock(&plic_toggle_lock); > + if (enable) > + writel(readl(reg) | hwirq_mask, reg); > + else > + writel(readl(reg) & ~hwirq_mask, reg); > + spin_unlock(&plic_toggle_lock); > +} > + > +static inline void plic_irq_toggle(struct irq_data *d, int enable) > +{ > + int cpu; > + > + writel(enable, plic_regs + PRIORITY_BASE + d->hwirq * PRIORITY_PER_ID); > + for_each_present_cpu(cpu) > + plic_toggle(cpu, d->hwirq, enable); I suggest to make that: for_each_cpu(cpu, irq_data_get_affinity_mask(d)) plic_toggle(cpu, d->hwirq, enable); That gives you immediately support for interrupt affinity. And then it's trivial to do the actual irq_chip::irq_set_affinity() magic as well. > +/* > + * Handling an interrupt is a two-step process: first you claim the interrupt > + * by reading the claim register, then you complete the interrupt by writing > + * that source ID back to the same claim register. This automatically enables > + * and disables the interrupt, so there's nothing else to do. > + */ > +static void plic_handle_irq(struct pt_regs *regs) > +{ > + void __iomem *claim = > + plic_hart_offset(smp_processor_id()) + CONTEXT_CLAIM; Either ignore the 80 char thing or just move the assignment into the code section please. That line break is horrible to read. > + irq_hw_number_t hwirq; > + Other than that this looks halfways sane. Thanks, tglx