Re: [PATCH v3 2/2] PCI: imx6: Add IOMMU and ITS MSI support for i.MX95

Robin Murphy
2024-11-01T17:25:58Z

On 2024-10-24 11:34 pm, Frank Li wrote:
[...]
> +static int imx_pcie_enable_device(struct pci_host_bridge *bridge, struct pci_dev *pdev)
> +{
> + u32 sid_i = 0, sid_m = 0, rid = pci_dev_id(pdev);
> + struct device_node *target;
> + struct imx_pcie *imx_pcie;
> + struct device *dev;
> + int err_i, err_m;
> +
> + imx_pcie = to_imx_pcie(to_dw_pcie_from_pp(bridge->sysdata));
> + dev = imx_pcie->pci->dev;
> +
> + target = NULL;
> + err_i = of_map_id(dev->of_node, rid, "iommu-map", "iommu-map-mask", &target, &sid_i);

No, you still need to actually check "target" at this point - if it is
now set, a mapping was found and "sid_i" is valid, otherwise if it still
NULL, no mapping exists even if "err_i" is 0 (i.e. an "iommu-map"
property was found, but did not contain any entries matching "rid" as
input). Note that the target node is returned with a reference held, so
needs an of_node_put() as well.

Thanks,
Robin.

> + target = NULL;
> + err_m = of_map_id(dev->of_node, rid, "msi-map", "msi-map-mask", &target, &sid_m);