Date: Fri, 17 Aug 2007 15:01:58 GMT From: Maxim Zhuravlev <thioretic@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 125269 for review Message-ID: <200708171501.l7HF1wa7054139@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708171501.l7HF1wa7054139>