From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796153483; b=mgmB1eZDsEdWTJt+x5sNeUWRLTsd7t84ZhsoEmNbrdPRO71vi3dqOc6m/Fo0ntxv/xB6 6zZQd+ZldGW/N72ktw50ccQDfCYXwnQMhazfbRNgqmqufJsGSzpQ7wELy6QHD+gRmpV0N qaHkHKDcbAbX0o8LujbO0u+GcZvq9skzeeIHLzMMGVMsC8J43FG88yw9M2/Ccx+qMyNGs Kk1/W4dytQnWlmVEsuS+uFUdIz1wGzSWdfUL+3ZiIigg8a3yLzKzfjQTqiv3kN2QLaMoN m7KJRs+iVySll+X2UuPLZMKlYvuEPSokAbUS5muAItBKjytNhEl0SAfRvjYSmsOf+SA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796153483; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:MIME-Version:Content-Type; bh=6AqyL6YcVR+GvSYKEs8FRKJ1BmPp6qtaedpKQJyVRbA=; b=5hapm9htOIGKcQg3zn8rWAe0G6QP8uXaCBMUxZFgbcK7w/8kecdcKpLHEwtm6Wvesw06 v2RmCKcNrEcuRBnJxpLUe25boLASDALiH6rO2ZbWE8iosBxzvCWJF3E56Fjorlu8EDQHB amTgYe7dJAgRXvQMJCky/raTJd61p1mGIUlU42LpJq370TTpmUwH9IZBVtWUIJD0S+ab+ 8oiArc1FYNxqnTcJclzQw7a5gcAPWNVIeZY7l+Pb4ZHi2O6LreNWVdbBqaHBTokemJ+BO yYZGgLwH+QM85KIVRYUscaH2Op+eVs70hOFAMjK6hnWE8SU/Dq1DOkBxQjw0cMaoQCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXlxtE4Z; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE0C1606A31A; Tue, 1 Dec 2026 19:31:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XXlxtE4Z Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF6C81F000C1; Tue, 1 Dec 2026 19:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796153482; bh=6AqyL6YcVR+GvSYKEs8FRKJ1BmPp6qtaedpKQJyVRbA=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=XXlxtE4ZOxHVxLgKxEKeOPpcMMiTmZL2d4Si1EVIW6iyb/1c3YvKaFbBZx8hSLXio PlIPh229v6F17frJYwyzS05jmTU5kg7/n5KjqxF+RGYSsr3DV33DU6sdORl9con7vm fDgFTqq3pEBjh1uPqJnhYbvZb+Aywygmp4jhxVZ8RJAlCSZn8Dd2QgHkMx754LMSpc 3W0aD/2KS4shFTAgz0k8S9MDLvcg2gajLSbKpiIdKjhTy5/JwSSJHZRe38ZBZKrlHV I31cy2YOcY4IwqeEAjydUkm5r6l3SP3y0voAVDNfsk5rs1RjgLcP5NjxciVrRpo1Mu nViY2vybz3zYA== From: Thomas Gleixner To: Charles Perry , Radu Rendec , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Romain Caritey , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Charles Perry Subject: Re: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller In-Reply-To: <20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-2-e87ed786dc1b@microchip.com> References: <20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-0-e87ed786dc1b@microchip.com> <20261201-linux-7-4-rc4-pic64hpsc-nvm-intc-v1-2-e87ed786dc1b@microchip.com> Date: Tue, 01 Dec 2026 20:31:19 +0100 Message-ID: <874icwpzlk.ffs@fw13> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain On Tue, Dec 01 2026 at 11:06, Charles Perry wrote: > +struct p64h_nvm_intc { > + struct device *dev; > + void __iomem *base; > + struct irq_domain *domain; > + raw_spinlock_t lock; Tabular formatting please: https://docs.kernel.org/process/maintainer-tip.html > +}; > + > +static inline bool p64h_nvm_intc_hwirq_is_valid(irq_hw_number_t hwirq) > +{ > + return hwirq < P64H_NVM_INTC_NUM_IRQS; > +} > + > +static void p64h_nvm_intc_update_enable(struct p64h_nvm_intc *intc, u32 clear, > + u32 set) > +{ > + unsigned long flags; > + u32 enable; > + > + raw_spin_lock_irqsave(&intc->lock, flags); guard(raw_spinlock)(&intc->lock); irqsave is not required because this is invoked from mask/unmask() which are invoked by the core code with the interrupt descriptor lock held and interrupts disabled. > + enable = readl(intc->base + P64H_NVM_INTC_ENABLE); > + enable &= ~clear; > + enable |= set; As you hold the lock, you can cache the enabled state in @intc and spare the read back. > + writel(enable, intc->base + P64H_NVM_INTC_ENABLE); > + > + raw_spin_unlock_irqrestore(&intc->lock, flags); > +} > +static void p64h_nvm_intc_irq_print_chip(struct irq_data *d, struct seq_file *p) > +{ > + struct p64h_nvm_intc *intc = irq_data_get_irq_chip_data(d); > + > + seq_printf(p, "nvm-intc-%s", dev_name(intc->dev)); What's the value of this print function? Why is a constant name for the interrupt chip not sufficient? > +} > + > +static const struct irq_chip p64h_nvm_intc_irq_chip = { > + .irq_print_chip = p64h_nvm_intc_irq_print_chip, > + .irq_ack = p64h_nvm_intc_irq_ack, > + .irq_disable = p64h_nvm_intc_irq_mask, Why do you need a disable callback, which just points at mask()? The core uses the mask() callback if there is no disable callback provided. > + .irq_mask = p64h_nvm_intc_irq_mask, > + .irq_unmask = p64h_nvm_intc_irq_unmask, > + .irq_set_type = p64h_nvm_intc_irq_set_type, Formatting > +}; > + > +static int p64h_nvm_intc_domain_map(struct irq_domain *domain, > + unsigned int virq, irq_hw_number_t hwirq) > +{ > + if (!p64h_nvm_intc_hwirq_is_valid(hwirq)) > + return -EINVAL; > + > + irq_set_chip_data(virq, domain->host_data); > + irq_set_chip_and_handler(virq, &p64h_nvm_intc_irq_chip, > + handle_level_irq); No line break required. You have 100 characters. (all over the place) > + irq_set_noprobe(virq); > + > + return 0; > +} > +static irqreturn_t p64h_nvm_intc_handler(int irq, void *data) > +{ > + struct p64h_nvm_intc *intc = data; > + unsigned long pending; > + unsigned int hwirq; > + > + pending = readl(intc->base + P64H_NVM_INTC_STATUS) & > + readl(intc->base + P64H_NVM_INTC_ENABLE) & I you cache the enabled bits, then you can spare the readout. No locking required as this demux handler and the mask/unmask operations of the individual interrupts are not serializable. Just use WRITE_ONCE() to update the cached bits under the lock and use READ_ONCE() here. The effect is the same as with reading the hardware. It reads either the old or the new value. > + P64H_NVM_INTC_VALID_MASK; > + > + if (!pending) > + return IRQ_NONE; > + > + /* > + * STATUS may hold a stale edge, already handled while masked. That's confusing at best. How is a level controller having an edge and how is it handled while masked? > + * Clear it, then dispatch only the sources whose line is still high. > + */ > + writel(pending, intc->base + P64H_NVM_INTC_STATUS); What happens in the case that there is only BIT(N) pending in STATUS and that bit is not set in ENABLED? The above !pending check will return. But the stale status bit is still there. Does that cause the demux handler to be invoked again? If so, you need to fix it. If not, please add a comment so people/tools who don't have the hardware documentation handy won't ask the same question. > + writel(0, intc->base + P64H_NVM_INTC_ENABLE); > + writel(P64H_NVM_INTC_VALID_MASK, intc->base + P64H_NVM_INTC_STATUS); > + > + intc->domain = irq_domain_create_linear(dev_fwnode(dev), > + P64H_NVM_INTC_NUM_IRQS, > + &p64h_nvm_intc_domain_ops, > + intc); devm_irq_domain_create_linear() > + if (!intc->domain) > + return dev_err_probe(dev, -ENOMEM, > + "failed to create IRQ domain\n"); Either remove the line break or you need to have curly brackets there. See documentation. Thanks, tglx