From: Stefan Berger Subject: [PATCH][TPM Driver][BUGFIX] Proper shutdown of tpm frontend Date: Wed, 11 Oct 2006 12:30:06 -0400 Message-ID: <1160584207.4686.4.camel@941e-2.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-s85lNzvfPS19g1MaCOv1" 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 --=-s85lNzvfPS19g1MaCOv1 Content-Type: text/plain Content-Transfer-Encoding: 7bit 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). I ran the vtpm-related xm-tests with these changes and they pass. Stefan Signed-off-by: Stefan Berger --=-s85lNzvfPS19g1MaCOv1 Content-Disposition: attachment; filename=tpmfront-proper-shutdown.diff Content-Type: text/x-patch; name=tpmfront-proper-shutdown.diff; charset=utf-8 Content-Transfer-Encoding: 7bit Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c @@ -351,13 +351,15 @@ 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++) { 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. */ Index: xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c =================================================================== --- xen.orig/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ xen/xen-unstable.hg/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -157,6 +157,7 @@ static void frontend_changed(struct xenb case XenbusStateClosing: be->instance = -1; + xenbus_switch_state(dev, XenbusStateClosing); break; case XenbusStateUnknown: --=-s85lNzvfPS19g1MaCOv1 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 --=-s85lNzvfPS19g1MaCOv1--