Skip to contentSkip to conversation

ufs: adjust queue settings to PRDT limitations

PATCH Superseded Akinobu Mita 2 participants 3 messages Sep 21, 2013 – Sep 23, 2013 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ufs: adjust queue settings to PRDT limitations

The data byte count field of PRDT indicates the length of data block which is a segment of data transfer for SCSI commands. The value of this field shall have Dword granularity and the the maximum of length is 256KB.

This adjusts dma pad mask and max segment size to the above-mentioned PRDT limitations.

Cc Vinayak Holikatti <[email protected]>
Cc Santosh Y <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 drivers/scsi/ufs/ufshcd.c | 15 +++++++++++++++
 drivers/scsi/ufs/ufshci.h |  3 +++
 2 files changed, 18 insertions(+)
drivers/scsi/ufs/ufshcd.c +15 -0
index 7ef9c17..c60537f 100644
@@ -1919,6 +1919,20 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev)
 }
 
 /**
+ * ufshcd_slave_configure - adjust SCSI device configurations
+ * @sdev: pointer to SCSI device
+ */
+static int ufshcd_slave_configure(struct scsi_device *sdev)
+{
+	struct request_queue *q = sdev->request_queue;
+
+	blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
+	blk_queue_max_segment_size(q, PRDT_DATA_BYTE_COUNT_MAX);
+
+	return 0;
+}
+
+/**
  * ufshcd_slave_destroy - remove SCSI device configurations
  * @sdev: pointer to SCSI device
  */
@@ -2749,6 +2763,7 @@ static struct scsi_host_template ufshcd_driver_template = {
 	.proc_name		= UFSHCD,
 	.queuecommand		= ufshcd_queuecommand,
 	.slave_alloc		= ufshcd_slave_alloc,
+	.slave_configure	= ufshcd_slave_configure,
 	.slave_destroy		= ufshcd_slave_destroy,
 	.eh_abort_handler	= ufshcd_abort,
 	.eh_device_reset_handler = ufshcd_device_reset,
drivers/scsi/ufs/ufshci.h +3 -0
index 0475c66..c8de354 100644
@@ -296,6 +296,9 @@ enum {
 	MASK_OCS			= 0x0F,
 };
 
+#define PRDT_DATA_BYTE_COUNT_MAX	(256 * 1024)
+#define PRDT_DATA_BYTE_COUNT_PAD	4
+
 /**
  * struct ufshcd_sg_entry - UFSHCI PRD Entry
  * @base_addr: Lower 32bit physical address DW-0
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 56 lines · Akinobu Mita

The data byte count field of PRDT indicates the length of data block which is a segment of data transfer for SCSI commands. The value of this field shall have Dword granularity and the the maximum of length is 256KB.

This adjusts dma pad mask and max segment size to the above-mentioned PRDT limitations.

Cc Vinayak Holikatti <[email protected]>
Cc Santosh Y <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
  drivers/scsi/ufs/ufshcd.c | 15 +++++++++++++++
  drivers/scsi/ufs/ufshci.h |  3 +++
  2 files changed, 18 insertions(+)
drivers/scsi/ufs/ufshcd.c +15 -0
index 7ef9c17..c60537f 100644
@@ -1919,6 +1919,20 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev)
  }
 
  /**
+ * ufshcd_slave_configure - adjust SCSI device configurations
+ * @sdev: pointer to SCSI device
+ */
+static int ufshcd_slave_configure(struct scsi_device *sdev)
+{
+	struct request_queue *q = sdev->request_queue;
+
+	blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
+	blk_queue_max_segment_size(q, PRDT_DATA_BYTE_COUNT_MAX);
+
+	return 0;
+}
+
+/**
   * ufshcd_slave_destroy - remove SCSI device configurations
   * @sdev: pointer to SCSI device
   */
@@ -2749,6 +2763,7 @@ static struct scsi_host_template ufshcd_driver_template = {
  	.proc_name		= UFSHCD,
  	.queuecommand		= ufshcd_queuecommand,
  	.slave_alloc		= ufshcd_slave_alloc,
+	.slave_configure	= ufshcd_slave_configure,
  	.slave_destroy		= ufshcd_slave_destroy,
  	.eh_abort_handler	= ufshcd_abort,
  	.eh_device_reset_handler = ufshcd_device_reset,
drivers/scsi/ufs/ufshci.h +0 -0
index 0475c66..c8de354 100644

drivers/scsi/ufs/ufshci.h enum { · line 298

Quoted 3 lines
drivers/scsi/ufs/ufshci.h +0 -0
@@ -296,6 +296,9 @@ enum {
  	MASK_OCS			= 0x0F,
  };
 

Ideally there should be comment here to explain the reason for this limitation. I see comments in commit text but not here in code. Its not general practice to browse through history to understand the reason behind this limitations. so it always helps to add comments in code itself.

Regards,
Subhash

Quoted 6 lines
drivers/scsi/ufs/ufshci.h +3 -0
+#define PRDT_DATA_BYTE_COUNT_MAX	(256 * 1024)
+#define PRDT_DATA_BYTE_COUNT_PAD	4
+
  /**
   * struct ufshcd_sg_entry - UFSHCI PRD Entry
   * @base_addr: Lower 32bit physical address DW-0
#2 lore raw
Quoted 2 lines

Ideally there should be comment here to explain the reason for this limitation. I see comments in commit text but not here in code. Its not general practice to browse through history to understand the reason behind this limitations. so it always helps to add comments in code itself.

OK, I'll update the patch with the comment.