dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <treding@nvidia.com>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Jani Nikula <jani.nikula@intel.com>,
	ML dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 1/3] drm/dsi: use stack buffer in mipi_dsi_dcs_write()
Date: Fri, 5 Jun 2020 19:37:50 +0200	[thread overview]
Message-ID: <20200605173750.GC1265773@ulmo> (raw)
In-Reply-To: <CACvgo53nBpP_cHp=kvBQJnCacdqPfOVxbTf1_x=KhiCyNzbWuQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2277 bytes --]

On Thu, May 28, 2020 at 05:47:41PM +0100, Emil Velikov wrote:
> On Tue, 5 May 2020 at 17:05, Emil Velikov <emil.l.velikov@gmail.com> 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@intel.com>
> > Cc: Thierry Reding <treding@nvidia.com>
> > Signed-off-by: Emil Velikov <emil.velikov@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) {
> >                 tx = kmalloc(size, GFP_KERNEL);
> >                 if (!tx)
> >                         return -ENOMEM;
> > -
> > -               /* concatenate the DCS command byte and the payload */
> > -               tx[0] = cmd;
> > -               memcpy(&tx[1], data, len);
> >         } else {
> > -               tx = &cmd;
> > -               size = 1;
> > +               tx = stack_tx;
> >         }
> >
> > +       /* concatenate the DCS command byte and the payload */
> > +       tx[0] = cmd;
> > +       if (data)
> > +               memcpy(&tx[1], data, len);
> > +
> >         err = mipi_dsi_dcs_write_buffer(dsi, tx, size);
> >
> > -       if (len > 0)
> > +       if (tx != stack_tx)
> >                 kfree(tx);
> >
> >         return err;
> > --
> 
> Thierry, others - humble ping.
> Can you check through the series?

I don't see patch 2 of this series anywhere? Did it fall victim to some
filter?

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-06-05 17:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 16:03 [PATCH 1/3] drm/dsi: use stack buffer in mipi_dsi_dcs_write() Emil Velikov
2020-05-05 16:03 ` [PATCH 2/3] drm/panel: use mipi_dsi_dcs_write_buffer where possible Emil Velikov
2020-05-11 11:28   ` Emil Velikov
2020-06-29  7:46     ` Sam Ravnborg
2020-05-05 16:03 ` [PATCH 3/3] drm/mipi: use dcs write for mipi_dsi_dcs_set_tear_scanline Emil Velikov
2020-05-07 12:29   ` Vinay Simha B N
2020-05-07 16:18     ` Emil Velikov
2020-05-13  9:44       ` Emil Velikov
2020-06-07 16:17         ` Vinay Simha B N
2020-06-05 17:36   ` Thierry Reding
2020-06-29  7:47   ` Sam Ravnborg
2020-05-28 16:47 ` [PATCH 1/3] drm/dsi: use stack buffer in mipi_dsi_dcs_write() Emil Velikov
2020-06-05 17:37   ` Thierry Reding [this message]
2020-06-05 17:26 ` Thierry Reding
2020-06-29  7:46 ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200605173750.GC1265773@ulmo \
    --to=treding@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=jani.nikula@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox