Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp44260ioo; Wed, 25 May 2022 20:06:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj3CfSWiZKob1YvxXLMJjxGO0by0vq9SPP3fmAXbXnm/z4Cs6nBaZoX2HUViUHncf1Yqzh X-Received: by 2002:a17:906:7308:b0:6fe:f979:6b05 with SMTP id di8-20020a170906730800b006fef9796b05mr13498912ejc.577.1653534387187; Wed, 25 May 2022 20:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653534387; cv=none; d=google.com; s=arc-20160816; b=dFNduhu+5pXTLAEUaIJ3A7uYHf+F6vJ3mZ08nREBPZvEiUA6UQ2gWyEA1gsqTOFnE7 Sf1d4LNmTVmaUETiISSLljIlHbg9jlTyraiH17Ycg99bvS9HgssTdQPr3pCtCbjbuZJp hmC+Hc/GTNFSbYVYeAtVJ5/r3JOzQ6Zvodb7Wmj/7B1PcjvAl7GbEQxM8LzALslPkvHK ecvTLgl2AlfBWDC5XSaMvaNCP8kfydqbjKtDkcEXKPHCO1G/H6YasTZ6KH9MELkx8iP4 kkXoyN94QdMLspvXoiQmx+eMthP8k17canPrlq6lgCHLp3Xlx1YJAHGGBFfsYO3uqGY6 GtNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=bW+Y7hfz6s4JPoohQV5O1wTXgUvwglTv2QGe18TK+7A=; b=JPXpL7lyuA3K/8786MZINgPq2Ililc4rFv6jukeaQF/1FGcAg+AQER6jdcLVVW53z1 P1ymEXXHGCl3BdWkbyvd/w6VVffbQ3pWKQQv0947o0Hp7WjH/Nis97kx/bPUYchexBx1 l0m0XdFHNRVq6NHmPuPnzhUnq9kX0twBSJA1IPPLh8GgCJMeIQBZwr6ejtk01x96nR4A eE5VE9QmnqWColmJ0R5oQFgxztAsTRDUJvN2E7zPWY4d0L1jICYgGGHSFoFf/Y/E0Smd Xk81NjjCH0/awL/CxZAVV3XSKcecKh8I/WocxWC/+3h5jmtJNnyrXtppd10TxEMzmY8i Tp9w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr13-20020a1709073f8d00b006ff149c2b6asi405005ejc.588.2022.05.25.20.06.01; Wed, 25 May 2022 20:06:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344326AbiEYTQ0 (ORCPT + 99 others); Wed, 25 May 2022 15:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344770AbiEYTPR (ORCPT ); Wed, 25 May 2022 15:15:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9EEE4252A4 for ; Wed, 25 May 2022 12:14:24 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FDE81424; Wed, 25 May 2022 12:14:24 -0700 (PDT) Received: from [10.57.81.38] (unknown [10.57.81.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6258A3F73D; Wed, 25 May 2022 12:14:23 -0700 (PDT) Message-ID: <35f95ba3-8a7b-7918-0f9d-e14274a5ffe9@arm.com> Date: Wed, 25 May 2022 20:14:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: Question about SPIs' interrupt trigger type restrictions Content-Language: en-GB To: richard clark , maz@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 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 == SPI_RANGE || range == ESPI_RANGE) && > type != IRQ_TYPE_LEVEL_HIGH && type != 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_RISING > 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: • It is asserted on detection of a rising edge of an interrupt signal and then, regardless of the state of the signal, remains asserted until the interrupt is acknowledged by software." External signals with the wrong polarity may need external logic to invert them (which might even be offered by the GIC implementation itself, e.g. [2]), but the programmer's model neither knows nor cares about such details, it only knows notions of "edge-triggered" and "level-sensitive", where from its point of view the asserted states are rising and high respectively. Robin. [1] https://developer.arm.com/documentation/ihi0069/latest [2] https://developer.arm.com/documentation/100336/0106/components-and-configuration/spi-collator/spi-collator-wires?lang=en