-/*
- * Description on Trace Daemon Synchronization
- *
- * Three categories of code are synchronizing between each other
- * 1. lctl, portals_debug_set_daemon(), the user debug control code,
- * as well as portals_debug_clear_buffer()
- * 2. CDEBUG, portals_debug_msg(), the debug put messages routine
- * 3. Daemon, portals_debug_daemon(), to write out debug log file
- *
- *
- * Three different controls for synchronizations
- *
- * 1. debug_daemon_semaphore
- * The usage of this semaphore is to serialize multiple lctl controls
- * in manipulating debug daemon state. The semaphore serves as the
- * gatekeeper to allow only one user control thread, at any giving time,
- * to access debug daemon state and keeps the other user control requests
- * in wait state until the current control request is serviced.
- *
- * 2. wait_queue_head_t lctl (paired with lctl_event flag)
- * Lctl event is the event between portals_debug_set_daemon() and
- * portals_debug_daemon(). Lctl is an indicator for portals_debug_daemon()
- * to flush data out to file. portals_debug_daemon() is to use lctl event
- * as signal channel to wakeup portals_debug_set_daemon() upon flush
- * operation is done.
- *
- * Producer :
- * portals_debug_daemon() uses to wake up
- * portals_debug_set_daemon(), pause and stop, routines
- * Consumer :
- * portals_debug_set_daemon(), stop and pause operations,
- * wait and sleep on the event
- *
- * 3. wait_queue_head_t daemon (paired with daemon_event flag)
- * This is an event channel to wakeup portals_debug_daemon. Daemon
- * wakes up to run whenever there is an event posted. Daemon handles
- * 2 types of operations . 1. Writes data out to debug file, 2. Flushes
- * file and terminates base on lctl event.
- * File operation -
- * Daemon is normally in a sleep state.
- * Daemon is woken up through daemon event whenever CDEBUG is
- * putting data over any 64K boundary.
- * File flush and termination -
- * On portals_debug_daemon_stop/pause() operations, lctl control
- * is to wake up daemon through daemon event.
- *
- * We can't use sleep_on() and wake_up() to replace daemon event because
- * portals_debug_daemon() must catch the wakeup operation posted by
- * portals_debug_daemon_stop/pause(). Otherwise, stop and pause may
- * stuck in lctl wait event.
- *
- * Producer :
- * a. portals_debug_daemon_pause() and portals_debug_daemon_stop()
- * uses the event to wake up portals_debug_daemon()
- * b. portals_debug_msg() uses the event to wake up
- * portals_debug_daemon() whenever the data output is acrossing
- * a 64K bytes boundary.
- * Consumer :
- * portals_debug_daemon() wakes up upon daemon event.
- *
- * Sequence for portals_debug_daemon_stop() operation
- *
- * _Portals_debug_daemon_stop()_ _Daemon_
- * Wait_event(daemon) or running
- * Paused = 1;
- * Wakeup_event (daemon)
- * Wait_event(lctl)
- * Set force_flush flag if lctlevnt
- * Flush data
- * Wakeup_event (lctl)
- * Wait_event(daemon)
- * Stopped = 1;
- * Wakeup_event (daemon)
- * Wait_event(lctl)
- * Exit daemon loop if (Stopped)
- * Wakeup_event (lctl)
- * Exit
- * Return to user application
- *
- *
- * _Portals_debug_msg()_ _Daemon_
- * Wait_event(daemon) or running
- * If (WriteStart<64K<WriteEnd)
- * Wakeup_event(daemon)
- * Do file IO
- * Wait_event(daemon)
- */
-struct debug_daemon_state {
- unsigned long overlapped;
- unsigned long stopped;
- atomic_t paused;
- unsigned long lctl_event; /* event for lctl */
- wait_queue_head_t lctl;
- unsigned long daemon_event; /* event for daemon */
- wait_queue_head_t daemon;
-};
-static struct debug_daemon_state debug_daemon_state;
-static DECLARE_MUTEX(debug_daemon_semaphore);
-
-static loff_t daemon_file_size_limit;
-char debug_daemon_file_path[1024] = "";
-
-spinlock_t portals_debug_lock = SPIN_LOCK_UNLOCKED;