Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55db890a authored by Pierre Ossman's avatar Pierre Ossman
Browse files

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: default avatarPierre Ossman <drzeus@drzeus.cx>
parent fe4a3c7a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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;

+2 −1
Original line number Diff line number Diff line
@@ -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;
+5 −1
Original line number Diff line number Diff line
@@ -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;
+3 −1
Original line number Diff line number Diff line
@@ -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);

Loading