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 5F3ABECE564 for ; Tue, 10 Sep 2024 09:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type: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=NUPvhy7zjqH0JhntKtCRqDE8VmRcrMtYQK3Cr5qGJOU=; b=IiGZIoWWn4L2LczEU6djJlus1c HBRiyW8uRxFpcwuwJtphpF148yIQ9UJyWuEZnJp2HE/W0xNyx9fz+vovQ02mCTRPhmvswTnJeD4Wd sAU+cAcVMDh6FWxDP5MKk7ExrUdlWVsla86+OmDJIiprXy8AAr1P8eg5Wx40l8va1ldzdfcopg++D BJxw64pebJRm6aOIWpUq0DanCClEMVZ+LNbim97aehSzSkydB5jzKawcxcTo5JSYnhLfUL2pZlHRo IfraSOBUvNHY/S8IM3rozXOs1A4UpDaU1iez0ZRPfj2LU/rPSguLiTVXdLX6ihiK1QEfCvLts4mpP I/DQCn6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snxbs-000000057a6-1DVT; Tue, 10 Sep 2024 09:56:32 +0000 Received: from mgamail.intel.com ([198.175.65.11]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snxar-000000057Sp-0BIL; Tue, 10 Sep 2024 09:55:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725962129; x=1757498129; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=FNaFQjCMOZPAZpGBC/QDYZQGjGeLuPkU+Tp/UfCEFCE=; b=hkoIoZKXXZFn4Z8zOyYiRA6PmCyTxFTm9pKI6Ugr3YanXFj2H+BgHhq8 4eUgpj2jKe4wzTpsZxSbd5Z443uKnEKiV/WEjSrmYtiFd+o+FqyBzX7S9 TUYPRocH3nmqZvm4W9wRGsgMwO44PVKrJClbVOy1BVI0YAh5Zz6n30ZS0 c8VYD8ewAPcsXaTMVrAvFOXV4VSLPZhB820VKxIYyjMQXjdWBbxK5NFez fkiEjMpxyHkqFLGAfLJXOvH3ZwYGefDCA4gvoya+jJrJ7Ec7hWT0zNbk5 dj9AUz7wzqABRCiYVVtVpyMtFznCakb82iVQPL4e/xZkaxxNDud0DIvGr w==; X-CSE-ConnectionGUID: v0XeztGhTEylcaMYGWRHng== X-CSE-MsgGUID: epT5AQTTSxmfrusjE+NCdQ== X-IronPort-AV: E=McAfee;i="6700,10204,11190"; a="35269412" X-IronPort-AV: E=Sophos;i="6.10,216,1719903600"; d="scan'208";a="35269412" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2024 02:55:28 -0700 X-CSE-ConnectionGUID: LbPBTunoSJqIxIuMdjNgyw== X-CSE-MsgGUID: yb+GqAbJQqyeG/Y+XlHwCg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,216,1719903600"; d="scan'208";a="90262719" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2024 02:55:24 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id E8E9311F83C; Tue, 10 Sep 2024 12:55:20 +0300 (EEST) Date: Tue, 10 Sep 2024 09:55:20 +0000 From: Sakari Ailus To: Jacopo Mondi Cc: Laurent Pinchart , Tomi Valkeinen , Mauro Carvalho Chehab , Raspberry Pi Kernel Maintenance , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , oe-kbuild-all@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Naushir Patuck , Kieran Bingham , kernel test robot Subject: Re: [PATCH v4 3/4] media: raspberrypi: Add support for RP1-CFE Message-ID: References: <40cc1e95-b9fc-4c27-9428-1698d0bf9d25@ideasonboard.com> <763b3147-d7cb-44a7-b73b-8f7f4fd622ab@ideasonboard.com> <20240909134516.GA9448@pendragon.ideasonboard.com> <6u2g4v4ktt543sy5jlp3vonemhzhrwyz2liikg6jb2kx3h7jao@z6s233clqwqk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6u2g4v4ktt543sy5jlp3vonemhzhrwyz2liikg6jb2kx3h7jao@z6s233clqwqk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_025529_181945_F0C68544 X-CRM114-Status: GOOD ( 59.16 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jacopo, On Tue, Sep 10, 2024 at 11:42:06AM +0200, Jacopo Mondi wrote: > > > > > > > Ah, I missed that one. > > > > > > > > > > > > > > I don't think it fixes the issue I mentioned. If we have PM enabled, and the > > > > > > > parent device requires powering up for the child device (BE) to be > > > > > > > accessible, the driver will crash when calling pispbe_hw_init(). I think you > > > > > > > should call pm_runtime_set_active() before calling pispbe_runtime_resume(). > > > > > > > > > > > > As discussed, this is not a problem currently for BE, but indeed you > > > > > > have a point. > > > > > > I admit the runtime_pm intrinsics are obscure to me, but Laurent just > > > made me notice something. > > > > > > Consider the following scenario > > > > > > *) Kernel compiled with CONFIG_PM > > > *) i2c sensor driver that supports both CONFIG_PM and !CONFIG_PM by: > > > *) Manually power up the sensor during probe > > > *) Call pm_runtime_enable() and pm_runtime_set_active() at the end > > > of the probe routine after having accessed the chip over i2c > > > (like most, if not all the i2c drivers in mainline do including > > > ccs) > > > > > > All these drivers work, and during the probe routine before accessing > > > the HW, they don't need to power up the parent i2c controller. > > > > This isn't done explicitly by the I²C drivers, indeed but... > > > > > > > > Might it be that during probe() the parent is guaranteed to be enabled ? > > > > ...yes. > > > > Unrelated, but I am wrong the driver core calls pm_request_idle() on > the just probed device ? Does this mean drivers doesn't have to do > that by themseleves ? (it's not a big deal, as request_idle() doesn't > change the usage counter) Seems like that. This could be omitted from drivers then. > > > > > > > I add a look in the driver-core and pm Documentation/ but found > > > nothing. > > > > > > A quick stroll in driver/base/ got me to __device_attach() and it > > > seems parents are powered up before attaching a driver to a device > > > (which in my understanding should be what ends up calling probe()). > > > Clearly I've no real understanding of what I'm talking about when it > > > comes to driver-core, so take this with a grain of salt. > > > > This only works with runtime PM enabled. > > > > It's the CONFIG_PM case that was worrying for Tomi > > > > > > > > > > > > > > > > Sad note: most of all the occurrences of "grep set_active" in > > > > > > drivers/media/platform/ show that set_active() is used as I've done in > > > > > > my patch > > > > > > > > > > > > > However, you said above that "supporting !CONFIG_PM is not that much work". > > > > > > > Maybe not. But how much work is it to get it right (for both PM and !PM), > > > > > > > and make sure it stays right? =). > > > > > > > > > > > > > > Just my opinion, but if there are zero use cases for the !PM, I would just > > > > > > > go with "depends on PM" to keep the driver simpler, less bug-prone, and > > > > > > > easier to maintain. > > > > > > > > > > I'm fine with that, and for platform drivers, that's my preferred > > > > > option. Sakari ? > > > > > > > > I'm concerned with your (?) recent finding that many architectures don't > > > > have support for CONFIG_PM. In this case the device is very unlikely to be > > > > used outside ARM(64) so I guess it's fine. > > > > > > > > > > Also, this IP is RPi specific, and the !CONFIG_PM case is not used or > > > tested on Pi. > > > > > > However, I think this current patch is correct (assuming the above > > > reasoning on i2c sensor drivers is correct) and doesn't require > > > CONFIG_PM, so I would be tempted to keep this version. > > > > I understand the current patch does depend on CONFIG_PM: it requires > > runtime PM to be operational to start the clock, for instance. > > > > Where do you see that ? > > This version still calls pispbe_runtime_resume() to power up the IP, > it doesn't go through runtime_pm: > https://patchwork.linuxtv.org/project/linux-media/patch/20240904095836.344833-5-jacopo.mondi@ideasonboard.com/ cfe_runtime_resume() is only called via runtime PM. > > Thanks! > > > > > > > > > > > > > > > I don't see a use case for !PM and we confirmed with RPi they don't > > > > > > need to support it. During the review of a previous version of the BE > > > > > > driver iirc I've been asked to support !PM but I'm not sure I recall > > > > > > the reasons. > > > > > > > > > > I hope it wasn't me :-) > > > > > > > > Me neither. Although it'd be nice: CONFIG_PM isn't a hardware specific > > > > option as such. As one part of the kernel requires !CONFIG_PM and another > > > > CONFIG_PM, we can expect problems, at least in principle. > > > > > > > > Ideally all architectures would support it so CONFIG_PM could be removed > > > > and we could say the problem has been solved. :-) -- Kind regards, Sakari Ailus