Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 142172 - gentoo-sources: Please add patch to mmc_block.c to support SD Card >1GB
Summary: gentoo-sources: Please add patch to mmc_block.c to support SD Card >1GB
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High enhancement
Assignee: Daniel Drake (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-30 05:12 UTC by Jan Schubert
Modified: 2006-09-17 11:23 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Schubert 2006-07-30 05:12:15 UTC
To support SD Cards (or any other smart cards) bigger than 1GB there is a need to patch drivers/mmc/mmc_block.c, see also http://marc.theaimsgroup.com/?l=linux-kernel&m=114980773206129&w=2. The trikc is to set the block size staticaly to 512 Byte (9 Bit) instead of reading it from the card itself which results in my case in an error like "unable to set block size to 1024".

Works fine for me and is included in other distros as well (seen in a forum, don't remember which one, I had to reboot my box to test the patch :-):

--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -325,52 +325,11 @@ static struct mmc_blk_data *mmc_blk_allo
 	md->read_only = mmc_blk_readonly(card);
 
 	/*
-	 * Figure out a workable block size.  MMC cards have:
-	 *  - two block sizes, one for read and one for write.
-	 *  - may support partial reads and/or writes
-	 *    (allows block sizes smaller than specified)
+	 * Both SD and MMC specifications state (although a bit
+	 * unclearly in the MMC case) that a block size of 512
+	 * bytes must always be supported by the card.
 	 */
-	md->block_bits = card->csd.read_blkbits;
-	if (card->csd.write_blkbits != card->csd.read_blkbits) {
-		if (card->csd.write_blkbits < card->csd.read_blkbits &&
-		    card->csd.read_partial) {
-			/*
-			 * write block size is smaller than read block
-			 * size, but we support partial reads, so choose
-			 * the smaller write block size.
-			 */
-			md->block_bits = card->csd.write_blkbits;
-		} else if (card->csd.write_blkbits > card->csd.read_blkbits &&
-			   card->csd.write_partial) {
-			/*
-			 * read block size is smaller than write block
-			 * size, but we support partial writes.  Use read
-			 * block size.
-			 */
-		} else {
-			/*
-			 * We don't support this configuration for writes.
-			 */
-			printk(KERN_ERR "%s: unable to select block size for "
-				"writing (rb%u wb%u rp%u wp%u)\n",
-				mmc_card_id(card),
-				1 << card->csd.read_blkbits,
-				1 << card->csd.write_blkbits,
-				card->csd.read_partial,
-				card->csd.write_partial);
-			md->read_only = 1;
-		}
-	}
-
-	/*
-	 * Refuse to allow block sizes smaller than 512 bytes.
-	 */
-	if (md->block_bits < 9) {
-		printk(KERN_ERR "%s: unable to support block size %u\n",
-			mmc_card_id(card), 1 << md->block_bits);
-		ret = -EINVAL;
-		goto err_kfree;
-	}
+	md->block_bits = 9;
 
 	md->disk = alloc_disk(1 << MMC_SHIFT);
 	if (md->disk == NULL) {
Comment 1 Jan Schubert 2006-08-21 13:49:41 UTC
still valid for gentoo-sources-2.6.17-r5 :-(
Comment 2 Daniel Drake (RETIRED) gentoo-dev 2006-08-21 14:03:32 UTC
Indeed, see my reply on the thread you linked to:

http://marc.theaimsgroup.com/?l=linux-kernel&m=115546362627753&w=2

Perhaps you could email Pierre with the success report as a gentle reminder about this patch :)
Comment 3 Daniel Drake (RETIRED) gentoo-dev 2006-09-09 06:57:41 UTC
This is merged into a subsystem tree
Comment 4 Daniel Drake (RETIRED) gentoo-dev 2006-09-09 19:37:30 UTC
Fixed in gentoo-sources-2.6.17-r8 (genpatches-2.6.17-10). Thanks for the patch.
Comment 5 Jan Schubert 2006-09-17 11:23:28 UTC
Works fine, thx a lot :-)