Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1938659ybi; Thu, 4 Jul 2019 02:23:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg0B2gMLgZ73TieYkq8IuMb+iaqP2ih16US0Z3hK8m0Jxsq3Uz8snaZpYb1sA0zt7EYlvn X-Received: by 2002:a63:c24d:: with SMTP id l13mr33568898pgg.330.1562232220147; Thu, 04 Jul 2019 02:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562232220; cv=none; d=google.com; s=arc-20160816; b=wvI9ZvWHMXNZ/xMz1SEP6+3EJ7gS0SGjNflQcAqBcO6Gc/KnmOIAtHQ1aV3eFLRZbJ lMr1gX51pdK15z1HdmqeRhdL86axSCUJZS5VbLhs5L+H4IwLE8+yIAX8HJjBTLmyNMlv XHVmyvE252vNva6f1XFnqdLlMZBWF6YPDuqTbXKgs1RdJFfF21gMwB9BcjhAglFns9R5 TgaiuroHBnPyFUkPUH51GOpsPfXwLq65zH2tdWtlZ0rulAS3BSULeUBJot2oHzQH0ftO W8GL9ompC8aF8YnycQeNzo7D/biQfiKob2uTD71zUg9DSqKysgE0DLxK6kLxv78PsgFD YrEQ== 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=jUuaO+qhZOiu5yfEjPbq8YQ1S0tW2rSm3aQnM4G6dRU=; b=VQUqwOC7+BVaa9SHEspH8Erax9YVnzrMFzxWy32McSSvdcsWSejYUyploZeRCpNMwT U3EGyqjQ1n5aVkl3yzb0qUZ/69y42kkGiUyKAmmJxxRXygcED2SStYv7pRY20a2cAiZH JqHJ8jUJ546TZNtBie4mKaY4+Ho4Loijvg4SdGzNhyHfEXmeLchQpdyOu9Twsv05RETi Vs+VZBdycWIMfvwP1lDKRlnFn48YL36kzAivEroR/mXZkIiKA4zrnli++2uN/VrA6v4k NKqrpO0wdO8k7bN54OwAjoJTcXMKz/nTn9TC6US02zec7ioDL0AxaWgYQSwvjodBXJO7 +lwQ== 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 h6si917886plr.105.2019.07.04.02.23.25; Thu, 04 Jul 2019 02:23:40 -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 S1727458AbfGDJVE (ORCPT + 99 others); Thu, 4 Jul 2019 05:21:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61824 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727169AbfGDJVE (ORCPT ); Thu, 4 Jul 2019 05:21:04 -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 x649IHMx053434 for ; Thu, 4 Jul 2019 05:21:03 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2thea711mg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 04 Jul 2019 05:21:03 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Jul 2019 10:21:01 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 4 Jul 2019 10:20:58 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x649Kv9h43450590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 4 Jul 2019 09:20:57 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 229E64C04E; Thu, 4 Jul 2019 09:20:57 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 972714C040; Thu, 4 Jul 2019 09:20:55 +0000 (GMT) Received: from boston16h.aus.stglabs.ibm.com (unknown [9.3.23.78]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 4 Jul 2019 09:20:55 +0000 (GMT) From: Abhishek Goel To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-pm@vger.kernel.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 v3 2/3] cpuidle : Add callback whenever a state usage is enabled/disabled Date: Thu, 4 Jul 2019 04:18:26 -0500 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190704091827.19555-1-huntbag@linux.vnet.ibm.com> References: <20190704091827.19555-1-huntbag@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19070409-0028-0000-0000-000003805A4A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19070409-0029-0000-0000-000024409C4E Message-Id: <20190704091827.19555-3-huntbag@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-07-04_06:,, 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=822 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907040122 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 | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index eb20adb5d..141671a53 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -415,8 +415,21 @@ static ssize_t cpuidle_state_store(struct kobject *kobj, struct attribute *attr, struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj); struct cpuidle_state_attr *cattr = attr_to_stateattr(attr); - 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); + } + } return ret; } diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index bb9a0db89..8a0e54bd0 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -119,6 +119,10 @@ struct cpuidle_driver { /* the driver handles the cpus in cpumask */ struct cpumask *cpumask; + + void (*disable_callback)(struct cpuidle_device *dev, + struct cpuidle_driver *drv); + }; #ifdef CONFIG_CPU_IDLE -- 2.17.1