From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754807AbdKNLTn (ORCPT ); Tue, 14 Nov 2017 06:19:43 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:39180 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751836AbdKNLTe (ORCPT ); Tue, 14 Nov 2017 06:19:34 -0500 Date: Tue, 14 Nov 2017 11:19:16 +0000 From: Russell King - ARM Linux To: "gregkh@linuxfoundation.org" Cc: Oleksandr Shamray , "devicetree@vger.kernel.org" , "jiri@resnulli.us" , "'Chip Bilbrey'" , "arnd@arndb.de" , "linux-api@vger.kernel.org" , "openbmc@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" , "openocd-devel-owner@lists.sourceforge.net" , "mec@shout.net" , Jiri Pirko , "robh+dt@kernel.org" , "joel@jms.id.au" , "linux-serial@vger.kernel.org" , "tklauser@distanz.ch" , "mchehab@kernel.org" , "davem@davemloft.net" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [v11,1/4] drivers: jtag: Add JTAG core driver Message-ID: <20171114111916.GO12318@n2100.armlinux.org.uk> References: <1509724449-26221-2-git-send-email-oleksandrs@mellanox.com> <8760aoz78q.fsf@bilbrey.org> <20171114111046.GA23820@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171114111046.GA23820@kroah.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 14, 2017 at 12:10:46PM +0100, gregkh@linuxfoundation.org wrote: > On Tue, Nov 14, 2017 at 10:34:49AM +0000, Oleksandr Shamray wrote: > > Greg, what you can suggest about it. May be better to add again single-open()-per-device lock with right locking way like: > > > > >if (mutex_lock_interruptible(&jtag->open_lock)) { > > You would stall an open? Why not just return saying you can't do that? Greg, I think you need to look at the code again. >>From the snippet in the email, this lock is not held while the device is open, as you apparently think it is. It's a short-term lock that is held to ensure atomic access to the jtag->opened member, so that two concurrent opens are unable to operate lock-step, resulting in jtag->opened becoming 2. The open function snippet in the email drops the lock as soon as it has incremented jtag->opened, or encounters an error. It seems entirely sensible, rather than using an atomic_t counter, as it means that other openers are held off until the current opener has either succeeded in opening the device or failed to open it. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up