[{"id":3679832,"web_url":"http://patchwork.ozlabs.org/comment/3679832/","msgid":"<aedfEzeRH5tH0-Fb@monoceros>","list_archive_url":null,"date":"2026-04-21T11:40:55","subject":"Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as\n atomic","submitter":{"id":88416,"url":"http://patchwork.ozlabs.org/api/people/88416/","name":"Uwe Kleine-König","email":"ukleinek@kernel.org"},"content":"Hello Sangyun,\n\nOn Sun, Apr 19, 2026 at 05:08:38PM +0900, Sangyun Kim wrote:\n> @@ -438,16 +441,33 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n>  \tif (err)\n>  \t\tgoto err_gclk;\n>  \n> +\terr = clk_rate_exclusive_get(tcbpwmc->clk);\n> +\tif (err)\n> +\t\tgoto err_disable_clk;\n> +\n> +\terr = clk_rate_exclusive_get(tcbpwmc->slow_clk);\n> +\tif (err)\n> +\t\tgoto err_clk_unlock;\n> +\n> +\ttcbpwmc->rate = clk_get_rate(tcbpwmc->clk);\n> +\ttcbpwmc->slow_rate = clk_get_rate(tcbpwmc->slow_clk);\n> +\n\nOnly one concern left: clk_get_rate() should only be called on enabled\nclocks. I don't know the architecture details and how expensive it is to\nhave .clk enabled (or if it's enabled anyhow).\n\nIf you're ok, I'd squash the following diff into your patch:\n\ndiff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c\nindex 1a2832f1ace2..3d30aeab507e 100644\n--- a/drivers/pwm/pwm-atmel-tcb.c\n+++ b/drivers/pwm/pwm-atmel-tcb.c\n@@ -437,13 +437,17 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n \ttcbpwmc->channel = channel;\n \ttcbpwmc->width = config->counter_width;\n \n-\terr = clk_prepare_enable(tcbpwmc->slow_clk);\n+\terr = clk_prepare_enable(tcbpwmc->clk);\n \tif (err)\n \t\tgoto err_gclk;\n \n+\terr = clk_prepare_enable(tcbpwmc->slow_clk);\n+\tif (err)\n+\t\tgoto err_disable_clk;;\n+\n \terr = clk_rate_exclusive_get(tcbpwmc->clk);\n \tif (err)\n-\t\tgoto err_disable_clk;\n+\t\tgoto err_disable_slow_clk;\n \n \terr = clk_rate_exclusive_get(tcbpwmc->slow_clk);\n \tif (err)\n@@ -469,6 +473,9 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n \tclk_rate_exclusive_put(tcbpwmc->clk);\n \n err_disable_clk:\n+\tclk_disable_unprepare(tcbpwmc->clk);\n+\n+err_disable_slow_clk:\n \tclk_disable_unprepare(tcbpwmc->slow_clk);\n \n err_gclk:\n@@ -492,6 +499,7 @@ static void atmel_tcb_pwm_remove(struct platform_device *pdev)\n \n \tclk_rate_exclusive_put(tcbpwmc->slow_clk);\n \tclk_rate_exclusive_put(tcbpwmc->clk);\n+\tclk_disable_unprepare(tcbpwmc->clk);\n \tclk_disable_unprepare(tcbpwmc->slow_clk);\n \tclk_put(tcbpwmc->gclk);\n \tclk_put(tcbpwmc->clk);\n\n\nThis has the downside that clk is kept enabled the whole driver\nlifetime, but that's the easiest way to make your fix honor the clk API\nconstraints. This allows to fast-track the patch fixing the sleeping\nfunction called from invalid context issue and the optimisation can then\nbe addressed with more time during the next development cycles.\n\nBest regards\nUwe","headers":{"Return-Path":"\n <linux-pwm+bounces-8664-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pwm@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=JnHmsRiS;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8664-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"JnHmsRiS\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sin.lore.kernel.org (sin.lore.kernel.org\n [IPv6:2600:3c15:e001:75::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0L5p6CwJz1yGt\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 21:41:02 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id 0DA293008CBB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 11:41:00 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id A8A89276049;\n\tTue, 21 Apr 2026 11:40:58 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 85FA413C9C4;\n\tTue, 21 Apr 2026 11:40:58 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id C072FC2BCB0;\n\tTue, 21 Apr 2026 11:40:57 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776771658; cv=none;\n b=PgVI93iK5eOZ6/2dnLjsW2RRbm4Usz0Py83OATLK/kcrH0dvNxyFuW1Wy9snOfHVEVbWhHy2GdB5VX4Yvq09O3RYU3x+gNU52hlGuDKHexsl9fR+pJ1aaVDeVttkYYNimg1AkJS1InP8xrnYDvOGLuZIPsc6Wx/+IbM3qD1z4iE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776771658; c=relaxed/simple;\n\tbh=AMrZo1hx0IaVR554MMJRzqOTHAysXa89TiJakACup3w=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=GyuGACzLiEZqIiwHiAd8PTpfOqr1sSo9kE2VHDrWjWQvkYz6vPejNNdQVvX/C2uDQS7p0ERNy1jrI8tEoGHTyaS/usU1KTFO9xXGgXIvwZvMHYK8rnvW+oQu6vS6gIqz950JzGf3KIrwpXIv4RNmRNkg2d70wMN+Fct/owCOLfs=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=JnHmsRiS; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776771658;\n\tbh=AMrZo1hx0IaVR554MMJRzqOTHAysXa89TiJakACup3w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JnHmsRiScc5GjzXlfh0NjHFnm9wOfj8svUl52iPpZKhGdUtgk8jl8OO/AN7wHh2dA\n\t 9ybsedV1naVRheAdzo6wj0TDYbYK/w2rVR4qsBs3Q/8BSmsJzdEGdK6AJJtcsKGpo/\n\t wNHDUVfBPjIDParXLo2fKN4S/HwKhMM6VofQTbx/KhpQ8jgrdiqRfZBeuTk9jOrBoR\n\t te9BAsxHW+mqsvhiCWw+WXq+2HC8WOrEBjfa4dZs8w6FLzeZefcuqPPAPbXltEBTzz\n\t 5ftIjazSXQ/D2AuTaen1lHLuQXFE8Par1wSCHYHOIC3UFG4cLcmmki6Mne1kQJz1UZ\n\t 3lyiUgPQ3YASA==","Date":"Tue, 21 Apr 2026 13:40:55 +0200","From":"Uwe =?utf-8?q?Kleine-K=C3=B6nig?= <ukleinek@kernel.org>","To":"Sangyun Kim <sangyun.kim@snu.ac.kr>","Cc":"nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,\n\tclaudiu.beznea@tuxon.dev, linux-pwm@vger.kernel.org,\n linux-arm-kernel@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org","Subject":"Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as\n atomic","Message-ID":"<aedfEzeRH5tH0-Fb@monoceros>","References":"<20260415093433.2359955-1-sangyun.kim@snu.ac.kr>\n <20260419080838.3192357-1-sangyun.kim@snu.ac.kr>","Precedence":"bulk","X-Mailing-List":"linux-pwm@vger.kernel.org","List-Id":"<linux-pwm.vger.kernel.org>","List-Subscribe":"<mailto:linux-pwm+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pwm+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha512;\n\tprotocol=\"application/pgp-signature\"; boundary=\"zmlydvd5ruato4sk\"","Content-Disposition":"inline","In-Reply-To":"<20260419080838.3192357-1-sangyun.kim@snu.ac.kr>"}},{"id":3680221,"web_url":"http://patchwork.ozlabs.org/comment/3680221/","msgid":"<20260422044940.tse3ek7jlv3x2dbt@nunu>","list_archive_url":null,"date":"2026-04-22T04:49:40","subject":"Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as\n atomic","submitter":{"id":93159,"url":"http://patchwork.ozlabs.org/api/people/93159/","name":"Sangyun Kim","email":"sangyun.kim@snu.ac.kr"},"content":"On Tue, Apr 21, 2026 at 01:40:55 PM +0200, Uwe Kleine-König wrote:\n>Hello Sangyun,\n\nHi Uwe,\nThanks for the review.\n\n>\n>On Sun, Apr 19, 2026 at 05:08:38PM +0900, Sangyun Kim wrote:\n>> @@ -438,16 +441,33 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n>>  \tif (err)\n>>  \t\tgoto err_gclk;\n>>\n>> +\terr = clk_rate_exclusive_get(tcbpwmc->clk);\n>> +\tif (err)\n>> +\t\tgoto err_disable_clk;\n>> +\n>> +\terr = clk_rate_exclusive_get(tcbpwmc->slow_clk);\n>> +\tif (err)\n>> +\t\tgoto err_clk_unlock;\n>> +\n>> +\ttcbpwmc->rate = clk_get_rate(tcbpwmc->clk);\n>> +\ttcbpwmc->slow_rate = clk_get_rate(tcbpwmc->slow_clk);\n>> +\n>\n>Only one concern left: clk_get_rate() should only be called on enabled\n>clocks. I don't know the architecture details and how expensive it is to\n>have .clk enabled (or if it's enabled anyhow).\n>\n>If you're ok, I'd squash the following diff into your patch:\n\nThat makes sense. clk_get_rate() should indeed only be used on enabled\nclocks, and your change is the simplest way to ensure correctness while\nrespecting the clk API constraints. I’m happy with squashing your diff\ninto my patch.\n\n>\n>diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c\n>index 1a2832f1ace2..3d30aeab507e 100644\n>--- a/drivers/pwm/pwm-atmel-tcb.c\n>+++ b/drivers/pwm/pwm-atmel-tcb.c\n>@@ -437,13 +437,17 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n> \ttcbpwmc->channel = channel;\n> \ttcbpwmc->width = config->counter_width;\n>\n>-\terr = clk_prepare_enable(tcbpwmc->slow_clk);\n>+\terr = clk_prepare_enable(tcbpwmc->clk);\n> \tif (err)\n> \t\tgoto err_gclk;\n>\n>+\terr = clk_prepare_enable(tcbpwmc->slow_clk);\n>+\tif (err)\n>+\t\tgoto err_disable_clk;;\n>+\n> \terr = clk_rate_exclusive_get(tcbpwmc->clk);\n> \tif (err)\n>-\t\tgoto err_disable_clk;\n>+\t\tgoto err_disable_slow_clk;\n>\n> \terr = clk_rate_exclusive_get(tcbpwmc->slow_clk);\n> \tif (err)\n>@@ -469,6 +473,9 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n> \tclk_rate_exclusive_put(tcbpwmc->clk);\n>\n> err_disable_clk:\n>+\tclk_disable_unprepare(tcbpwmc->clk);\n>+\n>+err_disable_slow_clk:\n> \tclk_disable_unprepare(tcbpwmc->slow_clk);\n>\n> err_gclk:\n>@@ -492,6 +499,7 @@ static void atmel_tcb_pwm_remove(struct platform_device *pdev)\n>\n> \tclk_rate_exclusive_put(tcbpwmc->slow_clk);\n> \tclk_rate_exclusive_put(tcbpwmc->clk);\n>+\tclk_disable_unprepare(tcbpwmc->clk);\n> \tclk_disable_unprepare(tcbpwmc->slow_clk);\n> \tclk_put(tcbpwmc->gclk);\n> \tclk_put(tcbpwmc->clk);\n>\n>\n>This has the downside that clk is kept enabled the whole driver\n>lifetime, but that's the easiest way to make your fix honor the clk API\n>constraints. This allows to fast-track the patch fixing the sleeping\n>function called from invalid context issue and the optimisation can then\n>be addressed with more time during the next development cycles.\n\nKeeping the clock enabled for the driver lifetime is acceptable for now\nto fast-track the fix, and we can revisit potential optimizations in a\nfollow-up patch.\n\nThanks again for the suggestion.\n\n>\n>Best regards\n>Uwe\n\nBest regards,\nSangyun","headers":{"Return-Path":"\n <linux-pwm+bounces-8668-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pwm@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=snu.ac.kr header.i=@snu.ac.kr header.a=rsa-sha256\n header.s=google header.b=G8K0zuPy;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8668-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=snu.ac.kr header.i=@snu.ac.kr\n header.b=\"G8K0zuPy\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.214.179","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=snu.ac.kr","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=snu.ac.kr"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0n1M5G4Yz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 14:53:43 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 4093E3055821\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 04:49:48 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id ED3672652A2;\n\tWed, 22 Apr 2026 04:49:47 +0000 (UTC)","from mail-pl1-f179.google.com (mail-pl1-f179.google.com\n [209.85.214.179])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D5A0277007\n\tfor <linux-pwm@vger.kernel.org>; Wed, 22 Apr 2026 04:49:44 +0000 (UTC)","by mail-pl1-f179.google.com with SMTP id\n d9443c01a7336-2b23fcf90b2so48265585ad.3\n        for <linux-pwm@vger.kernel.org>; Tue, 21 Apr 2026 21:49:44 -0700 (PDT)","from localhost (nunu.snu.ac.kr. [147.46.112.82])\n        by smtp.gmail.com with ESMTPSA id\n d9443c01a7336-2b5fab208d4sm160434605ad.55.2026.04.21.21.49.42\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Tue, 21 Apr 2026 21:49:43 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776833387; cv=none;\n b=LEmxtxojnu9YDZy9YBqV1ZSluwSH3j9DDUyffaJbjPAz5EbIYmrHeqbESAm3ZvUbBbOw7fCqL1zbBTSFy80A1SV9EeGr4wOVkzoLtqwLMN+WvTrbUNHgD1Zyv7AlqBJ269A4pduxgGwql4zC4SVRfojLnqYIDKHyBMC6EFWbRKA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776833387; c=relaxed/simple;\n\tbh=amoFYOXNj6ai1aoDXuC/QErgGvTREL0GtwLWXrsqXcg=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=EGIwkr96dotw3YDPtiadc6DmS8dnOOx0xM1Qd1K6stamlO59sOQ5PvPu5gcSQYQXnAo3GpZnEYH3qoOsLsofRPEqvwmigG23OVOl7/ZgivWvH/N1l5mrSyKiLWo+l6bNgda6q6b12g8KRI9lPbe7E6KQbAbXhj63/LJAvr4agoI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=snu.ac.kr;\n spf=pass smtp.mailfrom=snu.ac.kr;\n dkim=pass (1024-bit key) header.d=snu.ac.kr header.i=@snu.ac.kr\n header.b=G8K0zuPy; arc=none smtp.client-ip=209.85.214.179","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=snu.ac.kr; s=google; t=1776833383; x=1777438183;\n darn=vger.kernel.org;\n        h=in-reply-to:content-transfer-encoding:content-disposition\n         :mime-version:references:message-id:subject:cc:to:from:date:from:to\n         :cc:subject:date:message-id:reply-to;\n        bh=9eH4zus6aRXEsE79ZbJPuyaxQ8dOTtTmwWEdDWPv4Bs=;\n        b=G8K0zuPyRoYkvUe1EhM8NUBt1tHMZNeAVQzrApmScGaRhFM7njB6UGnaiwfwgjAmOC\n         CM73MJ+rbWI/NlfQLPlC7w4OxNmWIlX7X9NVAyUEiqmLc542HHFo2nkiuN4fSCkHC/uE\n         ZFe0ocnFcZvmT9r1j3UIMsYh4NgRt3RkXEwE4=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776833383; x=1777438183;\n        h=in-reply-to:content-transfer-encoding:content-disposition\n         :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg\n         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n        bh=9eH4zus6aRXEsE79ZbJPuyaxQ8dOTtTmwWEdDWPv4Bs=;\n        b=X6h6ox8A1YhO1mXernxYZssiF2m1j5Etaqu+kStOuE46JZIUjc3tNUMQAWM7A1v0Vo\n         sg6fGIMzQHrsRUJCH1eZtla9q0iIGs7DGDVX5brSkFxOmw3lkLv7VNWDfTlzVZlImraq\n         rqDx04dnd/QsGy28J3ePpvqkCRGwHfv1edDXmT4cI38vcnyRkdX+JJk35UowXTjh9FmL\n         gQrTlM74nX7h4hL79Pvz/e4Gk1tWmwFmezqvnipvz51sat9hY6PTrUQjuIK7r15KOrKK\n         emA9FmzrXznq9m8LXMImPxd1CbmbF+Ex/qiPodcGP2j21S+qMNltnVCdN79WErQfY0gI\n         w4yw==","X-Forwarded-Encrypted":"i=1;\n AFNElJ80sg5lo9ogfRo69362a8Ffq9Fw2mmdMEv49Ky/33nVkskyEQcZMxex3B+xwzQWpBRhr2zOIg7b7ZI=@vger.kernel.org","X-Gm-Message-State":"AOJu0YwWbvwNV2uvIZviNETcFJQP4oyvRHMNE6DRti0/E+mMGN+QSy9B\n\ttVYdEyf0Dz4rWCCDbcKCS/9v+71iG4j7deMxAcvgCm+0PnZ/gv0OtFbXikGL7JTMy54=","X-Gm-Gg":"AeBDiesfG8r14o/iLmCoW9pp+pHnKE8Gxmj8Zo7WRzUyXx8N1Vco1VVkBgTXovr9rMv\n\ttAIzRpCexUd6wmuFGDwR4xKU23ROzmy3YNsShnd9FW+4gl0DVYP2cfx0P/XzE+oJ0lL26OElCfd\n\tyedmG6XWcUbmqCJ5EZBXvFBahe3rMtCClnleQGV5FsF6H5e7MQQq2iFP9G0LmRAVFyUUqjR+eNp\n\tCduntMz57ZqvszEuDZVLzlOpH4tsmvNE1uK5jkH8x0Be4RZLaxVi3Y4GHT+fZIq5udQ4xExsf9K\n\tE2zBT7zrgbTOXUgWnw4ncXoEv9aCcez0+W3sVNGWTk3flBib53VtiZ6PqL6MapFw1wwPlZMamkb\n\tFvQxIvV9ndW2/uC/8Pfhq6t9Y+ay4sja9OSD4ogmaf6aLTpCbajJI+ci27VWQ+wwRvLEGELsGMy\n\tApK2g6VGXuTrUzhCvxBBtQqum1pf9sCTlVKLKlR8GwUVCACcJgXMoFVIQRYbVeggu/nb7jJq3fv\n\tw==","X-Received":"by 2002:a17:902:f9cf:b0:2b2:50e1:f104 with SMTP id\n d9443c01a7336-2b5f9e64c18mr142624095ad.3.1776833383473;\n        Tue, 21 Apr 2026 21:49:43 -0700 (PDT)","Date":"Wed, 22 Apr 2026 13:49:40 +0900","From":"Sangyun Kim <sangyun.kim@snu.ac.kr>","To":"Uwe =?utf-8?q?Kleine-K=C3=B6nig?= <ukleinek@kernel.org>","Cc":"nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,\n\tclaudiu.beznea@tuxon.dev, linux-pwm@vger.kernel.org,\n\tlinux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org","Subject":"Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as\n atomic","Message-ID":"<20260422044940.tse3ek7jlv3x2dbt@nunu>","References":"<20260415093433.2359955-1-sangyun.kim@snu.ac.kr>\n <20260419080838.3192357-1-sangyun.kim@snu.ac.kr>\n <aedfEzeRH5tH0-Fb@monoceros>","Precedence":"bulk","X-Mailing-List":"linux-pwm@vger.kernel.org","List-Id":"<linux-pwm.vger.kernel.org>","List-Subscribe":"<mailto:linux-pwm+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pwm+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<aedfEzeRH5tH0-Fb@monoceros>"}},{"id":3681967,"web_url":"http://patchwork.ozlabs.org/comment/3681967/","msgid":"<aetJZzTHd4RBcytw@monoceros>","list_archive_url":null,"date":"2026-04-24T10:46:00","subject":"Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as\n atomic","submitter":{"id":88416,"url":"http://patchwork.ozlabs.org/api/people/88416/","name":"Uwe Kleine-König","email":"ukleinek@kernel.org"},"content":"Hello Sangyun,\n\nOn Wed, Apr 22, 2026 at 01:49:40PM +0900, Sangyun Kim wrote:\n> > On Sun, Apr 19, 2026 at 05:08:38PM +0900, Sangyun Kim wrote:\n> > > @@ -438,16 +441,33 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)\n> > >  \tif (err)\n> > >  \t\tgoto err_gclk;\n> > > \n> > > +\terr = clk_rate_exclusive_get(tcbpwmc->clk);\n> > > +\tif (err)\n> > > +\t\tgoto err_disable_clk;\n> > > +\n> > > +\terr = clk_rate_exclusive_get(tcbpwmc->slow_clk);\n> > > +\tif (err)\n> > > +\t\tgoto err_clk_unlock;\n> > > +\n> > > +\ttcbpwmc->rate = clk_get_rate(tcbpwmc->clk);\n> > > +\ttcbpwmc->slow_rate = clk_get_rate(tcbpwmc->slow_clk);\n> > > +\n> > \n> > Only one concern left: clk_get_rate() should only be called on enabled\n> > clocks. I don't know the architecture details and how expensive it is to\n> > have .clk enabled (or if it's enabled anyhow).\n> > \n> > If you're ok, I'd squash the following diff into your patch:\n> \n> That makes sense. clk_get_rate() should indeed only be used on enabled\n> clocks, and your change is the simplest way to ensure correctness while\n> respecting the clk API constraints. I’m happy with squashing your diff\n> into my patch.\n\nJust for the record: I did that, the result is already in Linus' tree\nat https://git.kernel.org/linus/68637b68afcc3cb4d56aca14a3a1d1b47b879369\nand will be part of v7.1-rc1.\n\nBest regards\nUwe","headers":{"Return-Path":"\n <linux-pwm+bounces-8689-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pwm@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=pFpfhwgD;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8689-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"pFpfhwgD\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g28l32vsXz1yDD\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 20:46:07 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id E297D300145B\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 24 Apr 2026 10:46:04 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id E31772882BE;\n\tFri, 24 Apr 2026 10:46:02 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B75672D3EF2;\n\tFri, 24 Apr 2026 10:46:02 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 24BF6C19425;\n\tFri, 24 Apr 2026 10:46:01 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777027562; cv=none;\n b=YuFeFxY4VY1KcvdRA6b87h6FKycLo76jhPNLFORWuhpPj66eCkSE4XLLQLnEAVitUZOaJR/cGx55zQHeyGSZeRL31DMwG7FQca8FL+jN3gP3+qyxBYA7zAeoIZN0xMPnrSE0KuBQTpWd3BepU6xQ0LCebp4ljlK/pvWLgJ5aOKQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777027562; c=relaxed/simple;\n\tbh=wdjDn556jbNQ7WzXeovxIVH/s2CXei4diJaRwgeH7JQ=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=DVQbuar2yOmrJ2CwI/MwvFaNDtmD1nY9t/8rHWBtm+nE0uGynhsnNOior20KbvEOa6IWIMtLc2QbP2x4pf0kvGUXJlHuYd/xV323RxjxL6DgtGDj+Xscz5qI9ysJ2JDg6me+yRu3tBaVF75qgfx0egAcm+XiVAPwPi+SE3l1dTI=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=pFpfhwgD; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777027562;\n\tbh=wdjDn556jbNQ7WzXeovxIVH/s2CXei4diJaRwgeH7JQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pFpfhwgDLwVhkonHJohzjlaMdgRTAV05QdGH90A4J3liKHg1pMfsHoIlIA8JYM4/u\n\t KM5X9kK4PESEn1AMXMrr8e9TfO+Eqf2c63LsY/dR73mWFVuxOHH4iKTmcQDoAKhwsX\n\t tvmDyC5AHyIJKb5kXi+LQLP4+Il4P/bOZBTeEQ1jDstDfgUavlZsFqlc7p0f6qSzBj\n\t HkUUNMXXU/bQdRDaPPuPsIYhFRWA7ILKrMG5DaKJxtCV9JXU0WCUudSaQDq1w4zdPc\n\t otMC2pBvlhRjkLcOf/hmdVvfOC/9xE/n7OORCFHJGdo790iqZFZdByPUlCp7dqDlvP\n\t 2EaQbZO3rfysA==","Date":"Fri, 24 Apr 2026 12:46:00 +0200","From":"Uwe =?utf-8?q?Kleine-K=C3=B6nig?= <ukleinek@kernel.org>","To":"Sangyun Kim <sangyun.kim@snu.ac.kr>","Cc":"nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,\n\tclaudiu.beznea@tuxon.dev, linux-pwm@vger.kernel.org,\n linux-arm-kernel@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org","Subject":"Re: [PATCH v2] pwm: atmel-tcb: Cache clock rates and mark chip as\n atomic","Message-ID":"<aetJZzTHd4RBcytw@monoceros>","References":"<20260415093433.2359955-1-sangyun.kim@snu.ac.kr>\n <20260419080838.3192357-1-sangyun.kim@snu.ac.kr>\n <aedfEzeRH5tH0-Fb@monoceros>\n <20260422044940.tse3ek7jlv3x2dbt@nunu>","Precedence":"bulk","X-Mailing-List":"linux-pwm@vger.kernel.org","List-Id":"<linux-pwm.vger.kernel.org>","List-Subscribe":"<mailto:linux-pwm+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pwm+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha512;\n\tprotocol=\"application/pgp-signature\"; boundary=\"xeni4cw4nw33ej5e\"","Content-Disposition":"inline","In-Reply-To":"<20260422044940.tse3ek7jlv3x2dbt@nunu>"}}]