From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756850AbbCCOph (ORCPT ); Tue, 3 Mar 2015 09:45:37 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:48123 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755659AbbCCOpe (ORCPT ); Tue, 3 Mar 2015 09:45:34 -0500 Date: Tue, 3 Mar 2015 14:23:11 +0000 From: Mark Brown To: Doug Anderson Cc: milo.kim@ti.com, Axel Lin , Dmitry Torokhov , Olof Johansson , Javier Martinez Canillas , Paul Stewart , "stable@vger.kernel.org" , Liam Girdwood , "linux-kernel@vger.kernel.org" Message-ID: <20150303142311.GT21293@sirena.org.uk> References: <1425066064-18920-1-git-send-email-dianders@chromium.org> <20150302184722.GE21293@sirena.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mAtJG+yIcdzIW95h" Content-Disposition: inline In-Reply-To: X-Cookie: My LESLIE GORE record is BROKEN ... User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Re: [PATCH] regulator: core: Fix enable GPIO reference counting X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --mAtJG+yIcdzIW95h Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Mar 02, 2015 at 01:13:56PM -0800, Doug Anderson wrote: > On Mon, Mar 2, 2015 at 10:47 AM, Mark Brown wrote: > > Looking at the code it seems that you're adding checks to skip calls in > > the standard enable and disable paths but not touching other paths, > > based on this patch by itself I can't tell if this is a good idea or > > not. It certainly doesn't feel robust - if we're missing reference > > counting skipping operations seems likely to lead to other bugs popping > > up elsewhere when the other user that isn't doing a disable currently > > decides to start doing so. > I guess it depends on whether _regulator_do_enable() on an > already-enabled rdev is supposed to be a noop or not. My assumption > was that it was supposed to be a noop with reference counting handled > by _regulator_enable(). Yes, that's the point. > My assumption is that regulator drivers themselves shouldn't do > reference counting. That is: if you call > rdev->desc->ops->enable(rdev) twice you should not have to call > rdev->desc->ops->disable(rdev) twice to disable. Right? That means > my fix is making the "ena_pin" symmetric to how normal regulator > drivers work. > The refcounting being skipped by my patch is refcounting that's used > only when the same GPIO is shared by more than one regulator. That > is, if "vcc_a" uses GPIO1 and "vcc_b" also uses "GPIO1" we need > refcounting. GPIO1 will be in the "on" state if either vcc_a or vcc_b > is on. The problem came in because _regulator_do_enable() was > incrementing the shared refcount every time it was called even if the > specific regulator was already on. This is all analysis which should have been in the changelog... possibly not quite so verbosely but it should be there. > Anyway, I looked at Javier's patch and it's also fine / reasonable. > ...and in fact I would argue that possibly we could take both patches. > Javier's patch eliminates the one known place where > _regulator_do_enable() is called for an already-enabled regulator and > my patch means that if someone else adds a new call we won't end up > back in this same subtle bug. I'm happy to update the CL desc to make > it more obvious if you'd like. Yes, the changelog definitely needs to be *much* clearer. Especially for things like locking and reference counting the changelog needs to explain what the fix is and why it's safe, without that working it is a lot harder to do a review as the reviewer needs to go back and check that everything has been thought through properly. --mAtJG+yIcdzIW95h Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJU9cPOAAoJECTWi3JdVIfQQssH/jwTa2xeuBcNJEJ2H1nFYrIe izCjYCvCmetYAACmIddiSnlbc3imJMbFOYYibqRXwFfoFPbbMxF07rysh2dWRoRI mZQ7J59n2f8yrZz+74Pv8K9iPpi7gI5bmZPk149o6tLkIPkbidlupXnAkwivNTFW My6Io314DZkdMVTbfG8T5k6nEqQh8dwPiNRfmxUYWCTqZbZHOsWjBp0vxKmIgWwY DbVf+ixxVInXIrZCHVCTXE4qChXm+Bhjd+/bloS5pid8/i8IYlMqVwIzqbbW6bUP oC2PjuFmaH/bvl/eN03DclphyrGNXKrIQUKJGAcZMAfUF7Z+QUxTIjDTlWh0MOU= =EiRT -----END PGP SIGNATURE----- --mAtJG+yIcdzIW95h--