Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4739406iob; Sun, 8 May 2022 23:51:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3X8psoyMuywiqoiBZU1FBliE6XB21h4zO53T6ygc3aEYJiv+s+OYS7ZWMhdDG717c6TOx X-Received: by 2002:a05:6a00:1a08:b0:510:979e:f5b with SMTP id g8-20020a056a001a0800b00510979e0f5bmr7986614pfv.34.1652079067708; Sun, 08 May 2022 23:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652079067; cv=none; d=google.com; s=arc-20160816; b=TIKGzCAuQiG5MVOmpXq7g0fTUkbBF3QRPUMXhUKQpFggRxJp/jaZabJ25IsE9b+R5C oh+bMCdD4iSRTEvlSoTI/Mj6wrKkD5ssa4eoJm4Go2e6Q8X6giBypG8zFpG26iPA2fKD NJqtYaG6K1cFKZr79m3gjkH3BNugX3269dAwIRTglAOr+YnihVhrkrozBcKHhyAVR2OR 46ttGdVg5qR7vTR/jMBmi/ejz3ei07GLs0ckLJhm5RUN27Jz478b8qQnjRxJoUHzcwOy uxvFReXIVMfpCEjtCi056fIEjaogTfvnKIyB0P83jGd71LS2QMooSXAe/SLCXFYrsX8z TXsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mKsg/Jgd0uhsGlP+bbBSVyP6RaiPoNpJnQVYpnpxAsY=; b=l4DJNRGa17Wj7DHYF3qYNdN6TW83aHATvkhDDJJ2SPiCAcv/47FEm35KDb/ffZuRuc YIzeJIkvgdMV1WmjE88uWgvq3AbmHz6Hxx3YQ4ZoIn63J/zY5rY+dnbrP/Hu7699uhyj 8mGPlr1uaIuWjAFIZ6jkF772oE7Zx21EjTn40mbvrMskYP7pJNO7C+z2VvvlM25hEepA N0tLeTfD2JfT6ZiXL3WMdCvblBXzcujH2228kngtsu35ufL0UFUjk6TTrCIo2xiWJBli ni3jAwrAAXVr8mDFka5OjDYM1YuwYCL5cNtFHgsNGj4NXRvMCvdCGMTx4s7QYxUjZgHK ovPg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k11-20020a170902d58b00b00158da869427si10545759plh.176.2022.05.08.23.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:51:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 443A4191E59; Sun, 8 May 2022 23:48:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbiEHHRM (ORCPT + 99 others); Sun, 8 May 2022 03:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbiEHHRF (ORCPT ); Sun, 8 May 2022 03:17:05 -0400 Received: from bmailout2.hostsharing.net (bmailout2.hostsharing.net [IPv6:2a01:37:3000::53df:4ef0:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5673FDF0D for ; Sun, 8 May 2022 00:13:13 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id 05E3F2800BD8D; Sun, 8 May 2022 09:13:09 +0200 (CEST) Received: by h08.hostsharing.net (Postfix, from userid 100393) id ED86711AF9A; Sun, 8 May 2022 09:13:08 +0200 (CEST) Date: Sun, 8 May 2022 09:13:08 +0200 From: Lukas Wunner To: Andy Shevchenko Cc: Wolfram Sang , Jean Delvare , Heiner Kallweit , Lee Jones , Hans de Goede , Linus Walleij , Tan Jui Nee , Kate Hsuan , Jonathan Yong , linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-i2c@vger.kernel.org, linux-gpio@vger.kernel.org, platform-driver-x86@vger.kernel.org, Borislav Petkov , Mauro Carvalho Chehab , Tony Luck , James Morse , Robert Richter , Peter Tyser , Mika Westerberg , Mark Gross , Henning Schild Subject: Re: [PATCH v4 1/8] platform/x86/intel: Add Primary to Sideband (P2SB) bridge support Message-ID: <20220508071308.GA27815@wunner.de> References: <20220131151346.45792-1-andriy.shevchenko@linux.intel.com> <20220131151346.45792-2-andriy.shevchenko@linux.intel.com> <20220505145503.GA25423@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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, May 05, 2022 at 07:54:49PM +0200, Andy Shevchenko wrote: > On Thu, May 5, 2022 at 4:55 PM Lukas Wunner wrote: > > On Mon, Jan 31, 2022 at 05:13:39PM +0200, Andy Shevchenko wrote: > > > Background information > > > ====================== > > > > The wealth of information in the commit message obscures what the > > actual problem is, which is actually quite simple: SoC features > > such as GPIO are accessed via a reserved MMIO area, we don't know > > its address but can obtain it from the BAR of the P2SB device, > > that device is normally hidden so we have to temporarily unhide it. > > Right, but this long commit message was a result of the previous > discussions with Bjorn. If we're ever going to handle something like > this in the PCI core, perhaps he won't be happy if I remove it. Maybe > we can simply state what you wrote as a problem statement and move > this chapter at the end? Yes, feel free to copy-paste the synopsis from my e-mail above and rephrase as you see fit. > > > On top of that in some cases P2SB is represented by function 0 on PCI > > > slot (in terms of B:D.F) and according to the PCI specification any > > > other function can't be seen until function 0 is present and visible. > > > > I find that paragraph confusing: Do multi-function P2SB devices exist? > > What are the other functions? Are they visible but merely not enumerated > > because function 0 is not visible? > > The case I see is when we want to read the BAR from another slot of a > PCI device, 0 function of which is P2SB. Since P2SB is hidden, the > other device is hidden as well. Any idea how to reformulate this? And > yes, we have this in the existing SoCs. The spec you linked to in the commit message (for the 100 series chipset) says that P2SB is located at Device 31 Function 1. In those chipsets where P2SB is function 0, what kind of devices are at functions 1 and higher? > > Do you really need all the complicated logic in __pci_bus_read_base()? > > For comparison, simatic_ipc_get_membase0() in simatic-ipc.c merely does: > > > > pci_bus_read_config_dword(bus, p2sb, PCI_BASE_ADDRESS_0, &bar0); > > > > If that's sufficient for simatic-ipc.c, why is the more complicated code > > necessary in p2sb.c? > > Since it's a PCI device I want to follow what PCI core does with it. > As I explained somewhere that the current code (actually it's a > simplified version of what is done in PCI core) follows what spec > requires. I would like to be in alignment with the spec, while it > still may work with less code. Besides that, it's theoretically > possible that the base address may be 64-bit in new SoCs, I won't > rewrite code again just because we abused the spec. So as an alternative to copy-pasting __pci_bus_read_base(), you could just call pci_scan_single_device(). This will create a proper pci_dev that you can work with. Note that no driver will be bound to the device because of: pci_scan_single_device() pci_device_add() dev->match_driver = false After you've read the BAR, get rid of the pci_dev with pci_destroy_dev(). > > > + /* > > > + * I don't know how l can have all bits set. Copied from old code. > > > + * Maybe it fixes a bug on some ancient platform. > > > + */ > > > + if (PCI_POSSIBLE_ERROR(l)) > > > + l = 0; > > > > l can have all bits set if the device was hot-removed. That can't happen > > with a built-in device such as P2SB. > > Can be dropped, indeed. But that chicken bit emulates that :-) Anyway, > we unhide the device before looking into it, so we shouldn't have the > surprise "removals". pci_lock_rescan_remove() prevents concurrent unhiding as well as removal via sysfs. Thanks, Lukas