direct-io.hg

changeset 7225:21606b84b730

Activate suspending/resuming of the TPM interface and add
some missing code to tpmif.py.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Oct 05 23:15:00 2005 +0100 (2005-10-05)
parents f98c8238e909
children bde548fff7b4
files linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c tools/python/xen/xend/server/tpmif.py
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Wed Oct 05 19:15:56 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Wed Oct 05 23:15:00 2005 +0100
     1.3 @@ -442,26 +442,32 @@ static int tpmfront_remove(struct xenbus
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 -static int tpmfront_suspend(struct xenbus_device *dev)
     1.8 +static int
     1.9 +tpmfront_suspend(struct xenbus_device *dev)
    1.10  {
    1.11  	struct tpmfront_info *info = dev->data;
    1.12  	struct tpm_private *tp = &my_private;
    1.13 +	u32 ctr = 0;
    1.14  
    1.15 -	/* lock so no app can send */
    1.16 +	/* lock, so no app can send */
    1.17  	down(&suspend_lock);
    1.18  
    1.19 -	while (atomic_read(&tp->tx_busy)) {
    1.20 -		printk("---- TPMIF: Outstanding request.\n");
    1.21 -#if 0
    1.22 +	while (atomic_read(&tp->tx_busy) && ctr <= 25) {
    1.23 +	        if ((ctr % 10) == 0)
    1.24 +			printk("INFO: Waiting for outstanding request.\n");
    1.25  		/*
    1.26 -		 * Would like to wait until the outstanding request
    1.27 -		 * has come back, but this does not work properly, yet.
    1.28 +		 * Wait for a request to be responded to.
    1.29  		 */
    1.30 -		interruptible_sleep_on_timeout(&tp->wait_q,
    1.31 -		                               100);
    1.32 -#else
    1.33 -		break;
    1.34 -#endif
    1.35 +		interruptible_sleep_on_timeout(&tp->wait_q, 100);
    1.36 +		ctr++;
    1.37 +	}
    1.38 +
    1.39 +	if (atomic_read(&tp->tx_busy)) {
    1.40 +		/*
    1.41 +		 * A temporary work-around.
    1.42 +		 */
    1.43 +		printk("WARNING: Resetting busy flag.");
    1.44 +		atomic_set(&tp->tx_busy, 0);
    1.45  	}
    1.46  
    1.47  	unregister_xenbus_watch(&info->watch);
    1.48 @@ -469,44 +475,34 @@ static int tpmfront_suspend(struct xenbu
    1.49  	kfree(info->backend);
    1.50  	info->backend = NULL;
    1.51  
    1.52 -	destroy_tpmring(info, tp);
    1.53 -
    1.54 -	return 0;
    1.55 -}
    1.56 -
    1.57 -static int tpmif_recover(void)
    1.58 -{
    1.59  	return 0;
    1.60  }
    1.61  
    1.62 -static int tpmfront_resume(struct xenbus_device *dev)
    1.63 +static int
    1.64 +tpmfront_resume(struct xenbus_device *dev)
    1.65  {
    1.66  	struct tpmfront_info *info = dev->data;
    1.67 -	int err;
    1.68 +	int err = talk_to_backend(dev, info);
    1.69  
    1.70 -	err = talk_to_backend(dev, info);
    1.71 -	if (!err) {
    1.72 -		tpmif_recover();
    1.73 -	}
    1.74 -
    1.75 -	/* unlock so apps can resume */
    1.76 +	/* unlock, so apps can resume sending */
    1.77  	up(&suspend_lock);
    1.78  
    1.79  	return err;
    1.80  }
    1.81  
    1.82 -static void tpmif_connect(u16 evtchn, domid_t domid)
    1.83 +static void
    1.84 +tpmif_connect(u16 evtchn, domid_t domid)
    1.85  {
    1.86  	int err = 0;
    1.87  	struct tpm_private *tp = &my_private;
    1.88  
    1.89  	tp->evtchn = evtchn;
    1.90 -	tp->backend_id  = domid;
    1.91 +	tp->backend_id = domid;
    1.92  
    1.93 -	err = bind_evtchn_to_irqhandler(
    1.94 -		tp->evtchn,
    1.95 -		tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
    1.96 -	if ( err <= 0 ) {
    1.97 +	err = bind_evtchn_to_irqhandler(tp->evtchn,
    1.98 +					tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
    1.99 +					tp);
   1.100 +	if (err <= 0) {
   1.101  		WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
   1.102  		return;
   1.103  	}
   1.104 @@ -641,7 +637,7 @@ tpm_xmit(struct tpm_private *tp,
   1.105  
   1.106  		if (NULL == txb) {
   1.107  			DPRINTK("txb (i=%d) is NULL. buffers initilized?\n", i);
   1.108 -			DPRINTK("Not transmittin anything!\n");
   1.109 +			DPRINTK("Not transmitting anything!\n");
   1.110  			spin_unlock_irq(&tp->tx_lock);
   1.111  			return -EFAULT;
   1.112  		}
     2.1 --- a/tools/python/xen/xend/server/tpmif.py	Wed Oct 05 19:15:56 2005 +0100
     2.2 +++ b/tools/python/xen/xend/server/tpmif.py	Wed Oct 05 23:15:00 2005 +0100
     2.3 @@ -39,9 +39,24 @@ class TPMifController(DevController):
     2.4          """@see DevController.getDeviceDetails"""
     2.5          
     2.6          devid = int(sxp.child_value(config, 'instance', '0'))
     2.7 -        log.debug("The domain has a TPM with instance %d." % devid)
     2.8 +        log.info("The domain has a TPM with instance %d." % devid)
     2.9  
    2.10          back  = { 'instance' : "%i" % devid }
    2.11          front = { 'handle' : "%i" % devid }
    2.12  
    2.13          return (devid, back, front)
    2.14 +
    2.15 +    def configuration(self, devid):
    2.16 +
    2.17 +        log.info("The configuration method is called.")
    2.18 +
    2.19 +        result = DevContoller.configuration(self, devid)
    2.20 +
    2.21 +        (instance) = self.readBackend(devif,
    2.22 +                                      'instance')
    2.23 +
    2.24 +        if instance:
    2.25 +            result.append(['instance', instance])
    2.26 +            log.info("configuration: instance=%d." % instance)
    2.27 +
    2.28 +        return result