locking.rst 2.5 KB

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