From patchwork Fri Apr 24 11:40:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin GAIGNARD X-Patchwork-Id: 11507701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35BE992C for ; Fri, 24 Apr 2020 11:42:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0FF1620700 for ; Fri, 24 Apr 2020 11:42:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O99i5U0e"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=st.com header.i=@st.com header.b="k2a+ZW4j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0FF1620700 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=//j/EeCMMzl3wXyOBojWb6yTmhbUR/nRPuLquEMN/Og=; b=O99i5U0eNoLJ9G m5TE2Xl0fLHn7zjtRLstnHqIGFDLGwiX6E6/dsCGW+c+JW5SVjiczFr0fvdFFNLK6ZvOhP+JtFNLX rQu+O4Yjgls2DPWwmJSn3jgkHuzJKXEhzD/PXF34xK7/PqhXsRV5yo5lhhNtkDU+Rb3LOmxlqH9yv fGzJnvhMGsQC+VpZB/ZUWDI3pFXOFMFiHAgnokmty3/eZKx+XbJ05g/0WiQACK5pzgSpRHqffknBZ 1PYgMFp6bZ+NMbqCmHWobnB/5LXMNWcsho33Y/ZS/9YGt44oRyBsCFZncVsuSR3TMBps2YOSkQ+B5 7zl/y22Br8TFfVosM+0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRwiZ-0001BP-PJ; Fri, 24 Apr 2020 11:42:03 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRwhn-0000Od-6K for linux-arm-kernel@lists.infradead.org; Fri, 24 Apr 2020 11:41:18 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03OBWOO5009422; Fri, 24 Apr 2020 13:41:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=0feWfYVxQYrSEupQlVoVOosyiC2LKcVNCDVytVsfcsI=; b=k2a+ZW4je8Dasnp7OZgVgDh8l+4SvgkEllW2sAQP55NAcIM4Q3F8pELb2N3M00Cs75Zk jORYbUNTFOU5PdtYO99X3cOSWEjxmzIY9bf6wjuMcDgrx6tnHX4hucBkF5RkL9MIzzJH yIsG0VneX9sWsaZ3PA2DAjTITGrr+9LxkLghDreSvgmoqINhnkRIJb8uuLlVw68MW9y7 ocFIzN8qeCM/SlPsvfo2VQbi6WZN6j2fGB8nKrCAn7D0NSECPk6oMQmt9I1gg3bTH19u 1YWld5bdzgUoIKak9LfTSp2iB1iVDcBeRjxm4stI5GQKhc2hejaiXuZaaH3kzIxCZkWN YA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fq122v61-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Apr 2020 13:41:04 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6296810002A; Fri, 24 Apr 2020 13:41:03 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node3.st.com [10.75.127.9]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4D0F52B3DA1; Fri, 24 Apr 2020 13:41:03 +0200 (CEST) Received: from localhost (10.75.127.48) by SFHDAG3NODE3.st.com (10.75.127.9) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 24 Apr 2020 13:41:02 +0200 From: Benjamin Gaignard To: , , , , , , , Subject: [RFC 1/3] PM: QoS: Introduce cpufreq minimum load QoS Date: Fri, 24 Apr 2020 13:40:56 +0200 Message-ID: <20200424114058.21199-2-benjamin.gaignard@st.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200424114058.21199-1-benjamin.gaignard@st.com> References: <20200424114058.21199-1-benjamin.gaignard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG6NODE1.st.com (10.75.127.16) To SFHDAG3NODE3.st.com (10.75.127.9) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-24_04:2020-04-23, 2020-04-24 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200424_044115_706822_1FDBD4DC X-CRM114-Status: GOOD ( 18.42 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [62.209.51.94 listed in list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Gaignard , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Introduce cpufreq minimum load QoS, based on the "raw" low-level PM QoS, to represent the minimum expected cpu load by various devices. The cpufreq_minload_qos_limit() helper is defined to retrieve the aggregated constraints. Signed-off-by: Benjamin Gaignard --- include/linux/pm_qos.h | 12 +++ kernel/power/qos.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 4a69d4af3ff8..e2cc099322e3 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -316,4 +316,16 @@ int freq_qos_remove_notifier(struct freq_constraints *qos, enum freq_qos_req_type type, struct notifier_block *notifier); +/* Definitions related to the cpufreq minimum load QoS. */ + +#define CPUFREQ_GOV_QOS_MIN_LOAD_DEFAULT_VALUE 0 +#define CPUFREQ_GOV_QOS_MIN_LOAD_MAX_VALUE 10 + +s32 cpufreq_minload_qos_limit(void); +bool cpufreq_minload_qos_request_active(struct pm_qos_request *req); +void cpufreq_minload_qos_add_request(struct pm_qos_request *req, s32 value); +void cpufreq_minload_qos_update_request(struct pm_qos_request *req, + s32 new_value); +void cpufreq_minload_qos_remove_request(struct pm_qos_request *req); + #endif diff --git a/kernel/power/qos.c b/kernel/power/qos.c index db0bed2cae26..df2fdd962f35 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -671,3 +671,216 @@ int freq_qos_remove_notifier(struct freq_constraints *qos, return ret; } EXPORT_SYMBOL_GPL(freq_qos_remove_notifier); + +/* Definitions related to the cpufreq minimum load QoS. */ + +static struct pm_qos_constraints cpufreq_minload_constraints = { + .list = PLIST_HEAD_INIT(cpufreq_minload_constraints.list), + .target_value = CPUFREQ_GOV_QOS_MIN_LOAD_DEFAULT_VALUE, + .default_value = CPUFREQ_GOV_QOS_MIN_LOAD_DEFAULT_VALUE, + .no_constraint_value = CPUFREQ_GOV_QOS_MIN_LOAD_DEFAULT_VALUE, + .type = PM_QOS_MAX, +}; + +/** + * cpufreq_minload_qos_limit - Return current system-wide cpufreq + * minimum load QoS limit. + */ +s32 cpufreq_minload_qos_limit(void) +{ + return pm_qos_read_value(&cpufreq_minload_constraints); +} +EXPORT_SYMBOL_GPL(cpufreq_minload_qos_limit); + +/** + * cpufreq_minload_qos_request_active - Check the given PM QoS request. + * @req: PM QoS request to check. + * + * Return: 'true' if @req has been added to the cpufreq minimum load + * QoS list, 'false' otherwise. + */ +bool cpufreq_minload_qos_request_active(struct pm_qos_request *req) +{ + return req->qos == &cpufreq_minload_constraints; +} +EXPORT_SYMBOL_GPL(cpufreq_minload_qos_request_active); + +/** + * cpufreq_minload_qos_add_request - Add new cpufreq minimum load QoS request. + * @req: Pointer to a preallocated handle. + * @value: Requested constraint value. + * + * Use @value to initialize the request handle pointed to by @req, insert it as + * a new entry to the cpufreq minimum load QoS list and recompute the effective + * QoS constraint for that list. + * + * Callers need to save the handle for later use in updates and removal of the + * QoS request represented by it. + */ +void cpufreq_minload_qos_add_request(struct pm_qos_request *req, s32 value) +{ + if (!req) + return; + + if (cpufreq_minload_qos_request_active(req)) { + WARN(1, KERN_ERR "%s called for already added request\n", __func__); + return; + } + + trace_pm_qos_add_request(value); + + req->qos = &cpufreq_minload_constraints; + pm_qos_update_target(req->qos, &req->node, PM_QOS_ADD_REQ, value); +} +EXPORT_SYMBOL_GPL(cpufreq_minload_qos_add_request); + +/** + * cpufreq_minload_qos_update_request - Modify existing cpufreq minimum load + * QoS request. + * @req : QoS request to update. + * @new_value: New requested constraint value. + * + * Use @new_value to update the QoS request represented by @req in the cpufreq + * minimum load QoS list along with updating the effective constraint value for + * that list. + */ +void cpufreq_minload_qos_update_request(struct pm_qos_request *req, + s32 new_value) +{ + if (!req) + return; + + if (!cpufreq_minload_qos_request_active(req)) { + WARN(1, KERN_ERR "%s called for unknown object\n", __func__); + return; + } + + trace_pm_qos_update_request(new_value); + + if (new_value == req->node.prio) + return; + + pm_qos_update_target(req->qos, &req->node, PM_QOS_UPDATE_REQ, new_value); +} +EXPORT_SYMBOL_GPL(cpufreq_minload_qos_update_request); + +/** + * cpufreq_minload_qos_remove_request - Remove existing cpufreq minimum load QoS + * request. + * @req: QoS request to remove. + * + * Remove the cpufreq minimum load QoS request represented by @req from the + * cpufreq minimum load QoS list along with updating the effective constraint + * value for that list. + */ +void cpufreq_minload_qos_remove_request(struct pm_qos_request *req) +{ + if (!req) + return; + + if (!cpufreq_minload_qos_request_active(req)) { + WARN(1, KERN_ERR "%s called for unknown object\n", __func__); + return; + } + + trace_pm_qos_remove_request(PM_QOS_DEFAULT_VALUE); + + pm_qos_update_target(req->qos, &req->node, + PM_QOS_REMOVE_REQ, PM_QOS_DEFAULT_VALUE); + memset(req, 0, sizeof(*req)); +} +EXPORT_SYMBOL_GPL(cpufreq_minload_qos_remove_request); + +/* User space interface to the cpufreq minimum load QoS via misc device. */ + +static int cpufreq_minload_qos_open(struct inode *inode, struct file *filp) +{ + struct pm_qos_request *req; + + req = kzalloc(sizeof(*req), GFP_KERNEL); + if (!req) + return -ENOMEM; + + cpufreq_minload_qos_add_request(req, PM_QOS_DEFAULT_VALUE); + filp->private_data = req; + + return 0; +} + +static int cpufreq_minload_qos_release(struct inode *inode, struct file *filp) +{ + struct pm_qos_request *req = filp->private_data; + + filp->private_data = NULL; + + cpufreq_minload_qos_remove_request(req); + kfree(req); + + return 0; +} + +static ssize_t cpufreq_minload_qos_read(struct file *filp, char __user *buf, + size_t count, loff_t *f_pos) +{ + struct pm_qos_request *req = filp->private_data; + unsigned long flags; + s32 value; + + if (!req || !cpufreq_minload_qos_request_active(req)) + return -EINVAL; + + spin_lock_irqsave(&pm_qos_lock, flags); + value = pm_qos_get_value(&cpufreq_minload_constraints); + spin_unlock_irqrestore(&pm_qos_lock, flags); + + return simple_read_from_buffer(buf, count, f_pos, &value, sizeof(s32)); +} + +static ssize_t cpufreq_minload_qos_write(struct file *filp, + const char __user *buf, + size_t count, loff_t *f_pos) +{ + s32 value; + + if (count == sizeof(s32)) { + if (copy_from_user(&value, buf, sizeof(s32))) + return -EFAULT; + } else { + int ret; + + ret = kstrtos32_from_user(buf, count, 16, &value); + if (ret) + return ret; + } + + cpufreq_minload_qos_update_request(filp->private_data, value); + + return count; +} + +static const struct file_operations cpufreq_minload_qos_fops = { + .write = cpufreq_minload_qos_write, + .read = cpufreq_minload_qos_read, + .open = cpufreq_minload_qos_open, + .release = cpufreq_minload_qos_release, + .llseek = noop_llseek, +}; + +static struct miscdevice cpufreq_minload_qos_miscdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = "cpufreq_minimum_load", + .fops = &cpufreq_minload_qos_fops, +}; + +static int __init cpufreq_minload_qos_init(void) +{ + int ret; + + ret = misc_register(&cpufreq_minload_qos_miscdev); + if (ret < 0) + pr_err("%s: %s setup failed\n", __func__, + cpufreq_minload_qos_miscdev.name); + + return ret; +} +late_initcall(cpufreq_minload_qos_init); From patchwork Fri Apr 24 11:40:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin GAIGNARD X-Patchwork-Id: 11507689 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E16D314B4 for ; Fri, 24 Apr 2020 11:41:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCABE20776 for ; Fri, 24 Apr 2020 11:41:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XE21uhTE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=st.com header.i=@st.com header.b="Cz/dBvho" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCABE20776 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YkOcn3M4Jf7rC7O9AF2j0g/+MxduUnDIimqVxAeFywI=; b=XE21uhTEIQ7Rv4 fGOEyeCLIqibDGBkDZ01PKyoG6/wH9Ct4bpkvKD8Oe98aRP0dtUXx/dOAt/xFpX12I6j8uhzu1WbA MkmPDnxXWI0axIsJUsQuRPlw5z0p+ALwc+rNaenlxNLiv7DfXFRWRNS/0ZTwG2o/nbyF3YlIeMrnv Hfjx3OmOE111lyMTCxawra4h8IiuujQJOxa/lUCM5t99pGb2ightSo18Y3tdkKKKclYHMDWfZZYSs wMCbzCVPMgcWL3NRQmabcLWhajH9RHu+0/BcTzZDm4sQg6NtYchONcPen/moMvGQc//2Jo7JURC6F TYNHg9zYiDm9h9b8OQ7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRwhz-0000Zk-Og; Fri, 24 Apr 2020 11:41:27 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRwhn-0000Of-6h for linux-arm-kernel@lists.infradead.org; Fri, 24 Apr 2020 11:41:17 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03OBWRX1023149; Fri, 24 Apr 2020 13:41:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=5Rg4znNj42bzqjnolZJ9lV8rYKa4nFxeh6irBMvctcs=; b=Cz/dBvho/0XMcgtyhgX+W9Q4pEgmNqeGCaUPo1EHOg6bNV9ptL7BHw1WnEvIE6Lf9XEP +ALfbyWp8T0ILDB6RGdtVPIjLIEK3w8TCsKtyLyA2iVk1qAxD1T/kabR55faLv1Wwb7+ b2Y1rmm1MSweMa/CYsHoPvyACRCoeGlAgtjCYAjzvkrDKkJ2XCWvVUTr9FODH3X8fFX9 bcEK5ybbmsAC2pQgNrf6tb57RTceHw8hcSFwsAbaGqHAd42x99+QIHiWgf8JcDD428zM q3n/3Jb9Dxtfof3ZxFRrNOBOR1P7ZHflgA5+pyj99aRNe85rQNv9yXzp6dZVJO9QhWSw RA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fpp9bch9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Apr 2020 13:41:04 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6A0DE100038; Fri, 24 Apr 2020 13:41:04 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node3.st.com [10.75.127.9]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 576082B3DA2; Fri, 24 Apr 2020 13:41:04 +0200 (CEST) Received: from localhost (10.75.127.49) by SFHDAG3NODE3.st.com (10.75.127.9) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 24 Apr 2020 13:41:03 +0200 From: Benjamin Gaignard To: , , , , , , , Subject: [RFC 2/3] cpufreq: governor: Use minimum load QoS Date: Fri, 24 Apr 2020 13:40:57 +0200 Message-ID: <20200424114058.21199-3-benjamin.gaignard@st.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200424114058.21199-1-benjamin.gaignard@st.com> References: <20200424114058.21199-1-benjamin.gaignard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG5NODE2.st.com (10.75.127.14) To SFHDAG3NODE3.st.com (10.75.127.9) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-24_04:2020-04-23, 2020-04-24 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200424_044115_718044_2F06A392 X-CRM114-Status: GOOD ( 11.88 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.207.212.93 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Gaignard , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Make sure that the returned load is above the system-wide minimum load QoS. Devices could set this specific QoS to inform governors about their need in terms of CPU load when computing it from idle time isn't accurate. Signed-off-by: Benjamin Gaignard --- drivers/cpufreq/cpufreq_governor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index f99ae45efaea..1494e5e4c788 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -118,6 +118,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy) unsigned int ignore_nice = dbs_data->ignore_nice_load; unsigned int max_load = 0, idle_periods = UINT_MAX; unsigned int sampling_rate, io_busy, j; + unsigned int qos_min_load; /* * Sometimes governors may use an additional multiplier to increase @@ -225,6 +226,10 @@ unsigned int dbs_update(struct cpufreq_policy *policy) policy_dbs->idle_periods = idle_periods; + qos_min_load = cpufreq_minload_qos_limit(); + if (qos_min_load > max_load) + max_load = qos_min_load; + return max_load; } EXPORT_SYMBOL_GPL(dbs_update); From patchwork Fri Apr 24 11:40:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin GAIGNARD X-Patchwork-Id: 11507699 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24CF992C for ; Fri, 24 Apr 2020 11:41:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE7FE20767 for ; Fri, 24 Apr 2020 11:41:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GnWav6eB"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=st.com header.i=@st.com header.b="J6iWt8Py" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE7FE20767 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=80ClJHOF6XfmP/b7b0SaHsVsVf2bt/q1kmEziiuVh5w=; b=GnWav6eBBz+GjY V48VtSRdBjtZk2Lv1X634OaMi6Rq+dRNDnVwCLbpZMe3Lgp3KbdU7zfyiiQwKHUa1VRSl7A3R+ZCp PWZz3FQfaRNKbc/cP6CVgQA1JD6WMf2fA9xAr7FpL/7vblizx9W1XO/xfw2/KAo4K4PQlJV6NStwn 4qDmPFAsxSn75xFFMlnyxA07nygjvA+RtOIQVyxUFtE6ASCLfC9ysQqLbGB0Hri7yyzSo0Ll3dCZ7 Bp8V6tayTY0RIZG5x1bxG4siNmqWP+qAIzb8+3TX97H+JVIlRjhBFGiELCIGOKZ577yTGX+0qoyxB F5xzGF4E+1oDLbsgMsJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRwiM-0000wI-EV; Fri, 24 Apr 2020 11:41:50 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRwhn-0000Oe-6g for linux-arm-kernel@lists.infradead.org; Fri, 24 Apr 2020 11:41:18 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03OBWi4b029084; Fri, 24 Apr 2020 13:41:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=f15cWn5l7+qnePYQkKeXeKN4S4ucsruNAsfQ5NRJgnw=; b=J6iWt8Pyv/o+0QkN41DpefKdKHfaEICctClHv4A7K0E1jeD3OY6t7KuiCpqPXdQpHKTi kB0LtSxI4ZUBJ5mp1FJVcglFZRtbGFMtdCh5Y0vt7Iwu9T3izsZk13yUvjktYwSts4pv XZeXC4swut3fqjqkxE5Q60GIehyGJL2+w2X8qMehw0qFohRGhre+MShqtH+PdttmypEi mT8PQdxMWTslx4Vto/iXhx7ipAWXrHhuzsssoyCT4uWQGrpsvsm6611No7o7FJMDsQtj YNztTP2MAe+5pm166gIncvD4tcKAohbXc269wwqTOGLHn0yb2x6Ut6ZSGKijqc7vGDE9 0g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30freh30hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Apr 2020 13:41:05 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 75E6210002A; Fri, 24 Apr 2020 13:41:05 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node3.st.com [10.75.127.9]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 67D662B3DA0; Fri, 24 Apr 2020 13:41:05 +0200 (CEST) Received: from localhost (10.75.127.50) by SFHDAG3NODE3.st.com (10.75.127.9) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 24 Apr 2020 13:41:04 +0200 From: Benjamin Gaignard To: , , , , , , , Subject: [RFC 3/3] media: stm32-dcmi: Inform cpufreq governors about cpu load needs Date: Fri, 24 Apr 2020 13:40:58 +0200 Message-ID: <20200424114058.21199-4-benjamin.gaignard@st.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20200424114058.21199-1-benjamin.gaignard@st.com> References: <20200424114058.21199-1-benjamin.gaignard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG3NODE3.st.com (10.75.127.9) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-24_04:2020-04-23, 2020-04-24 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200424_044115_719531_EE42126D X-CRM114-Status: GOOD ( 13.69 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.207.212.93 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Gaignard , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When start streaming the CPU load could remain very low because almost all the capture pipeline is done in hardware (i.e. without using the CPU) and let believe to cpufreq governor that it could use lower frequencies. If the governor decides to use a too low frequency that becomes a problem when we need to acknowledge the interrupt during the blanking time. To avoid this problem, DCMI driver informs the cpufreq governors by adding a cpufreq minimum load QoS resquest. Signed-off-by: Benjamin Gaignard --- drivers/media/platform/stm32/stm32-dcmi.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index b8931490b83b..774f2506b2f1 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -173,6 +174,8 @@ struct stm32_dcmi { struct media_device mdev; struct media_pad vid_cap_pad; struct media_pipeline pipeline; + + struct pm_qos_request qos_request; }; static inline struct stm32_dcmi *notifier_to_dcmi(struct v4l2_async_notifier *n) @@ -827,6 +830,9 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count) else reg_set(dcmi->regs, DCMI_IER, IT_OVR | IT_ERR); + cpufreq_minload_qos_add_request(&dcmi->qos_request, + CPUFREQ_GOV_QOS_MIN_LOAD_MAX_VALUE); + return 0; err_pipeline_stop: @@ -859,6 +865,8 @@ static void dcmi_stop_streaming(struct vb2_queue *vq) struct stm32_dcmi *dcmi = vb2_get_drv_priv(vq); struct dcmi_buf *buf, *node; + cpufreq_minload_qos_remove_request(&dcmi->qos_request); + dcmi_pipeline_stop(dcmi); media_pipeline_stop(&dcmi->vdev->entity);