* [U-Boot] [PATCH v2] pcie-layerscape: Fixup iommu-map property of pci node
@ 2017-03-22 6:42 Bharat Bhushan
2017-03-26 18:36 ` york sun
2017-03-28 18:00 ` york sun
0 siblings, 2 replies; 3+ messages in thread
From: Bharat Bhushan @ 2017-03-22 6:42 UTC (permalink / raw)
To: u-boot
This patch fixup iommu-map property on pci node to have
a valid mapping of requester-id to stream-id.
The requester-id to stream-id mapping is based on
PCI-LUT table initialization.
Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
---
v1->v2
- Typo error in comment about phandle of MSI node rather than iommu
drivers/pci/pcie_layerscape_fixup.c | 53 +++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/drivers/pci/pcie_layerscape_fixup.c b/drivers/pci/pcie_layerscape_fixup.c
index 8f8f6b6..3aea587 100644
--- a/drivers/pci/pcie_layerscape_fixup.c
+++ b/drivers/pci/pcie_layerscape_fixup.c
@@ -103,6 +103,56 @@ static void fdt_pcie_set_msi_map_entry(void *blob, struct ls_pcie *pcie,
fdt_appendprop_u32(blob, nodeoffset, "msi-map", 1);
}
+/*
+ * An iommu-map is a property to be added to the pci controller
+ * node. It is a table, where each entry consists of 4 fields
+ * e.g.:
+ *
+ * iommu-map = <[devid] [phandle-to-iommu-ctrl] [stream-id] [count]
+ * [devid] [phandle-to-iommu-ctrl] [stream-id] [count]>;
+ */
+static void fdt_pcie_set_iommu_map_entry(void *blob, struct ls_pcie *pcie,
+ u32 devid, u32 streamid)
+{
+ u32 *prop;
+ u32 iommu_map[4];
+ int nodeoffset;
+ int lenp;
+
+ /* find pci controller node */
+ nodeoffset = fdt_node_offset_by_compat_reg(blob, "fsl,ls-pcie",
+ pcie->dbi_res.start);
+ if (nodeoffset < 0) {
+#ifdef CONFIG_FSL_PCIE_COMPAT /* Compatible with older version of dts node */
+ nodeoffset = fdt_node_offset_by_compat_reg(blob,
+ CONFIG_FSL_PCIE_COMPAT, pcie->dbi_res.start);
+ if (nodeoffset < 0)
+ return;
+#else
+ return;
+#endif
+ }
+
+ /* get phandle to iommu controller */
+ prop = fdt_getprop_w(blob, nodeoffset, "iommu-map", &lenp);
+ if (prop == NULL) {
+ debug("\n%s: ERROR: missing iommu-map: PCIe%d\n",
+ __func__, pcie->idx);
+ return;
+ }
+
+ /* set iommu-map row */
+ iommu_map[0] = cpu_to_fdt32(devid);
+ iommu_map[1] = *++prop;
+ iommu_map[2] = cpu_to_fdt32(streamid);
+ iommu_map[3] = cpu_to_fdt32(1);
+
+ if (devid == 0)
+ fdt_setprop_inplace(blob, nodeoffset, "iommu-map", iommu_map, 16);
+ else
+ fdt_appendprop(blob, nodeoffset, "iommu-map", iommu_map, 16);
+}
+
static void fdt_fixup_pcie(void *blob)
{
struct udevice *dev, *bus;
@@ -139,6 +189,9 @@ static void fdt_fixup_pcie(void *blob)
/* update msi-map in device tree */
fdt_pcie_set_msi_map_entry(blob, pcie, bdf >> 8,
streamid);
+ /* update iommu-map in device tree */
+ fdt_pcie_set_iommu_map_entry(blob, pcie, bdf >> 8,
+ streamid);
}
}
#endif
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] pcie-layerscape: Fixup iommu-map property of pci node
2017-03-22 6:42 [U-Boot] [PATCH v2] pcie-layerscape: Fixup iommu-map property of pci node Bharat Bhushan
@ 2017-03-26 18:36 ` york sun
2017-03-28 18:00 ` york sun
1 sibling, 0 replies; 3+ messages in thread
From: york sun @ 2017-03-26 18:36 UTC (permalink / raw)
To: u-boot
On 03/21/2017 11:45 PM, Bharat Bhushan wrote:
> This patch fixup iommu-map property on pci node to have
> a valid mapping of requester-id to stream-id.
> The requester-id to stream-id mapping is based on
> PCI-LUT table initialization.
>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
> ---
> v1->v2
> - Typo error in comment about phandle of MSI node rather than iommu
>
> drivers/pci/pcie_layerscape_fixup.c | 53 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/drivers/pci/pcie_layerscape_fixup.c b/drivers/pci/pcie_layerscape_fixup.c
> index 8f8f6b6..3aea587 100644
> --- a/drivers/pci/pcie_layerscape_fixup.c
> +++ b/drivers/pci/pcie_layerscape_fixup.c
> @@ -103,6 +103,56 @@ static void fdt_pcie_set_msi_map_entry(void *blob, struct ls_pcie *pcie,
> fdt_appendprop_u32(blob, nodeoffset, "msi-map", 1);
> }
>
> +/*
> + * An iommu-map is a property to be added to the pci controller
> + * node. It is a table, where each entry consists of 4 fields
> + * e.g.:
> + *
> + * iommu-map = <[devid] [phandle-to-iommu-ctrl] [stream-id] [count]
> + * [devid] [phandle-to-iommu-ctrl] [stream-id] [count]>;
> + */
> +static void fdt_pcie_set_iommu_map_entry(void *blob, struct ls_pcie *pcie,
> + u32 devid, u32 streamid)
> +{
> + u32 *prop;
> + u32 iommu_map[4];
> + int nodeoffset;
> + int lenp;
> +
> + /* find pci controller node */
> + nodeoffset = fdt_node_offset_by_compat_reg(blob, "fsl,ls-pcie",
> + pcie->dbi_res.start);
> + if (nodeoffset < 0) {
> +#ifdef CONFIG_FSL_PCIE_COMPAT /* Compatible with older version of dts node */
> + nodeoffset = fdt_node_offset_by_compat_reg(blob,
> + CONFIG_FSL_PCIE_COMPAT, pcie->dbi_res.start);
> + if (nodeoffset < 0)
> + return;
> +#else
> + return;
> +#endif
> + }
> +
> + /* get phandle to iommu controller */
> + prop = fdt_getprop_w(blob, nodeoffset, "iommu-map", &lenp);
> + if (prop == NULL) {
> + debug("\n%s: ERROR: missing iommu-map: PCIe%d\n",
> + __func__, pcie->idx);
> + return;
> + }
> +
> + /* set iommu-map row */
> + iommu_map[0] = cpu_to_fdt32(devid);
> + iommu_map[1] = *++prop;
> + iommu_map[2] = cpu_to_fdt32(streamid);
> + iommu_map[3] = cpu_to_fdt32(1);
> +
> + if (devid == 0)
> + fdt_setprop_inplace(blob, nodeoffset, "iommu-map", iommu_map, 16);
Line is too long.
> + else
> + fdt_appendprop(blob, nodeoffset, "iommu-map", iommu_map, 16);
> +}
> +
> static void fdt_fixup_pcie(void *blob)
> {
> struct udevice *dev, *bus;
> @@ -139,6 +189,9 @@ static void fdt_fixup_pcie(void *blob)
> /* update msi-map in device tree */
> fdt_pcie_set_msi_map_entry(blob, pcie, bdf >> 8,
> streamid);
> + /* update iommu-map in device tree */
> + fdt_pcie_set_iommu_map_entry(blob, pcie, bdf >> 8,
> + streamid);
Indentation not aligned.
You must have ignored checkpatch warning, or you didn't run it. I will
fix this one for you unless you want to respin the patch.
York
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] pcie-layerscape: Fixup iommu-map property of pci node
2017-03-22 6:42 [U-Boot] [PATCH v2] pcie-layerscape: Fixup iommu-map property of pci node Bharat Bhushan
2017-03-26 18:36 ` york sun
@ 2017-03-28 18:00 ` york sun
1 sibling, 0 replies; 3+ messages in thread
From: york sun @ 2017-03-28 18:00 UTC (permalink / raw)
To: u-boot
On 03/21/2017 11:45 PM, Bharat Bhushan wrote:
> This patch fixup iommu-map property on pci node to have
> a valid mapping of requester-id to stream-id.
> The requester-id to stream-id mapping is based on
> PCI-LUT table initialization.
>
> Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
> ---
> v1->v2
> - Typo error in comment about phandle of MSI node rather than iommu
>
Reformatted commit message. Applied to fsl-qoriq master, awaiting
upstream. Thanks.
York
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-28 18:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-22 6:42 [U-Boot] [PATCH v2] pcie-layerscape: Fixup iommu-map property of pci node Bharat Bhushan
2017-03-26 18:36 ` york sun
2017-03-28 18:00 ` york sun
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.