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