UFS1.0 and UFS1.1, published in the early 2010s, were more of a proof of
concept rather than a mature functional spec. Toshiba was the only
device manufacturer with the most accomplished phy team to come up with
a small UFS1.0 device. Alas, there were no commercial platforms it can
be paired with. Even UFS2.0 that was published in 2013, didn't really
make it to the market: too moot to take effect. It's not until UFS2.1
that was published in 2016, were a myriad of devices and platforms
flooded the market. Designated to mobile devices, dictates a rapid short
lives for those platforms. Hence, we can safely remove those pre-UFS2.1
pieces of code.
Changes from v1:
- remove ufshcd_get_local_unipro_ver which practically mean squashing
patch 1 & 2 into a single patch (Christoph)
- restore an if clause to avoid functional change in
ufshcd_compl_one_cqe (Bart)
Avri Altman (1):
scsi: ufs: Remove support for old UFSHCI versions
drivers/ufs/core/ufshcd.c | 174 +++---------------------------------
drivers/ufs/host/ufs-qcom.c | 3 +-
include/ufs/ufshcd.h | 2 -
include/ufs/ufshci.h | 7 --
4 files changed, 15 insertions(+), 171 deletions(-)
--
2.42.0
UFS spec version 2.1 was published more than 10 years ago. It is
vanishingly unlikely that even there are out there platforms that uses
earlier host controllers, let alone that those ancient platforms will
ever run a V6.10 kernel. Thus, remove support of host controllers prior
to UFS2.1.
This patch removes some legacy tuning calls that no longer apply.
Signed-off-by: Avri Altman <[email protected]>
---
drivers/ufs/core/ufshcd.c | 174 +++---------------------------------
drivers/ufs/host/ufs-qcom.c | 3 +-
include/ufs/ufshcd.h | 2 -
include/ufs/ufshci.h | 7 --
4 files changed, 15 insertions(+), 171 deletions(-)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 823bc28c0cb0..7791ee780eb1 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -740,22 +740,6 @@ static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
return err;
}
-/**
- * ufshcd_get_intr_mask - Get the interrupt bit mask
- * @hba: Pointer to adapter instance
- *
- * Return: interrupt bit mask per version
- */
-static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
-{
- if (hba->ufs_version == ufshci_version(1, 0))
- return INTERRUPT_MASK_ALL_VER_10;
- if (hba->ufs_version <= ufshci_version(2, 0))
- return INTERRUPT_MASK_ALL_VER_11;
-
- return INTERRUPT_MASK_ALL_VER_21;
-}
-
/**
* ufshcd_get_ufs_version - Get the UFS version supported by the HBA
* @hba: Pointer to adapter instance
@@ -990,30 +974,6 @@ bool ufshcd_is_hba_active(struct ufs_hba *hba)
}
EXPORT_SYMBOL_GPL(ufshcd_is_hba_active);
-u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba)
-{
- /* HCI version 1.0 and 1.1 supports UniPro 1.41 */
- if (hba->ufs_version <= ufshci_version(1, 1))
- return UFS_UNIPRO_VER_1_41;
- else
- return UFS_UNIPRO_VER_1_6;
-}
-EXPORT_SYMBOL(ufshcd_get_local_unipro_ver);
-
-static bool ufshcd_is_unipro_pa_params_tuning_req(struct ufs_hba *hba)
-{
- /*
- * If both host and device support UniPro ver1.6 or later, PA layer
- * parameters tuning happens during link startup itself.
- *
- * We can manually tune PA layer parameters if either host or device
- * doesn't support UniPro ver 1.6 or later. But to keep manual tuning
- * logic simple, we will only do manual tuning if local unipro version
- * doesn't support ver1.6 or later.
- */
- return ufshcd_get_local_unipro_ver(hba) < UFS_UNIPRO_VER_1_6;
-}
-
/**
* ufshcd_pm_qos_init - initialize PM QoS request
* @hba: per adapter instance
@@ -2674,14 +2634,7 @@ static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs)
{
u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
- if (hba->ufs_version == ufshci_version(1, 0)) {
- u32 rw;
- rw = set & INTERRUPT_MASK_RW_VER_10;
- set = rw | ((set ^ intrs) & intrs);
- } else {
- set |= intrs;
- }
-
+ set |= intrs;
ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
}
@@ -2694,16 +2647,7 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
{
u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
- if (hba->ufs_version == ufshci_version(1, 0)) {
- u32 rw;
- rw = (set & INTERRUPT_MASK_RW_VER_10) &
- ~(intrs & INTERRUPT_MASK_RW_VER_10);
- set = rw | ((set & intrs) & ~INTERRUPT_MASK_RW_VER_10);
-
- } else {
- set &= ~intrs;
- }
-
+ set &= ~intrs;
ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
}
@@ -2715,21 +2659,17 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
* @upiu_flags: flags required in the header
* @cmd_dir: requests data direction
* @ehs_length: Total EHS Length (in 32‐bytes units of all Extra Header Segments)
- * @legacy_type: UTP_CMD_TYPE_SCSI or UTP_CMD_TYPE_DEV_MANAGE
*/
static void
ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
u8 *upiu_flags, enum dma_data_direction cmd_dir,
- int ehs_length, enum utp_cmd_type legacy_type)
+ int ehs_length)
{
struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
struct request_desc_header *h = &req_desc->header;
enum utp_data_direction data_direction;
- if (hba->ufs_version <= ufshci_version(1, 1))
- lrbp->command_type = legacy_type;
- else
- lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+ lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
*h = (typeof(*h)){ };
@@ -2863,7 +2803,7 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
u8 upiu_flags;
int ret = 0;
- ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, 0, UTP_CMD_TYPE_DEV_MANAGE);
+ ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, 0);
if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
ufshcd_prepare_utp_query_req_upiu(hba, lrbp, upiu_flags);
@@ -2887,8 +2827,7 @@ static void ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
unsigned int ioprio_class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
u8 upiu_flags;
- ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
- lrbp->cmd->sc_data_direction, 0, UTP_CMD_TYPE_SCSI);
+ ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, lrbp->cmd->sc_data_direction, 0);
if (ioprio_class == IOPRIO_CLASS_RT)
upiu_flags |= UPIU_CMD_FLAGS_CP;
ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
@@ -5565,15 +5504,12 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
ufshcd_release_scsi_cmd(hba, lrbp);
/* Do not touch lrbp after scsi done */
scsi_done(cmd);
- } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
- lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
- if (hba->dev_cmd.complete) {
- if (cqe) {
- ocs = le32_to_cpu(cqe->status) & MASK_OCS;
- lrbp->utr_descriptor_ptr->header.ocs = ocs;
- }
- complete(hba->dev_cmd.complete);
+ } else if (hba->dev_cmd.complete) {
+ if (cqe) {
+ ocs = le32_to_cpu(cqe->status) & MASK_OCS;
+ lrbp->utr_descriptor_ptr->header.ocs = ocs;
}
+ complete(hba->dev_cmd.complete);
}
}
@@ -7229,7 +7165,7 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba,
ufshcd_setup_dev_cmd(hba, lrbp, cmd_type, 0, tag);
- ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, 0, UTP_CMD_TYPE_DEV_MANAGE);
+ ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, 0);
/* update the task tag in the request upiu */
req_upiu->header.task_tag = tag;
@@ -7381,7 +7317,7 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r
ufshcd_setup_dev_cmd(hba, lrbp, DEV_CMD_TYPE_RPMB, UFS_UPIU_RPMB_WLUN, tag);
- ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, ehs, UTP_CMD_TYPE_DEV_MANAGE);
+ ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE, ehs);
/* update the task tag */
req_upiu->header.task_tag = tag;
@@ -8368,83 +8304,6 @@ static void ufs_put_device_desc(struct ufs_hba *hba)
dev_info->model = NULL;
}
-/**
- * ufshcd_tune_pa_tactivate - Tunes PA_TActivate of local UniPro
- * @hba: per-adapter instance
- *
- * PA_TActivate parameter can be tuned manually if UniPro version is less than
- * 1.61. PA_TActivate needs to be greater than or equal to peerM-PHY's
- * RX_MIN_ACTIVATETIME_CAPABILITY attribute. This optimal value can help reduce
- * the hibern8 exit latency.
- *
- * Return: zero on success, non-zero error value on failure.
- */
-static int ufshcd_tune_pa_tactivate(struct ufs_hba *hba)
-{
- int ret = 0;
- u32 peer_rx_min_activatetime = 0, tuned_pa_tactivate;
-
- ret = ufshcd_dme_peer_get(hba,
- UIC_ARG_MIB_SEL(
- RX_MIN_ACTIVATETIME_CAPABILITY,
- UIC_ARG_MPHY_RX_GEN_SEL_INDEX(0)),
- &peer_rx_min_activatetime);
- if (ret)
- goto out;
-
- /* make sure proper unit conversion is applied */
- tuned_pa_tactivate =
- ((peer_rx_min_activatetime * RX_MIN_ACTIVATETIME_UNIT_US)
- / PA_TACTIVATE_TIME_UNIT_US);
- ret = ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE),
- tuned_pa_tactivate);
-
-out:
- return ret;
-}
-
-/**
- * ufshcd_tune_pa_hibern8time - Tunes PA_Hibern8Time of local UniPro
- * @hba: per-adapter instance
- *
- * PA_Hibern8Time parameter can be tuned manually if UniPro version is less than
- * 1.61. PA_Hibern8Time needs to be maximum of local M-PHY's
- * TX_HIBERN8TIME_CAPABILITY & peer M-PHY's RX_HIBERN8TIME_CAPABILITY.
- * This optimal value can help reduce the hibern8 exit latency.
- *
- * Return: zero on success, non-zero error value on failure.
- */
-static int ufshcd_tune_pa_hibern8time(struct ufs_hba *hba)
-{
- int ret = 0;
- u32 local_tx_hibern8_time_cap = 0, peer_rx_hibern8_time_cap = 0;
- u32 max_hibern8_time, tuned_pa_hibern8time;
-
- ret = ufshcd_dme_get(hba,
- UIC_ARG_MIB_SEL(TX_HIBERN8TIME_CAPABILITY,
- UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)),
- &local_tx_hibern8_time_cap);
- if (ret)
- goto out;
-
- ret = ufshcd_dme_peer_get(hba,
- UIC_ARG_MIB_SEL(RX_HIBERN8TIME_CAPABILITY,
- UIC_ARG_MPHY_RX_GEN_SEL_INDEX(0)),
- &peer_rx_hibern8_time_cap);
- if (ret)
- goto out;
-
- max_hibern8_time = max(local_tx_hibern8_time_cap,
- peer_rx_hibern8_time_cap);
- /* make sure proper unit conversion is applied */
- tuned_pa_hibern8time = ((max_hibern8_time * HIBERN8TIME_UNIT_US)
- / PA_HIBERN8_TIME_UNIT_US);
- ret = ufshcd_dme_set(hba, UIC_ARG_MIB(PA_HIBERN8TIME),
- tuned_pa_hibern8time);
-out:
- return ret;
-}
-
/**
* ufshcd_quirk_tune_host_pa_tactivate - Ensures that host PA_TACTIVATE is
* less than device PA_TACTIVATE time.
@@ -8517,11 +8376,6 @@ static int ufshcd_quirk_tune_host_pa_tactivate(struct ufs_hba *hba)
static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
{
- if (ufshcd_is_unipro_pa_params_tuning_req(hba)) {
- ufshcd_tune_pa_tactivate(hba);
- ufshcd_tune_pa_hibern8time(hba);
- }
-
ufshcd_vops_apply_dev_quirks(hba);
if (hba->dev_quirks & UFS_DEVICE_QUIRK_PA_TACTIVATE)
@@ -10508,7 +10362,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
hba->ufs_version = ufshcd_get_ufs_version(hba);
/* Get Interrupt bit mask per version */
- hba->intr_mask = ufshcd_get_intr_mask(hba);
+ hba->intr_mask = INTERRUPT_MASK_ALL_VER_21;
err = ufshcd_set_dma_mask(hba);
if (err) {
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 06859e17b67b..06391f923dba 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -531,8 +531,7 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
* and device TX LCC are disabled once link startup is
* completed.
*/
- if (ufshcd_get_local_unipro_ver(hba) != UFS_UNIPRO_VER_1_41)
- err = ufshcd_disable_host_tx_lcc(hba);
+ err = ufshcd_disable_host_tx_lcc(hba);
break;
default:
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index a35e12f8e68b..431af365cf5e 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1390,8 +1390,6 @@ void ufshcd_release(struct ufs_hba *hba);
void ufshcd_clkgate_delay_set(struct device *dev, unsigned long value);
-u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba);
-
int ufshcd_get_vreg(struct device *dev, struct ufs_vreg *vreg);
int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h
index 88193f5540e5..aecdc209ab75 100644
--- a/include/ufs/ufshci.h
+++ b/include/ufs/ufshci.h
@@ -425,13 +425,6 @@ union ufs_crypto_cfg_entry {
* Request Descriptor Definitions
*/
-/* Transfer request command type */
-enum utp_cmd_type {
- UTP_CMD_TYPE_SCSI = 0x0,
- UTP_CMD_TYPE_UFS = 0x1,
- UTP_CMD_TYPE_DEV_MANAGE = 0x2,
-};
-
/* To accommodate UFS2.0 required Command type */
enum {
UTP_CMD_TYPE_UFS_STORAGE = 0x1,
--
2.42.0
Martin hi,
Could you please take a look at this?
I have another cleanup series pending.
Thanks,
Avri
> UFS1.0 and UFS1.1, published in the early 2010s, were more of a proof of
> concept rather than a mature functional spec. Toshiba was the only
> device manufacturer with the most accomplished phy team to come up with
> a small UFS1.0 device. Alas, there were no commercial platforms it can
> be paired with. Even UFS2.0 that was published in 2013, didn't really
> make it to the market: too moot to take effect. It's not until UFS2.1
> that was published in 2016, were a myriad of devices and platforms
> flooded the market. Designated to mobile devices, dictates a rapid short
> lives for those platforms. Hence, we can safely remove those pre-UFS2.1
> pieces of code.
>
> Changes from v1:
> - remove ufshcd_get_local_unipro_ver which practically mean squashing
> patch 1 & 2 into a single patch (Christoph)
> - restore an if clause to avoid functional change in
> ufshcd_compl_one_cqe (Bart)
>
>
> Avri Altman (1):
> scsi: ufs: Remove support for old UFSHCI versions
>
> drivers/ufs/core/ufshcd.c | 174 +++---------------------------------
> drivers/ufs/host/ufs-qcom.c | 3 +-
> include/ufs/ufshcd.h | 2 -
> include/ufs/ufshci.h | 7 --
> 4 files changed, 15 insertions(+), 171 deletions(-)
>
> --
> 2.42.0
On 3/27/24 00:17, Avri Altman wrote:
> UFS spec version 2.1 was published more than 10 years ago. It is
> vanishingly unlikely that even there are out there platforms that uses
> earlier host controllers, let alone that those ancient platforms will
> ever run a V6.10 kernel. Thus, remove support of host controllers prior
> to UFS2.1.
According to this website, Pixel 1 devices have a UFSHCI 2.0 controller:
https://www.gsmarena.com/google_pixel-8346.php. There may be other
smartphones that have a UFSHCI 2.0 controller. Hence, I'm not sure we
can drop support for UFSHCI 2.0 controllers from the kernel.
Thanks,
Bart.
> On 3/27/24 00:17, Avri Altman wrote:
> > UFS spec version 2.1 was published more than 10 years ago. It is
> > vanishingly unlikely that even there are out there platforms that uses
> > earlier host controllers, let alone that those ancient platforms will
> > ever run a V6.10 kernel. Thus, remove support of host controllers prior
> > to UFS2.1.
>
> According to this website, Pixel 1 devices have a UFSHCI 2.0 controller:
> https://www.gsmarena.com/google_pixel-8346.php. There may be other
> smartphones that have a UFSHCI 2.0 controller. Hence, I'm not sure we
> can drop support for UFSHCI 2.0 controllers from the kernel.
Actually the Pixel 1 is an excellent example why we can and should -
It was announced in 2016, running Android 7 with a v4.4 kernel.
Even if you would be able to find a working specimen of that device -
It is not realistic it would ever run a 6.10 kernel.
Thanks,
Avri
>
> Thanks,
>
> Bart.
On 4/3/24 12:24, Avri Altman wrote:
>> On 3/27/24 00:17, Avri Altman wrote:
>>> UFS spec version 2.1 was published more than 10 years ago. It is
>>> vanishingly unlikely that even there are out there platforms that uses
>>> earlier host controllers, let alone that those ancient platforms will
>>> ever run a V6.10 kernel. Thus, remove support of host controllers prior
>>> to UFS2.1.
>>
>> According to this website, Pixel 1 devices have a UFSHCI 2.0 controller:
>> https://www.gsmarena.com/google_pixel-8346.php. There may be other
>> smartphones that have a UFSHCI 2.0 controller. Hence, I'm not sure we
>> can drop support for UFSHCI 2.0 controllers from the kernel.
> Actually the Pixel 1 is an excellent example why we can and should -
> It was announced in 2016, running Android 7 with a v4.4 kernel.
> Even if you would be able to find a working specimen of that device -
> It is not realistic it would ever run a 6.10 kernel.
v4.4 is the kernel version of the kernel included in the original
software. Multiple users of older smartphones switch to alternative
distributions once their device is no longer supported by the
manufacturer. These alternatives often include a more recent kernel.
See e.g. https://en.wikipedia.org/wiki/List_of_custom_Android_distributions.
Thanks,
Bart.
> On 4/3/24 12:24, Avri Altman wrote:
> >> On 3/27/24 00:17, Avri Altman wrote:
> >>> UFS spec version 2.1 was published more than 10 years ago. It is
> >>> vanishingly unlikely that even there are out there platforms that uses
> >>> earlier host controllers, let alone that those ancient platforms will
> >>> ever run a V6.10 kernel. Thus, remove support of host controllers prior
> >>> to UFS2.1.
> >>
> >> According to this website, Pixel 1 devices have a UFSHCI 2.0 controller:
> >> https://www.gsmarena.com/google_pixel-8346.php. There may be other
> >> smartphones that have a UFSHCI 2.0 controller. Hence, I'm not sure we
> >> can drop support for UFSHCI 2.0 controllers from the kernel.
> > Actually the Pixel 1 is an excellent example why we can and should -
> > It was announced in 2016, running Android 7 with a v4.4 kernel.
> > Even if you would be able to find a working specimen of that device -
> > It is not realistic it would ever run a 6.10 kernel.
>
> v4.4 is the kernel version of the kernel included in the original
> software. Multiple users of older smartphones switch to alternative
> distributions once their device is no longer supported by the
> manufacturer. These alternatives often include a more recent kernel.
> See e.g. https://en.wikipedia.org/wiki/List_of_custom_Android_distributions.
OK.
What about references of UFSHCI1.0 & UFSHCI1.1?
Is it safe to remove those?
Thanks,
Avri
>
> Thanks,
>
> Bart.
On Wed, 2024-03-27 at 09:17 +0200, Avri Altman wrote:
> UFS spec version 2.1 was published more than 10 years ago. It is
> vanishingly unlikely that even there are out there platforms that
> uses
> earlier host controllers, let alone that those ancient platforms will
> ever run a V6.10 kernel. Thus, remove support of host controllers
> prior
> to UFS2.1.
>
> This patch removes some legacy tuning calls that no longer apply.
>
> Signed-off-by: Avri Altman <[email protected]>
Hi Avri,
I think it's safe to remove support for UFS versions < UFS 2.1, but not
100% sure, let me check and give you a solid answer then.
Bean
On Wed, 2024-03-27 at 09:17 +0200, Avri Altman wrote:
> UFS spec version 2.1 was published more than 10 years ago. It is
> vanishingly unlikely that even there are out there platforms that
> uses
> earlier host controllers, let alone that those ancient platforms will
> ever run a V6.10 kernel. Thus, remove support of host controllers
> prior
> to UFS2.1.
>
> This patch removes some legacy tuning calls that no longer apply.
>
> Signed-off-by: Avri Altman <[email protected]>
Acked-by: Bean Huo <[email protected]>