Skip to contentSkip to conversation

scsi: ufs: add ioctl interface for query request

PATCH In review Yaniv Gardi 6 participants 18 messages Mar 9, 2016 – Mar 13, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v7 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/uapi/scsi/Kbuild      |   1 +
 include/uapi/scsi/ufs/Kbuild  |   3 +
 include/uapi/scsi/ufs/ioctl.h |  58 ++++++++++++
 include/uapi/scsi/ufs/ufs.h   |  67 ++++++++++++++
 6 files changed, 347 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
index b291fa6..d39410f 100644
@@ -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,
@@ -279,19 +261,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/uapi/scsi/Kbuild +1 -0
index d791e0a..fad00e0 100644
@@ -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
new file mode 100644
index 0000000..cc3ef20
@@ -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
#1 lore raw
Quoted 8 lines · Yaniv Gardi

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.

What tool is going to use this ioctl? Why does userspcae want to do something "special" with UFS devices? Shouldn't they just be treated like any other normal block device?

thanks,

greg k-h

#2 lore raw
Quoted 5 lines · Yaniv Gardi
Quoted 4 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.

Quoted 9 lines
Quoted 4 lines

What tool is going to use this ioctl? Why does userspcae want to do something "special" with UFS devices? Shouldn't they just be treated like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors. Not only ioctl interface is a useful way to interact with the device, we used it, and found it very helpful in varies cases.
hence, this patch.
This patch has been already addressed all comments of Arnd Bergman from 5 months ago, and now, re-uploaded again.

thanks,
Yaniv

Quoted 8 lines

thanks,

greg k-h
--
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

#8 lore raw
In reply to Greg KH
Quoted 5 lines · Yaniv Gardi
Quoted 4 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.

Quoted 9 lines
Quoted 4 lines

What tool is going to use this ioctl? Why does userspcae want to do something "special" with UFS devices? Shouldn't they just be treated like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors. Not only ioctl interface is a useful way to interact with the device, we used it, and found it very helpful in varies cases.
hence, this patch.
This patch has been already addressed all comments of Arnd Bergman from 5 months ago, and now, re-uploaded again.

thanks,
Yaniv

Quoted 8 lines

thanks,

greg k-h
--
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

#9 lore raw
Quoted 10 lines · On Wed, Mar 09, 2016 at 07:09:49PM -0000, [email protected] wrote:
Quoted 10 lines · Yaniv Gardi
Quoted 8 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.

Quoted 8 lines
Quoted 4 lines

What tool is going to use this ioctl? Why does userspcae want to do something "special" with UFS devices? Shouldn't they just be treated like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors.

But do you want to do with that information? Why does userspace care?

Quoted 2 lines

Not only ioctl interface is a useful way to interact with the device, we used it, and found it very helpful in varies cases.

In what case was it helpful? Why does userspace care about ufs specifics, it should just treat it like any other block device and not care at all.

thanks,

greg k-h

#10 lore raw
Quoted 17 lines · On Wed, Mar 09, 2016 at 07:09:49PM -0000…
Quoted 16 lines
Quoted 3 lines · Yaniv Gardi
Quoted 2 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

Quoted 11 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae want to do something "special" with UFS devices? Shouldn't they just be treated like any other normal block device?

Quoted 6 lines
Quoted 3 lines

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors.

But do you want to do with that information? Why does userspace care?

i don't really understand the subtext of your question -
as ANY ioctl cb, we decided to implement the ioctl callback of this scsi device in order to get information like UNIT DESC, DEVICE DESC, FLAGs, ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?
during development of this driver, it was useful in many cases to be able to communicate with the device, by simple IOCTL command, rather than implementing ad-hock.

regards,
Yaniv

Quoted 11 lines
Quoted 2 lines

Not only ioctl interface is a useful way to interact with the device, we used it, and found it very helpful in varies cases.

In what case was it helpful? Why does userspace care about ufs specifics, it should just treat it like any other block device and not care at all.

thanks,

greg k-h

#11 lore raw
Quoted 24 lines · On Wed, Mar 09, 2016 at 08:52:59PM -0000…
Quoted 17 lines · On Wed, Mar 09, 2016 at 07:09:49PM -0000…
Quoted 16 lines
Quoted 3 lines · Yaniv Gardi
Quoted 2 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

Quoted 11 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae want to do something "special" with UFS devices? Shouldn't they just be treated like any other normal block device?

Quoted 6 lines
Quoted 3 lines

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors.

But do you want to do with that information? Why does userspace care?

Quoted 6 lines

i don't really understand the subtext of your question -
as ANY ioctl cb, we decided to implement the ioctl callback of this scsi device in order to get information like UNIT DESC, DEVICE DESC, FLAGs, ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Why aren't those characteristics just exported as sysfs attributes under control by the UFS controller driver? Why do you need/want an ioctl for this?

Quoted 3 lines

during development of this driver, it was useful in many cases to be able to communicate with the device, by simple IOCTL command, rather than implementing ad-hock.

Do other storage busses have these types of "custom" ioctls for their bus-type alone? For simple attributes like this, shouldn't you be using sysfs instead so that it is much easier for userspace tools to get access to them?

thanks,

greg k-h

#12 lore raw
Quoted 36 lines · On Wed, Mar 09, 2016 at 08:52:59PM -0000, [email protected] wrote:
Quoted 28 lines
Quoted 3 lines · On Wed, Mar 09, 2016 at 07:09:49PM -0000, [email protected] wrote:
Quoted 2 lines
Quoted 2 lines · Yaniv Gardi
Quoted 1 line

This patch exposes the ioctl interface for UFS driver via SCSI

device

Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line

ioctl interface. As of now UFS driver would provide the ioctl for

query

Quoted 8 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae want to

do

Quoted 1 line
Quoted 1 line
Quoted 1 line

something "special" with UFS devices? Shouldn't they just be

treated

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and

descriptors.

Quoted 3 lines

But do you want to do with that information? Why does userspace care?

Quoted 6 lines

i don't really understand the subtext of your question -
as ANY ioctl cb, we decided to implement the ioctl callback of this scsi device in order to get information like UNIT DESC, DEVICE DESC, FLAGs, ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Quoted 4 lines

Why aren't those characteristics just exported as sysfs attributes under control by the UFS controller driver? Why do you need/want an ioctl for this?

Hi greg k-h,

in our code, we used the IOCTL during runtime, in order to determine some information about the RPMB well known lun.
with the rpmb lun ID we could then go to /dev/sgX and issue UFS_IOCTL_QUERY to this lun and get the data -
reading the QUERY_DESC_IDN_GEOMETRY descriptor and reading the QUERY_DESC_IDN_UNIT descriptor.

this was crucial to the work we do in RPMB.

thanks,
Yaniv

Quoted 14 lines
Quoted 4 lines

during development of this driver, it was useful in many cases to be able
to communicate with the device, by simple IOCTL command, rather than implementing ad-hock.

Do other storage busses have these types of "custom" ioctls for their bus-type alone? For simple attributes like this, shouldn't you be using sysfs instead so that it is much easier for userspace tools to get access to them?

thanks,

greg k-h

#13 lore raw
Quoted 43 lines · On Thu, Mar 10, 2016 at 03:52:54PM -0000…
Quoted 36 lines · On Wed, Mar 09, 2016 at 08:52:59PM -0000…
Quoted 28 lines
Quoted 3 lines · On Wed, Mar 09, 2016 at 07:09:49PM -0000…
Quoted 2 lines
Quoted 2 lines · Yaniv Gardi
Quoted 1 line

This patch exposes the ioctl interface for UFS driver via SCSI

device

Quoted 10 lines
Quoted 10 lines
Quoted 1 line
Quoted 1 line

ioctl interface. As of now UFS driver would provide the ioctl for

query

Quoted 8 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae want to

do

Quoted 1 line
Quoted 1 line
Quoted 1 line

something "special" with UFS devices? Shouldn't they just be

treated

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and

descriptors.

Quoted 3 lines

But do you want to do with that information? Why does userspace care?

Quoted 6 lines

i don't really understand the subtext of your question -
as ANY ioctl cb, we decided to implement the ioctl callback of this scsi device in order to get information like UNIT DESC, DEVICE DESC, FLAGs, ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Quoted 4 lines

Why aren't those characteristics just exported as sysfs attributes under control by the UFS controller driver? Why do you need/want an ioctl for this?

Hi greg k-h,

Quoted 8 lines

in our code, we used the IOCTL during runtime, in order to determine some information about the RPMB well known lun.
with the rpmb lun ID we could then go to /dev/sgX and issue UFS_IOCTL_QUERY to this lun and get the data -
reading the QUERY_DESC_IDN_GEOMETRY descriptor and reading the QUERY_DESC_IDN_UNIT descriptor.

this was crucial to the work we do in RPMB.

What is RPMB?

And again, why not just use sysfs attributes on your host controller device? Why does this have to be a custom ioctl?

greg k-h

#14 lore raw
Quoted 61 lines · On Thu, Mar 10, 2016 at 03:52:54PM -0000, [email protected] wrote:
Quoted 60 lines
Quoted 2 lines · On Wed, Mar 09, 2016 at 08:52:59PM -0000, [email protected] wrote:
Quoted 1 line
Quoted 1 line

On Wed, Mar 09, 2016 at 07:09:49PM -0000, [email protected]

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Yaniv Gardi
Quoted 1 line

This patch exposes the ioctl interface for UFS driver via SCSI

device

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioctl interface. As of now UFS driver would provide the ioctl

for

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

query

Quoted 8 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae want

to

Quoted 8 lines
Quoted 8 lines

do

Quoted 1 line
Quoted 1 line
Quoted 1 line

something "special" with UFS devices? Shouldn't they just be

treated

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that

sent

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

queries to the UFS devices in order to get information and

descriptors.

Quoted 2 lines

But do you want to do with that information? Why does userspace

care?

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

i don't really understand the subtext of your question - as ANY ioctl cb, we decided to implement the ioctl callback of this

scsi

Quoted 1 line
Quoted 1 line

device in order to get information like UNIT DESC, DEVICE DESC,

FLAGs,

Quoted 5 lines
Quoted 3 lines

ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Why aren't those characteristics just exported as sysfs attributes

under

Quoted 1 line

control by the UFS controller driver? Why do you need/want an ioctl

for

Quoted 2 lines

this?

Hi greg k-h,

in our code, we used the IOCTL during runtime, in order to determine some
information about the RPMB well known lun.
with the rpmb lun ID we could then go to /dev/sgX and issue UFS_IOCTL_QUERY to this lun and get the data -
reading the QUERY_DESC_IDN_GEOMETRY descriptor and reading the QUERY_DESC_IDN_UNIT descriptor.

Quoted 9 lines
Quoted 1 line

this was crucial to the work we do in RPMB.

What is RPMB?

And again, why not just use sysfs attributes on your host controller device? Why does this have to be a custom ioctl?

greg k-h

RPMB is spcial Logical Unit in the UFS device. you can read about it in the UFS spec. Greg, you are insisting on sysfs, but i can't implement it now, as i don't have the Hardware anymore, or the time.

This is a tested and verified code that was accepted and reviewed already, so i'm not sure what is wrong with this solution, not to say, it's already implemented, tested and verified.
hope you are help us push it.

thanks,
Yaniv

#15 lore raw
Quoted 68 lines · On Thu, Mar 10, 2016 at 04:29:55PM -0000, [email protected] wrote:
Quoted 68 lines · On Thu, Mar 10, 2016 at 03:52:54PM -0000, [email protected] wrote:
Quoted 60 lines
Quoted 2 lines · On Wed, Mar 09, 2016 at 08:52:59PM -0000, [email protected] wrote:
Quoted 1 line
Quoted 1 line

On Wed, Mar 09, 2016 at 07:09:49PM -0000, [email protected]

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Yaniv Gardi
Quoted 1 line

This patch exposes the ioctl interface for UFS driver via SCSI

device

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioctl interface. As of now UFS driver would provide the ioctl

for

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

query

Quoted 8 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae want

to

Quoted 8 lines
Quoted 8 lines

do

Quoted 1 line
Quoted 1 line
Quoted 1 line

something "special" with UFS devices? Shouldn't they just be

treated

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that

sent

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

queries to the UFS devices in order to get information and

descriptors.

Quoted 2 lines

But do you want to do with that information? Why does userspace

care?

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

i don't really understand the subtext of your question - as ANY ioctl cb, we decided to implement the ioctl callback of this

scsi

Quoted 1 line
Quoted 1 line

device in order to get information like UNIT DESC, DEVICE DESC,

FLAGs,

Quoted 5 lines
Quoted 3 lines

ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Why aren't those characteristics just exported as sysfs attributes

under

Quoted 1 line

control by the UFS controller driver? Why do you need/want an ioctl

for

Quoted 2 lines

this?

Hi greg k-h,

in our code, we used the IOCTL during runtime, in order to determine some
information about the RPMB well known lun.
with the rpmb lun ID we could then go to /dev/sgX and issue UFS_IOCTL_QUERY to this lun and get the data -
reading the QUERY_DESC_IDN_GEOMETRY descriptor and reading the QUERY_DESC_IDN_UNIT descriptor.

Quoted 1 line

this was crucial to the work we do in RPMB.

What is RPMB?

And again, why not just use sysfs attributes on your host controller device? Why does this have to be a custom ioctl?

Quoted 6 lines
Quoted 2 lines

greg k-h

RPMB is spcial Logical Unit in the UFS device. you can read about it in the UFS spec. Greg, you are insisting on sysfs, but i can't implement it now, as i don't have the Hardware anymore, or the time.

If you don't have the hardware, how are you testing this patch?

And if you don't have the hardware I guess you don't need this change :)

Quoted 4 lines

This is a tested and verified code that was accepted and reviewed already, so i'm not sure what is wrong with this solution, not to say, it's already implemented, tested and verified.
hope you are help us push it.

That's a horrible reason to merge a patch that someone else is going to have to support for 20+ years with an api that doesn't make much sense.

If you don't have the hardware, then this isn't needed. But if you do, then please look into using sysfs for this, as I think that should be the correct interface here, again, not some random ioctl.

greg k-h

#3 lore raw
In reply to [email protected]
Quoted 8 lines · On Wednesday 09 March 2016, [email protected] wrote:

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors. Not only ioctl interface is a useful way to interact with the device, we used it, and found it very helpful in varies cases.
hence, this patch.
This patch has been already addressed all comments of Arnd Bergman from 5 months ago, and now, re-uploaded again.

Do you have a pointer to that review? It's been a long while, so I have completely forgotten what issues I raised and how it got resolved.

Arnd

#16 lore raw
In reply to Greg KH
Quoted 75 lines · On Thu, Mar 10, 2016 at 04:29:55PM -0000…
Quoted 74 lines
Quoted 2 lines · On Thu, Mar 10, 2016 at 03:52:54PM -0000…
Quoted 1 line
Quoted 1 line

On Wed, Mar 09, 2016 at 08:52:59PM -0000, [email protected]

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Wed, Mar 09, 2016 at 07:09:49PM -0000, [email protected]

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Yaniv Gardi
Quoted 1 line

This patch exposes the ioctl interface for UFS driver via

SCSI

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

device

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioctl interface. As of now UFS driver would provide the

ioctl

Quoted 10 lines
Quoted 10 lines

for

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

query

Quoted 8 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae

want

Quoted 11 lines
Quoted 11 lines

to

Quoted 8 lines
Quoted 8 lines

do

Quoted 1 line
Quoted 1 line
Quoted 1 line

something "special" with UFS devices? Shouldn't they just be

treated

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that

sent

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

queries to the UFS devices in order to get information and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

descriptors.

Quoted 2 lines

But do you want to do with that information? Why does userspace

care?

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

i don't really understand the subtext of your question - as ANY ioctl cb, we decided to implement the ioctl callback of

this

Quoted 10 lines
Quoted 10 lines

scsi

Quoted 1 line
Quoted 1 line

device in order to get information like UNIT DESC, DEVICE DESC,

FLAGs,

Quoted 5 lines
Quoted 3 lines

ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Why aren't those characteristics just exported as sysfs attributes

under

Quoted 1 line

control by the UFS controller driver? Why do you need/want an

ioctl

Quoted 21 lines
Quoted 14 lines

for

Quoted 2 lines

this?

Hi greg k-h,

in our code, we used the IOCTL during runtime, in order to determine some
information about the RPMB well known lun.
with the rpmb lun ID we could then go to /dev/sgX and issue UFS_IOCTL_QUERY to this lun and get the data -
reading the QUERY_DESC_IDN_GEOMETRY descriptor and reading the QUERY_DESC_IDN_UNIT descriptor.

Quoted 1 line

this was crucial to the work we do in RPMB.

What is RPMB?

And again, why not just use sysfs attributes on your host controller device? Why does this have to be a custom ioctl?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

greg k-h

RPMB is spcial Logical Unit in the UFS device. you can read about it in the UFS spec. Greg, you are insisting on sysfs, but i can't implement it now, as i don't have the Hardware anymore, or the time.

If you don't have the hardware, how are you testing this patch?

This patch is already tested and verified, and also was much helpful during development.
Also, this patch is a few months old and was tested when previous version were uploaded.
Currently HW is not available.

Quoted 10 lines

And if you don't have the hardware I guess you don't need this change :)

Quoted 6 lines

This is a tested and verified code that was accepted and reviewed already,
so i'm not sure what is wrong with this solution, not to say, it's already
implemented, tested and verified.
hope you are help us push it.

Quoted 4 lines

That's a horrible reason to merge a patch that someone else is going to have to support for 20+ years with an api that doesn't make much sense.

If you don't have the hardware, then this isn't needed. But if you do,

Even if currently HW is not available it doesn't mean this is not needed in the future again.

Quoted 3 lines

then please look into using sysfs for this, as I think that should be the correct interface here, again, not some random ioctl.

Why sysfs makes more sense than this one ?

Quoted 2 lines

greg k-h

#17 lore raw
Quoted 99 lines · On Thu, Mar 10, 2016 at 06:48:54PM -0000, [email protected] wrote:
Quoted 75 lines · On Thu, Mar 10, 2016 at 04:29:55PM -0000, [email protected] wrote:
Quoted 74 lines
Quoted 2 lines · On Thu, Mar 10, 2016 at 03:52:54PM -0000, [email protected] wrote:
Quoted 1 line
Quoted 1 line

On Wed, Mar 09, 2016 at 08:52:59PM -0000, [email protected]

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Wed, Mar 09, 2016 at 07:09:49PM -0000, [email protected]

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines · Yaniv Gardi
Quoted 1 line

This patch exposes the ioctl interface for UFS driver via

SCSI

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

device

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioctl interface. As of now UFS driver would provide the

ioctl

Quoted 10 lines
Quoted 10 lines

for

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

query

Quoted 8 lines
Quoted 6 lines

interface to connected UFS device.

What tool is going to use this ioctl? Why does userspcae

want

Quoted 11 lines
Quoted 11 lines

to

Quoted 8 lines
Quoted 8 lines

do

Quoted 1 line
Quoted 1 line
Quoted 1 line

something "special" with UFS devices? Shouldn't they just be

treated

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

like any other normal block device?

Any userspace application can be a tool.
We already implemented and used a user space application, that

sent

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

queries to the UFS devices in order to get information and

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

descriptors.

Quoted 2 lines

But do you want to do with that information? Why does userspace

care?

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

i don't really understand the subtext of your question - as ANY ioctl cb, we decided to implement the ioctl callback of

this

Quoted 10 lines
Quoted 10 lines

scsi

Quoted 1 line
Quoted 1 line

device in order to get information like UNIT DESC, DEVICE DESC,

FLAGs,

Quoted 5 lines
Quoted 3 lines

ATTRIBUTES.
When dealing with UFS devices, one should be able to read the characteristics of the device. why ? well, why not ?

Why aren't those characteristics just exported as sysfs attributes

under

Quoted 1 line

control by the UFS controller driver? Why do you need/want an

ioctl

Quoted 21 lines
Quoted 14 lines

for

Quoted 2 lines

this?

Hi greg k-h,

in our code, we used the IOCTL during runtime, in order to determine some
information about the RPMB well known lun.
with the rpmb lun ID we could then go to /dev/sgX and issue UFS_IOCTL_QUERY to this lun and get the data -
reading the QUERY_DESC_IDN_GEOMETRY descriptor and reading the QUERY_DESC_IDN_UNIT descriptor.

Quoted 1 line

this was crucial to the work we do in RPMB.

What is RPMB?

And again, why not just use sysfs attributes on your host controller device? Why does this have to be a custom ioctl?

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

greg k-h

RPMB is spcial Logical Unit in the UFS device. you can read about it in the UFS spec. Greg, you are insisting on sysfs, but i can't implement it now, as i don't have the Hardware anymore, or the time.

If you don't have the hardware, how are you testing this patch?

This patch is already tested and verified, and also was much helpful during development.
Also, this patch is a few months old and was tested when previous version were uploaded.
Currently HW is not available.

Quoted 10 lines

And if you don't have the hardware I guess you don't need this change :)

Quoted 6 lines

This is a tested and verified code that was accepted and reviewed already,
so i'm not sure what is wrong with this solution, not to say, it's already
implemented, tested and verified.
hope you are help us push it.

Quoted 7 lines
Quoted 4 lines

That's a horrible reason to merge a patch that someone else is going to have to support for 20+ years with an api that doesn't make much sense.

If you don't have the hardware, then this isn't needed. But if you do,

Even if currently HW is not available it doesn't mean this is not needed in the future again.

Great, if in the future, you need this again, please resubmit it. Adding code to the kernel for no real user is a maintaince burden on others. Please don't do that. Especially for an API that is now required to be supported for forever.

Quoted 5 lines
Quoted 3 lines

then please look into using sysfs for this, as I think that should be the correct interface here, again, not some random ioctl.

Why sysfs makes more sense than this one ?

Why doesn't it? Why would an ioctl make sense to get simple attributes from a host controller? Why not use the interface that makes it trivial to use from userspace that other drivers already use in this type of situation.

In other words, why do you have to have this ioctl? What requires this to be the way the API works?

But again, as you don't need this code, let's just drop it. Feel free to revisit it sometime in the future if you ever get hardware and need this again.

thanks,

greg k-h

#4 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 09 March 2016, [email protected]…

Any userspace application can be a tool.
We already implemented and used a user space application, that sent queries to the UFS devices in order to get information and descriptors. Not only ioctl interface is a useful way to interact with the device, we used it, and found it very helpful in varies cases.
hence, this patch.
This patch has been already addressed all comments of Arnd Bergman from 5 months ago, and now, re-uploaded again.

Quoted 2 lines

Do you have a pointer to that review? It's been a long while, so I have completely forgotten what issues I raised and how it got resolved.

I got your link in private message and read up on it again now.

To clarify: I commented on the formal API definition, and you indeed addressed all my concerns, so this is now an ioctl command that follows our usual calling conventions.

However, this is orthogonal to the question of whether it is a good idea to have this interface implemented as an ioctl as asked by Greg, and who is actually using it.

I'm lacking the detailed subsystem knowledge to answer this, but I note that other block drivers have similar passthrough interfaces.

Looking through what other drivers do, I've found a couple of patterns now. n particular, most use the SG_IO ioctl to pass down commands from user space into a device specific command queue. Have you looked at that interface in the past to see if it would fit your use case?

There is also a 'bsg' API that some drivers implement, which I think would be another alternative.

Could any of the SCSI experts comment on what they expect a driver to use out of those three alternatives (if any):

* private ioctl
* bsg
* sg_io

Arnd

#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnd" == Arnd Bergmann <[email protected]> writes:

Arnd> Looking through what other drivers do, I've found a couple of Arnd> patterns now. n particular, most use the SG_IO ioctl to pass down Arnd> commands from user space into a device specific command Arnd> queue. Have you looked at that interface in the past to see if it Arnd> would fit your use case?

Arnd> There is also a 'bsg' API that some drivers implement, which I Arnd> think would be another alternative.

Arnd> Could any of the SCSI experts comment on what they expect a driver Arnd> to use out of those three alternatives (if any):

My preference is that if you want to expose any information that a user or admin would care about, put it in sysfs where it is easily accessible and can be scripted.

For things that need to directly send commands to the hardware (to configure vendor specific settings or inspect parameters for development purposes) use the sg or bsg interfaces like we do for both ATA and SCSI. bsg is newer and supports more features like bidirectional commands. But for this particular use case I don't think it offers any particular advantages over SG_IO. Both interfaces take the same descriptors so it really doesn't matter much.

See:

	http://sg.danny.cz/sg/
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#6 lore raw
Quoted 26 lines · Martin K. Petersen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnd" == Arnd Bergmann <[email protected]> writes:

Arnd> Looking through what other drivers do, I've found a couple of Arnd> patterns now. n particular, most use the SG_IO ioctl to pass down Arnd> commands from user space into a device specific command Arnd> queue. Have you looked at that interface in the past to see if it Arnd> would fit your use case?

Arnd> There is also a 'bsg' API that some drivers implement, which I Arnd> think would be another alternative.

Arnd> Could any of the SCSI experts comment on what they expect a driver Arnd> to use out of those three alternatives (if any):

My preference is that if you want to expose any information that a user or admin would care about, put it in sysfs where it is easily accessible and can be scripted.

For things that need to directly send commands to the hardware (to configure vendor specific settings or inspect parameters for development purposes) use the sg or bsg interfaces like we do for both ATA and SCSI. bsg is newer and supports more features like bidirectional commands. But for this particular use case I don't think it offers any particular advantages over SG_IO. Both interfaces take the same descriptors so it really doesn't matter much.

Quoted 4 lines

See:

	http://sg.danny.cz/sg/

And indeed I would expose this 'special' UFS RPMB as a 'generic' SCSI device and add the required fields in sysfs, much like Greg KH suggested.
Plus adding a 'bsg' interface for sending 'raw' UFS commands sounds much more appealing; that's what we do for SAS and FC, too.

But then, none of the above can be done if there is no hardware available. At the same time, you wouldn't be able to test any proposed fixes to the original ioctl patch.
So I guess you'll have to retract this patch or get hold of the hardware to actually _test_ something there.

Or send me some, I'll be happy to help out here :-)

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
#7 lore raw
Quoted 38 lines · Martin K. Petersen
Quoted 26 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnd" == Arnd Bergmann <[email protected]> writes:

Arnd> Looking through what other drivers do, I've found a couple of Arnd> patterns now. n particular, most use the SG_IO ioctl to pass down Arnd> commands from user space into a device specific command Arnd> queue. Have you looked at that interface in the past to see if it Arnd> would fit your use case?

Arnd> There is also a 'bsg' API that some drivers implement, which I Arnd> think would be another alternative.

Arnd> Could any of the SCSI experts comment on what they expect a driver Arnd> to use out of those three alternatives (if any):

My preference is that if you want to expose any information that a user or admin would care about, put it in sysfs where it is easily accessible and can be scripted.

For things that need to directly send commands to the hardware (to configure vendor specific settings or inspect parameters for development purposes) use the sg or bsg interfaces like we do for both ATA and SCSI. bsg is newer and supports more features like bidirectional commands. But for this particular use case I don't think it offers any particular advantages over SG_IO. Both interfaces take the same descriptors so it really doesn't matter much.

Quoted 4 lines

See:

	http://sg.danny.cz/sg/

And indeed I would expose this 'special' UFS RPMB as a 'generic' SCSI device and add the required fields in sysfs, much like Greg KH suggested.
Plus adding a 'bsg' interface for sending 'raw' UFS commands sounds much more appealing; that's what we do for SAS and FC, too.

Quoted 8 lines

But then, none of the above can be done if there is no hardware available. At the same time, you wouldn't be able to test any proposed fixes to the original ioctl patch.
So I guess you'll have to retract this patch or get hold of the hardware to actually _test_ something there.

Or send me some, I'll be happy to help out here :-)

I will submit proposal or new RPMB layer for both UFS and EMMC
It also sports IOCTL interface, similar and replacing to mmc_ioc_cmd which is also used to access RPMB partition on emmc.
Blocks of 512 bytes has to be transferred back and force so sysfs API is not good enough. RPMB partition is not suitable to be accessed via block layer. I've tried going via SICSI generic layers, it is a bit awkward as the protocol is very UFS specific. Currently I have working solution for both EMMC and UFS2.0.

Thanks
Tomas