Skip to content

Commit dbdd0f5

Browse files
committed
PCMCIA / PM: Avoid noirq suspend aborts during suspend-to-idle
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: 33e4f80 (ACPI / PM: Ignore spurious SCI wakeups from suspend-to-idle) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> [linux@dominikbrodowski.net: follow same codepaths for both suspend variants; call ->suspend()] Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent 91ab883 commit dbdd0f5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎drivers/pcmcia/cs.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,17 +452,20 @@ static int socket_insert(struct pcmcia_socket *skt)
452452

453453
static int socket_suspend(struct pcmcia_socket *skt)
454454
{
455-
if (skt->state & SOCKET_SUSPEND)
455+
if ((skt->state & SOCKET_SUSPEND) && !(skt->state & SOCKET_IN_RESUME))
456456
return -EBUSY;
457457

458458
mutex_lock(&skt->ops_mutex);
459-
skt->suspended_state = skt->state;
459+
/* store state on first suspend, but not after spurious wakeups */
460+
if (!(skt->state & SOCKET_IN_RESUME))
461+
skt->suspended_state = skt->state;
460462

461463
skt->socket = dead_socket;
462464
skt->ops->set_socket(skt, &skt->socket);
463465
if (skt->ops->suspend)
464466
skt->ops->suspend(skt);
465467
skt->state |= SOCKET_SUSPEND;
468+
skt->state &= ~SOCKET_IN_RESUME;
466469
mutex_unlock(&skt->ops_mutex);
467470
return 0;
468471
}
@@ -475,6 +478,7 @@ static int socket_early_resume(struct pcmcia_socket *skt)
475478
skt->ops->set_socket(skt, &skt->socket);
476479
if (skt->state & SOCKET_PRESENT)
477480
skt->resume_status = socket_setup(skt, resume_delay);
481+
skt->state |= SOCKET_IN_RESUME;
478482
mutex_unlock(&skt->ops_mutex);
479483
return 0;
480484
}
@@ -484,7 +488,7 @@ static int socket_late_resume(struct pcmcia_socket *skt)
484488
int ret = 0;
485489

486490
mutex_lock(&skt->ops_mutex);
487-
skt->state &= ~SOCKET_SUSPEND;
491+
skt->state &= ~(SOCKET_SUSPEND | SOCKET_IN_RESUME);
488492
mutex_unlock(&skt->ops_mutex);
489493

490494
if (!(skt->state & SOCKET_PRESENT)) {

‎drivers/pcmcia/cs_internal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct pccard_resource_ops {
7070
/* Flags in socket state */
7171
#define SOCKET_PRESENT 0x0008
7272
#define SOCKET_INUSE 0x0010
73+
#define SOCKET_IN_RESUME 0x0040
7374
#define SOCKET_SUSPEND 0x0080
7475
#define SOCKET_WIN_REQ(i) (0x0100<<(i))
7576
#define SOCKET_CARDBUS 0x8000

0 commit comments

Comments
 (0)