From patchwork Mon Jul 1 11:26:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168203 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2802032ilk; Mon, 1 Jul 2019 04:26:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrm3m41SETlqJem8s0ELy5zfwcGWNhcBIHM5/cinhI1N5UXmAzBQn0DjHJ5iPlCxISD2H4 X-Received: by 2002:a17:90a:3210:: with SMTP id k16mr29561579pjb.13.1561980391523; Mon, 01 Jul 2019 04:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561980391; cv=none; d=google.com; s=arc-20160816; b=F5oORTRr5ofyJuBvMls2QxGZywAEK6QRjIzbFGREavdYN2T7gY59xPdPisIXXAWLnx hwyac5RHmHpBp89DA4FMxr7p/KVuamQJIGM86esrVPVjZorcMOovGTE1dCOP8dF5qYE/ xQDiPfVKfdlbZ4v1WYd9MQzfnL4eTWJKjX85rqxz9Wlg21lP87ZxgkM6qcrmmT5yUgaT 0eVi5MwpRCNVzDF5KzW4Xbi06c89GPNP6Yy5Mfb1k5llXCSxtC0UZMM1nnSw9/sbbWDm 3DSeA+qaSOpfcwuWBFkiO/OF1i/NQwRL57hYrt75J19TzcJAo/6is0J9N1wAn4kg+9SR FgCw== 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 :dkim-signature; bh=+ZHoXqHDnWQNNxjeBIgVIp/1BFcAyIjpzOAOe/B47LU=; b=Gem27eQ3SMVFeM8GY2A/nIRgun8nfjK+5KeWggUm8j/uchPq5fseUR/GBYtX+zGVWc smj7Q75MIczbQ4RCYEQxpoAvIFZp4TcWgATFMO8bzcHyZ+wNs1Dw+squabF3zgXTVQpq DgaboVgQrkhQ9msDHiZmEFAFvjwBhEFraPhDLA+sAzyUp8IZIQD8zu9UjgKG5UmLcUdX 4bQppdYXexa4FQSJcv3Z5GucG2Rp2y7U+zoV4oKy8KACO7j31tuEMyTv+F6uGiqMFWfF yPfwWGv3+LJZbV/rP1x5o69Lv8m1Gh6u2HSjlJzbyBq4JLpl/z9qUl3pTHJbM0MW2cQ0 iuHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dUVUrmBa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16si10641170pfr.229.2019.07.01.04.26.31; Mon, 01 Jul 2019 04:26:31 -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=@linaro.org header.s=google header.b=dUVUrmBa; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728465AbfGAL03 (ORCPT + 30 others); Mon, 1 Jul 2019 07:26:29 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43336 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728441AbfGAL01 (ORCPT ); Mon, 1 Jul 2019 07:26:27 -0400 Received: by mail-pl1-f196.google.com with SMTP id cl9so7192688plb.10 for ; Mon, 01 Jul 2019 04:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+ZHoXqHDnWQNNxjeBIgVIp/1BFcAyIjpzOAOe/B47LU=; b=dUVUrmBauCNjHwpY8xMBZYQ4GRFLbO3Ntb704oAqX/pDjDK0rOXg5VkeBAmg6imlY9 lokkn1xb/h9XsSw2u8r7CIFC+li7G26E61o6Bm/py3Wd8PjkaOr3VgVkHSfEy/D+4gTM /YrlRxXz41Ytm+AjWojVND1+8ge/LSch2TnKq/h8oTadHMqK7mAScvXgE3/jgB+T2zyH G8PZoDdWD3USPuPIwLukR2YfR/zpbQxABrogxN8dbY2+Lx7rnAFVOQOHtbGudAGRqXjg yw30KTpn4calrfr4TDCGdpsQ3TaLl7LRj0n+SnQnibSKXfk66iQ8OEiAGhdhWDGgFqwC e0SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+ZHoXqHDnWQNNxjeBIgVIp/1BFcAyIjpzOAOe/B47LU=; b=mpApMqGkD81sdFpV9wm49z5erqSSnRmrV9rjmmo/DxwzK1QrRGSc2AovbIaBTEi03F DbfyL8W8RA9BdU7Hbp/BTVDmel67+0zuD1MoOt8WMSb8DpH/ODaO+8E230xgMFMSWFIR faWs/NF73GOQBbEARj6xJF8IOTKZAfWeRMLgVN2djNnWOusmGoAxxY3Ib3bIQuLFpLZw ttyuoGBmxLyqx4QE2nWAVgI9jzU+8qzpH3yP7APN9+zpf1cCK0pRcMiMspZ1xUaNnBmI tiDaSxEa+EH15CARBjl94hKq5H079csz60Hud12nAacDK56ZQT45kKY9G5DNODvAVEQF ggAA== X-Gm-Message-State: APjAAAV4CiYZaVMCLne8S7lzcW9p2aRdStahkT24XxLka7lmfBCZni3J DYUVvWbvzpdVOsOqqS+WgSDzxQ== X-Received: by 2002:a17:902:7791:: with SMTP id o17mr27113451pll.162.1561980386414; Mon, 01 Jul 2019 04:26:26 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id d14sm11077204pfo.154.2019.07.01.04.26.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 04:26:25 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Qais.Yousef@arm.com, mka@chromium.org, juri.lelli@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH V5 1/7] PM / QOS: Pass request type to dev_pm_qos_{add|remove}_notifier() Date: Mon, 1 Jul 2019 16:56:09 +0530 Message-Id: <765f3e870723a69580febc099e24e67a918f7828.1561979715.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to use the same set of routines to register notifiers for different request types, update the existing dev_pm_qos_{add|remove}_notifier() routines with an additional parameter: request-type. For now, it only supports resume-latency request type but will be extended to frequency limit (min/max) constraints later on. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar --- Documentation/power/pm_qos_interface.txt | 10 ++++++---- drivers/base/power/domain.c | 8 +++++--- drivers/base/power/qos.c | 14 ++++++++++++-- include/linux/pm_qos.h | 12 ++++++++---- 4 files changed, 31 insertions(+), 13 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index 19c5f7b1a7ba..ec7d662d1707 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt @@ -164,12 +164,14 @@ directory. Notification mechanisms: The per-device PM QoS framework has a per-device notification tree. -int dev_pm_qos_add_notifier(device, notifier): -Adds a notification callback function for the device. +int dev_pm_qos_add_notifier(device, notifier, type): +Adds a notification callback function for the device for a particular request +type. + The callback is called when the aggregated value of the device constraints list -is changed (for resume latency device PM QoS only). +is changed. -int dev_pm_qos_remove_notifier(device, notifier): +int dev_pm_qos_remove_notifier(device, notifier, type): Removes the notification callback function for the device. diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 33c30c1e6a30..b063bc41b0a9 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1536,7 +1536,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (ret) genpd_free_dev_data(dev, gpd_data); else - dev_pm_qos_add_notifier(dev, &gpd_data->nb); + dev_pm_qos_add_notifier(dev, &gpd_data->nb, + DEV_PM_QOS_RESUME_LATENCY); return ret; } @@ -1569,7 +1570,8 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, pdd = dev->power.subsys_data->domain_data; gpd_data = to_gpd_data(pdd); - dev_pm_qos_remove_notifier(dev, &gpd_data->nb); + dev_pm_qos_remove_notifier(dev, &gpd_data->nb, + DEV_PM_QOS_RESUME_LATENCY); genpd_lock(genpd); @@ -1597,7 +1599,7 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, out: genpd_unlock(genpd); - dev_pm_qos_add_notifier(dev, &gpd_data->nb); + dev_pm_qos_add_notifier(dev, &gpd_data->nb, DEV_PM_QOS_RESUME_LATENCY); return ret; } diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 6c91f8df1d59..cfd463212513 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -467,6 +467,7 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_remove_request); * * @dev: target device for the constraint * @notifier: notifier block managed by caller. + * @type: request type. * * Will register the notifier into a notification chain that gets called * upon changes to the target value for the device. @@ -474,10 +475,14 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_remove_request); * If the device's constraints object doesn't exist when this routine is called, * it will be created (or error code will be returned if that fails). */ -int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier) +int dev_pm_qos_add_notifier(struct device *dev, struct notifier_block *notifier, + enum dev_pm_qos_req_type type) { int ret = 0; + if (WARN_ON(type != DEV_PM_QOS_RESUME_LATENCY)) + return -EINVAL; + mutex_lock(&dev_pm_qos_mtx); if (IS_ERR(dev->power.qos)) @@ -500,15 +505,20 @@ EXPORT_SYMBOL_GPL(dev_pm_qos_add_notifier); * * @dev: target device for the constraint * @notifier: notifier block to be removed. + * @type: request type. * * Will remove the notifier from the notification chain that gets called * upon changes to the target value. */ int dev_pm_qos_remove_notifier(struct device *dev, - struct notifier_block *notifier) + struct notifier_block *notifier, + enum dev_pm_qos_req_type type) { int retval = 0; + if (WARN_ON(type != DEV_PM_QOS_RESUME_LATENCY)) + return -EINVAL; + mutex_lock(&dev_pm_qos_mtx); /* Silently return if the constraints object is not present. */ diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 6ea1ae373d77..1f4d456e8fff 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -146,9 +146,11 @@ int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); int dev_pm_qos_remove_request(struct dev_pm_qos_request *req); int dev_pm_qos_add_notifier(struct device *dev, - struct notifier_block *notifier); + struct notifier_block *notifier, + enum dev_pm_qos_req_type type); int dev_pm_qos_remove_notifier(struct device *dev, - struct notifier_block *notifier); + struct notifier_block *notifier, + enum dev_pm_qos_req_type type); void dev_pm_qos_constraints_init(struct device *dev); void dev_pm_qos_constraints_destroy(struct device *dev); int dev_pm_qos_add_ancestor_request(struct device *dev, @@ -202,10 +204,12 @@ static inline int dev_pm_qos_update_request(struct dev_pm_qos_request *req, static inline int dev_pm_qos_remove_request(struct dev_pm_qos_request *req) { return 0; } static inline int dev_pm_qos_add_notifier(struct device *dev, - struct notifier_block *notifier) + struct notifier_block *notifier, + enum dev_pm_qos_req_type type); { return 0; } static inline int dev_pm_qos_remove_notifier(struct device *dev, - struct notifier_block *notifier) + struct notifier_block *notifier, + enum dev_pm_qos_req_type type) { return 0; } static inline void dev_pm_qos_constraints_init(struct device *dev) { From patchwork Mon Jul 1 11:26:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168205 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2802150ilk; Mon, 1 Jul 2019 04:26:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqytLJkMxFELGXQv+goL0+giXe0NI5mpxQJubq3uzclAnvf7RRFv9q/bwsqPMPvWsULHEVMW X-Received: by 2002:a17:90a:fa07:: with SMTP id cm7mr29672613pjb.138.1561980397865; Mon, 01 Jul 2019 04:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561980397; cv=none; d=google.com; s=arc-20160816; b=vF8krfDCy9LwovW5AdnCW5TM6W2wd0pDYM2d/E1iYd0AnpQGrHfra/x3Fx7Eat9ey8 nJzpfIm64+HlBbYorO1kcKTNv1t/ce9xLCqwIYpOJ5+VgvA94X5Lw90w5w/Cnp5YLfu1 qG2nvtJ0Y8mn/OG5DI7lYaF7Ow9VA1jx//7HFyW/DvSLNdJ5xqnGLzTeDPOaO4eYcLaO Vq5YVttUF9svZ1MnT8hWb9FhWrFyypnJHf7HqofsCxhwuFhz25/ejS+SRgHMHN+SJ2qo /ImJKpqD/iEb2+2l4YSteGKLin4ztvPX9n3zg7ftlhyfBmvpOPC980pTI4f40oOrBE2Q bV0Q== 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 :dkim-signature; bh=mFea1NB8cblkfncT7oG1ziy//jPVykLkqdpiv/Sj2rY=; b=TAx1d+GUFwcaGD4fArADjspg7e2syDxIjI/Kj37UdRCjTxrCnELXiK16W5z9CRmwkA 79haXKNFRrrcByZOLniFOlSrLbK0cAyOd+YXQHBYyZRLvjU/aFanV7KZ4HyWXSDqbUAc V9WV+fWThLKY9UsmJGa5k3loek3vNw4NPUes9RzLzO1Nwhv4j8WUPd3MHbrJcnVqn4ET JkDz24n4O9MBdcFE6Nw0BKlCAcmOkSyHBnrG1eq2KbopP2lRbIYCSnEPLBTziMgslxl2 52Zf4AAeolRhDUYs+M1cp+xGAvKvVvJIS29Yu0kzOFeiEwil0LVPg92uYqDZNegsgtvH IVRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q19Xf6xV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o1si10317541plb.337.2019.07.01.04.26.37; Mon, 01 Jul 2019 04:26:37 -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=@linaro.org header.s=google header.b=q19Xf6xV; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728566AbfGAL0g (ORCPT + 30 others); Mon, 1 Jul 2019 07:26:36 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39953 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728517AbfGAL0d (ORCPT ); Mon, 1 Jul 2019 07:26:33 -0400 Received: by mail-pl1-f195.google.com with SMTP id a93so7220805pla.7 for ; Mon, 01 Jul 2019 04:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mFea1NB8cblkfncT7oG1ziy//jPVykLkqdpiv/Sj2rY=; b=q19Xf6xVs1WEk56gh2njTMtLGT4SpsfN/TXoLH9k4sqQi59MufkhkvAeeXC3l2LCSu SZ6W4q2yMLzgHu03nuSYNdtba3Jn3QwwNvjE7Uion8tr0a7/G/zPhGuPgOdXUGJ+25cy wlWCdjywjns9TWQx5VMyH7RZprrV6Gu36GWA7y1K05pMHnf8Z7DGK7oI6S1FUZwqJTG8 2KydMVt9I5y35NH9iz/2n38MJCARtEExNSwWxs5WoJH6tFJEI0Sg8G7SqCgwgzWVjq8R efXpYwBNUokSdc3vSa4TSPc9a7oqHMc+vGv7SMhGuo1C2R19ev6i86x+uMI7kRDHcRVE igKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mFea1NB8cblkfncT7oG1ziy//jPVykLkqdpiv/Sj2rY=; b=JZJ/ojkpktt5IeL8pSfgbx+bZer2bv3BC0BPHU31l1CddjtkITvaKgqFby2HYGcVSx TdorGAqX3ghFe//z4CCYt95N9flLnOXfL533Fibd/JFIbAPjJ9PjTpNN3HzTIl2Q/uPZ DhDtTTxNeSfPBZBfa+R/vhGTf+kx3VkolTXNxG5IMDOBoyjt2nek4UBkytfJe4R7Mig1 c7N2UOxnf4g4gXw0E2ZFUihBJA8U7ZgAkL+TpySdRDvW0wEwoFdbtuaruqatj7XEcq/I 96/hQz/h1nXCOuWtM1vIJlu/9dhHwFvAFd+H5yzkAfh6eWwcaAucwi7qaQuggqkdvy86 Lqkw== X-Gm-Message-State: APjAAAXkupN2a4PP1SIZGAC6m3bvCXnNqct8Q9gxkIKU1LUHzlxlykAg 2Jn6ATBxiU90NpBjexkuRf98WA== X-Received: by 2002:a17:902:1101:: with SMTP id d1mr28742850pla.212.1561980392649; Mon, 01 Jul 2019 04:26:32 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id m100sm12021381pje.12.2019.07.01.04.26.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 04:26:32 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Len Brown , Pavel Machek , Kevin Hilman , Ulf Hansson Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Qais.Yousef@arm.com, mka@chromium.org, juri.lelli@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH V5 3/7] PM / QOS: Pass request type to dev_pm_qos_read_value() Date: Mon, 1 Jul 2019 16:56:11 +0530 Message-Id: <58c6b468b1c2656df03a8265e82e2e4b8427d687.1561979715.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to allow dev_pm_qos_read_value() to read values for different QoS requests, pass request type as a parameter to these routines. For now, it only supports resume-latency request type but will be extended to frequency limit (min/max) constraints later on. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar --- Documentation/power/pm_qos_interface.txt | 2 +- drivers/base/power/domain_governor.c | 2 +- drivers/base/power/qos.c | 17 ++++++++++++----- include/linux/pm_qos.h | 16 +++++++++++++--- 4 files changed, 27 insertions(+), 10 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt index ec7d662d1707..cfcb1df39799 100644 --- a/Documentation/power/pm_qos_interface.txt +++ b/Documentation/power/pm_qos_interface.txt @@ -123,7 +123,7 @@ Will remove the element. After removal it will update the aggregate target and call the notification trees if the target was changed as a result of removing the request. -s32 dev_pm_qos_read_value(device): +s32 dev_pm_qos_read_value(device, type): Returns the aggregated value for a given device's constraints list. enum pm_qos_flags_status dev_pm_qos_flags(device, mask) diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 20e56a5be01f..daa8c7689f7e 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -33,7 +33,7 @@ static int dev_update_qos_constraint(struct device *dev, void *data) * take its current PM QoS constraint (that's the only thing * known at this point anyway). */ - constraint_ns = dev_pm_qos_read_value(dev); + constraint_ns = dev_pm_qos_read_value(dev, DEV_PM_QOS_RESUME_LATENCY); constraint_ns *= NSEC_PER_USEC; } diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c index 7a0d197f0809..2461fed0efa0 100644 --- a/drivers/base/power/qos.c +++ b/drivers/base/power/qos.c @@ -105,18 +105,25 @@ s32 __dev_pm_qos_resume_latency(struct device *dev) /** * dev_pm_qos_read_value - Get PM QoS constraint for a given device (locked). * @dev: Device to get the PM QoS constraint value for. + * @type: QoS request type. */ -s32 dev_pm_qos_read_value(struct device *dev) +s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type) { + struct dev_pm_qos *qos = dev->power.qos; unsigned long flags; s32 ret; spin_lock_irqsave(&dev->power.lock, flags); - if (IS_ERR_OR_NULL(dev->power.qos)) - ret = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; - else - ret = pm_qos_read_value(&dev->power.qos->resume_latency); + switch (type) { + case DEV_PM_QOS_RESUME_LATENCY: + ret = IS_ERR_OR_NULL(qos) ? PM_QOS_RESUME_LATENCY_NO_CONSTRAINT + : pm_qos_read_value(&qos->resume_latency); + break; + default: + WARN_ON(1); + ret = 0; + } spin_unlock_irqrestore(&dev->power.lock, flags); diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 06aa88496761..5ce1c310373e 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -140,7 +140,7 @@ s32 pm_qos_read_value(struct pm_qos_constraints *c); enum pm_qos_flags_status __dev_pm_qos_flags(struct device *dev, s32 mask); enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, s32 mask); s32 __dev_pm_qos_resume_latency(struct device *dev); -s32 dev_pm_qos_read_value(struct device *dev); +s32 dev_pm_qos_read_value(struct device *dev, enum dev_pm_qos_req_type type); int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, enum dev_pm_qos_req_type type, s32 value); int dev_pm_qos_update_request(struct dev_pm_qos_request *req, s32 new_value); @@ -191,8 +191,18 @@ static inline enum pm_qos_flags_status dev_pm_qos_flags(struct device *dev, { return PM_QOS_FLAGS_UNDEFINED; } static inline s32 __dev_pm_qos_resume_latency(struct device *dev) { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } -static inline s32 dev_pm_qos_read_value(struct device *dev) - { return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; } +static inline s32 dev_pm_qos_read_value(struct device *dev, + enum dev_pm_qos_req_type type) +{ + switch type { + case DEV_PM_QOS_RESUME_LATENCY: + return PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; + default: + WARN_ON(1); + return 0; + } +} + static inline int dev_pm_qos_add_request(struct device *dev, struct dev_pm_qos_request *req, enum dev_pm_qos_req_type type, From patchwork Mon Jul 1 11:26:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 168209 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2802439ilk; Mon, 1 Jul 2019 04:26:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmNoFQghvZdyovcWNxPbqhP+8wY7nJXmY2XockjlB+hp8l5z3lj6aN/1MIXq64K5s2GVWe X-Received: by 2002:a17:90a:8c18:: with SMTP id a24mr29804588pjo.111.1561980413327; Mon, 01 Jul 2019 04:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561980413; cv=none; d=google.com; s=arc-20160816; b=oeXKwQpQY9RcGHi362fTMLS916867EE7PNEJQqJ+iUVsoygrL2LEZueuNh1dYGJN11 YVZK9UQBbh5j7rzSqBIZhNvO4lYoeTxo+FesYq7i1LyARCCjnVvxPo99ExcmG0Tunfwq WIcn3UsMU1dpOfrBOHEQBzMwIXkLgjXR3ACS1VU1JprqGv4SeAwBZSJICqc4Crl+h7G5 NbWY035VEwXhJJS+qPh+rUxRgZ2tag23ATnWNS69cjuzryPtxMzmWL7qYSTi/ou7OhqE 5Z0sj18yJ8eeDX3RuWWDdCw7+6ie6UqawwunJUtS0ojiryFikabc1WEt0+K2t8+X7VX9 3aYg== 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 :dkim-signature; bh=dROVlj93TTPLRT6uezx74xZihEexZU3Wg3j3xsC8+gY=; b=Xij2zTGuU32/cHRazvp4HWBSmIFp/VORZYL0ncUerMTxI3rwDw0yojGxxY7OKGepBD zwVRLTEv10oHEjT1A9bHqy6MWXN2POzDQlY/3OOpLjNLL/4OQR1J80V3Xwg9FrWs79sd MyhGRJJBcBOEX0jfzkfErRfwWI4Oc46S9nkP1YuVs0Xbwr953ZyUV3LBBFpALiTBvvd4 5shRh+lKh2pvRQEMn0+ORUVKjqBFAenPDAp7QbMz90cyPg7KltnsgrU1UijF+7PdQeZ6 mKyp7/TpQbam4Hn4vqmk5KlvZ+zs5bfJb32JMza4B6Zck7qIiU8btB8aNgg4FNt58f9p 9o0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BT1t96iS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13si9553619pgv.398.2019.07.01.04.26.53; Mon, 01 Jul 2019 04:26:53 -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=@linaro.org header.s=google header.b=BT1t96iS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728882AbfGAL0w (ORCPT + 30 others); Mon, 1 Jul 2019 07:26:52 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35771 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728777AbfGAL0p (ORCPT ); Mon, 1 Jul 2019 07:26:45 -0400 Received: by mail-pl1-f194.google.com with SMTP id w24so7212918plp.2 for ; Mon, 01 Jul 2019 04:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dROVlj93TTPLRT6uezx74xZihEexZU3Wg3j3xsC8+gY=; b=BT1t96iSEupEstafHaM5OcOpOWJq1jh6RunK3V02KL+5vTHFuY7mV0T52uezzND5pr tJAIWIgl/d5+ZMRY91f3lrIIEMcbN2oNws5MzY0cth7XAiOb8j9SVHMA/CCybXvykRe0 zjJ6r8tbvjyw1x6SHVvW2pHwrZe1Dx8fjNpA3eKI3Xvf2tu2XR8M3M3ZGpEkZjuzv3dV XWWpmE1RmoCgSsJBW+hHngT44vHFmi0RNJBwMu9BxWXak2b1eZ8tRZSTSmzTPQ08vGCj HUI2PBl9HUQhUKGK1HufdiDKLPjtxPzE3JaGi0hsZeyGhZTnzl1UDE6C7SJX2DFiHGSb OcxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dROVlj93TTPLRT6uezx74xZihEexZU3Wg3j3xsC8+gY=; b=ncbCL1E6LGtUA02HQY4v0kLdOejnkoH+iSw/2IzG691/Bg50g5LD4TciLWdMb30hGA YqAKp3+bTHiAllixb6detDUAHRM9JpYeWQOJ38CWDjiTi40D32B4uyoQqm2xmTyhh0jH UPvBSkhp/YoB6J7uNXmpHIQKHjQXpXdodklrj719IrB5WrkXaukhG/MNcV9NpZyVVx/o YwngOLZhNk2Qwpwwu/cDJxRxqAShICvZ/F2y4nbKKCqUf8NWmyURdel8hodmTyA26c3u +E2k2kyInhqEPIwkngBg1TAKKu9ZEncqrDX3xc4/rQj/ySesq8j8aEqA5K1caRPq2vEK sIGg== X-Gm-Message-State: APjAAAX6Tt8FXmx7AunLoqu0igSbn1KUrxS4CEhplegdbVV04MH/xyeE NV3pgk7jNcwYUfCoUdoIhu2FbQ== X-Received: by 2002:a17:902:aa8a:: with SMTP id d10mr29046097plr.154.1561980404844; Mon, 01 Jul 2019 04:26:44 -0700 (PDT) Received: from localhost ([122.172.21.205]) by smtp.gmail.com with ESMTPSA id q126sm15303848pfq.123.2019.07.01.04.26.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jul 2019 04:26:44 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Qais.Yousef@arm.com, mka@chromium.org, juri.lelli@gmail.com, Ulf Hansson , linux-kernel@vger.kernel.org Subject: [PATCH V5 7/7] cpufreq: Add QoS requests for userspace constraints Date: Mon, 1 Jul 2019 16:56:15 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This implements QoS requests to manage userspace configuration of min and max frequency. Reviewed-by: Matthias Kaehlcke Reviewed-by: Ulf Hansson Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 87 ++++++++++++++++++++------------------- include/linux/cpufreq.h | 8 +--- 2 files changed, 46 insertions(+), 49 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 091789e868ee..13c2f119cc0c 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -718,23 +718,15 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf) static ssize_t store_##file_name \ (struct cpufreq_policy *policy, const char *buf, size_t count) \ { \ - int ret, temp; \ - struct cpufreq_policy new_policy; \ + unsigned long val; \ + int ret; \ \ - memcpy(&new_policy, policy, sizeof(*policy)); \ - new_policy.min = policy->user_policy.min; \ - new_policy.max = policy->user_policy.max; \ - \ - ret = sscanf(buf, "%u", &new_policy.object); \ + ret = sscanf(buf, "%lu", &val); \ if (ret != 1) \ return -EINVAL; \ \ - temp = new_policy.object; \ - ret = cpufreq_set_policy(policy, &new_policy); \ - if (!ret) \ - policy->user_policy.object = temp; \ - \ - return ret ? ret : count; \ + ret = dev_pm_qos_update_request(policy->object##_freq_req, val);\ + return ret >= 0 ? count : ret; \ } store_one(scaling_min_freq, min); @@ -1126,8 +1118,6 @@ void refresh_frequency_limits(struct cpufreq_policy *policy) new_policy = *policy; pr_debug("updating policy for CPU %u\n", policy->cpu); - new_policy.min = policy->user_policy.min; - new_policy.max = policy->user_policy.max; cpufreq_set_policy(policy, &new_policy); } @@ -1238,6 +1228,12 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) goto err_min_qos_notifier; } + policy->min_freq_req = kzalloc(2 * sizeof(*policy->min_freq_req), + GFP_KERNEL); + if (!policy->min_freq_req) + goto err_max_qos_notifier; + + policy->max_freq_req = policy->min_freq_req + 1; INIT_LIST_HEAD(&policy->policy_list); init_rwsem(&policy->rwsem); spin_lock_init(&policy->transition_lock); @@ -1248,6 +1244,9 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) policy->cpu = cpu; return policy; +err_max_qos_notifier: + dev_pm_qos_remove_notifier(dev, &policy->nb_max, + DEV_PM_QOS_MAX_FREQUENCY); err_min_qos_notifier: dev_pm_qos_remove_notifier(dev, &policy->nb_min, DEV_PM_QOS_MIN_FREQUENCY); @@ -1283,6 +1282,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) DEV_PM_QOS_MAX_FREQUENCY); dev_pm_qos_remove_notifier(dev, &policy->nb_min, DEV_PM_QOS_MIN_FREQUENCY); + dev_pm_qos_remove_request(policy->max_freq_req); + dev_pm_qos_remove_request(policy->min_freq_req); + kfree(policy->min_freq_req); cpufreq_policy_put_kobj(policy); free_cpumask_var(policy->real_cpus); @@ -1361,16 +1363,30 @@ static int cpufreq_online(unsigned int cpu) cpumask_and(policy->cpus, policy->cpus, cpu_online_mask); if (new_policy) { - policy->user_policy.min = policy->min; - policy->user_policy.max = policy->max; + struct device *dev = get_cpu_device(cpu); for_each_cpu(j, policy->related_cpus) { per_cpu(cpufreq_cpu_data, j) = policy; add_cpu_dev_symlink(policy, j); } - } else { - policy->min = policy->user_policy.min; - policy->max = policy->user_policy.max; + + ret = dev_pm_qos_add_request(dev, policy->min_freq_req, + DEV_PM_QOS_MIN_FREQUENCY, + policy->min); + if (ret < 0) { + dev_err(dev, "Failed to add min-freq constraint (%d)\n", + ret); + goto out_destroy_policy; + } + + ret = dev_pm_qos_add_request(dev, policy->max_freq_req, + DEV_PM_QOS_MAX_FREQUENCY, + policy->max); + if (ret < 0) { + dev_err(dev, "Failed to add max-freq constraint (%d)\n", + ret); + goto out_destroy_policy; + } } if (cpufreq_driver->get && has_target()) { @@ -2344,7 +2360,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, { struct cpufreq_governor *old_gov; struct device *cpu_dev = get_cpu_device(policy->cpu); - unsigned long min, max; int ret; pr_debug("setting new policy for CPU %u: %u - %u kHz\n", @@ -2352,24 +2367,12 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); - /* - * This check works well when we store new min/max freq attributes, - * because new_policy is a copy of policy with one field updated. - */ - if (new_policy->min > new_policy->max) - return -EINVAL; - /* * PM QoS framework collects all the requests from users and provide us * the final aggregated value here. */ - min = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MIN_FREQUENCY); - max = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MAX_FREQUENCY); - - if (min > new_policy->min) - new_policy->min = min; - if (max < new_policy->max) - new_policy->max = max; + new_policy->min = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MIN_FREQUENCY); + new_policy->max = dev_pm_qos_read_value(cpu_dev, DEV_PM_QOS_MAX_FREQUENCY); /* verify the cpu speed can be set within this limit */ ret = cpufreq_driver->verify(new_policy); @@ -2458,10 +2461,9 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, * @cpu: CPU to re-evaluate the policy for. * * Update the current frequency for the cpufreq policy of @cpu and use - * cpufreq_set_policy() to re-apply the min and max limits saved in the - * user_policy sub-structure of that policy, which triggers the evaluation - * of policy notifiers and the cpufreq driver's ->verify() callback for the - * policy in question, among other things. + * cpufreq_set_policy() to re-apply the min and max limits, which triggers the + * evaluation of policy notifiers and the cpufreq driver's ->verify() callback + * for the policy in question, among other things. */ void cpufreq_update_policy(unsigned int cpu) { @@ -2521,10 +2523,9 @@ static int cpufreq_boost_set_sw(int state) break; } - down_write(&policy->rwsem); - policy->user_policy.max = policy->max; - cpufreq_governor_limits(policy); - up_write(&policy->rwsem); + ret = dev_pm_qos_update_request(policy->max_freq_req, policy->max); + if (ret) + break; } return ret; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 1fa37b675a80..afc683021ac5 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -50,11 +50,6 @@ struct cpufreq_cpuinfo { unsigned int transition_latency; }; -struct cpufreq_user_policy { - unsigned int min; /* in kHz */ - unsigned int max; /* in kHz */ -}; - struct cpufreq_policy { /* CPUs sharing clock, require sw coordination */ cpumask_var_t cpus; /* Online CPUs only */ @@ -84,7 +79,8 @@ struct cpufreq_policy { struct work_struct update; /* if update_policy() needs to be * called, but you're in IRQ context */ - struct cpufreq_user_policy user_policy; + struct dev_pm_qos_request *min_freq_req; + struct dev_pm_qos_request *max_freq_req; struct cpufreq_frequency_table *freq_table; enum cpufreq_table_sorting freq_table_sorted;