queue.h 2.1 KB

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