From owner-p4-projects@FreeBSD.ORG Sat Jan 16 13:33:58 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9C9CF106566C; Sat, 16 Jan 2010 13:33:58 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 608531065679 for ; Sat, 16 Jan 2010 13:33:58 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4D2188FC0C for ; Sat, 16 Jan 2010 13:33:58 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o0GDXwYh057419 for ; Sat, 16 Jan 2010 13:33:58 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o0GDXwOp057417 for perforce@freebsd.org; Sat, 16 Jan 2010 13:33:58 GMT (envelope-from mav@freebsd.org) Date: Sat, 16 Jan 2010 13:33:58 GMT Message-Id: <201001161333.o0GDXwOp057417@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 173220 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Jan 2010 13:33:58 -0000 http://p4web.freebsd.org/chv.cgi?CH=173220 Change 173220 by mav@mav_mavtest on 2010/01/16 13:33:47 Unify bus scanning process. Instead of centralized call of reset and rescan for every bus registered at the moment on boot and every SIM later attach routine, schedule scanning every time bus registered and execute it as soon as system can do this. Move reset call from common to transport-specic code. Now each transport may decide whether it needs bus reset before scan. This change gives now several benefits: - simplifies SIM attach routines, - allows to avoid duplicate scan in some cases, - gives all SIM's, registering their buses after boot scan started, enough time to complete it, before boot will continue. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#69 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#136 edit .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_xpt.c#27 edit .. //depot/projects/scottl-camlock/src/sys/dev/ata/atapi-cam.c#21 edit .. //depot/projects/scottl-camlock/src/sys/dev/hptiop/hptiop.c#5 edit .. //depot/projects/scottl-camlock/src/sys/dev/ppbus/vpo.c#12 edit .. //depot/projects/scottl-camlock/src/sys/dev/trm/trm.c#14 edit .. //depot/projects/scottl-camlock/src/sys/dev/usb/storage/umass.c#17 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#69 (text+ko) ==== @@ -1019,7 +1019,7 @@ { struct cam_path *path; ata_scan_bus_info *scan_info; - union ccb *work_ccb; + union ccb *work_ccb, *reset_ccb; cam_status status; CAM_DEBUG(request_ccb->ccb_h.path, CAM_DEBUG_TRACE, @@ -1044,6 +1044,26 @@ return; } + /* We may need to reset bus first, if we haven't done it yet. */ + if ((work_ccb->cpi.hba_inquiry & + (PI_WIDE_32|PI_WIDE_16|PI_SDTR_ABLE)) && + !(work_ccb->cpi.hba_misc & PIM_NOBUSRESET) && + !timevalisset(&request_ccb->ccb_h.path->bus->last_reset)) { + reset_ccb = xpt_alloc_ccb_nowait(); + xpt_setup_ccb(&reset_ccb->ccb_h, request_ccb->ccb_h.path, + CAM_PRIORITY_NONE); + reset_ccb->ccb_h.func_code = XPT_RESET_BUS; + xpt_action(reset_ccb); + if (reset_ccb->ccb_h.status != CAM_REQ_CMP) { + request_ccb->ccb_h.status = reset_ccb->ccb_h.status; + xpt_free_ccb(reset_ccb); + xpt_free_ccb(work_ccb); + xpt_done(request_ccb); + return; + } + xpt_free_ccb(reset_ccb); + } + /* Save some state for use while we probe for devices */ scan_info = (ata_scan_bus_info *) malloc(sizeof(ata_scan_bus_info), M_CAMXPT, M_NOWAIT); ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#136 (text+ko) ==== @@ -102,6 +102,8 @@ /* queue for handling async rescan requests. */ TAILQ_HEAD(, ccb_hdr) ccb_scanq; + int buses_to_config; + int buses_config_done; /* Registered busses */ TAILQ_HEAD(,cam_eb) xpt_busses; @@ -225,11 +227,8 @@ xpt_find_target(struct cam_eb *bus, target_id_t target_id); static struct cam_ed* xpt_find_device(struct cam_et *target, lun_id_t lun_id); -static xpt_busfunc_t xptconfigbuscountfunc; -static xpt_busfunc_t xptconfigfunc; static void xpt_config(void *arg); static xpt_devicefunc_t xptpassannouncefunc; -static void xpt_finishconfig(struct cam_periph *periph, union ccb *ccb); static void xptaction(struct cam_sim *sim, union ccb *work_ccb); static void xptpoll(struct cam_sim *sim); static void camisr(void *); @@ -271,6 +270,7 @@ static xpt_targetfunc_t xptdeftargetfunc; static xpt_devicefunc_t xptdefdevicefunc; static xpt_periphfunc_t xptdefperiphfunc; +static void xpt_finishconfig_task(void *context, int pending); static int xpt_for_all_busses(xpt_busfunc_t *tr_func, void *arg); static int xpt_for_all_devices(xpt_devicefunc_t *tr_func, void *arg); @@ -808,45 +808,63 @@ return 0; } +static void +xpt_rescan_done(struct cam_periph *periph, union ccb *done_ccb) +{ + + xpt_lock_buses(); + xsoftc.buses_to_config--; + if (xsoftc.buses_to_config == 0 && xsoftc.buses_config_done == 0) { + struct xpt_task *task; + + xsoftc.buses_config_done = 1; + xpt_unlock_buses(); + /* Call manually because we don't have any busses */ + task = malloc(sizeof(struct xpt_task), M_CAMXPT, M_NOWAIT); + if (task != NULL) { + TASK_INIT(&task->task, 0, xpt_finishconfig_task, task); + taskqueue_enqueue(taskqueue_thread, &task->task); + } + } else + xpt_unlock_buses(); + if (done_ccb->ccb_h.ppriv_ptr1 == NULL) { + xpt_free_path(done_ccb->ccb_h.path); + xpt_free_ccb(done_ccb); + } else { + done_ccb->ccb_h.cbfcnp = done_ccb->ccb_h.ppriv_ptr1; + (*done_ccb->ccb_h.cbfcnp)(periph, done_ccb); + } +} + /* thread to handle bus rescans */ static void xpt_scanner_thread(void *dummy) { - cam_isrq_t queue; union ccb *ccb; struct cam_sim *sim; + xpt_lock_buses(); for (;;) { - /* - * Wait for a rescan request to come in. When it does, splice - * it onto a queue from local storage so that the xpt lock - * doesn't need to be held while the requests are being - * processed. - */ - xpt_lock_buses(); if (TAILQ_EMPTY(&xsoftc.ccb_scanq)) msleep(&xsoftc.ccb_scanq, &xsoftc.xpt_topo_lock, PRIBIO, "ccb_scanq", 0); - TAILQ_INIT(&queue); - TAILQ_CONCAT(&queue, &xsoftc.ccb_scanq, sim_links.tqe); - xpt_unlock_buses(); - - while ((ccb = (union ccb *)TAILQ_FIRST(&queue)) != NULL) { - TAILQ_REMOVE(&queue, &ccb->ccb_h, sim_links.tqe); + if ((ccb = (union ccb *)TAILQ_FIRST(&xsoftc.ccb_scanq)) != NULL) { + TAILQ_REMOVE(&xsoftc.ccb_scanq, &ccb->ccb_h, sim_links.tqe); + xpt_unlock_buses(); sim = ccb->ccb_h.path->bus->sim; CAM_SIM_LOCK(sim); - if( ccb->ccb_h.path->target->target_id == CAM_TARGET_WILDCARD ) ccb->ccb_h.func_code = XPT_SCAN_BUS; else ccb->ccb_h.func_code = XPT_SCAN_LUN; - ccb->ccb_h.cbfcnp = xptdone; + ccb->ccb_h.ppriv_ptr1 = ccb->ccb_h.cbfcnp; + ccb->ccb_h.cbfcnp = xpt_rescan_done; xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, CAM_PRIORITY_XPT); - cam_periph_runccb(ccb, NULL, 0, 0, NULL); - xpt_free_path(ccb->ccb_h.path); - xpt_free_ccb(ccb); + xpt_action(ccb); CAM_SIM_UNLOCK(sim); + + xpt_lock_buses(); } } } @@ -860,17 +878,20 @@ * Don't make duplicate entries for the same paths. */ xpt_lock_buses(); - TAILQ_FOREACH(hdr, &xsoftc.ccb_scanq, sim_links.tqe) { - if (xpt_path_comp(hdr->path, ccb->ccb_h.path) == 0) { - wakeup(&xsoftc.ccb_scanq); - xpt_unlock_buses(); - xpt_print(ccb->ccb_h.path, "rescan already queued\n"); - xpt_free_path(ccb->ccb_h.path); - xpt_free_ccb(ccb); - return; + if (ccb->ccb_h.cbfcnp == NULL) { + TAILQ_FOREACH(hdr, &xsoftc.ccb_scanq, sim_links.tqe) { + if (xpt_path_comp(hdr->path, ccb->ccb_h.path) == 0) { + wakeup(&xsoftc.ccb_scanq); + xpt_unlock_buses(); + xpt_print(ccb->ccb_h.path, "rescan already queued\n"); + xpt_free_path(ccb->ccb_h.path); + xpt_free_ccb(ccb); + return; + } } } TAILQ_INSERT_TAIL(&xsoftc.ccb_scanq, &ccb->ccb_h, sim_links.tqe); + xsoftc.buses_to_config++; wakeup(&xsoftc.ccb_scanq); xpt_unlock_buses(); } @@ -917,6 +938,7 @@ mtx_lock(&xsoftc.xpt_lock); if ((status = xpt_bus_register(xpt_sim, NULL, 0)) != CAM_SUCCESS) { + mtx_unlock(&xsoftc.xpt_lock); printf("xpt_init: xpt_bus_register failed with status %#x," " failing attach\n", status); return (EINVAL); @@ -930,6 +952,7 @@ if ((status = xpt_create_path(&path, NULL, CAM_XPT_PATH_ID, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD)) != CAM_REQ_CMP) { + mtx_unlock(&xsoftc.xpt_lock); printf("xpt_init: xpt_create_path failed with status %#x," " failing attach\n", status); return (EINVAL); @@ -3814,7 +3837,7 @@ struct cam_eb *new_bus; struct cam_eb *old_bus; struct ccb_pathinq cpi; - struct cam_path path; + struct cam_path *path; cam_status status; mtx_assert(sim->mtx, MA_OWNED); @@ -3826,6 +3849,11 @@ /* Couldn't satisfy request */ return (CAM_RESRC_UNAVAIL); } + path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_NOWAIT); + if (path == NULL) { + free(new_bus, M_CAMXPT); + return (CAM_RESRC_UNAVAIL); + } if (strcmp(sim->sim_name, "xpt") != 0) { sim->path_id = @@ -3860,13 +3888,12 @@ */ new_bus->xport = &xport_default; - bzero(&path, sizeof(path)); - status = xpt_compile_path(&path, /*periph*/NULL, sim->path_id, + status = xpt_compile_path(path, /*periph*/NULL, sim->path_id, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); if (status != CAM_REQ_CMP) printf("xpt_compile_path returned %d\n", status); - xpt_setup_ccb(&cpi.ccb_h, &path, CAM_PRIORITY_NORMAL); + xpt_setup_ccb(&cpi.ccb_h, path, CAM_PRIORITY_NORMAL); cpi.ccb_h.func_code = XPT_PATH_INQ; xpt_action((union ccb *)&cpi); @@ -3892,9 +3919,17 @@ /* Notify interested parties */ if (sim->path_id != CAM_XPT_PATH_ID) { - xpt_async(AC_PATH_REGISTERED, &path, &cpi); - } - xpt_release_path(&path); + union ccb *scan_ccb; + + xpt_async(AC_PATH_REGISTERED, path, &cpi); + /* Initiate bus rescan. */ + scan_ccb = xpt_alloc_ccb_nowait(); + scan_ccb->ccb_h.path = path; + scan_ccb->ccb_h.func_code = XPT_SCAN_BUS; + scan_ccb->crcn.flags = 0; + xpt_rescan(scan_ccb); + } else + xpt_free_path(path); return (CAM_SUCCESS); } @@ -4634,98 +4669,6 @@ xpt_action((union ccb *)&crs); } -static int busses_to_config; -static int busses_to_reset; - -static int -xptconfigbuscountfunc(struct cam_eb *bus, void *arg) -{ - - mtx_assert(bus->sim->mtx, MA_OWNED); - - if (bus->path_id != CAM_XPT_PATH_ID) { - struct cam_path path; - struct ccb_pathinq cpi; - int can_negotiate; - - busses_to_config++; - xpt_compile_path(&path, NULL, bus->path_id, - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); - xpt_setup_ccb(&cpi.ccb_h, &path, CAM_PRIORITY_NORMAL); - cpi.ccb_h.func_code = XPT_PATH_INQ; - xpt_action((union ccb *)&cpi); - can_negotiate = cpi.hba_inquiry; - can_negotiate &= (PI_WIDE_32|PI_WIDE_16|PI_SDTR_ABLE); - if ((cpi.hba_misc & PIM_NOBUSRESET) == 0 - && can_negotiate) - busses_to_reset++; - xpt_release_path(&path); - } - - return(1); -} - -static int -xptconfigfunc(struct cam_eb *bus, void *arg) -{ - struct cam_path *path; - union ccb *work_ccb; - - mtx_assert(bus->sim->mtx, MA_OWNED); - - if (bus->path_id != CAM_XPT_PATH_ID) { - cam_status status; - int can_negotiate; - - work_ccb = xpt_alloc_ccb_nowait(); - if (work_ccb == NULL) { - busses_to_config--; - xpt_finishconfig(xpt_periph, NULL); - return(0); - } - if ((status = xpt_create_path(&path, xpt_periph, bus->path_id, - CAM_TARGET_WILDCARD, - CAM_LUN_WILDCARD)) !=CAM_REQ_CMP){ - printf("xptconfigfunc: xpt_create_path failed with " - "status %#x for scbus%d\n", status, bus->path_id); - printf("xptconfigfunc: halting bus configuration\n"); - xpt_free_ccb(work_ccb); - busses_to_config--; - xpt_finishconfig(xpt_periph, NULL); - return(0); - } - xpt_setup_ccb(&work_ccb->ccb_h, path, CAM_PRIORITY_NORMAL); - work_ccb->ccb_h.func_code = XPT_PATH_INQ; - xpt_action(work_ccb); - if (work_ccb->ccb_h.status != CAM_REQ_CMP) { - printf("xptconfigfunc: CPI failed on scbus%d " - "with status %d\n", bus->path_id, - work_ccb->ccb_h.status); - xpt_finishconfig(xpt_periph, work_ccb); - return(1); - } - - can_negotiate = work_ccb->cpi.hba_inquiry; - can_negotiate &= (PI_WIDE_32|PI_WIDE_16|PI_SDTR_ABLE); - if ((work_ccb->cpi.hba_misc & PIM_NOBUSRESET) == 0 - && (can_negotiate != 0)) { - xpt_setup_ccb(&work_ccb->ccb_h, path, CAM_PRIORITY_NORMAL); - work_ccb->ccb_h.func_code = XPT_RESET_BUS; - work_ccb->ccb_h.cbfcnp = NULL; - CAM_DEBUG(path, CAM_DEBUG_SUBTRACE, - ("Resetting Bus\n")); - xpt_action(work_ccb); - xpt_finishconfig(xpt_periph, work_ccb); - } else { - /* Act as though we performed a successful BUS RESET */ - work_ccb->ccb_h.func_code = XPT_RESET_BUS; - xpt_finishconfig(xpt_periph, work_ccb); - } - } - - return(1); -} - static void xpt_config(void *arg) { @@ -4762,25 +4705,25 @@ #endif /* CAM_DEBUG_BUS */ #endif /* CAMDEBUG */ - /* Fire up rescan thread. */ - if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) { - printf("xpt_init: failed to create rescan thread\n"); - } periphdriver_init(1); - /* - * Scan all installed busses. - */ - xpt_for_all_busses(xptconfigbuscountfunc, NULL); + xpt_lock_buses(); + if (xsoftc.buses_to_config == 0 && xsoftc.buses_config_done == 0) { + struct xpt_task *task; - if (busses_to_config == 0) { + xsoftc.buses_config_done = 1; + xpt_unlock_buses(); /* Call manually because we don't have any busses */ - xpt_finishconfig(xpt_periph, NULL); - } else { - if (busses_to_reset > 0 && scsi_delay >= 2000) { - printf("Waiting %d seconds for SCSI " - "devices to settle\n", scsi_delay/1000); + task = malloc(sizeof(struct xpt_task), M_CAMXPT, M_NOWAIT); + if (task != NULL) { + TASK_INIT(&task->task, 0, xpt_finishconfig_task, task); + taskqueue_enqueue(taskqueue_thread, &task->task); } - xpt_for_all_busses(xptconfigfunc, NULL); + } else { + xpt_unlock_buses(); + } + /* Fire up rescan thread. */ + if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) { + printf("xpt_init: failed to create rescan thread\n"); } } @@ -4810,62 +4753,22 @@ xpt_finishconfig_task(void *context, int pending) { - if (busses_to_config == 0) { - periphdriver_init(2); - /* - * Check for devices with no "standard" peripheral driver - * attached. For any devices like that, announce the - * passthrough driver so the user will see something. - */ - xpt_for_all_devices(xptpassannouncefunc, NULL); + periphdriver_init(2); + /* + * Check for devices with no "standard" peripheral driver + * attached. For any devices like that, announce the + * passthrough driver so the user will see something. + */ + xpt_for_all_devices(xptpassannouncefunc, NULL); - /* Release our hook so that the boot can continue. */ - config_intrhook_disestablish(xsoftc.xpt_config_hook); - free(xsoftc.xpt_config_hook, M_CAMXPT); - xsoftc.xpt_config_hook = NULL; - } + /* Release our hook so that the boot can continue. */ + config_intrhook_disestablish(xsoftc.xpt_config_hook); + free(xsoftc.xpt_config_hook, M_CAMXPT); + xsoftc.xpt_config_hook = NULL; free(context, M_CAMXPT); } -static void -xpt_finishconfig(struct cam_periph *periph, union ccb *done_ccb) -{ - struct xpt_task *task; - - if (done_ccb != NULL) { - CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, - ("xpt_finishconfig\n")); - switch(done_ccb->ccb_h.func_code) { - case XPT_RESET_BUS: - if (done_ccb->ccb_h.status == CAM_REQ_CMP) { - done_ccb->ccb_h.func_code = XPT_SCAN_BUS; - done_ccb->ccb_h.cbfcnp = xpt_finishconfig; - done_ccb->crcn.flags = 0; - xpt_action(done_ccb); - return; - } - /* FALLTHROUGH */ - case XPT_SCAN_BUS: - default: - xpt_free_path(done_ccb->ccb_h.path); - busses_to_config--; - break; - } - } - - if (busses_to_config == 0) { - task = malloc(sizeof(struct xpt_task), M_CAMXPT, M_NOWAIT); - if (task != NULL) { - TASK_INIT(&task->task, 0, xpt_finishconfig_task, task); - taskqueue_enqueue(taskqueue_thread, &task->task); - } - } - - if (done_ccb != NULL) - xpt_free_ccb(done_ccb); -} - cam_status xpt_register_async(int event, ac_callback_t *cbfunc, void *cbarg, struct cam_path *path) ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_xpt.c#27 (text+ko) ==== @@ -1498,7 +1498,7 @@ case XPT_SCAN_BUS: { scsi_scan_bus_info *scan_info; - union ccb *work_ccb; + union ccb *work_ccb, *reset_ccb; struct cam_path *path; u_int i; u_int max_target; @@ -1533,6 +1533,26 @@ return; } + /* We may need to reset bus first, if we haven't done it yet. */ + if ((work_ccb->cpi.hba_inquiry & + (PI_WIDE_32|PI_WIDE_16|PI_SDTR_ABLE)) && + !(work_ccb->cpi.hba_misc & PIM_NOBUSRESET) && + !timevalisset(&request_ccb->ccb_h.path->bus->last_reset)) { + reset_ccb = xpt_alloc_ccb_nowait(); + xpt_setup_ccb(&reset_ccb->ccb_h, request_ccb->ccb_h.path, + CAM_PRIORITY_NONE); + reset_ccb->ccb_h.func_code = XPT_RESET_BUS; + xpt_action(reset_ccb); + if (reset_ccb->ccb_h.status != CAM_REQ_CMP) { + request_ccb->ccb_h.status = reset_ccb->ccb_h.status; + xpt_free_ccb(reset_ccb); + xpt_free_ccb(work_ccb); + xpt_done(request_ccb); + return; + } + xpt_free_ccb(reset_ccb); + } + /* Save some state for use while we probe for devices */ scan_info = (scsi_scan_bus_info *) malloc(sizeof(scsi_scan_bus_info), M_CAMXPT, M_NOWAIT); ==== //depot/projects/scottl-camlock/src/sys/dev/ata/atapi-cam.c#21 (text+ko) ==== @@ -315,6 +315,7 @@ switch (reason) { case BOOT_ATTACH: + case ATTACH: break; case RESET: xpt_async(AC_BUS_RESET, scp->path, NULL); @@ -322,8 +323,6 @@ if (!dev_changed) break; - /*FALLTHROUGH*/ - case ATTACH: cam_rescan(scp->sim); break; } ==== //depot/projects/scottl-camlock/src/sys/dev/hptiop/hptiop.c#5 (text+ko) ==== @@ -1539,8 +1539,6 @@ hba->ioctl_dev->si_drv1 = hba; #endif - hptiop_rescan_bus(hba); - return 0; ==== //depot/projects/scottl-camlock/src/sys/dev/ppbus/vpo.c#12 (text+ko) ==== @@ -83,9 +83,6 @@ /* cam related functions */ static void vpo_action(struct cam_sim *sim, union ccb *ccb); static void vpo_poll(struct cam_sim *sim); -static void vpo_cam_rescan_callback(struct cam_periph *periph, - union ccb *ccb); -static void vpo_cam_rescan(struct vpo_data *vpo); static void vpo_identify(driver_t *driver, device_t parent) @@ -176,44 +173,10 @@ return (ENXIO); } ppb_unlock(ppbus); - vpo_cam_rescan(vpo); /* have CAM rescan the bus */ return (0); } -static void -vpo_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ - - free(ccb, M_TEMP); -} - -static void -vpo_cam_rescan(struct vpo_data *vpo) -{ - device_t ppbus = device_get_parent(vpo->vpo_dev); - struct cam_path *path; - union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); - - ppb_lock(ppbus); - if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0) - != CAM_REQ_CMP) { - /* A failure is benign as the user can do a manual rescan */ - ppb_unlock(ppbus); - free(ccb, M_TEMP); - return; - } - - xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = vpo_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); - ppb_unlock(ppbus); - - /* The scan is in progress now. */ -} - /* * vpo_intr() */ ==== //depot/projects/scottl-camlock/src/sys/dev/trm/trm.c#14 (text+ko) ==== @@ -747,15 +747,6 @@ xpt_done(pccb); break; /* - * (Re)Scan the SCSI Bus - * Rescan the given bus, or bus/target/lun - */ - case XPT_SCAN_BUS: - TRM_DPRINTF(" XPT_SCAN_BUS \n"); - pccb->ccb_h.status = CAM_REQ_INVALID; - xpt_done(pccb); - break; - /* * Get EDT entries matching the given pattern */ case XPT_DEV_MATCH: ==== //depot/projects/scottl-camlock/src/sys/dev/usb/storage/umass.c#17 (text+ko) ==== @@ -469,8 +469,6 @@ static void umass_t_cbi_data_clear_stall_callback(struct usb_xfer *, uint8_t, uint8_t, usb_error_t); static int umass_cam_attach_sim(struct umass_softc *); -static void umass_cam_rescan_callback(struct cam_periph *, union ccb *); -static void umass_cam_rescan(struct umass_softc *); static void umass_cam_attach(struct umass_softc *); static void umass_cam_detach_sim(struct umass_softc *); static void umass_cam_action(struct cam_sim *, union ccb *); @@ -2145,68 +2143,6 @@ } static void -umass_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) -{ -#if USB_DEBUG - struct umass_softc *sc = NULL; - - if (ccb->ccb_h.status != CAM_REQ_CMP) { - DPRINTF(sc, UDMASS_SCSI, "%s:%d Rescan failed, 0x%04x\n", - periph->periph_name, periph->unit_number, - ccb->ccb_h.status); - } else { - DPRINTF(sc, UDMASS_SCSI, "%s%d: Rescan succeeded\n", - periph->periph_name, periph->unit_number); - } -#endif - - xpt_free_path(ccb->ccb_h.path); - free(ccb, M_USBDEV); -} - -static void -umass_cam_rescan(struct umass_softc *sc) -{ - struct cam_path *path; - union ccb *ccb; - - DPRINTF(sc, UDMASS_SCSI, "scbus%d: scanning for %d:%d:%d\n", - cam_sim_path(sc->sc_sim), - cam_sim_path(sc->sc_sim), - sc->sc_unit, CAM_LUN_WILDCARD); - - ccb = malloc(sizeof(*ccb), M_USBDEV, M_WAITOK | M_ZERO); - - if (ccb == NULL) { - return; - } -#if (__FreeBSD_version >= 700037) - mtx_lock(&sc->sc_mtx); -#endif - - if (xpt_create_path(&path, xpt_periph, cam_sim_path(sc->sc_sim), - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) - != CAM_REQ_CMP) { -#if (__FreeBSD_version >= 700037) - mtx_unlock(&sc->sc_mtx); -#endif - free(ccb, M_USBDEV); - return; - } - xpt_setup_ccb(&ccb->ccb_h, path, 5 /* priority (low) */ ); - ccb->ccb_h.func_code = XPT_SCAN_BUS; - ccb->ccb_h.cbfcnp = &umass_cam_rescan_callback; - ccb->crcn.flags = CAM_FLAG_NONE; - xpt_action(ccb); - -#if (__FreeBSD_version >= 700037) - mtx_unlock(&sc->sc_mtx); -#endif - - /* The scan is in progress now. */ -} - -static void umass_cam_attach(struct umass_softc *sc) { #ifndef USB_DEBUG @@ -2216,19 +2152,6 @@ sc->sc_name, cam_sim_path(sc->sc_sim), sc->sc_unit, CAM_LUN_WILDCARD, cam_sim_path(sc->sc_sim)); - - if (!cold) { - /* - * Notify CAM of the new device after a short delay. Any - * failure is benign, as the user can still do it by hand - * (camcontrol rescan ). Only do this if we are not - * booting, because CAM does a scan after booting has - * completed, when interrupts have been enabled. - */ - - /* scan the new sim */ - umass_cam_rescan(sc); - } } /* umass_cam_detach