Received: by 10.223.164.202 with SMTP id h10csp115590wrb; Wed, 22 Nov 2017 04:44:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMZYtP4S3ElaCpDH3GXJWxlorNkdRYhL+3QJFmO7eoUKd8i/qOLYEPevfGxJUWSUfl8sYoJJ X-Received: by 10.99.95.133 with SMTP id t127mr20361297pgb.368.1511354675721; Wed, 22 Nov 2017 04:44:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511354675; cv=none; d=google.com; s=arc-20160816; b=gBNc8DMBFHw8mKyhV05ypQONXkOMRBgWkx0M+y24KUo3kIg3s9YvfO5ue7yXrPAvv7 D4Y51qgqk4jmDoekHQNPGsF0alr7XSDQ0m03PoE+09WBODLmxqltzv+FJpqJRaccDCfe w+BUCS3zz95IH+bga1U8Hmo1wiejuu8OomGF8Mo6gXB3z6IkAQgFDwLsDn2e5Lk1uFAs zpzpOmkb1xaq8nWkrXCFwMEnM1iJ4ikKf6Ee5wKCavnG1LJvEcTtQ0fL2i+d444jhOUI nGQFrSbeOgi3wS50IfPPWN6OdX98mJ0ysnbk1RliB3gjnEHdeK1PRkLxL5CdmgunAmLw JmeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=WxJbbJ706FnKP1c7PYpv4io85v0onYOke2DmeNxk5f0=; b=lEjA1wdEVIib/OMoInJMuFziUX5yvtnyJkeeZUgPSJk3xrdN9xdcifs6arZT7q73/T GWgj0aO9z0wx2MVOccNSktP6NySkMv/GpfUj0dIMsJO++Ml6eRUbZ88svDgZ7xUG6XNS 2GGk0Rj97GfVLArZKNUZAYFNdA5MduKOTVdhGkpLtQN7F6dZAKPYqkGJB4Jc6grtZ71f bOIuT/W8qz9uEO49lj8v8rmKXJiw2k0zT7furzb7odlrAFY3F3ThdMFHNTL94Eoe4JUf WZk9KM6v7jZFGpkuDcTgSCRvK5zLklG0Irqol6RvqnfMP5+R/AN435zt+8HfcdL4kkd6 a8rA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z78si14804013pfk.259.2017.11.22.04.44.24; Wed, 22 Nov 2017 04:44:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751471AbdKVMnp convert rfc822-to-8bit (ORCPT + 77 others); Wed, 22 Nov 2017 07:43:45 -0500 Received: from mga06.intel.com ([134.134.136.31]:34243 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbdKVMnn (ORCPT ); Wed, 22 Nov 2017 07:43:43 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2017 04:43:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,436,1505804400"; d="scan'208";a="10686480" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga002.jf.intel.com with ESMTP; 22 Nov 2017 04:43:42 -0800 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 22 Nov 2017 04:43:42 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 22 Nov 2017 04:43:42 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.159]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Wed, 22 Nov 2017 20:43:40 +0800 From: "Zhang, Rui" To: "Zheng, Lv" , "Wysocki, Rafael J" , "Rafael J . Wysocki" , "Brown, Len" CC: "Zheng, Lv" , Lv Zheng , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" Subject: RE: [RFC PATCH v6 2/3] ACPI / EC: Add event detection support for noirq stages Thread-Topic: [RFC PATCH v6 2/3] ACPI / EC: Add event detection support for noirq stages Thread-Index: AQHTOM3m9avcxdswtEWVHkoMeobx96MgrBpA Date: Wed, 22 Nov 2017 12:43:38 +0000 Message-ID: <744357E9AAD1214791ACBA4B0B9092636BE55564@SHSMSX101.ccr.corp.intel.com> References: <99f23db65bbe89ee856018629654584a96734c84.1501141963.git.lv.zheng@intel.com> <78859881be29535e4a6bd60531902ff36f796ce9.1506653046.git.lv.zheng@intel.com> In-Reply-To: <78859881be29535e4a6bd60531902ff36f796ce9.1506653046.git.lv.zheng@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2JlZjE1NTMtMjc5Yi00MTRmLTk4NjktODdlODQ3MjA3YTI5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ6cTc3cWx4NDlYRFhcL1VxWEpGSTE3d01reFZncVwvWExLWXBhN3NBXC95UmY0bmJDd0NOWFRnb05EZGtWaUk2d3dMIn0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: linux-acpi-owner@vger.kernel.org [mailto:linux-acpi- > owner@vger.kernel.org] On Behalf Of Lv Zheng > Sent: Friday, September 29, 2017 10:50 AM > To: Wysocki, Rafael J ; Rafael J . Wysocki > ; Brown, Len > Cc: Zheng, Lv ; Lv Zheng ; linux- > kernel@vger.kernel.org; linux-acpi@vger.kernel.org > Subject: [RFC PATCH v6 2/3] ACPI / EC: Add event detection support for noirq > stages > > This patch adds a timer to poll EC events: > 1. between acpi_ec_suspend() and acpi_ec_block_transactions(), 2. between > acpi_ec_unblock_transactions() and acpi_ec_resume(). > During these periods, if an EC event occurred, we have not mean to detect it. > Thus the events occurred in late S3-entry could be dropped, and the events > occurred in early S3-exit could be deferred to acpi_ec_resume(). > > This patch solves event losses in S3-entry and resume order in S3-exit by > timely polling EC events during these periods. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=196129 [#1] > Signed-off-by: Lv Zheng > Tested-by: Tomislav Ivek No, the patches to fix the Fan spin issue (https://bugzilla.kernel.org/show_bug.cgi?id=196129) have already been applied by Rafael. This patch, together with patch 3/3 don't fix anything. I'm not saying the patch is wrong, but they should be verified to fix a real issue before submitting for upstream. Thanks, rui > --- > drivers/acpi/ec.c | 93 > +++++++++++++++++++++++++++++++++++++++++++++++-- > drivers/acpi/internal.h | 1 + > 2 files changed, 92 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index f1f320b..389c499 > 100644 > --- a/drivers/acpi/ec.c > +++ b/drivers/acpi/ec.c > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > #include > > #include "internal.h" > @@ -102,6 +103,7 @@ enum ec_command { > #define ACPI_EC_CLEAR_MAX 100 /* Maximum number of events to > query > * when trying to clear the EC */ > #define ACPI_EC_MAX_QUERIES 16 /* Maximum number of > parallel queries */ > +#define ACPI_EC_EVENT_INTERVAL 500 /* Detecting event every > 500ms */ > > enum { > EC_FLAGS_QUERY_ENABLED, /* Query is enabled */ > @@ -113,6 +115,7 @@ enum { > EC_FLAGS_STARTED, /* Driver is started */ > EC_FLAGS_STOPPED, /* Driver is stopped */ > EC_FLAGS_GPE_MASKED, /* GPE masked */ > + EC_FLAGS_GPE_POLLING, /* GPE polling is enabled */ > }; > > #define ACPI_EC_COMMAND_POLL 0x01 /* Available for > command byte */ > @@ -154,6 +157,15 @@ static bool ec_no_wakeup __read_mostly; > module_param(ec_no_wakeup, bool, 0644); > MODULE_PARM_DESC(ec_no_wakeup, "Do not wake up from suspend-to- > idle"); > > +static bool ec_detect_noirq_events __read_mostly; > +module_param(ec_detect_noirq_events, bool, 0644); > +MODULE_PARM_DESC(ec_detect_noirq_events, "Enabling event detection > +during noirq stage"); > + > +static unsigned int > +ec_detect_noirq_interval __read_mostly = ACPI_EC_EVENT_INTERVAL; > +module_param(ec_detect_noirq_interval, uint, 0644); > +MODULE_PARM_DESC(ec_detect_noirq_interval, "Event detection > +interval(ms) during noirq stage"); > + > struct acpi_ec_query_handler { > struct list_head node; > acpi_ec_query_func func; > @@ -358,6 +370,48 @@ static inline bool acpi_ec_is_gpe_raised(struct > acpi_ec *ec) > return (gpe_status & ACPI_EVENT_FLAG_STATUS_SET) ? true : false; } > > +static void acpi_ec_gpe_tick(struct acpi_ec *ec) { > + mod_timer(&ec->timer, > + jiffies + msecs_to_jiffies(ec_detect_noirq_interval)); > +} > + > +static void ec_start_gpe_poller(struct acpi_ec *ec) { > + unsigned long flags; > + bool start_tick = false; > + > + if (!acpi_ec_no_sleep_events() || !ec_detect_noirq_events) > + return; > + spin_lock_irqsave(&ec->lock, flags); > + if (!test_and_set_bit(EC_FLAGS_GPE_POLLING, &ec->flags)) { > + ec_log_drv("GPE poller started"); > + start_tick = true; > + /* kick off GPE polling without delay */ > + advance_transaction(ec); > + } > + spin_unlock_irqrestore(&ec->lock, flags); > + if (start_tick) > + acpi_ec_gpe_tick(ec); > +} > + > +static void ec_stop_gpe_poller(struct acpi_ec *ec) { > + unsigned long flags; > + bool stop_tick = false; > + > + if (!acpi_ec_no_sleep_events() || !ec_detect_noirq_events) > + return; > + spin_lock_irqsave(&ec->lock, flags); > + if (test_and_clear_bit(EC_FLAGS_GPE_POLLING, &ec->flags)) > + stop_tick = true; > + spin_unlock_irqrestore(&ec->lock, flags); > + if (stop_tick) { > + del_timer_sync(&ec->timer); > + ec_log_drv("GPE poller stopped"); > + } > +} > + > static inline void acpi_ec_enable_gpe(struct acpi_ec *ec, bool open) { > if (open) > @@ -1017,6 +1071,12 @@ static void acpi_ec_leave_noirq(struct acpi_ec > *ec) > spin_unlock_irqrestore(&ec->lock, flags); } > > +/* > + * Note: this API is prepared for tuning the order of the ACPI > + * suspend/resume steps as the last entry of EC during suspend, thus it > + * must be invoked after acpi_ec_suspend() or everything should be done > +in > + * acpi_ec_suspend(). > + */ > void acpi_ec_block_transactions(void) > { > struct acpi_ec *ec = first_ec; > @@ -1028,16 +1088,28 @@ void acpi_ec_block_transactions(void) > /* Prevent transactions from being carried out */ > acpi_ec_stop(ec, true); > mutex_unlock(&ec->mutex); > + ec_stop_gpe_poller(ec); > } > > +/* > + * Note: this API is prepared for tuning the order of the ACPI > + * suspend/resume steps as the first entry of EC during resume, thus it > + * must be invoked before acpi_ec_resume() or everything should be done > +in > + * acpi_ec_resume(). > + */ > void acpi_ec_unblock_transactions(void) > { > + struct acpi_ec *ec = first_ec; > + > + if (!ec) > + return; > + > + ec_start_gpe_poller(ec); > /* > * Allow transactions to happen again (this function is called from > * atomic context during wakeup, so we don't need to acquire the > mutex). > */ > - if (first_ec) > - acpi_ec_start(first_ec, true); > + acpi_ec_start(ec, true); > } > > /* -------------------------------------------------------------------------- > @@ -1278,6 +1350,19 @@ static u32 acpi_ec_gpe_handler(acpi_handle > gpe_device, > return ACPI_INTERRUPT_HANDLED; > } > > +static void acpi_ec_gpe_poller(ulong arg) { > + struct acpi_ec *ec = (struct acpi_ec *)arg; > + unsigned long flags; > + > + spin_lock_irqsave(&ec->lock, flags); > + ec_dbg_drv("GPE polling begin"); > + advance_transaction(ec); > + ec_dbg_drv("GPE polling end"); > + spin_unlock_irqrestore(&ec->lock, flags); > + acpi_ec_gpe_tick(ec); > +} > + > /* -------------------------------------------------------------------------- > * Address Space Management > * -------------------------------------------------------------------------- */ @@ -1347,6 > +1432,8 @@ static struct acpi_ec *acpi_ec_alloc(void) > INIT_LIST_HEAD(&ec->list); > spin_lock_init(&ec->lock); > INIT_WORK(&ec->work, acpi_ec_event_handler); > + init_timer(&ec->timer); > + setup_timer(&ec->timer, acpi_ec_gpe_poller, (ulong)ec); > ec->timestamp = jiffies; > ec->busy_polling = true; > ec->polling_guard = 0; > @@ -1918,6 +2005,7 @@ static int acpi_ec_suspend(struct device *dev) > > if (acpi_ec_no_sleep_events()) > acpi_ec_disable_event(ec); > + ec_start_gpe_poller(ec); > return 0; > } > > @@ -1952,6 +2040,7 @@ static int acpi_ec_resume(struct device *dev) > struct acpi_ec *ec = > acpi_driver_data(to_acpi_device(dev)); > > + ec_stop_gpe_poller(ec); > if (acpi_ec_no_sleep_events()) > acpi_ec_enable_event(ec); > else { > diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index > ede83d3..708b379 100644 > --- a/drivers/acpi/internal.h > +++ b/drivers/acpi/internal.h > @@ -171,6 +171,7 @@ struct acpi_ec { > struct transaction *curr; > spinlock_t lock; > struct work_struct work; > + struct timer_list timer; > unsigned long timestamp; > unsigned long nr_pending_queries; > bool busy_polling; > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the > body of a message to majordomo@vger.kernel.org More majordomo info at > http://vger.kernel.org/majordomo-info.html From 1579840680021154464@xxx Fri Sep 29 02:51:20 +0000 2017 X-GM-THRID: 1577233718035078680 X-Gmail-Labels: Inbox,Category Forums