locking.txt 2.5 KB

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