Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2012 18:05:55 +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: r230875 - stable/8/sys/cam/scsi
Message-ID:  <201202011805.q11I5tqE098484@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Feb  1 18:05:54 2012
New Revision: 230875
URL: http://svn.freebsd.org/changeset/base/230875

Log:
  MFC r228820, r228851:
  Merge to da driver quirks hinting 4K physical sector sizes for SATA disks
  connected via SAS or USB. Unluckily I've found that SAS (mps) and USB-SATA
  I have translate models in different ways, requiring twice more quirks.
  Unluckily for Hitachi, their model names are trimmed on SAS, making
  impossible to identify 4K sector drives that way.

Modified:
  stable/8/sys/cam/scsi/scsi_da.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  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/e1000/   (props changed)

Modified: stable/8/sys/cam/scsi/scsi_da.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_da.c	Wed Feb  1 18:03:21 2012	(r230874)
+++ stable/8/sys/cam/scsi/scsi_da.c	Wed Feb  1 18:05:54 2012	(r230875)
@@ -88,7 +88,8 @@ typedef enum {
 	DA_Q_NONE		= 0x00,
 	DA_Q_NO_SYNC_CACHE	= 0x01,
 	DA_Q_NO_6_BYTE		= 0x02,
-	DA_Q_NO_PREVENT		= 0x04
+	DA_Q_NO_PREVENT		= 0x04,
+	DA_Q_4K			= 0x08
 } da_quirks;
 
 typedef enum {
@@ -111,6 +112,8 @@ struct disk_params {
 	u_int8_t  secs_per_track;
 	u_int32_t secsize;	/* Number of bytes/sector */
 	u_int64_t sectors;	/* total number sectors */
+	u_int     stripesize;
+	u_int     stripeoffset;
 };
 
 struct da_softc {
@@ -563,7 +566,223 @@ static struct da_quirk_entry da_quirk_ta
 		 */
 		{T_DIRECT, SIP_MEDIA_REMOVABLE, "Sony", "Sony DSC", "*"},
 		/*quirks*/ DA_Q_NO_SYNC_CACHE | DA_Q_NO_PREVENT
-	}
+	},
+	/* ATA/SATA devices over SAS/USB/... */
+	{
+		/* Hitachi Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "Hitachi", "H??????????E3*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Samsung Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "SAMSUNG HD155UI*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Samsung Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "SAMSUNG", "HD155UI*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Samsung Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "SAMSUNG HD204UI*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Samsung Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "SAMSUNG", "HD204UI*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Barracuda Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST????DL*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Barracuda Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST????DL", "*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Barracuda Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST???DM*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Barracuda Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST???DM*", "*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Barracuda Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST????DM*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Barracuda Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST????DM", "*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9500423AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST950042", "3AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9500424AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST950042", "4AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9640423AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST964042", "3AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9640424AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST964042", "4AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9750420AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST975042", "0AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9750422AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST975042", "2AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST9750423AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST975042", "3AS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Thin Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "ST???LT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* Seagate Momentus Thin Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ST???LT*", "*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD????RS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "??RS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD????RX*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "??RX*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD??????RS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "????RS*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD??????RX*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Caviar Green Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "????RX*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Black Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD???PKT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Black Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "?PKT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Black Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD?????PKT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Black Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "???PKT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Blue Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD???PVT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Blue Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "?PVT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Blue Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "ATA", "WDC WD?????PVT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
+	{
+		/* WDC Scorpio Blue Advanced Format (4k) drives */
+		{ T_DIRECT, SIP_MEDIA_FIXED, "WDC WD??", "???PVT*", "*" },
+		/*quirks*/DA_Q_4K
+	},
 };
 
 static	disk_strategy_t	dastrategy;
@@ -584,7 +803,7 @@ static  int		daerror(union ccb *ccb, u_i
 static void		daprevent(struct cam_periph *periph, int action);
 static int		dagetcapacity(struct cam_periph *periph);
 static void		dasetgeom(struct cam_periph *periph, uint32_t block_len,
-				  uint64_t maxsector);
+				  uint64_t maxsector, u_int lbppbe, u_int lalba);
 static timeout_t	dasendorderedtag;
 static void		dashutdown(void *arg, int howto);
 
@@ -686,6 +905,8 @@ daopen(struct disk *dp)
 
 		softc->disk->d_sectorsize = softc->params.secsize;
 		softc->disk->d_mediasize = softc->params.secsize * (off_t)softc->params.sectors;
+		softc->disk->d_stripesize = softc->params.stripesize;
+		softc->disk->d_stripeoffset = softc->params.stripeoffset;
 		/* 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;
@@ -1661,7 +1882,7 @@ dadone(struct cam_periph *periph, union 
 				announce_buf[0] = '\0';
 				cam_periph_invalidate(periph);
 			} else {
-				dasetgeom(periph, block_size, maxsector);
+				dasetgeom(periph, block_size, maxsector, 0, 0);
 				dp = &softc->params;
 				snprintf(announce_buf, sizeof(announce_buf),
 				        "%juMB (%ju %u byte sectors: %dH %dS/T "
@@ -1992,7 +2213,7 @@ done:
 			    (uintmax_t) block_len);
 			error = EINVAL;
 		} else
-			dasetgeom(periph, block_len, maxsector);
+			dasetgeom(periph, block_len, maxsector, 0, 0);
 	}
 
 	xpt_release_ccb(ccb);
@@ -2003,7 +2224,8 @@ done:
 }
 
 static void
-dasetgeom(struct cam_periph *periph, uint32_t block_len, uint64_t maxsector)
+dasetgeom(struct cam_periph *periph, uint32_t block_len, uint64_t maxsector,
+    u_int lbppbe, u_int lalba)
 {
 	struct ccb_calc_geometry ccg;
 	struct da_softc *softc;
@@ -2014,6 +2236,17 @@ dasetgeom(struct cam_periph *periph, uin
 	dp = &softc->params;
 	dp->secsize = block_len;
 	dp->sectors = maxsector + 1;
+	if (lbppbe > 0) {
+		dp->stripesize = block_len << lbppbe;
+		dp->stripeoffset = (dp->stripesize - block_len * lalba) %
+		    dp->stripesize;
+	} else if (softc->quirks & DA_Q_4K) {
+		dp->stripesize = 4096;
+		dp->stripeoffset = 0;
+	} else {
+		dp->stripesize = 0;
+		dp->stripeoffset = 0;
+	}
 	/*
 	 * Have the controller provide us with a geometry
 	 * for this disk.  The only time the geometry



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