Quellcode durchsuchen

[ata] Make ATA command issuing partially asynchronous

Move the icky call to step() from aoe.c to ata.c; this takes it at
least one step further away from where it really doesn't belong.

Unfortunately, AoE has the ugly aoe_discover() mechanism which means
that we still have a step() loop in aoe.c for now; this needs to be
replaced at some future point.
tags/v0.9.8
Michael Brown vor 15 Jahren
Ursprung
Commit
54ec3673cc
4 geänderte Dateien mit 29 neuen und 9 gelöschten Zeilen
  1. 24
    1
      src/drivers/block/ata.c
  2. 2
    0
      src/include/gpxe/ata.h
  3. 1
    0
      src/include/gpxe/errfile.h
  4. 2
    8
      src/net/aoe.c

+ 24
- 1
src/drivers/block/ata.c Datei anzeigen

@@ -21,8 +21,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
21 21
 #include <stddef.h>
22 22
 #include <string.h>
23 23
 #include <assert.h>
24
+#include <errno.h>
24 25
 #include <byteswap.h>
25 26
 #include <gpxe/blockdev.h>
27
+#include <gpxe/process.h>
26 28
 #include <gpxe/ata.h>
27 29
 
28 30
 /** @file
@@ -45,13 +47,34 @@ block_to_ata ( struct block_device *blockdev ) {
45 47
  */
46 48
 static inline __attribute__ (( always_inline )) int
47 49
 ata_command ( struct ata_device *ata, struct ata_command *command ) {
50
+	int rc;
51
+
48 52
 	DBG ( "ATA cmd %02x dev %02x LBA%s %llx count %04x\n",
49 53
 	      command->cb.cmd_stat, command->cb.device,
50 54
 	      ( command->cb.lba48 ? "48" : "" ),
51 55
 	      ( unsigned long long ) command->cb.lba.native,
52 56
 	      command->cb.count.native );
53 57
 
54
-	return ata->command ( ata, command );	
58
+	/* Flag command as in-progress */
59
+	command->rc = -EINPROGRESS;
60
+
61
+	/* Issue ATA command */
62
+	if ( ( rc = ata->command ( ata, command ) ) != 0 ) {
63
+		/* Something went wrong with the issuing mechanism */
64
+		DBG ( "ATA could not issue command: %s\n", strerror ( rc ) );
65
+		return rc;
66
+	}
67
+
68
+	/* Wait for command to complete */
69
+	while ( command->rc == -EINPROGRESS )
70
+		step();
71
+	if ( ( rc = command->rc ) != 0 ) {
72
+		/* Something went wrong with the command execution */
73
+		DBG ( "ATA command failed: %s\n", strerror ( rc ) );
74
+		return rc;
75
+	}
76
+
77
+	return 0;
55 78
 }
56 79
 
57 80
 /**

+ 2
- 0
src/include/gpxe/ata.h Datei anzeigen

@@ -154,6 +154,8 @@ struct ata_command {
154 154
 	 * sectors in size.
155 155
 	 */
156 156
 	userptr_t data_in;
157
+	/** Command status code */
158
+	int rc;
157 159
 };
158 160
 
159 161
 /**

+ 1
- 0
src/include/gpxe/errfile.h Datei anzeigen

@@ -115,6 +115,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
115 115
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )
116 116
 #define ERRFILE_hermon		     ( ERRFILE_DRIVER | 0x00720000 )
117 117
 #define ERRFILE_linda		     ( ERRFILE_DRIVER | 0x00730000 )
118
+#define ERRFILE_ata		     ( ERRFILE_DRIVER | 0x00740000 )
118 119
 
119 120
 #define ERRFILE_aoe			( ERRFILE_NET | 0x00000000 )
120 121
 #define ERRFILE_arp			( ERRFILE_NET | 0x00010000 )

+ 2
- 8
src/net/aoe.c Datei anzeigen

@@ -68,6 +68,7 @@ static void aoe_done ( struct aoe_session *aoe, int rc ) {
68 68
 	/* Record overall command status */
69 69
 	if ( aoe->command ) {
70 70
 		aoe->command->cb.cmd_stat = aoe->status;
71
+		aoe->command->rc = rc;
71 72
 		aoe->command = NULL;
72 73
 	}
73 74
 
@@ -356,7 +357,6 @@ static int aoe_command ( struct ata_device *ata,
356 357
 			 struct ata_command *command ) {
357 358
 	struct aoe_session *aoe =
358 359
 		container_of ( ata->backend, struct aoe_session, refcnt );
359
-	int rc;
360 360
 
361 361
 	aoe->command = command;
362 362
 	aoe->status = 0;
@@ -365,15 +365,9 @@ static int aoe_command ( struct ata_device *ata,
365 365
 
366 366
 	aoe_send_command ( aoe );
367 367
 
368
-	aoe->rc = -EINPROGRESS;
369
-	while ( aoe->rc == -EINPROGRESS )
370
-		step();
371
-	rc = aoe->rc;
372
-
373
-	return rc;
368
+	return 0;
374 369
 }
375 370
 
376
-
377 371
 /**
378 372
  * Issue AoE config query for AoE target discovery
379 373
  *

Laden…
Abbrechen
Speichern