From: Stefan Berger Subject: [PATCH] [vTPM] Timing issue when doing local migration + cleanup Date: Wed, 17 May 2006 16:04:59 -0400 Message-ID: <1147896299.19437.6.camel@941e-2.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-J4nbqaDZLzehz3ZwErZM" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org --=-J4nbqaDZLzehz3ZwErZM Content-Type: text/plain Content-Transfer-Encoding: 7bit When doing local migration, a timing-related problem occurred due to the frontend switching to the Closed state, which could end up having the .remove function being called after the backend has shut down. This now fixes the problem by switching to the Closing state. The other part of the patch cleans up freeing of memory. Signed-off-by: Stefan Berger --=-J4nbqaDZLzehz3ZwErZM Content-Disposition: attachment; filename=vtpm_locmigr_fix.diff Content-Type: text/x-patch; name=vtpm_locmigr_fix.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c @@ -416,7 +416,7 @@ static int tpmfront_suspend(struct xenbu */ interruptible_sleep_on_timeout(&tp->wait_q, 100); } - xenbus_switch_state(dev, XenbusStateClosed); + xenbus_switch_state(dev, XenbusStateClosing); if (atomic_read(&tp->tx_busy)) { /* Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -150,7 +150,7 @@ static void frontend_changed(struct xenb break; case XenbusStateClosing: - xenbus_switch_state(dev, XenbusStateClosing); + be->tpmif->tpm_instance = -1; break; case XenbusStateClosed: Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h @@ -45,8 +45,6 @@ typedef struct tpmif_st { long int tpm_instance; unsigned long mmap_vstart; - struct work_struct work; - grant_handle_t shmem_handle; grant_ref_t shmem_ref; struct page *pagerange; Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c @@ -152,10 +152,8 @@ int tpmif_map(tpmif_t *tpmif, unsigned l return 0; } -static void __tpmif_disconnect_complete(void *arg) +void tpmif_disconnect_complete(tpmif_t *tpmif) { - tpmif_t *tpmif = (tpmif_t *) arg; - if (tpmif->irq) unbind_from_irqhandler(tpmif->irq, tpmif); @@ -167,12 +165,6 @@ static void __tpmif_disconnect_complete( free_tpmif(tpmif); } -void tpmif_disconnect_complete(tpmif_t * tpmif) -{ - INIT_WORK(&tpmif->work, __tpmif_disconnect_complete, (void *)tpmif); - schedule_work(&tpmif->work); -} - void __init tpmif_interface_init(void) { tpmif_cachep = kmem_cache_create("tpmif_cache", sizeof (tpmif_t), Index: root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c =================================================================== --- root.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c +++ root/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c @@ -1063,7 +1063,7 @@ static int __init tpmback_init(void) module_init(tpmback_init); -static void __exit tpmback_exit(void) +void __exit tpmback_exit(void) { vtpm_release_packets(NULL, 0); tpmif_xenbus_exit(); --=-J4nbqaDZLzehz3ZwErZM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-J4nbqaDZLzehz3ZwErZM--