[Midnightbsd-cvs] src [9070] trunk/sys/dev/ata: block dual channel use due to missing serialization logic

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Oct 1 06:15:26 EDT 2016


Revision: 9070
          http://svnweb.midnightbsd.org/src/?rev=9070
Author:   laffer1
Date:     2016-10-01 06:15:25 -0400 (Sat, 01 Oct 2016)
Log Message:
-----------
block dual channel use due to missing serialization logic

Modified Paths:
--------------
    trunk/sys/dev/ata/ata-cbus.c
    trunk/sys/dev/ata/chipsets/ata-acard.c

Modified: trunk/sys/dev/ata/ata-cbus.c
===================================================================
--- trunk/sys/dev/ata/ata-cbus.c	2016-10-01 10:14:23 UTC (rev 9069)
+++ trunk/sys/dev/ata/ata-cbus.c	2016-10-01 10:15:25 UTC (rev 9070)
@@ -53,10 +53,13 @@
     struct resource *bankio;
     struct resource *irq;
     void *ih;
+#ifndef ATA_CAM
     struct mtx bank_mtx;
     int locked_bank;
     int restart_bank;
     int hardware_bank;
+#endif
+    int channels;
     struct {
 	void (*function)(void *);
 	void *argument;
@@ -65,7 +68,9 @@
 
 /* local prototypes */
 static void ata_cbus_intr(void *);
+#ifndef ATA_CAM
 static int ata_cbuschannel_banking(device_t dev, int flags);
+#endif
 
 static int
 ata_cbus_probe(device_t dev)
@@ -155,12 +160,19 @@
 	return ENXIO;
     }
 
+#ifndef ATA_CAM
+	ctlr->channels = 2;
     mtx_init(&ctlr->bank_mtx, "ATA cbus bank lock", NULL, MTX_DEF);
     ctlr->hardware_bank = -1;
     ctlr->locked_bank = -1;
     ctlr->restart_bank = -1;
+#else
+	/* Work around the lack of channel serialization in ATA_CAM. */
+	ctlr->channels = 1;
+	device_printf(dev, "second channel ignored\n");
+#endif
 
-    for (unit = 0; unit < 2; unit++) {
+    for (unit = 0; unit < ctlr->channels; unit++) {
 	child = device_add_child(dev, "ata", unit);
 	if (child == NULL)
 	    device_printf(dev, "failed to add ata child device\n");
@@ -229,10 +241,12 @@
     struct ata_channel *ch;
     int unit;
 
-    for (unit = 0; unit < 2; unit++) {
+    for (unit = 0; unit < ctlr->channels; unit++) {
 	if (!(ch = ctlr->interrupt[unit].argument))
 	    continue;
+#ifndef ATA_CAM
 	if (ata_cbuschannel_banking(ch->dev, ATA_LF_WHICH) == unit)
+#endif
 	    ctlr->interrupt[unit].function(ch);
     }
 }
@@ -335,18 +349,16 @@
     return ata_resume(dev);
 }
 
+#ifndef ATA_CAM
 static int
 ata_cbuschannel_banking(device_t dev, int flags)
 {
     struct ata_cbus_controller *ctlr = device_get_softc(device_get_parent(dev));
-#ifndef ATA_CAM
     struct ata_channel *ch = device_get_softc(dev);
-#endif
     int res;
 
     mtx_lock(&ctlr->bank_mtx);
     switch (flags) {
-#ifndef ATA_CAM
     case ATA_LF_LOCK:
 	if (ctlr->locked_bank == -1)
 	    ctlr->locked_bank = ch->unit;
@@ -371,7 +383,6 @@
 	    }
 	}
 	break;
-#endif
 
     case ATA_LF_WHICH:
 	break;
@@ -380,6 +391,7 @@
     mtx_unlock(&ctlr->bank_mtx);
     return res;
 }
+#endif
 
 static device_method_t ata_cbuschannel_methods[] = {
     /* device interface */

Modified: trunk/sys/dev/ata/chipsets/ata-acard.c
===================================================================
--- trunk/sys/dev/ata/chipsets/ata-acard.c	2016-10-01 10:14:23 UTC (rev 9069)
+++ trunk/sys/dev/ata/chipsets/ata-acard.c	2016-10-01 10:15:25 UTC (rev 9070)
@@ -124,6 +124,10 @@
 			      M_ATAPCI, M_WAITOK | M_ZERO);
 	ata_serialize_init(serial);
 	ctlr->chipset_data = serial;
+#else
+	/* Work around the lack of channel serialization in ATA_CAM. */
+	ctlr->channels = 1;
+	device_printf(dev, "second channel ignored\n");
 #endif
     }
     else



More information about the Midnightbsd-cvs mailing list