2020-04-06 12:17:27

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit

Kai-Heng Feng <[email protected]> writes:

> On some systems we can constanly see rtw88 complains:
> [39584.721375] rtw_pci 0000:03:00.0: failed to send h2c command
>
> Increase interval of each check to wait the status bit really changes.
>
> While at it, add some helpers so we can use standarized
> readx_poll_timeout() macro.

One logical change per patch, please.

> --- a/drivers/net/wireless/realtek/rtw88/hci.h
> +++ b/drivers/net/wireless/realtek/rtw88/hci.h
> @@ -253,6 +253,10 @@ rtw_write8_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u8 data)
> rtw_write8(rtwdev, addr, set);
> }
>
> +#define rr8(addr) rtw_read8(rtwdev, addr)
> +#define rr16(addr) rtw_read16(rtwdev, addr)
> +#define rr32(addr) rtw_read32(rtwdev, addr)

For me these macros reduce code readability, not improve anything. They
hide the use of rtwdev variable, which is evil, and a name like rr8() is
just way too vague. Please keep the original function names as is.

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


2020-04-06 13:19:14

by Kai-Heng Feng

[permalink] [raw]
Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit



> On Apr 6, 2020, at 20:17, Kalle Valo <[email protected]> wrote:
>
> Kai-Heng Feng <[email protected]> writes:
>
>> On some systems we can constanly see rtw88 complains:
>> [39584.721375] rtw_pci 0000:03:00.0: failed to send h2c command
>>
>> Increase interval of each check to wait the status bit really changes.
>>
>> While at it, add some helpers so we can use standarized
>> readx_poll_timeout() macro.
>
> One logical change per patch, please.

Will split it into two separate patches.

>
>> --- a/drivers/net/wireless/realtek/rtw88/hci.h
>> +++ b/drivers/net/wireless/realtek/rtw88/hci.h
>> @@ -253,6 +253,10 @@ rtw_write8_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u8 data)
>> rtw_write8(rtwdev, addr, set);
>> }
>>
>> +#define rr8(addr) rtw_read8(rtwdev, addr)
>> +#define rr16(addr) rtw_read16(rtwdev, addr)
>> +#define rr32(addr) rtw_read32(rtwdev, addr)
>
> For me these macros reduce code readability, not improve anything. They
> hide the use of rtwdev variable, which is evil, and a name like rr8() is
> just way too vague. Please keep the original function names as is.

The inspiration is from another driver.
readx_poll_timeout macro only takes one argument for the op.
Some other drivers have their own poll_timeout implementation,
and I guess it makes sense to make one specific for rtw88.

Kai-Heng

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

2020-04-06 13:25:05

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit

Kai-Heng Feng <[email protected]> writes:

>> On Apr 6, 2020, at 20:17, Kalle Valo <[email protected]> wrote:
>>
>> Kai-Heng Feng <[email protected]> writes:
>>
>>> --- a/drivers/net/wireless/realtek/rtw88/hci.h
>>> +++ b/drivers/net/wireless/realtek/rtw88/hci.h
>>> @@ -253,6 +253,10 @@ rtw_write8_mask(struct rtw_dev *rtwdev, u32
>>> addr, u32 mask, u8 data)
>>> rtw_write8(rtwdev, addr, set);
>>> }
>>>
>>> +#define rr8(addr) rtw_read8(rtwdev, addr)
>>> +#define rr16(addr) rtw_read16(rtwdev, addr)
>>> +#define rr32(addr) rtw_read32(rtwdev, addr)
>>
>> For me these macros reduce code readability, not improve anything. They
>> hide the use of rtwdev variable, which is evil, and a name like rr8() is
>> just way too vague. Please keep the original function names as is.
>
> The inspiration is from another driver.
> readx_poll_timeout macro only takes one argument for the op.
> Some other drivers have their own poll_timeout implementation,
> and I guess it makes sense to make one specific for rtw88.

I'm not even understanding the problem you are tying to fix with these
macros. The upstream philosopyhy is to have the source code readable and
maintainable, not to use minimal number of characters. There's a reason
why we don't name our functions a(), b(), c() and so on.

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

2020-04-06 13:35:54

by Kai-Heng Feng

[permalink] [raw]
Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit



> On Apr 6, 2020, at 21:24, Kalle Valo <[email protected]> wrote:
>
> Kai-Heng Feng <[email protected]> writes:
>
>>> On Apr 6, 2020, at 20:17, Kalle Valo <[email protected]> wrote:
>>>
>>> Kai-Heng Feng <[email protected]> writes:
>>>
>>>> --- a/drivers/net/wireless/realtek/rtw88/hci.h
>>>> +++ b/drivers/net/wireless/realtek/rtw88/hci.h
>>>> @@ -253,6 +253,10 @@ rtw_write8_mask(struct rtw_dev *rtwdev, u32
>>>> addr, u32 mask, u8 data)
>>>> rtw_write8(rtwdev, addr, set);
>>>> }
>>>>
>>>> +#define rr8(addr) rtw_read8(rtwdev, addr)
>>>> +#define rr16(addr) rtw_read16(rtwdev, addr)
>>>> +#define rr32(addr) rtw_read32(rtwdev, addr)
>>>
>>> For me these macros reduce code readability, not improve anything. They
>>> hide the use of rtwdev variable, which is evil, and a name like rr8() is
>>> just way too vague. Please keep the original function names as is.
>>
>> The inspiration is from another driver.
>> readx_poll_timeout macro only takes one argument for the op.
>> Some other drivers have their own poll_timeout implementation,
>> and I guess it makes sense to make one specific for rtw88.
>
> I'm not even understanding the problem you are tying to fix with these
> macros. The upstream philosopyhy is to have the source code readable and
> maintainable, not to use minimal number of characters. There's a reason
> why we don't name our functions a(), b(), c() and so on.

The current h2c polling doesn't have delay between each interval, so the polling is too fast and the following logic considers it's a timeout.
The readx_poll_timeout() macro provides a generic mechanism to setup an interval delay and timeout which is what we need here.
However readx_poll_timeout only accepts one parameter which usually is memory address, while we need to pass both rtwdev and address.

So if hiding rtwdev is evil, we can roll our own variant of readx_poll_timeout() to make the polling readable.

Kai-Heng

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