Selaa lähdekoodia

[usb] Use generic refill framework for USB hub interrupt endpoints

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 vuotta sitten
vanhempi
commit
ebe433e795
2 muutettua tiedostoa jossa 7 lisäystä ja 51 poistoa
  1. 7
    49
      src/drivers/usb/usbhub.c
  2. 0
    2
      src/drivers/usb/usbhub.h

+ 7
- 49
src/drivers/usb/usbhub.c Näytä tiedosto

40
  * @v hubdev		Hub device
40
  * @v hubdev		Hub device
41
  */
41
  */
42
 static void hub_refill ( struct usb_hub_device *hubdev ) {
42
 static void hub_refill ( struct usb_hub_device *hubdev ) {
43
-	struct io_buffer *iobuf;
44
-	size_t mtu = hubdev->intr.mtu;
45
 	int rc;
43
 	int rc;
46
 
44
 
47
-	/* Enqueue any available I/O buffers */
48
-	while ( ( iobuf = list_first_entry ( &hubdev->intrs, struct io_buffer,
49
-					     list ) ) ) {
50
-
51
-		/* Reset size */
52
-		iob_put ( iobuf, ( mtu - iob_len ( iobuf ) ) );
53
-
54
-		/* Enqueue I/O buffer */
55
-		if ( ( rc = usb_stream ( &hubdev->intr, iobuf, 0 ) ) != 0 ) {
56
-			DBGC ( hubdev, "HUB %s could not enqueue interrupt: "
57
-			       "%s\n", hubdev->name, strerror ( rc ) );
58
-			/* Leave in available list and wait for next refill */
59
-			return;
60
-		}
61
-
62
-		/* Remove from available list */
63
-		list_del ( &iobuf->list );
45
+	/* Refill interrupt endpoint */
46
+	if ( ( rc = usb_refill ( &hubdev->intr ) ) != 0 ) {
47
+		DBGC ( hubdev, "HUB %s could not refill interrupt: %s\n",
48
+		       hubdev->name, strerror ( rc ) );
49
+		/* Continue attempting to refill */
50
+		return;
64
 	}
51
 	}
65
 
52
 
66
 	/* Stop refill process */
53
 	/* Stop refill process */
119
 	}
106
 	}
120
 
107
 
121
  done:
108
  done:
122
-	/* Return I/O buffer to available list */
123
-	list_add_tail ( &iobuf->list, &hubdev->intrs );
124
-
125
 	/* Start refill process */
109
 	/* Start refill process */
126
 	process_add ( &hubdev->refill );
110
 	process_add ( &hubdev->refill );
127
 }
111
 }
140
 static int hub_open ( struct usb_hub *hub ) {
124
 static int hub_open ( struct usb_hub *hub ) {
141
 	struct usb_hub_device *hubdev = usb_hub_get_drvdata ( hub );
125
 	struct usb_hub_device *hubdev = usb_hub_get_drvdata ( hub );
142
 	struct usb_device *usb = hubdev->usb;
126
 	struct usb_device *usb = hubdev->usb;
143
-	struct io_buffer *iobuf;
144
-	struct io_buffer *tmp;
145
 	unsigned int i;
127
 	unsigned int i;
146
 	int rc;
128
 	int rc;
147
 
129
 
156
 		}
138
 		}
157
 	}
139
 	}
158
 
140
 
159
-	/* Allocate I/O buffers */
160
-	for ( i = 0 ; i < USB_HUB_INTR_FILL ; i++ ) {
161
-		iobuf = alloc_iob ( hubdev->intr.mtu );
162
-		if ( ! iobuf ) {
163
-			rc = -ENOMEM;
164
-			goto err_alloc_iob;
165
-		}
166
-		list_add ( &iobuf->list, &hubdev->intrs );
167
-	}
168
-
169
 	/* Open interrupt endpoint */
141
 	/* Open interrupt endpoint */
170
 	if ( ( rc = usb_endpoint_open ( &hubdev->intr ) ) != 0 ) {
142
 	if ( ( rc = usb_endpoint_open ( &hubdev->intr ) ) != 0 ) {
171
 		DBGC ( hubdev, "HUB %s could not register interrupt: %s\n",
143
 		DBGC ( hubdev, "HUB %s could not register interrupt: %s\n",
183
 
155
 
184
 	usb_endpoint_close ( &hubdev->intr );
156
 	usb_endpoint_close ( &hubdev->intr );
185
  err_open:
157
  err_open:
186
- err_alloc_iob:
187
-	list_for_each_entry_safe ( iobuf, tmp, &hubdev->intrs, list ) {
188
-		list_del ( &iobuf->list );
189
-		free_iob ( iobuf );
190
-	}
191
  err_power:
158
  err_power:
192
 	return rc;
159
 	return rc;
193
 }
160
 }
199
  */
166
  */
200
 static void hub_close ( struct usb_hub *hub ) {
167
 static void hub_close ( struct usb_hub *hub ) {
201
 	struct usb_hub_device *hubdev = usb_hub_get_drvdata ( hub );
168
 	struct usb_hub_device *hubdev = usb_hub_get_drvdata ( hub );
202
-	struct io_buffer *iobuf;
203
-	struct io_buffer *tmp;
204
 
169
 
205
 	/* Close interrupt endpoint */
170
 	/* Close interrupt endpoint */
206
 	usb_endpoint_close ( &hubdev->intr );
171
 	usb_endpoint_close ( &hubdev->intr );
207
 
172
 
208
 	/* Stop refill process */
173
 	/* Stop refill process */
209
 	process_del ( &hubdev->refill );
174
 	process_del ( &hubdev->refill );
210
-
211
-	/* Free I/O buffers */
212
-	list_for_each_entry_safe ( iobuf, tmp, &hubdev->intrs, list ) {
213
-		list_del ( &iobuf->list );
214
-		free_iob ( iobuf );
215
-	}
216
 }
175
 }
217
 
176
 
218
 /**
177
 /**
415
 	hubdev->features =
374
 	hubdev->features =
416
 		( enhanced ? USB_HUB_FEATURES_ENHANCED : USB_HUB_FEATURES );
375
 		( enhanced ? USB_HUB_FEATURES_ENHANCED : USB_HUB_FEATURES );
417
 	usb_endpoint_init ( &hubdev->intr, usb, &usb_hub_intr_operations );
376
 	usb_endpoint_init ( &hubdev->intr, usb, &usb_hub_intr_operations );
418
-	INIT_LIST_HEAD ( &hubdev->intrs );
377
+	usb_refill_init ( &hubdev->intr, 0, USB_HUB_INTR_FILL );
419
 	process_init_stopped ( &hubdev->refill, &hub_refill_desc, NULL );
378
 	process_init_stopped ( &hubdev->refill, &hub_refill_desc, NULL );
420
 
379
 
421
 	/* Locate hub interface descriptor */
380
 	/* Locate hub interface descriptor */
510
 	/* Unregister hub */
469
 	/* Unregister hub */
511
 	unregister_usb_hub ( hubdev->hub );
470
 	unregister_usb_hub ( hubdev->hub );
512
 	assert ( ! process_running ( &hubdev->refill ) );
471
 	assert ( ! process_running ( &hubdev->refill ) );
513
-	assert ( list_empty ( &hubdev->intrs ) );
514
 
472
 
515
 	/* Free hub */
473
 	/* Free hub */
516
 	free_usb_hub ( hubdev->hub );
474
 	free_usb_hub ( hubdev->hub );

+ 0
- 2
src/drivers/usb/usbhub.h Näytä tiedosto

227
 
227
 
228
 	/** Interrupt endpoint */
228
 	/** Interrupt endpoint */
229
 	struct usb_endpoint intr;
229
 	struct usb_endpoint intr;
230
-	/** Recycled interrupt I/O buffers */
231
-	struct list_head intrs;
232
 	/** Interrupt endpoint refill process */
230
 	/** Interrupt endpoint refill process */
233
 	struct process refill;
231
 	struct process refill;
234
 };
232
 };

Loading…
Peruuta
Tallenna