drm: make drm_get_format_name atomic/irq safe again
Subsystems (6)
PATCH 1/1 drm: make drm_get_format_name atomic/irq safe again
drm: make drm_get_format_name thread-safe
[danvet: Clarify that the returned pointer must be freed with kfree().]
Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fourcc.c +4 -1
@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ; snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]
Quoted 7 lines
Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
btw, the new kfree the result approach moves the snprintf stuff outside the 'if (drm_debug & FOO)' check.. which is perhaps also a bit unfortunate..
I wonder how much the rest of the kernel would hate it if we pimped out vsprintf.c to give us a special fmt string for fourcc formats? I guess it would also be useful for v4l..
It's too bad the kernel doesn't have something like register_printf_function()..
BR,
-R
Quoted 22 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fourcc.c +4
-2@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ; snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)", --
Quoted 2 lines
2.7.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 26 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fourcc.c +0
-0@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);*/
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 96
Quoted 10 lines
drivers/gpu/drm/drm_fourcc.c +4
-1char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ; snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",
Why aren't we using kasprintf()?
Or we could have just made the caller provide the buffer...
Quoted 7 lines
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 35 lines · Ville Syrjälä
Quoted 34 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_fourcc.c +4
-1@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ;
Quoted 6 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 96
Quoted 2 lines
drivers/gpu/drm/drm_fourcc.c +0
-0snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",Why aren't we using
kasprintf()?Or we could have just made the caller provide the buffer...
I guess kasprintf() would do the job (although still not address the fact that we still always do the sprintf bits, rather than only doing it when debug logs are enabled).. caller provided buffer would be better. And make it more obvious that something needs to be fixed when merging/rebasing patches that started life before this change landed.
I still kinda like the idea of making vsprintf know about fourcc's with a new format string, and just making drm_get_format_name() go away.
But I don't really have time atm to re-work all the callers of drm_get_format_name(). So I guess unless someone else does, I'd go w/ kasprintf() for now.
BR,
-R
Quoted 11 lines
Quoted 7 lines
--
2.7.4_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 23 lines · Rob Clark
Quoted 21 lines · Ville Syrjälä
Quoted 20 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_fourcc.c +0
-0@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 93
Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c +4
-1*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ;
Unrelated bug, thanks for that fix too :)
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 96
Quoted 3 lines
drivers/gpu/drm/drm_fourcc.c +0
-0snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",Why aren't we using
kasprintf()?
Because I didn't know it was a thing :(
Patch using it incoming.
Quoted 10 lines
Quoted 2 lines
Or we could have just made the caller provide the buffer...
I guess
kasprintf()would do the job (although still not address the fact that we still always do the sprintf bits, rather than only doing it when debug logs are enabled).. caller provided buffer would be better. And make it more obvious that something needs to be fixed when merging/rebasing patches that started life before this change landed.
Quoted 7 lines
I still kinda like the idea of making vsprintf know about fourcc's with a new format string, and just making
drm_get_format_name()go away.But I don't really have time atm to re-work all the callers of
drm_get_format_name(). So I guess unless someone else does, I'd go w/kasprintf()for now.
That sounds cleaner to me indeed, I'll send a patch doing that tonight. Any idea for the name? drm_get_format_name_safe(uint32_t, char*)? I could also keep the same name and rely on the function signature change to make sure any merging of the old function call will break the compilation and be noticed that way.
Looks like I'm obviously not qualified to choose which is the best option, so I'll leave that to you guys :)
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm: make drm_get_format_name atomic/irq safe again
drm: make drm_get_format_name thread-safe
[danvet: Clarify that the returned pointer must be freed with kfree().]
Note (Rob Clark):
I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
---
I'll send another variant tonight that moves the allocation to the callers (sounds cleaner to me, although there'll be some code duplication and more opportunities to make mistakes I guess).
--- drivers/gpu/drm/drm_fourcc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/drm_fourcc.c +1 -5
@@ -87,9 +87,7 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + return kasprintf(GFP_ATOMIC, "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),
@@ -97,8 +95,6 @@ char *drm_get_format_name(uint32_t format)printable_char ((format >>24 ) &0x7f ), format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); - -return buf; }EXPORT_SYMBOL (drm_get_format_name);
Signature · 2 lines
Cheers, Eric
Quoted 41 lines · Eric Engestrom
Quoted 23 lines · Rob Clark
Quoted 21 lines · Ville Syrjälä
Quoted 20 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_fourcc.c +0
-0@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 93
Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c +4
-1*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ;Unrelated bug, thanks for that fix too :)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",Why aren't we using
kasprintf()?Because I didn't know it was a thing :(
Patch using it incoming.
Thanks
Quoted 18 lines
Quoted 10 lines
Quoted 2 lines
Or we could have just made the caller provide the buffer...
I guess
kasprintf()would do the job (although still not address the fact that we still always do the sprintf bits, rather than only doing it when debug logs are enabled).. caller provided buffer would be better. And make it more obvious that something needs to be fixed when merging/rebasing patches that started life before this change landed.Quoted 7 lines
I still kinda like the idea of making vsprintf know about fourcc's with a new format string, and just making
drm_get_format_name()go away.But I don't really have time atm to re-work all the callers of
drm_get_format_name(). So I guess unless someone else does, I'd go w/kasprintf()for now.
Quoted 5 lines
That sounds cleaner to me indeed, I'll send a patch doing that tonight. Any idea for the name?
drm_get_format_name_safe(uint32_t, char*)? I could also keep the same name and rely on the function signature change to make sure any merging of the old function call will break the compilation and be noticed that way.
I think if fxn signature changes, we can keep the same name. What I get nervous about is fxn sig+name stays same but semantics change ;-)
btw, if this isn't what you were already planning, I'd suggest:
char *drm_get_format_name(uint32_t, char *);
so we can keep it inline w/ DRM_DEBUG_xyz() macros. Or maybe something like:
typedef char drm_format_name_buf[MAX_SIZE] char *drm_get_format_name(uint32_t, drm_format_name_buf);
??
BR,
-R
Quoted 5 lines
Looks like I'm obviously not qualified to choose which is the best option, so I'll leave that to you guys :)
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 77 lines · Rob Clark
Quoted 41 lines · Eric Engestrom
Quoted 23 lines · Rob Clark
Quoted 21 lines · Ville Syrjälä
Quoted 20 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_fourcc.c +0
-0@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 93
Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c +4
-1*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ;Unrelated bug, thanks for that fix too :)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",Why aren't we using
kasprintf()?Because I didn't know it was a thing :(
Patch using it incoming.Thanks
Quoted 18 lines
Quoted 10 lines
Quoted 2 lines
Or we could have just made the caller provide the buffer...
I guess
kasprintf()would do the job (although still not address the fact that we still always do the sprintf bits, rather than only doing it when debug logs are enabled).. caller provided buffer would be better. And make it more obvious that something needs to be fixed when merging/rebasing patches that started life before this change landed.Quoted 7 lines
I still kinda like the idea of making vsprintf know about fourcc's with a new format string, and just making
drm_get_format_name()go away.But I don't really have time atm to re-work all the callers of
drm_get_format_name(). So I guess unless someone else does, I'd go w/kasprintf()for now.Quoted 5 lines
That sounds cleaner to me indeed, I'll send a patch doing that tonight. Any idea for the name?
drm_get_format_name_safe(uint32_t, char*)? I could also keep the same name and rely on the function signature change to make sure any merging of the old function call will break the compilation and be noticed that way.
Quoted 6 lines
I think if fxn signature changes, we can keep the same name. What I get nervous about is fxn sig+name stays same but semantics change ;-)
btw, if this isn't what you were already planning, I'd suggest:
char *drm_get_format_name(uint32_t, char *);
I would model it after snprintf(): drm_get_format_name(buf,size,format)
Although I guess you could have it return the string instead of int for extra ease of use.
But yeah, having the ability to register custom printf conversions would be pretty nice.
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 77 lines · Rob Clark
Quoted 41 lines · Eric Engestrom
Quoted 23 lines · Rob Clark
Quoted 21 lines · Ville Syrjälä
Quoted 20 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_fourcc.c +0
-0@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 93
Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c +4
-1*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ;Unrelated bug, thanks for that fix too :)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",Why aren't we using
kasprintf()?Because I didn't know it was a thing :(
Patch using it incoming.Thanks
Quoted 18 lines
Quoted 10 lines
Quoted 2 lines
Or we could have just made the caller provide the buffer...
I guess
kasprintf()would do the job (although still not address the fact that we still always do the sprintf bits, rather than only doing it when debug logs are enabled).. caller provided buffer would be better. And make it more obvious that something needs to be fixed when merging/rebasing patches that started life before this change landed.Quoted 7 lines
I still kinda like the idea of making vsprintf know about fourcc's with a new format string, and just making
drm_get_format_name()go away.But I don't really have time atm to re-work all the callers of
drm_get_format_name(). So I guess unless someone else does, I'd go w/kasprintf()for now.Quoted 5 lines
That sounds cleaner to me indeed, I'll send a patch doing that tonight. Any idea for the name?
drm_get_format_name_safe(uint32_t, char*)? I could also keep the same name and rely on the function signature change to make sure any merging of the old function call will break the compilation and be noticed that way.
Quoted 8 lines
I think if fxn signature changes, we can keep the same name. What I get nervous about is fxn sig+name stays same but semantics change ;-)
btw, if this isn't what you were already planning, I'd suggest:
char *drm_get_format_name(uint32_t, char *);so we can keep it inline w/
DRM_DEBUG_xyz()macros.
This was exactly my idea.
Quoted 6 lines
Or maybe something like:
typedef char drm_format_name_buf[MAX_SIZE] char *drm_get_format_name(uint32_t, drm_format_name_buf);??
I didn't think of that, but that would avoid mistakes about the size of the buffer. Modifying the code now, I'll send the patch in a few minutes.
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 drm: move allocation out of drm_get_format_name()
drm: make drm_get_format_name thread-safe
[danvet: Clarify that the returned pointer must be freed with kfree().]
--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_fourcc.c | 12 +++----- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- include/drm/drm_fourcc.h | 3 +- 17 files changed, 71 insertions(+), 84 deletions(-)
include/drm/drm_fourcc.h +2 -1
@@ -54,6 +54,7 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +typedef char drm_format_name_buf [32 ]; +char *drm_get_format_name (uint32_t format,drm_format_name_buf buf);#endif /* __DRM_FOURCC_H__ */
drivers/gpu/drm/drm_fourcc.c +4 -8
@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,drm_format_name_buf buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf, sizeof(drm_format_name_buf), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3 -4
@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3 -4
@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -1
@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3 -4
@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }
drivers/gpu/drm/drm_atomic.c +4 -3
@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + format_name));return ret; }
drivers/gpu/drm/drm_crtc.c +4 -3
@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + format_name)); goto out; } }
drivers/gpu/drm/drm_framebuffer.c +4 -3
@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + format_name));return -EINVAL ; }
drivers/gpu/drm/drm_modeset_helper.c +4 -3
@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); -kfree (format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + format_name)); fb->depth =0 ; fb->bits_per_pixel =0 ;
drivers/gpu/drm/drm_plane.c +4 -3
@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + format_name)); goto out; }
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -4
@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);
drivers/gpu/drm/i915/i915_debugfs.c +3 -5
@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );
@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
@@ -3001,8 +3001,6 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_h &0xffff ) *15625 ) >>10 , format_name, plane_rotation(state->rotation)); - -kfree (format_name); } }
drivers/gpu/drm/i915/intel_atomic_plane.c +4 -4
@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {
@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); -kfree (format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + format_name));return -EINVAL ;default :
drivers/gpu/drm/i915/intel_display.c +16 -25
101 lines not on this page · raw message
drivers/gpu/drm/radeon/atombios_crtc.c +6 -8
@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }
@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -1
@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, format_name));return ERR_PTR (-EINVAL ); }
Signature · 7 lines
Cheers, Eric _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm: move allocation out of drm_get_format_name()
For the vmwgfx part:
Quoted 505 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>--- drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_fourcc.c | 12 +++----- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 8 ++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- include/drm/drm_fourcc.h | 3 +- 17 files changed, 71 insertions(+), 84 deletions(-)include/drm/drm_fourcc.h +2
-1@@ -54,6 +54,7 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +typedef char drm_format_name_buf [32 ]; +char *drm_get_format_name (uint32_t format,drm_format_name_buf buf);#endif /* __DRM_FOURCC_H__ */ drivers/gpu/drm/drm_fourcc.c +4
-8@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,drm_format_name_buf buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf, sizeof(drm_format_name_buf), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3
-4@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3
-4@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-1@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3
-4@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +4
-3@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + format_name));return ret; }drivers/gpu/drm/drm_crtc.c +4
-3@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + format_name)); goto out; } }drivers/gpu/drm/drm_framebuffer.c +4
-3@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + format_name));return -EINVAL ; }drivers/gpu/drm/drm_modeset_helper.c +4
-3@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); -kfree (format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + format_name)); fb->depth =0 ; fb->bits_per_pixel =0 ;drivers/gpu/drm/drm_plane.c +4
-3@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + format_name)); goto out; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3
-4@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/i915_debugfs.c +3
-5@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",@@ -3001,8 +3001,6 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_h &0xffff ) *15625 ) >>10 , format_name, plane_rotation(state->rotation)); - -kfree (format_name); } }drivers/gpu/drm/i915/intel_atomic_plane.c +4
-4@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); -kfree (format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + format_name));return -EINVAL ;default :drivers/gpu/drm/i915/intel_display.c +16
-25@@ -12871,7 +12871,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,DRM_DEBUG_KMS ("planes on this crtc\n" );list_for_each_entry (plane, &dev->mode_config.plane_list, head) { -char *format_name; +drm_format_name_buf format_name; intel_plane =to_intel_plane (plane);if (intel_plane->pipe != crtc->pipe)continue ;@@ -12884,12 +12884,11 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,continue ; } - format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("[PLANE:%d:%s] enabled" , plane->base.id, plane->name);DRM_DEBUG_KMS ("\tFB:%d, fb = %ux%u format = %s" , - fb->base.id, fb->width, fb->height, format_name); + fb->base.id, fb->width, fb->height, +drm_get_format_name (fb->pixel_format, format_name)); DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", state->scaler_id, state->base.src.x1 >> 16,@@ -12899,8 +12898,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, state->base.dst.x1, state->base.dst.y1,drm_rect_width (&state->base.dst), drm_rect_height(&state->base.dst)); - -kfree (format_name); } }@@ -15749,7 +15746,7 @@ static int intel_framebuffer_init(struct drm_device *dev,unsigned int tiling =i915_gem_object_get_tiling (obj);int ret;u32 pitch_limit, stride_alignment; -char *format_name; +drm_format_name_buf format_name;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -15840,18 +15837,16 @@ static int intel_framebuffer_init(struct drm_device *dev,break ;case DRM_FORMAT_XRGB1555 :if (INTEL_INFO (dev)->gen >3 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); -kfree (format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, format_name));return -EINVAL ; }break ;case DRM_FORMAT_ABGR8888 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv) &&INTEL_INFO (dev)->gen <9 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); -kfree (format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, format_name));return -EINVAL ; }break ;@@ -15859,17 +15854,15 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_XBGR2101010 :if (INTEL_INFO (dev)->gen <4 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); -kfree (format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, format_name));return -EINVAL ; }break ;case DRM_FORMAT_ABGR2101010 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv)) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); -kfree (format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, format_name));return -EINVAL ; }break ;@@ -15878,16 +15871,14 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_YVYU :case DRM_FORMAT_VYUY :if (INTEL_INFO (dev)->gen <5 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); -kfree (format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, format_name));return -EINVAL ; }break ;default : - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); -kfree (format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, format_name));return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +6
-8@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, format_name));return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0
-0
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, · line 993
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-1@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, format_name));return ERR_PTR (-EINVAL ); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH] drm: move allocation out of drm_get_format_name()
In reply to Eric EngestromAm 05.11.2016 um 02:33 schrieb Eric Engestrom:
Quoted 1 line
+typedef char drm_format_name_buf[32];
Please don't use a typedef for this, just define the maximum size of characters the function might write somewhere.
See the kernel coding style as well:
Quoted 2 lines
In general, a pointer, or a struct that has elements that can reasonably be directly accessed should **never** be a typedef.
Regards,
Christian.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: move allocation out of drm_get_format_name()
Quoted 10 lines · Christian König
Am 05.11.2016 um 02:33 schrieb Eric Engestrom:
Quoted 1 line
+typedef char drm_format_name_buf[32];
Please don't use a typedef for this, just define the maximum size of characters the function might write somewhere.
See the kernel coding style as well:
Quoted 2 lines
In general, a pointer, or a struct that has elements that can reasonably be directly accessed should **never** be a typedef.
I would normally agree as I tend to hate typedefs ($DAYJOB {ab,mis}uses them way too much), and your way was what I wrote at first, but Rob Clark's typedef idea makes it much harder for someone to allocate a buffer of the wrong size, which IMO is good thing here.
I can rewrite the typedef out if you think it's better.
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: move allocation out of drm_get_format_name()
Quoted 8 lines · Eric Engestrom
Quoted 7 lines · Christian König
Am 05.11.2016 um 02:33 schrieb Eric Engestrom:
Quoted 1 line
+typedef char drm_format_name_buf[32];
Please don't use a typedef for this, just define the maximum size of characters the function might write somewhere.
See the kernel coding style as well:
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
In general, a pointer, or a struct that has elements that can reasonably be directly accessed should **never** be a typedef.
I would normally agree as I tend to hate typedefs ($DAYJOB {ab,mis}uses them way too much), and your way was what I wrote at first, but Rob Clark's typedef idea makes it much harder for someone to allocate a buffer of the wrong size, which IMO is good thing here.
IMHO I would make a small test program to verify this actually helps the compiler catch problems. And if it does, I would stick with it. The coding-style should be guidelines, not something that supersedes common sense / practicality.
That is my $0.02 anyways.. if others vehemently disagree and want to dogmatically stick to the coding-style guidelines, ok then. OTOH, if this approach doesn't help the compiler catch issues, then it isn't worth it.
BR,
-R
Quoted 8 lines
I can rewrite the typedef out if you think it's better.
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH] drm: move allocation out of drm_get_format_name()
Am 05.11.2016 um 17:49 schrieb Rob Clark:
Quoted 10 lines · Eric Engestrom
Quoted 9 lines · Christian König
Quoted 8 lines
Am 05.11.2016 um 02:33 schrieb Eric Engestrom:
Quoted 1 line
+typedef char drm_format_name_buf[32];
Please don't use a typedef for this, just define the maximum size of characters the function might write somewhere.
See the kernel coding style as well:
Quoted 2 lines
In general, a pointer, or a struct that has elements that can reasonably be directly accessed should **never** be a typedef.
Quoted 8 lines
Quoted 4 lines
I would normally agree as I tend to hate typedefs ($DAYJOB {ab,mis}uses them way too much), and your way was what I wrote at first, but Rob Clark's typedef idea makes it much harder for someone to allocate a buffer of the wrong size, which IMO is good thing here.
IMHO I would make a small test program to verify this actually helps the compiler catch problems. And if it does, I would stick with it. The coding-style should be guidelines, not something that supersedes common sense / practicality.
Well completely agree that we should be able to question the coding style rules, but when we do it we discuss this on a the mailing list first and then start to use it in code. Not the other way around.
Quoted 5 lines
That is my $0.02 anyways.. if others vehemently disagree and want to dogmatically stick to the coding-style guidelines, ok then. OTOH, if this approach doesn't help the compiler catch issues, then it isn't worth it.
Yeah, exactly that's the point. If I'm not completely mistaken the compiler won't issue a warning here if you pass an array with the wrong size.
I think you need something like "struct drm_format_name_buf { char str[32]; };" to trigger this.
Apart from that is this function really called so often that using kasprintf() is a problem here? Or is there another motivation behind the change?
Regards,
Christian.
Quoted 12 lines
BR,
-RQuoted 8 lines
I can rewrite the typedef out if you think it's better.
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: move allocation out of drm_get_format_name()
Quoted 31 lines · Christian König
Am 05.11.2016 um 17:49 schrieb Rob Clark:
Quoted 24 lines · Eric Engestrom
Quoted 16 lines · Christian König
Quoted 13 lines
Am 05.11.2016 um 02:33 schrieb Eric Engestrom:
Quoted 2 lines
+typedef char drm_format_name_buf[32];
Please don't use a typedef for this, just define the maximum size of characters the function might write somewhere.
See the kernel coding style as well:
Quoted 4 lines
In general, a pointer, or a struct that has elements that can reasonably
be directly accessed should **never** be a typedef.Quoted 5 lines
I would normally agree as I tend to hate typedefs ($DAYJOB {ab,mis}uses them way too much), and your way was what I wrote at first, but Rob Clark's
typedef idea makes it much harder for someone to allocate a buffer of the wrong size, which IMO is good thing here.Quoted 4 lines
IMHO I would make a small test program to verify this actually helps the compiler catch problems. And if it does, I would stick with it. The coding-style should be guidelines, not something that supersedes common sense / practicality.
Quoted 3 lines
Well completely agree that we should be able to question the coding style rules, but when we do it we discuss this on a the mailing list first and then start to use it in code. Not the other way around.
if I'm not mistaken, that is what we are doing ;-)
Quoted 7 lines
Quoted 5 lines
That is my $0.02 anyways.. if others vehemently disagree and want to dogmatically stick to the coding-style guidelines, ok then. OTOH, if this approach doesn't help the compiler catch issues, then it isn't worth it.
Quoted 5 lines
Yeah, exactly that's the point. If I'm not completely mistaken the compiler won't issue a warning here if you pass an array with the wrong size.
I think you need something like "struct
drm_format_name_buf{ char str[32]; };" to trigger this.
hmm, actually the struct is a nice idea then if the compiler wouldn't catch the wrong-size-array
Quoted 3 lines
Apart from that is this function really called so often that using
kasprintf()is a problem here? Or is there another motivation behind the change?
Two things trouble me about the kasprintf approach.. (ignoring the fact that atm it is not GFP_ATOMIC)
1) you can't do DRM_DEBUG("format: %s\n", drm_get_format_name(..)) so it pulls the memory allocation and sprintf outside of the drm_debug check
2) seems awfully easy to forget the kfree... I wouldn't have even known that now you need to free the result (with some patches I'm working on) if it weren't for the fact that lockdep alerted me to the GFP_KERNEL allocation in atomic ctx ;-)
BR,
-R
Quoted 19 lines
Regards,
Christian.Quoted 12 lines
BR,
-RQuoted 8 lines
I can rewrite the typedef out if you think it's better.
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: move allocation out of drm_get_format_name()
Quoted 46 lines · Rob Clark
Quoted 31 lines · Christian König
Am 05.11.2016 um 17:49 schrieb Rob Clark:
Quoted 24 lines · Eric Engestrom
Quoted 16 lines · Christian König
Quoted 13 lines
Am 05.11.2016 um 02:33 schrieb Eric Engestrom:
Quoted 2 lines
+typedef char drm_format_name_buf[32];
Please don't use a typedef for this, just define the maximum size of characters the function might write somewhere.
See the kernel coding style as well:
Quoted 4 lines
In general, a pointer, or a struct that has elements that can reasonably
be directly accessed should **never** be a typedef.Quoted 5 lines
I would normally agree as I tend to hate typedefs ($DAYJOB {ab,mis}uses them way too much), and your way was what I wrote at first, but Rob Clark's
typedef idea makes it much harder for someone to allocate a buffer of the wrong size, which IMO is good thing here.Quoted 4 lines
IMHO I would make a small test program to verify this actually helps the compiler catch problems. And if it does, I would stick with it. The coding-style should be guidelines, not something that supersedes common sense / practicality.
Quoted 3 lines
Well completely agree that we should be able to question the coding style rules, but when we do it we discuss this on a the mailing list first and then start to use it in code. Not the other way around.
if I'm not mistaken, that is what we are doing ;-)
Quoted 7 lines
Quoted 5 lines
That is my $0.02 anyways.. if others vehemently disagree and want to dogmatically stick to the coding-style guidelines, ok then. OTOH, if this approach doesn't help the compiler catch issues, then it isn't worth it.
Quoted 8 lines
Quoted 5 lines
Yeah, exactly that's the point. If I'm not completely mistaken the compiler won't issue a warning here if you pass an array with the wrong size.
I think you need something like "struct
drm_format_name_buf{ char str[32]; };" to trigger this.hmm, actually the struct is a nice idea then if the compiler wouldn't catch the wrong-size-array
Sending the patch in a minute.
Quoted 11 lines
Quoted 4 lines
apart from that is this function really called so often that using
kasprintf()is a problem here? or is there another motivation behind the change?two things trouble me about the kasprintf approach.. (ignoring the fact that atm it is not
gfp_atomic)
1) you can't dodrm_debug("format: %s\n", drm_get_format_name(..))so it pulls the memory allocation and sprintf outside of thedrm_debugcheck
2) seems awfully easy to forget the kfree...
I actually found a couple of these memory leaks while doing this patch, look for files where i don't remove kfree :)
(eg. vmwgfx at the end of the patch)
Quoted 7 lines
i wouldn't have even
known that now you need to free the result (with some patches i'm working on) if it weren't for the fact that lockdep alerted me to thegfp_kernelallocation in atomic ctx ;-)br,
-r
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/1 drm: move allocation out of drm_get_format_name()
drm: make drm_get_format_name thread-safe
[danvet: Clarify that the returned pointer must be freed with kfree().]
---
v2: use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)
--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)
include/drm/drm_fourcc.h +9 -1
@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);
@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */
drivers/gpu/drm/drm_fourcc.c +5 -9
@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),
@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3 -4
@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3 -4
@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -1
@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3 -4
@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/drm_atomic.c +4 -3
@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }
drivers/gpu/drm/drm_crtc.c +4 -3
@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }
drivers/gpu/drm/drm_framebuffer.c +4 -3
@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/drm_modeset_helper.c +4 -3
@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;
drivers/gpu/drm/drm_plane.c +4 -3
@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -4
@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);
drivers/gpu/drm/i915/i915_debugfs.c +4 -6
@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );
@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }
drivers/gpu/drm/i915/intel_atomic_plane.c +4 -4
@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {
@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :
drivers/gpu/drm/i915/intel_display.c +16 -25
101 lines not on this page · raw message
drivers/gpu/drm/radeon/atombios_crtc.c +6 -8
@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -1
@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }
Signature · 2 lines
Cheers, Eric
Re: [PATCH v2] drm: move allocation out of drm_get_format_name()
Am 07.11.2016 um 01:48 schrieb Eric Engestrom:
Quoted 5 lines
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>
Quoted 8 lines
[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>
Quoted 525 lines
---
v2: use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)include/drm/drm_fourcc.h +9
-1@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */ drivers/gpu/drm/drm_fourcc.c +5
-9@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3
-4@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3
-4@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-1@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3
-4@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +4
-3@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }drivers/gpu/drm/drm_crtc.c +4
-3@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }drivers/gpu/drm/drm_framebuffer.c +4
-3@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_modeset_helper.c +4
-3@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;drivers/gpu/drm/drm_plane.c +4
-3@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3
-4@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/i915_debugfs.c +4
-6@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }drivers/gpu/drm/i915/intel_atomic_plane.c +4
-4@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :drivers/gpu/drm/i915/intel_display.c +16
-25@@ -12871,7 +12871,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,DRM_DEBUG_KMS ("planes on this crtc\n" );list_for_each_entry (plane, &dev->mode_config.plane_list, head) { -char *format_name; +struct drm_format_name_buf format_name; intel_plane =to_intel_plane (plane);if (intel_plane->pipe != crtc->pipe)continue ;@@ -12884,12 +12884,11 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,continue ; } - format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("[PLANE:%d:%s] enabled" , plane->base.id, plane->name);DRM_DEBUG_KMS ("\tFB:%d, fb = %ux%u format = %s" , - fb->base.id, fb->width, fb->height, format_name); + fb->base.id, fb->width, fb->height, +drm_get_format_name (fb->pixel_format, &format_name)); DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", state->scaler_id, state->base.src.x1 >> 16,@@ -12899,8 +12898,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, state->base.dst.x1, state->base.dst.y1,drm_rect_width (&state->base.dst), drm_rect_height(&state->base.dst)); - -kfree (format_name); } }@@ -15749,7 +15746,7 @@ static int intel_framebuffer_init(struct drm_device *dev,unsigned int tiling =i915_gem_object_get_tiling (obj);int ret;u32 pitch_limit, stride_alignment; -char *format_name; +struct drm_format_name_buf format_name;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -15840,18 +15837,16 @@ static int intel_framebuffer_init(struct drm_device *dev,break ;case DRM_FORMAT_XRGB1555 :if (INTEL_INFO (dev)->gen >3 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR8888 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv) &&INTEL_INFO (dev)->gen <9 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15859,17 +15854,15 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_XBGR2101010 :if (INTEL_INFO (dev)->gen <4 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR2101010 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv)) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15878,16 +15871,14 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_YVYU :case DRM_FORMAT_VYUY :if (INTEL_INFO (dev)->gen <5 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;default : - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +6
-8@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0
-0
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, · line 993
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-1@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2] drm: move allocation out of drm_get_format_name()
In reply to Eric EngestromQuoted 8 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>
The Fixes: format is:
But is this a fix, really, or just an improvement? What exactly is the bug being fixed? The commit message is not sufficient.
Quoted 8 lines
Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>---
v2: use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)
Just to make it clear: NAK three times over for v1. This patch is definitely a better alternative.
Quoted 41 lines
--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)include/drm/drm_fourcc.h +8
-0@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);
include/drm/drm_fourcc.h int drm_format_horz_chroma_subsampling(uint32_t format); · line 65
Quoted 5 lines
include/drm/drm_fourcc.h +1
-1@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);
I wonder if it would be better to make that return "const char *". If the user really wants to look under the hood, there's buf->str. *shrug*
With the commit message improved,
Quoted 484 lines
include/drm/drm_fourcc.h +0
-0#endif /* __DRM_FOURCC_H__ */ drivers/gpu/drm/drm_fourcc.c +5
-9@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3
-4@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3
-4@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-1@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3
-4@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +4
-3@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }drivers/gpu/drm/drm_crtc.c +4
-3@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }drivers/gpu/drm/drm_framebuffer.c +4
-3@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_modeset_helper.c +4
-3@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;drivers/gpu/drm/drm_plane.c +4
-3@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3
-4@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/i915_debugfs.c +4
-6@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }drivers/gpu/drm/i915/intel_atomic_plane.c +4
-4@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :drivers/gpu/drm/i915/intel_display.c +16
-25@@ -12871,7 +12871,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,DRM_DEBUG_KMS ("planes on this crtc\n" );list_for_each_entry (plane, &dev->mode_config.plane_list, head) { -char *format_name; +struct drm_format_name_buf format_name; intel_plane =to_intel_plane (plane);if (intel_plane->pipe != crtc->pipe)continue ;@@ -12884,12 +12884,11 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,continue ; } - format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("[PLANE:%d:%s] enabled" , plane->base.id, plane->name);DRM_DEBUG_KMS ("\tFB:%d, fb = %ux%u format = %s" , - fb->base.id, fb->width, fb->height, format_name); + fb->base.id, fb->width, fb->height, +drm_get_format_name (fb->pixel_format, &format_name)); DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", state->scaler_id, state->base.src.x1 >> 16,@@ -12899,8 +12898,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, state->base.dst.x1, state->base.dst.y1,drm_rect_width (&state->base.dst), drm_rect_height(&state->base.dst)); - -kfree (format_name); } }@@ -15749,7 +15746,7 @@ static int intel_framebuffer_init(struct drm_device *dev,unsigned int tiling =i915_gem_object_get_tiling (obj);int ret;u32 pitch_limit, stride_alignment; -char *format_name; +struct drm_format_name_buf format_name;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -15840,18 +15837,16 @@ static int intel_framebuffer_init(struct drm_device *dev,break ;case DRM_FORMAT_XRGB1555 :if (INTEL_INFO (dev)->gen >3 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR8888 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv) &&INTEL_INFO (dev)->gen <9 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15859,17 +15854,15 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_XBGR2101010 :if (INTEL_INFO (dev)->gen <4 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR2101010 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv)) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15878,16 +15871,14 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_YVYU :case DRM_FORMAT_VYUY :if (INTEL_INFO (dev)->gen <5 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;default : - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +6
-8@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-1@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2] drm: move allocation out of drm_get_format_name()
Quoted 10 lines · Jani Nikula
Quoted 8 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>
Quoted 6 lines
The Fixes: format is:
Fixes 90844f00049e ("drm: make drm_get_format_name thread-safe")But is this a fix, really, or just an improvement? What exactly is the bug being fixed? The commit message is not sufficient.
"The function's behaviour was changed in 90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocating GFP_KERNEL memory in atomic contexts, breaking them.
Instead of having to allocate GFP_ATOMIC memory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory."
Does this sound good?
Quoted 9 lines
include/drm/drm_fourcc.h int drm_format_horz_chroma_subsampling(uint32_t format); · line 65
Quoted 6 lines
include/drm/drm_fourcc.h +1
-1@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);I wonder if it would be better to make that return "const char *". If the user really wants to look under the hood, there's
buf->str. *shrug*
Good idea, I'll do that in v3 with the proper commit msg and tags. It'll have to wait another day though, -ENOTIME and all.
Quoted 4 lines
With the commit message improved,
Reviewed-by Jani Nikula <[email protected]>
Cheers :)
Eric
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula
maintainerRe: [PATCH v2] drm: move allocation out of drm_get_format_name()
Quoted 24 lines · Eric Engestrom
Quoted 10 lines · Jani Nikula
Quoted 8 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Quoted 6 lines
The Fixes: format is:
Fixes 90844f00049e ("drm: make drm_get_format_name thread-safe")But is this a fix, really, or just an improvement? What exactly is the bug being fixed? The commit message is not sufficient.
"The function's behaviour was changed in
90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocatingGFP_KERNELmemory in atomic contexts, breaking them.
Quoted 8 lines
Instead of having to allocate
GFP_ATOMICmemory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory."Does this sound good?
It's fine; no need to go overboard. ;)
BR,
Jani.
Quoted 21 lines
Quoted 10 lines
include/drm/drm_fourcc.h int drm_format_horz_chroma_subsampling(uint32_t format); · line 65
Quoted 7 lines
include/drm/drm_fourcc.h +1
-1@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);I wonder if it would be better to make that return "const char *". If the user really wants to look under the hood, there's
buf->str. *shrug*Good idea, I'll do that in v3 with the proper commit msg and tags. It'll have to wait another day though,
-ENOTIMEand all.Quoted 4 lines
With the commit message improved,
Reviewed-by Jani Nikula <[email protected]>Cheers :)
Eric
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Re: [Intel-gfx] [PATCH v2] drm: move allocation out of drm_get_format_name()
Quoted 32 lines · Jani Nikula
Quoted 31 lines · Eric Engestrom
Quoted 10 lines · Jani Nikula
Quoted 8 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Quoted 6 lines
The Fixes: format is:
Fixes 90844f00049e ("drm: make drm_get_format_name thread-safe")But is this a fix, really, or just an improvement? What exactly is the bug being fixed? The commit message is not sufficient.
"The function's behaviour was changed in
90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocatingGFP_KERNELmemory in atomic contexts, breaking them.Instead of having to allocate
GFP_ATOMICmemory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory."
Quoted 3 lines
Quoted 1 line
Does this sound good?
It's fine; no need to go overboard. ;)
Can you pls resend with that and corrected Fixes and all the acks collected?
-Daniel
Quoted 32 lines
BR,
Jani.Quoted 21 lines
Quoted 10 lines
include/drm/drm_fourcc.h int drm_format_horz_chroma_subsampling(uint32_t format); · line 65
Quoted 7 lines
include/drm/drm_fourcc.h +1
-1@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);I wonder if it would be better to make that return "const char *". If the user really wants to look under the hood, there's
buf->str. *shrug*Good idea, I'll do that in v3 with the proper commit msg and tags. It'll have to wait another day though,
-ENOTIMEand all.Quoted 4 lines
With the commit message improved,
Reviewed-by Jani Nikula <[email protected]>Cheers :)
EricSignature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH v3 1/1 drm: move allocation out of drm_get_format_name()
The function's behaviour was changed in 90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocating GFP_KERNEL memory in atomic contexts, breaking them.
Instead of having to allocate GFP_ATOMIC memory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory.
---
v3 - fix "Fixes" tag, replace it with an actual commit message
- collect ack & r-b
v2 - use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)
--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)
include/drm/drm_fourcc.h +9 -1
@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);
@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */
drivers/gpu/drm/drm_fourcc.c +5 -9
@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),
@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3 -4
@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3 -4
@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -1
@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3 -4
@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/drm_atomic.c +4 -3
@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }
drivers/gpu/drm/drm_crtc.c +4 -3
@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }
drivers/gpu/drm/drm_framebuffer.c +4 -3
@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/drm_modeset_helper.c +4 -3
@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;
drivers/gpu/drm/drm_plane.c +4 -3
@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -4
@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);
drivers/gpu/drm/i915/i915_debugfs.c +4 -6
@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );
@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }
drivers/gpu/drm/i915/intel_atomic_plane.c +4 -4
@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {
@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :
drivers/gpu/drm/i915/intel_display.c +16 -25
101 lines not on this page · raw message
drivers/gpu/drm/radeon/atombios_crtc.c +6 -8
@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -1
@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }
Signature · 7 lines
Cheers, Eric _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter
AppliedRe: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 22 lines · Eric Engestrom
The function's behaviour was changed in
90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocatingGFP_KERNELmemory in atomic contexts, breaking them.Instead of having to allocate
GFP_ATOMICmemory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory.Fixes 90844f00049e ("drm: make drm_get_format_name thread-safe")Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Acked-by Christian König <[email protected]>Acked-by Rob Clark <[email protected]>Reviewed-by Jani Nikula <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>
Quoted 6 lines
---
v3 - fix "Fixes" tag, replace it with an actual commit message
- collect ack & r-bv2 - use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)
Applied to drm-misc, thanks.
-Daniel
Quoted 538 lines
--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)include/drm/drm_fourcc.h +9
-1@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */ drivers/gpu/drm/drm_fourcc.c +5
-9@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3
-4@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3
-4@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-1@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3
-4@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +4
-3@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }drivers/gpu/drm/drm_crtc.c +4
-3@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }drivers/gpu/drm/drm_framebuffer.c +4
-3@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_modeset_helper.c +4
-3@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;drivers/gpu/drm/drm_plane.c +4
-3@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3
-4@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/i915_debugfs.c +4
-6@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }drivers/gpu/drm/i915/intel_atomic_plane.c +4
-4@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :drivers/gpu/drm/i915/intel_display.c +16
-25@@ -12871,7 +12871,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,DRM_DEBUG_KMS ("planes on this crtc\n" );list_for_each_entry (plane, &dev->mode_config.plane_list, head) { -char *format_name; +struct drm_format_name_buf format_name; intel_plane =to_intel_plane (plane);if (intel_plane->pipe != crtc->pipe)continue ;@@ -12884,12 +12884,11 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,continue ; } - format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("[PLANE:%d:%s] enabled" , plane->base.id, plane->name);DRM_DEBUG_KMS ("\tFB:%d, fb = %ux%u format = %s" , - fb->base.id, fb->width, fb->height, format_name); + fb->base.id, fb->width, fb->height, +drm_get_format_name (fb->pixel_format, &format_name)); DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", state->scaler_id, state->base.src.x1 >> 16,@@ -12899,8 +12898,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, state->base.dst.x1, state->base.dst.y1,drm_rect_width (&state->base.dst), drm_rect_height(&state->base.dst)); - -kfree (format_name); } }@@ -15749,7 +15746,7 @@ static int intel_framebuffer_init(struct drm_device *dev,unsigned int tiling =i915_gem_object_get_tiling (obj);int ret;u32 pitch_limit, stride_alignment; -char *format_name; +struct drm_format_name_buf format_name;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -15840,18 +15837,16 @@ static int intel_framebuffer_init(struct drm_device *dev,break ;case DRM_FORMAT_XRGB1555 :if (INTEL_INFO (dev)->gen >3 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR8888 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv) &&INTEL_INFO (dev)->gen <9 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15859,17 +15854,15 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_XBGR2101010 :if (INTEL_INFO (dev)->gen <4 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR2101010 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv)) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15878,16 +15871,14 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_YVYU :case DRM_FORMAT_VYUY :if (INTEL_INFO (dev)->gen <5 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;default : - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +6
-8@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-1@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }Signature · 7 lines
Cheers, Eric _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 27 lines · Daniel Vetter
Quoted 26 lines · Eric Engestrom
The function's behaviour was changed in
90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocatingGFP_KERNELmemory in atomic contexts, breaking them.Instead of having to allocate
GFP_ATOMICmemory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory.Fixes 90844f00049e ("drm: make drm_get_format_name thread-safe")Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Acked-by Christian König <[email protected]>Acked-by Rob Clark <[email protected]>Reviewed-by Jani Nikula <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>---
v3 - fix "Fixes" tag, replace it with an actual commit message
- collect ack & r-b
Quoted 4 lines
Quoted 2 lines
v2 - use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)Applied to drm-misc, thanks.
Well, had to drop it again since it didn't compile:
CC [M] drivers/gpu/drm/drm_blend.odrivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’
drm_get_format_name(fb->pixel_format));
^~~~~~~~~~~~~~~~~~~
In file included from ./include/drm/drmP.h:71:0,
from drivers/gpu/drm/drm_atomic.c:29:
./include/drm/drm_fourcc.h:65:7: note: declared here
char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
^~~~~~~~~~~~~~~~~~~Can you pls rebase onto drm-misc or linux-next or something?
Thanks, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 47 lines · Daniel Vetter
Quoted 27 lines · Daniel Vetter
Quoted 26 lines · Eric Engestrom
The function's behaviour was changed in
90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocatingGFP_KERNELmemory in atomic contexts, breaking them.Instead of having to allocate
GFP_ATOMICmemory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory.Fixes 90844f00049e ("drm: make drm_get_format_name thread-safe")Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Acked-by Christian König <[email protected]>Acked-by Rob Clark <[email protected]>Reviewed-by Jani Nikula <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>---
v3 - fix "Fixes" tag, replace it with an actual commit message
- collect ack & r-bQuoted 4 lines
Quoted 2 lines
v2 - use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)Applied to drm-misc, thanks.
Well, had to drop it again since it didn't compile:
CC [M]
drivers/gpu/drm/drm_blend.odrivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~ In file included from ./include/drm/drmP.h:71:0, from drivers/gpu/drm/drm_atomic.c:29: ./include/drm/drm_fourcc.h:65:7: note: declared here char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf); ^~~~~~~~~~~~~~~~~~~
Quoted 1 line
Can you pls rebase onto drm-misc or linux-next or something?
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next.
Should I just rebase on top of current head of drm-next?
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 14 lines · Eric Engestrom
Quoted 14 lines
Well, had to drop it again since it didn't compile:
CC [M]
drivers/gpu/drm/drm_blend.odrivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~ In file included from ./include/drm/drmP.h:71:0, from drivers/gpu/drm/drm_atomic.c:29: ./include/drm/drm_fourcc.h:65:7: note: declared here char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf); ^~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 1 line
Can you pls rebase onto drm-misc or linux-next or something?
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next.
Should I just rebase on top of current head of drm-next?
It needs to be drm-misc (linux-next doesn't have it yet) due to the new atomic debug work that we just landed. I'm working on drm-tip as a drm local integration tree to ease pains like these a bit, but that doesn't really exist yet.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 23 lines · Daniel Vetter
Quoted 14 lines · Eric Engestrom
Quoted 14 lines
Well, had to drop it again since it didn't compile:
CC [M]
drivers/gpu/drm/drm_blend.odrivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~ In file included from ./include/drm/drmP.h:71:0, from drivers/gpu/drm/drm_atomic.c:29: ./include/drm/drm_fourcc.h:65:7: note: declared here char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf); ^~~~~~~~~~~~~~~~~~~Quoted 6 lines
Quoted 1 line
Can you pls rebase onto drm-misc or linux-next or something?
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next.
Should I just rebase on top of current head of drm-next?
Quoted 4 lines
It needs to be drm-misc (linux-next doesn't have it yet) due to the new atomic debug work that we just landed. I'm working on drm-tip as a drm local integration tree to ease pains like these a bit, but that doesn't really exist yet.
I'm confused as to how the different trees and branches merge back to Torvalds' tree (I'm interested in particular in drm), and I'm not sure which branch you want me to rebase on in the drm-misc tree [1], especially since all of them are older than drm-next [2].
I'll try to rebase on drm-misc-fixes (currently at 4da5caa6a6f82cda3193) as it sounds about right, but it doesn't apply at all, so it'll take a little while.
Could you give me a quick explanation or point me to a doc/page that explains how the various trees and branches get merged?
I googled a bit and found this doc [4] by Jani, but it doesn't mention drm-misc for instance, so I'm not sure how up-to-date and non-intel-specific it is.
Looking at this page, something just occurred to me: did you mean drm-fixes [3], instead of one of the branches on drm-misc?
Cheers,
Eric
[1] git://anongit.freedesktop.org/drm/drm-misc
[2] git://people.freedesktop.org/~airlied/linux drm-next
[2] git://people.freedesktop.org/~airlied/linux drm-fixes
[3] https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Hi Eric,
Quoted 32 lines · On Wednesday 09 Nov 2016 16:59:31 Eric Engestrom wrote:
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Eric Engestrom
Quoted 20 lines
Well, had to drop it again since it didn't compile:
CC [M]drivers/gpu/drm/drm_blend.o
drivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’> >>drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~In file included from
./include/drm/drmP.h:71:0,from
drivers/gpu/drm/drm_atomic.c:29:./include/drm/drm_fourcc.h:65:7: note: declared herechar *drm_get_format_name(uint32_t format, struct
drm_format_name_buf*buf);> >>^~~~~~~~~~~~~~~~~~~Can you pls rebase onto drm-misc or linux-next or something?
Quoted 8 lines
Quoted 3 lines
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next. Should I just rebase on top of current head of drm-next?
It needs to be drm-misc (linux-next doesn't have it yet) due to the new atomic debug work that we just landed. I'm working on drm-tip as a drm local integration tree to ease pains like these a bit, but that doesn't really exist yet.
Quoted 8 lines
I'm confused as to how the different trees and branches merge back to Torvalds' tree (I'm interested in particular in drm), and I'm not sure which branch you want me to rebase on in the drm-misc tree [1], especially since all of them are older than drm-next [2].
I'll try to rebase on drm-misc-fixes (currently at
4da5caa6a6f82cda3193) as it sounds about right, but it doesn't apply at all, so it'll take a little while.
While at it, could you make the function return a const char * ?
By the way, while this is an improvement over the current situation in that it fixes the missing kfree() issue, I wonder whether the problem we're trying to solve should be addressed at a more global level.
The issue here is that printk can't format the fourcc as a string by itself. There's a bunch of places in the kernel where a similar formatting problem occurs. In a few occasions it has been solved by extending printk with additional format specifiers (such as for MAC/IP addresses, GUIDs, various kind of device names, ...). DRM fourccs are probably too DRM specific to be worth a format specifier, but I wonder whether we could introduce a new specifier that takes a function pointer as a formatting helper. Another similarly crazy option would be a format specifier for strings that would free the passed pointer after printing it.
Quoted 16 lines
Could you give me a quick explanation or point me to a doc/page that explains how the various trees and branches get merged?
I googled a bit and found this doc [4] by Jani, but it doesn't mention drm-misc for instance, so I'm not sure how up-to-date and non-intel-specific it is.Looking at this page, something just occurred to me: did you mean drm-fixes [3], instead of one of the branches on drm-misc?
Cheers,
Eric[1]
git://anongit.freedesktop.org/drm/drm-misc
[2]git://people.freedesktop.org/~airlied/linuxdrm-next
[2]git://people.freedesktop.org/~airlied/linuxdrm-fixes
[3] https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 40 lines · Laurent Pinchart
Hi Eric,
Quoted 37 lines · On Wednesday 09 Nov 2016 16:59:31 Eric Engestrom wrote:
Quoted 22 lines · Daniel Vetter
Quoted 21 lines · Eric Engestrom
Quoted 20 lines
Well, had to drop it again since it didn't compile:
CC [M]drivers/gpu/drm/drm_blend.o
drivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’> >>drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~In file included from
./include/drm/drmP.h:71:0,from
drivers/gpu/drm/drm_atomic.c:29:./include/drm/drm_fourcc.h:65:7: note: declared herechar *drm_get_format_name(uint32_t format, struct
drm_format_name_buf*buf);> >>^~~~~~~~~~~~~~~~~~~Can you pls rebase onto drm-misc or linux-next or something?
Quoted 8 lines
Quoted 3 lines
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next. Should I just rebase on top of current head of drm-next?
It needs to be drm-misc (linux-next doesn't have it yet) due to the new atomic debug work that we just landed. I'm working on drm-tip as a drm local integration tree to ease pains like these a bit, but that doesn't really exist yet.
I'm confused as to how the different trees and branches merge back to Torvalds' tree (I'm interested in particular in drm), and I'm not sure which branch you want me to rebase on in the drm-misc tree [1], especially since all of them are older than drm-next [2].
Quoted 5 lines
Quoted 3 lines
I'll try to rebase on drm-misc-fixes (currently at
4da5caa6a6f82cda3193) as it sounds about right, but it doesn't apply at all, so it'll take a little while.While at it, could you make the function return a const char * ?
I thought I mentioned that too, though I didn't insist.
Quoted 3 lines
By the way, while this is an improvement over the current situation in that it fixes the missing
kfree()issue, I wonder whether the problem we're trying to solve should be addressed at a more global level.
Maybe, but let's not block this one!
Quoted 9 lines
The issue here is that printk can't format the fourcc as a string by itself. There's a bunch of places in the kernel where a similar formatting problem occurs. In a few occasions it has been solved by extending printk with additional format specifiers (such as for MAC/IP addresses, GUIDs, various kind of device names, ...). DRM fourccs are probably too DRM specific to be worth a format specifier, but I wonder whether we could introduce a new specifier that takes a function pointer as a formatting helper. Another similarly crazy option would be a format specifier for strings that would free the passed pointer after printing it.
I think there are too many non-standard format specifiers already. I can't review the non-standard format strings without looking at Documentation/prink-formats.txt first. The formatting hook would be a generic alternative, but that's more than a little scary from the security standpoint. And what if the hook has to allocate memory? Can't do that in atomic contexts.
BR,
Jani.
Quoted 17 lines
Quoted 17 lines
Could you give me a quick explanation or point me to a doc/page that explains how the various trees and branches get merged?
I googled a bit and found this doc [4] by Jani, but it doesn't mention drm-misc for instance, so I'm not sure how up-to-date and non-intel-specific it is.Looking at this page, something just occurred to me: did you mean drm-fixes [3], instead of one of the branches on drm-misc?
Cheers,
Eric[1]
git://anongit.freedesktop.org/drm/drm-misc
[2]git://people.freedesktop.org/~airlied/linuxdrm-next
[2]git://people.freedesktop.org/~airlied/linuxdrm-fixes
[3] https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Hi Jani,
Quoted 36 lines · On Thursday 10 Nov 2016 12:30:09 Jani Nikula wrote:
Quoted 35 lines · Laurent Pinchart
Quoted 34 lines · On Wednesday 09 Nov 2016 16:59:31 Eric Engestrom wrote:
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Eric Engestrom
Quoted 17 lines
Well, had to drop it again since it didn't compile:
CC [M]drivers/gpu/drm/drm_blend.o
drivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’> >>drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~In file included from
./include/drm/drmP.h:71:0,
fromdrivers/gpu/drm/drm_atomic.c:29:./include/drm/drm_fourcc.h:65:7: note: declared here
char *drm_get_format_name(uint32_t format, structdrm_format_name_buf *buf); ^~~~~~~~~~~~~~~~~~~Can you pls rebase onto drm-misc or linux-next or something?
Quoted 8 lines
Quoted 3 lines
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next. Should I just rebase on top of current head of drm-next?
It needs to be drm-misc (linux-next doesn't have it yet) due to the new atomic debug work that we just landed. I'm working on drm-tip as a drm local integration tree to ease pains like these a bit, but that doesn't really exist yet.
I'm confused as to how the different trees and branches merge back to Torvalds' tree (I'm interested in particular in drm), and I'm not sure which branch you want me to rebase on in the drm-misc tree [1], especially since all of them are older than drm-next [2].
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I'll try to rebase on drm-misc-fixes (currently at
4da5caa6a6f82cda3193) as it sounds about right, but it doesn't apply at all, so it'll take a little while.While at it, could you make the function return a const char * ?
I thought I mentioned that too, though I didn't insist.
You did, and I think Eric agreed to change that.
Quoted 5 lines
Quoted 3 lines
By the way, while this is an improvement over the current situation in that it fixes the missing
kfree()issue, I wonder whether the problem we're trying to solve should be addressed at a more global level.Maybe, but let's not block this one!
Sure, that wasn't the intent of my e-mail.
Quoted 11 lines
Quoted 10 lines
The issue here is that printk can't format the fourcc as a string by itself. There's a bunch of places in the kernel where a similar formatting problem occurs. In a few occasions it has been solved by extending printk with additional format specifiers (such as for MAC/IP addresses, GUIDs, various kind of device names, ...). DRM fourccs are probably too DRM specific to be worth a format specifier, but I wonder whether we could introduce a new specifier that takes a function pointer as a formatting helper. Another similarly crazy option would be a format specifier for strings that would free the passed pointer after printing it.
Quoted 6 lines
I think there are too many non-standard format specifiers already. I can't review the non-standard format strings without looking at
Documentation/prink-formats.txtfirst. The formatting hook would be a generic alternative, but that's more than a little scary from the security standpoint. And what if the hook has to allocate memory? Can't do that in atomic contexts.
There are lots of details to sort out obviously and I don't have an answer to all questions yet. I think it would be worth researching this, as the problem isn't specific to DRM/KMS.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Could you give me a quick explanation or point me to a doc/page that explains how the various trees and branches get merged?
I googled a bit and found this doc [4] by Jani, but it doesn't mention drm-misc for instance, so I'm not sure how up-to-date and non-intel-specific it is.Looking at this page, something just occurred to me: did you mean drm-fixes [3], instead of one of the branches on drm-misc?
Cheers,
Eric
[1]
git://anongit.freedesktop.org/drm/drm-misc
[2]git://people.freedesktop.org/~airlied/linuxdrm-next
[2]git://people.freedesktop.org/~airlied/linuxdrm-fixes
[3] https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
Quoted 22 lines · Laurent Pinchart
Hi Jani,
Quoted 12 lines · On Thursday 10 Nov 2016 12:30:09 Jani Nikula wrote:
Quoted 10 lines · Laurent Pinchart
The issue here is that printk can't format the fourcc as a string by itself. There's a bunch of places in the kernel where a similar formatting problem occurs. In a few occasions it has been solved by extending printk with additional format specifiers (such as for MAC/IP addresses, GUIDs, various kind of device names, ...). DRM fourccs are probably too DRM specific to be worth a format specifier, but I wonder whether we could introduce a new specifier that takes a function pointer as a formatting helper. Another similarly crazy option would be a format specifier for strings that would free the passed pointer after printing it.
Quoted 6 lines
I think there are too many non-standard format specifiers already. I can't review the non-standard format strings without looking at
Documentation/prink-formats.txtfirst. The formatting hook would be a generic alternative, but that's more than a little scary from the security standpoint. And what if the hook has to allocate memory? Can't do that in atomic contexts.
Quoted 3 lines
There are lots of details to sort out obviously and I don't have an answer to all questions yet. I think it would be worth researching this, as the problem isn't specific to DRM/KMS.
That's easy to agree to; as much as you didn't mean to shoot down the patch, I didn't mean to shoot down your idea! :)
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v3] drm: move allocation out of drm_get_format_name()
In reply to Eric EngestromQuoted 29 lines · Eric Engestrom
Quoted 23 lines · Daniel Vetter
Quoted 14 lines · Eric Engestrom
Quoted 14 lines
Well, had to drop it again since it didn't compile:
CC [M]
drivers/gpu/drm/drm_blend.odrivers/gpu/drm/drm_atomic.c: In function ‘drm_atomic_plane_print_state’:drivers/gpu/drm/drm_atomic.c:920:5: error: too few arguments to function ‘drm_get_format_name’drm_get_format_name(fb->pixel_format)); ^~~~~~~~~~~~~~~~~~~ In file included from ./include/drm/drmP.h:71:0, from drivers/gpu/drm/drm_atomic.c:29: ./include/drm/drm_fourcc.h:65:7: note: declared here char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf); ^~~~~~~~~~~~~~~~~~~Quoted 6 lines
Quoted 1 line
Can you pls rebase onto drm-misc or linux-next or something?
That was based on airlied/drm-next (last fetched on Sunday I think), I can rebase it on drm-misc if it helps, but it seems older than drm-next.
Should I just rebase on top of current head of drm-next?Quoted 4 lines
It needs to be drm-misc (linux-next doesn't have it yet) due to the new atomic debug work that we just landed. I'm working on drm-tip as a drm local integration tree to ease pains like these a bit, but that doesn't really exist yet.
Quoted 4 lines
I'm confused as to how the different trees and branches merge back to Torvalds' tree (I'm interested in particular in drm), and I'm not sure which branch you want me to rebase on in the drm-misc tree [1], especially since all of them are older than drm-next [2].
Dave just pulled in all outstanding pull requests, so just basing on top of his drm-next should be good enough.
Quoted 9 lines
I'll try to rebase on drm-misc-fixes (currently at
4da5caa6a6f82cda3193) as it sounds about right, but it doesn't apply at all, so it'll take a little while.Could you give me a quick explanation or point me to a doc/page that explains how the various trees and branches get merged?
I googled a bit and found this doc [4] by Jani, but it doesn't mention drm-misc for instance, so I'm not sure how up-to-date and non-intel-specific it is.
We atm don't have it :( drm-misc was kinda just a (very long running) experiment, but I want to know make it official. Unfortunately the scripting rework to split out a new drm-misc.git repo is taking a bit longer. Atm things are still in flux, but I hope that'll settle soon-ish.
Quoted 7 lines
Looking at this page, something just occurred to me: did you mean drm-fixes [3], instead of one of the branches on drm-misc?
Cheers,
Eric[1]
git://anongit.freedesktop.org/drm/drm-misc
Yeah, that's the new location, but atm it's just under testing and it's not the real drm-misc. That one is in drm-intel.git, in the topic/drm-misc branch.
Quoted 3 lines
[2]
git://people.freedesktop.org/~airlied/linuxdrm-next
[2]git://people.freedesktop.org/~airlied/linuxdrm-fixes
[3] https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-intel.html
https://01.org/linuxgraphics/gfx-docs/maintainer-tools/drm-misc.html
We need to flesh that out, and maybe feature it a bit more prominently. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 1/1 drm: move allocation out of drm_get_format_name()
The function's behaviour was changed in 90844f00049e, without changing its signature, causing people to keep using it the old way without realising they were now leaking memory.
Rob Clark also noticed it was also allocating GFP_KERNEL memory in atomic contexts, breaking them.
Instead of having to allocate GFP_ATOMIC memory and fixing the callers to make them cleanup the memory afterwards, let's change the function's signature by having the caller take care of the memory and passing it to the function.
The new parameter is a single-field struct in order to enforce the size of its buffer and help callers to correctly manage their memory.
---
v4 - rebase on drm-next (d8c1abd968f1c880ad8c)
- add missed const to the return value
v3 - fix "Fixes" tag, replace it with an actual commit message
- collect ack & r-b
v2 - use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)
--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 10 +++--- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 82 insertions(+), 87 deletions(-)
include/drm/drm_fourcc.h +9 -1
@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);
@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */
drivers/gpu/drm/drm_fourcc.c +5 -9
@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +const char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),
@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3 -4
@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3 -4
@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2 -1
@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3 -4
@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/drm_atomic.c +6 -4
@@ -861,9 +861,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name));return ret; }
@@ -917,9 +918,10 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,if (state->fb) {struct drm_framebuffer *fb = state->fb;int i, n =drm_format_num_planes (fb->pixel_format); +struct drm_format_name_buf format_name;drm_printf (p,"\t\tformat=%s\n" , -drm_get_format_name (fb->pixel_format)); +drm_get_format_name (fb->pixel_format, &format_name));drm_printf (p,"\t\tsize=%dx%d\n" , fb->width, fb->height);drm_printf (p,"\t\tlayers:\n" );for (i =0 ; i < n; i++) {
drivers/gpu/drm/drm_crtc.c +4 -3
@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); goto out; } }
drivers/gpu/drm/drm_framebuffer.c +4 -3
@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); -kfree (format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name));return -EINVAL ; }
drivers/gpu/drm/drm_modeset_helper.c +4 -3
@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); -kfree (format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); fb->depth =0 ; fb->bits_per_pixel =0 ;
drivers/gpu/drm/drm_plane.c +4 -3
@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); -kfree (format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); goto out; }
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -4
@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); -kfree (format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name));/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);
drivers/gpu/drm/i915/i915_debugfs.c +4 -6
@@ -3032,7 +3032,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );
@@ -3042,9 +3042,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",
@@ -3060,10 +3060,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }
drivers/gpu/drm/i915/intel_atomic_plane.c +4 -4
@@ -141,7 +141,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {
@@ -157,9 +157,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); -kfree (format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name));return -EINVAL ;default :
drivers/gpu/drm/i915/intel_display.c +16 -25
101 lines not on this page · raw message
drivers/gpu/drm/radeon/atombios_crtc.c +6 -8
@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {
@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); -kfree (format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -1
@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }
Signature · 2 lines
Cheers, Eric
Re: [PATCH v2] drm: move allocation out of drm_get_format_name()
In reply to Eric EngestromQuoted 5 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>
Quoted 8 lines
[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>
Thanks,
Quoted 536 lines
---
v2: use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)include/drm/drm_fourcc.h +9
-1@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */ drivers/gpu/drm/drm_fourcc.c +5
-9@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3
-4@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3
-4@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-1@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3
-4@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +4
-3@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }drivers/gpu/drm/drm_crtc.c +4
-3@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }drivers/gpu/drm/drm_framebuffer.c +4
-3@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_modeset_helper.c +4
-3@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;drivers/gpu/drm/drm_plane.c +4
-3@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3
-4@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/i915_debugfs.c +4
-6@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }drivers/gpu/drm/i915/intel_atomic_plane.c +4
-4@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :drivers/gpu/drm/i915/intel_display.c +16
-25@@ -12871,7 +12871,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,DRM_DEBUG_KMS ("planes on this crtc\n" );list_for_each_entry (plane, &dev->mode_config.plane_list, head) { -char *format_name; +struct drm_format_name_buf format_name; intel_plane =to_intel_plane (plane);if (intel_plane->pipe != crtc->pipe)continue ;@@ -12884,12 +12884,11 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,continue ; } - format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("[PLANE:%d:%s] enabled" , plane->base.id, plane->name);DRM_DEBUG_KMS ("\tFB:%d, fb = %ux%u format = %s" , - fb->base.id, fb->width, fb->height, format_name); + fb->base.id, fb->width, fb->height, +drm_get_format_name (fb->pixel_format, &format_name)); DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", state->scaler_id, state->base.src.x1 >> 16,@@ -12899,8 +12898,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, state->base.dst.x1, state->base.dst.y1,drm_rect_width (&state->base.dst), drm_rect_height(&state->base.dst)); - -kfree (format_name); } }@@ -15749,7 +15746,7 @@ static int intel_framebuffer_init(struct drm_device *dev,unsigned int tiling =i915_gem_object_get_tiling (obj);int ret;u32 pitch_limit, stride_alignment; -char *format_name; +struct drm_format_name_buf format_name;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -15840,18 +15837,16 @@ static int intel_framebuffer_init(struct drm_device *dev,break ;case DRM_FORMAT_XRGB1555 :if (INTEL_INFO (dev)->gen >3 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR8888 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv) &&INTEL_INFO (dev)->gen <9 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15859,17 +15854,15 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_XBGR2101010 :if (INTEL_INFO (dev)->gen <4 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR2101010 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv)) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15878,16 +15871,14 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_YVYU :case DRM_FORMAT_VYUY :if (INTEL_INFO (dev)->gen <5 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;default : - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +6
-8@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-2@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); } --
Quoted 3 lines
Cheers,
Eric
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2] drm: move allocation out of drm_get_format_name()
In reply to Eric EngestromThomas has already acked the earlier version, but in case you need it for this one, too.
vmwgfx portion: Acked-by: Sinclair Yeh <[email protected]>
Quoted 552 lines · Eric Engestrom
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Cc Rob Clark <[email protected]>Cc Christian König <[email protected]>Suggested-by Ville Syrjälä <[email protected]>Signed-off-by Eric Engestrom <[email protected]>---
v2: use single-field struct instead of typedef to let the compiler
enforce the type (Christian König)--- include/drm/drm_fourcc.h | 10 +++++- drivers/gpu/drm/drm_fourcc.c | 14 +++------ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 7 ++--- drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 7 ++--- drivers/gpu/drm/drm_atomic.c | 7 +++-- drivers/gpu/drm/drm_crtc.c | 7 +++-- drivers/gpu/drm/drm_framebuffer.c | 7 +++-- drivers/gpu/drm/drm_modeset_helper.c | 7 +++-- drivers/gpu/drm/drm_plane.c | 7 +++-- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 7 ++--- drivers/gpu/drm/i915/i915_debugfs.c | 10 +++--- drivers/gpu/drm/i915/intel_atomic_plane.c | 8 ++--- drivers/gpu/drm/i915/intel_display.c | 41 ++++++++++--------------- drivers/gpu/drm/radeon/atombios_crtc.c | 14 ++++----- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +- 17 files changed, 80 insertions(+), 86 deletions(-)include/drm/drm_fourcc.h +9
-1@@ -45,6 +45,14 @@ struct drm_format_info {u8 vsub; }; +/** +* struct drm_format_name_buf - name of a DRM format +* @str: string buffer containing the format name +*/ +struct drm_format_name_buf { +char str[32 ]; +}; +const struct drm_format_info *__drm_format_info (u32 format);const struct drm_format_info *drm_format_info (u32 format);uint32_t drm_mode_legacy_fb_format (uint32_t bpp,uint32_t depth);@@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);int drm_format_vert_chroma_subsampling (uint32_t format);int drm_format_plane_width (int width,uint32_t format,int plane);int drm_format_plane_height (int height,uint32_t format,int plane); -char *drm_get_format_name (uint32_t format) __malloc; +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf);#endif /* __DRM_FOURCC_H__ */ drivers/gpu/drm/drm_fourcc.c +5
-9@@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)EXPORT_SYMBOL (drm_mode_legacy_fb_format);/** -* drm_get_format_name - return a string for drm fourcc format +* drm_get_format_name - fill a string with a drm fourcc format's name * @format: format to compute name of +* @buf: caller-supplied buffer -* -* Note that the buffer returned by this function is owned by the caller -* and will need to be freed using kfree(). */ -char *drm_get_format_name (uint32_t format) +char *drm_get_format_name (uint32_t format,struct drm_format_name_buf *buf) { -char *buf =kmalloc (32 ,GFP_KERNEL ); - - snprintf(buf, 32, + snprintf(buf->str, sizeof(buf->str), "%c%c%c%c %s-endian (0x%08x)", printable_char(format & 0xff), printable_char((format >> 8) & 0xff),@@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format) format &DRM_FORMAT_BIG_ENDIAN ?"big" :"little" , format); -return buf; +return buf->str; }EXPORT_SYMBOL (drm_get_format_name);drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +3
-4@@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2144,9 +2144,8 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +3
-4@@ -2013,7 +2013,7 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2125,9 +2125,8 @@ static int dce_v11_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +2
-1@@ -1456,6 +1456,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1559,7 +1560,7 @@ static int dce_v6_0_crtc_do_set_base(struct drm_crtc *crtc,break ;default :DRM_ERROR ("Unsupported screen format %s\n" , -drm_get_format_name (target_fb->pixel_format)); +drm_get_format_name (target_fb->pixel_format, &format_name));return -EINVAL ; }drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +3
-4@@ -1910,7 +1910,7 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -2015,9 +2015,8 @@ static int dce_v8_0_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_atomic.c +4
-3@@ -835,9 +835,10 @@ static int drm_atomic_plane_check(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, state->fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_ATOMIC ("Invalid pixel format %s\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return ret; }drivers/gpu/drm/drm_crtc.c +4
-3@@ -827,9 +827,10 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, ret =drm_plane_check_pixel_format (crtc->primary, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; } }drivers/gpu/drm/drm_framebuffer.c +4
-3@@ -133,9 +133,10 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) info =__drm_format_info (r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN );if (!info) { -char *format_name =drm_get_format_name (r->pixel_format); -DRM_DEBUG_KMS ("bad framebuffer format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("bad framebuffer format %s\n" , +drm_get_format_name (r->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/drm_modeset_helper.c +4
-3@@ -75,10 +75,11 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, info =drm_format_info (mode_cmd->pixel_format);if (!info || !info->depth) { -char *format_name =drm_get_format_name (mode_cmd->pixel_format); +struct drm_format_name_buf format_name; -DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , format_name); +DRM_DEBUG_KMS ("non-RGB pixel format %s\n" , +drm_get_format_name (mode_cmd->pixel_format, + &format_name)); -kfree (format_name); fb->depth =0 ; fb->bits_per_pixel =0 ;drivers/gpu/drm/drm_plane.c +4
-3@@ -479,9 +479,10 @@ static int __setplane_internal(struct drm_plane *plane,/* Check whether this plane supports the fb pixel format. */ ret =drm_plane_check_pixel_format (plane, fb->pixel_format);if (ret) { -char *format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("Invalid pixel format %s\n" , format_name); +struct drm_format_name_buf format_name; +DRM_DEBUG_KMS ("Invalid pixel format %s\n" , +drm_get_format_name (fb->pixel_format, + &format_name)); -kfree (format_name); goto out; }drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3
-4@@ -608,17 +608,16 @@ static void ade_rdma_set(void __iomem *base, struct drm_framebuffer *fb, u32 ch, u32 y, u32 in_h, u32 fmt) { struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); -char *format_name; +struct drm_format_name_buf format_name;u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en;u32 stride = fb->pitches[0 ];u32 addr = (u32 )obj->paddr + y * stride;DRM_DEBUG_DRIVER ("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n" , ch +1 , y, in_h, stride, (u32 )obj->paddr); - format_name =drm_get_format_name (fb->pixel_format);DRM_DEBUG_DRIVER ("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n" , - addr, fb->width, fb->height, fmt, format_name); + addr, fb->width, fb->height, fmt, +drm_get_format_name (fb->pixel_format, &format_name)); -kfree (format_name);/* get reg offset */ reg_ctrl =RD_CH_CTRL (ch);drivers/gpu/drm/i915/i915_debugfs.c +4
-6@@ -2971,7 +2971,7 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc)for_each_intel_plane_on_crtc (dev, intel_crtc, intel_plane) {struct drm_plane_state *state;struct drm_plane *plane = &intel_plane->base; -char *format_name; +struct drm_format_name_buf format_name;if (!plane->state) {seq_puts (m,"plane->state is NULL!\n" );@@ -2981,9 +2981,9 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) state = plane->state;if (state->fb) { - format_name =drm_get_format_name (state->fb->pixel_format); +drm_get_format_name (state->fb->pixel_format, &format_name); }else { - format_name =kstrdup ("N/A" ,GFP_KERNEL ); +sprintf (format_name.str,"N/A" ); } seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n",@@ -2999,10 +2999,8 @@ static void intel_plane_info(struct seq_file *m, struct intel_crtc *intel_crtc) ((state->src_w &0xffff ) *15625 ) >>10 , (state->src_h >>16 ), ((state->src_h &0xffff ) *15625 ) >>10 , - format_name, + format_name.str, plane_rotation(state->rotation)); - -kfree (format_name); } }drivers/gpu/drm/i915/intel_atomic_plane.c +4
-4@@ -143,7 +143,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane, crtc_state->base.enable ? crtc_state->pipe_src_h :0 ;if (state->fb &&drm_rotation_90_or_270 (state->rotation)) { -char *format_name; +struct drm_format_name_buf format_name;if (!(state->fb->modifier[0 ] ==I915_FORMAT_MOD_Y_TILED || state->fb->modifier[0 ] == I915_FORMAT_MOD_Yf_TILED)) {@@ -159,9 +159,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,switch (state->fb->pixel_format) {case DRM_FORMAT_C8 :case DRM_FORMAT_RGB565 : - format_name =drm_get_format_name (state->fb->pixel_format); -DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , format_name); +DRM_DEBUG_KMS ("Unsupported pixel format %s for 90/270!\n" , +drm_get_format_name (state->fb->pixel_format, + &format_name)); -kfree (format_name);return -EINVAL ;default :drivers/gpu/drm/i915/intel_display.c +16
-25@@ -12871,7 +12871,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,DRM_DEBUG_KMS ("planes on this crtc\n" );list_for_each_entry (plane, &dev->mode_config.plane_list, head) { -char *format_name; +struct drm_format_name_buf format_name; intel_plane =to_intel_plane (plane);if (intel_plane->pipe != crtc->pipe)continue ;@@ -12884,12 +12884,11 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,continue ; } - format_name =drm_get_format_name (fb->pixel_format); -DRM_DEBUG_KMS ("[PLANE:%d:%s] enabled" , plane->base.id, plane->name);DRM_DEBUG_KMS ("\tFB:%d, fb = %ux%u format = %s" , - fb->base.id, fb->width, fb->height, format_name); + fb->base.id, fb->width, fb->height, +drm_get_format_name (fb->pixel_format, &format_name)); DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", state->scaler_id, state->base.src.x1 >> 16,@@ -12899,8 +12898,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, state->base.dst.x1, state->base.dst.y1,drm_rect_width (&state->base.dst), drm_rect_height(&state->base.dst)); - -kfree (format_name); } }@@ -15749,7 +15746,7 @@ static int intel_framebuffer_init(struct drm_device *dev,unsigned int tiling =i915_gem_object_get_tiling (obj);int ret;u32 pitch_limit, stride_alignment; -char *format_name; +struct drm_format_name_buf format_name;WARN_ON (!mutex_is_locked (&dev->struct_mutex));@@ -15840,18 +15837,16 @@ static int intel_framebuffer_init(struct drm_device *dev,break ;case DRM_FORMAT_XRGB1555 :if (INTEL_INFO (dev)->gen >3 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR8888 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv) &&INTEL_INFO (dev)->gen <9 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15859,17 +15854,15 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_XRGB2101010 :case DRM_FORMAT_XBGR2101010 :if (INTEL_INFO (dev)->gen <4 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;case DRM_FORMAT_ABGR2101010 :if (!IS_VALLEYVIEW (dev_priv) && !IS_CHERRYVIEW (dev_priv)) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;@@ -15878,16 +15871,14 @@ static int intel_framebuffer_init(struct drm_device *dev,case DRM_FORMAT_YVYU :case DRM_FORMAT_VYUY :if (INTEL_INFO (dev)->gen <5 ) { - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }break ;default : - format_name =drm_get_format_name (mode_cmd->pixel_format); -DRM_DEBUG ("unsupported pixel format: %s\n" , format_name); +DRM_DEBUG ("unsupported pixel format: %s\n" , +drm_get_format_name (mode_cmd->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/radeon/atombios_crtc.c +6
-8@@ -1156,7 +1156,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,u32 tmp, viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1260,9 +1260,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }@@ -1473,7 +1472,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,u32 viewport_w, viewport_h;int r;bool bypass_lut = false; -char *format_name; +struct drm_format_name_buf format_name;/* no fb bound */ if (!atomic && !crtc->primary->fb) {@@ -1563,9 +1562,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, bypass_lut = true;break ;default : - format_name =drm_get_format_name (target_fb->pixel_format); -DRM_ERROR ("Unsupported screen format %s\n" , format_name); +DRM_ERROR ("Unsupported screen format %s\n" , +drm_get_format_name (target_fb->pixel_format, &format_name)); -kfree (format_name);return -EINVAL ; }drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-1@@ -985,8 +985,9 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, info =drm_format_info (mode_cmd2->pixel_format);if (!info || !info->depth) { +struct drm_format_name_buf format_name;DRM_ERROR ("Unsupported framebuffer format %s\n" , -drm_get_format_name (mode_cmd2->pixel_format)); +drm_get_format_name (mode_cmd2->pixel_format, &format_name));return ERR_PTR (-EINVAL ); }Signature · 2 lines
Cheers, Eric
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 91 lines · Eric Engestrom
Quoted 77 lines · Rob Clark
Quoted 41 lines · Eric Engestrom
Quoted 23 lines · Rob Clark
Quoted 21 lines · Ville Syrjälä
Quoted 20 lines · Rob Clark
Fixes 90844f00049e9f42573fd31d7c32e8fd31d3fd07drm: make
drm_get_format_namethread-safeSigned-off-by Eric Engestrom <[email protected]>[danvet: Clarify that the returned pointer must be freed with
kfree().]Signed-off-by Daniel Vetter <[email protected]>Note: I think we need to be a bit careful about follow-up audits of callers of this.. now that you need to kfree the return value I think it is fairly easy for new patches to introduce new callers which leak the return value. We probably should have left the function as-is and introduce a new variant, or something like that.
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/drm_fourcc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/drm_fourcc.c +0
-0@@ -87,7 +87,10 @@ EXPORT_SYMBOL(drm_mode_legacy_fb_format);Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c EXPORT_SYMBOL(drm_mode_legacy_fb_format); · line 93
Quoted 8 lines
drivers/gpu/drm/drm_fourcc.c +4
-1*/ char *drm_get_format_name (uint32_t format) { -char *buf =kmalloc (32 ,GFP_KERNEL ); +char *buf =kmalloc (32 ,GFP_ATOMIC ); + +if (!buf) +return NULL ;Unrelated bug, thanks for that fix too :)
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
snprintf(buf, 32, "%c%c%c%c %s-endian (0x%08x)",Why aren't we using
kasprintf()?Because I didn't know it was a thing :(
Patch using it incoming.Thanks
Quoted 18 lines
Quoted 10 lines
Quoted 2 lines
Or we could have just made the caller provide the buffer...
I guess
kasprintf()would do the job (although still not address the fact that we still always do the sprintf bits, rather than only doing it when debug logs are enabled).. caller provided buffer would be better. And make it more obvious that something needs to be fixed when merging/rebasing patches that started life before this change landed.Quoted 7 lines
I still kinda like the idea of making vsprintf know about fourcc's with a new format string, and just making
drm_get_format_name()go away.But I don't really have time atm to re-work all the callers of
drm_get_format_name(). So I guess unless someone else does, I'd go w/kasprintf()for now.Quoted 5 lines
That sounds cleaner to me indeed, I'll send a patch doing that tonight. Any idea for the name?
drm_get_format_name_safe(uint32_t, char*)? I could also keep the same name and rely on the function signature change to make sure any merging of the old function call will break the compilation and be noticed that way.Quoted 8 lines
I think if fxn signature changes, we can keep the same name. What I get nervous about is fxn sig+name stays same but semantics change ;-)
btw, if this isn't what you were already planning, I'd suggest:
char *drm_get_format_name(uint32_t, char *);so we can keep it inline w/
DRM_DEBUG_xyz()macros.This was exactly my idea.
Quoted 2 lines
Or maybe something like:
Quoted 7 lines
Quoted 4 lines
typedef char drm_format_name_buf[MAX_SIZE] char *drm_get_format_name(uint32_t, drm_format_name_buf);??
I didn't think of that, but that would avoid mistakes about the size of the buffer. Modifying the code now, I'll send the patch in a few minutes.
I guess it would be worth a double check if gcc could catch the error if someone passes in a too-small buffer, but assuming it does, I think this approach would be simpler/safer than the "make it look like snprintf()" approach.. but if compiler doesn't catch it, maybe it is better to go w/ Ville's approach.
/me hoping at least a modern gcc is clever enough..
BR,
-R
Quoted 2 lines
Cheers,
Eric
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for drm: move allocation out of drm_get_format_name()
In reply to Rob Clark== Series Details ==
== Series Details ==
Series: drm: move allocation out of drm_get_format_name()
URL : https://patchwork.freedesktop.org/series/14873/
State : success
== Summary ==
Series 14873v1 drm: move allocation out of drm_get_format_name()
https://patchwork.freedesktop.org/api/1.0/series/14873/revisions/1/mbox/
Test gem_sync:
Subgroup basic-store-all:
fail -> PASS (fi-hsw-4770r)fi-bdw-5557u total:241 pass:226 dwarn:0 dfail:0 fail:0 skip:15 fi-bsw-n3050 total:241 pass:201 dwarn:0 dfail:0 fail:0 skip:40 fi-bxt-t5700 total:241 pass:213 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-j1900 total:241 pass:213 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-n2820 total:241 pass:209 dwarn:0 dfail:0 fail:0 skip:32 fi-hsw-4770 total:241 pass:221 dwarn:0 dfail:0 fail:0 skip:20 fi-hsw-4770r total:241 pass:221 dwarn:0 dfail:0 fail:0 skip:20 fi-ilk-650 total:241 pass:188 dwarn:0 dfail:0 fail:0 skip:53 fi-ivb-3520m total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-ivb-3770 total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-kbl-7200u total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-skl-6260u total:241 pass:227 dwarn:0 dfail:0 fail:0 skip:14 fi-skl-6700hq total:241 pass:220 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6700k total:241 pass:219 dwarn:1 dfail:0 fail:0 skip:21 fi-skl-6770hq total:241 pass:227 dwarn:0 dfail:0 fail:0 skip:14 fi-snb-2520m total:241 pass:209 dwarn:0 dfail:0 fail:0 skip:32 fi-snb-2600 total:241 pass:208 dwarn:0 dfail:0 fail:0 skip:33
49a651a2e66ef603995f88a470d0986c2ef8b5b8 drm-intel-nightly: 2016y-11m-04d-18h-04m-36s UTC integration manifest 7bc4368 drm: move allocation out of drm_get_format_name()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2912/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: warning for drm: move allocation out of drm_get_format_name() (rev2)
In reply to Rob Clark== Series Details ==
== Series Details ==
Series: drm: move allocation out of drm_get_format_name() (rev2)
URL : https://patchwork.freedesktop.org/series/14873/
State : warning
== Summary ==
Series 14873v2 drm: move allocation out of drm_get_format_name()
https://patchwork.freedesktop.org/api/1.0/series/14873/revisions/2/mbox/
Test drv_module_reload_basic:
pass -> DMESG-WARN (fi-skl-6770hq)
Test gem_sync:
Subgroup basic-store-all:
fail -> PASS (fi-hsw-4770r)
Test kms_force_connector_basic:
Subgroup prune-stale-modes:
pass -> DMESG-WARN (fi-snb-2520m)fi-bdw-5557u total:241 pass:226 dwarn:0 dfail:0 fail:0 skip:15 fi-bsw-n3050 total:241 pass:201 dwarn:0 dfail:0 fail:0 skip:40 fi-bxt-t5700 total:241 pass:213 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-j1900 total:241 pass:213 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-n2820 total:241 pass:209 dwarn:0 dfail:0 fail:0 skip:32 fi-hsw-4770 total:241 pass:221 dwarn:0 dfail:0 fail:0 skip:20 fi-hsw-4770r total:241 pass:221 dwarn:0 dfail:0 fail:0 skip:20 fi-ilk-650 total:241 pass:188 dwarn:0 dfail:0 fail:0 skip:53 fi-ivb-3520m total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-ivb-3770 total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-kbl-7200u total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-skl-6260u total:241 pass:227 dwarn:0 dfail:0 fail:0 skip:14 fi-skl-6700hq total:241 pass:220 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6700k total:241 pass:219 dwarn:1 dfail:0 fail:0 skip:21 fi-skl-6770hq total:241 pass:226 dwarn:1 dfail:0 fail:0 skip:14 fi-snb-2520m total:241 pass:208 dwarn:1 dfail:0 fail:0 skip:32 fi-snb-2600 total:241 pass:208 dwarn:0 dfail:0 fail:0 skip:33
49a651a2e66ef603995f88a470d0986c2ef8b5b8 drm-intel-nightly: 2016y-11m-04d-18h-04m-36s UTC integration manifest 6300c7f drm: move allocation out of drm_get_format_name()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2915/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.BAT: warning for drm: move allocation out of drm_get_format_name() (rev2)
Quoted 6 lines
== Series Details ==
Series: drm: move allocation out of
drm_get_format_name()(rev2)
URL : https://patchwork.freedesktop.org/series/14873/
State : warning
Quoted 7 lines
== Summary ==
Series 14873v2 drm: move allocation out of
drm_get_format_name()
https://patchwork.freedesktop.org/api/1.0/series/14873/revisions/2/mbox/Test
drv_module_reload_basic:pass -> DMESG-WARN (fi-skl-6770hq)
[ 35.972452] [drm:lspcon_init [i915]] *ERROR* Failed to probe lspcon [ 35.972476] [drm:intel_ddi_init [i915]] *ERROR* LSPCON init failed on port B
=> https://bugs.freedesktop.org/show_bug.cgi?id=98353
Quoted 6 lines
Test
gem_sync:Subgroup basic-store-all: fail -> PASS (fi-hsw-4770r) Test kms_force_connector_basic: Subgroup prune-stale-modes: pass -> DMESG-WARN (fi-snb-2520m)
*ERROR* EDID checksum is invalid, remainder is 167 Did we had bug on this?
Quoted 19 lines
fi-bdw-5557u total:241 pass:226 dwarn:0 dfail:0 fail:0 skip:15 fi-bsw-n3050 total:241 pass:201 dwarn:0 dfail:0 fail:0 skip:40 fi-bxt-t5700 total:241 pass:213 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-j1900 total:241 pass:213 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-n2820 total:241 pass:209 dwarn:0 dfail:0 fail:0 skip:32 fi-hsw-4770 total:241 pass:221 dwarn:0 dfail:0 fail:0 skip:20 fi-hsw-4770r total:241 pass:221 dwarn:0 dfail:0 fail:0 skip:20 fi-ilk-650 total:241 pass:188 dwarn:0 dfail:0 fail:0 skip:53 fi-ivb-3520m total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-ivb-3770 total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-kbl-7200u total:241 pass:219 dwarn:0 dfail:0 fail:0 skip:22 fi-skl-6260u total:241 pass:227 dwarn:0 dfail:0 fail:0 skip:14 fi-skl-6700hq total:241 pass:220 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6700k total:241 pass:219 dwarn:1 dfail:0 fail:0 skip:21 fi-skl-6770hq total:241 pass:226 dwarn:1 dfail:0 fail:0 skip:14 fi-snb-2520m total:241 pass:208 dwarn:1 dfail:0 fail:0 skip:32 fi-snb-2600 total:241 pass:208 dwarn:0 dfail:0 fail:0 skip:33
Quoted 7 lines
49a651a2e66ef603995f88a470d0986c2ef8b5b8drm-intel-nightly: 2016y-11m- 04d-18h-04m-36s UTC integration manifest 6300c7f drm: move allocation out ofdrm_get_format_name()== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2915/
Jani Saarinen
Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for drm: move allocation out of drm_get_format_name() (rev3)
In reply to Rob Clark== Series Details ==
== Series Details ==
Series: drm: move allocation out of drm_get_format_name() (rev3)
URL : https://patchwork.freedesktop.org/series/14873/
State : failure
== Summary ==
CC [M] drivers/gpu/drm/i915/dvo_ns2501.o CC [M] drivers/gpu/drm/i915/dvo_sil164.o CC [M] drivers/gpu/drm/i915/dvo_tfp410.o CC [M] drivers/gpu/drm/i915/intel_ddi.o CC [M] drivers/gpu/drm/i915/intel_crt.o CC [M] drivers/gpu/drm/i915/intel_dp_aux_backlight.o LD drivers/tty/serial/8250/8250.o CC [M] drivers/gpu/drm/i915/intel_dp_link_training.o CC [M] drivers/gpu/drm/i915/intel_dp.o CC [M] drivers/gpu/drm/i915/intel_dsi.o CC [M] drivers/gpu/drm/i915/intel_dsi_dcs_backlight.o CC [M] drivers/gpu/drm/i915/intel_dp_mst.o CC [M] drivers/gpu/drm/i915/intel_dsi_panel_vbt.o CC [M] drivers/gpu/drm/i915/intel_dsi_pll.o CC [M] drivers/gpu/drm/i915/intel_dvo.o CC [M] drivers/gpu/drm/i915/intel_i2c.o CC [M] drivers/gpu/drm/i915/intel_hdmi.o CC [M] drivers/gpu/drm/i915/intel_lspcon.o CC [M] drivers/gpu/drm/i915/intel_lvds.o CC [M] drivers/gpu/drm/i915/intel_panel.o CC [M] drivers/gpu/drm/i915/intel_tv.o CC [M] drivers/gpu/drm/i915/intel_sdvo.o CC [M] drivers/gpu/drm/i915/i915_vgpu.o CC [M] drivers/gpu/drm/i915/i915_gpu_error.o LD drivers/acpi/acpica/acpi.o LD lib/zlib_deflate/zlib_deflate.o LD lib/zlib_deflate/built-in.o LD drivers/pci/pcie/aer/aerdriver.o LD drivers/scsi/scsi_mod.o LD drivers/pci/pcie/aer/built-in.o LD drivers/pci/pcie/built-in.o LD [M] drivers/net/ethernet/broadcom/genet/genet.o LD lib/lz4/built-in.o LD drivers/acpi/acpica/built-in.o LD lib/zlib_inflate/zlib_inflate.o LD lib/zlib_inflate/built-in.o LD [M] drivers/gpu/drm/vgem/vgem.o LD net/netlink/built-in.o LD drivers/acpi/built-in.o LD lib/xz/xz_dec.o LD lib/xz/built-in.o LD net/unix/unix.o LD net/unix/built-in.o LD drivers/usb/gadget/libcomposite.o LD drivers/pci/built-in.o LD lib/raid6/raid6_pq.o LD drivers/usb/gadget/udc/udc-core.o LD lib/raid6/built-in.o LD drivers/usb/gadget/udc/built-in.o LD [M] drivers/net/ethernet/intel/igbvf/igbvf.o LD drivers/usb/gadget/built-in.o LD [M] drivers/net/ethernet/intel/e1000/e1000.o LD [M] drivers/misc/mei/mei-me.o LD drivers/scsi/sd_mod.o LD drivers/misc/built-in.o LD drivers/scsi/built-in.o LD net/packet/built-in.o LD drivers/usb/core/usbcore.o LD drivers/tty/serial/8250/8250_base.o LD drivers/tty/serial/8250/built-in.o LD drivers/tty/serial/built-in.o LD drivers/usb/core/built-in.o LD net/ipv6/ipv6.o LD net/ipv6/built-in.o LD drivers/tty/vt/built-in.o LD drivers/tty/built-in.o LD net/xfrm/built-in.o LD drivers/video/console/built-in.o LD drivers/video/built-in.o LD drivers/usb/host/xhci-hcd.o LD fs/btrfs/btrfs.o LD drivers/md/md-mod.o LD drivers/md/built-in.o LD drivers/usb/host/built-in.o CC arch/x86/kernel/cpu/capflags.o LD fs/btrfs/built-in.o LD arch/x86/kernel/cpu/built-in.o LD drivers/usb/built-in.o LD arch/x86/kernel/built-in.o AR lib/lib.a EXPORTS lib/lib-ksyms.o LD lib/built-in.o LD arch/x86/built-in.o LD [M] drivers/net/ethernet/intel/igb/igb.o LD [M] drivers/net/ethernet/intel/e1000e/e1000e.o LD fs/ext4/ext4.o LD fs/ext4/built-in.o LD fs/built-in.o LD net/core/built-in.o LD net/ipv4/built-in.o LD net/built-in.o LD drivers/net/ethernet/built-in.o LD drivers/net/built-in.o LD [M] drivers/gpu/drm/i915/i915.o
scripts/Makefile.build:475: recipe for target 'drivers/gpu/drm' failed make[2]: *** [drivers/gpu/drm] Error 2 scripts/Makefile.build:475: recipe for target 'drivers/gpu' failed make[1]: *** [drivers/gpu] Error 2
Makefile:983: recipe for target 'drivers' failed
make: *** [drivers] Error 2
Full logs at /archive/deploy/logs/Patchwork_2938
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm: move allocation out of drm_get_format_name() (rev4)
In reply to Rob Clark== Series Details ==
== Series Details ==
Series: drm: move allocation out of drm_get_format_name() (rev4)
URL : https://patchwork.freedesktop.org/series/14873/
State : success
== Summary ==
Series 14873v4 drm: move allocation out of drm_get_format_name()
https://patchwork.freedesktop.org/api/1.0/series/14873/revisions/4/mbox/
fi-bdw-5557u total:244 pass:229 dwarn:0 dfail:0 fail:0 skip:15 fi-bsw-n3050 total:244 pass:204 dwarn:0 dfail:0 fail:0 skip:40 fi-bxt-t5700 total:244 pass:216 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-j1900 total:244 pass:216 dwarn:0 dfail:0 fail:0 skip:28 fi-byt-n2820 total:244 pass:212 dwarn:0 dfail:0 fail:0 skip:32 fi-hsw-4770 total:244 pass:224 dwarn:0 dfail:0 fail:0 skip:20 fi-hsw-4770r total:244 pass:224 dwarn:0 dfail:0 fail:0 skip:20 fi-ilk-650 total:244 pass:191 dwarn:0 dfail:0 fail:0 skip:53 fi-ivb-3520m total:244 pass:222 dwarn:0 dfail:0 fail:0 skip:22 fi-ivb-3770 total:244 pass:222 dwarn:0 dfail:0 fail:0 skip:22 fi-skl-6260u total:244 pass:230 dwarn:0 dfail:0 fail:0 skip:14 fi-skl-6700hq total:244 pass:223 dwarn:0 dfail:0 fail:0 skip:21 fi-skl-6700k total:244 pass:222 dwarn:1 dfail:0 fail:0 skip:21 fi-skl-6770hq total:244 pass:230 dwarn:0 dfail:0 fail:0 skip:14 fi-snb-2520m total:244 pass:212 dwarn:0 dfail:0 fail:0 skip:32 fi-snb-2600 total:244 pass:211 dwarn:0 dfail:0 fail:0 skip:33
75c991da15a4f67572515019e4fb8ed292457563 drm-intel-nightly: 2016y-11m-11d-16h-22m-04s UTC integration manifest 3512576 drm: move allocation out of drm_get_format_name()
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_2974/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx