PERFORCE change 171031 for review

Alexander Motin mav at FreeBSD.org
Wed Nov 25 20:13:55 UTC 2009


http://p4web.freebsd.org/chv.cgi?CH=171031

Change 171031 by mav at mav_mavbook on 2009/11/25 20:13:23

	Make SATA revision really controllable via `camcontrol negotiate`.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#87 edit
.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.h#31 edit
.. //depot/projects/scottl-camlock/src/sys/dev/siis/siis.c#25 edit
.. //depot/projects/scottl-camlock/src/sys/dev/siis/siis.h#9 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#87 (text+ko) ====

@@ -776,7 +776,7 @@
 	struct ahci_controller *ctlr = device_get_softc(device_get_parent(dev));
 	struct ahci_channel *ch = device_get_softc(dev);
 	struct cam_devq *devq;
-	int rid, error, i;
+	int rid, error, i, sata_rev = 0;
 
 	ch->dev = dev;
 	ch->unit = (intptr_t)device_get_ivars(dev);
@@ -789,22 +789,22 @@
 	    device_get_unit(dev), "pm_level", &ch->pm_level);
 	if (ch->pm_level > 3)
 		callout_init_mtx(&ch->pm_timer, &ch->mtx, 0);
-	for (i = 0; i < 16; i++) {
-		ch->user[i].revision = 0;
-		ch->user[i].mode = 0;
-		ch->user[i].bytecount = 8192;
-		ch->user[i].tags = ch->numslots;
-		ch->curr[i] = ch->user[i];
-	}
 	/* Limit speed for my onboard JMicron external port.
 	 * It is not eSATA really. */
 	if (pci_get_devid(ctlr->dev) == 0x2363197b &&
 	    pci_get_subvendor(ctlr->dev) == 0x1043 &&
 	    pci_get_subdevice(ctlr->dev) == 0x81e4 &&
 	    ch->unit == 0)
-		ch->sata_rev = 1;
+		sata_rev = 1;
 	resource_int_value(device_get_name(dev),
-	    device_get_unit(dev), "sata_rev", &ch->sata_rev);
+	    device_get_unit(dev), "sata_rev", &sata_rev);
+	for (i = 0; i < 16; i++) {
+		ch->user[i].revision = sata_rev;
+		ch->user[i].mode = 0;
+		ch->user[i].bytecount = 8192;
+		ch->user[i].tags = ch->numslots;
+		ch->curr[i] = ch->user[i];
+	}
 	rid = ch->unit;
 	if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
 	    &rid, RF_ACTIVE)))
@@ -2075,6 +2075,7 @@
 ahci_sata_phy_reset(device_t dev, int quick)
 {
 	struct ahci_channel *ch = device_get_softc(dev);
+	int sata_rev;
 	uint32_t val;
 
 	if (quick) {
@@ -2085,11 +2086,12 @@
 
 	if (bootverbose)
 		device_printf(dev, "hardware reset ...\n");
-	if (ch->sata_rev == 1)
+	sata_rev = ch->user[ch->pm_present ? 15 : 0].revision;
+	if (sata_rev == 1)
 		val = ATA_SC_SPD_SPEED_GEN1;
-	else if (ch->sata_rev == 2)
+	else if (sata_rev == 2)
 		val = ATA_SC_SPD_SPEED_GEN2;
-	else if (ch->sata_rev == 3)
+	else if (sata_rev == 3)
 		val = ATA_SC_SPD_SPEED_GEN3;
 	else
 		val = 0;

==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.h#31 (text+ko) ====

@@ -341,7 +341,7 @@
 };
 
 struct ahci_device {
-	u_int			revision;
+	int			revision;
 	int			mode;
 	u_int			bytecount;
 	u_int			tags;
@@ -362,7 +362,6 @@
 	int			quirks;
 	int			numslots;	/* Number of present slots */
 	int			pm_level;	/* power management level */
-	int			sata_rev;	/* Maximum allowed SATA generation */
 
 	struct ahci_slot	slot[AHCI_MAX_SLOTS];
 	union ccb		*hold[AHCI_MAX_SLOTS];

==== //depot/projects/scottl-camlock/src/sys/dev/siis/siis.c#25 (text+ko) ====

@@ -415,21 +415,21 @@
 {
 	struct siis_channel *ch = device_get_softc(dev);
 	struct cam_devq *devq;
-	int rid, error, i;
+	int rid, error, i, sata_rev = 0;
 
 	ch->dev = dev;
 	ch->unit = (intptr_t)device_get_ivars(dev);
 	resource_int_value(device_get_name(dev),
 	    device_get_unit(dev), "pm_level", &ch->pm_level);
+	resource_int_value(device_get_name(dev),
+	    device_get_unit(dev), "sata_rev", &sata_rev);
 	for (i = 0; i < 16; i++) {
-		ch->user[i].revision = 0;
+		ch->user[i].revision = sata_rev;
 		ch->user[i].mode = 0;
 		ch->user[i].bytecount = 8192;
 		ch->user[i].tags = SIIS_MAX_SLOTS;
 		ch->curr[i] = ch->user[i];
 	}
-	resource_int_value(device_get_name(dev),
-	    device_get_unit(dev), "sata_rev", &ch->sata_rev);
 	mtx_init(&ch->mtx, "SIIS channel lock", NULL, MTX_DEF);
 	rid = ch->unit;
 	if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
@@ -1346,7 +1346,7 @@
 siis_reset(device_t dev)
 {
 	struct siis_channel *ch = device_get_softc(dev);
-	int i, retry = 0;
+	int i, retry = 0, sata_rev;
 	uint32_t val;
 
 	if (bootverbose)
@@ -1390,11 +1390,12 @@
 	/* Disable port interrupts */
 	ATA_OUTL(ch->r_mem, SIIS_P_IECLR, 0x0000FFFF);
 	/* Set speed limit. */
-	if (ch->sata_rev == 1)
+	sata_rev = ch->user[ch->pm_present ? 15 : 0].revision;
+	if (sata_rev == 1)
 		val = ATA_SC_SPD_SPEED_GEN1;
-	else if (ch->sata_rev == 2)
+	else if (sata_rev == 2)
 		val = ATA_SC_SPD_SPEED_GEN2;
-	else if (ch->sata_rev == 3)
+	else if (sata_rev == 3)
 		val = ATA_SC_SPD_SPEED_GEN3;
 	else
 		val = 0;

==== //depot/projects/scottl-camlock/src/sys/dev/siis/siis.h#9 (text+ko) ====

@@ -347,7 +347,7 @@
 };
 
 struct siis_device {
-	u_int			revision;
+	int			revision;
 	int			mode;
 	u_int			bytecount;
 	u_int			tags;
@@ -364,7 +364,6 @@
 	struct cam_sim		*sim;
 	struct cam_path		*path;
 	int			pm_level;	/* power management level */
-	int			sata_rev;	/* Maximum allowed SATA generation */
 
 	struct siis_slot	slot[SIIS_MAX_SLOTS];
 	union ccb		*hold[SIIS_MAX_SLOTS];


More information about the p4-projects mailing list