1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) IBM Corporation, 2004
7 * Author: Max Asböck <amax@us.ibm.com>
10 #include <linux/sched/signal.h>
12 #include "dot_command.h"
15 * Reverse Heartbeat, i.e. heartbeats sent from the driver to the
17 * These heartbeats are initiated by user level programs.
20 /* the reverse heartbeat dot command */
23 struct dot_command_header header
;
24 unsigned char command
[3];
32 .command
= { 4, 3, 6 }
36 void ibmasm_init_reverse_heartbeat(struct service_processor
*sp
, struct reverse_heartbeat
*rhb
)
38 init_waitqueue_head(&rhb
->wait
);
43 * start_reverse_heartbeat
44 * Loop forever, sending a reverse heartbeat dot command to the service
45 * processor, then sleeping. The loop comes to an end if the service
46 * processor fails to respond 3 times or we were interrupted.
48 int ibmasm_start_reverse_heartbeat(struct service_processor
*sp
, struct reverse_heartbeat
*rhb
)
54 cmd
= ibmasm_new_command(sp
, sizeof rhb_dot_cmd
);
58 while (times_failed
< 3) {
59 memcpy(cmd
->buffer
, (void *)&rhb_dot_cmd
, sizeof rhb_dot_cmd
);
60 cmd
->status
= IBMASM_CMD_PENDING
;
61 ibmasm_exec_command(sp
, cmd
);
62 ibmasm_wait_for_response(cmd
, IBMASM_CMD_TIMEOUT_NORMAL
);
64 if (cmd
->status
!= IBMASM_CMD_COMPLETE
)
67 wait_event_interruptible_timeout(rhb
->wait
,
69 REVERSE_HEARTBEAT_TIMEOUT
* HZ
);
71 if (signal_pending(current
) || rhb
->stopped
) {
82 void ibmasm_stop_reverse_heartbeat(struct reverse_heartbeat
*rhb
)
85 wake_up_interruptible(&rhb
->wait
);