--- /dev/null
+From 9ffdb67af0ee625ae127711845532f670cc6a4e7 Mon Sep 17 00:00:00 2001
+From: Imre Deak <imre.deak@intel.com>
+Date: Mon, 6 Feb 2023 13:48:55 +0200
+Subject: drm/display/dp_mst: Add drm_atomic_get_old_mst_topology_state()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Imre Deak <imre.deak@intel.com>
+
+commit 9ffdb67af0ee625ae127711845532f670cc6a4e7 upstream.
+
+Add a function to get the old MST topology state, required by a
+follow-up i915 patch.
+
+While at it clarify the code comment of
+drm_atomic_get_new_mst_topology_state() and add _new prefix
+to the new state pointer to remind about its difference from the old
+state.
+
+v2: Use old_/new_ prefixes for the state pointers. (Ville)
+
+Cc: Lyude Paul <lyude@redhat.com>
+Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
+Cc: stable@vger.kernel.org # 6.1
+Cc: dri-devel@lists.freedesktop.org
+Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
+Reviewed-by: Lyude Paul <lyude@redhat.com>
+Acked-by: Lyude Paul <lyude@redhat.com>
+Acked-by: Daniel Vetter <daniel@ffwll.ch>
+Acked-by: Wayne Lin <wayne.lin@amd.com>
+Acked-by: Jani Nikula <jani.nikula@intel.com>
+Signed-off-by: Imre Deak <imre.deak@intel.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20230206114856.2665066-3-imre.deak@intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/display/drm_dp_mst_topology.c | 33 ++++++++++++++++++++++----
+ include/drm/display/drm_dp_mst_helper.h | 3 ++
+ 2 files changed, 32 insertions(+), 4 deletions(-)
+
+--- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
++++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
+@@ -5355,27 +5355,52 @@ struct drm_dp_mst_topology_state *drm_at
+ EXPORT_SYMBOL(drm_atomic_get_mst_topology_state);
+
+ /**
++ * drm_atomic_get_old_mst_topology_state: get old MST topology state in atomic state, if any
++ * @state: global atomic state
++ * @mgr: MST topology manager, also the private object in this case
++ *
++ * This function wraps drm_atomic_get_old_private_obj_state() passing in the MST atomic
++ * state vtable so that the private object state returned is that of a MST
++ * topology object.
++ *
++ * Returns:
++ *
++ * The old MST topology state, or NULL if there's no topology state for this MST mgr
++ * in the global atomic state
++ */
++struct drm_dp_mst_topology_state *
++drm_atomic_get_old_mst_topology_state(struct drm_atomic_state *state,
++ struct drm_dp_mst_topology_mgr *mgr)
++{
++ struct drm_private_state *old_priv_state =
++ drm_atomic_get_old_private_obj_state(state, &mgr->base);
++
++ return old_priv_state ? to_dp_mst_topology_state(old_priv_state) : NULL;
++}
++EXPORT_SYMBOL(drm_atomic_get_old_mst_topology_state);
++
++/**
+ * drm_atomic_get_new_mst_topology_state: get new MST topology state in atomic state, if any
+ * @state: global atomic state
+ * @mgr: MST topology manager, also the private object in this case
+ *
+- * This function wraps drm_atomic_get_priv_obj_state() passing in the MST atomic
++ * This function wraps drm_atomic_get_new_private_obj_state() passing in the MST atomic
+ * state vtable so that the private object state returned is that of a MST
+ * topology object.
+ *
+ * Returns:
+ *
+- * The MST topology state, or NULL if there's no topology state for this MST mgr
++ * The new MST topology state, or NULL if there's no topology state for this MST mgr
+ * in the global atomic state
+ */
+ struct drm_dp_mst_topology_state *
+ drm_atomic_get_new_mst_topology_state(struct drm_atomic_state *state,
+ struct drm_dp_mst_topology_mgr *mgr)
+ {
+- struct drm_private_state *priv_state =
++ struct drm_private_state *new_priv_state =
+ drm_atomic_get_new_private_obj_state(state, &mgr->base);
+
+- return priv_state ? to_dp_mst_topology_state(priv_state) : NULL;
++ return new_priv_state ? to_dp_mst_topology_state(new_priv_state) : NULL;
+ }
+ EXPORT_SYMBOL(drm_atomic_get_new_mst_topology_state);
+
+--- a/include/drm/display/drm_dp_mst_helper.h
++++ b/include/drm/display/drm_dp_mst_helper.h
+@@ -867,6 +867,9 @@ struct drm_dp_mst_topology_state *
+ drm_atomic_get_mst_topology_state(struct drm_atomic_state *state,
+ struct drm_dp_mst_topology_mgr *mgr);
+ struct drm_dp_mst_topology_state *
++drm_atomic_get_old_mst_topology_state(struct drm_atomic_state *state,
++ struct drm_dp_mst_topology_mgr *mgr);
++struct drm_dp_mst_topology_state *
+ drm_atomic_get_new_mst_topology_state(struct drm_atomic_state *state,
+ struct drm_dp_mst_topology_mgr *mgr);
+ struct drm_dp_mst_atomic_payload *
--- /dev/null
+From f3221361dc85d4de22586ce8441ec2c67b454f5d Mon Sep 17 00:00:00 2001
+From: Jakub Kicinski <kuba@kernel.org>
+Date: Tue, 28 Feb 2023 16:28:57 -0800
+Subject: net: tls: avoid hanging tasks on the tx_lock
+
+From: Jakub Kicinski <kuba@kernel.org>
+
+commit f3221361dc85d4de22586ce8441ec2c67b454f5d upstream.
+
+syzbot sent a hung task report and Eric explains that adversarial
+receiver may keep RWIN at 0 for a long time, so we are not guaranteed
+to make forward progress. Thread which took tx_lock and went to sleep
+may not release tx_lock for hours. Use interruptible sleep where
+possible and reschedule the work if it can't take the lock.
+
+Testing: existing selftest passes
+
+Reported-by: syzbot+9c0268252b8ef967c62e@syzkaller.appspotmail.com
+Fixes: 79ffe6087e91 ("net/tls: add a TX lock")
+Link: https://lore.kernel.org/all/000000000000e412e905f5b46201@google.com/
+Cc: stable@vger.kernel.org # wait 4 weeks
+Reviewed-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/r/20230301002857.2101894-1-kuba@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/tls/tls_sw.c | 26 +++++++++++++++++++-------
+ 1 file changed, 19 insertions(+), 7 deletions(-)
+
+--- a/net/tls/tls_sw.c
++++ b/net/tls/tls_sw.c
+@@ -941,7 +941,9 @@ int tls_sw_sendmsg(struct sock *sk, stru
+ MSG_CMSG_COMPAT))
+ return -EOPNOTSUPP;
+
+- mutex_lock(&tls_ctx->tx_lock);
++ ret = mutex_lock_interruptible(&tls_ctx->tx_lock);
++ if (ret)
++ return ret;
+ lock_sock(sk);
+
+ if (unlikely(msg->msg_controllen)) {
+@@ -1275,7 +1277,9 @@ int tls_sw_sendpage(struct sock *sk, str
+ MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY))
+ return -EOPNOTSUPP;
+
+- mutex_lock(&tls_ctx->tx_lock);
++ ret = mutex_lock_interruptible(&tls_ctx->tx_lock);
++ if (ret)
++ return ret;
+ lock_sock(sk);
+ ret = tls_sw_do_sendpage(sk, page, offset, size, flags);
+ release_sock(sk);
+@@ -2416,11 +2420,19 @@ static void tx_work_handler(struct work_
+
+ if (!test_and_clear_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask))
+ return;
+- mutex_lock(&tls_ctx->tx_lock);
+- lock_sock(sk);
+- tls_tx_records(sk, -1);
+- release_sock(sk);
+- mutex_unlock(&tls_ctx->tx_lock);
++
++ if (mutex_trylock(&tls_ctx->tx_lock)) {
++ lock_sock(sk);
++ tls_tx_records(sk, -1);
++ release_sock(sk);
++ mutex_unlock(&tls_ctx->tx_lock);
++ } else if (!test_and_set_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask)) {
++ /* Someone is holding the tx_lock, they will likely run Tx
++ * and cancel the work on their way out of the lock section.
++ * Schedule a long delay just in case.
++ */
++ schedule_delayed_work(&ctx->tx_work.work, msecs_to_jiffies(10));
++ }
+ }
+
+ static bool tls_is_tx_ready(struct tls_sw_context_tx *ctx)
iommu-attach-device-group-to-old-domain-in-error-pat.patch
soundwire-cadence-remove-wasted-space-in-response_bu.patch
soundwire-cadence-drain-the-rx-fifo-after-an-io-time.patch
+net-tls-avoid-hanging-tasks-on-the-tx_lock.patch
+x86-resctl-fix-scheduler-confusion-with-current.patch
+vdpa-ifcvf-decouple-hw-features-manipulators-from-the-adapter.patch
+vdpa-ifcvf-decouple-config-space-ops-from-the-adapter.patch
+vdpa-ifcvf-alloc-the-mgmt_dev-before-the-adapter.patch
+vdpa-ifcvf-decouple-vq-irq-releasers-from-the-adapter.patch
+vdpa-ifcvf-decouple-config-irq-releaser-from-the-adapter.patch
+vdpa-ifcvf-decouple-vq-irq-requester-from-the-adapter.patch
+vdpa-ifcvf-decouple-config-dev-irq-requester-and-vectors-allocator-from-the-adapter.patch
+vdpa-ifcvf-ifcvf_request_irq-works-on-ifcvf_hw.patch
+vdpa-ifcvf-manage-ifcvf_hw-in-the-mgmt_dev.patch
+vdpa-ifcvf-allocate-the-adapter-in-dev_add.patch
+drm-display-dp_mst-add-drm_atomic_get_old_mst_topology_state.patch
--- /dev/null
+From 66e3970b16d1e960afbece65739a3628273633f1 Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:15 +0800
+Subject: vDPA/ifcvf: alloc the mgmt_dev before the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit 66e3970b16d1e960afbece65739a3628273633f1 upstream.
+
+This commit reverses the order of allocating the
+management device and the adapter. So that it would
+be possible to move the allocation of the adapter
+to dev_add().
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-4-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 31 ++++++++++++++-----------------
+ 1 file changed, 14 insertions(+), 17 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -831,22 +831,30 @@ static int ifcvf_probe(struct pci_dev *p
+ }
+
+ pci_set_master(pdev);
++ ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL);
++ if (!ifcvf_mgmt_dev) {
++ IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n");
++ return -ENOMEM;
++ }
+
+ adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
+ dev, &ifc_vdpa_ops, 1, 1, NULL, false);
+ if (IS_ERR(adapter)) {
+ IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
+- return PTR_ERR(adapter);
++ ret = PTR_ERR(adapter);
++ goto err;
+ }
+
++ adapter->pdev = pdev;
++ adapter->vdpa.dma_dev = &pdev->dev;
++ adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev;
++ ifcvf_mgmt_dev->adapter = adapter;
++
+ vf = &adapter->vf;
+ vf->dev_type = get_dev_type(pdev);
+ vf->base = pcim_iomap_table(pdev);
+ vf->pdev = pdev;
+
+- adapter->pdev = pdev;
+- adapter->vdpa.dma_dev = &pdev->dev;
+-
+ ret = ifcvf_init_hw(vf, pdev);
+ if (ret) {
+ IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");
+@@ -859,16 +867,6 @@ static int ifcvf_probe(struct pci_dev *p
+ vf->hw_features = ifcvf_get_hw_features(vf);
+ vf->config_size = ifcvf_get_config_size(vf);
+
+- ifcvf_mgmt_dev = kzalloc(sizeof(struct ifcvf_vdpa_mgmt_dev), GFP_KERNEL);
+- if (!ifcvf_mgmt_dev) {
+- IFCVF_ERR(pdev, "Failed to alloc memory for the vDPA management device\n");
+- return -ENOMEM;
+- }
+-
+- ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops;
+- ifcvf_mgmt_dev->mdev.device = dev;
+- ifcvf_mgmt_dev->adapter = adapter;
+-
+ dev_type = get_dev_type(pdev);
+ switch (dev_type) {
+ case VIRTIO_ID_NET:
+@@ -883,12 +881,11 @@ static int ifcvf_probe(struct pci_dev *p
+ goto err;
+ }
+
++ ifcvf_mgmt_dev->mdev.ops = &ifcvf_vdpa_mgmt_dev_ops;
++ ifcvf_mgmt_dev->mdev.device = dev;
+ ifcvf_mgmt_dev->mdev.max_supported_vqs = vf->nr_vring;
+ ifcvf_mgmt_dev->mdev.supported_features = vf->hw_features;
+
+- adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev;
+-
+-
+ ret = vdpa_mgmtdev_register(&ifcvf_mgmt_dev->mdev);
+ if (ret) {
+ IFCVF_ERR(pdev,
--- /dev/null
+From 93139037b582134deb1ed894bbc4bc1d34ff35e7 Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:22 +0800
+Subject: vDPA/ifcvf: allocate the adapter in dev_add()
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit 93139037b582134deb1ed894bbc4bc1d34ff35e7 upstream.
+
+The adapter is the container of the vdpa_device,
+this commits allocate the adapter in dev_add()
+rather than in probe(). So that the vdpa_device()
+could be re-created when the userspace creates
+the vdpa device, and free-ed in dev_del()
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-11-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 34 +++++++++++++---------------------
+ 1 file changed, 13 insertions(+), 21 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -746,12 +746,20 @@ static int ifcvf_vdpa_dev_add(struct vdp
+ int ret;
+
+ ifcvf_mgmt_dev = container_of(mdev, struct ifcvf_vdpa_mgmt_dev, mdev);
+- if (!ifcvf_mgmt_dev->adapter)
+- return -EOPNOTSUPP;
++ vf = &ifcvf_mgmt_dev->vf;
++ pdev = vf->pdev;
++ adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
++ &pdev->dev, &ifc_vdpa_ops, 1, 1, NULL, false);
++ if (IS_ERR(adapter)) {
++ IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
++ return PTR_ERR(adapter);
++ }
+
+- adapter = ifcvf_mgmt_dev->adapter;
+- vf = adapter->vf;
+- pdev = adapter->pdev;
++ ifcvf_mgmt_dev->adapter = adapter;
++ adapter->pdev = pdev;
++ adapter->vdpa.dma_dev = &pdev->dev;
++ adapter->vdpa.mdev = mdev;
++ adapter->vf = vf;
+ vdpa_dev = &adapter->vdpa;
+
+ if (name)
+@@ -769,7 +777,6 @@ static int ifcvf_vdpa_dev_add(struct vdp
+ return 0;
+ }
+
+-
+ static void ifcvf_vdpa_dev_del(struct vdpa_mgmt_dev *mdev, struct vdpa_device *dev)
+ {
+ struct ifcvf_vdpa_mgmt_dev *ifcvf_mgmt_dev;
+@@ -788,7 +795,6 @@ static int ifcvf_probe(struct pci_dev *p
+ {
+ struct ifcvf_vdpa_mgmt_dev *ifcvf_mgmt_dev;
+ struct device *dev = &pdev->dev;
+- struct ifcvf_adapter *adapter;
+ struct ifcvf_hw *vf;
+ u32 dev_type;
+ int ret, i;
+@@ -825,24 +831,10 @@ static int ifcvf_probe(struct pci_dev *p
+ return -ENOMEM;
+ }
+
+- adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
+- dev, &ifc_vdpa_ops, 1, 1, NULL, false);
+- if (IS_ERR(adapter)) {
+- IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
+- ret = PTR_ERR(adapter);
+- goto err;
+- }
+-
+- adapter->pdev = pdev;
+- adapter->vdpa.dma_dev = &pdev->dev;
+- adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev;
+- ifcvf_mgmt_dev->adapter = adapter;
+-
+ vf = &ifcvf_mgmt_dev->vf;
+ vf->dev_type = get_dev_type(pdev);
+ vf->base = pcim_iomap_table(pdev);
+ vf->pdev = pdev;
+- adapter->vf = vf;
+
+ ret = ifcvf_init_hw(vf, pdev);
+ if (ret) {
--- /dev/null
+From a70d833e696e538a0feff5e539086c74a90ddf90 Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:19 +0800
+Subject: vDPA/ifcvf: decouple config/dev IRQ requester and vectors allocator from the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit a70d833e696e538a0feff5e539086c74a90ddf90 upstream.
+
+This commit decouples the config irq requester, the device
+shared irq requester and the MSI vectors allocator from
+the adapter. So they can be safely invoked since probe
+before the adapter is allocated.
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-8-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 21 +++++++++------------
+ 1 file changed, 9 insertions(+), 12 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -132,10 +132,9 @@ static void ifcvf_free_irq(struct ifcvf_
+ * It returns the number of allocated vectors, negative
+ * return value when fails.
+ */
+-static int ifcvf_alloc_vectors(struct ifcvf_adapter *adapter)
++static int ifcvf_alloc_vectors(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+ int max_intr, ret;
+
+ /* all queues and config interrupt */
+@@ -222,10 +221,9 @@ err:
+ return -EFAULT;
+ }
+
+-static int ifcvf_request_dev_irq(struct ifcvf_adapter *adapter)
++static int ifcvf_request_dev_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+ int i, vector, ret, irq;
+
+ vector = 0;
+@@ -276,10 +274,9 @@ static int ifcvf_request_vq_irq(struct i
+ return ret;
+ }
+
+-static int ifcvf_request_config_irq(struct ifcvf_adapter *adapter)
++static int ifcvf_request_config_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+ int config_vector, ret;
+
+ if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
+@@ -322,7 +319,7 @@ static int ifcvf_request_irq(struct ifcv
+ struct ifcvf_hw *vf = &adapter->vf;
+ int nvectors, ret, max_intr;
+
+- nvectors = ifcvf_alloc_vectors(adapter);
++ nvectors = ifcvf_alloc_vectors(vf);
+ if (nvectors <= 0)
+ return -EFAULT;
+
+@@ -333,7 +330,7 @@ static int ifcvf_request_irq(struct ifcv
+
+ if (nvectors == 1) {
+ vf->msix_vector_status = MSIX_VECTOR_DEV_SHARED;
+- ret = ifcvf_request_dev_irq(adapter);
++ ret = ifcvf_request_dev_irq(vf);
+
+ return ret;
+ }
+@@ -342,7 +339,7 @@ static int ifcvf_request_irq(struct ifcv
+ if (ret)
+ return ret;
+
+- ret = ifcvf_request_config_irq(adapter);
++ ret = ifcvf_request_config_irq(vf);
+
+ if (ret)
+ return ret;
--- /dev/null
+From 23dac55cec3afdbc1b4eaed1c79f2cee00477f8b Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:17 +0800
+Subject: vDPA/ifcvf: decouple config IRQ releaser from the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit 23dac55cec3afdbc1b4eaed1c79f2cee00477f8b upstream.
+
+This commit decouples config IRQ releaser from the adapter,
+so that it could be invoked once probe or in err handlers.
+ifcvf_free_irq() works on ifcvf_hw in this commit
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-6-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 22 ++++++++++------------
+ 1 file changed, 10 insertions(+), 12 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -101,10 +101,9 @@ static void ifcvf_free_vq_irq(struct ifc
+ ifcvf_free_vqs_reused_irq(vf);
+ }
+
+-static void ifcvf_free_config_irq(struct ifcvf_adapter *adapter)
++static void ifcvf_free_config_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+
+ if (vf->config_irq == -EINVAL)
+ return;
+@@ -119,13 +118,12 @@ static void ifcvf_free_config_irq(struct
+ }
+ }
+
+-static void ifcvf_free_irq(struct ifcvf_adapter *adapter)
++static void ifcvf_free_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+
+ ifcvf_free_vq_irq(vf);
+- ifcvf_free_config_irq(adapter);
++ ifcvf_free_config_irq(vf);
+ ifcvf_free_irq_vectors(pdev);
+ }
+
+@@ -187,7 +185,7 @@ static int ifcvf_request_per_vq_irq(stru
+
+ return 0;
+ err:
+- ifcvf_free_irq(adapter);
++ ifcvf_free_irq(vf);
+
+ return -EFAULT;
+ }
+@@ -221,7 +219,7 @@ static int ifcvf_request_vqs_reused_irq(
+
+ return 0;
+ err:
+- ifcvf_free_irq(adapter);
++ ifcvf_free_irq(vf);
+
+ return -EFAULT;
+ }
+@@ -262,7 +260,7 @@ static int ifcvf_request_dev_irq(struct
+
+ return 0;
+ err:
+- ifcvf_free_irq(adapter);
++ ifcvf_free_irq(vf);
+
+ return -EFAULT;
+
+@@ -317,7 +315,7 @@ static int ifcvf_request_config_irq(stru
+
+ return 0;
+ err:
+- ifcvf_free_irq(adapter);
++ ifcvf_free_irq(vf);
+
+ return -EFAULT;
+ }
+@@ -508,7 +506,7 @@ static int ifcvf_vdpa_reset(struct vdpa_
+
+ if (status_old & VIRTIO_CONFIG_S_DRIVER_OK) {
+ ifcvf_stop_datapath(adapter);
+- ifcvf_free_irq(adapter);
++ ifcvf_free_irq(vf);
+ }
+
+ ifcvf_reset_vring(adapter);
--- /dev/null
+From af8eb69a62b73a2ce5f91575453534ac07f06eb4 Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:14 +0800
+Subject: vDPA/ifcvf: decouple config space ops from the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit af8eb69a62b73a2ce5f91575453534ac07f06eb4 upstream.
+
+This commit decopules the config space ops from the
+adapter layer, so these functions can be invoked
+once the device is probed.
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-3-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_base.c | 21 +++++----------------
+ 1 file changed, 5 insertions(+), 16 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_base.c
++++ b/drivers/vdpa/ifcvf/ifcvf_base.c
+@@ -10,11 +10,6 @@
+
+ #include "ifcvf_base.h"
+
+-struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw)
+-{
+- return container_of(hw, struct ifcvf_adapter, vf);
+-}
+-
+ u16 ifcvf_set_vq_vector(struct ifcvf_hw *hw, u16 qid, int vector)
+ {
+ struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
+@@ -37,8 +32,6 @@ u16 ifcvf_set_config_vector(struct ifcvf
+ static void __iomem *get_cap_addr(struct ifcvf_hw *hw,
+ struct virtio_pci_cap *cap)
+ {
+- struct ifcvf_adapter *ifcvf;
+- struct pci_dev *pdev;
+ u32 length, offset;
+ u8 bar;
+
+@@ -46,17 +39,14 @@ static void __iomem *get_cap_addr(struct
+ offset = le32_to_cpu(cap->offset);
+ bar = cap->bar;
+
+- ifcvf= vf_to_adapter(hw);
+- pdev = ifcvf->pdev;
+-
+ if (bar >= IFCVF_PCI_MAX_RESOURCE) {
+- IFCVF_DBG(pdev,
++ IFCVF_DBG(hw->pdev,
+ "Invalid bar number %u to get capabilities\n", bar);
+ return NULL;
+ }
+
+- if (offset + length > pci_resource_len(pdev, bar)) {
+- IFCVF_DBG(pdev,
++ if (offset + length > pci_resource_len(hw->pdev, bar)) {
++ IFCVF_DBG(hw->pdev,
+ "offset(%u) + len(%u) overflows bar%u's capability\n",
+ offset, length, bar);
+ return NULL;
+@@ -92,6 +82,7 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, s
+ IFCVF_ERR(pdev, "Failed to read PCI capability list\n");
+ return -EIO;
+ }
++ hw->pdev = pdev;
+
+ while (pos) {
+ ret = ifcvf_read_config_range(pdev, (u32 *)&cap,
+@@ -230,13 +221,11 @@ int ifcvf_verify_min_features(struct ifc
+
+ u32 ifcvf_get_config_size(struct ifcvf_hw *hw)
+ {
+- struct ifcvf_adapter *adapter;
+ u32 net_config_size = sizeof(struct virtio_net_config);
+ u32 blk_config_size = sizeof(struct virtio_blk_config);
+ u32 cap_size = hw->cap_dev_config_size;
+ u32 config_size;
+
+- adapter = vf_to_adapter(hw);
+ /* If the onboard device config space size is greater than
+ * the size of struct virtio_net/blk_config, only the spec
+ * implementing contents size is returned, this is very
+@@ -251,7 +240,7 @@ u32 ifcvf_get_config_size(struct ifcvf_h
+ break;
+ default:
+ config_size = 0;
+- IFCVF_ERR(adapter->pdev, "VIRTIO ID %u not supported\n", hw->dev_type);
++ IFCVF_ERR(hw->pdev, "VIRTIO ID %u not supported\n", hw->dev_type);
+ }
+
+ return config_size;
--- /dev/null
+From d59f633dd05940739b5f46f5d4403cafb91d2742 Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:13 +0800
+Subject: vDPA/ifcvf: decouple hw features manipulators from the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit d59f633dd05940739b5f46f5d4403cafb91d2742 upstream.
+
+This commit gets rid of ifcvf_adapter in hw features related
+functions in ifcvf_base. Then these functions are more rubust
+and de-coupling from the ifcvf_adapter layer. So these
+functions could be invoded once the device is probed, even
+before the adapter is allocaed.
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-2-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_base.c | 9 ++-------
+ drivers/vdpa/ifcvf/ifcvf_base.h | 1 +
+ drivers/vdpa/ifcvf/ifcvf_main.c | 1 +
+ 3 files changed, 4 insertions(+), 7 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_base.c
++++ b/drivers/vdpa/ifcvf/ifcvf_base.c
+@@ -220,10 +220,8 @@ u64 ifcvf_get_features(struct ifcvf_hw *
+
+ int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features)
+ {
+- struct ifcvf_adapter *ifcvf = vf_to_adapter(hw);
+-
+ if (!(features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM)) && features) {
+- IFCVF_ERR(ifcvf->pdev, "VIRTIO_F_ACCESS_PLATFORM is not negotiated\n");
++ IFCVF_ERR(hw->pdev, "VIRTIO_F_ACCESS_PLATFORM is not negotiated\n");
+ return -EINVAL;
+ }
+
+@@ -301,14 +299,11 @@ static void ifcvf_set_features(struct if
+
+ static int ifcvf_config_features(struct ifcvf_hw *hw)
+ {
+- struct ifcvf_adapter *ifcvf;
+-
+- ifcvf = vf_to_adapter(hw);
+ ifcvf_set_features(hw, hw->req_features);
+ ifcvf_add_status(hw, VIRTIO_CONFIG_S_FEATURES_OK);
+
+ if (!(ifcvf_get_status(hw) & VIRTIO_CONFIG_S_FEATURES_OK)) {
+- IFCVF_ERR(ifcvf->pdev, "Failed to set FEATURES_OK status\n");
++ IFCVF_ERR(hw->pdev, "Failed to set FEATURES_OK status\n");
+ return -EIO;
+ }
+
+--- a/drivers/vdpa/ifcvf/ifcvf_base.h
++++ b/drivers/vdpa/ifcvf/ifcvf_base.h
+@@ -89,6 +89,7 @@ struct ifcvf_hw {
+ u16 nr_vring;
+ /* VIRTIO_PCI_CAP_DEVICE_CFG size */
+ u32 cap_dev_config_size;
++ struct pci_dev *pdev;
+ };
+
+ struct ifcvf_adapter {
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -842,6 +842,7 @@ static int ifcvf_probe(struct pci_dev *p
+ vf = &adapter->vf;
+ vf->dev_type = get_dev_type(pdev);
+ vf->base = pcim_iomap_table(pdev);
++ vf->pdev = pdev;
+
+ adapter->pdev = pdev;
+ adapter->vdpa.dma_dev = &pdev->dev;
--- /dev/null
+From 004cbcabab46d9346e2524c4eedd71ea57fe4f3c Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:16 +0800
+Subject: vDPA/ifcvf: decouple vq IRQ releasers from the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit 004cbcabab46d9346e2524c4eedd71ea57fe4f3c upstream.
+
+This commit decouples the IRQ releasers from the
+adapter, so that these functions could be
+safely invoked once probe
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-5-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 21 +++++++++------------
+ 1 file changed, 9 insertions(+), 12 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -69,10 +69,9 @@ static void ifcvf_free_irq_vectors(void
+ pci_free_irq_vectors(data);
+ }
+
+-static void ifcvf_free_per_vq_irq(struct ifcvf_adapter *adapter)
++static void ifcvf_free_per_vq_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+ int i;
+
+ for (i = 0; i < vf->nr_vring; i++) {
+@@ -83,10 +82,9 @@ static void ifcvf_free_per_vq_irq(struct
+ }
+ }
+
+-static void ifcvf_free_vqs_reused_irq(struct ifcvf_adapter *adapter)
++static void ifcvf_free_vqs_reused_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+
+ if (vf->vqs_reused_irq != -EINVAL) {
+ devm_free_irq(&pdev->dev, vf->vqs_reused_irq, vf);
+@@ -95,14 +93,12 @@ static void ifcvf_free_vqs_reused_irq(st
+
+ }
+
+-static void ifcvf_free_vq_irq(struct ifcvf_adapter *adapter)
++static void ifcvf_free_vq_irq(struct ifcvf_hw *vf)
+ {
+- struct ifcvf_hw *vf = &adapter->vf;
+-
+ if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
+- ifcvf_free_per_vq_irq(adapter);
++ ifcvf_free_per_vq_irq(vf);
+ else
+- ifcvf_free_vqs_reused_irq(adapter);
++ ifcvf_free_vqs_reused_irq(vf);
+ }
+
+ static void ifcvf_free_config_irq(struct ifcvf_adapter *adapter)
+@@ -126,8 +122,9 @@ static void ifcvf_free_config_irq(struct
+ static void ifcvf_free_irq(struct ifcvf_adapter *adapter)
+ {
+ struct pci_dev *pdev = adapter->pdev;
++ struct ifcvf_hw *vf = &adapter->vf;
+
+- ifcvf_free_vq_irq(adapter);
++ ifcvf_free_vq_irq(vf);
+ ifcvf_free_config_irq(adapter);
+ ifcvf_free_irq_vectors(pdev);
+ }
--- /dev/null
+From f9a9ffb2e4dbde81090416fc51662441c2a7b73b Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:18 +0800
+Subject: vDPA/ifcvf: decouple vq irq requester from the adapter
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit f9a9ffb2e4dbde81090416fc51662441c2a7b73b upstream.
+
+This commit decouples the vq irq requester from the adapter,
+so that these functions can be invoked since probe.
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-7-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 19 ++++++++-----------
+ 1 file changed, 8 insertions(+), 11 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -155,10 +155,9 @@ static int ifcvf_alloc_vectors(struct if
+ return ret;
+ }
+
+-static int ifcvf_request_per_vq_irq(struct ifcvf_adapter *adapter)
++static int ifcvf_request_per_vq_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+ int i, vector, ret, irq;
+
+ vf->vqs_reused_irq = -EINVAL;
+@@ -190,10 +189,9 @@ err:
+ return -EFAULT;
+ }
+
+-static int ifcvf_request_vqs_reused_irq(struct ifcvf_adapter *adapter)
++static int ifcvf_request_vqs_reused_irq(struct ifcvf_hw *vf)
+ {
+- struct pci_dev *pdev = adapter->pdev;
+- struct ifcvf_hw *vf = &adapter->vf;
++ struct pci_dev *pdev = vf->pdev;
+ int i, vector, ret, irq;
+
+ vector = 0;
+@@ -266,15 +264,14 @@ err:
+
+ }
+
+-static int ifcvf_request_vq_irq(struct ifcvf_adapter *adapter)
++static int ifcvf_request_vq_irq(struct ifcvf_hw *vf)
+ {
+- struct ifcvf_hw *vf = &adapter->vf;
+ int ret;
+
+ if (vf->msix_vector_status == MSIX_VECTOR_PER_VQ_AND_CONFIG)
+- ret = ifcvf_request_per_vq_irq(adapter);
++ ret = ifcvf_request_per_vq_irq(vf);
+ else
+- ret = ifcvf_request_vqs_reused_irq(adapter);
++ ret = ifcvf_request_vqs_reused_irq(vf);
+
+ return ret;
+ }
+@@ -341,7 +338,7 @@ static int ifcvf_request_irq(struct ifcv
+ return ret;
+ }
+
+- ret = ifcvf_request_vq_irq(adapter);
++ ret = ifcvf_request_vq_irq(vf);
+ if (ret)
+ return ret;
+
--- /dev/null
+From 7cfd36b7e8be6bdaeb5af0f9729871b732a7a3c8 Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:20 +0800
+Subject: vDPA/ifcvf: ifcvf_request_irq works on ifcvf_hw
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit 7cfd36b7e8be6bdaeb5af0f9729871b732a7a3c8 upstream.
+
+All ifcvf_request_irq's callees are refactored
+to work on ifcvf_hw, so it should be decoupled
+from the adapter as well
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-9-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_main.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -314,9 +314,8 @@ err:
+ return -EFAULT;
+ }
+
+-static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
++static int ifcvf_request_irq(struct ifcvf_hw *vf)
+ {
+- struct ifcvf_hw *vf = &adapter->vf;
+ int nvectors, ret, max_intr;
+
+ nvectors = ifcvf_alloc_vectors(vf);
+@@ -468,7 +467,7 @@ static void ifcvf_vdpa_set_status(struct
+
+ if ((status & VIRTIO_CONFIG_S_DRIVER_OK) &&
+ !(status_old & VIRTIO_CONFIG_S_DRIVER_OK)) {
+- ret = ifcvf_request_irq(adapter);
++ ret = ifcvf_request_irq(vf);
+ if (ret) {
+ status = ifcvf_get_status(vf);
+ status |= VIRTIO_CONFIG_S_FAILED;
--- /dev/null
+From 6a3b2f179b49f2c6452ecc37b4778a43848b454c Mon Sep 17 00:00:00 2001
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+Date: Fri, 25 Nov 2022 22:57:21 +0800
+Subject: vDPA/ifcvf: manage ifcvf_hw in the mgmt_dev
+
+From: Zhu Lingshan <lingshan.zhu@intel.com>
+
+commit 6a3b2f179b49f2c6452ecc37b4778a43848b454c upstream.
+
+This commit allocates the hw structure in the
+management device structure. So the hardware
+can be initialized once the management device
+is allocated in probe.
+
+Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
+Cc: stable@vger.kernel.org
+Message-Id: <20221125145724.1129962-10-lingshan.zhu@intel.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/vdpa/ifcvf/ifcvf_base.h | 5 +++--
+ drivers/vdpa/ifcvf/ifcvf_main.c | 7 ++++---
+ 2 files changed, 7 insertions(+), 5 deletions(-)
+
+--- a/drivers/vdpa/ifcvf/ifcvf_base.h
++++ b/drivers/vdpa/ifcvf/ifcvf_base.h
+@@ -39,7 +39,7 @@
+ #define IFCVF_INFO(pdev, fmt, ...) dev_info(&pdev->dev, fmt, ##__VA_ARGS__)
+
+ #define ifcvf_private_to_vf(adapter) \
+- (&((struct ifcvf_adapter *)adapter)->vf)
++ (((struct ifcvf_adapter *)adapter)->vf)
+
+ /* all vqs and config interrupt has its own vector */
+ #define MSIX_VECTOR_PER_VQ_AND_CONFIG 1
+@@ -95,7 +95,7 @@ struct ifcvf_hw {
+ struct ifcvf_adapter {
+ struct vdpa_device vdpa;
+ struct pci_dev *pdev;
+- struct ifcvf_hw vf;
++ struct ifcvf_hw *vf;
+ };
+
+ struct ifcvf_vring_lm_cfg {
+@@ -110,6 +110,7 @@ struct ifcvf_lm_cfg {
+
+ struct ifcvf_vdpa_mgmt_dev {
+ struct vdpa_mgmt_dev mdev;
++ struct ifcvf_hw vf;
+ struct ifcvf_adapter *adapter;
+ struct pci_dev *pdev;
+ };
+--- a/drivers/vdpa/ifcvf/ifcvf_main.c
++++ b/drivers/vdpa/ifcvf/ifcvf_main.c
+@@ -402,7 +402,7 @@ static struct ifcvf_hw *vdpa_to_vf(struc
+ {
+ struct ifcvf_adapter *adapter = vdpa_to_adapter(vdpa_dev);
+
+- return &adapter->vf;
++ return adapter->vf;
+ }
+
+ static u64 ifcvf_vdpa_get_device_features(struct vdpa_device *vdpa_dev)
+@@ -750,7 +750,7 @@ static int ifcvf_vdpa_dev_add(struct vdp
+ return -EOPNOTSUPP;
+
+ adapter = ifcvf_mgmt_dev->adapter;
+- vf = &adapter->vf;
++ vf = adapter->vf;
+ pdev = adapter->pdev;
+ vdpa_dev = &adapter->vdpa;
+
+@@ -838,10 +838,11 @@ static int ifcvf_probe(struct pci_dev *p
+ adapter->vdpa.mdev = &ifcvf_mgmt_dev->mdev;
+ ifcvf_mgmt_dev->adapter = adapter;
+
+- vf = &adapter->vf;
++ vf = &ifcvf_mgmt_dev->vf;
+ vf->dev_type = get_dev_type(pdev);
+ vf->base = pcim_iomap_table(pdev);
+ vf->pdev = pdev;
++ adapter->vf = vf;
+
+ ret = ifcvf_init_hw(vf, pdev);
+ if (ret) {
--- /dev/null
+From 7fef099702527c3b2c5234a2ea6a24411485a13a Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Tue, 7 Mar 2023 13:06:29 -0800
+Subject: x86/resctl: fix scheduler confusion with 'current'
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit 7fef099702527c3b2c5234a2ea6a24411485a13a upstream.
+
+The implementation of 'current' on x86 is very intentionally special: it
+is a very common thing to look up, and it uses 'this_cpu_read_stable()'
+to get the current thread pointer efficiently from per-cpu storage.
+
+And the keyword in there is 'stable': the current thread pointer never
+changes as far as a single thread is concerned. Even if when a thread
+is preempted, or moved to another CPU, or even across an explicit call
+'schedule()' that thread will still have the same value for 'current'.
+
+It is, after all, the kernel base pointer to thread-local storage.
+That's why it's stable to begin with, but it's also why it's important
+enough that we have that special 'this_cpu_read_stable()' access for it.
+
+So this is all done very intentionally to allow the compiler to treat
+'current' as a value that never visibly changes, so that the compiler
+can do CSE and combine multiple different 'current' accesses into one.
+
+However, there is obviously one very special situation when the
+currently running thread does actually change: inside the scheduler
+itself.
+
+So the scheduler code paths are special, and do not have a 'current'
+thread at all. Instead there are _two_ threads: the previous and the
+next thread - typically called 'prev' and 'next' (or prev_p/next_p)
+internally.
+
+So this is all actually quite straightforward and simple, and not all
+that complicated.
+
+Except for when you then have special code that is run in scheduler
+context, that code then has to be aware that 'current' isn't really a
+valid thing. Did you mean 'prev'? Did you mean 'next'?
+
+In fact, even if then look at the code, and you use 'current' after the
+new value has been assigned to the percpu variable, we have explicitly
+told the compiler that 'current' is magical and always stable. So the
+compiler is quite free to use an older (or newer) value of 'current',
+and the actual assignment to the percpu storage is not relevant even if
+it might look that way.
+
+Which is exactly what happened in the resctl code, that blithely used
+'current' in '__resctrl_sched_in()' when it really wanted the new
+process state (as implied by the name: we're scheduling 'into' that new
+resctl state). And clang would end up just using the old thread pointer
+value at least in some configurations.
+
+This could have happened with gcc too, and purely depends on random
+compiler details. Clang just seems to have been more aggressive about
+moving the read of the per-cpu current_task pointer around.
+
+The fix is trivial: just make the resctl code adhere to the scheduler
+rules of using the prev/next thread pointer explicitly, instead of using
+'current' in a situation where it just wasn't valid.
+
+That same code is then also used outside of the scheduler context (when
+a thread resctl state is explicitly changed), and then we will just pass
+in 'current' as that pointer, of course. There is no ambiguity in that
+case.
+
+The fix may be trivial, but noticing and figuring out what went wrong
+was not. The credit for that goes to Stephane Eranian.
+
+Reported-by: Stephane Eranian <eranian@google.com>
+Link: https://lore.kernel.org/lkml/20230303231133.1486085-1-eranian@google.com/
+Link: https://lore.kernel.org/lkml/alpine.LFD.2.01.0908011214330.3304@localhost.localdomain/
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Tested-by: Tony Luck <tony.luck@intel.com>
+Tested-by: Stephane Eranian <eranian@google.com>
+Tested-by: Babu Moger <babu.moger@amd.com>
+Cc: stable@kernel.org
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/include/asm/resctrl.h | 12 ++++++------
+ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++--
+ arch/x86/kernel/process_32.c | 2 +-
+ arch/x86/kernel/process_64.c | 2 +-
+ 4 files changed, 10 insertions(+), 10 deletions(-)
+
+--- a/arch/x86/include/asm/resctrl.h
++++ b/arch/x86/include/asm/resctrl.h
+@@ -51,7 +51,7 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_
+ * simple as possible.
+ * Must be called with preemption disabled.
+ */
+-static void __resctrl_sched_in(void)
++static inline void __resctrl_sched_in(struct task_struct *tsk)
+ {
+ struct resctrl_pqr_state *state = this_cpu_ptr(&pqr_state);
+ u32 closid = state->default_closid;
+@@ -63,13 +63,13 @@ static void __resctrl_sched_in(void)
+ * Else use the closid/rmid assigned to this cpu.
+ */
+ if (static_branch_likely(&rdt_alloc_enable_key)) {
+- tmp = READ_ONCE(current->closid);
++ tmp = READ_ONCE(tsk->closid);
+ if (tmp)
+ closid = tmp;
+ }
+
+ if (static_branch_likely(&rdt_mon_enable_key)) {
+- tmp = READ_ONCE(current->rmid);
++ tmp = READ_ONCE(tsk->rmid);
+ if (tmp)
+ rmid = tmp;
+ }
+@@ -90,17 +90,17 @@ static inline unsigned int resctrl_arch_
+ return val * scale;
+ }
+
+-static inline void resctrl_sched_in(void)
++static inline void resctrl_sched_in(struct task_struct *tsk)
+ {
+ if (static_branch_likely(&rdt_enable_key))
+- __resctrl_sched_in();
++ __resctrl_sched_in(tsk);
+ }
+
+ void resctrl_cpu_detect(struct cpuinfo_x86 *c);
+
+ #else
+
+-static inline void resctrl_sched_in(void) {}
++static inline void resctrl_sched_in(struct task_struct *tsk) {}
+ static inline void resctrl_cpu_detect(struct cpuinfo_x86 *c) {}
+
+ #endif /* CONFIG_X86_CPU_RESCTRL */
+--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
++++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+@@ -314,7 +314,7 @@ static void update_cpu_closid_rmid(void
+ * executing task might have its own closid selected. Just reuse
+ * the context switch code.
+ */
+- resctrl_sched_in();
++ resctrl_sched_in(current);
+ }
+
+ /*
+@@ -535,7 +535,7 @@ static void _update_task_closid_rmid(voi
+ * Otherwise, the MSR is updated when the task is scheduled in.
+ */
+ if (task == current)
+- resctrl_sched_in();
++ resctrl_sched_in(task);
+ }
+
+ static void update_task_closid_rmid(struct task_struct *t)
+--- a/arch/x86/kernel/process_32.c
++++ b/arch/x86/kernel/process_32.c
+@@ -212,7 +212,7 @@ __switch_to(struct task_struct *prev_p,
+ switch_fpu_finish();
+
+ /* Load the Intel cache allocation PQR MSR. */
+- resctrl_sched_in();
++ resctrl_sched_in(next_p);
+
+ return prev_p;
+ }
+--- a/arch/x86/kernel/process_64.c
++++ b/arch/x86/kernel/process_64.c
+@@ -656,7 +656,7 @@ __switch_to(struct task_struct *prev_p,
+ }
+
+ /* Load the Intel cache allocation PQR MSR. */
+- resctrl_sched_in();
++ resctrl_sched_in(next_p);
+
+ return prev_p;
+ }