Platforms that use #address-cells = <2> on the fastrpc node encode the
context bank number in cell[1] of the reg property rather than cell[0].
Reading cell[0] on such platforms yields 0 for every context bank,
causing all sessions to share SID 0 and corrupting IOVA address
construction.

Use of_property_read_u32_index() with of_n_addr_cells() - 1 as the
index so the correct cell is read regardless of the parent address cell
width.

Signed-off-by: Vinayak Katoch <[email protected]>
---
 drivers/misc/fastrpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 98a61b8b9013..07a0f2b229b4 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2378,7 +2378,8 @@ static int fastrpc_cb_init(struct platform_device *pdev)
        if (!cctx)
                return -EINVAL;
 
-       if (of_property_read_u32(dev->of_node, "reg", &sid))
+       if (of_property_read_u32_index(dev->of_node, "reg",
+                                      of_n_addr_cells(dev->of_node) - 1, &sid))
                dev_info(dev, "FastRPC Session ID not specified in DT\n");
 
        spin_lock_irqsave(&cctx->lock, flags);

-- 
2.34.1

Reply via email to