public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: yhchuang@realtek.com
Cc: kvalo@codeaurora.org, linux-wireless@vger.kernel.org,
	tehuang@realtek.com
Subject: Re: [PATCH v2 2/5] rtw88: 8821c: add power tracking
Date: Fri, 5 Jun 2020 16:30:13 +0200	[thread overview]
Message-ID: <20200605143013.qnnwaemnt6l3rnf7@linutronix.de> (raw)
In-Reply-To: <20200603094218.19942-3-yhchuang@realtek.com>

On 2020-06-03 17:42:15 [+0800], yhchuang@realtek.com wrote:
> diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
> index 904eb494ccad..aa2457046ad1 100644
> --- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
> +++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
> @@ -61,6 +61,46 @@ static int rtw8821c_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
>  	return 0;
>  }
>  
> +static const u32 rtw8821c_txscale_tbl[] = {
> +	0x081, 0x088, 0x090, 0x099, 0x0a2, 0x0ac, 0x0b6, 0x0c0, 0x0cc, 0x0d8,
> +	0x0e5, 0x0f2, 0x101, 0x110, 0x120, 0x131, 0x143, 0x156, 0x16a, 0x180,
> +	0x197, 0x1af, 0x1c8, 0x1e3, 0x200, 0x21e, 0x23e, 0x261, 0x285, 0x2ab,
> +	0x2d3, 0x2fe, 0x32b, 0x35c, 0x38e, 0x3c4, 0x3fe
> +};
> +
> +static const u8 rtw8821c_get_swing_index(struct rtw_dev *rtwdev)
> +{
> +	u8 i = 0;
> +	u32 swing, table_value;
> +
> +	swing = rtw_read32_mask(rtwdev, REG_TXSCALE_A, 0xffe00000);
> +	for (i = 0; i < ARRAY_SIZE(rtw8821c_txscale_tbl); i++) {
> +		table_value = rtw8821c_txscale_tbl[i];
> +		if (swing == table_value)
> +			break;
> +	}
> +
> +	return i;
> +}

This matches rtw8822b_get_swing_index() and rtw8822b_txscale_tbl. How
often are the lookups performed and how likely is it that the value is
not found?
With something like this:

 static int rtw8821c_get_swing_index(unsigned int swing)
 {
         unsigned short val;
         int start, end;
         int candidate;
 
         start = 0;
         end = ARRAY_SIZE(rtw8821c_txscale_tbl);
         while (start < end) {
 
                 candidate = start + (end - start) / 2;
                 val = rtw8821c_txscale_tbl[candidate];
                 if (swing == val)
                         return candidate;
                 if (swing < val)
                         end = candidate;
                 else
                         start = candidate + 1;
         }
         return -EINVAL;
 }

you would end up with more less constant lookup time with ~6 lookups in worst
case. I guess it is not a hot path but still…
Can the table become u16?

…
> +const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = {
> +	.pwrtrk_5gb_n[0] = rtw8821c_pwrtrk_5gb_n[0],
> +	.pwrtrk_5gb_n[1] = rtw8821c_pwrtrk_5gb_n[1],
> +	.pwrtrk_5gb_n[2] = rtw8821c_pwrtrk_5gb_n[2],

so the other driver use RTW_PWR_TRK_5G_1…3. Using constants here isn't
better because a line like

	.pwrtrk_5gb_n[2] = rtw8821c_pwrtrk_5gb_n[22],

will not trigger a warning. This is just an observation.

Sebastian

  reply	other threads:[~2020-06-05 14:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-03  9:42 [PATCH v2 0/5] rtw88: 8821c: the rest patches to support 8821c yhchuang
2020-06-03  9:42 ` [PATCH v2 1/5] rtw88: 8821c: add cck pd settings yhchuang
2020-06-05 10:53   ` Sebastian Andrzej Siewior
2020-07-15  8:50   ` Kalle Valo
2020-07-15  9:29     ` Tony Chuang
2020-07-15  9:10   ` Kalle Valo
2020-06-03  9:42 ` [PATCH v2 2/5] rtw88: 8821c: add power tracking yhchuang
2020-06-05 14:30   ` Sebastian Andrzej Siewior [this message]
2020-06-03  9:42 ` [PATCH v2 3/5] rtw88: 8821c: add beamformee support yhchuang
2020-06-03  9:42 ` [PATCH v2 4/5] rtw88: single rf path chips don't support TX STBC yhchuang
2020-06-03  9:42 ` [PATCH v2 5/5] rtw88: 8821c: Add 8821CE to Kconfig and Makefile yhchuang
2020-06-08 19:01   ` Larry Finger
2020-06-16 11:07     ` Tony Chuang
2020-07-02  5:17       ` Kai-Heng Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200605143013.qnnwaemnt6l3rnf7@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tehuang@realtek.com \
    --cc=yhchuang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox