Skip to contentSkip to conversation

scsi: ufs: Platform and Query updates

PATCH In review Santosh Y 4 participants 8 messages May 2, 2013 – May 6, 2013 SCSI

lore
Share & tools
lore

Santosh Y

author
#0 lore raw

cover scsi: ufs: Platform and Query updates

Hi James,

Please merge the following patches to scsi tree.

Thanks,
Santosh

Dolev Raviv (1):
scsi: ufs: add support for query requests

Vinayak Holikatti (2):
ufs: Add Platform glue driver for ufshcd
ufs: Correct the expected data transfersize

 drivers/scsi/ufs/Kconfig         |  12 ++
 drivers/scsi/ufs/Makefile        |   1 +
 drivers/scsi/ufs/ufs.h           | 122 ++++++++++-
 drivers/scsi/ufs/ufshcd-pltfrm.c | 217 +++++++++++++++++++
 drivers/scsi/ufs/ufshcd.c        | 443 +++++++++++++++++++++++++++++++--------
 drivers/scsi/ufs/ufshcd.h        |  22 +-
 drivers/scsi/ufs/ufshci.h        |   2 +-
 7 files changed, 717 insertions(+), 102 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH 1/3 ufs: Add Platform glue driver for ufshcd

From: Vinayak Holikatti <[email protected]>

This patch adds Platform glue driver for ufshcd.

drivers/scsi/ufs/Kconfig +11 -0
index 0371047..35faf24 100644
@@ -57,3 +57,14 @@ config SCSI_UFSHCD_PCI
 	  If you have a controller with this interface, say Y or M here.
 
 	  If unsure, say N.
+
+config SCSI_UFSHCD_PLATFORM
+	tristate "Platform bus based UFS Controller support"
+	depends on SCSI_UFSHCD
+	---help---
+	This selects the UFS host controller support. Select this if
+	you have an UFS controller on Platform bus.
+
+	If you have a controller with this interface, say Y or M here.
+
+	  If unsure, say N.
drivers/scsi/ufs/Makefile +1 -0
index 9eda0df..1e5bd48 100644
@@ -1,3 +1,4 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
drivers/scsi/ufs/ufshcd-pltfrm.c new file +217 -0

217 lines not on this page · raw message

Signature · 1 line
1.8.1.2
author
#2 lore raw

PATCH 2/3 ufs: Correct the expected data transfersize

In reply to Santosh Y

From: Vinayak Holikatti <[email protected]>

This patch corrects the expected data transfer size of the command UPIU. The current implementation of cmd->transfersize is wrong as it probably equal to sector size. With this implementation the transfer size is updated correctly

drivers/scsi/ufs/ufshcd.c +1 -1
index 60fd40c..c32a478 100644
@@ -478,7 +478,7 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
 		ucd_cmd_ptr->header.dword_2 = 0;
 
 		ucd_cmd_ptr->exp_data_transfer_len =
-			cpu_to_be32(lrbp->cmd->transfersize);
+			cpu_to_be32(lrbp->cmd->sdb.length);
 
 		memcpy(ucd_cmd_ptr->cdb,
 		       lrbp->cmd->cmnd,
Signature · 1 line
1.8.1.2
author
#3 lore raw

PATCH 3/3 scsi: ufs: add support for query requests

In reply to Santosh Y

From: Dolev Raviv <[email protected]>

Add support for sending UFS query requests through tagged command queuing. This design allows queuing query requests in any open slot along with other SCSI commands. In this way there is no need to save a slot in the requests queue and decrease its size.

A query request is posing to a SCSI command to use native flow. But unlike normal SCSI command flow, the data and response fields are filled in UFS host data structure instead of passing as arguments while queuing into SCSI mlqueue (mid-layer SCSI queue, the requests from this queue are submitted to the device queue). As per specification only one query request is allowed to be processed by device. Hence a mutex lock for protecting data and response fields (hba->query.request and hba->query.response) needs to be held while query request is in progress.

The API for submitting a query request is ufs_query_request() in ufshcd.c. This function is responsible for:
1. Obtaining the SCSI device from the host
2. Keeping the query mutex to prevent multiple queries
3. Storing the required data for sending a query request in ufs_hba
4. Queuing a SCSI vendor specific command to trigger a query request in the UFS driver.

The callers of ufs_query_request() are expected to fill the query command data fields and are to provide an allocated response field for the driver to fill response fields after request completion.

The request and response upiu is extended in a union to enable using the same data structure, both for command upiu and query request upiu.

The query request flow is separated from the scsi command flow in:
1. Preparing the request
2. Validating response (error) codes
3. Copying data (only used for descriptor read/write query requests)
4. Copying response/sense

Data error can't be handled in the scsi command native flow. Hence, we pass the code as without a change back to the submitting layer.

UPIU (UFS Protocol Information Unit) size is increased to 512 bytes from 128. The UPIU header and the transaction specific fields (SCSI command or Query Request OSF - Op-code Specific Fields) are 32 bytes together, the rest is used to transfer extra request data (such as descriptor in query requests). In order to accommodate the largest descriptor in the UFS spec (256 bytes) we need to increase the UPIU size.

drivers/scsi/ufs/Kconfig +1 -0
index 35faf24..82417d6 100644
@@ -35,6 +35,7 @@
 config SCSI_UFSHCD
 	tristate "Universal Flash Storage Controller Driver Core"
 	depends on SCSI
+	default y
 	---help---
 	This selects the support for UFS devices in Linux, say Y and make
 	  sure that you know the name of your UFS host adapter (the card
drivers/scsi/ufs/ufs.h +114 -8

195 lines not on this page · raw message

drivers/scsi/ufs/ufshcd.c +352 -91

534 lines not on this page · raw message

drivers/scsi/ufs/ufshcd.h +20 -2
index 6b99a42..336980b 100644
@@ -60,6 +60,7 @@
 #include <scsi/scsi_tcq.h>
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_eh.h>
+#include <scsi/scsi_device.h>
 
 #include "ufs.h"
 #include "ufshci.h"
@@ -88,7 +89,7 @@ struct uic_command {
 /**
  * struct ufshcd_lrb - local reference block
  * @utr_descriptor_ptr: UTRD address of the command
- * @ucd_cmd_ptr: UCD address of the command
+ * @ucd_req_ptr: UCD address of the command
  * @ucd_rsp_ptr: Response UPIU address for this command
  * @ucd_prdt_ptr: PRDT address of the command
  * @cmd: pointer to SCSI command
@@ -101,7 +102,7 @@ struct uic_command {
  */
 struct ufshcd_lrb {
 	struct utp_transfer_req_desc *utr_descriptor_ptr;
-	struct utp_upiu_cmd *ucd_cmd_ptr;
+	struct utp_upiu_req *ucd_req_ptr;
 	struct utp_upiu_rsp *ucd_rsp_ptr;
 	struct ufshcd_sg_entry *ucd_prdt_ptr;
 
@@ -115,6 +116,19 @@ struct ufshcd_lrb {
 	unsigned int lun;
 };
 
+/**
+ * struct ufs_query - keeps the query request information
+ * @request: request upiu and function
+ * @descriptor: buffer for sending/receiving descriptor
+ * @response: response upiu and response
+ * @mutex: lock to allow one query at a time
+ */
+struct ufs_query {
+	struct ufs_query_req *request;
+	u8 *descriptor;
+	struct ufs_query_res *response;
+	struct mutex lock_ufs_query;
+};
 
 /**
  * struct ufs_hba - per adapter private structure
@@ -143,6 +157,7 @@ struct ufshcd_lrb {
  * @uic_workq: Work queue for UIC completion handling
  * @feh_workq: Work queue for fatal controller error handling
  * @errors: HBA errors
+ * @query: query request information
  */
 struct ufs_hba {
 	void __iomem *mmio_base;
@@ -184,6 +199,9 @@ struct ufs_hba {
 
 	/* HBA Errors */
 	u32 errors;
+
+	/* Query Request */
+	struct ufs_query query;
 };
 
 int ufshcd_init(struct device *, struct ufs_hba ** , void __iomem * ,
drivers/scsi/ufs/ufshci.h +1 -1
index 0c16484..4a86247 100644
@@ -39,7 +39,7 @@
 enum {
 	TASK_REQ_UPIU_SIZE_DWORDS	= 8,
 	TASK_RSP_UPIU_SIZE_DWORDS	= 8,
-	ALIGNED_UPIU_SIZE		= 128,
+	ALIGNED_UPIU_SIZE		= 512,
 };
 
 /* UFSHCI Registers */
Signature · 1 line
1.8.1.2
maintainer
#4 lore raw

Re: [PATCH 3/3] scsi: ufs: add support for query requests

Quoted 57 lines · Santosh Y

From: Dolev Raviv <[email protected]>

Add support for sending UFS query requests through tagged command queuing. This design allows queuing query requests in any open slot along with other SCSI commands. In this way there is no need to save a slot in the requests queue and decrease its size.

A query request is posing to a SCSI command to use native flow. But unlike normal SCSI command flow, the data and response fields are filled in UFS host data structure instead of passing as arguments while queuing into SCSI mlqueue (mid-layer SCSI queue, the requests from this queue are submitted to the device queue). As per specification only one query request is allowed to be processed by device. Hence a mutex lock for protecting data and response fields (hba->query.request and hba->query.response) needs to be held while query request is in progress.

The API for submitting a query request is ufs_query_request() in ufshcd.c. This function is responsible for:
1. Obtaining the SCSI device from the host
2. Keeping the query mutex to prevent multiple queries
3. Storing the required data for sending a query request in ufs_hba
4. Queuing a SCSI vendor specific command to trigger a query request in the UFS driver.

The callers of ufs_query_request() are expected to fill the query command data fields and are to provide an allocated response field for the driver to fill response fields after request completion.

The request and response upiu is extended in a union to enable using the same data structure, both for command upiu and query request upiu.

The query request flow is separated from the scsi command flow in:
1. Preparing the request
2. Validating response (error) codes
3. Copying data (only used for descriptor read/write query requests)
4. Copying response/sense

Data error can't be handled in the scsi command native flow. Hence, we pass the code as without a change back to the submitting layer.

UPIU (UFS Protocol Information Unit) size is increased to 512 bytes from 128. The UPIU header and the transaction specific fields (SCSI command or Query Request OSF - Op-code Specific Fields) are 32 bytes together, the rest is used to transfer extra request data (such as descriptor in query requests). In order to accommodate the largest descriptor in the UFS spec (256 bytes) we need to increase the UPIU size.

drivers/scsi/ufs/Kconfig +0 -0
index 35faf24..82417d6 100644

drivers/scsi/ufs/Kconfig line 41

Quoted 7 lines
drivers/scsi/ufs/Kconfig +1 -0
@@ -35,6 +35,7 @@
 config SCSI_UFSHCD
 	tristate "Universal Flash Storage Controller Driver Core"
 	depends on SCSI
+	default y
 	---help---
 	This selects the support for UFS devices in Linux, say Y and make
 	  sure that you know the name of your UFS host adapter (the card

I don't think you want to force this on in every configuration since it's only appropriate to non server/desktop. I stripped this hunk.

James

#5 lore raw

Re: [PATCH 3/3] scsi: ufs: add support for query requests

Hi James,
I've noticed you haven't merged this patch.
To avoid further problems I resent a V5 to this patch removing the Kconfig change.

Dolev

Quoted 78 lines · Santosh Y
Quoted 58 lines

From: Dolev Raviv <[email protected]>

Add support for sending UFS query requests through tagged command queuing. This design allows queuing query requests in any open slot along with other SCSI commands. In this way there is no need to save a slot in the requests queue and decrease its size.

A query request is posing to a SCSI command to use native flow. But unlike normal SCSI command flow, the data and response fields are filled in UFS host data structure instead of passing as arguments while queuing into SCSI mlqueue (mid-layer SCSI queue, the requests from this queue are submitted to the device queue). As per specification only one query request is allowed to be processed by device. Hence a mutex lock for protecting data and response fields (hba->query.request and
hba->query.response) needs to be held while query request is in progress.

The API for submitting a query request is ufs_query_request() in ufshcd.c. This function is responsible for:
1. Obtaining the SCSI device from the host
2. Keeping the query mutex to prevent multiple queries
3. Storing the required data for sending a query request in ufs_hba
4. Queuing a SCSI vendor specific command to trigger a query request in the UFS driver.

The callers of ufs_query_request() are expected to fill the query command data fields and are to provide an allocated response field for the driver to fill response fields after request completion.

The request and response upiu is extended in a union to enable using the same data structure, both for command upiu and query request upiu.

The query request flow is separated from the scsi command flow in:
1. Preparing the request
2. Validating response (error) codes
3. Copying data (only used for descriptor read/write query requests)
4. Copying response/sense

Data error can't be handled in the scsi command native flow. Hence, we pass the code as without a change back to the submitting layer.

UPIU (UFS Protocol Information Unit) size is increased to 512 bytes from 128. The UPIU header and the transaction specific fields (SCSI command or Query Request OSF - Op-code Specific Fields) are 32 bytes together, the rest is used to transfer extra request data (such as descriptor in query requests). In order to accommodate the largest descriptor in the UFS spec (256 bytes) we need to increase the UPIU size.

drivers/scsi/ufs/Kconfig +0 -0
index 35faf24..82417d6 100644

drivers/scsi/ufs/Kconfig line 41

Quoted 7 lines
drivers/scsi/ufs/Kconfig +1 -0
@@ -35,6 +35,7 @@
 config SCSI_UFSHCD
 	tristate "Universal Flash Storage Controller Driver Core"
 	depends on SCSI
+	default y
 	---help---
 	This selects the support for UFS devices in Linux, say Y and make
 	  sure that you know the name of your UFS host adapter (the card

I don't think you want to force this on in every configuration since it's only appropriate to non server/desktop. I stripped this hunk.

James

--
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

Signature · 2 lines
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
author
#6 lore raw

Re: [PATCH 3/3] scsi: ufs: add support for query requests

In reply to James Bottomley
Quoted 7 lines
Quoted 7 lines
drivers/scsi/ufs/Kconfig +0 -0
index 35faf24..82417d6 100644
@@ -35,6 +35,7 @@
 config SCSI_UFSHCD
      tristate "Universal Flash Storage Controller Driver Core"
Quoted 9 lines

drivers/scsi/ufs/Kconfig line 41

Quoted 5 lines
drivers/scsi/ufs/Kconfig +1 -0
      depends on SCSI
+     default y
      ---help---
      This selects the support for UFS devices in Linux, say Y and make
        sure that you know the name of your UFS host adapter (the card

I don't think you want to force this on in every configuration since it's only appropriate to non server/desktop. I stripped this hunk.

Hi James,

Please apply the patch without the particular change or you can apply the latest patch sent by Dolev -
http://marc.info/?l=linux-scsi&m=136774922024179&w=1.

Thanks,
Santosh

#7 lore raw

Re: [PATCH 3/3] scsi: ufs: add support for query requests

Quoted 30 lines
Quoted 7 lines
Quoted 7 lines
drivers/scsi/ufs/Kconfig +0 -0
index 35faf24..82417d6 100644
@@ -35,6 +35,7 @@
 config SCSI_UFSHCD
      tristate "Universal Flash Storage Controller Driver Core"
Quoted 9 lines

drivers/scsi/ufs/Kconfig line 41

Quoted 5 lines
drivers/scsi/ufs/Kconfig +1 -0
      depends on SCSI
+     default y
      ---help---
      This selects the support for UFS devices in Linux, say Y and make
        sure that you know the name of your UFS host adapter (the card

I don't think you want to force this on in every configuration since it's only appropriate to non server/desktop. I stripped this hunk.

Hi James,

Please apply the patch without the particular change or you can apply the latest patch sent by Dolev -
http://marc.info/?l=linux-scsi&m=136774922024179&w=1.

Thanks,
Santosh
--
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

Signature · 3 lines
Maya Erez
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation