From patchwork Tue Mar 18 20:52:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Winkler, Tomas" X-Patchwork-Id: 3855881 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A03D39F369 for ; Wed, 19 Mar 2014 17:56:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C799D20220 for ; Wed, 19 Mar 2014 17:56:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F3CB20259 for ; Wed, 19 Mar 2014 17:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933358AbaCRU4Y (ORCPT ); Tue, 18 Mar 2014 16:56:24 -0400 Received: from mga09.intel.com ([134.134.136.24]:18752 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932681AbaCRUxm (ORCPT ); Tue, 18 Mar 2014 16:53:42 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 18 Mar 2014 13:49:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,680,1389772800"; d="scan'208";a="475172445" Received: from twinkler-dhg.jer.intel.com ([10.12.87.116]) by orsmga001.jf.intel.com with ESMTP; 18 Mar 2014 13:53:39 -0700 From: Tomas Winkler To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Tomas Winkler , Alexander Usyskin Subject: [char-misc-next 07/13] mei: add function to check write queues Date: Tue, 18 Mar 2014 22:52:01 +0200 Message-Id: <1395175927-10562-8-git-send-email-tomas.winkler@intel.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1395175927-10562-1-git-send-email-tomas.winkler@intel.com> References: <1395175927-10562-1-git-send-email-tomas.winkler@intel.com> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver needs to check whether the write queue idle before entering power gating Signed-off-by: Tomas Winkler Signed-off-by: Alexander Usyskin --- drivers/misc/mei/init.c | 21 +++++++++++++++++++++ drivers/misc/mei/mei_dev.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 4b1eb37..abc5ea0 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c @@ -303,7 +303,28 @@ void mei_stop(struct mei_device *dev) } EXPORT_SYMBOL_GPL(mei_stop); +/** + * mei_write_is_idle - check if the write queues are idle + * + * @dev: the device structure + * + * returns true of there is no pending write + */ +bool mei_write_is_idle(struct mei_device *dev) +{ + bool idle = (dev->dev_state == MEI_DEV_ENABLED && + list_empty(&dev->ctrl_wr_list.list) && + list_empty(&dev->write_list.list)); + dev_dbg(&dev->pdev->dev, "write pg: is idle[%d] state=%s ctrl=%d write=%d\n", + idle, + mei_dev_state_str(dev->dev_state), + list_empty(&dev->ctrl_wr_list.list), + list_empty(&dev->write_list.list)); + + return idle; +} +EXPORT_SYMBOL_GPL(mei_write_is_idle); void mei_device_init(struct mei_device *dev) { diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index bec6ade..fe76e5b 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -680,6 +680,8 @@ static inline int mei_count_full_read_slots(struct mei_device *dev) bool mei_hbuf_acquire(struct mei_device *dev); +bool mei_write_is_idle(struct mei_device *dev); + #if IS_ENABLED(CONFIG_DEBUG_FS) int mei_dbgfs_register(struct mei_device *dev, const char *name); void mei_dbgfs_deregister(struct mei_device *dev);