Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge master.kernel.org:/home/rmk/linux-2.6-mmc

* master.kernel.org:/home/rmk/linux-2.6-mmc:
[MMC] Move set_ios debugging into mmc.c
[MMC] Correct mmc_request_done comments
[MMC] PXA: reduce the number of lines PXAMCI debug uses
[MMC] PXA and i.MX: don't avoid sending stop command on error
[MMC] extend data timeout for writes
[ARM] 3485/1: i.MX: MX1 SD/MMC fix of unintentional double start possibility

+95 -67
-3
drivers/mmc/at91_mci.c
··· 621 621 struct at91mci_host *host = mmc_priv(mmc); 622 622 unsigned long at91_master_clock = clk_get_rate(mci_clk); 623 623 624 - DBG("Clock %uHz, busmode %u, powermode %u, Vdd %u\n", 625 - ios->clock, ios->bus_mode, ios->power_mode, ios->vdd); 626 - 627 624 if (host) 628 625 host->bus_mode = ios->bus_mode; 629 626 else
-4
drivers/mmc/au1xmmc.c
··· 720 720 { 721 721 struct au1xmmc_host *host = mmc_priv(mmc); 722 722 723 - DBG("set_ios (power=%u, clock=%uHz, vdd=%u, mode=%u)\n", 724 - host->id, ios->power_mode, ios->clock, ios->vdd, 725 - ios->bus_mode); 726 - 727 723 if (ios->power_mode == MMC_POWER_OFF) 728 724 au1xmmc_set_power(host, 0); 729 725 else if (ios->power_mode == MMC_POWER_ON) {
+45 -17
drivers/mmc/imxmmc.c
··· 102 102 #define IMXMCI_PEND_CPU_DATA_b 5 103 103 #define IMXMCI_PEND_CARD_XCHG_b 6 104 104 #define IMXMCI_PEND_SET_INIT_b 7 105 + #define IMXMCI_PEND_STARTED_b 8 105 106 106 107 #define IMXMCI_PEND_IRQ_m (1 << IMXMCI_PEND_IRQ_b) 107 108 #define IMXMCI_PEND_DMA_END_m (1 << IMXMCI_PEND_DMA_END_b) ··· 112 111 #define IMXMCI_PEND_CPU_DATA_m (1 << IMXMCI_PEND_CPU_DATA_b) 113 112 #define IMXMCI_PEND_CARD_XCHG_m (1 << IMXMCI_PEND_CARD_XCHG_b) 114 113 #define IMXMCI_PEND_SET_INIT_m (1 << IMXMCI_PEND_SET_INIT_b) 114 + #define IMXMCI_PEND_STARTED_m (1 << IMXMCI_PEND_STARTED_b) 115 115 116 116 static void imxmci_stop_clock(struct imxmci_host *host) 117 117 { ··· 133 131 dev_dbg(mmc_dev(host->mmc), "imxmci_stop_clock blocked, no luck\n"); 134 132 } 135 133 136 - static void imxmci_start_clock(struct imxmci_host *host) 134 + static int imxmci_start_clock(struct imxmci_host *host) 137 135 { 138 - int i = 0; 139 - MMC_STR_STP_CLK &= ~STR_STP_CLK_STOP_CLK; 140 - while(i < 0x1000) { 141 - if(!(i & 0x7f)) 142 - MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; 136 + unsigned int trials = 0; 137 + unsigned int delay_limit = 128; 138 + unsigned long flags; 143 139 144 - if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) { 145 - /* Check twice before cut */ 140 + MMC_STR_STP_CLK &= ~STR_STP_CLK_STOP_CLK; 141 + 142 + clear_bit(IMXMCI_PEND_STARTED_b, &host->pending_events); 143 + 144 + /* 145 + * Command start of the clock, this usually succeeds in less 146 + * then 6 delay loops, but during card detection (low clockrate) 147 + * it takes up to 5000 delay loops and sometimes fails for the first time 148 + */ 149 + MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; 150 + 151 + do { 152 + unsigned int delay = delay_limit; 153 + 154 + while(delay--){ 146 155 if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) 147 - return; 156 + /* Check twice before cut */ 157 + if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) 158 + return 0; 159 + 160 + if(test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) 161 + return 0; 148 162 } 149 163 150 - i++; 151 - } 152 - dev_dbg(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n"); 164 + local_irq_save(flags); 165 + /* 166 + * Ensure, that request is not doubled under all possible circumstances. 167 + * It is possible, that cock running state is missed, because some other 168 + * IRQ or schedule delays this function execution and the clocks has 169 + * been already stopped by other means (response processing, SDHC HW) 170 + */ 171 + if(!test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) 172 + MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; 173 + local_irq_restore(flags); 174 + 175 + } while(++trials<256); 176 + 177 + dev_err(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n"); 178 + 179 + return -1; 153 180 } 154 181 155 182 static void imxmci_softreset(void) ··· 529 498 530 499 data_error = imxmci_finish_data(host, stat); 531 500 532 - if (host->req->stop && (data_error == MMC_ERR_NONE)) { 501 + if (host->req->stop) { 533 502 imxmci_stop_clock(host); 534 503 imxmci_start_cmd(host, host->req->stop, 0); 535 504 } else { ··· 653 622 atomic_set(&host->stuck_timeout, 0); 654 623 host->status_reg = stat; 655 624 set_bit(IMXMCI_PEND_IRQ_b, &host->pending_events); 625 + set_bit(IMXMCI_PEND_STARTED_b, &host->pending_events); 656 626 tasklet_schedule(&host->tasklet); 657 627 658 628 return IRQ_RETVAL(handled);; ··· 806 774 { 807 775 struct imxmci_host *host = mmc_priv(mmc); 808 776 int prescaler; 809 - 810 - dev_dbg(mmc_dev(host->mmc), "clock %u power %u vdd %u width %u\n", 811 - ios->clock, ios->power_mode, ios->vdd, 812 - (ios->bus_width==MMC_BUS_WIDTH_4)?4:1); 813 777 814 778 if( ios->bus_width==MMC_BUS_WIDTH_4 ) { 815 779 host->actual_bus_width = MMC_BUS_WIDTH_4;
+40 -22
drivers/mmc/mmc.c
··· 59 59 60 60 61 61 /** 62 - * mmc_request_done - finish processing an MMC command 63 - * @host: MMC host which completed command 64 - * @mrq: MMC request which completed 62 + * mmc_request_done - finish processing an MMC request 63 + * @host: MMC host which completed request 64 + * @mrq: MMC request which request 65 65 * 66 66 * MMC drivers should call this function when they have completed 67 - * their processing of a command. This should be called before the 68 - * data part of the command has completed. 67 + * their processing of a request. 69 68 */ 70 69 void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) 71 70 { 72 71 struct mmc_command *cmd = mrq->cmd; 73 - int err = mrq->cmd->error; 74 - pr_debug("MMC: req done (%02x): %d: %08x %08x %08x %08x\n", 75 - cmd->opcode, err, cmd->resp[0], cmd->resp[1], 76 - cmd->resp[2], cmd->resp[3]); 72 + int err = cmd->error; 73 + 74 + pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n", 75 + mmc_hostname(host), cmd->opcode, err, 76 + mrq->data ? mrq->data->error : 0, 77 + mrq->stop ? mrq->stop->error : 0, 78 + cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); 77 79 78 80 if (err && cmd->retries) { 79 81 cmd->retries--; ··· 99 97 void 100 98 mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) 101 99 { 102 - pr_debug("MMC: starting cmd %02x arg %08x flags %08x\n", 103 - mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); 100 + pr_debug("%s: starting CMD%u arg %08x flags %08x\n", 101 + mmc_hostname(host), mrq->cmd->opcode, 102 + mrq->cmd->arg, mrq->cmd->flags); 104 103 105 104 WARN_ON(host->card_busy == NULL); 106 105 ··· 315 312 316 313 EXPORT_SYMBOL(mmc_release_host); 317 314 315 + static inline void mmc_set_ios(struct mmc_host *host) 316 + { 317 + struct mmc_ios *ios = &host->ios; 318 + 319 + pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", 320 + mmc_hostname(host), ios->clock, ios->bus_mode, 321 + ios->power_mode, ios->chip_select, ios->vdd, 322 + ios->bus_width); 323 + 324 + host->ops->set_ios(host, ios); 325 + } 326 + 318 327 static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) 319 328 { 320 329 int err; ··· 379 364 } 380 365 } 381 366 382 - host->ops->set_ios(host, &host->ios); 367 + mmc_set_ios(host); 383 368 384 369 return MMC_ERR_NONE; 385 370 } ··· 430 415 ocr = 3 << bit; 431 416 432 417 host->ios.vdd = bit; 433 - host->ops->set_ios(host, &host->ios); 418 + mmc_set_ios(host); 434 419 } else { 435 420 ocr = 0; 436 421 } ··· 564 549 csd->read_partial = UNSTUFF_BITS(resp, 79, 1); 565 550 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); 566 551 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); 552 + csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); 567 553 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); 568 554 csd->write_partial = UNSTUFF_BITS(resp, 21, 1); 569 555 } else { ··· 599 583 csd->read_partial = UNSTUFF_BITS(resp, 79, 1); 600 584 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); 601 585 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); 586 + csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); 602 587 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); 603 588 csd->write_partial = UNSTUFF_BITS(resp, 21, 1); 604 589 } ··· 683 666 struct mmc_command cmd; 684 667 685 668 host->ios.chip_select = MMC_CS_HIGH; 686 - host->ops->set_ios(host, &host->ios); 669 + mmc_set_ios(host); 687 670 688 671 mmc_delay(1); 689 672 ··· 696 679 mmc_delay(1); 697 680 698 681 host->ios.chip_select = MMC_CS_DONTCARE; 699 - host->ops->set_ios(host, &host->ios); 682 + mmc_set_ios(host); 700 683 701 684 mmc_delay(1); 702 685 } ··· 721 704 host->ios.chip_select = MMC_CS_DONTCARE; 722 705 host->ios.power_mode = MMC_POWER_UP; 723 706 host->ios.bus_width = MMC_BUS_WIDTH_1; 724 - host->ops->set_ios(host, &host->ios); 707 + mmc_set_ios(host); 725 708 726 709 mmc_delay(1); 727 710 728 711 host->ios.clock = host->f_min; 729 712 host->ios.power_mode = MMC_POWER_ON; 730 - host->ops->set_ios(host, &host->ios); 713 + mmc_set_ios(host); 731 714 732 715 mmc_delay(2); 733 716 } ··· 740 723 host->ios.chip_select = MMC_CS_DONTCARE; 741 724 host->ios.power_mode = MMC_POWER_OFF; 742 725 host->ios.bus_width = MMC_BUS_WIDTH_1; 743 - host->ops->set_ios(host, &host->ios); 726 + mmc_set_ios(host); 744 727 } 745 728 746 729 static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) ··· 988 971 if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) 989 972 max_dtr = card->csd.max_dtr; 990 973 991 - pr_debug("MMC: selected %d.%03dMHz transfer rate\n", 974 + pr_debug("%s: selected %d.%03dMHz transfer rate\n", 975 + mmc_hostname(host), 992 976 max_dtr / 1000000, (max_dtr / 1000) % 1000); 993 977 994 978 return max_dtr; ··· 1064 1046 } else { 1065 1047 host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; 1066 1048 host->ios.clock = host->f_min; 1067 - host->ops->set_ios(host, &host->ios); 1049 + mmc_set_ios(host); 1068 1050 1069 1051 /* 1070 1052 * We should remember the OCR mask from the existing ··· 1100 1082 * Ok, now switch to push-pull mode. 1101 1083 */ 1102 1084 host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; 1103 - host->ops->set_ios(host, &host->ios); 1085 + mmc_set_ios(host); 1104 1086 1105 1087 mmc_read_csds(host); 1106 1088 ··· 1146 1128 * attached cards and the host support. 1147 1129 */ 1148 1130 host->ios.clock = mmc_calculate_clock(host); 1149 - host->ops->set_ios(host, &host->ios); 1131 + mmc_set_ios(host); 1150 1132 } 1151 1133 1152 1134 mmc_release_host(host);
+6
drivers/mmc/mmc_block.c
··· 187 187 brq.cmd.opcode = MMC_WRITE_BLOCK; 188 188 brq.data.flags |= MMC_DATA_WRITE; 189 189 brq.data.blocks = 1; 190 + 191 + /* 192 + * Scale up the timeout by the r2w factor 193 + */ 194 + brq.data.timeout_ns <<= card->csd.r2w_factor; 195 + brq.data.timeout_clks <<= card->csd.r2w_factor; 190 196 } 191 197 192 198 if (brq.data.blocks > 1) {
-3
drivers/mmc/mmci.c
··· 402 402 struct mmci_host *host = mmc_priv(mmc); 403 403 u32 clk = 0, pwr = 0; 404 404 405 - DBG(host, "clock %uHz busmode %u powermode %u Vdd %u\n", 406 - ios->clock, ios->bus_mode, ios->power_mode, ios->vdd); 407 - 408 405 if (ios->clock) { 409 406 if (ios->clock >= host->mclk) { 410 407 clk = MCI_CLK_BYPASS;
+3 -10
drivers/mmc/pxamci.c
··· 198 198 199 199 static void pxamci_finish_request(struct pxamci_host *host, struct mmc_request *mrq) 200 200 { 201 - pr_debug("PXAMCI: request done\n"); 202 201 host->mrq = NULL; 203 202 host->cmd = NULL; 204 203 host->data = NULL; ··· 290 291 pxamci_disable_irq(host, DATA_TRAN_DONE); 291 292 292 293 host->data = NULL; 293 - if (host->mrq->stop && data->error == MMC_ERR_NONE) { 294 + if (host->mrq->stop) { 294 295 pxamci_stop_clock(host); 295 296 pxamci_start_cmd(host, host->mrq->stop, 0); 296 297 } else { ··· 308 309 309 310 ireg = readl(host->base + MMC_I_REG); 310 311 311 - pr_debug("PXAMCI: irq %08x\n", ireg); 312 - 313 312 if (ireg) { 314 313 unsigned stat = readl(host->base + MMC_STAT); 315 314 316 - pr_debug("PXAMCI: stat %08x\n", stat); 315 + pr_debug("PXAMCI: irq %08x stat %08x\n", ireg, stat); 317 316 318 317 if (ireg & END_CMD_RES) 319 318 handled |= pxamci_cmd_done(host, stat); ··· 365 368 { 366 369 struct pxamci_host *host = mmc_priv(mmc); 367 370 368 - pr_debug("pxamci_set_ios: clock %u power %u vdd %u.%02u\n", 369 - ios->clock, ios->power_mode, ios->vdd / 100, 370 - ios->vdd % 100); 371 - 372 371 if (ios->clock) { 373 372 unsigned int clk = CLOCKRATE / ios->clock; 374 373 if (CLOCKRATE / clk > ios->clock) ··· 390 397 host->cmdat |= CMDAT_INIT; 391 398 } 392 399 393 - pr_debug("pxamci_set_ios: clkrt = %x cmdat = %x\n", 400 + pr_debug("PXAMCI: clkrt = %x cmdat = %x\n", 394 401 host->clkrt, host->cmdat); 395 402 } 396 403
-4
drivers/mmc/sdhci.c
··· 570 570 571 571 spin_lock_irqsave(&host->lock, flags); 572 572 573 - DBG("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", 574 - ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, 575 - ios->vdd, ios->bus_width); 576 - 577 573 /* 578 574 * Reset the chip on each power off. 579 575 * Should clear out any weird states.
-4
drivers/mmc/wbsd.c
··· 931 931 struct wbsd_host *host = mmc_priv(mmc); 932 932 u8 clk, setup, pwr; 933 933 934 - DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", 935 - ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, 936 - ios->vdd, ios->bus_width); 937 - 938 934 spin_lock_bh(&host->lock); 939 935 940 936 /*
+1
include/linux/mmc/card.h
··· 28 28 unsigned short cmdclass; 29 29 unsigned short tacc_clks; 30 30 unsigned int tacc_ns; 31 + unsigned int r2w_factor; 31 32 unsigned int max_dtr; 32 33 unsigned int read_blkbits; 33 34 unsigned int write_blkbits;