wifi: ath11k: workaround to use VMs
PATCH 1/1 wifi: ath11k: workaround to use VMs
Currently, this driver is not working when the device is handled in a Virtual Machine (PCI pass-through), as it was already reported here:
https://lore.kernel.org/all/[email protected]/T/
Baochen Qiang focused the problem and described how to have it working for a specific real MSI vector from host that needs to be used in VM too. And this value, as it was commented, can change.
The problem seems complex to me and I don't know if there is any easy way to solve it. Meanwhile and using the information from Baochen Qiang, since the use of VMs is very interesting for testing procedures, I would like to just add this workaround that consists on adding a parameter to pass the real MSI vector from host to the VM. In that way, checking the 'lscpi' command output from host, it could be handled manually or with some user tool in order to have the VM with the driver working. Of course, if this parameter is not configured (zero value and default), we will have the same behavior as always.
--- drivers/net/wireless/ath/ath11k/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/wireless/ath/ath11k/pci.c +20 -0
@@ -31,6 +31,11 @@#define TCSR_SOC_HW_SUB_VER 0x1910010 +static ulong ath11k_host_msi_addr =0 ; +module_param_named (host_msi_addr, ath11k_host_msi_addr, ulong,0644 ); +MODULE_PARM_DESC (host_msi_addr, +"Workaround to configure the MSI address that is used from host in order to be used in VM" ); +static const struct pci_device_id ath11k_pci_id_table[] = { {PCI_VDEVICE (QCOM ,QCA6390_DEVICE_ID ) }, {PCI_VDEVICE (QCOM ,WCN6855_DEVICE_ID ) },
@@ -443,6 +448,18 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci)ath11k_pci_msi_disable (ab_pci); +if (ath11k_host_msi_addr) { + ab_pci->ab->pci.msi.ep_base_data =0 ; + ab->pci.msi.addr_hi = (u32)(ath11k_host_msi_addr >>32 ); + ab->pci.msi.addr_lo = (u32)(ath11k_host_msi_addr &0xffffffff ); + +ath11k_dbg (ab,ATH11K_DBG_PCI ,"msi addr hi 0x%x lo 0x%x base data is %d\n" , + ab->pci.msi.addr_hi, + ab->pci.msi.addr_lo, + ab->pci.msi.ep_base_data); +return 0 ; + } + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab,"msi_desc is NULL!\n" );
@@ -482,6 +499,9 @@ static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) {struct msi_desc *msi_desc; +if (ath11k_host_msi_addr) +return 0 ; + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab_pci->ab,"msi_desc is NULL!\n" );
Signature · 1 line
2.44.0
Quoted 58 lines · Jose Ignacio Tornos Martinez
Currently, this driver is not working when the device is handled in a Virtual Machine (PCI pass-through), as it was already reported here:
https://lore.kernel.org/all/[email protected]/T/
Baochen Qiang focused the problem and described how to have it working for a specific real MSI vector from host that needs to be used in VM too. And this value, as it was commented, can change.The problem seems complex to me and I don't know if there is any easy way to solve it. Meanwhile and using the information from Baochen Qiang, since the use of VMs is very interesting for testing procedures, I would like to just add this workaround that consists on adding a parameter to pass the real MSI vector from host to the VM. In that way, checking the 'lscpi' command output from host, it could be handled manually or with some user tool in order to have the VM with the driver working. Of course, if this parameter is not configured (zero value and default), we will have the same behavior as always.
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>--- drivers/net/wireless/ath/ath11k/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/net/wireless/ath/ath11k/pci.c +17
-0@@ -31,6 +31,11 @@#define TCSR_SOC_HW_SUB_VER 0x1910010 +static ulong ath11k_host_msi_addr =0 ; +module_param_named (host_msi_addr, ath11k_host_msi_addr, ulong,0644 ); +MODULE_PARM_DESC (host_msi_addr, +"Workaround to configure the MSI address that is used from host in order to be used in VM" ); +static const struct pci_device_id ath11k_pci_id_table[] = { {PCI_VDEVICE (QCOM ,QCA6390_DEVICE_ID ) }, {PCI_VDEVICE (QCOM ,WCN6855_DEVICE_ID ) },@@ -443,6 +448,18 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci)ath11k_pci_msi_disable (ab_pci); +if (ath11k_host_msi_addr) { + ab_pci->ab->pci.msi.ep_base_data =0 ; + ab->pci.msi.addr_hi = (u32)(ath11k_host_msi_addr >>32 ); + ab->pci.msi.addr_lo = (u32)(ath11k_host_msi_addr &0xffffffff ); + +ath11k_dbg (ab,ATH11K_DBG_PCI ,"msi addr hi 0x%x lo 0x%x base data is %d\n" , + ab->pci.msi.addr_hi, + ab->pci.msi.addr_lo, + ab->pci.msi.ep_base_data); +return 0 ; + } + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab,"msi_desc is NULL!\n" );
drivers/net/wireless/ath/ath11k/pci.c static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) · line 507
Quoted 9 lines
drivers/net/wireless/ath/ath11k/pci.c +3
-0@@ -482,6 +499,9 @@ static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) {struct msi_desc *msi_desc; +if (ath11k_host_msi_addr) +return 0 ; + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab_pci->ab,"msi_desc is NULL!\n" );
+ [email protected] to make sure the Qualcomm VM experts are aware of this issue and to see if they have any additional suggestions.
Quoted 62 lines · Jeff Johnson
Quoted 61 lines · Jose Ignacio Tornos Martinez
Currently, this driver is not working when the device is handled in a Virtual Machine (PCI pass-through), as it was already reported here:
https://lore.kernel.org/all/[email protected]/T/
Baochen Qiang focused the problem and described how to have it working for a specific real MSI vector from host that needs to be used in VM too. And this value, as it was commented, can change.The problem seems complex to me and I don't know if there is any easy way to solve it. Meanwhile and using the information from Baochen Qiang, since the use of VMs is very interesting for testing procedures, I would like to just add this workaround that consists on adding a parameter to pass the real MSI vector from host to the VM. In that way, checking the 'lscpi' command output from host, it could be handled manually or with some user tool in order to have the VM with the driver working. Of course, if this parameter is not configured (zero value and default), we will have the same behavior as always.
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>--- drivers/net/wireless/ath/ath11k/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/net/wireless/ath/ath11k/pci.c +17
-0@@ -31,6 +31,11 @@#define TCSR_SOC_HW_SUB_VER 0x1910010 +static ulong ath11k_host_msi_addr =0 ; +module_param_named (host_msi_addr, ath11k_host_msi_addr, ulong,0644 ); +MODULE_PARM_DESC (host_msi_addr, +"Workaround to configure the MSI address that is used from host in order to be used in VM" ); +static const struct pci_device_id ath11k_pci_id_table[] = { {PCI_VDEVICE (QCOM ,QCA6390_DEVICE_ID ) }, {PCI_VDEVICE (QCOM ,WCN6855_DEVICE_ID ) },@@ -443,6 +448,18 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci)ath11k_pci_msi_disable (ab_pci); +if (ath11k_host_msi_addr) { + ab_pci->ab->pci.msi.ep_base_data =0 ; + ab->pci.msi.addr_hi = (u32)(ath11k_host_msi_addr >>32 ); + ab->pci.msi.addr_lo = (u32)(ath11k_host_msi_addr &0xffffffff ); + +ath11k_dbg (ab,ATH11K_DBG_PCI ,"msi addr hi 0x%x lo 0x%x base data is %d\n" , + ab->pci.msi.addr_hi, + ab->pci.msi.addr_lo, + ab->pci.msi.ep_base_data); +return 0 ; + } + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab,"msi_desc is NULL!\n" );@@ -482,6 +499,9 @@ static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) {struct msi_desc *msi_desc;
Quoted 10 lines
drivers/net/wireless/ath/ath11k/pci.c static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) · line 507
Quoted 6 lines
drivers/net/wireless/ath/ath11k/pci.c +3
-0+if (ath11k_host_msi_addr) +return 0 ; + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab_pci->ab,"msi_desc is NULL!\n" );+ [email protected] to make sure the Qualcomm VM experts are aware of this issue and to see if they have any additional suggestions.
If limit the fix/WAR to be within ath11k, not touching vfio or any other related module, I was imagining that if hardware could map the standard MSI registers in config space to some private MMIO registers so VM ath11k could read, or that if firmware could read them and send to VM ath11k via QMI interface? don't know if it is feasible to hardware/firmware.
Quoted 1 line
Quoted 27 lines · Jose Ignacio Tornos Martinez
Currently, this driver is not working when the device is handled in a Virtual Machine (PCI pass-through), as it was already reported here:
https://lore.kernel.org/all/[email protected]/T/
Baochen Qiang focused the problem and described how to have it working for a specific real MSI vector from host that needs to be used in VM too. And this value, as it was commented, can change.The problem seems complex to me and I don't know if there is any easy way to solve it. Meanwhile and using the information from Baochen Qiang, since the use of VMs is very interesting for testing procedures, I would like to just add this workaround that consists on adding a parameter to pass the real MSI vector from host to the VM. In that way, checking the 'lscpi' command output from host, it could be handled manually or with some user tool in order to have the VM with the driver working. Of course, if this parameter is not configured (zero value and default), we will have the same behavior as always.
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>--- drivers/net/wireless/ath/ath11k/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/net/wireless/ath/ath11k/pci.c +0
-0
drivers/net/wireless/ath/ath11k/pci.c line 37
Quoted 7 lines
drivers/net/wireless/ath/ath11k/pci.c +4
-0@@ -31,6 +31,11 @@#define TCSR_SOC_HW_SUB_VER 0x1910010 +static ulong ath11k_host_msi_addr =0 ; +module_param_named (host_msi_addr, ath11k_host_msi_addr, ulong,0644 ); +MODULE_PARM_DESC (host_msi_addr, +"Workaround to configure the MSI address that is used from host in order to be used in VM" );
MSI vector contains two parts: the address and the data. So you need to add a parameter for MSI data as well.
drivers/net/wireless/ath/ath11k/pci.c static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci) · line 452
Quoted 10 lines
drivers/net/wireless/ath/ath11k/pci.c +3
-0+static const struct pci_device_id ath11k_pci_id_table[] = { {PCI_VDEVICE (QCOM ,QCA6390_DEVICE_ID ) }, {PCI_VDEVICE (QCOM ,WCN6855_DEVICE_ID ) },@@ -443,6 +448,18 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci)ath11k_pci_msi_disable (ab_pci); +if (ath11k_host_msi_addr) { + ab_pci->ab->pci.msi.ep_base_data =0 ;
Here, I guess you are assigning 0 because I gave it in my example. But it is not always that, it changes from machine to machine, configuration to configuration, and even time to time.
The right way should be to use the MSI data parameter mentioned above.
Quoted 23 lines
drivers/net/wireless/ath/ath11k/pci.c +13
-0+ ab->pci.msi.addr_hi = (u32)(ath11k_host_msi_addr >>32 ); + ab->pci.msi.addr_lo = (u32)(ath11k_host_msi_addr &0xffffffff ); + +ath11k_dbg (ab,ATH11K_DBG_PCI ,"msi addr hi 0x%x lo 0x%x base data is %d\n" , + ab->pci.msi.addr_hi, + ab->pci.msi.addr_lo, + ab->pci.msi.ep_base_data); +return 0 ; + } + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab,"msi_desc is NULL!\n" );@@ -482,6 +499,9 @@ static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) {struct msi_desc *msi_desc; +if (ath11k_host_msi_addr) +return 0 ; + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab_pci->ab,"msi_desc is NULL!\n" );
Thank you for your comments.
I don't have seen any change in MSI vector data but if it can be different from zero I will complete it.
Best regards
José Ignacio
PATCH v2 1/1 wifi: ath11k: workaround to use VMs
In reply to Baochen QiangCurrently, this driver is not working when the device is handled in a Virtual Machine (PCI pass-through), as it was already reported here:
https://lore.kernel.org/all/[email protected]/T/
Baochen Qiang focused the problem and described how to have it working for a specific real MSI vector from host that needs to be used in VM too. And this value, as it was commented, can change.
The problem seems complex to me and I don't know if there is any easy way to solve it (with no more information, not hardware/firmware related help or VMM action).
Meanwhile and using the information from Baochen Qiang, since the use of VMs is very interesting for testing procedures, I would like to include this workaround that consists on adding two parameters to pass the real MSI vector address and data from host to the VM.
In that way, checking the 'lscpi' command output from host, it could be handled manually or with some user tool in order to have the VM with the driver working.
Of course, if the workaround is not used, that is if MSI vector address parameter is not configured (zero value and default), we will have the same behavior as always.
---
V1 -> V2:
- Add parameter for msi vector data as Baochen Qiang suggests.
drivers/net/wireless/ath/ath11k/pci.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/net/wireless/ath/ath11k/pci.c +24 -0
@@ -31,6 +31,15 @@#define TCSR_SOC_HW_SUB_VER 0x1910010 +static ulong ath11k_host_msi_vector_addr =0 ; +module_param_named (host_msi_vector_addr, ath11k_host_msi_vector_addr, ulong,0644 ); +MODULE_PARM_DESC (host_msi_vector_addr, +"Workaround to configure the MSI vector address that is used from host in order to be used in VM" ); +static uint ath11k_host_msi_vector_data =0 ; +module_param_named (host_msi_vector_data, ath11k_host_msi_vector_data, uint,0644 ); +MODULE_PARM_DESC (host_msi_vector_data, +"Workaround to configure the MSI vector data that is used from host in order to be used in VM" ); +static const struct pci_device_id ath11k_pci_id_table[] = { {PCI_VDEVICE (QCOM ,QCA6390_DEVICE_ID ) }, {PCI_VDEVICE (QCOM ,WCN6855_DEVICE_ID ) },
@@ -443,6 +452,18 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci)ath11k_pci_msi_disable (ab_pci); +if (ath11k_host_msi_vector_addr) { + ab_pci->ab->pci.msi.ep_base_data = ath11k_host_msi_vector_data; + ab->pci.msi.addr_hi = (u32)(ath11k_host_msi_vector_addr >>32 ); + ab->pci.msi.addr_lo = (u32)(ath11k_host_msi_vector_addr &0xffffffff ); + +ath11k_dbg (ab,ATH11K_DBG_PCI ,"msi addr hi 0x%x lo 0x%x base data is %d\n" , + ab->pci.msi.addr_hi, + ab->pci.msi.addr_lo, + ab->pci.msi.ep_base_data); +return 0 ; + } + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab,"msi_desc is NULL!\n" );
@@ -482,6 +503,9 @@ static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) {struct msi_desc *msi_desc; +if (ath11k_host_msi_vector_addr) +return 0 ; + msi_desc =irq_get_msi_desc (ab_pci->pdev->irq);if (!msi_desc) {ath11k_err (ab_pci->ab,"msi_desc is NULL!\n" );
Signature · 1 line
2.44.0