Skip to content

Commit 2f497d7

Browse files
jannaumarcan
authored andcommitted
drm/apple: Get rid of the piodma dummy driver
It's only needed to configure the display contoller's iommu to share buffers between the DCP co-processor and the display controller. Possible concern is runtime PM for it and its iommu. If we don't set it up the power domain might never go to lower power states even if it could. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 06747f0 commit 2f497d7

4 files changed

Lines changed: 44 additions & 113 deletions

File tree

drivers/gpu/drm/apple/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ apple_dcp-y += iomfb_v12_3.o
99
apple_dcp-y += iomfb_v13_3.o
1010
apple_dcp-$(CONFIG_TRACING) += trace.o
1111

12-
apple_piodma-y := dummy-piodma.o
1312

1413
obj-$(CONFIG_DRM_APPLE) += appledrm.o
1514
obj-$(CONFIG_DRM_APPLE) += apple_dcp.o
16-
obj-$(CONFIG_DRM_APPLE) += apple_piodma.o
1715

1816
# header test
1917

drivers/gpu/drm/apple/apple_drv.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -556,26 +556,6 @@ const struct component_master_ops apple_drm_ops = {
556556
.unbind = apple_drm_unbind,
557557
};
558558

559-
static const struct of_device_id apple_component_id_tbl[] = {
560-
{ .compatible = "apple,dcp-piodma" },
561-
{},
562-
};
563-
564-
static int add_display_components(struct device *dev,
565-
struct component_match **matchptr)
566-
{
567-
struct device_node *np;
568-
569-
for_each_matching_node(np, apple_component_id_tbl) {
570-
if (of_device_is_available(np))
571-
drm_of_component_match_add(dev, matchptr,
572-
component_compare_of, np);
573-
of_node_put(np);
574-
}
575-
576-
return 0;
577-
}
578-
579559
static int add_dcp_components(struct device *dev,
580560
struct component_match **matchptr)
581561
{
@@ -600,9 +580,6 @@ static int apple_platform_probe(struct platform_device *pdev)
600580
struct component_match *match = NULL;
601581
int num_dcp;
602582

603-
/* add PIODMA mapper components */
604-
add_display_components(mdev, &match);
605-
606583
/* add DCP components, handle less than 1 as probe error */
607584
num_dcp = add_dcp_components(mdev, &match);
608585
if (num_dcp < 1)

drivers/gpu/drm/apple/dcp.c

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/module.h>
1515
#include <linux/moduleparam.h>
1616
#include <linux/of_device.h>
17+
#include <linux/of_platform.h>
1718
#include <linux/slab.h>
1819
#include <linux/soc/apple/rtkit.h>
1920
#include <linux/string.h>
@@ -317,17 +318,39 @@ static void dcp_work_register_backlight(struct work_struct *work)
317318
mutex_unlock(&dcp->bl_register_mutex);
318319
}
319320

320-
static struct platform_device *dcp_get_dev(struct device *dev, const char *name)
321+
static int dcp_create_piodma_iommu_dev(struct apple_dcp *dcp)
321322
{
322-
struct platform_device *pdev;
323-
struct device_node *node = of_parse_phandle(dev->of_node, name, 0);
323+
int ret;
324+
struct device_node *node = of_get_child_by_name(dcp->dev->of_node, "piodma");
324325

325326
if (!node)
326-
return NULL;
327+
return dev_err_probe(dcp->dev, -ENODEV,
328+
"Failed to get piodma child DT node\n");
329+
330+
dcp->piodma = of_platform_device_create(node, NULL, dcp->dev);
331+
if (!dcp->piodma) {
332+
of_node_put(node);
333+
return dev_err_probe(dcp->dev, -ENODEV, "Failed to gcreate piodma pdev for %pOF\n", node);
334+
}
335+
336+
ret = dma_set_mask_and_coherent(&dcp->piodma->dev, DMA_BIT_MASK(42));
337+
if (ret)
338+
goto err_destroy_pdev;
339+
340+
ret = of_dma_configure(&dcp->piodma->dev, node, true);
341+
if (ret) {
342+
ret = dev_err_probe(dcp->dev, ret,
343+
"Failed to configure IOMMU child DMA\n");
344+
goto err_destroy_pdev;
345+
}
346+
of_node_put(node);
327347

328-
pdev = of_find_device_by_node(node);
348+
return 0;
349+
350+
err_destroy_pdev:
329351
of_node_put(node);
330-
return pdev;
352+
of_platform_device_destroy(&dcp->piodma->dev, NULL);
353+
return ret;
331354
}
332355

333356
static int dcp_get_disp_regs(struct apple_dcp *dcp)
@@ -433,8 +456,6 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
433456
if (IS_ERR(dcp->coproc_reg))
434457
return PTR_ERR(dcp->coproc_reg);
435458

436-
of_platform_default_populate(dev->of_node, NULL, dev);
437-
438459
if (!show_notch)
439460
ret = of_property_read_u32(dev->of_node, "apple,notch-height",
440461
&dcp->notch_height);
@@ -480,16 +501,10 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
480501
else
481502
dcp->connector_type = DRM_MODE_CONNECTOR_Unknown;
482503

483-
/*
484-
* Components do not ensure the bind order of sub components but
485-
* the piodma device is only used for its iommu. The iommu is fully
486-
* initialized by the time dcp_piodma_probe() calls component_add().
487-
*/
488-
dcp->piodma = dcp_get_dev(dev, "apple,piodma-mapper");
489-
if (!dcp->piodma) {
490-
dev_err(dev, "failed to find piodma\n");
491-
return -ENODEV;
492-
}
504+
ret = dcp_create_piodma_iommu_dev(dcp);
505+
if (ret)
506+
return dev_err_probe(dev, ret,
507+
"Failed to created PIODMA iommu child device");
493508

494509
ret = dcp_get_disp_regs(dcp);
495510
if (ret) {
@@ -546,8 +561,10 @@ static void dcp_comp_unbind(struct device *dev, struct device *main, void *data)
546561
if (dcp && dcp->shmem)
547562
iomfb_shutdown(dcp);
548563

549-
platform_device_put(dcp->piodma);
550-
dcp->piodma = NULL;
564+
if (dcp->piodma) {
565+
of_platform_device_destroy(&dcp->piodma->dev, NULL);
566+
dcp->piodma = NULL;
567+
}
551568

552569
devm_clk_put(dev, dcp->clk);
553570
dcp->clk = NULL;
@@ -563,6 +580,7 @@ static int dcp_platform_probe(struct platform_device *pdev)
563580
enum dcp_firmware_version fw_compat;
564581
struct device *dev = &pdev->dev;
565582
struct apple_dcp *dcp;
583+
int ret;
566584

567585
fw_compat = dcp_check_firmware_version(dev);
568586
if (fw_compat == DCP_FIRMWARE_UNKNOWN)
@@ -577,6 +595,12 @@ static int dcp_platform_probe(struct platform_device *pdev)
577595

578596
platform_set_drvdata(pdev, dcp);
579597

598+
ret = devm_of_platform_populate(dev);
599+
if (ret) {
600+
dev_err(dev, "failed to populate child devices: %d\n", ret);
601+
return ret;
602+
}
603+
580604
return component_add(&pdev->dev, &dcp_comp_ops);
581605
}
582606

drivers/gpu/drm/apple/dummy-piodma.c

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)