Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4935346ima; Tue, 5 Feb 2019 03:54:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IZSqnu+IJdALjj83WoQkxpD6iy0gHGZGNvS8cjpzW2FWa+9VYNt9I+Icg0gZEWJEarb73gN X-Received: by 2002:a62:29c3:: with SMTP id p186mr4660020pfp.117.1549367686156; Tue, 05 Feb 2019 03:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549367686; cv=none; d=google.com; s=arc-20160816; b=Db2Y8QxbEOL17z8K4bwCy2z78KZzKi+HojXhMQhNgOpZcpCWLJ+y7YWyvk4dXbkCjC I/QpATeiSVuzUNOEGdtCUn4/BpN81nd6PviGtYWxNHNPilaYE81BLOzxDKg3Fdza/t4C qB8372u5vrV0EZMd7JcMFDLF5V2D/a9WgUm25wyPliqiBVaS7wiRzrc0xGAoR+12st6X EMJcuJO4kPW4MO7oSJ1iN9v4lQAeKTQzXuqb6S5uXkKCBMzi2xgpZeX2Jvdbfw7Pnqoo Ng8+dyDK5XpMqZvl1TZrKY5XVrXLcXICm6O0AKq7aNZUF16rdXCAxqM3dZQOqoO9UYpz jURg== 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; bh=/zRpgXp9ofQ8ZLIjOgDoHrhAYH6OttutE8Qxj4abkjw=; b=ASUaFzKiASbhn9XgMl4t0h6cOAk5tm5cW0AOPEdHaO40AGGE3ZLtDhgw9ZjKw1kqXR PoNjB2dKqpnwAo+N6VHTd4D21TsGrF8Zjhxpk6Y4iIJdnXYXS/OH6JQ5cJVtZ65sEAvN APqNrKnwjDuEKIvxDIvB/hY1ALtydkmFSVQoULSOFf570a7G0WvzrcQemTr0nM2A2h/d 5uHj6EYdERFIKu+9mbj5Rta5IUYPF+cPbiWAuwNSYyA2zrvs/ecw4GZfQ4aaDigpd629 3mQweB2hAz6F4ynpkNPUp7J3hc6JjXbcVhYcF8pJ6GR+8pOLh5jBiuOi9XCOP6fJJGly wQ1g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si2997495pgg.288.2019.02.05.03.54.29; Tue, 05 Feb 2019 03:54:46 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728782AbfBELxa (ORCPT + 99 others); Tue, 5 Feb 2019 06:53:30 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:48140 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727496AbfBELxa (ORCPT ); Tue, 5 Feb 2019 06:53:30 -0500 Received: from 79.184.254.36.ipv4.supernova.orange.pl (79.184.254.36) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id 5e38e35669498778; Tue, 5 Feb 2019 12:53:28 +0100 From: "Rafael J. Wysocki" To: Thierry Reding Cc: Jon Hunter , "Rafael J. Wysocki" , Takashi Iwai , Pierre-Louis Bossart , Sameer Pujar , Jaroslav Kysela , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , mkumard@nvidia.com, rlokhande@nvidia.com, sharadg@nvidia.com, Linux Kernel Mailing List , linux-tegra@vger.kernel.org, Linux PM Subject: Re: [PATCH v2] ALSA: hda/tegra: enable clock during probe Date: Tue, 05 Feb 2019 12:52:17 +0100 Message-ID: <2224002.YA0vJHJrjz@aspire.rjw.lan> In-Reply-To: <20190204110510.GA10412@ulmo> References: <1548414418-5785-1-git-send-email-spujar@nvidia.com> <07d58962-4c49-0575-2f95-4c885998bb52@nvidia.com> <20190204110510.GA10412@ulmo> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, February 4, 2019 12:05:10 PM CET Thierry Reding wrote: > > --FCuugMFkClbJLl1L > Content-Type: text/plain; charset=us-ascii > Content-Disposition: inline > Content-Transfer-Encoding: quoted-printable > > On Mon, Feb 04, 2019 at 09:53:32AM +0000, Jon Hunter wrote: > >=20 > >=20 > > On 04/02/2019 08:45, Thierry Reding wrote: > >=20 > > ... > >=20 > > > The idea was, as I was saying below, to reuse dev_pm_ops even if > > > !CONFIG_PM. So pm_runtime_enable() could be something like this: > > >=20 > > > pm_runtime_enable(dev) > > > { > > > if (!CONFIG_PM) > > > if (dev->pm_ops->resume) > > > dev->pm_ops->resume(dev); > > >=20 > > > ... > > > } > > >=20 > > > But that's admittedly somewhat of a stretch. This could of course be > > > made somewhat nicer by adding an explicit variant, say: > > >=20 > > > pm_runtime_enable_foo(dev) > > > { > > > if (!CONFIG_PM && dev->pm_ops->resume) > > > return dev->pm_ops->resume(dev); > > >=20 > > > return 0; > > > } > > >=20 > > > Maybe the fact that I couldn't come up with a good name is a good > > > indication that this is a bad idea... > >=20 > > How about some new APIs called ... > >=20 > > pm_runtime_enable_get() > > pm_runtime_enable_get_sync() > > pm_runtime_put_disable() (implies a put_sync) > >=20 > > ... and in these APIs we add ... > >=20 > > pm_runtime_enable_get(dev) > > { > > if (!CONFIG_PM && dev->pm_ops->resume) > > return dev->pm_ops->resume(dev); No, we're not adding this to the core. While in principle you could provide a set of pointers to the routines you want to be called when CONFIG_PM is unset, IMO it is just cleaner and more straightforward (and fewer lines of code for that matter) to add a simple conditional to each ->probe() and ->remove(). [cut] > > None, but seems overkill just for this case. > > But that's precisely the point. It's not just about this case. We've > already got some drivers where we do a similar dance just to be able to > support the, let's admit it, exotic case where somebody turns off PM. I > think supporting !PM might have made sense at a point where we had no > support for power management at all. But I think we've come a long way > since then, and while we may still have some ways to go in some areas, > we do fairly decent runtime PM most of the time, to the point where I no > longer see any benefits in !PM. This IMO is an excellent point. Trying to handle the !CONFIG_PM case only really makes sense if you know what to do to turn the device on without relying on things like PM domains etc which are not even available if CONFIG_PM is not set. IOW, if any of the platforms your driver is expected to work with require something like genpd to even make the device functional, I wouldn't bother. Thanks, Rafael