Skip to content

Commit 17292e0

Browse files
committed
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 <[email protected]>
1 parent f1aa7c2 commit 17292e0

4 files changed

Lines changed: 41 additions & 114 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
@@ -558,26 +558,6 @@ const struct component_master_ops apple_drm_ops = {
558558
.unbind = apple_drm_unbind,
559559
};
560560

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

605-
/* add PIODMA mapper components */
606-
add_display_components(mdev, &match);
607-
608585
/* add DCP components, handle less than 1 as probe error */
609586
num_dcp = add_dcp_components(mdev, &match);
610587
if (num_dcp < 1)

drivers/gpu/drm/apple/dcp.c

Lines changed: 41 additions & 21 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,35 @@ 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+
return dev_err_probe(dcp->dev, -ENODEV, "Failed to create piodma pdev\n");
333+
334+
ret = dma_set_mask_and_coherent(&dcp->piodma->dev, DMA_BIT_MASK(42));
335+
if (ret)
336+
goto err_destroy_pdev;
327337

328-
pdev = of_find_device_by_node(node);
329-
of_node_put(node);
330-
return pdev;
338+
ret = of_dma_configure(&dcp->piodma->dev, node, true);
339+
if (ret) {
340+
ret = dev_err_probe(dcp->dev, ret,
341+
"Failed to configure IOMMU child DMA\n");
342+
goto err_destroy_pdev;
343+
}
344+
345+
return 0;
346+
347+
err_destroy_pdev:
348+
of_platform_device_destroy(&dcp->piodma->dev, NULL);
349+
return ret;
331350
}
332351

333352
static int dcp_get_disp_regs(struct apple_dcp *dcp)
@@ -433,8 +452,6 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
433452
if (IS_ERR(dcp->coproc_reg))
434453
return PTR_ERR(dcp->coproc_reg);
435454

436-
of_platform_default_populate(dev->of_node, NULL, dev);
437-
438455
if (!show_notch)
439456
ret = of_property_read_u32(dev->of_node, "apple,notch-height",
440457
&dcp->notch_height);
@@ -478,16 +495,10 @@ static int dcp_comp_bind(struct device *dev, struct device *main, void *data)
478495
else
479496
dcp->connector_type = DRM_MODE_CONNECTOR_Unknown;
480497

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

492503
ret = dcp_get_disp_regs(dcp);
493504
if (ret) {
@@ -544,8 +555,10 @@ static void dcp_comp_unbind(struct device *dev, struct device *main, void *data)
544555
if (dcp && dcp->shmem)
545556
iomfb_shutdown(dcp);
546557

547-
platform_device_put(dcp->piodma);
548-
dcp->piodma = NULL;
558+
if (dcp->piodma) {
559+
of_platform_device_destroy(&dcp->piodma->dev, NULL);
560+
dcp->piodma = NULL;
561+
}
549562

550563
devm_clk_put(dev, dcp->clk);
551564
dcp->clk = NULL;
@@ -561,6 +574,7 @@ static int dcp_platform_probe(struct platform_device *pdev)
561574
enum dcp_firmware_version fw_compat;
562575
struct device *dev = &pdev->dev;
563576
struct apple_dcp *dcp;
577+
int ret;
564578

565579
fw_compat = dcp_check_firmware_version(dev);
566580
if (fw_compat == DCP_FIRMWARE_UNKNOWN)
@@ -575,6 +589,12 @@ static int dcp_platform_probe(struct platform_device *pdev)
575589

576590
platform_set_drvdata(pdev, dcp);
577591

592+
ret = devm_of_platform_populate(dev);
593+
if (ret) {
594+
dev_err(dev, "failed to populate child devices: %d\n", ret);
595+
return ret;
596+
}
597+
578598
return component_add(&pdev->dev, &dcp_comp_ops);
579599
}
580600

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

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

0 commit comments

Comments
 (0)