Skip to content

Commit 5a0b0cb

Browse files
Sujit Reddy ThummaJames Bottomley
authored andcommitted
[SCSI] ufs: Add support for sending NOP OUT UPIU
As part of device initialization sequence, sending NOP OUT UPIU and waiting for NOP IN UPIU response is mandatory. This confirms that the device UFS Transport (UTP) layer is functional and the host can configure the device with further commands. Add support for sending NOP OUT UPIU to check the device connection path and test whether the UTP layer on the device side is functional during initialization. A tag is acquired from the SCSI tag map space in order to send the device management command. When the tag is acquired by internal command the scsi command is rejected with host busy flag in order to requeue the request. To avoid frequent collisions between internal commands and scsi commands the device management command tag is allocated in the opposite direction w.r.t block layer tag allocation. Signed-off-by: Sujit Reddy Thumma <[email protected]> Signed-off-by: Dolev Raviv <[email protected]> Signed-off-by: Santosh Y <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 5f09e1f commit 5a0b0cb

File tree

3 files changed

+539
-115
lines changed

3 files changed

+539
-115
lines changed

drivers/scsi/ufs/ufs.h

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@
3636
#ifndef _UFS_H
3737
#define _UFS_H
3838

39+
#include <linux/mutex.h>
40+
#include <linux/types.h>
41+
3942
#define MAX_CDB_SIZE 16
4043

4144
#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
42-
((byte3 << 24) | (byte2 << 16) |\
45+
cpu_to_be32((byte3 << 24) | (byte2 << 16) |\
4346
(byte1 << 8) | (byte0))
4447

4548
/*
@@ -73,6 +76,7 @@ enum {
7376
UPIU_TRANSACTION_TASK_RSP = 0x24,
7477
UPIU_TRANSACTION_READY_XFER = 0x31,
7578
UPIU_TRANSACTION_QUERY_RSP = 0x36,
79+
UPIU_TRANSACTION_REJECT_UPIU = 0x3F,
7680
};
7781

7882
/* UPIU Read/Write flags */
@@ -110,6 +114,12 @@ enum {
110114
UPIU_COMMAND_SET_TYPE_QUERY = 0x2,
111115
};
112116

117+
/* UTP Transfer Request Command Offset */
118+
#define UPIU_COMMAND_TYPE_OFFSET 28
119+
120+
/* Offset of the response code in the UPIU header */
121+
#define UPIU_RSP_CODE_OFFSET 8
122+
113123
enum {
114124
MASK_SCSI_STATUS = 0xFF,
115125
MASK_TASK_RESPONSE = 0xFF00,
@@ -138,32 +148,48 @@ struct utp_upiu_header {
138148

139149
/**
140150
* struct utp_upiu_cmd - Command UPIU structure
141-
* @header: UPIU header structure DW-0 to DW-2
142151
* @data_transfer_len: Data Transfer Length DW-3
143152
* @cdb: Command Descriptor Block CDB DW-4 to DW-7
144153
*/
145154
struct utp_upiu_cmd {
146-
struct utp_upiu_header header;
147155
u32 exp_data_transfer_len;
148156
u8 cdb[MAX_CDB_SIZE];
149157
};
150158

151159
/**
152-
* struct utp_upiu_rsp - Response UPIU structure
153-
* @header: UPIU header DW-0 to DW-2
160+
* struct utp_upiu_req - general upiu request structure
161+
* @header:UPIU header structure DW-0 to DW-2
162+
* @sc: fields structure for scsi command DW-3 to DW-7
163+
*/
164+
struct utp_upiu_req {
165+
struct utp_upiu_header header;
166+
struct utp_upiu_cmd sc;
167+
};
168+
169+
/**
170+
* struct utp_cmd_rsp - Response UPIU structure
154171
* @residual_transfer_count: Residual transfer count DW-3
155172
* @reserved: Reserved double words DW-4 to DW-7
156173
* @sense_data_len: Sense data length DW-8 U16
157174
* @sense_data: Sense data field DW-8 to DW-12
158175
*/
159-
struct utp_upiu_rsp {
160-
struct utp_upiu_header header;
176+
struct utp_cmd_rsp {
161177
u32 residual_transfer_count;
162178
u32 reserved[4];
163179
u16 sense_data_len;
164180
u8 sense_data[18];
165181
};
166182

183+
/**
184+
* struct utp_upiu_rsp - general upiu response structure
185+
* @header: UPIU header structure DW-0 to DW-2
186+
* @sr: fields structure for scsi command DW-3 to DW-12
187+
*/
188+
struct utp_upiu_rsp {
189+
struct utp_upiu_header header;
190+
struct utp_cmd_rsp sr;
191+
};
192+
167193
/**
168194
* struct utp_upiu_task_req - Task request UPIU structure
169195
* @header - UPIU header structure DW0 to DW-2

0 commit comments

Comments
 (0)