ia64/xen-unstable

changeset 7169:dd87869f877c

Allow adjustment of the size of TPM transfer buffers
to the size that a lower-layer driver supports.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Oct 03 15:05:37 2005 +0100 (2005-10-03)
parents a9dce0ffc901
children 85f92475b943
files linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.c linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.h 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_nopci.c	Mon Oct 03 15:04:27 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.c	Mon Oct 03 15:05:37 2005 +0100
     1.3 @@ -30,7 +30,8 @@
     1.4  
     1.5  enum {
     1.6  	TPM_MINOR = 224,	/* officially assigned */
     1.7 -	TPM_BUFSIZE = 2048,
     1.8 +	TPM_MIN_BUFSIZE = 2048,
     1.9 +	TPM_MAX_BUFSIZE = 65536,
    1.10  	TPM_NUM_DEVICES = 256,
    1.11  	TPM_NUM_MASK_ENTRIES = TPM_NUM_DEVICES / (8 * sizeof(int))
    1.12  };
    1.13 @@ -63,7 +64,7 @@ static void user_reader_timeout(unsigned
    1.14  
    1.15  	down(&chip->buffer_mutex);
    1.16  	atomic_set(&chip->data_pending, 0);
    1.17 -	memset(chip->data_buffer, 0, TPM_BUFSIZE);
    1.18 +	memset(chip->data_buffer, 0, chip->vendor->buffersize);
    1.19  	up(&chip->buffer_mutex);
    1.20  }
    1.21  
    1.22 @@ -458,7 +459,8 @@ int tpm_open(struct inode *inode, struct
    1.23  
    1.24  	spin_unlock(&driver_lock);
    1.25  
    1.26 -	chip->data_buffer = kmalloc(TPM_BUFSIZE * sizeof(u8), GFP_KERNEL);
    1.27 +	chip->data_buffer = kmalloc(chip->vendor->buffersize * sizeof(u8),
    1.28 +	                            GFP_KERNEL);
    1.29  	if (chip->data_buffer == NULL) {
    1.30  		chip->num_opens--;
    1.31  		put_device(chip->dev);
    1.32 @@ -507,8 +509,8 @@ ssize_t tpm_write(struct file * file, co
    1.33  
    1.34  	down(&chip->buffer_mutex);
    1.35  
    1.36 -	if (in_size > TPM_BUFSIZE)
    1.37 -		in_size = TPM_BUFSIZE;
    1.38 +	if (in_size > chip->vendor->buffersize)
    1.39 +		in_size = chip->vendor->buffersize;
    1.40  
    1.41  	if (copy_from_user
    1.42  	    (chip->data_buffer, (void __user *) buf, in_size)) {
    1.43 @@ -517,7 +519,9 @@ ssize_t tpm_write(struct file * file, co
    1.44  	}
    1.45  
    1.46  	/* atomic tpm command send and result receive */
    1.47 -	out_size = tpm_transmit(chip, chip->data_buffer, TPM_BUFSIZE);
    1.48 +	out_size = tpm_transmit(chip,
    1.49 +	                        chip->data_buffer,
    1.50 +	                        chip->vendor->buffersize);
    1.51  
    1.52  	atomic_set(&chip->data_pending, out_size);
    1.53  	up(&chip->buffer_mutex);
    1.54 @@ -667,6 +671,12 @@ int tpm_register_hardware_nopci(struct d
    1.55  
    1.56  	chip->vendor = entry;
    1.57  
    1.58 +	if (entry->buffersize < TPM_MIN_BUFSIZE) {
    1.59 +		entry->buffersize = TPM_MIN_BUFSIZE;
    1.60 +	} else if (entry->buffersize > TPM_MAX_BUFSIZE) {
    1.61 +		entry->buffersize = TPM_MAX_BUFSIZE;
    1.62 +	}
    1.63 +
    1.64  	chip->dev_num = -1;
    1.65  
    1.66  	for (i = 0; i < TPM_NUM_MASK_ENTRIES; i++)
     2.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.h	Mon Oct 03 15:04:27 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_nopci.h	Mon Oct 03 15:05:37 2005 +0100
     2.3 @@ -62,6 +62,7 @@ struct tpm_vendor_specific {
     2.4  	u8 req_complete_val;
     2.5  	u8 req_canceled;
     2.6  	u16 base;		/* TPM base address */
     2.7 +	u32 buffersize;         /* The device's requested buffersize */
     2.8  
     2.9  	int (*recv) (struct tpm_chip *, u8 *, size_t);
    2.10  	int (*send) (struct tpm_chip *, u8 *, size_t);
     3.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Mon Oct 03 15:04:27 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Mon Oct 03 15:05:37 2005 +0100
     3.3 @@ -445,6 +445,7 @@ static struct tpm_vendor_specific tpm_xe
     3.4  	.base = 0,
     3.5  	.attr = TPM_DEVICE_ATTRS,
     3.6  	.miscdev.fops = &tpm_xen_ops,
     3.7 +	.buffersize = 64 * 1024,
     3.8  };
     3.9  
    3.10  static struct device tpm_device = {
    3.11 @@ -477,6 +478,8 @@ static int __init init_xen(void)
    3.12  		return rc;
    3.13  	}
    3.14  
    3.15 +	tpm_xen.buffersize = tpmfe.max_tx_size;
    3.16 +
    3.17  	if ((rc = tpm_register_hardware_nopci(&tpm_device, &tpm_xen)) < 0) {
    3.18  		device_unregister(&tpm_device);
    3.19  		tpm_fe_unregister_receiver();