Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) Locking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) This file explains the locking and exclusion scheme used in the PCCARD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) and PCMCIA subsystems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) A) Overview, Locking Hierarchy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) pcmcia_socket_list_rwsem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	- protects only the list of sockets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) - skt_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	- serializes card insert / ejection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)   - ops_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	- serializes socket operation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) B) Exclusion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) The following functions and callbacks to struct pcmcia_socket must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) be called with "skt_mutex" held::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	socket_detect_change()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	send_event()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	socket_reset()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	socket_shutdown()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	socket_setup()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	socket_remove()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	socket_insert()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	socket_early_resume()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	socket_late_resume()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	socket_resume()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	socket_suspend()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct pcmcia_callback	*callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) The following functions and callbacks to struct pcmcia_socket must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) be called with "ops_mutex" held::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	socket_reset()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	socket_setup()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	struct pccard_operations	*ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	struct pccard_resource_ops	*resource_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) Note that send_event() and `struct pcmcia_callback *callback` must not be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) called with "ops_mutex" held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) C) Protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) =============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 1. Global Data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) struct list_head	pcmcia_socket_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) protected by pcmcia_socket_list_rwsem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 2. Per-Socket Data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) -------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) The resource_ops and their data are protected by ops_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) The "main" struct pcmcia_socket is protected as follows (read-only fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) or single-use fields not mentioned):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) - by pcmcia_socket_list_rwsem::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct list_head	socket_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) - by thread_lock::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	unsigned int		thread_events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) - by skt_mutex::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	u_int			suspended_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	void			(*tune_bridge);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct pcmcia_callback	*callback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int			resume_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) - by ops_mutex::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	socket_state_t		socket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	u_int			state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	u_short			lock_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	pccard_mem_map		cis_mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	void __iomem 		*cis_virt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	struct { }		irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	io_window_t		io[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	pccard_mem_map		win[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct list_head	cis_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	size_t			fake_cis_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	u8			*fake_cis;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	u_int			irq_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	void 			(*zoom_video);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	int 			(*power_hook);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	u8			resource...;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct list_head	devices_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	u8			device_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	struct 			pcmcia_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 3. Per PCMCIA-device Data:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) --------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) The "main" struct pcmcia_device is protected as follows (read-only fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) or single-use fields not mentioned):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) - by pcmcia_socket->ops_mutex::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct list_head	socket_device_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct config_t		*function_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	u16			_irq:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	u16			_io:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	u16			_win:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	u16			_locked:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	u16			allow_func_id_match:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	u16			suspended:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	u16			_removed:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) - by the PCMCIA driver::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	io_req_t		io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	irq_req_t		irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	config_req_t		conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	window_handle_t		win;