linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Loic Poulain <loic.poulain@linaro.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Kalle Valo <kvalo@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next] wifi: wcn36xx: Slightly optimize PREPARE_HAL_BUF()
Date: Sun, 5 Feb 2023 14:18:07 +0100	[thread overview]
Message-ID: <CAMZdPi-hUyorX6N-3koxOZ+gSxovdQc7iKxx7wuN+qJek_cvCA@mail.gmail.com> (raw)
In-Reply-To: <7d8ab7fee45222cdbaf80c507525f2d3941587c1.1675371372.git.christophe.jaillet@wanadoo.fr>

On Thu, 2 Feb 2023 at 21:58, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> In most (likely all) cases, INIT_HAL_MSG() is called before
> PREPARE_HAL_BUF().
> In such cases calling memset() is useless because:
>    msg_body.header.len = sizeof(msg_body)
>
> So, instead of writing twice the memory, we just have a sanity check to
> make sure that some potential trailing memory is zeroed.
> It even gives the opportunity to see that by itself and optimize it away.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Loic Poulain <loic.poulain@linaro.org>



> ---
>  drivers/net/wireless/ath/wcn36xx/smd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
> index 566f0b9c1584..17e1919d1cd8 100644
> --- a/drivers/net/wireless/ath/wcn36xx/smd.c
> +++ b/drivers/net/wireless/ath/wcn36xx/smd.c
> @@ -475,8 +475,8 @@ static int wcn36xx_smd_send_and_wait(struct wcn36xx *wcn, size_t len)
>
>  #define PREPARE_HAL_BUF(send_buf, msg_body) \
>         do {                                                    \
> -               memset(send_buf, 0, msg_body.header.len);       \
> -               memcpy(send_buf, &msg_body, sizeof(msg_body));  \
> +               memcpy_and_pad(send_buf, msg_body.header.len,   \
> +                              &msg_body, sizeof(msg_body), 0); \
>         } while (0)                                             \
>
>  #define PREPARE_HAL_PTT_MSG_BUF(send_buf, p_msg_body) \
> --
> 2.34.1
>

  reply	other threads:[~2023-02-05 13:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 20:58 [PATCH net-next] wifi: wcn36xx: Slightly optimize PREPARE_HAL_BUF() Christophe JAILLET
2023-02-05 13:18 ` Loic Poulain [this message]
2023-02-24 10:22 ` Kalle Valo

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=CAMZdPi-hUyorX6N-3koxOZ+gSxovdQc7iKxx7wuN+qJek_cvCA@mail.gmail.com \
    --to=loic.poulain@linaro.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wcn36xx@lists.infradead.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).