History log of /haiku/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp
Revision Date Author Comments
# 6eaaa521 29-Jan-2024 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Cancel queued transfers on the interrupt endpoint in removed().

May help with some KDLs.


# c4c09e7f 01-Jun-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Fix double-lock KDL on device removal.

Fixes #18431.


# 1eb7837d 31-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Ensure we are in a consistent locking state before calling free.

Should fix the KDL in #16745.


# ca40d4ab 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Probe by USB configuration instead of attributes.

In the case of devices where the mass-storage interface is not the
first one, we will miss it unless we were to check all attributes
one at a time in order. Instead of doing that, just fetch the configuration
and enumerate it directly.


# ac0506fd 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Granularize locking.

There is now an "io_lock" which must be held when performing any USB
operations. All ioctls that read basic status, size, icon, etc. information
do not need to acquire it, of course, which should improve userland
lockup occurrences on congested USB disks.


# 20313e56 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Clean up and consolidate mutex/semaphore creation/destruction.


# dd6e7cb9 30-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Use get_attr_uint8 instead of a loop to get class/subclass/protocol.

Suggested by axeld. The original logic was copied from the USB-ECM
driver, which may also be able to be simplified here.


# 197e4b5a 29-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Use DMAResource for bouncing and support physical I/O requests.

A "bypass" mechanism is left in for when DMAResource would just add
overhead for no reason. All other I/O goes through it and is submitted
to the USB stack as physical addresses.

Tested in QEMU, can still boot from USB on all busses.

Fixes #15569.

Change-Id: I26bfd2208de4ebe1a17170a7034316076927663f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6480
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# c88d4461 29-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Move icon data to a separate header.


# b256fa4a 25-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Transition to "new" driver API.

Change-Id: Ia46cb6ddc9f83917a8f797149508d35b770e44f1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6473
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# c098332d 25-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Retry actions after reset_recovery.

This is mostly important for B_GET_MEDIA_STATUS, which actually will
retry actions if the err_act is set appropriately.

Following this change, stalls are now fully recoverable without causing
the file descriptors of the mounted partition to be cleared, and the
system can resume normal operation without a problem.

Fixes part of #15569.
May help with #16745, #18185, #17543, #18421.


# 0a9e5c9e 25-May-2023 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Cancel queued transfers when clearing HALTs.

XHCI, at least, has "sticky" HALT states which must be cleared at
the controller level. Invoking cancel_queued_transfers takes care
of this.

This fixes USB disks spontaneously unmounting whenever stalls occur.
However, trying to read anything from the mounted partition results
in "Bad file descriptor", probably due to media-status error propagation.


# 688acf41 15-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

add physical_block_size field where applicable

only scsi_disk checks the actual value, other drivers take the logical block size.

This change reports the physical block size from the disk rather than the block
size used by IDE/SATA/SCSI commands. On typical modern SATA disks, the SATA
commands will use 512 byte blocks, but the disk will actually read and write
4K blocks internally. This is only of importance for partition alignment for DriveSetup,
and is independant of file systems or partitioning systems. This could also influence
the recommended block size for some file systems.

Change-Id: Id0f2e22659e89fcef64c1f8d04f81cd68995e01f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5667
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# d2e5fc7f 24-Jun-2022 Jérôme Duval <jerome.duval@gmail.com>

usb_disk: add support for drives bigger than 2TB

* tested read/write with a NTFS partition at the end of a 5TB USB hard disk.
* fix #14670

Change-Id: Ic005dfb7ef94b50a2d6fc8099ef5c83ec6b4a730
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5397
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 407f08de 27-Sep-2021 Jérôme Duval <jerome.duval@gmail.com>

usb_disk: fix SMAP violation for B_GET_MEDIA_STATUS ioctl

should fix #17283. To be tested.

Change-Id: If594129a6e16b50c314efa2a7bb1d18e01cdad15
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4505
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# b4d3d516 16-Jan-2021 X512 <danger_mail@list.ru>

usb_disk: use MutexLocker in usb_disk_ioctl()

Change-Id: Ic3994f6267ea24cf776cb067e0d94226132f4c7e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3638
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# fb52ab82 26-Mar-2019 Augustin Cavalier <waddlesplash@gmail.com>

Minor tweaks to fix the build after the last commit.

* firewire and freebsd_network expect the macros come from
sys/param.h, as this is one of the places FreeBSD defines them
* All others are Haiku-native and can use Be-style macros.


# c61fa718 17-Feb-2019 Augustin Cavalier <waddlesplash@gmail.com>

usb_disk: Handle user buffer-to-partial buffer copies correctly.

Discovered by an SMAP violation triggered by running "writembr" on a
USB drive.


# 16a54a87 28-Nov-2018 Adrien Destugues <pulkomandy@pulkomandy.tk>

Merge usb_floppy back into usb_disk.

- USB pen drive seems to still work. More extensive testing welcome.
- USB floppies don't work yet, but they don't work anymore with the
current driver, either. I'm still investigating that part.

Fixes #9276

Change-Id: I8aa5ab828ad2ad867d0c187062d6e179372fc2ad
Reviewed-on: https://review.haiku-os.org/747
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 21c87a5d 09-Sep-2018 Jérôme Duval <jerome.duval@gmail.com>

drivers: remove some non-haiku support code.

Change-Id: Ic55bb4832adabeb807f763c87ad938e74fb3a97d
Reviewed-on: https://review.haiku-os.org/520
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 5692356b 07-Jan-2016 François Revol <revol@free.fr>

usb_disk: add the Zip icon

not used yet, my USB Zip drive seems to have gone to the mechanical valhalla.


# e3c95b5a 25-Nov-2015 François Revol <revol@free.fr>

usb_disk: add icon for mobile phones

Add a match for my Kazam dumb phone, which is not very descriptive...


# eff74a33 24-Nov-2015 François Revol <revol@free.fr>

usb_disk: use SD card and Memory Stick icons when found

Check for partial matches on the product_name string.

Tested with a USB card reader and an SD card.

Feel free to add icons for Compact Flash and Secure Media and more matches.


# 6c51d263 24-Nov-2015 François Revol <revol@free.fr>

usb_disk: use CD icon for optical media

Tested with a CD drive and a USB adapter.


# ce27a0cc 23-Nov-2015 François Revol <revol@free.fr>

usb_disk: add some icons

- CD
- SD
- MemoryStick


# 0cd7643b 02-Dec-2014 Adrien Destugues <pulkomandy@gmail.com>

usb_disk, usb_floppy: missing const.


# 92d55608 03-Aug-2014 Jérôme Duval <jerome.duval@gmail.com>

USB_massbulk.h: use a proper naming for a public header.


# d9ecf5f3 31-Jul-2014 Jérôme Duval <jerome.duval@gmail.com>

usb_disk: extract specs into a public header.


# 578558b4 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


# b38fed93 07-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

usb_disk: accept B_DEV_MEDIA_CHANGED as a ready unit.


# 3ffd22ce 20-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: base the error sense handling on a reference table.

* imported asc-num.txt as a reference, was used to generate the asc sense table.
* use the sense asc and key tables to know which action and status codes are
to be applied.
* tested with an hard disk and a dvd reader.
* these tables could be reused by the scsi_periph module.


# 1a07e84d 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixed mounting a USB disk on x86_64

* usb_disk_prepare_partial_buffer() was miscalculating the offset in the temp buffer,
which led to a page fault later when copying to the user buffer.


# 6b48fa09 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixes 64bit trace build


# 5308f230 15-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: returns B_DEV_NOT_READY for SCSI_SENSE_KEY_NOT_READY

...instead of B_DEV_NO_MEDIA. The latter seems to imply we stop testing
the unit is ready in usb_disk_device_added().
Based on a patch provided by markh in #9589.


# a20d6452 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixed mounting a USB disk on x86_64

* usb_disk_prepare_partial_buffer() was miscalculating the offset in the temp buffer,
which led to a page fault later when copying to the user buffer.


# 367d2544 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixes 64bit trace build


# b119365b 15-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: returns B_DEV_NOT_READY for SCSI_SENSE_KEY_NOT_READY

...instead of B_DEV_NO_MEDIA. The latter seems to imply we stop testing
the unit is ready in usb_disk_device_added().
Based on a patch provided by markh in #9589.


# 066ca38a 23-Mar-2013 Michael Lotz <mmlr@mlotz.ch>

Include the actual error message in usb_disk debug output.


# 9def48ad 28-Nov-2012 Michael Lotz <mmlr@mlotz.ch>

Implement B_GET_DEVICE_NAME in usb_disk returning SCSI info.

The SCSI inquiry vendor and product information is concatenated into a
single string to form the device name. Multiple spaces are then
collapsed to make the string more readable. The space padding is quite
common as the fields are fixed size in the inquiry block.


# 9b9cb227 08-Oct-2012 Axel Dörfler <axeld@pinc-software.de>

Consolidated and fixed device_geometry computation.

* The only implementation that would accept more than 2 TB was the one in
scsi_disk. But even that one was limited to 63 TB.
* Now there is a new utility function devfs_compute_geometry_size() which
does it correctly for sizes up to 2^64 which should be good enough for
quite some time :-)
* This fixes bug #8992.


# d8b4cfc9 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# d1abffca 01-Apr-2012 Adrien Destugues - PulkoMandy <pulkomandy@pulkomandy.tk>

Force read/write mode for "removable media" devices as well. This makes
it possible to write files to my MP3 player.


# 9f6dd249 13-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Don't try to do another request sense if the failing operation already was a
request sense. Otherwise we can easily run into an infinite recursion. Should
fix #8022.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42840 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6e876fc 13-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Tiny cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42838 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3ce8cd8 14-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

small logic fix on my part, not properly handling usb drives with empty media. Potential fix to #7687

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42186 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5be4b532 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Put uint8 back to uint32 as per ML recommendations
* Begin using multi-architecture friendly formatting macros per ML
* Change uint32 snoozeTime to preferred bigtime_t per ML
* Thanks for the great feedback!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42062 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 331ecb30 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

change to non-posix int introduced a small bug, sorry about that

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1639f80 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

small change, use non-posix style int typedef

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea9b910a 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* change overly large uint32 to uint8 as we only count to 12 max
* add additional tracing to usb_disk lun inquiry
* cd and other optical disk devices can take some time to spin up
when plugged. Now we give them some time to do so to ensure we
can detect the media type properly if there is a cd in the drive.
Things non-mechanical (flash drives) will continue almost immediately
as there is no spin up time. The more attempts, the longer the wait.
We now try 7 times (28 seconds total), my modern usb cdrom takes
about 6 (21 seconds) of those cycles to be ready on power up and 4
(10 seconds) on media change while powered up.
* tested with usb media and cd media. Doesn't introduce any visible
delay to the user.
* the write protected status in lun is now correct for my usb cd device
on plug (it wasn't previously)
* still seeing it though as read/write. Looking at this now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42058 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13486cf5 20-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Fix dereference after free. CID 10543.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47e9b53f 28-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fix some coding style violations (case scope blocks get their
opening parenthesis on a new line & 80 chars/line limit).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38837 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 395346c4 28-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by Matthias: The residue field is not maintained
correctly by all USB devices, so calculate it instead.
Gets some USB disk devices working like the SuperTOP.
MacOS X is doing the same thing, as researched by Jérôme.
Closes ticket #6604. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f4f2bf9 11-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Implement support for ATAPI command set devices. It's used by some USB CD drives
and easy to implement since ATAPI basically is SCSI anyway and we don't use many
problematic commands. Only tested for the 0x05 subclass, but 0x02 should work
the same.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36162 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8b6349fd 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

* Add a missing result assign that would cause the synchronize ioctl to always
return an error.
* Properly use the name length instead of a hardcoded buffer size when composing
the name of the raw device and ensure proper termination.
* Case new ioctls for Haiku as the target platform. Indeed this driver works
fine on BeOS even though it was written natively for Haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33240 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 88861a88 31-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Also test for the "no medium persent" case and don't tell B_DEV_MEDIA_CHANGED in
such a case as that would try to read info about a non-present medium.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32862 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fa8a197 26-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Actually don't report any failures of the TUR command, as for devices with no
media present they will always fail with the no media or media changed errors.
+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32732 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de9aa21e 26-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

If the device tells us that it doesn't support the Test Unit Ready (TUR) command,
don't try to use it for media status polling. In those cases we'll assume a
fixed device with no exchangable medias and therefore always return B_OK.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32731 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f579914 22-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Enlarge the timeout for data transfers. It was 2 seconds before and under a bit
of load, when using large enough block sizes or when simply having a slow device
this is by far not enough. It is now at 15 seconds, which should reduce timeout
problems to those cases where the device actually get's stuck (because of us
doing something wrong).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32615 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 40b708f7 17-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Do not base the device number on the device count. Fixes bug #4267.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32474 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ac0a9729 09-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Adding mode sense command to retrieve the write protected status. Doesn't work
yet, so not enabled for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30082 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 236ecca7 19-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Fix missing mutex_unlock() in case of opening an already removed device.
Spotted by Mika Lindqvist, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28957 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8b00954 18-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Style cleanup. Please at least try to...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28953 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9c2491cc 18-Jan-2009 François Revol <revol@free.fr>

Implement B_GET_ICON_NAME to return "devices/drive-removable-media-usb" as it seems correct as per the FreeDesktop.org Icon Naming Specification we agreed to use for now, cf. http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cad6c36 18-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Add ioctl cases for B_GET_ICON, B_GET_ICON_NAME and B_GET_VECTOR_ICON. The first
won't be implemented, the second currently isn't and the third is. This gets
rid of the frequent "unhandled ioctl" messages when using USB drives and also
adds the nice pendrive icon to the mount list when using USB storage devices.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28948 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8311b012 18-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* Fix a lock leak in the eject/load ioctls. It did return directly without
unlocking the device again, causing deadlocks after unmounting a USB mass
storage device.
* Synchronize on close again, but this time with proper locking of the device.
* Restructured usb_disk_synchronize() a bit and updated comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28934 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b289baf1 17-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* The close hook did trigger a synchronize without locking the device. This
could have messed up the state of other transfers currently running on that
device. Since devices are regularly opened/closed for enumeration/scanning
from different threads, this could've easily lead to bad situations. I've
removed the sync completely as it's not our task to issue it and because
a close doesn't always correspond with an unmount at all.
* Retry receiving the command status wrapper also when another error than a
stall is returned. The specs aren't too specific, but the graphic suggests
this is a general recovery path.
* Do a reset in case there is an error during data transfer to start the next
command from a clean state.
* Make sure we never acknowledge more data than we actually transfered. This
is to make sure devices that return broken residue values do not mess up our
transfers.
* Detect a few more cases of invalid and non-meaningful command status wrappers.
* If the device explicitly tells us that the sync command isn't supported don't
try it a few more times. Only retry at most five times if an unspecific error
is returned that could also come from another (temporary) error case.
* Add a bit more trace output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28930 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c5b7a57 01-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

While the comment was correct with regards to collecting the semaphore after
the cancel, it wasn't actually done. This could bring a device out of sync in
the case timeouts actually happened (which shouldn't be a commen case).
Fixed that and increased the timeout to 2 seconds in favor of slower devices.
Might need some fine tuning later still.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26197 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6cf75244 22-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Add comment explaining the reason for retrying capacity reads.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26083 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 27b95d52 22-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Impose a one second timeout on all usb_disk data transfers. This should avoid
hanging systems on boot, but probably just hides a problem somewhere else, as
the transfers should timeout on their own if the device doesn't respond.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26082 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 717b5b78 22-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Retry reading the capacity up to three times. The first try might only yield a
unit attention telling us that the device or media status changed, which is
expected.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 50320b55 14-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Implement B_EJECT_DEVICE and B_LOAD_MEDIA through the START_STOP_UNIT SCSI
command.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25955 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e109130a 06-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Fix a deadlock when removing a mass storage device that had active transfers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25829 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b07b8e0 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25690 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86dd3875 05-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Updating device->removed must be protected by the device lock
* Also updating device->open_count must be protected by the device list lock

This fixes the (unlikely) case where a device was removed from usb_disk
standpoint while it still had an open read/write/ioctl operation.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24811 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f1a9c3c2 04-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Implement a downcounter for the synchronize cache command. There are devices
that do not support it (probably because they do not have a cache at all like
in flash media) and this should at least avoid spamming the syslog when this is
the case. It will try 5 times and then disable syncing for that device. Untested
as of yet though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24803 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a380bc25 04-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Add support for devices with multiple LUNs
* A device now has one or more LUNs which are used for LUN specific functions
* Adapted these LUN specific functions to the new design and also change the
(un-)publishing accordingly
* Handle "no media" cases more correctly
* Output some interesting device infos also with tracing disabled
* Add some more helpful debug output here and there

Devices that provide multiple logical units (like those n in 1 card readers)
should now be usable with usb_disk too. Also we don't fail when a device is
attached which currently does not contain a media. Instead handle media changes
correctly so inserting a media works as expected. Note that hot-unplugging and
media removal still does not quite work right at the devfs or disk device
manager level and easily crashes the system.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24799 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ad0015d 01-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Retry some times when the device reports it is not ready
* Use the CBW_SIGNATURE define instead of the numeric value

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24729 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01533b17 31-Mar-2008 Michael Lotz <mmlr@mlotz.ch>

Introduce a simple usb_disk driver that supports USB mass storage devices of
the bulk-only class using transparent SCSI commands (i.e. most of the current
external harddrives and flash media). It emulates the few SCSI commands needed
to get this sort of devices working and does not interface with the SCSI
subsystem. This makes it far easier to get working and also far better fits
how the USB stack works (as drivers can be dynamically rescanned when device
changes occur). This will allow for easy dynamic un- and replugging at runtime.
Note that while the device is currently published when you plug something in at
runtime, the partitions are not scanned and published automatically. It works
however if you have the device plugged in at boot.
I haven't added this driver to the image yet, but if properly installed and
with boot module links to the driver and USB stack, it allows to boot Haiku
from USB media like memory sticks or external harddrives.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0cd7643bd3699954e22c4c0bb49437bcd1c12ef7 02-Dec-2014 Adrien Destugues <pulkomandy@gmail.com>

usb_disk, usb_floppy: missing const.


# 92d556084ca7f0e9472976a35aff6a21acf12fda 03-Aug-2014 Jérôme Duval <jerome.duval@gmail.com>

USB_massbulk.h: use a proper naming for a public header.


# d9ecf5f373dab3ddaf7579c0b725705c7178d4b0 31-Jul-2014 Jérôme Duval <jerome.duval@gmail.com>

usb_disk: extract specs into a public header.


# 578558b439867f563d44d168a29223f76d6bb23e 07-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

add-ons/kernel: add spaces between literals and identifiers

Due to introduction of user-defined suffixes C++11 requires that there
is a space between literal and identifier to avoid ambiguity.

This patch makes the whole kernel build successfully with C++11.


# b38fed9370deb68349657e011e27d59e693d51dc 07-Oct-2013 Jérôme Duval <jerome.duval@gmail.com>

usb_disk: accept B_DEV_MEDIA_CHANGED as a ready unit.


# 3ffd22ce6d0671c4d51507f8b57a78143d9b2ab0 20-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: base the error sense handling on a reference table.

* imported asc-num.txt as a reference, was used to generate the asc sense table.
* use the sense asc and key tables to know which action and status codes are
to be applied.
* tested with an hard disk and a dvd reader.
* these tables could be reused by the scsi_periph module.


# 1a07e84d0381f46de01d03c55648288294f95e56 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixed mounting a USB disk on x86_64

* usb_disk_prepare_partial_buffer() was miscalculating the offset in the temp buffer,
which led to a page fault later when copying to the user buffer.


# 6b48fa0994c9fe5cadb92141f198a05e8a9cc586 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixes 64bit trace build


# 5308f230252c431646f6e4d69c94ff00144482df 15-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: returns B_DEV_NOT_READY for SCSI_SENSE_KEY_NOT_READY

...instead of B_DEV_NO_MEDIA. The latter seems to imply we stop testing
the unit is ready in usb_disk_device_added().
Based on a patch provided by markh in #9589.


# a20d64522658966dcfc148b5aeff24ad387fe768 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixed mounting a USB disk on x86_64

* usb_disk_prepare_partial_buffer() was miscalculating the offset in the temp buffer,
which led to a page fault later when copying to the user buffer.


# 367d254419ed612ac5a6b3d4d8c262bc30038c53 16-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: fixes 64bit trace build


# b119365b2198a23308fed21af0145dcdc3aa272a 15-Sep-2013 Jerome Duval <jerome.duval@gmail.com>

usb_disk: returns B_DEV_NOT_READY for SCSI_SENSE_KEY_NOT_READY

...instead of B_DEV_NO_MEDIA. The latter seems to imply we stop testing
the unit is ready in usb_disk_device_added().
Based on a patch provided by markh in #9589.


# 066ca38aea3742d0054963b76fd1259125bb3e5b 23-Mar-2013 Michael Lotz <mmlr@mlotz.ch>

Include the actual error message in usb_disk debug output.


# 9def48ad2e7ef77665a09724536d4f456405b64c 28-Nov-2012 Michael Lotz <mmlr@mlotz.ch>

Implement B_GET_DEVICE_NAME in usb_disk returning SCSI info.

The SCSI inquiry vendor and product information is concatenated into a
single string to form the device name. Multiple spaces are then
collapsed to make the string more readable. The space padding is quite
common as the fields are fixed size in the inquiry block.


# 9b9cb227c7835fa55076dafac035a25e30b089ff 08-Oct-2012 Axel Dörfler <axeld@pinc-software.de>

Consolidated and fixed device_geometry computation.

* The only implementation that would accept more than 2 TB was the one in
scsi_disk. But even that one was limited to 63 TB.
* Now there is a new utility function devfs_compute_geometry_size() which
does it correctly for sizes up to 2^64 which should be good enough for
quite some time :-)
* This fixes bug #8992.


# d8b4cfc9829119291e68cfe0152c239fd8850b3d 04-Aug-2012 Rene Gollent <anevilyak@gmail.com>

Get USB functional on x86-64.

- Various changes to printf format specifiers to make them 32/64 safe.
- Adjustments to various descriptor structures since addr_t is not 32-bit
on x86-64, and consequently this breaks the physical structure that's
expected. Also adjusted padding to accomodate 32-byte boundaries when
64-bit pointers are in use.
- Adjustments to make use of phys_addr_t where needed.


# d1abffcaa267478916c5922ec1712cf27509bcec 01-Apr-2012 Adrien Destugues - PulkoMandy <pulkomandy@pulkomandy.tk>

Force read/write mode for "removable media" devices as well. This makes
it possible to write files to my MP3 player.


# 9f6dd249744f1bd2dad7cfed5a59f9be277c7433 13-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Don't try to do another request sense if the failing operation already was a
request sense. Otherwise we can easily run into an infinite recursion. Should
fix #8022.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42840 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6e876fc853e81fe09af0e2c43696205e1633864 13-Oct-2011 Michael Lotz <mmlr@mlotz.ch>

Tiny cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42838 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3ce8cd8ba265648ccc919077a29c9fa2bcb7abc 14-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

small logic fix on my part, not properly handling usb drives with empty media. Potential fix to #7687

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42186 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5be4b532a864f0e88d4098c01033c426ff791e87 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* Put uint8 back to uint32 as per ML recommendations
* Begin using multi-architecture friendly formatting macros per ML
* Change uint32 snoozeTime to preferred bigtime_t per ML
* Thanks for the great feedback!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42062 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 331ecb302cddb105fdb72abb24196cf01c40a579 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

change to non-posix int introduced a small bug, sorry about that

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1639f80d89fea28571cc446763f0c49ac187ed7 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

small change, use non-posix style int typedef

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42059 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ea9b910a269e39fb24e9bdec7f9e1cd4436ebddd 08-Jun-2011 Alexander von Gluck IV <kallisti5@unixzen.com>

* change overly large uint32 to uint8 as we only count to 12 max
* add additional tracing to usb_disk lun inquiry
* cd and other optical disk devices can take some time to spin up
when plugged. Now we give them some time to do so to ensure we
can detect the media type properly if there is a cd in the drive.
Things non-mechanical (flash drives) will continue almost immediately
as there is no spin up time. The more attempts, the longer the wait.
We now try 7 times (28 seconds total), my modern usb cdrom takes
about 6 (21 seconds) of those cycles to be ready on power up and 4
(10 seconds) on media change while powered up.
* tested with usb media and cd media. Doesn't introduce any visible
delay to the user.
* the write protected status in lun is now correct for my usb cd device
on plug (it wasn't previously)
* still seeing it though as read/write. Looking at this now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42058 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13486cf5311fe5f5660f89e9ce578863b0afa255 20-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Fix dereference after free. CID 10543.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 47e9b53fe4a1038eec9c9b1da9d5e615b221ebe2 28-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Fix some coding style violations (case scope blocks get their
opening parenthesis on a new line & 80 chars/line limit).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38837 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 395346c411a08a22d5a7efcde929b58c4190784a 28-Sep-2010 Stephan Aßmus <superstippi@gmx.de>

Patch by Matthias: The residue field is not maintained
correctly by all USB devices, so calculate it instead.
Gets some USB disk devices working like the SuperTOP.
MacOS X is doing the same thing, as researched by Jérôme.
Closes ticket #6604. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8f4f2bf933413442fc8b541f26fb53a908ecbc4a 11-Apr-2010 Michael Lotz <mmlr@mlotz.ch>

Implement support for ATAPI command set devices. It's used by some USB CD drives
and easy to implement since ATAPI basically is SCSI anyway and we don't use many
problematic commands. Only tested for the 0x05 subclass, but 0x02 should work
the same.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36162 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8b6349fd3278fcc2ae839c8bf8e830d70d273a94 22-Sep-2009 Michael Lotz <mmlr@mlotz.ch>

* Add a missing result assign that would cause the synchronize ioctl to always
return an error.
* Properly use the name length instead of a hardcoded buffer size when composing
the name of the raw device and ensure proper termination.
* Case new ioctls for Haiku as the target platform. Indeed this driver works
fine on BeOS even though it was written natively for Haiku.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33240 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 88861a88884727091c9ffbd30030a6e31d061dde 31-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Also test for the "no medium persent" case and don't tell B_DEV_MEDIA_CHANGED in
such a case as that would try to read info about a non-present medium.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32862 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5fa8a19786a8fa8071daf4231e616dc318c12d4f 26-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Actually don't report any failures of the TUR command, as for devices with no
media present they will always fail with the no media or media changed errors.
+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32732 a95241bf-73f2-0310-859d-f6bbb57e9c96


# de9aa21e08bdec378dd06f5b49477edcf347e6cb 26-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

If the device tells us that it doesn't support the Test Unit Ready (TUR) command,
don't try to use it for media status polling. In those cases we'll assume a
fixed device with no exchangable medias and therefore always return B_OK.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32731 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7f5799140f536653f5f5bf15057e263d7d6a2eda 22-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Enlarge the timeout for data transfers. It was 2 seconds before and under a bit
of load, when using large enough block sizes or when simply having a slow device
this is by far not enough. It is now at 15 seconds, which should reduce timeout
problems to those cases where the device actually get's stuck (because of us
doing something wrong).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32615 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 40b708f776042f64213f40af1586234ae17e9b31 17-Aug-2009 Michael Lotz <mmlr@mlotz.ch>

Do not base the device number on the device count. Fixes bug #4267.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32474 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ac0a97298599d31d45e83b47234b453328d3613f 09-Apr-2009 Michael Lotz <mmlr@mlotz.ch>

Adding mode sense command to retrieve the write protected status. Doesn't work
yet, so not enabled for now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30082 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 236ecca7dad4b630c048214a98a16613c530a119 19-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Fix missing mutex_unlock() in case of opening an already removed device.
Spotted by Mika Lindqvist, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28957 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a8b00954336b059d096b6ffe303601b839900a11 18-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Style cleanup. Please at least try to...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28953 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9c2491ccc43a5f2f019837ef39446e7ae597e77b 18-Jan-2009 François Revol <revol@free.fr>

Implement B_GET_ICON_NAME to return "devices/drive-removable-media-usb" as it seems correct as per the FreeDesktop.org Icon Naming Specification we agreed to use for now, cf. http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28949 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9cad6c36321fff368e6f79c0edcbc387ac9406ec 18-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

Add ioctl cases for B_GET_ICON, B_GET_ICON_NAME and B_GET_VECTOR_ICON. The first
won't be implemented, the second currently isn't and the third is. This gets
rid of the frequent "unhandled ioctl" messages when using USB drives and also
adds the nice pendrive icon to the mount list when using USB storage devices.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28948 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8311b012d1bc4247bd7f06a85d8af89e95614032 18-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* Fix a lock leak in the eject/load ioctls. It did return directly without
unlocking the device again, causing deadlocks after unmounting a USB mass
storage device.
* Synchronize on close again, but this time with proper locking of the device.
* Restructured usb_disk_synchronize() a bit and updated comments.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28934 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b289baf147e686b847f07f26808a049afe3cfb51 17-Jan-2009 Michael Lotz <mmlr@mlotz.ch>

* The close hook did trigger a synchronize without locking the device. This
could have messed up the state of other transfers currently running on that
device. Since devices are regularly opened/closed for enumeration/scanning
from different threads, this could've easily lead to bad situations. I've
removed the sync completely as it's not our task to issue it and because
a close doesn't always correspond with an unmount at all.
* Retry receiving the command status wrapper also when another error than a
stall is returned. The specs aren't too specific, but the graphic suggests
this is a general recovery path.
* Do a reset in case there is an error during data transfer to start the next
command from a clean state.
* Make sure we never acknowledge more data than we actually transfered. This
is to make sure devices that return broken residue values do not mess up our
transfers.
* Detect a few more cases of invalid and non-meaningful command status wrappers.
* If the device explicitly tells us that the sync command isn't supported don't
try it a few more times. Only retry at most five times if an unspecific error
is returned that could also come from another (temporary) error case.
* Add a bit more trace output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28930 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5c5b7a576013946d60b5101fd99d407b32909ec1 01-Jul-2008 Michael Lotz <mmlr@mlotz.ch>

While the comment was correct with regards to collecting the semaphore after
the cancel, it wasn't actually done. This could bring a device out of sync in
the case timeouts actually happened (which shouldn't be a commen case).
Fixed that and increased the timeout to 2 seconds in favor of slower devices.
Might need some fine tuning later still.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26197 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6cf7524447e811754e70d15a0b162212424f6dc7 22-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Add comment explaining the reason for retrying capacity reads.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26083 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 27b95d52b8f5a4381ddbe58db05e1d4659154ea8 22-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Impose a one second timeout on all usb_disk data transfers. This should avoid
hanging systems on boot, but probably just hides a problem somewhere else, as
the transfers should timeout on their own if the device doesn't respond.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26082 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 717b5b78ce92d4b8749793195f63048c259b8981 22-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Retry reading the capacity up to three times. The first try might only yield a
unit attention telling us that the device or media status changed, which is
expected.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26081 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 50320b5500dbfd9503ffa22e531952297eda86ec 14-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Implement B_EJECT_DEVICE and B_LOAD_MEDIA through the START_STOP_UNIT SCSI
command.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25955 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e109130a10a696baf71eef98b3132b178c7bb9b8 06-Jun-2008 Michael Lotz <mmlr@mlotz.ch>

Fix a deadlock when removing a mass storage device that had active transfers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25829 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b07b8e0f1a7f1e76f31db24a21a42cbb01d7b9c 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25690 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 86dd3875cd040344362f74e482e7dde63df48163 05-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Updating device->removed must be protected by the device lock
* Also updating device->open_count must be protected by the device list lock

This fixes the (unlikely) case where a device was removed from usb_disk
standpoint while it still had an open read/write/ioctl operation.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24811 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f1a9c3c21468099abed6e55837d8bf0559f3e789 04-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Implement a downcounter for the synchronize cache command. There are devices
that do not support it (probably because they do not have a cache at all like
in flash media) and this should at least avoid spamming the syslog when this is
the case. It will try 5 times and then disable syncing for that device. Untested
as of yet though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24803 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a380bc25131132eaafceca992acc027690fbaf55 04-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Add support for devices with multiple LUNs
* A device now has one or more LUNs which are used for LUN specific functions
* Adapted these LUN specific functions to the new design and also change the
(un-)publishing accordingly
* Handle "no media" cases more correctly
* Output some interesting device infos also with tracing disabled
* Add some more helpful debug output here and there

Devices that provide multiple logical units (like those n in 1 card readers)
should now be usable with usb_disk too. Also we don't fail when a device is
attached which currently does not contain a media. Instead handle media changes
correctly so inserting a media works as expected. Note that hot-unplugging and
media removal still does not quite work right at the devfs or disk device
manager level and easily crashes the system.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24799 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ad0015d569f3cb860c0a6a282185a84056195dc 01-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

* Retry some times when the device reports it is not ready
* Use the CBW_SIGNATURE define instead of the numeric value

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24729 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01533b17a2fb17655269a98888e9af6622708127 31-Mar-2008 Michael Lotz <mmlr@mlotz.ch>

Introduce a simple usb_disk driver that supports USB mass storage devices of
the bulk-only class using transparent SCSI commands (i.e. most of the current
external harddrives and flash media). It emulates the few SCSI commands needed
to get this sort of devices working and does not interface with the SCSI
subsystem. This makes it far easier to get working and also far better fits
how the USB stack works (as drivers can be dynamically rescanned when device
changes occur). This will allow for easy dynamic un- and replugging at runtime.
Note that while the device is currently published when you plug something in at
runtime, the partitions are not scanned and published automatically. It works
however if you have the device plugged in at boot.
I haven't added this driver to the image yet, but if properly installed and
with boot module links to the driver and USB stack, it allows to boot Haiku
from USB media like memory sticks or external harddrives.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24713 a95241bf-73f2-0310-859d-f6bbb57e9c96