[PATCH 1/3] drm/dsi: use stack buffer in mipi_dsi_dcs_write()
Thierry Reding
treding at nvidia.com
Fri Jun 5 17:26:38 UTC 2020
On Tue, May 05, 2020 at 05:03:27PM +0100, Emil Velikov wrote:
> Currently the function heap allocates when we have any payload. Where in
> many case the payload is 1 byte - ouch.
>
> From casual observation, vast majority of the payloads are smaller than
> 8 bytes - so use a stack array tx[8] to avoid the senseless kmalloc and
> kfree dance.
>
> Cc: Jani Nikula <jani.nikula at intel.com>
> Cc: Thierry Reding <treding at nvidia.com>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
> drivers/gpu/drm/drm_mipi_dsi.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 55531895dde6..b96d5b4629d7 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -748,26 +748,26 @@ ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
> {
> ssize_t err;
> size_t size;
> + u8 stack_tx[8];
> u8 *tx;
>
> - if (len > 0) {
> - size = 1 + len;
> -
> + size = 1 + len;
> + if (len > ARRAY_SIZE(stack_tx) - 1) {
I think it would be clearer to do:
if (size > ARRAY_SIZE(stack_tx))
but either way:
Reviewed-by: Thierry Reding <treding at nvidia.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20200605/c8e12f66/attachment.sig>
More information about the dri-devel
mailing list