Skip to content

Commit a851b2b

Browse files
avri-altman-sndkmartinkpetersen
authored andcommitted
scsi: uapi: ufs: Make utp_upiu_req visible to user space
in preparation to send UPIU requests via bsg. Signed-off-by: Avri Altman <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c6049cd commit a851b2b

File tree

3 files changed

+78
-63
lines changed

3 files changed

+78
-63
lines changed

drivers/scsi/ufs/ufs.h

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
#include <linux/mutex.h>
4040
#include <linux/types.h>
41+
#include <uapi/scsi/scsi_bsg_ufs.h>
4142

42-
#define MAX_CDB_SIZE 16
4343
#define GENERAL_UPIU_REQUEST_SIZE 32
4444
#define QUERY_DESC_MAX_SIZE 255
4545
#define QUERY_DESC_MIN_SIZE 2
@@ -432,65 +432,6 @@ enum ufs_dev_pwr_mode {
432432
UFS_POWERDOWN_PWR_MODE = 3,
433433
};
434434

435-
/**
436-
* struct utp_upiu_header - UPIU header structure
437-
* @dword_0: UPIU header DW-0
438-
* @dword_1: UPIU header DW-1
439-
* @dword_2: UPIU header DW-2
440-
*/
441-
struct utp_upiu_header {
442-
__be32 dword_0;
443-
__be32 dword_1;
444-
__be32 dword_2;
445-
};
446-
447-
/**
448-
* struct utp_upiu_cmd - Command UPIU structure
449-
* @data_transfer_len: Data Transfer Length DW-3
450-
* @cdb: Command Descriptor Block CDB DW-4 to DW-7
451-
*/
452-
struct utp_upiu_cmd {
453-
__be32 exp_data_transfer_len;
454-
u8 cdb[MAX_CDB_SIZE];
455-
};
456-
457-
/**
458-
* struct utp_upiu_query - upiu request buffer structure for
459-
* query request.
460-
* @opcode: command to perform B-0
461-
* @idn: a value that indicates the particular type of data B-1
462-
* @index: Index to further identify data B-2
463-
* @selector: Index to further identify data B-3
464-
* @reserved_osf: spec reserved field B-4,5
465-
* @length: number of descriptor bytes to read/write B-6,7
466-
* @value: Attribute value to be written DW-5
467-
* @reserved: spec reserved DW-6,7
468-
*/
469-
struct utp_upiu_query {
470-
u8 opcode;
471-
u8 idn;
472-
u8 index;
473-
u8 selector;
474-
__be16 reserved_osf;
475-
__be16 length;
476-
__be32 value;
477-
__be32 reserved[2];
478-
};
479-
480-
/**
481-
* struct utp_upiu_req - general upiu request structure
482-
* @header:UPIU header structure DW-0 to DW-2
483-
* @sc: fields structure for scsi command DW-3 to DW-7
484-
* @qr: fields structure for query request DW-3 to DW-7
485-
*/
486-
struct utp_upiu_req {
487-
struct utp_upiu_header header;
488-
union {
489-
struct utp_upiu_cmd sc;
490-
struct utp_upiu_query qr;
491-
};
492-
};
493-
494435
/**
495436
* struct utp_cmd_rsp - Response UPIU structure
496437
* @residual_transfer_count: Residual transfer count DW-3

drivers/scsi/ufs/ufshcd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,8 +2241,8 @@ void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp, u32 upiu_flags)
22412241
ucd_req_ptr->sc.exp_data_transfer_len =
22422242
cpu_to_be32(lrbp->cmd->sdb.length);
22432243

2244-
cdb_len = min_t(unsigned short, lrbp->cmd->cmd_len, MAX_CDB_SIZE);
2245-
memset(ucd_req_ptr->sc.cdb, 0, MAX_CDB_SIZE);
2244+
cdb_len = min_t(unsigned short, lrbp->cmd->cmd_len, UFS_CDB_SIZE);
2245+
memset(ucd_req_ptr->sc.cdb, 0, UFS_CDB_SIZE);
22462246
memcpy(ucd_req_ptr->sc.cdb, lrbp->cmd->cmnd, cdb_len);
22472247

22482248
memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
@@ -8000,7 +8000,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
80008000
host->max_lun = UFS_MAX_LUNS;
80018001
host->max_channel = UFSHCD_MAX_CHANNEL;
80028002
host->unique_id = host->host_no;
8003-
host->max_cmd_len = MAX_CDB_SIZE;
8003+
host->max_cmd_len = UFS_CDB_SIZE;
80048004

80058005
hba->max_pwr_info.is_valid = false;
80068006

include/uapi/scsi/scsi_bsg_ufs.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* UFS Transport SGIO v4 BSG Message Support
4+
*
5+
* Copyright (C) 2011-2013 Samsung India Software Operations
6+
*/
7+
#ifndef SCSI_BSG_UFS_H
8+
#define SCSI_BSG_UFS_H
9+
10+
/*
11+
* This file intended to be included by both kernel and user space
12+
*/
13+
14+
#define UFS_CDB_SIZE 16
15+
16+
/**
17+
* struct utp_upiu_header - UPIU header structure
18+
* @dword_0: UPIU header DW-0
19+
* @dword_1: UPIU header DW-1
20+
* @dword_2: UPIU header DW-2
21+
*/
22+
struct utp_upiu_header {
23+
__be32 dword_0;
24+
__be32 dword_1;
25+
__be32 dword_2;
26+
};
27+
28+
/**
29+
* struct utp_upiu_query - upiu request buffer structure for
30+
* query request.
31+
* @opcode: command to perform B-0
32+
* @idn: a value that indicates the particular type of data B-1
33+
* @index: Index to further identify data B-2
34+
* @selector: Index to further identify data B-3
35+
* @reserved_osf: spec reserved field B-4,5
36+
* @length: number of descriptor bytes to read/write B-6,7
37+
* @value: Attribute value to be written DW-5
38+
* @reserved: spec reserved DW-6,7
39+
*/
40+
struct utp_upiu_query {
41+
__u8 opcode;
42+
__u8 idn;
43+
__u8 index;
44+
__u8 selector;
45+
__be16 reserved_osf;
46+
__be16 length;
47+
__be32 value;
48+
__be32 reserved[2];
49+
};
50+
51+
/**
52+
* struct utp_upiu_cmd - Command UPIU structure
53+
* @data_transfer_len: Data Transfer Length DW-3
54+
* @cdb: Command Descriptor Block CDB DW-4 to DW-7
55+
*/
56+
struct utp_upiu_cmd {
57+
__be32 exp_data_transfer_len;
58+
u8 cdb[UFS_CDB_SIZE];
59+
};
60+
61+
/**
62+
* struct utp_upiu_req - general upiu request structure
63+
* @header:UPIU header structure DW-0 to DW-2
64+
* @sc: fields structure for scsi command DW-3 to DW-7
65+
* @qr: fields structure for query request DW-3 to DW-7
66+
*/
67+
struct utp_upiu_req {
68+
struct utp_upiu_header header;
69+
union {
70+
struct utp_upiu_cmd sc;
71+
struct utp_upiu_query qr;
72+
};
73+
};
74+
#endif /* UFS_BSG_H */

0 commit comments

Comments
 (0)