locking.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. Note that send_event() and struct pcmcia_callback *callback must not be
  30. called with "ops_mutex" held.
  31. C) Protection
  32. =============
  33. 1. Global Data:
  34. ---------------
  35. struct list_head pcmcia_socket_list;
  36. protected by pcmcia_socket_list_rwsem;
  37. 2. Per-Socket Data:
  38. -------------------
  39. The resource_ops are on their own to provide proper locking.
  40. The "main" struct pcmcia_socket is protected as follows (read-only fields
  41. or single-use fields not mentioned):
  42. - by pcmcia_socket_list_rwsem:
  43. struct list_head socket_list;
  44. - by thread_lock:
  45. unsigned int thread_events;
  46. - by skt_mutex:
  47. u_int suspended_state;
  48. void (*tune_bridge);
  49. struct pcmcia_callback *callback;
  50. int resume_status;
  51. - by ops_mutex:
  52. socket_state_t socket;
  53. u_int state;
  54. u_short lock_count;
  55. pccard_mem_map cis_mem;
  56. void __iomem *cis_virt;
  57. struct { } irq;
  58. io_window_t io[];
  59. pccard_mem_map win[];
  60. struct list_head cis_cache;
  61. size_t fake_cis_len;
  62. u8 *fake_cis;
  63. u_int irq_mask;
  64. void (*zoom_video);
  65. int (*power_hook);
  66. u8 resource...;
  67. struct list_head devices_list;
  68. u8 device_count;
  69. struct pcmcia_state;
  70. 3. Per PCMCIA-device Data:
  71. --------------------------
  72. The "main" struct pcmcia_devie is protected as follows (read-only fields
  73. or single-use fields not mentioned):
  74. - by pcmcia_socket->ops_mutex:
  75. struct list_head socket_device_list;
  76. struct config_t *function_config;
  77. u16 _irq:1;
  78. u16 _io:1;
  79. u16 _win:4;
  80. u16 _locked:1;
  81. u16 allow_func_id_match:1;
  82. u16 suspended:1;
  83. u16 _removed:1;
  84. - by the PCMCIA driver:
  85. io_req_t io;
  86. irq_req_t irq;
  87. config_req_t conf;
  88. window_handle_t win;