Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp869323pxb; Wed, 13 Jan 2021 18:54:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTfAXwtyzvJuLlpnTsw7bQR449kweCrVx9OiqBCnh7BNVbGU5QkKO9QtYhzvOLAIi5hKtz X-Received: by 2002:a05:6402:a52:: with SMTP id bt18mr4190815edb.228.1610592895239; Wed, 13 Jan 2021 18:54:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610592895; cv=none; d=google.com; s=arc-20160816; b=VAUDKx02Kf5bbcM1obplGOX8s+BqwoMEgfUWEyKPfWi67gUwpQq53EwCnDfWK3ZGCJ pXH5SPVvy1WKgy2Ab1FiYxlqjySPBP9rD2UG2qYUJKgoGzOb9Fri9OhIh6KZEM94te2S vNWmhxqIcbPKHhbYMc839s4msjIRljEbkh1no1IYE/+yQwE6WnxSLNKf3QLwQxEjI81m S8Uw8Wb9GGHGTmiryAmzZDLBmIVBK962nKvMkTge6emVrryIXlnxIYE7SV/2hjpgGP46 n2iNC8KmVfo08tYGx9O4JSFycJmz3duaZz5QeXGp1zKnVd7YwyWsbog/oLHK60qh026z oKXg== 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=zDts93KNqVztQALW8qpClcq9/CdVKVlz9LFMeuurQb4=; b=YJNJkMYmHwLJLvArsl1Vi7W1+DUPsw0um6TemhEXElDXqZ1AxMbU01AndWKgWtlCwy zHaq0TVYJ5Lv/EJ3FyG+m5k2MEhDg9mVogHrYuVrEVnXXPagvuOmNosgnGRP3PUUrtEu 2JdWjbbXCiLw8UzZKboHjzXbyB7rrEiIRc5Ugy9Ol3RTspCnTT+fn6A9vBtl7txHRpTT 9jAffMOCo3lvPY18OJgpHdvdZFojt3gSr5pbVrV4vDnmw8dadKYUA7EA4+nSFLn78bQG Motibela5/i5Ixk5QCDDIQT1hWrRlM8WVCpl3bQztWosOryO4rTuYSnUpV9BwYkmTXmB 0Hyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tt9GZfIf; 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 t23si1905088ejs.184.2021.01.13.18.54.32; Wed, 13 Jan 2021 18:54:55 -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=Tt9GZfIf; 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 S1727624AbhANCwU (ORCPT + 99 others); Wed, 13 Jan 2021 21:52:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:49426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbhANCwM (ORCPT ); Wed, 13 Jan 2021 21:52:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B08D5235FF; Thu, 14 Jan 2021 02:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610592692; bh=kA9yXXpdDPjKVxfq3CqRKkEzJJlAEd43QeCIiR9fR4I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Tt9GZfIfGlQnWcVcwsCJLfnGfb4UxiZbUl/tNF0YLHnTCEKKlujGIvZyAadpASTw+ rYUTlNF7QehedC0VxcQ1AQx90WJb4sdMhiPLCq/wQF+ig3Bppt3T5EEQFNk5cBbyJS DF0t3E4I/hgKwycox366VECqRrXjlyMnohf+6Xg4Lik7Rq6ox4EDMD3khlHxXRK0GU H0NwpUW3L83hKnfBDb7GuGQemViJEiBvsmU+Nk6ahcJgspGayYpHBKiOILOZdshtUG yunuWEvBtiK/5fd1osL87KQjPXKZHHtg+gF9AoMNWxtTnYkx1d6MsXMhCOmUTTIFOl K7FoO0v9ByL6Q== Date: Thu, 14 Jan 2021 04:51:27 +0200 From: Jarkko Sakkinen To: Tianjia Zhang Cc: Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang Subject: Re: [PATCH] tpm/tpm_tis: Fix variable reset during IRQ probing Message-ID: References: <20210113120021.59045-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210113120021.59045-1-tianjia.zhang@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 08:00:21PM +0800, Tianjia Zhang wrote: > In tpm_tis_core_init(), tpm2_probe() will be called first, this > function will eventually call tpm_tis_send(), and then > tpm_tis_probe_irq_single() will detect whether the interrupt is > normal, mainly the installation interrupted, set `priv->irq_tested` > to false. The logic will eventually be executed to tpm_tis_send() > to trigger an interrupt. > > There is currently such a scenario, which will cause the IRQ probe > code to never be executed, so that the TPM device is in polling > mode: after setting irq_tested to false, an interrupt occurs > between entering the ttpm_tis_send() function, and the interrupt > will be first set irq_tested to true will cause the IRQ probe code > to never be executed. Can you describe the scenario more detail? > It seems that this interrupt comes from tpm2_probe(). Although the > interrupt has not been installed when tpm2_probe() is called, the > interrupt of tpm2_probe() is only received after IRQ detection. > > This patch solves this issue by introducing a new variable, which > is only used in interrupts, and irq_tested only marks whether the > interrupt test has been completed. > > Signed-off-by: Tianjia Zhang > --- I'm not sure I understand this patch. TPM should be in polling mode. This is also assumption before calling tpm_get_timeouts(): /* Before doing irq testing issue a command to the TPM in polling mode * to make sure it works. May as well use that command to set the * proper timeouts for the driver. */ if (tpm_get_timeouts(chip)) { dev_err(dev, "Could not get TPM timeouts and durations\n"); rc = -ENODEV; goto out_err; } /Jarkko