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,8 +218,10 @@ struct scsi_device {
218 218
 
219 219
 /** SCSI device flags */
220 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 227
 /** A SCSI command */
@@ -897,16 +899,20 @@ static struct interface_descriptor scsidev_ready_desc =
897 899
 static void scsidev_step ( struct scsi_device *scsidev ) {
898 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 906
 	/* Wait until underlying SCSI device is ready */
901 907
 	if ( xfer_window ( &scsidev->scsi ) == 0 )
902 908
 		return;
903 909
 
904
-	/* Stop process */
905
-	process_del ( &scsidev->process );
906
-
907 910
 	DBGC ( scsidev, "SCSI %p waiting for unit to become ready\n",
908 911
 	       scsidev );
909 912
 
913
+	/* Mark TEST UNIT READY as sent */
914
+	scsidev->flags |= SCSIDEV_UNIT_TESTED;
915
+
910 916
 	/* Issue TEST UNIT READY command */
911 917
 	if ( ( rc = scsidev_test_unit_ready ( scsidev, &scsidev->ready )) !=0){
912 918
 		scsidev_close ( scsidev, rc );
@@ -916,6 +922,7 @@ static void scsidev_step ( struct scsi_device *scsidev ) {
916 922
 
917 923
 /** SCSI device SCSI interface operations */
918 924
 static struct interface_operation scsidev_scsi_op[] = {
925
+	INTF_OP ( xfer_window_changed, struct scsi_device *, scsidev_step ),
919 926
 	INTF_OP ( intf_close, struct scsi_device *, scsidev_close ),
920 927
 };
921 928
 
@@ -926,7 +933,7 @@ static struct interface_descriptor scsidev_scsi_desc =
926 933
 
927 934
 /** SCSI device process descriptor */
928 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 939
  * Open SCSI device

Loading…
Cancel
Save