git: 5473dee73005 - main - Hyper-V: vPCI: Write back original BAR values after prepopulating bars

From: Wei Hu <whu_at_FreeBSD.org>
Date: Wed, 30 Mar 2022 07:11:15 UTC
The branch main has been updated by whu:

URL: https://cgit.FreeBSD.org/src/commit/?id=5473dee7300507de64c2e6c140b87c9bde8e4462

commit 5473dee7300507de64c2e6c140b87c9bde8e4462
Author:     Wei Hu <whu@FreeBSD.org>
AuthorDate: 2022-03-30 06:56:09 +0000
Commit:     Wei Hu <whu@FreeBSD.org>
CommitDate: 2022-03-30 06:56:09 +0000

    Hyper-V: vPCI: Write back original BAR values after prepopulating bars
    
    In vmbus_pcib_prepopulate_bars(), after writing all 1's to the
    avialable device bars, those without being configured by device driver
    are also set to its initialized values. However, this could cause
    weird problem which results to device failure. The issue has been
    reported to happen on LSI 9211-8i HBA card for DDA access on Hyper-V.
    Writing back the orignal BAR values seem to work around this problem.
    
    Reported by:    Alexander Motin <mavbsd@gmail.com>
    Tested by:      Mathias Kraut <krautmaster@gmail.com>
    Fixes:          75412a521f6 Hyper-V: vPCI: Prepopulate device bars
    MFC after:      1 month
---
 sys/dev/hyperv/pcib/vmbus_pcib.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/dev/hyperv/pcib/vmbus_pcib.c b/sys/dev/hyperv/pcib/vmbus_pcib.c
index fd2b732267f0..81b05a6da055 100644
--- a/sys/dev/hyperv/pcib/vmbus_pcib.c
+++ b/sys/dev/hyperv/pcib/vmbus_pcib.c
@@ -1391,6 +1391,10 @@ vmbus_pcib_prepopulate_bars(struct hv_pcibus *hbus)
 
 				_hv_pcifront_write_config(hpdev, PCIR_BAR(i),
 				    4, 0xffffffff);
+
+				/* Now write the original value back */
+				_hv_pcifront_write_config(hpdev, PCIR_BAR(i),
+				    4, bar_val);
 			}
 		}
 	}