From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7B98C433F5 for ; Mon, 17 Jan 2022 15:40:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 85224834B6; Mon, 17 Jan 2022 16:39:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="Vo3qzHJ+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 127AD837B1; Mon, 17 Jan 2022 16:39:35 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B3704837C4 for ; Mon, 17 Jan 2022 16:39:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4561860FB1; Mon, 17 Jan 2022 15:39:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 895E7C36AF2; Mon, 17 Jan 2022 15:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642433963; bh=Qp+zaNNToqlhx+3fRy9DMQgyI/luMSH556pCt94EGek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vo3qzHJ+0fmt8T60nJFlW6Cqc7tFWEVVy+9LHW/odHv/fd4YxgFIhSJn4lb9hMOup GM1MVt8TF8ynsD5FsgKKe7vfRvWp9PX+7oxW5EWVt/6WVkM2AL94biiUSU/RBMMZo6 Xa8VB+4YCS/sgGTY4cr925Po1CqARwhH5hk6FEukf5kIxvNyjADGWcIKMMxBLBv2/W ZsKKKCz9OGyTp7SNIjuw7u0USHZ7GuXkGXyLK/FQNmdNIdq6Mddb9+GjjspcF/LK+G ACFkr50KElzMlZ1/2FRwPrkSvaeG0/qvwNLW1K5ZiCHcpX1gAeNzv7KX58GawJRoLY OspjQGXl8JBJw== Received: by pali.im (Postfix) id 550971DEC; Mon, 17 Jan 2022 16:39:21 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Bin Meng , Simon Glass , Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: u-boot@lists.denx.de Subject: [PATCH 2/4] pci: Extend 'pci regions' command with bus number Date: Mon, 17 Jan 2022 16:38:38 +0100 Message-Id: <20220117153840.31173-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220117153840.31173-1-pali@kernel.org> References: <20220117153840.31173-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.2 at phobos.denx.de X-Virus-Status: Clean 'pci regions' currently prints only region information from bus 0 which belongs to controller 0. Parser for 'pci regions' cmdline currently ignores any additional arguments and so U-Boot always uses bus 0. Regions are stored in controller (not on the bus) and therefore to retrieve controller from the bus, it is needed to call pci_get_controller() which returns root bus. Because bus 0 is root bus, current code worked fine for controller 0. Extend cmdline parser for 'pci regions' to allows specifying bus number, extend pci_show_regions() code to accept also non-zero bus number and print bus ranges for which is regions configuration assigned. Signed-off-by: Pali Rohár --- cmd/pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/pci.c b/cmd/pci.c index 3b1863f139c9..53edf0d90010 100644 --- a/cmd/pci.c +++ b/cmd/pci.c @@ -443,7 +443,7 @@ static const struct pci_flag_info { static void pci_show_regions(struct udevice *bus) { - struct pci_controller *hose = dev_get_uclass_priv(bus); + struct pci_controller *hose = dev_get_uclass_priv(pci_get_controller(bus)); const struct pci_region *reg; int i, j; @@ -452,6 +452,7 @@ static void pci_show_regions(struct udevice *bus) return; } + printf("Buses %02x-%02x\n", hose->first_busno, hose->last_busno); printf("# %-18s %-18s %-18s %s\n", "Bus start", "Phys start", "Size", "Flags"); for (i = 0, reg = hose->regions; i < hose->region_count; i++, reg++) { @@ -520,8 +521,9 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) value = 0; argc--; } - if (argc > 1) - busnum = hextoul(argv[1], NULL); + if (argc > 2 || (argc > 1 && cmd != 'r' && argv[1][0] != 's')) { + busnum = hextoul(argv[argc - 1], NULL); + } } ret = uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus); if (ret) { @@ -586,7 +588,7 @@ static char pci_help_text[] = " - show header of PCI device 'bus.device.function'\n" "pci bar b.d.f\n" " - show BARs base and size for device b.d.f'\n" - "pci regions\n" + "pci regions [bus]\n" " - show PCI regions\n" "pci display[.b, .w, .l] b.d.f [address] [# of objects]\n" " - display PCI configuration space (CFG)\n" -- 2.20.1