From nobody Sat Feb 7 08:02:18 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D8B21FE457; Mon, 2 Dec 2024 13:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145355; cv=none; b=bhvC8HXH00tZc2MYvT6CTkNUJ8wXvtO8HRwyc7Y3v2PVpW7IxIRlsca6sxwrGry6bqZkUcmfn8wcj6y/qOxT9740E56N0TEeumYGESPYqfEXthm5D9O4m+MtWpTT5HbQjRJ03JKQyYD67AmtWhQH3S+MYW1RCV1wCOUxQNV5Hdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145355; c=relaxed/simple; bh=MXo9qknpg/+O6aSt5D4boZNtCfs9E34s+VnJp5uU0F4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJ0Zc0H6+xnPyMOysysdbfMbTtL0vyXpXXT0IFnldJUx2DJ0fqQE6gqWnN84alhGpDTeUXXFQOeUOTZ21kFjE2vyboZG+KADf8H4/NOTxwoGfbjGGCfLrjliePFfDqlOea9Ibdq+921OsWzaYb8p0yp64H6MvMSqmulj4gvxi9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=mHr36Ocs; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mHr36Ocs" Received: by mail.gandi.net (Postfix) with ESMTPA id 182C6C0002; Mon, 2 Dec 2024 13:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733145345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ohmmf1f1Tk0D6JeMPzj0EkbnDhwhxLtjoCBBfJqa1U4=; b=mHr36OcsfTU27NHmM/RhKbgD5xskIe0akyUqRTkGMyH5sNUVW5hMRBdE9OWJzj9Uw+k4te k7FGtry/e1XO3KYMAKxEyY+NZtZ0AKE8kKo/IZ2IOOxjApCT0qm7uLUdUk0CVVMkSL3J4M JSGnRhX5RoeiBMu8R6txjssfyeAr2bdz9NZ/hCSRgEHFJeSYHhNzvwLQnpCYHkJz4mGYVB ebtbj8dawnIrbmukJXIRvCO4ybVqut5cLPh+pyIAIs7KNq7sofG0d2m16fqvy/nQeENXo2 BRaMKzUilhS//zydImJWGUqLBYtW48DjxNhRHys5b6afYFZai0ldBJ0uUwBxIQ== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v4 1/6] driver core: Introduce device_{add,remove}_of_node() Date: Mon, 2 Dec 2024 14:15:13 +0100 Message-ID: <20241202131522.142268-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202131522.142268-1-herve.codina@bootlin.com> References: <20241202131522.142268-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" An of_node can be set to a device using device_set_node(). This function cannot prevent any of_node and/or fwnode overwrites. When adding an of_node on an already present device, the following operations need to be done: - Attach the of_node if no of_node were already attached - Attach the of_node as a fwnode if no fwnode were already attached This is the purpose of device_add_of_node(). device_remove_of_node() reverts the operations done by device_add_of_node(). Signed-off-by: Herve Codina --- drivers/base/core.c | 52 ++++++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 2 ++ 2 files changed, 54 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 8b056306f04e..3953c5ab7316 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -5216,6 +5216,58 @@ void set_secondary_fwnode(struct device *dev, struct= fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(set_secondary_fwnode); =20 +/** + * device_remove_of_node - Remove an of_node from a device + * @dev: device whose device-tree node is being removed + */ +void device_remove_of_node(struct device *dev) +{ + dev =3D get_device(dev); + if (!dev) + return; + + if (!dev->of_node) + goto end; + + if (dev->fwnode =3D=3D of_fwnode_handle(dev->of_node)) + dev->fwnode =3D NULL; + + of_node_put(dev->of_node); + dev->of_node =3D NULL; + +end: + put_device(dev); +} +EXPORT_SYMBOL_GPL(device_remove_of_node); + +/** + * device_add_of_node - Add an of_node to an existing device + * @dev: device whose device-tree node is being added + * @of_node: of_node to add + */ +void device_add_of_node(struct device *dev, struct device_node *of_node) +{ + if (!of_node) + return; + + dev =3D get_device(dev); + if (!dev) + return; + + if (WARN(dev->of_node, "%s: Cannot replace node %pOF with %pOF\n", + dev_name(dev), dev->of_node, of_node)) + goto end; + + dev->of_node =3D of_node_get(of_node); + + if (!dev->fwnode) + dev->fwnode =3D of_fwnode_handle(of_node); + +end: + put_device(dev); +} +EXPORT_SYMBOL_GPL(device_add_of_node); + /** * device_set_of_node_from_dev - reuse device-tree node of another device * @dev: device whose device-tree node is being set diff --git a/include/linux/device.h b/include/linux/device.h index 667cb6db9019..ef4c0f3c41cd 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1149,6 +1149,8 @@ int device_online(struct device *dev); void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode); void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode= ); void device_set_node(struct device *dev, struct fwnode_handle *fwnode); +void device_add_of_node(struct device *dev, struct device_node *of_node); +void device_remove_of_node(struct device *dev); void device_set_of_node_from_dev(struct device *dev, const struct device *= dev2); =20 static inline struct device_node *dev_of_node(struct device *dev) --=20 2.47.0 From nobody Sat Feb 7 08:02:18 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D8531FDE34; Mon, 2 Dec 2024 13:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145355; cv=none; b=P824DTzc2KV3Hf0Lmv4ziQD7K6b10zBkIUodqE0/G6mAJKXD+y8S4eUVW7EZcSMwBsm4ApBQ0Lm4zj6RZjjxTAr+I1o268314NuYK0f2PE95Stw9CSesZbAMFxTbe7Q4D9F7EIt4kGC04meiqOMocEVI5/wG/ZvESY1zLqBOSSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145355; c=relaxed/simple; bh=4UvhhQ1Jex31RMk9g02TFZQDPBVoUdYag+WpQcTXYHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=omGWe+CdRzDf7T8HQXI+PlF08aT+kFU/02J8b1w1m6JWOguSSmrnLTf24njyp0yjlkOuLbcAaHBTQ9M9OVfmhKgixrKMaaEQSvsb3CPJXPm2F24E3P7KGbjTpevdZ686ZU+cOn5Yn1hBRYJL1kwvRTMRZ+V3P9WAb7UBhQL9leY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BvD+mYQb; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="BvD+mYQb" Received: by mail.gandi.net (Postfix) with ESMTPA id D2083C000B; Mon, 2 Dec 2024 13:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733145346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FXg4BZgKA1+Ndy4F/ZpFJ4y1Qvg3Ti15BrIzt2+zxYY=; b=BvD+mYQbJGtUgeZ9Sh7LgADooVVFb3212hNPChXaC2bPG8eHLzoUFWwxeAdGABYQa7ANqG 4WO71eOYJn0m/fAMcxydV743pbGT4cb+J/G2E2gkzzy1aVGqMn8wc8r+riPRSaUWvb8TfH 3krpRxDbTHv40XFsH2lVcnjWphzOloS/FLBXyiNMRF9F+Bc3Y2kE5zYRKaDh5lJeZcFsiB 6k+Gb6nYNGNbTVA7degIi+6o8RCYgyEFpbVe+CRVCyNOIOxm77bUvcxwI+ZM9YXfPDuAyn Y+kKfN0ma8R1XyiVJUEKltwem/R4ar4SuHOA4qVYdlkIEk/6jqFZSEAblthmHA== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v4 2/6] PCI: of: Use device_{add,remove}_of_node() to attach of_node to existing device Date: Mon, 2 Dec 2024 14:15:14 +0100 Message-ID: <20241202131522.142268-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202131522.142268-1-herve.codina@bootlin.com> References: <20241202131522.142268-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" The commit 407d1a51921e ("PCI: Create device tree node for bridge") creates of_node for PCI devices. The newly created of_node is attached to an existing device. This is done setting directly pdev->dev.of_node in the code. Even if pdev->dev.of_node cannot be previously set, this doesn't handle the fwnode field of the struct device. Indeed, this field needs to be set if it hasn't already been set. device_{add,remove}_of_node() have been introduced to handle this case. Use them instead of the direct setting. Signed-off-by: Herve Codina --- drivers/pci/of.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 52f770bcc481..3cca33105b85 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -655,8 +655,8 @@ void of_pci_remove_node(struct pci_dev *pdev) np =3D pci_device_to_OF_node(pdev); if (!np || !of_node_check_flag(np, OF_DYNAMIC)) return; - pdev->dev.of_node =3D NULL; =20 + device_remove_of_node(&pdev->dev); of_changeset_revert(np->data); of_changeset_destroy(np->data); of_node_put(np); @@ -713,7 +713,7 @@ void of_pci_make_dev_node(struct pci_dev *pdev) goto out_free_node; =20 np->data =3D cset; - pdev->dev.of_node =3D np; + device_add_of_node(&pdev->dev, np); kfree(name); =20 return; --=20 2.47.0 From nobody Sat Feb 7 08:02:18 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23DDD1FF5EF; Mon, 2 Dec 2024 13:15:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145357; cv=none; b=YoQ5J636mDKJoH6ebQGKsDVvLTPb+3zu3BZL6JNuQD8TmexuqNvzUPaN7u6pDpdq56BNllSN8+VVT0TM2FS6dyWOnPCZx+ryv7/nzXlEndCVvdTSk/fjQhe90CFfIW+qiJ/s6jasQo3Cmrm/Cj3jOfYKIViNJp6ueqXCqGFxTJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145357; c=relaxed/simple; bh=PloGdo8yWaAB0mEU1AiYQL4TycpKuip5XLuZ2Uy87RU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eNdfqHjrk3FyZ13XiM4g9xZnRZrEPRs8ICU/5uVUd8lnh5+DoaHYmZ7/jjZXEoBWeu/tdbQjXOESLJZc1pe19hzKAepPhL79OlMleRTH850y1ODeQ+v7FrHKQ6jqdK6huiv1j0EI6OV6+Jwo1P+BRA5o1a8ZAynLzuCq3UnC3yY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=cqnB9xJK; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="cqnB9xJK" Received: by mail.gandi.net (Postfix) with ESMTPA id 8EF5BC0006; Mon, 2 Dec 2024 13:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733145347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GU1Q5uwrUxslDSQGz6WRaqjWVuhawVTEJ7MmY7c/q20=; b=cqnB9xJKfCytEUibvgcliQS3DEHnBmfmtIxYGkLuFbIPNt4ShYzO70gzTdlfPqxrjFirV+ PEllEyzZFX8vkxapC6Y/mOMccctqEtKV8kaoLFkzaCuGgnPAKpyXFFrT05BkyHsdWRHJ8I pOinkIKXUtFZh+VLeBKW0+1vieyhe8SIeByNOeLp03hOaOCpRbQdzhFe3vQVi+2PlTQBgJ 3rJasvndZCBvvimlcdxrpiVI2C882I9Deu8NfXgmONQ9vhyNNq/yFQeJkiGpVYzmzFaJoE 1KzNwMvVFL4bud3U6/L5djiugPRxdBgLrz4T4qxEkcGXWj634vUSRoxp77awQQ== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v4 3/6] PCI: of_property: Add support for NULL pdev in of_pci_set_address() Date: Mon, 2 Dec 2024 14:15:15 +0100 Message-ID: <20241202131522.142268-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202131522.142268-1-herve.codina@bootlin.com> References: <20241202131522.142268-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" The pdev (pointer to a struct pci_dev) parameter of of_pci_set_address() cannot be NULL. In order to reuse of_pci_set_address() when creating the PCI root bus node, this function needs to support a NULL pdev parameter. Indeed, in the case of the PCI root bus node creation, no pdev are available and of_pci_set_address() will be used with the bridge windows. Allow to call of_pci_set_address() with a NULL pdev. Signed-off-by: Herve Codina --- drivers/pci/of_property.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index 886c236e5de6..8aff9ca1f222 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -54,9 +54,13 @@ enum of_pci_prop_compatible { static void of_pci_set_address(struct pci_dev *pdev, u32 *prop, u64 addr, u32 reg_num, u32 flags, bool reloc) { - prop[0] =3D FIELD_PREP(OF_PCI_ADDR_FIELD_BUS, pdev->bus->number) | - FIELD_PREP(OF_PCI_ADDR_FIELD_DEV, PCI_SLOT(pdev->devfn)) | - FIELD_PREP(OF_PCI_ADDR_FIELD_FUNC, PCI_FUNC(pdev->devfn)); + if (pdev) + prop[0] =3D FIELD_PREP(OF_PCI_ADDR_FIELD_BUS, pdev->bus->number) | + FIELD_PREP(OF_PCI_ADDR_FIELD_DEV, PCI_SLOT(pdev->devfn)) | + FIELD_PREP(OF_PCI_ADDR_FIELD_FUNC, PCI_FUNC(pdev->devfn)); + else + prop[0] =3D 0; + prop[0] |=3D flags | reg_num; if (!reloc) { prop[0] |=3D OF_PCI_ADDR_FIELD_NONRELOC; --=20 2.47.0 From nobody Sat Feb 7 08:02:18 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2311FF611; Mon, 2 Dec 2024 13:15:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145357; cv=none; b=ZJerlry6VmFAzLMuTq0P7wgjjdZU04lcu1fzsiGp/y/FZzao6etZW1VFhcKNaaPR3lhsb1Qq6UR/hvaYue8C8INKkT9acc7tn0PyrWeuaJcW5RGQKBdLGsXdlj2iGxF17IOU5Q4dUCAiaZpCNWn1gLGs+H7eFdKWcm8rzYdE/OI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145357; c=relaxed/simple; bh=H8MC/Q72vk0UPF9u8+tzJ8SETywEWYWPmMDVOO5AKeI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dfWd47LFZd6EfNzKs3OLMAXH6MfJelYPQ0hXPzl0FL+UPOhFgwxvE4ZGKFOX5h6XTNQmQnh5htjzgbbANOYndUOxcw3meJOF5cA2bcbZvspaL192dLo6MALyHiHm/CnYOEJO3ziVFsqmOSf2CjXwVO+amFv6+v22BEvImO6x5K0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Ik0FCJnv; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Ik0FCJnv" Received: by mail.gandi.net (Postfix) with ESMTPA id 5D07FC000F; Mon, 2 Dec 2024 13:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733145348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lD+dgpGNPBxXSWsz/EZ9nW0M7S5/QsWHsehlXFF/WCY=; b=Ik0FCJnv8/CJE97B+IAi2eGNXbw0F2+TuN2TVpCPReYddGqk14LVV7jL5REFRAMVutWk6F +aJ1mhRyxOfQlTYrtnkBV9SzNnH5PuzCOfw6tHS2uvjMRjcX09b3EmHVE9OkstqrfJLfSp LjxSiR3j+7T7MCzMJ0cGXSFRMOFJJ3Cw4daDAK9bVLgCCTezPOSHvRJn9n09MQak596wH7 0cJyoZZapoo21+QbHE7WT/8zY936ojqk9WvxdKZHGls7jqGZStrVrJTSZm5x8oaFT9L9c6 tlVNWCcVUGDYqNmmtnGaLM12iqvdCN2+76+5wJHUFPh0xRBqlj8R/syZJB044Q== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v4 4/6] PCI: of_property: Constify parameter in of_pci_get_addr_flags() Date: Mon, 2 Dec 2024 14:15:16 +0100 Message-ID: <20241202131522.142268-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202131522.142268-1-herve.codina@bootlin.com> References: <20241202131522.142268-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" The res parameter has no reason to be a pointer to an un-const struct resource. Indeed, struct resource is not supposed to be modified by the function. Constify the res parameter. Signed-off-by: Herve Codina --- drivers/pci/of_property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index 8aff9ca1f222..400c4c2e434d 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -69,7 +69,7 @@ static void of_pci_set_address(struct pci_dev *pdev, u32 = *prop, u64 addr, } } =20 -static int of_pci_get_addr_flags(struct resource *res, u32 *flags) +static int of_pci_get_addr_flags(const struct resource *res, u32 *flags) { u32 ss; =20 --=20 2.47.0 From nobody Sat Feb 7 08:02:18 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4880C201015; Mon, 2 Dec 2024 13:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145359; cv=none; b=dqZ2kgocMnaVY7DW55X3LNoqYbY+B6qfiyd3g+P5+pXTkTKXU6WO4u8x273xYsMs6iXgafzpWez6WM09x3woiMymZmmOxWwG8Y/XPnFlXPslpWjF99U2NoDGpq3EEDTt88x32x3xkP4WYF9eE5FWXlwkAv0DVTMRipjq+MLUuW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145359; c=relaxed/simple; bh=TOW/EzyDbIvADmJ/cMQpnmtwR6NOgiVR9PmYtOf7bXI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TYwGzxO6NBw/yQJmzwqzZuCxLR03AZumD7tEwQJOj8MOKyOGpqN9VaG+4TdSuFBDZ7Sj76dhpcohDryjJUBmRjEDWLp7KfUbKEl7ZBMZte/xxCHjaw6/Sdl8ISnVZ85VIxBeaXGoKkuOmu48rEmS2tUs30+atQLT4/rSDxmM1po= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=WgTv8Mtd; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WgTv8Mtd" Received: by mail.gandi.net (Postfix) with ESMTPA id 2F446C000D; Mon, 2 Dec 2024 13:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733145348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hVpn7dEumaHVgEROgoe+qNLD7BNzHl5S0UXnNdPNwZ4=; b=WgTv8MtdQGa1MyCqNQZZ2awfM8pOrl9Xx9hEjsIidxSFjhZq+uj48dDS3X0YLAwrpCXe8g gPWJThY0m3D877rqBc5FVQfqAeX2zpyxqjUX5Fw7RwYXcAu7FVz8PiqfgYrm+GCaKGGr2J 2khUfjou6YphHNFRHAZhBQrGkMHlBvExA7OlSj+TV5nhPRr4YECCgmWaiaj+X+HVmtOVCh +ZwhrPfiQgFm9ggssVhB7XDC9aKBJtI99TScF+bteDKIetV/SoVp20OhpEb4fCkBT8fbmn KY/ZE6hp52DFG9TsJomztvaL0uDvwi96C+uqvPumKbBKuV9Pjuk/JL40MCN7ag== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v4 5/6] of: Add #address-cells/#size-cells in the device-tree root empty node Date: Mon, 2 Dec 2024 14:15:17 +0100 Message-ID: <20241202131522.142268-6-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202131522.142268-1-herve.codina@bootlin.com> References: <20241202131522.142268-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" On systems where ACPI is enabled or when a device-tree is not passed to the kernel by the bootloader, a device-tree root empty node is created. This device-tree root empty node does not have the #address-cells and the #size-cells properties This leads to the use of the default address cells and size cells values which are defined in the code to 1 for the address cells value and 1 for the size cells value. According to the devicetree specification and the OpenFirmware standard (IEEE 1275-1994) the default value for #address-cells should be 2. Also, according to the devicetree specification, the #address-cells and the #size-cells are required properties in the root node. The device tree compiler already uses 2 as default value for address cells and 1 for size cells. The powerpc PROM code also uses 2 as default value for address cells and 1 for size cells. Modern implementation should have the #address-cells and the #size-cells properties set and should not rely on default values. On x86, this root empty node is used and the code default values are used. In preparation of the support for device-tree overlay on PCI devices feature on x86 (i.e. the creation of the PCI root bus device-tree node), the default value for #address-cells needs to be updated. Indeed, on x86_64, addresses are on 64bits and the upper part of an address is needed for correct address translations. On x86_32 having the default value updated does not lead to issues while the upper part of a 64-bit value is zero. Changing the default value for all architectures may break device-tree compatibility. Indeed, existing dts file without the #address-cells property set in the root node will not be compatible with this modification. Instead of updating default values, add both required #address-cells and #size-cells properties in the device-tree empty node. Use 2 for both properties value in order to fully support 64-bit addresses and sizes on systems using this empty root node. Signed-off-by: Herve Codina --- drivers/of/empty_root.dts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/of/empty_root.dts b/drivers/of/empty_root.dts index cf9e97a60f48..cbe169ba3db5 100644 --- a/drivers/of/empty_root.dts +++ b/drivers/of/empty_root.dts @@ -2,5 +2,12 @@ /dts-v1/; =20 / { - + /* + * #address-cells/#size-cells are required properties at root node. + * Use 2 cells for both address cells and size cells in order to fully + * support 64-bit addresses and sizes on systems using this empty root + * node. + */ + #address-cells =3D <0x02>; + #size-cells =3D <0x02>; }; --=20 2.47.0 From nobody Sat Feb 7 08:02:18 2026 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48F9320101A; Mon, 2 Dec 2024 13:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145358; cv=none; b=csoekq64Aud+MOTAsc3zK8kzdIPAWtqecLqd7PDayuqoPriBv1TR0RpWAOjba1O+CKmEbXwRw/2IHaRWIlZNbm2E6d51Nq3E+4nsZ1AWvCO+fD4ldikeDmSAiQzXNbwfwNw3e1SSBN2buB2OXzt7paRlgE5nyDXQOD/vBV3gSSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733145358; c=relaxed/simple; bh=pXG2lNKrNxbQNSXeEqbEkvWSgUB67r8uakq/Fw79NeU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gJdMfwU9eViqsEqj2/iZusralqJlqurt6HVy2J48CaeyNiugF/ZL2J+C55VuFnSEXUWDZpvLhcfJVIsn3k/hMgZ0r07hK/wySs75hXtR5WzUZHHSFIyDY9P6LvalQLes2W248F2jqhLspPvweH5SGAZnKMjnZubNkL3aYF4Vilk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=PzySwLJq; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="PzySwLJq" Received: by mail.gandi.net (Postfix) with ESMTPA id E32BCC0012; Mon, 2 Dec 2024 13:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733145349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gJaxBHF3x4TI5XAw2BFga0+cPmQYa0O4/5xdJ6Zf6c8=; b=PzySwLJqrPG3ReKWauwBKVGmVNmgrwx99UBlXv2W5kw5cr1Yxfez9Whjh5DkQXXSv7QGZJ J2EurAtbvELBId28WM1QSIdueTLi8wQ0lVDrVhVPumbyEIETlByoCw6RYBrOhWBcuF/X/o BY4GK29o6AAXswlNDRmEHMNpWHNMB7RFzInR6KCKeHeurvqsBbJAgQmM98Y+q6jngDhABJ WQDsBh2wZjH0621/YrUtVtRr+BipVhuz90YmruePw3CYVSzFGEjVaJn3iUuI4fJgOpe+NB 7QWNjeiQqrEtW181ZFbI/mPK3rBtM2YMo0Bg8rtuAFF3FXP2NlkWpCy7y7OseQ== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v4 6/6] PCI: of: Create device-tree PCI host bridge node Date: Mon, 2 Dec 2024 14:15:18 +0100 Message-ID: <20241202131522.142268-7-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202131522.142268-1-herve.codina@bootlin.com> References: <20241202131522.142268-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" PCI devices device-tree nodes can be already created. This was introduced by commit 407d1a51921e ("PCI: Create device tree node for bridge"). In order to have device-tree nodes related to PCI devices attached on their PCI root bus (the PCI bus handled by the PCI host bridge), a PCI root bus device-tree node is needed. This root bus node will be used as the parent node of the first level devices scanned on the bus. On device-tree based systems, this PCI root bus device tree node is set to the node of the related PCI host bridge. The PCI host bridge node is available in the device-tree used to describe the hardware passed at boot. On non device-tree based system (such as ACPI), a device-tree node for the PCI host bridge or for the root bus do not exist. Indeed, the PCI host bridge is not described in a device-tree used at boot simply because no device-tree are passed at boot. The device-tree PCI host bridge node creation needs to be done at runtime. This is done in the same way as for the creation of the PCI device nodes. I.e. node and properties are created based on computed information done by the PCI core. Also, as is done on device-tree based systems, this PCI host bridge node is used for the PCI root bus. Signed-off-by: Herve Codina --- drivers/pci/of.c | 94 ++++++++++++++++++++++++++++++++++- drivers/pci/of_property.c | 102 ++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 6 +++ drivers/pci/probe.c | 2 + drivers/pci/remove.c | 2 + 5 files changed, 205 insertions(+), 1 deletion(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 3cca33105b85..a63799848aac 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -726,7 +726,99 @@ void of_pci_make_dev_node(struct pci_dev *pdev) out_free_name: kfree(name); } -#endif + +void of_pci_remove_host_bridge_node(struct pci_host_bridge *bridge) +{ + struct device_node *np; + + np =3D pci_bus_to_OF_node(bridge->bus); + if (!np || !of_node_check_flag(np, OF_DYNAMIC)) + return; + + device_remove_of_node(&bridge->bus->dev); + device_remove_of_node(&bridge->dev); + of_changeset_revert(np->data); + of_changeset_destroy(np->data); + of_node_put(np); +} + +void of_pci_make_host_bridge_node(struct pci_host_bridge *bridge) +{ + struct device_node *np =3D NULL; + struct of_changeset *cset; + const char *name; + int ret; + + /* + * If there is already a device-tree node linked to the PCI bus handled + * by this bridge (i.e. the PCI root bus), nothing to do. + */ + if (pci_bus_to_OF_node(bridge->bus)) + return; + + /* The root bus has no node. Check that the host bridge has no node too */ + if (bridge->dev.of_node) { + pr_err("PCI host bridge of_node already set"); + return; + } + + /* Check if there is a DT root node to attach the created node */ + if (!of_root) { + pr_err("of_root node is NULL, cannot create PCI host bridge node\n"); + return; + } + + name =3D kasprintf(GFP_KERNEL, "pci@%x,%x", pci_domain_nr(bridge->bus), + bridge->bus->number); + if (!name) + return; + + cset =3D kmalloc(sizeof(*cset), GFP_KERNEL); + if (!cset) + goto out_free_name; + of_changeset_init(cset); + + np =3D of_changeset_create_node(cset, of_root, name); + if (!np) + goto out_destroy_cset; + + ret =3D of_pci_add_host_bridge_properties(bridge, cset, np); + if (ret) + goto out_free_node; + + /* + * This of_node will be added to an existing device. The of_node parent + * is the root OF node and so this node will be handled by the platform + * bus. Avoid any new device creation. + */ + of_node_set_flag(np, OF_POPULATED); + np->fwnode.dev =3D &bridge->dev; + fwnode_dev_initialized(&np->fwnode, true); + + ret =3D of_changeset_apply(cset); + if (ret) + goto out_free_node; + + np->data =3D cset; + + /* Add the of_node to host bridge and the root bus */ + device_add_of_node(&bridge->dev, np); + device_add_of_node(&bridge->bus->dev, np); + + kfree(name); + + return; + +out_free_node: + of_node_put(np); +out_destroy_cset: + of_changeset_destroy(cset); + kfree(cset); +out_free_name: + kfree(name); +} + +#endif /* CONFIG_PCI_DYNAMIC_OF_NODES */ =20 /** * of_pci_supply_present() - Check if the power supply is present for the = PCI diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index 400c4c2e434d..b03baff651ee 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -394,3 +394,105 @@ int of_pci_add_properties(struct pci_dev *pdev, struc= t of_changeset *ocs, =20 return 0; } + +static bool of_pci_is_range_resource(const struct resource *res, u32 *flag= s) +{ + if (!(resource_type(res) & IORESOURCE_MEM) && + !(resource_type(res) & IORESOURCE_MEM_64)) + return false; + + if (of_pci_get_addr_flags(res, flags)) + return false; + + return true; +} + +static int of_pci_host_bridge_prop_ranges(struct pci_host_bridge *bridge, + struct of_changeset *ocs, + struct device_node *np) +{ + struct resource_entry *window; + unsigned int ranges_sz =3D 0; + unsigned int n_range =3D 0; + struct resource *res; + int n_addr_cells; + u32 *ranges; + u64 val64; + u32 flags; + int ret; + + n_addr_cells =3D of_n_addr_cells(np); + if (n_addr_cells <=3D 0 || n_addr_cells > 2) + return -EINVAL; + + resource_list_for_each_entry(window, &bridge->windows) { + res =3D window->res; + if (!of_pci_is_range_resource(res, &flags)) + continue; + n_range++; + } + + if (!n_range) + return 0; + + ranges =3D kcalloc(n_range, + (OF_PCI_ADDRESS_CELLS + OF_PCI_SIZE_CELLS + + n_addr_cells) * sizeof(*ranges), + GFP_KERNEL); + if (!ranges) + return -ENOMEM; + + resource_list_for_each_entry(window, &bridge->windows) { + res =3D window->res; + if (!of_pci_is_range_resource(res, &flags)) + continue; + + /* PCI bus address */ + val64 =3D res->start; + of_pci_set_address(NULL, &ranges[ranges_sz], val64 - window->offset, + 0, flags, false); + ranges_sz +=3D OF_PCI_ADDRESS_CELLS; + + /* Host bus address */ + if (n_addr_cells =3D=3D 2) + ranges[ranges_sz++] =3D upper_32_bits(val64); + ranges[ranges_sz++] =3D lower_32_bits(val64); + + /* Size */ + val64 =3D resource_size(res); + ranges[ranges_sz] =3D upper_32_bits(val64); + ranges[ranges_sz + 1] =3D lower_32_bits(val64); + ranges_sz +=3D OF_PCI_SIZE_CELLS; + } + + ret =3D of_changeset_add_prop_u32_array(ocs, np, "ranges", ranges, ranges= _sz); + kfree(ranges); + return ret; +} + +int of_pci_add_host_bridge_properties(struct pci_host_bridge *bridge, + struct of_changeset *ocs, + struct device_node *np) +{ + int ret; + + ret =3D of_changeset_add_prop_string(ocs, np, "device_type", "pci"); + if (ret) + return ret; + + ret =3D of_changeset_add_prop_u32(ocs, np, "#address-cells", + OF_PCI_ADDRESS_CELLS); + if (ret) + return ret; + + ret =3D of_changeset_add_prop_u32(ocs, np, "#size-cells", + OF_PCI_SIZE_CELLS); + if (ret) + return ret; + + ret =3D of_pci_host_bridge_prop_ranges(bridge, ocs, np); + if (ret) + return ret; + + return 0; +} diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 2e40fc63ba31..0cdb2b3daea8 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -871,9 +871,15 @@ void of_pci_make_dev_node(struct pci_dev *pdev); void of_pci_remove_node(struct pci_dev *pdev); int of_pci_add_properties(struct pci_dev *pdev, struct of_changeset *ocs, struct device_node *np); +void of_pci_make_host_bridge_node(struct pci_host_bridge *bridge); +void of_pci_remove_host_bridge_node(struct pci_host_bridge *bridge); +int of_pci_add_host_bridge_properties(struct pci_host_bridge *bridge, stru= ct of_changeset *ocs, + struct device_node *np); #else static inline void of_pci_make_dev_node(struct pci_dev *pdev) { } static inline void of_pci_remove_node(struct pci_dev *pdev) { } +static inline void of_pci_make_host_bridge_node(struct pci_host_bridge *br= idge) { } +static inline void of_pci_remove_host_bridge_node(struct pci_host_bridge *= bridge) { } #endif =20 #ifdef CONFIG_PCIEAER diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 2e81ab0f5a25..629287f6b3d9 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1051,6 +1051,8 @@ static int pci_register_host_bridge(struct pci_host_b= ridge *bridge) dev_info(&bus->dev, "root bus resource %pR%s\n", res, addr); } =20 + of_pci_make_host_bridge_node(bridge); + down_write(&pci_bus_sem); list_add_tail(&bus->node, &pci_root_buses); up_write(&pci_bus_sem); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index efc37fcb73e2..9f7df2b20183 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -163,6 +163,8 @@ void pci_stop_root_bus(struct pci_bus *bus) &bus->devices, bus_list) pci_stop_bus_device(child); =20 + of_pci_remove_host_bridge_node(host_bridge); + /* stop the host bridge */ device_release_driver(&host_bridge->dev); } --=20 2.47.0