From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946117AbcBSI1Z (ORCPT ); Fri, 19 Feb 2016 03:27:25 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:19970 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427197AbcBSI1V (ORCPT ); Fri, 19 Feb 2016 03:27:21 -0500 X-AuditID: cbfec7f5-f79b16d000005389-99-56c6d1e7fe7b Subject: Re: [PATCH] serial: samsung: fix the inconsistency in spinlock To: Anand Moon References: <1455817202-3005-1-git-send-email-linux.amoon@gmail.com> <56C603E9.9050307@hurleysoftware.com> <56C6C7E3.4060200@samsung.com> Cc: Peter Hurley , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, "linux-samsung-soc@vger.kernel.org" , Linux Kernel From: Krzysztof Kozlowski Message-id: <56C6D1E3.1060202@samsung.com> Date: Fri, 19 Feb 2016 17:27:15 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRmVeSWpSXmKPExsVy+t/xy7rPLx4LM7hxytiiefF6NospGz4w Wbx+YWhxedccNosZ5/cxWZxZ3MtusW7jLXaLY5f+MTpweOycdZfdY8Wf9Wwe++euYffo27KK 0WP9lqssHp83yQWwRXHZpKTmZJalFunbJXBlnLrQy17wTbri9Y/fzA2MR8S6GDk5JARMJKa+ 3M0GYYtJXLi3HswWEljKKLHvRR6E/ZRR4useLRBbWMBdYuntt6wgtoiAmsSVpyuAbC6gmpXM EqvOv2UEcZgFpjFJ9EzqYgGpYhMwlti8fAnYVF4BLYlFk9qZQWwWAVWJE4/2gNmiAhEShzu7 2CFqBCV+TL4H1sspECxx4u8aoBoOoKHqElOm5IKEmQXkJTavecs8gVFgFpKOWQhVs5BULWBk XsUomlqaXFCclJ5rpFecmFtcmpeul5yfu4kREvRfdzAuPWZ1iFGAg1GJh7dC71iYEGtiWXFl 7iFGCQ5mJRFeXX+gEG9KYmVValF+fFFpTmrxIUZpDhYlcd6Zu96HCAmkJ5akZqemFqQWwWSZ ODilGhgZGGKFJaR+6EqEv7BKPt9j+nf+bMl2rZssZdeu/F325MGR82oHZGesrkiS4mfTErs9 8dwuQ/1V93r4pv9e7ne75oVrkYAp98K/C1mmd/VGHw0KThHM1q2c+bzhj8qSx8Xi721OT/t0 S7Gsb9bsX1ut7Vxtz6/zTtwYNpGZM5pTaxOv8kY/7VQlluKMREMt5qLiRADvcdfVdgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19.02.2016 17:23, Anand Moon wrote: > Hi Krzysztof, > > On 19 February 2016 at 13:14, Krzysztof Kozlowski > wrote: >> On 19.02.2016 15:51, Anand Moon wrote: >>> Hi Krzysztof, >>> >>> On 19 February 2016 at 11:39, Krzysztof Kozlowski >>> wrote: >>>> 2016-02-19 4:14 GMT+09:00 Anand Moon : >>>>> Hi Peter, >>>>> >>>>> On 18 February 2016 at 23:18, Peter Hurley wrote: >>>>>> Hi Anand, >>>>>> >>>>>> On 02/18/2016 09:40 AM, Anand Moon wrote: >>>>>>> From: Anand Moon >>>>>>> >>>>>>> changes fix the correct order of the spin_lock_irqrestore/save. >>>>>>> >>>>>>> Signed-off-by: Anand Moon >>>>>>> --- >>>>>>> drivers/tty/serial/samsung.c | 4 ++-- >>>>>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>>>>> >>>>>>> diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c >>>>>>> index d72cd73..96fe14d 100644 >>>>>>> --- a/drivers/tty/serial/samsung.c >>>>>>> +++ b/drivers/tty/serial/samsung.c >>>>>>> @@ -759,9 +759,9 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id) >>>>>>> } >>>>>>> >>>>>>> if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) { >>>>>>> - spin_unlock(&port->lock); >>>>>>> + spin_unlock_irqrestore(&port->lock, flags); >>>>>>> uart_write_wakeup(port); >>>>>>> - spin_lock(&port->lock); >>>>>>> + spin_lock_irqsave(&port->lock, flags); >>>>>> >>>>>> This driver shouldn't be dropping the spin lock at for write wakeup. >>>>>> If this is causing lock-ups in a line discipline, the line discipline >>>>>> needs fixed. >>>>>> >>>>> >>>>> Thanks for pointing out. >>>>> Their is no lock up, just the inconstancy of the spin_lock. >>>>> Then I will resend this patch dropping the spin_unlock/spin_lock >>>>> around uart_write_wakeup. >>>>> Is that ok with you. >>>> >>>> Anand, before doing that, can you check Peter's second sentence? I >>>> mean the "If this is causing lock-ups in a line discipline, the line >>>> discipline needs fixed.". >>>> Don't drop the spin-locks "just because". I would be happy to see more >>>> detailed explanation in changelog. >>>> >>>> Best regards, >>>> Krzysztof >>> >>> Yes I understood the meaning of the sentence. Already the >>> s3c24xx_serial_tx_chars function. >>> holds the lock port->lock for safe IRQ execution. >> >> I am sorry but I don't get your explanation. I mentioned Peter's >> thoughts about lockups after adding locking over uart_write(). However >> you are referring to s3c24xx_serial_tx_chars() holding the spin lock... >> I am missing the point... >> >> Best regards, >> Krzysztof >> > > I should be sorry I could not explain you in technical terms. > Interrupt routine already hold the port->lock > > s3c24xx_serial_tx_chars > \ > spin_lock_irqsave(&port->lock, flags); > \... > spin_unlock(&port->lock); > uart_write_wakeup(port); > spin_lock(&port->lock); > \ > spin_unlock_irqrestore(&port->lock, flags); > This is obvious. > In my next patch I have tried to remove the spin_unlock/spin_lock over > uart_write_wakeup(port); Which may create lockups. Previously there was no port locking around uart_write_wakeup. Now there will be. You are effectively adding locking over uart_write_wakeup(). Again, we are back at the Peter's message - just check the damned lockups... BR, Krzysztof BR