Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp564099imm; Wed, 17 Oct 2018 04:58:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV61nopF1olVTEG15mcc3/2cL16n0KFmLaFmzo06WWM1kKxKwv52LaFHCwZaW8iCUJiTetYuW X-Received: by 2002:a65:4d03:: with SMTP id i3-v6mr24224320pgt.239.1539777517164; Wed, 17 Oct 2018 04:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539777517; cv=none; d=google.com; s=arc-20160816; b=rLzsPA4G5Rz2xZD67F0ztrYWkxJIdGJVkUXXZhieJjWvaviYvLClSO5h/qhj3dKGjH fDSyvUfwCmNLDffiJpM+So4BR1MdtVF5Et4v0yUtXEuxBbEs9d2H/oGVH2DRGnubymMI OEVdfGmzhdt3j6BeMrjflG6GqgAoWSfpxHiwqmHuyOcdFfxLDdcz5pUfYB9nH4l/Eg0g haRX+eswR8VQETNUDIlbv58N0sHjR1rdcANcS8Bw6wEcANgGUWzXjBlxghGi5y269zBz Y4+li6jMW9I6mUBsUvv9q3MlTNRn9JjoAnRgWW7jnBYAFn2hzKBtbekCqTTU2XDydYq1 EmCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject; bh=Ntbkv0GNnZdk9hhhxIEwQ5NUTlwwaxL6+W1WNu7HynA=; b=AEabHrW3jXSaNj3jg1CdvOCt8jxBGfWISzS0TjVP6+x8JK2Fmz2UVl4cX1fdTuUkyv l8x+89I0xoEYqoT/CqrHvTjvKA4924yT1fmTXfhxM64cwN8H2myg2CfjrqtcjU60X2xJ 5Kf1NcS2509VWZXNr4LUjInkWFqDDYN49XAKPhaU0RwggVliLdc9hN49kbKYn+vsRE66 GRL2FO1hxpKeFPJWBWvcBNaEWl1adpVHQ+o0qgotZW/UrN0gUxrEXFTaSSGztnigO3RO zonzzz48aRIOGE8kF191Tv005aLs3NxuKD+gt4XKUYeR2/tNK2FyIRf9jyIOKNfxy1/Z B29A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si15888852plo.418.2018.10.17.04.58.21; Wed, 17 Oct 2018 04:58:37 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbeJQTxM (ORCPT + 99 others); Wed, 17 Oct 2018 15:53:12 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51938 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbeJQTxM (ORCPT ); Wed, 17 Oct 2018 15:53:12 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9HBnVD9100282 for ; Wed, 17 Oct 2018 07:57:48 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n638dus1c-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Oct 2018 07:57:48 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 17 Oct 2018 07:57:47 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 17 Oct 2018 07:57:42 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9HBvfvw46137520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Oct 2018 11:57:41 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D6A8AC059; Wed, 17 Oct 2018 11:57:41 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79209AC05B; Wed, 17 Oct 2018 11:57:38 +0000 (GMT) Received: from [9.79.213.117] (unknown [9.79.213.117]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 17 Oct 2018 11:57:38 +0000 (GMT) Subject: Re: [PATCH v6 03/20] tpm: factor out tpm 1.x duration calculation to tpm1-cmd.c To: Tomas Winkler , Jarkko Sakkinen , Jason Gunthorpe Cc: Nayna Jain , Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org References: <20181017064613.19746-1-tomas.winkler@intel.com> <20181017064613.19746-4-tomas.winkler@intel.com> From: Nayna Jain Date: Wed, 17 Oct 2018 17:24:34 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20181017064613.19746-4-tomas.winkler@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18101711-0072-0000-0000-000003B712FE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009891; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000268; SDB=6.01103954; UDB=6.00571464; IPR=6.00884006; MB=3.00023791; MTD=3.00000008; XFM=3.00000015; UTC=2018-10-17 11:57:45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101711-0073-0000-0000-000049C96131 Message-Id: <05fea3e6-91a3-b508-83c0-d8f06d6bbd5c@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-16_14:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/17/2018 12:15 PM, Tomas Winkler wrote: > diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c > index caa86b19c76d..5d20e98b844f 100644 > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c > @@ -370,6 +370,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) > struct i2c_client *client = to_i2c_client(dev); > u32 ordinal; > size_t count = 0; > + unsigned long duration; > int burst_count, bytes2write, retries, rc = -EIO; > > for (retries = 0; retries < TPM_RETRY; retries++) { > @@ -455,12 +456,11 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) > return rc; > } > ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); > - rc = i2c_nuvoton_wait_for_data_avail(chip, > - tpm_calc_ordinal_duration(chip, > - ordinal), > - &priv->read_queue); > + duration = tpm1_calc_ordinal_duration(chip, ordinal); This version of the patch didn't address my previous comment - "The original code in the nuvoton driver does not differentiate between TPM 1.2 and TPM 2.0 as it does in tpm_tis_core.c. Before making any changes, I would first fix it, so that it could easily be backported. Only then do the refactoring." Thanks & Regards,    - Nayna > + rc = i2c_nuvoton_wait_for_data_avail(chip, duration, &priv->read_queue); > if (rc) { > - dev_err(dev, "%s() timeout command duration\n", __func__); > + dev_err(dev, "%s() timeout command duration %ld\n", > + __func__, duration); > i2c_nuvoton_ready(chip); > return rc; > } > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index d2345d9fd7b5..14c332104de4 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -476,7 +476,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len) > if (chip->flags & TPM_CHIP_FLAG_TPM2) > dur = tpm2_calc_ordinal_duration(chip, ordinal); > else > - dur = tpm_calc_ordinal_duration(chip, ordinal); > + dur = tpm1_calc_ordinal_duration(chip, ordinal); > > if (wait_for_tpm_stat > (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur, > diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c > index b150f87f38f5..77097229bf49 100644 > --- a/drivers/char/tpm/xen-tpmfront.c > +++ b/drivers/char/tpm/xen-tpmfront.c > @@ -164,7 +164,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) > notify_remote_via_evtchn(priv->evtchn); > > ordinal = be32_to_cpu(((struct tpm_input_header*)buf)->ordinal); > - duration = tpm_calc_ordinal_duration(chip, ordinal); > + duration = tpm1_calc_ordinal_duration(chip, ordinal); > > if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration, > &priv->read_queue, true) < 0) {