Message ID | 1580978008-9327-9-git-send-email-cang@codeaurora.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | UFS driver general fixes bundle 4 | expand |
Hi Can, > ADAPT is added specifically for HS Gear4 mode only, select INITIAL adapt > before do power mode change to G4 and select no adapt before switch to > non-G4 modes. UFSHCI 3.0 says: 7.4.1 Adapt The use of Adapt isn't mandatory but the specification provides some guidelines on its use. The HCI should perform an Initial Adapt in the following cases if the link is running at HS-G4 speed: - If DME_RESET is initiated. - If an unused line is activated for HS-G4. - If UECDME.EC is triggered with bit 3 set to '1'. - If a change between Rate A and Rate B in HS-G4 is performed. If it's not mandatory - why are we setting this for all vendors on all platforms? Or am I miss-reading the spec? Thanks, Avri
On 2020-02-06 21:20, Avri Altman wrote: > Hi Can, > > >> ADAPT is added specifically for HS Gear4 mode only, select INITIAL >> adapt >> before do power mode change to G4 and select no adapt before switch to >> non-G4 modes. > > UFSHCI 3.0 says: > 7.4.1 Adapt > The use of Adapt isn't mandatory but the specification provides some > guidelines on its use. > The HCI should perform an Initial Adapt in the following cases if the > link is running at HS-G4 > speed: > - If DME_RESET is initiated. > - If an unused line is activated for HS-G4. > - If UECDME.EC is triggered with bit 3 set to '1'. > - If a change between Rate A and Rate B in HS-G4 is performed. > > If it's not mandatory - why are we setting this for all vendors on all > platforms? > Or am I miss-reading the spec? > > Thanks, > Avri Hi Avri, Yes, it is not mandatory, but I don't know a flash vendor that refuses to use ADAPT so far, it is even recommended by flash vendors. So there is no meaning of adding a specific quirk for it, as all flash vendors need this quirk. Otherwise, we would need to add another vops to allow platform vendors to control it before send PMC. Any other suggestions? FYI, ADAPT sequence is used to train an M-RX equalizer. It gives both sides better signal integrity against the influence caused by temperature and voltage variations. ADAPT is also used by Quality of Service Monitoring for HS-G4. As for the usage of it, here is just setting the type of it before PMC to HS-G4, HW will use ADAPT, only if both sides support ADAPT, when it is required as what the spec is saying. Thanks, Can Guo.
On 2020-02-07 10:56, Can Guo wrote: > On 2020-02-06 21:20, Avri Altman wrote: >> Hi Can, >> >> >>> ADAPT is added specifically for HS Gear4 mode only, select INITIAL >>> adapt >>> before do power mode change to G4 and select no adapt before switch >>> to >>> non-G4 modes. >> >> UFSHCI 3.0 says: >> 7.4.1 Adapt >> The use of Adapt isn't mandatory but the specification provides some >> guidelines on its use. >> The HCI should perform an Initial Adapt in the following cases if the >> link is running at HS-G4 >> speed: >> - If DME_RESET is initiated. >> - If an unused line is activated for HS-G4. >> - If UECDME.EC is triggered with bit 3 set to '1'. >> - If a change between Rate A and Rate B in HS-G4 is performed. >> >> If it's not mandatory - why are we setting this for all vendors on all >> platforms? >> Or am I miss-reading the spec? >> >> Thanks, >> Avri > > Hi Avri, > > Yes, it is not mandatory, but I don't know a flash vendor that > refuses to use ADAPT so far, it is even recommended by flash vendors. > So there is no meaning of adding a specific quirk for it, as all flash > vendors need this quirk. Otherwise, we would need to add another vops > to allow platform vendors to control it before send PMC. > > Any other suggestions? > > FYI, ADAPT sequence is used to train an M-RX equalizer. It gives both > sides better signal integrity against the influence caused by > temperature and voltage variations. ADAPT is also used by Quality of > Service Monitoring for HS-G4. > > As for the usage of it, here is just setting the type of it before > PMC to HS-G4, HW will use ADAPT, only if both sides support ADAPT, > when it is required as what the spec is saying. > > Thanks, > > Can Guo. Hi Avri, I will drop this one for now as it may take some time to nail down it. I will come back with a separate patch series for it later. Thanks for the review. Can Guo.
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 20fa509..e0bf551 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4071,6 +4071,17 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HSSERIES), pwr_mode->hs_rate); + if (hba->ufs_version >= UFSHCI_VERSION_30) { + if (pwr_mode->gear_tx == UFS_HS_G4) + /* INITIAL ADAPT */ + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXHSADAPTTYPE), + PA_INITIAL_ADAPT); + else + /* NO ADAPT */ + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TXHSADAPTTYPE), + PA_NO_ADAPT); + } + ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA0), DL_FC0ProtectionTimeOutVal_Default); ufshcd_dme_set(hba, UIC_ARG_MIB(PA_PWRMODEUSERDATA1), @@ -8449,7 +8460,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) if ((hba->ufs_version != UFSHCI_VERSION_10) && (hba->ufs_version != UFSHCI_VERSION_11) && (hba->ufs_version != UFSHCI_VERSION_20) && - (hba->ufs_version != UFSHCI_VERSION_21)) + (hba->ufs_version != UFSHCI_VERSION_21) && + (hba->ufs_version != UFSHCI_VERSION_30)) dev_err(hba->dev, "invalid UFS version 0x%x\n", hba->ufs_version); diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index c2961d3..f2ee816 100644 --- a/drivers/scsi/ufs/ufshci.h +++ b/drivers/scsi/ufs/ufshci.h @@ -104,6 +104,7 @@ enum { UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */ UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */ UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */ + UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */ }; /* diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h index 3dc4d8b..5a724b2 100644 --- a/drivers/scsi/ufs/unipro.h +++ b/drivers/scsi/ufs/unipro.h @@ -146,6 +146,12 @@ #define PA_SLEEPNOCONFIGTIME 0x15A2 #define PA_STALLNOCONFIGTIME 0x15A3 #define PA_SAVECONFIGTIME 0x15A4 +#define PA_TXHSADAPTTYPE 0x15D4 + +/* Adpat type for PA_TXHSADAPTTYPE attribute */ +#define PA_REFRESH_ADAPT 0x00 +#define PA_INITIAL_ADAPT 0x01 +#define PA_NO_ADAPT 0x03 #define PA_TACTIVATE_TIME_UNIT_US 10 #define PA_HIBERN8_TIME_UNIT_US 100 @@ -203,6 +209,7 @@ enum ufs_hs_gear_tag { UFS_HS_G1, /* HS Gear 1 (default for reset) */ UFS_HS_G2, /* HS Gear 2 */ UFS_HS_G3, /* HS Gear 3 */ + UFS_HS_G4, /* HS Gear 4 */ }; enum ufs_unipro_ver {