public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail•com>
To: "Marek Behún" <kabel@kernel•org>
Cc: "David S. Miller" <davem@davemloft•net>,
	Paolo Abeni <pabeni@redhat•com>,
	netdev@vger•kernel.org
Subject: Re: [PATCH net v2 1/2] net: dsa: qca8k: fix regmap bulk read/write methods on big endian systems
Date: Thu, 5 Oct 2023 12:48:45 +0200	[thread overview]
Message-ID: <651e948f.1c0a0220.e602c.04aa@mx.google.com> (raw)
In-Reply-To: <20231004091904.16586-2-kabel@kernel.org>

On Wed, Oct 04, 2023 at 11:19:03AM +0200, Marek Behún wrote:
> Commit c766e077d927 ("net: dsa: qca8k: convert to regmap read/write
> API") introduced bulk read/write methods to qca8k's regmap.
> 
> The regmap bulk read/write methods get the register address in a buffer
> passed as a void pointer parameter (the same buffer contains also the
> read/written values). The register address occupies only as many bytes
> as it requires at the beginning of this buffer. For example if the
> .reg_bits member in regmap_config is 16 (as is the case for this
> driver), the register address occupies only the first 2 bytes in this
> buffer, so it can be cast to u16.
> 
> But the original commit implementing these bulk read/write methods cast
> the buffer to u32:
>   u32 reg = *(u32 *)reg_buf & U16_MAX;
> taking the first 4 bytes. This works on little endian systems where the
> first 2 bytes of the buffer correspond to the low 16-bits, but it
> obviously cannot work on big endian systems.
> 
> Fix this by casting the beginning of the buffer to u16 as
>    u32 reg = *(u16 *)reg_buf;
> 
> Fixes: c766e077d927 ("net: dsa: qca8k: convert to regmap read/write API")
> Signed-off-by: Marek Behún <kabel@kernel•org>

Just find time to test this on a friend's big-endian device and can confirm
this fix the problem. Thanks!

Tested-by: Christian Marangi <ansuelsmth@gmail•com>
Reviewed-by: Christian Marangi <ansuelsmth@gmail•com>

-- 
	Ansuel

  reply	other threads:[~2023-10-05 10:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04  9:19 [PATCH net v2 0/2] net: dsa: qca8k: fix qca8k driver for Turris 1.x Marek Behún
2023-10-04  9:19 ` [PATCH net v2 1/2] net: dsa: qca8k: fix regmap bulk read/write methods on big endian systems Marek Behún
2023-10-05 10:48   ` Christian Marangi [this message]
2023-10-04  9:19 ` [PATCH net v2 2/2] net: dsa: qca8k: fix potential MDIO bus conflict when accessing internal PHYs via management frames Marek Behún
2023-10-05 10:49   ` Christian Marangi
2023-10-06 10:50 ` [PATCH net v2 0/2] net: dsa: qca8k: fix qca8k driver for Turris 1.x patchwork-bot+netdevbpf

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=651e948f.1c0a0220.e602c.04aa@mx.google.com \
    --to=ansuelsmth@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=kabel@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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