From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394AbdAQVYa (ORCPT ); Tue, 17 Jan 2017 16:24:30 -0500 Received: from quartz.orcorp.ca ([184.70.90.242]:58314 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbdAQVXF (ORCPT ); Tue, 17 Jan 2017 16:23:05 -0500 Date: Tue, 17 Jan 2017 13:59:33 -0700 From: Jason Gunthorpe To: Andrey Pronin Cc: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, semenzato@chromium.org, groeck@chromium.org Subject: Re: [PATCH] tpm/tpm_i2c_infineon: ensure no ongoing commands on shutdown Message-ID: <20170117205933.GA9604@obsidianresearch.com> References: <20170114000954.17728-1-apronin@chromium.org> <20170114002857.GA5851@obsidianresearch.com> <20170114004230.GA21035@apronin> <20170116161919.GA20238@obsidianresearch.com> <20170117175827.GA124090@apronin> <20170117192728.GF27528@obsidianresearch.com> <20170117201336.GA140854@apronin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170117201336.GA140854@apronin> User-Agent: Mutt/1.5.24 (2015-08-30) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.156 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 17, 2017 at 12:13:36PM -0800, Andrey Pronin wrote: > > Is there some way we can have the TPM core do this without requiring > > the driver to add a shutdown the struct driver? > > > > Maybe we could put something in chip->dev->driver? Not sure.. > > I can play more with it. We can check in tpm_chip_register() if > chip->dev->driver->shutdown is NULL, and, if so, set it to a default > handler. Or, do register_reboot_notifier() instead, to avoid messing > with struct device_driver from tpm-chip.c. Not sure if that's a > consideration at alli - any reason not to mess with those structures? I think ordering is important here, the TPM core has to do any shutdown before the driver shutdown method. That restriction might entirely preclude using a reboot_notifier. > Whatever we do, we should allow the drivers to still send > (vendor-specific) commands from their shutdown handlers. A vendor specific command should be done via a new core TPM mechanism. I really want to keep access drivers (eg i2c, lpc, spi, etc) out of the buisness of *assuming* they are connected to any specific chip. So, the core should detect chip XYZ and then issue the required vendor-specific command in some way. The driver shutdown would be used to close the access interface in some way. > But, yes, setting a default handler through chip->dev->driver > might just be good enough. Probably the *best* thing would be to add shutdown to 'struct class' in the driver core like suspend/resume? Jason