diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c index e28850dec9ed767f6192a5bf683dbc79b98cdee5..2ce50f38e3c7d21c54d22b2be788bd6f4fc0acbd 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) mmc->caps = MMC_CAP_BYTEBLOCK; mmc->max_blk_size = 4095; + mmc->max_blk_count = mmc->max_req_size; host = mmc_priv(mmc); host->mmc = mmc; diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c index 74e6ac0c7f71079933ce972e5f75f0f7e5b17afd..b834be261ab7ea163eaed79f592ad180458c0d62 100644 --- a/drivers/mmc/au1xmmc.c +++ b/drivers/mmc/au1xmmc.c @@ -923,6 +923,7 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev) mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT; mmc->max_blk_size = 2048; + mmc->max_blk_count = 512; mmc->ocr_avail = AU1XMMC_OCR; diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c index 2107f8a8605e8f25f2e1a46f6980a9a653aa57c5..b060d4bfba29b731a37653c79d361be5b82b3c83 100644 --- a/drivers/mmc/imxmmc.c +++ b/drivers/mmc/imxmmc.c @@ -958,9 +958,10 @@ static int imxmci_probe(struct platform_device *pdev) /* MMC core transfer sizes tunable parameters */ mmc->max_hw_segs = 64; mmc->max_phys_segs = 64; - mmc->max_sectors = 64; /* default 1 << (PAGE_CACHE_SHIFT - 9) */ mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */ + mmc->max_req_size = 64*512; /* default PAGE_CACHE_SIZE */ mmc->max_blk_size = 2048; + mmc->max_blk_count = 65535; host = mmc_priv(mmc); host->mmc = mmc; diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 9bda3fddad17380771903a39e30da3d371520ce8..fb04bdd26c36f9b5a536ce381376649fb0807267 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) mrq->cmd->mrq = mrq; if (mrq->data) { BUG_ON(mrq->data->blksz > host->max_blk_size); + BUG_ON(mrq->data->blocks > host->max_blk_count); + BUG_ON(mrq->data->blocks * mrq->data->blksz > + host->max_req_size); mrq->cmd->data = mrq->data; mrq->data->error = 0; @@ -1605,10 +1608,11 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) */ host->max_hw_segs = 1; host->max_phys_segs = 1; - host->max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); host->max_seg_size = PAGE_CACHE_SIZE; + host->max_req_size = PAGE_CACHE_SIZE; host->max_blk_size = 512; + host->max_blk_count = PAGE_CACHE_SIZE / 512; } return host; diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index 5a4eacac0bbe89a4f6b9a26d81ac92f25dfb108a..19ccfed8a54f8b36178f3400c9a294bf15666f49 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) brq.cmd.arg <<= 9; brq.cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; brq.data.blksz = 1 << md->block_bits; - brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); brq.stop.opcode = MMC_STOP_TRANSMISSION; brq.stop.arg = 0; brq.stop.flags = MMC_RSP_R1B | MMC_CMD_AC; + brq.data.blocks = req->nr_sectors >> (md->block_bits - 9); + if (brq.data.blocks > card->host->max_blk_count) + brq.data.blocks = card->host->max_blk_count; mmc_set_data_timeout(&brq.data, card, rq_data_dir(req) != READ); diff --git a/drivers/mmc/mmc_queue.c b/drivers/mmc/mmc_queue.c index 3e35a43819fba1a75c00d7cdac55265cda17f9f8..c27e42645cdb240933456fb872e1510eeb7bc5d5 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 blk_queue_prep_rq(mq->queue, mmc_prep_request); blk_queue_bounce_limit(mq->queue, limit); - blk_queue_max_sectors(mq->queue, host->max_sectors); + blk_queue_max_sectors(mq->queue, host->max_req_size / 512); blk_queue_max_phys_segments(mq->queue, host->max_phys_segs); blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); blk_queue_max_segment_size(mq->queue, host->max_seg_size); diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 5d48e0081894ffff34ddb3c7a87a4c19dd6e9951..5941dd951e824bfc8a1ef9a0290590fbc8e0cefe 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) /* * Since we only have a 16-bit data length register, we must * ensure that we don't exceed 2^16-1 bytes in a single request. - * Choose 64 (512-byte) sectors as the limit. */ - mmc->max_sectors = 64; + mmc->max_req_size = 65535; /* * Set the maximum segment size. Since we aren't doing DMA * (yet) we are only limited by the data length register. */ - mmc->max_seg_size = mmc->max_sectors << 9; + mmc->max_seg_size = mmc->max_req_size; /* * Block size can be up to 2048 bytes, but must be a power of two. */ mmc->max_blk_size = 2048; + /* + * No limit on the number of blocks transferred. + */ + mmc->max_blk_count = mmc->max_req_size; + spin_lock_init(&host->lock); writel(0, host->base + MMCIMASK0); diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c index fa69a0dc5969049b4e758b075b8017177a80d92d..1e96a2f65022eee03e234b14bae7e92fb0c30c02 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) mmc->max_phys_segs = 32; mmc->max_hw_segs = 32; mmc->max_blk_size = 2048; /* BLEN is 11 bits (+1) */ - mmc->max_sectors = 256; /* NBLK max 11-bits, OMAP also limited by DMA */ - mmc->max_seg_size = mmc->max_sectors * 512; + mmc->max_blk_count = 2048; /* NBLK is 11 bits (+1) */ + mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; + mmc->max_seg_size = mmc->max_req_size; if (host->power_pin >= 0) { if ((ret = omap_request_gpio(host->power_pin)) != 0) { diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index 9fc9aed1a5efb2f4518d37dffb11066c0776ca53..9774fc68b61a0c56cae19d96276aab5bd18e56cc 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c @@ -455,6 +455,11 @@ static int pxamci_probe(struct platform_device *pdev) */ mmc->max_blk_size = 1023; + /* + * Block count register is 16 bits. + */ + mmc->max_blk_count = 65535; + host = mmc_priv(mmc); host->mmc = mmc; host->dma = -1; diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 155aafe69bf4e094d7e6eada413b22b9d70ef213..99f1db92295bd7005bca1017a965a868d7afb7f0 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) /* * Maximum number of sectors in one transfer. Limited by DMA boundary - * size (512KiB), which means (512 KiB/512=) 1024 entries. + * size (512KiB). */ - mmc->max_sectors = 1024; + mmc->max_req_size = 524288; /* * Maximum segment size. Could be one segment with the maximum number - * of sectors. + * of bytes. */ - mmc->max_seg_size = mmc->max_sectors * 512; + mmc->max_seg_size = mmc->max_req_size; /* * Maximum block size. This varies from controller to controller and @@ -1356,6 +1356,11 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot) } mmc->max_blk_size = 512 << mmc->max_blk_size; + /* + * Maximum block count. + */ + mmc->max_blk_count = 65535; + /* * Init tasklets. */ diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c index bdfad15371b89b575367cee84602a0ea019b6491..7e607b75f4bc7ffdd862acefaee44c157ad7aac3 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) mmc->f_max = 24000000; mmc->max_hw_segs = 1; mmc->max_phys_segs = 1; - mmc->max_sectors = 127; - //2k maximum hw block length - mmc->max_seg_size = mmc->max_sectors << 11; + // limited by DMA counter - it's safer to stick with + // block counter has 11 bits though + mmc->max_blk_count = 256; + // 2k maximum hw block length mmc->max_blk_size = 2048; + mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; + mmc->max_seg_size = mmc->max_req_size; sock->signal_irq = tifm_sd_signal_irq; rc = tifm_sd_initialize_host(host); diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 5711beecb4e8cdb193a68b2fdfc1247c5c86c09d..cf16e44c030198c05b1d4f0e9766d1b99ac1b1bf 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c @@ -1343,16 +1343,15 @@ static int __devinit wbsd_alloc_mmc(struct device *dev) mmc->max_phys_segs = 128; /* - * Maximum number of sectors in one transfer. Also limited by 64kB - * buffer. + * Maximum request size. Also limited by 64KiB buffer. */ - mmc->max_sectors = 128; + mmc->max_req_size = 65536; /* * Maximum segment size. Could be one segment with the maximum number - * of segments. + * of bytes. */ - mmc->max_seg_size = mmc->max_sectors * 512; + mmc->max_seg_size = mmc->max_req_size; /* * 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) */ mmc->max_blk_size = 4087; + /* + * Maximum block count. There is no real limit so the maximum + * request size will be the only restriction. + */ + mmc->max_blk_count = mmc->max_req_size; + dev_set_drvdata(dev, mmc); return 0; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 2da0c918a8ccd38aa05a7fd36bb013b5578938dd..913e5752569f1c70f7c3cb6315af0d3514a22c92 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -92,9 +92,10 @@ struct mmc_host { unsigned int max_seg_size; /* see blk_queue_max_segment_size */ unsigned short max_hw_segs; /* see blk_queue_max_hw_segments */ unsigned short max_phys_segs; /* see blk_queue_max_phys_segments */ - unsigned short max_sectors; /* see blk_queue_max_sectors */ unsigned short unused; + unsigned int max_req_size; /* maximum number of bytes in one req */ unsigned int max_blk_size; /* maximum size of one mmc block */ + unsigned int max_blk_count; /* maximum number of blocks in one req */ /* private data */ struct mmc_ios ios; /* current io bus settings */