linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Santosh Y <santoshsy@gmail.com>
To: Sujit Reddy Thumma <sthumma@codeaurora.org>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH V2 3/4] scsi: ufs: Fix device and host reset methods
Date: Wed, 3 Jul 2013 11:19:56 +0530	[thread overview]
Message-ID: <CALMYJDuq17Q6WBSy6BkFnbXwSRc3no4wopK0eToQ2=y2DCqM-g@mail.gmail.com> (raw)
In-Reply-To: <1372444531-24340-4-git-send-email-sthumma@codeaurora.org>

> +
> +/**
> + * ufshcd_eh_device_reset_handler - device reset handler registered to
> + *                                    scsi layer.
> + * @cmd - SCSI command pointer
> + *
> + * Returns SUCCESS/FAILED
> + */
> +static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
> +{
> +       struct ufs_hba *hba;
> +       int err;
> +       unsigned long flags;
> +
> +       hba = shost_priv(cmd->device->host);
> +
> +       spin_lock_irqsave(hba->host->host_lock, flags);
> +       if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
> +               dev_warn(hba->dev, "%s: reset in progress\n", __func__);
> +               err = SUCCESS;
> +               spin_unlock_irqrestore(hba->host->host_lock, flags);
> +               goto out;

It is better to wait here until the state changes to 'operational' or
'error' before returning success.

> +       }
> +
> +       hba->ufshcd_state = UFSHCD_STATE_RESET;
> +       ufshcd_set_device_reset_pending(hba);
> +       spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> +       err = ufshcd_reset_and_restore(hba);
> +
> +       spin_lock_irqsave(hba->host->host_lock, flags);
> +       if (!err) {
> +               err = SUCCESS;
> +               hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
> +       } else {
> +               err = FAILED;
> +               hba->ufshcd_state = UFSHCD_STATE_ERROR;
> +       }
> +       spin_unlock_irqrestore(hba->host->host_lock, flags);
> +out:
> +       return err;
> +}
> +
> +/**
> + * ufshcd_eh_host_reset_handler - host reset handler registered to scsi layer
> + * @cmd - SCSI command pointer
> + *
> + * Returns SUCCESS/FAILED
> + */
> +static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +{
> +       struct ufs_hba *hba;
> +       int err;
> +       unsigned long flags;
> +
> +       hba = shost_priv(cmd->device->host);
> +
> +       spin_lock_irqsave(hba->host->host_lock, flags);
> +       if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
> +               dev_warn(hba->dev, "%s: reset in progress\n", __func__);
> +               err = SUCCESS;
> +               spin_unlock_irqrestore(hba->host->host_lock, flags);
> +               goto out;

same in this case also.

> +       }
> +
> +       hba->ufshcd_state = UFSHCD_STATE_RESET;
> +       ufshcd_set_host_reset_pending(hba);
> +       spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> +       err = ufshcd_reset_and_restore(hba);
> +
> +       spin_lock_irqsave(hba->host->host_lock, flags);
> +       if (!err) {
> +               err = SUCCESS;
> +               hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
> +       } else {
> +               err = FAILED;
> +               hba->ufshcd_state = UFSHCD_STATE_ERROR;
> +       }
> +       spin_unlock_irqrestore(hba->host->host_lock, flags);
> +out:
> +       return err;
> +}
> +
> +/**

-- 
~Santosh

  reply	other threads:[~2013-07-03  5:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-28 18:35 [PATCH V2 0/4] scsi: ufs: Improve UFS error handling Sujit Reddy Thumma
2013-06-28 18:35 ` [PATCH V2 1/4] scsi: ufs: Fix broken task management command implementation Sujit Reddy Thumma
2013-06-28 18:35 ` [PATCH V2 2/4] scsi: ufs: Fix hardware race conditions while aborting a command Sujit Reddy Thumma
2013-06-28 18:35 ` [PATCH V2 3/4] scsi: ufs: Fix device and host reset methods Sujit Reddy Thumma
2013-07-03  5:49   ` Santosh Y [this message]
2013-07-03 16:35     ` Sujit Reddy Thumma
2013-06-28 18:35 ` [PATCH V2 4/4] scsi: ufs: Improve UFS fatal error handling Sujit Reddy Thumma
2013-07-03 16:52   ` Santosh Y
2013-07-04  7:44     ` Sujit Reddy Thumma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALMYJDuq17Q6WBSy6BkFnbXwSRc3no4wopK0eToQ2=y2DCqM-g@mail.gmail.com' \
    --to=santoshsy@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sthumma@codeaurora.org \
    --cc=vinholikatti@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).