Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752945AbdHNXIH (ORCPT ); Mon, 14 Aug 2017 19:08:07 -0400 Received: from mx0b-00010702.pphosted.com ([148.163.158.57]:54347 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752668AbdHNXIF (ORCPT ); Mon, 14 Aug 2017 19:08:05 -0400 X-Greylist: delayed 879 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Aug 2017 19:08:04 EDT Subject: Re: [PATCH] [RFC] tpm_tis: tpm_tcg_flush() after iowrite*()s To: Jarkko Sakkinen , 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> <20170808215848.nngnph6wkqvx6zh3@linux.intel.com> From: Haris Okanovic Message-ID: Date: Mon, 14 Aug 2017 17:53:15 -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: <20170808215848.nngnph6wkqvx6zh3@linux.intel.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: MWHPR12CA0044.namprd12.prod.outlook.com (10.172.49.30) To MWHPR04MB0702.namprd04.prod.outlook.com (10.172.167.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1da5c9ce-56e5-4ef2-5827-08d4e367420c 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:AsNqcyOJ2IBwzqyy078WHzJfVqvgrK5phjPAxsuPtbDlgzdLUorgc2Jw/DCZWf+0FdCZDQW4+FmtICNGbNrp6URA7sldO6INgXgNnDrD+qT403lBlWi6Pp+p2j0dM1iKxPMWD1HGHN3EXWN6WYYTdl0PRdqve+e4v098UThnF2uyn057KdycjG+sAGB4w5VqMWD9WPioyU5/coXyfRAxCMueWqC4Rtmw13dXYBFi7hZDJ986W3tHIYijl/k1ync/;25:G9QoKCbs0JunTxsBKHcOM5L/T9U6rHyj/vZ6l6HLCW+SdwWRzSves4dFQbtVyGqMu//pGGUldS8ubA+c84EvF6Ebs/D2yvI1fWma0+K01AQalmFDPyHu19boYzyWF/SmMy3K5we1CSBXBJo3UIvjuWcj30Oa8bjI1fsuXy/m0+GrLsB+s2lhxFw+m7M6tM6bxDMjH3t2nozGyDNZKvAqaj3CbnR7N9UB/03b4KSzr/hgJe7B3zxBDCctn5iYYa9MQwMdU6hPwim+WyqnpmKtfPdz2GBAtaeZhiU6s/5MHv+ac5I6+NMG5B70EOzhCBA27RiabV1Hc8gnRJFkTM0ZhA==;31:/+DqFw26OllXdApbdqE1aDxm9noePzpEjCaPpUeoiMNI99jyfRzmvM9ix2LmQyeVLffEWmR/BIY9WD8jOCABO0DkW+ogN/VI2cy1fUN+n1QN2bz8cB2AtGz3T4DgXmXVE79RtqZKO7KzcK7iLsSFV1CsbVZqJrblUQSY3SEm9JgBhURhFqfmbD4m49HfIscG7EHBquGlmT8Qq3qBNmbAerCihtP2lAq0JRmhY2w5zCo= X-MS-TrafficTypeDiagnostic: MWHPR04MB0702: X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB0702;20:tmSgVo+f4jpeldSt0c+UFsSdv/iWR8s7qK2B5F+UEIVbiNggFcBll1i/3HW6znMHDA0mY2M1b+QzQzwiSI9bZdwDcu+RZ+m8w+R6NbfOkVNqaQcZInGb0Eye/6uIKUSBc4D6njCqKFq3K7PWfJHu6KkZ4G7FRm0An56iB1+DeOjVwcRtDlsuqajHKcHp7Vp8SfrnqbYBnD1+2Ao3Bk6WVBzv914HbP61oh1DIIEQjArCwMzoydEvGSQ2WuPwDWxNCkV56WIPiFhaHnTHYDA/JPOgBx4JkWvr4w9av9j9fQdLlTzwuldizCJQgwg7LC65Nt5w3dEXzewJ60HUlwAbPXLADPbXV3JMY/Rrx7ZsRyFj0L99eDqYgwXXXyrsYjcFBgUi63iBbVPeTPETVbVyR0GwrNdwcf3uuHrATFoVnu4t8pePIiTPovOocZVCRdy7ekcstaF3IHE5QpuQ8sIboYQ8RYCvL52i45bXRV8ax5oxYibDZ66NPQOJdo4gMkWpX+niADbKQDZUTHVebYAp93zptjk9PYvbUuwKPPl5rwyXiz1rvnHyBNwSnI3cbikLQBV8bNvNqYYBlqWA+4qFZewmlJdpcmFFNXnvfiWwrcA=;4:GtpmspY0wjt2slOnIwgy9ShmnlsQ6UAFUtv3tRQPmW52WJfNxlrq0pCyfW+OvLIn7Sartip/zlUfZs3TaRewLE11hsQb/tnCCdgTHYaOIOfvwEJtqq+dM/Ey7FCfiDGD4QrTAwU9hpNPFzCNkDuwPtk9PlhMThPdLKarunzbPupG6xjoUxq+Uco5ajAiZZT+yonuIOAqFCdC3Qo7xSFfsPhc3qrRo9DyHmMDjGuGC8QXwIBL1yMtD/6LiGicOgkU 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)(20161123562025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(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: 039975700A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(189002)(199003)(377454003)(24454002)(3846002)(65806001)(8676002)(65956001)(6116002)(81156014)(81166006)(106356001)(6512007)(105586002)(23676002)(7736002)(6246003)(66066001)(68736007)(33646002)(6506006)(53936002)(50986999)(478600001)(54356999)(36756003)(305945005)(76176999)(42186005)(101416001)(86362001)(47776003)(7350300001)(6486002)(83506001)(50466002)(2906002)(97736004)(4326008)(189998001)(25786009)(65826007)(5660300001)(4001350100001)(53546010)(2950100002)(230700001)(31686004)(6666003)(64126003)(31696002)(6636002)(229853002);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?MTtNV0hQUjA0TUIwNzAyOzIzOlpYbTNESTJnRGRZelBXTWt2NGhkY09kRjJn?= =?utf-8?B?K0p0N3FKUklXV2hVZWw1VFJkRGFWN3hVeThDNG1lT0lKTmV0M0NweEVXa2tC?= =?utf-8?B?ZXFCMVRDek9KcjZZY1FxUzNUTFVNRG9kZlcwWE5kdVdGUnJyczA2ZGNvUWtm?= =?utf-8?B?M09ZQnkxSUJ5bzYrNGpCQUxXSzBGV0I4R0RFZXpWWXVIUDZFQjZxbmlVTFBG?= =?utf-8?B?R2VVWWZkbW5JRDltSlRLSEZqNm5kSmRJclU4QlZNdlpIUmtPcGsxMlZOY1F6?= =?utf-8?B?TzMyN3Y0OGxqY0hjTHhkNlBZZ2pSTW1TZUd0SEJzZmNXRktZbk9HdFdMRVR2?= =?utf-8?B?enZrY2NiRTlSWDhaaU9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IE2EpeNAEO/lun+03SrapIt6reC5ZPw/XrUb1SkhD6mcJrDnnjEHOeg3qiNyNtNJPkx4daEwmtkH6tPxPgXr1FsWMh0Y5TkKKAfeAZwqhA==;24:LPDc7jy71IEa9BG+9Ixq7iKqPklSJcJamigP50fFew9WpjXfaP4OlBlAT6mjDlsjPTYjDzCmQAG0A7BQCjit4VtgnyJ7kiEYiVu7kcOaZYw=;7:XRmejx7HM/VeSLSYwCihGshelJwBHnOK6TTM6iH11ugzQeLc6ldsCAu0QwD2CSleJnaWcD/cS8hF2hNiDONF9LG6j+wQAgtIhpFGVfdROkWPFS2deRIzJIV8b4cP0dU/Lc8yEiiYfCUcwa5qkE8Egt6fCpHo5F/4yX1CnEaU53pWPAX5l/xgsrWmp9ZUz01c+nfWFYxwXnQAKsdpIXPUKsb+g2R9qwrx2EXGPEvJm5Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ni.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2017 22:53:18.8449 (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-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: 2060 Lines: 48 On 08/08/2017 04:58 PM, Jarkko Sakkinen wrote: > On Mon, Aug 07, 2017 at 09:59:35AM -0500, 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". >> >> 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 > > What if we as quick resort we add tpm_tis_iowrite8() to the TPM driver. > Would be easy to move to iowrite8() if the problem is sorted out there > later on. > Sounds OK to me. I will submit a PATCH shortly. > /Jarkko >