mmc: mtk-sd: reduce CIT for better performance
Subsystems (3)
PATCH v2 1/1 mmc: mtk-sd: reduce CIT for better performance
CQHCI_SSC1 indicates to CQE the polling period to use when using periodic SEND_QUEUE_STATUS(CMD13) polling.
The default value 0x1000 that corresponds to 150us, let's decrease it to 0x40 that corresponds to 3us, which can improve the performance of some eMMC devices.
--- drivers/mmc/host/mtk-sd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/mtk-sd.c +4 -0
@@ -2453,6 +2453,7 @@ static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc,static void msdc_cqe_enable (struct mmc_host *mmc) {struct msdc_host *host =mmc_priv (mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );
@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)
Signature · 1 line
2.25.1
AngeloGioacchino Del Regno
maintainerIl 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 3 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
The default value0x1000that corresponds to 150us, let's decrease it to
The default value 0x1000 (4096) corresponds to 4096 * 52.08uS = 231.33uS ...so the default is not 150uS.
If I'm wrong, this means that the CQCAP field is not 0, which would mean that the expected 3uS would be wrong.
Also, since the calculation can be done dynamically, this is what we should actually do in the driver, as this gives information to the next engineer checking this piece of code.
Apart from this, by just writing 0x40 to the CQHCI_SSC1 register, you are assuming that the CQCAP value requirement is fullfilled, but you cannot assume that the bootloader has set the CQCAP's ITCFVAL and ITCFMUL fields as you expect on all platforms: this means that implementing this takes a little more effort.
You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul = itcfmul_to_mhz(ITCFMUL); /* pseudo function interprets reg value*/ tclk = ITCFVAL * tclk_mul;
2. Set SSC1 so that we get 3nS:
#define CQHCI_SSC1_CIT GENMASK(15, 0)
poll_time = cit_time_ns_to_regval(3);
sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time)
cqhci_writel( ... )*** Second **
1. Pre-set ITCFMUL and ITCFVAL to
ITCFVAL = 192 (decimal)
ITCFMUL = 2 (where 2 == 0.1MHz)2. Set SSC1 so that we get 3nS:
#define CQHCI_SSC1_CIT GENMASK(15, 0)
poll_time = cit_time_ns_to_regval(3);
sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time)
cqhci_writel( ... )I would implement the first way, as it paves the way to extend this to different tclk values if needed in the future.
Regards,
Angelo
Quoted 30 lines
0x40that corresponds to 3us, which can improve the performance of some eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/mtk-sd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/host/mtk-sd.c +4
-0@@ -2453,6 +2453,7 @@ static void msdc_hs400_enhanced_strobe(struct mmc_host *mmc,static void msdc_cqe_enable (struct mmc_host *mmc) {struct msdc_host *host =mmc_priv (mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)
Quoted 60 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 5 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
The default value0x1000that corresponds to 150us, let's decrease it toThe default value
0x1000(4096) corresponds to 4096 * 52.08uS = 231.33uS
...so the default is not 150uS.If I'm wrong, this means that the CQCAP field is not 0, which would mean
that the expected 3uS would be wrong.Also, since the calculation can be done dynamically, this is what we should
actually do in the driver, as this gives information to the next engineer
checking this piece of code.Apart from this, by just writing
0x40to theCQHCI_SSC1register, you are
assuming that the CQCAP value requirement is fullfilled, but you cannot
assume that the bootloader has set the CQCAP's ITCFVAL and ITCFMUL fields
as you expect on all platforms: this means that implementing this takes
a little more effort.You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo function
interprets reg value*/tclk = ITCFVAL * tclk_mul;2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )*** Second **
1. Pre-set ITCFMUL and ITCFVAL to
ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz)2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )
Quoted 6 lines
I would implement the first way, as it paves the way to extend this to different
tclk values if needed in the future.Regards,
Angelo
Hi Angelo,
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports 182, and these fields are the same and are readonly for all IC, but since Mediatek CQE uses msdc_hclk(273MHz), CMD13'interval calculation driver should use 273MHz to get the actual time, so the actual clock is 27.3MHz.
If CIT is 0x1000 by default, CMD idle time: 0x1000 * 1 / 27.3MHz = around 150us.
In addition the bootloader will not set the CQCAP's ITCFVAL and ITCFMUL fields, because these fields of CQCAP register is RO(readonly), so we can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.
Thanks
Wenbin
Quoted 36 lines
Quoted 34 lines
0x40that corresponds to 3us, which can improve the performance of some
eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/mtk-sd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/host/mtk-sd.c +1
-0@@ -2453,6 +2453,7 @@ static void msdc_hs400_enhanced_strobe(structmmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel(MSDC_INT_CMDQ, host->base + MSDC_INTEN);drivers/mmc/host/mtk-sd.c +3
-0@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }static void
msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
Quoted 69 lines · Wenbin Mei (梅文彬)
Quoted 68 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until
you have verified the sender or the content.Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 6 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
The default value0x1000that corresponds to 150us, let's decrease
it toThe default value
0x1000(4096) corresponds to 4096 * 52.08uS = 231.33uS
...so the default is not 150uS.If I'm wrong, this means that the CQCAP field is not 0, which would mean
that the expected 3uS would be wrong.Also, since the calculation can be done dynamically, this is what we
should
actually do in the driver, as this gives information to the next engineer
checking this piece of code.Apart from this, by just writing
0x40to theCQHCI_SSC1register, you
are
assuming that the CQCAP value requirement is fullfilled, but you cannot
assume that the bootloader has set the CQCAP's ITCFVAL and ITCFMUL fields
as you expect on all platforms: this means that implementing this takes
a little more effort.You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo function
interprets reg value*/tclk = ITCFVAL * tclk_mul;2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )*** Second **
1. Pre-set ITCFMUL and ITCFVAL to
ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz)2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )I would implement the first way, as it paves the way to extend this to different
tclk values if needed in the future.
Quoted 8 lines
Quoted 2 lines
Regards,
AngeloHi Angelo,
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports
update: ITCFMUL is 0x2(0x1MHz) -> ITCFMUL is 0x2(0.1MHz)
Quoted 57 lines
182,
and these fields are the same and are readonly for all IC, but since Mediatek CQE usesmsdc_hclk(273MHz), CMD13'interval calculation driver
should use 273MHz to get the actual time, so the actual clock is 27.3MHz.If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz = around 150us.In addition the bootloader will not set the CQCAP's ITCFVAL and ITCFMUL
fields, because these fields of CQCAP register is RO(readonly), so we can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.Thanks
WenbinQuoted 40 lines
Quoted 38 lines
0x40that corresponds to 3us, which can improve the performance of
some
eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/mtk-sd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0
sd.c
indexedade0e54a0c..ffeccddcd028100644drivers/mmc/host/mtk-sd.c +0
-0@@ -2453,6 +2453,7 @@ static voidmsdc_hs400_enhanced_strobe(struct
mmc_host*mmc,
static voidmsdc_cqe_enable(struct mmc_host *mmc){ struct msdc_host *host = mmc_priv(mmc);drivers/mmc/host/mtk-sd.c +4
-0+struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }static void msdc_cqe_disable(struct
mmc_host*mmc, bool
recovery)
AngeloGioacchino Del Regno
maintainerIl 31/05/23 09:32, Wenbin Mei (梅文彬) ha scritto:
Quoted 69 lines · AngeloGioacchino Del Regno
Quoted 60 lines
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 5 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
The default value0x1000that corresponds to 150us, let's decrease it toThe default value
0x1000(4096) corresponds to 4096 * 52.08uS = 231.33uS
...so the default is not 150uS.If I'm wrong, this means that the CQCAP field is not 0, which would mean
that the expected 3uS would be wrong.Also, since the calculation can be done dynamically, this is what we should
actually do in the driver, as this gives information to the next engineer
checking this piece of code.Apart from this, by just writing
0x40to theCQHCI_SSC1register, you are
assuming that the CQCAP value requirement is fullfilled, but you cannot
assume that the bootloader has set the CQCAP's ITCFVAL and ITCFMUL fields
as you expect on all platforms: this means that implementing this takes
a little more effort.You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo function
interprets reg value*/tclk = ITCFVAL * tclk_mul;2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )*** Second ** 1. Pre-set ITCFMUL and ITCFVAL to ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz) 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )Quoted 6 lines
I would implement the first way, as it paves the way to extend this to different
tclk values if needed in the future.Regards,
AngeloHi Angelo,
Quoted 8 lines
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports 182, and these fields are the same and are readonly for all IC, but since Mediatek CQE uses
msdc_hclk(273MHz), CMD13'interval calculation driver should use 273MHz to get the actual time, so the actual clock is 27.3MHz.
You're right, I've misread the datasheet, just rechecked and it reports RO.
Quoted 7 lines
If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz = around 150us.In addition the bootloader will not set the CQCAP's ITCFVAL and ITCFMUL fields, because these fields of CQCAP register is RO(readonly), so we can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.
Yes, that's right, again - this means that you should go for the first proposed implementation, as future MediaTek SoCs may (or may not) change
that: if you implement as proposed, this is going to be a one-time thing and future SoCs won't need specific changes.
That implementation also documents the flow about how we're getting to the actual value, which is important for community people reading this driver in the future for debugging purposes.
Regards,
Angelo
Quoted 38 lines
Thanks
WenbinQuoted 36 lines
Quoted 34 lines
0x40that corresponds to 3us, which can improve the performance of some
eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/mtk-sd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/host/mtk-sd.c +1
-0@@ -2453,6 +2453,7 @@ static void msdc_hs400_enhanced_strobe(structmmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel(MSDC_INT_CMDQ, host->base + MSDC_INTEN);drivers/mmc/host/mtk-sd.c +3
-0@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }static void
msdc_cqe_disable(struct mmc_host *mmc, bool recovery)
Quoted 113 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 31/05/23 09:32, Wenbin Mei (梅文彬) ha scritto:Quoted 1 line
On Thu, 2023-05-18 at 11:13 +0200, AngeloGioacchino Del Regno
Quoted 1 line · wrote:
Quoted 1 line
External email : Please do not click links or open attachments
until
Quoted 8 lines
Quoted 8 lines
you have verified the sender or the content.
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 4 lines
CQHCI_SSC1indicates to CQE the polling period to use when using periodicSEND_QUEUE_STATUS(CMD13)polling.
The default value0x1000that corresponds to 150us, let'sdecrease
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
it to
The default value
0x1000(4096) corresponds to 4096 * 52.08uS = 231.33uS
...so the default is not 150uS.If I'm wrong, this means that the CQCAP field is not 0, which
would
Quoted 4 lines
Quoted 4 lines
mean
that the expected 3uS would be wrong.Also, since the calculation can be done dynamically, this is what
we
Quoted 6 lines
Quoted 6 lines
should
actually do in the driver, as this gives information to the next engineer
checking this piece of code.Apart from this, by just writing
0x40to theCQHCI_SSC1register,you
Quoted 28 lines
Quoted 28 lines
are
assuming that the CQCAP value requirement is fullfilled, but you cannot
assume that the bootloader has set the CQCAP's ITCFVAL and ITCFMUL fields
as you expect on all platforms: this means that implementing this takes
a little more effort.You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo function
interprets reg value*/tclk = ITCFVAL * tclk_mul;2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )*** Second ** 1. Pre-set ITCFMUL and ITCFVAL to ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz)Quoted 7 lines
Quoted 7 lines
2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )I would implement the first way, as it paves the way to extend
this
Quoted 10 lines
Quoted 5 lines
to different
tclk values if needed in the future.Regards,
AngeloHi Angelo,
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports
182,
Quoted 1 line
and these fields are the same and are readonly for all IC, but
since
Quoted 1 line
Mediatek CQE uses
msdc_hclk(273MHz), CMD13'interval calculationdriver
Quoted 3 lines
should use 273MHz to get the actual time, so the actual clock is 27.3MHz.
You're right, I've misread the datasheet, just rechecked and it reports RO.
Quoted 4 lines
If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz = around 150us.In addition the bootloader will not set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 1 line
fields, because these fields of CQCAP register is RO(readonly), so
we
Quoted 2 lines
can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.
Yes, that's right, again - this means that you should go for the first
proposed implementation, as future MediaTek SoCs may (or may not) change
that: if you implement as proposed, this is going to be a one-time thing
and future SoCs won't need specific changes.
Quoted 9 lines
That implementation also documents the flow about how we're getting to
the actual value, which is important for community people reading this
driver in the future for debugging purposes.Regards,
Angelo
Thanks for your proposal.
I have discussed with our designer, and the fields of CQCAP's ITCFVAL and ITCFMUL will not change.
If we add more code for it, these codes will also affect the execution efficiency, even if it has a very small effect.
I think if it's just for reading convenience, we can add more comments to make it easier to read the code.
Do you think it's okay to add more comments?
Begards,
Wenbin
Quoted 44 lines
Quoted 4 lines
Thanks
WenbinQuoted 2 lines
Quoted 2 lines
0x40that corresponds to 3us, which can improve the performanceof
Quoted 9 lines
Quoted 9 lines
drivers/mmc/host/mtk-
Quoted 9 lines
some
eMMC devices.Signed-off-by Wenbin Mei <[email protected]>--- drivers/mmc/host/mtk-sd.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0
sd.cQuoted 4 lines
Quoted 4 lines
drivers/mmc/host/mtk-sd.c static void
Quoted 4 lines
index
edade0e54a0c..ffeccddcd028100644drivers/mmc/host/mtk-sd.c +0
-0@@ -2453,6 +2453,7 @@ static voidmsdc_hs400_enhanced_strobe(struct
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
drivers/mmc/host/mtk-sd.c +1
-0mmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel(MSDC_INT_CMDQ, host->base + MSDC_INTEN);drivers/mmc/host/mtk-sd.c +3
-0@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }Quoted 1 line
Quoted 1 line
Quoted 1 line
static void msdc_cqe_disable(struct
mmc_host*mmc, boolrecovery)
Quoted 2 lines
Quoted 2 lines
A message that is not in the archive (sent off-list or not yet received): [email protected]
AngeloGioacchino Del Regno
maintainerIl 01/06/23 05:16, Wenbin Mei (梅文彬) ha scritto:
Quoted 200 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 31/05/23 09:32, Wenbin Mei (梅文彬) ha scritto:
Quoted 144 lines · AngeloGioacchino Del Regno
Quoted 125 lines
External email : Please do not click links or open attachments until
you have verified the sender or the content.
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 9 lines
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
SEND_QUEUE_STATUS(CMD13)polling.The default value
0x1000that corresponds to 150us, let's decreaseit to
The default value
0x1000(4096) corresponds to 4096 * 52.08uS =231.33uS
...so the default is not 150uS.
If I'm wrong, this means that the CQCAP field is not 0, which would
mean
that the expected 3uS would be wrong.
Also, since the calculation can be done dynamically, this is what we
should
actually do in the driver, as this gives information to the next
engineer
checking this piece of code.
Apart from this, by just writing
0x40to theCQHCI_SSC1register, youare
assuming that the CQCAP value requirement is fullfilled, but you
cannot
assume that the bootloader has set the CQCAP's ITCFVAL and ITCFMUL
fields
as you expect on all platforms: this means that implementing this
takes
a little more effort.
You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo functioninterprets reg value*/
tclk = ITCFVAL * tclk_mul; 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... ) *** Second ** 1. Pre-set ITCFMUL and ITCFVAL to ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz) 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... )I would implement the first way, as it paves the way to extend this
to different
Quoted 7 lines
tclk values if needed in the future.
Regards,
Angelo
Hi Angelo,
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports 182,
Quoted 9 lines
and these fields are the same and are readonly for all IC, but since
Mediatek CQE uses
msdc_hclk(273MHz), CMD13'interval calculation drivershould use 273MHz to get the actual time, so the actual clock is
27.3MHz.
You're right, I've misread the datasheet, just rechecked and it reports RO.
Quoted 6 lines
If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz =around 150us.
Quoted 7 lines
In addition the bootloader will not set the CQCAP's ITCFVAL and ITCFMUL
fields, because these fields of CQCAP register is RO(readonly), so we
can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.
Yes, that's right, again - this means that you should go for the first
proposed implementation, as future MediaTek SoCs may (or may not) change
that: if you implement as proposed, this is going to be a one-time thing
and future SoCs won't need specific changes.
That implementation also documents the flow about how we're getting to
the actual value, which is important for community people reading this
driver in the future for debugging purposes.
Regards,
Angelo
Quoted 9 lines
Thanks for your proposal.
I have discussed with our designer, and this fields of CQCAP's ITCFVAL and ITCFMUL will not change. If we add more code for it, these codes will also affect the execution efficiency, even if it has a very small effect.
I think if it's just for reading convenience, we can add mode comments to make it easier to read the code. Do you think it's okay to add more comments?
This isn't a performance path, but anyway, if you think that it will be at some point, you can read the two registers at probe time as part of the MMC_CAP2_CQE if branch, and then cache the invariable values to struct msdc_host: this will make you able to never perform register reads for ITCFVAL/FMUL in msdc_cqe_enable(), resolving the efficiency issue.
Even better, instead of caching ITCFVAL/FMUL to two variables, since the idle timer value likely won't ever change during runtime, you can directly perform the calculation for SSC1 at probe time and cache that value instead, so that in msdc_cqe_enable() you will have something like...
/* Set the send status command idle timer */ cqhci_writel(cq_host, host->cq_ssc1_time, CQHCI_SSC1);
where cq_ssc1_time is
struct msdc_host {
.......
u32 cq_ssc1_time;
....
}and where your probe function is
static int msdc_drv_probe(struct platform_device *pdev)
{
......
if (mmc->caps2 & MMC_CAP2_CQE) {
host->cq_host = ......
........
read itcfval;
read itcfmul;
host->cq_ssc1_time = calculated-value;
........
}
.......
}Regards,
Angelo
Quoted 81 lines
Begards,
WenbinQuoted 75 lines
Thanks
Wenbin
Quoted 71 lines
Quoted 67 lines
0x40that corresponds to 3us, which can improve the performance ofsome
eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>---
drivers/mmc/host/mtk-sd.c | 4 ++++1 file changed, 4 insertions(+)drivers/mmc/host/mtk-sd.c +0
-0index
edade0e54a0c..ffeccddcd028100644---
a/drivers/mmc/host/mtk-sd.c+++
b/drivers/mmc/host/mtk-sd.cdrivers/mmc/host/mtk-sd.c +4
-0@@ -2453,6 +2453,7 @@ static void msdc_hs400_enhanced_strobe(structmmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); +struct cqhci_host *cq_host = mmc->cqe_private;/* enable cmdq irq */ writel (MSDC_INT_CMDQ , host->base +MSDC_INTEN );@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct mmc_host *mmc)msdc_set_busy_timeout (host,20 *1000000000ULL ,0 );/* default read data timeout 1s */ msdc_set_timeout (host,1000000000ULL ,0 ); + +/* decrease the send status command idle timer to 3us */ +cqhci_writel (cq_host,0x40 ,CQHCI_SSC1 ); }static void msdc_cqe_disable (struct mmc_host *mmc,bool recovery)
Quoted 281 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 01/06/23 05:16, Wenbin Mei (梅文彬) ha scritto:Quoted 1 line
On Wed, 2023-05-31 at 10:18 +0200, AngeloGioacchino Del Regno
Quoted 1 line · wrote:
External email : Please do not click links or open attachments
until you have verified the sender or the content.
Quoted 4 lines
Il 31/05/23 09:32, Wenbin Mei (梅文彬) ha scritto:
Quoted 1 line
On Thu, 2023-05-18 at 11:13 +0200, AngeloGioacchino Del Regno
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
External email : Please do not click links or open attachments
until
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
you have verified the sender or the content.
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
SEND_QUEUE_STATUS(CMD13)polling.The default value
0x1000that corresponds to 150us, let'sdecrease
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
it to
The default value
0x1000(4096) corresponds to 4096 * 52.08uS =Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
231.33uS
...so the default is not 150uS.
If I'm wrong, this means that the CQCAP field is not 0, which
would
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mean
that the expected 3uS would be wrong.
Also, since the calculation can be done dynamically, this is what
we
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
should
actually do in the driver, as this gives information to the next
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
engineer
checking this piece of code.
Apart from this, by just writing
0x40to theCQHCI_SSC1register,you
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
are
assuming that the CQCAP value requirement is fullfilled, but you
cannot
assume that the bootloader has set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 55 lines
Quoted 54 lines
Quoted 54 lines
fields
as you expect on all platforms: this means that implementing this
takes
a little more effort.
You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo functioninterprets reg value*/
tclk = ITCFVAL * tclk_mul; 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... ) *** Second ** 1. Pre-set ITCFMUL and ITCFVAL to ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz) 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
sscit =
FIELD_PREP(CQHCI_SSC1_CIT, poll_time)cqhci_writel( ... )
I would implement the first way, as it paves the way to extend
this
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
to different
tclk values if needed in the future.
Regards,
Angelo
Hi Angelo,
Quoted 5 lines
Quoted 5 lines
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports
182,
Quoted 2 lines
Quoted 2 lines
and these fields are the same and are readonly for all IC, but
since
Quoted 2 lines
Quoted 2 lines
Mediatek CQE uses
msdc_hclk(273MHz), CMD13'interval calculationdriver
Quoted 9 lines
Quoted 6 lines
should use 273MHz to get the actual time, so the actual clock is
27.3MHz.
You're right, I've misread the datasheet, just rechecked and it
reports RO.
Quoted 9 lines
Quoted 9 lines
If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz =around 150us.
In addition the bootloader will not set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 2 lines
Quoted 2 lines
fields, because these fields of CQCAP register is RO(readonly), so
we
Quoted 7 lines
Quoted 4 lines
can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.
Yes, that's right, again - this means that you should go for the
first
Quoted 2 lines
proposed implementation, as future MediaTek SoCs may (or may not)
change
Quoted 2 lines
that: if you implement as proposed, this is going to be a one-time
thing
Quoted 5 lines
and future SoCs won't need specific changes.
That implementation also documents the flow about how we're getting
to
Quoted 2 lines
the actual value, which is important for community people reading
this
Quoted 6 lines
driver in the future for debugging purposes.
Regards,
Quoted 8 lines
Angelo
Thanks for your proposal.
I have discussed with our designer, and this fields of CQCAP's
ITCFVAL and ITCFMUL will not change.
Quoted 1 line
If we add more code for it, these codes will also affect the
execution efficiency, even if it has a very
Quoted 2 lines
small effect.
I think if it's just for reading convenience, we can add modecomments to make it easier to read the code.
Quoted 2 lines
Do you think it's okay to add more comments?
This isn't a performance path, but anyway, if you think that it will be at some
point, you can read the two registers at probe time as part of theMMC_CAP2_CQE
if branch, and then cache the invariable values tostruct msdc_host: this
will make you able to never perform register reads for ITCFVAL/FMUL inmsdc_cqe_enable(), resolving the efficiency issue.Even better, instead of caching ITCFVAL/FMUL to two variables, since the idle
timer value likely won't ever change during runtime, you can directly perform
the calculation for SSC1 at probe time and cache that value instead, so that
inmsdc_cqe_enable()you will have something like.../* Set the send status command idle timer */
cqhci_writel(cq_host, host->cq_ssc1_time, CQHCI_SSC1);where
cq_ssc1_timeis
structmsdc_host{
.......
u32cq_ssc1_time;
....
}and where your probe function is
static int
msdc_drv_probe(struct platform_device *pdev){
......if (
mmc->caps2&MMC_CAP2_CQE) {host->cq_host= ......
........
read itcfval;
read itcfmul;host->cq_ssc1_time= calculated-value;
........
}
Quoted 3 lines
.......
}
Yes, I think it's okay for me.
Another problem, ITCFVAL reports 182 for MediaTek SoCs, but we can not use it to calculate, as i said earlier, since our CQE uses msdc_hclk(273MHz), CMD13' interval calculation drivers should use 273MHz to get the actual time, not 182MHz.
If we use ITCFVAL, we will get a wrong value.
So I think it's meaningless.
Begards,
Wenbin
Quoted 91 lines
Regards,
AngeloQuoted 10 lines
Begards,
WenbinQuoted 7 lines
Thanks
Wenbin
Quoted 3 lines
Quoted 3 lines
0x40that corresponds to 3us, which can improve the performanceof
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
some
eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>---
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mmc/host/mtk-
Quoted 7 lines
drivers/mmc/host/mtk-sd.c | 4 ++++1 file changed, 4 insertions(+)drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0
sd.cQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/mtk- static void
Quoted 8 lines
index
edade0e54a0c..ffeccddcd028100644---
a/drivers/mmc/host/mtk-sd.c+++
b/drivers/mmc/host/mtk-sd.cdrivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0@@ -2453,6 +2453,7 @@ static voidmsdc_hs400_enhanced_strobe(struct
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +1
-0mmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); + struct cqhci_host *cq_host = mmc->cqe_private;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/mtk- static void msdc_cqe_enable(struct
Quoted 5 lines
/* enable cmdq irq */ writel(MSDC_INT_CMDQ, host->base + MSDC_INTEN);drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct
mmc_hostQuoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +2
-0*mmc) msdc_set_busy_timeout(host, 20 * 1000000000ULL, 0); /* default read data timeout 1s */ msdc_set_timeout(host, 1000000000ULL, 0); + + /* decrease the send status command idle timer to 3us */Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
+
cqhci_writel(cq_host, 0x40, CQHCI_SSC1);}
static void msdc_cqe_disable(struct
mmc_host*mmc, boolrecovery)
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
AngeloGioacchino Del Regno
maintainerIl 01/06/23 14:08, Wenbin Mei (梅文彬) ha scritto:
Quoted 285 lines · AngeloGioacchino Del Regno
Quoted 281 lines
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 01/06/23 05:16, Wenbin Mei (梅文彬) ha scritto:Quoted 1 line
On Wed, 2023-05-31 at 10:18 +0200, AngeloGioacchino Del Regno
Quoted 1 line · wrote:
External email : Please do not click links or open attachments
until you have verified the sender or the content.
Quoted 4 lines
Il 31/05/23 09:32, Wenbin Mei (梅文彬) ha scritto:
Quoted 1 line
On Thu, 2023-05-18 at 11:13 +0200, AngeloGioacchino Del Regno
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
External email : Please do not click links or open attachments
until
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
you have verified the sender or the content.
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
CQHCI_SSC1indicates to CQE the polling period to use when usingperiodic
SEND_QUEUE_STATUS(CMD13)polling.The default value
0x1000that corresponds to 150us, let'sdecrease
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
it to
The default value
0x1000(4096) corresponds to 4096 * 52.08uS =Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
231.33uS
...so the default is not 150uS.
If I'm wrong, this means that the CQCAP field is not 0, which
would
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
mean
that the expected 3uS would be wrong.
Also, since the calculation can be done dynamically, this is what
we
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
should
actually do in the driver, as this gives information to the next
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
engineer
checking this piece of code.
Apart from this, by just writing
0x40to theCQHCI_SSC1register,you
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
are
assuming that the CQCAP value requirement is fullfilled, but you
cannot
assume that the bootloader has set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 55 lines
Quoted 54 lines
Quoted 54 lines
fields
as you expect on all platforms: this means that implementing this
takes
a little more effort.
You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo functioninterprets reg value*/
tclk = ITCFVAL * tclk_mul; 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... ) *** Second ** 1. Pre-set ITCFMUL and ITCFVAL to ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz) 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
sscit =
FIELD_PREP(CQHCI_SSC1_CIT, poll_time)cqhci_writel( ... )
I would implement the first way, as it paves the way to extend
this
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
to different
tclk values if needed in the future.
Regards,
Angelo
Hi Angelo,
Quoted 5 lines
Quoted 5 lines
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL reports
182,
Quoted 2 lines
Quoted 2 lines
and these fields are the same and are readonly for all IC, but
since
Quoted 2 lines
Quoted 2 lines
Mediatek CQE uses
msdc_hclk(273MHz), CMD13'interval calculationdriver
Quoted 9 lines
Quoted 6 lines
should use 273MHz to get the actual time, so the actual clock is
27.3MHz.
You're right, I've misread the datasheet, just rechecked and it
reports RO.
Quoted 9 lines
Quoted 9 lines
If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz =around 150us.
In addition the bootloader will not set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 2 lines
Quoted 2 lines
fields, because these fields of CQCAP register is RO(readonly), so
we
Quoted 7 lines
Quoted 4 lines
can ignore the change for the CQCAP's ITCFVAL and ITCFMUL fields.
Yes, that's right, again - this means that you should go for the
first
Quoted 2 lines
proposed implementation, as future MediaTek SoCs may (or may not)
change
Quoted 2 lines
that: if you implement as proposed, this is going to be a one-time
thing
Quoted 5 lines
and future SoCs won't need specific changes.
That implementation also documents the flow about how we're getting
to
Quoted 2 lines
the actual value, which is important for community people reading
this
Quoted 6 lines
driver in the future for debugging purposes.
Regards,
Quoted 8 lines
Angelo
Thanks for your proposal.
I have discussed with our designer, and this fields of CQCAP's
ITCFVAL and ITCFMUL will not change.
Quoted 1 line
If we add more code for it, these codes will also affect the
execution efficiency, even if it has a very
Quoted 2 lines
small effect.
I think if it's just for reading convenience, we can add modecomments to make it easier to read the code.
Quoted 2 lines
Do you think it's okay to add more comments?
This isn't a performance path, but anyway, if you think that it will be at some
point, you can read the two registers at probe time as part of theMMC_CAP2_CQE
if branch, and then cache the invariable values tostruct msdc_host: this
will make you able to never perform register reads for ITCFVAL/FMUL inmsdc_cqe_enable(), resolving the efficiency issue.Even better, instead of caching ITCFVAL/FMUL to two variables, since the idle
timer value likely won't ever change during runtime, you can directly perform
the calculation for SSC1 at probe time and cache that value instead, so that
inmsdc_cqe_enable()you will have something like.../* Set the send status command idle timer */
cqhci_writel(cq_host, host->cq_ssc1_time, CQHCI_SSC1);where
cq_ssc1_timeis
structmsdc_host{
.......
u32cq_ssc1_time;
....
}and where your probe function is
static int
msdc_drv_probe(struct platform_device *pdev){
......if (
mmc->caps2&MMC_CAP2_CQE) {host->cq_host= ......
........
read itcfval;
read itcfmul;host->cq_ssc1_time= calculated-value;
........
}Quoted 3 lines
.......
}
Quoted 7 lines
Yes, I think it's okay for me.
Another problem, ITCFVAL reports 182 for MediaTek SoCs, but we can not use it to calculate, as i said earlier, since our CQE usesmsdc_hclk(273MHz), CMD13' interval calculation drivers should use 273MHz to get the actual time, not 182MHz.
If we use ITCFVAL, we will get a wrong value.
So I think it's meaningless.
clk_get_rate(msdc_hclk) gives you the current msdc_hclk clock rate: use it in place of reading ITCFVAL, that's your solution.
I would imagine that *at least* ITCFMUL is correct on MediaTek SoCs, so you can use that one as it is.
Regards,
Angelo
Quoted 94 lines
Begards,
WenbinQuoted 91 lines
Regards,
AngeloQuoted 10 lines
Begards,
WenbinQuoted 7 lines
Thanks
Wenbin
Quoted 3 lines
Quoted 3 lines
0x40that corresponds to 3us, which can improve the performanceof
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
some
eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>---
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mmc/host/mtk-
Quoted 7 lines
drivers/mmc/host/mtk-sd.c | 4 ++++1 file changed, 4 insertions(+)drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0
sd.cQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/mtk- static void
Quoted 8 lines
index
edade0e54a0c..ffeccddcd028100644---
a/drivers/mmc/host/mtk-sd.c+++
b/drivers/mmc/host/mtk-sd.cdrivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0@@ -2453,6 +2453,7 @@ static voidmsdc_hs400_enhanced_strobe(struct
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +1
-0mmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); + struct cqhci_host *cq_host = mmc->cqe_private;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/mtk- static void msdc_cqe_enable(struct
Quoted 5 lines
/* enable cmdq irq */ writel(MSDC_INT_CMDQ, host->base + MSDC_INTEN);drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct
mmc_hostQuoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +2
-0*mmc) msdc_set_busy_timeout(host, 20 * 1000000000ULL, 0); /* default read data timeout 1s */ msdc_set_timeout(host, 1000000000ULL, 0); + + /* decrease the send status command idle timer to 3us */Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
+
cqhci_writel(cq_host, 0x40, CQHCI_SSC1);}
static void msdc_cqe_disable(struct
mmc_host*mmc, boolrecovery)
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 317 lines · AngeloGioacchino Del Regno
External email : Please do not click links or open attachments until you have verified the sender or the content.
Il 01/06/23 14:08, Wenbin Mei (梅文彬) ha scritto:Quoted 1 line
On Thu, 2023-06-01 at 12:00 +0200, AngeloGioacchino Del Regno
Quoted 2 lines · wrote:
Quoted 2 lines
External email : Please do not click links or open attachments
until
Quoted 21 lines
Quoted 21 lines
you have verified the sender or the content.
Il 01/06/23 05:16, Wenbin Mei (梅文彬) ha scritto:Quoted 1 line
On Wed, 2023-05-31 at 10:18 +0200, AngeloGioacchino Del Regno
Quoted 1 line · wrote:
External email : Please do not click links or open attachments
until you have verified the sender or the content.
Quoted 4 lines
Il 31/05/23 09:32, Wenbin Mei (梅文彬) ha scritto:
Quoted 1 line
On Thu, 2023-05-18 at 11:13 +0200, AngeloGioacchino Del Regno
Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
External email : Please do not click links or open attachments
until
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
you have verified the sender or the content.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Il 10/05/23 03:58, Wenbin Mei ha scritto:
Quoted 1 line
CQHCI_SSC1indicates to CQE the polling period to use whenusing
Quoted 23 lines
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
periodic
SEND_QUEUE_STATUS(CMD13)polling.The default value
0x1000that corresponds to 150us, let'sdecrease
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
it to
The default value
0x1000(4096) corresponds to 4096 * 52.08uS =Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
231.33uS
...so the default is not 150uS.
If I'm wrong, this means that the CQCAP field is not 0, which
would
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
mean
that the expected 3uS would be wrong.
Also, since the calculation can be done dynamically, this is
what
Quoted 5 lines
Quoted 5 lines
we
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
should
actually do in the driver, as this gives information to the
next
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
engineer
checking this piece of code.
Apart from this, by just writing
0x40to theCQHCI_SSC1register,
Quoted 5 lines
Quoted 5 lines
you
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
are
assuming that the CQCAP value requirement is fullfilled, but
you
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
cannot
assume that the bootloader has set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
fields
as you expect on all platforms: this means that implementing
this
Quoted 74 lines
Quoted 74 lines
Quoted 51 lines
Quoted 50 lines
Quoted 50 lines
takes
a little more effort.
You have two ways to implement this:
*** First ***
1. Read ITCFMUL and ITCFVAL, then:
tclk_mul=itcfmul_to_mhz(ITCFMUL); /* pseudo functioninterprets reg value*/
tclk = ITCFVAL * tclk_mul; 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3); sscit = FIELD_PREP(CQHCI_SSC1_CIT, poll_time) cqhci_writel( ... ) *** Second ** 1. Pre-set ITCFMUL and ITCFVAL to ITCFVAL = 192 (decimal) ITCFMUL = 2 (where 2 == 0.1MHz) 2. Set SSC1 so that we get 3nS: #define CQHCI_SSC1_CIT GENMASK(15, 0) poll_time = cit_time_ns_to_regval(3);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
sscit =
FIELD_PREP(CQHCI_SSC1_CIT, poll_time)cqhci_writel( ... )
I would implement the first way, as it paves the way to extend
this
Quoted 15 lines
Quoted 14 lines
Quoted 10 lines
to different
tclk values if needed in the future.
Regards,
Angelo
Hi Angelo,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Sorry for lately reply.
For Mediatek mmc host IP, ITCFMUL is 0x2(0x1MHz), ITVFVAL
reports
Quoted 15 lines
Quoted 15 lines
182,
Quoted 2 lines
Quoted 2 lines
and these fields are the same and are readonly for all IC, but
since
Quoted 2 lines
Quoted 2 lines
Mediatek CQE uses
msdc_hclk(273MHz), CMD13'interval calculationdriver
Quoted 8 lines
Quoted 6 lines
should use 273MHz to get the actual time, so the actual clock is
27.3MHz.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
You're right, I've misread the datasheet, just rechecked and it
reports RO.
Quoted 3 lines
Quoted 3 lines
If CIT is
0x1000by default, CMD idle time:0x1000* 1 / 27.3MHz=
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
around 150us.
In addition the bootloader will not set the CQCAP's ITCFVAL and
ITCFMUL
Quoted 2 lines
Quoted 2 lines
fields, because these fields of CQCAP register is RO(readonly),
so
Quoted 3 lines
Quoted 3 lines
we
Quoted 2 lines
Quoted 2 lines
can ignore the change for the CQCAP's ITCFVAL and ITCFMUL
fields.
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
Yes, that's right, again - this means that you should go for the
first
Quoted 2 lines
proposed implementation, as future MediaTek SoCs may (or may not)
change
Quoted 2 lines
that: if you implement as proposed, this is going to be a one-
time
Quoted 6 lines
Quoted 6 lines
thing
Quoted 5 lines
and future SoCs won't need specific changes.
That implementation also documents the flow about how we're
getting
Quoted 20 lines
Quoted 20 lines
to
Quoted 2 lines
the actual value, which is important for community people reading
this
Quoted 6 lines
driver in the future for debugging purposes.
Regards,
Quoted 8 lines
Angelo
Thanks for your proposal.
I have discussed with our designer, and this fields of CQCAP's
ITCFVAL and ITCFMUL will not change.
Quoted 1 line
If we add more code for it, these codes will also affect the
Quoted 8 lines
Quoted 8 lines
execution efficiency, even if it has a very
Quoted 2 lines
small effect.
I think if it's just for reading convenience, we can add modecomments to make it easier to read the code.
Quoted 2 lines
Do you think it's okay to add more comments?
This isn't a performance path, but anyway, if you think that it
will
Quoted 6 lines
Quoted 6 lines
be at some
point, you can read the two registers at probe time as part of theMMC_CAP2_CQE
if branch, and then cache the invariable values tostruct msdc_host: this
will make you able to never perform register reads forITCFVAL/FMUL
Quoted 4 lines
Quoted 4 lines
in
msdc_cqe_enable(), resolving the efficiency issue.Even better, instead of caching ITCFVAL/FMUL to two variables,
since
Quoted 2 lines
Quoted 2 lines
the idle
timer value likely won't ever change during runtime, you candirectly
Quoted 2 lines
Quoted 2 lines
perform
the calculation for SSC1 at probe time and cache that valueinstead,
Quoted 28 lines
Quoted 28 lines
so that
inmsdc_cqe_enable()you will have something like.../* Set the send status command idle timer */
cqhci_writel(cq_host, host->cq_ssc1_time, CQHCI_SSC1);where
cq_ssc1_timeis
structmsdc_host{
.......
u32cq_ssc1_time;
....
}and where your probe function is
static int
msdc_drv_probe(struct platform_device *pdev){
......if (
mmc->caps2&MMC_CAP2_CQE) {host->cq_host= ......
........
read itcfval;
read itcfmul;host->cq_ssc1_time= calculated-value;
........
}Quoted 5 lines
Quoted 3 lines
.......
}Yes, I think it's okay for me.
Another problem, ITCFVAL reports 182 for MediaTek SoCs, but we cannot
Quoted 5 lines
use it to calculate, as i said earlier, since our CQE uses
msdc_hclk(273MHz), CMD13' interval calculation drivers should use 273MHz to get the actual time, not 182MHz.
If we use ITCFVAL, we will get a wrong value.
So I think it's meaningless.
Quoted 7 lines
clk_get_rate(msdc_hclk)gives you the currentmsdc_hclkclock rate:
use it
in place of reading ITCFVAL, that's your solution.I would imagine that *at least* ITCFMUL is correct on MediaTek SoCs, so you
can use that one as it is.
Thanks for your review.
I will implement it in the next version.
Begards,
Wenbin
Quoted 100 lines
Regards,
AngeloQuoted 17 lines
Begards,
WenbinQuoted 14 lines
Regards,
AngeloQuoted 10 lines
Begards,
WenbinQuoted 7 lines
Thanks
Wenbin
Quoted 3 lines
Quoted 3 lines
0x40that corresponds to 3us, which can improve theperformance
Quoted 77 lines
Quoted 77 lines
of
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
some
eMMC devices.
Signed-off-by Wenbin Mei <[email protected]>---
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/mmc/host/mtk-
Quoted 7 lines
drivers/mmc/host/mtk-sd.c | 4 ++++1 file changed, 4 insertions(+)drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0
sd.cQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/mtk- static void
Quoted 8 lines
index
edade0e54a0c..ffeccddcd028100644---
a/drivers/mmc/host/mtk-sd.c+++
b/drivers/mmc/host/mtk-sd.cdrivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0@@ -2453,6 +2453,7 @@ static voidmsdc_hs400_enhanced_strobe(struct
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +1
-0mmc_host *mmc, static void msdc_cqe_enable(struct mmc_host *mmc) { struct msdc_host *host = mmc_priv(mmc); + struct cqhci_host *cq_host = mmc->cqe_private;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/mtk- static void msdc_cqe_enable(struct
Quoted 5 lines
/* enable cmdq irq */ writel(MSDC_INT_CMDQ, host->base + MSDC_INTEN);drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +0
-0@@ -2462,6 +2463,9 @@ static void msdc_cqe_enable(struct
mmc_hostQuoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
drivers/mmc/host/mtk- renamed from drivers/mmc/host/mtk-sd.c +2
-0*mmc) msdc_set_busy_timeout(host, 20 * 1000000000ULL, 0); /* default read data timeout 1s */ msdc_set_timeout(host, 1000000000ULL, 0); + + /* decrease the send status command idle timer to 3us */Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
+
cqhci_writel(cq_host, 0x40, CQHCI_SSC1);}
static void msdc_cqe_disable(struct
mmc_host*mmc, boolrecovery)
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines