Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3865735pxa; Sun, 9 Aug 2020 14:41:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw63I6rx5yV0I8AAGc0/dyTxXvm7GkkfSDwdIWuPrLJM2yUPmA+bnYsKa2upXC2u8VAQH/Y X-Received: by 2002:aa7:cd46:: with SMTP id v6mr17606260edw.21.1597009273642; Sun, 09 Aug 2020 14:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597009273; cv=none; d=google.com; s=arc-20160816; b=OQxwfRmFv8CW7tRCJachS6lS457BPKdjT9mvFmZDLfxduX3vHrKhXjnL6B6iclHJd5 rrdN4HnaObj7cEz2VnVlnBXjOOKBe1zBN1P2Cu4DwxlfLoL5aVso7v7GlgJux+CBvz5A S7FSlK+NTFSYNsfwoYRORNCkP38S4ZWh3yZBMTtI6Q6cZe9ngW6MVWpbA1pmi+dnKvXL NfDFzTKf5Nr6M2ulQyAwxn0/r+uKMbOti2sEhQR95hLeI6yeO4A7tF/G9h4pNYRP6J84 j2SRpf9WNDSzAKUKLW0M0V+P1+rWq0R1R5Y/ifCqHWr9fuYAc3Li8GzPaGLfwOOMljjt Vp7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=+ep4HojIQDcPfiGIdNJSmErIHNth9ZyqLjovwLChR98=; b=UKFa8ML2jHYZubicbYC/zV1gwLCVi96L6GBVOZq//AnY8lNBul2hQ48ortz50bJ/qQ tgOk55nQiTfv7hmGvYqRQJwrTPsNqMQ5ET9JabL3Zy/45B8iyVD4eqcqBnTSAIRye7Y3 uAwCCkUSLX/PFNS630JpUahcU78x4aAVoJSSkqa2ajdCj1YVemSUxfc+HzvgoENB1LMn X7j6dSoagc1/rnNjMcg+/lATI9HVimnavCh71vJ3Axb87bJtq6ef4nO0G6I7vbBreP4Z 6ru8kHp1hJ3bFHQJVhqm2mhITJMWCHXxmNNkhYLb15kiWWwyvaBtfE4oToVLptAD965i YV3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=umebzz1A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ov24si9921636ejb.229.2020.08.09.14.40.49; Sun, 09 Aug 2020 14:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=umebzz1A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726350AbgHIVkI (ORCPT + 99 others); Sun, 9 Aug 2020 17:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgHIVkI (ORCPT ); Sun, 9 Aug 2020 17:40:08 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD6AC061756 for ; Sun, 9 Aug 2020 14:40:07 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id v15so3683381lfg.6 for ; Sun, 09 Aug 2020 14:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=+ep4HojIQDcPfiGIdNJSmErIHNth9ZyqLjovwLChR98=; b=umebzz1A/fKNdhwy09ATaiKEGNk6aY1qV/L7qFryoORsJN0s4VhQLKbJCotKTfxmTB BxXLFUoD457Nb+PD4kKbd6xI5t4P5vDgIb2ZAd7aAQ0ExrElioJEkrkYaAmKDEIRYY8B 2etoYNm28mEe1sn1QoOj5T41hcyBx28YpBoCBTurs9UxDUDYThI1zLNodZe46igFNV65 KO2CT3TsyO2jWm4WljSCrLo0qQHtWds8IPF/3coLvNCKLQFtOQBWJwWeXjLXF1qa71BZ IPCtELmpWGA1stzqMmdqGfYXVBaSQ06oFAKt7zqz89OBE2tQfgQ0y9IwIiLdtiAvGuHa YQSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+ep4HojIQDcPfiGIdNJSmErIHNth9ZyqLjovwLChR98=; b=m318q0IlwMf267E+ZvNA4mA/O/c9VaIf6g8Z8npQw4V9xXpeqhObSNVr1YslwHl/tA XjfCFfAgHpCjDBAZbEAiqBMELtDfkYWquHJGCZCvgQnQvQmYYSaIuRr3W1ZGwgmG8n6I mwvTvYHt5R3ZPqZDJPLznU1dfaEwFpf7j+bK9V469zrVWmxuQ1LQNFNJpWGBwTMbMG+O FrvlFs1VCWgnrw23FE9autcuj8lVt1Jk6rSjmXdEC4yzDKQqCY4JcM2WAum5oFAZf8nb DvwqEAmV84SlZwtdIdmd4Gn5yLHRvOuMUPNrmcY9f/ms26VaClCOPqZkg5FMUS+4gKZH Avvw== X-Gm-Message-State: AOAM530F8voPBTREYg9QOrFDaRwNsPDH9H3OEJLtRdbTl73SNhRkB7tJ eJStCwJh15pa7XxNol++vdrYxDrD X-Received: by 2002:ac2:58d5:: with SMTP id u21mr11435036lfo.31.1597009205791; Sun, 09 Aug 2020 14:40:05 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id w8sm8287705ljm.48.2020.08.09.14.40.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Aug 2020 14:40:05 -0700 (PDT) Subject: Re: [PATCH] regulator: simplify locking To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org References: From: Dmitry Osipenko Message-ID: <40871bc7-2d6c-10d4-53b3-0aded21edf3b@gmail.com> Date: Mon, 10 Aug 2020 00:40:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 10.08.2020 00:16, Michał Mirosław пишет: > Simplify regulator locking by removing locking around locking. rdev->ref > is now accessed only when the lock is taken. The code still smells fishy, > but now its obvious why. > > Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking") > Signed-off-by: Michał Mirosław > --- > drivers/regulator/core.c | 37 ++++++-------------------------- > include/linux/regulator/driver.h | 1 - > 2 files changed, 6 insertions(+), 32 deletions(-) > > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c > index 9e18997777d3..b0662927487c 100644 > --- a/drivers/regulator/core.c > +++ b/drivers/regulator/core.c > @@ -45,7 +45,6 @@ > pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) > > static DEFINE_WW_CLASS(regulator_ww_class); > -static DEFINE_MUTEX(regulator_nesting_mutex); > static DEFINE_MUTEX(regulator_list_mutex); > static LIST_HEAD(regulator_map_list); > static LIST_HEAD(regulator_ena_gpio_list); > @@ -150,32 +149,13 @@ static bool regulator_ops_is_valid(struct regulator_dev *rdev, int ops) > static inline int regulator_lock_nested(struct regulator_dev *rdev, > struct ww_acquire_ctx *ww_ctx) > { > - bool lock = false; > int ret = 0; > > - mutex_lock(®ulator_nesting_mutex); > + if (ww_ctx || !mutex_trylock_recursive(&rdev->mutex.base)) Have you seen comment to the mutex_trylock_recursive()? https://elixir.bootlin.com/linux/v5.8/source/include/linux/mutex.h#L205 * This function should not be used, _ever_. It is purely for hysterical GEM * raisins, and once those are gone this will be removed. I knew about this function and I don't think it's okay to use it, hence this is why there is that "nesting_mutex" and "owner" checking. If you disagree, then perhaps you should make another patch to remove the stale comment to trylock_recursive().