Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp55012imm; Tue, 22 May 2018 13:56:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpIgugXubQ2W3IN96jd2hnBJzc9ilA41j/FOAohYd6xRJGvp4MW1hk3WeXFXryyzJv6SAch X-Received: by 2002:a62:de02:: with SMTP id h2-v6mr27271pfg.205.1527022563159; Tue, 22 May 2018 13:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527022563; cv=none; d=google.com; s=arc-20160816; b=QBkvWg8Huyx3FZRrAx7f1A1qPCrnywc6bU4iqaZQr7GQlecII/Rm2y0ut8yUJ1eYof rtQG6CJK39aM4/fVyCYj9L8/PCJzw2pIK34bqv0EC0CW99PLiiejrJDL6uog0qCGkEPM 6lwmV+Vl3zfhckA5KfTwouleQEWDjGVAhxuMnLcWSjIZ0h1IVc4KJwwn/nr/l/PdTllP RXTUKAb/ebrBsCxW3AuoqMbSnQy+bGllJkcSFF68UJU3RRK8xRXk8Rd8s/71D2LMx7PM BKJ+hTtKWoOISVqTZ1cs562dMG8BwXBARD6DOrl7yVrkcwI/3GHOMPQR5AsySW3csEZQ Hiig== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=ALSje+3omgyTRux8Wdsusg1Lc6hZHOGO9X7fVfG+aJ0=; b=g6NgtM4fNgLZsji/F/B9rPwtbNDD5VlZ4hMAX/NIsTFTTlV9wXjAq96mu+KpoSys3P hRkCaiPPXouNVGZxJCMKTCta2RTJob36R1vuapqkR+ExTSZrnPTPUx41/PHjFBzb2+Al ZDuleZINFFfQFiCwbv2desOSk+Twb2o4ll2Xh6AgxaU9UjMvWXoJHAwchz7EZat2HpCi pdrkdNp6Ic0HfE9eXuNut0yASqAhUD3vtlIwDQ/p/TAlQ2iJA3oUSHv+SUbZcZxXeXSQ s58kppLgJ+e/Of1ApSveGtKtRPP9Pqmy/qPbQPaedJlZ+JSd6V5fgsz5KYDtK6LBwSrw 98+Q== 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e125-v6si8254946pgc.128.2018.05.22.13.55.48; Tue, 22 May 2018 13:56:03 -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; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753109AbeEVUz0 (ORCPT + 99 others); Tue, 22 May 2018 16:55:26 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:15751 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753081AbeEVUzY (ORCPT ); Tue, 22 May 2018 16:55:24 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1, AES128-SHA) id ; Tue, 22 May 2018 13:55:26 -0700 Received: from HQMAIL101.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 22 May 2018 13:55:23 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 22 May 2018 13:55:23 -0700 Received: from [10.26.11.88] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 22 May 2018 20:55:18 +0000 Subject: Re: [PATCH 8/9] PM / Domains: Add support for multi PM domains per device to genpd To: Ulf Hansson CC: "Rafael J . Wysocki" , Linux PM , Greg Kroah-Hartman , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Viresh Kumar , Vincent Guittot , Kevin Hilman , Linux Kernel Mailing List , Linux ARM , References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> <1526639490-12167-9-git-send-email-ulf.hansson@linaro.org> From: Jon Hunter Message-ID: <5a79d3a2-d090-645b-da69-524b7e7a4d90@nvidia.com> Date: Tue, 22 May 2018 21:55:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/05/18 15:47, Ulf Hansson wrote: > [...] > >>> >>> +/** >>> + * genpd_dev_pm_attach_by_id() - Attach a device to one of its PM domain. >>> + * @dev: Device to attach. >>> + * @index: The index of the PM domain. >>> + * >>> + * Parse device's OF node to find a PM domain specifier at the provided @index. >>> + * If such is found, allocates a new device and attaches it to retrieved >>> + * pm_domain ops. >>> + * >>> + * Returns the allocated device if successfully attached PM domain, NULL when >>> + * the device don't need a PM domain or have a single PM domain, else PTR_ERR() >>> + * in case of failures. Note that if a power-domain exists for the device, but >>> + * cannot be found or turned on, then return PTR_ERR(-EPROBE_DEFER) to ensure >>> + * that the device is not probed and to re-try again later. >>> + */ >>> +struct device *genpd_dev_pm_attach_by_id(struct device *dev, >>> + unsigned int index) >>> +{ >>> + struct device *genpd_dev; >>> + int num_domains; >>> + int ret; >>> + >>> + if (!dev->of_node) >>> + return NULL; >>> + >>> + /* Deal only with devices using multiple PM domains. */ >>> + num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", >>> + "#power-domain-cells"); >>> + if (num_domains < 2 || index >= num_domains) >>> + return NULL; >>> + >>> + /* Allocate and register device on the genpd bus. */ >>> + genpd_dev = kzalloc(sizeof(*genpd_dev), GFP_KERNEL); >>> + if (!genpd_dev) >>> + return ERR_PTR(-ENOMEM); >>> + >>> + dev_set_name(genpd_dev, "genpd:%u:%s", index, dev_name(dev)); >>> + genpd_dev->bus = &genpd_bus_type; >>> + genpd_dev->release = genpd_release_dev; >>> + >>> + ret = device_register(genpd_dev); >>> + if (ret) { >>> + kfree(genpd_dev); >>> + return ERR_PTR(ret); >>> + } >>> + >>> + /* Try to attach the device to the PM domain at the specified index. */ >>> + ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index); >>> + if (ret < 1) { >>> + device_unregister(genpd_dev); >>> + return ret ? ERR_PTR(ret) : NULL; >>> + } >>> + >>> + pm_runtime_set_active(genpd_dev); >>> + pm_runtime_enable(genpd_dev); >>> + >>> + return genpd_dev; >>> +} >>> +EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); >> >> Thanks for sending this. Believe it or not this has still been on my to-do list >> and so we definitely need a solution for Tegra. >> >> Looking at the above it appears that additional power-domains exposed as devices >> to the client device. So I assume that this means that the drivers for devices >> with multiple power-domains will need to call RPM APIs for each of these >> additional power-domains. Is that correct? > > They can, but should not! > > Instead, the driver shall use device_link_add() and device_link_del(), > dynamically, depending on what PM domain that their original device > needs for the current running use case. > > In that way, they keep existing runtime PM deployment, operating on > its original device. OK, sounds good. Any reason why the linking cannot be handled by the above API? Is there a use-case where you would not want it linked? Thanks Jon -- nvpublic