From owner-p4-projects@FreeBSD.ORG Fri Aug 17 15:01:59 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CCB7F16A46D; Fri, 17 Aug 2007 15:01: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 57C9E16A468 for ; Fri, 17 Aug 2007 15:01:58 +0000 (UTC) (envelope-from thioretic@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 48E5C13C48D for ; Fri, 17 Aug 2007 15:01:58 +0000 (UTC) (envelope-from thioretic@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l7HF1wqY054142 for ; Fri, 17 Aug 2007 15:01:58 GMT (envelope-from thioretic@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l7HF1wa7054139 for perforce@freebsd.org; Fri, 17 Aug 2007 15:01:58 GMT (envelope-from thioretic@FreeBSD.org) Date: Fri, 17 Aug 2007 15:01:58 GMT Message-Id: <200708171501.l7HF1wa7054139@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to thioretic@FreeBSD.org using -f From: Maxim Zhuravlev To: Perforce Change Reviews Cc: Subject: PERFORCE change 125269 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2007 15:01:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=125269 Change 125269 by thioretic@thioretic on 2007/08/17 15:01:26 Some io/driver interaction Affected files ... .. //depot/projects/soc2007/thioretic_gidl2/kern/ior_if.m#1 add .. //depot/projects/soc2007/thioretic_gidl2/kern/subr_bus.c#5 edit .. //depot/projects/soc2007/thioretic_gidl2/kern/subr_busio.c#5 edit Differences ... ==== //depot/projects/soc2007/thioretic_gidl2/kern/subr_bus.c#5 (text+ko) ==== @@ -1026,6 +1026,28 @@ if (returns_val) \ return (val); +#define FOR_ALL_DRIVERS_REV (exclude_raw, returns_val, return_on_non_zero, func, memb, ...) \ + int level; \ + driverinfolink_t dil; \ + int val = 0; \ + for (level = DRL_LOWEST; level <= DRL_TOPMOST; level++){ \ + if (TAILQ_EMPTY(&dev->drivers[level])) \ + continue; \ + TAILQ_FOREACH (dil, &dev->drivers[level], link){ \ + if (exclude_raw && dil->pdriver->state == DS_RAW) \ + continue; \ + if (returns_val){ \ + val = func (dil->pdriver->##memb , __VA_ARGS__); \ + if (val && return_on_non_zero) \ + return (val); \ + } \ + else \ + func (dil->pdriver->##memb , __VA_ARGS__); \ + } \ + } \ + if (returns_val) \ + return (val); + /** * device control multiplexing entries */ @@ -1192,6 +1214,18 @@ dname, dunit); } +/** + * ior control multiplexing entries + */ + +FUNC (void, PREFIX, do, device_t dev, ior_t r){ + FOR_ALL_DRIVERS (FALSE, FALSE, FALSE, IOR_DO, functional_ops, r); +} + +FUNC (void, PREFIX, done, device_t dev, ior_t r){ + FOR_ALL_DRIVERS_REV (FALSE, FALSE, FALSE, IOR_DO, functional_ops, r); +} + #define DRIVERMETHOD (name, if_prefix, driver_prefix) \ DEVMETHOD (if_prefix##_##name, driver_prefix##_##name) @@ -1226,7 +1260,10 @@ DRIVERMETHOD (child_pnpinfo_str, bus, PREFIX), DRIVERMETHOD (child_location_str, bus, PREFIX), DRIVERMETHOD (config_intr, bus, PREFIX), - DRIVERMETHOD (hinted_child, bus, PREFIX) + DRIVERMETHOD (hinted_child, bus, PREFIX), + + DRIVERMETHOD (do, ior, PREFIX), + DRIVERMETHOD (done, ior, PREFIX) }; static driver_t drv_compat_ctrl_driver = { /*TODO*/ ==== //depot/projects/soc2007/thioretic_gidl2/kern/subr_busio.c#5 (text+ko) ==== @@ -56,6 +56,7 @@ /*ior_link_list_t*/ int children; device_t origin; devicelink_list_t path; + devicelink_t curdev; int queue_id; struct mtx guard_spin_mtx; @@ -98,7 +99,9 @@ work_kthreads_set_number, "I", "Number of kernel threads" "to process queued io requests"); -static void bus_io_process_next_irp (work_kthread_t tp); +static void bus_io_process_next_ior (work_kthread_t tp); +static int ior_do (ior_t r); +static int ior_done (ior_t r); static void work_kthread_proc (void *arg){ @@ -216,7 +219,7 @@ if (r = q.todo) break; } - if (qid = IOR_QUEUES_NUM) + if (qid == IOR_QUEUES_NUM) return (1); ior_lock (r); @@ -234,7 +237,10 @@ r->state = IORS_OWNED; ior_unlock (r); - //deliver ior to first in path driver + if (ior_get_flags(r) &= IORS_DONE) + ior_do (r); + else + ior_done (r); return (0); } @@ -260,7 +266,7 @@ } mtx_init (&new_ior->guard_spin_mtx, - "ior_mtx", NULL, MTX_SPIN); + "ior_mtx", NULL, MTX_SPIN|MTX_RECURSE); if (error = ior_set_path (new_ior, origin, path)){ free (new_ior); free (ils); @@ -388,7 +394,7 @@ mtx_unlock_spin (&q.guard_spin_mtx); - r->queue_id = queue_id; + r->queue_id = queue_id + 1; r->state = IORS_ENQUEUED; ior_unlock (r); @@ -408,7 +414,7 @@ ior_lock (r); - if (r->state == IORS_NONE || r->children){ + if (r->state != IOR_ENQUEUED || r->children){ ior_unlock (r); return (1); } @@ -442,3 +448,39 @@ ior_unlock (ior_t r){ mtx_unlock_spin (&r->guard_spin_mtx); } + +static int +ior_do (ior_t r){ + devicelink_t nextdev; + + ior_lock (r); + + nextdev = TAILQ_NEXT(r->curdev, link); + if (!nextdev){ + return (1); + } + + ior_unlock (r); + + IOR_DO (nextdev->device_ptr, r); + + ior_enqueue_adv (r, r->queue_id); +} + +static int +ior_done (ior_t r){ + devicelink_t nextdev; + + ior_lock (r); + + nextdev = TAILQ_PREV(r->curdev, devicelink_list, link); + if (!nextdev){ + return (1); + } + + ior_unlock (r); + + IOR_DONE (nextdev->device_ptr, r); + + ior_enqueue_adv (r, r->queue_id); +}