void ata_dpc_PIO( ide_qrequest *qrequest ) { ide_device_info *device = qrequest->device; bigtime_t timeout = qrequest->request->cam_timeout > 0 ? qrequest->request->cam_timeout : IDE_STD_TIMEOUT; if( !check_rw_error( device, qrequest ) || !check_rw_status( device, qrequest, qrequest->is_write ? device->left_blocks > 1 : true )) { /*if( (device->sense.sense_key == SCSIS_KEY_ABORTED_COMMAND || device->sense.ascq == SCSIS_ASC_UNREC_READ_ERR) && ++qrequest->retries < MAX_PIO_RETRIES ) { finish_rw_request( qrequest, ide_finish_rw_retry ); } else*/ finish_checksense( qrequest ); return; } if( qrequest->is_write ) { if( device->left_blocks == 0 ) goto finish; if( !wait_for_drq( device )) goto finish; start_waiting_nolock( device->bus, timeout, ide_state_async_waiting ); // having a too short data buffer shouldn't happen here // anyway - we are prepared if( write_PIO_block( qrequest, 512 ) == ERR_GENERAL ) goto finish_cancel_timeout; --device->left_blocks; } else { if( device->left_blocks > 0 ) start_waiting_nolock( device->bus, timeout, ide_state_async_waiting ); // see write if( read_PIO_block( qrequest, 512 ) == ERR_GENERAL ) goto finish_cancel_timeout; --device->left_blocks; if( device->left_blocks == 0 ) { wait_for_drqdown( device ); goto finish_cancel_timeout; } } //start_waiting( device->bus ); return; finish_cancel_timeout: cancel_irq_timeout( device->bus ); finish: finish_checksense( qrequest ); return; }
void ata_dpc_PIO(ide_qrequest *qrequest) { ide_device_info *device = qrequest->device; uint32 timeout = qrequest->request->timeout > 0 ? qrequest->request->timeout : IDE_STD_TIMEOUT; SHOW_FLOW0(3, ""); if (check_rw_error(device, qrequest) || !check_rw_status(device, qrequest->is_write ? device->left_blocks > 0 : true)) { // failure reported by device SHOW_FLOW0( 3, "command finished unsuccessfully" ); finish_checksense(qrequest); return; } if (qrequest->is_write) { if (device->left_blocks == 0) { // this was the end-of-transmission IRQ SHOW_FLOW0(3, "write access finished"); if (!wait_for_drqdown(device)) { SHOW_ERROR0(3, "device wants to transmit data though command is finished"); goto finish; } goto finish; } // wait until device requests data SHOW_FLOW0(3, "Waiting for device ready to transmit"); if (!wait_for_drq(device)) { SHOW_FLOW0(3, "device not ready for data transmission - abort"); goto finish; } // start async waiting for next block/end of command // we should start that when block is transmitted, but with bad // luck the IRQ fires exactly between transmission and start of waiting, // so we better start waiting too early; as we are in service thread, // a DPC initiated by IRQ cannot overtake us, so there is no need to block // IRQs during sent start_waiting_nolock(device->bus, timeout, ide_state_async_waiting); // having a too short data buffer shouldn't happen here // anyway - we are prepared SHOW_FLOW0(3, "Writing one block"); if (write_PIO_block(qrequest, 512) == B_ERROR) goto finish_cancel_timeout; --device->left_blocks; } else { if (device->left_blocks > 1) { // start async waiting for next command (see above) start_waiting_nolock(device->bus, timeout, ide_state_async_waiting); } // see write SHOW_FLOW0( 3, "Reading one block" ); if (read_PIO_block(qrequest, 512) == B_ERROR) goto finish_cancel_timeout; --device->left_blocks; if (device->left_blocks == 0) { // at end of transmission, wait for data request going low SHOW_FLOW0( 3, "Waiting for device to finish transmission" ); if (!wait_for_drqdown(device)) SHOW_FLOW0( 3, "Device continues data transmission - abort command" ); // we don't cancel timeout as no timeout is started during last block goto finish; } } return; finish_cancel_timeout: cancel_irq_timeout(device->bus); finish: finish_checksense(qrequest); }