From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.154.123 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796425124; b=POdai3q3pgfh7PGCsh+qRqtX46tfyE5oR0fEKPQAUSuuMK/HAYQ5v7X43JvueNRThySD 1U22VSB/e7r2UnokNM0JZs2hEo40QifxaaxsDRgRG9GOF9f/WUqfBBOqsgo9PxjLCepIN GfBI/ZXqunGaW2fIQRsZn8rd92ydBOAQ2va6WnWhxR/QrC/GHTpcJcLeTdsGSMUjVQs77 FbPj8D892hxhoIJghnRTOtGXfM4eKn+9QTzG/DGAeqCSXM1Sf6A+xPaAoof+kt20WUYYj L4+yiWHT/ZaOLzKBjTmP4Wp15GijLYbk0Zmu4faeEUzeYunUnj253FF6Ft2AQUgIH+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796425124; 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=o7RlS5CCHIvAM/mE8h6SWVXE1/8Mljz6a5MfguKAxZc=; b=U+3/Q1+7wZD+ytwxALQRBoMhl27DM+EOMw21wgwKAXx6F9CsLW3ltOc+Uzyw+xJtoifK Jc0vqzgnz/jJZx/t1y53pydVrwKS40eZ5v80lHhAJD2E/Q88qyy/e9KtguF5/z4ulzfLF 3xTzPebNA1Sak3FgqMR4FlqNho6T+D+CweFRHP5gjUsQEXjwFTxIflSq1dxM/upHznBDj MVWcE0yB7LFVmiQsXQbysGJmgkjBvPrWnwsGxcISAYtFZha3geDM/Oda5rGKTcFpe5zmj 2cycjgZjxbjizTfwuOrzzDJE0J2JgCSBU7cZjwo/pmJnOD47yyugMqnNY6xVb3OsKpA== 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=RayfPb9H; arc=none smtp.remote-ip=68.232.154.123 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 71531606A322; Fri, 4 Dec 2026 22:58:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 71531606A322 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=RayfPb9H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796425123; x=1827961123; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ETgy/17guFV5IPlodMP+kUplNTa6gmnk6wHP4C9eQdU=; b=RayfPb9Hc0Db+JCpy52IXEXDA7rfp+qboZ/ayfqtTRY9+BaXbPLM5V39 26Je6r4jMUdgGHpwQCMjqMk/WS8u6PhVmHU//2gtVsZVLTftUaLUbntQL rGoz2ftRO8b9/gcxjmQpcovKDK+5SO866b88dhkj7t3hev+w2KS9+9nJW LrGlm/ETFW7X4jxUwmvIePgv/BZTjP2JUYOvhJDxfjgq84x1zJxSn9p3n 1mcZkclvP5q0IKASdpe+T5Nc8ggSSdr54GDzioQgPt7Bk9UlpELt4MXqo +ckb1hUO3lgwYnWw/mTa4d2w3ifprDfzA2vQ11a4qPqMImspoEKjKGlUj w==; X-CSE-ConnectionGUID: d7QH5hWARrq2pbRQ3JH9NA== X-CSE-MsgGUID: tepqmZ2PR9y3ROnBgjTuow== X-IronPort-AV: E=Sophos;i="6.29,79,1794898800"; d="scan'208";a="234506068" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 04 Dec 2026 15:58:42 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Fri, 4 Dec 2026 15:58:42 -0700 Received: from MON-LT-C78453.mchp-main.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58 via Frontend Transport; Fri, 4 Dec 2026 15:58:40 -0700 Date: Fri, 4 Dec 2026 17:58:38 -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> <87ecbyodnb.ffs@fw13> <87wlppmhz7.ffs@fw13> <87a4mkn5jl.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; charset="us-ascii" Content-Disposition: inline In-Reply-To: <87a4mkn5jl.ffs@fw13> On Fri, Dec 04, 2026 at 09:40:14PM +0100, Thomas Gleixner wrote: > On Fri, Dec 04 2026 at 10:54, Charles Perry wrote: > > On Fri, Dec 04, 2026 at 11:57:00AM +0100, Thomas Gleixner wrote: > >> So this sequence: > >> > >> pending = read(STATUS) & read(ENABLE); > >> > >> write(pending, STATUS); > >> > >> pending &= read(STATUS); > > > > This read() was on VALUE, see my diagram below. > >> > >> does not make sense for a sanely designed level type controller which > >> usually does: > >> > >> STATUS = LINESTATE & ENABLED > >> > >> and if it has multiple input lines then the output is simply: > >> > >> OUTLINE = STATUS(0) | STATUS(1) .... | STATUS(N) > >> > >> From your code and comments it seems STATUS is latched which does not > >> make sense. > > > > We have 3 registers, VALUE, STATUS and ENABLE. VALUE is the live output of > > the device, STATUS reflects a latched value of each input and ENABLE > > controls which output gets muxed: > > > > +----------------------------------------+ > > | nvm-intc | > > | | > > | | > > +--------+ VALUE[0] +------+ STATUS[0] +---+ +---+ | > > | Device |----|------>| Edge |---------->| | | | | > > | | | | | | | | | | > > +--------+ | +------+ |AND| | | | > > | | |-->| | | +--------+ > > | | | | | | | APLIC | > > | ENABLE[0]--->| | | | | | | > > | +---+ | | | | | > > | | |----->| | > > +--------+ VALUE[1] +------+ STATUS[1] +---+ |OR | | | | > > | Device |----------->| Edge |---------->| | | | | | | > > | | | | | | | | | | | | > > +--------+ | +------+ |AND|-->| | | +--------+ > > | | | | | | > > | | | | | | > > | ENABLE[1]--->| | | | | > > | +---+ | | | > > | | | | > > | ... | | | > > +----------------------------------+---+-+ > > > > Is it a problem that ENABLE doesn't prevent VALUE from latching STATUS? > > Not if you mask it out with the enabled bits. But ... > > >> But even then it does not explain how the status bit stays raised with > >> the mask_ack() sequence of the level handler. > > > > Because ENABLE acts on the output, it doesn't prevent VALUE from latching > > STATUS. So if another interrupt happens while calling the device handler > > STATUS will be high, even though ENABLE is 0. > > .. you say the input is latched into status on a raising edge, right? Yes, VALUE needs to make a 0-1 transition for STATUS to latch. If you clear STATUS while VALUE is 1 you will miss interrupts. > > Which means the input logic is edge type. The output is level type. > > But you claim the input is level type too. That doesn't make any sense. I was under the impression that it's the device (and not the interrupt controller) that decides if an interrupt is level or edge but maybe I'm wrong. > > A strict level type interrupt source in a device is not required to have > a 1-0-1 transition. The interrupt line can stay asserted even when the > first interrupt is handled by the device driver. A typical scenario is > that in the device there is a interrupt status register. So the > following can happen: > > Device dev-irq > IS == 0 0 > IS == 1 1 > interrupt > mask_ack() > handler() > // Reads 1 > pending = read(IS); > IS == 3 > // Clears bit(0) > IS == 2 handle(pending) > return; > unmask(); If this happens on an input of nvm-intc, then VALUE=1 and STATUS=0. The way we would handle this with nvm-intc is to check VALUE after unmask() and call the interrupt handler again if it is raised. That's not done in the patch I sent because I never encountered the issue. > > That's legit from a device driver POV if the device interrupt is > strictly level type output because the driver can rely on the interrupt > being re-raised in the CPU after the unmask. > > If your input logic latches on a rising edge, then this case is not > re-raising the interrupt because the mask_ack() clears the status bit > and if there is no 1-0-1 transition on the input line, then the > interrupt line becomes stale. Yes, that is correct. Pretty much all of the IP designed in-house for PIC64-HPSC/HX use the same VALUE, STATUS and ENABLE circuitry. > > So none of this adds up. > > If the interrupt is latched on a rising edge, then you need to treat it > as edge interrupt type. The underlying APLIC interrupt can still be Ok, that should work. IIUC, I should use handle_edge_irq() which ->irq_ack() but does not ->irq_mask(). In our first attempt to support this, we added the STATUS register in all of the NVM controllers (xSPI, SD, NAND) and each of these drivers would ack their interrupt bit in the STATUS register without any masking. That worked fine but is a bit of a hack because you need to map the same register in 3 different drivers. > level type because that's an independent interrupt. Yes, that one I know for sure is level. Thank you for all your detailed explanations, it helps a lot. -- Thanks, Charles