linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout'
@ 2023-11-13  5:49 Su Hui
  2023-11-14  6:42 ` Ping-Ke Shih
  0 siblings, 1 reply; 4+ messages in thread
From: Su Hui @ 2023-11-13  5:49 UTC (permalink / raw)
  To: Jes.Sorensen, kvalo; +Cc: Su Hui, linux-wireless, linux-kernel, kernel-janitors

When 'rtl8xxxu_dma_agg_pages <= page_thresh', 'timeout' should equal to
'page_thresh' rather than '4'. Change the code order to fix this problem.

Fixes: 614e389f36a9 ("rtl8xxxu: gen1: Set aggregation timeout (REG_RXDMA_AGG_PG_TH + 1) as well")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c    | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 43ee7592bc6e..9cab8b1dc486 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4757,6 +4757,12 @@ void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
 	 *   RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6))
 	 */
 
+	/* REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on
+	 * gen2 chips and rtl8188eu. The rtl8723au seems unhappy if we
+	 * don't set it, so better set both.
+	 */
+	timeout = 4;
+
 	page_thresh = (priv->fops->rx_agg_buf_size / 512);
 	if (rtl8xxxu_dma_agg_pages >= 0) {
 		if (rtl8xxxu_dma_agg_pages <= page_thresh)
@@ -4771,12 +4777,6 @@ void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
 				__func__, rtl8xxxu_dma_agg_pages, page_thresh);
 	}
 	rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh);
-	/*
-	 * REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on
-	 * gen2 chips and rtl8188eu. The rtl8723au seems unhappy if we
-	 * don't set it, so better set both.
-	 */
-	timeout = 4;
 
 	if (rtl8xxxu_dma_agg_timeout >= 0) {
 		if (rtl8xxxu_dma_agg_timeout <= 127)
-- 
2.30.2


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

* RE: [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout'
  2023-11-13  5:49 [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout' Su Hui
@ 2023-11-14  6:42 ` Ping-Ke Shih
  2023-11-14  9:17   ` Su Hui
  2023-11-20 12:31   ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Ping-Ke Shih @ 2023-11-14  6:42 UTC (permalink / raw)
  To: Su Hui, Jes.Sorensen, kvalo; +Cc: linux-wireless, linux-kernel, kernel-janitors



> -----Original Message-----
> From: Su Hui <suhui@nfschina.com>
> Sent: Monday, November 13, 2023 1:49 PM
> To: Jes.Sorensen@gmail.com; kvalo@kernel.org
> Cc: Su Hui <suhui@nfschina.com>; linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org;
> kernel-janitors@vger.kernel.org
> Subject: [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout'
> 
> When 'rtl8xxxu_dma_agg_pages <= page_thresh', 'timeout' should equal to
> 'page_thresh' rather than '4'. Change the code order to fix this problem.
> 
> Fixes: 614e389f36a9 ("rtl8xxxu: gen1: Set aggregation timeout (REG_RXDMA_AGG_PG_TH + 1) as well")

I think this should fix
Fixes: fd83f1227826 ("rtl8xxxu: gen1: Add module parameters to adjust DMA aggregation parameters")

> Signed-off-by: Su Hui <suhui@nfschina.com>
> ---
>  .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c    | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index 43ee7592bc6e..9cab8b1dc486 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -4757,6 +4757,12 @@ void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
>          *   RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6))
>          */
> 
> +       /* REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on
> +        * gen2 chips and rtl8188eu. The rtl8723au seems unhappy if we
> +        * don't set it, so better set both.
> +        */
> +       timeout = 4;
> +
>         page_thresh = (priv->fops->rx_agg_buf_size / 512);
>         if (rtl8xxxu_dma_agg_pages >= 0) {
>                 if (rtl8xxxu_dma_agg_pages <= page_thresh)

The logic here is:

	page_thresh = (priv->fops->rx_agg_buf_size / 512);
	if (rtl8xxxu_dma_agg_pages >= 0) {
		if (rtl8xxxu_dma_agg_pages <= page_thresh)
			timeout = page_thresh;

Do you know why 'timeout = page_thresh;'? Intuitively, units of 'timeout' and
'thresh' are different. Maybe, we should correct here instead?



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

* Re: [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout'
  2023-11-14  6:42 ` Ping-Ke Shih
@ 2023-11-14  9:17   ` Su Hui
  2023-11-20 12:31   ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Su Hui @ 2023-11-14  9:17 UTC (permalink / raw)
  To: Ping-Ke Shih, Jes.Sorensen, kvalo
  Cc: linux-wireless, linux-kernel, kernel-janitors

On 2023/11/14 14:42, Ping-Ke Shih wrote:
>> -----Original Message-----
>> From: Su Hui <suhui@nfschina.com>
>> Sent: Monday, November 13, 2023 1:49 PM
>> To: Jes.Sorensen@gmail.com; kvalo@kernel.org
>> Cc: Su Hui <suhui@nfschina.com>; linux-wireless@vger.kernel.org; linux-kernel@vger.kernel.org;
>> kernel-janitors@vger.kernel.org
>> Subject: [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout'
>>
>> When 'rtl8xxxu_dma_agg_pages <= page_thresh', 'timeout' should equal to
>> 'page_thresh' rather than '4'. Change the code order to fix this problem.
>>
>> Fixes: 614e389f36a9 ("rtl8xxxu: gen1: Set aggregation timeout (REG_RXDMA_AGG_PG_TH + 1) as well")
> I think this should fix
> Fixes: fd83f1227826 ("rtl8xxxu: gen1: Add module parameters to adjust DMA aggregation parameters")
Agreed. Thanks for your reminder!
>
>> Signed-off-by: Su Hui <suhui@nfschina.com>
>> ---
>>   .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c    | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> index 43ee7592bc6e..9cab8b1dc486 100644
>> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
>> @@ -4757,6 +4757,12 @@ void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
>>           *   RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6))
>>           */
>>
>> +       /* REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on
>> +        * gen2 chips and rtl8188eu. The rtl8723au seems unhappy if we
>> +        * don't set it, so better set both.
>> +        */
>> +       timeout = 4;
>> +
>>          page_thresh = (priv->fops->rx_agg_buf_size / 512);
>>          if (rtl8xxxu_dma_agg_pages >= 0) {
>>                  if (rtl8xxxu_dma_agg_pages <= page_thresh)
> The logic here is:
>
> 	page_thresh = (priv->fops->rx_agg_buf_size / 512);
> 	if (rtl8xxxu_dma_agg_pages >= 0) {
> 		if (rtl8xxxu_dma_agg_pages <= page_thresh)
> 			timeout = page_thresh;
>
> Do you know why 'timeout = page_thresh;'? Intuitively, units of 'timeout' and
> 'thresh' are different. Maybe, we should correct here instead?
I don't know the reason about this. :(
I found this error because clang static checker complains about this 
code that value stored to 'timeout'
is never read.

Su Hui


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

* Re: [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout'
  2023-11-14  6:42 ` Ping-Ke Shih
  2023-11-14  9:17   ` Su Hui
@ 2023-11-20 12:31   ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-11-20 12:31 UTC (permalink / raw)
  To: Ping-Ke Shih
  Cc: Su Hui, Jes.Sorensen, kvalo, linux-wireless, linux-kernel,
	kernel-janitors

On Tue, Nov 14, 2023 at 06:42:50AM +0000, Ping-Ke Shih wrote:
> > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> > index 43ee7592bc6e..9cab8b1dc486 100644
> > --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> > +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> > @@ -4757,6 +4757,12 @@ void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
> >          *   RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6))
> >          */
> > 
> > +       /* REG_RXDMA_AGG_PG_TH + 1 seems to be the timeout register on
> > +        * gen2 chips and rtl8188eu. The rtl8723au seems unhappy if we
> > +        * don't set it, so better set both.
> > +        */
> > +       timeout = 4;
> > +
> >         page_thresh = (priv->fops->rx_agg_buf_size / 512);
> >         if (rtl8xxxu_dma_agg_pages >= 0) {
> >                 if (rtl8xxxu_dma_agg_pages <= page_thresh)
> 
> The logic here is:
> 
> 	page_thresh = (priv->fops->rx_agg_buf_size / 512);
> 	if (rtl8xxxu_dma_agg_pages >= 0) {
> 		if (rtl8xxxu_dma_agg_pages <= page_thresh)
> 			timeout = page_thresh;
> 
> Do you know why 'timeout = page_thresh;'? Intuitively, units of 'timeout' and
> 'thresh' are different. Maybe, we should correct here instead?
> 

Yeah.  That's strange.  I'm not convinced this fix is correct.  I'm
hesitant to suggest this but maybe the following is the correct fix?
It just silences the warning but doesn't change runtime.

I don't know.  *shrug*.  One thing that we could do is just leave the
warning as-is until someone who knows better than we do can take a look
at it.

regards,
dan carpenter

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 43ee7592bc6e..68d9b4a0ee63 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -4759,16 +4759,16 @@ void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
 
 	page_thresh = (priv->fops->rx_agg_buf_size / 512);
 	if (rtl8xxxu_dma_agg_pages >= 0) {
-		if (rtl8xxxu_dma_agg_pages <= page_thresh)
-			timeout = page_thresh;
-		else if (rtl8xxxu_dma_agg_pages <= 6)
-			dev_err(&priv->udev->dev,
-				"%s: dma_agg_pages=%i too small, minimum is 6\n",
-				__func__, rtl8xxxu_dma_agg_pages);
-		else
-			dev_err(&priv->udev->dev,
-				"%s: dma_agg_pages=%i larger than limit %i\n",
-				__func__, rtl8xxxu_dma_agg_pages, page_thresh);
+		if (rtl8xxxu_dma_agg_pages > page_thresh) {
+			if (rtl8xxxu_dma_agg_pages <= 6)
+				dev_err(&priv->udev->dev,
+					"%s: dma_agg_pages=%i too small, minimum is 6\n",
+					__func__, rtl8xxxu_dma_agg_pages);
+			else
+				dev_err(&priv->udev->dev,
+					"%s: dma_agg_pages=%i larger than limit %i\n",
+					__func__, rtl8xxxu_dma_agg_pages, page_thresh);
+		}
 	}
 	rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh);
 	/*

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

end of thread, other threads:[~2023-11-20 12:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13  5:49 [PATCH] wifi: rtl8xxxu: correct the error value of 'timeout' Su Hui
2023-11-14  6:42 ` Ping-Ke Shih
2023-11-14  9:17   ` Su Hui
2023-11-20 12:31   ` Dan Carpenter

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