From patchwork Sat Oct 17 17:50:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 531834 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 604141402B0 for ; Sun, 18 Oct 2015 04:50:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=nawyJhb1; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EDC6C4B635; Sat, 17 Oct 2015 19:50:33 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XOosahteXQ45; Sat, 17 Oct 2015 19:50:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 621024B62A; Sat, 17 Oct 2015 19:50:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 678364B62B for ; Sat, 17 Oct 2015 19:50:30 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XdlBp5bbBnHc for ; Sat, 17 Oct 2015 19:50:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-io0-f178.google.com (mail-io0-f178.google.com [209.85.223.178]) by theia.denx.de (Postfix) with ESMTPS id 0C2E94B62C for ; Sat, 17 Oct 2015 19:50:25 +0200 (CEST) Received: by iow1 with SMTP id 1so154150067iow.1 for ; Sat, 17 Oct 2015 10:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QI31Lxl6SgZSBy8qyVkd05fmgS1flzeyINsqQBb7vMQ=; b=nawyJhb12+4EcBERQ6zMB5h5o7FhtjWiLR+ASQHARVKVBjIODjU87iJIH/ZR81mnQM bcum5eBsq0gaGFabZJLHk578b0/KCoqu/Aw8puaWfSzOmbPsrra52PGFFBw4ZSQWpQpB jqfAlmLSu6UPotpH2vxSHtx2zjMb/C/nkxHxcL+LwVBhBUWSdN+LfI/8YLfOaiSQ6saG qeZq9avT+/H5Mq3j5fOYuiTDUX+zvLmN9o7Oo5qHa6QhKHLsS/xVlaPEH65Ywu/eMq8k Wi6EafjgahFMdO6uvqYcbgP3VZsvB+FkdaNqGyaq8wh0pDUQIhR1PrguC0HwXKIZZ/BW 9WsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QI31Lxl6SgZSBy8qyVkd05fmgS1flzeyINsqQBb7vMQ=; b=MNLpS37ikcK8ymWAYjRCR5fg5iVHgqnurk+fDw0pFhQLRVdOtMMXpvj7cZHeHnDkZz Rk8X+maOalL0bsJEH/WMcB+Wd89NkfNcgnqd4k03WStyobmi8ug/KskHa0QQVyZ/1sqv XVhA+OdIrJBf34xPNB8NhOxrgO6HZLMg8t5denPk7oXUFQchvyyOza5d4ZNOwcgMkQGt jxXjwegN29CC3tu5SR2hkp+JlTIp8k5Ao0nqHDsQVkZnKu/WkExtDN5qE8f0n4wVMQJo jSDehwr+VUQa9LamYaol/hJyAJk3Ts0zOoHiE4/1JXo/GfKURYn7j7NCsC3dcWb4rLT6 Bd8A== X-Gm-Message-State: ALoCoQnab9dhJ6g8wvk1GZd4em0JSaSKoLW8Z1HQYQdW7U7oRCyeec00Ire25xRpSsay5IQ8KrYo X-Received: by 10.107.137.213 with SMTP id t82mr23584577ioi.102.1445104224227; Sat, 17 Oct 2015 10:50:24 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id z133sm614823iod.13.2015.10.17.10.50.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Oct 2015 10:50:23 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id EE6C7220BFC; Sat, 17 Oct 2015 11:50:22 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 17 Oct 2015 11:50:01 -0600 Message-Id: <1445104205-4079-5-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1445104205-4079-1-git-send-email-sjg@chromium.org> References: <1445104205-4079-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Stephen Warren , Tom Warren Subject: [U-Boot] [PATCH 4/8] dm: pci: Support decoding ranges with duplicate entries X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 time. 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. Signed-off-by: Simon Glass --- 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 6dda056..a59e468 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -698,6 +698,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; @@ -720,9 +721,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 */