[SeaBIOS] [PATCH 2/2] scsi: Launch a thread when scanning for drives in the scsi drivers

Kevin O'Connor kevin at koconnor.net
Tue Apr 5 19:06:32 CEST 2016


Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 src/hw/esp-scsi.c |  8 ++++----
 src/hw/lsi-scsi.c |  8 ++++----
 src/hw/megasas.c  |  7 +++----
 src/hw/mpt-scsi.c | 23 ++++++++++-------------
 src/hw/pvscsi.c   |  8 ++++----
 5 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/hw/esp-scsi.c b/src/hw/esp-scsi.c
index c98989c..d2ba023 100644
--- a/src/hw/esp-scsi.c
+++ b/src/hw/esp-scsi.c
@@ -20,6 +20,7 @@
 #include "pcidevice.h" // foreachpci
 #include "pci_ids.h" // PCI_DEVICE_ID
 #include "pci_regs.h" // PCI_VENDOR_ID
+#include "stacks.h" // run_thread
 #include "std/disk.h" // DISK_RET_SUCCESS
 #include "string.h" // memset
 #include "util.h" // usleep
@@ -188,8 +189,9 @@ esp_scsi_scan_target(struct pci_device *pci, u32 iobase, u8 target)
 }
 
 static void
-init_esp_scsi(struct pci_device *pci)
+init_esp_scsi(void *data)
 {
+    struct pci_device *pci = data;
     u32 iobase = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0);
     if (!iobase)
         return;
@@ -203,8 +205,6 @@ init_esp_scsi(struct pci_device *pci)
     int i;
     for (i = 0; i <= 7; i++)
         esp_scsi_scan_target(pci, iobase, i);
-
-    return;
 }
 
 void
@@ -221,6 +221,6 @@ esp_scsi_setup(void)
         if (pci->vendor != PCI_VENDOR_ID_AMD
             || pci->device != PCI_DEVICE_ID_AMD_SCSI)
             continue;
-        init_esp_scsi(pci);
+        run_thread(init_esp_scsi, pci);
     }
 }
diff --git a/src/hw/lsi-scsi.c b/src/hw/lsi-scsi.c
index fd695fa..b63430d 100644
--- a/src/hw/lsi-scsi.c
+++ b/src/hw/lsi-scsi.c
@@ -20,6 +20,7 @@
 #include "pcidevice.h" // foreachpci
 #include "pci_ids.h" // PCI_DEVICE_ID_VIRTIO_BLK
 #include "pci_regs.h" // PCI_VENDOR_ID
+#include "stacks.h" // run_thread
 #include "std/disk.h" // DISK_RET_SUCCESS
 #include "string.h" // memset
 #include "util.h" // usleep
@@ -168,8 +169,9 @@ lsi_scsi_scan_target(struct pci_device *pci, u32 iobase, u8 target)
 }
 
 static void
-init_lsi_scsi(struct pci_device *pci)
+init_lsi_scsi(void *data)
 {
+    struct pci_device *pci = data;
     u32 iobase = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0);
     if (!iobase)
         return;
@@ -183,8 +185,6 @@ init_lsi_scsi(struct pci_device *pci)
     int i;
     for (i = 0; i < 7; i++)
         lsi_scsi_scan_target(pci, iobase, i);
-
-    return;
 }
 
 void
@@ -201,6 +201,6 @@ lsi_scsi_setup(void)
         if (pci->vendor != PCI_VENDOR_ID_LSI_LOGIC
             || pci->device != PCI_DEVICE_ID_LSI_53C895A)
             continue;
-        init_lsi_scsi(pci);
+        run_thread(init_lsi_scsi, pci);
     }
 }
diff --git a/src/hw/megasas.c b/src/hw/megasas.c
index 7514164..efd0f6e 100644
--- a/src/hw/megasas.c
+++ b/src/hw/megasas.c
@@ -357,8 +357,9 @@ static int megasas_transition_to_ready(struct pci_device *pci, u32 ioaddr)
 }
 
 static void
-init_megasas(struct pci_device *pci)
+init_megasas(void *data)
 {
+    struct pci_device *pci = data;
     u32 bar = PCI_BASE_ADDRESS_2;
     if (!(pci_config_readl(pci->bdf, bar) & PCI_BASE_ADDRESS_IO_MASK))
         bar = PCI_BASE_ADDRESS_0;
@@ -372,8 +373,6 @@ init_megasas(struct pci_device *pci)
     // reset
     if (megasas_transition_to_ready(pci, iobase) == 0)
         megasas_scan_target(pci, iobase);
-
-    return;
 }
 
 void
@@ -401,6 +400,6 @@ megasas_setup(void)
             pci->device == PCI_DEVICE_ID_DELL_PERC5 ||
             pci->device == PCI_DEVICE_ID_LSI_SAS2208 ||
             pci->device == PCI_DEVICE_ID_LSI_SAS3108)
-            init_megasas(pci);
+            run_thread(init_megasas, pci);
     }
 }
diff --git a/src/hw/mpt-scsi.c b/src/hw/mpt-scsi.c
index 7d1aa3d..a37e44c 100644
--- a/src/hw/mpt-scsi.c
+++ b/src/hw/mpt-scsi.c
@@ -15,6 +15,7 @@
 #include "pcidevice.h" // foreachpci
 #include "pci_ids.h" // PCI_DEVICE_ID
 #include "pci_regs.h" // PCI_VENDOR_ID
+#include "stacks.h" // run_thread
 #include "std/disk.h" // DISK_RET_SUCCESS
 #include "string.h" // memset
 #include "util.h" // usleep
@@ -241,8 +242,9 @@ mpt_out_doorbell(u8 func, u8 arg, u16 iobase)
 }
 
 static void
-init_mpt_scsi(struct pci_device *pci, const char *dev_name)
+init_mpt_scsi(void *data)
 {
+    struct pci_device *pci = data;
     u16 *msg_in_p;
     u32 iobase = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0);
     if (!iobase)
@@ -250,7 +252,8 @@ init_mpt_scsi(struct pci_device *pci, const char *dev_name)
     struct MptIOCInitReply MptIOCInitReply;
     pci_enable_busmaster(pci);
 
-    dprintf(1, "found %s at %pP, io @ %x\n", dev_name, pci, iobase);
+    dprintf(1, "found mpt-scsi(%04x) at %pP, io @ %x\n"
+            , pci->device, pci, iobase);
 
     // reset
     mpt_out_doorbell(MPT_DOORBELL_MSG_RESET, 0, iobase);
@@ -295,16 +298,10 @@ mpt_scsi_setup(void)
 
     struct pci_device *pci;
     foreachpci(pci) {
-        if (pci->vendor == PCI_VENDOR_ID_LSI_LOGIC) {
-            if (pci->device == PCI_DEVICE_ID_LSI_53C1030) {
-                init_mpt_scsi(pci, "lsi53c1030");
-            }
-            if (pci->device == PCI_DEVICE_ID_LSI_SAS1068) {
-                init_mpt_scsi(pci, "sas1068");
-            }
-            if (pci->device == PCI_DEVICE_ID_LSI_SAS1068E) {
-                init_mpt_scsi(pci, "sas1068e");
-            }
-        }
+        if (pci->vendor == PCI_VENDOR_ID_LSI_LOGIC
+            && (pci->device == PCI_DEVICE_ID_LSI_53C1030
+                || pci->device == PCI_DEVICE_ID_LSI_SAS1068
+                || pci->device == PCI_DEVICE_ID_LSI_SAS1068E))
+            run_thread(init_mpt_scsi, pci);
     }
 }
diff --git a/src/hw/pvscsi.c b/src/hw/pvscsi.c
index a9d118b..05cbd91 100644
--- a/src/hw/pvscsi.c
+++ b/src/hw/pvscsi.c
@@ -17,6 +17,7 @@
 #include "pci_ids.h" // PCI_DEVICE_ID_VMWARE_PVSCSI
 #include "pci_regs.h" // PCI_VENDOR_ID
 #include "pvscsi.h" // pvscsi_setup
+#include "stacks.h" // run_thread
 #include "std/disk.h" // DISK_RET_SUCCESS
 #include "string.h" // memset
 #include "util.h" // usleep
@@ -294,8 +295,9 @@ pvscsi_scan_target(struct pci_device *pci, void *iobase,
 }
 
 static void
-init_pvscsi(struct pci_device *pci)
+init_pvscsi(void *data)
 {
+    struct pci_device *pci = data;
     void *iobase = pci_enable_membar(pci, PCI_BASE_ADDRESS_0);
     if (!iobase)
         return;
@@ -310,8 +312,6 @@ init_pvscsi(struct pci_device *pci)
     int i;
     for (i = 0; i < 7; i++)
         pvscsi_scan_target(pci, iobase, ring_dsc, i);
-
-    return;
 }
 
 void
@@ -328,6 +328,6 @@ pvscsi_setup(void)
         if (pci->vendor != PCI_VENDOR_ID_VMWARE
             || pci->device != PCI_DEVICE_ID_VMWARE_PVSCSI)
             continue;
-        init_pvscsi(pci);
+        run_thread(init_pvscsi, pci);
     }
 }
-- 
2.5.5




More information about the SeaBIOS mailing list