Re: [PATCH v2 09/13] mpt3sas: scan and add nvme device after controller reset

2017-08-03 Thread Sreekanth Reddy
On Thu, Aug 3, 2017 at 12:10 PM, Hannes Reinecke  wrote:
> On 07/14/2017 03:22 PM, Suganath Prabu S wrote:
>> After Controller reset, Scan and add nvme device back to the topology.
>>
>> Signed-off-by: Chaitra P B 
>> Signed-off-by: Suganath Prabu S 
>> ---
>>  drivers/scsi/mpt3sas/mpt3sas_scsih.c |  194 
>> +-
>>  1 files changed, 190 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
>> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
>> index c5a131f..e3e803c 100644
>> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
>> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
>> @@ -4869,6 +4869,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
>> struct scsi_cmnd *scmd,
>>   char *desc_scsi_state = ioc->tmp_string;
>>   u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
>>   struct _sas_device *sas_device = NULL;
>> + struct _pcie_device *pcie_device = NULL;
>>   struct scsi_target *starget = scmd->device->sdev_target;
>>   struct MPT3SAS_TARGET *priv_target = starget->hostdata;
>>   char *device_str = NULL;
>> @@ -5001,6 +5002,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
>> struct scsi_cmnd *scmd,
>>   if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
>>   pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name,
>>   device_str, (unsigned long long)priv_target->sas_address);
>> + } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
>> + pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
>> + if (pcie_device) {
>> + pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n",
>> + ioc->name,
>> + (unsigned long long)pcie_device->wwid,
>> + pcie_device->port_num);
>> + if (pcie_device->enclosure_handle != 0)
>> + pr_info(MPT3SAS_FMT
>> + "\tenclosure logical id(0x%016llx), "
>> + "slot(%d)\n", ioc->name,
>> + (unsigned long long)
>> + pcie_device->enclosure_logical_id,
>> + pcie_device->slot);
>> + if (pcie_device->connector_name[0])
>> + pr_info(MPT3SAS_FMT
>> + "\tenclosure level(0x%04x),"
>> + "connector name( %s)\n",
>> + ioc->name, pcie_device->enclosure_level,
>> + pcie_device->connector_name);
>> + pcie_device_put(pcie_device);
>> + }
>>   } else {
>>   sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
>>   if (sas_device) {
>> @@ -5047,11 +5070,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
>> struct scsi_cmnd *scmd,
>>   struct sense_info data;
>>   _scsih_normalize_sense(scmd->sense_buffer, );
>>   pr_warn(MPT3SAS_FMT
>> - "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
>> count(%d)\n",
>> - ioc->name, data.skey,
>> - data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
>> +   "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
>> count(%d)\n",
>> +   ioc->name, data.skey,
>> +   data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
>>   }
>> -
>>   if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
>>   response_info = le32_to_cpu(mpi_reply->ResponseInfo);
>>   response_bytes = (u8 *)_info;
>> @@ -8512,6 +8534,130 @@ _scsih_search_responding_sas_devices(struct 
>> MPT3SAS_ADAPTER *ioc)
>>  }
>>
>>  /**
>> + * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
>> + * @ioc: per adapter object
>> + * @pcie_device_pg0: PCIe Device page 0
>> + *
>> + * After host reset, find out whether devices are still responding.
>> + * Used in _scsih_remove_unresponding_devices.
>> + *
>> + * Return nothing.
>> + */
>> +static void
>> +_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
>> + Mpi26PCIeDevicePage0_t *pcie_device_pg0)
>> +{
>> + struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
>> + struct scsi_target *starget;
>> + struct _pcie_device *pcie_device;
>> + unsigned long flags;
>> +
>> + spin_lock_irqsave(>pcie_device_lock, flags);
>> + list_for_each_entry(pcie_device, >pcie_device_list, list) {
>> + if ((pcie_device->wwid == pcie_device_pg0->WWID) &&
>> + (pcie_device->slot == pcie_device_pg0->Slot)) {
>> + pcie_device->responding = 1;
>> + starget = pcie_device->starget;
>> + if (starget && 

Re: [PATCH v2 09/13] mpt3sas: scan and add nvme device after controller reset

2017-08-03 Thread Sreekanth Reddy
On Thu, Aug 3, 2017 at 12:10 PM, Hannes Reinecke  wrote:
> On 07/14/2017 03:22 PM, Suganath Prabu S wrote:
>> After Controller reset, Scan and add nvme device back to the topology.
>>
>> Signed-off-by: Chaitra P B 
>> Signed-off-by: Suganath Prabu S 
>> ---
>>  drivers/scsi/mpt3sas/mpt3sas_scsih.c |  194 
>> +-
>>  1 files changed, 190 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
>> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
>> index c5a131f..e3e803c 100644
>> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
>> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
>> @@ -4869,6 +4869,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
>> struct scsi_cmnd *scmd,
>>   char *desc_scsi_state = ioc->tmp_string;
>>   u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
>>   struct _sas_device *sas_device = NULL;
>> + struct _pcie_device *pcie_device = NULL;
>>   struct scsi_target *starget = scmd->device->sdev_target;
>>   struct MPT3SAS_TARGET *priv_target = starget->hostdata;
>>   char *device_str = NULL;
>> @@ -5001,6 +5002,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
>> struct scsi_cmnd *scmd,
>>   if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
>>   pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name,
>>   device_str, (unsigned long long)priv_target->sas_address);
>> + } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
>> + pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
>> + if (pcie_device) {
>> + pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n",
>> + ioc->name,
>> + (unsigned long long)pcie_device->wwid,
>> + pcie_device->port_num);
>> + if (pcie_device->enclosure_handle != 0)
>> + pr_info(MPT3SAS_FMT
>> + "\tenclosure logical id(0x%016llx), "
>> + "slot(%d)\n", ioc->name,
>> + (unsigned long long)
>> + pcie_device->enclosure_logical_id,
>> + pcie_device->slot);
>> + if (pcie_device->connector_name[0])
>> + pr_info(MPT3SAS_FMT
>> + "\tenclosure level(0x%04x),"
>> + "connector name( %s)\n",
>> + ioc->name, pcie_device->enclosure_level,
>> + pcie_device->connector_name);
>> + pcie_device_put(pcie_device);
>> + }
>>   } else {
>>   sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
>>   if (sas_device) {
>> @@ -5047,11 +5070,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
>> struct scsi_cmnd *scmd,
>>   struct sense_info data;
>>   _scsih_normalize_sense(scmd->sense_buffer, );
>>   pr_warn(MPT3SAS_FMT
>> - "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
>> count(%d)\n",
>> - ioc->name, data.skey,
>> - data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
>> +   "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
>> count(%d)\n",
>> +   ioc->name, data.skey,
>> +   data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
>>   }
>> -
>>   if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
>>   response_info = le32_to_cpu(mpi_reply->ResponseInfo);
>>   response_bytes = (u8 *)_info;
>> @@ -8512,6 +8534,130 @@ _scsih_search_responding_sas_devices(struct 
>> MPT3SAS_ADAPTER *ioc)
>>  }
>>
>>  /**
>> + * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
>> + * @ioc: per adapter object
>> + * @pcie_device_pg0: PCIe Device page 0
>> + *
>> + * After host reset, find out whether devices are still responding.
>> + * Used in _scsih_remove_unresponding_devices.
>> + *
>> + * Return nothing.
>> + */
>> +static void
>> +_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
>> + Mpi26PCIeDevicePage0_t *pcie_device_pg0)
>> +{
>> + struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
>> + struct scsi_target *starget;
>> + struct _pcie_device *pcie_device;
>> + unsigned long flags;
>> +
>> + spin_lock_irqsave(>pcie_device_lock, flags);
>> + list_for_each_entry(pcie_device, >pcie_device_list, list) {
>> + if ((pcie_device->wwid == pcie_device_pg0->WWID) &&
>> + (pcie_device->slot == pcie_device_pg0->Slot)) {
>> + pcie_device->responding = 1;
>> + starget = pcie_device->starget;
>> + if (starget && starget->hostdata) {
>> + sas_target_priv_data = 

Re: [PATCH v2 09/13] mpt3sas: scan and add nvme device after controller reset

2017-08-03 Thread Hannes Reinecke
On 07/14/2017 03:22 PM, Suganath Prabu S wrote:
> After Controller reset, Scan and add nvme device back to the topology.
> 
> Signed-off-by: Chaitra P B 
> Signed-off-by: Suganath Prabu S 
> ---
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c |  194 
> +-
>  1 files changed, 190 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index c5a131f..e3e803c 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -4869,6 +4869,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
> struct scsi_cmnd *scmd,
>   char *desc_scsi_state = ioc->tmp_string;
>   u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
>   struct _sas_device *sas_device = NULL;
> + struct _pcie_device *pcie_device = NULL;
>   struct scsi_target *starget = scmd->device->sdev_target;
>   struct MPT3SAS_TARGET *priv_target = starget->hostdata;
>   char *device_str = NULL;
> @@ -5001,6 +5002,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
> struct scsi_cmnd *scmd,
>   if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
>   pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name,
>   device_str, (unsigned long long)priv_target->sas_address);
> + } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
> + pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
> + if (pcie_device) {
> + pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n",
> + ioc->name,
> + (unsigned long long)pcie_device->wwid,
> + pcie_device->port_num);
> + if (pcie_device->enclosure_handle != 0)
> + pr_info(MPT3SAS_FMT
> + "\tenclosure logical id(0x%016llx), "
> + "slot(%d)\n", ioc->name,
> + (unsigned long long)
> + pcie_device->enclosure_logical_id,
> + pcie_device->slot);
> + if (pcie_device->connector_name[0])
> + pr_info(MPT3SAS_FMT
> + "\tenclosure level(0x%04x),"
> + "connector name( %s)\n",
> + ioc->name, pcie_device->enclosure_level,
> + pcie_device->connector_name);
> + pcie_device_put(pcie_device);
> + }
>   } else {
>   sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
>   if (sas_device) {
> @@ -5047,11 +5070,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
> struct scsi_cmnd *scmd,
>   struct sense_info data;
>   _scsih_normalize_sense(scmd->sense_buffer, );
>   pr_warn(MPT3SAS_FMT
> - "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
> count(%d)\n",
> - ioc->name, data.skey,
> - data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
> +   "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n",
> +   ioc->name, data.skey,
> +   data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
>   }
> -
>   if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
>   response_info = le32_to_cpu(mpi_reply->ResponseInfo);
>   response_bytes = (u8 *)_info;
> @@ -8512,6 +8534,130 @@ _scsih_search_responding_sas_devices(struct 
> MPT3SAS_ADAPTER *ioc)
>  }
>  
>  /**
> + * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
> + * @ioc: per adapter object
> + * @pcie_device_pg0: PCIe Device page 0
> + *
> + * After host reset, find out whether devices are still responding.
> + * Used in _scsih_remove_unresponding_devices.
> + *
> + * Return nothing.
> + */
> +static void
> +_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
> + Mpi26PCIeDevicePage0_t *pcie_device_pg0)
> +{
> + struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
> + struct scsi_target *starget;
> + struct _pcie_device *pcie_device;
> + unsigned long flags;
> +
> + spin_lock_irqsave(>pcie_device_lock, flags);
> + list_for_each_entry(pcie_device, >pcie_device_list, list) {
> + if ((pcie_device->wwid == pcie_device_pg0->WWID) &&
> + (pcie_device->slot == pcie_device_pg0->Slot)) {
> + pcie_device->responding = 1;
> + starget = pcie_device->starget;
> + if (starget && starget->hostdata) {
> + sas_target_priv_data = starget->hostdata;
> + sas_target_priv_data->tm_busy = 0;
> + 

Re: [PATCH v2 09/13] mpt3sas: scan and add nvme device after controller reset

2017-08-03 Thread Hannes Reinecke
On 07/14/2017 03:22 PM, Suganath Prabu S wrote:
> After Controller reset, Scan and add nvme device back to the topology.
> 
> Signed-off-by: Chaitra P B 
> Signed-off-by: Suganath Prabu S 
> ---
>  drivers/scsi/mpt3sas/mpt3sas_scsih.c |  194 
> +-
>  1 files changed, 190 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
> b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index c5a131f..e3e803c 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -4869,6 +4869,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
> struct scsi_cmnd *scmd,
>   char *desc_scsi_state = ioc->tmp_string;
>   u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
>   struct _sas_device *sas_device = NULL;
> + struct _pcie_device *pcie_device = NULL;
>   struct scsi_target *starget = scmd->device->sdev_target;
>   struct MPT3SAS_TARGET *priv_target = starget->hostdata;
>   char *device_str = NULL;
> @@ -5001,6 +5002,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
> struct scsi_cmnd *scmd,
>   if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
>   pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name,
>   device_str, (unsigned long long)priv_target->sas_address);
> + } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
> + pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
> + if (pcie_device) {
> + pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n",
> + ioc->name,
> + (unsigned long long)pcie_device->wwid,
> + pcie_device->port_num);
> + if (pcie_device->enclosure_handle != 0)
> + pr_info(MPT3SAS_FMT
> + "\tenclosure logical id(0x%016llx), "
> + "slot(%d)\n", ioc->name,
> + (unsigned long long)
> + pcie_device->enclosure_logical_id,
> + pcie_device->slot);
> + if (pcie_device->connector_name[0])
> + pr_info(MPT3SAS_FMT
> + "\tenclosure level(0x%04x),"
> + "connector name( %s)\n",
> + ioc->name, pcie_device->enclosure_level,
> + pcie_device->connector_name);
> + pcie_device_put(pcie_device);
> + }
>   } else {
>   sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
>   if (sas_device) {
> @@ -5047,11 +5070,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
> struct scsi_cmnd *scmd,
>   struct sense_info data;
>   _scsih_normalize_sense(scmd->sense_buffer, );
>   pr_warn(MPT3SAS_FMT
> - "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
> count(%d)\n",
> - ioc->name, data.skey,
> - data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
> +   "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n",
> +   ioc->name, data.skey,
> +   data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
>   }
> -
>   if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
>   response_info = le32_to_cpu(mpi_reply->ResponseInfo);
>   response_bytes = (u8 *)_info;
> @@ -8512,6 +8534,130 @@ _scsih_search_responding_sas_devices(struct 
> MPT3SAS_ADAPTER *ioc)
>  }
>  
>  /**
> + * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
> + * @ioc: per adapter object
> + * @pcie_device_pg0: PCIe Device page 0
> + *
> + * After host reset, find out whether devices are still responding.
> + * Used in _scsih_remove_unresponding_devices.
> + *
> + * Return nothing.
> + */
> +static void
> +_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
> + Mpi26PCIeDevicePage0_t *pcie_device_pg0)
> +{
> + struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
> + struct scsi_target *starget;
> + struct _pcie_device *pcie_device;
> + unsigned long flags;
> +
> + spin_lock_irqsave(>pcie_device_lock, flags);
> + list_for_each_entry(pcie_device, >pcie_device_list, list) {
> + if ((pcie_device->wwid == pcie_device_pg0->WWID) &&
> + (pcie_device->slot == pcie_device_pg0->Slot)) {
> + pcie_device->responding = 1;
> + starget = pcie_device->starget;
> + if (starget && starget->hostdata) {
> + sas_target_priv_data = starget->hostdata;
> + sas_target_priv_data->tm_busy = 0;
> + sas_target_priv_data->deleted = 0;
> +   

[PATCH v2 09/13] mpt3sas: scan and add nvme device after controller reset

2017-07-14 Thread Suganath Prabu S
After Controller reset, Scan and add nvme device back to the topology.

Signed-off-by: Chaitra P B 
Signed-off-by: Suganath Prabu S 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  194 +-
 1 files changed, 190 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index c5a131f..e3e803c 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -4869,6 +4869,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct 
scsi_cmnd *scmd,
char *desc_scsi_state = ioc->tmp_string;
u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
struct _sas_device *sas_device = NULL;
+   struct _pcie_device *pcie_device = NULL;
struct scsi_target *starget = scmd->device->sdev_target;
struct MPT3SAS_TARGET *priv_target = starget->hostdata;
char *device_str = NULL;
@@ -5001,6 +5002,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct 
scsi_cmnd *scmd,
if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name,
device_str, (unsigned long long)priv_target->sas_address);
+   } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
+   pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
+   if (pcie_device) {
+   pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n",
+   ioc->name,
+   (unsigned long long)pcie_device->wwid,
+   pcie_device->port_num);
+   if (pcie_device->enclosure_handle != 0)
+   pr_info(MPT3SAS_FMT
+   "\tenclosure logical id(0x%016llx), "
+   "slot(%d)\n", ioc->name,
+   (unsigned long long)
+   pcie_device->enclosure_logical_id,
+   pcie_device->slot);
+   if (pcie_device->connector_name[0])
+   pr_info(MPT3SAS_FMT
+   "\tenclosure level(0x%04x),"
+   "connector name( %s)\n",
+   ioc->name, pcie_device->enclosure_level,
+   pcie_device->connector_name);
+   pcie_device_put(pcie_device);
+   }
} else {
sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
if (sas_device) {
@@ -5047,11 +5070,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
struct scsi_cmnd *scmd,
struct sense_info data;
_scsih_normalize_sense(scmd->sense_buffer, );
pr_warn(MPT3SAS_FMT
-   "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
count(%d)\n",
-   ioc->name, data.skey,
-   data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
+ "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n",
+ ioc->name, data.skey,
+ data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
}
-
if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
response_info = le32_to_cpu(mpi_reply->ResponseInfo);
response_bytes = (u8 *)_info;
@@ -8512,6 +8534,130 @@ _scsih_search_responding_sas_devices(struct 
MPT3SAS_ADAPTER *ioc)
 }
 
 /**
+ * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
+ * @ioc: per adapter object
+ * @pcie_device_pg0: PCIe Device page 0
+ *
+ * After host reset, find out whether devices are still responding.
+ * Used in _scsih_remove_unresponding_devices.
+ *
+ * Return nothing.
+ */
+static void
+_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
+   Mpi26PCIeDevicePage0_t *pcie_device_pg0)
+{
+   struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
+   struct scsi_target *starget;
+   struct _pcie_device *pcie_device;
+   unsigned long flags;
+
+   spin_lock_irqsave(>pcie_device_lock, flags);
+   list_for_each_entry(pcie_device, >pcie_device_list, list) {
+   if ((pcie_device->wwid == pcie_device_pg0->WWID) &&
+   (pcie_device->slot == pcie_device_pg0->Slot)) {
+   pcie_device->responding = 1;
+   starget = pcie_device->starget;
+   if (starget && starget->hostdata) {
+   sas_target_priv_data = starget->hostdata;
+   sas_target_priv_data->tm_busy = 0;
+   sas_target_priv_data->deleted = 0;
+   } else
+   

[PATCH v2 09/13] mpt3sas: scan and add nvme device after controller reset

2017-07-14 Thread Suganath Prabu S
After Controller reset, Scan and add nvme device back to the topology.

Signed-off-by: Chaitra P B 
Signed-off-by: Suganath Prabu S 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  194 +-
 1 files changed, 190 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index c5a131f..e3e803c 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -4869,6 +4869,7 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct 
scsi_cmnd *scmd,
char *desc_scsi_state = ioc->tmp_string;
u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
struct _sas_device *sas_device = NULL;
+   struct _pcie_device *pcie_device = NULL;
struct scsi_target *starget = scmd->device->sdev_target;
struct MPT3SAS_TARGET *priv_target = starget->hostdata;
char *device_str = NULL;
@@ -5001,6 +5002,28 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, struct 
scsi_cmnd *scmd,
if (priv_target->flags & MPT_TARGET_FLAGS_VOLUME) {
pr_warn(MPT3SAS_FMT "\t%s wwid(0x%016llx)\n", ioc->name,
device_str, (unsigned long long)priv_target->sas_address);
+   } else if (priv_target->flags & MPT_TARGET_FLAGS_PCIE_DEVICE) {
+   pcie_device = mpt3sas_get_pdev_from_target(ioc, priv_target);
+   if (pcie_device) {
+   pr_info(MPT3SAS_FMT "\twwid(0x%016llx), port(%d)\n",
+   ioc->name,
+   (unsigned long long)pcie_device->wwid,
+   pcie_device->port_num);
+   if (pcie_device->enclosure_handle != 0)
+   pr_info(MPT3SAS_FMT
+   "\tenclosure logical id(0x%016llx), "
+   "slot(%d)\n", ioc->name,
+   (unsigned long long)
+   pcie_device->enclosure_logical_id,
+   pcie_device->slot);
+   if (pcie_device->connector_name[0])
+   pr_info(MPT3SAS_FMT
+   "\tenclosure level(0x%04x),"
+   "connector name( %s)\n",
+   ioc->name, pcie_device->enclosure_level,
+   pcie_device->connector_name);
+   pcie_device_put(pcie_device);
+   }
} else {
sas_device = mpt3sas_get_sdev_from_target(ioc, priv_target);
if (sas_device) {
@@ -5047,11 +5070,10 @@ _scsih_scsi_ioc_info(struct MPT3SAS_ADAPTER *ioc, 
struct scsi_cmnd *scmd,
struct sense_info data;
_scsih_normalize_sense(scmd->sense_buffer, );
pr_warn(MPT3SAS_FMT
-   "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], 
count(%d)\n",
-   ioc->name, data.skey,
-   data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
+ "\t[sense_key,asc,ascq]: [0x%02x,0x%02x,0x%02x], count(%d)\n",
+ ioc->name, data.skey,
+ data.asc, data.ascq, le32_to_cpu(mpi_reply->SenseCount));
}
-
if (scsi_state & MPI2_SCSI_STATE_RESPONSE_INFO_VALID) {
response_info = le32_to_cpu(mpi_reply->ResponseInfo);
response_bytes = (u8 *)_info;
@@ -8512,6 +8534,130 @@ _scsih_search_responding_sas_devices(struct 
MPT3SAS_ADAPTER *ioc)
 }
 
 /**
+ * _scsih_mark_responding_pcie_device - mark a pcie_device as responding
+ * @ioc: per adapter object
+ * @pcie_device_pg0: PCIe Device page 0
+ *
+ * After host reset, find out whether devices are still responding.
+ * Used in _scsih_remove_unresponding_devices.
+ *
+ * Return nothing.
+ */
+static void
+_scsih_mark_responding_pcie_device(struct MPT3SAS_ADAPTER *ioc,
+   Mpi26PCIeDevicePage0_t *pcie_device_pg0)
+{
+   struct MPT3SAS_TARGET *sas_target_priv_data = NULL;
+   struct scsi_target *starget;
+   struct _pcie_device *pcie_device;
+   unsigned long flags;
+
+   spin_lock_irqsave(>pcie_device_lock, flags);
+   list_for_each_entry(pcie_device, >pcie_device_list, list) {
+   if ((pcie_device->wwid == pcie_device_pg0->WWID) &&
+   (pcie_device->slot == pcie_device_pg0->Slot)) {
+   pcie_device->responding = 1;
+   starget = pcie_device->starget;
+   if (starget && starget->hostdata) {
+   sas_target_priv_data = starget->hostdata;
+   sas_target_priv_data->tm_busy = 0;
+   sas_target_priv_data->deleted = 0;
+   } else
+   sas_target_priv_data = NULL;
+   if (starget) {
+