Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp397191imm; Tue, 22 May 2018 21:53:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJLmgiRWxx8P9x1+/24miQJtX9oK5/XMm+LwhE8tVILXlCgNAZHYoAR0ZBo7JmBzExM0GX X-Received: by 2002:a62:6e88:: with SMTP id j130-v6mr1306236pfc.111.1527051199035; Tue, 22 May 2018 21:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527051199; cv=none; d=google.com; s=arc-20160816; b=XiibFHX4jJRAlQBPu9cMK3U8zxPjTmRvRFMDBrP7E12mfxN6O+VSs1B12jvviRF5ml k+EyYQtQaIspvl4nAIG+CDpNR+HGZLbLgHnaID6TIIUQG/epfxkaiGzRU3UudZ7vmDe9 y5mfhAlSJstjj4UMrHUwtr7owKIEANNu4sDIjlkL5MQ96+Urt3kcmFChseE50NcaGttd JtRsz79B9r/funQWNERTIWOucdKwaH4jxd6x/EA9oNwLVXMqNo3/U+Vsw4cKwUChZ4CP s+GKdip4K6qwm/0uuud9L0otouvjSy7R6rrePQwdApfV5teShYHczElzXf/c41XwWXyR E66Q== 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:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=xx3l3rgI3g/+GJvXhFm6z95rlT8GQGjzgT1vs+bDBsQ=; b=huBf8XAd6nIY97EGHH3QaHZOxm3xwri5+Ut7ggXGMfP/2QIx/MEuTpECIgKHBR74/T Gx1EbbD0xmBNVysTSZSbrEiH5ACaIzcST9kNWizPRNNPLsiRfFLEI9POXqsNeDOIiWzY 9Pyp/Cf4HlIziysGc9RZzFnJ4aK9CSkMb/jxEeSqWlp/ZbeDl/6oSsiG9qyyeVEmFj6w bUiZPzWdF1m4jY7cJ16FzI0OTIUuC4PVWSSkY2+gMUFtu1pEdrCvlgTYpG99q+0tDWYH ECgcI9QpcplkkPY7T2q23hbsMgpJckV8aBikDM546o79q8YukwbdU7dKBnW00A7cSkRY NciA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=WNTm3Bp+; dkim=pass header.i=@codeaurora.org header.s=default header.b=SznL28s9; 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 90-v6si17716500plc.205.2018.05.22.21.53.03; Tue, 22 May 2018 21:53:19 -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=@codeaurora.org header.s=default header.b=WNTm3Bp+; dkim=pass header.i=@codeaurora.org header.s=default header.b=SznL28s9; 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 S1753915AbeEWEvo (ORCPT + 99 others); Wed, 23 May 2018 00:51:44 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45792 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbeEWEvk (ORCPT ); Wed, 23 May 2018 00:51:40 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7A57160A06; Wed, 23 May 2018 04:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527051099; bh=wlCUj6yw3wnrpZS5jUVHMvVPAkDQ4E8aOvzvZv6s9R8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=WNTm3Bp+c7LOgygc2wfOZ/IETKHW/dz7DH19hzUDC6srsm4oI1XjZtf0mTiB+JhhI xd3SjIRuiEYmfNWwlHSHfCgPmUKrbc5bvk6t5Cw2TCjuxWjTw/ORCVLBHr1T2hWkPz YVFakzJssTRTIGB8d9zgkFdy9LXmx83DQy7lBg0Y= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.79.40.88] (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rnayak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E6D1D60213; Wed, 23 May 2018 04:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527051098; bh=wlCUj6yw3wnrpZS5jUVHMvVPAkDQ4E8aOvzvZv6s9R8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=SznL28s9J6zx9TnGhXCiih1dRO8Yjrzy/wBzKkAy5MZjfiR0B6DfQDoIN7B7UjNeg U4kWPVJTRJrqu7+v7JI7L+5QWgVpz7rZTtac4yjOxTIaPLDX3gHT6j7rc9853npoXj udebA2pFh+JAKoQEWvCTb8NjSWmOU1cq4nBsMTH0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E6D1D60213 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rnayak@codeaurora.org Subject: Re: [PATCH 8/9] PM / Domains: Add support for multi PM domains per device to genpd To: Jon Hunter , Ulf Hansson Cc: Geert Uytterhoeven , Linux PM , Greg Kroah-Hartman , Kevin Hilman , "Rafael J . Wysocki" , Linux Kernel Mailing List , Todor Tomov , Viresh Kumar , linux-tegra@vger.kernel.org, Vincent Guittot , Linux ARM References: <1526639490-12167-1-git-send-email-ulf.hansson@linaro.org> <1526639490-12167-9-git-send-email-ulf.hansson@linaro.org> <5a79d3a2-d090-645b-da69-524b7e7a4d90@nvidia.com> From: Rajendra Nayak Message-ID: <51f7de26-579a-8b9e-4e79-f4eee923ab38@codeaurora.org> Date: Wed, 23 May 2018 10:21:32 +0530 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: <5a79d3a2-d090-645b-da69-524b7e7a4d90@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/23/2018 02:25 AM, Jon Hunter wrote: > > 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? I am guessing the linking is what would give the driver the ability to decide which subset of powerdomains it actually wants to control at any point using runtime PM. If we have cases wherein the driver would want to turn on/off _all_ its associated powerdomains _always_ then a default linking of all would help. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation