提交 d0fc91d6 编写于 作者: K Kashyap Desai 提交者: Martin K. Petersen

scsi: megaraid_sas: Send SYNCHRONIZE_CACHE for VD to firmware

Until now the megaraid_sas driver has reported successful completion on
SYNCHRONIZE_CACHE commands without sending them down to the controller.
The controller firmware has been responsible for taking care of flushing
disk caches for all drives that belong to a Virtual Disk at the time of
system reboot/shutdown.

There may have been a reason to avoid sending SYNCHRONIZE_CACHE to a VD
in the past but that no longer appears to be valid.

Older versions of MegaRaid firmware (Gen2 and Gen2.5) set the WCE bit
for Virtual Disks but the firmware does not report correct completion
status for a SYNCHRONIZE_CACHE command. As a result, we must use another
method to identify whether it is safe to send the command to the
controller. We use the canHandleSyncCache firmware flag in the scratch
pad register at offset 0xB4.

New SYNCHRONIZE_CACHE behavior:

IF 'JBOD'

	Driver sends SYNCHRONIZE_CACHE command to the firmware
	Firmware sends SYNCHRONIZE_CACHE to drive
	Firmware obtains status from drive and returns same status back to driver

ELSEIF 'VirtualDisk'

	IF firmware supports new API bit called canHandleSyncCache
		Driver sends SYNCHRONIZE_CACHE command to the firmware
		Firmware does not send SYNCHRONIZE_CACHE to drives
		Firmware returns SUCCESS
	ELSE
		Driver does not send SYNCHRONIZE_CACHE command to the firmware
		Driver return SUCCESS for that command
	ENDIF
ENDIF

[mkp: edited patch description]
Signed-off-by: NKashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: NSumit Saxena <sumit.saxena@broadcom.com>
Reviewed-by: NTomas Henzl <thenzl@redhat.com>
Reviewed-by: NHannes Reinecke <hare@suse.com>
Reviewed-by: NEwan D. Milne <emilne@redhat.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 52198226
...@@ -1429,6 +1429,8 @@ enum FW_BOOT_CONTEXT { ...@@ -1429,6 +1429,8 @@ enum FW_BOOT_CONTEXT {
#define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT 14 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT 14
#define MR_MAX_MSIX_REG_ARRAY 16 #define MR_MAX_MSIX_REG_ARRAY 16
#define MR_RDPQ_MODE_OFFSET 0X00800000 #define MR_RDPQ_MODE_OFFSET 0X00800000
#define MR_CAN_HANDLE_SYNC_CACHE_OFFSET 0X01000000
/* /*
* register set for both 1068 and 1078 controllers * register set for both 1068 and 1078 controllers
* structure extended for 1078 registers * structure extended for 1078 registers
...@@ -2140,6 +2142,7 @@ struct megasas_instance { ...@@ -2140,6 +2142,7 @@ struct megasas_instance {
u8 is_imr; u8 is_imr;
u8 is_rdpq; u8 is_rdpq;
bool dev_handle; bool dev_handle;
bool fw_sync_cache_support;
}; };
struct MR_LD_VF_MAP { struct MR_LD_VF_MAP {
u32 size; u32 size;
......
...@@ -1700,11 +1700,8 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd) ...@@ -1700,11 +1700,8 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
goto out_done; goto out_done;
} }
/* if ((scmd->cmnd[0] == SYNCHRONIZE_CACHE) && MEGASAS_IS_LOGICAL(scmd) &&
* FW takes care of flush cache on its own for Virtual Disk. (!instance->fw_sync_cache_support)) {
* No need to send it down for VD. For JBOD send SYNCHRONIZE_CACHE to FW.
*/
if ((scmd->cmnd[0] == SYNCHRONIZE_CACHE) && MEGASAS_IS_LOGICAL(scmd)) {
scmd->result = DID_OK << 16; scmd->result = DID_OK << 16;
goto out_done; goto out_done;
} }
......
...@@ -748,6 +748,11 @@ megasas_ioc_init_fusion(struct megasas_instance *instance) ...@@ -748,6 +748,11 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
goto fail_fw_init; goto fail_fw_init;
} }
instance->fw_sync_cache_support = (scratch_pad_2 &
MR_CAN_HANDLE_SYNC_CACHE_OFFSET) ? 1 : 0;
dev_info(&instance->pdev->dev, "FW supports sync cache\t: %s\n",
instance->fw_sync_cache_support ? "Yes" : "No");
IOCInitMessage = IOCInitMessage =
dma_alloc_coherent(&instance->pdev->dev, dma_alloc_coherent(&instance->pdev->dev,
sizeof(struct MPI2_IOC_INIT_REQUEST), sizeof(struct MPI2_IOC_INIT_REQUEST),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册