netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version
@ 2020-09-08 14:32 Vadym Kochan
  2020-09-09 11:53 ` Alex Elder
  0 siblings, 1 reply; 4+ messages in thread
From: Vadym Kochan @ 2020-09-08 14:32 UTC (permalink / raw)
  To: Alex Elder, David S. Miller, Jakub Kicinski, netdev
  Cc: linux-kernel, Vadym Kochan

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@plvision.eu>
---
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);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version
  2020-09-08 14:32 [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version Vadym Kochan
@ 2020-09-09 11:53 ` Alex Elder
  2020-09-09 12:02   ` Vadym Kochan
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Elder @ 2020-09-09 11:53 UTC (permalink / raw)
  To: Vadym Kochan, Alex Elder, David S. Miller, Jakub Kicinski, netdev
  Cc: linux-kernel

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@plvision.eu>

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@linaro.org>

> ---
> 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);
>  }
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version
  2020-09-09 11:53 ` Alex Elder
@ 2020-09-09 12:02   ` Vadym Kochan
  2020-09-09 12:04     ` Alex Elder
  0 siblings, 1 reply; 4+ messages in thread
From: Vadym Kochan @ 2020-09-09 12:02 UTC (permalink / raw)
  To: Alex Elder
  Cc: Alex Elder, David S. Miller, Jakub Kicinski, netdev, linux-kernel

Hi Alex,

On Wed, Sep 09, 2020 at 06:53:17AM -0500, Alex Elder wrote:
> 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@plvision.eu>
> 
> 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.
> 

I had such assumption that probably it works without the fix.

> Nevertheless, you have fixed this bug and I appreciate it.
> 
> Reviewed-by: Alex Elder <elder@linaro.org>
> 

My understanding is that I need to re-submit this as an official patch
without RFT/RFC prefix and with your reviewed tag ?

Regards,
Vadym Kochan

> > ---
> > 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);
> >  }
> > 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version
  2020-09-09 12:02   ` Vadym Kochan
@ 2020-09-09 12:04     ` Alex Elder
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2020-09-09 12:04 UTC (permalink / raw)
  To: Vadym Kochan
  Cc: Alex Elder, David S. Miller, Jakub Kicinski, netdev, linux-kernel

On 9/9/20 7:02 AM, Vadym Kochan wrote:
> Hi Alex,
> 
> On Wed, Sep 09, 2020 at 06:53:17AM -0500, Alex Elder wrote:
>> 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@plvision.eu>
>>
>> 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.
>>
> 
> I had such assumption that probably it works without the fix.
> 
>> Nevertheless, you have fixed this bug and I appreciate it.
>>
>> Reviewed-by: Alex Elder <elder@linaro.org>
>>
> 
> My understanding is that I need to re-submit this as an official patch
> without RFT/RFC prefix and with your reviewed tag ?

I hope David will accept it with my review, but if not maybe
he can answer your question.  Let's give him a chance to do
that, and if he hasn't responded within a day or two then
go ahead and send an updated version 2.

					-Alex

> Regards,
> Vadym Kochan
> 
>>> ---
>>> 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);
>>>  }
>>>
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-09 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-08 14:32 [RFT net] net: ipa: fix u32_replace_bits by u32p_xxx version Vadym Kochan
2020-09-09 11:53 ` Alex Elder
2020-09-09 12:02   ` Vadym Kochan
2020-09-09 12:04     ` Alex Elder

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).