diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp index 84bd530139..c955045bcd 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp +++ b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp @@ -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 diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.h b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.h index c57909cf74..34a693255d 100644 --- a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.h +++ b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.h @@ -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;