Re: [PATCH repost 3] [SCSI] Retrieve the Caching mode page

Luben Tuikov
2010-11-22T20:02:27Z

--- On Mon, 11/22/10, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> > Some kernel transport drivers unconditionally disable
> > retrieval of the Caching mode page. One such for
> example is
> > the BBB/CBI transport over USB.
>
> One reason for that is that historically we've seen devices
> that
> simply go crazy - to the point of simply stopping to
> respond to
> anything - when you ask for pages that Windows doesn't ask
> for.
>
> It's especially common on USB storage, but it happens
> elsewhere too.
> The device firmware simply hasn't ever been tested in that
> situation,
> and it's buggy.
>
> So I don't mind the patch per se, but I think it's
> potentially way
> more dangerous than it looks.

This patch does not ask for pages that Windows doesn't ask for. The sd driver already asks for all pages (page code 0x3F) and then checks if the device is write protected. Here is the present code:

2217 sd_read_write_protect_flag(sdkp, buffer);
2218 sd_read_cache_type(sdkp, buffer);
2219 sd_read_app_tag_own(sdkp, buffer);

Line 2217 asks for page code 0x3F, meaning all mode pages.
Line 2218 asks for the Caching mode page or not at all if the device flags forbid it (all USB storage devices in the Linux kernel).

This patch adds processing of the data returned when all mode pages are asked for (0x3F) in the function on line 2218. It then parses the data to find out if the Caching mode page is present.

Luben