From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DBFFC19F2B for ; Thu, 4 Aug 2022 10:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oEjIJ64JAKfywtFwEWm2Lut063ddDBTKTZH+33n16wM=; b=M02qN1KVPFBOkL XiQrcSAoDikFwEcGyItuAW5c4KIS/ulZm8XUWTPmxzbZKlnfm3XYYNGEpDQ/7GTLIEFy6/jdshGYF TGXY1yYFNjQL+8Myfz5Pdg0y8LDExej0HE/Hl8CkCVH0gDkc+2R6vNBCHt2EK67HoHigSzcRBO8Gl 1AYbUcBvK9KymQTS3R4VWUCwF0ioW+DAFnpTi29cpxUsS14dLS4U8Lza60WgUEMSLY9S/jNLsw8ZB vp1nSK3KvPWHA/O7+2GFccY62Jc6AOzzRR8/RUkXyXvt5+4hWQOFo/FquPc8ER+nannyF33lbJci/ Ft4vim2PfGNQCg178f5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJYE6-005G2R-18; Thu, 04 Aug 2022 10:37:14 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJYDl-005Fhy-Su for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2022 10:36:56 +0000 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 8CB7FB8119C; Thu, 4 Aug 2022 10:36:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66C34C433D6; Thu, 4 Aug 2022 10:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659609408; bh=ES/iHojojwBeWATmvF586pssKR6IM+n64XwkRqabZhM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G4iODQzk2o507TOyNZ9YdPnsp04nepRb1NxsdHFTlYs/YDfMvZ8e9NeSAY+Hx3QXD a94/Suuw4dA3lc/FiB/JntVvRyacRO62LwWgCezjrPJwwl6MRNEDCeLfJhGSzaHRcR Tv8O0aWvDnbGdjrq2DADM4dC58LzfY8CWIEHxiI9RR0svVp5rAKEVU1PUrECDD8U+M cFmNIskF2+eG98FoKaiyyV5LbstQSgDcYj3pmAZKYZ0zQqKj8vQ7VZYOmfEoG9Z9cN XV2ypNTCRPsBNmA9scCo7+pFa4VElC6sG8Aa6dlq/RaiURX8XM2T+fYz58F/p57jbY 1EO4L9RyDM0qQ== Date: Thu, 4 Aug 2022 12:36:41 +0200 From: Lorenzo Pieralisi To: Benjamin Herrenschmidt Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, Jeremy Linton , Ali Saidi , David Woodhouse Subject: Re: arm64 PCI resource allocation issue Message-ID: References: <204dda77248a7c95787e27fc7a382f514341c88e.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <204dda77248a7c95787e27fc7a382f514341c88e.camel@kernel.crashing.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220804_033654_415941_C08C1A90 X-CRM114-Status: GOOD ( 31.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Aug 02, 2022 at 02:07:00PM +1000, Benjamin Herrenschmidt wrote: [...] > The case back then was that there existed some (how many ? there was > one real example if I remember correctly) bogus firwmares that came out > of UEFI with too small windows. We could just quirk those .... There is just one way to discover "how many" unfortunately, quirking those can be more problematic than it seems. [...] > The alternative here would be to use ad-hock kludges for such system > devices, to "register" the addresses early, and have some kind of hook > in the PCI code that keeps track of them as they get remapped. That's what x86 does AFAICS (pcibios_save_fw_addr()), even though it is used in a different scope (ie revert to FW address if the resource allocation fails). > If we want this, I would propose (happy to provide the implementation > but let's discuss the design first) something along the line of a > generic mechanism to "register" such a system device, which would add > it to a list. That list would be scanned on PCI device discovery for > BAR address matches, and the pci_dev/BAR# added to the entry (that or > put a pointer to the entry into pci_dev for speed/efficiency). > > The difficulty is how is that update propagated: > > This is of course fiddly. For example, the serial info is passed via > two different ways, one being earlycon (and probably the easiest to > track), the other one an ASCII string passed to > add_preferred_console(), which would require more significant hackery > (the code dealing with console mathing is a gothic horror). > > Also if such a system device is in continuous use during the boot > process (UART ?) it needs to be "updated" as soon as possible after the > BARs (and parent BARs) have been also updated (in fact this is > generally why PCI debug dies horribly when using PCI based UARTs). > Maybe an (optional) callback that earlycon can add ? > > Additionally, this would only work if such system devices are > "registered" before they get remapped... > > Another approach would be to have pci_dev keep a copy of the original > resources (at least for the primary BARs) and provide an accessor for > use by things like earlycon or 8250 to compare against these, though > that doesn't solve the problem of promptly "updating" drivers for > system devices. > > Opinions ? You may also want to look into IORESOURCE_PCI_FIXED even though the last time I looked into I found some broken logic (basically the immutable/"fixed" BAR resources should obviously take into account the PCI tree hierarchy - upstream bridges, etc., which I don't think IORESOURCE_PCI_FIXED does - how it works remains a bit of a mystery for me). Lorenzo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel