linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [net-next] net: stmmac: handle endianness in dwmac4_get_timestamp
@ 2019-02-14 17:26 Alexandre Torgue
  2019-02-14 18:09 ` Florian Fainelli
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Torgue @ 2019-02-14 17:26 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Jose Abreu, davem
  Cc: netdev, Alexandre Torgue, linux-stm32, linux-arm-kernel, linux-kernel

GMAC IP is little-endian and used on several kind of CPU (big or little
endian). Main callbacks functions of the stmmac drivers take care about
it. It was not the case for dwmac4_get_timestamp function.

Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index 20299f6..736e296 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -241,15 +241,18 @@ static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
 static int dwmac4_rx_check_timestamp(void *desc)
 {
 	struct dma_desc *p = (struct dma_desc *)desc;
+	unsigned int rdes0 = le32_to_cpu(p->des0);
+	unsigned int rdes1 = le32_to_cpu(p->des1);
+	unsigned int rdes3 = le32_to_cpu(p->des3);
 	u32 own, ctxt;
 	int ret = 1;
 
-	own = p->des3 & RDES3_OWN;
-	ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR)
+	own = rdes3 & RDES3_OWN;
+	ctxt = ((rdes3 & RDES3_CONTEXT_DESCRIPTOR)
 		>> RDES3_CONTEXT_DESCRIPTOR_SHIFT);
 
 	if (likely(!own && ctxt)) {
-		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
+		if ((rdes0 == 0xffffffff) && (rdes1 == 0xffffffff))
 			/* Corrupted value */
 			ret = -EINVAL;
 		else
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next] net: stmmac: handle endianness in dwmac4_get_timestamp
  2019-02-14 17:26 [net-next] net: stmmac: handle endianness in dwmac4_get_timestamp Alexandre Torgue
@ 2019-02-14 18:09 ` Florian Fainelli
  2019-02-15  9:09   ` Alexandre Torgue
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2019-02-14 18:09 UTC (permalink / raw)
  To: Alexandre Torgue, Giuseppe Cavallaro, Jose Abreu, davem
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel

On 2/14/19 9:26 AM, Alexandre Torgue wrote:
> GMAC IP is little-endian and used on several kind of CPU (big or little
> endian). Main callbacks functions of the stmmac drivers take care about
> it. It was not the case for dwmac4_get_timestamp function.

This is clearly a bugfix, so you should be targeting the 'net' tree and
provide a Fixes: tag so this can be backported to relevant stable kernels.

> 
> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> index 20299f6..736e296 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
> @@ -241,15 +241,18 @@ static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
>  static int dwmac4_rx_check_timestamp(void *desc)
>  {
>  	struct dma_desc *p = (struct dma_desc *)desc;
> +	unsigned int rdes0 = le32_to_cpu(p->des0);
> +	unsigned int rdes1 = le32_to_cpu(p->des1);
> +	unsigned int rdes3 = le32_to_cpu(p->des3);
>  	u32 own, ctxt;
>  	int ret = 1;
>  
> -	own = p->des3 & RDES3_OWN;
> -	ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR)
> +	own = rdes3 & RDES3_OWN;
> +	ctxt = ((rdes3 & RDES3_CONTEXT_DESCRIPTOR)
>  		>> RDES3_CONTEXT_DESCRIPTOR_SHIFT);
>  
>  	if (likely(!own && ctxt)) {
> -		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
> +		if ((rdes0 == 0xffffffff) && (rdes1 == 0xffffffff))
>  			/* Corrupted value */
>  			ret = -EINVAL;
>  		else
> 


-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [net-next] net: stmmac: handle endianness in dwmac4_get_timestamp
  2019-02-14 18:09 ` Florian Fainelli
@ 2019-02-15  9:09   ` Alexandre Torgue
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Torgue @ 2019-02-15  9:09 UTC (permalink / raw)
  To: Florian Fainelli, Giuseppe Cavallaro, Jose Abreu, davem
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel



On 2/14/19 7:09 PM, Florian Fainelli wrote:
> On 2/14/19 9:26 AM, Alexandre Torgue wrote:
>> GMAC IP is little-endian and used on several kind of CPU (big or little
>> endian). Main callbacks functions of the stmmac drivers take care about
>> it. It was not the case for dwmac4_get_timestamp function.
> 
> This is clearly a bugfix, so you should be targeting the 'net' tree and
> provide a Fixes: tag so this can be backported to relevant stable kernels.
> 

Ok Florian, I just have to find the right commit to fix :)

>>
>> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
>> index 20299f6..736e296 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
>> @@ -241,15 +241,18 @@ static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts)
>>   static int dwmac4_rx_check_timestamp(void *desc)
>>   {
>>   	struct dma_desc *p = (struct dma_desc *)desc;
>> +	unsigned int rdes0 = le32_to_cpu(p->des0);
>> +	unsigned int rdes1 = le32_to_cpu(p->des1);
>> +	unsigned int rdes3 = le32_to_cpu(p->des3);
>>   	u32 own, ctxt;
>>   	int ret = 1;
>>   
>> -	own = p->des3 & RDES3_OWN;
>> -	ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR)
>> +	own = rdes3 & RDES3_OWN;
>> +	ctxt = ((rdes3 & RDES3_CONTEXT_DESCRIPTOR)
>>   		>> RDES3_CONTEXT_DESCRIPTOR_SHIFT);
>>   
>>   	if (likely(!own && ctxt)) {
>> -		if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff))
>> +		if ((rdes0 == 0xffffffff) && (rdes1 == 0xffffffff))
>>   			/* Corrupted value */
>>   			ret = -EINVAL;
>>   		else
>>
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-02-15  9:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 17:26 [net-next] net: stmmac: handle endianness in dwmac4_get_timestamp Alexandre Torgue
2019-02-14 18:09 ` Florian Fainelli
2019-02-15  9:09   ` Alexandre Torgue

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