Skip to content

Commit

Permalink
bus: fsl-mc: fix mmio base address for child DPRCs
Browse files Browse the repository at this point in the history
[ Upstream commit 8990f96 ]

Some versions of the MC firmware wrongly report 0 for register base
address of the DPMCP associated with child DPRC objects thus rendering
them unusable. This is particularly troublesome in ACPI boot scenarios
where the legacy way of extracting this base address from the device
tree does not apply.
Given that DPMCPs share the same base address, workaround this by using
the base address extracted from the root DPRC container.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Link: https://lore.kernel.org/r/20210715140718.8513-8-laurentiu.tudor@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tudorl authored and gregkh committed Sep 18, 2021
1 parent 0ee0311 commit 3533c19
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions drivers/bus/fsl-mc/fsl-mc-bus.c
Expand Up @@ -68,6 +68,8 @@ struct fsl_mc_addr_translation_range {
#define MC_FAPR_PL BIT(18)
#define MC_FAPR_BMT BIT(17)

static phys_addr_t mc_portal_base_phys_addr;

/**
* fsl_mc_bus_match - device to driver matching callback
* @dev: the fsl-mc device to match against
Expand Down Expand Up @@ -703,14 +705,30 @@ static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev,
* If base address is in the region_desc use it otherwise
* revert to old mechanism
*/
if (region_desc.base_address)
if (region_desc.base_address) {
regions[i].start = region_desc.base_address +
region_desc.base_offset;
else
} else {
error = translate_mc_addr(mc_dev, mc_region_type,
region_desc.base_offset,
&regions[i].start);

/*
* Some versions of the MC firmware wrongly report
* 0 for register base address of the DPMCP associated
* with child DPRC objects thus rendering them unusable.
* This is particularly troublesome in ACPI boot
* scenarios where the legacy way of extracting this
* base address from the device tree does not apply.
* Given that DPMCPs share the same base address,
* workaround this by using the base address extracted
* from the root DPRC container.
*/
if (is_fsl_mc_bus_dprc(mc_dev) &&
regions[i].start == region_desc.base_offset)
regions[i].start += mc_portal_base_phys_addr;
}

if (error < 0) {
dev_err(parent_dev,
"Invalid MC offset: %#x (for %s.%d\'s region %d)\n",
Expand Down Expand Up @@ -1126,6 +1144,8 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
plat_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mc_portal_phys_addr = plat_res->start;
mc_portal_size = resource_size(plat_res);
mc_portal_base_phys_addr = mc_portal_phys_addr & ~0x3ffffff;

error = fsl_create_mc_io(&pdev->dev, mc_portal_phys_addr,
mc_portal_size, NULL,
FSL_MC_IO_ATOMIC_CONTEXT_PORTAL, &mc_io);
Expand Down

0 comments on commit 3533c19

Please sign in to comment.