Commit 3ef0ad5c authored by John Ballance's avatar John Ballance

Tuned previous commit and resolved potential interlock issue

Detail:
  More precise detection of sense status error condition, and blocked
  reentrancy possible condition at start of Glue_Tick().
  Previous fix didn't always fix offending device.
Admin:
  Tested on iMx6

Version 0.24. Tagged as 'SCSISoftUSB-0_24'
parent f4c5a80e
/* (0.23)
/* (0.24)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.23
#define Module_MajorVersion_CMHG 0.24
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 01 Jul 2018
#define Module_MajorVersion "0.23"
#define Module_Version 23
#define Module_MajorVersion "0.24"
#define Module_Version 24
#define Module_MinorVersion ""
#define Module_Date "01 Jul 2018"
......@@ -18,6 +18,6 @@
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.23"
#define Module_HelpVersion "0.23 (01 Jul 2018)"
#define Module_LibraryVersionInfo "0:23"
#define Module_FullVersion "0.24"
#define Module_HelpVersion "0.24 (01 Jul 2018)"
#define Module_LibraryVersionInfo "0:24"
......@@ -351,9 +351,9 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
softc->transfer_priv = NULL; /* don't do callback if we're reset from interrupt, until transfer_priv is initialised */
device->command_active = true; /* prevent any new commands from being started until we're done */
device->ticker_semaphore = true; /* prevent TickerV from doing anything */
if (!irqs_were_off) _kernel_irqs_on();
device->background_transfer_active = false;
device->current_fill=0;
if (!irqs_were_off) _kernel_irqs_on();
if (data_direction != DIR_NONE << 24)
{
......@@ -407,6 +407,8 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
*/
device->is_capacity = ((control_block[0] == 0x25) && (data_direction == (DIR_IN<<24)) && (control_block_length == 10) && (transfer_length == 8));
device->is_sensestatus = ((control_block[0] == 0x03) && (data_direction == (DIR_IN<<24)) && (control_block_length == 6));
device->callback = callback; /* remember the address to call in SCSIDriver */
device->callback_pw = callback_pw;
device->callback_wp = callback_wp;
......@@ -478,7 +480,9 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
void glue_Tick(my_usb_device_t *device)
{
/* Semaphore check .. out quickly if already here */
if (device->ticker_semaphore) return;
bool irqs_were_off = _kernel_irqs_disabled();
if (!irqs_were_off) _kernel_irqs_off();
if (device->ticker_semaphore) {if(!irqs_were_off)_kernel_irqs_on();return;}
device->ticker_semaphore = true;
DEBUGf("\nTick ");
......@@ -691,6 +695,12 @@ void glue_Tick(my_usb_device_t *device)
}
else
{
if(device->is_sensestatus && !device->curr_transferlength && buffer_used)
{
DEBUGf("Was sense status.. purging buffer of %x bytes\n ", buffer_used);
// flush the buffer.. we're done here
PURGE_SPACE(device->current_pipe->buffer);
}
device->status = USBD_NORMAL_COMPLETION;
if ((device->is_capacity) && ((softc->transfer_state == TSTATE_BBB_DATA) || (softc->transfer_state == TSTATE_CBI_DATA)) && (device->orig_scatterlist->length >= 8))
{
......
......@@ -45,6 +45,7 @@
#define REMOVE_BLOCK(buffer_id, block, length) do { asm_CallBufferManager(3, buffer_id, block, length, static_BufManWS, static_BufManRout); } while(0)
#define USED_SPACE(buffer_id) asm_CallBufferManager(6, buffer_id, 0, 0, static_BufManWS, static_BufManRout)
#define FREE_SPACE(buffer_id) asm_CallBufferManager(7, buffer_id, 0, 0, static_BufManWS, static_BufManRout)
#define PURGE_SPACE(buffer_id) asm_CallBufferManager(8, buffer_id, 0, 0, static_BufManWS, static_BufManRout)
/*****************************************************************************
......
......@@ -138,6 +138,7 @@ typedef struct my_usb_device
bool ticker_semaphore; /* paranoid ticker re-entrancy semaphore */
bool background_transfer_active; /* active and at a phase involving a bulk pipe */
bool is_capacity; /* True if we're processing a CAPACITY command */
bool is_sensestatus; /* True if we're processing a SENSE STATUS command */
scatter_entry_t *orig_scatterlist; /* scatterlist pointer st start of background xfer */
size_t orig_transferlength; /* to-do count at start of background xfer */
scatter_entry_t *curr_scatterlist; /* working scatterlist pointer */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment