From: Alex Elder <elder@linaro.org>
To: Amy Parker <enbyamy@gmail.com>
Cc: davem@davemloft.net, kuba@kernel.org, elder@kernel.org,
evgreen@chromium.org, bjorn.andersson@linaro.org,
cpratapa@codeaurora.org, subashab@codeaurora.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/4] net: ipa: use the right accessor in ipa_endpoint_status_skip()
Date: Mon, 1 Feb 2021 18:15:37 -0600 [thread overview]
Message-ID: <5a415ba4-9d69-5479-3be0-c5e6167b0f8a@linaro.org> (raw)
In-Reply-To: <CAE1WUT6VOx=sS1K1PaJG+Ks06CMpoz_efCyNhFQhD83_YNLk5A@mail.gmail.com>
On 2/1/21 6:02 PM, Amy Parker wrote:
> On Mon, Feb 1, 2021 at 3:32 PM Alex Elder <elder@linaro.org> wrote:
>>
>> When extracting the destination endpoint ID from the status in
>> ipa_endpoint_status_skip(), u32_get_bits() is used. This happens to
>> work, but it's wrong: the structure field is only 8 bits wide
>> instead of 32.
>>
>> Fix this by using u8_get_bits() to get the destination endpoint ID.
>
> Isn't
(I saw your second message.)
>> Signed-off-by: Alex Elder <elder@linaro.org>
>> ---
>> drivers/net/ipa/ipa_endpoint.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
>> index 448d89da1e456..612afece303f3 100644
>> --- a/drivers/net/ipa/ipa_endpoint.c
>> +++ b/drivers/net/ipa/ipa_endpoint.c
>> @@ -1164,8 +1164,8 @@ static bool ipa_endpoint_status_skip(struct ipa_endpoint *endpoint,
>> return true;
>
> A few lines above this, endpoint_id is initialized as u32. If we're
> going for "correctness", endpoint_id should be a u8. But of course,
> this would contrast with ipa_endpoint having it as a u32.
You are correct, endpoint_id is *defined* as type u32.
But the issue here is that the field status->endp_dst_idx
has type u8. u32_get_bits() assumes the field it is
passed has type u32; while u8_get_bits() takes a u8.
The return value of u8_get_bits() is u8, as you might
suspect. The C standard guarantees that the u8 value
will be promoted to the u32 target type here.
>> if (!status->pkt_len)
>> return true;
>> - endpoint_id = u32_get_bits(status->endp_dst_idx,
>> - IPA_STATUS_DST_IDX_FMASK);
>> + endpoint_id = u8_get_bits(status->endp_dst_idx,
>> + IPA_STATUS_DST_IDX_FMASK);
>> if (endpoint_id != endpoint->endpoint_id)
>> return true;
>>
>> --
>> 2.27.0
>>
>
> As far as I see it, using u32_get_bits instead of u8_get_bits simply
> eliminates confusion about the type of endpoint_id. Perhaps instead of
> this patch, send a patch with a comment that while u32_get_bits is
> used, the field is only 8 bits?
No. We really want to extract a sub-field from the u8
value passed to u8_get_bits() (not u32_get_bits()).
Does that make sense?
-Alex
> Best regards,
> Amy Parker
> (she/her/hers)
>
next prev parent reply other threads:[~2021-02-02 0:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-01 23:26 [PATCH net 0/4] net: ipa: a few bug fixes Alex Elder
2021-02-01 23:26 ` [PATCH net 1/4] net: ipa: add a missing __iomem attribute Alex Elder
2021-02-02 0:09 ` Amy Parker
2021-02-01 23:26 ` [PATCH net 2/4] net: ipa: be explicit about endianness Alex Elder
2021-02-01 23:26 ` [PATCH net 3/4] net: ipa: use the right accessor in ipa_endpoint_status_skip() Alex Elder
2021-02-02 0:02 ` Amy Parker
2021-02-02 0:03 ` Amy Parker
2021-02-02 0:15 ` Alex Elder [this message]
2021-02-02 0:49 ` Amy Parker
2021-02-01 23:26 ` [PATCH net 4/4] net: ipa: fix two format specifier errors Alex Elder
2021-02-02 17:00 ` [PATCH net 0/4] net: ipa: a few bug fixes 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=5a415ba4-9d69-5479-3be0-c5e6167b0f8a@linaro.org \
--to=elder@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=cpratapa@codeaurora.org \
--cc=davem@davemloft.net \
--cc=elder@kernel.org \
--cc=enbyamy@gmail.com \
--cc=evgreen@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=subashab@codeaurora.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).