Received: by 10.192.165.148 with SMTP id m20csp4861741imm; Tue, 24 Apr 2018 09:32:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+AOjhEAu90wk7AlXSamseCp3ZokvNHB/ozMa6G7EJrKw8SFsqqb3cg5Jko4hEXDIoy07Ry X-Received: by 10.101.65.77 with SMTP id x13mr11045420pgp.223.1524587535135; Tue, 24 Apr 2018 09:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524587535; cv=none; d=google.com; s=arc-20160816; b=PIvTN3C0pXeNfQaJ+P+mFYJTVVrdw934jF9+oB9mtTDyJJJ5ldRQBaPqUAnDDFyDhq zjZnRuAbyCAohc7kBHLMCkpB6RykEL/xvh8ueLAt5t0qLqe/MeJbhDx3fF2m6Ubf5PdF G6SlgJihYcr0i2Lz8Eh0w6kV+vAAoTFTzjM2wMYHXM1g5t4MiCCh6w6+xZS7b6ETt3Pz nWqCPLAlRT0n9F3G62/2GFk3mofQS/4CsvAVmHEPaKEVY4DxOJp2FEhSvZW9Nze5wDy8 FHBSDZD+QXIofd8T+3tDBKB4xUyg9/FVi2rKhNNNJE7mcc7Z0tycnA7aoEVqlC4H8uZA p9bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=ieeRkRiWFhcLEDCKrAc7jc8uNhm6bIyRAtSWPLAO6CU=; b=n5S1nwKje1hj8a0u5dlft33nyHAYCIwnwzJ9MNchXjV8FyIV6/yJyUb5pGmWMc4Yy/ izZgdbNDt5Zl2whkjtKSsabin4+mWceAS1TlxhNzu62cBBlQ2Nx1DDmFXUEdGcKMiCwC VmkoJNhj8nFcTGu/eZsQAcc3AQ62aZEdTVeETNxE1ie733kAVAxAsN3aITpOB7uoj22p 4lW1LSHLNxiwt0KLjEGz9rf2SOHTpbXTYG4u2QVHqFrbjDUnkSlMPJJDoGBDTe/P/pX3 VpPMYZcrlHpOV7wLPTXUPwC1Yx7s9zInWH3L5TfcdxB6a89gdJIIKicheWjAHwb94sNo PHMA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j84si9485843pfk.203.2018.04.24.09.32.00; Tue, 24 Apr 2018 09:32:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751535AbeDXQa7 (ORCPT + 99 others); Tue, 24 Apr 2018 12:30:59 -0400 Received: from mga01.intel.com ([192.55.52.88]:3592 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750814AbeDXQa6 (ORCPT ); Tue, 24 Apr 2018 12:30:58 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2018 09:30:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,323,1520924400"; d="scan'208";a="48732645" Received: from clanggaa-mobl.ger.corp.intel.com (HELO localhost) ([10.249.254.59]) by fmsmga004.fm.intel.com with ESMTP; 24 Apr 2018 09:30:53 -0700 Date: Tue, 24 Apr 2018 19:30:52 +0300 From: Jarkko Sakkinen To: Nayna Jain Cc: linux-integrity@vger.kernel.org, zohar@linux.vnet.ibm.com, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, tpmdd@selhorst.net, jgunthorpe@obsidianresearch.com, patrickc@us.ibm.com Subject: Re: [PATCH v2 2/2] tpm: reduce polling time to usecs for even finer granularity Message-ID: <20180424163052.GD5119@linux.intel.com> References: <20180417131246.434-1-nayna@linux.vnet.ibm.com> <20180417131246.434-3-nayna@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180417131246.434-3-nayna@linux.vnet.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 17, 2018 at 09:12:46AM -0400, Nayna Jain wrote: > The TPM burstcount and status commands are supposed to return very > quickly [1][2]. 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 TPM 1.2 with an 8 byte burstcount for > 1000 extends improved from ~10.7 sec to ~7 sec. > > [1] From 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." > > [2] From 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 Great, thanks for finding those references. Kind of stuff that I will forget within months and have to revisit with git blame/log :-) Reviewed-by: Jarkko Sakkinen /Jarkko