mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avri Altman <Avri.Altman@wdc.com>
To: Kiwoong Kim <kwmad.kim@samsung.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"beanhuo@micron.com" <beanhuo@micron.com>,
	"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
	"sc.suh@samsung.com" <sc.suh@samsung.com>,
	"hy50.seo@samsung.com" <hy50.seo@samsung.com>,
	"sh425.lee@samsung.com" <sh425.lee@samsung.com>,
	"kwangwon.min@samsung.com" <kwangwon.min@samsung.com>,
	"junwoo80.lee@samsung.com" <junwoo80.lee@samsung.com>
Subject: RE: [PATCH v2 2/3] ufs: poll HCS.UCRDY before issuing a UIC command
Date: Mon, 5 Jun 2023 07:05:58 +0000	[thread overview]
Message-ID: <DM6PR04MB6575F26AC01FD6C9D4D5ED3DFC4DA@DM6PR04MB6575.namprd04.prod.outlook.com> (raw)
In-Reply-To: <40006660eaece22f76b9532c70479d719655b33f.1685927620.git.kwmad.kim@samsung.com>

 
> v1 -> v2: replace usleep_range with udelay because it's a sleepable period.
> 
> With auto hibern8 enabled, UIC could be working for a while to process a
> hibern8 operation and HCI reports UIC not ready for a short term through
> HCS.UCRDY.
> And UFS driver can't recognize the operation.
> UFSHCI spec specifies UCRDY like this:
> whether the host controller is ready to process UIC COMMAND
> 
> The 'ready' could be seen as many different meanings. If the meaning includes
> not processing any request from HCI, processing a hibern8 operation can be
> 'not ready'. In this situation, the driver needs to wait until the operations is
> completed.
> 
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
>  drivers/ufs/core/ufshcd.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> a89d39a..1f58a20 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2365,7 +2365,18 @@ static inline int ufshcd_hba_capabilities(struct
> ufs_hba *hba)
>   */
>  static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)  {
> -       return ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
> UIC_COMMAND_READY;
> +       ktime_t timeout = ktime_add_ms(ktime_get(), UIC_CMD_TIMEOUT);
> +       u32 val = 0;
> +
> +       do {
> +               val = ufshcd_readl(hba, REG_CONTROLLER_STATUS) &
> +                       UIC_COMMAND_READY;
> +               if (val)
> +                       break;
> +               udelay(500);
> +       } while (ktime_before(ktime_get(), timeout));
> +
> +       return val ? true : false;
>  }
Can you use read_poll_timeout() instead?

Thanks,
Avri

> 
>  /**
> --
> 2.7.4


  reply	other threads:[~2023-06-05  7:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230605012505epcas2p4fa6facb5ad68289d0e7904bc77ea8506@epcas2p4.samsung.com>
2023-06-05  1:15 ` [PATCH v2 0/3] change UIC command handling Kiwoong Kim
     [not found]   ` <CGME20230605012506epcas2p2c487b751827e3a39c74fdbd88dbd1311@epcas2p2.samsung.com>
2023-06-05  1:15     ` [PATCH v2 1/3] ufs: make __ufshcd_send_uic_cmd not wrapped by host_lock Kiwoong Kim
2023-06-07 18:54       ` Bart Van Assche
     [not found]   ` <CGME20230605012507epcas2p3ecc0a358b558fe09d74a56b67b6477d2@epcas2p3.samsung.com>
2023-06-05  1:15     ` [PATCH v2 2/3] ufs: poll HCS.UCRDY before issuing a UIC command Kiwoong Kim
2023-06-05  7:05       ` Avri Altman [this message]
     [not found]   ` <CGME20230605012508epcas2p140e42906361b870e20b1e734e9e4df06@epcas2p1.samsung.com>
2023-06-05  1:15     ` [PATCH v2 3/3] ufs: poll pmc until another pa request is completed Kiwoong Kim
2023-06-07 19:01       ` Bart Van Assche

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=DM6PR04MB6575F26AC01FD6C9D4D5ED3DFC4DA@DM6PR04MB6575.namprd04.prod.outlook.com \
    --to=avri.altman@wdc.com \
    --cc=adrian.hunter@intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=hy50.seo@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=junwoo80.lee@samsung.com \
    --cc=kwangwon.min@samsung.com \
    --cc=kwmad.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sc.suh@samsung.com \
    --cc=sh425.lee@samsung.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

all inboxes | Powered by JetHome®