Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2880934lqp; Mon, 25 Mar 2024 11:51:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOaD8kM1WVtKQ90wQIyzJasHSAQrneYaSerz3LzWpqZzxgFelAOmpNpEnaAKsCvBO0WrJOA5l3OtVwwPzCl2Imp2nacb4nYS8ytuF3/Q== X-Google-Smtp-Source: AGHT+IHJ2xF0EooPqEr+64GoKLF6Gau12DaaGCSHTWhT0GzBgT3+CoIViFmL5HoT2jREB615/j+N X-Received: by 2002:a17:907:a0a:b0:a47:52e7:8df with SMTP id bb10-20020a1709070a0a00b00a4752e708dfmr3684353ejc.41.1711392670795; Mon, 25 Mar 2024 11:51:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711392670; cv=pass; d=google.com; s=arc-20160816; b=lTS/YgNMRMxcGbTnPxdZf0L7l5adhDaGzPdc/4hjZ8G45nkdIq9/ffwbz9SrUSagDB 7DfV2HWGIqnjnd11m7JnCd9qLWBLL0ciF4n9oXUiGYKvE+xE7IT3ENeHVHzA6EeZ2rVu zaDZINptwsd2w7WZZO7naXVZO9qZi4lRjWHgwAhQ3W8UHSF7ETU5PnkjDh9y7tW/g5Md ow1CitKIx+FiVSbjLQ9BnhChgu23LGYp8LGk6vLgP3nElEs+fdr/N7wKMEq8KqR55lSx xWgnPprsH11Xs9Yc4tTSc+6x4zt9UhXCcG2s7zVr6NSW1q13R5KRe8uH9rU9XmAFMfh4 POew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6Yu4LRINmB+FHJtN+EqzZ9jG1nQsAP1LnUefARNLYSI=; fh=z/zm7tH+5sM7XgtkV4nVsbjEbNPWzYHRcJFaEJSqTw8=; b=ygQx7zi8uqzHLo2fr8t0WCE8GNFRaTy8nLF1XNhQWnyv873HAQ6wlhMqXE+gR1hBoq 3EYics27rr9hSzjsHnyx2KEkwUdSABHEGkPLG+bR7TE+5iNKqnwCDxDH5JVjewlsEniG nyMt+2RTovYJhU2EaSZRl2RmR3doWtRGxozdNKQqW25EIe8zY+nklQqFsRtdKKusUALg q9dsnlSgixjVgGdsshY3NPAVShL+IDbhJAKTRLE7lPQeCC7iYbDbpUVLW/Zo+AZuyBVy hsxJ0bbJ9NUR++/wy2IbgxvNd1m/g3oXVzUHI5GAzGA/1b41bAqH01f1DoqIxpiG0IVM z/KQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cXTm7SFx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hs15-20020a1709073e8f00b00a4748f1cacfsi2233959ejc.440.2024.03.25.11.51.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cXTm7SFx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117738-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117738-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8371A1FA73A8 for ; Mon, 25 Mar 2024 18:51:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC27D823A6; Mon, 25 Mar 2024 18:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cXTm7SFx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CDE0757E3; Mon, 25 Mar 2024 18:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711392127; cv=none; b=HQ6efbuJnrOQi+ELX4z66jsf2BAMv1P/h8K470G8qYZJEklCUrKV+RCNkV+XC7OjGS3x4VCua86NA5P0RmQxPJX9clRdgjruyvX4EtIsrA4uDoRzlECuYlRj/jd48IwrOr9mI+c4U+PuXtLZSLh0vXDp2PTYGXw156tuTv8x36k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711392127; c=relaxed/simple; bh=Oc5kvRHq0ucUhQzYgSZ1NBEHxsfc22nR4S713LRmA5U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AMGa/9NP3jMUg94kiQ1sFcLSr0LJPVCQhhATcHk1UYdBx/BIfh0EYFQjjRuiO4nGhl8beJ7BQtxTTgk84rxHJ1xbfv5G6TZEN7xMk+G8FDdL2w7HNmyeOuTfPbHlXoZ75IiAs+AeVwNT9h9Mn6sytcGziQNXSaWMGQVMeyuzqU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cXTm7SFx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85DEAC433A6; Mon, 25 Mar 2024 18:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711392126; bh=Oc5kvRHq0ucUhQzYgSZ1NBEHxsfc22nR4S713LRmA5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXTm7SFxCYGify3bM7fX8aO2vfYdDaF5JHeOV6tCOA1wOh+OHIsj8W0u2lrJz6/7C M7FCyTcIdQMBFura6GHFNJ4J59wMLYDYA+381tUcy3azG1/4/KZpRObBmsoYKlbatr Y0y+eE+T9idqWTqwWT1Wy1uFYzTBfYtcdZQviFVJUmad+Kga3BUTocAHL4XoiSsZ3K w1WKDJ1MhluUB470BueWlPLE+kE1xHHQ9BYsMzRbSHU+z9Nd1pALCcTGi240ssTCRJ 1rFgASajzvAL4TtGmOA5l/E3D1/TURpKBRQUTy5VXT//Y3m70imlVWi3bQ1kRY3sfz FPq2xt4nfKfdQ== From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, patches@lists.linux.dev, linux-arm-msm@vger.kernel.org, Douglas Anderson Subject: [PATCH v2 2/5] clk: Don't hold prepare_lock when calling kref_put() Date: Mon, 25 Mar 2024 11:41:56 -0700 Message-ID: <20240325184204.745706-3-sboyd@kernel.org> X-Mailer: git-send-email 2.44.0.396.g6e790dbe36-goog In-Reply-To: <20240325184204.745706-1-sboyd@kernel.org> References: <20240325184204.745706-1-sboyd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit We don't need to hold the prepare_lock when dropping a ref on a struct clk_core. The release function is only freeing memory and any code with a pointer reference has already unlinked anything pointing to the clk_core. This reduces the holding area of the prepare_lock a bit. Note that we also don't call free_clk() with the prepare_lock held. There isn't any reason to do that. Reviewed-by: Douglas Anderson Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 44e71736477d..9fc522c26de8 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4448,7 +4448,8 @@ void clk_unregister(struct clk *clk) if (ops == &clk_nodrv_ops) { pr_err("%s: unregistered clock: %s\n", __func__, clk->core->name); - goto unlock; + clk_prepare_unlock(); + return; } /* * Assign empty clock ops for consumers that might still hold @@ -4482,11 +4483,10 @@ void clk_unregister(struct clk *clk) if (clk->core->protect_count) pr_warn("%s: unregistering protected clock: %s\n", __func__, clk->core->name); + clk_prepare_unlock(); kref_put(&clk->core->ref, __clk_release); free_clk(clk); -unlock: - clk_prepare_unlock(); } EXPORT_SYMBOL_GPL(clk_unregister); @@ -4645,13 +4645,11 @@ void __clk_put(struct clk *clk) if (clk->min_rate > 0 || clk->max_rate < ULONG_MAX) clk_set_rate_range_nolock(clk, 0, ULONG_MAX); - owner = clk->core->owner; - kref_put(&clk->core->ref, __clk_release); - clk_prepare_unlock(); + owner = clk->core->owner; + kref_put(&clk->core->ref, __clk_release); module_put(owner); - free_clk(clk); } -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git