Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2013 05:37:06 +0000 (UTC)
From:      Scott Long <scottl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r251899 - in stable/9/sys/dev: isci mps
Message-ID:  <201306180537.r5I5b6Rp006889@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Tue Jun 18 05:37:06 2013
New Revision: 251899
URL: http://svnweb.freebsd.org/changeset/base/251899

Log:
  MFC r248825, 248775
  
  Add unmapped i/o support for the mps and isci drivers.
  
  Submitted by:	mav, jimharris
  Obtained from:	Netflix

Modified:
  stable/9/sys/dev/isci/isci_controller.c
  stable/9/sys/dev/isci/isci_io_request.c
  stable/9/sys/dev/mps/mps_sas.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/isci/isci_controller.c
==============================================================================
--- stable/9/sys/dev/isci/isci_controller.c	Tue Jun 18 05:22:17 2013	(r251898)
+++ stable/9/sys/dev/isci/isci_controller.c	Tue Jun 18 05:37:06 2013	(r251899)
@@ -632,7 +632,8 @@ void isci_action(struct cam_sim *sim, un
 			cpi->version_num = 1;
 			cpi->hba_inquiry = PI_TAG_ABLE;
 			cpi->target_sprt = 0;
-			cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
+			cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN |
+			    PIM_UNMAPPED;
 			cpi->hba_eng_cnt = 0;
 			cpi->max_target = SCI_MAX_REMOTE_DEVICES - 1;
 			cpi->max_lun = ISCI_MAX_LUN;

Modified: stable/9/sys/dev/isci/isci_io_request.c
==============================================================================
--- stable/9/sys/dev/isci/isci_io_request.c	Tue Jun 18 05:22:17 2013	(r251898)
+++ stable/9/sys/dev/isci/isci_io_request.c	Tue Jun 18 05:37:06 2013	(r251899)
@@ -506,10 +506,31 @@ uint8_t *
 scif_cb_io_request_get_virtual_address_from_sgl(void * scif_user_io_request,
     uint32_t byte_offset)
 {
-	struct ISCI_IO_REQUEST *isci_request =
-	    (struct ISCI_IO_REQUEST *)scif_user_io_request;
+	struct ISCI_IO_REQUEST	*isci_request;
+	union ccb		*ccb;
+
 
-	return (isci_request->ccb->csio.data_ptr + byte_offset);
+	isci_request = scif_user_io_request;
+	ccb = isci_request->ccb;
+
+	/*
+	 * This callback is only invoked for SCSI/ATA translation of
+	 *  PIO commands such as INQUIRY and READ_CAPACITY, to allow
+	 *  the driver to write the translated data directly into the
+	 *  data buffer.  It is never invoked for READ/WRITE commands.
+	 *  The driver currently assumes only READ/WRITE commands will
+	 *  be unmapped.
+	 *
+	 * As a safeguard against future changes to unmapped commands,
+	 *  add an explicit panic here should the DATA_MASK != VADDR.
+	 *  Otherwise, we would return some garbage pointer back to the
+	 *  caller which would result in a panic or more subtle data
+	 *  corruption later on.
+	 */
+	if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR)
+		panic("%s: requesting pointer into unmapped ccb", __func__);
+
+	return (ccb->csio.data_ptr + byte_offset);
 }
 
 /**
@@ -747,10 +768,6 @@ isci_io_request_execute_scsi_io(union cc
 	io_request->current_sge_index = 0;
 	io_request->parent.remote_device_handle = device->sci_object;
 
-	if ((ccb->ccb_h.flags & CAM_DATA_MASK) != CAM_DATA_VADDR)
-		panic("Unexpected cam data format!  flags = 0x%x\n",
-		    ccb->ccb_h.flags);
-
 	error = bus_dmamap_load_ccb(io_request->parent.dma_tag,
 	    io_request->parent.dma_map, ccb,
 	    isci_io_request_construct, io_request, 0x0);

Modified: stable/9/sys/dev/mps/mps_sas.c
==============================================================================
--- stable/9/sys/dev/mps/mps_sas.c	Tue Jun 18 05:22:17 2013	(r251898)
+++ stable/9/sys/dev/mps/mps_sas.c	Tue Jun 18 05:37:06 2013	(r251899)
@@ -914,7 +914,7 @@ mpssas_action(struct cam_sim *sim, union
 		cpi->version_num = 1;
 		cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
 		cpi->target_sprt = 0;
-		cpi->hba_misc = PIM_NOBUSRESET;
+		cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED;
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = sassc->sc->facts->MaxTargets - 1;
 		cpi->max_lun = 255;
@@ -2238,6 +2238,7 @@ mpssas_scsiio_complete(struct mps_softc 
 		if ((csio->cdb_io.cdb_bytes[0] == INQUIRY) &&
 		    (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) &&
 		    (sc->mapping_table[csio->ccb_h.target_id].device_info &



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