From 1ac80442947e975cbb338c942eb6127bd5464fc1 Mon Sep 17 00:00:00 2001 From: GuEe-GUI <2991707448@qq.com> Date: Thu, 7 Nov 2024 13:52:55 +0800 Subject: [PATCH] [DM/FIXUP] Fixup PCI device ofw private node for MSI Some PCI device devicetree is like: ```dts pcie@fe270000 { device_type = "pci"; msi-map = <0x1000 0x9c 0x1000 0x1000>; pcie@10 { reg = <0x100000 0x00 0x00 0x00 0x00>; #address-cells = <0x03>; #size-cells = <0x02>; pcie@10,0 { reg = <0x00 0x00 0x00 0x00 0x00>; }; }; }; ``` that the pcie@10,0 have a private ofw node, it will find property name `msi-map` or `msi-parent` fail. We should only find the property in host bridge's ofw node. Signed-off-by: GuEe-GUI <2991707448@qq.com> --- components/drivers/pci/ofw.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/components/drivers/pci/ofw.c b/components/drivers/pci/ofw.c index d6ed4428c8..0207e7a87d 100644 --- a/components/drivers/pci/ofw.c +++ b/components/drivers/pci/ofw.c @@ -461,7 +461,7 @@ static void ofw_msi_pic_init(struct rt_pci_device *pdev) { #ifdef RT_PCI_MSI rt_uint32_t rid; - struct rt_pci_bus *bus; + struct rt_pci_host_bridge *bridge; struct rt_ofw_node *np, *msi_ic_np = RT_NULL; /* @@ -473,26 +473,14 @@ static void ofw_msi_pic_init(struct rt_pci_device *pdev) */ rid = rt_pci_dev_id(pdev); - for (bus = pdev->bus; bus; bus = bus->parent) + bridge = rt_pci_find_host_bridge(pdev->bus); + RT_ASSERT(bridge != RT_NULL); + + np = bridge->parent.ofw_node; + + if (!(msi_ic_np = rt_ofw_parse_phandle(np, "msi-parent", 0))) { - if (rt_pci_is_root_bus(bus)) - { - np = bus->host_bridge->parent.ofw_node; - } - else - { - np = bus->self->parent.ofw_node; - } - - if ((msi_ic_np = rt_ofw_parse_phandle(np, "msi-parent", 0))) - { - break; - } - - if (!rt_ofw_map_id(np, rid, "msi-map", "msi-map-mask", &msi_ic_np, RT_NULL)) - { - break; - } + rt_ofw_map_id(np, rid, "msi-map", "msi-map-mask", &msi_ic_np, RT_NULL); } if (!msi_ic_np)