Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3583094iog; Mon, 27 Jun 2022 20:51:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1voZKXLHjNeU/BpaX+NBgtWfWG51EOFyUL8OeVRMLp9EPpM/uXUCqwQAewbsm6j9QMt6FD0 X-Received: by 2002:a17:902:f652:b0:156:701b:9a2a with SMTP id m18-20020a170902f65200b00156701b9a2amr2853528plg.14.1656388305558; Mon, 27 Jun 2022 20:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656388305; cv=none; d=google.com; s=arc-20160816; b=f12bWpH41takWz6/cKoPkZ5S7MOTFHuPFbickrq0CJ+sejzNu/7HWwVS/j2IEH1DxE gWDM//kvmGiAqMLX5bTB3iJgVQUc2soTxEfmZu9X63KpHXgDSkI601nPGbQn0N26xPP6 8AS5JBuf9HM6bgWN17nfJaKOQ85JNRAJS8FkdEL+z7BOT2RvMItHB0zco7N+uLnlIG5d 9J589bIzuX3GyWRA9VOT8mqWIOB5yuCvrm6ge7bI4upojZnwinwj0torkyixs6SIQEW1 mGX6V/aH/RDi7m4KgJDHQanYXHvVOvZMTGM0rBbQ84ssyiD7OLjBAUddGBuTp430ODff M7ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DALIPsATD9l6uK1v5HPzZy9rVX2bD5FJQQN6WaPxRfM=; b=Hl5w0H8ER5oQMc/y5Ai/4fItT6t4K4Lf0HjdGd2V1Xzry2YWWS+4rkzHa1TlreJrWm 17+M+zUDaVE8bUunWsjtDLjEkmUOgsEYY2ugrIoF82rl8dtfdgeiF8SevCqbu6L6oVGa +5MYXAggRnnxuSMtThbjaOAhY6cvJhh1+MhCdLhvlOt5Wff6LOm9RZGtkFKcR2SlN1js dwQclaYL1BWvpS1+owTICVsEqA0RecNWU291UfJnXWdcFY4nIJzwK2ts3lDY5o1DTvYN WtX86LfNxa4YF2c+NmuWHQ0xCNnMwY8aHEsuBg+LBmLR650HUN1AL2jxoVHoAbiiY4OP DHEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R0ErmPAL; 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 l21-20020a170902d35500b0015f3d889431si16570173plk.446.2022.06.27.20.51.31; Mon, 27 Jun 2022 20:51:45 -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=R0ErmPAL; 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 S231207AbiF1DEm (ORCPT + 99 others); Mon, 27 Jun 2022 23:04:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243334AbiF1DEk (ORCPT ); Mon, 27 Jun 2022 23:04:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CAA212D1D; Mon, 27 Jun 2022 20:04:37 -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 F2ED6B81C0C; Tue, 28 Jun 2022 03:04:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B71DCC341CE; Tue, 28 Jun 2022 03:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656385474; bh=Dr3/Y/ZEFbz5YUD1O4lFuoAblnOIw2GNM9YjX37GVH8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=R0ErmPALbkmJwBeVFyS4uRUSDdonftuKGiu/OsMcHbWNRZtqKfZ9pK7eRL8ew+ih9 nfc0yHRKBRZdGGxXs8V3gfI7Qjt0wvSahFOx+O0msj5o5L+N+1m/hLOzIlRh+AjRtB nP2Rkx9roqAvNn6R13svRPBDYcSKA2FzvKiHGg99GRehV2MhiZeCjJTIR0cG3nXD4U tgki4uId0RC74c201aGQOQD8diLMtA+XggQVwAttyqEfCsW3OS4R1VIWRNDgysC8DU YlXRbC8Sw5dnMVZ8jxhGVzUmp/75Nsb2dWJ4yBzp0YcAn40RjEZ22wLcCMYlo1HQhy 6qVEQIKZKbTKQ== Received: by mail-vs1-f46.google.com with SMTP id j1so10743441vsj.12; Mon, 27 Jun 2022 20:04:34 -0700 (PDT) X-Gm-Message-State: AJIora97pSiN518gmVzc9550m4iRrnoHIzDNCeq1wLm31MLFyr8CPxdO 0qe5ApA4Hr9d9le3/ykrC7pE89IFFEbAmN5ICto= X-Received: by 2002:a05:6102:366f:b0:356:352f:9de2 with SMTP id bg15-20020a056102366f00b00356352f9de2mr959975vsb.2.1656385473552; Mon, 27 Jun 2022 20:04:33 -0700 (PDT) MIME-Version: 1.0 References: <20220627051257.38543-1-samuel@sholland.org> <20220627051257.38543-2-samuel@sholland.org> In-Reply-To: From: Guo Ren Date: Tue, 28 Jun 2022 11:04:22 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 1/3] dt-bindings: interrupt-controller: Require trigger type for T-HEAD PLIC To: Samuel Holland Cc: Lad Prabhakar , Prabhakar , Marc Zyngier , Sagar Kadam , Paul Walmsley , Palmer Dabbelt , linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , Thomas Gleixner , Biju Das , Albert Ou , Krzysztof Kozlowski , Rob Herring , devicetree , Linux Kernel Mailing List , linux-riscv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.5 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 Mon, Jun 27, 2022 at 10:14 PM Samuel Holland wrote= : > > On 6/27/22 2:40 AM, Guo Ren wrote: > > On Mon, Jun 27, 2022 at 1:13 PM Samuel Holland wr= ote: > >> > >> The RISC-V PLIC specification unfortunately allows PLIC implementation= s > >> to ignore edges seen while an edge-triggered interrupt is being handle= d: > >> > >> Depending on the design of the device and the interrupt handler, > >> in between sending an interrupt request and receiving notice of its > >> handler=E2=80=99s completion, the gateway might either ignore additi= onal > >> matching edges or increment a counter of pending interrupts. > >> > >> For PLICs with that misfeature, software needs to know the trigger typ= e > >> of each interrupt. This allows it to work around the issue by completi= ng > >> edge-triggered interrupts before handling them. Such a workaround is > >> required to avoid missing any edges. > >> > >> The T-HEAD C9xx PLIC is an example of a PLIC with this behavior. > > Actually, C9xx support pulse signals which configed by > > pad_plic_int_cfg_x for SoC vendor: > > > > https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_= rtl/plic/rtl/plic_int_kid.v > > 104: assign int_new_pending =3D pad_plic_int_cfg_x ? int_pulse > > 105: > > : level_int_pending; > > > > They could put pad_plic_int_cfg_x into the SoC software config > > registers region or bind them to constant values. > > The issue here is the "!int_active" condition for int_new_set_pending, > regardless of that configuration input. > > For interrupt sources that send pulses, those pulses will be lost if they= are > received while int_active is true. So the driver has to make sure int_act= ive is > false _before_ servicing an interrupt, or it may miss the next one. This = means > the driver needs to know which interrupt _sources_ send pulses and which = ones > assert levels. You are right, in plus mode, we can't receive any interrupt between claim & complete, then the irq could be lost. I think the design follows the sentence written by PLIC spec: https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc If the global interrupt source was edge-triggered, the gateway will convert the =EF=AC=81rst matching signal edge into an interrupt request. Depending on the design of the device and the interrupt handler, in between sending an interrupt request and receiving notice of its handler=E2=80=99s completion, the gateway might either **ignore additional matching edges** or increment a counter of pending interrupts. Also, the hardware could easily support the feature, but the engineer follows the first choice and disable the useful function. -_*! > > For level interrupts, pad_plic_int_cfg_x had better be 0, but that is a > hardware/firmware configuration concern. The driver should not have to ca= re > about that. > > (On the Allwinner D1, those inputs are memory mapped, which was the reaso= n for > the stacked interrupt controller mentioned in my other reply. But while > pad_plic_int_cfg_x =3D=3D 1 only works with edge interrupts, the pad_plic= _int_cfg_x > =3D=3D 0 choice works with either kind of interrupt source, so the stacke= d driver is > not really needed.) > > Regards, > Samuel -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/