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