Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 May 2014 20:28:23 +0000 (UTC)
From:      "Kenneth D. Merry" <ken@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265709 - in head/sys/dev: mpr mps
Message-ID:  <201405082028.s48KSNnJ076026@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ken
Date: Thu May  8 20:28:22 2014
New Revision: 265709
URL: http://svnweb.freebsd.org/changeset/base/265709

Log:
  Fix TLR (Transport Layer Retry) support in the mps(4) and mpr(4) drivers.
  
  TLR is necessary for reliable communication with SAS tape drives.
  
  This was broken by change 246713 in the mps(4) driver.  It changed the
  cm_data field for SCSI I/O requests to point to the CCB instead of the data
  buffer.  So, instead, look at the CCB's data pointer to determine whether
  or not we're talking to a tape drive.
  
  Also, take the residual into account to make sure that we don't go off the
  end of the request.
  
  MFC after:	3 days
  Sponsored by:	Spectra Logic Corporation

Modified:
  head/sys/dev/mpr/mpr_sas.c
  head/sys/dev/mps/mps_sas.c

Modified: head/sys/dev/mpr/mpr_sas.c
==============================================================================
--- head/sys/dev/mpr/mpr_sas.c	Thu May  8 20:27:06 2014	(r265708)
+++ head/sys/dev/mpr/mpr_sas.c	Thu May  8 20:28:22 2014	(r265709)
@@ -2355,8 +2355,9 @@ mprsas_scsiio_complete(struct mpr_softc 
 		    (csio->cdb_io.cdb_bytes[1] & SI_EVPD) &&
 		    (csio->cdb_io.cdb_bytes[2] == SVPD_SUPPORTED_PAGE_LIST) &&
 		    ((csio->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) &&
-		    (csio->data_ptr != NULL) && (((uint8_t *)cm->cm_data)[0] ==
-		    T_SEQUENTIAL) && (sc->control_TLR) &&
+		    (csio->data_ptr != NULL) &&
+		    ((csio->data_ptr[0] & 0x1f) == T_SEQUENTIAL) &&
+		    (sc->control_TLR) &&
 		    (sc->mapping_table[csio->ccb_h.target_id].device_info &
 		    MPI2_SAS_DEVICE_INFO_SSP_TARGET)) {
 			vpd_list = (struct scsi_vpd_supported_page_list *)
@@ -2367,6 +2368,7 @@ mprsas_scsiio_complete(struct mpr_softc 
 			TLR_on = (u8)MPI2_SCSIIO_CONTROL_TLR_ON;
 			alloc_len = ((u16)csio->cdb_io.cdb_bytes[3] << 8) +
 			    csio->cdb_io.cdb_bytes[4];
+			alloc_len -= csio->resid;
 			for (i = 0; i < MIN(vpd_list->length, alloc_len); i++) {
 				if (vpd_list->list[i] == 0x90) {
 					*TLR_bits = TLR_on;

Modified: head/sys/dev/mps/mps_sas.c
==============================================================================
--- head/sys/dev/mps/mps_sas.c	Thu May  8 20:27:06 2014	(r265708)
+++ head/sys/dev/mps/mps_sas.c	Thu May  8 20:28:22 2014	(r265709)
@@ -2316,8 +2316,9 @@ mpssas_scsiio_complete(struct mps_softc 
 		    (csio->cdb_io.cdb_bytes[1] & SI_EVPD) &&
 		    (csio->cdb_io.cdb_bytes[2] == SVPD_SUPPORTED_PAGE_LIST) &&
 		    ((csio->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) &&
-		    (csio->data_ptr != NULL) && (((uint8_t *)cm->cm_data)[0] ==
-		    T_SEQUENTIAL) && (sc->control_TLR) &&
+		    (csio->data_ptr != NULL) &&
+		    ((csio->data_ptr[0] & 0x1f) == T_SEQUENTIAL) &&
+		    (sc->control_TLR) &&
 		    (sc->mapping_table[csio->ccb_h.target_id].device_info &
 		    MPI2_SAS_DEVICE_INFO_SSP_TARGET)) {
 			vpd_list = (struct scsi_vpd_supported_page_list *)
@@ -2328,6 +2329,7 @@ mpssas_scsiio_complete(struct mps_softc 
 			TLR_on = (u8)MPI2_SCSIIO_CONTROL_TLR_ON;
 			alloc_len = ((u16)csio->cdb_io.cdb_bytes[3] << 8) +
 			    csio->cdb_io.cdb_bytes[4];
+			alloc_len -= csio->resid;
 			for (i = 0; i < MIN(vpd_list->length, alloc_len); i++) {
 				if (vpd_list->list[i] == 0x90) {
 					*TLR_bits = TLR_on;



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