Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751550AbdFHSjb (ORCPT ); Thu, 8 Jun 2017 14:39:31 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:37929 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751344AbdFHSj2 (ORCPT ); Thu, 8 Jun 2017 14:39:28 -0400 Date: Thu, 8 Jun 2017 12:39:20 -0600 From: Jason Gunthorpe To: Alan Cox Cc: "Shaikh, Azhar" , "jarkko.sakkinen@linux.intel.com" , "tpmdd-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , "linux-security-module@vger.kernel.org" Subject: Re: [PATCH v3] tpm: Enable CLKRUN protocol for Braswell systems Message-ID: <20170608183920.GA7984@obsidianresearch.com> References: <1496369044-38234-1-git-send-email-azhar.shaikh@intel.com> <1496870610-29462-1-git-send-email-azhar.shaikh@intel.com> <20170607224444.5043f545@lxorguk.ukuu.org.uk> <5FFFAD06ADE1CA4381B3F0F7C6AF5828910C7B@ORSMSX109.amr.corp.intel.com> <20170608192259.43150ffa@lxorguk.ukuu.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170608192259.43150ffa@lxorguk.ukuu.org.uk> 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 Content-Length: 1076 Lines: 29 On Thu, Jun 08, 2017 at 07:22:59PM +0100, Alan Cox wrote: > > > > + outb(0x80, 0xCC); > > > > + > > > > + /* Make sure the above write is completed */ > > > > + wmb(); > > > > > > Why the wmb(). It doesn't do what the comment says! Also this code is x86 > > > specific > > > > > > > > > > Memory barrier to enforce the order so that the outb() is > > completed, which ensures that the LPC clocks are running before > > sending any TPM command. > > wmb() doesn't do that. It merely ensures that the write has been posted > to the fabric. If as I suspect your LPC bus implements outb() as a > non-posted write you don't need the wmb(). I think the point here is to bootstrap the sleeping LPC bus clock before a TPM command is issued, presumably because the auto-wakeup circuit is busted or something. For that purpose all that should be required is strong ordering of the outb relative to the other TPM commands at the LPC interface FIFO. I also think the wmb is not needed because outb is already defined to be strongly in order with respect to writel/readl ? Jason