From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 CAEA72DCBF8 for ; Thu, 6 Aug 2026 00:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785975289; cv=none; b=XhMr3ORU3V0LkK/2abit2BsRm9FuZPH+z9HurxTIv/hir3tG3B1RnWekuwL6aJRyiWwbH/r9ZmcUSvPPHDpwBwreKzEIFDSPlr3caWwJM1u/BaWP6mm0gB5AYni7oXdFqihdWgo6RsFV1NoKm3h4tE/foaPx37IZIuaePvR3wSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785975289; c=relaxed/simple; bh=TCOeojARLb3MBkjNdpdSt2zaLkUZYeR0EbfJg8HBZf4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WoZWRDodLlZybZIm/TEGOfw+rVKPbpnqmnDrNUsE9zlE58EQCxcSmJqOghEQzrZOu9uiJHPOYHdhW+EX/TwYfiYNm1U1FaN2ZnPU+gdPaW1rPI0kQeBDljGk5/atNgsZTxP9HHkmmSmRzhycKcSEuDsPc7UNarq90ZI2Q3Dgmqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Z3jCsFtg; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=MYI1AR4r; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z3jCsFtg"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="MYI1AR4r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1785975286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bOdorbk/UlhKifvig4KB0lM7KTYBeYcFRnwahVZUW58=; b=Z3jCsFtg6kYxTbizKRZy3Tvvn00aZQE2pYvBiqkEYh2E2sCVa+p042QSXId+tLn6/JWBQ3 ILvp6RJGS9kOImmvbODZmZKhlGpJERTcsRVqN/PwWUgdla863NXyP0PPkQjGOmUYXWm4xM stK+RJY1aGo8x10Vncq8BNz8wnO8uo8= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-qwnodBbEO_6Puz_h_YeirA-1; Wed, 05 Aug 2026 20:14:45 -0400 X-MC-Unique: qwnodBbEO_6Puz_h_YeirA-1 X-Mimecast-MFC-AGG-ID: qwnodBbEO_6Puz_h_YeirA_1785975285 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-81bee860fb7so52938057b3.3 for ; Wed, 05 Aug 2026 17:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1785975285; x=1786580085; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=bOdorbk/UlhKifvig4KB0lM7KTYBeYcFRnwahVZUW58=; b=MYI1AR4rZIN9oi+V9Re+827hC83TXsfe1Kl1mgdvXvLROsWqomYslzSiH7tPc5HyY2 DZyKfxg8piEhXbtyKgGx0MAmJkrfFG9nn99evU6Omt3V9/EXl3rLZCLe2tjZkvsaod/I GQEUmSUqzFMJp2gPd5lwe/bZE+1R2ipQjXn9DjvZvA8DCDjFcZvXYrnSZZxK90BMqZGB xWJX2+f9sTM8fHQRYdjCRBj3lEssGq63f6IXYqFR6OFywqdZHKyre0JDAeImpDfY57IJ uJhfXf8rHLLfMrTl9xZ8oPPhqq2huhMYzqBmIy0d/WBSS6YbaUVTLUoKUa9J6DJOyL8S HZ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785975285; x=1786580085; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=bOdorbk/UlhKifvig4KB0lM7KTYBeYcFRnwahVZUW58=; b=e5wc2vPrCrFRcYDEm+iQJfSEovfvz7Grm2uzvaTMq6rFpucfx9+h67UKPKUGxjm+GF B/LkQxFhz6X4hnc8uff3ZDhYEJdbLUMXidhqT1KG858a7TXhhsTEZ9kapIXl1D+lNPza cfLGKukIVsJtUUBx30OLi09xIxMh9E1TB62JQfVQ0eOls2fKVhFnpos61NFjaWdJ1L06 ql0cBN/cnJruJDUBZQVS12SF90J46MdgUAQA//xUIp7uAwZKZZrxGQDGQKWEJ2TT963V qpsiiTtwCISPFrtMqypfZHHI0IqfSoUi1UUQlVcqJAZvq0ug6NNxCV/ji4KReby995ef KqPg== X-Forwarded-Encrypted: i=1; AHgh+RqTy8lsUaMfmgXnjxcdZY55Syflp56geMQ79ZiD8Ni0ZHguxK+b0WWm3vjynXNd6UOgM5lzJjqq43lAoKU=@vger.kernel.org X-Gm-Message-State: AOJu0YzDsGfUQMQgEOlZqyZsWzAwpzlu6XcsQiZbT1eqZnh1b2IrXRJQ Le1JVS+vHJ9AM7nsUMfxhKzPLqx4vTV1tbkbrrTn/eKNyY3+CPRUhsDswrXD29yN6hXv0sTP549 /RlceooqXs7fEkzoUVkXCW3W0DsSpFJlHgY6D/xqsdE5xUj8uKGSZmK09QdRBqsIfRA== X-Gm-Gg: AR+sD13CsBBDSGh4KFa8gEgZosimicyiBrY/EQ7DDXPbtA9I4KRuzoUdD1+7CXJ7LW/ seya6ATEIdYLMnsEcIlEyKQRXPzRkIFOAkio8ty8z4ttftC3pTPKvUaFNU8YbwMdvO24lrAKurl 43vYoGLYnLWZ8ogM/rb8hA+wzYDbC+ACi19rl9h/tkNbATKWSf3M4Ovn7JNcgWvbmLZRXK8SUvi +qJOPKzFQpgEz7KvAqA9qNanwHQAjJ5uopecKdWXQ+o1HsKflqllScTMRu3jMo9fMYEy9h4nqPK +/zP64HJGE0YbspyTMknof9ZK7TYXh+b914gApSGeybf3SOPQqYxe9j6JtlMetr9Uc5yQ1b/H2L Vz+fCTsHIK9qIV2fu9Cw4ChT5gK1/rwCno7U= X-Received: by 2002:a05:690c:3613:b0:81e:9826:942c with SMTP id 00721157ae682-8201bab4aeamr67377757b3.0.1785975284782; Wed, 05 Aug 2026 17:14:44 -0700 (PDT) X-Received: by 2002:a05:690c:3613:b0:81e:9826:942c with SMTP id 00721157ae682-8201bab4aeamr67377517b3.0.1785975284317; Wed, 05 Aug 2026 17:14:44 -0700 (PDT) Received: from redhat.com (c-73-183-53-213.hsd1.pa.comcast.net. [73.183.53.213]) by smtp.gmail.com with ESMTPSA id 00721157ae682-82013c49127sm29075737b3.32.2026.08.05.17.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 17:14:43 -0700 (PDT) Date: Wed, 5 Aug 2026 20:14:42 -0400 From: Brian Masney To: Jerome Brunet , Chen-Yu Tsai Cc: Michael Turquette , Stephen Boyd , Russell King , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] clk: fix self-consuming provider module pinning Message-ID: References: <20260723-clk-provider-pinning-v2-1-8dad72eb79f0@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260723-clk-provider-pinning-v2-1-8dad72eb79f0@baylibre.com> User-Agent: Mutt/2.4.0 (2026-06-19) Hi Chen-Yu, On Thu, Jul 23, 2026 at 03:00:51PM +0200, Jerome Brunet wrote: > clk_hw_get_clk() lets a provider get a struct clk for one of its own > struct clk_hw. > > When a struct clk is created, the module usage count of the provider > is unconditionally increased. For a self-consuming provider, this means > it pins itself and the module can never be unloaded. > > Increasing the module usage count should only be done when the consumer > lives in a different module from the provider. Use THIS_MODULE to > capture caller's module and increase the module usage count accordingly. > > It is OK for consumer-only APIs such as clk_get() or of_clk_get() to > pass a NULL owner. As a result, any provider module will get pinned, > same as before. > > Fixes: 30d6f8c15d2c ("clk: add api to get clk consumer from clk_hw") > Signed-off-by: Jerome Brunet > --- > This issue has been present for a while. Virtually all users of > clk_hw_get_clk() are affected. The majority are compiled as builtins > according to the defconfigs. It is not problem in this case but it is > if the configuration is changed to module. > > The following modules are using clk_hw_get_clk() and are compiled as > module with some shipped defconfigs: > * drivers/gpu/drm/msm/disp/mdp4/mdp4_lvds_pll.c > * drivers/phy/cadence/phy-cadence-sierra.c > * drivers/pwm/pwm-meson.c > * sound/soc/codecs/lpass-va-macro.c > > Currently those module cannot be unloaded once they have been loaded. > > """ > rmmod: ERROR: Module blabla-module is in use > """ > > With this applied, we can get back to removing the direct usage > of the struct clk in struct clk_hw and eventually remove this > struct member entirely. Do you have any thoughts about this patch to the clk core? I agree with Stephen that we should add kunit tests for changes to the clk core where possible, however in this particular case I think it would be very complicated. It also feels more like an integration test instead of a unit test to me. In the hopefully limited cases where we don't add kunit tests, I think it would be good to get multiple trusted contributors to review. Thanks, Brian