All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v1 03/24] pci: pci-uclass: Dynamically allocate the PCI regions
Date: Tue, 28 Jul 2020 13:01:28 -0600	[thread overview]
Message-ID: <CAPnjgZ2E8Js4gEW3K-NcqtMuVxGDWW35Umpx9v+bc4XuK1VVKA@mail.gmail.com> (raw)
In-Reply-To: <20200724100856.1482324-4-sr@denx.de>

Hi Stefan,

On Fri, 24 Jul 2020 at 04:09, Stefan Roese <sr@denx.de> wrote:
>
> Instead of using a fixed length pre-allocated array of regions, this
> patch moves to dynamically allocating the regions based on the number
> of available regions plus the necessary regions for DRAM banks.
>
> Since MAX_PCI_REGIONS is not needed any more, its removed completely
> with this patch.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> ---
>
> Changes in v1:
> - New patch, replaces increase of MAX_PCI_REGIONS to 10
>
>  board/renesas/rcar-common/common.c | 10 +++++-----
>  drivers/pci/pci-uclass.c           | 14 ++++++++------
>  include/pci.h                      |  4 +---
>  3 files changed, 14 insertions(+), 14 deletions(-)
>

Can you please split out the generic PCI changes into a separate patch?

> diff --git a/board/renesas/rcar-common/common.c b/board/renesas/rcar-common/common.c
> index 83dd288847..83440c11ef 100644
> --- a/board/renesas/rcar-common/common.c
> +++ b/board/renesas/rcar-common/common.c
> @@ -58,12 +58,12 @@ int ft_board_setup(void *blob, struct bd_info *bd)
>         uclass_foreach_dev(dev, uc) {
>                 struct pci_controller hose = { 0 };
>
> -               for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
> -                       if (hose.region_count == MAX_PCI_REGIONS) {
> -                               printf("maximum number of regions parsed, aborting\n");
> -                               break;
> -                       }
> +               /* Dynamically allocate the regions array */

Why is the driver allocating this? Shouldn't it happen in pci-uclass.c ?


> +               hose.regions = (struct pci_region *)
> +                       calloc(1, CONFIG_NR_DRAM_BANKS *
> +                              sizeof(struct pci_region));
>
> +               for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
>                         if (bd->bi_dram[i].size) {
>                                 pci_set_region(&hose.regions[hose.region_count++],
>                                                bd->bi_dram[i].start,
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 69fb46d3f4..0fbbef70c8 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -874,6 +874,7 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
>         struct bd_info *bd = gd->bd;
>         int cells_per_record;
>         const u32 *prop;
> +       int max_regions;
>         int len;
>         int i;
>
> @@ -893,7 +894,13 @@ 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);
> -       for (i = 0; i < MAX_PCI_REGIONS; i++, 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) {
>                 u64 pci_addr, addr, size;
>                 int space_code;
>                 u32 flags;
> @@ -943,11 +950,6 @@ 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 281f353916..53f1386fd4 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -590,8 +590,6 @@ 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
>
>  /**
> @@ -632,7 +630,7 @@ struct pci_controller {
>          * for PCI controllers and a separate UCLASS (or perhaps
>          * UCLASS_PCI_GENERIC) is used for bridges.
>          */
> -       struct pci_region regions[MAX_PCI_REGIONS];
> +       struct pci_region *regions;
>         int region_count;
>
>         struct pci_config_table *config_table;
> --
> 2.27.0
>

  reply	other threads:[~2020-07-28 19:01 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 10:08 [PATCH v1 00/24] arm: Introduce Marvell/Cavium OcteonTX/TX2 Stefan Roese
2020-07-24 10:08 ` [PATCH v1 01/24] fdtdec: Add API to read pci bus-range property Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-30 15:09     ` Stefan Roese
2020-07-24 10:08 ` [PATCH v1 02/24] pci: pci-uclass: Remove #ifdef CONFIG_NR_DRAM_BANKS as its always set Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 03/24] pci: pci-uclass: Dynamically allocate the PCI regions Stefan Roese
2020-07-28 19:01   ` Simon Glass [this message]
2020-07-30 15:16     ` Stefan Roese
2020-08-05  9:12       ` Stefan Roese
2020-07-24 10:08 ` [PATCH v1 04/24] pci: pci-uclass: Fix incorrect argument in map_sysmem Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 05/24] pci: pci-uclass: Make DT subnode parse optional Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 06/24] pci: pci-uclass: Add multi entry support for memory regions Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-30 15:35     ` Stefan Roese
2020-07-31 18:44       ` Simon Glass
2020-08-04 14:03         ` Stefan Roese
2020-08-04 15:05           ` Simon Glass
2020-08-14 11:40             ` Stefan Roese
2020-08-22 15:09               ` Simon Glass
2020-08-23  9:41                 ` Stefan Roese
2020-08-23 14:03                   ` Tom Rini
2020-08-24  7:36                     ` Stefan Roese
2020-08-24 13:09                       ` Tom Rini
2020-08-25 15:04                         ` Simon Glass
2020-08-25 15:09                           ` Tom Rini
2020-07-24 10:08 ` [PATCH v1 07/24] pci: pci-uclass: Add support for Enhanced Allocation in Bridges Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 08/24] pci: pci-uclass: Add support for Single-Root I/O Virtualization Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 09/24] pci: pci-uclass: Add VF BAR map support for Enhanced Allocation Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 10/24] pci: pci-uclass: Add support for Alternate-RoutingID capability Stefan Roese
2020-07-24 10:08 ` [PATCH v1 11/24] pci: pci-uclass: Check validity of ofnode Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 12/24] arm: include/asm/io.h: Add 64bit clrbits and setbits helpers Stefan Roese
2020-07-24 10:08 ` [PATCH v1 13/24] arm: octeontx: Add headers for OcteonTX Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-31 14:21     ` Stefan Roese
2020-07-31 18:44       ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 14/24] arm: octeontx2: Add headers for OcteonTX2 Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-31 14:23     ` Stefan Roese
2020-07-24 10:08 ` [PATCH v1 15/24] ata: ahci: Add BAR index quirk for Cavium PCI SATA device Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-30 15:41     ` Stefan Roese
2020-07-31 18:35       ` Simon Glass
2020-08-04 13:37         ` Stefan Roese
2020-07-24 10:08 ` [PATCH v1 16/24] pci: Add PCI controller driver for OcteonTX / TX2 Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-30 16:25     ` Stefan Roese
2020-07-31 18:44       ` Simon Glass
2020-08-05 13:25         ` Stefan Roese
2020-07-24 10:08 ` [PATCH v1 17/24] mmc: Remove static qualifier on mmc_power_init Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-24 10:08 ` [PATCH v1 18/24] mmc: Add MMC controller driver for OcteonTX / TX2 Stefan Roese
2020-07-24 10:08 ` [PATCH v1 19/24] mtd: nand: Add NAND controller driver for OcteonTX Stefan Roese
2020-07-24 10:08 ` [PATCH v1 20/24] net: Add NIC " Stefan Roese
2020-07-24 10:08 ` [PATCH v1 21/24] net: Add NIC controller driver for OcteonTX2 Stefan Roese
2020-07-24 10:08 ` [PATCH v1 22/24] watchdog: Add reset support for OcteonTX / TX2 Stefan Roese
2020-07-28 19:01   ` Simon Glass
2020-07-31 14:25     ` Stefan Roese
2020-08-05 13:47       ` Stefan Roese
2020-07-24 10:08 ` [PATCH v1 23/24] arm: octeontx: Add support for OcteonTX SoC platforms Stefan Roese
2020-07-24 10:08 ` [PATCH v1 24/24] arm: octeontx2: Add support for OcteonTX2 " Stefan Roese

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=CAPnjgZ2E8Js4gEW3K-NcqtMuVxGDWW35Umpx9v+bc4XuK1VVKA@mail.gmail.com \
    --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.