|
|
b37f23 |
From a28d10b2a9bec8714f59e12fe7fb53bfe8c6ef17 Mon Sep 17 00:00:00 2001
|
|
|
b37f23 |
From: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
|
|
|
b37f23 |
Date: Tue, 10 Jan 2017 18:20:46 -0500
|
|
|
b37f23 |
Subject: [PATCH 04/11] scsi: megaraid_sas: SAS3.5 Generic Megaraid Controllers
|
|
|
b37f23 |
Stream Detection and IO Coalescing
|
|
|
b37f23 |
|
|
|
b37f23 |
Detect sequential Write IOs and pass the hint that it is part of sequential
|
|
|
b37f23 |
stream to help HBA Firmware do the Full Stripe Writes. For read IOs on
|
|
|
b37f23 |
certain RAID volumes like Read Ahead volumes,this will help driver to
|
|
|
b37f23 |
send it to Firmware even if the IOs can potentially be sent to
|
|
|
b37f23 |
hardware directly (called fast path) bypassing firmware.
|
|
|
b37f23 |
|
|
|
b37f23 |
Design: 8 streams are maintained per RAID volume as per the combined
|
|
|
b37f23 |
firmware/driver design. When there is no stream detected the LRU stream
|
|
|
b37f23 |
is used for next potential stream and LRU/MRU map is updated to make this
|
|
|
b37f23 |
as MRU stream. Every time a stream is detected the MRU map
|
|
|
b37f23 |
is updated to make the current stream as MRU stream.
|
|
|
b37f23 |
|
|
|
b37f23 |
Signed-off-by: Sasikumar Chandrasekaran <sasikumar.pc@broadcom.com>
|
|
|
b37f23 |
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
|
|
|
b37f23 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
|
b37f23 |
---
|
|
|
b37f23 |
drivers/scsi/megaraid/megaraid_sas.h | 1 +
|
|
|
b37f23 |
drivers/scsi/megaraid/megaraid_sas_base.c | 43 +++++++-
|
|
|
b37f23 |
drivers/scsi/megaraid/megaraid_sas_fp.c | 2 +
|
|
|
b37f23 |
drivers/scsi/megaraid/megaraid_sas_fusion.c | 165 +++++++++++++++++++++++-----
|
|
|
b37f23 |
drivers/scsi/megaraid/megaraid_sas_fusion.h | 117 +++++++++++++++++++-
|
|
|
b37f23 |
5 files changed, 297 insertions(+), 31 deletions(-)
|
|
|
b37f23 |
|
|
|
b37f23 |
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
|
|
|
b37f23 |
index ccef47b..f387b32 100644
|
|
|
b37f23 |
--- a/drivers/scsi/megaraid/megaraid_sas.h
|
|
|
b37f23 |
+++ b/drivers/scsi/megaraid/megaraid_sas.h
|
|
|
b37f23 |
@@ -2070,6 +2070,7 @@ struct megasas_instance {
|
|
|
b37f23 |
/* used to sync fire the cmd to fw */
|
|
|
b37f23 |
spinlock_t hba_lock;
|
|
|
b37f23 |
/* used to synch producer, consumer ptrs in dpc */
|
|
|
b37f23 |
+ spinlock_t stream_lock;
|
|
|
b37f23 |
spinlock_t completion_lock;
|
|
|
b37f23 |
struct dma_pool *frame_dma_pool;
|
|
|
b37f23 |
struct dma_pool *sense_dma_pool;
|
|
|
b37f23 |
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
|
|
|
b37f23 |
index c78d7ee..0722286 100644
|
|
|
b37f23 |
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
|
|
|
b37f23 |
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
|
|
|
b37f23 |
@@ -5048,7 +5048,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
|
|
|
b37f23 |
struct megasas_register_set __iomem *reg_set;
|
|
|
b37f23 |
struct megasas_ctrl_info *ctrl_info = NULL;
|
|
|
b37f23 |
unsigned long bar_list;
|
|
|
b37f23 |
- int i, loop, fw_msix_count = 0;
|
|
|
b37f23 |
+ int i, j, loop, fw_msix_count = 0;
|
|
|
b37f23 |
struct IOV_111 *iovPtr;
|
|
|
b37f23 |
struct fusion_context *fusion;
|
|
|
b37f23 |
|
|
|
b37f23 |
@@ -5235,6 +5235,36 @@ static int megasas_init_fw(struct megasas_instance *instance)
|
|
|
b37f23 |
}
|
|
|
b37f23 |
|
|
|
b37f23 |
memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+ /* stream detection initialization */
|
|
|
b37f23 |
+ if (instance->is_ventura) {
|
|
|
b37f23 |
+ fusion->stream_detect_by_ld =
|
|
|
b37f23 |
+ kzalloc(sizeof(struct LD_STREAM_DETECT *)
|
|
|
b37f23 |
+ * MAX_LOGICAL_DRIVES_EXT,
|
|
|
b37f23 |
+ GFP_KERNEL);
|
|
|
b37f23 |
+ if (!fusion->stream_detect_by_ld) {
|
|
|
b37f23 |
+ dev_err(&instance->pdev->dev,
|
|
|
b37f23 |
+ "unable to allocate stream detection for pool of LDs\n");
|
|
|
b37f23 |
+ goto fail_get_ld_pd_list;
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+ for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) {
|
|
|
b37f23 |
+ fusion->stream_detect_by_ld[i] =
|
|
|
b37f23 |
+ kmalloc(sizeof(struct LD_STREAM_DETECT),
|
|
|
b37f23 |
+ GFP_KERNEL);
|
|
|
b37f23 |
+ if (!fusion->stream_detect_by_ld[i]) {
|
|
|
b37f23 |
+ dev_err(&instance->pdev->dev,
|
|
|
b37f23 |
+ "unable to allocate stream detect by LD\n ");
|
|
|
b37f23 |
+ for (j = 0; j < i; ++j)
|
|
|
b37f23 |
+ kfree(fusion->stream_detect_by_ld[j]);
|
|
|
b37f23 |
+ kfree(fusion->stream_detect_by_ld);
|
|
|
b37f23 |
+ fusion->stream_detect_by_ld = NULL;
|
|
|
b37f23 |
+ goto fail_get_ld_pd_list;
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+ fusion->stream_detect_by_ld[i]->mru_bit_map
|
|
|
b37f23 |
+ = MR_STREAM_BITMAP;
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+
|
|
|
b37f23 |
if (megasas_ld_list_query(instance,
|
|
|
b37f23 |
MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
|
|
|
b37f23 |
megasas_get_ld_list(instance);
|
|
|
b37f23 |
@@ -5354,6 +5384,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
|
|
|
b37f23 |
|
|
|
b37f23 |
return 0;
|
|
|
b37f23 |
|
|
|
b37f23 |
+fail_get_ld_pd_list:
|
|
|
b37f23 |
+ instance->instancet->disable_intr(instance);
|
|
|
b37f23 |
fail_get_pd_list:
|
|
|
b37f23 |
instance->instancet->disable_intr(instance);
|
|
|
b37f23 |
megasas_destroy_irqs(instance);
|
|
|
b37f23 |
@@ -5896,6 +5928,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
|
|
|
b37f23 |
|
|
|
b37f23 |
spin_lock_init(&instance->mfi_pool_lock);
|
|
|
b37f23 |
spin_lock_init(&instance->hba_lock);
|
|
|
b37f23 |
+ spin_lock_init(&instance->stream_lock);
|
|
|
b37f23 |
spin_lock_init(&instance->completion_lock);
|
|
|
b37f23 |
|
|
|
b37f23 |
mutex_init(&instance->reset_mutex);
|
|
|
b37f23 |
@@ -6363,6 +6396,14 @@ static void megasas_detach_one(struct pci_dev *pdev)
|
|
|
b37f23 |
if (instance->msix_vectors)
|
|
|
b37f23 |
pci_disable_msix(instance->pdev);
|
|
|
b37f23 |
|
|
|
b37f23 |
+ if (instance->is_ventura) {
|
|
|
b37f23 |
+ for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i)
|
|
|
b37f23 |
+ kfree(fusion->stream_detect_by_ld[i]);
|
|
|
b37f23 |
+ kfree(fusion->stream_detect_by_ld);
|
|
|
b37f23 |
+ fusion->stream_detect_by_ld = NULL;
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+
|
|
|
b37f23 |
if (instance->ctrl_context) {
|
|
|
b37f23 |
megasas_release_fusion(instance);
|
|
|
b37f23 |
pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
|
|
|
b37f23 |
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
|
|
|
b37f23 |
index e413113..fe5b074 100644
|
|
|
b37f23 |
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
|
|
|
b37f23 |
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
|
|
|
b37f23 |
@@ -933,6 +933,8 @@ MR_BuildRaidContext(struct megasas_instance *instance,
|
|
|
b37f23 |
|
|
|
b37f23 |
ld = MR_TargetIdToLdGet(ldTgtId, map);
|
|
|
b37f23 |
raid = MR_LdRaidGet(ld, map);
|
|
|
b37f23 |
+ /*check read ahead bit*/
|
|
|
b37f23 |
+ io_info->ra_capable = raid->capability.ra_capable;
|
|
|
b37f23 |
|
|
|
b37f23 |
/*
|
|
|
b37f23 |
* if rowDataSize @RAID map and spanRowDataSize @SPAN INFO are zero
|
|
|
b37f23 |
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
|
|
|
b37f23 |
index 27c6a1f..946f7c0 100644
|
|
|
b37f23 |
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
|
|
|
b37f23 |
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
|
|
|
b37f23 |
@@ -1704,6 +1704,90 @@ megasas_set_pd_lba(struct MPI2_RAID_SCSI_IO_REQUEST *io_request, u8 cdb_len,
|
|
|
b37f23 |
}
|
|
|
b37f23 |
|
|
|
b37f23 |
/**
|
|
|
b37f23 |
+ * megasas_stream_detect - stream detection on read and and write IOs
|
|
|
b37f23 |
+ * @instance: Adapter soft state
|
|
|
b37f23 |
+ * @cmd: Command to be prepared
|
|
|
b37f23 |
+ * @io_info: IO Request info
|
|
|
b37f23 |
+ *
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+/** stream detection on read and and write IOs */
|
|
|
b37f23 |
+static void megasas_stream_detect(struct megasas_instance *instance,
|
|
|
b37f23 |
+ struct megasas_cmd_fusion *cmd,
|
|
|
b37f23 |
+ struct IO_REQUEST_INFO *io_info)
|
|
|
b37f23 |
+{
|
|
|
b37f23 |
+ struct fusion_context *fusion = instance->ctrl_context;
|
|
|
b37f23 |
+ u32 device_id = io_info->ldTgtId;
|
|
|
b37f23 |
+ struct LD_STREAM_DETECT *current_ld_sd
|
|
|
b37f23 |
+ = fusion->stream_detect_by_ld[device_id];
|
|
|
b37f23 |
+ u32 *track_stream = ¤t_ld_sd->mru_bit_map, stream_num;
|
|
|
b37f23 |
+ u32 shifted_values, unshifted_values;
|
|
|
b37f23 |
+ u32 index_value_mask, shifted_values_mask;
|
|
|
b37f23 |
+ int i;
|
|
|
b37f23 |
+ bool is_read_ahead = false;
|
|
|
b37f23 |
+ struct STREAM_DETECT *current_sd;
|
|
|
b37f23 |
+ /* find possible stream */
|
|
|
b37f23 |
+ for (i = 0; i < MAX_STREAMS_TRACKED; ++i) {
|
|
|
b37f23 |
+ stream_num =
|
|
|
b37f23 |
+ (*track_stream >> (i * BITS_PER_INDEX_STREAM)) &
|
|
|
b37f23 |
+ STREAM_MASK;
|
|
|
b37f23 |
+ current_sd = ¤t_ld_sd->stream_track[stream_num];
|
|
|
b37f23 |
+ /* if we found a stream, update the raid
|
|
|
b37f23 |
+ * context and also update the mruBitMap
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+ /* boundary condition */
|
|
|
b37f23 |
+ if ((current_sd->next_seq_lba) &&
|
|
|
b37f23 |
+ (io_info->ldStartBlock >= current_sd->next_seq_lba) &&
|
|
|
b37f23 |
+ (io_info->ldStartBlock <= (current_sd->next_seq_lba+32)) &&
|
|
|
b37f23 |
+ (current_sd->is_read == io_info->isRead)) {
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+ if ((io_info->ldStartBlock != current_sd->next_seq_lba)
|
|
|
b37f23 |
+ && ((!io_info->isRead) || (!is_read_ahead)))
|
|
|
b37f23 |
+ /*
|
|
|
b37f23 |
+ * Once the API availible we need to change this.
|
|
|
b37f23 |
+ * At this point we are not allowing any gap
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+ continue;
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+ cmd->io_request->RaidContext.raid_context_g35.stream_detected = true;
|
|
|
b37f23 |
+ current_sd->next_seq_lba =
|
|
|
b37f23 |
+ io_info->ldStartBlock + io_info->numBlocks;
|
|
|
b37f23 |
+ /*
|
|
|
b37f23 |
+ * update the mruBitMap LRU
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+ shifted_values_mask =
|
|
|
b37f23 |
+ (1 << i * BITS_PER_INDEX_STREAM) - 1;
|
|
|
b37f23 |
+ shifted_values = ((*track_stream & shifted_values_mask)
|
|
|
b37f23 |
+ << BITS_PER_INDEX_STREAM);
|
|
|
b37f23 |
+ index_value_mask =
|
|
|
b37f23 |
+ STREAM_MASK << i * BITS_PER_INDEX_STREAM;
|
|
|
b37f23 |
+ unshifted_values =
|
|
|
b37f23 |
+ *track_stream & ~(shifted_values_mask |
|
|
|
b37f23 |
+ index_value_mask);
|
|
|
b37f23 |
+ *track_stream =
|
|
|
b37f23 |
+ unshifted_values | shifted_values | stream_num;
|
|
|
b37f23 |
+ return;
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+ /*
|
|
|
b37f23 |
+ * if we did not find any stream, create a new one
|
|
|
b37f23 |
+ * from the least recently used
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+ stream_num =
|
|
|
b37f23 |
+ (*track_stream >> ((MAX_STREAMS_TRACKED - 1) * BITS_PER_INDEX_STREAM)) &
|
|
|
b37f23 |
+ STREAM_MASK;
|
|
|
b37f23 |
+ current_sd = ¤t_ld_sd->stream_track[stream_num];
|
|
|
b37f23 |
+ current_sd->is_read = io_info->isRead;
|
|
|
b37f23 |
+ current_sd->next_seq_lba = io_info->ldStartBlock + io_info->numBlocks;
|
|
|
b37f23 |
+ *track_stream =
|
|
|
b37f23 |
+ (((*track_stream & ZERO_LAST_STREAM) << 4) | stream_num);
|
|
|
b37f23 |
+ return;
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+}
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+/**
|
|
|
b37f23 |
* megasas_build_ldio_fusion - Prepares IOs to devices
|
|
|
b37f23 |
* @instance: Adapter soft state
|
|
|
b37f23 |
* @scp: SCSI command
|
|
|
b37f23 |
@@ -1725,15 +1809,17 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
struct fusion_context *fusion;
|
|
|
b37f23 |
struct MR_DRV_RAID_MAP_ALL *local_map_ptr;
|
|
|
b37f23 |
u8 *raidLUN;
|
|
|
b37f23 |
+ unsigned long spinlock_flags;
|
|
|
b37f23 |
|
|
|
b37f23 |
device_id = MEGASAS_DEV_INDEX(scp);
|
|
|
b37f23 |
|
|
|
b37f23 |
fusion = instance->ctrl_context;
|
|
|
b37f23 |
|
|
|
b37f23 |
io_request = cmd->io_request;
|
|
|
b37f23 |
- io_request->RaidContext.VirtualDiskTgtId = cpu_to_le16(device_id);
|
|
|
b37f23 |
- io_request->RaidContext.status = 0;
|
|
|
b37f23 |
- io_request->RaidContext.exStatus = 0;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.VirtualDiskTgtId =
|
|
|
b37f23 |
+ cpu_to_le16(device_id);
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.status = 0;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.exStatus = 0;
|
|
|
b37f23 |
|
|
|
b37f23 |
req_desc = (union MEGASAS_REQUEST_DESCRIPTOR_UNION *)cmd->request_desc;
|
|
|
b37f23 |
|
|
|
b37f23 |
@@ -1804,11 +1890,11 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
|
|
|
b37f23 |
if ((MR_TargetIdToLdGet(device_id, local_map_ptr) >=
|
|
|
b37f23 |
instance->fw_supported_vd_count) || (!fusion->fast_path_io)) {
|
|
|
b37f23 |
- io_request->RaidContext.regLockFlags = 0;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.regLockFlags = 0;
|
|
|
b37f23 |
fp_possible = 0;
|
|
|
b37f23 |
} else {
|
|
|
b37f23 |
if (MR_BuildRaidContext(instance, &io_info,
|
|
|
b37f23 |
- &io_request->RaidContext,
|
|
|
b37f23 |
+ &io_request->RaidContext.raid_context,
|
|
|
b37f23 |
local_map_ptr, &raidLUN))
|
|
|
b37f23 |
fp_possible = io_info.fpOkForIo;
|
|
|
b37f23 |
}
|
|
|
b37f23 |
@@ -1819,6 +1905,18 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
cmd->request_desc->SCSIIO.MSIxIndex = instance->msix_vectors ?
|
|
|
b37f23 |
raw_smp_processor_id() % instance->msix_vectors : 0;
|
|
|
b37f23 |
|
|
|
b37f23 |
+ if (instance->is_ventura) {
|
|
|
b37f23 |
+ spin_lock_irqsave(&instance->stream_lock, spinlock_flags);
|
|
|
b37f23 |
+ megasas_stream_detect(instance, cmd, &io_info);
|
|
|
b37f23 |
+ spin_unlock_irqrestore(&instance->stream_lock, spinlock_flags);
|
|
|
b37f23 |
+ /* In ventura if stream detected for a read and it is read ahead
|
|
|
b37f23 |
+ * capable make this IO as LDIO
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+ if (io_request->RaidContext.raid_context_g35.stream_detected &&
|
|
|
b37f23 |
+ io_info.isRead && io_info.ra_capable)
|
|
|
b37f23 |
+ fp_possible = false;
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+
|
|
|
b37f23 |
if (fp_possible) {
|
|
|
b37f23 |
megasas_set_pd_lba(io_request, scp->cmd_len, &io_info, scp,
|
|
|
b37f23 |
local_map_ptr, start_lba_lo);
|
|
|
b37f23 |
@@ -1827,15 +1925,16 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
(MPI2_REQ_DESCRIPT_FLAGS_FP_IO
|
|
|
b37f23 |
<< MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
|
|
b37f23 |
if (fusion->adapter_type == INVADER_SERIES) {
|
|
|
b37f23 |
- if (io_request->RaidContext.regLockFlags ==
|
|
|
b37f23 |
+ if (io_request->RaidContext.raid_context.regLockFlags ==
|
|
|
b37f23 |
REGION_TYPE_UNUSED)
|
|
|
b37f23 |
cmd->request_desc->SCSIIO.RequestFlags =
|
|
|
b37f23 |
(MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
|
|
|
b37f23 |
MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
|
|
b37f23 |
- io_request->RaidContext.Type = MPI2_TYPE_CUDA;
|
|
|
b37f23 |
- io_request->RaidContext.nseg = 0x1;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.Type
|
|
|
b37f23 |
+ = MPI2_TYPE_CUDA;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.nseg = 0x1;
|
|
|
b37f23 |
io_request->IoFlags |= cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
|
|
|
b37f23 |
- io_request->RaidContext.regLockFlags |=
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.regLockFlags |=
|
|
|
b37f23 |
(MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
|
|
|
b37f23 |
MR_RL_FLAGS_SEQ_NUM_ENABLE);
|
|
|
b37f23 |
}
|
|
|
b37f23 |
@@ -1862,22 +1961,24 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
/* populate the LUN field */
|
|
|
b37f23 |
memcpy(io_request->LUN, raidLUN, 8);
|
|
|
b37f23 |
} else {
|
|
|
b37f23 |
- io_request->RaidContext.timeoutValue =
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.timeoutValue =
|
|
|
b37f23 |
cpu_to_le16(local_map_ptr->raidMap.fpPdIoTimeoutSec);
|
|
|
b37f23 |
cmd->request_desc->SCSIIO.RequestFlags =
|
|
|
b37f23 |
(MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
|
|
|
b37f23 |
<< MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
|
|
b37f23 |
if (fusion->adapter_type == INVADER_SERIES) {
|
|
|
b37f23 |
if (io_info.do_fp_rlbypass ||
|
|
|
b37f23 |
- (io_request->RaidContext.regLockFlags == REGION_TYPE_UNUSED))
|
|
|
b37f23 |
+ (io_request->RaidContext.raid_context.regLockFlags
|
|
|
b37f23 |
+ == REGION_TYPE_UNUSED))
|
|
|
b37f23 |
cmd->request_desc->SCSIIO.RequestFlags =
|
|
|
b37f23 |
(MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK <<
|
|
|
b37f23 |
MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
|
|
|
b37f23 |
- io_request->RaidContext.Type = MPI2_TYPE_CUDA;
|
|
|
b37f23 |
- io_request->RaidContext.regLockFlags |=
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.Type
|
|
|
b37f23 |
+ = MPI2_TYPE_CUDA;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.regLockFlags |=
|
|
|
b37f23 |
(MR_RL_FLAGS_GRANT_DESTINATION_CPU0 |
|
|
|
b37f23 |
MR_RL_FLAGS_SEQ_NUM_ENABLE);
|
|
|
b37f23 |
- io_request->RaidContext.nseg = 0x1;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.nseg = 0x1;
|
|
|
b37f23 |
}
|
|
|
b37f23 |
io_request->Function = MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST;
|
|
|
b37f23 |
io_request->DevHandle = cpu_to_le16(device_id);
|
|
|
b37f23 |
@@ -1913,7 +2014,7 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
local_map_ptr = fusion->ld_drv_map[(instance->map_id & 1)];
|
|
|
b37f23 |
io_request->DataLength = cpu_to_le32(scsi_bufflen(scmd));
|
|
|
b37f23 |
/* get RAID_Context pointer */
|
|
|
b37f23 |
- pRAID_Context = &io_request->RaidContext;
|
|
|
b37f23 |
+ pRAID_Context = &io_request->RaidContext.raid_context;
|
|
|
b37f23 |
/* Check with FW team */
|
|
|
b37f23 |
pRAID_Context->VirtualDiskTgtId = cpu_to_le16(device_id);
|
|
|
b37f23 |
pRAID_Context->regLockRowLBA = 0;
|
|
|
b37f23 |
@@ -2000,7 +2101,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
|
|
|
b37f23 |
io_request = cmd->io_request;
|
|
|
b37f23 |
/* get RAID_Context pointer */
|
|
|
b37f23 |
- pRAID_Context = &io_request->RaidContext;
|
|
|
b37f23 |
+ pRAID_Context = &io_request->RaidContext.raid_context;
|
|
|
b37f23 |
pRAID_Context->regLockFlags = 0;
|
|
|
b37f23 |
pRAID_Context->regLockRowLBA = 0;
|
|
|
b37f23 |
pRAID_Context->regLockLength = 0;
|
|
|
b37f23 |
@@ -2094,9 +2195,9 @@ megasas_build_io_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
io_request->Control = 0;
|
|
|
b37f23 |
io_request->EEDPBlockSize = 0;
|
|
|
b37f23 |
io_request->ChainOffset = 0;
|
|
|
b37f23 |
- io_request->RaidContext.RAIDFlags = 0;
|
|
|
b37f23 |
- io_request->RaidContext.Type = 0;
|
|
|
b37f23 |
- io_request->RaidContext.nseg = 0;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.RAIDFlags = 0;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.Type = 0;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.nseg = 0;
|
|
|
b37f23 |
|
|
|
b37f23 |
memcpy(io_request->CDB.CDB32, scp->cmnd, scp->cmd_len);
|
|
|
b37f23 |
/*
|
|
|
b37f23 |
@@ -2143,8 +2244,8 @@ megasas_build_io_fusion(struct megasas_instance *instance,
|
|
|
b37f23 |
/* numSGE store lower 8 bit of sge_count.
|
|
|
b37f23 |
* numSGEExt store higher 8 bit of sge_count
|
|
|
b37f23 |
*/
|
|
|
b37f23 |
- io_request->RaidContext.numSGE = sge_count;
|
|
|
b37f23 |
- io_request->RaidContext.numSGEExt = (u8)(sge_count >> 8);
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.numSGE = sge_count;
|
|
|
b37f23 |
+ io_request->RaidContext.raid_context.numSGEExt = (u8)(sge_count >> 8);
|
|
|
b37f23 |
|
|
|
b37f23 |
io_request->SGLFlags = cpu_to_le16(MPI2_SGE_FLAGS_64_BIT_ADDRESSING);
|
|
|
b37f23 |
|
|
|
b37f23 |
@@ -2303,8 +2404,8 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
|
|
|
b37f23 |
cmd_fusion->scmd->SCp.ptr = NULL;
|
|
|
b37f23 |
|
|
|
b37f23 |
scmd_local = cmd_fusion->scmd;
|
|
|
b37f23 |
- status = scsi_io_req->RaidContext.status;
|
|
|
b37f23 |
- extStatus = scsi_io_req->RaidContext.exStatus;
|
|
|
b37f23 |
+ status = scsi_io_req->RaidContext.raid_context.status;
|
|
|
b37f23 |
+ extStatus = scsi_io_req->RaidContext.raid_context.exStatus;
|
|
|
b37f23 |
|
|
|
b37f23 |
switch (scsi_io_req->Function) {
|
|
|
b37f23 |
case MPI2_FUNCTION_SCSI_TASK_MGMT:
|
|
|
b37f23 |
@@ -2337,8 +2438,8 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex)
|
|
|
b37f23 |
case MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST: /* LD-IO Path */
|
|
|
b37f23 |
/* Map the FW Cmd Status */
|
|
|
b37f23 |
map_cmd_status(cmd_fusion, status, extStatus);
|
|
|
b37f23 |
- scsi_io_req->RaidContext.status = 0;
|
|
|
b37f23 |
- scsi_io_req->RaidContext.exStatus = 0;
|
|
|
b37f23 |
+ scsi_io_req->RaidContext.raid_context.status = 0;
|
|
|
b37f23 |
+ scsi_io_req->RaidContext.raid_context.exStatus = 0;
|
|
|
b37f23 |
if (megasas_cmd_type(scmd_local) == READ_WRITE_LDIO)
|
|
|
b37f23 |
atomic_dec(&instance->ldio_outstanding);
|
|
|
b37f23 |
megasas_return_cmd_fusion(instance, cmd_fusion);
|
|
|
b37f23 |
@@ -2901,7 +3002,7 @@ void megasas_refire_mgmt_cmd(struct megasas_instance *instance)
|
|
|
b37f23 |
&& !(cmd_mfi->flags & DRV_DCMD_SKIP_REFIRE);
|
|
|
b37f23 |
if (refire_cmd)
|
|
|
b37f23 |
megasas_fire_cmd_fusion(instance, req_desc,
|
|
|
b37f23 |
- instance->is_ventura);
|
|
|
b37f23 |
+ instance->is_ventura);
|
|
|
b37f23 |
else
|
|
|
b37f23 |
megasas_return_cmd(instance, cmd_mfi);
|
|
|
b37f23 |
}
|
|
|
b37f23 |
@@ -3390,7 +3491,7 @@ int megasas_check_mpio_paths(struct megasas_instance *instance,
|
|
|
b37f23 |
/* Core fusion reset function */
|
|
|
b37f23 |
int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
|
|
|
b37f23 |
{
|
|
|
b37f23 |
- int retval = SUCCESS, i, convert = 0;
|
|
|
b37f23 |
+ int retval = SUCCESS, i, j, convert = 0;
|
|
|
b37f23 |
struct megasas_instance *instance;
|
|
|
b37f23 |
struct megasas_cmd_fusion *cmd_fusion;
|
|
|
b37f23 |
struct fusion_context *fusion;
|
|
|
b37f23 |
@@ -3555,6 +3656,16 @@ transition_to_ready:
|
|
|
b37f23 |
shost_for_each_device(sdev, shost)
|
|
|
b37f23 |
megasas_update_sdev_properties(sdev);
|
|
|
b37f23 |
|
|
|
b37f23 |
+ /* reset stream detection array */
|
|
|
b37f23 |
+ if (instance->is_ventura) {
|
|
|
b37f23 |
+ for (j = 0; j < MAX_LOGICAL_DRIVES_EXT; ++j) {
|
|
|
b37f23 |
+ memset(fusion->stream_detect_by_ld[j],
|
|
|
b37f23 |
+ 0, sizeof(struct LD_STREAM_DETECT));
|
|
|
b37f23 |
+ fusion->stream_detect_by_ld[j]->mru_bit_map
|
|
|
b37f23 |
+ = MR_STREAM_BITMAP;
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+ }
|
|
|
b37f23 |
+
|
|
|
b37f23 |
clear_bit(MEGASAS_FUSION_IN_RESET,
|
|
|
b37f23 |
&instance->reset_flags);
|
|
|
b37f23 |
instance->instancet->enable_intr(instance);
|
|
|
b37f23 |
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
|
|
|
b37f23 |
index 3cd3d0a..d9cf496 100644
|
|
|
b37f23 |
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
|
|
|
b37f23 |
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
|
|
|
b37f23 |
@@ -133,12 +133,95 @@ struct RAID_CONTEXT {
|
|
|
b37f23 |
u8 resvd2;
|
|
|
b37f23 |
};
|
|
|
b37f23 |
|
|
|
b37f23 |
+/*
|
|
|
b37f23 |
+ * Raid Context structure which describes ventura MegaRAID specific
|
|
|
b37f23 |
+ * IO Paramenters ,This resides at offset 0x60 where the SGL normally
|
|
|
b37f23 |
+ * starts in MPT IO Frames
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+struct RAID_CONTEXT_G35 {
|
|
|
b37f23 |
+#if defined(__BIG_ENDIAN_BITFIELD)
|
|
|
b37f23 |
+ u16 resvd0:8;
|
|
|
b37f23 |
+ u16 nseg:4;
|
|
|
b37f23 |
+ u16 type:4;
|
|
|
b37f23 |
+#else
|
|
|
b37f23 |
+ u16 type:4; /* 0x00 */
|
|
|
b37f23 |
+ u16 nseg:4; /* 0x00 */
|
|
|
b37f23 |
+ u16 resvd0:8;
|
|
|
b37f23 |
+#endif
|
|
|
b37f23 |
+ u16 timeout_value; /* 0x02 -0x03 */
|
|
|
b37f23 |
+ union {
|
|
|
b37f23 |
+ struct {
|
|
|
b37f23 |
+#if defined(__BIG_ENDIAN_BITFIELD)
|
|
|
b37f23 |
+ u16 set_divert:4;
|
|
|
b37f23 |
+ u16 cpu_sel:4;
|
|
|
b37f23 |
+ u16 log:1;
|
|
|
b37f23 |
+ u16 rw:1;
|
|
|
b37f23 |
+ u16 sbs:1;
|
|
|
b37f23 |
+ u16 sqn:1;
|
|
|
b37f23 |
+ u16 fwn:1;
|
|
|
b37f23 |
+ u16 c2f:1;
|
|
|
b37f23 |
+ u16 sld:1;
|
|
|
b37f23 |
+ u16 reserved:1;
|
|
|
b37f23 |
+#else
|
|
|
b37f23 |
+ u16 reserved:1;
|
|
|
b37f23 |
+ u16 sld:1;
|
|
|
b37f23 |
+ u16 c2f:1;
|
|
|
b37f23 |
+ u16 fwn:1;
|
|
|
b37f23 |
+ u16 sqn:1;
|
|
|
b37f23 |
+ u16 sbs:1;
|
|
|
b37f23 |
+ u16 rw:1;
|
|
|
b37f23 |
+ u16 log:1;
|
|
|
b37f23 |
+ u16 cpu_sel:4;
|
|
|
b37f23 |
+ u16 set_divert:4;
|
|
|
b37f23 |
+#endif
|
|
|
b37f23 |
+ } bits;
|
|
|
b37f23 |
+ u16 s;
|
|
|
b37f23 |
+ } routing_flags; /* 0x04 -0x05 routing flags */
|
|
|
b37f23 |
+ u16 virtual_disk_tgt_id; /* 0x06 -0x07 */
|
|
|
b37f23 |
+ u64 reg_lock_row_lba; /* 0x08 - 0x0F */
|
|
|
b37f23 |
+ u32 reg_lock_length; /* 0x10 - 0x13 */
|
|
|
b37f23 |
+ union {
|
|
|
b37f23 |
+ u16 next_lmid; /* 0x14 - 0x15 */
|
|
|
b37f23 |
+ u16 peer_smid; /* used for the raid 1/10 fp writes */
|
|
|
b37f23 |
+ } smid;
|
|
|
b37f23 |
+ u8 ex_status; /* 0x16 : OUT */
|
|
|
b37f23 |
+ u8 status; /* 0x17 status */
|
|
|
b37f23 |
+ u8 RAIDFlags; /* 0x18 resvd[7:6], ioSubType[5:4],
|
|
|
b37f23 |
+ * resvd[3:1], preferredCpu[0]
|
|
|
b37f23 |
+ */
|
|
|
b37f23 |
+ u8 span_arm; /* 0x1C span[7:5], arm[4:0] */
|
|
|
b37f23 |
+ u16 config_seq_num; /* 0x1A -0x1B */
|
|
|
b37f23 |
+#if defined(__BIG_ENDIAN_BITFIELD) /* 0x1C - 0x1D */
|
|
|
b37f23 |
+ u16 stream_detected:1;
|
|
|
b37f23 |
+ u16 reserved:3;
|
|
|
b37f23 |
+ u16 num_sge:12;
|
|
|
b37f23 |
+#else
|
|
|
b37f23 |
+ u16 num_sge:12;
|
|
|
b37f23 |
+ u16 reserved:3;
|
|
|
b37f23 |
+ u16 stream_detected:1;
|
|
|
b37f23 |
+#endif
|
|
|
b37f23 |
+ u8 resvd2[2]; /* 0x1E-0x1F */
|
|
|
b37f23 |
+};
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+union RAID_CONTEXT_UNION {
|
|
|
b37f23 |
+ struct RAID_CONTEXT raid_context;
|
|
|
b37f23 |
+ struct RAID_CONTEXT_G35 raid_context_g35;
|
|
|
b37f23 |
+};
|
|
|
b37f23 |
+
|
|
|
b37f23 |
#define RAID_CTX_SPANARM_ARM_SHIFT (0)
|
|
|
b37f23 |
#define RAID_CTX_SPANARM_ARM_MASK (0x1f)
|
|
|
b37f23 |
|
|
|
b37f23 |
#define RAID_CTX_SPANARM_SPAN_SHIFT (5)
|
|
|
b37f23 |
#define RAID_CTX_SPANARM_SPAN_MASK (0xE0)
|
|
|
b37f23 |
|
|
|
b37f23 |
+/* number of bits per index in U32 TrackStream */
|
|
|
b37f23 |
+#define BITS_PER_INDEX_STREAM 4
|
|
|
b37f23 |
+#define INVALID_STREAM_NUM 16
|
|
|
b37f23 |
+#define MR_STREAM_BITMAP 0x76543210
|
|
|
b37f23 |
+#define STREAM_MASK ((1 << BITS_PER_INDEX_STREAM) - 1)
|
|
|
b37f23 |
+#define ZERO_LAST_STREAM 0x0fffffff
|
|
|
b37f23 |
+#define MAX_STREAMS_TRACKED 8
|
|
|
b37f23 |
+
|
|
|
b37f23 |
/*
|
|
|
b37f23 |
* define region lock types
|
|
|
b37f23 |
*/
|
|
|
b37f23 |
@@ -409,7 +492,7 @@ struct MPI2_RAID_SCSI_IO_REQUEST {
|
|
|
b37f23 |
u8 LUN[8]; /* 0x34 */
|
|
|
b37f23 |
__le32 Control; /* 0x3C */
|
|
|
b37f23 |
union MPI2_SCSI_IO_CDB_UNION CDB; /* 0x40 */
|
|
|
b37f23 |
- struct RAID_CONTEXT RaidContext; /* 0x60 */
|
|
|
b37f23 |
+ union RAID_CONTEXT_UNION RaidContext; /* 0x60 */
|
|
|
b37f23 |
union MPI2_SGE_IO_UNION SGL; /* 0x80 */
|
|
|
b37f23 |
};
|
|
|
b37f23 |
|
|
|
b37f23 |
@@ -656,11 +739,13 @@ struct MR_LD_RAID {
|
|
|
b37f23 |
u32 encryptionType:8;
|
|
|
b37f23 |
u32 pdPiMode:4;
|
|
|
b37f23 |
u32 ldPiMode:4;
|
|
|
b37f23 |
- u32 reserved5:3;
|
|
|
b37f23 |
+ u32 reserved5:2;
|
|
|
b37f23 |
+ u32 ra_capable:1;
|
|
|
b37f23 |
u32 fpCapable:1;
|
|
|
b37f23 |
#else
|
|
|
b37f23 |
u32 fpCapable:1;
|
|
|
b37f23 |
- u32 reserved5:3;
|
|
|
b37f23 |
+ u32 ra_capable:1;
|
|
|
b37f23 |
+ u32 reserved5:2;
|
|
|
b37f23 |
u32 ldPiMode:4;
|
|
|
b37f23 |
u32 pdPiMode:4;
|
|
|
b37f23 |
u32 encryptionType:8;
|
|
|
b37f23 |
@@ -745,6 +830,7 @@ struct IO_REQUEST_INFO {
|
|
|
b37f23 |
u64 start_row;
|
|
|
b37f23 |
u8 span_arm; /* span[7:5], arm[4:0] */
|
|
|
b37f23 |
u8 pd_after_lb;
|
|
|
b37f23 |
+ bool ra_capable;
|
|
|
b37f23 |
};
|
|
|
b37f23 |
|
|
|
b37f23 |
struct MR_LD_TARGET_SYNC {
|
|
|
b37f23 |
@@ -930,6 +1016,30 @@ struct MR_PD_CFG_SEQ_NUM_SYNC {
|
|
|
b37f23 |
struct MR_PD_CFG_SEQ seq[1];
|
|
|
b37f23 |
} __packed;
|
|
|
b37f23 |
|
|
|
b37f23 |
+/* stream detection */
|
|
|
b37f23 |
+struct STREAM_DETECT {
|
|
|
b37f23 |
+ u64 next_seq_lba; /* next LBA to match sequential access */
|
|
|
b37f23 |
+ struct megasas_cmd_fusion *first_cmd_fusion; /* first cmd in group */
|
|
|
b37f23 |
+ struct megasas_cmd_fusion *last_cmd_fusion; /* last cmd in group */
|
|
|
b37f23 |
+ u32 count_cmds_in_stream; /* count of host commands in this stream */
|
|
|
b37f23 |
+ u16 num_sges_in_group; /* total number of SGEs in grouped IOs */
|
|
|
b37f23 |
+ u8 is_read; /* SCSI OpCode for this stream */
|
|
|
b37f23 |
+ u8 group_depth; /* total number of host commands in group */
|
|
|
b37f23 |
+ /* TRUE if cannot add any more commands to this group */
|
|
|
b37f23 |
+ bool group_flush;
|
|
|
b37f23 |
+ u8 reserved[7]; /* pad to 64-bit alignment */
|
|
|
b37f23 |
+};
|
|
|
b37f23 |
+
|
|
|
b37f23 |
+struct LD_STREAM_DETECT {
|
|
|
b37f23 |
+ bool write_back; /* TRUE if WB, FALSE if WT */
|
|
|
b37f23 |
+ bool fp_write_enabled;
|
|
|
b37f23 |
+ bool members_ssds;
|
|
|
b37f23 |
+ bool fp_cache_bypass_capable;
|
|
|
b37f23 |
+ u32 mru_bit_map; /* bitmap used to track MRU and LRU stream indicies */
|
|
|
b37f23 |
+ /* this is the array of stream detect structures (one per stream) */
|
|
|
b37f23 |
+ struct STREAM_DETECT stream_track[MAX_STREAMS_TRACKED];
|
|
|
b37f23 |
+};
|
|
|
b37f23 |
+
|
|
|
b37f23 |
struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY {
|
|
|
b37f23 |
u64 RDPQBaseAddress;
|
|
|
b37f23 |
u32 Reserved1;
|
|
|
b37f23 |
@@ -983,6 +1093,7 @@ struct fusion_context {
|
|
|
b37f23 |
struct LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES_EXT];
|
|
|
b37f23 |
LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT];
|
|
|
b37f23 |
u8 adapter_type;
|
|
|
b37f23 |
+ struct LD_STREAM_DETECT **stream_detect_by_ld;
|
|
|
b37f23 |
};
|
|
|
b37f23 |
|
|
|
b37f23 |
union desc_value {
|
|
|
b37f23 |
--
|
|
|
b37f23 |
1.8.3.1
|
|
|
b37f23 |
|