Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752243AbcKGHrN (ORCPT ); Mon, 7 Nov 2016 02:47:13 -0500 Received: from mail-bl2nam02on0070.outbound.protection.outlook.com ([104.47.38.70]:64651 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751991AbcKGHrJ (ORCPT ); Mon, 7 Nov 2016 02:47:09 -0500 X-Greylist: delayed 156047 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 Nov 2016 02:47:09 EST Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Christian.Koenig@amd.com; Subject: Re: [PATCH v2] drm: move allocation out of drm_get_format_name() To: Eric Engestrom , References: <20161107004713.GA26032@engestrom.ch> <20161107004821.25369-1-eric@engestrom.ch> CC: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , "Rob Clark" , Alex Deucher , "David Airlie" , Xinliang Liu , "Daniel Vetter" , Jani Nikula , VMware Graphics , Sinclair Yeh , Thomas Hellstrom , Tom St Denis , =?UTF-8?Q?Michel_D=c3=a4nzer?= , Gustavo Padovan , Emily Deng , Chunming Zhou , "Flora Cui" , Vitaly Prosyak , "Colin Ian King" , Ken Wang , "Alexandre Demers" , Eric Engestrom , Junwei Zhang , Xinwei Kong , Wei Yongjun , Chris Wilson , Laurent Pinchart , , From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <00291917-4818-81a4-b03b-b77cebfe4b2e@amd.com> Date: Mon, 7 Nov 2016 08:46:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161107004821.25369-1-eric@engestrom.ch> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [2a02:908:1251:7981:7912:6941:cf2f:a396] X-ClientProxiedBy: VI1PR07CA0071.eurprd07.prod.outlook.com (10.164.94.167) To BN6PR12MB1298.namprd12.prod.outlook.com (10.168.227.148) X-MS-Office365-Filtering-Correlation-Id: fc2d4693-5f60-47b6-1fca-08d406e2456e X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;2:Z4NqgqE/nzYaD3K1c4f2sMOgxgE5QUgq5pK/vTHBUphT15VTyM5zmVFmUVreQjeAg8R69C+XP4pUboie8BBBeR5wAAO9X/wihj4YGh4aaluqHZcHd/ALUJEXmJfCd6vstWrnfjg49AR1oUwW1ENPHQZld9ss6kTigRIH42RMcgC41+XAkYsRaAeCR1RsrIEr2iujr89bF3nHzgtn4X2XOw==;3:3M5Ff0AqYmGVPIHg7nVpO33A8RvhJ7/dcZ7NyfUtq3T6AkUiYS6AdKCwIepWPq1quIZjehWw0kcZEEI9cwIQ6hiyMoTjnPSM9gpVLWXcmN7hvDfINcCCEJsFFztyu24C94qWHkQp6kmOWijt1qbdug==;25:R03fqskDqF2bajV6mH5eSgAjRjVT6K9fo2hWwyk1ckdJhRX+3efOHC+VCJpgXa7Nl45S0PgzGg0HbUI8ihG3n/CDjOmKsvlw+Yaui2+ntR3RCQ28y/VdraF4rCPFR7f+2WA0ti134SX1IHjR3lo6YuT8ey7wdRJQE+W1+koAHHZ/9HNG6/yFfnELeaCGsJI6WkQyS0RxJ2P3kp7tEZ7NI8A2U2WJpnLv8ZwiE8BNahl4m8DonSg3261s0CWdIIVrjhlN/aQm9HUeC2RstRIXy5UUR64JA/HlNsGYel9/gAXSsyJrXqX86ZPNekEM17qVNEoanSsRbN/+G4bwQiSAc+oBDEpJRcseqINPYcFtufvuBYN09CEBc2Wl1Fqskb1Vb6dxLOgrJ+gdXsLuVNKBaeg51QXn4rrFd3m/HGCxrwc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN6PR12MB1298; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;31:jVVxOWDTsPTeaNw0cKk1b1B/rZoKqrK6dG2oEkIReRS4i+1c7Rwekufp+6JGtMy15cFYd7RH160EC+rgGFYIf6laciJWsd7leWVFGknrv9ApeyItvFeh4yWWFWR7ddpra9BcIs5OR7qBs9GhFM/Hm0IxDLAi57kkYyUFj/tp/sv9yuDQIcucsywn9o2emZcD4MmrxEg5ZEZfTopYm7955h/c9QynqztdhTqm/iyuQNZzOuLM/mlPtIKY5icvJSXH;20:abbnSZpOyKHRiSQIZOFBWgfZx8ngcqICcQyeGop2plnTyJi11wvcGd3gSiB30UtBzX4R48q/NuGU5QCVxK9Vwe0GfdBf0r81GGjCiwvKYq1rvlpeLZm/qBO1NsgXsyUZOV4MCTUddX+bTVSu13MeExchQTn7pRjCoo6eryp1cO+PXvWQsbJt4e2Uqq0akvbxpUYwBj0c97iBq+mefzpfWE7cxo4t1DcdPS8pU6p8ihs8Q+E/5uZp5zPAt1DfHHJnB3q3VJQd+i6KtlI5TXbjTgh2wsyLYJ6nb1NUYAtnxHH1wy9sJcDBAG6c1N+cw6XZ+tuqYbB88YfIofKbF+nxVSmk2LQu1TJijbpKJ8z/rw+mE5HM92byPMY92Yq9u7+So2Py4TwsbNUp3sqZRJXQU9M1bxNP658veIYq8QfmXKW6z9vXj9kxa2EWHJOGVHcFZUWzuNf2k5HO2srdm6RbEI5wYTMkcqzWnPgkYXLwiNKeZH7TWAR5tgYlxABQx71v X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:BN6PR12MB1298;BCL:0;PCL:0;RULEID:;SRVR:BN6PR12MB1298; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1298;4:mDJFa5L5lY9B9ng7yzYHXfxLXZMvPZI5pf64fzZqup/ZqeRBx8LhIT6dgbrXKZWlEWLLGu/c8nRBEqXCjwwrw/MrfB65fkvOj71R61T+TVGewl3KXEy8sYIJOUhb/xWX8eyQYjHFdJ9GEii5wR5TNMByk3n3jd6kIMmC44GYZDSfoJJng5wgze9iQmy0cb443Xv2/bWOxmQZX2TP9DqJJGeEd2yHHbMMJcKrhlyKsU/vMWpbMyZy3lTHMJQiEnQtoplxLnY4b9LVvMwPjYeHfwoiIFCmUGW20rKTe9/jK56pachcvJNa5ieYNi6UPZADrUNd7IJvYO2UcOACQ3JsUYCuZ47n97Omuc+wnYjyN6ybEu8GGSpljwppy7gOLqYLYAaANrKo5gs8pk36gMatPEfjW0PWO2IrY+SzvzgtEZ/Tq37Zufcfcu28+rmshjRocaK9IO4jmeykm1FKgkC2njmY6gbzK2Gu924sR/Y9ClqUAPbft3CtR+kQgtlbfVje X-Forefront-PRVS: 0119DC3B5E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(23676002)(189998001)(8676002)(50466002)(586003)(65956001)(81156014)(81166006)(65806001)(77096005)(47776003)(7416002)(33646002)(7736002)(7846002)(2950100002)(6666003)(5001770100001)(4001350100001)(97736004)(65826007)(36756003)(5660300001)(2870700001)(64126003)(31686004)(42186005)(83506001)(2906002)(19580395003)(19580405001)(68736007)(101416001)(4326007)(105586002)(305945005)(575784001)(31696002)(86362001)(76176999)(54356999)(92566002)(106356001)(1706002)(6116002)(50986999);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1298;H:[IPv6:2a02:908:1251:7981:7912:6941:cf2f:a396];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMjk4OzIzOk1abTNEbzNBamlNZTgzWnZ6b3hrTmo2WHRV?= =?utf-8?B?MUdINUJLTCs3K2dzNWU5YlNSMXNHaVk1SmdPM3ZUZFhBSFAweDM3Tmpiak5C?= =?utf-8?B?WUxWVU1SYlhHajRnQ0UwSTRSZjMvbzFIejhhUnh3aWZjTzRBZlhiUFZDdUMx?= =?utf-8?B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riginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2016 07:47:02.0196 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1298 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 22854 Lines: 552 Am 07.11.2016 um 01:48 schrieb Eric Engestrom: > Fixes: 90844f00049e9f42573fd31d7c32e8fd31d3fd07 > > drm: make drm_get_format_name thread-safe > > Signed-off-by: Eric Engestrom > [danvet: Clarify that the returned pointer must be freed with > kfree().] > Signed-off-by: Daniel Vetter > > Cc: Rob Clark > Cc: Christian König > Suggested-by: Ville Syrjälä > Signed-off-by: Eric Engestrom Acked-by: Christian König . > --- > > 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(-) > > diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h > index dc0aafa..4b03ca0 100644 > --- a/include/drm/drm_fourcc.h > +++ b/include/drm/drm_fourcc.h > @@ -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__ */ > diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c > index cbb8b77..99b0b60 100644 > --- a/drivers/gpu/drm/drm_fourcc.c > +++ b/drivers/gpu/drm/drm_fourcc.c > @@ -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); > > diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c > index 199d3f7..2924cdd 100644 > --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c > index ecd000e..f0e3c5c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c > index 44547f9..5c6b82f 100644 > --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c > index 979aedf..5aef19d 100644 > --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c > +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index c32fb3c..f29d3c5 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c > index 13441e2..08ac216 100644 > --- a/drivers/gpu/drm/drm_crtc.c > +++ b/drivers/gpu/drm/drm_crtc.c > @@ -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; > } > } > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c > index 49fd7db..df6b180 100644 > --- a/drivers/gpu/drm/drm_framebuffer.c > +++ b/drivers/gpu/drm/drm_framebuffer.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c > index 2544dfe..2f452b3 100644 > --- a/drivers/gpu/drm/drm_modeset_helper.c > +++ b/drivers/gpu/drm/drm_modeset_helper.c > @@ -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; > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c > index 249c0ae..2ba0c22 100644 > --- a/drivers/gpu/drm/drm_plane.c > +++ b/drivers/gpu/drm/drm_plane.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c > index 7e7a4d4..afc2b5d 100644 > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c > @@ -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); > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c > index 20638d2..670423e 100644 > --- a/drivers/gpu/drm/i915/i915_debugfs.c > +++ b/drivers/gpu/drm/i915/i915_debugfs.c > @@ -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); > } > } > > diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c > index c762ae5..6c76e3d 100644 > --- a/drivers/gpu/drm/i915/intel_atomic_plane.c > +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c > @@ -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: > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c > index 6f8f6ec..8209170 100644 > --- a/drivers/gpu/drm/i915/intel_display.c > +++ b/drivers/gpu/drm/i915/intel_display.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c > index 74f99ba..05f4ebe 100644 > --- a/drivers/gpu/drm/radeon/atombios_crtc.c > +++ b/drivers/gpu/drm/radeon/atombios_crtc.c > @@ -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; > } > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c > index c965514..e3f68cc 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c > @@ -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); > } >