Re: [PATCH 1/7] megaraid_sas : Jbod sequence number support

2015-08-13 Thread Martin K. Petersen
 Sumit == Sumit Saxena sumit.sax...@avagotech.com writes:

Sumit I will create separate patch for these new flags which are not
Sumit related to JBOD sequence support. These flags are created to keep
Sumit APIs in sync across driver and firmware.

*nod*

 Why -1 here? Presumably MAX_PHYSICAL_DEVICES is a count, not an
 index.
Sumit Yes it is count only.  struct MR_PD_CFG_SEQ_NUM_SYNC has struct
Sumit MR_PD_CFG_SEQ as one of its member so struct MR_PD_CFG_SEQ
Sumit corresponding to PD index 0 is embedded inside struct
Sumit MR_PD_CFG_SEQ_NUM_SYNC. That's why -1 here.

OK. Just checking.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 1/7] megaraid_sas : Jbod sequence number support

2015-08-12 Thread Sumit Saxena
 -Original Message-
 From: Martin K. Petersen [mailto:martin.peter...@oracle.com]
 Sent: Wednesday, August 12, 2015 6:59 AM
 To: sumit.sax...@avagotech.com
 Cc: linux-scsi@vger.kernel.org; the...@redhat.com;
 martin.peter...@oracle.com; h...@infradead.org; jbottom...@parallels.com;
 kashyap.de...@avagotech.com; kiran-kumar.kast...@avagotech.com;
 uday.ling...@avagotech.com
 Subject: Re: [PATCH 1/7] megaraid_sas : Jbod sequence number support


 Sumit,

 @@ -973,7 +973,12 @@ struct megasas_ctrl_info {

   struct {
  #if defined(__BIG_ENDIAN_BITFIELD)
 - u32 reserved:12;
 + u32 reserved:7;
 + u32 useSeqNumJbodFP:1;
 + u32 supportExtendedSSCSize:1;
 + u32 supportDiskCacheSettingForSysPDs:1;
 + u32 supportCPLDUpdate:1;
 + u32 supportTTYLogCompression:1;
   u32 discardCacheDuringLDDelete:1;
   u32 supportSecurityonJBOD:1;
   u32 supportCacheBypassModes:1;
 @@ -1013,7 +1018,12 @@ struct megasas_ctrl_info {
   u32 supportCacheBypassModes:1;
   u32 supportSecurityonJBOD:1;
   u32 discardCacheDuringLDDelete:1;
 - u32 reserved:12;
 + u32 supportTTYLogCompression:1;
 + u32 supportCPLDUpdate:1;
 + u32 supportDiskCacheSettingForSysPDs:1;
 + u32 supportExtendedSSCSize:1;
 + u32 useSeqNumJbodFP:1;
 + u32 reserved:7;
  #endif
   } adapterOperations3;

 Looks like most of these new flags should be in a separate patch.
I will create separate patch for these new flags which are not related to
JBOD sequence support. These flags are created to keep APIs in sync across
driver and firmware.

 @@ -4482,6 +4506,62 @@ megasas_destroy_irqs(struct megasas_instance
 *instance) {  }

  /**
 + * megasas_setup_jbod_map -  setup jbod map for FP seq_number.
 + * @instance:Adapter soft state
 + * @is_probe:Driver probe check
 + *
 + * Return 0 on success.
 + */
 +void
 +megasas_setup_jbod_map(struct megasas_instance *instance) {
 + int i;
 + struct fusion_context *fusion = instance-ctrl_context;
 + u32 pd_seq_map_sz;
 +
 + pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
 + (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES -
 1));

 Why -1 here? Presumably MAX_PHYSICAL_DEVICES is a count, not an index.
Yes it is count only.  struct MR_PD_CFG_SEQ_NUM_SYNC has struct
MR_PD_CFG_SEQ as one of its member so struct MR_PD_CFG_SEQ corresponding
to PD index 0 is embedded inside struct MR_PD_CFG_SEQ_NUM_SYNC. That's
why -1 here.

 +
 + if (reset_devices || !fusion ||
 + !instance-ctrl_info-adapterOperations3.useSeqNumJbodFP)
{
 + dev_info(instance-pdev-dev,
 + Jbod map is not supported %s %d\n,
 + __func__, __LINE__);
 + instance-use_seqnum_jbod_fp = 0;

 Nitpick: It's a bool so use false. Occurs throughout the patch.
Agree, will do this.

 + return;
 + }
 +
 + if (fusion-pd_seq_sync[0])
 + goto skip_alloc;
 +
 + for (i = 0; i  2; i++) {

 Magic number. See comment below.

 @@ -5510,10 +5594,16 @@ static void megasas_shutdown_controller(struct
 megasas_instance *instance,

   if (instance-aen_cmd)
   megasas_issue_blocked_abort_cmd(instance,
 - instance-aen_cmd, 30);
 + instance-aen_cmd,
 + MEGASAS_BLOCKED_CMD_TIMEOUT);
   if (instance-map_update_cmd)
   megasas_issue_blocked_abort_cmd(instance,
 - instance-map_update_cmd, 30);
 + instance-map_update_cmd,
 + MEGASAS_BLOCKED_CMD_TIMEOUT);
 + if (instance-jbod_seq_cmd)
 + megasas_issue_blocked_abort_cmd(instance,
 + instance-jbod_seq_cmd,
 + MEGASAS_BLOCKED_CMD_TIMEOUT);
   dcmd = cmd-frame-dcmd;

 Nice cleanup but ideally those non-jbod timeouts would have been in a
separate
 patch. Please make sure your patches only do what they purport to do.
Agree, will create separate patch.


   memset(dcmd-mbox.b, 0, MFI_MBOX_SIZE); @@ -5648,6 +5738,7 @@
 megasas_resume(struct pci_dev *pdev)
   }
   if (!megasas_get_map_info(instance))
   megasas_sync_map_info(instance);
 +
   }
   break;
   default:

 Whitespace snafu.
Oops.. My bad. Will work on it.

 @@ -5781,6 +5874,9 @@ static void megasas_detach_one(struct pci_dev
 *pdev)
   case PCI_DEVICE_ID_LSI_INVADER:
   case PCI_DEVICE_ID_LSI_FURY:
   megasas_release_fusion(instance);
 + pd_seq_map_sz = sizeof(struct
 MR_PD_CFG_SEQ_NUM_SYNC) +
 + (sizeof(struct MR_PD_CFG_SEQ

Re: [PATCH 1/7] megaraid_sas : Jbod sequence number support

2015-08-11 Thread Martin K. Petersen

Sumit,

@@ -973,7 +973,12 @@ struct megasas_ctrl_info {
 
struct {
 #if defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:12;
+   u32 reserved:7;
+   u32 useSeqNumJbodFP:1;
+   u32 supportExtendedSSCSize:1;
+   u32 supportDiskCacheSettingForSysPDs:1;
+   u32 supportCPLDUpdate:1;
+   u32 supportTTYLogCompression:1;
u32 discardCacheDuringLDDelete:1;
u32 supportSecurityonJBOD:1;
u32 supportCacheBypassModes:1;
@@ -1013,7 +1018,12 @@ struct megasas_ctrl_info {
u32 supportCacheBypassModes:1;
u32 supportSecurityonJBOD:1;
u32 discardCacheDuringLDDelete:1;
-   u32 reserved:12;
+   u32 supportTTYLogCompression:1;
+   u32 supportCPLDUpdate:1;
+   u32 supportDiskCacheSettingForSysPDs:1;
+   u32 supportExtendedSSCSize:1;
+   u32 useSeqNumJbodFP:1;
+   u32 reserved:7;
 #endif
} adapterOperations3;
 
Looks like most of these new flags should be in a separate patch.

@@ -4482,6 +4506,62 @@ megasas_destroy_irqs(struct megasas_instance *instance) {
 }
 
 /**
+ * megasas_setup_jbod_map -setup jbod map for FP seq_number.
+ * @instance:  Adapter soft state
+ * @is_probe:  Driver probe check
+ *
+ * Return 0 on success.
+ */
+void
+megasas_setup_jbod_map(struct megasas_instance *instance)
+{
+   int i;
+   struct fusion_context *fusion = instance-ctrl_context;
+   u32 pd_seq_map_sz;
+
+   pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
+   (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1));

Why -1 here? Presumably MAX_PHYSICAL_DEVICES is a count, not an index.

+
+   if (reset_devices || !fusion ||
+   !instance-ctrl_info-adapterOperations3.useSeqNumJbodFP) {
+   dev_info(instance-pdev-dev,
+   Jbod map is not supported %s %d\n,
+   __func__, __LINE__);
+   instance-use_seqnum_jbod_fp = 0;

Nitpick: It's a bool so use false. Occurs throughout the patch.

+   return;
+   }
+
+   if (fusion-pd_seq_sync[0])
+   goto skip_alloc;
+
+   for (i = 0; i  2; i++) {

Magic number. See comment below.

@@ -5510,10 +5594,16 @@ static void megasas_shutdown_controller(struct 
megasas_instance *instance,
 
if (instance-aen_cmd)
megasas_issue_blocked_abort_cmd(instance,
-   instance-aen_cmd, 30);
+   instance-aen_cmd,
+   MEGASAS_BLOCKED_CMD_TIMEOUT);
if (instance-map_update_cmd)
megasas_issue_blocked_abort_cmd(instance,
-   instance-map_update_cmd, 30);
+   instance-map_update_cmd,
+   MEGASAS_BLOCKED_CMD_TIMEOUT);
+   if (instance-jbod_seq_cmd)
+   megasas_issue_blocked_abort_cmd(instance,
+   instance-jbod_seq_cmd,
+   MEGASAS_BLOCKED_CMD_TIMEOUT);
dcmd = cmd-frame-dcmd;

Nice cleanup but ideally those non-jbod timeouts would have been in a
separate patch. Please make sure your patches only do what they purport
to do.

 
memset(dcmd-mbox.b, 0, MFI_MBOX_SIZE);
@@ -5648,6 +5738,7 @@ megasas_resume(struct pci_dev *pdev)
}
if (!megasas_get_map_info(instance))
megasas_sync_map_info(instance);
+
}
break;
default:

Whitespace snafu.

@@ -5781,6 +5874,9 @@ static void megasas_detach_one(struct pci_dev *pdev)
case PCI_DEVICE_ID_LSI_INVADER:
case PCI_DEVICE_ID_LSI_FURY:
megasas_release_fusion(instance);
+   pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
+   (sizeof(struct MR_PD_CFG_SEQ) *
+   (MAX_PHYSICAL_DEVICES - 1));
for (i = 0; i  2 ; i++) {
if (fusion-ld_map[i])
dma_free_coherent(instance-pdev-dev,

Minus one again.

+   pd_sync = (void *)fusion-pd_seq_sync[(instance-pd_seq_map_id  1)];
+   pd_seq_h = fusion-pd_seq_phys[(instance-pd_seq_map_id  1)];
+   pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
+   (sizeof(struct MR_PD_CFG_SEQ) *
+   (MAX_PHYSICAL_DEVICES - 1));

Patch description could do with a description of the data structures you
set up.


+   /*Want to send all IO via FW path*/

Comment needs spaces.

@@ -828,6 +844,8 @@ struct fusion_context {
u32 current_map_sz;
u32 drv_map_sz;
u32 drv_map_pages;
+   struct MR_PD_CFG_SEQ_NUM_SYNC   *pd_seq_sync[2];
+   

[PATCH 1/7] megaraid_sas : Jbod sequence number support

2015-08-07 Thread Sumit.Saxena
Implemented JBOD map which will provide quick access for JBOD path and also 
provide sequence number.
This will help hardware to fail command to the FW in case of any sequence 
mismatch.

Fast Path IO for JBOD will refer JBOD map (which has sequence number per JBOD 
devices) 
instead of Raid map.  Earlier, driver use Raid map to get device handle for 
fast path IO,
which does not have sequence number information. Now, driver will use JBOD map 
for the same purpose.
As part of error handling, if JBOD map is failed/not supported by firmware; 
driver will continue legacy behavior.

Now there will be three IO path for JBOD (syspd)

JBOD map with sequence number (Fast Path)
Raid map without sequence number (Fast Path)
FW path via h/w exceptional queue deliberately setup devhandle 0x (FW path).

Driver send new DCMD MR_DCMD_SYSTEM_PD_MAP_GET_INFO for this purpose.

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---

diff --git a/megaraid_sas.h b/megaraid_sas.h
index 20c3754..45500ba 100644
--- a/megaraid_sas.h
+++ b/megaraid_sas.h
@@ -973,7 +973,12 @@ struct megasas_ctrl_info {
 
struct {
 #if defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:12;
+   u32 reserved:7;
+   u32 useSeqNumJbodFP:1;
+   u32 supportExtendedSSCSize:1;
+   u32 supportDiskCacheSettingForSysPDs:1;
+   u32 supportCPLDUpdate:1;
+   u32 supportTTYLogCompression:1;
u32 discardCacheDuringLDDelete:1;
u32 supportSecurityonJBOD:1;
u32 supportCacheBypassModes:1;
@@ -1013,7 +1018,12 @@ struct megasas_ctrl_info {
u32 supportCacheBypassModes:1;
u32 supportSecurityonJBOD:1;
u32 discardCacheDuringLDDelete:1;
-   u32 reserved:12;
+   u32 supportTTYLogCompression:1;
+   u32 supportCPLDUpdate:1;
+   u32 supportDiskCacheSettingForSysPDs:1;
+   u32 supportExtendedSSCSize:1;
+   u32 useSeqNumJbodFP:1;
+   u32 reserved:7;
 #endif
} adapterOperations3;
 
@@ -1690,6 +1700,7 @@ struct megasas_instance {
u32 crash_dump_drv_support;
u32 crash_dump_app_support;
u32 secure_jbod_support;
+   bool use_seqnum_jbod_fp;   /* Added for PD sequence */
spinlock_t crashdump_lock;
 
struct megasas_register_set __iomem *reg_set;
@@ -1769,7 +1780,9 @@ struct megasas_instance {
struct msix_entry msixentry[MEGASAS_MAX_MSIX_QUEUES];
struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
u64 map_id;
+   u64 pd_seq_map_id;
struct megasas_cmd *map_update_cmd;
+   struct megasas_cmd *jbod_seq_cmd;
unsigned long bar;
long reset_flags;
struct mutex reset_mutex;
@@ -1985,6 +1998,9 @@ __le16 get_updated_dev_handle(struct megasas_instance 
*instance,
 void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
struct LD_LOAD_BALANCE_INFO *lbInfo);
 int megasas_get_ctrl_info(struct megasas_instance *instance);
+/* PD sequence */
+int
+megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend);
 int megasas_set_crash_dump_params(struct megasas_instance *instance,
u8 crash_buf_state);
 void megasas_free_host_crash_buffer(struct megasas_instance *instance);
@@ -2000,5 +2016,6 @@ void __megasas_return_cmd(struct megasas_instance 
*instance,
 void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
struct megasas_cmd *cmd_mfi, struct megasas_cmd_fusion *cmd_fusion);
 int megasas_cmd_type(struct scsi_cmnd *cmd);
+void megasas_setup_jbod_map(struct megasas_instance *instance);
 
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/megaraid_sas_base.c b/megaraid_sas_base.c
index 71b884d..1843a50 100644
--- a/megaraid_sas_base.c
+++ b/megaraid_sas_base.c
@@ -2833,7 +2833,7 @@ megasas_complete_cmd(struct megasas_instance *instance, 
struct megasas_cmd *cmd,
struct megasas_header *hdr = cmd-frame-hdr;
unsigned long flags;
struct fusion_context *fusion = instance-ctrl_context;
-   u32 opcode;
+   u32 opcode, status;
 
/* flag for the retry reset */
cmd-retry_for_fw_reset = 0;
@@ -2941,6 +2941,7 @@ megasas_complete_cmd(struct megasas_instance *instance, 
struct megasas_cmd *cmd,
 (cmd-frame-dcmd.mbox.b[1] == 1)) {
fusion-fast_path_io = 0;
spin_lock_irqsave(instance-host-host_lock, flags);
+   instance-map_update_cmd = NULL;
if (cmd-frame-hdr.cmd_status != 0) {
if (cmd-frame-hdr.cmd_status !=
MFI_STAT_NOT_FOUND)
@@ -2979,6 +2980,27 @@ megasas_complete_cmd(struct