All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: linux-arm-kernel@lists.infradead.org
Cc: Rob Herring <rob.herring@calxeda.com>,Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH 1/3] ARM: pci: make bus I/O resources optional
Date: Fri, 26 Mar 2021 12:18:08 +0000	[thread overview]
Message-ID: <E1lPlPk-0007oG-2X@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20210326121735.GQ1463@shell.armlinux.org.uk>

Adding a bus I/O resource that extends from pcibios_min_io to the top
of PCI space breaks Footbridge based platforms, which may have ISA
southbridges and IDE controllers that are in legacy mode.

The PCI I/O space on these machines really does cover port addresses
from zero upwards, even when pcibios_min_io is non-zero.

Fix this by making Rob's changes optional - Rob's change is probably
based on a misunderstanding of what pcibios_min_io is - it is the
minimum IO port address that we wish to start allocating bus resources
which may not be the same as the minimum IO port address for the bus.

Fixes: 3c5d1699887b ("ARM: move PCI i/o resource setup into common code")
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 arch/arm/include/asm/mach/pci.h |  1 +
 arch/arm/kernel/bios32.c        | 37 ++++++++++++++++++++-------------
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/arch/arm/include/asm/mach/pci.h b/arch/arm/include/asm/mach/pci.h
index 83d340702680..0f96c2462ee5 100644
--- a/arch/arm/include/asm/mach/pci.h
+++ b/arch/arm/include/asm/mach/pci.h
@@ -21,6 +21,7 @@ struct hw_pci {
 	struct pci_ops	*ops;
 	int		nr_controllers;
 	unsigned int	io_optional:1;
+	unsigned int	no_bus_ioport_resource:1;
 	void		**private_data;
 	int		(*setup)(int nr, struct pci_sys_data *);
 	int		(*scan)(int nr, struct pci_host_bridge *);
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index ed46ca69813d..c48476193687 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -412,10 +412,11 @@ static int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 }
 
 static int pcibios_init_resource(int busnr, struct pci_sys_data *sys,
-				 int io_optional)
+				 int io_optional, int bus_ioport_resource)
 {
-	int ret;
 	struct resource_entry *window;
+	struct resource *res;
+	int ret;
 
 	if (list_empty(&sys->resources)) {
 		pci_add_resource_offset(&sys->resources,
@@ -434,19 +435,25 @@ static int pcibios_init_resource(int busnr, struct pci_sys_data *sys,
 		if (resource_type(window->res) == IORESOURCE_IO)
 			return 0;
 
-	sys->io_res.start = (busnr * SZ_64K) ?  : pcibios_min_io;
-	sys->io_res.end = (busnr + 1) * SZ_64K - 1;
-	sys->io_res.flags = IORESOURCE_IO;
-	sys->io_res.name = sys->io_res_name;
-	sprintf(sys->io_res_name, "PCI%d I/O", busnr);
+	if (bus_ioport_resource) {
+		sys->io_res.start = (busnr * SZ_64K) ?  : pcibios_min_io;
+		sys->io_res.end = (busnr + 1) * SZ_64K - 1;
+		sys->io_res.flags = IORESOURCE_IO;
+		sys->io_res.name = sys->io_res_name;
+		sprintf(sys->io_res_name, "PCI%d I/O", busnr);
+
+		ret = request_resource(&ioport_resource, &sys->io_res);
+		if (ret) {
+			pr_err("PCI: unable to allocate I/O port region (%d)\n", ret);
+			return ret;
+		}
 
-	ret = request_resource(&ioport_resource, &sys->io_res);
-	if (ret) {
-		pr_err("PCI: unable to allocate I/O port region (%d)\n", ret);
-		return ret;
+		res = &sys->io_res;
+	} else {
+		res = &ioport_resource;
 	}
-	pci_add_resource_offset(&sys->resources, &sys->io_res,
-				sys->io_offset);
+
+	pci_add_resource_offset(&sys->resources, res, sys->io_offset);
 
 	return 0;
 }
@@ -478,8 +485,8 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,
 		ret = hw->setup(nr, sys);
 
 		if (ret > 0) {
-
-			ret = pcibios_init_resource(nr, sys, hw->io_optional);
+			ret = pcibios_init_resource(nr, sys, hw->io_optional,
+						  !hw->no_bus_ioport_resource);
 			if (ret)  {
 				pci_free_host_bridge(bridge);
 				break;
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-26 12:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 12:17 [PATCH 0/3] Fix Footbridge PCI I/O resources Russell King - ARM Linux admin
2021-03-26 12:18 ` Russell King [this message]
2021-03-26 13:33   ` [PATCH 1/3] ARM: pci: make bus I/O resources optional Arnd Bergmann
2021-03-26 13:39     ` Russell King - ARM Linux admin
2021-03-26 14:01       ` Arnd Bergmann
2021-03-26 12:18 ` [PATCH 2/3] ARM: footbridge: avoid using separate PCI I/O bus resource Russell King
2021-03-26 12:18 ` [PATCH 3/3] ARM: footbridge: restore allocation of CSR I/O resource Russell King
2021-03-26 13:37   ` Arnd Bergmann
2021-03-26 13:40     ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1lPlPk-0007oG-2X@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=rob.herring@calxeda.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.