Skip to content

Commit 5a903a4

Browse files
konradybciorobclark
authored andcommitted
drm/msm/a6xx: Introduce GMU wrapper support
Some (particularly SMD_RPM, a.k.a non-RPMh) SoCs implement A6XX GPUs but don't implement the associated GMUs. This is due to the fact that the GMU directly pokes at RPMh. Sadly, this means we have to take care of enabling & scaling power rails, clocks and bandwidth ourselves. Reuse existing Adreno-common code and modify the deeply-GMU-infused A6XX code to facilitate these GPUs. This involves if-ing out lots of GMU callbacks and introducing a new type of GMU - GMU wrapper (it's the actual name that Qualcomm uses in their downstream kernels). This is essentially a register region which is convenient to model as a device. We'll use it for managing the GDSCs. The register layout matches the actual GMU_CX/GX regions on the "real GMU" devices and lets us reuse quite a bit of gmu_read/write/rmw calls. Signed-off-by: Konrad Dybcio <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/542766/ Signed-off-by: Rob Clark <[email protected]>
1 parent 30f55f3 commit 5a903a4

File tree

6 files changed

+266
-36
lines changed

6 files changed

+266
-36
lines changed

drivers/gpu/drm/msm/adreno/a6xx_gmu.c

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,7 @@ static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, struct platform_device *pdev,
14311431

14321432
void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
14331433
{
1434+
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
14341435
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
14351436
struct platform_device *pdev = to_platform_device(gmu->dev);
14361437

@@ -1456,10 +1457,12 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu)
14561457
gmu->mmio = NULL;
14571458
gmu->rscc = NULL;
14581459

1459-
a6xx_gmu_memory_free(gmu);
1460+
if (!adreno_has_gmu_wrapper(adreno_gpu)) {
1461+
a6xx_gmu_memory_free(gmu);
14601462

1461-
free_irq(gmu->gmu_irq, gmu);
1462-
free_irq(gmu->hfi_irq, gmu);
1463+
free_irq(gmu->gmu_irq, gmu);
1464+
free_irq(gmu->hfi_irq, gmu);
1465+
}
14631466

14641467
/* Drop reference taken in of_find_device_by_node */
14651468
put_device(gmu->dev);
@@ -1478,6 +1481,69 @@ static int cxpd_notifier_cb(struct notifier_block *nb,
14781481
return 0;
14791482
}
14801483

1484+
int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
1485+
{
1486+
struct platform_device *pdev = of_find_device_by_node(node);
1487+
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
1488+
int ret;
1489+
1490+
if (!pdev)
1491+
return -ENODEV;
1492+
1493+
gmu->dev = &pdev->dev;
1494+
1495+
of_dma_configure(gmu->dev, node, true);
1496+
1497+
pm_runtime_enable(gmu->dev);
1498+
1499+
/* Mark legacy for manual SPTPRAC control */
1500+
gmu->legacy = true;
1501+
1502+
/* Map the GMU registers */
1503+
gmu->mmio = a6xx_gmu_get_mmio(pdev, "gmu");
1504+
if (IS_ERR(gmu->mmio)) {
1505+
ret = PTR_ERR(gmu->mmio);
1506+
goto err_mmio;
1507+
}
1508+
1509+
gmu->cxpd = dev_pm_domain_attach_by_name(gmu->dev, "cx");
1510+
if (IS_ERR(gmu->cxpd)) {
1511+
ret = PTR_ERR(gmu->cxpd);
1512+
goto err_mmio;
1513+
}
1514+
1515+
if (!device_link_add(gmu->dev, gmu->cxpd, DL_FLAG_PM_RUNTIME)) {
1516+
ret = -ENODEV;
1517+
goto detach_cxpd;
1518+
}
1519+
1520+
init_completion(&gmu->pd_gate);
1521+
complete_all(&gmu->pd_gate);
1522+
gmu->pd_nb.notifier_call = cxpd_notifier_cb;
1523+
1524+
/* Get a link to the GX power domain to reset the GPU */
1525+
gmu->gxpd = dev_pm_domain_attach_by_name(gmu->dev, "gx");
1526+
if (IS_ERR(gmu->gxpd)) {
1527+
ret = PTR_ERR(gmu->gxpd);
1528+
goto err_mmio;
1529+
}
1530+
1531+
gmu->initialized = true;
1532+
1533+
return 0;
1534+
1535+
detach_cxpd:
1536+
dev_pm_domain_detach(gmu->cxpd, false);
1537+
1538+
err_mmio:
1539+
iounmap(gmu->mmio);
1540+
1541+
/* Drop reference taken in of_find_device_by_node */
1542+
put_device(gmu->dev);
1543+
1544+
return ret;
1545+
}
1546+
14811547
int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)
14821548
{
14831549
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;

0 commit comments

Comments
 (0)