From owner-p4-projects@FreeBSD.ORG Tue Feb 2 16:18:19 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0FD3010656B3; Tue, 2 Feb 2010 16:18:19 +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 AFAD710656B0 for ; Tue, 2 Feb 2010 16:18:18 +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 67D6A8FC18 for ; Tue, 2 Feb 2010 16:18:18 +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 o12GIITe076083 for ; Tue, 2 Feb 2010 16:18:18 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o12GIIYW076081 for perforce@freebsd.org; Tue, 2 Feb 2010 16:18:18 GMT (envelope-from mav@freebsd.org) Date: Tue, 2 Feb 2010 16:18:18 GMT Message-Id: <201002021618.o12GIIYW076081@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 174150 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: Tue, 02 Feb 2010 16:18:19 -0000 http://p4web.freebsd.org/chv.cgi?CH=174150 Change 174150 by mav@mav_mavtest on 2010/02/02 16:17:35 Change the way in which fake async events generated. Do not use taskqueue for lock decoupling, as it causes unwanted races. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#148 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#148 (text+ko) ==== @@ -2392,10 +2392,8 @@ { struct cam_path path; struct ccb_getdev cgd; - struct async_node *cur_entry; + struct ccb_setasync *csa = (struct ccb_setasync *)arg; - cur_entry = (struct async_node *)arg; - /* * Don't report unconfigured devices (Wildcard devs, * devices only for target mode, device instances @@ -2413,7 +2411,7 @@ xpt_setup_ccb(&cgd.ccb_h, &path, CAM_PRIORITY_NORMAL); cgd.ccb_h.func_code = XPT_GDEV_TYPE; xpt_action((union ccb *)&cgd); - cur_entry->callback(cur_entry->callback_arg, + csa->callback(csa->callback_arg, AC_FOUND_DEVICE, &path, &cgd); xpt_release_path(&path); @@ -2426,9 +2424,7 @@ { struct cam_path path; struct ccb_pathinq cpi; - struct async_node *cur_entry; - - cur_entry = (struct async_node *)arg; + struct ccb_setasync *csa = (struct ccb_setasync *)arg; xpt_compile_path(&path, /*periph*/NULL, bus->sim->path_id, @@ -2437,7 +2433,7 @@ xpt_setup_ccb(&cpi.ccb_h, &path, CAM_PRIORITY_NORMAL); cpi.ccb_h.func_code = XPT_PATH_INQ; xpt_action((union ccb *)&cpi); - cur_entry->callback(cur_entry->callback_arg, + csa->callback(csa->callback_arg, AC_PATH_REGISTERED, &path, &cpi); xpt_release_path(&path); @@ -2445,35 +2441,6 @@ return(1); } -static void -xpt_action_sasync_cb(void *context, int pending) -{ - struct async_node *cur_entry; - struct xpt_task *task; - uint32_t added; - - task = (struct xpt_task *)context; - cur_entry = (struct async_node *)task->data1; - added = task->data2; - - if ((added & AC_FOUND_DEVICE) != 0) { - /* - * Get this peripheral up to date with all - * the currently existing devices. - */ - xpt_for_all_devices(xptsetasyncfunc, cur_entry); - } - if ((added & AC_PATH_REGISTERED) != 0) { - /* - * Get this peripheral up to date with all - * the currently existing busses. - */ - xpt_for_all_busses(xptsetasyncbusfunc, cur_entry); - } - - free(task, M_CAMXPT); -} - void xpt_action(union ccb *start_ccb) { @@ -2890,6 +2857,7 @@ } else { cur_entry->event_enable = csa->event_enable; } + csa->event_enable = added; } else { cur_entry = malloc(sizeof(*cur_entry), M_CAMXPT, M_NOWAIT); @@ -2903,27 +2871,6 @@ SLIST_INSERT_HEAD(async_head, cur_entry, links); xpt_acquire_device(csa->ccb_h.path->device); } - - /* - * Need to decouple this operation via a taqskqueue so that - * the locking doesn't become a mess. - */ - if ((added & (AC_FOUND_DEVICE | AC_PATH_REGISTERED)) != 0) { - struct xpt_task *task; - - task = malloc(sizeof(struct xpt_task), M_CAMXPT, - M_NOWAIT); - if (task == NULL) { - csa->ccb_h.status = CAM_RESRC_UNAVAIL; - break; - } - - TASK_INIT(&task->task, 0, xpt_action_sasync_cb, task); - task->data1 = cur_entry; - task->data2 = added; - taskqueue_enqueue(taskqueue_thread, &task->task); - } - start_ccb->ccb_h.status = CAM_REQ_CMP; break; } @@ -4823,6 +4770,23 @@ if (xptpath) { xpt_free_path(path); mtx_unlock(&xsoftc.xpt_lock); + + if ((status == CAM_REQ_CMP) && + (csa.event_enable & AC_FOUND_DEVICE)) { + /* + * Get this peripheral up to date with all + * the currently existing devices. + */ + xpt_for_all_devices(xptsetasyncfunc, &csa); + } + if ((status == CAM_REQ_CMP) && + (csa.event_enable & AC_PATH_REGISTERED)) { + /* + * Get this peripheral up to date with all + * the currently existing busses. + */ + xpt_for_all_busses(xptsetasyncbusfunc, &csa); + } } return (status); }