Re: [PATCH] Forcing SCSI capacity for broken SD Card readers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 16 Dec 2009, Grant Grundler wrote:

> +linux-usb
> 
> On Wed, Dec 16, 2009 at 8:51 AM, Clemens Fruhwirth
> <clemens@xxxxxxxxxxxxx> wrote:
> > On Thu, Oct 15, 2009 at 1:29 AM, Grant Grundler <grundler@xxxxxxxxxx> wrote:
> >> On Wed, Oct 14, 2009 at 2:13 PM, Clemens Fruhwirth
> >> <clemens@xxxxxxxxxxxxx> wrote:
> >>> Short: Attached is an incomplete patch that allows user space to force
> >>> the capacity of an scsi device to a specific value. Any not over
> >>> my-dead-body objections with that?
> >>
> >> No major objection - just the usual nits:
> >> Why not make /sys/block/sdX/size writeable?
> >>    (instead of adding an ioctl())
> >
> > Oh, I like that. Sorry it took me so long to reply. It turned out that
> > this is a much better idea. The value that is printed when reading the
> > size attribute is to the value that I set in my patch indirectly
> > through set_capacity. So, making size writable replaces that totally.
> >
> > Patch attached.

Isn't just changing a block device's size at random times a bad thing 
to do?  The size gets used a for a bunch of different things (checking 
partition boundaries, validating I/O block ranges, and so on).

> >> After reading the wiki page[1], my impression is that the block size
> >> gets reported wrong and thus the total capacity is miscalculated for
> >> 1GB-4GB SD cards with 1024 or 2048 byte blocks. Two questions around this:
> >> a) Does the host need to know the correct block size for correct operation?
> >
> > From experiments it does not look like that's the case. This is
> > surprising though, as one would suspect the card not to  function
> > properly otherwise. Frankly speaking, I have not looked down the
> > calling chain, especially how usb-storage treats these blocks, but I'd
> > say not at all. Seems like the USB reader, I have, just doesn't get
> > the capacity right, by not considering BLOCK_LEN > 512.

A lot of older card readers can't handle cards larger than 1 or 2 GB (I 
forget which).  Or they see that the card has a larger block size and 
then don't report it to the host.

> >> b) Do the devices report which SD Card Association spec they are compliant
> >>   with in the USB headers?

No.  Cards don't report anything but block data; only the reader
provides meta-information.  And it doesn't necessarily know anything
about the card -- in fact, the card might not even be inserted when the
reader is queried.

> > Autofixing this doesn't seem possible to me (except for the partition
> > trick) as the capacity = BLOCK_LEN * BLOCKS. If BLOCK_LEN isn't
> > detected correctly, we can't distinguish a 1GB from 2GB card.
> 
> Agreed. That's why I'm thinking getting BLOCK_LEN right is more important
> than hacking the resulting partition size. I'd be surprised if this conversation
> hasn't already occurred on linux-usb mailing list.

It has.  Even if you managed to fix the block size, there's a good 
chance the reader wouldn't work with large cards.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux