Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Mar 2014 16:42:33 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r262789 - head/sys/dev/hyperv/storvsc
Message-ID:  <201403051642.s25GgXAM093812@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Mar  5 16:42:33 2014
New Revision: 262789
URL: http://svnweb.freebsd.org/changeset/base/262789

Log:
  Remove custom bus scanner code and fix use of CAM's default scanner.
  
  This fixes kernel panic during boot, caused by incompatibility of recent
  CAM locking changes and this bus scanner code.
  
  Submitted by:	Microsoft
  MFC after:	1 week

Modified:
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Wed Mar  5 16:19:29 2014	(r262788)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Wed Mar  5 16:42:33 2014	(r262789)
@@ -171,15 +171,12 @@ static struct storvsc_driver_props g_drv
 	 STORVSC_RINGBUFFER_SIZE}
 };
 
-static struct storvsc_softc *hs_softc[HS_MAX_ADAPTERS];
-
 /* static functions */
 static int storvsc_probe(device_t dev);
 static int storvsc_attach(device_t dev);
 static int storvsc_detach(device_t dev);
 static void storvsc_poll(struct cam_sim * sim);
 static void storvsc_action(struct cam_sim * sim, union ccb * ccb);
-static void scan_for_luns(struct storvsc_softc * sc);
 static void create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp);
 static void storvsc_free_request(struct storvsc_softc *sc, struct hv_storvsc_request *reqp);
 static enum hv_storage_type storvsc_get_storage_type(device_t dev);
@@ -669,84 +666,6 @@ hv_storvsc_on_channel_callback(void *con
 }
 
 /**
- * @brief callback function for completing a single LUN scan
- *
- * This function is responsible for waking up the executer of
- * the scan LUN CCB action (cam_periph_runccb.)  cam_periph_ccbwait
- * sleeps on the mutex being signaled.
- *
- * @param periph a pointer to a CAM peripheral
- * @param done_ccb pointer to CAM control block
- */
-static void
-storvsc_xptdone(struct cam_periph *periph, union ccb *done_ccb)
-{
-	wakeup(&done_ccb->ccb_h.cbfcnp);
-}
-
-/**
- * @brief scan for attached logical unit numbers (LUNs)
- *
- * In Hyper-V there is no backend changed device operation which
- * presents FreeBSD with a list of devices to connect.  The result is
- * that we have to scan for a list of luns in the storvsc_attach()
- * routine.  There is only one SCSI target, so scan for the maximum
- * number of luns.
- *
- * @param pointer to softc
- */
-static void
-scan_for_luns(struct storvsc_softc *sc)
-{
-	union ccb *request_ccb;
-	struct cam_path *path = sc->hs_path;
-	struct cam_path *my_path = NULL;
-	cam_status status;
-	int lun_nb = 0;
-	int error;
-
-	request_ccb = malloc(sizeof(union ccb), M_CAMXPT, M_WAITOK);
-	my_path = malloc(sizeof(*my_path), M_CAMXPT, M_WAITOK);
-
-	mtx_lock(&sc->hs_lock);
-	do {
-		/*
-		 * Scan the next LUN. Reuse path and ccb structs.
-		 */
-		bzero(my_path, sizeof(*my_path));
-		bzero(request_ccb, sizeof(*request_ccb));
-		status = xpt_compile_path(my_path,
-				  xpt_periph,
-				  path->bus->path_id,
-				  0,
-				  lun_nb);
-
-		if (status != CAM_REQ_CMP) {
-			mtx_unlock(&sc->hs_lock);
-	       		xpt_print(path, "scan_for_lunYYY: can't compile"
-					 " path, 0x%p can't continue\n",
-					 sc->hs_path);
-			free(request_ccb, M_CAMXPT);
-			free(my_path, M_CAMXPT);
-			return;
-		}
-
-		xpt_setup_ccb(&request_ccb->ccb_h, my_path, 5);
-		request_ccb->ccb_h.func_code = XPT_SCAN_LUN;
-		request_ccb->ccb_h.cbfcnp    = storvsc_xptdone;
-		request_ccb->crcn.flags	     = CAM_FLAG_NONE;
-
-		error = cam_periph_runccb(request_ccb, NULL, 
-						CAM_FLAG_NONE, 0, NULL);
-		KASSERT(error == 0, ("cam_periph_runccb failed %d\n", error));
-		xpt_release_path(my_path);
-	} while ( ++lun_nb < sc->hs_drv_props->drv_max_luns_per_target);
-	mtx_unlock(&sc->hs_lock);
-	free(request_ccb, M_CAMXPT);
-	free(my_path, M_CAMXPT);
-}
-
-/**
  * @brief StorVSC probe function
  *
  * Device probe function.  Returns 0 if the input device is a StorVSC
@@ -904,10 +823,6 @@ storvsc_attach(device_t dev)
 	}
 
 	mtx_unlock(&sc->hs_lock);
-	scan_for_luns(sc);
-	for (i = 0; (hs_softc[i] != NULL) && (i < HS_MAX_ADAPTERS); i++);
-	KASSERT(i < HS_MAX_ADAPTERS, ("storvsc_attach: hs_softc full\n"));
-	hs_softc[i] = sc;
 
 	root_mount_rel(root_mount_token);
 	return (0);
@@ -1147,7 +1062,7 @@ storvsc_action(struct cam_sim *sim, unio
 		cpi->hba_eng_cnt = 0;
 		cpi->max_target = STORVSC_MAX_TARGETS;
 		cpi->max_lun = sc->hs_drv_props->drv_max_luns_per_target;
-		cpi->initiator_id = 0;
+		cpi->initiator_id = cpi->max_lun + 1;
 		cpi->bus_id = cam_sim_bus(sim);
 		cpi->base_transfer_speed = 300000;
 		cpi->transport = XPORT_SAS;



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