Re: [EXT] [PATCH 2/3] scsi: ufs: Allow resetting the UFS device

From: John Stultz
Date: Tue Jun 04 2019 - 14:14:14 EST


On Tue, Jun 4, 2019 at 1:14 AM Bean Huo (beanhuo) <beanhuo@xxxxxxxxxx> wrote:
>
> Hi, Bjorn
>
> >Acquire the device-reset GPIO and toggle this to reset the UFS device during
> >initialization and host reset.
> >
> >+/**
> >+ ufshcd_device_reset() - toggle the (optional) device reset line
> >+ * @hba: per-adapter instance
> >+ *
> >+ * Toggles the (optional) reset line to reset the attached device.
> >+ */
> >+static void ufshcd_device_reset(struct ufs_hba *hba) {
> >+ /*
> >+ * The USB device shall detect reset pulses of 1us, sleep for 10us to
> >+ * be on the safe side.
> >+ */
> >+ gpiod_set_value_cansleep(hba->device_reset, 1);
> >+ usleep_range(10, 15);
> >+
> >+ gpiod_set_value_cansleep(hba->device_reset, 0);
> >+ usleep_range(10, 15);
> >+}
> >+
> > /**
> > * ufshcd_host_reset_and_restore - reset and restore host controller
> > * @hba: per-adapter instance
> >@@ -6159,6 +6179,9 @@ static int ufshcd_reset_and_restore(struct ufs_hba
> >*hba)
> > int retries = MAX_HOST_RESET_RETRIES;
> >
> > do {
> >+ /* Reset the attached device */
> >+ ufshcd_device_reset(hba);
> >+
>
> what's problem you met, and you should reset UFS device here? could you give more info?

On the pixel3, devices with micron UFS chips won't boot upstream
kernels without this patch, which is a rewrite of an earlier patch:
https://git.linaro.org/people/john.stultz/android-dev.git/commit/?h=dev/p3&id=99f3dd8519a848b752679584451c45f42c326a17

Which was pulled from the downstream tree from here:
https://android.googlesource.com/kernel/msm.git/+/9c8077087e818017%5E%21/

CCing Subhash as he may have additional context.

thanks
-john