Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2891386lqt; Tue, 23 Apr 2024 05:05:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjgfA3TqNKH4/9kN6JUev1MhA8fuQhS0AaCmejlsvn3O9aTabpv8xEkaOb1/kctpuN1JOeJRWv1QZECKeY/AkLUgjyuCeBwuXBWPfV+g== X-Google-Smtp-Source: AGHT+IFErAMCXTrt5dmydDdXji5g71h3Y1ASmmUX37fE3coIrTAuMpo6C+5k04MsupMwAma8eZAB X-Received: by 2002:a17:902:da8b:b0:1e3:d4a2:387e with SMTP id j11-20020a170902da8b00b001e3d4a2387emr16229690plx.1.1713873955385; Tue, 23 Apr 2024 05:05:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713873955; cv=pass; d=google.com; s=arc-20160816; b=OB5GAt+rsAJcremiPLMXnOzBfWIRBuSY4Rd7h4mlpf4Vi26XRzDc+cHuIE4setW4N6 xfRV2jL0nFAjroI1UVBZoMm7lOnbC6g80cxrJPqOWFgDLKFFSxViggkos7nLyu4s45E0 1m4m6mH5Cli7M7jlXR+OSHl59f+srVg84QpVs+AIAyyifEMO6/U7Yk+S7Ozof+MuUazK DLn3A6KTN/J8RKWQxRfayJuRfNqEL1DV2n/aJRtmP4iL4VxBTkdjjzLEdsldwvyAOqH3 ek6DaGfvJN/d8nVZ4u6IcgFrnI+mW7DWt914Mi2OCDv8lkgpO3xdc1qij4qeyZmoBO+8 Munw== 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=0+GnUKluiJDVSVzsNJE6rCvY3nEUVC6fWJDpSRriJCU=; fh=YUoKI3y81WpgTq5CH9PN5U0wZIwo0D0r6Bvi/7kNfCQ=; b=bQiGK4B3ci0EcwpgpC0g8B5aJE7WklhiPNNuhgQTUXcmrr8qoGFr51/a7M2NYzpVFV F05qXUAgq1WuBGoqmXV/p8IgQI98he0ksJiPM6VNaOGftZaLUD712XkspVd3yr0IEjEt Qo0sV6SXR742QgzdMO4pHvwViJEjw+LkMgToNkj6KrYeN54rVcEPekc+NRJzR8GMUepA 8PB1oh5FqcRqqYKg74uBGzpjgcrAEOjHDftfKbjb6dp8PWv97k4QBWydCzSWvkZzsbSy b/nC9CSxd9B4oLi1RBYGmKbcgfaDQ58jxSv4cpCvySMWBno/Z1WSu8hkaGjci+ZdDz0b WgXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A1xCf7CR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b9-20020a170902650900b001e4063f59a4si9291019plk.581.2024.04.23.05.05.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A1xCf7CR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155069-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 119BBB26AFE for ; Tue, 23 Apr 2024 11:54:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BBAE1482F6; Tue, 23 Apr 2024 11:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A1xCf7CR" 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 4C55E147C75; Tue, 23 Apr 2024 11:41:39 +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=1713872499; cv=none; b=eUMUrqQNHH7OpkunM4vIa339a1r4XtKuyXbiBexm+1PsEjGHkUFnqacAnsRQvQVN5/vFIyLUGha4ujjPKfCVmyWu4p2CST8v9FLnzaaNSpfuOAcO/jJcPJWanqunp9HNT3248FfnbFy5JoYqd7jy4eWpj7V8HkfBooQ9grMhJTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713872499; c=relaxed/simple; bh=It5ieeiGLQBbVO/VocXMayUZ4M94B8Ebxj9EVLkv/+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EZZ6gBF5e1o7UaoccxnmhRoH6CY+8wtPvYHyFYGLjfeGwho/gZyElzpggaIaeBKqHSOFfKZhPrBbdP1F1Bkxni4OJSIFeb+qAj9RMZg+bOBvmD6xeH+U9Ob/5beVjsqZ8fv6COCfTj5RRebihM9iiVc6DL6oMtUgOia+wxu41jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A1xCf7CR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FF44C32782; Tue, 23 Apr 2024 11:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713872499; bh=It5ieeiGLQBbVO/VocXMayUZ4M94B8Ebxj9EVLkv/+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1xCf7CRI7iuIR96Ji+/Hx0dCxZzKDDkAz2AtM9aSz1ZAjBlNAQqajfqmrIjHM3ms AsqNH4tV+URpN6q+hpl2Z4jux3zrxBoWSbGKBYmSZWrFCU+IuUMKOdcjJKBAitx2o2 OIfwlta8SZSDjwLDF2CodK5vmnfXnjlgjyjAd5f/+hl9yUBYlUaxeOnt1WGThPQLTf NbYjxZCg2B9LOt9Vj3OwhhU1i+N8JHG/LcUYMG4DSPjlNfTUtpVD7WKuHxNjcEFzuE Nr2g+2bsuAqgOb80DF7bSZrt5r7w9kcKbQZiGiPvzZLrgAbQbUDBg3oqggNhMKAKcE FrjfAAgON81qg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stephen Boyd , Douglas Anderson , Sasha Levin , mturquette@baylibre.com, linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 6/9] clk: Don't hold prepare_lock when calling kref_put() Date: Tue, 23 Apr 2024 07:02:44 -0400 Message-ID: <20240423110249.1659263-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240423110249.1659263-1-sashal@kernel.org> References: <20240423110249.1659263-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.215 Content-Transfer-Encoding: 8bit From: Stephen Boyd [ Upstream commit 6f63af7511e7058f3fa4ad5b8102210741c9f947 ] 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 Link: https://lore.kernel.org/r/20240325184204.745706-3-sboyd@kernel.org Signed-off-by: Sasha Levin --- 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 aa2f1f8aa2994..c64beabca7cde 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4096,7 +4096,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 @@ -4130,11 +4131,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); @@ -4297,13 +4297,11 @@ void __clk_put(struct clk *clk) clk->max_rate < clk->core->req_rate) clk_core_set_rate_nolock(clk->core, clk->core->req_rate); - 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); } -- 2.43.0