Skip to content

Commit 643515a

Browse files
lumagRob Clark
authored andcommitted
drm/msm: rework binding of Imageon GPUs
Currently the msm driver creates an extra interim platform device for Imageon GPUs. This is not ideal, as the device doesn't have corresponding OF node. If the headless mode is used for newer GPUs, then the msm_use_mmu() function can not detect corresponding IOMMU devices. Also the DRM device (although it's headless) is created with modesetting flags being set. To solve all these issues, rework the way the Imageon devices are bound. Remove the interim device, don't register a component and instead use a cut-down version of the normal functions to probe or remove the driver. Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/662584/ Signed-off-by: Rob Clark <[email protected]>
1 parent 27c3547 commit 643515a

File tree

3 files changed

+72
-59
lines changed

3 files changed

+72
-59
lines changed

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

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -260,42 +260,22 @@ static const struct component_ops a3xx_ops = {
260260
.unbind = adreno_unbind,
261261
};
262262

263-
static void adreno_device_register_headless(void)
264-
{
265-
/* on imx5, we don't have a top-level mdp/dpu node
266-
* this creates a dummy node for the driver for that case
267-
*/
268-
struct platform_device_info dummy_info = {
269-
.parent = NULL,
270-
.name = "msm",
271-
.id = -1,
272-
.res = NULL,
273-
.num_res = 0,
274-
.data = NULL,
275-
.size_data = 0,
276-
.dma_mask = ~0,
277-
};
278-
platform_device_register_full(&dummy_info);
279-
}
280-
281263
static int adreno_probe(struct platform_device *pdev)
282264
{
283-
284-
int ret;
285-
286-
ret = component_add(&pdev->dev, &a3xx_ops);
287-
if (ret)
288-
return ret;
289-
290265
if (of_device_is_compatible(pdev->dev.of_node, "amd,imageon"))
291-
adreno_device_register_headless();
266+
return msm_gpu_probe(pdev, &a3xx_ops);
292267

293-
return 0;
268+
return component_add(&pdev->dev, &a3xx_ops);
294269
}
295270

296271
static void adreno_remove(struct platform_device *pdev)
297272
{
298-
component_del(&pdev->dev, &a3xx_ops);
273+
struct msm_drm_private *priv = platform_get_drvdata(pdev);
274+
275+
if (priv->kms_init)
276+
component_del(&pdev->dev, &a3xx_ops);
277+
else
278+
msm_gpu_remove(pdev, &a3xx_ops);
299279
}
300280

301281
static void adreno_shutdown(struct platform_device *pdev)

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module_param(modeset, bool, 0600);
5757
DECLARE_FAULT_ATTR(fail_gem_alloc);
5858
DECLARE_FAULT_ATTR(fail_gem_iova);
5959

60-
static int msm_drm_uninit(struct device *dev)
60+
static int msm_drm_uninit(struct device *dev, const struct component_ops *gpu_ops)
6161
{
6262
struct platform_device *pdev = to_platform_device(dev);
6363
struct msm_drm_private *priv = platform_get_drvdata(pdev);
@@ -84,15 +84,19 @@ static int msm_drm_uninit(struct device *dev)
8484
if (priv->kms)
8585
msm_drm_kms_uninit(dev);
8686

87-
component_unbind_all(dev, ddev);
87+
if (gpu_ops)
88+
gpu_ops->unbind(dev, dev, NULL);
89+
else
90+
component_unbind_all(dev, ddev);
8891

8992
ddev->dev_private = NULL;
9093
drm_dev_put(ddev);
9194

9295
return 0;
9396
}
9497

95-
static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
98+
static int msm_drm_init(struct device *dev, const struct drm_driver *drv,
99+
const struct component_ops *gpu_ops)
96100
{
97101
struct msm_drm_private *priv = dev_get_drvdata(dev);
98102
struct drm_device *ddev;
@@ -139,7 +143,10 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
139143
dma_set_max_seg_size(dev, UINT_MAX);
140144

141145
/* Bind all our sub-components: */
142-
ret = component_bind_all(dev, ddev);
146+
if (gpu_ops)
147+
ret = gpu_ops->bind(dev, dev, NULL);
148+
else
149+
ret = component_bind_all(dev, ddev);
143150
if (ret)
144151
goto err_put_dev;
145152

@@ -151,11 +158,6 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
151158
ret = msm_drm_kms_init(dev, drv);
152159
if (ret)
153160
goto err_msm_uninit;
154-
} else {
155-
/* valid only for the dummy headless case, where of_node=NULL */
156-
WARN_ON(dev->of_node);
157-
ddev->driver_features &= ~DRIVER_MODESET;
158-
ddev->driver_features &= ~DRIVER_ATOMIC;
159161
}
160162

161163
ret = drm_dev_register(ddev, 0);
@@ -172,7 +174,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
172174
return 0;
173175

174176
err_msm_uninit:
175-
msm_drm_uninit(dev);
177+
msm_drm_uninit(dev, gpu_ops);
176178

177179
return ret;
178180

@@ -834,6 +836,28 @@ static const struct drm_driver msm_driver = {
834836
.patchlevel = MSM_VERSION_PATCHLEVEL,
835837
};
836838

839+
static const struct drm_driver msm_gpu_driver = {
840+
.driver_features = DRIVER_GEM |
841+
DRIVER_RENDER |
842+
DRIVER_SYNCOBJ_TIMELINE |
843+
DRIVER_SYNCOBJ,
844+
.open = msm_open,
845+
.postclose = msm_postclose,
846+
.gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
847+
#ifdef CONFIG_DEBUG_FS
848+
.debugfs_init = msm_debugfs_init,
849+
#endif
850+
.show_fdinfo = msm_show_fdinfo,
851+
.ioctls = msm_ioctls,
852+
.num_ioctls = ARRAY_SIZE(msm_ioctls),
853+
.fops = &fops,
854+
.name = "msm",
855+
.desc = "MSM Snapdragon DRM",
856+
.major = MSM_VERSION_MAJOR,
857+
.minor = MSM_VERSION_MINOR,
858+
.patchlevel = MSM_VERSION_PATCHLEVEL,
859+
};
860+
837861
/*
838862
* Componentized driver support:
839863
*/
@@ -958,12 +982,12 @@ static int add_gpu_components(struct device *dev,
958982

959983
static int msm_drm_bind(struct device *dev)
960984
{
961-
return msm_drm_init(dev, &msm_driver);
985+
return msm_drm_init(dev, &msm_driver, NULL);
962986
}
963987

964988
static void msm_drm_unbind(struct device *dev)
965989
{
966-
msm_drm_uninit(dev);
990+
msm_drm_uninit(dev, NULL);
967991
}
968992

969993
const struct component_master_ops msm_drm_ops = {
@@ -1012,29 +1036,34 @@ int msm_drv_probe(struct device *master_dev,
10121036
return 0;
10131037
}
10141038

1015-
/*
1016-
* Platform driver:
1017-
* Used only for headlesss GPU instances
1018-
*/
1019-
1020-
static int msm_pdev_probe(struct platform_device *pdev)
1039+
int msm_gpu_probe(struct platform_device *pdev,
1040+
const struct component_ops *ops)
10211041
{
1022-
return msm_drv_probe(&pdev->dev, NULL, NULL);
1042+
struct msm_drm_private *priv;
1043+
int ret;
1044+
1045+
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
1046+
if (!priv)
1047+
return -ENOMEM;
1048+
1049+
platform_set_drvdata(pdev, priv);
1050+
1051+
/* on all devices that I am aware of, iommu's which can map
1052+
* any address the cpu can see are used:
1053+
*/
1054+
ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
1055+
if (ret)
1056+
return ret;
1057+
1058+
return msm_drm_init(&pdev->dev, &msm_gpu_driver, ops);
10231059
}
10241060

1025-
static void msm_pdev_remove(struct platform_device *pdev)
1061+
void msm_gpu_remove(struct platform_device *pdev,
1062+
const struct component_ops *ops)
10261063
{
1027-
component_master_del(&pdev->dev, &msm_drm_ops);
1064+
msm_drm_uninit(&pdev->dev, ops);
10281065
}
10291066

1030-
static struct platform_driver msm_platform_driver = {
1031-
.probe = msm_pdev_probe,
1032-
.remove = msm_pdev_remove,
1033-
.driver = {
1034-
.name = "msm",
1035-
},
1036-
};
1037-
10381067
static int __init msm_drm_register(void)
10391068
{
10401069
if (!modeset)
@@ -1049,13 +1078,13 @@ static int __init msm_drm_register(void)
10491078
adreno_register();
10501079
msm_mdp4_register();
10511080
msm_mdss_register();
1052-
return platform_driver_register(&msm_platform_driver);
1081+
1082+
return 0;
10531083
}
10541084

10551085
static void __exit msm_drm_unregister(void)
10561086
{
10571087
DBG("fini");
1058-
platform_driver_unregister(&msm_platform_driver);
10591088
msm_mdss_unregister();
10601089
msm_mdp4_unregister();
10611090
msm_dp_unregister();

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ extern const struct component_master_ops msm_drm_ops;
543543
int msm_kms_pm_prepare(struct device *dev);
544544
void msm_kms_pm_complete(struct device *dev);
545545

546+
int msm_gpu_probe(struct platform_device *pdev,
547+
const struct component_ops *ops);
548+
void msm_gpu_remove(struct platform_device *pdev,
549+
const struct component_ops *ops);
546550
int msm_drv_probe(struct device *dev,
547551
int (*kms_init)(struct drm_device *dev),
548552
struct msm_kms *kms);

0 commit comments

Comments
 (0)