Message ID | 20220421120903.73715-5-pkshih@realtek.com |
---|---|
State | New |
Headers | show |
Series | rtw89: 8852c: extend PCI code to support 8852ce and add 8852c chip_ops | expand |
Ping-Ke Shih <pkshih@realtek.com> wrote: > In lower power mode, there are very low amount of RX, and it must process > in a separated function instead of schedule_napi(), because the existing > napi_poll does many things to optimize performance, but not all registers > can access in low power mode. The simple way is to use threadfn to process > the simple thing. > > Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> The title is hard to understand.
Kalle Valo <kvalo@kernel.org> writes: > Ping-Ke Shih <pkshih@realtek.com> wrote: > >> In lower power mode, there are very low amount of RX, and it must process >> in a separated function instead of schedule_napi(), because the existing >> napi_poll does many things to optimize performance, but not all registers >> can access in low power mode. The simple way is to use threadfn to process >> the simple thing. >> >> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> > > The title is hard to understand. If you can provide a new title I can fix it during commit.
On Sat, 2022-04-23 at 15:37 +0300, Kalle Valo wrote: > Kalle Valo <kvalo@kernel.org> writes: > > > Ping-Ke Shih <pkshih@realtek.com> wrote: > > > > > In lower power mode, there are very low amount of RX, and it must process > > > in a separated function instead of schedule_napi(), because the existing > > > napi_poll does many things to optimize performance, but not all registers > > > can access in low power mode. The simple way is to use threadfn to process > > > the simple thing. > > > > > > Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> > > > > The title is hard to understand. > > If you can provide a new title I can fix it during commit. > Please help re-title to "rtw89: pci: add a separated interrupt handler for low power mode". Thank you Ping-Ke
Pkshih <pkshih@realtek.com> writes: > On Sat, 2022-04-23 at 15:37 +0300, Kalle Valo wrote: >> Kalle Valo <kvalo@kernel.org> writes: >> >> > Ping-Ke Shih <pkshih@realtek.com> wrote: >> > >> > > In lower power mode, there are very low amount of RX, and it must process >> > > in a separated function instead of schedule_napi(), because the existing >> > > napi_poll does many things to optimize performance, but not all registers >> > > can access in low power mode. The simple way is to use threadfn to process >> > > the simple thing. >> > > >> > > Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> >> > >> > The title is hard to understand. >> >> If you can provide a new title I can fix it during commit. >> > > Please help re-title to "rtw89: pci: add a separated interrupt handler for low power mode". This is much better, thanks. I'll update the title during commit.
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c index 6e8a65b021ce4..796b205854ac6 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -1420,7 +1420,10 @@ static void rtw89_core_rx_to_mac80211(struct rtw89_dev *rtwdev, { rtw89_core_hw_to_sband_rate(rx_status); rtw89_core_rx_stats(rtwdev, phy_ppdu, desc_info, skb_ppdu); + /* In low power mode, it does RX in thread context. */ + local_bh_disable(); ieee80211_rx_napi(rtwdev->hw, NULL, skb_ppdu, &rtwdev->napi); + local_bh_enable(); rtwdev->napi_budget_countdown--; } diff --git a/drivers/net/wireless/realtek/rtw89/pci.c b/drivers/net/wireless/realtek/rtw89/pci.c index c1bb44bcd48e1..e8bcecbe77e14 100644 --- a/drivers/net/wireless/realtek/rtw89/pci.c +++ b/drivers/net/wireless/realtek/rtw89/pci.c @@ -713,6 +713,18 @@ static void rtw89_pci_ops_recovery_complete(struct rtw89_dev *rtwdev) spin_unlock_irqrestore(&rtwpci->irq_lock, flags); } +static void rtw89_pci_low_power_interrupt_handler(struct rtw89_dev *rtwdev) +{ + struct rtw89_pci *rtwpci = (struct rtw89_pci *)rtwdev->priv; + int budget = NAPI_POLL_WEIGHT; + + /* To prevent RXQ get stuck due to run out of budget. */ + rtwdev->napi_budget_countdown = budget; + + rtw89_pci_poll_rpq_dma(rtwdev, rtwpci, budget); + rtw89_pci_poll_rxq_dma(rtwdev, rtwpci, budget); +} + static irqreturn_t rtw89_pci_interrupt_threadfn(int irq, void *dev) { struct rtw89_dev *rtwdev = dev; @@ -733,6 +745,11 @@ static irqreturn_t rtw89_pci_interrupt_threadfn(int irq, void *dev) if (unlikely(rtwpci->under_recovery)) return IRQ_HANDLED; + if (unlikely(rtwpci->low_power)) { + rtw89_pci_low_power_interrupt_handler(rtwdev); + goto enable_intr; + } + if (likely(rtwpci->running)) { local_bh_disable(); napi_schedule(&rtwdev->napi); @@ -740,6 +757,12 @@ static irqreturn_t rtw89_pci_interrupt_threadfn(int irq, void *dev) } return IRQ_HANDLED; + +enable_intr: + spin_lock_irqsave(&rtwpci->irq_lock, flags); + rtw89_chip_enable_intr(rtwdev, rtwpci); + spin_unlock_irqrestore(&rtwpci->irq_lock, flags); + return IRQ_HANDLED; } static irqreturn_t rtw89_pci_interrupt_handler(int irq, void *dev)
In lower power mode, there are very low amount of RX, and it must process in a separated function instead of schedule_napi(), because the existing napi_poll does many things to optimize performance, but not all registers can access in low power mode. The simple way is to use threadfn to process the simple thing. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> --- drivers/net/wireless/realtek/rtw89/core.c | 3 +++ drivers/net/wireless/realtek/rtw89/pci.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+)