From: Ross Lagerwall <ross.lagerwall@citrix.com>
To: netdev@vger.kernel.org
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
Javi Merino <javi.merino@kernel.org>,
intel-wired-lan@lists.osuosl.org,
Ross Lagerwall <ross.lagerwall@citrix.com>
Subject: [Intel-wired-lan] [PATCH v2] ice: Fix enabling SR-IOV with Xen
Date: Mon, 29 Apr 2024 13:49:22 +0100 [thread overview]
Message-ID: <20240429124922.2872002-1-ross.lagerwall@citrix.com> (raw)
When the PCI functions are created, Xen is informed about them and
caches the number of MSI-X entries each function has. However, the
number of MSI-X entries is not set until after the hardware has been
configured and the VFs have been started. This prevents
PCI-passthrough from working because Xen rejects mapping MSI-X
interrupts to domains because it thinks the MSI-X interrupts don't
exist.
Fix this by moving the call to pci_enable_sriov() later so that the
number of MSI-X entries is set correctly in hardware by the time Xen
reads it.
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Javi Merino <javi.merino@kernel.org>
---
In v2:
* Fix cleanup on if pci_enable_sriov() fails.
drivers/net/ethernet/intel/ice/ice_sriov.c | 23 +++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index a958fcf3e6be..bc97493046a8 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -864,6 +864,8 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
int total_vectors = pf->hw.func_caps.common_cap.num_msix_vectors;
struct device *dev = ice_pf_to_dev(pf);
struct ice_hw *hw = &pf->hw;
+ struct ice_vf *vf;
+ unsigned int bkt;
int ret;
pf->sriov_irq_bm = bitmap_zalloc(total_vectors, GFP_KERNEL);
@@ -877,24 +879,20 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
set_bit(ICE_OICR_INTR_DIS, pf->state);
ice_flush(hw);
- ret = pci_enable_sriov(pf->pdev, num_vfs);
- if (ret)
- goto err_unroll_intr;
-
mutex_lock(&pf->vfs.table_lock);
ret = ice_set_per_vf_res(pf, num_vfs);
if (ret) {
dev_err(dev, "Not enough resources for %d VFs, err %d. Try with fewer number of VFs\n",
num_vfs, ret);
- goto err_unroll_sriov;
+ goto err_unroll_intr;
}
ret = ice_create_vf_entries(pf, num_vfs);
if (ret) {
dev_err(dev, "Failed to allocate VF entries for %d VFs\n",
num_vfs);
- goto err_unroll_sriov;
+ goto err_unroll_intr;
}
ice_eswitch_reserve_cp_queues(pf, num_vfs);
@@ -905,6 +903,10 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
goto err_unroll_vf_entries;
}
+ ret = pci_enable_sriov(pf->pdev, num_vfs);
+ if (ret)
+ goto err_unroll_start_vfs;
+
clear_bit(ICE_VF_DIS, pf->state);
/* rearm global interrupts */
@@ -915,12 +917,15 @@ static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
return 0;
+err_unroll_start_vfs:
+ ice_for_each_vf(pf, bkt, vf) {
+ ice_dis_vf_mappings(vf);
+ ice_vf_vsi_release(vf);
+ }
err_unroll_vf_entries:
ice_free_vf_entries(pf);
-err_unroll_sriov:
- mutex_unlock(&pf->vfs.table_lock);
- pci_disable_sriov(pf->pdev);
err_unroll_intr:
+ mutex_unlock(&pf->vfs.table_lock);
/* rearm interrupts here */
ice_irq_dynamic_ena(hw, NULL, NULL);
clear_bit(ICE_OICR_INTR_DIS, pf->state);
--
2.43.0
next reply other threads:[~2024-04-29 12:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 12:49 Ross Lagerwall [this message]
2024-04-29 13:04 ` [Intel-wired-lan] [PATCH v2] ice: Fix enabling SR-IOV with Xen Paul Menzel
2024-04-30 9:03 ` Ross Lagerwall
2024-05-08 9:23 ` Sergey Temerkhanov
2024-05-06 21:27 ` Tony Nguyen
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=20240429124922.2872002-1-ross.lagerwall@citrix.com \
--to=ross.lagerwall@citrix.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=javi.merino@kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).