Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5481540ybl; Tue, 14 Jan 2020 09:37:33 -0800 (PST) X-Google-Smtp-Source: APXvYqx45ZJdq0+rkGxe17gMulbaEtN9bBv+w8GdEAuobYMOMNEZZ8LE8A/ez2/bDm/4804YGwB1 X-Received: by 2002:a9d:198b:: with SMTP id k11mr18484224otk.295.1579023452728; Tue, 14 Jan 2020 09:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579023452; cv=none; d=google.com; s=arc-20160816; b=aq3LxUZZGRCoBWjoLQwL6XoUNAnI2QLQZcjZGqaeDwwa95LehmOqj8fNv5NxAQ9qf7 VnSKUl7Td3VaMpq1cD2DPZ50Gw0xiTbc4TxJw0mTL53p4/cULJoaTq4pLX1po98Gqvav Z8YjVjIsrHkxM19sy9y69xhNNS4Jt4vED+G6u3kAYwPxQbniuij8zW+zaprp3e6gkiBq MOpFlVyoT1gHCpGFYpjA4WWQWp9O0u0fXqUo3aGZViVeeTsRWmVdxbRVaUDk/nE2fC8W 3TIssYv19iocnjCHCl0LudMhVMryuM5qMiAb5nhxnqtcGWMTh+NdA88hY6yCqEPtt6Ku TA2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AOjR7GPbUcR+F4SzZs6rw3neeZdf5pVADLE7G6aAJJA=; b=wsgoNyAr/ZtkICE1rKsN8mS0jwzcFDwoIo3sH25mxv6hFIkyFjGyJAqM7iCS8J2hC6 MGNUivcRueeYwEO7V0AA6om3WI6H11nOBUoGdXCEBLCTJ77NuJ0QM9673IZySSaDBfoV RkyKfYp6Pq+B+cEs37727jHLfKlc4bGYJaC0bpjzDLNZcFw96J2X8beoj5yh7SKsUuy8 C+OM4ts9v8Qvca9ZWIaoXVTccH0IaPdDJnCJynHk6NZ/WlDlwHawUsPaSQJvdGMvpmYB bOJZpmAfaCdpBhRxDeThtN4SNRdp86x93ciT3do8k8NiQGAJ9KDFdfge8skqqEety8o8 rZlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dYMr4g7y; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si7163169oic.12.2020.01.14.09.37.21; Tue, 14 Jan 2020 09:37:32 -0800 (PST) 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=@kernel.org header.s=default header.b=dYMr4g7y; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728741AbgANRga (ORCPT + 99 others); Tue, 14 Jan 2020 12:36:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:47268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgANRg3 (ORCPT ); Tue, 14 Jan 2020 12:36:29 -0500 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBBE02467C; Tue, 14 Jan 2020 17:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579023388; bh=a9R3hUWXn3kAB+DS0N+9xFdgrpDwftcTX/kWypdj37U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=dYMr4g7yJ5aOXktTFjc1j2XEGesBlPo9euxdwpbPfcFul0dglZnApPzzchTHX40zn MIsuubK1uTrkCyAj3aH9ygJGyv5fQQhLwrNFp3Xg1tPWohwQVGDL+edgGaTUk8kOs9 jQjVrzAsazVrPPQ/KkmurqpRN3vX0RaP4GX8PQaU= Received: by mail-lf1-f50.google.com with SMTP id r14so10486002lfm.5; Tue, 14 Jan 2020 09:36:27 -0800 (PST) X-Gm-Message-State: APjAAAW1HjhLUKOZUF2k/LXzW4zdcV1K+ORFtyaIjInJ7zJfOSMi3vTi yc3TJfTjCB7bt7ReLMO0pDiF9phTv9yTeVlSQQU= X-Received: by 2002:ac2:5582:: with SMTP id v2mr2461646lfg.183.1579023385769; Tue, 14 Jan 2020 09:36:25 -0800 (PST) MIME-Version: 1.0 References: <20200110094913.1.I146403d05b9ec82f48b807efd416a57f545b447a@changeid> <20200110094913.2.Ie8eacf976ce7a13e421592f5c1ab8dbdc537da5c@changeid> In-Reply-To: From: Chanwoo Choi Date: Wed, 15 Jan 2020 02:35:48 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] PM / devfreq: Use exclusively PM QoS to determine frequency limits To: Leonard Crestez Cc: Chanwoo Choi , Matthias Kaehlcke , Viresh Kumar , MyungJoo Ham , Kyungmin Park , Zhang Rui , Daniel Lezcano , Amit Kucheria , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 15, 2020 at 1:08 AM Leonard Crestez wrote: > > On 13.01.2020 09:24, Chanwoo Choi wrote: > > Hi, > > > > Any device driver except for devfreq_cooling.c might > > use dev_pm_opp_enable/disable interface. > > So, don't need to remove the devfreq->scaling_max_freq > > and devfreq->scaling_min_freq for supporting OPP interface. > > It seems that devfreq_cooling was the only upstream user of > dev_pm_opp_enable and the remaining callers of dev_pm_opp_disable are > probe-time checks. OPP interface has still dev_pm_opp_enable and dev_pm_opp_disable function. As long as remains them, any device driver related to devfreq could call them at some time. The devfreq supports the OPP interface, not just for only devfreq_cooling. > > > Regards, > > Chanwoo Choi > > > > On 1/11/20 2:49 AM, Matthias Kaehlcke wrote: > >> Traditionally devfreq cooling devices dynamically disabled OPPs > >> that shouldn't be used because of thermal pressure. Devfreq cooling > >> devices now use PM QoS to set frequency limits, hence the devfreq > >> code dealing that deals with disabled OPPs can be removed. > >> > >> Signed-off-by: Matthias Kaehlcke > >> --- > >> > >> drivers/devfreq/devfreq.c | 75 +++++---------------------------------- > >> include/linux/devfreq.h | 4 --- > >> 2 files changed, 8 insertions(+), 71 deletions(-) > >> > >> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > >> index 57f6944d65a6..ec66e2c27cc4 100644 > >> --- a/drivers/devfreq/devfreq.c > >> +++ b/drivers/devfreq/devfreq.c > >> @@ -73,34 +73,6 @@ static struct devfreq *find_device_devfreq(struct device *dev) > >> return ERR_PTR(-ENODEV); > >> } > >> > >> -static unsigned long find_available_min_freq(struct devfreq *devfreq) > >> -{ > >> - struct dev_pm_opp *opp; > >> - unsigned long min_freq = 0; > >> - > >> - opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq); > >> - if (IS_ERR(opp)) > >> - min_freq = 0; > >> - else > >> - dev_pm_opp_put(opp); > >> - > >> - return min_freq; > >> -} > >> - > >> -static unsigned long find_available_max_freq(struct devfreq *devfreq) > >> -{ > >> - struct dev_pm_opp *opp; > >> - unsigned long max_freq = ULONG_MAX; > >> - > >> - opp = dev_pm_opp_find_freq_floor(devfreq->dev.parent, &max_freq); > >> - if (IS_ERR(opp)) > >> - max_freq = 0; > >> - else > >> - dev_pm_opp_put(opp); > >> - > >> - return max_freq; > >> -} > >> - > >> /** > >> * get_freq_range() - Get the current freq range > >> * @devfreq: the devfreq instance > >> @@ -141,10 +113,6 @@ static void get_freq_range(struct devfreq *devfreq, > >> *max_freq = min(*max_freq, > >> (unsigned long)HZ_PER_KHZ * qos_max_freq); > >> > >> - /* Apply constraints from OPP interface */ > >> - *min_freq = max(*min_freq, devfreq->scaling_min_freq); > >> - *max_freq = min(*max_freq, devfreq->scaling_max_freq); > >> - > >> if (*min_freq > *max_freq) > >> *min_freq = *max_freq; > >> } > >> @@ -610,23 +578,10 @@ static int devfreq_notifier_call(struct notifier_block *nb, unsigned long type, > >> void *devp) > >> { > >> struct devfreq *devfreq = container_of(nb, struct devfreq, nb); > >> - int err = -EINVAL; > >> + int err; > >> > >> mutex_lock(&devfreq->lock); > >> - > >> - devfreq->scaling_min_freq = find_available_min_freq(devfreq); > >> - if (!devfreq->scaling_min_freq) > >> - goto out; > >> - > >> - devfreq->scaling_max_freq = find_available_max_freq(devfreq); > >> - if (!devfreq->scaling_max_freq) { > >> - devfreq->scaling_max_freq = ULONG_MAX; > >> - goto out; > >> - } > >> - > >> err = update_devfreq(devfreq); > >> - > >> -out: > >> mutex_unlock(&devfreq->lock); > >> if (err) > >> dev_err(devfreq->dev.parent, > >> @@ -781,19 +736,15 @@ struct devfreq *devfreq_add_device(struct device *dev, > >> mutex_lock(&devfreq->lock); > >> } > >> > >> - devfreq->scaling_min_freq = find_available_min_freq(devfreq); > >> - if (!devfreq->scaling_min_freq) { > >> - mutex_unlock(&devfreq->lock); > >> - err = -EINVAL; > >> + err = dev_pm_qos_add_request(dev, &devfreq->user_min_freq_req, > >> + DEV_PM_QOS_MIN_FREQUENCY, 0); > >> + if (err < 0) > >> goto err_dev; > >> - } > >> - > >> - devfreq->scaling_max_freq = find_available_max_freq(devfreq); > >> - if (!devfreq->scaling_max_freq) { > >> - mutex_unlock(&devfreq->lock); > >> - err = -EINVAL; > >> + err = dev_pm_qos_add_request(dev, &devfreq->user_max_freq_req, > >> + DEV_PM_QOS_MAX_FREQUENCY, > >> + PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE); > >> + if (err < 0) > >> goto err_dev; > >> - } > >> > >> devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev); > >> atomic_set(&devfreq->suspend_count, 0); > >> @@ -834,16 +785,6 @@ struct devfreq *devfreq_add_device(struct device *dev, > >> > >> mutex_unlock(&devfreq->lock); > >> > >> - err = dev_pm_qos_add_request(dev, &devfreq->user_min_freq_req, > >> - DEV_PM_QOS_MIN_FREQUENCY, 0); > >> - if (err < 0) > >> - goto err_devfreq; > >> - err = dev_pm_qos_add_request(dev, &devfreq->user_max_freq_req, > >> - DEV_PM_QOS_MAX_FREQUENCY, > >> - PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE); > >> - if (err < 0) > >> - goto err_devfreq; > >> - > > Performing PM QoS initialization under devfreq->lock triggers lockdep > warnings for me. The warnings seem to be legitimate: > > 1) At init time &dev_pm_qos_mtx is taken under &devfreq->lock; > 2) At update time &devfreq->lock is called under &dev_pm_qos_mtx (it's > held while notifiers are called). > > It's not clear why you moved dev_pm_qos_add_request higher? > > >> devfreq->nb_min.notifier_call = qos_min_notifier_call; > >> err = dev_pm_qos_add_notifier(devfreq->dev.parent, &devfreq->nb_min, > >> DEV_PM_QOS_MIN_FREQUENCY); > >> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h > >> index fb376b5b7281..cb75f23ad2f4 100644 > >> --- a/include/linux/devfreq.h > >> +++ b/include/linux/devfreq.h > >> @@ -126,8 +126,6 @@ struct devfreq_dev_profile { > >> * touch this. > >> * @user_min_freq_req: PM QoS minimum frequency request from user (via sysfs) > >> * @user_max_freq_req: PM QoS maximum frequency request from user (via sysfs) > >> - * @scaling_min_freq: Limit minimum frequency requested by OPP interface > >> - * @scaling_max_freq: Limit maximum frequency requested by OPP interface > >> * @stop_polling: devfreq polling status of a device. > >> * @suspend_freq: frequency of a device set during suspend phase. > >> * @resume_freq: frequency of a device set in resume phase. > >> @@ -166,8 +164,6 @@ struct devfreq { > >> > >> struct dev_pm_qos_request user_min_freq_req; > >> struct dev_pm_qos_request user_max_freq_req; > >> - unsigned long scaling_min_freq; > >> - unsigned long scaling_max_freq; > >> bool stop_polling; > >> > >> unsigned long suspend_freq; > >> > > > -- Best Regards, Chanwoo Choi