Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp6507ybm; Wed, 27 May 2020 17:32:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjXdNfCjujSzJa3CdG2JcaA4LoLn+7hzEMdpZ7Ztua4hEGT67F3JfDZOwIRmRP+tQVFl5b X-Received: by 2002:a17:906:6843:: with SMTP id a3mr754721ejs.245.1590625977844; Wed, 27 May 2020 17:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590625977; cv=none; d=google.com; s=arc-20160816; b=TfQBAKS1wRD+AHZJApo40HsNF8/gET42dPIwlEnewc4Owa1c9QXD7mgoM0a2mouZre 7bMwynIXE+zGJup2aRY00m2I2cfs9Y4FSe1CV6Cbv7mPH3vzYaRxu2kFg/Fx7SUzg9js ihCwB1SSDrn6MPjZV2BkaA9zNV6uGUW1Qz8KfAYhMRhf3kS6OIXxiHTSOe/o+Kvt8D1o Jmpol6ytiCjeyHJN8vVjcQw5pN+B4eu4Z+/qWCTGFCmGGPwHta3esO+QWOM9IDz8yi5u QlXXk5zenCrCn4fYjDEytZbn+pgfPPgk5G8YutTJixe65yYaZOKR+y073gsjd0UOFcnq bSGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=hfW9CN86kdzx1iKXuLJ+3YE1Y82VpglqQ4pEelTax4Q=; b=jfzqSdClz1O5mXTH69Oq80xcEcaxdrsikkw3itr2NPtysumj8EgPfZTuVPgRZ0cQAr NQN6pl/TQuKOgEuqGxTwGIq66k8MtTHK2IoE6f3yq5PKhZvLaQM4o/GuLZYbG6TW+p5s QkQY8GfOAKwptqrJasCF1YSZ54M0F8rLGv84vISn1qtjdIVzM/bNYTRcD7svHV9KukzC zEmMImhajOPHW6Rs0/LFdb4v8qn0coElg6QIPheXaA+EeoiRmudmywyXVHLVXitPkFIq /PZ+Dhp82nhUWfjXlVUuQZRAJuez+s8xQHGM7WLRxdbzLi9eyBlInPWVe40NpuH4HlQ7 95ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 93si2384879edg.247.2020.05.27.17.32.34; Wed, 27 May 2020 17:32:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725836AbgE1Aas (ORCPT + 99 others); Wed, 27 May 2020 20:30:48 -0400 Received: from mga12.intel.com ([192.55.52.136]:57832 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgE1Aar (ORCPT ); Wed, 27 May 2020 20:30:47 -0400 IronPort-SDR: Nf0hnbVkzV4qm0gf4RXdfSt8l9f2ggJsYAprXsMyx22I/+LeCpQs3hmth95FCVOiig2FhsOz8l Rf53bDaiLVtQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2020 17:30:47 -0700 IronPort-SDR: S5SHPJ+Xm9MoDJC2vdZQKMQRCVIFpatQk41EKWiDygVs/pRpCjTwu5JB6USmIjrcM6ENgUtKeE lV6QGat+m/gQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,443,1583222400"; d="scan'208";a="302284465" Received: from ederaloi-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.44.51]) by fmsmga002.fm.intel.com with ESMTP; 27 May 2020 17:30:42 -0700 Date: Thu, 28 May 2020 03:30:40 +0300 From: Jarkko Sakkinen To: Tadeusz Struk Cc: James Bottomley , Mario Limonciello , Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Jeffrin Jose T , Alex Guzman Subject: Re: [PATCH] tpm: Revert "tpm: fix invalid locking in NONBLOCKING mode" Message-ID: <20200528003040.GA4781@linux.intel.com> References: <20200526183213.20720-1-mario.limonciello@dell.com> <1590520454.11810.40.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 26, 2020 at 12:39:37PM -0700, Tadeusz Struk wrote: > On 5/26/20 12:14 PM, James Bottomley wrote: > > + /* atomic tpm command send and result receive. We only hold the ops > > + * lock during this period so that the tpm can be unregistered even if > > + * the char dev is held open. > > + */ > > + if (tpm_try_get_ops(priv->chip)) { > > + ret = -EPIPE; > > + goto out; > > + } > > + > Hi James, > This won't help if the message is read by an async tcti. If the problem lies > in the chip get locality code, perhaps this could help to debug the root-cause > instead of masking it out in the upper layer code: What is TCTI and async TCTI? Not following. > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index 2435216bd10a..da5ecd0376bf 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -202,20 +202,22 @@ static int request_locality(struct tpm_chip *chip, int l) > return rc; > > stop = jiffies + chip->timeout_a; > + timeout = stop - jiffies; > > if (chip->flags & TPM_CHIP_FLAG_IRQ) { > again: > timeout = stop - jiffies; > if ((long)timeout <= 0) > - return -1; > + goto out; > + > rc = wait_event_interruptible_timeout(priv->int_queue, > - (check_locality > - (chip, l)), > + check_locality(chip, l), > timeout); > if (rc > 0) > return l; > if (rc == -ERESTARTSYS && freezing(current)) { > clear_thread_flag(TIF_SIGPENDING); > + timeout = stop - jiffies; > goto again; > } > } else { > @@ -226,6 +228,10 @@ static int request_locality(struct tpm_chip *chip, int l) > tpm_msleep(TPM_TIMEOUT); > } while (time_before(jiffies, stop)); > } > +out: > + dev_warn(&chip->dev, "%s: failed to request locality %d after %lu ms\n", > + __func__, l, timeout * HZ / 1000); > + > return -1; > } > /Jarkko