All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Snitselaar <jsnitsel@redhat.com>
To: Laurent Bigonville <bigon@debian.org>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	Alexander.Steffen@infineon.com, linux-integrity@vger.kernel.org
Subject: Re: [tpmdd-devel] tpm device not showing up in /dev anymore
Date: Thu, 3 May 2018 10:43:11 -0700	[thread overview]
Message-ID: <20180503174311.d7bejzqjclvdcfyn@cantor> (raw)
In-Reply-To: <471775d9-374a-a97b-dacd-a4ca2beb56eb@debian.org>

On Thu May 03 18, Laurent Bigonville wrote:
>Le 15/03/18 a 17:24, Jarkko Sakkinen a ecrit :
>>On Fri, 2018-03-09 at 18:24 +0100, Laurent Bigonville wrote:
>>>The duration that that was in your patch seems to work, cannot this be
>>>implemented?
>>>
>>>I'm quite surprised I'm the only one impacted by this...
>>Sorry it took so long time response but I had forgotten so too many
>>details.
>>
>>After re-reading (PHEW!) the whole thread I'm thinking if we could
>>use section 5.5.2.4 as a reference to select a timeout of TIMEOUT_A
>>(albeit it is for request locality) and use Jerry's suggestion to
>>put wait_for_tpm_stat() there? Opinions?
>Hey,
>
>Sorry to bother you again, but are there any progress on getting this 
>mainlined?
>
>Kind regards,
>
>Laurent Bigonville

Jarkko would something like this work? Building it to test on tpm2.0 system right now.
I don't have access to a system with a tpm1.2 tis device at the moment. I tested a
patch similar to this based on the slightly older code that is currently in the
rhel kernel and it seemed work fine. release_locality was still a void function
back then, so might have to think more about the return values here and checking
them. Also wondering if release_locality, check_locality, and wait_for_tpm_stat
can be refactored since they would all have basically the same chunk of code.

Jerry

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 5a1f47b43947..31ee154450eb 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -143,12 +143,56 @@ static bool check_locality(struct tpm_chip *chip, int l)
        return false;
 }
 
+static bool locality_inactive(struct tpm_chip *chip, int l)
+{
+       struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
+       int rc;
+       u8 access;
+
+       rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access);
+       if (rc < 0)
+               return false;
+
+       if ((access & (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) == TPM_ACCESS_VALID)
+               return true;
+
+       return false;
+}
+
 static int release_locality(struct tpm_chip *chip, int l)
 {
        struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
+       unsigned long stop, timeout;
+       long rc;
 
        tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY);
 
+       stop = jiffies + chip->timeout_a;
+
+       if (chip->flags & TPM_CHIP_FLAG_IRQ) {
+again:
+               timeout = stop - jiffies;
+               if ((long)timeout <= 0)
+                       return -1;
+
+               rc = wait_event_interruptible_timeout(priv->int_queue,
+                                                     (locality_inactive(chip, l)),
+                                                     timeout);
+
+               if (rc > 0)
+                       return rc;
+
+               if (rc == -ERESTARTSYS && freezing(current)) {
+                       clear_thread_flag(TIF_SIGPENDING);
+                       goto again;
+               }
+       } else {
+               do {
+                       if (locality_inactive(chip, l))
+                               return 0;
+                       tpm_msleep(TPM_TIMEOUT);
+               } while (time_before(jiffies, stop));
+       }
        return 0;
 }

  reply	other threads:[~2018-05-03 17:43 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 11:28 tpm device not showing up in /dev anymore Laurent Bigonville
     [not found] ` <f9526f55-df96-64fc-a4d6-877ce04e7156-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2017-08-29 16:00   ` Alexander.Steffen-d0qZbvYSIPpWk0Htik3J/w
     [not found]     ` <dcad0104c46d4d5f88e642862bdb42c2-nFblLGNE8XKJSz+rYg/bSJowlv4uC7bZ@public.gmane.org>
2017-08-29 16:35       ` Laurent Bigonville
     [not found]         ` <47c4300b-8701-79a6-1c58-3a5853f4c5e3-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2017-08-29 17:39           ` Peter Huewe
2017-08-29 18:55           ` Laurent Bigonville
     [not found]             ` <595efb25-8d87-f39d-037f-9c9a98462339-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2017-08-31 12:10               ` Alexander.Steffen-d0qZbvYSIPpWk0Htik3J/w
     [not found]                 ` <857106e4bb864bb8a68b1381fffc8f50-nFblLGNE8XKJSz+rYg/bSJowlv4uC7bZ@public.gmane.org>
2017-08-31 16:40                   ` Jerry Snitselaar
2017-09-01 12:10                     ` Laurent Bigonville
     [not found]                       ` <0d9be244-ace0-030d-6ff9-c4e94c63b7e9-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2017-09-06  4:05                         ` Jarkko Sakkinen
2017-10-14  8:13                           ` [tpmdd-devel] " Jerry Snitselaar
2017-10-14  8:13                             ` Jerry Snitselaar
2017-10-21  8:53                             ` [tpmdd-devel] " Laurent Bigonville
2017-10-21  8:53                               ` Laurent Bigonville
2017-10-23 13:23                               ` [tpmdd-devel] " Jarkko Sakkinen
2017-10-23 13:23                                 ` Jarkko Sakkinen
2017-10-23 13:45                                 ` [tpmdd-devel] " Jerry Snitselaar
2017-10-23 13:45                                   ` Jerry Snitselaar
2017-10-23 13:48                                   ` [tpmdd-devel] " Laurent Bigonville
2017-10-23 13:48                                     ` Laurent Bigonville
2017-10-24 13:51                                   ` [tpmdd-devel] " Jarkko Sakkinen
2017-10-24 13:51                                     ` Jarkko Sakkinen
2017-10-24 14:57                                     ` [tpmdd-devel] " Jerry Snitselaar
2017-10-24 14:57                                       ` Jerry Snitselaar
2017-10-24 16:07                                       ` [tpmdd-devel] " Jarkko Sakkinen
2017-10-24 16:07                                         ` Jarkko Sakkinen
2017-11-09  0:04                                         ` [tpmdd-devel] " Laurent Bigonville
2017-11-09  0:04                                           ` Laurent Bigonville
2017-11-09 19:58                                           ` [tpmdd-devel] " Laurent Bigonville
2017-11-09 19:58                                             ` Laurent Bigonville
2017-11-09 23:50                                             ` [tpmdd-devel] " Jerry Snitselaar
2017-11-09 23:50                                               ` Jerry Snitselaar
2017-11-10  2:19                                               ` [tpmdd-devel] " Jerry Snitselaar
2017-11-10  2:19                                                 ` Jerry Snitselaar
2017-11-10  0:28                                             ` [tpmdd-devel] " Jerry Snitselaar
2017-11-10  7:07                                               ` Jerry Snitselaar
2017-11-10  8:21                                                 ` Laurent Bigonville
2017-11-10 20:53                                                   ` Jerry Snitselaar
2017-11-11 15:45                                                     ` Jason Gunthorpe
2017-11-11 19:12                                                       ` Jerry Snitselaar
2017-11-11 19:46                                                         ` Jason Gunthorpe
2017-11-11 20:31                                                           ` Jerry Snitselaar
2017-11-14  0:26                                                             ` Laurent Bigonville
2017-11-14  2:45                                                               ` Jason Gunthorpe
2017-11-14 14:59                                                             ` Jarkko Sakkinen
2017-11-14 15:17                                                               ` James Bottomley
2017-11-17 13:16                                                                 ` Jarkko Sakkinen
2018-01-02 23:54                                                                   ` Laurent Bigonville
2018-01-03  0:33                                                                     ` Jerry Snitselaar
2018-01-05 19:01                                                                       ` Laurent Bigonville
2018-02-09 10:53                                                                       ` Laurent Bigonville
2018-02-14 11:44                                                                         ` Jarkko Sakkinen
2018-03-09 17:24                                                                           ` Laurent Bigonville
2018-03-15 16:24                                                                             ` Jarkko Sakkinen
2018-05-03 11:38                                                                               ` Laurent Bigonville
2018-05-03 17:43                                                                                 ` Jerry Snitselaar [this message]
2018-05-04  8:20                                                                                   ` Jarkko Sakkinen
2018-05-04  8:18                                                                                 ` Jarkko Sakkinen
2018-05-04 14:22                                                                                   ` Jerry Snitselaar
2017-11-14 14:55                                                           ` Jarkko Sakkinen
2017-11-14 14:43                                                     ` Jarkko Sakkinen
2017-10-25  8:04                                     ` Laurent Bigonville
2017-10-25  8:04                                       ` Laurent Bigonville

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180503174311.d7bejzqjclvdcfyn@cantor \
    --to=jsnitsel@redhat.com \
    --cc=Alexander.Steffen@infineon.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=bigon@debian.org \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.