Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497AbdHQUMr (ORCPT ); Thu, 17 Aug 2017 16:12:47 -0400 Received: from mx0b-00010702.pphosted.com ([148.163.158.57]:57343 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753422AbdHQUMp (ORCPT ); Thu, 17 Aug 2017 16:12:45 -0400 Subject: Re: [tpmdd-devel] [PATCH v2] tpm_tis: fix stall after iowrite*()s To: Jason Gunthorpe , Sebastian Andrzej Siewior Cc: Ken Goldman , linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, harisokn@gmail.com, julia.cartwright@ni.com, gratian.crisan@ni.com, scott.hartman@ni.com, chris.graf@ni.com, brad.mouring@ni.com, jonathan.david@ni.com, peterhuewe@gmx.de, tpmdd@selhorst.net, jarkko.sakkinen@linux.intel.com, eric.gardiner@ni.com References: <20170804215651.29247-1-haris.okanovic@ni.com> <20170815201308.20024-1-haris.okanovic@ni.com> <13741b28-1b5c-de55-3945-e05911e5a4e2@linux.vnet.ibm.com> <20170817103807.ubrbylnud6wxod3s@linutronix.de> <20170817171732.GA22792@obsidianresearch.com> From: Haris Okanovic Message-ID: Date: Thu, 17 Aug 2017 15:12:01 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170817171732.GA22792@obsidianresearch.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [130.164.62.171] X-ClientProxiedBy: CO1PR15CA0065.namprd15.prod.outlook.com (10.175.176.33) To MWHPR04MB0702.namprd04.prod.outlook.com (10.172.167.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 47697312-51f7-4a3a-cbe6-08d4e5ac3c22 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:MWHPR04MB0702; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB0702;3:72CWfMu5YEjKQXErrM2ou9/qI9H4BcPmjAOg+UCGg+M+/9UuVg5G/4FLmgvNWjtTJwvc/jQZBXXdYSNRP+RTqtrREQd4fd/eUmk98S1TwQw96nsV1Lux+1AeN+jR26NmXZAU+LEPCPyajg36R5RcHoTcdAjEMlSr3myBGz3pzaM5kjob8fdx0gJUgtzekUbvXqvWYTXd9gWp+y/Zu4BE06L3QcJxknuwUpwImu/zMKbNSU3ejYNbHqT7ZTB+VVqV;25:HqiBAnEyn1k1BJGaZyIiuS9waHn0bNcEEnEQ84AqrkkXwS2No87tB1FdmqYo9OFYN9pc8m3bf4oKzmAVlJL9+mYj1KMLEKFW2OCgBz0KdZQIqRc+3+7ME/Cw9mY3ZelPGzNhQm9TsQeNi5PDnBFAtUx4geTzpMq3NUsYy74HrOBI1lxqiBrNzffhfAk6ePoQ9wL/ksRsmkJZ/uSysiMSAsACriUhRSFYcZ/yLLckg66hTvmh4J+xzCJsIAVXuLOUDsJJkBVr2iJX4cEs1z5GkTu9ye0j1jhuHmP2vxfgmrfOISZPHTsJubyqaPfK96HDPqtEScZNxSatjvlcA6++iA==;31:FTEESttcvlCumzAnRkK6D22gpRVeU+WST71PvGXuvnGRvo8ne0T6pIyg8X+9njdWkGCffNzUsM6AauBdPocYMBkB/ABEMzC//2tBINR3qNAbSIOb/lsQZCcsDgaw3I1xr/9NJrAiRELE5qWHK3eVMzXfDQpjzjeXr0JVmA85Tu7zY7fRLULtfDx3l/AiCNXEVG+2wOMgL/o6M3pROE/zY/f19sJtT8/F8tBpGZCz9to= X-MS-TrafficTypeDiagnostic: MWHPR04MB0702: X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB0702;20:dTEeKgiwKf2XfhaVAUN1EWOOOy4CybHq3xIrqn55UK/rxYATpA6QAD+Mio1cPW5kTm51i2iu+Cz8uZQmIWrQiS6SqdUAOo5T0KZUq5zfB0C1xm4W+sq4Ce3SINhb59g7P5Repe3jJxwMC+l7C8z/GRiC8pZzcflX4ld7/IOZ8odo9sC5ULU47t6bC/v5lgUUJk/4Rp7vbnHJbKlb4eizbZFRRP3I/vD+psVBmS0/GEsc7RbYcXylzGjnnpPhVVj6S+cxMCxDpDUjtCaiXnVoBFN+/+gV2EA9gm/oWChz0EEzGutmC8aPDwpRJsJ82U/c5Fzha4oScizaWPUv87i6N6jyHB+Fhd3DnuggjYeD5bOItwHRoEFtloieBO17s/wlH2/xXndDqlPDagy8ulYODoVDvfDNhI0t8Zakwm0co7OZ3HBYPZTx3UMzyDrdvZvka15tgHJfQtlP412D4O70l9yK0IEoC9FJ+jXTdIFxiK0mvhJIfqD5n5Td/q/r5SKoYsU36CLtCkUx42+dAoLihv69JW8rtK+zs9Ucr6wfu0MTDUAgBFHq9qEM/I9LsOF1v4sFgT7igvIY7Y5LYqMTQ+YGdyZZoTgPtrIXRzyibxI=;4:HHqk6FVtnFvLMimoy1A5h+aXvU6cJ+QtySLNU3Rw8muh/UyGwerrAXCzH4deV4EjgivaYt27zsgzeSuPqzcuWNlCZbf0tmer13QOVYReqVnhOD1nEBtzH61qQea8W4BJB6PcOmwQqCtU+4ucECbn1M5Ennyv8EfqmDAozOPbcXGLcXiyn9atceJAuIildzdSwlVA4na3eG/TrEoeWTE3Uhq2ghJtksURG+pTx3hFPTjZoCXYB4jmWHI9d8Zw9LZI X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR04MB0702;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR04MB0702; X-Forefront-PRVS: 0402872DA1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(979002)(6009001)(377454003)(189002)(199003)(24454002)(6246003)(6666003)(2950100002)(6486002)(36756003)(6506006)(4326008)(86362001)(53936002)(25786009)(65956001)(6512007)(66066001)(97736004)(47776003)(229853002)(53546010)(65806001)(2906002)(68736007)(31696002)(23676002)(83506001)(305945005)(54356999)(105586002)(76176999)(31686004)(8666007)(478600001)(6116002)(106356001)(50986999)(3846002)(65826007)(5660300001)(4001350100001)(7736002)(50466002)(189998001)(101416001)(7416002)(7350300001)(230700001)(42186005)(81156014)(81166006)(93886005)(33646002)(64126003)(8676002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB0702;H:harisdt.amer.corp.natinst.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjA0TUIwNzAyOzIzOmRvc1h4NVphYkhoWHUvWTh0bXQrSVBFV3ht?= =?utf-8?B?R2RBWUNNWVJYTkhwRWloRG9hMUdOemZ6eFZGSTlzYTVieVdQMXI0NUluMGVl?= =?utf-8?B?VXk0eHVHbDRKSG44a3QzMjJ4Nnh3VFFZUmVPS0lBdlNkZFF2UjhlRWZTd00r?= =?utf-8?B?NmdrTi9rZ2Iyb3ViSlJWelFiTElFL2FhSTVVRXF3SkNGdWhiNVZEcWxnaC9l?= =?utf-8?B?WmQ3TDh3djFsNjNCN29MbThmR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-Diagnostics: 1;MWHPR04MB0702;6:Yw+d+WDNDqoVjV39V5gby91GWHtj601G3TrKl+phJhbud7I9YGUMghvp5ZFUMfdsKyVykOeXPw1Y1CP6EIGO22WnkhG4MdpMZvcpEVBIDDPRlncxhNk4xouoGeuVumnRUmMQSQU0eF7lcUrQFmNm50GmVqE7WuN0bRIJWMNNSKhUPYJ9fqdsPAkBddftDb3uNPmQCslXabp894H6KlOonxaHK2dvPvWM1cKjn+JJtmOpyMrHtcLwfIveOv+E3fX8cjZaVfgcCVHsYJCHnA8G9SzNIsfNDNqrYIs85KRoVJsxke+J1V3YZ8l9iJ3JzOJF+Pg5tmH2Xujc7H9YEseqYw==;5:gaoy+GMMtzriOel5d0CTmiDjz3JtoE72kdaxrwdHAmYsTmLPpeHZsvK+E9ftGwHFp9VH3YkuAUwSd1jMjKB6xi1KbSPytFq4f32FEx9S8w45TIQsOLbwSxztDSWc4UvmIvRBDanWLUK/SKnInuWYBQ==;24:1gQD4PCNYymdUeEElfnBEMdTpadvTcqP57VTl5rlGNSaeSt2nx3+dpepwQOdeg6Poh3dd55aWpGaZwheUtTaFQvC6IVFqc3JNKF1r8PYQo4=;7:8Wab/M8M2uFRWUzS4YgBqTpdT1VRfxC114CsSf+XwSQDXDn9XLxDHrR3cEIE2jatYlkVwQlU0DL22rcVZo6pOgGfMI5AyPj6C4pMsrdMS4I7fsaZF0cu3i3zUA8rQn5Br0+PPCeXYM33tzDKwd5utfQn3Mtz2+VqxUMKzRSAqnuv5OEqerWgPiT51OVqicWu95uOU0Gyr+OSs6GlfbYik9IqhgeZLibnjjpWnKLSiGc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ni.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2017 20:12:06.1350 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0702 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-17_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_policy_notspam policy=outbound_policy score=30 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=30 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708170325 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1934 Lines: 46 Neither wmb() nor mb() have any effect when substituted for ioread8(iobase + TPM_ACCESS(0)) in tpm_tis_flush(). I still see 300 - 400 us spikes in cyclictest invoking my TPM chip's RNG. -- Haris On 08/17/2017 12:17 PM, Jason Gunthorpe wrote: > On Thu, Aug 17, 2017 at 12:38:07PM +0200, Sebastian Andrzej Siewior wrote: > >>> I worry a bit about "appears to fix". It seems odd that the TPM device >>> driver would be the first code to uncover this. Can anyone confirm that the >>> chipset does indeed have this bug? >> >> What Haris says makes sense. It is just not all architectures >> accumulate/ batch writes to HW. > > It doesn't seem that odd to me.. In modern Intel chipsets the physical > LPC bus is used for very little. Maybe some flash and possibly a > winbond super IO at worst? Plus the TPM. > > I can't confirm what Intel has done, but if writes are posted, then it > is not a 'bug', but expected operation for a PCI/LPC bridge device to > have an ordered queue of posted writes, and thus higher latency when > processing reads due to ordering requirments. > > Other drivers may not see it because most LPC usages would not be > write heavy, or might use IO instructions which are not posted.. > > I can confirm that my ARM systems with a custom PCI-LPC bridge will > have exactly the same problem, and that the readl is the only > solution. > > This is becuase writes to LPC are posted over PCI and will be buffered > in the root complex, device end port and internally in the LPC > bridge. Since they are posted there is no way for the CPU to know when > the complete and when it would be 'low latency' to issue a read. > >> So powerpc (for instance) has a sync operation after each write to HW. I >> am wondering if we could need something like that on x86. > > Even on something like PPC 'sync' is not defined to globally flush > posted writes, and wil not help. WMB is probably similar. > > Jason >