Skip to content

Commit

Permalink
ufs: adjust queue settings to PRDT limitations
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Akinobu Mita <[email protected]>
Reviewed-by: Subhash Jadavani <[email protected]>
Tested-by: Dolev Raviv <[email protected]>
Acked-by: Vinayak Holikatti <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
mita authored and Christoph Hellwig committed Jul 25, 2014
1 parent b2a6c52 commit eeda474
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/scsi/ufs/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,20 @@ int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth, int reason)
return depth;
}

/**
* 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
Expand Down Expand Up @@ -3145,6 +3159,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,
.change_queue_depth = ufshcd_change_queue_depth,
.eh_abort_handler = ufshcd_abort,
Expand Down
5 changes: 5 additions & 0 deletions drivers/scsi/ufs/ufshci.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ enum {
MASK_OCS = 0x0F,
};

/* The maximum length of the data byte count field in the PRDT is 256KB */
#define PRDT_DATA_BYTE_COUNT_MAX (256 * 1024)
/* The granularity of the data byte count field in the PRDT is 32-bit */
#define PRDT_DATA_BYTE_COUNT_PAD 4

/**
* struct ufshcd_sg_entry - UFSHCI PRD Entry
* @base_addr: Lower 32bit physical address DW-0
Expand Down

0 comments on commit eeda474

Please sign in to comment.