All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] tpm tis: Do not print timeout messages twice
@ 2016-10-26 22:28 Jason Gunthorpe
       [not found] ` <1477520926-32594-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Jason Gunthorpe @ 2016-10-26 22:28 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

The tis driver does a tpm_get_timeouts out side of tpm_chip_register,
and tpm_get_timeouts can print a message, resulting in two prints, eg:

 tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 10000->750000us B 10000->2000000us C 10000->750000us D 10000->750000us

Keep track and prevent tpm_get_timeouts from running a second time, and
clarify the purpose of the call in tpm_tis_core to only be connected to
irq testing.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 drivers/char/tpm/tpm-interface.c |  7 +++++++
 drivers/char/tpm/tpm.h           |  1 +
 drivers/char/tpm/tpm_tis_core.c  | 20 ++++++++++----------
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index aef20ee2331a..d0285faa4f1b 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -505,6 +505,9 @@ int tpm_get_timeouts(struct tpm_chip *chip)
 	struct duration_t *duration_cap;
 	ssize_t rc;
 
+	if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS)
+		return 0;
+
 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
 		/* Fixed timeouts for TPM2 */
 		chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A);
@@ -517,6 +520,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)
 		    msecs_to_jiffies(TPM2_DURATION_MEDIUM);
 		chip->duration[TPM_LONG] =
 		    msecs_to_jiffies(TPM2_DURATION_LONG);
+
+		chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
 		return 0;
 	}
 
@@ -630,6 +635,8 @@ duration:
 		chip->duration_adjusted = true;
 		dev_info(&chip->dev, "Adjusting TPM timeout parameters.");
 	}
+
+	chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
 	return 0;
 }
 EXPORT_SYMBOL_GPL(tpm_get_timeouts);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index b0585e99da49..2611459271e5 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -143,6 +143,7 @@ enum tpm_chip_flags {
 	TPM_CHIP_FLAG_TPM2		= BIT(1),
 	TPM_CHIP_FLAG_IRQ		= BIT(2),
 	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
+	TPM_CHIP_FLAG_HAVE_TIMEOUTS	= BIT(4),
 };
 
 struct tpm_chip {
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index d66f51b3648e..193bee4d70e0 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -749,20 +749,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 	if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
 		dev_dbg(dev, "\tData Avail Int Support\n");
 
-	/* Very early on issue a command to the TPM in polling mode to make
-	 * sure it works. May as well use that command to set the proper
-	 *  timeouts for the driver.
-	 */
-	if (tpm_get_timeouts(chip)) {
-		dev_err(dev, "Could not get TPM timeouts and durations\n");
-		rc = -ENODEV;
-		goto out_err;
-	}
-
 	/* INTERRUPT Setup */
 	init_waitqueue_head(&priv->read_queue);
 	init_waitqueue_head(&priv->int_queue);
 	if (irq != -1) {
+		/* Before doing irq testing issue a command to the TPM in polling mode
+		 * to make sure it works. May as well use that command to set the
+		 * proper timeouts for the driver.
+		 */
+		if (tpm_get_timeouts(chip)) {
+			dev_err(dev, "Could not get TPM timeouts and durations\n");
+			rc = -ENODEV;
+			goto out_err;
+		}
+
 		if (irq) {
 			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
 						 irq);
-- 
2.1.4


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] tpm xen: Remove bogus tpm_chip_unregister
       [not found] ` <1477520926-32594-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-10-26 22:28   ` Jason Gunthorpe
       [not found]     ` <1477520926-32594-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2016-10-26 22:28   ` [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED Jason Gunthorpe
  2016-11-02 10:26   ` [PATCH 1/3] tpm tis: Do not print timeout messages twice Jarkko Sakkinen
  2 siblings, 1 reply; 10+ messages in thread
From: Jason Gunthorpe @ 2016-10-26 22:28 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

tpm_chip_unregister can only be called after tpm_chip_register.
devm manages the allocation so no unwind is needed here.

Fixes: afb5abc262e96 ("tpm: two-phase chip management functions")
---
 drivers/char/tpm/xen-tpmfront.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index 62028f483bba..a2ab00831df1 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -307,7 +307,6 @@ static int tpmfront_probe(struct xenbus_device *dev,
 	rv = setup_ring(dev, priv);
 	if (rv) {
 		chip = dev_get_drvdata(&dev->dev);
-		tpm_chip_unregister(chip);
 		ring_free(priv);
 		return rv;
 	}
-- 
2.1.4


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED
       [not found] ` <1477520926-32594-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2016-10-26 22:28   ` [PATCH 2/3] tpm xen: Remove bogus tpm_chip_unregister Jason Gunthorpe
@ 2016-10-26 22:28   ` Jason Gunthorpe
       [not found]     ` <1477520926-32594-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2016-11-02 10:26   ` [PATCH 1/3] tpm tis: Do not print timeout messages twice Jarkko Sakkinen
  2 siblings, 1 reply; 10+ messages in thread
From: Jason Gunthorpe @ 2016-10-26 22:28 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

This is no longer necessary, all calls to tpm_chip_unregister happen
in remove() callbacks.

Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
---
 drivers/char/tpm/tpm-chip.c | 5 -----
 drivers/char/tpm/tpm.h      | 1 -
 2 files changed, 6 deletions(-)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index e5950131bd90..836f056f7d27 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -375,8 +375,6 @@ int tpm_chip_register(struct tpm_chip *chip)
 		return rc;
 	}
 
-	chip->flags |= TPM_CHIP_FLAG_REGISTERED;
-
 	rc = tpm_add_legacy_sysfs(chip);
 	if (rc) {
 		tpm_chip_unregister(chip);
@@ -402,9 +400,6 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
  */
 void tpm_chip_unregister(struct tpm_chip *chip)
 {
-	if (!(chip->flags & TPM_CHIP_FLAG_REGISTERED))
-		return;
-
 	tpm_del_legacy_sysfs(chip);
 
 	tpm1_chip_unregister(chip);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 2611459271e5..79ce937ec557 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -139,7 +139,6 @@ enum tpm2_startup_types {
 #define TPM_PPI_VERSION_LEN		3
 
 enum tpm_chip_flags {
-	TPM_CHIP_FLAG_REGISTERED	= BIT(0),
 	TPM_CHIP_FLAG_TPM2		= BIT(1),
 	TPM_CHIP_FLAG_IRQ		= BIT(2),
 	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
-- 
2.1.4


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED
       [not found]     ` <1477520926-32594-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-10-27 20:35       ` Winkler, Tomas
  2016-11-02 10:33       ` Jarkko Sakkinen
  1 sibling, 0 replies; 10+ messages in thread
From: Winkler, Tomas @ 2016-10-27 20:35 UTC (permalink / raw)
  To: Jason Gunthorpe, Jarkko Sakkinen
  Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f


> 
> This is no longer necessary, all calls to tpm_chip_unregister happen in
> remove() callbacks.
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> ---
>  drivers/char/tpm/tpm-chip.c | 5 -----
>  drivers/char/tpm/tpm.h      | 1 -
>  2 files changed, 6 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index
> e5950131bd90..836f056f7d27 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -375,8 +375,6 @@ int tpm_chip_register(struct tpm_chip *chip)
>  		return rc;
>  	}
> 
> -	chip->flags |= TPM_CHIP_FLAG_REGISTERED;
> -
>  	rc = tpm_add_legacy_sysfs(chip);
>  	if (rc) {
>  		tpm_chip_unregister(chip);
> @@ -402,9 +400,6 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
>   */
>  void tpm_chip_unregister(struct tpm_chip *chip)  {
> -	if (!(chip->flags & TPM_CHIP_FLAG_REGISTERED))
> -		return;
> -
>  	tpm_del_legacy_sysfs(chip);
> 
>  	tpm1_chip_unregister(chip);
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index
> 2611459271e5..79ce937ec557 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -139,7 +139,6 @@ enum tpm2_startup_types {
>  #define TPM_PPI_VERSION_LEN		3
> 
>  enum tpm_chip_flags {
> -	TPM_CHIP_FLAG_REGISTERED	= BIT(0),
>  	TPM_CHIP_FLAG_TPM2		= BIT(1),
>  	TPM_CHIP_FLAG_IRQ		= BIT(2),
>  	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
> --
> 2.1.4
> 
Reviewed-by: Tomas Winkler <tomas.winkler-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] tpm tis: Do not print timeout messages twice
       [not found] ` <1477520926-32594-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2016-10-26 22:28   ` [PATCH 2/3] tpm xen: Remove bogus tpm_chip_unregister Jason Gunthorpe
  2016-10-26 22:28   ` [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED Jason Gunthorpe
@ 2016-11-02 10:26   ` Jarkko Sakkinen
  2016-11-04  7:21     ` [tpmdd-devel] " Jarkko Sakkinen
  2 siblings, 1 reply; 10+ messages in thread
From: Jarkko Sakkinen @ 2016-11-02 10:26 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Wed, Oct 26, 2016 at 04:28:44PM -0600, Jason Gunthorpe wrote:
> The tis driver does a tpm_get_timeouts out side of tpm_chip_register,
> and tpm_get_timeouts can print a message, resulting in two prints, eg:
> 
>  tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 10000->750000us B 10000->2000000us C 10000->750000us D 10000->750000us
> 
> Keep track and prevent tpm_get_timeouts from running a second time, and
> clarify the purpose of the call in tpm_tis_core to only be connected to
> irq testing.
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

Thanks for improving the comment. It makes a lot more sense now.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

/Jarkko

> ---
>  drivers/char/tpm/tpm-interface.c |  7 +++++++
>  drivers/char/tpm/tpm.h           |  1 +
>  drivers/char/tpm/tpm_tis_core.c  | 20 ++++++++++----------
>  3 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index aef20ee2331a..d0285faa4f1b 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -505,6 +505,9 @@ int tpm_get_timeouts(struct tpm_chip *chip)
>  	struct duration_t *duration_cap;
>  	ssize_t rc;
>  
> +	if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS)
> +		return 0;
> +
>  	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
>  		/* Fixed timeouts for TPM2 */
>  		chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A);
> @@ -517,6 +520,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)
>  		    msecs_to_jiffies(TPM2_DURATION_MEDIUM);
>  		chip->duration[TPM_LONG] =
>  		    msecs_to_jiffies(TPM2_DURATION_LONG);
> +
> +		chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
>  		return 0;
>  	}
>  
> @@ -630,6 +635,8 @@ duration:
>  		chip->duration_adjusted = true;
>  		dev_info(&chip->dev, "Adjusting TPM timeout parameters.");
>  	}
> +
> +	chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(tpm_get_timeouts);
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index b0585e99da49..2611459271e5 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -143,6 +143,7 @@ enum tpm_chip_flags {
>  	TPM_CHIP_FLAG_TPM2		= BIT(1),
>  	TPM_CHIP_FLAG_IRQ		= BIT(2),
>  	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
> +	TPM_CHIP_FLAG_HAVE_TIMEOUTS	= BIT(4),
>  };
>  
>  struct tpm_chip {
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index d66f51b3648e..193bee4d70e0 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -749,20 +749,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>  	if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
>  		dev_dbg(dev, "\tData Avail Int Support\n");
>  
> -	/* Very early on issue a command to the TPM in polling mode to make
> -	 * sure it works. May as well use that command to set the proper
> -	 *  timeouts for the driver.
> -	 */
> -	if (tpm_get_timeouts(chip)) {
> -		dev_err(dev, "Could not get TPM timeouts and durations\n");
> -		rc = -ENODEV;
> -		goto out_err;
> -	}
> -
>  	/* INTERRUPT Setup */
>  	init_waitqueue_head(&priv->read_queue);
>  	init_waitqueue_head(&priv->int_queue);
>  	if (irq != -1) {
> +		/* Before doing irq testing issue a command to the TPM in polling mode
> +		 * to make sure it works. May as well use that command to set the
> +		 * proper timeouts for the driver.
> +		 */
> +		if (tpm_get_timeouts(chip)) {
> +			dev_err(dev, "Could not get TPM timeouts and durations\n");
> +			rc = -ENODEV;
> +			goto out_err;
> +		}
> +
>  		if (irq) {
>  			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
>  						 irq);
> -- 
> 2.1.4
> 

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] tpm xen: Remove bogus tpm_chip_unregister
       [not found]     ` <1477520926-32594-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-11-02 10:30       ` Jarkko Sakkinen
       [not found]         ` <20161102103030.llb45xwnnlwokotm-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Jarkko Sakkinen @ 2016-11-02 10:30 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Wed, Oct 26, 2016 at 04:28:45PM -0600, Jason Gunthorpe wrote:
> tpm_chip_unregister can only be called after tpm_chip_register.
> devm manages the allocation so no unwind is needed here.
> 
> Fixes: afb5abc262e96 ("tpm: two-phase chip management functions")

Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

/Jarkko

> ---
>  drivers/char/tpm/xen-tpmfront.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
> index 62028f483bba..a2ab00831df1 100644
> --- a/drivers/char/tpm/xen-tpmfront.c
> +++ b/drivers/char/tpm/xen-tpmfront.c
> @@ -307,7 +307,6 @@ static int tpmfront_probe(struct xenbus_device *dev,
>  	rv = setup_ring(dev, priv);
>  	if (rv) {
>  		chip = dev_get_drvdata(&dev->dev);
> -		tpm_chip_unregister(chip);
>  		ring_free(priv);
>  		return rv;
>  	}
> -- 
> 2.1.4
> 

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED
       [not found]     ` <1477520926-32594-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2016-10-27 20:35       ` Winkler, Tomas
@ 2016-11-02 10:33       ` Jarkko Sakkinen
  2016-11-04  7:22         ` [tpmdd-devel] " Jarkko Sakkinen
  1 sibling, 1 reply; 10+ messages in thread
From: Jarkko Sakkinen @ 2016-11-02 10:33 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Wed, Oct 26, 2016 at 04:28:46PM -0600, Jason Gunthorpe wrote:
> This is no longer necessary, all calls to tpm_chip_unregister happen
> in remove() callbacks.
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

/Jarkko

> ---
>  drivers/char/tpm/tpm-chip.c | 5 -----
>  drivers/char/tpm/tpm.h      | 1 -
>  2 files changed, 6 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index e5950131bd90..836f056f7d27 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -375,8 +375,6 @@ int tpm_chip_register(struct tpm_chip *chip)
>  		return rc;
>  	}
>  
> -	chip->flags |= TPM_CHIP_FLAG_REGISTERED;
> -
>  	rc = tpm_add_legacy_sysfs(chip);
>  	if (rc) {
>  		tpm_chip_unregister(chip);
> @@ -402,9 +400,6 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
>   */
>  void tpm_chip_unregister(struct tpm_chip *chip)
>  {
> -	if (!(chip->flags & TPM_CHIP_FLAG_REGISTERED))
> -		return;
> -
>  	tpm_del_legacy_sysfs(chip);
>  
>  	tpm1_chip_unregister(chip);
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 2611459271e5..79ce937ec557 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -139,7 +139,6 @@ enum tpm2_startup_types {
>  #define TPM_PPI_VERSION_LEN		3
>  
>  enum tpm_chip_flags {
> -	TPM_CHIP_FLAG_REGISTERED	= BIT(0),
>  	TPM_CHIP_FLAG_TPM2		= BIT(1),
>  	TPM_CHIP_FLAG_IRQ		= BIT(2),
>  	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
> -- 
> 2.1.4
> 

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [tpmdd-devel] [PATCH 1/3] tpm tis: Do not print timeout messages twice
  2016-11-02 10:26   ` [PATCH 1/3] tpm tis: Do not print timeout messages twice Jarkko Sakkinen
@ 2016-11-04  7:21     ` Jarkko Sakkinen
  0 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2016-11-04  7:21 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: tpmdd-devel, linux-security-module, linux-kernel

On Wed, Nov 02, 2016 at 04:26:17AM -0600, Jarkko Sakkinen wrote:
> On Wed, Oct 26, 2016 at 04:28:44PM -0600, Jason Gunthorpe wrote:
> > The tis driver does a tpm_get_timeouts out side of tpm_chip_register,
> > and tpm_get_timeouts can print a message, resulting in two prints, eg:
> > 
> >  tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 10000->750000us B 10000->2000000us C 10000->750000us D 10000->750000us
> > 
> > Keep track and prevent tpm_get_timeouts from running a second time, and
> > clarify the purpose of the call in tpm_tis_core to only be connected to
> > irq testing.
> > 
> > Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> 
> Thanks for improving the comment. It makes a lot more sense now.
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> /Jarkko

Applied.

/Jarkko

> 
> > ---
> >  drivers/char/tpm/tpm-interface.c |  7 +++++++
> >  drivers/char/tpm/tpm.h           |  1 +
> >  drivers/char/tpm/tpm_tis_core.c  | 20 ++++++++++----------
> >  3 files changed, 18 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> > index aef20ee2331a..d0285faa4f1b 100644
> > --- a/drivers/char/tpm/tpm-interface.c
> > +++ b/drivers/char/tpm/tpm-interface.c
> > @@ -505,6 +505,9 @@ int tpm_get_timeouts(struct tpm_chip *chip)
> >  	struct duration_t *duration_cap;
> >  	ssize_t rc;
> >  
> > +	if (chip->flags & TPM_CHIP_FLAG_HAVE_TIMEOUTS)
> > +		return 0;
> > +
> >  	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> >  		/* Fixed timeouts for TPM2 */
> >  		chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A);
> > @@ -517,6 +520,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)
> >  		    msecs_to_jiffies(TPM2_DURATION_MEDIUM);
> >  		chip->duration[TPM_LONG] =
> >  		    msecs_to_jiffies(TPM2_DURATION_LONG);
> > +
> > +		chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
> >  		return 0;
> >  	}
> >  
> > @@ -630,6 +635,8 @@ duration:
> >  		chip->duration_adjusted = true;
> >  		dev_info(&chip->dev, "Adjusting TPM timeout parameters.");
> >  	}
> > +
> > +	chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL_GPL(tpm_get_timeouts);
> > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> > index b0585e99da49..2611459271e5 100644
> > --- a/drivers/char/tpm/tpm.h
> > +++ b/drivers/char/tpm/tpm.h
> > @@ -143,6 +143,7 @@ enum tpm_chip_flags {
> >  	TPM_CHIP_FLAG_TPM2		= BIT(1),
> >  	TPM_CHIP_FLAG_IRQ		= BIT(2),
> >  	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
> > +	TPM_CHIP_FLAG_HAVE_TIMEOUTS	= BIT(4),
> >  };
> >  
> >  struct tpm_chip {
> > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > index d66f51b3648e..193bee4d70e0 100644
> > --- a/drivers/char/tpm/tpm_tis_core.c
> > +++ b/drivers/char/tpm/tpm_tis_core.c
> > @@ -749,20 +749,20 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
> >  	if (intfcaps & TPM_INTF_DATA_AVAIL_INT)
> >  		dev_dbg(dev, "\tData Avail Int Support\n");
> >  
> > -	/* Very early on issue a command to the TPM in polling mode to make
> > -	 * sure it works. May as well use that command to set the proper
> > -	 *  timeouts for the driver.
> > -	 */
> > -	if (tpm_get_timeouts(chip)) {
> > -		dev_err(dev, "Could not get TPM timeouts and durations\n");
> > -		rc = -ENODEV;
> > -		goto out_err;
> > -	}
> > -
> >  	/* INTERRUPT Setup */
> >  	init_waitqueue_head(&priv->read_queue);
> >  	init_waitqueue_head(&priv->int_queue);
> >  	if (irq != -1) {
> > +		/* Before doing irq testing issue a command to the TPM in polling mode
> > +		 * to make sure it works. May as well use that command to set the
> > +		 * proper timeouts for the driver.
> > +		 */
> > +		if (tpm_get_timeouts(chip)) {
> > +			dev_err(dev, "Could not get TPM timeouts and durations\n");
> > +			rc = -ENODEV;
> > +			goto out_err;
> > +		}
> > +
> >  		if (irq) {
> >  			tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
> >  						 irq);
> > -- 
> > 2.1.4
> > 
> 
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [tpmdd-devel] [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED
  2016-11-02 10:33       ` Jarkko Sakkinen
@ 2016-11-04  7:22         ` Jarkko Sakkinen
  0 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2016-11-04  7:22 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: tpmdd-devel, linux-security-module, linux-kernel

On Wed, Nov 02, 2016 at 04:33:03AM -0600, Jarkko Sakkinen wrote:
> On Wed, Oct 26, 2016 at 04:28:46PM -0600, Jason Gunthorpe wrote:
> > This is no longer necessary, all calls to tpm_chip_unregister happen
> > in remove() callbacks.
> > 
> > Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> /Jarkko

Applied.

/Jarkko

> 
> > ---
> >  drivers/char/tpm/tpm-chip.c | 5 -----
> >  drivers/char/tpm/tpm.h      | 1 -
> >  2 files changed, 6 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> > index e5950131bd90..836f056f7d27 100644
> > --- a/drivers/char/tpm/tpm-chip.c
> > +++ b/drivers/char/tpm/tpm-chip.c
> > @@ -375,8 +375,6 @@ int tpm_chip_register(struct tpm_chip *chip)
> >  		return rc;
> >  	}
> >  
> > -	chip->flags |= TPM_CHIP_FLAG_REGISTERED;
> > -
> >  	rc = tpm_add_legacy_sysfs(chip);
> >  	if (rc) {
> >  		tpm_chip_unregister(chip);
> > @@ -402,9 +400,6 @@ EXPORT_SYMBOL_GPL(tpm_chip_register);
> >   */
> >  void tpm_chip_unregister(struct tpm_chip *chip)
> >  {
> > -	if (!(chip->flags & TPM_CHIP_FLAG_REGISTERED))
> > -		return;
> > -
> >  	tpm_del_legacy_sysfs(chip);
> >  
> >  	tpm1_chip_unregister(chip);
> > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> > index 2611459271e5..79ce937ec557 100644
> > --- a/drivers/char/tpm/tpm.h
> > +++ b/drivers/char/tpm/tpm.h
> > @@ -139,7 +139,6 @@ enum tpm2_startup_types {
> >  #define TPM_PPI_VERSION_LEN		3
> >  
> >  enum tpm_chip_flags {
> > -	TPM_CHIP_FLAG_REGISTERED	= BIT(0),
> >  	TPM_CHIP_FLAG_TPM2		= BIT(1),
> >  	TPM_CHIP_FLAG_IRQ		= BIT(2),
> >  	TPM_CHIP_FLAG_VIRTUAL		= BIT(3),
> > -- 
> > 2.1.4
> > 
> 
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] tpm xen: Remove bogus tpm_chip_unregister
       [not found]         ` <20161102103030.llb45xwnnlwokotm-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2016-11-04  7:23           ` Jarkko Sakkinen
  0 siblings, 0 replies; 10+ messages in thread
From: Jarkko Sakkinen @ 2016-11-04  7:23 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Wed, Nov 02, 2016 at 04:30:30AM -0600, Jarkko Sakkinen wrote:
> On Wed, Oct 26, 2016 at 04:28:45PM -0600, Jason Gunthorpe wrote:
> > tpm_chip_unregister can only be called after tpm_chip_register.
> > devm manages the allocation so no unwind is needed here.
> > 
> > Fixes: afb5abc262e96 ("tpm: two-phase chip management functions")
> 
> Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> 
> /Jarkko

Applied.

/Jarkko

> 
> > ---
> >  drivers/char/tpm/xen-tpmfront.c | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
> > index 62028f483bba..a2ab00831df1 100644
> > --- a/drivers/char/tpm/xen-tpmfront.c
> > +++ b/drivers/char/tpm/xen-tpmfront.c
> > @@ -307,7 +307,6 @@ static int tpmfront_probe(struct xenbus_device *dev,
> >  	rv = setup_ring(dev, priv);
> >  	if (rv) {
> >  		chip = dev_get_drvdata(&dev->dev);
> > -		tpm_chip_unregister(chip);
> >  		ring_free(priv);
> >  		return rv;
> >  	}
> > -- 
> > 2.1.4
> > 
> 
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-11-04  7:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-26 22:28 [PATCH 1/3] tpm tis: Do not print timeout messages twice Jason Gunthorpe
     [not found] ` <1477520926-32594-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-10-26 22:28   ` [PATCH 2/3] tpm xen: Remove bogus tpm_chip_unregister Jason Gunthorpe
     [not found]     ` <1477520926-32594-2-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-02 10:30       ` Jarkko Sakkinen
     [not found]         ` <20161102103030.llb45xwnnlwokotm-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-11-04  7:23           ` Jarkko Sakkinen
2016-10-26 22:28   ` [PATCH 3/3] tpm: Get rid of TPM_CHIP_FLAG_REGISTERED Jason Gunthorpe
     [not found]     ` <1477520926-32594-3-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-10-27 20:35       ` Winkler, Tomas
2016-11-02 10:33       ` Jarkko Sakkinen
2016-11-04  7:22         ` [tpmdd-devel] " Jarkko Sakkinen
2016-11-02 10:26   ` [PATCH 1/3] tpm tis: Do not print timeout messages twice Jarkko Sakkinen
2016-11-04  7:21     ` [tpmdd-devel] " Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.