From owner-svn-src-all@FreeBSD.ORG Wed Mar 12 07:27:06 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 80C0DDD; Wed, 12 Mar 2014 07:27:06 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6C7691BC; Wed, 12 Mar 2014 07:27:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2C7R6fF043116; Wed, 12 Mar 2014 07:27:06 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2C7R6FV043115; Wed, 12 Mar 2014 07:27:06 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201403120727.s2C7R6FV043115@svn.freebsd.org> From: Alexander Motin Date: Wed, 12 Mar 2014 07:27:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r263065 - stable/10/sys/dev/hyperv/storvsc X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Mar 2014 07:27:06 -0000 Author: mav Date: Wed Mar 12 07:27:05 2014 New Revision: 263065 URL: http://svnweb.freebsd.org/changeset/base/263065 Log: MFC r262789, r262847: 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 Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Mar 12 07:18:39 2014 (r263064) +++ stable/10/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Mar 12 07:27:05 2014 (r263065) @@ -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_target; cpi->bus_id = cam_sim_bus(sim); cpi->base_transfer_speed = 300000; cpi->transport = XPORT_SAS;