Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d532dbe2 authored by bo yang's avatar bo yang Committed by James Bottomley
Browse files

[SCSI] megaraid_sas: Fix the frame count calculation



When Driver sent wrong frame count to firmware.  As this particular
command is sent to drive, FW is seeing continuous chip resets and so
the command will timeout.

Signed-off-by Bo Yang<bo.yang@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent b70a41e0
Loading
Loading
Loading
Loading
+21 −10
Original line number Original line Diff line number Diff line
@@ -488,12 +488,13 @@ megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp,


 /**
 /**
 * megasas_get_frame_count - Computes the number of frames
 * megasas_get_frame_count - Computes the number of frames
 * @frame_type		: type of frame- io or pthru frame
 * @sge_count		: number of sg elements
 * @sge_count		: number of sg elements
 *
 *
 * Returns the number of frames required for numnber of sge's (sge_count)
 * Returns the number of frames required for numnber of sge's (sge_count)
 */
 */


static u32 megasas_get_frame_count(u8 sge_count)
static u32 megasas_get_frame_count(u8 sge_count, u8 frame_type)
{
{
	int num_cnt;
	int num_cnt;
	int sge_bytes;
	int sge_bytes;
@@ -505,12 +506,21 @@ static u32 megasas_get_frame_count(u8 sge_count)


	/*
	/*
	 * Main frame can contain 2 SGEs for 64-bit SGLs and
	 * Main frame can contain 2 SGEs for 64-bit SGLs and
	* 3 SGEs for 32-bit SGLs
	 * 3 SGEs for 32-bit SGLs for ldio &
	 * 1 SGEs for 64-bit SGLs and
	 * 2 SGEs for 32-bit SGLs for pthru frame
	 */
	 */
	if (unlikely(frame_type == PTHRU_FRAME)) {
		if (IS_DMA64)
			num_cnt = sge_count - 1;
		else
			num_cnt = sge_count - 2;
	} else {
		if (IS_DMA64)
		if (IS_DMA64)
			num_cnt = sge_count - 2;
			num_cnt = sge_count - 2;
		else
		else
			num_cnt = sge_count - 3;
			num_cnt = sge_count - 3;
	}


	if(num_cnt>0){
	if(num_cnt>0){
		sge_bytes = sge_sz * num_cnt;
		sge_bytes = sge_sz * num_cnt;
@@ -592,7 +602,8 @@ megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp,
	 * Compute the total number of frames this command consumes. FW uses
	 * Compute the total number of frames this command consumes. FW uses
	 * this number to pull sufficient number of frames from host memory.
	 * this number to pull sufficient number of frames from host memory.
	 */
	 */
	cmd->frame_count = megasas_get_frame_count(pthru->sge_count);
	cmd->frame_count = megasas_get_frame_count(pthru->sge_count,
							PTHRU_FRAME);


	return cmd->frame_count;
	return cmd->frame_count;
}
}
@@ -709,7 +720,7 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp,
	 * Compute the total number of frames this command consumes. FW uses
	 * Compute the total number of frames this command consumes. FW uses
	 * this number to pull sufficient number of frames from host memory.
	 * this number to pull sufficient number of frames from host memory.
	 */
	 */
	cmd->frame_count = megasas_get_frame_count(ldio->sge_count);
	cmd->frame_count = megasas_get_frame_count(ldio->sge_count, IO_FRAME);


	return cmd->frame_count;
	return cmd->frame_count;
}
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -542,6 +542,10 @@ struct megasas_ctrl_info {


#define MEGASAS_FW_BUSY				1
#define MEGASAS_FW_BUSY				1


/* Frame Type */
#define IO_FRAME				0
#define PTHRU_FRAME				1

/*
/*
 * When SCSI mid-layer calls driver's reset routine, driver waits for
 * When SCSI mid-layer calls driver's reset routine, driver waits for
 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
 * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note