queue.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef MMC_QUEUE_H
  2. #define MMC_QUEUE_H
  3. static inline bool mmc_req_is_special(struct request *req)
  4. {
  5. return req &&
  6. (req_op(req) == REQ_OP_FLUSH ||
  7. req_op(req) == REQ_OP_DISCARD ||
  8. req_op(req) == REQ_OP_SECURE_ERASE);
  9. }
  10. struct request;
  11. struct task_struct;
  12. struct mmc_blk_request {
  13. struct mmc_request mrq;
  14. struct mmc_command sbc;
  15. struct mmc_command cmd;
  16. struct mmc_command stop;
  17. struct mmc_data data;
  18. int retune_retry_done;
  19. };
  20. enum mmc_packed_type {
  21. MMC_PACKED_NONE = 0,
  22. MMC_PACKED_WRITE,
  23. };
  24. #define mmc_packed_cmd(type) ((type) != MMC_PACKED_NONE)
  25. #define mmc_packed_wr(type) ((type) == MMC_PACKED_WRITE)
  26. struct mmc_packed {
  27. struct list_head list;
  28. u32 cmd_hdr[1024];
  29. unsigned int blocks;
  30. u8 nr_entries;
  31. u8 retries;
  32. s16 idx_failure;
  33. };
  34. struct mmc_queue_req {
  35. struct request *req;
  36. struct mmc_blk_request brq;
  37. struct scatterlist *sg;
  38. char *bounce_buf;
  39. struct scatterlist *bounce_sg;
  40. unsigned int bounce_sg_len;
  41. struct mmc_async_req mmc_active;
  42. enum mmc_packed_type cmd_type;
  43. struct mmc_packed *packed;
  44. };
  45. struct mmc_queue {
  46. struct mmc_card *card;
  47. struct task_struct *thread;
  48. struct semaphore thread_sem;
  49. unsigned int flags;
  50. #define MMC_QUEUE_SUSPENDED (1 << 0)
  51. #define MMC_QUEUE_NEW_REQUEST (1 << 1)
  52. int (*issue_fn)(struct mmc_queue *, struct request *);
  53. void *data;
  54. struct request_queue *queue;
  55. struct mmc_queue_req mqrq[2];
  56. struct mmc_queue_req *mqrq_cur;
  57. struct mmc_queue_req *mqrq_prev;
  58. };
  59. extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
  60. const char *);
  61. extern void mmc_cleanup_queue(struct mmc_queue *);
  62. extern void mmc_queue_suspend(struct mmc_queue *);
  63. extern void mmc_queue_resume(struct mmc_queue *);
  64. extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
  65. struct mmc_queue_req *);
  66. extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
  67. extern void mmc_queue_bounce_post(struct mmc_queue_req *);
  68. extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
  69. extern void mmc_packed_clean(struct mmc_queue *);
  70. extern int mmc_access_rpmb(struct mmc_queue *);
  71. #endif