Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp682588pxf; Thu, 1 Apr 2021 10:48:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAuZ3urnObp4dpPWJSM3R9fKbgkY5XEnXJVbDmMBoe0R9Cmx/BRTsGKKSrrhAQyDIbTXP7 X-Received: by 2002:a17:907:162b:: with SMTP id hb43mr10600545ejc.41.1617299337396; Thu, 01 Apr 2021 10:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617299337; cv=none; d=google.com; s=arc-20160816; b=RtcyifUuFTDq1HqbTG4zfpEvXBLe6fqCki0BKIE6hpkX9uPjOGxC3UeKP7aBjRz3RI /WOYDFzu64ABD4e6D+VBApowVYHbGC+hbh5Ryq6X0nYmbEsNcSDlY+9apYGqjgJH0Txa O9siBOI6pOMMOk9M3AqScEK4Il6BKIgwwmkCxI+M5SSiQ6eDKReqXNryWEI7jfXsb2WJ LI9j6Jd55iyn/4ir7dqiPOd6tYMhOAaLEcJk0dTzD3sNG1+/4AuqzJKOcCB+jxtx9Lce srXK5yxXIkmWzb8hKN7EZ3+0vypxHTU9ux3q8QKpy2U3EP28R7zrxxU62feTbwVYRCNL fCjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=IxdcTItBMHQjVvtPycOPGKDP+puhE8Z+vZ5JsUyIgfo=; b=O8+BGnD9TyYly/UVNyzRMYbNUVCa55Tm96Oz/xQf32gb1lvRWML6Hw0yQUee0E3Iun GXjdYg99OwnjVM5Qvz5QnY5AKe0OJ7HJokKPwyE9phT43naIyAZD9+2octYMpyIDsh7j VUBT+SPxoQ4TAKxf5uGv3boFpimY97F1lrWpxIZJKF0RYsCTn7GWcUzQnsNCHtHufod9 ggGxRJAzJZGQteoY4HweQ78nZ2bMvsqwZdTTTLr33WgO4FrkJ4z+gHx9+dOa3BCv6dH5 /MZMkjDhpL+ORs0Rt8HCthVf/WUZQI9P4L856ODWsOMs9+kzi/W+dfCpPuUP9xlMVpn+ hi1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V0A1RN+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si4893805eds.501.2021.04.01.10.48.34; Thu, 01 Apr 2021 10:48:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V0A1RN+D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236289AbhDARoS (ORCPT + 99 others); Thu, 1 Apr 2021 13:44:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:40596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234559AbhDARiA (ORCPT ); Thu, 1 Apr 2021 13:38:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B76F161386; Thu, 1 Apr 2021 16:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617295378; bh=i04niHeXuQvwIy5MixftZzotTP0TGOM+jM0OxbF9CXw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=V0A1RN+DPE2xtWYyDCDoxSGkMsS1QrILEzosJPbis4ibuJoVVIl4ZdF3i89mvsOY6 +fH7WX9Ps2Jlw9/cbCJBJ5mE48dsmK6NXkCaZyPpEvUSmKuddYv4gHqDBUra6f0Ov4 nsJ3lsAcFsxMUwflSoK41pwCfsEUJjmbZyP54B0FA4EbtF5Lil1xT4B5yteUg0cR6O 44aRc52oTCBzFrJ/QDenCd7I7SjQU+BqxUMTOsg65DGdcFl/pJDm9X3KNf6oNC+8bX O+nOlYUmtOKeZLZEjVUn4oBVUMvm5rzm9B0e6Vr7a4PrWk6PM1tA3AKtNmQXJt5Kd5 bVuJrTDgpDRZg== Date: Thu, 1 Apr 2021 11:42:56 -0500 From: Bjorn Helgaas To: Andy Shevchenko Cc: Henning Schild , Wolfram Sang , Jean Delvare , Lee Jones , Tan Jui Nee , Jim Quinlan , Jonathan Yong , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, Jean Delvare , Peter Tyser , hdegoede@redhat.com Subject: Re: [PATCH v1 3/7] PCI: New Primary to Sideband (P2SB) bridge support library Message-ID: <20210401164256.GA1516177@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 01, 2021 at 06:45:02PM +0300, Andy Shevchenko wrote: > On Tue, Mar 09, 2021 at 09:42:52AM +0100, Henning Schild wrote: > > Am Mon, 8 Mar 2021 19:42:21 -0600 > > schrieb Bjorn Helgaas : > > > On Mon, Mar 08, 2021 at 09:16:50PM +0200, Andy Shevchenko wrote: > > > > On Mon, Mar 08, 2021 at 12:52:12PM -0600, Bjorn Helgaas wrote: > > > > > On Mon, Mar 08, 2021 at 02:20:16PM +0200, Andy Shevchenko wrote: > > ... > > > > > > > + /* Read the first BAR of the device in question */ > > > > > > + __pci_bus_read_base(bus, devfn, pci_bar_unknown, mem, > > > > > > PCI_BASE_ADDRESS_0, true); > > > > > > > > > > I don't get this. Apparently this normally hidden device is > > > > > consuming PCI address space. The PCI core needs to know > > > > > about this. If it doesn't, the PCI core may assign this > > > > > space to another device. > > > > > > > > Right, it returns all 1:s to any request so PCI core *thinks* > > > > it's plugged off (like D3cold or so). > > > > > > I'm asking about the MMIO address space. The BAR is a register > > > in config space. AFAICT, clearing P2SBC_HIDE_BYTE makes that > > > BAR visible. The BAR describes a region of PCI address space. > > > It looks like setting P2SBC_HIDE_BIT makes the BAR disappear > > > from config space, but it sounds like the PCI address space > > > *described* by the BAR is still claimed by the device. If the > > > device didn't respond to that MMIO space, you would have no > > > reason to read the BAR at all. > > > > > > So what keeps the PCI core from assigning that MMIO space to > > > another device? > > > > The device will respond to MMIO while being hidden. I am afraid > > nothing stops a collision, except for the assumption that the BIOS > > is always right and PCI devices never get remapped. But just > > guessing here. > > > > I have seen devices with coreboot having the P2SB visible, and > > most likely relocatable. Making it visible in Linux and not hiding > > it again might work, but probably only as long as Linux will not > > relocate it. Which i am afraid might seriously upset the BIOS, > > depending on what a device does with those GPIOs and which parts > > are implemented in the BIOS. > > So the question is, do we have knobs in PCI core to mark device > fixes in terms of BARs, no relocation must be applied, no other > devices must have the region? I think the closest thing is the IORESOURCE_PCI_FIXED bit that we use for things that must not be moved. Generally PCI resources are associated with a pci_dev, and we set IORESOURCE_PCI_FIXED for BARs, e.g., dev->resource[n]. We do that for IDE legacy regions (see LEGACY_IO_RESOURCE), Langwell devices (pci_fixed_bar_fixup()), "enhanced allocation" (pci_ea_flags()), and some quirks (quirk_io()). In your case, the device is hidden so it doesn't respond to config accesses, so there is no pci_dev for it. Maybe you could do some sort of quirk that allocates its own struct resource, fills it in, sets IORESOURCE_PCI_FIXED, and does something similar to pci_claim_resource()? Bjorn