drm/msm: rework the ties between KMS and GPU parts of the driver
Subsystems (5)
v5 cover drm/msm: rework the ties between KMS and GPU parts of the driver
Currently the KMS and GPU parts of the msm driver are pretty much intertwined. It is impossible to register a KMS-only device and registering a GPU-only DRM device requires modifying the DT. Not to mention that binding the GPU-only device creates an interim platform devices, which complicates IOMMU setup.
Rework the driver:
- Make it possible to disable KMS parts (if MDP4, MDP5 and DPU drivers are disabled).
- Register GPU-only devices without an interim platform device.
- Add module param that makes msm driver register GPU and KMS devices separately.
---
Changes in v5:
- Rebased on msm-next, dropped applied patches, re-picked up no-GPU
patch
- Rewored debugfs, GEM VM_BIND and ioctls code to reduce number of
#ifdef's
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Rebased on msm-next(-robclark)
- Temporarily dropped the "no-GPU" patch, it will be reposted later
(Rob)
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Disabled SYNCOBJ / SYNCOBJ_TIMELINE for KMS-only driver (Rob Clark)
- Further refine Kconfig dependencies
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Got rid of mdp4_crtc.id and msm_drm_private.num_crtcs
- Moved msm_drm_private.wq and msm_drm_private.event_thread to struct
msm_kms (Rob Clark)
- Moved HDMI / DSI / DP pointers to msm_kms (Abhinav)
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Dmitry Baryshkov (5):
drm/msm: correct separate_gpu_kms description drm/msm: split VM_BIND from the rest of GEM VMA code drm/msm: split away IOCTLs implementation drm/msm: split debugfs implementation drm/msm: make it possible to disable GPU support
drivers/gpu/drm/msm/Kconfig | 27 +- drivers/gpu/drm/msm/Makefile | 21 +- drivers/gpu/drm/msm/msm_debugfs.c | 420 ------------ drivers/gpu/drm/msm/msm_debugfs.h | 14 - drivers/gpu/drm/msm/msm_drv.c | 645 +++--------------- drivers/gpu/drm/msm/msm_drv.h | 16 - drivers/gpu/drm/msm/msm_gem.h | 10 + drivers/gpu/drm/msm/msm_gem_debugfs.c | 96 +++ drivers/gpu/drm/msm/msm_gem_vm_bind.c | 1116 +++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_gem_vma.c | 1177 +-------------------------------- drivers/gpu/drm/msm/msm_gem_vma.h | 119 ++++ drivers/gpu/drm/msm/msm_gpu.c | 45 ++ drivers/gpu/drm/msm/msm_gpu.h | 111 +++- drivers/gpu/drm/msm/msm_gpu_debugfs.c | 213 ++++++ drivers/gpu/drm/msm/msm_ioctl.c | 484 ++++++++++++++ drivers/gpu/drm/msm/msm_ioctl.h | 37 ++ drivers/gpu/drm/msm/msm_kms.h | 8 + drivers/gpu/drm/msm/msm_kms_debugfs.c | 129 ++++ drivers/gpu/drm/msm/msm_submitqueue.c | 12 +- 19 files changed, 2463 insertions(+), 2237 deletions(-)
---
base-commit: 05af764719214d6568adb55c8749dec295228da8
change-id: 20250411-msm-gpu-split-2701e49e40f0
Best regards,
Signature · 2 lines
With best wishes Dmitry
PATCH v5 1/5 drm/msm: correct separate_gpu_kms description
While applying commit 217ed15bd399 ("drm/msm: enable separate binding of GPU and display devices") the module param was renamed from separate_gpu_drm to separate_gpu_kms. However param name inside MODULE_PARAM_DESC wasn't updated to reflect the new name.
Update MODULE_PARAM_DESC to use current name for the module param.
--- drivers/gpu/drm/msm/msm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disabmodule_param (modeset, bool,0600 );static bool separate_gpu_kms; -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)" ); +MODULE_PARM_DESC (separate_gpu_kms,"Use separate DRM device for the GPU (0=single DRM device for both GPU and display (default), 1=two DRM devices)" );module_param (separate_gpu_kms, bool,0400 );DECLARE_FAULT_ATTR (fail_gem_alloc);
Signature · 1 line
2.47.3
PATCH v5 2/5 drm/msm: split VM_BIND from the rest of GEM VMA code
In reply to Dmitry BaryshkovIn preparation to disabling GPU functionality split VM_BIND-related functions (which are used only for the GPU) from the rest of the GEM VMA implementation.
--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/msm_gem_vm_bind.c | 1116 +++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_gem_vma.c | 1177 +-------------------------------- drivers/gpu/drm/msm/msm_gem_vma.h | 105 +++ 4 files changed, 1225 insertions(+), 1174 deletions(-)
drivers/gpu/drm/msm/Makefile +1 -0
@@ -115,6 +115,7 @@ msm-y += \ msm_gem_shrinker.o \ msm_gem_submit.o \ msm_gem_vma.o \ + msm_gem_vm_bind.o \ msm_gpu.o \ msm_gpu_devfreq.o \ msm_io_utils.o \
drivers/gpu/drm/msm/msm_gem_vm_bind.c new file +1116 -0
1,116 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gem_vma.c +3 -1174
1,226 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gem_vma.h new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.47.3
Re: [PATCH v5 2/5] drm/msm: split VM_BIND from the rest of GEM VMA code
Quoted 25 lines · Dmitry Baryshkov
In preparation to disabling GPU functionality split VM_BIND-related functions (which are used only for the GPU) from the rest of the GEM VMA implementation.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/msm_gem_vm_bind.c | 1116 +++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_gem_vma.c | 1177 +-------------------------------- drivers/gpu/drm/msm/msm_gem_vma.h | 105 +++ 4 files changed, 1225 insertions(+), 1174 deletions(-)drivers/gpu/drm/msm/Makefile +1
-0@@ -115,6 +115,7 @@ msm-y += \ msm_gem_shrinker.o \ msm_gem_submit.o \ msm_gem_vma.o \ + msm_gem_vm_bind.o \ msm_gpu.o \ msm_gpu_devfreq.o \ msm_io_utils.o \
[snip]
Quoted 52 lines
drivers/gpu/drm/msm/msm_gem_vma.h new file +46
-0@@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2016 Red Hat +* Author: Rob Clark <[email protected]> +*/ + +#ifndef _MSM_GEM_VMA_H_ +#define _MSM_GEM_VMA_H_ + +#define vm_dbg(fmt, ...) pr_debug("%s:%d: "fmt"\n", __func__, __LINE__, ##__VA_ARGS__) + +/** + * struct msm_vm_map_op - create new pgtable mapping + */ +struct msm_vm_map_op { + /** @iova: start address for mapping */ + uint64_t iova; + /** @range: size of the region to map */ + uint64_t range; + /** @offset: offset into @sgt to map */ + uint64_t offset; + /** @sgt: pages to map, or NULL for a PRR mapping */ + struct sg_table *sgt; + /** @prot: the mapping protection flags */ + int prot; + + /** + * @queue_id: The id of the submitqueue the operation is performed + * on, or zero for (in particular) UNMAP ops triggered outside of + * a submitqueue (ie. process cleanup) + */ + int queue_id; +}; + +/** + * struct msm_vm_unmap_op - unmap a range of pages from pgtable + */ +struct msm_vm_unmap_op { + /** @iova: start address for unmap */ + uint64_t iova; + /** @range: size of region to unmap */ + uint64_t range; + + /** @reason: The reason for the unmap */ + const char *reason; +
drivers/gpu/drm/msm/msm_gem_vma.h line 56
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.h new file +10
-0+/** +* @queue_id: The id of the submitqueue the operation is performed +* on, or zero for (in particular) UNMAP ops triggered outside of +* a submitqueue (ie. process cleanup) +*/ +int queue_id; +}; + +static void +vm_log (struct msm_gem_vm *vm,const char *op,uint64_t iova,uint64_t range,int queue_id)
These would have to be static-inline
But overall I'm not sure how I feel about this.. I guess the goal is to reduce the size of a kms-only driver? If so, I think you could do better with some ugly ifdef (for ex, you could also remove scheduler and other fields not used by kernel managed VMs from msm_gem_vm).
I'm not sure how much the savings would be, or if it is worth the pain (ie. extra build configurations to test going forward, etc). Having no GPU doesn't seem like a case worth optimizing for, tbh. You could still have a single driver which binds to multiple different devices, ie. if # of GPUs != # of DPUs without this with no change in footprint.
BR,
-R
Quoted 53 lines
drivers/gpu/drm/msm/msm_gem_vma.h new file +49
-1+{ +int idx; + +if (!vm->managed) +lockdep_assert_held (&vm->mmu_lock); + +vm_dbg ("%s:%p:%d: %016llx %016llx" , op, vm, queue_id, iova, iova + range); + +if (!vm->log) +return ; + + idx = vm->log_idx; + vm->log[idx].op = op; + vm->log[idx].iova = iova; + vm->log[idx].range = range; + vm->log[idx].queue_id = queue_id; + vm->log_idx = (vm->log_idx +1 ) & ((1 << vm->log_shift) -1 ); +} + +static void +vm_unmap_op (struct msm_gem_vm *vm,const struct msm_vm_unmap_op *op) +{ +const char *reason = op->reason; + +if (!reason) + reason ="unmap" ; + +vm_log (vm, reason, op->iova, op->range, op->queue_id); + + vm->mmu->funcs->unmap (vm->mmu, op->iova, op->range); +} + +static int +vm_map_op (struct msm_gem_vm *vm,const struct msm_vm_map_op *op) +{ +vm_log (vm,"map" , op->iova, op->range, op->queue_id); + +return vm->mmu->funcs->map (vm->mmu, op->iova, op->sgt, op->offset, + op->range, op->prot); +} + +int msm_gem_vm_sm_step_map (struct drm_gpuva_op *op,void *_arg); +int msm_gem_vm_sm_step_remap (struct drm_gpuva_op *op,void *arg); +int msm_gem_vm_sm_step_unmap (struct drm_gpuva_op *op,void *_arg); + +int msm_gem_vm_sched_init (struct msm_gem_vm *vm,struct drm_device *drm); +void msm_gem_vm_sched_fini (struct msm_gem_vm *vm); + +#endif --2.47.3
Re: [PATCH v5 2/5] drm/msm: split VM_BIND from the rest of GEM VMA code
Quoted 95 lines · Rob Clark
Quoted 25 lines · Dmitry Baryshkov
In preparation to disabling GPU functionality split VM_BIND-related functions (which are used only for the GPU) from the rest of the GEM VMA implementation.
Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/msm_gem_vm_bind.c | 1116 +++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_gem_vma.c | 1177 +-------------------------------- drivers/gpu/drm/msm/msm_gem_vma.h | 105 +++ 4 files changed, 1225 insertions(+), 1174 deletions(-)drivers/gpu/drm/msm/Makefile +1
-0@@ -115,6 +115,7 @@ msm-y += \ msm_gem_shrinker.o \ msm_gem_submit.o \ msm_gem_vma.o \ + msm_gem_vm_bind.o \ msm_gpu.o \ msm_gpu_devfreq.o \ msm_io_utils.o \[snip]
Quoted 52 lines
drivers/gpu/drm/msm/msm_gem_vma.h new file +46
-0@@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2016 Red Hat +* Author: Rob Clark <[email protected]> +*/ + +#ifndef _MSM_GEM_VMA_H_ +#define _MSM_GEM_VMA_H_ + +#define vm_dbg(fmt, ...) pr_debug("%s:%d: "fmt"\n", __func__, __LINE__, ##__VA_ARGS__) + +/** + * struct msm_vm_map_op - create new pgtable mapping + */ +struct msm_vm_map_op { + /** @iova: start address for mapping */ + uint64_t iova; + /** @range: size of the region to map */ + uint64_t range; + /** @offset: offset into @sgt to map */ + uint64_t offset; + /** @sgt: pages to map, or NULL for a PRR mapping */ + struct sg_table *sgt; + /** @prot: the mapping protection flags */ + int prot; + + /** + * @queue_id: The id of the submitqueue the operation is performed + * on, or zero for (in particular) UNMAP ops triggered outside of + * a submitqueue (ie. process cleanup) + */ + int queue_id; +}; + +/** + * struct msm_vm_unmap_op - unmap a range of pages from pgtable + */ +struct msm_vm_unmap_op { + /** @iova: start address for unmap */ + uint64_t iova; + /** @range: size of region to unmap */ + uint64_t range; + + /** @reason: The reason for the unmap */ + const char *reason; +drivers/gpu/drm/msm/msm_gem_vma.h line 56
Quoted 10 lines
drivers/gpu/drm/msm/msm_gem_vma.h new file +10
-0+/** +* @queue_id: The id of the submitqueue the operation is performed +* on, or zero for (in particular) UNMAP ops triggered outside of +* a submitqueue (ie. process cleanup) +*/ +int queue_id; +}; + +static void +vm_log (struct msm_gem_vm *vm,const char *op,uint64_t iova,uint64_t range,int queue_id)These would have to be static-inline
Quoted 4 lines
But overall I'm not sure how I feel about this.. I guess the goal is to reduce the size of a kms-only driver? If so, I think you could do better with some ugly ifdef (for ex, you could also remove scheduler and other fields not used by kernel managed VMs from
msm_gem_vm).
More or less so. I also wanted to separate the complicated parts from the simple GEM parts, but I see your point too.
I was also trying to trim the dependencies, but this can be #ifdef'd.
Quoted 6 lines
I'm not sure how much the savings would be, or if it is worth the pain (ie. extra build configurations to test going forward, etc). Having no GPU doesn't seem like a case worth optimizing for, tbh. You could still have a single driver which binds to multiple different devices, ie. if # of GPUs != # of DPUs without this with no change in footprint.
Counting GPUs and DPUs isn't that easy, because this also makes things
assymmetric: some of the GPU/DPU pairs can be handled natively, some of them need to have buffers exported and then imported. We also have a usecase of splitting the GPU driver because for some of the workloads it would be better to load just the GPU driver or just the display driver (possibly replacing the other one with the proprietary driver).
Quoted 60 lines
BR,
-RQuoted 53 lines
drivers/gpu/drm/msm/msm_gem_vma.h new file +49
-1+{ +int idx; + +if (!vm->managed) +lockdep_assert_held (&vm->mmu_lock); + +vm_dbg ("%s:%p:%d: %016llx %016llx" , op, vm, queue_id, iova, iova + range); + +if (!vm->log) +return ; + + idx = vm->log_idx; + vm->log[idx].op = op; + vm->log[idx].iova = iova; + vm->log[idx].range = range; + vm->log[idx].queue_id = queue_id; + vm->log_idx = (vm->log_idx +1 ) & ((1 << vm->log_shift) -1 ); +} + +static void +vm_unmap_op (struct msm_gem_vm *vm,const struct msm_vm_unmap_op *op) +{ +const char *reason = op->reason; + +if (!reason) + reason ="unmap" ; + +vm_log (vm, reason, op->iova, op->range, op->queue_id); + + vm->mmu->funcs->unmap (vm->mmu, op->iova, op->range); +} + +static int +vm_map_op (struct msm_gem_vm *vm,const struct msm_vm_map_op *op) +{ +vm_log (vm,"map" , op->iova, op->range, op->queue_id); + +return vm->mmu->funcs->map (vm->mmu, op->iova, op->sgt, op->offset, + op->range, op->prot); +} + +int msm_gem_vm_sm_step_map (struct drm_gpuva_op *op,void *_arg); +int msm_gem_vm_sm_step_remap (struct drm_gpuva_op *op,void *arg); +int msm_gem_vm_sm_step_unmap (struct drm_gpuva_op *op,void *_arg); + +int msm_gem_vm_sched_init (struct msm_gem_vm *vm,struct drm_device *drm); +void msm_gem_vm_sched_fini (struct msm_gem_vm *vm); + +#endif --2.47.3
Signature · 2 lines
With best wishes Dmitry
PATCH v5 3/5 drm/msm: split away IOCTLs implementation
In reply to Dmitry BaryshkovThe IOCTL interface is only used for interfacing the GPU parts of the driver. In preparation to disabling GPU functionality split MSM IOCTLs to a separate source file.
--- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/msm_drv.c | 489 +--------------------------------------- drivers/gpu/drm/msm/msm_ioctl.c | 484 +++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_ioctl.h | 37 +++ 4 files changed, 523 insertions(+), 488 deletions(-)
drivers/gpu/drm/msm/Makefile +1 -0
@@ -119,6 +119,7 @@ msm-y += \ msm_gpu.o \ msm_gpu_devfreq.o \ msm_io_utils.o \ + msm_ioctl.o \ msm_iommu.o \ msm_perf.o \ msm_rd.o \
drivers/gpu/drm/msm/msm_drv.c +1 -488
508 lines not on this page · raw message
drivers/gpu/drm/msm/msm_ioctl.c new file +484 -0
484 lines not on this page · raw message
drivers/gpu/drm/msm/msm_ioctl.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. +* Copyright (C) 2013 Red Hat +* Author: Rob Clark <[email protected]> +*/ + +#ifndef __MSM_IOCTLS_H__ +#define __MSM_IOCTLS_H__ + +#include <linux/types.h> + +struct drm_device ; +struct drm_file ; +struct drm_gem_object ; + +int msm_ioctl_get_param (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_set_param (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_gem_new (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_gem_cpu_prep (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_gem_cpu_fini (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_gem_info_iova (struct drm_device *dev,struct drm_file *file, +struct drm_gem_object *obj,uint64_t *iova); +int msm_ioctl_gem_info_set_iova (struct drm_device *dev,struct drm_file *file, +struct drm_gem_object *obj,uint64_t iova); +int msm_ioctl_gem_info_set_metadata (struct drm_gem_object *obj, +__user void *metadata,u32 metadata_size); +int msm_ioctl_gem_info_get_metadata (struct drm_gem_object *obj, +__user void *metadata,u32 *metadata_size); +int msm_ioctl_gem_info (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_wait_fence (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_gem_madvise (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_submitqueue_new (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_submitqueue_query (struct drm_device *dev,void *data,struct drm_file *file); +int msm_ioctl_submitqueue_close (struct drm_device *dev,void *data,struct drm_file *file); + +#endif
Signature · 1 line
2.47.3
PATCH v5 4/5 drm/msm: split debugfs implementation
In reply to Dmitry BaryshkovIn preparation for making the GPU supporting code optional split the debugfs code into three main pieces: GEM (always enabled), KMS (only enabled if KMS driver parts are enabled) and GPU (currently always enabled, will become optional later).
--- drivers/gpu/drm/msm/Makefile | 4 +- drivers/gpu/drm/msm/msm_debugfs.c | 420 ---------------------------------- drivers/gpu/drm/msm/msm_debugfs.h | 14 -- drivers/gpu/drm/msm/msm_drv.c | 21 +- drivers/gpu/drm/msm/msm_drv.h | 4 +- drivers/gpu/drm/msm/msm_gem.h | 8 + drivers/gpu/drm/msm/msm_gem_debugfs.c | 96 ++++++++ drivers/gpu/drm/msm/msm_gpu_debugfs.c | 213 +++++++++++++++++ drivers/gpu/drm/msm/msm_kms.h | 8 + drivers/gpu/drm/msm/msm_kms_debugfs.c | 129 +++++++++++ 10 files changed, 476 insertions(+), 441 deletions(-)
drivers/gpu/drm/msm/Makefile +3 -1
@@ -107,10 +107,10 @@ msm-display-$(CONFIG_DRM_MSM_KMS) += \ disp/msm_disp_snapshot_util.o \ msm-y += \ - msm_debugfs.o \ msm_drv.o \ msm_fence.o \ msm_gem.o \ + msm_gem_debugfs.o \ msm_gem_prime.o \ msm_gem_shrinker.o \ msm_gem_submit.o \
@@ -118,6 +118,7 @@ msm-y += \ msm_gem_vm_bind.o \ msm_gpu.o \ msm_gpu_devfreq.o \ + msm_gpu_debugfs.o \ msm_io_utils.o \ msm_ioctl.o \ msm_iommu.o \
@@ -133,6 +134,7 @@ msm-$(CONFIG_DRM_MSM_KMS) += \ msm_atomic_tracepoints.o \ msm_fb.o \ msm_kms.o \ + msm_kms_debugfs.o \ msm-$(CONFIG_DRM_MSM_KMS_FBDEV) += msm_fbdev.o
drivers/gpu/drm/msm/msm_debugfs.c deleted +0 -420
420 lines not on this page · raw message
drivers/gpu/drm/msm/msm_debugfs.h deleted +0 -14
@@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (C) 2016 Red Hat -* Author: Rob Clark <[email protected]> -*/ - -#ifndef __MSM_DEBUGFS_H__ -#define __MSM_DEBUGFS_H__ - -#ifdef CONFIG_DEBUG_FS -void msm_debugfs_init (struct drm_minor *minor); -#endif - -#endif /* __MSM_DEBUGFS_H__ */
drivers/gpu/drm/msm/msm_drv.c +17 -4
@@ -15,7 +15,6 @@#include <drm/drm_of.h> #include "msm_drv.h" -#include "msm_debugfs.h" #include "msm_gpu.h" #include "msm_ioctl.h" #include "msm_kms.h"
@@ -64,6 +63,22 @@ bool msm_gpu_no_components(void)return separate_gpu_kms; } +#ifdef CONFIG_DEBUG_FS +static void msm_debugfs_late_init (struct drm_device *dev) +{ +msm_gpu_debugfs_late_init (dev); +} + +static void msm_debugfs_init (struct drm_minor *minor) +{ +msm_gpu_debugfs_init (minor); + +msm_kms_debugfs_init (minor); + +msm_gem_debugfs_init (minor); +} +#endif +static int msm_drm_uninit (struct device *dev,const struct component_ops *gpu_ops) {struct platform_device *pdev =to_platform_device (dev);
@@ -171,9 +186,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv,if (ret) goto err_msm_uninit; - ret =msm_debugfs_late_init (ddev); -if (ret) - goto err_msm_uninit; +msm_debugfs_late_init (ddev);if (priv->kms_init)msm_drm_kms_post_init (dev);
drivers/gpu/drm/msm/msm_drv.h +2 -2
@@ -436,7 +436,8 @@ static inline void msm_mdss_unregister(void) {}#ifdef CONFIG_DEBUG_FS void msm_framebuffer_describe (struct drm_framebuffer *fb,struct seq_file *m); -int msm_debugfs_late_init (struct drm_device *dev); +void msm_gpu_debugfs_init (struct drm_minor *minor); +void msm_gpu_debugfs_late_init (struct drm_device *dev);int msm_rd_debugfs_init (struct drm_minor *minor);void msm_rd_debugfs_cleanup (struct msm_drm_private *priv);__printf (3 ,4 )
@@ -445,7 +446,6 @@ void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,int msm_perf_debugfs_init (struct drm_minor *minor);void msm_perf_debugfs_cleanup (struct msm_drm_private *priv);#else -static inline int msm_debugfs_late_init (struct drm_device *dev) {return 0 ; } __printf(3, 4) static inline void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *submit,
drivers/gpu/drm/msm/msm_gem.h +8 -0
@@ -498,4 +498,12 @@ static inline void msm_gem_submit_put(struct msm_gem_submit *submit)void msm_submit_retire (struct msm_gem_submit *submit); +#ifdef CONFIG_DEBUG_FS +void msm_gem_debugfs_init (struct drm_minor *minor); +#else +static inline void msm_gem_debugfs_init (struct drm_minor *minor) +{ +} +#endif +#endif /* __MSM_GEM_H__ */
drivers/gpu/drm/msm/msm_gem_debugfs.c new file +96 -0
96 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gpu_debugfs.c new file +213 -0
213 lines not on this page · raw message
drivers/gpu/drm/msm/msm_kms.h +8 -0
@@ -240,4 +240,12 @@ static inline void msm_drm_kms_uninit(struct device *dev)#endif +#if defined(CONFIG_DEBUG_FS ) && defined(CONFIG_DRM_MSM_KMS ) +void msm_kms_debugfs_init (struct drm_minor *minor); +#else +static inline void msm_kms_debugfs_init (struct drm_minor *minor) +{ +} +#endif +#endif /* __MSM_KMS_H__ */
drivers/gpu/drm/msm/msm_kms_debugfs.c new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH v5 5/5 drm/msm: make it possible to disable GPU support
In reply to Dmitry BaryshkovSome of the platforms don't have onboard GPU or don't provide support for the GPU in the drm/msm driver. Make it possible to disable the GPU part of the driver and build the KMS-only part.
--- drivers/gpu/drm/msm/Kconfig | 27 +++++-- drivers/gpu/drm/msm/Makefile | 15 ++-- drivers/gpu/drm/msm/msm_drv.c | 133 ++++++++++++++-------------------- drivers/gpu/drm/msm/msm_drv.h | 16 ---- drivers/gpu/drm/msm/msm_gem.h | 2 + drivers/gpu/drm/msm/msm_gem_vma.h | 14 ++++ drivers/gpu/drm/msm/msm_gpu.c | 45 ++++++++++++ drivers/gpu/drm/msm/msm_gpu.h | 111 +++++++++++++++++++++++----- drivers/gpu/drm/msm/msm_submitqueue.c | 12 +-- 9 files changed, 240 insertions(+), 135 deletions(-)
drivers/gpu/drm/msm/Kconfig +19 -8
@@ -13,33 +13,43 @@ config DRM_MSM depends on QCOM_COMMAND_DB || QCOM_COMMAND_DB=n depends on PM select IOMMU_IO_PGTABLE - select QCOM_MDT_LOADER if ARCH_QCOM select REGULATOR - select DRM_EXEC select DRM_GPUVM - select DRM_SCHED select SHMEM select TMPFS - select QCOM_SCM select QCOM_UBWC_CONFIG select WANT_DEV_COREDUMP select SND_SOC_HDMI_CODEC if SND_SOC - select SYNC_FILE select PM_OPP - select NVMEM select PM_GENERIC_DOMAINS select TRACE_GPU_MEM help DRM/KMS driver for MSM/snapdragon. +config DRM_MSM_ADRENO + bool "Qualcomm Adreno GPU support" + default y + depends on DRM_MSM + select DRM_EXEC + select DRM_SCHED + select NVMEM + select QCOM_MDT_LOADER if ARCH_QCOM + select QCOM_SCM if ARCH_QCOM + select SYNC_FILE + help + Enable support for the GPU present on most of Qualcomm Snapdragon + platforms. Without this option the driver will only support the + unaccelerated display output. + If you are unsure, say Y. + config DRM_MSM_GPU_STATE bool - depends on DRM_MSM && (DEBUG_FS || DEV_COREDUMP) + depends on DRM_MSM_ADRENO && (DEBUG_FS || DEV_COREDUMP) default y config DRM_MSM_GPU_SUDO bool "Enable SUDO flag on submits" - depends on DRM_MSM && EXPERT + depends on DRM_MSM_ADRENO && EXPERT default n help Enable userspace that has CAP_SYS_RAWIO to submit GPU commands
@@ -189,6 +199,7 @@ config DRM_MSM_HDMI default y select DRM_DISPLAY_HDMI_HELPER select DRM_DISPLAY_HDMI_STATE_HELPER + select QCOM_SCM help Compile in support for the HDMI output MSM DRM driver. It can be a primary or a secondary display on device. Note that this is used
drivers/gpu/drm/msm/Makefile +9 -6
@@ -108,26 +108,29 @@ msm-display-$(CONFIG_DRM_MSM_KMS) += \ msm-y += \ msm_drv.o \ - msm_fence.o \ msm_gem.o \ msm_gem_debugfs.o \ msm_gem_prime.o \ msm_gem_shrinker.o \ - msm_gem_submit.o \ msm_gem_vma.o \ + msm_io_utils.o \ + msm_iommu.o \ + msm_gpu_tracepoints.o \ + +msm-$(CONFIG_DRM_MSM_ADRENO) += \ + msm_fence.o \ + msm_gem_submit.o \ msm_gem_vm_bind.o \ msm_gpu.o \ + msm_gpu_debugfs.o \ msm_gpu_devfreq.o \ msm_gpu_debugfs.o \ - msm_io_utils.o \ msm_ioctl.o \ - msm_iommu.o \ msm_perf.o \ msm_rd.o \ msm_ringbuffer.o \ msm_submitqueue.o \ msm_syncobj.o \ - msm_gpu_tracepoints.o \ msm-$(CONFIG_DRM_MSM_KMS) += \ msm_atomic.o \
@@ -163,7 +166,7 @@ msm-display-$(CONFIG_DRM_MSM_DSI_14NM_PHY) += dsi/phy/dsi_phy_14nm.o msm-display-$(CONFIG_DRM_MSM_DSI_10NM_PHY) += dsi/phy/dsi_phy_10nm.o msm-display-$(CONFIG_DRM_MSM_DSI_7NM_PHY) += dsi/phy/dsi_phy_7nm.o -msm-y += $(adreno-y) +msm-$(CONFIG_DRM_MSM_ADRENO) += $(adreno-y) msm-$(CONFIG_DRM_MSM_KMS) += $(msm-display-y) obj-$(CONFIG_DRM_MSM) += msm.o
drivers/gpu/drm/msm/msm_drv.c +56 -77
243 lines not on this page · raw message
drivers/gpu/drm/msm/msm_drv.h +0 -16
@@ -436,22 +436,6 @@ static inline void msm_mdss_unregister(void) {}#ifdef CONFIG_DEBUG_FS void msm_framebuffer_describe (struct drm_framebuffer *fb,struct seq_file *m); -void msm_gpu_debugfs_init (struct drm_minor *minor); -void msm_gpu_debugfs_late_init (struct drm_device *dev); -int msm_rd_debugfs_init (struct drm_minor *minor); -void msm_rd_debugfs_cleanup (struct msm_drm_private *priv); -__printf(3, 4) -void msm_rd_dump_submit (struct msm_rd_state *rd,struct msm_gem_submit *submit, -const char *fmt, ...); -int msm_perf_debugfs_init (struct drm_minor *minor); -void msm_perf_debugfs_cleanup (struct msm_drm_private *priv); -#else -__printf(3, 4) -static inline void msm_rd_dump_submit (struct msm_rd_state *rd, -struct msm_gem_submit *submit, -const char *fmt, ...) {} -static inline void msm_rd_debugfs_cleanup (struct msm_drm_private *priv) {} -static inline void msm_perf_debugfs_cleanup (struct msm_drm_private *priv) {}#endif struct clk *msm_clk_get (struct platform_device *pdev,const char *name);
drivers/gpu/drm/msm/msm_gem.h +2 -0
@@ -68,6 +68,7 @@ struct msm_gem_vm {/** @base: Inherit from drm_gpuvm. */ struct drm_gpuvm base; +#ifdef CONFIG_DRM_MSM_ADRENO /** * @sched: Scheduler used for asynchronous VM_BIND request. *
@@ -94,6 +95,7 @@ struct msm_gem_vm {*/ atomic_t in_flight; } prealloc_throttle; +#endif /** * @mm: Memory management for kernel managed VA allocations
drivers/gpu/drm/msm/msm_gem_vma.h +14 -0
@@ -95,11 +95,25 @@ vm_map_op(struct msm_gem_vm *vm, const struct msm_vm_map_op *op) op->range, op->prot); } +#ifdef CONFIG_DRM_MSM_ADRENO int msm_gem_vm_sm_step_map (struct drm_gpuva_op *op,void *_arg);int msm_gem_vm_sm_step_remap (struct drm_gpuva_op *op,void *arg);int msm_gem_vm_sm_step_unmap (struct drm_gpuva_op *op,void *_arg);int msm_gem_vm_sched_init (struct msm_gem_vm *vm,struct drm_device *drm);void msm_gem_vm_sched_fini (struct msm_gem_vm *vm); +#else + +#define msm_gem_vm_sm_step_map NULL +#define msm_gem_vm_sm_step_remap NULL +#define msm_gem_vm_sm_step_unmap NULL + +static inline int msm_gem_vm_sched_init (struct msm_gem_vm *vm,struct drm_device *drm) +{ +return -EINVAL ; +} + +static inline void msm_gem_vm_sched_fini (struct msm_gem_vm *vm) {} +#endif #endif
drivers/gpu/drm/msm/msm_gpu.c +45 -0
48 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gpu.h +91 -20
170 lines not on this page · raw message
drivers/gpu/drm/msm/msm_submitqueue.c +4 -8
@@ -49,10 +49,8 @@ int msm_context_set_sysprof(struct msm_context *ctx, struct msm_gpu *gpu, int syreturn 0 ; } -void __msm_context_destroy (struct kref *kref) +void msm_submitqueue_fini (struct msm_context *ctx) { -struct msm_context *ctx =container_of (kref, - struct msm_context, ref);int i;for (i =0 ; i <ARRAY_SIZE (ctx->entities); i++) {
@@ -62,11 +60,6 @@ void __msm_context_destroy(struct kref *kref)drm_sched_entity_destroy (ctx->entities[i]);kfree (ctx->entities[i]); } - -drm_gpuvm_put (ctx->vm); -kfree (ctx->comm); -kfree (ctx->cmdline); -kfree (ctx); }void msm_submitqueue_destroy (struct kref *kref)
@@ -264,6 +257,9 @@ int msm_submitqueue_init(struct drm_device *drm, struct msm_context *ctx)struct msm_drm_private *priv = drm->dev_private;int default_prio, max_priority; +INIT_LIST_HEAD (&ctx->submitqueues); +rwlock_init (&ctx->queuelock); +if (!priv->gpu)return -ENODEV ;
Signature · 1 line
2.47.3