Skip to content

Commit 217ed15

Browse files
lumagRob Clark
authored andcommitted
drm/msm: enable separate binding of GPU and display devices
There are cases when we want to have separate DRM devices for GPU and display pipelines. One example is development, when it is beneficial to be able to bind the GPU driver separately, without the display pipeline (and without the hacks adding "amd,imageon" to the compatible string). Another example is some of Qualcomm platforms, which have two MDSS units, but only one GPU. With current approach it is next to impossible to support this usecase properly, while separate binding allows users to have three DRM devices: two for MDSS units and a single headless GPU. Add kernel param msm.separate_gpu_kms, which if set to true forces creation of separate display and GPU DRM devices. Mesa supports this setup by using the kmsro wrapper. The param is disabled by default, in order to be able to test userspace for the compatibility issues. Simple clients are able to handle this setup automatically. Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/662590/ [Rob: renamed the modparam to separate_gpu_kms, and add missing DRIVER_GEM_GPUVA] Signed-off-by: Rob Clark <[email protected]>
1 parent 643515a commit 217ed15

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ static const struct component_ops a3xx_ops = {
262262

263263
static int adreno_probe(struct platform_device *pdev)
264264
{
265-
if (of_device_is_compatible(pdev->dev.of_node, "amd,imageon"))
265+
if (of_device_is_compatible(pdev->dev.of_node, "amd,imageon") ||
266+
msm_gpu_no_components())
266267
return msm_gpu_probe(pdev, &a3xx_ops);
267268

268269
return component_add(&pdev->dev, &a3xx_ops);

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ static bool modeset = true;
5454
MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disable)");
5555
module_param(modeset, bool, 0600);
5656

57+
static bool separate_gpu_kms;
58+
MODULE_PARM_DESC(separate_gpu_drm, "Use separate DRM device for the GPU (0=single DRM device for both GPU and display (default), 1=two DRM devices)");
59+
module_param(separate_gpu_kms, bool, 0400);
60+
5761
DECLARE_FAULT_ATTR(fail_gem_alloc);
5862
DECLARE_FAULT_ATTR(fail_gem_iova);
5963

64+
bool msm_gpu_no_components(void)
65+
{
66+
return separate_gpu_kms;
67+
}
68+
6069
static int msm_drm_uninit(struct device *dev, const struct component_ops *gpu_ops)
6170
{
6271
struct platform_device *pdev = to_platform_device(dev);
@@ -836,8 +845,33 @@ static const struct drm_driver msm_driver = {
836845
.patchlevel = MSM_VERSION_PATCHLEVEL,
837846
};
838847

848+
static const struct drm_driver msm_kms_driver = {
849+
.driver_features = DRIVER_GEM |
850+
DRIVER_ATOMIC |
851+
DRIVER_MODESET,
852+
.open = msm_open,
853+
.postclose = msm_postclose,
854+
.dumb_create = msm_gem_dumb_create,
855+
.dumb_map_offset = msm_gem_dumb_map_offset,
856+
.gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
857+
#ifdef CONFIG_DEBUG_FS
858+
.debugfs_init = msm_debugfs_init,
859+
#endif
860+
MSM_FBDEV_DRIVER_OPS,
861+
.show_fdinfo = msm_show_fdinfo,
862+
.ioctls = msm_ioctls,
863+
.num_ioctls = ARRAY_SIZE(msm_ioctls),
864+
.fops = &fops,
865+
.name = "msm-kms",
866+
.desc = "MSM Snapdragon DRM",
867+
.major = MSM_VERSION_MAJOR,
868+
.minor = MSM_VERSION_MINOR,
869+
.patchlevel = MSM_VERSION_PATCHLEVEL,
870+
};
871+
839872
static const struct drm_driver msm_gpu_driver = {
840873
.driver_features = DRIVER_GEM |
874+
DRIVER_GEM_GPUVA |
841875
DRIVER_RENDER |
842876
DRIVER_SYNCOBJ_TIMELINE |
843877
DRIVER_SYNCOBJ,
@@ -982,7 +1016,11 @@ static int add_gpu_components(struct device *dev,
9821016

9831017
static int msm_drm_bind(struct device *dev)
9841018
{
985-
return msm_drm_init(dev, &msm_driver, NULL);
1019+
return msm_drm_init(dev,
1020+
msm_gpu_no_components() ?
1021+
&msm_kms_driver :
1022+
&msm_driver,
1023+
NULL);
9861024
}
9871025

9881026
static void msm_drm_unbind(struct device *dev)
@@ -1018,9 +1056,11 @@ int msm_drv_probe(struct device *master_dev,
10181056
return ret;
10191057
}
10201058

1021-
ret = add_gpu_components(master_dev, &match);
1022-
if (ret)
1023-
return ret;
1059+
if (!msm_gpu_no_components()) {
1060+
ret = add_gpu_components(master_dev, &match);
1061+
if (ret)
1062+
return ret;
1063+
}
10241064

10251065
/* on all devices that I am aware of, iommu's which can map
10261066
* any address the cpu can see are used:

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,4 +554,6 @@ void msm_kms_shutdown(struct platform_device *pdev);
554554

555555
bool msm_disp_drv_should_bind(struct device *dev, bool dpu_driver);
556556

557+
bool msm_gpu_no_components(void);
558+
557559
#endif /* __MSM_DRV_H__ */

0 commit comments

Comments
 (0)