| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 703972946a42cf1f83bf50cf389d618d61b69500 Mon Sep 17 00:00:00 2001 |
| 2 | From: Bharat Bhushan <Bharat.Bhushan@nxp.com> |
| 3 | Date: Mon, 10 Dec 2018 14:42:51 +0530 |
| 4 | Subject: [PATCH] bus: fsl-mc: Allocate mc-portal from root dprc container |
| 5 | |
| 6 | Root dprc container have allocate-able mc-portals which |
| 7 | can be allocated by kernel drivers. |
| 8 | |
| 9 | As per current design mc-portal is allocated from parent |
| 10 | dprc container if requesting device is not root-dprc. |
| 11 | This works fine if the requesting device is child of |
| 12 | root dprc container, because their parent is root-dprc |
| 13 | container. But if request device is grandchild of root |
| 14 | dprc container then it tries to allocate from it's parent |
| 15 | root dprc-container and it fails. |
| 16 | |
| 17 | Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> |
| 18 | Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com> |
| 19 | --- |
| 20 | drivers/bus/fsl-mc/mc-io.c | 10 ++++++---- |
| 21 | 1 file changed, 6 insertions(+), 4 deletions(-) |
| 22 | |
| 23 | --- a/drivers/bus/fsl-mc/mc-io.c |
| 24 | +++ b/drivers/bus/fsl-mc/mc-io.c |
| 25 | @@ -174,14 +174,16 @@ int __must_check fsl_mc_portal_allocate( |
| 26 | int error = -EINVAL; |
| 27 | struct fsl_mc_resource *resource = NULL; |
| 28 | struct fsl_mc_io *mc_io = NULL; |
| 29 | + struct device *root_dprc_dev; |
| 30 | |
| 31 | - if (mc_dev->flags & FSL_MC_IS_DPRC) { |
| 32 | + if (fsl_mc_is_root_dprc(&mc_dev->dev)) { |
| 33 | mc_bus_dev = mc_dev; |
| 34 | } else { |
| 35 | - if (!dev_is_fsl_mc(mc_dev->dev.parent)) |
| 36 | - return error; |
| 37 | + fsl_mc_get_root_dprc(&mc_dev->dev, &root_dprc_dev); |
| 38 | + if (WARN_ON(!root_dprc_dev)) |
| 39 | + return -EINVAL; |
| 40 | |
| 41 | - mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent); |
| 42 | + mc_bus_dev = to_fsl_mc_device(root_dprc_dev); |
| 43 | } |
| 44 | |
| 45 | mc_bus = to_fsl_mc_bus(mc_bus_dev); |