Re: [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version

From: Alex Elder
Date: Wed Sep 09 2020 - 08:16:40 EST


On 9/8/20 9:32 AM, Vadym Kochan wrote:
> Looks like u32p_replace_bits() should be used instead of
> u32_replace_bits() which does not modifies the value but returns the
> modified version.
>
> Fixes: 2b9feef2b6c2 ("soc: qcom: ipa: filter and routing tables")
> Signed-off-by: Vadym Kochan <vadym.kochan@xxxxxxxxxxx>

You are correct! Thank you for finding this.

Your fix is good, and I have now tested it and verified it
works as desired.

FYI, this is currently used only for the SDM845 platform. It turns
out the register values (route and filter hash config) that are read
and intended to be updated always have value 0, so (fortunately) your
change has no effect there.

Nevertheless, you have fixed this bug and I appreciate it.

Reviewed-by: Alex Elder <elder@xxxxxxxxxx>

> ---
> Found it while grepping of u32_replace_bits() usage and
> replaced it w/o testing.
>
> drivers/net/ipa/ipa_table.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c
> index 2098ca2f2c90..b3790aa952a1 100644
> --- a/drivers/net/ipa/ipa_table.c
> +++ b/drivers/net/ipa/ipa_table.c
> @@ -521,7 +521,7 @@ static void ipa_filter_tuple_zero(struct ipa_endpoint *endpoint)
> val = ioread32(endpoint->ipa->reg_virt + offset);
>
> /* Zero all filter-related fields, preserving the rest */
> - u32_replace_bits(val, 0, IPA_REG_ENDP_FILTER_HASH_MSK_ALL);
> + u32p_replace_bits(&val, 0, IPA_REG_ENDP_FILTER_HASH_MSK_ALL);
>
> iowrite32(val, endpoint->ipa->reg_virt + offset);
> }
> @@ -573,7 +573,7 @@ static void ipa_route_tuple_zero(struct ipa *ipa, u32 route_id)
> val = ioread32(ipa->reg_virt + offset);
>
> /* Zero all route-related fields, preserving the rest */
> - u32_replace_bits(val, 0, IPA_REG_ENDP_ROUTER_HASH_MSK_ALL);
> + u32p_replace_bits(&val, 0, IPA_REG_ENDP_ROUTER_HASH_MSK_ALL);
>
> iowrite32(val, ipa->reg_virt + offset);
> }
>