]> xenbits.xensource.com Git - seabios.git/commitdiff
scsi: Launch a thread when scanning for drives in the scsi drivers
authorKevin O'Connor <kevin@koconnor.net>
Tue, 5 Apr 2016 17:04:07 +0000 (13:04 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 6 Apr 2016 13:53:55 +0000 (09:53 -0400)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/esp-scsi.c
src/hw/lsi-scsi.c
src/hw/megasas.c
src/hw/mpt-scsi.c
src/hw/pvscsi.c

index c98989cea9b280919a662efe85624beaab2f4f73..d2ba02337f50caf95172a8db9ad631c6a91f156b 100644 (file)
@@ -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);
     }
 }
index fd695fa7eb6a22d4a0734048e0b90bee67c68308..b63430dc9cc2cfffb7f6bc9351d40757e8be1ea9 100644 (file)
@@ -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);
     }
 }
index 7514164beb28806b89513d434ac258ae5df1bcac..efd0f6ef16bc7a5a5b3098c865266664754e64fc 100644 (file)
@@ -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);
     }
 }
index 7d1aa3dada5b025d32a07b2698efb588e8d52aea..a37e44c4416345c1ee8e331d450236d2fd3b4a36 100644 (file)
@@ -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);
     }
 }
index a9d118b87e7a67bfea1c3c0950bc47e832b6501d..05cbd91b5d3269a00d4a4399045bbebc5c0c8fbc 100644 (file)
@@ -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);
     }
 }