queue.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. __le32 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. void *data;
  53. struct request_queue *queue;
  54. struct mmc_queue_req mqrq[2];
  55. struct mmc_queue_req *mqrq_cur;
  56. struct mmc_queue_req *mqrq_prev;
  57. };
  58. extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
  59. const char *);
  60. extern void mmc_cleanup_queue(struct mmc_queue *);
  61. extern void mmc_queue_suspend(struct mmc_queue *);
  62. extern void mmc_queue_resume(struct mmc_queue *);
  63. extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
  64. struct mmc_queue_req *);
  65. extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
  66. extern void mmc_queue_bounce_post(struct mmc_queue_req *);
  67. extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
  68. extern void mmc_packed_clean(struct mmc_queue *);
  69. extern int mmc_access_rpmb(struct mmc_queue *);
  70. #endif