PERFORCE change 166569 for review

Alexander Motin mav at FreeBSD.org
Sat Jul 25 20:29:34 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166569

Change 166569 by mav at mav_mavbook on 2009/07/25 20:28:57

	Cleanup code.
	Fix ordered request insertion for ada.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#21 edit
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#4 edit
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#30 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#21 (text+ko) ====

@@ -70,8 +70,7 @@
 	ADA_FLAG_PACK_INVALID	= 0x001,
 	ADA_FLAG_CAN_48BIT	= 0x002,
 	ADA_FLAG_CAN_FLUSHCACHE	= 0x004,
-	ADA_FLAG_CAN_NCQ		= 0x008,
-	ADA_FLAG_TAGGED_QUEUING	= 0x010,
+	ADA_FLAG_CAN_NCQ	= 0x008,
 	ADA_FLAG_NEED_OTAG	= 0x020,
 	ADA_FLAG_WENT_IDLE	= 0x040,
 	ADA_FLAG_RETRY_UA	= 0x080,
@@ -80,10 +79,7 @@
 } ada_flags;
 
 typedef enum {
-	ADA_Q_NONE		= 0x00,
-	ADA_Q_NO_SYNC_CACHE	= 0x01,
-	ADA_Q_NO_6_BYTE		= 0x02,
-	ADA_Q_NO_PREVENT		= 0x04
+	ADA_Q_NONE		= 0x00
 } ada_quirks;
 
 typedef enum {
@@ -331,14 +327,7 @@
 
 	cam_periph_lock(periph);
 
-#if 0
 	/*
-	 * check it's not too big a transfer for our adapter
-	 */
-	scsi_minphys(bp,&sd_switch);
-#endif
-
-	/*
 	 * Mask interrupts so that the pack cannot be invalidated until
 	 * after we are in the queue.  Otherwise, we might not properly
 	 * clean up one of the buffers.
@@ -551,11 +540,6 @@
 		if (cgd->protocol != PROTO_ATA)
 			break;
 
-//		if (SID_TYPE(&cgd->inq_data) != T_DIRECT
-//		    && SID_TYPE(&cgd->inq_data) != T_RBC
-//		    && SID_TYPE(&cgd->inq_data) != T_OPTICAL)
-//			break;
-
 		/*
 		 * Allocate a peripheral instance for
 		 * this device and start the probe
@@ -651,7 +635,7 @@
 
 	if (softc == NULL) {
 		printf("adaregister: Unable to probe new device. "
-		       "Unable to allocate softc\n");				
+		    "Unable to allocate softc\n");
 		return(CAM_REQ_CMP_ERR);
 	}
 
@@ -666,8 +650,6 @@
 	if (cgd->ident_data.satacapabilities & ATA_SUPPORT_NCQ &&
 	    cgd->ident_data.queue >= 31)
 		softc->flags |= ADA_FLAG_CAN_NCQ;
-//	if ((cgd->inq_data.flags & SID_CmdQue) != 0)
-//		softc->flags |= ADA_FLAG_TAGGED_QUEUING;
 
 	periph->softc = softc;
 
@@ -728,8 +710,6 @@
 	/* XXX: these are not actually "firmware" values, so they may be wrong */
 	softc->disk->d_fwsectors = softc->params.secs_per_track;
 	softc->disk->d_fwheads = softc->params.heads;
-//	softc->disk->d_devstat->block_size = softc->params.secsize;
-//	softc->disk->d_devstat->flags &= ~DEVSTAT_BS_UNAVAILABLE;
 
 	disk_create(softc->disk, DISK_VERSION);
 	mtx_lock(periph->sim->mtx);
@@ -815,9 +795,9 @@
 			if ((softc->flags & ADA_FLAG_NEED_OTAG) != 0) {
 				softc->flags &= ~ADA_FLAG_NEED_OTAG;
 				softc->ordered_tag_count++;
-				tag_code = 0;//MSG_ORDERED_Q_TAG;
+				tag_code = 0;
 			} else {
-				tag_code = 0;//MSG_SIMPLE_Q_TAG;
+				tag_code = 1;
 			}
 			switch (bp->bio_cmd) {
 			case BIO_READ:
@@ -836,7 +816,7 @@
 				    bp->bio_bcount,
 				    ada_default_timeout*1000);
 
-				if (softc->flags & ADA_FLAG_CAN_NCQ) {
+				if ((softc->flags & ADA_FLAG_CAN_NCQ) && tag_code) {
 					if (bp->bio_cmd == BIO_READ) {
 						ata_ncq_cmd(ataio, ATA_READ_FPDMA_QUEUED,
 						    lba, count);
@@ -870,7 +850,7 @@
 				    1,
 				    adadone,
 				    CAM_DIR_NONE,
-				    tag_code,
+				    0,
 				    NULL,
 				    0,
 				    ada_default_timeout*1000);
@@ -1047,10 +1027,6 @@
 	lbasize = (u_int32_t)cgd->ident_data.lba_size_1 |
 		  ((u_int32_t)cgd->ident_data.lba_size_2 << 16);
 
-    /* does this device need oldstyle CHS addressing */
-//    if (!ad_version(cgd->ident_data.version_major) || !lbasize)
-//	atadev->flags |= ATA_D_USE_CHS;
-
 	/* use the 28bit LBA size if valid or bigger than the CHS mapping */
 	if (cgd->ident_data.cylinders == 16383 || dp->sectors < lbasize)
 		dp->sectors = lbasize;

==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#4 (text+ko) ====

@@ -72,22 +72,11 @@
 } pmp_state;
 
 typedef enum {
-	PMP_FLAG_PACK_INVALID	= 0x001,
 	PMP_FLAG_SCTX_INIT	= 0x200
 } pmp_flags;
 
 typedef enum {
-	PMP_Q_NONE		= 0x00
-} pmp_quirks;
-
-typedef enum {
 	PMP_CCB_PROBE		= 0x01,
-	PMP_CCB_PROBE2		= 0x02,
-	PMP_CCB_BUFFER_IO	= 0x03,
-	PMP_CCB_WAITING		= 0x04,
-	PMP_CCB_DUMP		= 0x05,
-	PMP_CCB_TYPE_MASK	= 0x0F,
-	PMP_CCB_RETRY_UA		= 0x10
 } pmp_ccb_state;
 
 /* Offsets into our private area for storing information */
@@ -98,7 +87,6 @@
 	SLIST_ENTRY(pmp_softc)	links;
 	pmp_state		state;
 	pmp_flags		flags;
-	pmp_quirks		quirks;
 	uint32_t		pm_pid;
 	uint32_t		pm_prv;
 	int			pm_ports;
@@ -111,15 +99,6 @@
 	struct sysctl_oid	*sysctl_tree;
 };
 
-struct pmp_quirk_entry {
-	struct scsi_inquiry_pattern inq_pat;
-	pmp_quirks quirks;
-};
-
-//static struct pmp_quirk_entry pmp_quirk_table[] =
-//{
-//};
-
 static	periph_init_t	pmpinit;
 static	void		pmpasync(void *callback_arg, u_int32_t code,
 				struct cam_path *path, void *arg);
@@ -136,7 +115,7 @@
 #endif
 
 #ifndef	PMP_DEFAULT_RETRY
-#define	PMP_DEFAULT_RETRY	4
+#define	PMP_DEFAULT_RETRY	1
 #endif
 
 static int pmp_retry_count = PMP_DEFAULT_RETRY;
@@ -200,9 +179,6 @@
 			xpt_free_path(dpath);
 		}
 	}
-
-	softc->flags |= PMP_FLAG_PACK_INVALID;
-
 	xpt_print(periph->path, "lost device\n");
 }
 
@@ -319,8 +295,6 @@
 	struct pmp_softc *softc;
 	struct ccb_pathinq cpi;
 	struct ccb_getdev *cgd;
-	char   announce_buf[80];
-	caddr_t match;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (periph == NULL) {
@@ -347,20 +321,6 @@
 	softc->pm_pid = ((uint32_t *)&cgd->ident_data)[0];
 	softc->pm_prv = ((uint32_t *)&cgd->ident_data)[1];
 
-	/*
-	 * See if this device has any quirks.
-	 */
-//	match = cam_quirkmatch((caddr_t)&cgd->inq_data,
-//			       (caddr_t)pmp_quirk_table,
-//			       sizeof(pmp_quirk_table)/sizeof(*pmp_quirk_table),
-//			       sizeof(*pmp_quirk_table), scsi_inquiry_match);
-	match = NULL;
-
-	if (match != NULL)
-		softc->quirks = ((struct pmp_quirk_entry *)match)->quirks;
-	else
-		softc->quirks = PMP_Q_NONE;
-
 	/* Check if the SIM does not want queued commands */
 	bzero(&cpi, sizeof(cpi));
 	xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
@@ -369,9 +329,7 @@
 
 	TASK_INIT(&softc->sysctl_task, 0, pmpsysctlinit, periph);
 
-	snprintf(announce_buf, sizeof(announce_buf),
-		"PMP");
-	xpt_announce_periph(periph, announce_buf);
+	xpt_announce_periph(periph, NULL);
 
 	/*
 	 * Add async callbacks for bus reset and
@@ -407,35 +365,35 @@
 	switch (softc->state) {
 	case PMP_STATE_PORTS:
 		cam_fill_ataio(ataio,
-		      1,
+		      pmp_retry_count,
 		      pmpdone,
 		      /*flags*/CAM_DIR_NONE,
 		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
-		      10 * 1000);
+		      pmp_default_timeout * 1000);
 		ata_pm_read_cmd(ataio, 2, 15);
 		break;
 	case PMP_STATE_CONFIG:
 		cam_fill_ataio(ataio,
-		      1,
+		      pmp_retry_count,
 		      pmpdone,
 		      /*flags*/CAM_DIR_NONE,
 		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
-		      10 * 1000);
+		      pmp_default_timeout * 1000);
 		ata_pm_write_cmd(ataio, 0x60, 15, 0xf);
 		break;
 	case PMP_STATE_RESET:
 		cam_fill_ataio(ataio,
-		      1,
+		      pmp_retry_count,
 		      pmpdone,
 		      /*flags*/CAM_DIR_NONE,
 		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
-		      10 * 1000);
+		      pmp_default_timeout * 1000);
 		ata_pm_write_cmd(ataio, 2, softc->pm_step,
 		    (softc->found & (1 << softc->pm_step)) ? 0 : 1);
 printf("PM RESET %d %04x %d\n", softc->pm_step, softc->found,
@@ -443,35 +401,35 @@
 		break;
 	case PMP_STATE_CONNECT:
 		cam_fill_ataio(ataio,
-		      1,
+		      pmp_retry_count,
 		      pmpdone,
 		      /*flags*/CAM_DIR_NONE,
 		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
-		      10 * 1000);
+		      pmp_default_timeout * 1000);
 		ata_pm_write_cmd(ataio, 2, softc->pm_step, 0);
 		break;
 	case PMP_STATE_CHECK:
 		cam_fill_ataio(ataio,
-		      1,
+		      pmp_retry_count,
 		      pmpdone,
 		      /*flags*/CAM_DIR_NONE,
 		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
-		      10 * 1000);
+		      pmp_default_timeout * 1000);
 		ata_pm_read_cmd(ataio, 0, softc->pm_step);
 		break;
 	case PMP_STATE_CLEAR:
 		cam_fill_ataio(ataio,
-		      1,
+		      pmp_retry_count,
 		      pmpdone,
 		      /*flags*/CAM_DIR_NONE,
 		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
-		      10 * 1000);
+		      pmp_default_timeout * 1000);
 		ata_pm_write_cmd(ataio, 1, softc->pm_step, 0xFFFFFFFF);
 		break;
 	default:

==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#30 (text+ko) ====

@@ -62,7 +62,6 @@
 
 #include <cam/scsi/scsi_all.h>
 #include <cam/scsi/scsi_message.h>
-#include <cam/scsi/scsi_pass.h>
 #include <cam/ata/ata_all.h>
 #include <machine/stdarg.h>	/* for xpt_print below */
 #include "opt_cam.h"
@@ -309,7 +308,7 @@
 		      0,
 		      probedone,
 		      /*flags*/CAM_DIR_NONE,
-		      MSG_SIMPLE_Q_TAG,
+		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
 		      (start_ccb->ccb_h.target_id == 15 ? 3 : 15) * 1000);
@@ -340,7 +339,7 @@
 		      1,
 		      probedone,
 		      /*flags*/CAM_DIR_IN,
-		      MSG_SIMPLE_Q_TAG,
+		      0,
 		      /*data_ptr*/(u_int8_t *)ident_buf,
 		      /*dxfer_len*/sizeof(struct ata_params),
 		      30 * 1000);
@@ -359,7 +358,7 @@
 		      1,
 		      probedone,
 		      /*flags*/CAM_DIR_IN,
-		      MSG_SIMPLE_Q_TAG,
+		      0,
 		      /*data_ptr*/(u_int8_t *)ident_buf,
 		      /*dxfer_len*/sizeof(struct ata_params),
 		      30 * 1000);
@@ -402,7 +401,7 @@
 		      1,
 		      probedone,
 		      /*flags*/CAM_DIR_NONE,
-		      MSG_SIMPLE_Q_TAG,
+		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
 		      10 * 1000);
@@ -413,7 +412,7 @@
 		      1,
 		      probedone,
 		      /*flags*/CAM_DIR_NONE,
-		      MSG_SIMPLE_Q_TAG,
+		      0,
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
 		      10 * 1000);
@@ -1417,114 +1416,6 @@
 			scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB;
 	}
 
-	/* SPI specific sanity checking */
-	if (cts->transport == XPORT_SPI && async_update == FALSE) {
-		u_int spi3caps;
-		struct ccb_trans_settings_spi *spi;
-		struct ccb_trans_settings_spi *cur_spi;
-
-		spi = &cts->xport_specific.spi;
-
-		cur_spi = &cur_cts.xport_specific.spi;
-
-		/* Fill in any gaps in what the user gave us */
-		if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) == 0)
-			spi->sync_period = cur_spi->sync_period;
-		if ((cur_spi->valid & CTS_SPI_VALID_SYNC_RATE) == 0)
-			spi->sync_period = 0;
-		if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) == 0)
-			spi->sync_offset = cur_spi->sync_offset;
-		if ((cur_spi->valid & CTS_SPI_VALID_SYNC_OFFSET) == 0)
-			spi->sync_offset = 0;
-		if ((spi->valid & CTS_SPI_VALID_PPR_OPTIONS) == 0)
-			spi->ppr_options = cur_spi->ppr_options;
-		if ((cur_spi->valid & CTS_SPI_VALID_PPR_OPTIONS) == 0)
-			spi->ppr_options = 0;
-		if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) == 0)
-			spi->bus_width = cur_spi->bus_width;
-		if ((cur_spi->valid & CTS_SPI_VALID_BUS_WIDTH) == 0)
-			spi->bus_width = 0;
-		if ((spi->valid & CTS_SPI_VALID_DISC) == 0) {
-			spi->flags &= ~CTS_SPI_FLAGS_DISC_ENB;
-			spi->flags |= cur_spi->flags & CTS_SPI_FLAGS_DISC_ENB;
-		}
-		if ((cur_spi->valid & CTS_SPI_VALID_DISC) == 0)
-			spi->flags &= ~CTS_SPI_FLAGS_DISC_ENB;
-		if (((device->flags & CAM_DEV_INQUIRY_DATA_VALID) != 0
-		  && (inq_data->flags & SID_Sync) == 0
-		  && cts->type == CTS_TYPE_CURRENT_SETTINGS)
-		 || ((cpi.hba_inquiry & PI_SDTR_ABLE) == 0)) {
-			/* Force async */
-			spi->sync_period = 0;
-			spi->sync_offset = 0;
-		}
-
-		switch (spi->bus_width) {
-		case MSG_EXT_WDTR_BUS_32_BIT:
-			if (((device->flags & CAM_DEV_INQUIRY_DATA_VALID) == 0
-			  || (inq_data->flags & SID_WBus32) != 0
-			  || cts->type == CTS_TYPE_USER_SETTINGS)
-			 && (cpi.hba_inquiry & PI_WIDE_32) != 0)
-				break;
-			/* Fall Through to 16-bit */
-		case MSG_EXT_WDTR_BUS_16_BIT:
-			if (((device->flags & CAM_DEV_INQUIRY_DATA_VALID) == 0
-			  || (inq_data->flags & SID_WBus16) != 0
-			  || cts->type == CTS_TYPE_USER_SETTINGS)
-			 && (cpi.hba_inquiry & PI_WIDE_16) != 0) {
-				spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT;
-				break;
-			}
-			/* Fall Through to 8-bit */
-		default: /* New bus width?? */
-		case MSG_EXT_WDTR_BUS_8_BIT:
-			/* All targets can do this */
-			spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
-			break;
-		}
-
-		spi3caps = cpi.xport_specific.spi.ppr_options;
-		if ((device->flags & CAM_DEV_INQUIRY_DATA_VALID) != 0
-		 && cts->type == CTS_TYPE_CURRENT_SETTINGS)
-			spi3caps &= inq_data->spi3data;
-
-		if ((spi3caps & SID_SPI_CLOCK_DT) == 0)
-			spi->ppr_options &= ~MSG_EXT_PPR_DT_REQ;
-
-		if ((spi3caps & SID_SPI_IUS) == 0)
-			spi->ppr_options &= ~MSG_EXT_PPR_IU_REQ;
-
-		if ((spi3caps & SID_SPI_QAS) == 0)
-			spi->ppr_options &= ~MSG_EXT_PPR_QAS_REQ;
-
-		/* No SPI Transfer settings are allowed unless we are wide */
-		if (spi->bus_width == 0)
-			spi->ppr_options = 0;
-
-		if ((spi->valid & CTS_SPI_VALID_DISC)
-		 && ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) == 0)) {
-			/*
-			 * Can't tag queue without disconnection.
-			 */
-			scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB;
-			scsi->valid |= CTS_SCSI_VALID_TQ;
-		}
-
-		/*
-		 * If we are currently performing tagged transactions to
-		 * this device and want to change its negotiation parameters,
-		 * go non-tagged for a bit to give the controller a chance to
-		 * negotiate unhampered by tag messages.
-		 */
-		if (cts->type == CTS_TYPE_CURRENT_SETTINGS
-		 && (device->inq_flags & SID_CmdQue) != 0
-		 && (scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0
-		 && (spi->flags & (CTS_SPI_VALID_SYNC_RATE|
-				   CTS_SPI_VALID_SYNC_OFFSET|
-				   CTS_SPI_VALID_BUS_WIDTH)) != 0)
-			scsi_toggle_tags(cts->ccb_h.path);
-	}
-
 	if (cts->type == CTS_TYPE_CURRENT_SETTINGS
 	 && (scsi->valid & CTS_SCSI_VALID_TQ) != 0) {
 		int device_tagenb;


More information about the p4-projects mailing list