Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 2009 12:04:43 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r196732 - in stable/8: sbin/camcontrol sys sys/amd64/include/xen sys/cam/ata sys/cddl/contrib/opensolaris sys/contrib/dev/acpica sys/contrib/pf sys/dev/xen/xenpci
Message-ID:  <200909011204.n81C4hL0060765@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Tue Sep  1 12:04:43 2009
New Revision: 196732
URL: http://svn.freebsd.org/changeset/base/196732

Log:
  MFC r196657:
  ATA_FLUSHCACHE is a 28bit format command, not 48.
  
  MFC r196658:
  Improve camcontrol ATA support:
   - Tune protocol version reporting,
   - Add supported DMA/PIO modes reporting.
   - Fix IDENTIFY request for ATAPI devices.
   - Remove confusing "-" for NCQ status.
  
  MFC r196659:
  Short ATA command format has 28bit address, not 36bit.
  Rename ata_36bit_cmd() into ata_28bit_cmd(), while it didn't become legacy.
  
  Approved by:	re (ATA-CAM blanket)

Modified:
  stable/8/sbin/camcontrol/   (props changed)
  stable/8/sbin/camcontrol/camcontrol.c
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cam/ata/ata_all.c
  stable/8/sys/cam/ata/ata_all.h
  stable/8/sys/cam/ata/ata_da.c
  stable/8/sys/cam/ata/ata_xpt.c
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sbin/camcontrol/camcontrol.c
==============================================================================
--- stable/8/sbin/camcontrol/camcontrol.c	Tue Sep  1 11:44:30 2009	(r196731)
+++ stable/8/sbin/camcontrol/camcontrol.c	Tue Sep  1 12:04:43 2009	(r196732)
@@ -206,6 +206,7 @@ static void cts_print(struct cam_device 
 		      struct ccb_trans_settings *cts);
 static void cpi_print(struct ccb_pathinq *cpi);
 static int get_cpi(struct cam_device *device, struct ccb_pathinq *cpi);
+static int get_cgd(struct cam_device *device, struct ccb_getdev *cgd);
 static int get_print_cts(struct cam_device *device, int user_settings,
 			 int quiet, struct ccb_trans_settings *cts);
 static int ratecontrol(struct cam_device *device, int retry_count,
@@ -1015,17 +1016,18 @@ atacapprint(struct ata_params *parm)
 				((u_int64_t)parm->lba_size48_4 << 48);
 
 	printf("\n");
-	printf("Protocol              ");
+	printf("protocol              ");
+	printf("ATA/ATAPI-%d", ata_version(parm->version_major));
 	if (parm->satacapabilities && parm->satacapabilities != 0xffff) {
 		if (parm->satacapabilities & ATA_SATA_GEN2)
-			printf("SATA revision 2.x\n");
+			printf(" SATA 2.x\n");
 		else if (parm->satacapabilities & ATA_SATA_GEN1)
-			printf("SATA revision 1.x\n");
+			printf(" SATA 1.x\n");
 		else
-			printf("Unknown SATA revision\n");
+			printf(" SATA x.x\n");
 	}
 	else
-		printf("ATA/ATAPI revision %d\n", ata_version(parm->version_major));
+		printf("\n");
 	printf("device model          %.40s\n", parm->model);
 	printf("serial number         %.20s\n", parm->serial);
 	printf("firmware revision     %.8s\n", parm->revision);
@@ -1038,22 +1040,74 @@ atacapprint(struct ata_params *parm)
 	    (parm->support.command2 & ATA_SUPPORT_CFA))
 		printf("CFA supported\n");
 
-	printf("lba%ssupported         ",
+	printf("LBA%ssupported         ",
 		parm->capabilities1 & ATA_SUPPORT_LBA ? " " : " not ");
 	if (lbasize)
 		printf("%d sectors\n", lbasize);
 	else
 		printf("\n");
 
-	printf("lba48%ssupported       ",
+	printf("LBA48%ssupported       ",
 		parm->support.command2 & ATA_SUPPORT_ADDRESS48 ? " " : " not ");
 	if (lbasize48)
 		printf("%ju sectors\n", (uintmax_t)lbasize48);
 	else
 		printf("\n");
 
-	printf("dma%ssupported\n",
+	printf("PIO supported         PIO");
+	if (parm->atavalid & ATA_FLAG_64_70) {
+		if (parm->apiomodes & 0x02)
+			printf("4");
+		else if (parm->apiomodes & 0x01)
+			printf("3");
+	} else if (parm->mwdmamodes & 0x04)
+		printf("4");
+	else if (parm->mwdmamodes & 0x02)
+		printf("3");
+	else if (parm->mwdmamodes & 0x01)
+		printf("2");
+	else if ((parm->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x200)
+		printf("2");
+	else if ((parm->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x100)
+		printf("1");
+	else
+		printf("0");
+	printf("\n");
+
+	printf("DMA%ssupported         ",
 		parm->capabilities1 & ATA_SUPPORT_DMA ? " " : " not ");
+	if (parm->capabilities1 & ATA_SUPPORT_DMA) {
+		if (parm->mwdmamodes & 0xff) {
+			printf("WDMA");
+			if (parm->mwdmamodes & 0x04)
+				printf("2");
+			else if (parm->mwdmamodes & 0x02)
+				printf("1");
+			else if (parm->mwdmamodes & 0x01)
+				printf("0");
+			printf(" ");
+		}
+		if ((parm->atavalid & ATA_FLAG_88) &&
+		    (parm->udmamodes & 0xff)) {
+			printf("UDMA");
+			if (parm->udmamodes & 0x40)
+				printf("6");
+			else if (parm->udmamodes & 0x20)
+				printf("5");
+			else if (parm->udmamodes & 0x10)
+				printf("4");
+			else if (parm->udmamodes & 0x08)
+				printf("3");
+			else if (parm->udmamodes & 0x04)
+				printf("2");
+			else if (parm->udmamodes & 0x02)
+				printf("1");
+			else if (parm->udmamodes & 0x01)
+				printf("0");
+			printf(" ");
+		}
+	}
+	printf("\n");
 
 	printf("overlap%ssupported\n",
 		parm->capabilities1 & ATA_SUPPORT_OVERLAP ? " " : " not ");
@@ -1070,10 +1124,10 @@ atacapprint(struct ata_params *parm)
 		parm->enabled.command1 & ATA_SUPPORT_LOOKAHEAD ? "yes" : "no");
 
 	if (parm->satacapabilities && parm->satacapabilities != 0xffff) {
-		printf("Native Command Queuing (NCQ)   %s	%s"
+		printf("Native Command Queuing (NCQ)   %s	"
 			"	%d/0x%02X\n",
 			parm->satacapabilities & ATA_SUPPORT_NCQ ?
-				"yes" : "no", " -",
+				"yes" : "no",
 			(parm->satacapabilities & ATA_SUPPORT_NCQ) ?
 				ATA_QUEUE_LEN(parm->queue) : 0,
 			(parm->satacapabilities & ATA_SUPPORT_NCQ) ?
@@ -1121,9 +1175,14 @@ ataidentify(struct cam_device *device, i
 {
 	union ccb *ccb;
 	struct ata_params *ident_buf;
+	struct ccb_getdev cgd;
 	u_int i, error = 0;
 	int16_t *ptr;
-	
+
+	if (get_cgd(device, &cgd) != 0) {
+		warnx("couldn't get CGD");
+		return(1);
+	}
 	ccb = cam_getccb(device);
 
 	if (ccb == NULL) {
@@ -1152,10 +1211,10 @@ ataidentify(struct cam_device *device, i
 		      /*data_ptr*/(u_int8_t *)ptr,
 		      /*dxfer_len*/sizeof(struct ata_params),
 		      timeout ? timeout : 30 * 1000);
-//	if (periph->path->device->protocol == PROTO_ATA)
-		ata_36bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0);
-//	else
-//		ata_36bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
+	if (cgd.protocol == PROTO_ATA)
+		ata_28bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0);
+	else
+		ata_28bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
 
 	/* Disable freezing the device queue */
 	ccb->ccb_h.flags |= CAM_DEV_QFRZDIS;
@@ -2588,46 +2647,71 @@ get_cpi(struct cam_device *device, struc
 	int retval = 0;
 
 	ccb = cam_getccb(device);
-
 	if (ccb == NULL) {
 		warnx("get_cpi: couldn't allocate CCB");
 		return(1);
 	}
-
 	bzero(&(&ccb->ccb_h)[1],
 	      sizeof(struct ccb_pathinq) - sizeof(struct ccb_hdr));
-
 	ccb->ccb_h.func_code = XPT_PATH_INQ;
-
 	if (cam_send_ccb(device, ccb) < 0) {
 		warn("get_cpi: error sending Path Inquiry CCB");
-
 		if (arglist & CAM_ARG_VERBOSE)
 			cam_error_print(device, ccb, CAM_ESF_ALL,
 					CAM_EPF_ALL, stderr);
-
 		retval = 1;
-
 		goto get_cpi_bailout;
 	}
-
 	if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
-
 		if (arglist & CAM_ARG_VERBOSE)
 			cam_error_print(device, ccb, CAM_ESF_ALL,
 					CAM_EPF_ALL, stderr);
-
 		retval = 1;
-
 		goto get_cpi_bailout;
 	}
-
 	bcopy(&ccb->cpi, cpi, sizeof(struct ccb_pathinq));
 
 get_cpi_bailout:
-
 	cam_freeccb(ccb);
+	return(retval);
+}
 
+/*
+ * Get a get device CCB for the specified device.  
+ */
+static int
+get_cgd(struct cam_device *device, struct ccb_getdev *cgd)
+{
+	union ccb *ccb;
+	int retval = 0;
+
+	ccb = cam_getccb(device);
+	if (ccb == NULL) {
+		warnx("get_cgd: couldn't allocate CCB");
+		return(1);
+	}
+	bzero(&(&ccb->ccb_h)[1],
+	      sizeof(struct ccb_pathinq) - sizeof(struct ccb_hdr));
+	ccb->ccb_h.func_code = XPT_GDEV_TYPE;
+	if (cam_send_ccb(device, ccb) < 0) {
+		warn("get_cgd: error sending Path Inquiry CCB");
+		if (arglist & CAM_ARG_VERBOSE)
+			cam_error_print(device, ccb, CAM_ESF_ALL,
+					CAM_EPF_ALL, stderr);
+		retval = 1;
+		goto get_cgd_bailout;
+	}
+	if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+		if (arglist & CAM_ARG_VERBOSE)
+			cam_error_print(device, ccb, CAM_ESF_ALL,
+					CAM_EPF_ALL, stderr);
+		retval = 1;
+		goto get_cgd_bailout;
+	}
+	bcopy(&ccb->cgd, cgd, sizeof(struct ccb_getdev));
+
+get_cgd_bailout:
+	cam_freeccb(ccb);
 	return(retval);
 }
 
@@ -2673,6 +2757,9 @@ cpi_print(struct ccb_pathinq *cpi)
 		case PI_SOFT_RST:
 			str = "soft reset alternative";
 			break;
+		case PI_SATAPM:
+			str = "SATA Port Multiplier";
+			break;
 		default:
 			str = "unknown PI bit set";
 			break;
@@ -2702,6 +2789,12 @@ cpi_print(struct ccb_pathinq *cpi)
 			str = "user has disabled initial BUS RESET or"
 			      " controller is in target/mixed mode";
 			break;
+		case PIM_NO_6_BYTE:
+			str = "do not send 6-byte commands";
+			break;
+		case PIM_SEQSCAN:
+			str = "scan bus sequentially";
+			break;
 		default:
 			str = "unknown PIM bit set";
 			break;

Modified: stable/8/sys/cam/ata/ata_all.c
==============================================================================
--- stable/8/sys/cam/ata/ata_all.c	Tue Sep  1 11:44:30 2009	(r196731)
+++ stable/8/sys/cam/ata/ata_all.c	Tue Sep  1 12:04:43 2009	(r196732)
@@ -91,7 +91,7 @@ ata_print_ident(struct ata_params *ident
 }
 
 void
-ata_36bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features,
+ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features,
     uint32_t lba, uint8_t sector_count)
 {
 	bzero(&ataio->cmd, sizeof(ataio->cmd));

Modified: stable/8/sys/cam/ata/ata_all.h
==============================================================================
--- stable/8/sys/cam/ata/ata_all.h	Tue Sep  1 11:44:30 2009	(r196731)
+++ stable/8/sys/cam/ata/ata_all.h	Tue Sep  1 12:04:43 2009	(r196732)
@@ -83,7 +83,7 @@ struct ata_res {
 int	ata_version(int ver);
 void	ata_print_ident(struct ata_params *ident_data);
 
-void	ata_36bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features,
+void	ata_28bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint8_t features,
     uint32_t lba, uint8_t sector_count);
 void	ata_48bit_cmd(struct ccb_ataio *ataio, uint8_t cmd, uint16_t features,
     uint64_t lba, uint16_t sector_count);

Modified: stable/8/sys/cam/ata/ata_da.c
==============================================================================
--- stable/8/sys/cam/ata/ata_da.c	Tue Sep  1 11:44:30 2009	(r196731)
+++ stable/8/sys/cam/ata/ata_da.c	Tue Sep  1 12:04:43 2009	(r196732)
@@ -287,7 +287,7 @@ adaclose(struct disk *dp)
 		if (softc->flags & ADA_FLAG_CAN_48BIT)
 			ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE48, 0, 0, 0);
 		else
-			ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0);
+			ata_28bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0);
 		cam_periph_runccb(ccb, /*error_routine*/NULL, /*cam_flags*/0,
 		    /*sense_flags*/SF_RETRY_UA,
 		    softc->disk->d_devstat);
@@ -411,7 +411,7 @@ adadump(void *arg, void *virtual, vm_off
 			ata_48bit_cmd(&ccb.ataio, ATA_WRITE_DMA48,
 			    0, lba, count);
 		} else {
-			ata_36bit_cmd(&ccb.ataio, ATA_WRITE_DMA,
+			ata_28bit_cmd(&ccb.ataio, ATA_WRITE_DMA,
 			    0, lba, count);
 		}
 		xpt_polled_action(&ccb);
@@ -441,7 +441,7 @@ adadump(void *arg, void *virtual, vm_off
 		if (softc->flags & ADA_FLAG_CAN_48BIT)
 			ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0);
 		else
-			ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0);
+			ata_28bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0);
 		xpt_polled_action(&ccb);
 
 		if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
@@ -856,10 +856,10 @@ adastart(struct cam_periph *periph, unio
 					}
 				} else {
 					if (bp->bio_cmd == BIO_READ) {
-						ata_36bit_cmd(ataio, ATA_READ_DMA,
+						ata_28bit_cmd(ataio, ATA_READ_DMA,
 						    0, lba, count);
 					} else {
-						ata_36bit_cmd(ataio, ATA_WRITE_DMA,
+						ata_28bit_cmd(ataio, ATA_WRITE_DMA,
 						    0, lba, count);
 					}
 				}
@@ -878,7 +878,7 @@ adastart(struct cam_periph *periph, unio
 				if (softc->flags & ADA_FLAG_CAN_48BIT)
 					ata_48bit_cmd(ataio, ATA_FLUSHCACHE48, 0, 0, 0);
 				else
-					ata_48bit_cmd(ataio, ATA_FLUSHCACHE, 0, 0, 0);
+					ata_28bit_cmd(ataio, ATA_FLUSHCACHE, 0, 0, 0);
 				break;
 			}
 			start_ccb->ccb_h.ccb_state = ADA_CCB_BUFFER_IO;
@@ -1126,7 +1126,7 @@ adashutdown(void * arg, int howto)
 		if (softc->flags & ADA_FLAG_CAN_48BIT)
 			ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0);
 		else
-			ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0);
+			ata_28bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0);
 		xpt_polled_action(&ccb);
 
 		if ((ccb.ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)

Modified: stable/8/sys/cam/ata/ata_xpt.c
==============================================================================
--- stable/8/sys/cam/ata/ata_xpt.c	Tue Sep  1 11:44:30 2009	(r196731)
+++ stable/8/sys/cam/ata/ata_xpt.c	Tue Sep  1 12:04:43 2009	(r196732)
@@ -357,9 +357,9 @@ probestart(struct cam_periph *periph, un
 		      /*dxfer_len*/sizeof(struct ata_params),
 		      30 * 1000);
 		if (periph->path->device->protocol == PROTO_ATA)
-			ata_36bit_cmd(ataio, ATA_ATA_IDENTIFY, 0, 0, 0);
+			ata_28bit_cmd(ataio, ATA_ATA_IDENTIFY, 0, 0, 0);
 		else
-			ata_36bit_cmd(ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
+			ata_28bit_cmd(ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
 		break;
 	}
 	case PROBE_SETMODE:
@@ -375,7 +375,7 @@ probestart(struct cam_periph *periph, un
 		      /*data_ptr*/NULL,
 		      /*dxfer_len*/0,
 		      30 * 1000);
-		ata_36bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0,
+		ata_28bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0,
 		    ata_max_mode(ident_buf, ATA_UDMA6, ATA_UDMA6));
 		break;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909011204.n81C4hL0060765>