lib/thread: Make thread_run not block the current state
If a thread wants to block a state transition it can use thread_run_until. Otherwise just let the thread run. `thread_join` can be used to block on the thread. Boot states are also a ramstage concept. If we want to use this API in any other stage, we need a way of starting a thread without talking about stages. BUG=b:179699789 TEST=verify thread_run no longer blocks the current state Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I3e5b0aed70385ddcd23ffcf7b063f8ccb547fc05 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56351 Reviewed-by: Karthik Ramasubramanian <kramasub@google.com> Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
		
				
					committed by
					
						
						Raul Rangel
					
				
			
			
				
	
			
			
			
						parent
						
							cc01da50b7
						
					
				
				
					commit
					4aec58dce7
				
			@@ -46,9 +46,8 @@ void threads_initialize(void);
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
void *arch_get_thread_stackbase(void);
 | 
					void *arch_get_thread_stackbase(void);
 | 
				
			||||||
/* Run func(arrg) on a new thread. Return 0 on successful start of thread, < 0
 | 
					/* Run func(arrg) on a new thread. Return 0 on successful start of thread, < 0
 | 
				
			||||||
 * when thread could not be started. Note that the thread will block the
 | 
					 * when thread could not be started. The thread handle if populated, will
 | 
				
			||||||
 * current state in the boot state machine until it is complete. The thread
 | 
					 * reflect the state and return code of the thread.
 | 
				
			||||||
 * handle if populated, will reflect the state and return code of the thread.
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int thread_run(struct thread_handle *handle, enum cb_err (*func)(void *), void *arg);
 | 
					int thread_run(struct thread_handle *handle, enum cb_err (*func)(void *), void *arg);
 | 
				
			||||||
/* thread_run_until is the same as thread_run() except that it blocks state
 | 
					/* thread_run_until is the same as thread_run() except that it blocks state
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -162,18 +162,6 @@ static void asmlinkage call_wrapper(void *unused)
 | 
				
			|||||||
	terminate_thread(current, error);
 | 
						terminate_thread(current, error);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Block the current state transitions until thread is complete. */
 | 
					 | 
				
			||||||
static void asmlinkage call_wrapper_block_current(void *unused)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct thread *current = current_thread();
 | 
					 | 
				
			||||||
	enum cb_err error;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	boot_state_current_block();
 | 
					 | 
				
			||||||
	error = current->entry(current->entry_arg);
 | 
					 | 
				
			||||||
	boot_state_current_unblock();
 | 
					 | 
				
			||||||
	terminate_thread(current, error);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct block_boot_state {
 | 
					struct block_boot_state {
 | 
				
			||||||
	boot_state_t state;
 | 
						boot_state_t state;
 | 
				
			||||||
	boot_state_sequence_t seq;
 | 
						boot_state_sequence_t seq;
 | 
				
			||||||
@@ -312,7 +300,7 @@ int thread_run(struct thread_handle *handle, enum cb_err (*func)(void *), void *
 | 
				
			|||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	prepare_thread(t, handle, func, arg, call_wrapper_block_current, NULL);
 | 
						prepare_thread(t, handle, func, arg, call_wrapper, NULL);
 | 
				
			||||||
	schedule(t);
 | 
						schedule(t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user