Skip to content

Commit 1799cad

Browse files
committed
[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 <[email protected]>
1 parent fed7c9a commit 1799cad

File tree

1 file changed

+7
-19
lines changed
  • components/drivers/pci

1 file changed

+7
-19
lines changed

components/drivers/pci/ofw.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void ofw_msi_pic_init(struct rt_pci_device *pdev)
461461
{
462462
#ifdef RT_PCI_MSI
463463
rt_uint32_t rid;
464-
struct rt_pci_bus *bus;
464+
struct rt_pci_host_bridge *bridge;
465465
struct rt_ofw_node *np, *msi_ic_np = RT_NULL;
466466

467467
/*
@@ -473,26 +473,14 @@ static void ofw_msi_pic_init(struct rt_pci_device *pdev)
473473
*/
474474
rid = rt_pci_dev_id(pdev);
475475

476-
for (bus = pdev->bus; bus; bus = bus->parent)
477-
{
478-
if (rt_pci_is_root_bus(bus))
479-
{
480-
np = bus->host_bridge->parent.ofw_node;
481-
}
482-
else
483-
{
484-
np = bus->self->parent.ofw_node;
485-
}
476+
bridge = rt_pci_find_host_bridge(pdev->bus);
477+
RT_ASSERT(bridge != RT_NULL);
486478

487-
if ((msi_ic_np = rt_ofw_parse_phandle(np, "msi-parent", 0)))
488-
{
489-
break;
490-
}
479+
np = bridge->parent.ofw_node;
491480

492-
if (!rt_ofw_map_id(np, rid, "msi-map", "msi-map-mask", &msi_ic_np, RT_NULL))
493-
{
494-
break;
495-
}
481+
if (!(msi_ic_np = rt_ofw_parse_phandle(np, "msi-parent", 0)))
482+
{
483+
rt_ofw_map_id(np, rid, "msi-map", "msi-map-mask", &msi_ic_np, RT_NULL);
496484
}
497485

498486
if (!msi_ic_np)

0 commit comments

Comments
 (0)