From: cl349@firebug.cl.cam.ac.uk Date: Tue, 23 Aug 2005 08:40:50 +0000 (+0000) Subject: Use explicit functions with args instead of work_structs for callbacks. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16871^2~16 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b4d1caa528b2eecc30b0d79c2f20c4a0bbfd28d2;p=xen.git Use explicit functions with args instead of work_structs for callbacks. Signed-off-by: Christian Limpach --- b4d1caa528b2eecc30b0d79c2f20c4a0bbfd28d2 diff --cc linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c index 99c68ae11e,63deb685f3..7a9339d7b8 --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c @@@ -67,16 -65,6 +67,18 @@@ get_free_entry return fh; } +static void do_free_callbacks(void) +{ - struct gnttab_free_callback *callback = gnttab_free_callback_list; ++ struct gnttab_free_callback *callback = gnttab_free_callback_list, *next; + gnttab_free_callback_list = NULL; + while (callback) { - schedule_work(callback->work); - callback = callback->next; ++ next = callback->next; ++ callback->next = NULL; ++ callback->fn(callback->arg); ++ callback = next; + } +} + static inline void put_free_entry( grant_ref_t ref) @@@ -264,15 -244,6 +266,18 @@@ gnttab_release_grant_reference( grant_r *private_head = release; } +void +gnttab_request_free_callback(struct gnttab_free_callback *callback, - struct work_struct *work) ++ void (*fn)(void *), void *arg) +{ - callback->work = work; ++ if (callback->next) ++ return; ++ callback->fn = fn; ++ callback->arg = arg; + callback->next = gnttab_free_callback_list; + gnttab_free_callback_list = callback; +} + /* * ProcFS operations */ diff --cc linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index 368fb8d1bf,d4e60ace2b..47576b7d77 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@@ -143,34 -152,30 +143,39 @@@ static inline void flush_requests(struc module_init(xlblk_init); -static struct xlbd_disk_info *head_waiting = NULL; -static void kick_pending_request_queues(void) +static void kick_pending_request_queues(struct blkfront_info *info) { - struct xlbd_disk_info *di; - while ( ((di = head_waiting) != NULL) && !RING_FULL(&blk_ring) ) - { - head_waiting = di->next_waiting; - di->next_waiting = NULL; - /* Re-enable calldowns. */ - blk_start_queue(di->rq); - /* Kick things off immediately. */ - do_blkif_request(di->rq); - } + if (!RING_FULL(&info->ring)) { + /* Re-enable calldowns. */ + blk_start_queue(info->rq); + /* Kick things off immediately. */ + do_blkif_request(info->rq); + } +} + +static void blkif_restart_queue(void *arg) +{ + struct blkfront_info *info = (struct blkfront_info *)arg; + spin_lock_irq(&blkif_io_lock); - info->callback.work = NULL; + kick_pending_request_queues(info); + spin_unlock_irq(&blkif_io_lock); +} + ++static void blkif_restart_queue_callback(void *arg) ++{ ++ struct blkfront_info *info = (struct blkfront_info *)arg; ++ schedule_work(&info->work); + } + int blkif_open(struct inode *inode, struct file *filep) { - struct gendisk *gd = inode->i_bdev->bd_disk; - struct xlbd_disk_info *di = (struct xlbd_disk_info *)gd->private_data; + // struct gendisk *gd = inode->i_bdev->bd_disk; + // struct xlbd_disk_info *di = (struct xlbd_disk_info *)gd->private_data; - /* Update of usage count is protected by per-device semaphore. */ - di->mi->usage++; - - return 0; + /* Update of usage count is protected by per-device semaphore. */ + // di->mi->usage++; + + return 0; } @@@ -232,22 -237,12 +237,20 @@@ static int blkif_queue_request(struct r unsigned long id; unsigned int fsect, lsect; int ref; + grant_ref_t gref_head, gref_terminal; - if ( unlikely(blkif_state != BLKIF_STATE_CONNECTED) ) + if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) return 1; + if (gnttab_alloc_grant_references(BLKIF_MAX_SEGMENTS_PER_REQUEST, + &gref_head, &gref_terminal) < 0) { - if (info->callback.work) - return 1; - INIT_WORK(&info->work, blkif_restart_queue, (void *)info); - gnttab_request_free_callback(&info->callback, &info->work); ++ gnttab_request_free_callback(&info->callback, ++ blkif_restart_queue_callback, info); + return 1; + } + /* Fill out a communications ring structure. */ - ring_req = RING_GET_REQUEST(&blk_ring, blk_ring.req_prod_pvt); + ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt); id = GET_ID_FROM_FREELIST(); blk_shadow[id].request = (unsigned long)req; @@@ -1238,10 -1250,9 +1241,11 @@@ static int blkfront_probe(struct xenbus xenbus_dev_error(dev, err, "allocating info structure"); return err; } - info->dev = dev; + info->xbdev = dev; info->vdevice = vdevice; - info->connected = 0; + info->connected = BLKIF_STATE_DISCONNECTED; + info->mi = NULL; ++ INIT_WORK(&info->work, blkif_restart_queue, (void *)info); /* Front end dir is a number, which is used as the id. */ info->handle = simple_strtoul(strrchr(dev->nodename,'/')+1, NULL, 0); diff --cc linux-2.6-xen-sparse/include/asm-xen/gnttab.h index 292652c681,642a74dbf9..b5d0de4cc6 --- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h +++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h @@@ -21,13 -21,6 +21,14 @@@ #define NR_GRANT_FRAMES 4 #define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t)) +struct work_struct; + +struct gnttab_free_callback { + struct gnttab_free_callback *next; - struct work_struct *work; ++ void (*fn)(void *); ++ void *arg; +}; + int gnttab_grant_foreign_access( domid_t domid, unsigned long frame, int readonly); @@@ -71,10 -60,6 +72,10 @@@ voi gnttab_release_grant_reference( grant_ref_t *private_head, grant_ref_t release ); +void +gnttab_request_free_callback( - struct gnttab_free_callback *callback, struct work_struct *work ); ++ struct gnttab_free_callback *callback, void (*fn)(void *), void *arg); + void gnttab_grant_foreign_access_ref( grant_ref_t ref, domid_t domid, unsigned long frame, int readonly);