drivers/of/dynamic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
From: Peng Fan <peng.fan@nxp.com>
When PCI node was created using an overlay and the overlay is
reverted/destroyed, the "linux,pci-domain" property no longer
exists, so of_get_pci_domain_nr will return failure. Then
of_pci_bus_release_domain_nr will actually use the dynamic IDA,
even if the IDA was allocated in static IDA.
So move the notify before revert to fix the issue.
Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
The initial thread:
https://lore.kernel.org/all/20230913115737.GA426735@bhelgaas/
drivers/of/dynamic.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 3bf27052832f..0a5ec2bda380 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -834,13 +834,15 @@ int __of_changeset_revert_notify(struct of_changeset *ocs)
static int __of_changeset_revert(struct of_changeset *ocs)
{
- int ret, ret_reply;
+ int ret, ret_reply = 0;
- ret_reply = 0;
- ret = __of_changeset_revert_entries(ocs, &ret_reply);
+ ret = __of_changeset_revert_notify(ocs);
+ if (ret)
+ return ret;
- if (!ret)
- ret = __of_changeset_revert_notify(ocs);
+ ret = __of_changeset_revert_entries(ocs, &ret_reply);
+ if (ret && !ret_reply)
+ ret = __of_changeset_apply_notify(ocs);
return ret;
}
--
2.37.1
On Wed, Feb 28, 2024 at 12:13 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> When PCI node was created using an overlay and the overlay is
> reverted/destroyed, the "linux,pci-domain" property no longer
> exists, so of_get_pci_domain_nr will return failure. Then
> of_pci_bus_release_domain_nr will actually use the dynamic IDA,
> even if the IDA was allocated in static IDA.
That usage is broken to begin with unless there is a guarantee that
static and dynamic domain numbers don't overlap. For example, a
dynamic number is assigned and then you load an overlay with the same
number defined in it.
> So move the notify before revert to fix the issue.
You can't just change the timing. Something might require notify to be
after the revert.
> Fixes: c14f7ccc9f5d ("PCI: Assign PCI domain IDs by ida_alloc()")
I don't see where the notifier is even used.
Rob
© 2016 - 2026 Red Hat, Inc.