Browse Source

[scsi] Eliminate polling while waiting for window to open

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
5c9c39e299
1 changed files with 13 additions and 6 deletions
  1. 13
    6
      src/drivers/block/scsi.c

+ 13
- 6
src/drivers/block/scsi.c View File

218
 
218
 
219
 /** SCSI device flags */
219
 /** SCSI device flags */
220
 enum scsi_device_flags {
220
 enum scsi_device_flags {
221
-	/** Unit is ready */
222
-	SCSIDEV_UNIT_READY = 0x0001,
221
+	/** TEST UNIT READY has been issued */
222
+	SCSIDEV_UNIT_TESTED = 0x0001,
223
+	/** TEST UNIT READY has completed successfully */
224
+	SCSIDEV_UNIT_READY = 0x0002,
223
 };
225
 };
224
 
226
 
225
 /** A SCSI command */
227
 /** A SCSI command */
897
 static void scsidev_step ( struct scsi_device *scsidev ) {
899
 static void scsidev_step ( struct scsi_device *scsidev ) {
898
 	int rc;
900
 	int rc;
899
 
901
 
902
+	/* Do nothing if we have already issued TEST UNIT READY */
903
+	if ( scsidev->flags & SCSIDEV_UNIT_TESTED )
904
+		return;
905
+
900
 	/* Wait until underlying SCSI device is ready */
906
 	/* Wait until underlying SCSI device is ready */
901
 	if ( xfer_window ( &scsidev->scsi ) == 0 )
907
 	if ( xfer_window ( &scsidev->scsi ) == 0 )
902
 		return;
908
 		return;
903
 
909
 
904
-	/* Stop process */
905
-	process_del ( &scsidev->process );
906
-
907
 	DBGC ( scsidev, "SCSI %p waiting for unit to become ready\n",
910
 	DBGC ( scsidev, "SCSI %p waiting for unit to become ready\n",
908
 	       scsidev );
911
 	       scsidev );
909
 
912
 
913
+	/* Mark TEST UNIT READY as sent */
914
+	scsidev->flags |= SCSIDEV_UNIT_TESTED;
915
+
910
 	/* Issue TEST UNIT READY command */
916
 	/* Issue TEST UNIT READY command */
911
 	if ( ( rc = scsidev_test_unit_ready ( scsidev, &scsidev->ready )) !=0){
917
 	if ( ( rc = scsidev_test_unit_ready ( scsidev, &scsidev->ready )) !=0){
912
 		scsidev_close ( scsidev, rc );
918
 		scsidev_close ( scsidev, rc );
916
 
922
 
917
 /** SCSI device SCSI interface operations */
923
 /** SCSI device SCSI interface operations */
918
 static struct interface_operation scsidev_scsi_op[] = {
924
 static struct interface_operation scsidev_scsi_op[] = {
925
+	INTF_OP ( xfer_window_changed, struct scsi_device *, scsidev_step ),
919
 	INTF_OP ( intf_close, struct scsi_device *, scsidev_close ),
926
 	INTF_OP ( intf_close, struct scsi_device *, scsidev_close ),
920
 };
927
 };
921
 
928
 
926
 
933
 
927
 /** SCSI device process descriptor */
934
 /** SCSI device process descriptor */
928
 static struct process_descriptor scsidev_process_desc =
935
 static struct process_descriptor scsidev_process_desc =
929
-	PROC_DESC ( struct scsi_device, process, scsidev_step );
936
+	PROC_DESC_ONCE ( struct scsi_device, process, scsidev_step );
930
 
937
 
931
 /**
938
 /**
932
  * Open SCSI device
939
  * Open SCSI device

Loading…
Cancel
Save