Add Mediatek UFS Multi Circular Queue
Subsystems (4)
cover Add Mediatek UFS Multi Circular Queue
This patch support Mediatek SoC UFSHCI 4.0 MCQ (Multi Circular Queue) capability. The implementation is based on "Add Multi Circular Queue Support" series [1] by Asutosh Das, and provide
1. Customize MCQ register resource vops
2. Mediatek MCQ porting
This series test pass use FIO on Mediatek platform
[1] https://www.spinics.net/lists/linux-scsi/msg178322.html
Eddie Huang (2):
ufs: core: mcq: Add config_mcq_resource vops
ufs: mtk-host: Add MCQ feature
drivers/ufs/core/ufs-mcq.c | 3 +++ drivers/ufs/core/ufshcd-priv.h | 8 ++++++++ drivers/ufs/host/ufs-mediatek.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-mediatek.h | 7 +++++++ include/ufs/ufshcd.h | 1 + 5 files changed, 56 insertions(+)
Signature · 1 line
2.9.2
PATCH 1/2 ufs: core: mcq: Add config_mcq_resource vops
SoCs vendor config MCQ register address resource in config_mcq_resource vops
--- drivers/ufs/core/ufs-mcq.c | 3 +++ drivers/ufs/core/ufshcd-priv.h | 8 ++++++++ include/ufs/ufshcd.h | 1 + 3 files changed, 12 insertions(+)
drivers/ufs/core/ufs-mcq.c +3 -0
@@ -173,6 +173,9 @@ static int ufshcd_mcq_config_resource(struct ufs_hba *hba)struct resource *res_mem, *res_mcq;int i, ret =0 ; +if (ufshcd_mcq_vops_config_resource (hba) ==0 ) +return 0 ; +memcpy (hba->res, ufs_res_info,sizeof (ufs_res_info));for (i =0 ; i <RES_MAX ; i++) {
drivers/ufs/core/ufshcd-priv.h +8 -0
@@ -257,6 +257,14 @@ static inline int ufshcd_vops_get_outstanding_cqs(struct ufs_hba *hba,return -EOPNOTSUPP ; } +static inline int ufshcd_mcq_vops_config_resource (struct ufs_hba *hba) +{ +if (hba->vops && hba->vops->config_mcq_resource) +return hba->vops->config_mcq_resource (hba); + +return -EOPNOTSUPP ; +} +extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[];/**
include/ufs/ufshcd.h +1 -0
@@ -339,6 +339,7 @@ struct ufs_hba_variant_ops {int (*op_runtime_config)(struct ufs_hba *hba);int (*get_outstanding_cqs)(struct ufs_hba *hba,unsigned long *ocqs); +int (*config_mcq_resource)(struct ufs_hba *hba); };/* clock gating state */
Signature · 1 line
2.9.2
PATCH 2/2 ufs: mtk-host: Add MCQ feature
In reply to Eddie HuangAdd Mediatek mcq resource and runtime configuration function to support MCQ capability
--- drivers/ufs/host/ufs-mediatek.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-mediatek.h | 7 +++++++ 2 files changed, 44 insertions(+)
drivers/ufs/host/ufs-mediatek.c +37 -0
@@ -31,6 +31,8 @@#define CREATE_TRACE_POINTS #include "ufs-mediatek-trace.h" +#define MCQ_QUEUE_OFFSET (c) ((((c) >> 16) & 0xFF) * 0x200) +static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = { { .wmanufacturerid =UFS_ANY_VENDOR , .model =UFS_ANY_MODEL ,
@@ -833,6 +835,8 @@ static int ufs_mtk_init(struct ufs_hba *hba) host->ip_ver =ufshcd_readl (hba,REG_UFS_MTK_IP_VER ); + hba->caps |=UFSHCD_CAP_MCQ_EN ; + goto out; out_variant_clear:
@@ -1314,6 +1318,37 @@ static void ufs_mtk_event_notify(struct ufs_hba *hba,trace_ufs_mtk_event (evt, val); } +static int ufs_mtk_op_runtime_config (struct ufs_hba *hba) +{ +struct ufshcd_mcq_opr_info_t *opr; +int i; + +for (i =0 ; i <OPR_MAX ; i++) { + opr = &hba->mcq_opr[i]; + opr->stride =REG_UFS_MCQ_STRIDE ; + } + + hba->mcq_opr[OPR_SQD ].offset =REG_UFS_MTK_SQD ; + hba->mcq_opr[OPR_SQIS ].offset =REG_UFS_MTK_SQIS ; + hba->mcq_opr[OPR_CQD ].offset =REG_UFS_MTK_CQD ; + hba->mcq_opr[OPR_CQIS ].offset =REG_UFS_MTK_CQIS ; + + hba->mcq_opr[OPR_SQD ].base = hba->mmio_base +REG_UFS_MTK_SQD ; + hba->mcq_opr[OPR_SQIS ].base = hba->mmio_base +REG_UFS_MTK_SQIS ; + hba->mcq_opr[OPR_CQD ].base = hba->mmio_base +REG_UFS_MTK_CQD ; + hba->mcq_opr[OPR_CQIS ].base = hba->mmio_base +REG_UFS_MTK_CQIS ; + +return 0 ; +} + +static int ufs_mtk_config_mcq_resource (struct ufs_hba *hba) +{ + hba->mcq_base = hba->mmio_base + +MCQ_QUEUE_OFFSET (hba->mcq_capabilities); + +return 0 ; +} +/* * struct ufs_hba_mtk_vops - UFS MTK specific variant operations *
@@ -1335,6 +1370,8 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .dbg_register_dump = ufs_mtk_dbg_register_dump, .device_reset = ufs_mtk_device_reset, .event_notify = ufs_mtk_event_notify, + .op_runtime_config = ufs_mtk_op_runtime_config, + .config_mcq_resource = ufs_mtk_config_mcq_resource, };/**
drivers/ufs/host/ufs-mediatek.h +7 -0
@@ -26,6 +26,13 @@#define REG_UFS_DEBUG_SEL_B2 0x22D8#define REG_UFS_DEBUG_SEL_B3 0x22DC +#define REG_UFS_MTK_SQD 0x2800 +#define REG_UFS_MTK_SQIS 0x2814 +#define REG_UFS_MTK_CQD 0x281C +#define REG_UFS_MTK_CQIS 0x2824 + +#define REG_UFS_MCQ_STRIDE 0x30 +/* * Ref-clk control *
Signature · 1 line
2.9.2
AngeloGioacchino Del Regno
maintainerRe: [PATCH v1 2/2] ufs: mtk-host: Add MCQ feature
Il 26/10/22 09:39, Eddie Huang ha scritto:
Quoted 13 lines
Add Mediatek mcq resource and runtime configuration function to support MCQ capability
Signed-off-by Eddie Huang <[email protected]>--- drivers/ufs/host/ufs-mediatek.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-mediatek.h | 7 +++++++ 2 files changed, 44 insertions(+)drivers/ufs/host/ufs-mediatek.c +0
-0
..snip..
drivers/ufs/host/ufs-mediatek.c static void ufs_mtk_event_notify(struct ufs_hba *hba, · line 1347
Quoted 5 lines
drivers/ufs/host/ufs-mediatek.c +5
-0+ +static int ufs_mtk_config_mcq_resource (struct ufs_hba *hba) +{ + hba->mcq_base = hba->mmio_base + +MCQ_QUEUE_OFFSET (hba->mcq_capabilities);
This seems to either be an additional usecase that should be implemented into the API and not in MediaTek drivers, (as in that case I believe MediaTek won't be the only user of such usecase)... or just a way to avoid adding the MCQ iospace to the UFS devicetree node.
Please clarify.
Thanks,
Angelo
Re: [PATCH v1 2/2] ufs: mtk-host: Add MCQ feature
Hi Angelo
Sorry for late due to miss the mail
Quoted 11 lines · AngeloGioacchino Del Regno
Il 26/10/22 09:39, Eddie Huang ha scritto:
Quoted 10 lines
Add Mediatek mcq resource and runtime configuration function to support MCQ capability
Signed-off-by Eddie Huang <[email protected]>--- drivers/ufs/host/ufs-mediatek.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-mediatek.h | 7 +++++++ 2 files changed, 44 insertions(+)
Quoted 15 lines
Quoted 5 lines
drivers/ufs/host/ufs-mediatek.c +0
-0..snip..
Quoted 6 lines
drivers/ufs/host/ufs-mediatek.c +5
-0+ +static int ufs_mtk_config_mcq_resource (struct ufs_hba *hba) +{ + hba->mcq_base = hba->mmio_base + + MCQ_QUEUE_OFFSET(hba-Quoted 1 line
mcq_capabilities);
This define in UFSHCI4 spec
ADDR(SQATTR0) = UFS_HCI_BASE + QCFGPTR*200h
Quoted 8 lines
This seems to either be an additional usecase that should be implemented into the
API and not in MediaTek drivers, (as in that case I believe MediaTek won't be the
only user of such usecase)... or just a way to avoid adding the MCQ iospace to the
UFS devicetree node.
I can base on next version of UFS MCQ patch [1], and check whether add new API
[1]: https://www.spinics.net/lists/linux-scsi/msg178322.html
Thanks,
Eddie