Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752906AbdHNWwt (ORCPT ); Mon, 14 Aug 2017 18:52:49 -0400 Received: from mx0a-00010702.pphosted.com ([148.163.156.75]:46089 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752770AbdHNWwq (ORCPT ); Mon, 14 Aug 2017 18:52:46 -0400 Subject: Re: [PATCH] [RFC] tpm_tis: tpm_tcg_flush() after iowrite*()s To: Julia Cartwright Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, harisokn@gmail.com, gratian.crisan@ni.com, scott.hartman@ni.com, chris.graf@ni.com, brad.mouring@ni.com, jonathan.david@ni.com References: <20170804215651.29247-1-haris.okanovic@ni.com> <20170807145935.GW8384@jcartwri.amer.corp.natinst.com> From: Haris Okanovic Message-ID: <16bd7bd9-6489-1a0d-d39c-fd78ce03bc6e@ni.com> Date: Mon, 14 Aug 2017 17:52:38 -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: <20170807145935.GW8384@jcartwri.amer.corp.natinst.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [130.164.62.171] X-ClientProxiedBy: MWHPR12CA0036.namprd12.prod.outlook.com (10.172.49.22) To CY4PR04MB0695.namprd04.prod.outlook.com (10.172.137.12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02cc09ea-f0d9-4c93-2862-08d4e3672c84 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:CY4PR04MB0695; X-Microsoft-Exchange-Diagnost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StP5M7pmxwT3nMsfwjAJl3CuHL72iDiFqYYLWnm6YRaYQrTxt5FKMfn9r1lsKsV7/pRbg9mW8JtUJYyaw5U6tPWgFe6VcI2nbELJotS92SOY6XQC0E6Y4PZ5iNqkKL57Hy98FeR9zITfKVHxtB25fC/Q/m5LKz5Z64MIln8clKnxWltbJMyuHfJ1HS00A34w6f/gMnulShS0Ile1zdLHZ28FKcnsB8blzSXRli6SUkNXRDELpGY4WQhIMuv0awsXwDHJ6R3Ro/Y7P2EVObHqNilpV1a/hOgtp8yOAo0vI6T8iND6C7MmMuUzENF3GeaxvXgftkExPRZNmC8N2gAioy90IEmvTSCzevimywRjK0p05vQZXk1zcoOAxe9K8fO/NwKy8nkuSdOP8mFBIBFJTRqgmIRn1jpPNnuBpFj2Nb4btWawDUrTAYtrLaagsh//GCYCXAkLWn3VITOy8k=;4:UjckuXvZOxGNXZw/KstKiVElib8RyS49zrTvWjUhMD/1OsdedfW+7YzoHB6LOkynwItPN4b13tn/hSQ2frqEJmhQLUx1gYhuJ+LjjhysH65yqz9PnyXB/RpVbSgP1deMasuvfbBQzSH+NNJVq2d461pIe4gzVjDfNTOSP/tuRaTjYG4HUYuvullPLH+ThqxlBOcWMI8JWaX8FX1SimO97WeYkbdqXrDxYAg5pAc4W1i7VHD3uZmPlhVZ1eIeglgm 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)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR04MB0695;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR04MB0695; X-Forefront-PRVS: 039975700A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(377454003)(189002)(199003)(24454002)(230700001)(66066001)(47776003)(6486002)(81156014)(65806001)(65956001)(3846002)(6116002)(64126003)(101416001)(42186005)(4326008)(305945005)(7736002)(33646002)(23746002)(50466002)(8676002)(81166006)(6506006)(25786009)(105586002)(106356001)(97736004)(65826007)(189998001)(31686004)(6666003)(5660300001)(6636002)(2950100002)(6512007)(36756003)(53936002)(6862004)(110136004)(2906002)(83506001)(86362001)(229853002)(7350300001)(53546010)(50986999)(54356999)(76176999)(4001350100001)(6246003)(478600001)(68736007)(31696002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR04MB0695;H:harisdt.amer.corp.natinst.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;CY4PR04MB0695;23:ajjPy9LTQQjFi8ll5JDzsUMyQtclxFJ6ZE4+J?= =?Windows-1252?Q?brMe6EM1lbosbPww4ogtBDMvKq5Ms0YaqDWyjWlht0kA4AWZf0+aICzN?= =?Windows-1252?Q?S8BngXiQepBtW40L6Ii8+12k/v4/0yndkxMc2PRa4NINycatvDzcR9cu?= =?Windows-1252?Q?u7NXpTV6NZ2I5WTEyjtYKQl8aRk+7wz5O5d/Ez7LETvbpF0PQt1hyGIu?= =?Windows-1252?Q?Ok7I/QW6SbvuYb14B+c6g8CtodcNKkj6zSUDOaGssSCAXlyvflIrw1nG?= =?Windows-1252?Q?sCyXNoYk/sJIWCwMd0Z5TmDA73mEds/bXrihADchJRM/B4Qv/WFUW13v?= =?Windows-1252?Q?Ryscz81oke4Qk63Z7DLkT6SXxrfQLHNOw5PgGMlOHy6RCmC07gbfm62K?= =?Windows-1252?Q?f726ZH6K6fpWGtAtsmsP31ZWVeY8HukLQIq5uSIAU6pc0jHjkB8HyPhx?= =?Windows-1252?Q?M7PnZw2+pA2QjW1o2bFWnzHfSD+ckd62HcMsA+vNwOl3WDXIC/ZrdoXE?= =?Windows-1252?Q?uD6ChisINzuPHRZOJSaRzKCQ39+o/TAv/7FOXCLD6H0OBcJq0WcNyoRY?= =?Windows-1252?Q?iGau6dTz3RTmjCgKouCh3Wv22Wa4JVdBHzKBDuAcCb6828itvFn1E3XN?= =?Windows-1252?Q?PD2AQLp2PPoE882dJAB/dRtkXz+HKg8uiI7aoM0u1xrBC+7Bb+3LiaEw?= =?Windows-1252?Q?ZDeiVXuIZlwxPkubbjCJFJi8K1vsbRFkhSo1lrRGbcdLpYP05PZfXQ2P?= =?Windows-1252?Q?abqAMw+UosCcF19Jb1MdmR10EHFMd14R6mvE4LbminkupsKyd+Y87sxw?= =?Windows-1252?Q?pqWeM/3FDgSKf8Do3bUHRxXH7PXTfzOv7p2SjOhf6rKrAL/XbhWgCWGy?= =?Windows-1252?Q?tE+AzLlQj6P/JaRbdV8ule81BinZQbmHzmZabVPkNLnk1sTeF4zvsFYo?= =?Windows-1252?Q?7c4tXghzBsji8mBQt/PPz6YNxljVUBhfG7YeTILsxj9JJbOD5b4ptAlq?= =?Windows-1252?Q?jqRH6PTzxqgOyUw3yThSytddhmq2IxHKhZalRASVMnTDDJV2dIJBcx25?= =?Windows-1252?Q?lcICcJRj2dU731Ymm1jLCtUPptRLTKgO/KW7FRKHk3PCwpQtobCzCW3D?= =?Windows-1252?Q?ipYEAYORqaCvofY6ZDPvsYxpFOGq663yc1yzLDlghKeIyOcAFtXuNQrG?= =?Windows-1252?Q?XfNal0Xksy24P4DvKOS4NkBl+Jt2JTaB0yyH7GP1edVoqCWRwdue0gRk?= =?Windows-1252?Q?RqEXiMr+T70LzwUeNtOTflTJ00CE1xa/LHtBYoS3mYMPeRIIWHuK40E5?= =?Windows-1252?Q?56xlcIUaf2zkyxg4YnFp+b9aTbLrGnEnbdS8Gvxu9CP5zSS0mztJ91Wz?= =?Windows-1252?Q?WbfhXtt61ivW5ew+5nnncF9ckI7qUg4KfN/qtFjA6W2VfsfVrPVC/n8F?= =?Windows-1252?Q?0xREwZThIZeWm1/nUCR2BZX/Q0SUh2e08zi45cmb9lePfjBaNJzhodH/?= =?Windows-1252?Q?WmNLvc=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY4PR04MB0695;6:NIFvxVUJFp4D2HVjnC+wCJ5B87fzRbxQvgANpPYGGE4+XBO4WuvQKzeq1Urc110tepAYmLZzlztVpmq2cub7KSB76iMgMd+gJ9sznGCCn4YZuGQ3PusEtUAtsktMfZeVAu6yx5qSR4vTu87VhcRlKcgCNDTAuaCEavptYd+5XJrR6PBtsC3BJjY/5FmBBDiGVg4N9Ckirde/aKVPv9GJdEZRfzAdxTLRpAK49BqNLbbnLUrxhu9zVR5/VKKzN6ULe1Htuz//Cx+osgWcvHewkt35rXCzIVKzwAzKoel1GVwTYhSH5FkAXE9v/GhZcBOZAkj/OLpXCh9nZhd43xMgEg==;5:1a/idbM2lOFOhZscKcaSizkj7akMntsJikSbblPP2gh+UsbD5fc88WPvX+/LO7M6MrG4M3X1lBh4It0rnxFzEAJPXyzNgqV24bhjb4ow2ECKu9FwlZb4JREsExqDrtXfnvSmm4toLOS65esT52NxIA==;24:u+keIvM5JldnS5L5MTMtRQJ17+BYqTvrbjPdhcOKj2i/p6lRlDP2vUrsrM2UXDYzLzyptPTKYB6DrH9rB5dxZXUAAXySG400b68g+KbphrI=;7:UhUmILFo/jUStZUQr5hkLT/2RZIq9v5mkScc2RzWKB8cyoCbmVjubR9p3lA3b+dvmUDxZIaFyLF02qiVfnR5g4G3fvoO9SJqxutQ24EVd3FPZea1LXaCd7fxzRSg/lLpvhAmSOhpz+clTIp1Syqsdps97N+AwEJm1OFqY+CIOf7f6JuXZmCmO0XZa0CQkf/W0nCIYw73SA+4bJ5iNDvEK2n0b4+FEFDsfFEaLw0tGPw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ni.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2017 22:52:41.8608 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR04MB0695 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-14_20:,, 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-1706020000 definitions=main-1708140377 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1757 Lines: 41 On 08/07/2017 09:59 AM, Julia Cartwright wrote: > On Fri, Aug 04, 2017 at 04:56:51PM -0500, Haris Okanovic wrote: >> I have a latency issue using a SPI-based TPM chip with tpm_tis driver >> from non-rt usermode application, which induces ~400 us latency spikes >> in cyclictest (Intel Atom E3940 system, PREEMPT_RT_FULL kernel). >> >> The spikes are caused by a stalling ioread8() operation, following a >> sequence of 30+ iowrite8()s to the same address. I believe this happens >> because the writes are cached (in cpu or somewhere along the bus), which >> gets flushed on the first LOAD instruction (ioread*()) that follows. > > To use the ARM parlance, these accesses aren't "cached" (which would > imply that a result could be returned to the load from any intermediate > node in the interconnect), but instead are "bufferable". > Fixed wording > It is really unfortunate that we continue to run into this class of > problem across various CPU vendors and various underlying bus > technologies; it's the continuing curse of running an PREEMPT_RT on > commodity hardware. RT is not easy :) > >> The enclosed change appears to fix this issue: read the TPM chip's >> access register (status code) after every iowrite*() operation. > > Are we engaged in a game of wack-a-mole with all of the drivers which > use this same access pattern (of which I imagine there are quite a > few!)? > > I'm wondering if we should explore the idea of adding a load in the > iowriteN()/writeX() macros (marking those accesses in which reads cause > side effects explicitly, redirecting to a _raw() variant or something). > > Obviously that would be expensive for non-RT use cases, but for helping > constrain latency, it may be worth it for RT. > > Julia >