Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3722108pxb; Tue, 19 Apr 2022 08:34:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXUyo5sDreYNr/R1Z4XQFajTXA1hqW10wHsFOtBgLyc4xJ0zSruto8bDRQDpukG2BnP55P X-Received: by 2002:a50:c3cf:0:b0:41d:5fc4:7931 with SMTP id i15-20020a50c3cf000000b0041d5fc47931mr18388753edf.244.1650382487477; Tue, 19 Apr 2022 08:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650382487; cv=none; d=google.com; s=arc-20160816; b=0zTtvHlvLXqXhfogCpIUiYpUYSGsXQ1XS+JSv15rfPId4YmLMmwXSOimi4WAeZOjcU 5bWJrV9iwQG+A5Rcq4f/DTwM1I32UM0Z9x/R5CLT3HS+lT2UriIhq3PuoK/Jj6iLHD6D fO5UctZE7po927qYB6yf6WlkHxgh428xxwfcfMnazZhRWRb99OfN3ounmkrdvty+RSR7 KtMEc9y2YyqTeKmbkV9Fj+FERpVC8BW0tWYWUnLkkWGAKBSsAfni4O8zJ0IN71xiaPcX y4DY0w7p30+xtMxkPsyTCjDdSUmzr23rrY7BIh42g+t9kOCXaGRTlCEGiTpQuWyunojn eTeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=a293GE0F91ir9tV4DqTn9nxN523z5yFFcbdifbj+QLA=; b=kWc8AKfmPcAQTZwRUpO5JTEJi80XCPZNMMKLaGLEOBnjREBoc0CThkaAnnWtT2VI71 fCvHA+yi1it70GToKaKdNLRGXNm2ytpzRuG0K0wBLpuadCvmgcH1a/f3+sRH9tOscQWT aLOSH9bliLaIPcozi/LZWbMIO6GWtk0dSpiABhqKx1lydBcZiBGD+ZFjbjI9z3RYVCUi lJZO9TqSvAVnS27BI2q0hgDjI5dmeNb3jj3tAYJmFKPdpgjv8Z82OcFzpJT4TNRHvFMU +wGWc0M0Ll1fJATi196Z1FDSzRlnqpgZhD7lv6GvjfUX9dnzArUjLvGXrEJAHtTmAyeY EKow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BzGw5yGl; 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 f2-20020a170906560200b006e01f1d9677si9245784ejq.532.2022.04.19.08.34.20; Tue, 19 Apr 2022 08:34:47 -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=BzGw5yGl; 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 S233185AbiDRW4b (ORCPT + 99 others); Mon, 18 Apr 2022 18:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233096AbiDRW41 (ORCPT ); Mon, 18 Apr 2022 18:56:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E28DC2C648; Mon, 18 Apr 2022 15:53:46 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 73D8D61183; Mon, 18 Apr 2022 22:53:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C81B4C385A7; Mon, 18 Apr 2022 22:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650322425; bh=rWhmhUMtdpZrg81Duj60cEzYJ4LxtasGcSah4PuyDcQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BzGw5yGl8f86SHdpWaRO3N0W6Eu2t/rqO9J/315qJBr7UiglDnTrssBf1TdThb5BA 3uEcUiMlwCUXwnwlJ5B6/DqHxtHRfwzZqM7hOqT2mxRb9xMAsb6cA4HgFHlqSSvnE4 rNcDhyklS/+z3efqGfveFoPyPn3DMETucjW/ahr8Ai65uDxZsE4htcj98IOyDWD0vT heFKO6ijGhKlH+zKYdP6J0txm+aoh92+rWp6D2sO9szMizMp4wdlmriLJ4991jkwfo cz4IyCaWZxcHz/hpqr37uo3A5oqkocV3YlVkqzpXH179kXB1NLXjrKN2tasEe+/VP7 RtUc39pLpda/w== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=billy-the-mountain.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 1ngaFb-005Aof-7r; Mon, 18 Apr 2022 23:53:43 +0100 Date: Mon, 18 Apr 2022 23:53:41 +0100 Message-ID: <878rs2c8ay.wl-maz@kernel.org> From: Marc Zyngier To: Peter Geis Cc: Lorenzo Pieralisi , Rob Herring , Krzysztof =?UTF-8?B?V2lsY3p5xYRza2k=?= , Bjorn Helgaas , Heiko Stuebner , "open list:ARM/Rockchip SoC..." , PCI , devicetree , arm-mail-list , Linux Kernel Mailing List Subject: Re: [PATCH v7 2/4] PCI: dwc: rockchip: add legacy interrupt support In-Reply-To: References: <20220416110507.642398-1-pgwipeout@gmail.com> <20220416110507.642398-3-pgwipeout@gmail.com> <308e9c47197d4f7ae5a31cfcb5a10886@kernel.org> <87zgkk9gtc.wl-maz@kernel.org> <87sfqaa7uv.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 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: pgwipeout@gmail.com, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, heiko@sntech.de, linux-rockchip@lists.infradead.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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.7 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, 18 Apr 2022 16:13:39 +0100, Peter Geis wrote: > > On Mon, Apr 18, 2022 at 8:34 AM Marc Zyngier wrote: > > > > On Mon, 18 Apr 2022 12:37:00 +0100, > > Peter Geis wrote: > > > > > > On Sun, Apr 17, 2022 at 5:53 AM Marc Zyngier wrote: > > > > > > > > On Sat, 16 Apr 2022 14:24:26 +0100, > > > > Peter Geis wrote: > > > > > > > > > > Okay, that makes sense. I'm hitting the entire block when it should be > > > > > the individual IRQ. > > > > > I also notice some drivers protect this with a spinlock while others > > > > > do not, how should this be handled? > > > > > > > > It obviously depends on how the HW. works. If this is a shared > > > > register using a RMW sequence, then you need some form of mutual > > > > exclusion in order to preserve the atomicity of the update. > > > > > > > > If the HW supports updating the masks using a set of hot bits (with > > > > separate clear/set registers), than there is no need for locking. In > > > > your case PCIE_CLIENT_INTR_MASK_LEGACY seems to support this odd > > > > "write-enable" feature which can probably be used to implement a > > > > lockless access, something like: > > > > > > > > void mask(struct irq_data *d) > > > > { > > > > u32 val = BIT(d->hwirq + 16) | BIT(d->hwirq); > > > > > > This is what HIWORD_UPDATE_BIT does, it's rather common in Rockchip code. > > > I believe I can safely drop the spinlock when enabling/disabling > > > individual interrupts. > > > > Yes. > > > > > > > > > writel_relaxed(val, ...); > > > > } > > > > > > > > void mask(struct irq_data *d) > > > > { > > > > u32 val = BIT(d->hwirq + 16); > > > > writel_relaxed(val, ...); > > > > } > > > > > > > > Another thing is that it is completely unclear to me what initialises > > > > these interrupts the first place (INTR_MASK_LEGACY, INTR_EN_LEGACY). > > > > Are you relying on the firmware to do that for you? > > > > > > There is no dedicated mask or enable/disable for the legacy interrupt > > > line (unless it's undocumented). > > > > I'm talking about the INTR_MASK_LEGACY and INTR_EN_LEGACY registers, > > which control the INTx (although the latter seems to default to some > > reserved values). I don't see where you initialise them to a state > > where they are enabled and masked, which should be the initial state > > once this driver has probed. The output interrupt itself is obviously > > controlled by the GIC driver. > > PCIE_CLIENT_INTR_MASK_LEGACY is the register I use here to mask/unmask > the interrupts. > It defaults to all masked on reset. And? Are your really expecting that the firmware that runs before the kernel will preserve this register and not write anything silly to it because, oh wait, it wants to use interrupts? Or that nobody will kexec a secondary kernel from the first one after having used these interrupts? Rule #1: Initialise the HW to sensible values Rule #2: See Rule #1 > The current rk3568 trm v1.1 does not reference an INTR_EN_LEGACY register. The TRM for RK3588 mentions it, and is the same IP. > > > > > It appears to be enabled via an "or" function with the emulated interrupts. > > > As far as I can tell this is common for dw-pcie, looking at the other drivers. > > > > I think we're talking past each other. I'm solely concerned with the > > initialisation of the input control registers, for which I see no code > > in this patch. > > Downstream points to the mask/unmask functions for the enable/disable > functions, which would be superfluous here as mainline defaults to > that anyways if they are null. Yeah, that's completely dumb. But there is no shortage of dumb stuff in the RK downstream code... > > I've double checked and downstream only uses the mask register, enable > and routing config appears to be left as is from reset. And that's a bug. > I'm rather concerned about the lack of any obvious way to control > routing, nor an ack mechanism for the irq. Which routing? Do you mean the affinity? You can't change it, as this would change the affinity of all interrupts at once. > I see other implementations reference the core registers or vendor > defined registers for these functions. > Unfortunately the rk3568 trm does not include the core register > definitions, and the designware documentation appears to be behind a > paywall/nda. If you use a search engine, you'll find *CONFIDENTIAL* copies of the DW stuff. The whole thing is a laugh anyway. > > I suspect most of the confusion here boils down to a lack of > documentation, but it's entirely possible I am simply not > understanding the question. My only ask is that you properly initialise the HW. This will save countless amount of head-scratching once you have a decent firmware or kexec. M. -- Without deviation from the norm, progress is not possible.