mmc: dw_mmc: correct the calculation for CLKDIV
Subsystems (2)
PATCH 4/4 mmc: dw_mmc: correct the calculation for CLKDIV
In case of "host->bus_hz < slot->clock", divider value is miscalculated. And clock divider register value is multiple of 2. If calculated divider value is odd number, result can be over-clocking.
--- drivers/mmc/host/dw_mmc.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/mmc/host/dw_mmc.c +6 -4
@@ -617,14 +617,16 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot)u32 div;if (slot->clock != host->current_speed) { -if (host->bus_hz % slot->clock) + div = host->bus_hz / slot->clock; +if (host->bus_hz % slot->clock && + host->bus_hz > slot->clock)/* * move the + 1 after the divide to prevent * over-clocking the card. */ - div = ((host->bus_hz / slot->clock) >>1 ) +1 ; -else - div = (host->bus_hz / slot->clock) >>1 ; + div +=1 ; + + div = (host->bus_hz != slot->clock) ?DIV_ROUND_UP (div,2 ) :0 ;dev_info (&slot->mmc->class_dev, "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ"
Signature · 1 line
1.7.0.4
Quoted 16 lines · Seungwon Jeon
In case of "
host->bus_hz<slot->clock", divider value is miscalculated. And clock divider register value is multiple of 2. If calculated divider value is odd number, result can be over-clocking.Signed-off-by Seungwon Jeon <[email protected]>---
drivers/mmc/host/dw_mmc.c | 10 ++++++----1 files changed, 6 insertions(+), 4 deletions(-)drivers/mmc/host/dw_mmc.c +0
-0@@ -617,14 +617,16 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) u32 div;
drivers/mmc/host/dw_mmc.c static void dw_mci_setup_bus(struct dw_mci_slot *slot) · line 626
Quoted 10 lines
drivers/mmc/host/dw_mmc.c +3
-1if (slot->clock != host->current_speed) { - if (host->bus_hz % slot->clock) + div = host->bus_hz / slot->clock; + if (host->bus_hz % slot->clock && + host->bus_hz > slot->clock) /** move the + 1 after the divide to prevent * over-clocking the card. */
This comment seems to be no longer relevant so it should be removed.
Quoted 17 lines
drivers/mmc/host/dw_mmc.c +3
-3- div = ((host->bus_hz / slot->clock) >> 1) + 1; - else - div = (host->bus_hz / slot->clock) >> 1; + div += 1; + + div = (host->bus_hz != slot->clock) ? DIV_ROUND_UP(div, 2) : 0; dev_info(&slot->mmc->class_dev,"Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ" --
1.7.0.4--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 18 lines · Will Newton
Quoted 17 lines · Seungwon Jeon
In case of "
host->bus_hz<slot->clock", divider value is miscalculated. And clock divider register value is multiple of 2. If calculated divider value is odd number, result can be over-clocking.Signed-off-by Seungwon Jeon <[email protected]>---
drivers/mmc/host/dw_mmc.c | 10 ++++++----1 files changed, 6 insertions(+), 4 deletions(-)drivers/mmc/host/dw_mmc.c +0
-0@@ -617,14 +617,16 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) u32 div;
Quoted 16 lines
drivers/mmc/host/dw_mmc.c static void dw_mci_setup_bus(struct dw_mci_slot *slot) · line 626
Quoted 9 lines
drivers/mmc/host/dw_mmc.c +3
-1if (slot->clock != host->current_speed) { - if (host->bus_hz % slot->clock) + div = host->bus_hz / slot->clock; + if (host->bus_hz % slot->clock && + host->bus_hz > slot->clock) /** move the + 1 after the divide to prevent * over-clocking the card. */ This comment seems to be no longer relevant so it should be removed.
Quoted 4 lines
drivers/mmc/host/dw_mmc.c +1
-3- div = ((host->bus_hz / slot->clock) >> 1) + 1; - else - div = (host->bus_hz / slot->clock) >> 1; + div += 1;
div += 1;
It's still effective.
Best regards,
Seungwon Jeon
Quoted 17 lines
Quoted 9 lines
drivers/mmc/host/dw_mmc.c +2
-0+ + div = (host->bus_hz != slot->clock) ? DIV_ROUND_UP(div, 2) : 0; dev_info(&slot->mmc->class_dev,"Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ" --
1.7.0.4Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html