All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lv Zheng <lv.zheng@intel.com>
To: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Len Brown <len.brown@intel.com>
Cc: Lv Zheng <lv.zheng@intel.com>, Lv Zheng <zetalog@gmail.com>,
	linux-acpi@vger.kernel.org
Subject: [PATCH 4/6] ACPI/EC: Fix a code path that global lock is not held
Date: Wed, 14 Jan 2015 19:28:41 +0800	[thread overview]
Message-ID: <c66cf9c07985d4fd34738dae927abd3d0383896a.1421234254.git.lv.zheng@intel.com> (raw)
In-Reply-To: <cover.1421234254.git.lv.zheng@intel.com>

Currently QR_EC is queued up on CPU 0 to be safe with SMM because there is
no global lock held for acpi_ec_gpe_query(). As we are about to move QR_EC
to a non CPU 0 bound work queue to avoid invoking kmalloc() in
advance_transaction(), we have to acquire global lock for the new QR_EC
work item to avoid regressions.

Known issue:
1. Global lock for acpi_ec_clear().
   This is an existing issue that acpi_ec_clear() which invokes
   acpi_ec_sync_query() also suffers from the same issue. But this patch's
   target is only the code to invoke acpi_ec_sync_query() in a CPU 0 bound
   work queue item, and the acpi_ec_clear() can be automatically fixed by
   further patch that merges the redundant code, so it is left unchanged.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
---
 drivers/acpi/ec.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index a94ee9f..3c97122 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -690,11 +690,21 @@ static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data)
 static void acpi_ec_gpe_query(void *ec_cxt)
 {
 	struct acpi_ec *ec = ec_cxt;
+	acpi_status status;
+	u32 glk;
 
 	if (!ec)
 		return;
 	mutex_lock(&ec->mutex);
+	if (ec->global_lock) {
+		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
+		if (ACPI_FAILURE(status))
+			goto unlock;
+	}
 	acpi_ec_sync_query(ec, NULL);
+	if (ec->global_lock)
+		acpi_release_global_lock(glk);
+unlock:
 	mutex_unlock(&ec->mutex);
 }
 
-- 
1.7.10


  parent reply	other threads:[~2015-01-14  3:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-19  5:59 [RFC PATCH 0/6] ACPI/EC: Enhance EC driver state machine Lv Zheng
2014-12-19  5:59 ` [RFC PATCH 1/6] ACPI/EC: Cleanup transaction wakeup code Lv Zheng
2014-12-19  5:59 ` [RFC PATCH 2/6] ACPI/EC: Add reference counting for query handlers Lv Zheng
2014-12-19  5:59 ` [RFC PATCH 3/6] ACPI/EC: Fix returning values in acpi_ec_sync_query() Lv Zheng
2014-12-19  5:59 ` [RFC PATCH 4/6] ACPI/EC: Fix a code path that global lock is not held Lv Zheng
2014-12-19  6:00 ` [RFC PATCH 5/6] ACPI/EC: Fix issues related to the SCI_EVT handling Lv Zheng
2014-12-19  6:00 ` [RFC PATCH 6/6] ACPI/EC: Cleanup QR_EC related code Lv Zheng
2014-12-19 22:28 ` [RFC PATCH 0/6] ACPI/EC: Enhance EC driver state machine Rafael J. Wysocki
2015-01-14 11:28 ` [PATCH " Lv Zheng
2015-01-14 11:28   ` [PATCH 1/6] ACPI/EC: Cleanup transaction wakeup code Lv Zheng
2015-01-21 22:17     ` Rafael J. Wysocki
2015-01-22  6:37       ` Zheng, Lv
2015-01-22 16:00         ` Rafael J. Wysocki
2015-01-23  2:18           ` Zheng, Lv
2015-01-23 15:22             ` Rafael J. Wysocki
2015-01-14 11:28   ` [PATCH 2/6] ACPI/EC: Add reference counting for query handlers Lv Zheng
2015-01-14 11:28   ` [PATCH 3/6] ACPI/EC: Fix returning values in acpi_ec_sync_query() Lv Zheng
2015-01-14 11:28   ` Lv Zheng [this message]
2015-01-14 11:28   ` [PATCH 5/6] ACPI/EC: Fix issues related to the SCI_EVT handling Lv Zheng
2015-01-14 11:28   ` [PATCH 6/6] ACPI/EC: Cleanup QR_EC related code Lv Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c66cf9c07985d4fd34738dae927abd3d0383896a.1421234254.git.lv.zheng@intel.com \
    --to=lv.zheng@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=zetalog@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.