Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751743AbcLCWrr (ORCPT ); Sat, 3 Dec 2016 17:47:47 -0500 Received: from mail-db5eur01on0109.outbound.protection.outlook.com ([104.47.2.109]:59680 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751317AbcLCWrp (ORCPT ); Sat, 3 Dec 2016 17:47:45 -0500 X-Greylist: delayed 40096 seconds by postgrey-1.27 at vger.kernel.org; Sat, 03 Dec 2016 17:47:44 EST Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=bhuvanchandra.dv@toradex.com; Subject: Re: [PATCH] tty: serial: fsl_lpuart: fix del_timer_sync() vs timer routine deadlock To: Nikita Yushchenko , Stefan Agner References: <1480674490-24718-1-git-send-email-nikita.yoush@cogentembedded.com> <77e2726b8b84c55f9109ff18dfcfbbdf@agner.ch> CC: Greg Kroah-Hartman , Jiri Slaby , Wei Yongjun , Aaron Brice , Nicolae Rosia , , Chris Healy , From: Bhuvanchandra DV Message-ID: <9ee78fcd-7aca-e2d3-4df1-fe65a512a0f5@toradex.com> Date: Sat, 3 Dec 2016 12:36:31 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [106.51.139.89] X-ClientProxiedBy: MA1PR01CA0009.INDPRD01.PROD.OUTLOOK.COM (10.164.117.16) To AM5PR0501MB2385.eurprd05.prod.outlook.com (10.169.149.135) X-MS-Office365-Filtering-Correlation-Id: 00962c07-99c6-4b3b-cfb7-08d41b4af27f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM5PR0501MB2385; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2385;3:UkUsiA2Q51fWcfDcOmYYhGaE4bo4T7I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-Diagnostics: 1;AM5PR0501MB2385;31:6coxdJ0as0KJGOau8LJBOGZ2Olkzxv5zb0fm2yTuvPTEUWUL5tFsuVctoKozEMNZo04Ma7scO4fexn5iwH5dymzNwoQ69yuYohJjd6p5WiW4lKP5l2CB6n9zaa8otGqqOWo7mswCFvBeoUPt911PXu3zuK3R879VULAoAW+IHm5CPL20KmJXNWxM4Q4CeBuVptB+nJLoj5wB4Fiu0KeBqw3U2Idao422w1Zk62wCSWFHg7Bj51ItcfqxBBJdRc8H50i/MWXXtUink9YPqc76uiYLRins3pWWJZToWLfWSFo=;20:kw6RNj2uHdD4zk8d9MSTNlpsnk90VlBcQtzEvigUGIlV1pHBn5UAlchBC2IpAXK4aiGKY139c3FryJmaVbLe4xXAqXRPAH+cujLve2pffu71kty2Z+khueskTE7utS8oSGG6/lsXrVO752CEWHqbiVvepSrhDiW7e8N8lGcptzaYwOeWklDaRq655m2GZMBS80cUH/g9ZKL6jyG7lSIVt/+LcpP4F9qvWPSNLCIh7D8R3ZWL7eL+kQfAiosNMGoSODv3U7VOnGTlUtJnM2hntfuui0oYRaW0003y/ifh9S1LS8tXxt3brkpZRo9y+ZUYc8DWTVX2oFk1ZGK8B2b3Ow== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6090148)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6072148);SRVR:AM5PR0501MB2385;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0501MB2385; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2385;4:AYy8HAr9g1/q6qE9SjmUq1xonm5HuBgK1yT9JNfrfDhwYTVts7BqOmheyVSDnyFVugWYHjJ6+L6/vOL1Cxv1w6anGbWMzPYg/qiGXMtQ9VkWHV+ZV2kC6ErfjCKRBTsHiSeyFwnpwwbGGS3enC2VY6vS/1GRHJZI7JYTPI6sqS0HH3s/UX+z2cF7IcQlJZU1Tj1O84gg1CspPhcXL/zTfqZigh9wMFzvSp8zH8Ved6mzeiQbr+edAg5zqwVDO3SHMbwVp+uJ5fkK7bdS5+CdWg0DvUZHod/x0AIy1NqZQaj2r0Nk4iWcsdyRXv5AGnKMcTj0NHyCi9tz8fKRdEBmsTJo5WhBqT82au5Z79XeCuIpT4Ubk0PXyPoQytglQo9tLB39AViXA/y0V62M5MlURSGlwcjaNM78Sqi48WFd1AwdgWw6q27s2MtxT8KEgh/+gkO05itImIJJTL7enHjxO0qg/Z7vnkoqNmgcLRbjS8GSOz85f2naQWdB3/BPCoeB9YzPmvf4KC2bcF1mmWCUBhOKqYjry9yKFFiQ650bVdq5+VXt/WYTvzPA0ShomnTiTG3E9QIm+dTrBYVB9mogIg== X-Forefront-PRVS: 0145758B1D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(979002)(6049001)(6009001)(7916002)(189002)(24454002)(199003)(377454003)(65826007)(733004)(39060400001)(5001770100001)(97736004)(83506001)(229853002)(189998001)(9456002)(230700001)(33646002)(38730400001)(6486002)(86362001)(7416002)(5660300001)(77096006)(31696002)(106356001)(105586002)(39450400002)(4001350100001)(76176999)(54356999)(2950100002)(101416001)(23676002)(50986999)(6666003)(2906002)(31686004)(42186005)(68736007)(64126003)(7736002)(66066001)(6116002)(47776003)(92566002)(7846002)(65956001)(65806001)(5009440100003)(81156014)(81166006)(4326007)(3846002)(36756003)(305945005)(90366009)(50466002)(8676002)(20860200003)(32040200003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0501MB2385;H:[10.243.248.147];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjA1MDFNQjIzODU7MjM6SHJQYW1FSGFCc29ENUlnYkx6TGx5SW42?= =?utf-8?B?RWNvUTdnRzRMRVV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C6GhR8FeyJNgDQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB2385;7:RX/+Elz6TNYCvL4rdjdtwgHJJCr43G9b0wm5CXEm/PHrRyW6UnLGnf9gX85WySnKDRZVrmkvhQvfl6o7Zcl5YS3mkwdOjsLNdQltNhSjlM86jyvCuMyuRk4pV2uhx9Z2FW/OuWtGP0AtJwdSftR0rMnLdiN9XbdDgcTlAMkj+GrECRrbFVJrP/ueNAaeh9BtPaPSvYAjDnLJ7xdO4RqT6UsXIs5VIKwCviXPnTVoUqfXv4cA1gazaHlgX9+ZFS1XkT2NtIiPnVjR/meUd5jlQWUEOqW6pkR+DTxmPmw+kmCV3eZZ5r+M8Ny7yThk13vxU0Ku3X0gqYAOkq5yF4FkI5RS28aUTvuGci4QrkQKY+h9VwNHxESSEMAt0pqtfQONGAIFmrCaelEYpa7pthzxwinH1K4HCiSW+NX2sMGNcKyg0QtdVHOEU9c4mOZDWmTfiX/U/ukKakdMK8Jwx8uG2A== X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2016 07:06:45.3480 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB2385 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1526 Lines: 42 On 12/03/2016 02:58 AM, Nikita Yushchenko wrote: >>> Problem found via lockdep: >>> >>> - lpuart_set_termios() calls del_timer_sync(&sport->lpuart_timer) while >>> holding sport->port.lock >>> >>> - sport->lpuart_timer routine is lpuart_timer_func() that calls >>> lpuart_copy_rx_to_tty() that acquires same lock. >>> >>> To fix, move Rx DMA stopping out of lock, as it already is in other places >>> in the same file. >>> >>> While at it, also make Rx DMA start/stop code to look the same is in >>> other places in the same file. >> Yeah I saw that too, never really came around to look closer into it. >> >> Thanks for looking into it. >> >> You removed the check whether there was an old configuration, I think >> the idea of that was that we only resize DMA if it was configured >> differently before... > Per my code reading, checking for sport->lpuart_dma_rx_use should be > enough, this flag will be set only if DMA was previously enabled, The check is to make sure the reconfiguration of DMA is done only when the baudrate is altered. -- Bhuvan > >>> + if (sport->lpuart_dma_rx_use) { >>> + if (!lpuart_start_rx_dma(sport)) { >>> sport->lpuart_dma_rx_use = true; >> No need to set to true here, it is guaranteed to be true at this point. > I've seen this... However elsewhere in this file (namely in > lpuart_resume(), in very similar situation, code is exactly the same, > i.e. it sets sport->lpuart_dma_rx_use in both clauses. I thought it > could be for a reason (i.e. for readability). > > Nikita