Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3922624ybz; Mon, 20 Apr 2020 11:57:34 -0700 (PDT) X-Google-Smtp-Source: APiQypI+9UqMLhOd9KdePQJXDUaBsh6yZONFPGcG7nA4l2/ZBB9AkigUovOcTxxPp29tit8rTMTW X-Received: by 2002:a17:906:1387:: with SMTP id f7mr17087002ejc.333.1587409054033; Mon, 20 Apr 2020 11:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587409054; cv=none; d=google.com; s=arc-20160816; b=XQTjVYeinB0xZMXLrpGGQbXxn74Zef9MQqLWtXYv5V3kGEMEc/QMuwudFDOqeHFdKN LvbgdHRb0acXz1y2noFwaYzj2LvUiEUmUC7GBVf58RcUlGp522PeifJmx+CsaudvK/w2 8lpJf6j1/NoKZ1rfAWt7vuhZOFHhlBhcruhT2noY6DV4HpBuvBKNcfZJCQ5bP3jE63fw 6OgRHUNB+xhqdRCl42T8HwRtCQlnCpqWjdrbvtY+uxQuULvMkxSWzK1Wknz/fNw7kT7X E1lnw7jcTCFoAo274Ss4qYklXrV6vOJ8LqqPbzV1mRCi8wdQK3LWB3fb0oLM+OlpkeuU 0jbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pHkfqaZsrvViCrU4vsZGcZiXBeGIBVSy7YBzRqpKWdA=; b=DBqZ/Vx3E3EfjHtKvc1fweO3614KUUUep/ht8gXn93xkId8LgZ2nAhitx1JYnB6NaB HN6pldPdYCxgTDDfP5OGuwjeq/gBVKwxaMQ36F0KKmfG9TvIzoaGgsSpQbg5rRbra04G 9IvWwgx6RjMh8xF5paXKMhaPo1PpJRYbMzyubyNu/B2j0XTmMnUEWffFmexB3p91mt1D hj6gbmGxRKk7NzObPEGaa5Dia1vgtaWd0AZNhu3KFtgJy3dXmyn8+LFkKfcub6BOXJ79 lTH6of5B8FAX9xkW4Yqe+C2vHNdn8U7k4U9ad2jF2gBBDEA+1DkSwde/qLXqSrDnXuXx TISw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DocS62iB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b21si162012edj.146.2020.04.20.11.57.10; Mon, 20 Apr 2020 11:57:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DocS62iB; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbgDTQl3 (ORCPT + 99 others); Mon, 20 Apr 2020 12:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726208AbgDTQl2 (ORCPT ); Mon, 20 Apr 2020 12:41:28 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB79FC061A0C; Mon, 20 Apr 2020 09:41:27 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id j1so7595273wrt.1; Mon, 20 Apr 2020 09:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pHkfqaZsrvViCrU4vsZGcZiXBeGIBVSy7YBzRqpKWdA=; b=DocS62iBm+MaxthEy8q58x+ZJU00CguRHCiYuW6dSG4/U6ZyGPWmJrpqRaNjkRtbF7 /RdZSQWSQ5H6mteZjuHLXUdo5lFRpI3NnH8AfGByJ9+aIiSkz/qzxmyb5XOd0oKkuUsG 5IetuYNfruFqMLFvjQX8+VAgTEgvRhLcCFAVYfSpeNrSsewv1pjunDnWaVYCwjh2Ec5N /3t24EgrtLPIjg2mkbufRaGlL+k6ZWxTG60iMpCC+tZKDq3qJ9vY+fbowAm6WE53kEhc o9nC28ByOnpk4pqSScAIK+vx+0Bn7EcqO7v0rNdv5mDmP2rkenwq4oordoJJOvDWy/aI NbXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pHkfqaZsrvViCrU4vsZGcZiXBeGIBVSy7YBzRqpKWdA=; b=WCY63XXr/U0haQyEZ6ICnhPE/UFnOGjfJeX1C7QPgx6s6/iITJJxzsWa85qf/+Indy LkucqTz4Cb+vMm7kWhhkacrxGC4+gVClp6wVB8bQ5aLo4yow0OcQRERVbdA8NlZBAhB0 DHfHpvnPbXCHyi3QyC4PIn31POfi6zqDXN6ICEgckuEUuFXImZ+GD+7/ZmFatWsiWYE9 czir/Wef4nh83ImzUAC9BxLMkLFXV86xeVPVbikHUt0ZWMvDE7z9pwkX6xatXlH86n3y ptAJlSTo3aNtCN8cLrOLRUlrzpXjHTTQI2u7prq5+q+Q7APtpFGZ32b99q2ExijkSbim R8XA== X-Gm-Message-State: AGi0PuabZfvauEq4yAhhVSsDKiaxoB3xoJksNtpW/LXNfg9AMg6NQv40 RNRR/qUAPctICHuwDV5Qh4w= X-Received: by 2002:a5d:6148:: with SMTP id y8mr19160703wrt.236.1587400886434; Mon, 20 Apr 2020 09:41:26 -0700 (PDT) Received: from jernej-laptop.localnet (cpe-194-152-20-232.static.triera.net. [194.152.20.232]) by smtp.gmail.com with ESMTPSA id j13sm48180wro.51.2020.04.20.09.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 09:41:25 -0700 (PDT) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Samuel Holland , linux-sunxi@googlegroups.com Cc: Maxime Ripard , Chen-Yu Tsai , Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, paul.kocialkowski@bootlin.com Subject: Re: [linux-sunxi] [PATCH] media: cedrus: Implement runtime PM Date: Mon, 20 Apr 2020 18:41:23 +0200 Message-ID: <5590139.lOV4Wx5bFT@jernej-laptop> In-Reply-To: <20200420151010.GL125838@aptenodytes> References: <20200408010232.48432-1-samuel@sholland.org> <244922ec-ed3a-eca7-6640-49de7ad9c605@sholland.org> <20200420151010.GL125838@aptenodytes> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 napisal(= a): > > >> This allows the VE clocks and PLL_VE to be disabled most of the time. > > >>=20 > > >> Since the device is stateless, each frame gets a separate runtime PM > > >> reference. Enable autosuspend so the PM callbacks are not run before > > >> 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 ++++++++++++---= =2D-- > > >> .../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_ca= p() > > > a > > > function is called, which sets few registers in HW. Of course, there = 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 differe= nt > > > format than expected. It could be even argued that registers should n= ot > > > be set in that function and that this is design issue or bug in drive= r. > >=20 > > You're right. I didn't see that cedrus_dst_format_set() was called outs= ide > > cedrus_engine_enable/disable(). >=20 > This might indeed be an issue with multiple decoding contexts in parallel, > 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. 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, whi= ch=20 is then truly stateless. Best regards, Jernej >=20 > > > Anyway, I made a runtime PM support long time ago, but never do anyth= ing > > > besides running few tests: > > > https://github.com/jernejsk/linux-1/commit/ > > > d245b7fa2a26e519ff675a255c45230575a4a848 > > >=20 > > > It takes a bit different approach. Power is enabled in start streaming > > > and > > > disabled in stop streaming. This is simpler approach and doesn't need > > > autosuspend functionality. I also moved call to a function which sets > > > format in HW registers to start streaming handler, so it's guaranteed > > > 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. With > > > 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 better > > with !CONFIG_PM. > Thanks, that should do it! >=20 > Cheers, >=20 > Paul