queue.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef MMC_QUEUE_H
  2. #define MMC_QUEUE_H
  3. #include <linux/types.h>
  4. #include <linux/blkdev.h>
  5. #include <linux/blk-mq.h>
  6. #include <linux/mmc/core.h>
  7. #include <linux/mmc/host.h>
  8. static inline struct mmc_queue_req *req_to_mmc_queue_req(struct request *rq)
  9. {
  10. return blk_mq_rq_to_pdu(rq);
  11. }
  12. struct mmc_queue_req;
  13. static inline struct request *mmc_queue_req_to_req(struct mmc_queue_req *mqr)
  14. {
  15. return blk_mq_rq_from_pdu(mqr);
  16. }
  17. struct task_struct;
  18. struct mmc_blk_data;
  19. struct mmc_blk_ioc_data;
  20. struct mmc_blk_request {
  21. struct mmc_request mrq;
  22. struct mmc_command sbc;
  23. struct mmc_command cmd;
  24. struct mmc_command stop;
  25. struct mmc_data data;
  26. int retune_retry_done;
  27. };
  28. /**
  29. * enum mmc_drv_op - enumerates the operations in the mmc_queue_req
  30. * @MMC_DRV_OP_IOCTL: ioctl operation
  31. * @MMC_DRV_OP_BOOT_WP: write protect boot partitions
  32. * @MMC_DRV_OP_GET_CARD_STATUS: get card status
  33. * @MMC_DRV_OP_GET_EXT_CSD: get the EXT CSD from an eMMC card
  34. */
  35. enum mmc_drv_op {
  36. MMC_DRV_OP_IOCTL,
  37. MMC_DRV_OP_BOOT_WP,
  38. MMC_DRV_OP_GET_CARD_STATUS,
  39. MMC_DRV_OP_GET_EXT_CSD,
  40. };
  41. struct mmc_queue_req {
  42. struct mmc_blk_request brq;
  43. struct scatterlist *sg;
  44. struct mmc_async_req areq;
  45. enum mmc_drv_op drv_op;
  46. int drv_op_result;
  47. void *drv_op_data;
  48. unsigned int ioc_count;
  49. };
  50. struct mmc_queue {
  51. struct mmc_card *card;
  52. struct task_struct *thread;
  53. struct semaphore thread_sem;
  54. bool suspended;
  55. bool asleep;
  56. struct mmc_blk_data *blkdata;
  57. struct request_queue *queue;
  58. /*
  59. * FIXME: this counter is not a very reliable way of keeping
  60. * track of how many requests that are ongoing. Switch to just
  61. * letting the block core keep track of requests and per-request
  62. * associated mmc_queue_req data.
  63. */
  64. int qcnt;
  65. };
  66. extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
  67. const char *);
  68. extern void mmc_cleanup_queue(struct mmc_queue *);
  69. extern void mmc_queue_suspend(struct mmc_queue *);
  70. extern void mmc_queue_resume(struct mmc_queue *);
  71. extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
  72. struct mmc_queue_req *);
  73. extern int mmc_access_rpmb(struct mmc_queue *);
  74. #endif