queue.h 2.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
L
Linus Torvalds 已提交
2 3 4
#ifndef MMC_QUEUE_H
#define MMC_QUEUE_H

5 6
#include <linux/types.h>
#include <linux/blkdev.h>
7
#include <linux/blk-mq.h>
8 9 10
#include <linux/mmc/core.h>
#include <linux/mmc/host.h>

11 12 13 14 15
static inline struct mmc_queue_req *req_to_mmc_queue_req(struct request *rq)
{
	return blk_mq_rq_to_pdu(rq);
}

16 17 18 19 20 21 22
struct mmc_queue_req;

static inline struct request *mmc_queue_req_to_req(struct mmc_queue_req *mqr)
{
	return blk_mq_rq_from_pdu(mqr);
}

L
Linus Torvalds 已提交
23
struct task_struct;
L
Linus Walleij 已提交
24
struct mmc_blk_data;
25
struct mmc_blk_ioc_data;
L
Linus Torvalds 已提交
26

27 28 29 30 31 32
struct mmc_blk_request {
	struct mmc_request	mrq;
	struct mmc_command	sbc;
	struct mmc_command	cmd;
	struct mmc_command	stop;
	struct mmc_data		data;
33
	int			retune_retry_done;
34 35
};

36 37 38
/**
 * enum mmc_drv_op - enumerates the operations in the mmc_queue_req
 * @MMC_DRV_OP_IOCTL: ioctl operation
39
 * @MMC_DRV_OP_IOCTL_RPMB: RPMB-oriented ioctl operation
40
 * @MMC_DRV_OP_BOOT_WP: write protect boot partitions
41 42
 * @MMC_DRV_OP_GET_CARD_STATUS: get card status
 * @MMC_DRV_OP_GET_EXT_CSD: get the EXT CSD from an eMMC card
43 44 45
 */
enum mmc_drv_op {
	MMC_DRV_OP_IOCTL,
46
	MMC_DRV_OP_IOCTL_RPMB,
47
	MMC_DRV_OP_BOOT_WP,
48 49
	MMC_DRV_OP_GET_CARD_STATUS,
	MMC_DRV_OP_GET_EXT_CSD,
50 51
};

52 53 54
struct mmc_queue_req {
	struct mmc_blk_request	brq;
	struct scatterlist	*sg;
55
	struct mmc_async_req	areq;
56
	enum mmc_drv_op		drv_op;
57
	int			drv_op_result;
58
	void			*drv_op_data;
59
	unsigned int		ioc_count;
60 61
};

L
Linus Torvalds 已提交
62 63
struct mmc_queue {
	struct mmc_card		*card;
C
Christoph Hellwig 已提交
64
	struct task_struct	*thread;
L
Linus Torvalds 已提交
65
	struct semaphore	thread_sem;
66
	bool			suspended;
67
	bool			asleep;
L
Linus Walleij 已提交
68
	struct mmc_blk_data	*blkdata;
L
Linus Torvalds 已提交
69
	struct request_queue	*queue;
70 71 72 73 74 75
	/*
	 * FIXME: this counter is not a very reliable way of keeping
	 * track of how many requests that are ongoing. Switch to just
	 * letting the block core keep track of requests and per-request
	 * associated mmc_queue_req data.
	 */
76
	int			qcnt;
L
Linus Torvalds 已提交
77 78
};

79 80
extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
			  const char *);
L
Linus Torvalds 已提交
81 82 83
extern void mmc_cleanup_queue(struct mmc_queue *);
extern void mmc_queue_suspend(struct mmc_queue *);
extern void mmc_queue_resume(struct mmc_queue *);
84 85
extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
				     struct mmc_queue_req *);
86

L
Linus Torvalds 已提交
87
#endif