scsi: ufs: add ioctl interface for query request
Subsystems (3)
PATCH v3 1/1 scsi: ufs: add ioctl interface for query request
This patch exposes the ioctl interface for UFS driver via SCSI device ioctl interface. As of now UFS driver would provide the ioctl for query interface to connected UFS device.
--- drivers/scsi/ufs/ufs.h | 53 +++-------- drivers/scsi/ufs/ufshcd.c | 208 +++++++++++++++++++++++++++++++++++++++++- include/scsi/scsi.h | 1 + include/uapi/scsi/Kbuild | 1 + include/uapi/scsi/ufs/Kbuild | 3 + include/uapi/scsi/ufs/ioctl.h | 58 ++++++++++++ include/uapi/scsi/ufs/ufs.h | 67 ++++++++++++++ 7 files changed, 348 insertions(+), 43 deletions(-) create mode 100644 include/uapi/scsi/ufs/Kbuild create mode 100644 include/uapi/scsi/ufs/ioctl.h create mode 100644 include/uapi/scsi/ufs/ufs.h
drivers/scsi/ufs/ufs.h +11 -42
@@ -38,6 +38,7 @@#include <linux/mutex.h> #include <linux/types.h> +#include <scsi/ufs/ufs.h> #define MAX_CDB_SIZE 16#define GENERAL_UPIU_REQUEST_SIZE 32
@@ -72,6 +73,16 @@ enum { UFS_UPIU_RPMB_WLUN = 0xC4, }; +/** +* ufs_is_valid_unit_desc_lun - checks if the given LUN has a unit descriptor +* @lun: LU number to check +* @return: true if the lun has a matching unit descriptor, false otherwise +*/ +static inline bool ufs_is_valid_unit_desc_lun (u8 lun) +{ +return lun ==UFS_UPIU_RPMB_WLUN || (lun <UFS_UPIU_MAX_GENERAL_LUN ); +} +/* * UFS Protocol Information Unit related definitions */
@@ -127,35 +138,6 @@ enum { UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81, }; -/* Flag idn for Query Requests*/ -enum flag_idn { -QUERY_FLAG_IDN_FDEVICEINIT =0x01 , -QUERY_FLAG_IDN_PWR_ON_WPE =0x03 , -QUERY_FLAG_IDN_BKOPS_EN =0x04 , -}; - -/* Attribute idn for Query requests */ -enum attr_idn { -QUERY_ATTR_IDN_ACTIVE_ICC_LVL =0x03 , -QUERY_ATTR_IDN_BKOPS_STATUS =0x05 , -QUERY_ATTR_IDN_EE_CONTROL =0x0D , -QUERY_ATTR_IDN_EE_STATUS =0x0E , -}; - -/* Descriptor idn for Query requests */ -enum desc_idn { -QUERY_DESC_IDN_DEVICE =0x0 , -QUERY_DESC_IDN_CONFIGURAION =0x1 , -QUERY_DESC_IDN_UNIT =0x2 , -QUERY_DESC_IDN_RFU_0 =0x3 , -QUERY_DESC_IDN_INTERCONNECT =0x4 , -QUERY_DESC_IDN_STRING =0x5 , -QUERY_DESC_IDN_RFU_1 =0x6 , -QUERY_DESC_IDN_GEOMETRY =0x7 , -QUERY_DESC_IDN_POWER =0x8 , -QUERY_DESC_IDN_MAX , -}; -enum desc_header_offset {QUERY_DESC_LENGTH_OFFSET =0x00 ,QUERY_DESC_DESC_TYPE_OFFSET =0x01 ,
@@ -278,19 +260,6 @@ enum bkops_status { BKOPS_STATUS_MAX = BKOPS_STATUS_CRITICAL, }; -/* UTP QUERY Transaction Specific Fields OpCode */ -enum query_opcode { -UPIU_QUERY_OPCODE_NOP =0x0 , -UPIU_QUERY_OPCODE_READ_DESC =0x1 , -UPIU_QUERY_OPCODE_WRITE_DESC =0x2 , -UPIU_QUERY_OPCODE_READ_ATTR =0x3 , -UPIU_QUERY_OPCODE_WRITE_ATTR =0x4 , -UPIU_QUERY_OPCODE_READ_FLAG =0x5 , -UPIU_QUERY_OPCODE_SET_FLAG =0x6 , -UPIU_QUERY_OPCODE_CLEAR_FLAG =0x7 , -UPIU_QUERY_OPCODE_TOGGLE_FLAG =0x8 , -}; -/* Query response result code */ enum {QUERY_RESULT_SUCCESS =0x00 ,
drivers/scsi/ufs/ufshcd.c +207 -1
232 lines not on this page · raw message
include/scsi/scsi.h +1 -0
@@ -284,6 +284,7 @@ static inline int scsi_is_wlun(u64 lun)* Here are some scsi specific ioctl commands which are sometimes useful. * * Note that include/linux/cdrom.h also defines IOCTL 0x5300 - 0x5395 +* include/uapi/scsi/ufs/ioctl.h defines 0x5388 */ /* Used to obtain PUN and LUN info. Conflicts with CDROMAUDIOBUFSIZ */
include/uapi/scsi/Kbuild +1 -0
@@ -1,5 +1,6 @@ # UAPI Header export list header-y += fc/ +header-y += ufs/ header-y += scsi_bsg_fc.h header-y += scsi_netlink.h header-y += scsi_netlink_fc.h
include/uapi/scsi/ufs/Kbuild new file +3 -0
@@ -0,0 +1,3 @@ +# UAPI Header export list +header-y += ioctl.h +header-y += ufs.h
include/uapi/scsi/ufs/ioctl.h new file +58 -0
58 lines not on this page · raw message
include/uapi/scsi/ufs/ufs.h new file +67 -0
67 lines not on this page · raw message
Signature · 4 lines
1.8.5.2 -- QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 9 lines · On Thursday 08 October 2015 14:09:24 Yaniv Gardi wrote:
This patch exposes the ioctl interface for UFS driver via SCSI device ioctl interface. As of now UFS driver would provide the ioctl for query interface to connected UFS device.
Signed-off-by Dolev Raviv <[email protected]>Signed-off-by Noa Rubens <[email protected]>Signed-off-by Raviv Shvili <[email protected]>Signed-off-by Gilad Broner <[email protected]>Signed-off-by Yaniv Gardi <[email protected]>
Thanks for the changes, looks much better already
drivers/scsi/ufs/ufshcd.c static struct scsi_host_template ufshcd_driver_template = { · line 5317
Quoted 11 lines
drivers/scsi/ufs/ufshcd.c +4
-0@@ -5106,6 +5308,10 @@ static struct scsi_host_template ufshcd_driver_template = { .eh_device_reset_handler = ufshcd_eh_device_reset_handler, .eh_host_reset_handler = ufshcd_eh_host_reset_handler, .eh_timed_out = ufshcd_eh_timed_out, + .ioctl = ufshcd_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ufshcd_ioctl, +#endif .this_id =-1 , .sg_tablesize = SG_ALL, .cmd_per_lun = UFSHCD_CMD_PER_LUN,
no need for the #ifdef here.
include/scsi/scsi.h static inline int scsi_is_wlun(u64 lun) · line 289
Quoted 11 lines
include/scsi/scsi.h +1
-0@@ -284,6 +284,7 @@ static inline int scsi_is_wlun(u64 lun)* Here are some scsi specific ioctl commands which are sometimes useful. * * Note that include/linux/cdrom.h also defines IOCTL 0x5300 - 0x5395 +* include/uapi/scsi/ufs/ioctl.h defines 0x5388 */
The comment is now wrong.
Hmm, the buffer now is not aligned to four bytes, which will make copying it a bit slower. If that can be a concern, adding a padding byte would help.
Arnd
thanks Arnd for the comment. V4 is on its way
Quoted 14 lines · On Thursday 08 October 2015 14:09:24 Yaniv Gardi wrote:
Quoted 9 lines
This patch exposes the ioctl interface for UFS driver via SCSI device ioctl interface. As of now UFS driver would provide the ioctl for query interface to connected UFS device.
Signed-off-by Dolev Raviv <[email protected]>Signed-off-by Noa Rubens <[email protected]>Signed-off-by Raviv Shvili <[email protected]>Signed-off-by Gilad Broner <[email protected]>Signed-off-by Yaniv Gardi <[email protected]>Thanks for the changes, looks much better already
Quoted 14 lines
Quoted 11 lines
drivers/scsi/ufs/ufshcd.c +4
-0@@ -5106,6 +5308,10 @@ static struct scsi_host_template ufshcd_driver_template = { .eh_device_reset_handler = ufshcd_eh_device_reset_handler, .eh_host_reset_handler = ufshcd_eh_host_reset_handler, .eh_timed_out = ufshcd_eh_timed_out, + .ioctl = ufshcd_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ufshcd_ioctl, +#endif .this_id =-1 , .sg_tablesize = SG_ALL,Quoted 1 line
.cmd_per_lun =
UFSHCD_CMD_PER_LUN,no need for the #ifdef here.
in include\scsi\scsi_host.h
the hook - compat_ioctl is defined inside #ifdef CONFIG_COMPAT
#ifdef CONFIG_COMPAT int (* compat_ioctl)(struct scsi_device *dev, int cmd, void __user *arg);
#endif
Quoted 28 lines
Quoted 7 lines
include/scsi/scsi.h +0
-0@@ -284,6 +284,7 @@ static inline int scsi_is_wlun(u64 lun)* Here are some scsi specific ioctl commands which are sometimes Quoted 6 lines
useful.
*
* Note thatinclude/linux/cdrom.halso defines IOCTL0x5300-0x5395
+ *include/uapi/scsi/ufs/ioctl.hdefines0x5388
*/The comment is now wrong.
Hmm, the buffer now is not aligned to four bytes, which will make copying it
a bit slower. If that can be a concern, adding a padding byte would help.Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 12 lines · On Sunday 11 October 2015 11:02:34 [email protected]…
Quoted 2 lines
no need for the #ifdef here.
in include\scsi\scsi_host.h
the hook -compat_ioctlis defined inside #ifdefCONFIG_COMPAT#ifdef CONFIG_COMPAT int (* compat_ioctl)(struct scsi_device *dev, int cmd, void __user *arg);#endif
Ah, sorry about that. I saw your v4 before I saw this reply here, and you are right. This is different from the normal file_operations compat_ioctl method that doesn't need the #ifdef.
Arnd