dma-buf: add dma_fence_describe and dma_resv_describe
Subsystems (9)
PATCH 1/4 dma-buf: add dma_fence_describe and dma_resv_describe
Add functions to dump dma_fence and dma_resv objects into a seq_file and use them for printing the debugfs informations.
--- drivers/dma-buf/dma-buf.c | 11 +---------- drivers/dma-buf/dma-fence.c | 16 ++++++++++++++++ drivers/dma-buf/dma-resv.c | 23 +++++++++++++++++++++++ include/linux/dma-fence.h | 1 + include/linux/dma-resv.h | 1 + 5 files changed, 42 insertions(+), 10 deletions(-)
drivers/dma-buf/dma-buf.c +1 -10
@@ -1368,8 +1368,6 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) {struct dma_buf *buf_obj;struct dma_buf_attachment *attach_obj; -struct dma_resv_iter cursor; -struct dma_fence *fence;int count =0 , attach_count;size_t size =0 ;int ret;
@@ -1397,14 +1395,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)file_inode (buf_obj->file)->i_ino, buf_obj->name ?: ""); -dma_resv_for_each_fence (&cursor, buf_obj->resv, true, fence) { -seq_printf (s,"\t%s fence: %s %s %ssignalled\n" , -dma_resv_iter_is_exclusive (&cursor) ? -"Exclusive" :"Shared" , - fence->ops->get_driver_name (fence), - fence->ops->get_timeline_name (fence), -dma_fence_is_signaled (fence) ?"" :"un" ); - } +dma_resv_describe (buf_obj->resv, s);seq_puts (s,"\tAttached Devices:\n" ); attach_count =0 ;
drivers/dma-buf/dma-fence.c +16 -0
@@ -907,6 +907,22 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count, }EXPORT_SYMBOL (dma_fence_wait_any_timeout); +/** +* dma_fence_describe - Dump fence describtion into seq_file +* @fence: the 6fence to describe +* @seq: the seq_file to put the textual description into +* +* Dump a textual description of the fence and it's state into the seq_file. +*/ +void dma_fence_describe (struct dma_fence *fence,struct seq_file *seq) +{ +seq_printf (seq,"%s %s seq %llu %ssignalled\n" , + fence->ops->get_driver_name (fence), + fence->ops->get_timeline_name (fence), fence->seqno, +dma_fence_is_signaled (fence) ?"" :"un" ); +} +EXPORT_SYMBOL (dma_fence_describe); +/** * dma_fence_init - Initialize a custom fence. * @fence: the fence to initialize
drivers/dma-buf/dma-resv.c +23 -0
@@ -38,6 +38,7 @@#include <linux/mm.h> #include <linux/sched/mm.h> #include <linux/mmu_notifier.h> +#include <linux/seq_file.h> /** * DOC: Reservation Object Overview
@@ -654,6 +655,28 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) }EXPORT_SYMBOL_GPL (dma_resv_test_signaled); +/** +* dma_resv_describe - Dump description of the resv object into seq_file +* @obj: the reservation object +* @seq: the seq_file to dump the description into +* +* Dump a textual description of the fences inside an dma_resv object into the +* seq_file. +*/ +void dma_resv_describe (struct dma_resv *obj,struct seq_file *seq) +{ +struct dma_resv_iter cursor; +struct dma_fence *fence; + +dma_resv_for_each_fence (&cursor, obj, true, fence) { +seq_printf (seq,"\t%s fence:" , +dma_resv_iter_is_exclusive (&cursor) ? +"Exclusive" :"Shared" ); +dma_fence_describe (fence, seq); + } +} +EXPORT_SYMBOL_GPL (dma_resv_describe); +#if IS_ENABLED (CONFIG_LOCKDEP )static int __init dma_resv_lockdep (void ) {
include/linux/dma-fence.h +1 -0
@@ -264,6 +264,7 @@ void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,void dma_fence_release (struct kref *kref);void dma_fence_free (struct dma_fence *fence); +void dma_fence_describe (struct dma_fence *fence,struct seq_file *seq);/** * dma_fence_put - decreases refcount of the fence
include/linux/dma-resv.h +1 -0
@@ -486,5 +486,6 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);long dma_resv_wait_timeout (struct dma_resv *obj,bool wait_all,bool intr,unsigned long timeout);bool dma_resv_test_signaled (struct dma_resv *obj,bool test_all); +void dma_resv_describe (struct dma_resv *obj,struct seq_file *seq);#endif /* _LINUX_RESERVATION_H */
Signature · 1 line
2.25.1
PATCH 2/4 drm/msm: allow compile_test on !ARM
MSM is one of the few drivers which won't even compile test on !ARM platforms.
Looking into this a bit more it turned out that there is actually not that much missing to at least let the driver compile on x86 as well.
So this patch replaces the use of phys_to_page() with the open coded version and provides a dummy for of_drm_find_bridge().
--- drivers/gpu/drm/msm/Kconfig | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 2 +- include/drm/drm_bridge.h | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/Kconfig +2 -2
@@ -3,9 +3,9 @@ config DRM_MSM tristate "MSM DRM" depends on DRM - depends on ARCH_QCOM || SOC_IMX5 || (ARM && COMPILE_TEST) + depends on ARCH_QCOM || SOC_IMX5 || COMPILE_TEST depends on IOMMU_SUPPORT - depends on OF && COMMON_CLK + depends on (OF && COMMON_CLK) || COMPILE_TEST depends on QCOM_OCMEM || QCOM_OCMEM=n depends on QCOM_LLCC || QCOM_LLCC=n depends on QCOM_COMMAND_DB || QCOM_COMMAND_DB=n
drivers/gpu/drm/msm/msm_gem.c +1 -1
@@ -85,7 +85,7 @@ static struct page **get_pages_vram(struct drm_gem_object *obj, int npages) paddr =physaddr (obj);for (i =0 ; i < npages; i++) { - p[i] =phys_to_page (paddr); + p[i] =pfn_to_page (__phys_to_pfn (paddr)); paddr +=PAGE_SIZE ; }
include/drm/drm_bridge.h +9 -1
@@ -790,11 +790,19 @@ drm_priv_to_bridge(struct drm_private_obj *priv)void drm_bridge_add (struct drm_bridge *bridge);void drm_bridge_remove (struct drm_bridge *bridge); -struct drm_bridge *of_drm_find_bridge (struct device_node *np);int drm_bridge_attach (struct drm_encoder *encoder,struct drm_bridge *bridge,struct drm_bridge *previous,enum drm_bridge_attach_flags flags); +#ifdef CONFIG_OF +struct drm_bridge *of_drm_find_bridge (struct device_node *np); +#else +static inline struct drm_bridge *of_drm_find_bridge (struct device_node *np) +{ +return NULL ; +} +#endif +/** * drm_bridge_get_next_bridge() - Get the next bridge in the chain * @bridge: bridge object
Signature · 1 line
2.25.1
Re: [PATCH 2/4] drm/msm: allow compile_test on !ARM
As long as nobody objects I'm going to push this one here to drm-misc-next with Rob's rb.
The other patches still need a bit more work, but being able to at least compile test MSM on x86 is really helpful.
Christian.
Am 24.09.21 um 09:17 schrieb Christian König:
Quoted 71 lines
MSM is one of the few drivers which won't even compile test on !ARM platforms.
Looking into this a bit more it turned out that there is actually not that much missing to at least let the driver compile on x86 as well.
So this patch replaces the use of
phys_to_page()with the open coded version and provides a dummy forof_drm_find_bridge().Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/msm/Kconfig | 4 ++-- drivers/gpu/drm/msm/msm_gem.c | 2 +- include/drm/drm_bridge.h | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/Kconfig +2
-2@@ -3,9 +3,9 @@ config DRM_MSM tristate "MSM DRM" depends on DRM - depends on ARCH_QCOM || SOC_IMX5 || (ARM && COMPILE_TEST) + depends on ARCH_QCOM || SOC_IMX5 || COMPILE_TEST depends on IOMMU_SUPPORT - depends on OF && COMMON_CLK + depends on (OF && COMMON_CLK) || COMPILE_TEST depends on QCOM_OCMEM || QCOM_OCMEM=n depends on QCOM_LLCC || QCOM_LLCC=n depends on QCOM_COMMAND_DB || QCOM_COMMAND_DB=ndrivers/gpu/drm/msm/msm_gem.c +1
-1@@ -85,7 +85,7 @@ static struct page **get_pages_vram(struct drm_gem_object *obj, int npages) paddr =physaddr (obj);for (i =0 ; i < npages; i++) { - p[i] =phys_to_page (paddr); + p[i] =pfn_to_page (__phys_to_pfn (paddr)); paddr +=PAGE_SIZE ; }include/drm/drm_bridge.h +9
-1@@ -790,11 +790,19 @@ drm_priv_to_bridge(struct drm_private_obj *priv)void drm_bridge_add (struct drm_bridge *bridge);void drm_bridge_remove (struct drm_bridge *bridge); -struct drm_bridge *of_drm_find_bridge (struct device_node *np);int drm_bridge_attach (struct drm_encoder *encoder,struct drm_bridge *bridge,struct drm_bridge *previous,enum drm_bridge_attach_flags flags); +#ifdef CONFIG_OF +struct drm_bridge *of_drm_find_bridge (struct device_node *np); +#else +static inline struct drm_bridge *of_drm_find_bridge (struct device_node *np) +{ +return NULL ; +} +#endif +/** * drm_bridge_get_next_bridge() - Get the next bridge in the chain * @bridge: bridge object
PATCH 3/4 drm/msm: use the new dma_resv_describe
In reply to Christian KönigInstead of hand rolling pretty much the same code.
--- drivers/gpu/drm/msm/msm_gem.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/gpu/drm/msm/msm_gem.c +1 -19
@@ -865,23 +865,11 @@ int msm_gem_cpu_fini(struct drm_gem_object *obj) }#ifdef CONFIG_DEBUG_FS -static void describe_fence (struct dma_fence *fence,const char *type, -struct seq_file *m) -{ -if (!dma_fence_is_signaled (fence)) -seq_printf (m,"\t%9s: %s %s seq %llu\n" , type, - fence->ops->get_driver_name (fence), - fence->ops->get_timeline_name (fence), - fence->seqno); -} -void msm_gem_describe (struct drm_gem_object *obj,struct seq_file *m,struct msm_gem_stats *stats) {struct msm_gem_object *msm_obj =to_msm_bo (obj);struct dma_resv *robj = obj->resv; -struct dma_resv_iter cursor; -struct dma_fence *fence;struct msm_gem_vma *vma;uint64_t off =drm_vma_node_start (&obj->vma_node);const char *madv;
@@ -955,13 +943,7 @@ void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m,seq_puts (m,"\n" ); } -dma_resv_for_each_fence (&cursor, robj, true, fence) { -if (dma_resv_iter_is_exclusive (&cursor)) -describe_fence (fence,"Exclusive" , m); -else -describe_fence (fence,"Shared" , m); - } - +dma_resv_describe (robj, m);msm_gem_unlock (obj); }
Signature · 1 line
2.25.1
PATCH 4/4 drm/etnaviv: use dma_resv_describe
In reply to Christian KönigInstead of dumping the fence info manually.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +7 -19
@@ -425,36 +425,24 @@ int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj, }#ifdef CONFIG_DEBUG_FS -static void etnaviv_gem_describe_fence (struct dma_fence *fence, -const char *type,struct seq_file *m) -{ -seq_printf (m,"\t%9s: %s %s seq %llu\n" , type, - fence->ops->get_driver_name (fence), - fence->ops->get_timeline_name (fence), - fence->seqno); -} -static void etnaviv_gem_describe (struct drm_gem_object *obj,struct seq_file *m) {struct etnaviv_gem_object *etnaviv_obj =to_etnaviv_bo (obj);struct dma_resv *robj = obj->resv; -struct dma_resv_iter cursor; -struct dma_fence *fence;unsigned long off =drm_vma_node_start (&obj->vma_node); +int r;seq_printf (m,"%08x: %c %2d (%2d) %08lx %p %zd\n" , etnaviv_obj->flags,is_active (etnaviv_obj) ?'A' :'I' , obj->name,kref_read (&obj->refcount), off, etnaviv_obj->vaddr, obj->size); -dma_resv_iter_begin (&cursor, robj, true); -dma_resv_for_each_fence_unlocked (&cursor, fence) { -if (dma_resv_iter_is_exclusive (&cursor)) -etnaviv_gem_describe_fence (fence,"Exclusive" , m); -else -etnaviv_gem_describe_fence (fence,"Shared" , m); - } -dma_resv_iter_end (&cursor); + r =dma_resv_lock (robj,NULL ); +if (r) +return ; + +dma_resv_describe (robj, m); +dma_resv_unlock (robj); } void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv,
Signature · 1 line
2.25.1
Quoted 5 lines · Christian König
Add functions to dump
dma_fenceanddma_resvobjects into aseq_fileand use them for printing the debugfs informations.Signed-off-by Christian König <[email protected]>
for the series,
Quoted 131 lines
--- drivers/dma-buf/dma-buf.c | 11 +---------- drivers/dma-buf/dma-fence.c | 16 ++++++++++++++++ drivers/dma-buf/dma-resv.c | 23 +++++++++++++++++++++++ include/linux/dma-fence.h | 1 + include/linux/dma-resv.h | 1 + 5 files changed, 42 insertions(+), 10 deletions(-)drivers/dma-buf/dma-buf.c +1
-10@@ -1368,8 +1368,6 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) {struct dma_buf *buf_obj;struct dma_buf_attachment *attach_obj; -struct dma_resv_iter cursor; -struct dma_fence *fence;int count =0 , attach_count;size_t size =0 ;int ret;@@ -1397,14 +1395,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused)file_inode (buf_obj->file)->i_ino, buf_obj->name ?: ""); -dma_resv_for_each_fence (&cursor, buf_obj->resv, true, fence) { -seq_printf (s,"\t%s fence: %s %s %ssignalled\n" , -dma_resv_iter_is_exclusive (&cursor) ? -"Exclusive" :"Shared" , - fence->ops->get_driver_name (fence), - fence->ops->get_timeline_name (fence), -dma_fence_is_signaled (fence) ?"" :"un" ); - } +dma_resv_describe (buf_obj->resv, s);seq_puts (s,"\tAttached Devices:\n" ); attach_count =0 ;drivers/dma-buf/dma-fence.c +16
-0@@ -907,6 +907,22 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count, }EXPORT_SYMBOL (dma_fence_wait_any_timeout); +/** +* dma_fence_describe - Dump fence describtion into seq_file +* @fence: the 6fence to describe +* @seq: the seq_file to put the textual description into +* +* Dump a textual description of the fence and it's state into the seq_file. +*/ +void dma_fence_describe (struct dma_fence *fence,struct seq_file *seq) +{ +seq_printf (seq,"%s %s seq %llu %ssignalled\n" , + fence->ops->get_driver_name (fence), + fence->ops->get_timeline_name (fence), fence->seqno, +dma_fence_is_signaled (fence) ?"" :"un" ); +} +EXPORT_SYMBOL (dma_fence_describe); +/** * dma_fence_init - Initialize a custom fence. * @fence: the fence to initialize drivers/dma-buf/dma-resv.c +23
-0@@ -38,6 +38,7 @@#include <linux/mm.h> #include <linux/sched/mm.h> #include <linux/mmu_notifier.h> +#include <linux/seq_file.h> /** * DOC: Reservation Object Overview @@ -654,6 +655,28 @@ bool dma_resv_test_signaled(struct dma_resv *obj, bool test_all) }EXPORT_SYMBOL_GPL (dma_resv_test_signaled); +/** +* dma_resv_describe - Dump description of the resv object into seq_file +* @obj: the reservation object +* @seq: the seq_file to dump the description into +* +* Dump a textual description of the fences inside an dma_resv object into the +* seq_file. +*/ +void dma_resv_describe (struct dma_resv *obj,struct seq_file *seq) +{ +struct dma_resv_iter cursor; +struct dma_fence *fence; + +dma_resv_for_each_fence (&cursor, obj, true, fence) { +seq_printf (seq,"\t%s fence:" , +dma_resv_iter_is_exclusive (&cursor) ? +"Exclusive" :"Shared" ); +dma_fence_describe (fence, seq); + } +} +EXPORT_SYMBOL_GPL (dma_resv_describe); +#if IS_ENABLED (CONFIG_LOCKDEP )static int __init dma_resv_lockdep (void ) {include/linux/dma-fence.h +1
-0@@ -264,6 +264,7 @@ void dma_fence_init(struct dma_fence *fence, const struct dma_fence_ops *ops,void dma_fence_release (struct kref *kref);void dma_fence_free (struct dma_fence *fence); +void dma_fence_describe (struct dma_fence *fence,struct seq_file *seq);/** * dma_fence_put - decreases refcount of the fence include/linux/dma-resv.h +1
-1@@ -486,5 +486,6 @@ int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);long dma_resv_wait_timeout (struct dma_resv *obj,bool wait_all,bool intr,unsigned long timeout);bool dma_resv_test_signaled (struct dma_resv *obj,bool test_all); +void dma_resv_describe (struct dma_resv *obj,struct seq_file *seq);#endif /* _LINUX_RESERVATION_H */ --2.25.1