Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2150854pxb; Fri, 29 Jan 2021 14:53:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzYQhVTUTyiWb5I3RHViH3MM1UeX5hVO+vPig5TaIdaiZECbzY5PUq/HDzLGsvu3nDCPA0 X-Received: by 2002:a05:6402:220e:: with SMTP id cq14mr7767321edb.240.1611960831927; Fri, 29 Jan 2021 14:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611960831; cv=none; d=google.com; s=arc-20160816; b=rGrAnQda9wp7ECNVskwaUxZBa7WF9BHkphNI27Emf71254+U/TPQ0s0rcpMR+soHVV pW0LjzFuz4ZpF4MvpKZIG9TOYWCUditnjvJd3LGh2fqgbzGUheZvuiUvMUXwlA2SZnT4 mUu0bd7IOxhiF+3enfPQ4g2JZwoQX6uGt5cA2QqvY4KWYnxbCBRDBCnoBcg4WdU2QarI C8hdJwIxIcF+Gc6H+dkekI9Q3HtlMEXzbr4OB8fhJTe3qglO6LDgZFHXvyFWshw6QOvf Jc00Roo3UaEjzLpEr5FqqsJmokSP1c+WlhwDf4pNQ0z7bZjyz/JZxYvet9P8rB8LQItz z8zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eLsFj/QGdxdvfuum//xRceK9axhEx93O098QWTINbnM=; b=N5Vqd8yzDRK1PKdGyyi0L4/uFdHuOdI7C4c+W7oxwBUHrCh+k5J2ASDJ8wCxpfmM/E Zf647YaSBkvH514egQozleX6IBCqq3/kfhWJ+CtDgWFPgB0dfFJT9nx+Yb74TxuebbDe JxJzPyJQfoH/CUwh2oMNoyTQuVqeH+KClH6s8Ak9fI1+GaWsShnd8sWdtdgF9CUdH4X6 LwsUoj9tLb1iKQXjGqR6lRKTCfJ53hFJTmaTaCcK3k9bJCMPet73TYTo0ubHH0Dd9P7U SfqxUP7g12eHKRrGeAcy6lZnbNhk2x1uIEuxeJG3GZhUIzsUQGtrYxeLO540c145Vxe1 WJQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BMhpzb8C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si6148463edh.11.2021.01.29.14.53.27; Fri, 29 Jan 2021 14:53:51 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BMhpzb8C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232582AbhA2Wur (ORCPT + 99 others); Fri, 29 Jan 2021 17:50:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:60864 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231623AbhA2Wuo (ORCPT ); Fri, 29 Jan 2021 17:50:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2256064DE2; Fri, 29 Jan 2021 22:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611960603; bh=zXm0xZuG9OSEEtoZN5Qt00ROf9jG6ey6+nY9VvgoWrQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BMhpzb8CfhxkKEC+gxSq0Iymiz08WhyWdMB/VeM+OjVsUzv2kWCo0vcIB1ek8bjhx GJ+sYPdaRMf/0+Qat0fJVOXMJduukJglLfh90+YidwqmkPByeSM1YFxO3jqmhK+PoX dJpuAviGp2pB6NpDNMgSn6Cj14pEhFMUOEZNtUwki1djvXgUVf7ImF0PsXSHSr4988 I5u/pTevihPaETPn60QJ5fWPi4zihIy4mu3yuAAW+XqZ9Tyi8WUgRf/wzV3k6JL3Le /4AhjbGCupsZ37h+xEJG2JJN0f8KHeZbOSzt8sCDBfrCVWJgmPoVqRotm1Ya2dpVON MkYdA584TmyEw== Date: Sat, 30 Jan 2021 00:49:58 +0200 From: Jarkko Sakkinen To: Guenter Roeck Cc: Lukasz Majczak , Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Radoslaw Biernacki , Marcin Wojtas , Alex Levin Subject: Re: [PATCH] tpm_tis: Add missing start/stop_tpm_chip calls Message-ID: References: <20210123014247.989368-1-lma@semihalf.com> <20210125171846.GA31929@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210125171846.GA31929@roeck-us.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2021 at 09:18:46AM -0800, Guenter Roeck wrote: > Hi Lukasz, > > On Sat, Jan 23, 2021 at 02:42:47AM +0100, Lukasz Majczak wrote: > > There is a missing call to start_tpm_chip before the call to > > the tpm_get_timeouts() and tpm_tis_probe_irq_single(). As the current > > approach maight work for tpm2, it fails for tpm1.x - in that case > > call to tpm_get_timeouts() or tpm_tis_probe_irq_single() tries to > > transmit TPM commands on a disabled chip what what doesn't succeed > > s/what what/what/ s/maight/might/ Also, would be nice to have the capatalization of acronyms correct and consistent. E.g. tpm1.x should be rather written as "TPM 1.x chips". It's also incorrect to state that something fails for TPM 1.x chips, unless you can somehow make a sense that every single TPM 1.x at wild fails, which probably is not true. > > and in turn causes tpm_tis_core_init() to fail. > > Tested on Samsung Chromebook Pro (Caroline). Anyone can tell me what does Caroline mean anyway? > > > > Signed-off-by: Lukasz Majczak > > --- > > drivers/char/tpm/tpm_tis_core.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > > index 92c51c6cfd1b..ff0e5fe46a9d 100644 > > --- a/drivers/char/tpm/tpm_tis_core.c > > +++ b/drivers/char/tpm/tpm_tis_core.c > > @@ -1063,12 +1063,16 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, > > init_waitqueue_head(&priv->read_queue); > > init_waitqueue_head(&priv->int_queue); > > if (irq != -1) { > > + rc = tpm_chip_start(chip); > > Unless I am missing something, the underlying problem seems to be > the calls to tpm1_getcap(). From other code calling this function, > it looks like it may only require tpm_clk_enable() to work. I don't claim to be bus expert but afaik CLKRUN is used with to power on/off clock, when using LPC bus. Also, TPM interface specification speaks about CLKRUN in the section 6.3 "TPM LPC Hardware Protocol". > With that in mind, would it possibly be better to call tpm_clk_enable() > and tpm_clk_disable() around the calls to tpm1_getcap(), ie in > tpm1_get_timeouts() and in tpm_tis_gen_interrupt() ? > > This would avoid the unnecessary calls to tpm_chip_start() and > tpm_chip_stop() for tpm2 chips. Not enough information about hardware and no klog. Cannot make much conclusions with the information available. > Thanks, > Guenter Off-topic: I noticed some dumb code in tpm_tis_core.c: if (chip->ops->clk_enable != NULL) chip->ops->clk_enable(chip, false); These should be definitely changed as: tpm_tis_clkrun_enable(chip, false); ->clk_enable() should be only used in tpm-interface.c. Not a bug, just really stupid code (and harder to trace). /Jarkko