2013-10-22 17:54:20

by Peter Huewe

[permalink] [raw]
Subject: [PATCH 01/15] tpm: MAINTAINERS: Add myself as tpm maintainer

Since I'm actively maintaining the tpm subsystem for a few months now,
it's time to step up and be an official maintainer for the tpm subsystem,
atleast until I hear something different from my company.

The maintaining is done solely in my private time, out of private interest.
Speaking only on behalf of myself, trying to be as vendor neutral as possible.

Signed-off-by: Peter Huewe <[email protected]>
---
MAINTAINERS | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4fde706..936adb4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8475,6 +8475,7 @@ F: drivers/media/usb/tm6000/
TPM DEVICE DRIVER
M: Leonidas Da Silva Barbosa <[email protected]>
M: Ashley Lai <[email protected]>
+M: Peter Huewe <[email protected]>
M: Rajiv Andrade <[email protected]>
W: http://tpmdd.sourceforge.net
M: Marcel Selhorst <[email protected]>
--
1.7.5.4


2013-10-22 17:54:30

by Peter Huewe

[permalink] [raw]
Subject: [PATCH 04/15] tpm: Store devname in the tpm_chip

From: Jason Gunthorpe <[email protected]>

Just put the memory directly in the chip structure, rather than
in a 2nd dedicated kmalloc.

Signed-off-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Joel Schopp <[email protected]>
Reviewed-by: Peter Huewe <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
Acked-by: Ashley Lai <[email protected]>
---
drivers/char/tpm/tpm.c | 17 ++++++-----------
drivers/char/tpm/tpm.h | 1 +
2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index e3c974a..71eb8c7 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1463,7 +1463,6 @@ void tpm_dev_vendor_release(struct tpm_chip *chip)
chip->vendor.release(chip->dev);

clear_bit(chip->dev_num, dev_mask);
- kfree(chip->vendor.miscdev.name);
}
EXPORT_SYMBOL_GPL(tpm_dev_vendor_release);

@@ -1496,17 +1495,13 @@ EXPORT_SYMBOL_GPL(tpm_dev_release);
struct tpm_chip *tpm_register_hardware(struct device *dev,
const struct tpm_vendor_specific *entry)
{
-#define DEVNAME_SIZE 7
-
- char *devname;
struct tpm_chip *chip;

/* Driver specific per-device data */
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
- devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL);

- if (chip == NULL || devname == NULL)
- goto out_free;
+ if (chip == NULL)
+ return NULL;

mutex_init(&chip->buffer_mutex);
mutex_init(&chip->tpm_mutex);
@@ -1531,8 +1526,9 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,

set_bit(chip->dev_num, dev_mask);

- scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
- chip->vendor.miscdev.name = devname;
+ scnprintf(chip->devname, sizeof(chip->devname), "%s%d", "tpm",
+ chip->dev_num);
+ chip->vendor.miscdev.name = chip->devname;

chip->vendor.miscdev.parent = dev;
chip->dev = get_device(dev);
@@ -1558,7 +1554,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev,
goto put_device;
}

- chip->bios_dir = tpm_bios_log_setup(devname);
+ chip->bios_dir = tpm_bios_log_setup(chip->devname);

/* Make chip available */
spin_lock(&driver_lock);
@@ -1571,7 +1567,6 @@ put_device:
put_device(chip->dev);
out_free:
kfree(chip);
- kfree(devname);
return NULL;
}
EXPORT_SYMBOL_GPL(tpm_register_hardware);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index a7bfc17..0df18b5 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -122,6 +122,7 @@ struct tpm_chip {
struct device *dev; /* Device stuff */

int dev_num; /* /dev/tpm# */
+ char devname[7];
unsigned long is_open; /* only one allowed */
int time_expired;

--
1.7.5.4

2013-10-22 17:54:37

by Peter Huewe

[permalink] [raw]
Subject: [PATCH 05/15] tpm: Use container_of to locate the tpm_chip in tpm_open

From: Jason Gunthorpe <[email protected]>

misc_open sets the file->private_date to the misc_dev when calling
open. We can use container_of to go from the misc_dev back to the
tpm_chip.

Future clean ups will move tpm_open into a new file and this change
means we do not have to export the tpm_chip list.

Signed-off-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Joel Schopp <[email protected]>
Reviewed-by: Peter Huewe <[email protected]>
Acked-by: Ashley Lai <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
---
drivers/char/tpm/tpm.c | 21 ++++-----------------
1 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 71eb8c7..c3ab508 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1170,38 +1170,25 @@ EXPORT_SYMBOL_GPL(wait_for_tpm_stat);
*/
int tpm_open(struct inode *inode, struct file *file)
{
- int minor = iminor(inode);
- struct tpm_chip *chip = NULL, *pos;
-
- rcu_read_lock();
- list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
- if (pos->vendor.miscdev.minor == minor) {
- chip = pos;
- get_device(chip->dev);
- break;
- }
- }
- rcu_read_unlock();
-
- if (!chip)
- return -ENODEV;
+ struct miscdevice *misc = file->private_data;
+ struct tpm_chip *chip = container_of(misc, struct tpm_chip,
+ vendor.miscdev);

if (test_and_set_bit(0, &chip->is_open)) {
dev_dbg(chip->dev, "Another process owns this TPM\n");
- put_device(chip->dev);
return -EBUSY;
}

chip->data_buffer = kzalloc(TPM_BUFSIZE, GFP_KERNEL);
if (chip->data_buffer == NULL) {
clear_bit(0, &chip->is_open);
- put_device(chip->dev);
return -ENOMEM;
}

atomic_set(&chip->data_pending, 0);

file->private_data = chip;
+ get_device(chip->dev);
return 0;
}
EXPORT_SYMBOL_GPL(tpm_open);
--
1.7.5.4

2013-10-22 17:54:28

by Peter Huewe

[permalink] [raw]
Subject: [PATCH 02/15] tpm: ibmvtpm: Use %zd formatting for size_t format arguments

From: Jason Gunthorpe <[email protected]>

This suppresses compile warnings on 32 bit builds.

Signed-off-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Joel Schopp <[email protected]>
Reviewed-by: Peter Huewe <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
Acked-by: Ashley Lai <[email protected]>
---
drivers/char/tpm/tpm_ibmvtpm.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index 56b07c3..838f043 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -98,7 +98,7 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)

if (count < len) {
dev_err(ibmvtpm->dev,
- "Invalid size in recv: count=%ld, crq_size=%d\n",
+ "Invalid size in recv: count=%zd, crq_size=%d\n",
count, len);
return -EIO;
}
@@ -136,7 +136,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)

if (count > ibmvtpm->rtce_size) {
dev_err(ibmvtpm->dev,
- "Invalid size in send: count=%ld, rtce_size=%d\n",
+ "Invalid size in send: count=%zd, rtce_size=%d\n",
count, ibmvtpm->rtce_size);
return -EIO;
}
--
1.7.5.4

2013-10-22 17:55:16

by Peter Huewe

[permalink] [raw]
Subject: [PATCH 03/15] tpm atmel: Call request_region with the correct base

From: Jason Gunthorpe <[email protected]>

Commit e0dd03caf20d040a0a86 ("tpm: return chip from
tpm_register_hardware") changed the code path here so that
ateml_get_base_addr no longer directly altered the tpm_vendor_specific
structure, and instead placed the base address on the stack.

The commit missed updating the request_region call, which would have
resulted in request_region being called with 0 as the base address.

I don't know if request_region(0, ..) will fail, if so the
driver has been broken since 2006 and we should remove it
from the tree as it has no users.

Signed-off-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Joel Schopp <[email protected]>
Reviewed-by: Peter Huewe <[email protected]>
Signed-off-by: Peter Huewe <[email protected]>
---
drivers/char/tpm/tpm_atmel.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 99d6820..c9a528d 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -202,7 +202,7 @@ static int __init init_atmel(void)

have_region =
(atmel_request_region
- (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
+ (base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;

pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0);
if (IS_ERR(pdev)) {
--
1.7.5.4

2013-10-22 17:56:02

by Luigi Semenzato

[permalink] [raw]
Subject: Re: [tpmdd-devel] [PATCH 01/15] tpm: MAINTAINERS: Add myself as tpm maintainer

I completely support Peter's request, and many thanks to Peter for volunteering.

On Tue, Oct 22, 2013 at 10:53 AM, Peter Huewe <[email protected]> wrote:
> Since I'm actively maintaining the tpm subsystem for a few months now,
> it's time to step up and be an official maintainer for the tpm subsystem,
> atleast until I hear something different from my company.
>
> The maintaining is done solely in my private time, out of private interest.
> Speaking only on behalf of myself, trying to be as vendor neutral as possible.
>
> Signed-off-by: Peter Huewe <[email protected]>
> ---
> MAINTAINERS | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 4fde706..936adb4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8475,6 +8475,7 @@ F: drivers/media/usb/tm6000/
> TPM DEVICE DRIVER
> M: Leonidas Da Silva Barbosa <[email protected]>
> M: Ashley Lai <[email protected]>
> +M: Peter Huewe <[email protected]>
> M: Rajiv Andrade <[email protected]>
> W: http://tpmdd.sourceforge.net
> M: Marcel Selhorst <[email protected]>
> --
> 1.7.5.4
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> tpmdd-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

2013-10-22 19:22:22

by Ashley Lai

[permalink] [raw]
Subject: Re: [PATCH 01/15] tpm: MAINTAINERS: Add myself as tpm maintainer

On Tue, 2013-10-22 at 19:53 +0200, Peter Huewe wrote:
> Since I'm actively maintaining the tpm subsystem for a few months now,
> it's time to step up and be an official maintainer for the tpm subsystem,
> atleast until I hear something different from my company.
>
> The maintaining is done solely in my private time, out of private interest.
> Speaking only on behalf of myself, trying to be as vendor neutral as possible.
>
> Signed-off-by: Peter Huewe <[email protected]>
> ---
> MAINTAINERS | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 4fde706..936adb4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8475,6 +8475,7 @@ F: drivers/media/usb/tm6000/
> TPM DEVICE DRIVER
> M: Leonidas Da Silva Barbosa <[email protected]>
> M: Ashley Lai <[email protected]>
> +M: Peter Huewe <[email protected]>
> M: Rajiv Andrade <[email protected]>
> W: http://tpmdd.sourceforge.net
> M: Marcel Selhorst <[email protected]>

Peter has been a great help on maintaining the tpm driver. Thanks for
volunteering, you have my support on this.

--Ashley Lai

2013-10-22 19:29:06

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 01/15] tpm: MAINTAINERS: Add myself as tpm maintainer

On Tue, 2013-10-22 at 14:22 -0500, Ashley D Lai wrote:
> On Tue, 2013-10-22 at 19:53 +0200, Peter Huewe wrote:
> > Since I'm actively maintaining the tpm subsystem for a few months now,
> > it's time to step up and be an official maintainer for the tpm subsystem,
> > atleast until I hear something different from my company.
> >
> > The maintaining is done solely in my private time, out of private interest.
> > Speaking only on behalf of myself, trying to be as vendor neutral as possible.
> >
> > Signed-off-by: Peter Huewe <[email protected]>
> > ---
> > MAINTAINERS | 1 +
> > 1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 4fde706..936adb4 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -8475,6 +8475,7 @@ F: drivers/media/usb/tm6000/
> > TPM DEVICE DRIVER
> > M: Leonidas Da Silva Barbosa <[email protected]>
> > M: Ashley Lai <[email protected]>
> > +M: Peter Huewe <[email protected]>
> > M: Rajiv Andrade <[email protected]>
> > W: http://tpmdd.sourceforge.net
> > M: Marcel Selhorst <[email protected]>
>
> Peter has been a great help on maintaining the tpm driver. Thanks for
> volunteering, you have my support on this.

It'd be nice if all the M entries were clustered
together and probably nice too if the
W: http://www.sirrix.com
entry removed. I didn't notice anything useful
there about the driver.
Maybe there's a specific page about the driver
buried on the corporate website. If so, that
specific page should be linked instead.