diff options
author | Pierre Ossman <drzeus@drzeus.cx> | 2006-11-21 11:55:45 -0500 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2007-02-04 14:54:10 -0500 |
commit | 55db890a838c7b37256241b1fc53d6344aa79cc0 (patch) | |
tree | 02d5868f69a15eea69aaf517b67bc9cbdffe2ff8 /drivers | |
parent | fe4a3c7a20f14d86022a8132adbf6ddb98e7197c (diff) |
mmc: Allow host drivers to specify max block count
Many controllers have an upper limit on the number of blocks that can be
transferred in one request. Allow the host drivers to specify this and make
sure we avoid hitting this limit.
Also change the max_sectors field to avoid confusion. This makes it map
less directly to the block layer limits, but as they didn't apply directly
on MMC cards anyway, this isn't a great loss.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mmc/at91_mci.c | 1 | ||||
-rw-r--r-- | drivers/mmc/au1xmmc.c | 1 | ||||
-rw-r--r-- | drivers/mmc/imxmmc.c | 3 | ||||
-rw-r--r-- | drivers/mmc/mmc.c | 6 | ||||
-rw-r--r-- | drivers/mmc/mmc_block.c | 4 | ||||
-rw-r--r-- | drivers/mmc/mmc_queue.c | 2 | ||||
-rw-r--r-- | drivers/mmc/mmci.c | 10 | ||||
-rw-r--r-- | drivers/mmc/omap.c | 5 | ||||
-rw-r--r-- | drivers/mmc/pxamci.c | 5 | ||||
-rw-r--r-- | drivers/mmc/sdhci.c | 13 | ||||
-rw-r--r-- | drivers/mmc/tifm_sd.c | 9 | ||||
-rw-r--r-- | drivers/mmc/wbsd.c | 15 |
12 files changed, 53 insertions, 21 deletions
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c index e28850dec9ed..2ce50f38e3c7 100644 --- a/drivers/mmc/at91_mci.c +++ b/drivers/mmc/at91_mci.c | |||
@@ -824,6 +824,7 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
824 | mmc->caps = MMC_CAP_BYTEBLOCK; | 824 | mmc->caps = MMC_CAP_BYTEBLOCK; |
825 | 825 | ||
826 | mmc->max_blk_size = 4095; | 826 | mmc->max_blk_size = 4095; |
827 | mmc->max_blk_count = mmc->max_req_size; | ||
827 | 828 | ||
828 | host = mmc_priv(mmc); | 829 | host = mmc_priv(mmc); |
829 | host->mmc = mmc; | 830 | host->mmc = mmc; |
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c index 74e6ac0c7f71..b834be261ab7 100644 --- a/drivers/mmc/au1xmmc.c +++ b/drivers/mmc/au1xmmc.c | |||
@@ -923,6 +923,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev) | |||
923 | mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT; | 923 | mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT; |
924 | 924 | ||
925 | mmc->max_blk_size = 2048; | 925 | mmc->max_blk_size = 2048; |
926 | mmc->max_blk_count = 512; | ||
926 | 927 | ||
927 | mmc->ocr_avail = AU1XMMC_OCR; | 928 | mmc->ocr_avail = AU1XMMC_OCR; |
928 | 929 | ||
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c index 2107f8a8605e..b060d4bfba29 100644 --- a/drivers/mmc/imxmmc.c +++ b/drivers/mmc/imxmmc.c | |||
@@ -958,9 +958,10 @@ static int imxmci_probe(struct platform_device *pdev) | |||
958 | /* MMC core transfer sizes tunable parameters */ | 958 | /* MMC core transfer sizes tunable parameters */ |
959 | mmc->max_hw_segs = 64; | 959 | mmc->max_hw_segs = 64; |
960 | mmc->max_phys_segs = 64; | 960 | mmc->max_phys_segs = 64; |
961 | mmc->max_sectors = 64; /* default 1 << (PAGE_CACHE_SHIFT - 9) */ | ||
962 | mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */ | 961 | mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */ |
962 | mmc->max_req_size = 64*512; /* default PAGE_CACHE_SIZE */ | ||
963 | mmc->max_blk_size = 2048; | 963 | mmc->max_blk_size = 2048; |
964 | mmc->max_blk_count = 65535; | ||
964 | 965 | ||
965 | host = mmc_priv(mmc); | 966 | host = mmc_priv(mmc); |
966 | host->mmc = mmc; | 967 | host->mmc = mmc; |
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 9bda3fddad17..fb04bdd26c36 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c | |||
@@ -109,6 +109,9 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | |||
109 | mrq->cmd->mrq = mrq; | 109 | mrq->cmd->mrq = mrq; |
110 | if (mrq->data) { | 110 | if (mrq->data) { |
111 | BUG_ON(mrq->data->blksz > host->max_blk_size); | 111 | BUG_ON(mrq->data->blksz > host->max_blk_size); |
112 | BUG_ON(mrq->data->blocks > host->max_blk_count); | ||
113 | BUG_ON(mrq->data->blocks * mrq->data->blksz > | ||
114 | host->max_req_size); | ||
112 | 115 | ||
113 | mrq->cmd->data = mrq->data; | 116 | mrq->cmd->data = mrq->data; |
114 | mrq->data->error = 0; | 117 | mrq->data->error = 0; |
@@ -1605,10 +1608,11 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) | |||
1605 | */ | 1608 | */ |
1606 | host->max_hw_segs = 1; | 1609 | host->max_hw_segs = 1; |
1607 | host->max_phys_segs = 1; | 1610 | host->max_phys_segs = 1; |
1608 | host->max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); | ||
1609 | host->max_seg_size = PAGE_CACHE_SIZE; | 1611 | host->max_seg_size = PAGE_CACHE_SIZE; |
1610 | 1612 | ||
1613 | host->max_req_size = PAGE_CACHE_SIZE; | ||
1611 | host->max_blk_size = 512; | 1614 | host->max_blk_size = 512; |
1615 | host->max_blk_count = PAGE_CACHE_SIZE / 512; | ||
1612 | } | 1616 | } |
1613 | 1617 | ||
1614 | return host; | 1618 | return host; |
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index 5a4eacac0bbe..19ccfed8a54f 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c | |||
@@ -242,10 +242,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
242 | brq.cmd.arg <<= 9; | 242 | brq.cmd.arg <<= 9; |
243 | brq.cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; | 243 | brq.cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; |
244 | brq.data.blksz = 1 << md->block_bits; | 244 | brq.data.blksz = 1 << md->block_bits; |
245 | brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); | ||
246 | brq.stop.opcode = MMC_STOP_TRANSMISSION; | 245 | brq.stop.opcode = MMC_STOP_TRANSMISSION; |
247 | brq.stop.arg = 0; | 246 | brq.stop.arg = 0; |
248 | brq.stop.flags = MMC_RSP_R1B | MMC_CMD_AC; | 247 | brq.stop.flags = MMC_RSP_R1B | MMC_CMD_AC; |
248 | brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); | ||
249 | if (brq.data.blocks > card->host->max_blk_count) | ||
250 | brq.data.blocks = card->host->max_blk_count; | ||
249 | 251 | ||
250 | mmc_set_data_timeout(&brq.data, card, rq_data_dir(req) != READ); | 252 | mmc_set_data_timeout(&brq.data, card, rq_data_dir(req) != READ); |
251 | 253 | ||
diff --git a/drivers/mmc/mmc_queue.c b/drivers/mmc/mmc_queue.c index 3e35a43819fb..c27e42645cdb 100644 --- a/drivers/mmc/mmc_queue.c +++ b/drivers/mmc/mmc_queue.c | |||
@@ -147,7 +147,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock | |||
147 | 147 | ||
148 | blk_queue_prep_rq(mq->queue, mmc_prep_request); | 148 | blk_queue_prep_rq(mq->queue, mmc_prep_request); |
149 | blk_queue_bounce_limit(mq->queue, limit); | 149 | blk_queue_bounce_limit(mq->queue, limit); |
150 | blk_queue_max_sectors(mq->queue, host->max_sectors); | 150 | blk_queue_max_sectors(mq->queue, host->max_req_size / 512); |
151 | blk_queue_max_phys_segments(mq->queue, host->max_phys_segs); | 151 | blk_queue_max_phys_segments(mq->queue, host->max_phys_segs); |
152 | blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); | 152 | blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); |
153 | blk_queue_max_segment_size(mq->queue, host->max_seg_size); | 153 | blk_queue_max_segment_size(mq->queue, host->max_seg_size); |
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 5d48e0081894..5941dd951e82 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c | |||
@@ -524,21 +524,25 @@ static int mmci_probe(struct amba_device *dev, void *id) | |||
524 | /* | 524 | /* |
525 | * Since we only have a 16-bit data length register, we must | 525 | * Since we only have a 16-bit data length register, we must |
526 | * ensure that we don't exceed 2^16-1 bytes in a single request. | 526 | * ensure that we don't exceed 2^16-1 bytes in a single request. |
527 | * Choose 64 (512-byte) sectors as the limit. | ||
528 | */ | 527 | */ |
529 | mmc->max_sectors = 64; | 528 | mmc->max_req_size = 65535; |
530 | 529 | ||
531 | /* | 530 | /* |
532 | * Set the maximum segment size. Since we aren't doing DMA | 531 | * Set the maximum segment size. Since we aren't doing DMA |
533 | * (yet) we are only limited by the data length register. | 532 | * (yet) we are only limited by the data length register. |
534 | */ | 533 | */ |
535 | mmc->max_seg_size = mmc->max_sectors << 9; | 534 | mmc->max_seg_size = mmc->max_req_size; |
536 | 535 | ||
537 | /* | 536 | /* |
538 | * Block size can be up to 2048 bytes, but must be a power of two. | 537 | * Block size can be up to 2048 bytes, but must be a power of two. |
539 | */ | 538 | */ |
540 | mmc->max_blk_size = 2048; | 539 | mmc->max_blk_size = 2048; |
541 | 540 | ||
541 | /* | ||
542 | * No limit on the number of blocks transferred. | ||
543 | */ | ||
544 | mmc->max_blk_count = mmc->max_req_size; | ||
545 | |||
542 | spin_lock_init(&host->lock); | 546 | spin_lock_init(&host->lock); |
543 | 547 | ||
544 | writel(0, host->base + MMCIMASK0); | 548 | writel(0, host->base + MMCIMASK0); |
diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c index fa69a0dc5969..1e96a2f65022 100644 --- a/drivers/mmc/omap.c +++ b/drivers/mmc/omap.c | |||
@@ -1100,8 +1100,9 @@ static int __init mmc_omap_probe(struct platform_device *pdev) | |||
1100 | mmc->max_phys_segs = 32; | 1100 | mmc->max_phys_segs = 32; |
1101 | mmc->max_hw_segs = 32; | 1101 | mmc->max_hw_segs = 32; |
1102 | mmc->max_blk_size = 2048; /* BLEN is 11 bits (+1) */ | 1102 | mmc->max_blk_size = 2048; /* BLEN is 11 bits (+1) */ |
1103 | mmc->max_sectors = 256; /* NBLK max 11-bits, OMAP also limited by DMA */ | 1103 | mmc->max_blk_count = 2048; /* NBLK is 11 bits (+1) */ |
1104 | mmc->max_seg_size = mmc->max_sectors * 512; | 1104 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; |
1105 | mmc->max_seg_size = mmc->max_req_size; | ||
1105 | 1106 | ||
1106 | if (host->power_pin >= 0) { | 1107 | if (host->power_pin >= 0) { |
1107 | if ((ret = omap_request_gpio(host->power_pin)) != 0) { | 1108 | if ((ret = omap_request_gpio(host->power_pin)) != 0) { |
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index 9fc9aed1a5ef..9774fc68b61a 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c | |||
@@ -455,6 +455,11 @@ static int pxamci_probe(struct platform_device *pdev) | |||
455 | */ | 455 | */ |
456 | mmc->max_blk_size = 1023; | 456 | mmc->max_blk_size = 1023; |
457 | 457 | ||
458 | /* | ||
459 | * Block count register is 16 bits. | ||
460 | */ | ||
461 | mmc->max_blk_count = 65535; | ||
462 | |||
458 | host = mmc_priv(mmc); | 463 | host = mmc_priv(mmc); |
459 | host->mmc = mmc; | 464 | host->mmc = mmc; |
460 | host->dma = -1; | 465 | host->dma = -1; |
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 155aafe69bf4..99f1db92295b 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c | |||
@@ -1333,15 +1333,15 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) | |||
1333 | 1333 | ||
1334 | /* | 1334 | /* |
1335 | * Maximum number of sectors in one transfer. Limited by DMA boundary | 1335 | * Maximum number of sectors in one transfer. Limited by DMA boundary |
1336 | * size (512KiB), which means (512 KiB/512=) 1024 entries. | 1336 | * size (512KiB). |
1337 | */ | 1337 | */ |
1338 | mmc->max_sectors = 1024; | 1338 | mmc->max_req_size = 524288; |
1339 | 1339 | ||
1340 | /* | 1340 | /* |
1341 | * Maximum segment size. Could be one segment with the maximum number | 1341 | * Maximum segment size. Could be one segment with the maximum number |
1342 | * of sectors. | 1342 | * of bytes. |
1343 | */ | 1343 | */ |
1344 | mmc->max_seg_size = mmc->max_sectors * 512; | 1344 | mmc->max_seg_size = mmc->max_req_size; |
1345 | 1345 | ||
1346 | /* | 1346 | /* |
1347 | * Maximum block size. This varies from controller to controller and | 1347 | * Maximum block size. This varies from controller to controller and |
@@ -1357,6 +1357,11 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) | |||
1357 | mmc->max_blk_size = 512 << mmc->max_blk_size; | 1357 | mmc->max_blk_size = 512 << mmc->max_blk_size; |
1358 | 1358 | ||
1359 | /* | 1359 | /* |
1360 | * Maximum block count. | ||
1361 | */ | ||
1362 | mmc->max_blk_count = 65535; | ||
1363 | |||
1364 | /* | ||
1360 | * Init tasklets. | 1365 | * Init tasklets. |
1361 | */ | 1366 | */ |
1362 | tasklet_init(&host->card_tasklet, | 1367 | tasklet_init(&host->card_tasklet, |
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c index bdfad15371b8..7e607b75f4bc 100644 --- a/drivers/mmc/tifm_sd.c +++ b/drivers/mmc/tifm_sd.c | |||
@@ -885,10 +885,13 @@ static int tifm_sd_probe(struct tifm_dev *sock) | |||
885 | mmc->f_max = 24000000; | 885 | mmc->f_max = 24000000; |
886 | mmc->max_hw_segs = 1; | 886 | mmc->max_hw_segs = 1; |
887 | mmc->max_phys_segs = 1; | 887 | mmc->max_phys_segs = 1; |
888 | mmc->max_sectors = 127; | 888 | // limited by DMA counter - it's safer to stick with |
889 | //2k maximum hw block length | 889 | // block counter has 11 bits though |
890 | mmc->max_seg_size = mmc->max_sectors << 11; | 890 | mmc->max_blk_count = 256; |
891 | // 2k maximum hw block length | ||
891 | mmc->max_blk_size = 2048; | 892 | mmc->max_blk_size = 2048; |
893 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | ||
894 | mmc->max_seg_size = mmc->max_req_size; | ||
892 | sock->signal_irq = tifm_sd_signal_irq; | 895 | sock->signal_irq = tifm_sd_signal_irq; |
893 | rc = tifm_sd_initialize_host(host); | 896 | rc = tifm_sd_initialize_host(host); |
894 | 897 | ||
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 5711beecb4e8..cf16e44c0301 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c | |||
@@ -1343,16 +1343,15 @@ static int __devinit wbsd_alloc_mmc(struct device *dev) | |||
1343 | mmc->max_phys_segs = 128; | 1343 | mmc->max_phys_segs = 128; |
1344 | 1344 | ||
1345 | /* | 1345 | /* |
1346 | * Maximum number of sectors in one transfer. Also limited by 64kB | 1346 | * Maximum request size. Also limited by 64KiB buffer. |
1347 | * buffer. | ||
1348 | */ | 1347 | */ |
1349 | mmc->max_sectors = 128; | 1348 | mmc->max_req_size = 65536; |
1350 | 1349 | ||
1351 | /* | 1350 | /* |
1352 | * Maximum segment size. Could be one segment with the maximum number | 1351 | * Maximum segment size. Could be one segment with the maximum number |
1353 | * of segments. | 1352 | * of bytes. |
1354 | */ | 1353 | */ |
1355 | mmc->max_seg_size = mmc->max_sectors * 512; | 1354 | mmc->max_seg_size = mmc->max_req_size; |
1356 | 1355 | ||
1357 | /* | 1356 | /* |
1358 | * Maximum block size. We have 12 bits (= 4095) but have to subtract | 1357 | * Maximum block size. We have 12 bits (= 4095) but have to subtract |
@@ -1360,6 +1359,12 @@ static int __devinit wbsd_alloc_mmc(struct device *dev) | |||
1360 | */ | 1359 | */ |
1361 | mmc->max_blk_size = 4087; | 1360 | mmc->max_blk_size = 4087; |
1362 | 1361 | ||
1362 | /* | ||
1363 | * Maximum block count. There is no real limit so the maximum | ||
1364 | * request size will be the only restriction. | ||
1365 | */ | ||
1366 | mmc->max_blk_count = mmc->max_req_size; | ||
1367 | |||
1363 | dev_set_drvdata(dev, mmc); | 1368 | dev_set_drvdata(dev, mmc); |
1364 | 1369 | ||
1365 | return 0; | 1370 | return 0; |