LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Cc: linux-media@vger.kernel.org, ezequiel@vanguardiasur.com.ar,
	nicolas.dufresne@collabora.com, mchehab@kernel.org,
	robh+dt@kernel.org, mripard@kernel.org, wens@csie.org,
	p.zabel@pengutronix.de, gregkh@linuxfoundation.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: Re: Re: [PATCH 1/7] media: hantro: add support for reset lines
Date: Tue, 23 Nov 2021 17:46:30 +0100	[thread overview]
Message-ID: <9986998.nUPlyArG6x@kista> (raw)
In-Reply-To: <c474e2b5-8900-a7ca-620d-e03a284cf0fb@collabora.com>

Hi all,

Dne torek, 23. november 2021 ob 17:36:57 CET je Andrzej Pietrasiewicz 
napisal(a):
> Hi Dan, hi Jernej,
> 
> W dniu 23.11.2021 o 15:59, Dan Carpenter pisze:
> > On Tue, Nov 23, 2021 at 12:09:03PM +0100, Andrzej Pietrasiewicz wrote:
> >>> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/
media/hantro/hantro_drv.c
> >>> index ab2467998d29..8c3de31f51b3 100644
> >>> --- a/drivers/staging/media/hantro/hantro_drv.c
> >>> +++ b/drivers/staging/media/hantro/hantro_drv.c
> >>> @@ -905,6 +905,10 @@ static int hantro_probe(struct platform_device 
*pdev)
> >>>    			return PTR_ERR(vpu->clocks[0].clk);
> >>>    	}
> >>> +	vpu->resets = devm_reset_control_array_get(&pdev->dev, false, 
true);
> >>> +	if (IS_ERR(vpu->resets))
> >>> +		return PTR_ERR(vpu->resets);
> >>> +
> >>>    	num_bases = vpu->variant->num_regs ?: 1;
> >>>    	vpu->reg_bases = devm_kcalloc(&pdev->dev, num_bases,
> >>>    				      sizeof(*vpu->reg_bases), 
GFP_KERNEL);
> >>> @@ -978,10 +982,16 @@ static int hantro_probe(struct platform_device 
*pdev)
> >>>    	pm_runtime_use_autosuspend(vpu->dev);
> >>>    	pm_runtime_enable(vpu->dev);
> >          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > It looks like this is the pm stuff that we have to unwind on error
> > 
> >>> +	ret = reset_control_deassert(vpu->resets);
> >>> +	if (ret) {
> >>> +		dev_err(&pdev->dev, "Failed to deassert resets\n");
> >>> +		return ret;
> >                  ^^^^^^^^^^
> > So this return should be a goto undo_pm_stuff
> > 
> > 
> >>> +	}
> >>> +
> >>>    	ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
> >>>    	if (ret) {
> >>>    		dev_err(&pdev->dev, "Failed to prepare clocks\n");
> >>> -		return ret;
> > 
> > And this return should also have been a goto so it's a bug in the
> > original code.
> 
> So we probably want a separate patch addressing that first, and then
> the series proper on top of that.

I was just about to suggest that.

Other drivers usually enable PM last, so they don't have PM calls in unwind 
code. However, I think current approach is just as valid (with a fix).

Best regards,
Jernej

> 
> Regards,
> 
> Andrzej
> 
> > 
> >>> +		goto err_rst_assert;
> >>
> >> Before your patch is applied if clk_bulk_prepare() fails, we
> >> simply return on the spot. After the patch is applied not only
> >> do you...
> >>
> >>>    	}
> >>>    	ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
> >>> @@ -1037,6 +1047,8 @@ static int hantro_probe(struct platform_device 
*pdev)
> >>>    	v4l2_device_unregister(&vpu->v4l2_dev);
> >>>    err_clk_unprepare:
> >>>    	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);
> >>> +err_rst_assert:
> >>> +	reset_control_assert(vpu->resets);
> >>
> >> ...revert the effect of reset_control_deassert(), you also...
> >>
> >>>    	pm_runtime_dont_use_autosuspend(vpu->dev);
> >>>    	pm_runtime_disable(vpu->dev);
> >>
> >> ... do pm_*() stuff. Is there any reason why this is needed?
> > 
> > So, yes, it's needed, but you're correct to spot that it's not
> > consistent.
> > 
> > regards,
> > dan carpenter
> > 
> 
> 



  reply	other threads:[~2021-11-23 16:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22 18:46 [PATCH 0/7] media: hantro: add Allwinner H6 support Jernej Skrabec
2021-11-22 18:46 ` [PATCH 1/7] media: hantro: add support for reset lines Jernej Skrabec
2021-11-23 11:09   ` Andrzej Pietrasiewicz
2021-11-23 14:59     ` Dan Carpenter
2021-11-23 16:36       ` Andrzej Pietrasiewicz
2021-11-23 16:46         ` Jernej Škrabec [this message]
     [not found]           ` <CAAEAJfD3d4zjwvbv967+oe6awnAkZiGNKroYF5jvoTy=0sn+Pw@mail.gmail.com>
2021-11-30 10:39             ` Andrzej Pietrasiewicz
2021-11-22 18:46 ` [PATCH 2/7] media: hantro: vp9: use double buffering if needed Jernej Skrabec
2021-11-23 11:22   ` Andrzej Pietrasiewicz
2021-11-22 18:46 ` [PATCH 3/7] media: hantro: vp9: add support for legacy register set Jernej Skrabec
2021-11-23 12:06   ` Andrzej Pietrasiewicz
2021-11-22 18:46 ` [PATCH 4/7] media: hantro: move postproc enablement for old cores Jernej Skrabec
2021-11-23 12:12   ` Andrzej Pietrasiewicz
2021-11-25 12:00   ` Ezequiel Garcia
2021-11-25 19:21     ` Jernej Škrabec
2021-11-22 18:47 ` [PATCH 5/7] media: dt-bindings: allwinner: document H6 Hantro G2 binding Jernej Skrabec
2021-11-22 18:47 ` [PATCH 6/7] media: hantro: Add support for Allwinner H6 Jernej Skrabec
2021-11-23 12:23   ` Andrzej Pietrasiewicz
2021-11-22 18:47 ` [PATCH 7/7] arm64: dts: allwinner: h6: Add Hantro G2 node Jernej Skrabec
2021-11-22 18:51 ` [PATCH 0/7] media: hantro: add Allwinner H6 support Jernej Škrabec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9986998.nUPlyArG6x@kista \
    --to=jernej.skrabec@gmail.com \
    --cc=andrzej.p@collabora.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=wens@csie.org \
    --subject='Re: Re: [PATCH 1/7] media: hantro: add support for reset lines' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).