Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1953803ybl; Thu, 15 Aug 2019 04:08:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgeyUDTJ1miZTtVzAZWHGZEdCAI4m02aN8EOijGXQUpffFZempeHkRzE6dfHirl2BL1rmK X-Received: by 2002:aa7:9719:: with SMTP id a25mr4982937pfg.2.1565867325273; Thu, 15 Aug 2019 04:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565867325; cv=none; d=google.com; s=arc-20160816; b=cpqAUPEbCE4vgUZaXW7s1RiYL1Y7qE4FJMulK+ZXXgD6/FIa6cFoHneyEE0L0tQFHT Ub9ZrGZEG1aXKKJIPDtVzVTR8ZwJsMs9BiFn2mTgcmBzMDzIgmDZViR1cWn6L9FcNKfQ /95/eW6rmedneNWrUYDZwlQ3kJY+ivEcurbvPbsySGpNZA1/YFH7rlFMDZtsuv7UU4rI 90F0BJrIF4bHSNAtmGWnHl53iQdvbjqnxdyWxD3yhQ1UAqxtD1ZbzOzc9535ZE6xUCuX jZQELFWhnOoNh/nz+wpX2bjBUaRhHDk98EdE/kGcO9esK7lHb/feKsvmJRsIy17eAixR /HDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gehrfSX/wYrGDiK8IqXnoPhYbim32JFwF8t1ONu8CwY=; b=0eJRUcxlQq4LyNq8l7NJ396nQGuxCXhLRrbOgu5L5WvWzF7D7+y+TR7pZ1cJYuz5fy EvS7DlJhRQcSC874uy6TUEY5Apex0lWe0VGKF/naxRbYwByJfMvehgTfXQMC2Jii8udj E+LNGKpTKsMfvwUYHp2vW3b5dxlCK9D7xBov9H7T6MxJDNDtq5OZ5+D3v13dsk+6MY9k 5Dhj8HFbCnmLiG0xhrBjRkpPmuVYH3L06EeomAgaejQkT4tgdotokPvUTMQ51jLOu5e3 PaJYsUQbZSrqX3sRe/fUeJTdSU/ulYc4kPs6RbnU7s1pC6rYGwjAuRZcYDfWZ/73ZwhG a/pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IKj4fHPm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24si1746122pll.364.2019.08.15.04.08.29; Thu, 15 Aug 2019 04:08:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IKj4fHPm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730737AbfHOKaR (ORCPT + 99 others); Thu, 15 Aug 2019 06:30:17 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:42100 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbfHOKaQ (ORCPT ); Thu, 15 Aug 2019 06:30:16 -0400 Received: by mail-ed1-f66.google.com with SMTP id m44so1705273edd.9 for ; Thu, 15 Aug 2019 03:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gehrfSX/wYrGDiK8IqXnoPhYbim32JFwF8t1ONu8CwY=; b=IKj4fHPmdhELeh90ShgbJmumqDoKz4HjY9PfX+7XdlHjTTZy8VBZMWV8V0jgtKigwJ RqABRgkm9B8EAn+pmeIpfze0Tyfh2OmUTy9FzVzVkYUiACFB6c0YcnrGGDeZX/qyDe0P N3pdQMX0iGWiIsb1N8JDM8yyCWEvtLttRdL/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gehrfSX/wYrGDiK8IqXnoPhYbim32JFwF8t1ONu8CwY=; b=BO3PsH93+98I/VtXrCCZGu+ycCsh8GZT5HHo4vLYa4+5oF5mgsvIP2mwhT/lYbUPlJ FqZ503Ib6VNLReoew0QdY1U9QRog1VhhjEo77SuUNNg9BBVo6LjNoqgimLHs8sTLPN2a NezLjHKPwyyDqalQjvYxFwLgkuyYiS89Nrd5FWnobKVwGB0i8BmxS85wHi0h+YHRmiKk hb9SeeAbT7MnfBsa/FugSUmPtd23o7g7OMY73iS5v6Jh7grZ/w+9JqmbS8yjTSiDX+bq SdVpIqrNg4/RlLWqSAA8CGUK1rwd2JrksyYRxcbP6NTz9DouILPQALy3V3aCDvcv4dat xNWw== X-Gm-Message-State: APjAAAXWKCy0/0kwWlKKjYQNESfjDuDvgjw7C/L7PjL2vo0XMmZZbKZG WizeOOXuAmH8woKje6TJLiuXqwmYV99Dlg== X-Received: by 2002:a50:97ea:: with SMTP id f39mr4506598edb.279.1565865014145; Thu, 15 Aug 2019 03:30:14 -0700 (PDT) Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com. [209.85.221.48]) by smtp.gmail.com with ESMTPSA id f22sm484389edr.15.2019.08.15.03.30.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Aug 2019 03:30:12 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id z1so1757601wru.13 for ; Thu, 15 Aug 2019 03:30:11 -0700 (PDT) X-Received: by 2002:adf:f851:: with SMTP id d17mr4704460wrq.77.1565865011444; Thu, 15 Aug 2019 03:30:11 -0700 (PDT) MIME-Version: 1.0 References: <20190730184256.30338-1-helen.koike@collabora.com> <20190730184256.30338-6-helen.koike@collabora.com> <20190808091406.GQ21370@paasikivi.fi.intel.com> <20190815082422.GM6133@paasikivi.fi.intel.com> In-Reply-To: <20190815082422.GM6133@paasikivi.fi.intel.com> From: Tomasz Figa Date: Thu, 15 Aug 2019 19:29:59 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 05/14] media: rkisp1: add Rockchip ISP1 subdev driver To: Sakari Ailus Cc: Helen Koike , "open list:ARM/Rockchip SoC..." , devicetree@vger.kernel.org, Eddie Cai , Mauro Carvalho Chehab , =?UTF-8?Q?Heiko_St=C3=BCbner?= , Chen Jacob , Jeffy , =?UTF-8?B?6ZKf5Lul5bSH?= , Linux Kernel Mailing List , Hans Verkuil , Laurent Pinchart , kernel@collabora.com, Ezequiel Garcia , Linux Media Mailing List , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Shunqian Zheng , Jacob Chen , Allon Huang 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 On Thu, Aug 15, 2019 at 5:25 PM Sakari Ailus wrote: > > Hi Helen, > > On Wed, Aug 14, 2019 at 09:58:05PM -0300, Helen Koike wrote: > > ... > > > >> +static int rkisp1_isp_sd_set_fmt(struct v4l2_subdev *sd, > > >> + struct v4l2_subdev_pad_config *cfg, > > >> + struct v4l2_subdev_format *fmt) > > >> +{ > > >> + struct rkisp1_device *isp_dev = sd_to_isp_dev(sd); > > >> + struct rkisp1_isp_subdev *isp_sd = &isp_dev->isp_sdev; > > >> + struct v4l2_mbus_framefmt *mf = &fmt->format; > > >> + > > > > > > Note that for sub-device nodes, the driver is itself responsible for > > > serialising the access to its data structures. > > > > But looking at subdev_do_ioctl_lock(), it seems that it serializes the > > ioctl calls for subdevs, no? Or I'm misunderstanding something (which is > > most probably) ? > > Good question. I had missed this change --- subdev_do_ioctl_lock() is > relatively new. But setting that lock is still not possible as the struct > is allocated in the framework and the device is registered before the > driver gets hold of it. It's a good idea to provide the same serialisation > for subdevs as well. > > I'll get back to this later. > > ... > > > >> +static int rkisp1_isp_sd_s_power(struct v4l2_subdev *sd, int on) > > > > > > If you support runtime PM, you shouldn't implement the s_power op. > > > > Is is ok to completly remove the usage of runtime PM then? > > Like this http://ix.io/1RJb ? > > Please use runtime PM instead. In the long run we should get rid of the > s_power op. Drivers themselves know better when the hardware they control > should be powered on or off. > One also needs to use runtime PM to handle power domains and power dependencies on auxiliary devices, e.g. IOMMU. > > > > tbh I'm not that familar with runtime PM and I'm not sure what is the > > difference of it and using s_power op (and Documentation/power/runtime_pm.rst > > is not being that helpful tbh). > > You can find a simple example e.g. in > drivers/media/platform/atmel/atmel-isi.c . > > > > > > > > > You'll still need to call s_power on external subdevs though. > > > > > >> +{ > > >> + struct rkisp1_device *isp_dev = sd_to_isp_dev(sd); > > >> + int ret; > > >> + > > >> + v4l2_dbg(1, rkisp1_debug, &isp_dev->v4l2_dev, "s_power: %d\n", on); > > >> + > > >> + if (on) { > > >> + ret = pm_runtime_get_sync(isp_dev->dev); > > > > If this is not ok to remove suport for runtime PM, then where should I put > > the call to pm_runtime_get_sync() if not in this s_power op ? > > Basically the runtime_resume and runtime_suspend callbacks are where the > device power state changes are implemented, and pm_runtime_get_sync and > pm_runtime_put are how the driver controls the power state. > > So you no longer need the s_power() op at all. The op needs to be called on > the pipeline however, as there are drivers that still use it. > For this driver, I suppose we would _get_sync() when we start streaming (in the hardware, i.e. we want the ISP to start capturing frames) and _put() when we stop and the driver shouldn't perform any access to the hardware when the streaming is not active. Best regards, Tomasz