Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Jun 2019 06:14:21 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349358 - in head/sys/cam: ata scsi
Message-ID:  <201906250614.x5P6ELXa062408@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Jun 25 06:14:21 2019
New Revision: 349358
URL: https://svnweb.freebsd.org/changeset/base/349358

Log:
  Replay r349340 by imp accidentally reverted by r349352
  
  Create ata_param_fixup
  
  Create a common fixup routine to do the canonical fixup of the
  ata_param fixup. Call it from both the ATA and the ATA over SCSI
  paths.

Modified:
  head/sys/cam/ata/ata_all.c
  head/sys/cam/ata/ata_all.h
  head/sys/cam/ata/ata_xpt.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/ata/ata_all.c
==============================================================================
--- head/sys/cam/ata/ata_all.c	Tue Jun 25 06:14:16 2019	(r349357)
+++ head/sys/cam/ata/ata_all.c	Tue Jun 25 06:14:21 2019	(r349358)
@@ -1238,3 +1238,28 @@ ata_zac_mgmt_in(struct ccb_ataio *ataio, uint32_t retr
 		ataio->aux = auxiliary;
 	}
 }
+
+void
+ata_param_fixup(struct ata_params *ident_buf)
+{
+	int16_t *ptr;
+
+	for (ptr = (int16_t *)ident_buf;
+	     ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) {
+		*ptr = le16toh(*ptr);
+	}
+	if (strncmp(ident_buf->model, "FX", 2) &&
+	    strncmp(ident_buf->model, "NEC", 3) &&
+	    strncmp(ident_buf->model, "Pioneer", 7) &&
+	    strncmp(ident_buf->model, "SHARP", 5)) {
+		ata_bswap(ident_buf->model, sizeof(ident_buf->model));
+		ata_bswap(ident_buf->revision, sizeof(ident_buf->revision));
+		ata_bswap(ident_buf->serial, sizeof(ident_buf->serial));
+	}
+	ata_btrim(ident_buf->model, sizeof(ident_buf->model));
+	ata_bpack(ident_buf->model, ident_buf->model, sizeof(ident_buf->model));
+	ata_btrim(ident_buf->revision, sizeof(ident_buf->revision));
+	ata_bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision));
+	ata_btrim(ident_buf->serial, sizeof(ident_buf->serial));
+	ata_bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial));
+}

Modified: head/sys/cam/ata/ata_all.h
==============================================================================
--- head/sys/cam/ata/ata_all.h	Tue Jun 25 06:14:16 2019	(r349357)
+++ head/sys/cam/ata/ata_all.h	Tue Jun 25 06:14:21 2019	(r349358)
@@ -135,6 +135,7 @@ void	ata_read_log(struct ccb_ataio *ataio, uint32_t re
 		     uint16_t block_count, uint32_t protocol,
 		     uint8_t *data_ptr, uint32_t dxfer_len, uint32_t timeout);
 
+void	ata_param_fixup(struct ata_params *ident_buf);
 void	ata_bswap(int8_t *buf, int len);
 void	ata_btrim(int8_t *buf, int len);
 void	ata_bpack(int8_t *src, int8_t *dst, int len);

Modified: head/sys/cam/ata/ata_xpt.c
==============================================================================
--- head/sys/cam/ata/ata_xpt.c	Tue Jun 25 06:14:16 2019	(r349357)
+++ head/sys/cam/ata/ata_xpt.c	Tue Jun 25 06:14:21 2019	(r349358)
@@ -893,31 +893,13 @@ noerror:
 	case PROBE_IDENTIFY:
 	{
 		struct ccb_pathinq cpi;
-		int16_t *ptr;
 		int veto = 0;
 
 		/*
 		 * Convert to host byte order, and fix the strings.
 		 */
 		ident_buf = &softc->ident_data;
-		for (ptr = (int16_t *)ident_buf;
-		     ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) {
-			*ptr = le16toh(*ptr);
-		}
-		if (strncmp(ident_buf->model, "FX", 2) &&
-		    strncmp(ident_buf->model, "NEC", 3) &&
-		    strncmp(ident_buf->model, "Pioneer", 7) &&
-		    strncmp(ident_buf->model, "SHARP", 5)) {
-			ata_bswap(ident_buf->model, sizeof(ident_buf->model));
-			ata_bswap(ident_buf->revision, sizeof(ident_buf->revision));
-			ata_bswap(ident_buf->serial, sizeof(ident_buf->serial));
-		}
-		ata_btrim(ident_buf->model, sizeof(ident_buf->model));
-		ata_bpack(ident_buf->model, ident_buf->model, sizeof(ident_buf->model));
-		ata_btrim(ident_buf->revision, sizeof(ident_buf->revision));
-		ata_bpack(ident_buf->revision, ident_buf->revision, sizeof(ident_buf->revision));
-		ata_btrim(ident_buf->serial, sizeof(ident_buf->serial));
-		ata_bpack(ident_buf->serial, ident_buf->serial, sizeof(ident_buf->serial));
+		ata_param_fixup(ident_buf);
 
 		/*
 		 * Allow others to veto this ATA disk attachment.  This

Modified: head/sys/cam/scsi/scsi_da.c
==============================================================================
--- head/sys/cam/scsi/scsi_da.c	Tue Jun 25 06:14:16 2019	(r349357)
+++ head/sys/cam/scsi/scsi_da.c	Tue Jun 25 06:14:21 2019	(r349358)
@@ -5192,7 +5192,7 @@ dadone_probeata(struct cam_periph *periph, union ccb *
 	struct da_softc *softc;
 	u_int32_t  priority;
 	int continue_probe;
-	int error, i;
+	int error;
 	int16_t *ptr;
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeata\n"));
@@ -5210,8 +5210,7 @@ dadone_probeata(struct cam_periph *periph, union ccb *
 	if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
 		uint16_t old_rate;
 
-		for (i = 0; i < sizeof(*ata_params) / 2; i++)
-			ptr[i] = le16toh(ptr[i]);
+		ata_param_fixup(ata_params);
 		if (ata_params->support_dsm & ATA_SUPPORT_DSM_TRIM &&
 		    (softc->quirks & DA_Q_NO_UNMAP) == 0) {
 			dadeleteflag(softc, DA_DELETE_ATA_TRIM, 1);



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