mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "ebiggers@google.com" <ebiggers@google.com>,
	"James.Bottomley@HansenPartnership.com"
	<James.Bottomley@HansenPartnership.com>,
	"quic_ziqichen@quicinc.com" <quic_ziqichen@quicinc.com>,
	"tanghuan@vivo.com" <tanghuan@vivo.com>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"keosung.park@samsung.com" <keosung.park@samsung.com>,
	"beanhuo@micron.com" <beanhuo@micron.com>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"gwendal@chromium.org" <gwendal@chromium.org>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"manivannan.sadhasivam@linaro.org"
	<manivannan.sadhasivam@linaro.org>,
	"minwoo.im@samsung.com" <minwoo.im@samsung.com>,
	"quic_nguyenb@quicinc.com" <quic_nguyenb@quicinc.com>,
	"avri.altman@wdc.com" <avri.altman@wdc.com>,
	"quic_cang@quicinc.com" <quic_cang@quicinc.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Cc: "luhongfei@vivo.com" <luhongfei@vivo.com>,
	"opensource.kernel@vivo.com" <opensource.kernel@vivo.com>,
	"wenxing.cheng@vivo.com" <wenxing.cheng@vivo.com>
Subject: Re: [PATCH] ufs: core: Add HID support
Date: Tue, 22 Apr 2025 07:37:31 +0000	[thread overview]
Message-ID: <59e91374fb4232ba22c8d80defe7ee65666dbd40.camel@mediatek.com> (raw)
In-Reply-To: <20250417125008.123-1-tanghuan@vivo.com>

On Thu, 2025-04-17 at 20:50 +0800, Huan Tang wrote:
> +
> +#define HID_SCHED_COUNT_LIMIT  300
> +static int hid_sched_cnt;
> +static void ufs_hid_enable_work_fn(struct work_struct *work)
> +{
> +       struct ufs_hba *hba;
> +       int ret = 0;
> +       enum ufs_hid_defrag_operation defrag_op;
> +       u32 hid_ahit = 0;
> +       bool hid_flag = false;
> +
> +       hba = container_of(work, struct ufs_hba,
> ufs_hid_enable_work.work);
> +
> +       if (!hba->dev_info.hid_sup)
> +               return;
> +
> +       down(&hba->host_sem);
> +
> +       if (!ufshcd_is_user_access_allowed(hba)) {
> +               up(&hba->host_sem);
> +               return;
> +       }
> +
> +       ufshcd_rpm_get_sync(hba);
> +       hid_ahit = hba->ahit;
> +       ufshcd_auto_hibern8_update(hba, 0);
> +
> +       ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
> +                       QUERY_ATTR_IDN_HID_STATE, 0, 0, &hba-
> >dev_info.hid_state);
> +       if (ret)
> +               hba->dev_info.hid_state = HID_IDLE;
> +
> +       switch (hba->dev_info.hid_state) {
> +       case HID_IDLE:
> +               defrag_op = HID_ANALYSIS_ENABLE;
> 

Hi Huan,

Can change to HID_ANALYSIS_AND_DEFRAG_ENABLE to save defragment time?


> +               hid_flag = true;
> +               break;
> +       case DEFRAG_REQUIRED:
> +               defrag_op = HID_ANALYSIS_AND_DEFRAG_ENABLE;
> +               hid_flag = true;
> +               break;
> +       case DEFRAG_COMPLETED:
> +       case DEFRAG_IS_NOT_REQUIRED:
> +               defrag_op = HID_ANALYSIS_AND_DEFRAG_DISABLE;
> +               hid_flag = true;
> +               break;
> 

Can just break? Because according the spec. 
After the host reads the bHIDState value when it is 04h (Defrag
Completion) or 05h (Defrag Not Required), the following parameters
shall be initialized: 
bHIDState value to 00h (Idle)


> 
> @@ -9614,6 +9619,8 @@ static int __ufshcd_wl_suspend(struct ufs_hba
> *hba, enum ufs_pm_op pm_op)
>                 req_link_state = UIC_LINK_OFF_STATE;
>         }
> 
> +       if (hba->dev_info.hid_sup)
> +               cancel_delayed_work_sync(&hba->ufs_hid_enable_work);
> 

Will have dead-lock when ufs_hid_enable_work_fn invoke
ufshcd_rpm_get_sync?


>         /*
>          * If we can't transition into any of the low power modes
>          * just gate the clocks.
> diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h
> index 8a24ed59ec46..6e8546024e09 100644
> --- a/include/ufs/ufs.h
> +++ b/include/ufs/ufs.h
> 
>  /* Descriptor idn for Query requests */
> @@ -390,6 +395,7 @@ enum {
>         UFS_DEV_EXT_TEMP_NOTIF          = BIT(6),
>         UFS_DEV_HPB_SUPPORT             = BIT(7),
>         UFS_DEV_WRITE_BOOSTER_SUP       = BIT(8),
> +       UFS_DEV_HID_SUPPORT     = BIT(13),
> 

Please align the arrangement of these enums.


>  };
>  #define UFS_DEV_HPB_SUPPORT_VERSION            0x310
> 
> @@ -454,6 +460,23 @@ enum ufs_ref_clk_freq {
>         REF_CLK_FREQ_INVAL      = -1,
>  };
> 
> +/* bDefragOperation attribute values */
> +enum ufs_hid_defrag_operation {
> +       HID_ANALYSIS_AND_DEFRAG_DISABLE = 0,
> +       HID_ANALYSIS_ENABLE     = 1,
> +       HID_ANALYSIS_AND_DEFRAG_ENABLE  = 2,
> 

Please align the arrangement of these enums.


> +};
> +
> +/* bHIDState attribute values */
> +enum ufs_hid_state {
> +       HID_IDLE        = 0,
> +       ANALYSIS_IN_PROGRESS    = 1,
> +       DEFRAG_REQUIRED = 2,
> +       DEFRAG_IN_PROGRESS      = 3,
> +       DEFRAG_COMPLETED        = 4,
> +       DEFRAG_IS_NOT_REQUIRED  = 5,
> 

Please align the arrangement of these enums.

Thanks.
Peter





  parent reply	other threads:[~2025-04-22  7:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 12:50 Huan Tang
2025-04-17 22:05 ` Bart Van Assche
2025-05-12 13:35   ` Huan Tang
2025-04-18  8:05 ` Avri Altman
2025-05-12 13:36   ` Huan Tang
2025-04-22  7:37 ` Peter Wang (王信友) [this message]
2025-05-12 13:37   ` Huan Tang

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=59e91374fb4232ba22c8d80defe7ee65666dbd40.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=ebiggers@google.com \
    --cc=gwendal@chromium.org \
    --cc=keosung.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luhongfei@vivo.com \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=martin.petersen@oracle.com \
    --cc=minwoo.im@samsung.com \
    --cc=opensource.kernel@vivo.com \
    --cc=quic_cang@quicinc.com \
    --cc=quic_nguyenb@quicinc.com \
    --cc=quic_ziqichen@quicinc.com \
    --cc=tanghuan@vivo.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wenxing.cheng@vivo.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®