From owner-p4-projects@FreeBSD.ORG Sat Dec 29 01:34:11 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 818EE16A469; Sat, 29 Dec 2007 01:34:11 +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 45FC916A421 for ; Sat, 29 Dec 2007 01:34:11 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 3823313C455 for ; Sat, 29 Dec 2007 01:34:11 +0000 (UTC) (envelope-from kmacy@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 lBT1YB99004714 for ; Sat, 29 Dec 2007 01:34:11 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id lBT1YAR6004710 for perforce@freebsd.org; Sat, 29 Dec 2007 01:34:10 GMT (envelope-from kmacy@freebsd.org) Date: Sat, 29 Dec 2007 01:34:10 GMT Message-Id: <200712290134.lBT1YAR6004710@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 131944 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: Sat, 29 Dec 2007 01:34:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=131944 Change 131944 by kmacy@pandemonium:kmacy:xen31 on 2007/12/29 01:33:52 fix WITNESS complaints about xenbus compile in block and console devices we now hang waiting for block device interrupts when mounting root Affected files ... .. //depot/projects/xen31/sys/conf/files#11 edit .. //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#2 edit .. //depot/projects/xen31/sys/dev/xen/console/console.c#2 edit .. //depot/projects/xen31/sys/dev/xen/console/xencons_ring.c#2 edit .. //depot/projects/xen31/sys/i386/include/xen/xen-public/io/console.h#1 add .. //depot/projects/xen31/sys/xen/xenbus/xenbus_probe.c#3 edit .. //depot/projects/xen31/sys/xen/xenbus/xenbus_xs.c#5 edit Differences ... ==== //depot/projects/xen31/sys/conf/files#11 (text+ko) ==== @@ -2117,6 +2117,9 @@ xen/xenbus/xenbus_dev.c optional xen xen/xenbus/xenbus_probe.c optional xen xen/xenbus/xenbus_xs.c optional xen +dev/xen/console/console.c optional xen +dev/xen/console/xencons_ring.c optional xen +dev/xen/blkfront/blkfront.c optional xen # gnu/fs/xfs/xfs_alloc.c optional xfs \ ==== //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#2 (text+ko) ==== @@ -37,17 +37,17 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include +#include +#include #include @@ -245,8 +245,8 @@ return err; } - info = malloc(sizeof(*info), M_DEVBUF, M_WAITOK); - if (!info) { + info = malloc(sizeof(*info), M_DEVBUF, M_NOWAIT); + if (info == NULL) { xenbus_dev_fatal(dev, ENOMEM, "allocating info structure"); return ENOMEM; } @@ -362,8 +362,8 @@ info->ring_ref = GRANT_INVALID_REF; - sring = (blkif_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK); - if (!sring) { + sring = (blkif_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT); + if (sring == NULL) { xenbus_dev_fatal(dev, ENOMEM, "allocating shared ring"); return ENOMEM; } @@ -473,10 +473,10 @@ (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); /* Kick pending requests. */ - mtx_lock_spin(&blkif_io_lock); + mtx_lock(&blkif_io_lock); info->connected = BLKIF_STATE_CONNECTED; kick_pending_request_queues(info); - mtx_unlock_spin(&blkif_io_lock); + mtx_unlock(&blkif_io_lock); #if 0 add_disk(info->gd); @@ -577,9 +577,10 @@ static void blkif_restart_queue(void *arg) { struct blkfront_info *info = (struct blkfront_info *)arg; - mtx_lock_spin(&blkif_io_lock); + + mtx_lock(&blkif_io_lock); kick_pending_request_queues(info); - mtx_unlock_spin(&blkif_io_lock); + mtx_unlock(&blkif_io_lock); } #endif @@ -794,16 +795,15 @@ struct bio *bp; blkif_response_t *bret; RING_IDX i, rp; - unsigned long flags; struct blkfront_info *info = xsc; DPRINTK(""); TRACE_ENTER; - mtx_lock_irqsave(&blkif_io_lock, flags); + mtx_lock(&blkif_io_lock); if (unlikely(info->connected != BLKIF_STATE_CONNECTED)) { - mtx_unlock_irqrestore(&blkif_io_lock, flags); + mtx_unlock(&blkif_io_lock); return; } @@ -870,7 +870,7 @@ kick_pending_request_queues(info); - mtx_unlock_irqrestore(&blkif_io_lock, flags); + mtx_unlock(&blkif_io_lock); } static void @@ -878,10 +878,10 @@ { /* Prevent new requests being issued until we fix things up. */ - mtx_lock_spin(&blkif_io_lock); + mtx_lock(&blkif_io_lock); info->connected = suspend ? BLKIF_STATE_SUSPENDED : BLKIF_STATE_DISCONNECTED; - mtx_unlock_spin(&blkif_io_lock); + mtx_unlock(&blkif_io_lock); /* Free resources associated with old device channel. */ if (info->ring_ref != GRANT_INVALID_REF) { @@ -957,17 +957,17 @@ (void)xenbus_switch_state(info->xbdev, NULL, XenbusStateConnected); /* Now safe for us to use the shared ring */ - mtx_lock_spin(&blkif_io_lock); - info->connected = BLKIF_STATE_CONNECTED; - mtx_unlock_spin(&blkif_io_lock); + mtx_lock(&blkif_io_lock); + info->connected = BLKIF_STATE_CONNECTED; + mtx_unlock(&blkif_io_lock); /* Send off requeued requests */ flush_requests(info); /* Kick any other new requests queued since we resumed */ - mtx_lock_spin(&blkif_io_lock); + mtx_lock(&blkif_io_lock); kick_pending_request_queues(info); - mtx_unlock_spin(&blkif_io_lock); + mtx_unlock(&blkif_io_lock); } static struct xenbus_device_id blkfront_ids[] = { @@ -993,7 +993,7 @@ xenbus_register_frontend(&blkfront); } -MTX_SYSINIT(ioreq, &blkif_io_lock, "BIO LOCK", MTX_SPIN | MTX_NOWITNESS); /* XXX how does one enroll a lock? */ +MTX_SYSINIT(ioreq, &blkif_io_lock, "BIO LOCK", MTX_NOWITNESS); /* XXX how does one enroll a lock? */ MTX_SYSINIT(ioreq_block, &blkif_io_block_lock, "BIO BLOCK LOCK", MTX_SPIN | MTX_NOWITNESS); SYSINIT(xbdev, SI_SUB_PSEUDO, SI_ORDER_SECOND, xenbus_init, NULL); ==== //depot/projects/xen31/sys/dev/xen/console/console.c#2 (text+ko) ==== @@ -14,14 +14,14 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include -#include +#include #include "opt_ddb.h" ==== //depot/projects/xen31/sys/dev/xen/console/xencons_ring.c#2 (text+ko) ==== @@ -14,16 +14,17 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include +#define console_evtchn console.domU.evtchn extern char *console_page; static inline struct xencons_interface * ==== //depot/projects/xen31/sys/xen/xenbus/xenbus_probe.c#3 (text+ko) ==== @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -81,7 +82,7 @@ struct xendev_list_head xenbus_device_backend_list; static LIST_HEAD(, xenbus_driver) xendrv_list; -extern struct sema xenwatch_mutex; +extern struct sx xenwatch_mutex; EVENTHANDLER_DECLARE(xenstore_event, xenstore_event_handler_t); static struct eventhandler_list *xenstore_chain; @@ -563,12 +564,11 @@ drv->driver.probe = xenbus_dev_probe; drv->driver.remove = xenbus_dev_remove; - return ret; #endif - down(&xenwatch_mutex); + sx_xlock(&xenwatch_mutex); LIST_INSERT_HEAD(&xendrv_list, drv, list); - up(&xenwatch_mutex); + sx_xunlock(&xenwatch_mutex); LIST_FOREACH(xdev, bus->bus, list) { if (match_device(drv->ids, xdev)) { xdev->driver = drv; ==== //depot/projects/xen31/sys/xen/xenbus/xenbus_xs.c#5 (text+ko) ==== @@ -37,6 +37,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -98,7 +101,7 @@ int reply_waitq; /* One request at a time. */ - struct semaphore request_mutex; + struct sx request_mutex; /* Protect transactions against save/restore. */ struct rw_semaphore suspend_mutex; @@ -119,7 +122,7 @@ * carrying out work. */ static pid_t xenwatch_pid; -/* static */ DECLARE_MUTEX(xenwatch_mutex); +struct sx xenwatch_mutex; static int watch_events_waitq; static int get_error(const char *errorstring) @@ -184,12 +187,12 @@ msg.type = XS_DEBUG; msg.len = sizeof("print") + count + 1; - down(&xs_state.request_mutex); + sx_xlock(&xs_state.request_mutex); xb_write(&msg, sizeof(msg)); xb_write("print", sizeof("print")); xb_write(str, count); xb_write("", 1); - up(&xs_state.request_mutex); + sx_xunlock(&xs_state.request_mutex); } #endif @@ -202,7 +205,7 @@ if (req_msg.type == XS_TRANSACTION_START) down_read(&xs_state.suspend_mutex); - down(&xs_state.request_mutex); + sx_xlock(&xs_state.request_mutex); err = xb_write(msg, sizeof(*msg) + msg->len); if (err) { @@ -212,7 +215,7 @@ ret = read_reply(&msg->type, &msg->len); } - up(&xs_state.request_mutex); + sx_xunlock(&xs_state.request_mutex); if ((msg->type == XS_TRANSACTION_END) || ((req_msg.type == XS_TRANSACTION_START) && @@ -241,25 +244,25 @@ for (i = 0; i < num_vecs; i++) msg.len += iovec[i].iov_len; - down(&xs_state.request_mutex); + sx_xlock(&xs_state.request_mutex); err = xb_write(&msg, sizeof(msg)); if (err) { - up(&xs_state.request_mutex); + sx_xunlock(&xs_state.request_mutex); return ERR_PTR(err); } for (i = 0; i < num_vecs; i++) { err = xb_write(iovec[i].iov_base, iovec[i].iov_len);; - if (err) { - up(&xs_state.request_mutex); + if (err) { + sx_xunlock(&xs_state.request_mutex); return ERR_PTR(err); } } ret = read_reply(&msg.type, len); - up(&xs_state.request_mutex); + sx_xunlock(&xs_state.request_mutex); if (IS_ERR(ret)) return ret; @@ -689,8 +692,8 @@ /* Flush any currently-executing callback, unless we are it. :-) */ if (curproc->p_pid != xenwatch_pid) { - down(&xenwatch_mutex); - up(&xenwatch_mutex); + sx_xlock(&xenwatch_mutex); + sx_xunlock(&xenwatch_mutex); } } EXPORT_SYMBOL(unregister_xenbus_watch); @@ -698,7 +701,7 @@ void xs_suspend(void) { down_write(&xs_state.suspend_mutex); - down(&xs_state.request_mutex); + sx_xlock(&xs_state.request_mutex); } void xs_resume(void) @@ -706,7 +709,7 @@ struct xenbus_watch *watch; char token[sizeof(watch) * 2 + 1]; - up(&xs_state.request_mutex); + sx_xunlock(&xs_state.request_mutex); /* No need for watches_lock: the suspend_mutex is sufficient. */ LIST_FOREACH(watch, &watches, list) { @@ -725,7 +728,7 @@ wait_event_interruptible(&watch_events_waitq, !list_empty(&watch_events)); - down(&xenwatch_mutex); + sx_xlock(&xenwatch_mutex); spin_lock(&watch_events_lock); msg = TAILQ_FIRST(&watch_events); @@ -743,7 +746,7 @@ kfree(msg); } - up(&xenwatch_mutex); + sx_xunlock(&xenwatch_mutex); } } @@ -829,13 +832,14 @@ TAILQ_INIT(&xs_state.reply_list); TAILQ_INIT(&watch_events); mtx_init(&xs_state.reply_lock, "state reply", NULL, MTX_DEF); - sema_init(&xs_state.request_mutex, 1, "xenstore request"); sema_init(&xs_state.suspend_mutex, 1, "xenstore suspend"); - sema_init(&xenwatch_mutex, 1, "xenwatch"); + sx_init(&xenwatch_mutex, "xenwatch"); + sx_init(&xs_state.request_mutex, "xenstore request"); + #if 0 - mtx_init(&xs_state.request_mutex, "xenstore request", NULL, MTX_DEF); mtx_init(&xs_state.suspend_mutex, "xenstore suspend", NULL, MTX_DEF); - mtx_init(&xenwatch_mutex, "xenwatch", NULL, MTX_DEF); + sema_init(&xs_state.request_mutex, 1, "xenstore request"); + sema_init(&xenwatch_mutex, 1, "xenwatch"); #endif mtx_init(&watches_lock, "watches", NULL, MTX_DEF); mtx_init(&watch_events_lock, "watch events", NULL, MTX_DEF);