From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gofer.mess.org (gofer.mess.org [88.97.38.141]) (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 9EAD8374C0; Tue, 19 Dec 2023 17:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mess.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mess.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mess.org header.i=@mess.org header.b="fuyZeC94" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703005464; bh=Mk9PhkmouZ13dtQwJISx9AtOkdubRybUQt5D1rkXFrs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fuyZeC9428j2fdhhR3IhMBmr2XL5MSFZN0xIIdCCywHWHR9Q+0blG4LqouDPRN+G+ unxHV+139w1UI8IfecS6IBOxvn6gBtg+pOrEFkJv4OlG3/GnLeYa6Q3kGH6FLBtaeo cM+uncmQlltL4VnCizkjoigt941AbvDMcBmuQBht4q7lV9BRDrvRDSPlSXDIoEU23a wZxgVYvQ2d4kjdYWsvvt2mzRivCUl0det1h9EfkvA5W7VYU9nX7kwVyajG9kxhz/0W jI+wunyZmTN2walGiorVVLVS5s9THnVRTTqjTmy0GiCapRVcEsoDeiAIxV+zlMOesS +kk2z7yHKPBtQ== Received: by gofer.mess.org (Postfix, from userid 1000) id E2EAB1000FD; Tue, 19 Dec 2023 17:04:24 +0000 (GMT) Date: Tue, 19 Dec 2023 17:04:24 +0000 From: Sean Young To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 5/6] pwm: bcm2835: Allow PWM driver to be used in atomic context Message-ID: References: <5249bb5d6c067692e4cd09573ced2df58966693b.1702890244.git.sean@mess.org> Precedence: bulk X-Mailing-List: linux-pwm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hello Uwe, On Mon, Dec 18, 2023 at 10:31:36AM +0100, Uwe Kleine-König wrote: > On Mon, Dec 18, 2023 at 09:06:46AM +0000, Sean Young wrote: > > + pc->rate = clk_get_rate(pc->clk); > > + if (!pc->rate) { > > + clk_rate_exclusive_put(pc->clk); > > + return dev_err_probe(&pdev->dev, -EINVAL, > > + "failed to get clock rate\n"); > > + } > > + > > pc->chip.dev = &pdev->dev; > > pc->chip.ops = &bcm2835_pwm_ops; > > + pc->chip.atomic = true; > > pc->chip.npwm = 2; > > > > platform_set_drvdata(pdev, pc); > > > > ret = devm_pwmchip_add(&pdev->dev, &pc->chip); > > - if (ret < 0) > > + if (ret < 0) { > > + clk_rate_exclusive_put(pc->clk); > > return dev_err_probe(&pdev->dev, ret, > > "failed to add pwmchip\n"); > > + } > > + > > + return 0; > > +} > > + > > +static int bcm2835_pwm_remove(struct platform_device *pdev) > > +{ > > + struct bcm2835_pwm *pc = platform_get_drvdata(pdev); > > + > > + clk_rate_exclusive_put(pc->clk); > > The ugly thing here is that now clk_rate_exclusive_put() happens before > pwmchip_remove(). Mixing devm with non-devm does lead to problems like this. > Maybe register a devm cleanup which also gets rid of > the two clk_rate_exclusive_put() in probe's error path? That's good idea, I've done that in v10. > > > return 0; > > } > > @@ -197,6 +216,7 @@ static struct platform_driver bcm2835_pwm_driver = { > > .pm = pm_ptr(&bcm2835_pwm_pm_ops), > > }, > > .probe = bcm2835_pwm_probe, > > + .remove = bcm2835_pwm_remove, > > Please use .remove_new No longer needed in v10. Sean From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73D6CC46CCD for ; Tue, 19 Dec 2023 17:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JBD2tsWtwCVMAxal2ZMvq6MN4tYvKLFINR+DFjk3i6Q=; b=Tgg+kGTTb+51DS ZyYsqhrONQY14qD9yslJRwds2cIuZfujKBfiC6RvZ5uO9Q8J7MzXYi/C5ACZVlZBqCxoabpl6epde x+kJOyRkZu6IzYrLKdEohPsa0G7A6G0zrGg3/hnfmbMnh1T3CVb5RBOuGJWrGc+opuFUJfDm1D31D usMf2dHdHqXx3NRbIXZyku3TAOvbJfAyj9rRxd7dxtLaoXaIWAwLrKW+RqfSdJsSFdSlsLbfC8I3x 6JGd2hRoeNIXiaTVvi/y6HU3UEe3bgpG6cwSLjpCQ4ZyIisWGehjQMqXIy9UDmhVhmmEkMm1jtF8h uF3n2CclfrwMiPqKUSkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFdWe-00ErLF-0a; Tue, 19 Dec 2023 17:05:00 +0000 Received: from gofer.mess.org ([88.97.38.141]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFdW9-00Er48-0E; Tue, 19 Dec 2023 17:04:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mess.org; s=2020; t=1703005464; bh=Mk9PhkmouZ13dtQwJISx9AtOkdubRybUQt5D1rkXFrs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fuyZeC9428j2fdhhR3IhMBmr2XL5MSFZN0xIIdCCywHWHR9Q+0blG4LqouDPRN+G+ unxHV+139w1UI8IfecS6IBOxvn6gBtg+pOrEFkJv4OlG3/GnLeYa6Q3kGH6FLBtaeo cM+uncmQlltL4VnCizkjoigt941AbvDMcBmuQBht4q7lV9BRDrvRDSPlSXDIoEU23a wZxgVYvQ2d4kjdYWsvvt2mzRivCUl0det1h9EfkvA5W7VYU9nX7kwVyajG9kxhz/0W jI+wunyZmTN2walGiorVVLVS5s9THnVRTTqjTmy0GiCapRVcEsoDeiAIxV+zlMOesS +kk2z7yHKPBtQ== Received: by gofer.mess.org (Postfix, from userid 1000) id E2EAB1000FD; Tue, 19 Dec 2023 17:04:24 +0000 (GMT) Date: Tue, 19 Dec 2023 17:04:24 +0000 From: Sean Young To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: linux-media@vger.kernel.org, linux-pwm@vger.kernel.org, Ivaylo Dimitrov , Thierry Reding , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 5/6] pwm: bcm2835: Allow PWM driver to be used in atomic context Message-ID: References: <5249bb5d6c067692e4cd09573ced2df58966693b.1702890244.git.sean@mess.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_090429_427442_EAE730FB X-CRM114-Status: GOOD ( 18.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello Uwe, On Mon, Dec 18, 2023 at 10:31:36AM +0100, Uwe Kleine-K=F6nig wrote: > On Mon, Dec 18, 2023 at 09:06:46AM +0000, Sean Young wrote: > > + pc->rate =3D clk_get_rate(pc->clk); > > + if (!pc->rate) { > > + clk_rate_exclusive_put(pc->clk); > > + return dev_err_probe(&pdev->dev, -EINVAL, > > + "failed to get clock rate\n"); > > + } > > + > > pc->chip.dev =3D &pdev->dev; > > pc->chip.ops =3D &bcm2835_pwm_ops; > > + pc->chip.atomic =3D true; > > pc->chip.npwm =3D 2; > > = > > platform_set_drvdata(pdev, pc); > > = > > ret =3D devm_pwmchip_add(&pdev->dev, &pc->chip); > > - if (ret < 0) > > + if (ret < 0) { > > + clk_rate_exclusive_put(pc->clk); > > return dev_err_probe(&pdev->dev, ret, > > "failed to add pwmchip\n"); > > + } > > + > > + return 0; > > +} > > + > > +static int bcm2835_pwm_remove(struct platform_device *pdev) > > +{ > > + struct bcm2835_pwm *pc =3D platform_get_drvdata(pdev); > > + > > + clk_rate_exclusive_put(pc->clk); > = > The ugly thing here is that now clk_rate_exclusive_put() happens before > pwmchip_remove(). Mixing devm with non-devm does lead to problems like this. > Maybe register a devm cleanup which also gets rid of > the two clk_rate_exclusive_put() in probe's error path? That's good idea, I've done that in v10. > = > > return 0; > > } > > @@ -197,6 +216,7 @@ static struct platform_driver bcm2835_pwm_driver = =3D { > > .pm =3D pm_ptr(&bcm2835_pwm_pm_ops), > > }, > > .probe =3D bcm2835_pwm_probe, > > + .remove =3D bcm2835_pwm_remove, > = > Please use .remove_new No longer needed in v10. Sean _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel