mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Dominik Brodowski <linux@dominikbrodowski.net>,
	Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] PCMCIA / PM: Avoid noirq suspend aborts during suspend-to-idle
Date: Wed, 21 Feb 2018 13:24:16 +0100	[thread overview]
Message-ID: <3352336.6IBe4RuE7s@aspire.rjw.lan> (raw)
In-Reply-To: <20180220213839.GA12082@light.dominikbrodowski.net>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

There is a problem with PCMCIA system resume callbacks with respect
to suspend-to-idle in which the ->suspend_noirq() callback may be
invoked after the ->resume_noirq() one without resuming the system
entirely in some cases.  This doesn't work for PCMCIA because of
the lack of symmetry between its system suspend and system resume
"noirq" callbacks.

The system resume handling in PCMCIA is split between
socket_early_resume() and socket_late_resume() which are called in
different phases of system resume and both need to run for
socket_suspend() (invoked by the system suspend "noirq" callback)
to work.  Specifically, socket_suspend() returns an error when
called after socket_early_resume() without socket_late_resume(),
so if the suspend-to-idle core detects a spurious wakeup event and
attempts to put the system back to sleep, that is aborted by the
error coming from socket_suspend().

Avoid that by using a new socket state flag, SOCKET_IN_RESUME,
to indicate that socket_early_resume() has already run for the
socket in which case socket_suspend() will do minimum handling
and return 0.

This change has been tested on my venerable Toshiba Portege R500
(which is where the problem has been discovered in the first place),
but admittedly I have no PCMCIA cards to test along with the socket
itself.

Fixes: 33e4f80ee69b (ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This replaces https://patchwork.kernel.org/patch/10229821/

---
 drivers/pcmcia/cs.c          |   11 ++++++++++-
 drivers/pcmcia/cs_internal.h |    1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

Index: linux-pm/drivers/pcmcia/cs.c
===================================================================
--- linux-pm.orig/drivers/pcmcia/cs.c
+++ linux-pm/drivers/pcmcia/cs.c
@@ -452,6 +452,14 @@ static int socket_insert(struct pcmcia_s
 
 static int socket_suspend(struct pcmcia_socket *skt)
 {
+	if (skt->state & SOCKET_IN_RESUME) {
+		mutex_lock(&skt->ops_mutex);
+		skt->socket = dead_socket;
+		skt->ops->set_socket(skt, &skt->socket);
+		mutex_unlock(&skt->ops_mutex);
+		return 0;
+	}
+
 	if (skt->state & SOCKET_SUSPEND)
 		return -EBUSY;
 
@@ -475,6 +483,7 @@ static int socket_early_resume(struct pc
 	skt->ops->set_socket(skt, &skt->socket);
 	if (skt->state & SOCKET_PRESENT)
 		skt->resume_status = socket_setup(skt, resume_delay);
+	skt->state |= SOCKET_IN_RESUME;
 	mutex_unlock(&skt->ops_mutex);
 	return 0;
 }
@@ -484,7 +493,7 @@ static int socket_late_resume(struct pcm
 	int ret = 0;
 
 	mutex_lock(&skt->ops_mutex);
-	skt->state &= ~SOCKET_SUSPEND;
+	skt->state &= ~(SOCKET_SUSPEND | SOCKET_IN_RESUME);
 	mutex_unlock(&skt->ops_mutex);
 
 	if (!(skt->state & SOCKET_PRESENT)) {
Index: linux-pm/drivers/pcmcia/cs_internal.h
===================================================================
--- linux-pm.orig/drivers/pcmcia/cs_internal.h
+++ linux-pm/drivers/pcmcia/cs_internal.h
@@ -70,6 +70,7 @@ struct pccard_resource_ops {
 /* Flags in socket state */
 #define SOCKET_PRESENT		0x0008
 #define SOCKET_INUSE		0x0010
+#define SOCKET_IN_RESUME	0x0040
 #define SOCKET_SUSPEND		0x0080
 #define SOCKET_WIN_REQ(i)	(0x0100<<(i))
 #define SOCKET_CARDBUS		0x8000

  parent reply	other threads:[~2018-02-21 12:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20 11:47 [PATCH] PCMCIA / PM: Combine system resume callbacks Rafael J. Wysocki
2018-02-20 21:38 ` Dominik Brodowski
2018-02-21  9:09   ` Rafael J. Wysocki
2018-02-21 12:24   ` Rafael J. Wysocki [this message]
2018-02-22 16:45     ` [PATCH] PCMCIA / PM: Avoid noirq suspend aborts during suspend-to-idle Dominik Brodowski
2018-02-22 17:32       ` Rafael J. Wysocki
2018-02-22 21:49         ` Rafael J. Wysocki

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=3352336.6IBe4RuE7s@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@dominikbrodowski.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®