public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sujit Reddy Thumma <sthumma@codeaurora.org>
To: Santosh Y <santoshsy@gmail.com>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] scsi: ufs: Generalize UFS Interconnect Layer (UIC) command support
Date: Thu, 02 May 2013 17:03:22 +0530	[thread overview]
Message-ID: <51824F02.9070103@codeaurora.org> (raw)
In-Reply-To: <CALMYJDtE=GnETSi7KfLCWWqow3Let3Q5aL70ei3MkJKH6FWzFg@mail.gmail.com>

On 5/2/2013 12:49 PM, Santosh Y wrote:
>> -static inline void
>> -ufshcd_send_uic_command(struct ufs_hba *hba, struct uic_command *uic_cmnd)
>> +static int ufshcd_send_uic_command(struct ufs_hba *hba,
>> +               struct uic_command *uic_cmnd, int retries)
>>   {
>> +       int err = 0;
>> +       unsigned long flags;
>> +
>> +       if (unlikely(mutex_trylock(&hba->uic_cmd_mutex))) {
>> +               mutex_unlock(&hba->uic_cmd_mutex);
>> +               dev_err(hba->dev, "%s: called without prepare command\n",
>> +                               __func__);
>> +               BUG();
>> +       }
>> +
>> +retry:
>> +       /* check if controller is ready to accept UIC commands */
>> +       if (!(readl(hba->mmio_base + REG_CONTROLLER_STATUS) &
>> +                               UIC_COMMAND_READY)) {
>> +               dev_err(hba->dev, "Controller not ready to accept UIC commands\n");
>> +               err = -EIO;
>> +               goto out;
>> +       }
>> +
>> +       init_completion(&uic_cmnd->completion);
>> +
>> +       spin_lock_irqsave(hba->host->host_lock, flags);
>> +
>> +       /* enable UIC related interrupts */
>> +       if (!(hba->int_enable_mask & UIC_COMMAND_COMPL)) {
>> +               hba->int_enable_mask |= UIC_COMMAND_COMPL;
>> +               ufshcd_int_config(hba, UFSHCD_INT_ENABLE);
>> +       }
>> +
>
> No need to check if the interrupt is already enabled, it can be
> directly enabled.

That would be unnecessary device access (writel) every time we send a 
UIC command.

>
>
>>          /* Write Args */
>>          writel(uic_cmnd->argument1,
>>                (hba->mmio_base + REG_UIC_COMMAND_ARG_1));
>> @@ -415,6 +491,45 @@ ufshcd_send_uic_command(struct ufs_hba *hba, struct uic_command *uic_cmnd)
>>          /* Write UIC Cmd */
>>          writel((uic_cmnd->command & COMMAND_OPCODE_MASK),
>>                 (hba->mmio_base + REG_UIC_COMMAND));
>> +
>> +       /* flush to make sure h/w sees the write */
>> +       readl(hba->mmio_base + REG_UIC_COMMAND);
>> +
>> +       spin_unlock_irqrestore(hba->host->host_lock, flags);
>> +
>
> mutex lock/unlock can be done in the send_uic_command, It will
> simplify the process for the caller.

  ufshcd_dme_get_attr()
  {
    1) ufshcd_prepare_uic_command_lck();
    2) ufshcd_send_uic_command();
    3) Read arg3 to know the value of Uni-pro attribute.
    4) ufshcd_unprepare_uic_command_unlck();
  }

Step 3 above is optional for some of the UIC commands but when it is 
required it should be done with mutex lock held as the 
hba->active_uic_cmd might be modified by some one else before value 
present hba->active_uic_cmd->argument3 is read.

But thinking more on this holding lock only in send_uic_command() is 
feasible.

>
>> +       err = wait_for_completion_timeout(
>> +                       &uic_cmnd->completion, UIC_COMMAND_TIMEOUT);
>> +       if (!err) {
>> +               err = -ETIMEDOUT;
>> +       } else if (uic_cmnd->argument2 & MASK_UIC_COMMAND_RESULT) {
>> +               /* something bad with h/w or arguments, try again */
>> +               if (--retries)
>> +                       goto retry;
>> +
>

-- 
Regards,
Sujit

      reply	other threads:[~2013-05-02 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 16:57 [PATCH 1/1] scsi: ufs: Generalize UFS Interconnect Layer (UIC) command support Sujit Reddy Thumma
2013-05-02  7:19 ` Santosh Y
2013-05-02 11:33   ` Sujit Reddy Thumma [this message]

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=51824F02.9070103@codeaurora.org \
    --to=sthumma@codeaurora.org \
    --cc=JBottomley@parallels.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=santoshsy@gmail.com \
    --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