Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3872294ybz; Mon, 20 Apr 2020 11:00:55 -0700 (PDT) X-Google-Smtp-Source: APiQypJASLby7vH0DkABJuiZ/5nGPTG+VRFMA4kmqeaOYFDYHXb/EfGj4Ggfk9Z7W5QDrt2kZVt2 X-Received: by 2002:a17:906:5fd2:: with SMTP id k18mr16885885ejv.243.1587405654689; Mon, 20 Apr 2020 11:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587405654; cv=none; d=google.com; s=arc-20160816; b=pZyiPqD+8FWBUhrQiz2oLl8YvZMK5uVdslY/+aUUxm+xwM3eDczrHLSHpGRhSPj1/M 4pCIyQvJUggXBhwj9L0btl36x39sFgmnATpo2rfo+NSupLK1P3Ym9ADYHB7GRcsgqRfg zavrWbHxKZ5uDcAPZqrq7omf1lq+ETytHN7993GD6f17Bb0bCpP4TiIhJm8O/Q/LCbH0 3Qb3QZhhIciHtfHY2u7ZoTusemc/srHmBCwuL2iEPArbJ93TOG22P5a8bs389FZP7bF3 nmHl2O6QMKZHB0musKYtoWWOS8oS36HjnvmaIYiQT66qQ59LGH+O/5eDLe7kNSpmv7nj 0O5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jnbDdBqev6YaVbAijM5UL9e9wmbBzoFcdXXepcCPw9M=; b=iEh3wQGdbwB+OhBhvzImKPy0ZA9RwcFTS93X+ZDs6QBMQIinkA9dQ5h56GOM/wE906 DedBIr3+sSn1FGOxsAoIXN5d89i/Ut7dUs5kKDpa7ZfJDqwhz7GQAaM+WZnFlHbiRooI iPnBULD+w3fyFBNaaVYSooa1Up/rQjp8M2jBhUuR3gJtYdBZPKJtroheQdWQi3UgJYZU Jk77Sg8zHSnkZFupvgHyDIueggJirBmEjudV3fWFaR4pAINJLX6CWAGYV1jvEnENnw5D DPmGeFT1NXPkXhLi31KKcqNgKJvRIefyHXIBeB0Yh7ILa5lqC5CdqYOl+HiApR4EV27B 8xSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn21si1143305ejc.379.2020.04.20.11.00.30; Mon, 20 Apr 2020 11:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbgDTR44 (ORCPT + 99 others); Mon, 20 Apr 2020 13:56:56 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:35099 "EHLO relay11.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726013AbgDTR4z (ORCPT ); Mon, 20 Apr 2020 13:56:55 -0400 Received: from aptenodytes (196.109.29.93.rev.sfr.net [93.29.109.196]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 65F65100006; Mon, 20 Apr 2020 17:56:51 +0000 (UTC) Date: Mon, 20 Apr 2020 19:56:51 +0200 From: Paul Kocialkowski To: Jernej =?utf-8?Q?=C5=A0krabec?= Cc: Samuel Holland , linux-sunxi@googlegroups.com, Maxime Ripard , Chen-Yu Tsai , Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [linux-sunxi] [PATCH] media: cedrus: Implement runtime PM Message-ID: <20200420175651.GA610776@aptenodytes> References: <20200408010232.48432-1-samuel@sholland.org> <244922ec-ed3a-eca7-6640-49de7ad9c605@sholland.org> <20200420151010.GL125838@aptenodytes> <5590139.lOV4Wx5bFT@jernej-laptop> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: <5590139.lOV4Wx5bFT@jernej-laptop> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Jernej, On Mon 20 Apr 20, 18:41, Jernej =C5=A0krabec wrote: > Dne ponedeljek, 20. april 2020 ob 17:10:10 CEST je Paul Kocialkowski=20 > napisal(a): > > Hi, > >=20 > > On Sun 19 Apr 20, 15:28, Samuel Holland wrote: > > > On 4/8/20 11:01 AM, Jernej =C5=A0krabec wrote: > > > > Hi Samuel! > > > >=20 > > > > Dne sreda, 08. april 2020 ob 03:02:32 CEST je Samuel Holland napisa= l(a): > > > >> This allows the VE clocks and PLL_VE to be disabled most of the ti= me. > > > >>=20 > > > >> Since the device is stateless, each frame gets a separate runtime = PM > > > >> reference. Enable autosuspend so the PM callbacks are not run befo= re > > > >> and > > > >> after every frame. > > > >>=20 > > > >> Signed-off-by: Samuel Holland > > > >> --- > > > >>=20 > > > >> I tested this with v4l2-request-test. I don't have the setup to do > > > >> anything more complicated at the moment. > > > >>=20 > > > >> --- > > > >>=20 > > > >> drivers/staging/media/sunxi/cedrus/cedrus.c | 7 ++ > > > >> .../staging/media/sunxi/cedrus/cedrus_hw.c | 115 ++++++++++++-= ----- > > > >> .../staging/media/sunxi/cedrus/cedrus_hw.h | 3 + > > > >> 3 files changed, 88 insertions(+), 37 deletions(-) > > >=20 > > > [snip] > > >=20 > > > > Reset above causes problem. When format is set in cedrus_s_fmt_vid_= cap() > > > > a > > > > function is called, which sets few registers in HW. Of course, ther= e is > > > > no > > > > guarantee that someone will start decoding immediately after capture > > > > format is set. So, if the driver puts VPU to sleep in the mean time, > > > > reset will clear those registers and decoded video will be in diffe= rent > > > > format than expected. It could be even argued that registers should= not > > > > be set in that function and that this is design issue or bug in dri= ver. > > >=20 > > > You're right. I didn't see that cedrus_dst_format_set() was called ou= tside > > > cedrus_engine_enable/disable(). > >=20 > > This might indeed be an issue with multiple decoding contexts in parall= el, > > with potentially different formats. For that reason, it looks like the > > right thing to do would be to set the format at each decoding run based= on > > the format set in the context by s_fmt. >=20 > So you are suggesting that cedrus_dst_format_set() should be moved to=20 > cedrus_device_run(), right? This way all registers are set at each run, w= hich=20 > is then truly stateless. Yes, exactly! But this is outside of the scope of this series though. Cheers, Paul > Best regards, > Jernej >=20 > >=20 > > > > Anyway, I made a runtime PM support long time ago, but never do any= thing > > > > besides running few tests: > > > > https://github.com/jernejsk/linux-1/commit/ > > > > d245b7fa2a26e519ff675a255c45230575a4a848 > > > >=20 > > > > It takes a bit different approach. Power is enabled in start stream= ing > > > > and > > > > disabled in stop streaming. This is simpler approach and doesn't ne= ed > > > > autosuspend functionality. I also moved call to a function which se= ts > > > > format in HW registers to start streaming handler, so it's guarante= ed > > > > to be set at the beginning. > > >=20 > > > Assuming cedrus_device_run() only gets called between streamon and > > > streamoff (which appears to be the case), this looks like a better > > > design. > >=20 > > Yes, this is defintiely ensured by the V4L2 framework. I agree that > > streamon/off are the correct sync points. > >=20 > > > > Note that some registers are only set in start streaming handler. W= ith > > > > your > > > > approach, if first frame is submitted too late, asserting and > > > > de-asserting > > > > reset line could reset those registers. > > >=20 > > > I only see registers being set in cedrus_start_streaming() after your > > > patch, where you add a call to cedrus_dst_format_set(). I can't find = any > > > registers being written in any of the ->start() callbacks. > > >=20 > > > I'll send a v2 which combines the two patches: yours which handles the > > > runtime part better, and mine which handles the probe/remove part bet= ter > > > with !CONFIG_PM. > > Thanks, that should do it! > >=20 > > Cheers, > >=20 > > Paul >=20 >=20 >=20 >=20 --=20 Paul Kocialkowski, Bootlin Embedded Linux and kernel engineering https://bootlin.com --rwEMma7ioTxnRzrJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAl6d4mIACgkQ3cLmz3+f v9EzUwf/fWYkOXQ7aCfBor+vnOz95eIXeb6WY3jGTqlLKcK+4HY9KlRVwHAt4Eiw 9vxNX+qb3CUvMu1WsvE+t7Zn2Xvd6PSLuYyTHsW+DCuY9qlbwT8iQHCzwWLelCui 4g+RaZU555V7GxVNk2lHtWMtfn9lD0cHnsAJLUHSEJDMWSGJW7O5cZ0Zb639iDxf GEGaw6YVbheeiOCHHQbMkPjzCkEu99R9Rzp1GT4tszc3RiUBgxxpYYgnCr+mhZ01 Kt1mRfGlTXFdmzHPYAj83sbcKXJtlp3aS/dya99bAM91Z2Tbeeg0hHs4Lkfgn3ZQ NA4GEvITmUZyyxDEeTCw48xHR1mgrA== =x5mQ -----END PGP SIGNATURE----- --rwEMma7ioTxnRzrJ--