From: Ping-Ke Shih <pkshih@realtek.com>
To: Bitterblue Smith <rtl8821cerfe2@gmail.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH rtw-next 4/5] wifi: rtw88: pci: Add functions to support older chips
Date: Wed, 25 Nov 2026 01:52:47 +0000 [thread overview]
Message-ID: <fd5ab121d9214a299f8ff72a18a83fe2@realtek.com> (raw)
In-Reply-To: <f7a9c585-3c3b-4818-a262-6c9f8103387a@gmail.com>
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> On 24/10/2026 02:02, Bitterblue Smith wrote:
> > Add pci_old.{c,h} to support older chips, like RTL8821AE and RTL8812AE.
> > They handle the PCI communications differently.
> >
> > Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> > ---
> > drivers/net/wireless/realtek/rtw88/Makefile | 2 +-
> > drivers/net/wireless/realtek/rtw88/pci.c | 9 +-
> > drivers/net/wireless/realtek/rtw88/pci.h | 6 +
> > drivers/net/wireless/realtek/rtw88/pci_old.c | 522 +++++++++++++++++++
> > drivers/net/wireless/realtek/rtw88/pci_old.h | 39 ++
> > drivers/net/wireless/realtek/rtw88/reg.h | 3 +
> > drivers/net/wireless/realtek/rtw88/rx.h | 4 +
> > drivers/net/wireless/realtek/rtw88/tx.h | 5 +
> > 8 files changed, 584 insertions(+), 6 deletions(-)
> > create mode 100644 drivers/net/wireless/realtek/rtw88/pci_old.c
> > create mode 100644 drivers/net/wireless/realtek/rtw88/pci_old.h
> >
> > diff --git a/drivers/net/wireless/realtek/rtw88/Makefile
> b/drivers/net/wireless/realtek/rtw88/Makefile
> > index 6889b3796449..d4007ca2b2ca 100644
> > --- a/drivers/net/wireless/realtek/rtw88/Makefile
> > +++ b/drivers/net/wireless/realtek/rtw88/Makefile
> > @@ -110,7 +110,7 @@ obj-$(CONFIG_RTW88_8814AU) += rtw88_8814au.o
> > rtw88_8814au-objs := rtw8814au.o
> >
> > obj-$(CONFIG_RTW88_PCI) += rtw88_pci.o
> > -rtw88_pci-objs := pci.o
> > +rtw88_pci-objs := pci.o pci_old.o
> >
> > obj-$(CONFIG_RTW88_SDIO) += rtw88_sdio.o
> > rtw88_sdio-objs := sdio.o
> > diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
> > index c51ad15cfba7..35f45e3ede81 100644
> > --- a/drivers/net/wireless/realtek/rtw88/pci.c
> > +++ b/drivers/net/wireless/realtek/rtw88/pci.c
> > @@ -16,7 +16,7 @@
> > #include "mac.h"
> >
> > static bool rtw_disable_msi;
> > -static bool rtw_pci_disable_aspm;
> > +bool rtw_pci_disable_aspm;
> > module_param_named(disable_msi, rtw_disable_msi, bool, 0644);
> > module_param_named(disable_aspm, rtw_pci_disable_aspm, bool, 0644);
> > MODULE_PARM_DESC(disable_msi, "Set Y to disable MSI interrupt support");
> > @@ -32,8 +32,7 @@ static const u32 rtw_pci_tx_queue_idx_addr[] = {
> > [RTW_TX_QUEUE_H2C] = RTK_PCI_TXBD_IDX_H2CQ,
> > };
> >
> > -static u8 rtw_pci_get_tx_qsel(struct sk_buff *skb,
> > - enum rtw_tx_queue_type queue)
> > +u8 rtw_pci_get_tx_qsel(struct sk_buff *skb, enum rtw_tx_queue_type queue)
> > {
> > switch (queue) {
> > case RTW_TX_QUEUE_BCN:
> > @@ -675,8 +674,8 @@ static void rtw_pci_deep_ps(struct rtw_dev *rtwdev, bool enter)
> > spin_unlock_bh(&rtwpci->irq_lock);
> > }
> >
> > -static void rtw_pci_release_rsvd_page(struct rtw_pci *rtwpci,
> > - struct rtw_pci_tx_ring *ring)
> > +void rtw_pci_release_rsvd_page(struct rtw_pci *rtwpci,
> > + struct rtw_pci_tx_ring *ring)
> > {
> > struct sk_buff *prev = skb_dequeue(&ring->queue);
> > struct rtw_pci_tx_data *tx_data;
> > diff --git a/drivers/net/wireless/realtek/rtw88/pci.h b/drivers/net/wireless/realtek/rtw88/pci.h
> > index 5ab78ba3255d..92532f842ebc 100644
> > --- a/drivers/net/wireless/realtek/rtw88/pci.h
> > +++ b/drivers/net/wireless/realtek/rtw88/pci.h
> > @@ -144,6 +144,8 @@
> > /* IMR 3 */
> > #define IMR_H2CDOK BIT(16)
> >
> > +extern bool rtw_pci_disable_aspm;
> > +
> > enum rtw_pci_flags {
> > RTW_PCI_FLAG_NAPI_RUNNING,
> >
> > @@ -268,6 +270,10 @@ extern const struct dev_pm_ops rtw_pm_ops;
> > extern const struct pci_error_handlers rtw_pci_err_handler;
> > extern const struct rtw_pci_gen rtw_pci_gen_new;
> >
> > +u8 rtw_pci_get_tx_qsel(struct sk_buff *skb, enum rtw_tx_queue_type queue);
> > +void rtw_pci_release_rsvd_page(struct rtw_pci *rtwpci,
> > + struct rtw_pci_tx_ring *ring);
> > +
> > int rtw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id);
> > void rtw_pci_remove(struct pci_dev *pdev);
> > void rtw_pci_shutdown(struct pci_dev *pdev);
> > diff --git a/drivers/net/wireless/realtek/rtw88/pci_old.c
> b/drivers/net/wireless/realtek/rtw88/pci_old.c
> > new file mode 100644
> > index 000000000000..464b57d8a629
> > --- /dev/null
> > +++ b/drivers/net/wireless/realtek/rtw88/pci_old.c
> > @@ -0,0 +1,522 @@
>
> [...]
>
> > +
> > +static void rtw_pci_old_clkreq_set(struct rtw_dev *rtwdev, bool enable)
> > +{
> > +}
> > +
> > +static void rtw_pci_old_aspm_set(struct rtw_dev *rtwdev, bool enable)
> > +{
> > + struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv;
> > + struct pci_dev *pdev = rtwpci->pdev;
> > +
> > + if (rtw_pci_disable_aspm)
> > + return;
> > +
> > + if (enable) {
> > + pcie_capability_set_word(pdev, PCI_EXP_LNKCTL,
> > + PCI_EXP_LNKCTL_CCC | PCI_EXP_LNKCTL_ASPMC);
> > +
> > + pcie_capability_set_word(pdev, PCI_EXP_LNKCTL,
> > + PCI_EXP_LNKCTL_CLKREQ_EN);
> > + } else {
> > + pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL,
> > + PCI_EXP_LNKCTL_CLKREQ_EN);
> > +
> > + pcie_capability_clear_and_set_word(pdev, PCI_EXP_LNKCTL,
> > + PCI_EXP_LNKCTL_CCC | PCI_EXP_LNKCTL_ASPMC,
> > + PCI_EXP_LNKCTL_CCC);
> > + }
>
> Is this the right way? rtw88 (pci.c) never writes PCI_EXP_LNKCTL,
> only reads it. Instead it uses DBI writes to RTK_PCIE_LINK_CFG to
> enable or disable BIT_L1_SW_EN and BIT_CLKREQ_SW_EN.
The rtw88 should not change the PCI standard capability normally,
because it should be PnP, BIOS or OS assign the values.
The RTK_PCIE_LINK_CFG is Realtek proprietary settings. rtw88 should
control this only.
About the DBI is an interface to access PCI configuration via
register space. Mostly, it can be replaced by pcie_capability_set_word()
(and its friends).
>
> rtlwifi writes PCI_EXP_LNKCTL as above, and additionally always
> writes RTK_PCIE_LINK_CFG to enable BIT_L1_SW_EN and BIT_CLKREQ_SW_EN
> in _rtl8821ae_enable_aspm_back_door().
>
> rtlwifi writes PCI_EXP_LNKCTL only when the device is probed, whereas
> rtw_pci_old_aspm_set() runs when LPS is enabled/disabled.
I have no idea about old design. What current rtw88 and rtw89 do is
suggested by hardware designers.
>
> Does the comment in rtw_pci_link_cfg() apply to this older design?
Yes.
>
> /* Though there is standard PCIE configuration space to set the
> * link control register, but by Realtek's design, driver should
> * check if host supports CLKREQ/ASPM to enable the HW module.
> *
> * These functions are implemented by two HW modules associated,
> * one is responsible to access PCIE configuration space to
> * follow the host settings, and another is in charge of doing
> * CLKREQ/ASPM mechanisms, it is default disabled. Because sometimes
> * the host does not support it, and due to some reasons or wrong
> * settings (ex. CLKREQ# not Bi-Direction), it could lead to device
> * loss if HW misbehaves on the link.
> *
> * Hence it's designed that driver should first check the PCIE
> * configuration space is sync'ed and enabled, then driver can turn
> * on the other module that is actually working on the mechanism.
> */
>
> (I'm looking at this again because BIT_CLKREQ_SW_EN is required
> for Wowlan. The card can't wake the laptop unless this bit is set.)
I'll check this bit internally and get back to you if any input.
next prev parent reply other threads:[~2026-11-25 1:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 22:57 [PATCH rtw-next 0/5] wifi: rtw88: pci: Support an older design, like RTL8821AE/RTL8812AE Bitterblue Smith
2026-10-23 22:59 ` [PATCH rtw-next 1/5] wifi: rtw88: Pass RX buffer to rtw_rx_query_rx_desc() Bitterblue Smith
2026-10-23 23:00 ` [PATCH rtw-next 2/5] wifi: rtw88: Pass TX descriptor to rtw_tx_fill_tx_desc() Bitterblue Smith
2026-10-23 23:01 ` [PATCH rtw-next 3/5] wifi: rtw88: pci: Introduce struct rtw_pci_gen Bitterblue Smith
2026-10-24 8:41 ` Luka Gejak
2026-10-28 21:26 ` Bitterblue Smith
2026-10-23 23:02 ` [PATCH rtw-next 4/5] wifi: rtw88: pci: Add functions to support older chips Bitterblue Smith
2026-10-24 8:36 ` Luka Gejak
2026-10-28 17:40 ` Bitterblue Smith
2026-11-24 19:54 ` Bitterblue Smith
2026-11-25 1:52 ` Ping-Ke Shih [this message]
2026-10-23 23:05 ` [PATCH rtw-next 5/5] wifi: rtw88: pci: Handle more RX interrupts for RTL8821AE Bitterblue Smith
2026-10-27 1:52 ` [PATCH rtw-next 0/5] wifi: rtw88: pci: Support an older design, like RTL8821AE/RTL8812AE Ping-Ke Shih
2026-10-27 7:25 ` Luka Gejak
2026-10-27 8:07 ` Ping-Ke Shih
2026-10-28 17:41 ` Bitterblue Smith
2026-10-29 0:51 ` Ping-Ke Shih
2026-10-29 1:29 ` Ping-Ke Shih
2026-10-29 21:00 ` Bitterblue Smith
2026-10-30 0:43 ` Ping-Ke Shih
2026-10-30 18:47 ` Bitterblue Smith
2026-10-31 7:42 ` Luka Gejak
2026-11-05 13:31 ` Bitterblue Smith
2026-11-13 10:46 ` Bitterblue Smith
2026-11-16 7:43 ` Ping-Ke Shih
2026-11-18 12:41 ` Bitterblue Smith
2026-11-19 5:48 ` Ping-Ke Shih
2026-11-23 21:10 ` Bitterblue Smith
2026-11-24 1:32 ` Ping-Ke Shih
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=fd5ab121d9214a299f8ff72a18a83fe2@realtek.com \
--to=pkshih@realtek.com \
--cc=linux-wireless@vger.kernel.org \
--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