From patchwork Thu Aug 5 08:28:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12420631 X-Patchwork-Delegate: robh@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15390C4320A for ; Thu, 5 Aug 2021 08:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DEDF3610FC for ; Thu, 5 Aug 2021 08:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239471AbhHEI3X (ORCPT ); Thu, 5 Aug 2021 04:29:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:44514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234559AbhHEI3W (ORCPT ); Thu, 5 Aug 2021 04:29:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16DD260EBC; Thu, 5 Aug 2021 08:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628152149; bh=UrIWFc7afenUxoN8+PAqdiMMD3Kbx2IdAKavVf2zlSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D5lv+kSHXKU6RGsELotrmJvaldo8hI2Thnc77w6J2D5e0vBKMHiljyJll3LtD09or Lxr/ku4Dbl9L2mH2I+AIHk6JTVSR6J/+Ezx8HqXGFKrio9SAavXw2QdHIK67Ge0gKe QZV69x0UKi5exEzw8CmigU64xljgbivOINeFjSgIyjawtx2wdyRAYqMO56qgPZTiBm dhYeIiRVVFQ2Jg9t6vK/YXWw4O4kV7vWJdmkZ+P2Ce+6HuNMP72btrPvraLg9Ugz9r aZvNXkvPSsHYemWAJX3OnjsjLPbVBfMK6QYoWCEeeIQm4/RN1q0XK2mOjaXszOtyYF Y4GeSXmXKijow== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mBYkP-001DuV-Sg; Thu, 05 Aug 2021 10:29:01 +0200 From: Mauro Carvalho Chehab To: Rob Herring Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 1/3] PCI: of: Fix handling of multi-level PCI devices Date: Thu, 5 Aug 2021 10:28:58 +0200 Message-Id: <3365235394fe4e7f35694c95af95fce96da7c9bb.1628151761.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org When the DT schema is like: pcie@f4000000 { pcie@0,0 { pcie@1,0 { }; pcie@5,0 { }; pcie@7,0 { }; }; }; The logic under pci_set_bus_of_node() will try to setup some buses with a NULL node, causing it to register just a small set of devices: $ find /sys/devices/platform/soc/f4000000.pcie/ -name of_node /sys/devices/platform/soc/f4000000.pcie/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/pci_bus/0000:01/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/pci_bus/0000:00/of_node On such case, it needs to go to the parent node, in order to register everything: $ find /sys/devices/platform/soc/f4000000.pcie/ -name of_node /sys/devices/platform/soc/f4000000.pcie/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:07.0/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:07.0/pci_bus/0000:06/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/pci_bus/0000:02/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:05.0/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:05.0/pci_bus/0000:05/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:01.0/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/0000:02:01.0/pci_bus/0000:03/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/pci_bus/0000:01/of_node /sys/devices/platform/soc/f4000000.pcie/pci0000:00/pci_bus/0000:00/of_node Adding some debug prints with such change will produce the following output: $ dmesg|grep of_node [ 4.932405] (null): pci_set_bus_of_node: of_node: /soc/pcie@f4000000 [ 4.985916] pci 0000:00:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000 [ 5.014190] pci_bus 0000:01: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.065680] pci 0000:01:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.118754] pci_bus 0000:02: pci_set_bus_of_node: use of_node of the parent [ 5.135279] pci_bus 0000:02: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.158921] pci 0000:02:01.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.187393] pci 0000:02:04.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.215982] pci 0000:02:05.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.244607] pci 0000:02:07.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.272825] pci 0000:02:09.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0 [ 5.335258] pci_bus 0000:03: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@1,0 [ 5.367538] pci 0000:03:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@1,0 [ 5.415959] pci_bus 0000:04: pci_set_bus_of_node: use of_node of the parent [ 5.424190] pci_bus 0000:04: pci_set_bus_of_node: of_node: (null) [ 5.438727] pci_bus 0000:05: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@5,0 [ 5.455691] pci_bus 0000:06: pci_set_bus_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@7,0 [ 5.491643] pci 0000:06:00.0: pci_set_of_node: of_node: /soc/pcie@f4000000/pcie@0,0/pcie@7,0 [ 5.526157] pci_bus 0000:07: pci_set_bus_of_node: use of_node of the parent [ 5.534361] pci_bus 0000:07: pci_set_bus_of_node: of_node: (null) Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/of.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index a143b02b2dcd..b6fa3bd46ae6 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -41,6 +41,8 @@ void pci_set_bus_of_node(struct pci_bus *bus) node = pcibios_get_phb_of_node(bus); } else { node = of_node_get(bus->self->dev.of_node); + if (!node) + node = of_node_get(bus->self->dev.parent->of_node); if (node && of_property_read_bool(node, "external-facing")) bus->self->external_facing = true; } From patchwork Thu Aug 5 08:28:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12420629 X-Patchwork-Delegate: robh@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDF48C4338F for ; Thu, 5 Aug 2021 08:29:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CB60610FC for ; Thu, 5 Aug 2021 08:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239462AbhHEI3X (ORCPT ); Thu, 5 Aug 2021 04:29:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:44512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233871AbhHEI3W (ORCPT ); Thu, 5 Aug 2021 04:29:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14D1C60F43; Thu, 5 Aug 2021 08:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628152149; bh=yWq8YLyiFewgrTfnETHlC/L3kFIsqG78OX2q0kQmbRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1WNQnAWBAGniaPG60IxnhgbSvUpwPf//+BZ4Drhtsr9Kny8e3rr5vx0p14xA9JYI RBn3IyV/9yTx5/SsEpeZ43GVz/0Z1uMqEPJDyRe5zaJSgAjZW1cFEyRIP1ZvjvmEWG dsK3PA0DekE77A64g3OTdV9CYyl/dZrOF+L9cUj/dmAJ99mKIAg1WVCXhhjhm8h1YR lz4RNycAKYMqKkzI6zEUDDYYWkxZWdh1yJxZz9eWUEic0TuDDVn4y2ssb0IkEPeypY Jw0YL9tHl2eg+5ZLfUqh98ZR22Jjxz1IKbLoYL4whDoDpzB2LZ6QBViZvFzbsG2ve4 Fn/U+cJr+PPZQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mBYkP-001DuY-UI; Thu, 05 Aug 2021 10:29:01 +0200 From: Mauro Carvalho Chehab To: Rob Herring Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 2/3] PCI: of: Setup PCI before setting the OF node Date: Thu, 5 Aug 2021 10:28:59 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org With this change, it is easier to add a debug printk at pci_set_of_node() in order to address possible issues. Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/probe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 79177ac37880..c5dfc1afb1d3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2374,15 +2374,14 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) dev->vendor = l & 0xffff; dev->device = (l >> 16) & 0xffff; - pci_set_of_node(dev); - if (pci_setup_device(dev)) { - pci_release_of_node(dev); pci_bus_put(dev->bus); kfree(dev); return NULL; } + pci_set_of_node(dev); + return dev; } From patchwork Thu Aug 5 08:29:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12420635 X-Patchwork-Delegate: robh@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA97CC4320E for ; Thu, 5 Aug 2021 08:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 834F8610FC for ; Thu, 5 Aug 2021 08:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239495AbhHEI3Y (ORCPT ); Thu, 5 Aug 2021 04:29:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:44526 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239448AbhHEI3W (ORCPT ); Thu, 5 Aug 2021 04:29:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C0AA6105A; Thu, 5 Aug 2021 08:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628152149; bh=PXKl7KMyp7SLlsXgaxi3qGWK1QDFQApdkdN/A03yZq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N/mCiZWdZanEJLQArYEgGe0ZP3oJVB72D0XLbep1VHeBPl1kKXu4Nr8AK3OttYSlZ awlT+wDjhCwtc9l9K9L3eIP5Tp/Cw0XumsnG1P7Ml8wwcakIL/IBXhzRMk2UfuSO8J gWVQYG5Dgb6q2pqnNV+e7btj48s9Fn8YxS31UGEmrW38QcBES1+k0qe42FvhLOi2wm Wda1m37Fob0XR3zNGn5PHIbFaHI7jD1IdguZ4DwRM6fYwvz4Vht5VVX7Umapv0KdjE s9cvGxRi8W8NlqChYdPIHIXVQukon8KVBUazU6nruumsY5KkW+dMdqPDD9ust0YXXW Ov/kaI/Q8Pxxg== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mBYkP-001Dub-Vb; Thu, 05 Aug 2021 10:29:01 +0200 From: Mauro Carvalho Chehab To: Rob Herring Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Bjorn Helgaas , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 3/3] PCI: of: Add some debug printks to track problems with of_node setup Date: Thu, 5 Aug 2021 10:29:00 +0200 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org In order to be able to identify why some of_nodes are not created, we need to add some debug prints. Signed-off-by: Mauro Carvalho Chehab --- drivers/pci/of.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index b6fa3bd46ae6..7b8c2b87eb25 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -18,6 +18,9 @@ #ifdef CONFIG_PCI void pci_set_of_node(struct pci_dev *dev) { + dev_dbg(&dev->dev, "%s: of_node: %pOF\n", + __func__, dev->bus->dev.of_node); + if (!dev->bus->dev.of_node) return; dev->dev.of_node = of_pci_find_child_device(dev->bus->dev.of_node, @@ -41,12 +44,16 @@ void pci_set_bus_of_node(struct pci_bus *bus) node = pcibios_get_phb_of_node(bus); } else { node = of_node_get(bus->self->dev.of_node); - if (!node) + if (!node) { node = of_node_get(bus->self->dev.parent->of_node); + dev_dbg(&bus->dev, "%s: use of_node of the parent", + __func__); + } if (node && of_property_read_bool(node, "external-facing")) bus->self->external_facing = true; } + dev_dbg(&bus->dev, "%s: of_node: %pOF\n", __func__, node); bus->dev.of_node = node; if (bus->dev.of_node)