svn commit: r298143 - in head/sys: cam cam/ata dev/ahci dev/ata dev/mvs dev/siis

Warner Losh imp at FreeBSD.org
Sun Apr 17 05:24:38 UTC 2016


Author: imp
Date: Sun Apr 17 05:24:36 2016
New Revision: 298143
URL: https://svnweb.freebsd.org/changeset/base/298143

Log:
  Implement Auxiliary register. Add PIM_ATA_EXT flag to flag that a SIM
  can handle it, and add the code to add it to the FIS that's sent to
  the drive. The mvs driver is the only other ATA driver in the system,
  and its hardware doesn't appear to support setting the Auxiliary
  register.
  
  Differential Revision: https://reviews.freebsd.org/D5598

Modified:
  head/sys/cam/ata/ata_all.h
  head/sys/cam/ata/ata_da.c
  head/sys/cam/cam_ccb.h
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ata/ata-all.c
  head/sys/dev/mvs/mvs.c
  head/sys/dev/siis/siis.c

Modified: head/sys/cam/ata/ata_all.h
==============================================================================
--- head/sys/cam/ata/ata_all.h	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/cam/ata/ata_all.h	Sun Apr 17 05:24:36 2016	(r298143)
@@ -46,7 +46,6 @@ struct ata_cmd {
 #define		CAM_ATAIO_CONTROL	0x04	/* Control, not a command */
 #define		CAM_ATAIO_NEEDRESULT	0x08	/* Request requires result. */
 #define		CAM_ATAIO_DMA		0x10	/* DMA command */
-#define		CAM_ATAIO_AUX_HACK	0x20	/* Kludge to make FPDMA DSM TRIM work */
 
 	u_int8_t	command;
 	u_int8_t	features;

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/cam/ata/ata_da.c	Sun Apr 17 05:24:36 2016	(r298143)
@@ -1522,7 +1522,7 @@ adaregister(struct cam_periph *periph, v
 	 * the sim do do things properly. Perhaps we should look at log 13
 	 * dword 0 bit 0 and dword 1 bit 0 are set too...
 	 */
-	if (cpi.hba_misc & PIM_NCQ_KLUDGE)
+	if (cpi.hba_misc & PIM_ATA_EXT)
 		softc->flags |= ADA_FLAG_PIM_CAN_NCQ_TRIM;
 	if ((softc->quirks & ADA_Q_NCQ_TRIM_BROKEN) == 0 &&
 	    (softc->flags & ADA_FLAG_PIM_CAN_NCQ_TRIM) != 0 &&
@@ -1728,7 +1728,8 @@ ada_ncq_dsmtrim(struct ada_softc *softc,
 	    0,
 	    (ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES);
 	ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM;
-	ataio->cmd.flags |= CAM_ATAIO_AUX_HACK;
+	ataio->ata_flags |= ATA_FLAG_AUX;
+	ataio->aux = 1;
 }
 
 static void

Modified: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/cam/cam_ccb.h	Sun Apr 17 05:24:36 2016	(r298143)
@@ -581,7 +581,7 @@ typedef enum {
 } pi_tmflag;
 
 typedef enum {
-	PIM_NCQ_KLUDGE  = 0x200, /* Supports the sata ncq trim kludge */
+	PIM_ATA_EXT	= 0x200,/* ATA requests can understand ata_ext requests */
 	PIM_EXTLUNS	= 0x100,/* 64bit extended LUNs supported */
 	PIM_SCANHILO	= 0x80,	/* Bus scans from high ID to low ID */
 	PIM_NOREMOVE	= 0x40,	/* Removeable devices not included in scan */
@@ -745,7 +745,9 @@ struct ccb_ataio {
 	u_int32_t  dxfer_len;		/* Data transfer length */
 	u_int32_t  resid;		/* Transfer residual length: 2's comp */
 	u_int8_t   ata_flags;		/* Flags for the rest of the buffer */
-	uint32_t   unused[2];		/* Keep the same size */
+#define ATA_FLAG_AUX 0x1
+	uint32_t   aux;
+	uint32_t   unused;
 };
 
 struct ccb_accept_tio {

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/dev/ahci/ahci.c	Sun Apr 17 05:24:36 2016	(r298143)
@@ -2417,12 +2417,15 @@ ahci_setup_fis(struct ahci_channel *ch, 
 			fis[13] = ccb->ataio.cmd.sector_count_exp;
 		}
 		fis[15] = ATA_A_4BIT;
-		/* Gross and vile hack -- makes ncq trim work w/o changing ataio size */
-		if (ccb->ataio.cmd.flags & CAM_ATAIO_AUX_HACK)
-			fis[16] = 1;
 	} else {
 		fis[15] = ccb->ataio.cmd.control;
 	}
+	if (ccb->ataio.ata_flags & ATA_FLAG_AUX) {
+		fis[16] =  ccb->ataio.aux        & 0xff;
+		fis[17] = (ccb->ataio.aux >>  8) & 0xff;
+		fis[18] = (ccb->ataio.aux >> 16) & 0xff;
+		fis[19] = (ccb->ataio.aux >> 24) & 0xff;
+	}
 	return (20);
 }
 
@@ -2677,7 +2680,7 @@ ahciaction(struct cam_sim *sim, union cc
 		if (ch->caps & AHCI_CAP_SPM)
 			cpi->hba_inquiry |= PI_SATAPM;
 		cpi->target_sprt = 0;
-		cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_NCQ_KLUDGE;
+		cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_ATA_EXT;
 		cpi->hba_eng_cnt = 0;
 		if (ch->caps & AHCI_CAP_SPM)
 			cpi->max_target = 15;

Modified: head/sys/dev/ata/ata-all.c
==============================================================================
--- head/sys/dev/ata/ata-all.c	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/dev/ata/ata-all.c	Sun Apr 17 05:24:36 2016	(r298143)
@@ -962,6 +962,12 @@ ata_check_ids(device_t dev, union ccb *c
 		xpt_done(ccb);
 		return (-1);
 	}
+	/*
+	 * It's a programming error to see AUXILIARY register requests.
+	 */
+	KASSERT(ccb->ccb_h.func_code != XPT_ATA_IO ||
+	    ((ccb->ataio.ata_flags & ATA_FLAG_AUX) == 0),
+	    ("AUX register unsupported"));
 	return (0);
 }
 

Modified: head/sys/dev/mvs/mvs.c
==============================================================================
--- head/sys/dev/mvs/mvs.c	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/dev/mvs/mvs.c	Sun Apr 17 05:24:36 2016	(r298143)
@@ -2245,6 +2245,12 @@ mvs_check_ids(device_t dev, union ccb *c
 		xpt_done(ccb);
 		return (-1);
 	}
+	/*
+	 * It's a programming error to see AUXILIARY register requests.
+	 */
+	KASSERT(ccb->ccb_h.func_code != XPT_ATA_IO ||
+	    ((ccb->ataio.ata_flags & ATA_FLAG_AUX) == 0),
+	    ("AUX register unsupported"));
 	return (0);
 }
 

Modified: head/sys/dev/siis/siis.c
==============================================================================
--- head/sys/dev/siis/siis.c	Sun Apr 17 05:24:28 2016	(r298142)
+++ head/sys/dev/siis/siis.c	Sun Apr 17 05:24:36 2016	(r298143)
@@ -1728,6 +1728,12 @@ siis_setup_fis(device_t dev, struct siis
 			fis[13] = ccb->ataio.cmd.sector_count_exp;
 		}
 		fis[15] = ATA_A_4BIT;
+		if (ccb->ataio.ata_flags & ATA_FLAG_AUX) {
+			fis[16] =  ccb->ataio.aux        & 0xff;
+			fis[17] = (ccb->ataio.aux >>  8) & 0xff;
+			fis[18] = (ccb->ataio.aux >> 16) & 0xff;
+			fis[19] = (ccb->ataio.aux >> 24) & 0xff;
+		}
 	} else {
 		/* Soft reset. */
 	}
@@ -1946,7 +1952,7 @@ siisaction(struct cam_sim *sim, union cc
 		cpi->hba_inquiry = PI_SDTR_ABLE | PI_TAG_ABLE;
 		cpi->hba_inquiry |= PI_SATAPM;
 		cpi->target_sprt = 0;
-		cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED;
+		cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_ATA_EXT;
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = 15;
 		cpi->max_lun = 0;


More information about the svn-src-head mailing list