From 200610d19187cfd44f9fe0a92436b7c1bb6166b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
 <marmarek@invisiblethingslab.com>
Date: Fri, 13 Sep 2024 17:25:52 +0200
Subject: [PATCH] Apply the FLR reset quirk before calling the reset too

If device got reset in between some other way, the AF FLR capability
would not be visible. Make sure such action still doesn't break device
reset.

QubesOS/qubes-issues#9356
---
 ...I-add-a-reset-quirk-for-Intel-I219LM-ethernet-adap.patch | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/0001-PCI-add-a-reset-quirk-for-Intel-I219LM-ethernet-adap.patch b/0001-PCI-add-a-reset-quirk-for-Intel-I219LM-ethernet-adap.patch
index 3c7c37ff..fb35398c 100644
--- a/0001-PCI-add-a-reset-quirk-for-Intel-I219LM-ethernet-adap.patch
+++ b/0001-PCI-add-a-reset-quirk-for-Intel-I219LM-ethernet-adap.patch
@@ -51,7 +51,7 @@ diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
 index 568410e64ce6..9b77e6182500 100644
 --- a/drivers/pci/quirks.c
 +++ b/drivers/pci/quirks.c
-@@ -4194,6 +4194,70 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)
+@@ -4194,6 +4194,74 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)
  	return 0;
  }
  
@@ -108,6 +108,10 @@ index 568410e64ce6..9b77e6182500 100644
 +{
 +	int ret;
 +
++	/* Ensure AF FLR is visible before using it */
++	if (!probe)
++		fixup_intel_i219lm_flr(dev);
++
 +	/* Call normal FLR, but re-apply fixup_intel_i219lm_flr() afterwards. */
 +	ret = pci_af_flr(dev, probe);
 +	if (ret)