From patchwork Sat Jan 14 00:09:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Pronin X-Patchwork-Id: 9516631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A82D4607D6 for ; Sat, 14 Jan 2017 00:10:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96D282877D for ; Sat, 14 Jan 2017 00:10:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8916028784; Sat, 14 Jan 2017 00:10:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0B4B2877D for ; Sat, 14 Jan 2017 00:10:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cSBv2-0003h6-UH; Sat, 14 Jan 2017 00:10:04 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cSBv1-0003gx-6O for tpmdd-devel@lists.sourceforge.net; Sat, 14 Jan 2017 00:10:03 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of chromium.org designates 209.85.192.179 as permitted sender) client-ip=209.85.192.179; envelope-from=apronin@chromium.org; helo=mail-pf0-f179.google.com; Received: from mail-pf0-f179.google.com ([209.85.192.179]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1cSBv0-00045T-Ek for tpmdd-devel@lists.sourceforge.net; Sat, 14 Jan 2017 00:10:03 +0000 Received: by mail-pf0-f179.google.com with SMTP id y143so38395231pfb.0 for ; Fri, 13 Jan 2017 16:10:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8pMNtjHSNNNtNO6VBCk5iWJ9PZnSn1wiCE8kQwR1cK4=; b=ID8UemeBoA2Lt9JEieYlPXqcL7Rb6bq5oUWFSRqzWEgmJ25qVLKwxsJdMb2JCzKdKG mmr45RI1TjhF6D3b2j6y0G6HLApmLn4XnhDTDd1bOyIYTk/g1xpQcK6/tH6g4XFcd4QI XtE/gLD1kHTtfhrjGRnQAlOKihcjTE4EaKtCa5Xw+7cDUgXTTFw99AzK14OgkW+1Voc0 nBHaw83n/XD9dRkQrrjZgg9QcgRXpVMIZce6h3gts59DZr1tMS7ISNLwR6ZJ4QMaUJL9 iGa4IN3KT6v9UXT44COv174HKVuYBPjW5n3GDGSKy/MA6W3/aj6+BOEDRjn/0UTaAy9M tznw== X-Gm-Message-State: AIkVDXLjB951a+YZVGJ70Lx30znhU2u4RHwwIiKb+zEcE43W82LQ3pBI7lsscVA0I/KDoVMO X-Received: by 10.99.99.68 with SMTP id x65mr27293808pgb.126.1484352596796; Fri, 13 Jan 2017 16:09:56 -0800 (PST) Received: from apronin0.mtv.corp.google.com ([172.22.64.136]) by smtp.gmail.com with ESMTPSA id 134sm31816455pgh.13.2017.01.13.16.09.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 16:09:56 -0800 (PST) From: Andrey Pronin To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen Date: Fri, 13 Jan 2017 16:09:54 -0800 Message-Id: <20170114000954.17728-1-apronin@chromium.org> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog X-Headers-End: 1cSBv0-00045T-Ek Cc: linux-kernel@vger.kernel.org, semenzato@chromium.org, tpmdd-devel@lists.sourceforge.net, groeck@chromium.org Subject: [tpmdd-devel] [PATCH] tpm/tpm_i2c_infineon: ensure no ongoing commands on shutdown X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP Resetting TPM while processing a command may lead to issues on the next boot. Ensure that we don't have any ongoing commands, and that no further commands can be sent to the chip by unregistering the device in the shutdown handler. tpm_chip_unregister() waits for the completion of an ongoing command, if any, and then clears out chip->ops and unregisters sysfs entities. Signed-off-by: Andrey Pronin --- drivers/char/tpm/tpm_i2c_infineon.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c index 62ee44e57ddc..0c829fe26561 100644 --- a/drivers/char/tpm/tpm_i2c_infineon.c +++ b/drivers/char/tpm/tpm_i2c_infineon.c @@ -689,14 +689,18 @@ static int tpm_tis_i2c_probe(struct i2c_client *client, return rc; } -static int tpm_tis_i2c_remove(struct i2c_client *client) +static void tpm_tis_i2c_shutdown(struct i2c_client *client) { struct tpm_chip *chip = tpm_dev.chip; tpm_chip_unregister(chip); release_locality(chip, tpm_dev.locality, 1); tpm_dev.client = NULL; +} +static int tpm_tis_i2c_remove(struct i2c_client *client) +{ + tpm_tis_i2c_shutdown(client); return 0; } @@ -704,6 +708,7 @@ static struct i2c_driver tpm_tis_i2c_driver = { .id_table = tpm_tis_i2c_table, .probe = tpm_tis_i2c_probe, .remove = tpm_tis_i2c_remove, + .shutdown = tpm_tis_i2c_shutdown, .driver = { .name = "tpm_i2c_infineon", .pm = &tpm_tis_i2c_ops,