On 11/20/2023 2:15 AM, Kang Yang wrote: > On some platforms it's not possible to allocate 32 MSI vectors for > various reasons, maybe kernel configuration, VT-d disabled, buggy BIOS > etc. So ath12k was not able to use WCN7850 PCI devices on those > platforms. Add support for one MSI vector to solve that. > > In case of one MSI vector, interrupt migration needs to be disabled. > This is because when interrupt migration happens, the msi_data may > change. However, msi_data is already programmed to rings during initial > phase and ath12k has no way to know that msi_data is changed during run > time and reprogram again. > > In case of one MSI vector, MHI subsystem should not use IRQF_NO_SUSPEND > as WCN7850 doesn't set this flag too. Ath12k doesn't need to leave IRQ > enabled in suspend state. > > Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4 > > Signed-off-by: Kang Yang <quic_kangyang@xxxxxxxxxxx> > --- > drivers/net/wireless/ath/ath12k/mhi.c | 16 +++++++-- > drivers/net/wireless/ath/ath12k/pci.c | 51 ++++++++++++++++++++------- > 2 files changed, 52 insertions(+), 15 deletions(-) ... > diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c > index 3bb2d622dc52..4484bac18f4e 100644 > --- a/drivers/net/wireless/ath/ath12k/pci.c > +++ b/drivers/net/wireless/ath/ath12k/pci.c ... > @@ -713,18 +731,26 @@ static int ath12k_pci_msi_alloc(struct ath12k_pci *ab_pci) > msi_config->total_vectors, > msi_config->total_vectors, > PCI_IRQ_MSI); > - if (num_vectors != msi_config->total_vectors) { > - ath12k_err(ab, "failed to get %d MSI vectors, only %d available", > - msi_config->total_vectors, num_vectors); > > - if (num_vectors >= 0) > - return -EINVAL; > - else > - return num_vectors; > - } else { > + if (num_vectors == msi_config->total_vectors) { > set_bit(ATH12K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags); > ab_pci->irq_flags = IRQF_SHARED; > + } else { > + num_vectors = pci_alloc_irq_vectors(ab_pci->pdev, > + 1, > + 1, > + PCI_IRQ_MSI); > + if (num_vectors < 0) { > + ret = -EINVAL; > + goto reset_msi_config; > + } > + clear_bit(ATH12K_PCI_FLAG_MULTI_MSI_VECTORS, &ab_pci->flags); > + ab_pci->msi_config = &msi_config_one_msi; > + ab_pci->irq_flags = IRQF_SHARED | IRQF_NOBALANCING; > + ath12k_dbg(ab, ATH12K_DBG_PCI, "request MSI one vector\n"); > + ath12k-check is flagging this: drivers/net/wireless/ath/ath12k/pci.c:761: Blank lines aren't necessary before a close brace '}' < > } > + ath12k_info(ab, "MSI vectors: %d\n", num_vectors); > > ath12k_pci_msi_disable(ab_pci); >