Re: [PATCHv4 11/12] mpt3sas: simplify _wait_for_commands_to_complete()
On 03/03/2017 12:57 PM, Sreekanth Reddy wrote: On Wed, Feb 22, 2017 at 4:01 PM, Hannes Reineckewrote: Use 'host_busy' instead of counting outstanding commands by hand. Suggested-by: Christoph Hellwig Signed-off-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index e6aafa5..169d185 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -2408,9 +2408,9 @@ struct scsiio_tracker * * See _wait_for_commands_to_complete() call with regards to this code. */ if (ioc->shost_recovery && ioc->pending_io_count) { - if (ioc->pending_io_count == 1) + ioc->pending_io_count = atomic_read(>shost->host_busy); This won't consider the scsi IO issued from ioctl path. If that scsi io is still outstanding then here we will return without waiting for it to complete. True. Will be fixing it up. Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage h...@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCHv4 11/12] mpt3sas: simplify _wait_for_commands_to_complete()
On Wed, Feb 22, 2017 at 4:01 PM, Hannes Reineckewrote: > Use 'host_busy' instead of counting outstanding commands by hand. > > Suggested-by: Christoph Hellwig > Signed-off-by: Hannes Reinecke > --- > drivers/scsi/mpt3sas/mpt3sas_base.c | 14 -- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c > b/drivers/scsi/mpt3sas/mpt3sas_base.c > index e6aafa5..169d185 100644 > --- a/drivers/scsi/mpt3sas/mpt3sas_base.c > +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c > @@ -2408,9 +2408,9 @@ struct scsiio_tracker * > * See _wait_for_commands_to_complete() call with regards to this > code. > */ > if (ioc->shost_recovery && ioc->pending_io_count) { > - if (ioc->pending_io_count == 1) > + ioc->pending_io_count = atomic_read(>shost->host_busy); This won't consider the scsi IO issued from ioctl path. If that scsi io is still outstanding then here we will return without waiting for it to complete. > + if (ioc->pending_io_count == 0) > wake_up(>reset_wq); > - ioc->pending_io_count--; > } > } > > @@ -5687,15 +5687,13 @@ struct scsiio_tracker * > * _wait_for_commands_to_complete - reset controller > * @ioc: Pointer to MPT_ADAPTER structure > * > - * This function waiting(3s) for all pending commands to complete > + * This function is waiting 10s for all pending commands to complete > * prior to putting controller in reset. > */ > static void > _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) > { > u32 ioc_state; > - unsigned long flags; > - u16 i; > > ioc->pending_io_count = 0; > > @@ -5704,11 +5702,7 @@ struct scsiio_tracker * > return; > > /* pending command count */ > - spin_lock_irqsave(>scsi_lookup_lock, flags); > - for (i = 0; i < ioc->scsiio_depth; i++) > - if (ioc->scsi_lookup[i].cb_idx != 0xFF) > - ioc->pending_io_count++; > - spin_unlock_irqrestore(>scsi_lookup_lock, flags); > + ioc->pending_io_count = atomic_read(>shost->host_busy); > > if (!ioc->pending_io_count) > return; > -- > 1.8.5.6 >
[PATCHv4 11/12] mpt3sas: simplify _wait_for_commands_to_complete()
Use 'host_busy' instead of counting outstanding commands by hand. Suggested-by: Christoph HellwigSigned-off-by: Hannes Reinecke --- drivers/scsi/mpt3sas/mpt3sas_base.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index e6aafa5..169d185 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -2408,9 +2408,9 @@ struct scsiio_tracker * * See _wait_for_commands_to_complete() call with regards to this code. */ if (ioc->shost_recovery && ioc->pending_io_count) { - if (ioc->pending_io_count == 1) + ioc->pending_io_count = atomic_read(>shost->host_busy); + if (ioc->pending_io_count == 0) wake_up(>reset_wq); - ioc->pending_io_count--; } } @@ -5687,15 +5687,13 @@ struct scsiio_tracker * * _wait_for_commands_to_complete - reset controller * @ioc: Pointer to MPT_ADAPTER structure * - * This function waiting(3s) for all pending commands to complete + * This function is waiting 10s for all pending commands to complete * prior to putting controller in reset. */ static void _wait_for_commands_to_complete(struct MPT3SAS_ADAPTER *ioc) { u32 ioc_state; - unsigned long flags; - u16 i; ioc->pending_io_count = 0; @@ -5704,11 +5702,7 @@ struct scsiio_tracker * return; /* pending command count */ - spin_lock_irqsave(>scsi_lookup_lock, flags); - for (i = 0; i < ioc->scsiio_depth; i++) - if (ioc->scsi_lookup[i].cb_idx != 0xFF) - ioc->pending_io_count++; - spin_unlock_irqrestore(>scsi_lookup_lock, flags); + ioc->pending_io_count = atomic_read(>shost->host_busy); if (!ioc->pending_io_count) return; -- 1.8.5.6