From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796250049; b=zksc5pimCAjM4X7iQlIXXL5Ag8155FOqxFo0JksW4EdO4AVTR96a8AMB8IeA+6T03RL1 M4c0yzOpV66kY+CyxLs9+AG2ha265v7WBb9iODlQ8QpOfndKLRIwkASPZWibYW2wFbRwf TeKltGrvX/HU5x2FNzhXCg+mIca5ByEDVc6vnPNg0NUvDxZsDcappQV/43HfTi/DwCUvQ ZjQELpcyD81Gwdd/R6er/KWPZbMmNAnX/sUKmWkTusdaFw0tbgoWrnaAe067N/2HesjXS VvH1xsZRj+RbU7mjHHOARdrnxevoWcFwlw5iFQacLgK6Ywd2YO/Q6CKzKhHr7iy4c8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796250049; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:Date:From:To:CC: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=SjTbBSIhHFklTswxwSuV+9K+zAS2T1whUMZDcqNk0y4=; b=JE+Clx25B2sg9iDihSI7BGHu0zVY8B38e+8BMd+xCxuCz9Xgk8HlLGuyiCpZn51kqzbn GuDA+k2ZRGI+fx/htZtO2sw9UUR81DUMki90yRDgEzRUce2NfajfFQzsFAL4lBKq/ut54 FjE6Kj2Y1MeiMto0RstWD0raofCBh4HDUOAosVWaoKprbDeEyec805/6Ab+lVok1dW/Xo s4UlPP9IQf4XAh6dI4h9kom6pA015v6mAr7w4kLhXFvpm6aOmoFfRxu1k8cJhQRP1JG2i 7hmpHnTt54iqvBLX8ZiDeURd/2biS2jXQif3nbZgW/CXLJMY2gjP3ej0E1PkqtHNOBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=AFCVDpvn; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B720606A322; Wed, 2 Dec 2026 22:20:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7B720606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=AFCVDpvn DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796250057; x=1827786057; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=IbLEUe/gbamFWm+KNopSAcPJJeKLRoLnJtJMtaVNtWI=; b=AFCVDpvnSFS0Ms4hgFGd4RurhTD9OFPxyIbHJKkGrG+OJ7u6c7Ig+AH3 IkogcvIeUCoph3KGt/NW/NEUTFppJfcZrU07kloDRG2KSTPxvfFk0TGzX eRt53UFUko2hPc7HM2b9cLVb5Q/NyPALC4UBQn/+ThJWJrIT6sLXoqh+K e7GhNXLUgZJUqmvHgrRfhFCK9WD5qB0YupgttKGKHjEjj0ce1NMCffe3i BCGQg8jF4Tz6dalYU8el6bz7Q75qP4gUgNYi/M/poGb/u1bZalojd0iwE PGH2mTrUS4iNwdSJDPvsJLIr811/1FGV3B4aI4/Nfppv9jLnrJytjX9lX g==; X-CSE-ConnectionGUID: WJChmaAzTQuuvn1N6raXBQ== X-CSE-MsgGUID: yptW0JJGSGSIM0p48PHLYg== X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="67376511" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 15:20:51 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex4.mchp-main.com (10.10.87.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Wed, 2 Dec 2026 15:20:41 -0700 Received: from MON-LT-C78453.mchp-main.com (10.10.85.11) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58 via Frontend Transport; Wed, 2 Dec 2026 15:20:39 -0700 Date: Wed, 2 Dec 2026 17:20:37 -0500 From: Charles Perry To: Thomas Gleixner CC: Charles Perry , Radu Rendec , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Romain Caritey , , Subject: Re: [PATCH 2/2] irqchip: Add Microchip PIC64-HPSC/HX NVM interrupt controller Message-ID: 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> <874icwpzlk.ffs@fw13> X-Mailing-List: linux-kernel@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; charset="us-ascii" Content-Disposition: inline In-Reply-To: <874icwpzlk.ffs@fw13> On Tue, Dec 01, 2026 at 08:31:19PM +0100, Thomas Gleixner wrote: > 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 > Ok. > > +}; > > + > > +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. Ok, thank you for that info. > > > + 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. Ok, good idea. > > > + 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? There's either 2 or 4 of those interrupt controllers in our SoC so it allows to identify more easily the irq domain in /proc/interrupts by adding the dev_name() that is unique per nvm-intc. > > > +} > > + > > +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. No reason, I didn't knew about this. I'll remove it. > > > + .irq_mask = p64h_nvm_intc_irq_mask, > > + .irq_unmask = p64h_nvm_intc_irq_unmask, > > + .irq_set_type = p64h_nvm_intc_irq_set_type, > > Formatting Ok. > > > +}; > > + > > +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) Ok, sorry I'm used to netdev which prefer 80. Will change. > > > + 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. Ok, will do. > > > + 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? This comment makes no sense, I'll remove it. > > > + * 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? That happens only with PREEMPT_RT. > > The above !pending check will return. But the stale status bit is still > there. Does that cause the demux handler to be invoked again? Yes, if the STATUS bit is not cleared, the handler will re-run until something clears it. > > 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. Ok, the issue I'm trying to solve with all these register reads and masking is that when doing xSPI+SD with PREEMPT_RT, I have some spurious interrupts in the SD irq. Its possible that there is a PREEMPT_RT issue within the SD driver. I'm now realizing that my handler can return IRQ_HANDLED while not handling anything if the VALUE read mask some of the pending bits. This needs to be fixed too. > > > + 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() Ok, this looks very new. Thanks. > > > + 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. Ok. > > Thanks, > > tglx -- Thanks, Charles