]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
mmc: Allow host drivers to specify a max block size
authorPierre Ossman <drzeus@drzeus.cx>
Tue, 21 Nov 2006 16:54:23 +0000 (17:54 +0100)
committerPierre Ossman <drzeus@drzeus.cx>
Sun, 4 Feb 2007 19:54:10 +0000 (20:54 +0100)
Most controllers have an upper limit on the block size. Allow the host
drivers to specify this and make sure we avoid hitting this limit.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
12 files changed:
drivers/mmc/at91_mci.c
drivers/mmc/au1xmmc.c
drivers/mmc/imxmmc.c
drivers/mmc/mmc.c
drivers/mmc/mmci.c
drivers/mmc/omap.c
drivers/mmc/pxamci.c
drivers/mmc/sdhci.c
drivers/mmc/sdhci.h
drivers/mmc/tifm_sd.c
drivers/mmc/wbsd.c
include/linux/mmc/host.h

index aa152f31851eb4efd8659250219558837e829759..e28850dec9ed767f6192a5bf683dbc79b98cdee5 100644 (file)
@@ -823,6 +823,8 @@ static int __init at91_mci_probe(struct platform_device *pdev)
        mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
        mmc->caps = MMC_CAP_BYTEBLOCK;
 
+       mmc->max_blk_size = 4095;
+
        host = mmc_priv(mmc);
        host->mmc = mmc;
        host->buffer = NULL;
index 6d6fe6e6d4151fb0e111a87865ecb5e8ebefe53e..74e6ac0c7f71079933ce972e5f75f0f7e5b17afd 100644 (file)
@@ -922,6 +922,8 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev)
                mmc->max_seg_size = AU1XMMC_DESCRIPTOR_SIZE;
                mmc->max_phys_segs = AU1XMMC_DESCRIPTOR_COUNT;
 
+               mmc->max_blk_size = 2048;
+
                mmc->ocr_avail = AU1XMMC_OCR;
 
                host = mmc_priv(mmc);
index bfb9ff693208fa51c81667622a699cd5748916c0..2107f8a8605e8f25f2e1a46f6980a9a653aa57c5 100644 (file)
@@ -960,6 +960,7 @@ static int imxmci_probe(struct platform_device *pdev)
        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_blk_size = 2048;
 
        host = mmc_priv(mmc);
        host->mmc = mmc;
index b48c277312de95791530be2ee99e792f9aacd9cf..9bda3fddad17380771903a39e30da3d371520ce8 100644 (file)
@@ -108,6 +108,8 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
        mrq->cmd->error = 0;
        mrq->cmd->mrq = mrq;
        if (mrq->data) {
+               BUG_ON(mrq->data->blksz > host->max_blk_size);
+
                mrq->cmd->data = mrq->data;
                mrq->data->error = 0;
                mrq->data->mrq = mrq;
@@ -1605,6 +1607,8 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
                host->max_phys_segs = 1;
                host->max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
                host->max_seg_size = PAGE_CACHE_SIZE;
+
+               host->max_blk_size = 512;
        }
 
        return host;
index ccfe6561be240ec65dadbbab2ea56ce0166cd001..5d48e0081894ffff34ddb3c7a87a4c19dd6e9951 100644 (file)
@@ -534,6 +534,11 @@ static int mmci_probe(struct amba_device *dev, void *id)
         */
        mmc->max_seg_size = mmc->max_sectors << 9;
 
+       /*
+        * Block size can be up to 2048 bytes, but must be a power of two.
+        */
+       mmc->max_blk_size = 2048;
+
        spin_lock_init(&host->lock);
 
        writel(0, host->base + MMCIMASK0);
index d30540b2761420cff6bf445f761b8d0b27b34b40..fa69a0dc5969049b4e758b075b8017177a80d92d 100644 (file)
@@ -1099,6 +1099,7 @@ 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;
 
index 6073d998b11f3ee1164d3209be639a21ba640be3..9fc9aed1a5efb2f4518d37dffb11066c0776ca53 100644 (file)
@@ -450,6 +450,11 @@ static int pxamci_probe(struct platform_device *pdev)
         */
        mmc->max_seg_size = PAGE_SIZE;
 
+       /*
+        * Block length register is 10 bits.
+        */
+       mmc->max_blk_size = 1023;
+
        host = mmc_priv(mmc);
        host->mmc = mmc;
        host->dma = -1;
index 175a9427b9bac0d6384bcb60eec348b851608821..155aafe69bf4e094d7e6eada413b22b9d70ef213 100644 (file)
@@ -381,7 +381,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
 
        /* Sanity checks */
        BUG_ON(data->blksz * data->blocks > 524288);
-       BUG_ON(data->blksz > host->max_block);
+       BUG_ON(data->blksz > host->mmc->max_blk_size);
        BUG_ON(data->blocks > 65535);
 
        /* timeout in us */
@@ -1290,15 +1290,6 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
        if (caps & SDHCI_TIMEOUT_CLK_UNIT)
                host->timeout_clk *= 1000;
 
-       host->max_block = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
-       if (host->max_block >= 3) {
-               printk(KERN_ERR "%s: Invalid maximum block size.\n",
-                       host->slot_descr);
-               ret = -ENODEV;
-               goto unmap;
-       }
-       host->max_block = 512 << host->max_block;
-
        /*
         * Set host parameters.
         */
@@ -1352,6 +1343,19 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
         */
        mmc->max_seg_size = mmc->max_sectors * 512;
 
+       /*
+        * Maximum block size. This varies from controller to controller and
+        * is specified in the capabilities register.
+        */
+       mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
+       if (mmc->max_blk_size >= 3) {
+               printk(KERN_ERR "%s: Invalid maximum block size.\n",
+                       host->slot_descr);
+               ret = -ENODEV;
+               goto unmap;
+       }
+       mmc->max_blk_size = 512 << mmc->max_blk_size;
+
        /*
         * Init tasklets.
         */
index f9d1a0a6f03a97fae3e0b1ebd7a129999877c42a..bc6bf7e7757de46109675a913a2cc0684538fc84 100644 (file)
@@ -174,7 +174,6 @@ struct sdhci_host {
 
        unsigned int            max_clk;        /* Max possible freq (MHz) */
        unsigned int            timeout_clk;    /* Timeout freq (KHz) */
-       unsigned int            max_block;      /* Max block size (bytes) */
 
        unsigned int            clock;          /* Current clock (MHz) */
        unsigned short          power;          /* Current voltage */
index ce19b045ca6a4d7f8c7e601176729588eaa8712e..bdfad15371b89b575367cee84602a0ea019b6491 100644 (file)
@@ -886,7 +886,9 @@ static int tifm_sd_probe(struct tifm_dev *sock)
        mmc->max_hw_segs = 1;
        mmc->max_phys_segs = 1;
        mmc->max_sectors = 127;
-       mmc->max_seg_size = mmc->max_sectors << 11; //2k maximum hw block length
+       //2k maximum hw block length
+       mmc->max_seg_size = mmc->max_sectors << 11;
+       mmc->max_blk_size = 2048;
        sock->signal_irq = tifm_sd_signal_irq;
        rc = tifm_sd_initialize_host(host);
 
index 7a282672f8e9037d9995859e9fbdb31504ecbf94..5711beecb4e8cdb193a68b2fdfc1247c5c86c09d 100644 (file)
@@ -1354,6 +1354,12 @@ static int __devinit wbsd_alloc_mmc(struct device *dev)
         */
        mmc->max_seg_size = mmc->max_sectors * 512;
 
+       /*
+        * Maximum block size. We have 12 bits (= 4095) but have to subtract
+        * space for CRC. So the maximum is 4095 - 4*2 = 4087.
+        */
+       mmc->max_blk_size = 4087;
+
        dev_set_drvdata(dev, mmc);
 
        return 0;
index ae98d6766bdd1ca4f309682130dfafd2bf058cbe..2da0c918a8ccd38aa05a7fd36bb013b5578938dd 100644 (file)
@@ -94,6 +94,7 @@ struct mmc_host {
        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_blk_size;   /* maximum size of one mmc block */
 
        /* private data */
        struct mmc_ios          ios;            /* current io bus settings */