Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7028675imu; Thu, 31 Jan 2019 03:52:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6apJGajt3WZVFczudhaECf8MwT1uVRPKeSi10Lw0oycfCaq2sbRXyxuaLch0DU+Ez/Ongd X-Received: by 2002:a63:d655:: with SMTP id d21mr31215276pgj.280.1548935524004; Thu, 31 Jan 2019 03:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548935523; cv=none; d=google.com; s=arc-20160816; b=A9oqP0/iv8rOMODs4yLHfDpihuemFuREcjf0FxN3GEQK87O8hN3VOCxHaS2ogkaGdv o+pHkH/Q8uHxYIWk5UA7TIMKLgPIi0CQeQ/rbWXNO7DtxOd+hZ7cSBbQUek1X4k4LMfV OTFAUkfVvtRNTNuNxngwlw3fXEEM2yRqC4bYGVbr+6eSpa3/ENy4eurbEb2PEUFKAJv2 Z0BwoPemqgJ1KBvf99SHlNJ3vxJ/IR/06PUKODfI8cC4E7xTqFw6qjMeyOg197SpZAI4 5T69wfqu+Mz58I7ZvKnaLTP/C3LhLE6mnO0GyrQ406W2fq8qCHJf3vn/zYRrhGOSN68v dgCQ== 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; bh=mCxIq+0h/pKoS2oVEcpuljzWqFkn6kG+fh6ULECbGQM=; b=rjUTKO4G3b5tbwMN8jii/nEa4Hc+odyCUtObeizei86W64rKxJwtjrxg5CfHfHOV/p OZ7A9UhRgzgaR0IigAA2I/fIH7LTtRvBDVAdQtAba3Hh5rkWRn+JZtRuv2bKbfEuSpDd i6KV7OU4ce+8sRbvnvSdGTUsncYwX6sM8Su9ypRrzFWMpzttf/cglPPhX2/09RlaFABP XR1u8mpJfuSGm9tkhq9v+7BaoIkuiTTBKr8cV7scBmTwISbjvhLqILCNsgIJSvgiNV5G Hsm1TENCIPsWLZ3T++7juSL2+u9bX/ZQ+fQWtuvWrzKvA+YBQ3FWO6QYT4wP+/1pcZ47 iE7A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 124si4513110pgg.397.2019.01.31.03.51.48; Thu, 31 Jan 2019 03:52:03 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732307AbfAaLrH (ORCPT + 99 others); Thu, 31 Jan 2019 06:47:07 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:42540 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728067AbfAaLrH (ORCPT ); Thu, 31 Jan 2019 06:47:07 -0500 Received: by mail-oi1-f194.google.com with SMTP id w13so2440423oiw.9; Thu, 31 Jan 2019 03:47:06 -0800 (PST) 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=mCxIq+0h/pKoS2oVEcpuljzWqFkn6kG+fh6ULECbGQM=; b=SHMz0ycW/xcre4G8u8AK88DHPkglyUwAgzNFBSSPAJf9Qpwexu9VK3W/xKu3B1+/QM t7roNwZmO9ldQvzMwgZgFjc/O+9h1DymyeDhV/qead3FOy06s4M03CVwKPHEixgFoHuK d3NcUsffoFzTe4j2cyHpwwE8iCv2urtHQW6g95LprUqLR2fG2hRQvwZanNBud6/vPnTk 3iw9M2MCQuyWXz1PCTYjladGtTb0nXc1tFOPM/bvjUiijcrIjOqp4/k3kMhSVMG7UxGL kyMhFi2CAr1MysJQbheqYg0sN8Ioufq6fShk6KpjH0ScxHVjnFRdOcpLkZvYwAQVbpDR 9Gfg== X-Gm-Message-State: AJcUukdk/qv1XHFELcwB5yNknQT1SdOl2+XqPgm3jVlxnCjDmVQPok25 pt9PoF8hRDTE6m/W4a7oZd/qDG/FiLVeHz4Fm1M= X-Received: by 2002:aca:6c8b:: with SMTP id h133mr15274552oic.33.1548935225963; Thu, 31 Jan 2019 03:47:05 -0800 (PST) MIME-Version: 1.0 References: <1548414418-5785-1-git-send-email-spujar@nvidia.com> <20190131110530.GA23438@ulmo> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 31 Jan 2019 12:46:54 +0100 Message-ID: Subject: Re: [PATCH v2] ALSA: hda/tegra: enable clock during probe To: Takashi Iwai Cc: Thierry Reding , "Rafael J. Wysocki" , Jon Hunter , 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 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, Jan 31, 2019 at 12:21 PM Takashi Iwai wrote: > > On Thu, 31 Jan 2019 12:05:30 +0100, > Thierry Reding wrote: > > > > On Wed, Jan 30, 2019 at 05:40:42PM +0100, Takashi Iwai wrote: [cut] > > > If I understand correctly the code, the pm domain is already activated > > > at calling driver's probe callback. > > > > As far as I can tell, the domain will also be powered off again after > > probe finished, unless the device grabs a runtime PM reference. This is > > what happens via the dev->pm_domain->sync() call after successful probe > > of a driver. > > Ah, a good point. This can be a problem with a probe work like this > case. > > > It seems to me like it's not a very well defined case what to do when a > > device needs to be powered up but runtime PM is not enabled. > > > > Adding Rafael and linux-pm, maybe they can provide some guidance on what > > to do in these situations. > > > > To summarize, what we're debating here is how to handle powering up a > > device if the pm_runtime infrastructure doesn't take care of it. Jon's > > proposal here was, and we use this elsewhere, to do something like this: > > > > pm_runtime_enable(dev); > > if (!pm_runtime_enabled(dev)) { > > err = foo_runtime_resume(dev); > > if (err < 0) > > goto fail; > > } > > > > So basically when runtime PM is not available, we explicitly "resume" > > the device to power it up. > > > > It seems to me like that's a fairly common problem, so I'm wondering if > > there's something that the runtime PM core could do to help with this. > > Or perhaps there's already a way to achieve this that we're all > > overlooking? > > > > Rafael, any suggestions? > > If any, a common helper would be appreciated, indeed. I'm not sure that I understand the problem correctly, so let me restate it the way I understand it. What we're talking about is a driver ->probe() callback. Runtime PM is disabled initially and the device is off. It needs to be powered up, but the way to do that depends on some configuration of the board etc., so ideally pm_runtime_enable(dev); ret = pm_runtime_resume(dev); should just work, but the question is what to do if runtime PM doesn't work as expected. That is, CONFIG_PM_RUNTIME is unset? Or something else?