From patchwork Sun Feb 7 15:11:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1437178 X-Patchwork-Delegate: priyanka.jain@nxp.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DDGlvMmy; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DYXgr3GTJz9sBJ for ; Mon, 8 Feb 2021 02:12:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B59982735; Sun, 7 Feb 2021 16:11:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DDGlvMmy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DF8382731; Sun, 7 Feb 2021 16:11:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D796C826C2 for ; Sun, 7 Feb 2021 16:11:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-ej1-x62b.google.com with SMTP id w1so20639026ejf.11 for ; Sun, 07 Feb 2021 07:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IEgXAzS5/xiHeLOgLg0H2JaCSgHAN3oA3Hz3yQKp4Vk=; b=DDGlvMmyFXdpQf5gbj7hSL5rEymoyDLn56UU7YtuPuEJ6nW5N5mn38LWM+zOuQ9Tph VCvMAlKcq63NvAL8HbcNroxzYNcAvDvUmTUYcxGT9DBLene7CxOGUNsA91+0hjsOd85W G5iG4BLMaNVa5eLhvB5JPn/tlffe1eoxzZQXRKsnBc2VxwZYb5V+TaugIvl1rUBQmYYe jtnTKMGN0dwJccIDh6/Wpj/qK9yTJzktG1PNccVZRxg/10cmYgz/CUmUaEUBE4V1IORF 6U85uS18l9OwHcr5uPc4142J3BfkrCjuXNO/zQR0MwVZinHgiVJzw9drh2PMGSjivP18 vymQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IEgXAzS5/xiHeLOgLg0H2JaCSgHAN3oA3Hz3yQKp4Vk=; b=ZMaupfGedlWUAm61UEf3Yy0v7Em0vh1ra+Bkicd/+LGpLavKLQqKAqXGj/88HYwRwa 3jdjtTVoh8oojsRnZmBCJDb+hH9GSEE2OQaOBT9e8tlOAjrpJe9bqu+o0uduye7S56pm k3onyDAuPIJiXplsbIZfGMCAhAYuUHxlyCx08QO3xinD68RQYBao+pJ5yZm6LSC6kR6w lBZfJlqVJzvomE9zl35hcOAaHvQsU1NVWUKWoQ1pfsIIwCfpErK9f4fHB38cCbjSHQvb htOErRr5o7GKWNR0jlY95THuZ1jfQ/Rabmm9z1S4O17fF8Pw6Rv0qk3b0q6kbrbv0Hc4 IBjg== X-Gm-Message-State: AOAM533BRzsS126c2D1FG4aOmSKVWYSXMUv1aKmCslOgJ3lskcPGYJ92 NjZd40QYB/9y1RPQuO//+0k= X-Google-Smtp-Source: ABdhPJzekCgzi0VKPg0tn/rPIV+v5n+Ok8OSr0LIQeyVjAYaHsW4vhhw5bEgsYl/E7BqNWFkqa7glw== X-Received: by 2002:a17:907:1b02:: with SMTP id mp2mr3902842ejc.419.1612710706611; Sun, 07 Feb 2021 07:11:46 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id w26sm2010399edq.46.2021.02.07.07.11.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Feb 2021 07:11:46 -0800 (PST) From: Bin Meng To: Simon Glass , Alexander Graf , Priyanka Jain Cc: Tom Rini , U-Boot Mailing List , Stefan Roese Subject: [PATCH 01/26] Revert "pci: pci-uclass: Dynamically allocate the PCI regions" Date: Sun, 7 Feb 2021 23:11:01 +0800 Message-Id: <1612710687-56493-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612710687-56493-1-git-send-email-bmeng.cn@gmail.com> References: <1612710687-56493-1-git-send-email-bmeng.cn@gmail.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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 --- 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;