Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp394248ioo; Thu, 26 May 2022 06:11:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW8WP/6+rYUs9XFX5ITpzmbkCVidu2GLzjg7Z25uLK0eKBysx7VS0VOrYusW54FCe+68KQ X-Received: by 2002:a05:6a00:2386:b0:519:1ff1:d723 with SMTP id f6-20020a056a00238600b005191ff1d723mr1807279pfc.21.1653570719432; Thu, 26 May 2022 06:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653570719; cv=none; d=google.com; s=arc-20160816; b=LkzthwD0ORVO/hs/0EdC5/8RRZZ0gNYi19l9oibXMfYoVfx+Yf3J7Lcp141Q4hETv6 wJVhT8wff0KYmbeMomfYE53tO9KCT6UDBrKc8AXTX7f4+k7Huex+yRjk6h/l8rGiOewl 8ugOR//KvUs9J4GjOngoNrsV9A5DZ5Ke8FRqM3aAy8HX00QKcT24e1MRT3KyLAypC/aj 38/ogA1E+8wKheC3DgxYMsj1Ifwe4x/r7GfeLOEzSsRbiuIomxJY7s96T4C0l9O2nhqp l9xlMY5jZGNYqjJZ/Bw/rHlglTUlvvQa86H9RDHAKDEimDE2py4N+ZrZ7CgntVo/xGlY ulWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=POm4bvJj5NUsZAqeLV8uvpmUTg4LkO2j/1nI4OtA++I=; b=gO78j/0xRWbDIPe/0PT9PMnz73dm69Zb/XBoEEJwJysZv5Anlf1TsWnjSpF610FVXr ZcWFwiit4T0Sdh3tsdnqN06w7hFMjn1XBf/7rj/ANzlsNQMy5s8VI5EP6M57hhVwEeL0 Ns24pxdoSzBmO5Ty8QssEzmqlM66QNlFyCFYWF2Da3thtdxR0WqkaOZT0IUEOVv0AUn6 /VJa75+7UVLcDaBEkfqI02PTwJGTHOiG7sGGN/faPo2TfMALrDoYsWf8TW1RXGNOD2VC dN0aBeWwdcIfiNl5Uu+e69srGCtqNalnNRrD94leD09HwVYHh4PRMfV5y/KOnxGmWxlG 1UdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YdFlNA8n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a632a0d000000b003f5ef22eb62si2285708pgq.724.2022.05.26.06.11.46; Thu, 26 May 2022 06:11:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YdFlNA8n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343788AbiEZMwv (ORCPT + 99 others); Thu, 26 May 2022 08:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235381AbiEZMwt (ORCPT ); Thu, 26 May 2022 08:52:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B902ED46 for ; Thu, 26 May 2022 05:52:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6BB46B82058 for ; Thu, 26 May 2022 12:52:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6244C385A9; Thu, 26 May 2022 12:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653569564; bh=Z3C6dkYdPm8lWq2xILiBEXeVjfcYz6sTr481QH2GFp4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YdFlNA8n+XGTjQ7ypalb4t9BC9Ib5TAVbONZ1gNnJ6QPJ51RnQw8NYxoRbM4P0sY6 Hiq5RTMPDLMRMWBht8+FYLqcl13WNd7eriPi/WK+O1CFtrgWv8KPUAeCl7J57aTLcx zLhjZqcZD5z954/dlKPhE0YKV+xi2H1Lfv4nTPZ2RbIOBFfRRnWTQq8b8aDdKQzvP2 73gR3/f5bsH3sGYVo+jKBUSUR5zC7FOnWfCEY6PHysCBZccqqELZBkdGUoBKXXu3pK Q4vNvS3MfESk3f7723cgVJ4lEr4XEBHQCyAwnCH79X5u2rs+3eR61ZtVf1TrTcD844 9dF8AtOxNq2WQ== Received: from athedsl-4557779.home.otenet.gr ([94.70.87.219] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nuCyo-00Dquf-Cp; Thu, 26 May 2022 13:52:42 +0100 Date: Thu, 26 May 2022 13:52:40 +0100 Message-ID: <87czg0mp5z.wl-maz@kernel.org> From: Marc Zyngier To: richard clark Cc: 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 In-Reply-To: References: <35f95ba3-8a7b-7918-0f9d-e14274a5ffe9@arm.com> <87ee0gn5rq.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 94.70.87.219 X-SA-Exim-Rcpt-To: richard.xnu.clark@gmail.com, robin.murphy@arm.com, 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 X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, 26 May 2022 13:09:32 +0100, richard clark wrote: >=20 > CC'ing some nxp guys for the S32G274A SOC... >=20 > On Thu, May 26, 2022 at 2:54 PM Marc Zyngier wrote: > > > > On Thu, 26 May 2022 04:44:41 +0100, > > richard clark wrote: > > > > > > On Thu, May 26, 2022 at 3:14 AM Robin Murphy w= rote: > > > > > > > > On 2022-05-25 11:01, richard clark wrote: > > > > > Hi Marc, > > > > > > > > > > For below code snippet about SPI interrupt trigger type: > > > > > > > > > > static int gic_set_type(struct irq_data *d, unsigned int type) > > > > > { > > > > > ... > > > > > /* SPIs have restrictions on the supported types */ > > > > > if ((range =3D=3D SPI_RANGE || range =3D=3D ESPI_RANGE) = && > > > > > type !=3D IRQ_TYPE_LEVEL_HIGH && type !=3D IRQ_TYPE_= EDGE_RISING) > > > > > return -EINVAL; > > > > > ... > > > > > } > > > > > > > > > > We have a device at hand whose interrupt type is SPI, Falling edge > > > > > will trigger the interrupt. But the request_irq(50, handler, > > > > > IRQ_TYPE_EDGE_FALLING, ...) will return -EINVAL. > > > > > > > > > > The question is, why must the SPI interrupt use IRQ_TYPE_EDGE_RIS= ING > > > > > instead of IRQ_TYPE_EDGE_FALLING? > > > > > > > > Because that's what the GIC architecture[1] says. From section 1.2.1 > > > > "Interrupt Types": > > > > > > > > "An interrupt that is edge-triggered has the following property: > > > > =E2=80=A2 It is asserted on detection of a rising edge of a= n interrupt signal > > > > > > This rising edge detection is not true, it's also asserted by > > > falling edge, just like the GICD_ICFGR register says: Changing the > > > interrupt configuration between level-sensitive and *edge-triggered > > > (in either direction)* at a time when there is a pending interrupt > > > ..., > > > > Let me finish the sentence for you: > > > > > > ... will leave the interrupt in an UNKNOWN pending state. > > >=20 > Context sensitive(register-update leaves UNKNOWN pending) and >=20 > > > > and the direction here is about the configuration bit, not the edge > > direction. >=20 > with this(configuration bit: either level-sensitive or > edge-triggered), but it doesn't matter. >=20 > > > > > which has been confirmed by GIC-500 on my platform. > > > > 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. >=20 > 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). This is thus driven by an external piece of HW, which, I expect, would perform the signal conversion. >=20 > 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... If you can prove that the GIC itself (and not some piece of HW on the signal path) latches on a falling edge, then that would be a huge bug. I would encourage you (or NXP) to report it to ARM so that it would be fixed. Now, given that GIC500 has been with us for over 8 years, such a bug would have been witnessed on tons of existing systems (all the SPI-based MSIs would trigger twice, for example). Since there has been (to my knowledge) no report of such an issue, I seriously doubt what you are seeing is a GIC misbehaviour. M. --=20 Without deviation from the norm, progress is not possible.