public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 01/26] Revert "pci: pci-uclass: Dynamically allocate the PCI regions"
Date: Sun,  7 Feb 2021 23:11:01 +0800	[thread overview]
Message-ID: <1612710687-56493-2-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1612710687-56493-1-git-send-email-bmeng.cn@gmail.com>

This reverts commit e002474158d1054a7a2ff9a66149384c639ff242.

Commit e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
changes 'struct pci_controller'.regions from pre-allocated array of
regions to dynamically allocated, which unfortunately broken lots of
boards that still use the non-DM PCI driver.

We may update every non-DM PCI board codes to do the dynamical
allocation of PCI regions but that's a lot of work (e.g.: almost
all Freescale PowerPC boards are broken now and need to be fixed).
Let's do the easy way.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/pci/pci-uclass.c | 14 ++++++--------
 include/pci.h            |  4 +++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index ba65f47..8a94ea2 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -907,7 +907,6 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 	int cells_per_record;
 	struct bd_info *bd;
 	const u32 *prop;
-	int max_regions;
 	int len;
 	int i;
 
@@ -927,13 +926,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 	hose->region_count = 0;
 	debug("%s: len=%d, cells_per_record=%d\n", __func__, len,
 	      cells_per_record);
-
-	/* Dynamically allocate the regions array */
-	max_regions = len / cells_per_record + CONFIG_NR_DRAM_BANKS;
-	hose->regions = (struct pci_region *)
-		calloc(1, max_regions * sizeof(struct pci_region));
-
-	for (i = 0; i < max_regions; i++, len -= cells_per_record) {
+	for (i = 0; i < MAX_PCI_REGIONS; i++, len -= cells_per_record) {
 		u64 pci_addr, addr, size;
 		int space_code;
 		u32 flags;
@@ -987,6 +980,11 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 		return;
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+		if (hose->region_count == MAX_PCI_REGIONS) {
+			pr_err("maximum number of regions parsed, aborting\n");
+			break;
+		}
+
 		if (bd->bi_dram[i].size) {
 			pci_set_region(hose->regions + hose->region_count++,
 				       bd->bi_dram[i].start,
diff --git a/include/pci.h b/include/pci.h
index 5f36537..64dff55 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -610,6 +610,8 @@ extern void pci_cfgfunc_do_nothing(struct pci_controller* hose, pci_dev_t dev,
 extern void pci_cfgfunc_config_device(struct pci_controller* hose, pci_dev_t dev,
 				      struct pci_config_table *);
 
+#define MAX_PCI_REGIONS		7
+
 #define INDIRECT_TYPE_NO_PCIE_LINK	1
 
 /**
@@ -650,7 +652,7 @@ struct pci_controller {
 	 * for PCI controllers and a separate UCLASS (or perhaps
 	 * UCLASS_PCI_GENERIC) is used for bridges.
 	 */
-	struct pci_region *regions;
+	struct pci_region regions[MAX_PCI_REGIONS];
 	int region_count;
 
 	struct pci_config_table *config_table;
-- 
2.7.4

  reply	other threads:[~2021-02-07 15:11 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-07 15:11 [PATCH 00/26] ppc: qemu: Convert qemu-ppce500 to driver model Bin Meng
2021-02-07 15:11 ` Bin Meng [this message]
2021-02-07 15:33   ` [PATCH 01/26] Revert "pci: pci-uclass: Dynamically allocate the PCI regions" Simon Glass
2021-02-07 19:33     ` Tom Rini
2021-02-10  0:46     ` Bin Meng
2021-02-10  2:36       ` Tom Rini
2021-02-10  5:10       ` Simon Glass
2021-02-10  7:13         ` Stefan Roese
2021-02-10 14:13       ` Tom Rini
2021-02-10 14:27         ` Marek Vasut
2021-02-10 14:48           ` Tom Rini
2021-02-10 14:50             ` Marek Vasut
2021-02-14  4:53         ` Bin Meng
2021-02-14 14:35           ` Tom Rini
2021-02-14 14:44             ` Marek Vasut
2021-02-14 14:52               ` Tom Rini
2021-02-14 19:12                 ` Daniel Schwierzeck
2021-02-14 20:30                   ` Tom Rini
2021-02-18  0:32                     ` Bin Meng
2021-02-07 15:11 ` [PATCH 02/26] ppc: qemu: Update MAINTAINERS for correct email address Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-07 15:11 ` [PATCH 03/26] common: fdt_support: Support special case of PCI address in fdt_read_prop() Bin Meng
2021-02-08  4:21   ` Simon Glass
2021-02-08  5:17     ` Bin Meng
2021-02-08 14:08       ` Simon Glass
2021-02-07 15:11 ` [PATCH 04/26] ppc: qemu: Support non-identity PCI bus address Bin Meng
2021-02-07 15:11 ` [PATCH 05/26] ppc: qemu: Fix CONFIG_SYS_PCI_MAP_END Bin Meng
2021-02-07 15:11 ` [PATCH 06/26] ppc: mpc85xx: Wrap LAW related codes with CONFIG_FSL_LAW Bin Meng
2021-02-07 15:11 ` [PATCH 07/26] ppc: qemu: Drop init_laws() and print_laws() Bin Meng
2021-02-07 15:11 ` [PATCH 08/26] ppc: qemu: Drop board_early_init_f() Bin Meng
2021-02-07 15:11 ` [PATCH 09/26] ppc: qemu: Enable OF_CONTROL Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-07 15:11 ` [PATCH 10/26] ppc: qemu: Enable driver model Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-07 15:11 ` [PATCH 11/26] include: Remove extern from addr_map.h Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-07 15:11 ` [PATCH 12/26] lib: addr_map: Move address_map[] type to the header file Bin Meng
2021-02-08  4:21   ` Simon Glass
2021-02-07 15:11 ` [PATCH 13/26] cmd: Add a command to display the address map Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-08  5:12     ` Bin Meng
2021-02-08 14:13       ` Simon Glass
2021-02-07 15:11 ` [PATCH 14/26] lib: kconfig: Mention CONFIG_ADDR_MAP limitation in the help Bin Meng
2021-02-08  4:21   ` Simon Glass
2021-02-07 15:11 ` [PATCH 15/26] ppc: io.h: Use addrmap_ translation APIs only in post-relocation phase Bin Meng
2021-02-07 15:11 ` [PATCH 16/26] common: Move initr_addr_map() to a bit earlier Bin Meng
2021-02-08  4:21   ` Simon Glass
2021-02-07 15:11 ` [PATCH 17/26] ppc: qemu: Switch over to use DM serial Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-07 15:11 ` [PATCH 18/26] pci: mpc85xx: Wrap LAW programming with CONFIG_FSL_LAW Bin Meng
2021-02-07 15:11 ` [PATCH 19/26] pci: mpc85xx: Support controller register physical address beyond 32-bit Bin Meng
2021-02-07 15:11 ` [PATCH 20/26] pci: mpc85xx: Support 64-bit bus and cpu address Bin Meng
2021-02-07 15:11 ` [PATCH 21/26] ppc: qemu: Switch over to use DM ETH and PCI Bin Meng
2021-02-07 15:11 ` [PATCH 22/26] ppc: qemu: Drop CONFIG_OF_BOARD_SETUP Bin Meng
2021-02-07 15:11 ` [PATCH 23/26] cmd: Fix virtio command dependency Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-07 15:11 ` [PATCH 24/26] ppc: qemu: Enable VirtIO NET support Bin Meng
2021-02-07 15:11 ` [PATCH 25/26] ppc: qemu: Move board directory from board/freescale to board/emulation Bin Meng
2021-02-07 15:11 ` [PATCH 26/26] doc: Add a reST document for qemu-ppce500 Bin Meng
2021-02-08  4:20   ` Simon Glass
2021-02-10  0:36 ` [PATCH 00/26] ppc: qemu: Convert qemu-ppce500 to driver model Bin Meng

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=1612710687-56493-2-git-send-email-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox