From owner-p4-projects@FreeBSD.ORG Sun Jan 17 10:03:35 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7F3081065676; Sun, 17 Jan 2010 10:03:35 +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 43CDA106566B for ; Sun, 17 Jan 2010 10:03:35 +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 31DAE8FC16 for ; Sun, 17 Jan 2010 10:03:35 +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 o0HA3Zq9025930 for ; Sun, 17 Jan 2010 10:03:35 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o0HA3ZcC025928 for perforce@freebsd.org; Sun, 17 Jan 2010 10:03:35 GMT (envelope-from mav@freebsd.org) Date: Sun, 17 Jan 2010 10:03:35 GMT Message-Id: <201001171003.o0HA3ZcC025928@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 173254 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: Sun, 17 Jan 2010 10:03:35 -0000 http://p4web.freebsd.org/chv.cgi?CH=173254 Change 173254 by mav@mav_mavtest on 2010/01/17 10:02:55 Delay boot while PMP scan completes. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#27 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#137 edit .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#20 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#27 (text+ko) ==== @@ -303,9 +303,10 @@ if (code == AC_SCSI_AEN && softc->state != PMP_STATE_NORMAL && softc->state != PMP_STATE_SCAN) break; - if (softc->state != PMP_STATE_SCAN) + if (softc->state != PMP_STATE_SCAN) { + xpt_hold_boot(); pmpfreeze(periph, softc->found); - else + } else pmpfreeze(periph, softc->found & ~(1 << softc->pm_step)); if (code == AC_SENT_BDR || code == AC_BUS_RESET) softc->found = 0; /* We have to reset everything. */ @@ -410,6 +411,7 @@ * the end of probe. */ (void)cam_periph_acquire(periph); + xpt_hold_boot(); xpt_schedule(periph, CAM_PRIORITY_DEV); return(CAM_REQ_CMP); @@ -759,7 +761,7 @@ done_ccb->ccb_h.func_code = XPT_SCAN_LUN; done_ccb->ccb_h.cbfcnp = pmpdone; done_ccb->crcn.flags = done_ccb->crcn.flags; - xpt_action(done_ccb); + xpt_rescan_direct(done_ccb, 1); pmprelease(periph, 1 << softc->pm_step); return; default: @@ -769,6 +771,7 @@ xpt_release_ccb(done_ccb); done1: softc->state = PMP_STATE_NORMAL; + xpt_release_boot(); pmprelease(periph, -1); cam_periph_release_locked(periph); } ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#137 (text+ko) ==== @@ -812,21 +812,6 @@ 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); @@ -834,6 +819,7 @@ done_ccb->ccb_h.cbfcnp = done_ccb->ccb_h.ppriv_ptr1; (*done_ccb->ccb_h.cbfcnp)(periph, done_ccb); } + xpt_release_boot(); } /* thread to handle bus rescans */ @@ -854,13 +840,6 @@ 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.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); xpt_action(ccb); CAM_SIM_UNLOCK(sim); @@ -872,13 +851,32 @@ void xpt_rescan(union ccb *ccb) { + + xpt_rescan_direct(ccb, 0); +} + +void +xpt_rescan_direct(union ccb *ccb, int direct) +{ struct ccb_hdr *hdr; - /* - * Don't make duplicate entries for the same paths. - */ + /* Prepare request */ + 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.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); + /* Execute directly if requested. */ + if (direct) { + xpt_hold_boot(); + xpt_action(ccb); + return; + } + /* Don't make duplicate entries for the same paths. */ xpt_lock_buses(); - if (ccb->ccb_h.cbfcnp == NULL) { + if (ccb->ccb_h.ppriv_ptr1 == 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); @@ -4706,7 +4704,27 @@ #endif /* CAMDEBUG */ periphdriver_init(1); + xpt_hold_boot(); + xpt_release_boot(); + /* 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"); + } +} + +void +xpt_hold_boot(void) +{ xpt_lock_buses(); + xsoftc.buses_to_config++; + xpt_unlock_buses(); +} + +void +xpt_release_boot(void) +{ + xpt_lock_buses(); + xsoftc.buses_to_config--; if (xsoftc.buses_to_config == 0 && xsoftc.buses_config_done == 0) { struct xpt_task *task; @@ -4718,13 +4736,8 @@ TASK_INIT(&task->task, 0, xpt_finishconfig_task, task); taskqueue_enqueue(taskqueue_thread, &task->task); } - } else { + } 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"); - } } /* ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#20 (text+ko) ==== @@ -114,7 +114,10 @@ struct cam_periph *xpt_path_periph(struct cam_path *path); void xpt_async(u_int32_t async_code, struct cam_path *path, void *async_arg); +void xpt_rescan_direct(union ccb *ccb, int direct); void xpt_rescan(union ccb *ccb); +void xpt_hold_boot(void); +void xpt_release_boot(void); void xpt_lock_buses(void); void xpt_unlock_buses(void); cam_status xpt_register_async(int event, ac_callback_t *cbfunc,