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,