From: Eugen Hristev <eugen.hristev@linaro.org>
To: Stephen Boyd <sboyd@kernel.org>, linux-arm-msm@vger.kernel.org
Cc: andersson@kernel.org, konradybcio@kernel.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
linux-pm@vger.kernel.org, djakov@kernel.org,
mturquette@baylibre.com, evgreen@chromium.org
Subject: Re: [PATCH v2] soc: qcom: Rework BCM_TCS_CMD macro
Date: Mon, 11 Nov 2024 15:05:02 +0200 [thread overview]
Message-ID: <14689f79-58fd-4be3-87ac-e56cba3deb26@linaro.org> (raw)
In-Reply-To: <e6637dcc85ca23efaf72af906f364328.sboyd@kernel.org>
On 11/8/24 21:00, Stephen Boyd wrote:
> Quoting Eugen Hristev (2024-10-30 01:28:14)
>> On 10/30/24 02:40, Stephen Boyd wrote:
>>>
>>> If the rpmh-rsc code didn't use writel() or readl() I'd believe
>>> that the data member is simply a u32 container. But those
>>> writel() and readl() functions are doing a byte swap, which
>>> seems to imply that the data member is a native CPU endian u32
>>> that needs to be converted to little-endian. Sounds like
>>> BCM_TCS_CMD() should just pack things into a u32 and we can
>>> simply remove the cpu_to_l32() stuff in the macro?
>>
>> This review [1] from Evan Green on the original patch submission
>> requested the use of cpu_to_le32
>>
>> So that's how it ended up there.
>>
>
> Thanks. I still don't see why this can't just be treated as a u32
> and then we have writel() take care of it for us.
If the values are in the wrong endianness, e.g. 0xff11 instead of
0x11ff, the corresponding field would be filled up wrongly, even
possibly writing unwanted bits. vote_x and vote_y have a mask of length
14, so there is one byte and another 6 more bits. If the endianness of
the value is not correct, the one byte might end up written over the 6
bits and 2 extra bits which are supposed to be for another field.
In my example 0x11 should be in the first 6 bits and the 0xff in the
next byte, but if the endianness of the cpu is different, we might write
0xff on the 6 bit field.
So we must ensure that the multi-byte fields are in the correct
endianness that the hardware expects.
In other words, writel does not know about the multi-byte fields inside
this u32 which have a specific bit shift, and those fields are expected
to be in le32 order written to the hardware. Whether or not the cpu is
le32 is not important because using cpu_to_le32 will make it safe either
way.
I apologize for my not so great explanation
next prev parent reply other threads:[~2024-11-11 13:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 16:34 [PATCH v2] soc: qcom: Rework BCM_TCS_CMD macro Eugen Hristev
2024-10-28 17:56 ` Stephen Boyd
2024-10-29 13:12 ` Eugen Hristev
2024-10-30 0:40 ` Stephen Boyd
2024-10-30 8:28 ` Eugen Hristev
2024-11-08 19:00 ` Stephen Boyd
2024-11-11 13:05 ` Eugen Hristev [this message]
2024-11-19 23:32 ` Stephen Boyd
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=14689f79-58fd-4be3-87ac-e56cba3deb26@linaro.org \
--to=eugen.hristev@linaro.org \
--cc=andersson@kernel.org \
--cc=djakov@kernel.org \
--cc=evgreen@chromium.org \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.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