Linux-mediatek Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1] mt76: mt7615: Fix build with older compilers
@ 2019-12-01 18:17 Pablo Greco
  2019-12-02  9:18 ` Sergei Shtylyov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pablo Greco @ 2019-12-01 18:17 UTC (permalink / raw)
  Cc: Ryder Lee, netdev, linux-wireless, Pablo Greco, linux-kernel,
	Matthias Brugger, linux-mediatek, linux-arm-kernel, Roy Luo,
	Lorenzo Bianconi, David S. Miller, Kalle Valo, Felix Fietkau

Some compilers (tested with 4.8.5 from CentOS 7) fail properly process
FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
Convert inline function to a macro.

Fixes commit bf92e7685100 ("mt76: mt7615: add support for per-chain
signal strength reporting")
Reported in https://lkml.org/lkml/2019/9/21/146

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Pablo Greco <pgreco@centosproject.org>
---
 drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index c77adc5d2552..77e395ca2c6a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -13,10 +13,7 @@
 #include "../dma.h"
 #include "mac.h"
 
-static inline s8 to_rssi(u32 field, u32 rxv)
-{
-	return (FIELD_GET(field, rxv) - 220) / 2;
-}
+#define to_rssi(field, rxv)		((FIELD_GET(field, rxv) - 220) / 2)
 
 static struct mt76_wcid *mt7615_rx_get_wcid(struct mt7615_dev *dev,
 					    u8 idx, bool unicast)
-- 
2.18.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH v1] mt76: mt7615: Fix build with older compilers
  2019-12-01 18:17 [PATCH v1] mt76: mt7615: Fix build with older compilers Pablo Greco
@ 2019-12-02  9:18 ` Sergei Shtylyov
  2019-12-02 10:30   ` Pablo Sebastián Greco
  2019-12-02  9:25 ` Kalle Valo
       [not found] ` <0101016ec5ed7d91-eac61501-1e4a-42f1-881d-cc2c02eb8372-000000@us-west-2.amazonses.com>
  2 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2019-12-02  9:18 UTC (permalink / raw)
  To: Pablo Greco
  Cc: Ryder Lee, netdev, linux-wireless, linux-kernel,
	Matthias Brugger, linux-mediatek, linux-arm-kernel, Roy Luo,
	Lorenzo Bianconi, David S. Miller, Kalle Valo, Felix Fietkau

Hello!

On 01.12.2019 21:17, Pablo Greco wrote:

> Some compilers (tested with 4.8.5 from CentOS 7) fail properly process

    Fail to?

> FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
> Convert inline function to a macro.
> 
> Fixes commit bf92e7685100 ("mt76: mt7615: add support for per-chain
> signal strength reporting")

    Should be:

Fixes: bf92e7685100 ("mt76: mt7615: add support for per-chain signal strength 
reporting")

    Do not ever break up the Fixes: line and don't insert empty lines between 
it and other tags.

> Reported in https://lkml.org/lkml/2019/9/21/146
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Pablo Greco <pgreco@centosproject.org>
[...]

MBR, Sergei

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH v1] mt76: mt7615: Fix build with older compilers
  2019-12-01 18:17 [PATCH v1] mt76: mt7615: Fix build with older compilers Pablo Greco
  2019-12-02  9:18 ` Sergei Shtylyov
@ 2019-12-02  9:25 ` Kalle Valo
       [not found] ` <0101016ec5ed7d91-eac61501-1e4a-42f1-881d-cc2c02eb8372-000000@us-west-2.amazonses.com>
  2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2019-12-02  9:25 UTC (permalink / raw)
  To: Pablo Greco
  Cc: Ryder Lee, netdev, linux-wireless, linux-kernel,
	Matthias Brugger, linux-mediatek, Roy Luo, Lorenzo Bianconi,
	David S. Miller, linux-arm-kernel, Felix Fietkau

Pablo Greco <pgreco@centosproject.org> writes:

> Some compilers (tested with 4.8.5 from CentOS 7) fail properly process
> FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
> Convert inline function to a macro.
>
> Fixes commit bf92e7685100 ("mt76: mt7615: add support for per-chain
> signal strength reporting")
> Reported in https://lkml.org/lkml/2019/9/21/146
>
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Pablo Greco <pgreco@centosproject.org>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> index c77adc5d2552..77e395ca2c6a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> @@ -13,10 +13,7 @@
>  #include "../dma.h"
>  #include "mac.h"
>  
> -static inline s8 to_rssi(u32 field, u32 rxv)
> -{
> -	return (FIELD_GET(field, rxv) - 220) / 2;
> -}
> +#define to_rssi(field, rxv)		((FIELD_GET(field, rxv) - 220) / 2)

What about u32_get_bits() instead of FIELD_GET(), would that work? I
guess chances for that is slim, but it's always a shame to convert a
function to a macro so we should try other methods first.

Or even better if we could fix FIELD_GET() to work with older compilers.

-- 
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH v1] mt76: mt7615: Fix build with older compilers
  2019-12-02  9:18 ` Sergei Shtylyov
@ 2019-12-02 10:30   ` Pablo Sebastián Greco
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Sebastián Greco @ 2019-12-02 10:30 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: Ryder Lee, netdev, linux-wireless, linux-kernel,
	Matthias Brugger, linux-mediatek, linux-arm-kernel, Roy Luo,
	Lorenzo Bianconi, David S. Miller, Kalle Valo, Felix Fietkau


On 2/12/19 06:18, Sergei Shtylyov wrote:
> Hello!
>
> On 01.12.2019 21:17, Pablo Greco wrote:
>
>> Some compilers (tested with 4.8.5 from CentOS 7) fail properly process
>
>    Fail to?
Right
>
>> FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
>> Convert inline function to a macro.
>>
>> Fixes commit bf92e7685100 ("mt76: mt7615: add support for per-chain
>> signal strength reporting")
>
>    Should be:
>
> Fixes: bf92e7685100 ("mt76: mt7615: add support for per-chain signal 
> strength reporting")
>
>    Do not ever break up the Fixes: line and don't insert empty lines 
> between it and other tags.
Ack, I'll fix those for v2
>
>> Reported in https://lkml.org/lkml/2019/9/21/146
>>
>> Reported-by: kbuild test robot <lkp@intel.com>
>> Signed-off-by: Pablo Greco <pgreco@centosproject.org>
> [...]
>
> MBR, Sergei


Thanks, Pablo


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH v1] mt76: mt7615: Fix build with older compilers
       [not found] ` <0101016ec5ed7d91-eac61501-1e4a-42f1-881d-cc2c02eb8372-000000@us-west-2.amazonses.com>
@ 2019-12-02 10:42   ` Pablo Sebastián Greco
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Sebastián Greco @ 2019-12-02 10:42 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Ryder Lee, netdev, linux-wireless, linux-kernel,
	Matthias Brugger, linux-mediatek, Roy Luo, Lorenzo Bianconi,
	David S. Miller, linux-arm-kernel, Felix Fietkau


On 2/12/19 06:25, Kalle Valo wrote:
> Pablo Greco <pgreco@centosproject.org> writes:
>
>> Some compilers (tested with 4.8.5 from CentOS 7) fail properly process
>> FIELD_GET inside an inline function, which ends up in a BUILD_BUG_ON.
>> Convert inline function to a macro.
>>
>> Fixes commit bf92e7685100 ("mt76: mt7615: add support for per-chain
>> signal strength reporting")
>> Reported in https://lkml.org/lkml/2019/9/21/146
>>
>> Reported-by: kbuild test robot <lkp@intel.com>
>> Signed-off-by: Pablo Greco <pgreco@centosproject.org>
>> ---
>>   drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> index c77adc5d2552..77e395ca2c6a 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> @@ -13,10 +13,7 @@
>>   #include "../dma.h"
>>   #include "mac.h"
>>   
>> -static inline s8 to_rssi(u32 field, u32 rxv)
>> -{
>> -	return (FIELD_GET(field, rxv) - 220) / 2;
>> -}
>> +#define to_rssi(field, rxv)		((FIELD_GET(field, rxv) - 220) / 2)
> What about u32_get_bits() instead of FIELD_GET(), would that work? I
> guess chances for that is slim, but it's always a shame to convert a
> function to a macro so we should try other methods first.
Anything that doesn't check field at build time should work, but between 
losing a check, or turning an inline into a macro, I'd rather use the macro.
> Or even better if we could fix FIELD_GET() to work with older compilers.
>
The problem is not FIELD_GET itself, is that the compiler is trying to 
use "field" as a variable, instead as the macro expansion of GENMASK, as 
if the function wasn't inline.
In the linked page you can see this message

BUILD_BUG_ON failed: (((field) + (1ULL << (__builtin_ffsll(field) - 1))) 
& (((field) + (1ULL << (__builtin_ffsll(field) - 1))) - 1)) != 0
      _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

which is is not right, because "field" should never be used for that check.



Pablo.

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01 18:17 [PATCH v1] mt76: mt7615: Fix build with older compilers Pablo Greco
2019-12-02  9:18 ` Sergei Shtylyov
2019-12-02 10:30   ` Pablo Sebastián Greco
2019-12-02  9:25 ` Kalle Valo
     [not found] ` <0101016ec5ed7d91-eac61501-1e4a-42f1-881d-cc2c02eb8372-000000@us-west-2.amazonses.com>
2019-12-02 10:42   ` Pablo Sebastián Greco

Linux-mediatek Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mediatek/0 linux-mediatek/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mediatek linux-mediatek/ https://lore.kernel.org/linux-mediatek \
		linux-mediatek@lists.infradead.org
	public-inbox-index linux-mediatek

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mediatek


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git