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
This commit is contained in:
parent
0ee109102b
commit
f1a9c3c214
@ -436,10 +436,21 @@ usb_disk_update_capacity(device_lun *lun)
|
||||
status_t
|
||||
usb_disk_synchronize(device_lun *lun, bool force)
|
||||
{
|
||||
if (lun->device->sync_support == 0) {
|
||||
// this device repeatedly reported an illegal request when syncing
|
||||
// it obviously does really not support this command...
|
||||
return B_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (lun->should_sync || force) {
|
||||
status_t result = usb_disk_operation(lun, SCSI_SYNCHRONIZE_CACHE_10,
|
||||
10, 0, 0, NULL, NULL, false);
|
||||
lun->should_sync = false;
|
||||
|
||||
if (result == B_OK)
|
||||
lun->device->sync_support = SYNC_SUPPORT_RELOAD;
|
||||
else if (result == B_DEV_INVALID_IOCTL)
|
||||
lun->device->sync_support--;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -474,6 +485,7 @@ usb_disk_device_added(usb_device newDevice, void **cookie)
|
||||
device->open_count = 0;
|
||||
device->interface = 0xff;
|
||||
device->current_tag = 0;
|
||||
device->sync_support = SYNC_SUPPORT_RELOAD;
|
||||
device->luns = NULL;
|
||||
|
||||
// scan through the interfaces to find our bulk-only data interface
|
||||
|
@ -25,6 +25,8 @@
|
||||
#define CSW_STATUS_COMMAND_FAILED 0x01
|
||||
#define CSW_STATUS_PHASE_ERROR 0x02
|
||||
|
||||
#define SYNC_SUPPORT_RELOAD 5
|
||||
|
||||
typedef struct device_lun_s device_lun;
|
||||
|
||||
// holds common information about an attached device (pointed to by luns)
|
||||
@ -40,6 +42,7 @@ typedef struct disk_device_s {
|
||||
usb_pipe bulk_out;
|
||||
uint8 interface;
|
||||
uint32 current_tag;
|
||||
uint8 sync_support;
|
||||
|
||||
// used to store callback information
|
||||
sem_id notify;
|
||||
|
Loading…
Reference in New Issue
Block a user