ia64/xen-unstable

changeset 14221:cc18ea7309b3

[Linux] [TPM driver] Resume frontend after checkpointing

This patch implements TPM frontend driver resume after checkpointing a
domain. I also now let the front-end wait for the response from the
TPM until the response is there. A response must come due to the
strict request/response nature of the protocol, but the time until the
responses arrives depends on the type of operation that is executed by
the vTPM. Resending a request is not possible with this type of device.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Fri Mar 02 16:03:21 2007 +0000 (2007-03-02)
parents 1fb5ae0ee453
children bc265a79dd32
files linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Mar 02 16:00:22 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Mar 02 16:03:21 2007 +0000
     1.3 @@ -421,7 +421,7 @@ static int tpmfront_suspend(struct xenbu
     1.4  	mutex_lock(&suspend_lock);
     1.5  	tp->is_suspended = 1;
     1.6  
     1.7 -	for (ctr = 0; atomic_read(&tp->tx_busy) && ctr <= 300; ctr++) {
     1.8 +	for (ctr = 0; atomic_read(&tp->tx_busy); ctr++) {
     1.9  		if ((ctr % 10) == 0)
    1.10  			printk("TPM-FE [INFO]: Waiting for outstanding "
    1.11  			       "request.\n");
    1.12 @@ -430,19 +430,24 @@ static int tpmfront_suspend(struct xenbu
    1.13  		 */
    1.14  		interruptible_sleep_on_timeout(&tp->wait_q, 100);
    1.15  	}
    1.16 -	xenbus_switch_state(dev, XenbusStateClosing);
    1.17 -
    1.18 -	if (atomic_read(&tp->tx_busy)) {
    1.19 -		/*
    1.20 -		 * A temporary work-around.
    1.21 -		 */
    1.22 -		printk("TPM-FE [WARNING]: Resetting busy flag.");
    1.23 -		atomic_set(&tp->tx_busy, 0);
    1.24 -	}
    1.25  
    1.26  	return 0;
    1.27  }
    1.28  
    1.29 +static int __tpmfront_suspend_cancel(struct tpm_private *tp)
    1.30 +{
    1.31 +	tp->is_suspended = 0;
    1.32 +	/* unlock, so apps can send again */
    1.33 +	mutex_unlock(&suspend_lock);
    1.34 +	return 0;
    1.35 +}
    1.36 +
    1.37 +static int tpmfront_suspend_cancel(struct xenbus_device *dev)
    1.38 +{
    1.39 +	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
    1.40 +	return __tpmfront_suspend_cancel(tp);
    1.41 +}
    1.42 +
    1.43  static int tpmfront_resume(struct xenbus_device *dev)
    1.44  {
    1.45  	struct tpm_private *tp = tpm_private_from_dev(&dev->dev);
    1.46 @@ -484,6 +489,7 @@ static struct xenbus_driver tpmfront = {
    1.47  	.resume = tpmfront_resume,
    1.48  	.otherend_changed = backend_changed,
    1.49  	.suspend = tpmfront_suspend,
    1.50 +	.suspend_cancel = tpmfront_suspend_cancel,
    1.51  };
    1.52  
    1.53  static void __init init_tpm_xenbus(void)
    1.54 @@ -689,9 +695,7 @@ static void tpmif_set_connected_state(st
    1.55  	 * This also removes the suspend state.
    1.56  	 */
    1.57  	if (is_connected == 1 && tp->is_suspended == 1) {
    1.58 -		tp->is_suspended = 0;
    1.59 -		/* unlock, so apps can resume sending */
    1.60 -		mutex_unlock(&suspend_lock);
    1.61 +		__tpmfront_suspend_cancel(tp);
    1.62  	}
    1.63  
    1.64  	if (is_connected != tp->is_connected) {