Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp609353ybg; Fri, 12 Jun 2020 09:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnyezg+Arx61GjzAP+hMkkBu/DDRpvUPktGOet6S9qdzgXp6rLt7ZBmkrxneGHuJI5Zo/G X-Received: by 2002:a17:907:2162:: with SMTP id rl2mr13174621ejb.365.1591980580907; Fri, 12 Jun 2020 09:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591980580; cv=none; d=google.com; s=arc-20160816; b=DyPJjuI+M8WX3M6pIWUe0Hr0jzV56zpDIlgPpEiKdxMnKbrIKXlEZsyMazpRauD8CK Bl/z+XQ8elnm1Ixnus3PRS3dsOzFjbzIrcygmboI2LOAQCPKeqCxVozgRa/GW2RGElBN P92ppTi4jmtnyeBxJRVUvPOXDkwnv1ENWFsAmWT2bdFg1HL6OoFU7uVtmffBzeL1Zfmv m48m42Q2KvZryFx3G58frWpFOw3deuCYhJkcSc2rUXe+lA6tDrEmTwgK/qBu5C2wpoBT Z/VotQeHOMEFGXTPDMQgrSH6GfhU+UJX4GG7N+5cXYfR78+g8F9PcXxKhFcjA+jY1d0Z ztqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tb7anQ0dfUrgS0mQUOKdhrdHXOAgDrwuFfPVco5xa+4=; b=BsuTnJl1lq9rPhzmjqJcSe9zemxAQ6mYyze6APKZgYLbPiEIijp/1RH3//0d6IpNFj WVDrSj32+9neUdKn7D4n5nS7bL20VnjXIQEt/+m1IOfsC2wjyyt8TpxNBbveP0SHjLNY U2GR5n+f8ev4ng0YnsplqhLEczHRhvXhpCeSRamG4gmfOeio8DCIp/dLJGn+c/FVVQMj cxYBfTqhe7Ru0RJWT0raJgEJ8ZYBaKFowt2FBYVjiy1CstQrnGnPL3CZzuCo7zLsrO0F cKehgF9Sci7uwMeyVx2P9ian4LYxvu7GQj4NUBueI0UTpc1iGADg1ACQM7zJ8DexufhN /UVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si4211027ejt.432.2020.06.12.09.49.17; Fri, 12 Jun 2020 09:49:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbgFLQr1 (ORCPT + 99 others); Fri, 12 Jun 2020 12:47:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:59068 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbgFLQr0 (ORCPT ); Fri, 12 Jun 2020 12:47:26 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3C117ACCF; Fri, 12 Jun 2020 16:47:29 +0000 (UTC) From: Nicolas Saenz Julienne To: mbrugger@suse.com, u-boot@lists.denx.de, bmeng.cn@gmail.com, marex@denx.de, linux-kernel@vger.kernel.org Cc: sjg@chromium.org, m.szyprowski@samsung.com, s.nawrocki@samsung.com, mark.kettenis@xs4all.nl, Nicolas Saenz Julienne Subject: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge Date: Fri, 12 Jun 2020 18:46:32 +0200 Message-Id: <20200612164632.25648-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200612164632.25648-1-nsaenzjulienne@suse.de> References: <20200612164632.25648-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node. This permits setups like this to work correctly: pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; }; Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected. Signed-off-by: Nicolas Saenz Julienne --- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 9ab3539a49..ea27e78465 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -762,7 +762,20 @@ static int pci_find_and_bind_driver(struct udevice *parent, str = strdup(name); if (!str) return -ENOMEM; - drv = bridge ? "pci_bridge_drv" : "pci_generic_drv"; + + if (bridge) { + drv = "pci_bridge_drv"; + + /* + * If we're dealing with the root bridge pass the parent device + * node, as there isn't a distinction in device tree between + * that and the actual controller platform device. + */ + if (!PCI_MASK_BUS(bdf)) + node = parent->node; + } else { + drv = "pci_generic_drv"; + } ret = device_bind_driver_to_node(parent, drv, str, node, devp); if (ret) { -- 2.26.2