From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Van Assche Subject: Re: [PATCH 08/37] smartpqi: add suspend and resume support Date: Tue, 25 Apr 2017 20:05:28 +0000 Message-ID: <1493150725.2628.13.camel@sandisk.com> References: <149314950730.13903.644081079070695025.stgit@brunhilda> <149314960079.13903.626198058289190508.stgit@brunhilda> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from esa2.hgst.iphmx.com ([68.232.143.124]:10718 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1953795AbdDYUFt (ORCPT ); Tue, 25 Apr 2017 16:05:49 -0400 In-Reply-To: <149314960079.13903.626198058289190508.stgit@brunhilda> Content-Language: en-US Content-ID: Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: "hch@infradead.org" , "Viswas.G@microsemi.com" , "gerry.morong@microsemi.com" , "Mahesh.Rajashekhara@microsemi.com" , "POSWALD@suse.com" , "scott.benesh@microsemi.com" , "don.brace@microsemi.com" , "bader.alisaleh@microsemi.com" , "Kevin.Barnett@microsemi.com" , "joseph.szczypek@hpe.com" , "scott.teel@microsemi.com" , "jejb@linux.vnet.ibm.com" , "Justin.Lindley@microsemi.com" , "john.hall@microsemi.com" Cc: "linux-scsi@vger.kernel.org" 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_inf= o, > +=A0=A0=A0=A0=A0=A0=A0struct pqi_scsi_dev *device) > +{ > +=A0=A0=A0=A0=A0=A0=A0while (atomic_read(&device->scsi_cmds_outstanding))= { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0pqi_check_ctrl_health(ctrl_= info); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (pqi_ctrl_offline(ctrl_i= nfo)) > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret= urn -ENXIO; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0usleep_range(1000, 2000); > +=A0=A0=A0=A0=A0=A0=A0} > + > +=A0=A0=A0=A0=A0=A0=A0return 0; > +} > + > +static int pqi_ctrl_wait_for_pending_io(struct pqi_ctrl_info *ctrl_info) > +{ > +=A0=A0=A0=A0=A0=A0=A0bool io_pending; > +=A0=A0=A0=A0=A0=A0=A0unsigned long flags; > +=A0=A0=A0=A0=A0=A0=A0struct pqi_scsi_dev *device; > + > +=A0=A0=A0=A0=A0=A0=A0while (1) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0io_pending =3D false; > + > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0spin_lock_irqsave(&ctrl_inf= o->scsi_device_list_lock, flags); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0list_for_each_entry(device,= &ctrl_info->scsi_device_list, > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0scs= i_device_list_entry) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if = (atomic_read(&device->scsi_cmds_outstanding)) { > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0io_pending =3D true; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0break; > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0} > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0spin_unlock_irqrestore(&ctr= l_info->scsi_device_list_lock, > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0flags); > + > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (!io_pending) > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0bre= ak; > + > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0pqi_check_ctrl_health(ctrl_= info); > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (pqi_ctrl_offline(ctrl_i= nfo)) > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0ret= urn -ENXIO; > + > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0usleep_range(1000, 2000); > +=A0=A0=A0=A0=A0=A0=A0} > + > +=A0=A0=A0=A0=A0=A0=A0return 0; > +} The same comment applies here that applies to the previous patch: please us= e scsi_target_block() / scsi_target_unblock() instead of reimplementing these functions. Thanks, Bart.=