From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: "Linux Kernel" <linux-kernel@vger.kernel.org>,
"Sameer Nanda" <snanda@chromium.org>,
"Benson Leung" <bleung@chromium.org>,
"Enric Balletbò" <enric.balletbo@collabora.co.uk>,
"Vic Yang" <victoryang@chromium.org>,
"Vincent Palatin" <vpalatin@chromium.org>,
"Randall Spangler" <rspangler@chromium.org>,
"Gwendal Grignou" <gwendal@chromium.org>,
"Vic Yang" <victoryang@google.com>,
"Olof Johansson" <olof@lixom.net>,
linux-input@vger.kernel.org,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Lee Jones" <lee.jones@linaro.org>
Subject: Re: [PATCH v1 2/6] mfd: cros_ec: Add MKBP event support
Date: Thu, 11 Feb 2016 15:52:33 +0100 [thread overview]
Message-ID: <56BCA031.3010702@collabora.com> (raw)
In-Reply-To: <CAMHSBOXRvC7U_KWeg+rX3Qymaos0-3FN6AuaXT2cyP=gAN47mA@mail.gmail.com>
On 02/05/2016 06:24 PM, Gwendal Grignou wrote:
> We should not used kmalloc when get events, these functions are called
> quite often.
> Gwendal.
>
> On Fri, Feb 5, 2016 at 5:32 AM, Tomeu Vizoso <tomeu.vizoso@collabora.com
> <mailto:tomeu.vizoso@collabora.com>> wrote:
>
> +static int cros_ec_get_host_command_version_mask(struct
> cros_ec_device *ec_dev,
> + u16 cmd, u32 *mask)
> +{
> + struct ec_params_get_cmd_versions *pver;
> + struct ec_response_get_cmd_versions *rver;
> + struct cros_ec_command *msg;
> + int ret;
> +
> + msg = kmalloc(sizeof(*msg) + max(sizeof(rver), sizeof(pver)),
> + GFP_KERNEL);
> + if (!msg)
> + return -ENOMEM;
>
> Victor's version in https://chromium-review.googlesource.com/272954
> looks cleaner: no malloc, no need to cast rver.
I agree that it looks cleaner, but how would you allocate the payload at
build time if it has to be max(sizeof(*pver), sizeof(*rver))?
> +static int get_next_event(struct cros_ec_device *ec_dev)
> +{
> + struct cros_ec_command *msg;
> + int ret;
> +
> + msg = kmalloc(sizeof(*msg) + sizeof(ec_dev->event_data),
> GFP_KERNEL);
> + if (!msg)
> + return -ENOMEM;
>
> Same grip about malloc(). This function will be called very often when
> sensors are used.
Ok.
> +static int get_keyboard_state_event(struct cros_ec_device *ec_dev)
> +{
> + struct cros_ec_command *msg;
> +
> + msg = kmalloc(sizeof(*msg) + sizeof(ec_dev->event_data.data),
> + GFP_KERNEL);
> + if (!msg)
> + return -ENOMEM;
>
> Given this command will be used on every key press, it is better to
> pre-allocate data (like
> in https://chromium-review.googlesource.com/276768) and use msg on the
> stack like Victor's changes.
Ok.
Thanks,
Tomeu
next prev parent reply other threads:[~2016-02-11 14:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 13:32 [PATCH v1 0/6] EC-based USB Power Delivery support for Chrome machines Tomeu Vizoso
2016-02-05 13:32 ` [PATCH v1 2/6] mfd: cros_ec: Add MKBP event support Tomeu Vizoso
2016-02-10 17:41 ` Gwendal Grignou
2016-02-11 9:15 ` Lee Jones
[not found] ` <CAMHSBOXRvC7U_KWeg+rX3Qymaos0-3FN6AuaXT2cyP=gAN47mA@mail.gmail.com>
2016-02-11 14:52 ` Tomeu Vizoso [this message]
2016-02-11 18:49 ` Gwendal Grignou
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=56BCA031.3010702@collabora.com \
--to=tomeu.vizoso@collabora.com \
--cc=bleung@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=enric.balletbo@collabora.co.uk \
--cc=gwendal@chromium.org \
--cc=lee.jones@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=rspangler@chromium.org \
--cc=snanda@chromium.org \
--cc=victoryang@chromium.org \
--cc=victoryang@google.com \
--cc=vpalatin@chromium.org \
/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;
as well as URLs for NNTP newsgroup(s).