All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/8] dm: pci: Support decoding ranges with duplicate entries
Date: Thu, 12 Nov 2015 09:07:22 -0700	[thread overview]
Message-ID: <1447344446-17277-5-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1447344446-17277-1-git-send-email-sjg@chromium.org>

At present we add a new resource entry for every range entry. But some range
entries refer to configuration regions. To make this work, avoid adding two
regions of the same type. The later ranges will overwrite the earlier
(configuration) ones.

There does not seem to be a way to distinguish the configuration ranges
other than by ordering (as per the device tree binding).

We could perhaps instead just store one region of each type in a simple
array. Once we are sure that we don't need to support multiple regions, we
could change this. It would be easier to do it when all drivers are
converted to use driver model for PCI.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Update commit message to mention future work

 drivers/pci/pci-uclass.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 6d860c4..7b48879 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -704,6 +704,7 @@ static int decode_regions(struct pci_controller *hose, const void *blob,
 		int space_code;
 		u32 flags;
 		int type;
+		int pos;
 
 		if (len < cells_per_record)
 			break;
@@ -726,9 +727,15 @@ static int decode_regions(struct pci_controller *hose, const void *blob,
 		} else {
 			continue;
 		}
-		debug(" - type=%d\n", type);
-		pci_set_region(hose->regions + hose->region_count++, pci_addr,
-			       addr, size, type);
+		pos = -1;
+		for (i = 0; i < hose->region_count; i++) {
+			if (hose->regions[i].flags == type)
+				pos = i;
+		}
+		if (pos == -1)
+			pos = hose->region_count++;
+		debug(" - type=%d, pos=%d\n", type, pos);
+		pci_set_region(hose->regions + pos, pci_addr, addr, size, type);
 	}
 
 	/* Add a region for our local memory */
-- 
2.6.0.rc2.230.g3dd15c0

  parent reply	other threads:[~2015-11-12 16:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 16:07 [U-Boot] [PATCH v2 0/8] dm: pci: tegra: Convert Tegra PCI to driver model Simon Glass
2015-11-12 16:07 ` [U-Boot] [PATCH v2 1/8] dm: tegra: pci: Move CONFIG_PCI_TEGRA to Kconfig Simon Glass
2015-11-12 16:07 ` [U-Boot] [PATCH v2 2/8] dm: pci: Avoid a driver model build error with CONFIG_CMD_PCI_ENUM Simon Glass
2015-11-12 16:07 ` [U-Boot] [PATCH v2 3/8] dm: pci: Set up the SDRAM mapping correctly Simon Glass
2015-11-12 16:07 ` Simon Glass [this message]
2015-11-12 16:07 ` [U-Boot] [PATCH v2 5/8] dm: pci: Add functions to emulate 8- and 16-bit access Simon Glass
2015-11-12 16:07 ` [U-Boot] [PATCH v2 6/8] dm: pci: Add a function to get the controller for a bus Simon Glass
2015-11-12 16:07 ` [U-Boot] [PATCH v2 7/8] dm: pci: Add a function to find the regions for a PCI bus Simon Glass
2015-11-12 16:07 ` [U-Boot] [PATCH v2 8/8] dm: tegra: pci: Convert tegra boards to driver model for PCI Simon Glass
2015-11-12 16:16   ` Tom Warren
2015-11-12 16:41     ` Stephen Warren
2015-11-12 16:58       ` Tom Warren
2015-11-12 17:02         ` Simon Glass
2015-11-12 16:51     ` Simon Glass
2015-11-12 17:00       ` Tom Warren

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=1447344446-17277-5-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --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 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.