aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/mic/mpssd
diff options
context:
space:
mode:
authorDasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>2013-10-03 21:06:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-05 21:01:42 -0400
commitaf190494f9b2e1fb6e1c039e9626c3c334717da1 (patch)
tree3c6b5168cd9e3bd9455380ca5360a4a250820ab0 /Documentation/mic/mpssd
parent12b3af3096cdfb0613da374021167868c6abc9ce (diff)
misc: mic: Enable OSPM suspend and resume support.
This patch enables support for OSPM suspend and resume in the MIC driver. During a host suspend event, the driver performs an orderly shutdown of the cards if they are online. Upon resume, any cards that were previously online before suspend are rebooted. The driver performs an orderly shutdown of the card primarily to ensure that applications in the card are terminated and mounted devices are safely un-mounted before the card is powered down in the event of an OSPM suspend. The driver makes use of the MIC daemon to accomplish OSPM suspend and resume. The driver registers a PM notifier per MIC device. The devices get notified synchronously during PM_SUSPEND_PREPARE and PM_POST_SUSPEND phases. During the PM_SUSPEND_PREPARE phase, the driver performs one of the following three tasks. 1) If the card is 'offline', the driver sets the card to a 'suspended' state and returns. 2) If the card is 'online', the driver initiates card shutdown by setting the card state to suspending. This notifies the MIC daemon which invokes shutdown and sets card state to 'suspended'. The driver returns after the shutdown is complete. 3) If the card is already being shutdown, possibly by a host user space application, the driver sets the card state to 'suspended' and returns after the shutdown is complete. During the PM_POST_SUSPEND phase, the driver simply notifies the daemon and returns. The daemon boots those cards that were previously online during the suspend phase. Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Nikhil Rao <nikhil.rao@intel.com> Signed-off-by: Harshavardhan R Kharche <harshavardhan.r.kharche@intel.com> Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com> Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'Documentation/mic/mpssd')
-rw-r--r--Documentation/mic/mpssd/mpssd.c27
-rw-r--r--Documentation/mic/mpssd/mpssd.h1
2 files changed, 24 insertions, 4 deletions
diff --git a/Documentation/mic/mpssd/mpssd.c b/Documentation/mic/mpssd/mpssd.c
index 82c6bc2e3cb6..0c980ad40b17 100644
--- a/Documentation/mic/mpssd/mpssd.c
+++ b/Documentation/mic/mpssd/mpssd.c
@@ -1295,7 +1295,13 @@ reset(struct mic_info *mic)
1295 goto retry; 1295 goto retry;
1296 mpsslog("%s: %s %d state %s\n", 1296 mpsslog("%s: %s %d state %s\n",
1297 mic->name, __func__, __LINE__, state); 1297 mic->name, __func__, __LINE__, state);
1298 if ((!strcmp(state, "offline"))) { 1298
1299 /*
1300 * If the shutdown was initiated by OSPM, the state stays
1301 * in "suspended" which is also a valid condition for reset.
1302 */
1303 if ((!strcmp(state, "offline")) ||
1304 (!strcmp(state, "suspended"))) {
1299 free(state); 1305 free(state);
1300 break; 1306 break;
1301 } 1307 }
@@ -1334,6 +1340,10 @@ static int get_mic_state(struct mic_info *mic, char *state)
1334 return MIC_SHUTTING_DOWN; 1340 return MIC_SHUTTING_DOWN;
1335 if (!strcmp(state, "reset_failed")) 1341 if (!strcmp(state, "reset_failed"))
1336 return MIC_RESET_FAILED; 1342 return MIC_RESET_FAILED;
1343 if (!strcmp(state, "suspending"))
1344 return MIC_SUSPENDING;
1345 if (!strcmp(state, "suspended"))
1346 return MIC_SUSPENDED;
1337 mpsslog("%s: BUG invalid state %s\n", mic->name, state); 1347 mpsslog("%s: BUG invalid state %s\n", mic->name, state);
1338 /* Invalid state */ 1348 /* Invalid state */
1339 assert(0); 1349 assert(0);
@@ -1418,6 +1428,17 @@ retry:
1418 case MIC_SHUTTING_DOWN: 1428 case MIC_SHUTTING_DOWN:
1419 mic_handle_shutdown(mic); 1429 mic_handle_shutdown(mic);
1420 goto close_error; 1430 goto close_error;
1431 case MIC_SUSPENDING:
1432 mic->boot_on_resume = 1;
1433 setsysfs(mic->name, "state", "suspend");
1434 mic_handle_shutdown(mic);
1435 goto close_error;
1436 case MIC_OFFLINE:
1437 if (mic->boot_on_resume) {
1438 setsysfs(mic->name, "state", "boot");
1439 mic->boot_on_resume = 0;
1440 }
1441 break;
1421 default: 1442 default:
1422 break; 1443 break;
1423 } 1444 }
@@ -1621,11 +1642,9 @@ init_mic_list(void)
1621 1642
1622 while ((file = readdir(dp)) != NULL) { 1643 while ((file = readdir(dp)) != NULL) {
1623 if (!strncmp(file->d_name, "mic", 3)) { 1644 if (!strncmp(file->d_name, "mic", 3)) {
1624 mic->next = malloc(sizeof(struct mic_info)); 1645 mic->next = calloc(1, sizeof(struct mic_info));
1625 if (mic->next) { 1646 if (mic->next) {
1626 mic = mic->next; 1647 mic = mic->next;
1627 mic->next = NULL;
1628 memset(mic, 0, sizeof(struct mic_info));
1629 mic->id = atoi(&file->d_name[3]); 1648 mic->id = atoi(&file->d_name[3]);
1630 mic->name = malloc(strlen(file->d_name) + 16); 1649 mic->name = malloc(strlen(file->d_name) + 16);
1631 if (mic->name) 1650 if (mic->name)
diff --git a/Documentation/mic/mpssd/mpssd.h b/Documentation/mic/mpssd/mpssd.h
index ccd589ff9146..f5f18b15d9a0 100644
--- a/Documentation/mic/mpssd/mpssd.h
+++ b/Documentation/mic/mpssd/mpssd.h
@@ -91,6 +91,7 @@ struct mic_info {
91 struct mic_net_info mic_net; 91 struct mic_net_info mic_net;
92 struct mic_virtblk_info mic_virtblk; 92 struct mic_virtblk_info mic_virtblk;
93 int restart; 93 int restart;
94 int boot_on_resume;
94 struct mic_info *next; 95 struct mic_info *next;
95}; 96};
96 97