Received: by 10.192.165.148 with SMTP id m20csp4513045imm; Tue, 8 May 2018 09:35:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpcQiqb/Nv/w0xONso1A4J8yPwTT2iqgF5Ud85hlJfhV6GNHWVOBerw1pIeLEKqsjGSL3BD X-Received: by 2002:a65:6215:: with SMTP id d21-v6mr10160090pgv.170.1525797303795; Tue, 08 May 2018 09:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525797303; cv=none; d=google.com; s=arc-20160816; b=qKk8RR9uW9KaMQIcGdTDiC8CwW6xsvV6v1MwLKnaAsTd1irZ/Qk7+S0Hae7+gGnzKJ +Vd2s/uyyDXM15+va3b86VQ4GVFeQGwOQzb/yQp10fmcchEgxmrJZtrVbP9qodQikhq+ iNRHaCe2CwuDKLOZjX77417WFh5+3XkEcSLs4v5BTK5JjfxCB/Y9QGgHrc1UAic/RDWd Dy1yjLvhYQy1so9aL+oUQQ5XAXGAKTpf2I5ZTPXW19C7caSRcpr5WDvHJSC6BZ9zTIA4 0Cla+etEi5K/HGheervM4Rkzd06Nb8RC+U0850Jfb0k6mA05j1pJHlm2kVoForNzD0DV 874A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=7aUkj+ZWKE8gUrOqS9W/gidnrlAy90AlkhH661tKN/8=; b=Oy9z635cL2HgSOcldEnKtLcoVhWv5iSS7LIfZouse/csjLDSzdJxWc3ouyEeU9qtuY CVzGDlflOQ3ob0sWoMXKwpgo0rsh+Wla5yLOxOubJOcu9GyCfYrsQhqFB2YyOLxFGZjC hykfuxawXZSbXdyCVlJy6k30SPJWiCDb2fbOc5CF56ONtAFM7cFcJAYeg6gIIeNVY+TP B3PTeiGsmvJO2V/tbNDVVwobtADrRbUj4n1xV/EfgvJ/9+0IDeyzo2AXK8GKMuOyXX/O hku9Ubu4gR3a004eUR8xaYkjB/v7KmXMnzWWjNZ9wGr74rkTKNRt6/1s2WftJtOmqTk4 0iSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eIBckZN+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18-v6si9959859pgv.306.2018.05.08.09.34.49; Tue, 08 May 2018 09:35:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eIBckZN+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932784AbeEHQeT (ORCPT + 99 others); Tue, 8 May 2018 12:34:19 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:45532 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755350AbeEHQeJ (ORCPT ); Tue, 8 May 2018 12:34:09 -0400 Received: by mail-pg0-f68.google.com with SMTP id w3-v6so874676pgv.12; Tue, 08 May 2018 09:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=7aUkj+ZWKE8gUrOqS9W/gidnrlAy90AlkhH661tKN/8=; b=eIBckZN+zK7/i+A4WgQ4yPQSYu00CVdn+pshZXex+7uORlIZoQRR3IvGpyuwJEpbU5 TLeItc8y5GR0EhbAINTYRTNS8qyAN3q2SGj/2l50TPDKjL9VjNV9rV16FBfDkPAMnfP/ IJU1ymcZeJLTFkp9VhLfS2BnESu2abV5RYaHa3O94y40RT7/wrn98bPMOu9LT6AxmqJQ gLX0JbaSeL8PAvve4uQVXPumXWURRYAfBvljeeCbQ/zpctiXlrwqEGJscAd6MlYHdVlJ eG8/lUnTblXIsYSOlMkXpVO8ZTlf7frydX6q3AwgndPwUmTaqtc8FJCAvk+k2LQTMEyj PB3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=7aUkj+ZWKE8gUrOqS9W/gidnrlAy90AlkhH661tKN/8=; b=DqVQp7TggEjLWICU3Ks8EyeKizb9zrc31TTaQVfUHJ5hkr9VIoUnNqHUyvaHgbP8Ej vnErRxZKI4nWemZr51zzQxF0o/FfMJ6oVRxD0XZn7SJVYZoHJ7GfTI5zGilqmRSiktwY 569Jdr3wq/hFjqv2LYEy8uBk2LjsLXE57xXDH5PxK7PuB1OWLslashrvAoFzIXRZu68O 368a/16W4UJDhoC+5VhR/7nMLBPaAxdwGncd+jwBXXMeZ94hWyJTrABkO7QqUKA2sD16 RhpjxT4b9c8mf8CXBKj7EoZ8lhWhhweYNQIFw6LInGNdIR9KCcRI9/tCFAkmgUqQsFLR ddDw== X-Gm-Message-State: ALQs6tCklEGKS+EBQRA110BkgGI+wcNMM7bP5D5xWy18YntyH08641EY tu0pYJAuboPRDPFWNrT/lks= X-Received: by 2002:a63:b80a:: with SMTP id p10-v6mr32976898pge.250.1525797248534; Tue, 08 May 2018 09:34:08 -0700 (PDT) Received: from JF-EN-C02V905BHTDF.tld ([12.111.169.54]) by smtp.gmail.com with ESMTPSA id j1sm55569849pfc.159.2018.05.08.09.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 09:34:07 -0700 (PDT) Subject: Re: [PATCH v3 2/2] tpm: reduce polling time to usecs for even finer granularity To: Nayna Jain , linux-integrity@vger.kernel.org Cc: zohar@linux.vnet.ibm.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, tpmdd@selhorst.net, jgunthorpe@obsidianresearch.com, patrickc@us.ibm.com References: <20180507160733.8817-1-nayna@linux.vnet.ibm.com> <20180507160733.8817-3-nayna@linux.vnet.ibm.com> From: J Freyensee Message-ID: Date: Tue, 8 May 2018 09:34:05 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180507160733.8817-3-nayna@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/7/18 9:07 AM, Nayna Jain wrote: > The TPM burstcount and status commands are supposed to return very > quickly [2][3]. This patch further reduces the TPM poll sleep time to usecs > in get_burstcount() and wait_for_tpm_stat() by calling usleep_range() > directly. > > After this change, performance on a system[1] with a TPM 1.2 with an 8 byte > burstcount for 1000 extends improved from ~10.7 sec to ~7 sec. > > [1] All tests are performed on an x86 based, locked down, single purpose > closed system. It has Infineon TPM 1.2 using LPC Bus. > > [2] From the TCG Specification "TCG PC Client Specific TPM Interface > Specification (TIS), Family 1.2": > > "NOTE : It takes roughly 330 ns per byte transfer on LPC. 256 bytes would > take 84 us, which is a long time to stall the CPU. Chipsets may not be > designed to post this much data to LPC; therefore, the CPU itself is > stalled for much of this time. Sending 1 kB would take 350 μs. Therefore, > even if the TPM_STS_x.burstCount field is a high value, software SHOULD > be interruptible during this period." > > [3] From the TCG Specification 2.0, "TCG PC Client Platform TPM Profile > (PTP) Specification": > > "It takes roughly 330 ns per byte transfer on LPC. 256 bytes would take > 84 us. Chipsets may not be designed to post this much data to LPC; > therefore, the CPU itself is stalled for much of this time. Sending 1 kB > would take 350 us. Therefore, even if the TPM_STS_x.burstCount field is a > high value, software should be interruptible during this period. For SPI, > assuming 20MHz clock and 64-byte transfers, it would take about 120 usec > to move 256B of data. Sending 1kB would take about 500 usec. If the > transactions are done using 4 bytes at a time, then it would take about > 1 msec. to transfer 1kB of data." > > Signed-off-by: Nayna Jain > Reviewed-by: Mimi Zohar > Reviewed-by: Jarkko Sakkinen > --- Acked-by: Jay Freyensee