Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933037AbcKGSMq (ORCPT ); Mon, 7 Nov 2016 13:12:46 -0500 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:25756 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932526AbcKGSMl (ORCPT ); Mon, 7 Nov 2016 13:12:41 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=syeh@vmware.com; Date: Mon, 7 Nov 2016 10:12:21 -0800 From: Sinclair Yeh To: Eric Engestrom CC: , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Rob Clark , Christian =?iso-8859-1?Q?K=F6nig?= , Alex Deucher , David Airlie , Xinliang Liu , Daniel Vetter , "Jani Nikula" , VMware Graphics , Thomas Hellstrom , Tom St Denis , Michel =?iso-8859-1?Q?D=E4nzer?= , 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 , , Subject: Re: [PATCH v2] drm: move allocation out of drm_get_format_name() Message-ID: <20161107181221.GA15287@promb-2n-dhcp72.eng.vmware.com> References: <20161107004713.GA26032@engestrom.ch> <20161107004821.25369-1-eric@engestrom.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161107004821.25369-1-eric@engestrom.ch> User-Agent: Mutt/1.6.1 (2016-04-27) X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: MWHPR19CA0007.namprd19.prod.outlook.com (10.173.246.145) To DM5PR05MB3243.namprd05.prod.outlook.com (10.173.220.9) X-MS-Office365-Filtering-Correlation-Id: 9a01fb87-27b2-4c14-296c-08d40739a64e X-Microsoft-Exchange-Diagnostics: 1;DM5PR05MB3243;2:MQIojBaM6aLFvnTWovpUWEU6N2b1xViIqttxo4Db8umuQ8xFuydkD8zPojLVq2068+LpAxQMujyhRI+PPFDJgK9gBjL20J7MRyPQEGY6Ecztajvwd3cf/7flfBiGxcOhqa8EZJmYlq7PR3TlxmpG85noOw/fX/H2k/NHpaidBHT8KGdwxM3fs2MZkiGjHiMxAepxBkDoYz3mWQf6YQmhBg==;3:6C7H/g6xS3QOFBC+i5gF/tK3wcO4sKfpYZZxnN6IfG4M8/zgdqzhsQTbHw7cSIsIF3qR6B4qBLQvsYy8JMKVhnAb+yHNJnOgidqqdZ6LEtKvDWiw/Y5VbC/Xqd3IRGonKrv9rX8IihNyyUqYGAiJuA==;25:Nga1NhOuDbVRt7BoFuD8dGKewyi/5AnaMMf11Wvvzf1s35H/ctHNl+ubWQTnx9DAQJyy+3t5Rpnv8hbI30HTwq4LSbfjPVGBxwa8S9PXorDlVMmk8lbaM19/ISnz72+js0L6uGKqCc6oelXiQMNrd2Co5kPTGfOqNNMr79HVeBxYYY7ERnrTtgTG5SDbaXyXanUf/ItVpOrWq6zbheCaLMuWqyf8JoeoqlJHogKXFmlEFhdfn7kLhGiT/NrB7g04Jzdz81lVMoOcLRg09xBSWNYauW9WGssOQknDUtfvsEQ1XzBy7CodjtbBiZZognP6py2QNPFa5Dt3ugmvDaGeuLVD5eiKTeOPJ2yF9yvPhXU1+oySTAYN8IubrtQJkAx4Krw4JwA6d6IUbBggSg8JezIdMaY4/ZnsXlyvoXffSf4= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM5PR05MB3243; X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;DM5PR05MB3243;31:5ugd3glYhbGvT+kPxOlbM9wgmskTyqyJsiocnde07B3blGzk+nxDyMBsXkshUkRP+kufOSmDn9rgx6axwJvMwjEOA9eX4hccwDqNBgwncw33U0fFdq0a8P70+BJRVsfQI/Ut87akZ7QN2cmyWjLS03lBmGVXmE//PpA/U1DIc0908nRnR/oYXY/o333Fp2YdTZbCOP/0nPAB1fAFmCQMMYDF1mLVsyFBAggBr1N1Qf//Gf03M5GBP3rYoX1KSO8dVCyxnJGh1M2NGJmg16Xpfg==;20:Vm7yFwq8Q9GqsJFze7+DB/npS80n+UkOuPKKMFovMK9sIPMYl6RbkmwUXOJIFoX/p8sLF3egxFJyF4IrHYw3D3oSH4lM2eUAZIOCNt01N6Pi4I/vJ0YlC80H91N2vp5QMfvm8MAmMw0LazHJ+OuiJXV5hvrThL3uPE17HOa0F/DrA7aXDJwf14jKlHSMqWge6RSKnQ2f0tBdq8w8YuEfSVQyKGNMjUpMRaS2SOl/l4RoRJd5Z+XyIHr7pbqZFmqmmc9T89nxX5usoUtWN+P5HsYfcE9lYs+Mo/UaXpizNNXjhOFgM68OmLVtTeZCd03RzAGEZKbXPalg7yJcAEHVSreKdAomiIqy5s0tJRAAj5a3JdacnKRtI72BCXk+LeZVq7nG+osQQBAhVHCIsJGKpbPw5YXtw2jPKTm1jDcH2pb26Tkw1M9VK8ZxRXITXq4C0EnWjbRmShqx0d58U9qyZF164L8ZbVNshqACFabQJ1tlPDYzBt0je9D21TVr8wyG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150)(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:DM5PR05MB3243;BCL:0;PCL:0;RULEID:;SRVR:DM5PR05MB3243; X-Microsoft-Exchange-Diagnostics: 1;DM5PR05MB3243;4:aIr2dSPqo5Ynv5Rh4+9eUORnEGqnq66D2DpDcNVSZIyvfmqF71uQnbBVieVme6dgKgCneg2Wi2E+STPmbzHkrv9m4CzhBeJCm1YhtLVzn1KLVGUGWaL4UdWQBVRi7ONkYNcjroJ1Q2cGyWazNm7gwvY1RepajDNI++JupLfnUS12INf6SE1/5Tpn+Km0SM9f+ErvnQk5dO1QpnkJZFvNiPCvjAznJMNTfYtlEClpeENfWNykqGTK1mR97GuxgGOsN+XJZVZDuc+egxaLPW5VqdeY1yMhB+F79MKO/fLVJRO9kOPQPLJdFYoSrH1lCSo63s4g3R7xLsECaA0dTe8Xd+unJ0oSHekn2+tr2pPj3E8VpHnsyGs7XObmtUXsjPC0hGi1oDvahGDCiXSw/P7TpVcn6DDMbYp8W7ElsN6xfDFK7Ph9h2tYRNltU8gZEwfqjos2k9aYsNPGfn/LvlwPpgPkE7svjexTB4wxmSc6r8dR6ehDdcbUD9jpQ86ISuxw X-Forefront-PRVS: 0119DC3B5E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(24454002)(42186005)(77096005)(2906002)(8666005)(106356001)(2870700001)(110136003)(1076002)(83506001)(105586002)(6116002)(586003)(3846002)(47776003)(4326007)(5660300001)(66066001)(92566002)(2950100002)(6916009)(6666003)(81166006)(81156014)(8676002)(33656002)(7416002)(54356999)(23756003)(50466002)(86362001)(575784001)(101416001)(4001350100001)(97736004)(76176999)(50986999)(68736007)(305945005)(189998001)(7846002)(7736002)(19580405001)(19580395003)(7099028)(18370500001)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR05MB3243;H:promb-2n-dhcp72.eng.vmware.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;DM5PR05MB3243;23:rTBu5kAaVhXifUqj4Ecml8psSheRyzyjzVVDAm7?= =?iso-8859-1?Q?82DinfXd+lY1cO1/QqE6GT/84w0LzT2IERMhd9e/IQ8bibVU+Bb7baeesa?= =?iso-8859-1?Q?DcRjPXxm14dkxmGlhqUQ3Rn8EYXw2TT5ay2HUH6dURAG3YLNQQM15QeL3D?= =?iso-8859-1?Q?dAywd8sgt7g0BiLER3O1gPDAIog9qUWOK1Q3DjBRrGmzEbC3mdBgiZqkp6?= =?iso-8859-1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V4fRCp1+bPROUN6mdkC5w8HgQ1J30CX31OQK3/vBZIbCYbX3X1r49Tvhq45S3pqyxxroDdr0mpnx7nztOJIdx5KaWI1KxrWC9+3xSPT6v0Pq5FUAgTOzd58S/XY4LE4i+fSW7VrwqxtlrfEvKfY2WTMfVEkrSRdnsUiycbzIPs4oMK01A9JZ0yMkF2uZk3LhEwlhUjaTL7PJygl+kON+RHLqhoH4R20irX4gFPRdV9Jf3pfr0YTnSwelROIRdgZq39KUHibeCsbY=;20:hVr+oRCf9ESAFcbVtVDxhLfJYMngzOuN2jFLX0a8ziZhIKqfUiDMDJHhymKmt/iFQYdVy4lccLzLlkMANJLmdSpvcXnrcpVW3uobTcwm/BRIMXlCtzVc2BQ8X36GUysedXLXYPi7Np3eh/TLvZu4ZgPJ8c/uwe+sZEcH2Xbdugs= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2016 18:12:32.6893 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR05MB3243 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 22728 Lines: 558 Thomas has already acked the earlier version, but in case you need it for this one, too. vmwgfx portion: Acked-by: Sinclair Yeh On Mon, Nov 07, 2016 at 12:48:09AM +0000, Eric Engestrom wrote: > 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 > --- > > 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); > } > > -- > Cheers, > Eric >