mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] MMC/SD: SDHC card capacity not correct
@ 2009-01-09  3:53 yi li
       [not found] ` <20090111204852.GA3869@compegg.wr.niftyegg.com>
  2009-01-12 15:20 ` Pierre Ossman
  0 siblings, 2 replies; 5+ messages in thread
From: yi li @ 2009-01-09  3:53 UTC (permalink / raw)
  To: drzeus-mmc; +Cc: linux-kernel

Hi Pierre,

I am using a Transcend SDHC 8GB SD card, with mmc-spi driver in
Linux-2.6.28. When inserting the card, the messages shows the card
capacity is "3.51 GiB":
"mmc0: new SDHC card on SPI
mmcblk0: mmc0:0000 SDC   3.51 GiB
 mmcblk0: p1  "

While fdisk shows correct capacity:
" fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 8068 MB, 8068268032 bytes
249 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 15438 * 512 = 7904256 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1               1        1020     7873349  83 Linux
"
So I think there are something wrong with mmc-block code.

Could you please have a look? (I am not on the LKML btw).

Best Regards,
- Li Yi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] MMC/SD: SDHC card capacity not correct
       [not found] ` <20090111204852.GA3869@compegg.wr.niftyegg.com>
@ 2009-01-12  4:59   ` yi li
  0 siblings, 0 replies; 5+ messages in thread
From: yi li @ 2009-01-12  4:59 UTC (permalink / raw)
  To: Nifty niftylinkern Mitch; +Cc: linux-kernel, drzeus-mmc

On Mon, Jan 12, 2009 at 4:48 AM, Nifty niftylinkern Mitch
<niftylinkern@niftyegg.com> wrote:
>
> Check the partition map.  I see one partition smaller than the SD card.
> Compare /dev/mmcblk0 and /dev/mmcblk0p1.
> If this is the answer post a follow up to the kernel list that it was solved.
>

Thanks for the response, but what do you mean?
There is only one partition in the partition table, i.e.,
/dev/mmcblk0p1, isn't it?

fdisk /dev/mmcblk0

Command (m for help): p

Disk /dev/mmcblk0: 8068 MB, 8068268032 bytes
249 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 15438 * 512 = 7904256 bytes

        Device Boot      Start         End      Blocks  Id System
/dev/mmcblk0p1               1        1020     7873349  83 Linux

Command (m for help): x
Expert command (m for help): p
Disk /dev/mmcblk0: 249 heads, 62 sectors, 1020 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl      Start       Size ID
 1 00   1   1    0 248  62 1019         62   15746698 83
 2 00   0   0    0   0   0    0          0          0 00
 3 00   0   0    0   0   0    0          0          0 00
 4 00   0   0    0   0   0    0          0          0 00

-Yi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] MMC/SD: SDHC card capacity not correct
  2009-01-09  3:53 [BUG] MMC/SD: SDHC card capacity not correct yi li
       [not found] ` <20090111204852.GA3869@compegg.wr.niftyegg.com>
@ 2009-01-12 15:20 ` Pierre Ossman
  2009-01-13  8:00   ` yi li
  1 sibling, 1 reply; 5+ messages in thread
From: Pierre Ossman @ 2009-01-12 15:20 UTC (permalink / raw)
  To: yi li; +Cc: linux-kernel

On Fri, 9 Jan 2009 11:53:52 +0800
"yi li" <liyi.dev@gmail.com> wrote:

> Hi Pierre,
> 
> I am using a Transcend SDHC 8GB SD card, with mmc-spi driver in
> Linux-2.6.28. When inserting the card, the messages shows the card
> capacity is "3.51 GiB":
> "mmc0: new SDHC card on SPI
> mmcblk0: mmc0:0000 SDC   3.51 GiB
>  mmcblk0: p1  "
> 
> While fdisk shows correct capacity:
> " fdisk -l /dev/mmcblk0
> Disk /dev/mmcblk0: 8068 MB, 8068268032 bytes

Odd. Is the entire device accessible? (I.e. is it just a printk
problem?)

Could you give me a dmesg dump with MMC_DEBUG turned on in Kconfig?

Rgds
-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] MMC/SD: SDHC card capacity not correct
  2009-01-12 15:20 ` Pierre Ossman
@ 2009-01-13  8:00   ` yi li
  2009-01-24 17:46     ` Pierre Ossman
  0 siblings, 1 reply; 5+ messages in thread
From: yi li @ 2009-01-13  8:00 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: linux-kernel

On Mon, Jan 12, 2009 at 11:20 PM, Pierre Ossman <drzeus-mmc@drzeus.cx> wrote:
>
> Odd. Is the entire device accessible? (I.e. is it just a printk
> problem?)
>

It is a printk problem.

> Could you give me a dmesg dump with MMC_DEBUG turned on in Kconfig?
>

I did debug on my side (I think it is more easy to reproduce here :-)
).  The issue is in mmc/card/block.c: mmc_block_probe().

"string_get_size(get_capacity(md->disk) << 9, STRING_UNITS_2,
 			cap_str, sizeof(cap_str));
"
get_capacity() returns a type "sector_t" value, since I am working on
a 32-bit processor (Analog Devices BF537),
and I did not enable CONFIG_LBD, "sector_t" is actually a 32-bit
"unsigned long".  So  "get_capacity(md->disk) << 9" loses the MSB.

I can think of two fixes:

1. Set CONFIG_LBD
2. Fix like this:
--- card/block.c	2009-01-13 15:56:05.000000000 +0800
+++ card/block.c.new	2009-01-13 15:53:45.000000000 +0800
@@ -514,7 +514,7 @@ static int mmc_blk_probe(struct mmc_card
 	if (err)
 		goto out;

-	string_get_size(get_capacity(md->disk) << 9, STRING_UNITS_2,
+	string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2,
 			cap_str, sizeof(cap_str));
 	printk(KERN_INFO "%s: %s %s %s %s\n",
 		md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),

I prefer the second fix, what do you think?

Regards,

-Li Yi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [BUG] MMC/SD: SDHC card capacity not correct
  2009-01-13  8:00   ` yi li
@ 2009-01-24 17:46     ` Pierre Ossman
  0 siblings, 0 replies; 5+ messages in thread
From: Pierre Ossman @ 2009-01-24 17:46 UTC (permalink / raw)
  To: yi li; +Cc: linux-kernel

On Tue, 13 Jan 2009 16:00:21 +0800
yi li <liyi.dev@gmail.com> wrote:

> 2. Fix like this:
> --- card/block.c	2009-01-13 15:56:05.000000000 +0800
> +++ card/block.c.new	2009-01-13 15:53:45.000000000 +0800
> @@ -514,7 +514,7 @@ static int mmc_blk_probe(struct mmc_card
>  	if (err)
>  		goto out;
> 
> -	string_get_size(get_capacity(md->disk) << 9, STRING_UNITS_2,
> +	string_get_size((u64)get_capacity(md->disk) << 9, STRING_UNITS_2,
>  			cap_str, sizeof(cap_str));
>  	printk(KERN_INFO "%s: %s %s %s %s\n",
>  		md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
> 
> I prefer the second fix, what do you think?
> 

Agreed. Send me a proper patch with a S-o-b and all that. :)

Rgds
-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-24 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-09  3:53 [BUG] MMC/SD: SDHC card capacity not correct yi li
     [not found] ` <20090111204852.GA3869@compegg.wr.niftyegg.com>
2009-01-12  4:59   ` yi li
2009-01-12 15:20 ` Pierre Ossman
2009-01-13  8:00   ` yi li
2009-01-24 17:46     ` Pierre Ossman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®