From afae5412ad601987e967235984705fdf8a3feaaa Mon Sep 17 00:00:00 2001
From: "Wesley W. Terpstra" <w.terpstra@gsi.de>
Date: Thu, 28 Apr 2016 16:12:23 +0200
Subject: [PATCH] wishbone: in case hardware has a pending MSI on power-up,
 prime the Q!

---
 pcie-wb/wishbone.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pcie-wb/wishbone.c b/pcie-wb/wishbone.c
index 4cd0b32..194c845 100644
--- a/pcie-wb/wishbone.c
+++ b/pcie-wb/wishbone.c
@@ -164,13 +164,12 @@ retry:
 	
 	/* If no MSI handler, handle it immediately */
 	index = request.addr / ((wb->mask/WISHBONE_MAX_MSI_OPEN)+1);
-	if (!wb->msi_map[index]) {
+	if (!(context = wb->msi_map[index])) {
 		wb->wops->reply(wb, 1, ~(wb_data_t)0);
 		goto retry;
 	}
 	
 	/* Fill in the MSI data */
-	context = wb->msi_map[index];
 	wptr = &context->msi[0];
 	
 	wptr[0] = ETHERBONE_BCA;
@@ -625,6 +624,10 @@ int wishbone_register(struct wishbone* wb)
 	list_add_tail(&wb->list, list_pos);
 	
 	mutex_unlock(&wishbone_mutex);
+	
+	/* Startup the MSI queue */
+	wishbone_slave_ready(wb);
+	
 	return 0;
 
 fail_master_cdev:
-- 
GitLab