RE: [PATCH 08/37] smartpqi: add suspend and resume support

2017-05-03 Thread Don Brace
> -Original Message-
> On Tue, 2017-04-25 at 14:46 -0500, Don Brace wrote:
> > +static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info,
> > +   struct pqi_scsi_dev *device)
> > +{
> > +   while (atomic_read(>scsi_cmds_outstanding)) {
> > +   pqi_check_ctrl_health(ctrl_info);
> > +   if (pqi_ctrl_offline(ctrl_info))
> > +   return -ENXIO;
> > +   usleep_range(1000, 2000);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int pqi_ctrl_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info)
> > +{
> > +   bool io_pending;
> > +   unsigned long flags;
> > +   struct pqi_scsi_dev *device;
> > +
> > +   while (1) {
> > +   io_pending = false;
> > +
> > +   spin_lock_irqsave(_info->scsi_device_list_lock, flags);
> > +   list_for_each_entry(device, _info->scsi_device_list,
> > +   scsi_device_list_entry) {
> > +   if (atomic_read(>scsi_cmds_outstanding)) {
> > +   io_pending = true;
> > +   break;
> > +   }
> > +   }
> > +   spin_unlock_irqrestore(_info->scsi_device_list_lock,
> > +   flags);
> > +
> > +   if (!io_pending)
> > +   break;
> > +
> > +   pqi_check_ctrl_health(ctrl_info);
> > +   if (pqi_ctrl_offline(ctrl_info))
> > +   return -ENXIO;
> > +
> > +   usleep_range(1000, 2000);
> > +   }
> > +
> > +   return 0;
> > +}
> 
> The same comment applies here that applies to the previous patch: please
> use
> scsi_target_block() / scsi_target_unblock() instead of reimplementing these
> functions.
> 
> Thanks,
> 
> Bart.

Our LUN reset functions have to do several PQI-specific things in order to work 
correctly,
which is why we did not use scsi_target_block()/scsi_target_unblock()

Hope this is acceptable

Thanks for your review
Don Brace
ESC - Smart Storage
Microsemi Corporation



Re: [PATCH 08/37] smartpqi: add suspend and resume support

2017-04-25 Thread Bart Van Assche
On Tue, 2017-04-25 at 14:46 -0500, Don Brace wrote:
> +static int pqi_device_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info,
> +   struct pqi_scsi_dev *device)
> +{
> +   while (atomic_read(>scsi_cmds_outstanding)) {
> +   pqi_check_ctrl_health(ctrl_info);
> +   if (pqi_ctrl_offline(ctrl_info))
> +   return -ENXIO;
> +   usleep_range(1000, 2000);
> +   }
> +
> +   return 0;
> +}
> +
> +static int pqi_ctrl_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info)
> +{
> +   bool io_pending;
> +   unsigned long flags;
> +   struct pqi_scsi_dev *device;
> +
> +   while (1) {
> +   io_pending = false;
> +
> +   spin_lock_irqsave(_info->scsi_device_list_lock, flags);
> +   list_for_each_entry(device, _info->scsi_device_list,
> +   scsi_device_list_entry) {
> +   if (atomic_read(>scsi_cmds_outstanding)) {
> +   io_pending = true;
> +   break;
> +   }
> +   }
> +   spin_unlock_irqrestore(_info->scsi_device_list_lock,
> +   flags);
> +
> +   if (!io_pending)
> +   break;
> +
> +   pqi_check_ctrl_health(ctrl_info);
> +   if (pqi_ctrl_offline(ctrl_info))
> +   return -ENXIO;
> +
> +   usleep_range(1000, 2000);
> +   }
> +
> +   return 0;
> +}

The same comment applies here that applies to the previous patch: please use
scsi_target_block() / scsi_target_unblock() instead of reimplementing these
functions.

Thanks,

Bart.