Skip to contentSkip to conversation

Proper shutdown of TPM frontend

PATCH New Stefan Berger 1 participant 1 message Oct 18, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Proper shutdown of TPM frontend

This patch fixes the tpm frontend to properly shut down when the domain is shutting down (call to xenbus_frontend_closed()). Also the driver now waits longer until an outstanding response has been received (to support a busy system).
Moves the 'Unknown' state with the other states that are not used by the TPM frontend.

I ran the vtpm-related xm-tests with these changes and they pass.

Stefan

xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +7 -4
Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
===================================================================
@@ -343,6 +343,7 @@ static void backend_changed(struct xenbu
 	case XenbusStateInitialising:
 	case XenbusStateInitWait:
 	case XenbusStateInitialised:
+	case XenbusStateUnknown:
 		break;
 
 	case XenbusStateConnected:
@@ -351,13 +352,14 @@ static void backend_changed(struct xenbu
 
 	case XenbusStateClosing:
 		tpmif_set_connected_state(tp, 0);
+		xenbus_frontend_closed(dev);
 		break;
 
-	case XenbusStateUnknown:
 	case XenbusStateClosed:
+		tpmif_set_connected_state(tp, 0);
 		if (tp->is_suspended == 0)
 			device_unregister(&dev->dev);
-		xenbus_switch_state(dev, XenbusStateClosed);
+		xenbus_frontend_closed(dev);
 		break;
 	}
 }
@@ -419,9 +421,10 @@ static int tpmfront_suspend(struct xenbu
 	mutex_lock(&suspend_lock);
 	tp->is_suspended = 1;
 
-	for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 25; ctr++) {
+	for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 300; ctr++) {
 		if ((ctr % 10) == 0)
-			printk("TPM-FE [INFO]: Waiting for outstanding request.\n");
+			printk("TPM-FE [INFO]: Waiting for outstanding "
+			       "request.\n");
 		/*
 		 * Wait for a request to be responded to.
 		 */
xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +3 -1
Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
===================================================================
@@ -157,10 +157,12 @@ static void frontend_changed(struct xenb
 
 	case XenbusStateClosing:
 		be->instance = -1;
+		xenbus_switch_state(dev, XenbusStateClosing);
 		break;
 
-	case XenbusStateUnknown:
+	case XenbusStateUnknown: /* keep it here */
 	case XenbusStateClosed:
+		xenbus_switch_state(dev, XenbusStateClosed);
 		device_unregister(&be->dev->dev);
 		tpmback_remove(dev);
 		break;

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