Skip to contentSkip to conversation

Timing issue when doing local migration + cleanup

PATCH New Stefan Berger 1 participant 1 message May 17, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Timing issue when doing local migration + cleanup

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.

xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +1 -1
Index: 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)) {
 		/*
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +1 -1
Index: 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:
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h +0 -2
Index: 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;
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c +1 -9
Index: 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),
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c +1 -1
Index: 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();

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel