Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp287609iof; Mon, 6 Jun 2022 03:34:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ91SWqX9iHEpL7O2N2/5huKqNm5gzCj3qlKFGX0zP6HP97JeOPqgGcAz/YpGp4GhzwoIR X-Received: by 2002:a65:6e88:0:b0:39d:2647:f75d with SMTP id bm8-20020a656e88000000b0039d2647f75dmr20719501pgb.523.1654511694780; Mon, 06 Jun 2022 03:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654511694; cv=none; d=google.com; s=arc-20160816; b=qh/4hujq9NUIQOBPetjvpSM2+FWqetQasiRmO86IeRzIOiZcwTKqhU+TX/sNxpN0pI w9xG7+L3OpfCn9kH5dAKdAtKWwaZ6H3VYPyCLy44yuRRV/w7y4cgjNM5p/oXBYoDuJh1 5spWsj1KVvBMpIlOxhl9xSSbcJlF9rE+1Dj3DejVOGJiWtleQxZzR7dg78Suzc+Bss+g GhUzXcFhJmAuOv3Y3Nc3I4L8s/nRRT6X3gM3ADkeePL3kYR5p/dwjBZF3Fwz32X9E1Jf mSnn9txuJF5gOeqsk2mspUlAPGuEXW+Fi4VvDvs484bRaFvICzWxLazpQ7d1PxjAWE3T ZU1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0RV+F6arkyT/aJPRBm6+IBJsF9KPkstWE0UH1z609Qo=; b=cP9p/2UzxlWg3/HqxjqEsIO9qGaTf2i0tB+6oDAvTY+/46pWd+xE4/o7tUIUWpQxhs d2yYSH/MAeYWL0EuHROXoEgjkzSfro/GRr8s51LYfKtzy6O9Ju0EgKOv6gzaSD+YrH30 vXnC0FgZ+6Ei/sfkZOAnHAI/6XnUjQUVzKw/twrudwFJu3mN9gayQuWjGP0oC0LCcsqK Jm+JrsUGTGaJvG31dIRHzX79WSbojbja+CE9xv1fhoS+Ky37UhB448glMoKc41e5Yi5s dl59HShc+WdH6zHhYpgtT6BbXByNLFMm6RiLmREB1hkLxjqyOwcSwbFxtorcLSKUl4lU doCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UDCenwDu; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id oo7-20020a17090b1c8700b001e31c6cc63asi22802187pjb.43.2022.06.06.03.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 03:34:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UDCenwDu; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5CCF810FD0; Mon, 6 Jun 2022 03:13:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233828AbiFFKMr (ORCPT + 99 others); Mon, 6 Jun 2022 06:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233718AbiFFKMf (ORCPT ); Mon, 6 Jun 2022 06:12:35 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A7781611EC for ; Mon, 6 Jun 2022 03:08:53 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id p10so19156688wrg.12 for ; Mon, 06 Jun 2022 03:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0RV+F6arkyT/aJPRBm6+IBJsF9KPkstWE0UH1z609Qo=; b=UDCenwDu62ZZ5s6UnVflatrxJRwEFWIX/ZzZ2ukt8uBk7uew6UbMwm9LJCyufH/MFM dmYEM/4Wsbx6Kp4eXUBl2U4HkP8ESFmu+jCE3Y0lpcuMGIz/5X6EQ2v7LH4Nr4JIWXMC x7oTYz6ediTp3erUqgrR+tvzGpa41h7nrKoHmdgxGHen9pSh85bJfUnmvhho/WlbJ/QY HR2DlVOk4RWh5xdOfNYdfv7TgofjFUoSSJRt2yGWbq43nQY6IerM61OjUZPEnbVYLQLW mTxV5I51BS3h/S3NgTgwVOivSYDQVWZEcs3M9c1m7IWYy4C0xKsMqwDumj5TweyEAfzI /50Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0RV+F6arkyT/aJPRBm6+IBJsF9KPkstWE0UH1z609Qo=; b=XG58nObEPCMJdbPmYfrUJx3qw5mmJIF0dbKpOCUdsCStnTFR2MPEoKGWMeiDHa+0wo h7MG0aiEKkyAk8xHCOEjlHXyvIHCeu6aRBkBlxrAT+J3SIdIdhwrpm32DttTTSdqqxfR Ah8BgTGJP68UWxpKpwB9hw++NnsPiDfrVD4g5KJaw5B7dri33VR0wxbQzOGrBm6RyCeK dsjAtJmcypNm9zz5WOfuqyliEgZIIfnEKGbO4wkdc47PnSdUcqzgX3B6tmU+9PDZCt+l wIsR/koSaiH+rT79oQDEqEfFy6dHFrkXXdU+r4I5eANdVgpm7DVJizhEdYJ8dIHJ4Bxr JIaw== X-Gm-Message-State: AOAM532b/W40d9xnGnc0Y0X6ukSk3yGaCyijElgCu7BlA3eOcoZnq+Wt HRfeNdoYFY5V2YzYeNAo+Xzneg== X-Received: by 2002:a05:6000:2ab:b0:211:7fef:7730 with SMTP id l11-20020a05600002ab00b002117fef7730mr20446387wry.533.1654510131375; Mon, 06 Jun 2022 03:08:51 -0700 (PDT) Received: from maple.lan (cpc141216-aztw34-2-0-cust174.18-1.cable.virginm.net. [80.7.220.175]) by smtp.gmail.com with ESMTPSA id q18-20020a5d61d2000000b0020d0c9c95d3sm11964896wrv.77.2022.06.06.03.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 03:08:50 -0700 (PDT) Date: Mon, 6 Jun 2022 11:08:48 +0100 From: Daniel Thompson To: richard clark Cc: Marc Zyngier , Robin Murphy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, s32@nxp.com, leoyang.li@nxp.com, catalin-dan.udma@nxp.com, bogdan.hamciuc@nxp.com, bogdan.folea@nxp.com, ciprianmarian.costea@nxp.com, radu-nicolae.pirea@nxp.com, ghennadi.procopciuc@nxp.com Subject: Re: Question about SPIs' interrupt trigger type restrictions Message-ID: <20220606100848.ir4bkj5qsskxe6in@maple.lan> References: <35f95ba3-8a7b-7918-0f9d-e14274a5ffe9@arm.com> <87ee0gn5rq.wl-maz@kernel.org> <20220530084039.7rjjbm4gkplg5747@maple.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 05, 2022 at 08:03:02PM +0800, richard clark wrote: > On Mon, May 30, 2022 at 4:40 PM Daniel Thompson > wrote: > > > > On Thu, May 26, 2022 at 08:09:32PM +0800, richard clark wrote: > > > CC'ing some nxp guys for the S32G274A SOC... > > > > > > On Thu, May 26, 2022 at 2:54 PM Marc Zyngier wrote: > > > > richard clark wrote: > > > > > On Thu, May 26, 2022 at 3:14 AM Robin Murphy wrote: > > > > > > On 2022-05-25 11:01, richard clark wrote: > > > > From the GIC500 r1p1 TRM, page 2-8: > > > > > > > > > > > > SPIs are generated either by wire inputs or by writes to the AXI4 > > > > slave programming interface. The GIC-500 can support up to 960 SPIs > > > > corresponding to the external spi[991:32] signal. The number of SPIs > > > > available depends on the implemented configuration. The permitted > > > > values are 32-960, in steps of 32. The first SPI has an ID number of > > > > 32. You can configure whether each SPI is triggered on a rising edge > > > > or is active-HIGH level-sensitive. > > > > > > > > > > > > So I have no idea what you are talking about, but you definitely have > > > > the wrong end of the stick. Both the architecture and the > > > > implementations are aligned with what the GIC drivers do. > > > > > > What I am talking about is - The SPI is triggered on a rising edge > > > only, while the falling edge is not as the document says. But I've > > > observed the falling edge does trigger the SPI interrupt on my > > > platform (the SOC is NXP S32G274A, an external wakeup signal with high > > > to low transition to wake up the SOC - 'Wakeup/Interrupt Rising-Edge > > > Event Enable Register (WIREER)' and 'Wakeup/Interrupt Falling-Edge > > > Event Enable Register (WIFEER)', WIFEER set 1 and WIREER set 0 > > > works). > > > > > > I don't know why the GIC has such a behavior and what the subtle > > > rationale is behind this, so just mark this as a record... > > > > Are you really describing the GIC behaviour here? It sounds like you are > > describing the behaviour of the Wakeup Unit. > > Definitely it's behavior of GIC, not WKPU's I don't understand what evidence you are basing this on. Everything you say below contradicts this assertion. > > The SPI that goes to the GIC is the *output* of the WKPU. However the > > registers you mention above all control edge detection at the input to > > the WKPU. If so, the kernel would need an WKPU irqchip driver in order > > to manage the trigger mode registers above (and to clear them). > > external wakeup signal has a transition from High to Low to the SOC, > then output of WIREER (rising detect) or WIFEER(falling detect) to > generate INTID to the GIC, you have to enable WIFEER to generate the > IRQ signal to the GIC which is also an evidence that the external > wakup is falling edge. That's what I mean. How can you reason about the behaviour of the GIC when every observation you make is based on the behaviour of a second level interrupt controller (the WKPU)? I have no doubt you are observing a falling edge being delivered to the SoC... but that falling edge is *not* delivered to the GIC; it is delivered to the WKPU. The WKPU then delivers an active-high signal to the GIC. > With this clear *falling edge*, I have to > write the below irq_request code as: > > request_irq(50, wkup12_interrupt, IRQ_TYPE_EDGE_RISING...) > > IMO, this is very weird because the wakeup signal is falling edge from > the point of SOC/GIC side, but I have to name it as > *IRQ_TYPE_EDGE_RISING*, but it works just to pass the sanity > check(although I think which is not necessary as the fact shows) It is indeed very weird. However it is not the falling edge from the SoC/GIC side that makes it weird! In fact there is *not* a falling edge from the SoC *and* the GIC because they are not the same thing. There is a secondary interrupt controller between the SoC pin and the GIC which inverts the logic (and also obviates any need to deploy the GIC's edge detection features at all... IMHO the GIC trigger mode should be active high). Instead, I think the reason your code is weird is because the irqchip driver for the WKPU is missing or broken. A secondary interrupt controller requires an irqchip driver or you will end up with pieces of the interrupt controller management code (e.g. weird pokes to the WKPU to acknowledge things) appearing in all manner of inappropriate places. > > PS I can't find any sign of a WKPU driver in the mainline kernel and > > AFAICT this would make wake up sources unusable. What kernel have > > you been running your experiments on? > > 5.10.44- BSP code from NXP: > https://source.codeaurora.org/external/autobsps32/linux Given you are running a vendor kernel I think you need to discuss this with that vendor's support channels. To stop your code being weird then you need to obtain (or implement) an irqchip driver for the WKPU. Daniel.