Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1776351ybn; Wed, 2 Oct 2019 23:32:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqylFaGtyCinPol6xWxtEgI5Lt9NrQtsEzN+cybJ4+m1mq2zFSIBlQcIwQRbgVTYR+BD4VL3 X-Received: by 2002:a50:b6c8:: with SMTP id f8mr7893598ede.33.1570084334614; Wed, 02 Oct 2019 23:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570084334; cv=none; d=google.com; s=arc-20160816; b=b9FqPSCHbMicAk3MzhGfOkoPsYdSKoD7a/6faU+dcYV9+LNcbX5UwPxU9ithEp2oqT z4DMTwNXdgS4rFqfnTJ4eFhfaYR4Uc5erGurO2nSi7iSTJrJaeCRCVs4D7+ZcEztE2iw SivXfuN4SCn3L62wBC2h2ZR1EEI4kmJMk1Kz0wvae9PzcKtMuBnC2WpfwTnH4Bmjc60T llxUQvl8oZnP2sGHAcp+GBcVc0c5oZtQim7/63TlrTBVFqy96DZXSOza+kh1/YQm3+Wk zak5fEUFI1sdn1nEUvLgc+2iw8bzPpNevVbbD9SOjzBHtd0oq7sf6eeOY9Mhnyd4M+q8 w+kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=Qecb0Ee51V/MLRLzA+KKTjhXNKEf5h1fTBtPahl6QMc=; b=oYMCJo+xiApicfqtnzahUEOZ8QVjzabgm35kszwjxfI4vjO0d+z5xyevQfB9+t3OiE Ll2L7Ogya9qfd3JlSjvArzs345z/UgrB6mrlsJnAImtR0f/4S54qgB5eNEnOC9UG9dHp xy+e7IGTtH3efLPuYw4iw4q9oAXA8Gx0whW4pofmFU5j+l8/yCEY3Qs3cqFG5QW4A32J ZWQVJ6R2daI/+MJUAqmE9N7TMGjKycYEN+qZnP8Aev46BXEmDwmSQJGVRSqbHJmOPkWN sZkVS4k0xwu7Ac1bDiy9iiOe43QD+HrSQ7EvUXhm3Y1IOQtFMVWa0olZzWMwOVvGxpL0 qD4w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si801906eda.277.2019.10.02.23.31.50; Wed, 02 Oct 2019 23:32:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbfJCGaB (ORCPT + 99 others); Thu, 3 Oct 2019 02:30:01 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:13048 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727326AbfJCGaB (ORCPT ); Thu, 3 Oct 2019 02:30:01 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x936LpOp115386 for ; Thu, 3 Oct 2019 02:29:58 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vdasy1dmc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 03 Oct 2019 02:29:58 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 3 Oct 2019 07:29:56 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 3 Oct 2019 07:29:53 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x936Tqcp52625544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Oct 2019 06:29:52 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 73FA5A4054; Thu, 3 Oct 2019 06:29:52 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E66FDA4064; Thu, 3 Oct 2019 06:29:50 +0000 (GMT) Received: from boston16h.aus.stglabs.ibm.com (unknown [9.3.23.78]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 3 Oct 2019 06:29:50 +0000 (GMT) From: Abhishek Goel To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: npiggin@gmail.com, rjw@rjwysocki.net, daniel.lezcano@linaro.org, mpe@ellerman.id.au, ego@linux.vnet.ibm.com, dja@axtens.net, Abhishek Goel Subject: [RFC v5 2/3] cpuidle : Add callback whenever a state usage is enabled/disabled Date: Thu, 3 Oct 2019 01:26:45 -0500 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003062646.54258-1-huntbag@linux.vnet.ibm.com> References: <20191003062646.54258-1-huntbag@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19100306-0012-0000-0000-00000353919D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19100306-0013-0000-0000-0000218E9756 Message-Id: <20191003062646.54258-3-huntbag@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-10-03_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=949 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910030061 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To force wakeup a cpu, we need to compute the timeout in the fast idle path as a state may be enabled or disabled but there did not exist a feedback to driver when a state is enabled or disabled. This patch adds a callback whenever a state_usage records a store for disable attribute Signed-off-by: Abhishek Goel --- drivers/cpuidle/sysfs.c | 15 ++++++++++++++- include/linux/cpuidle.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 2bb2683b4..6c9bf2f7b 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -418,8 +418,21 @@ static ssize_t cpuidle_state_store(struct kobject *kobj, struct attribute *attr, struct cpuidle_state_attr *cattr = attr_to_stateattr(attr); struct cpuidle_device *dev = kobj_to_device(kobj); - if (cattr->store) + if (cattr->store) { ret = cattr->store(state, state_usage, buf, size); + if (ret == size && + strncmp(cattr->attr.name, "disable", + strlen("disable"))) { + struct kobject *cpuidle_kobj = kobj->parent; + struct cpuidle_device *dev = + to_cpuidle_device(cpuidle_kobj); + struct cpuidle_driver *drv = + cpuidle_get_cpu_driver(dev); + + if (drv->disable_callback) + drv->disable_callback(dev, drv); + } + } /* reset poll time cache */ dev->poll_limit_ns = 0; diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 4b6b5bea8..1729a497b 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -122,6 +122,9 @@ struct cpuidle_driver { /* the driver handles the cpus in cpumask */ struct cpumask *cpumask; + void (*disable_callback)(struct cpuidle_device *dev, + struct cpuidle_driver *drv); + /* preferred governor to switch at register time */ const char *governor; }; -- 2.17.1