mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mehmet Fide <mehmet.fide@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: Bitterblue Smith <rtl8821cerfe2@gmail.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	mehmet.fide@screeningeagle.com
Subject: Re: [PATCH rtw-next] wifi: rtw88: honour the transmit power mac80211 asks for
Date: Tue, 22 Sep 2026 08:26:41 +0200	[thread overview]
Message-ID: <20260922062641.1313856-1-mehmet.fide@gmail.com> (raw)
In-Reply-To: <dc09d252a96c4992ad18e2ba70cfad31@realtek.com>

On Tue, 22 Sep 2026, Ping-Ke Shih wrote:

> How did you measure the TX power decreasing as your expectation?

Two ways. The exact check is the tx_pwr_tbl debugfs table on the AP
before and after "iw phy phy0 set txpower fixed <mBm>": with fixed 1000
on the RTL8822BU every rate that sat above 10 dBm moved to the 7 dBm
index (10 dBm less the 3 dB two-path share) and the rates already below
it kept their index; fixed 100 gave index 0 instead of the wrap that
patch 1 of v2 fixes; fixed 2000 and "auto" left every index as the
stock driver programs it.

Over the air, a second radio (an RTL8821CU in station mode on a second
unit, at a fixed distance) read the AP's beacons at about -52 dBm with
"auto", -59 with fixed 1000, -62 with fixed 500 and -66 with fixed 100,
and about -52 again after "auto". The drop is smaller than the request
because the beacon goes out at the 1 Mbit/s CCK rate, whose calibrated
index already sits below the channel maximum, so the table is the exact
check and the second radio confirms direction and order.

> And, curiously, what is the purpose you added this? which application?

A handheld measuring instrument that carries the module as its access
point. The hardware team wanted to be able to run the module a fixed
number of dB below the regulatory maximum for an RF exposure
assessment. On the other products of the family the module is an
ath9k_htc one, where "iw set txpower" is the knob we use; on this one
the same command was accepted and mac80211 reported it as in force
while the chip kept transmitting at the maximum.

When I wrote v1 I did not know that rtw88 already exposes
set_sar_specs. I have since verified it on the RTL8822BU: it caps the
per-path index from the given dBm and covers our exposure case, so we
will use it. That leaves the patch as a consistency question rather
than a need of ours: should rtw88 honour the level mac80211 hands over,
as ath9k and most other drivers do, instead of accepting it and letting
mac80211 report it as applied? If you want that, a v2 with your review
points addressed is ready and I will send it. If you prefer SAR to be
the only way to lower the power on these chips, I will drop it.

> Miss to add pwr_param->pwr_user to rtw_debugfs_get_tx_pwr_tbl() to
> show the correct final TX power and pwr_user factor.

Done in v2: a "usr" column, and the effective ceiling column now takes
it into account.

> > +	if (changed & IEEE80211_CONF_CHANGE_CHANNEL)
> > +		rtw_set_channel(rtwdev);
> > +	else if (changed & IEEE80211_CONF_CHANGE_POWER)
>
> Should it be 'if' instead of 'else if'?

rtw_set_channel() ends with rtw_phy_set_tx_power_level(), so when the
channel changed the tables are already programmed with the level kept
in rtw_hal, and a second pass would program the same values again. The
explicit call is only needed when the level changed on its own, so I
kept the else. If you prefer the plain if for readability I will change
it.

> In reverse X'mas tree order.

Fixed in v2.

> > +	return (s8)clamp_t(s32, idx, -chip->max_power_index - 1,
> > +			   chip->max_power_index) - base;
>
> Should it clamp after 'idx - base' ?

The function returns an offset relative to the by-rate base, like the
limit and SAR values it is compared with, and that offset has to go
negative to pull a rate below its base; clamping idx - base would forbid
exactly that. What has to stay inside the chip's index range is the
requested absolute index, so that is what is clamped, and the final sum
is clamped in patch 1 of v2. In v2 the clamp is on its own line before
the subtraction so the order is visible.

Mehmet

  reply	other threads:[~2026-09-22  6:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 14:19 Mehmet Fide
2026-09-22  1:56 ` Ping-Ke Shih
2026-09-22  6:26   ` Mehmet Fide [this message]
2026-09-22  6:48     ` Ping-Ke Shih
2026-09-22  6:59       ` Mehmet Fide

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=20260922062641.1313856-1-mehmet.fide@gmail.com \
    --to=mehmet.fide@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=pkshih@realtek.com \
    --cc=rtl8821cerfe2@gmail.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

all inboxes | Powered by JetHome®