Commit 79066903 authored by Yu-Yen Ting's avatar Yu-Yen Ting Committed by Kalle Valo

rtw88: pci: enable MSI interrupt

MSI interrupt should be enabled on certain platform.

Add a module parameter disable_msi to disable MSI interrupt,
driver will then use legacy interrupt instead.

One could rebind the PCI device, probe() will pick up the
new value of the module parameter. Such as:

    echo '0000:01:00.0' > /sys/bus/pci/drivers/rtw_pci/unbind
    echo '0000:01:00.0' > /sys/bus/pci/drivers/rtw_pci/bind
Tested-by: default avatarJán Veselý <jano.vesely@gmail.com>
Reviewed-by: default avatarBrian Norris <briannorris@chromium.org>
Reviewed-by: default avatarDaniel Drake <drake@endlessm.com>
Signed-off-by: default avatarYu-Yen Ting <steventing@realtek.com>
Signed-off-by: default avatarYan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent b3d07736
......@@ -11,6 +11,10 @@
#include "fw.h"
#include "debug.h"
static bool rtw_disable_msi;
module_param_named(disable_msi, rtw_disable_msi, bool, 0644);
MODULE_PARM_DESC(disable_msi, "Set Y to disable MSI interrupt support");
static u32 rtw_pci_tx_queue_idx_addr[] = {
[RTW_TX_QUEUE_BK] = RTK_PCI_TXBD_IDX_BKQ,
[RTW_TX_QUEUE_BE] = RTK_PCI_TXBD_IDX_BEQ,
......@@ -873,6 +877,11 @@ static irqreturn_t rtw_pci_interrupt_handler(int irq, void *dev)
/* disable RTW PCI interrupt to avoid more interrupts before the end of
* thread function
*
* disable HIMR here to also avoid new HISR flag being raised before
* the HISRs have been Write-1-cleared for MSI. If not all of the HISRs
* are cleared, the edge-triggered interrupt will not be generated when
* a new HISR flag is set.
*/
rtw_pci_disable_interrupt(rtwdev, rtwpci);
out:
......@@ -1116,6 +1125,38 @@ static struct rtw_hci_ops rtw_pci_ops = {
.write_data_h2c = rtw_pci_write_data_h2c,
};
static int rtw_pci_request_irq(struct rtw_dev *rtwdev, struct pci_dev *pdev)
{
unsigned int flags = PCI_IRQ_LEGACY;
int ret;
if (!rtw_disable_msi)
flags |= PCI_IRQ_MSI;
ret = pci_alloc_irq_vectors(pdev, 1, 1, flags);
if (ret < 0) {
rtw_err(rtwdev, "failed to alloc PCI irq vectors\n");
return ret;
}
ret = devm_request_threaded_irq(rtwdev->dev, pdev->irq,
rtw_pci_interrupt_handler,
rtw_pci_interrupt_threadfn,
IRQF_SHARED, KBUILD_MODNAME, rtwdev);
if (ret) {
rtw_err(rtwdev, "failed to request irq %d\n", ret);
pci_free_irq_vectors(pdev);
}
return ret;
}
static void rtw_pci_free_irq(struct rtw_dev *rtwdev, struct pci_dev *pdev)
{
devm_free_irq(rtwdev->dev, pdev->irq, rtwdev);
pci_free_irq_vectors(pdev);
}
static int rtw_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
......@@ -1170,10 +1211,7 @@ static int rtw_pci_probe(struct pci_dev *pdev,
goto err_destroy_pci;
}
ret = devm_request_threaded_irq(rtwdev->dev, pdev->irq,
rtw_pci_interrupt_handler,
rtw_pci_interrupt_threadfn,
IRQF_SHARED, KBUILD_MODNAME, rtwdev);
ret = rtw_pci_request_irq(rtwdev, pdev);
if (ret) {
ieee80211_unregister_hw(hw);
goto err_destroy_pci;
......@@ -1212,7 +1250,7 @@ static void rtw_pci_remove(struct pci_dev *pdev)
rtw_pci_disable_interrupt(rtwdev, rtwpci);
rtw_pci_destroy(rtwdev, pdev);
rtw_pci_declaim(rtwdev, pdev);
devm_free_irq(rtwdev->dev, rtwpci->pdev->irq, rtwdev);
rtw_pci_free_irq(rtwdev, pdev);
rtw_core_deinit(rtwdev);
ieee80211_free_hw(hw);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment