1 diff -ur linux.old/drivers/scsi/hosts.c linux.dev/drivers/scsi/hosts.c
2 --- linux.old/drivers/scsi/hosts.c 2003-06-13 16:51:36.000000000 +0200
3 +++ linux.dev/drivers/scsi/hosts.c 2006-07-30 12:34:30.000000000 +0200
5 if (shn) shn->host_registered = 0;
6 /* else {} : This should not happen, we should panic here... */
8 + /* If we are removing the last host registered, it is safe to reuse
9 + * its host number (this avoids "holes" at boot time) (DB)
10 + * It is also safe to reuse those of numbers directly below which have
11 + * been released earlier (to avoid some holes in numbering).
13 + if(sh->host_no == max_scsi_hosts - 1) {
14 + while(--max_scsi_hosts >= next_scsi_host) {
15 + shpnt = scsi_hostlist;
16 + while(shpnt && shpnt->host_no != max_scsi_hosts - 1)
17 + shpnt = shpnt->next;
27 diff -ur linux.old/drivers/usb/hcd.c linux.dev/drivers/usb/hcd.c
28 --- linux.old/drivers/usb/hcd.c 2004-04-14 15:05:32.000000000 +0200
29 +++ linux.dev/drivers/usb/hcd.c 2006-07-30 11:49:06.000000000 +0200
33 allowed |= USB_DISABLE_SPD | USB_QUEUE_BULK
34 - | USB_ZERO_PACKET | URB_NO_INTERRUPT;
35 + | USB_ZERO_PACKET | URB_NO_INTERRUPT
36 + | URB_NO_TRANSFER_DMA_MAP;
39 allowed |= USB_DISABLE_SPD;
42 sizeof (struct usb_ctrlrequest),
44 - if (urb->transfer_buffer_length != 0)
45 + if (urb->transfer_buffer_length != 0
46 + && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
47 urb->transfer_dma = pci_map_single (
50 diff -ur linux.old/drivers/usb/host/ehci-hcd.c linux.dev/drivers/usb/host/ehci-hcd.c
51 --- linux.old/drivers/usb/host/ehci-hcd.c 2006-07-30 11:31:57.000000000 +0200
52 +++ linux.dev/drivers/usb/host/ehci-hcd.c 2006-07-30 11:48:14.000000000 +0200
54 ehci_mem_cleanup (ehci);
62 + pci_read_config_dword (ehci->hcd.pdev, PCI_VENDOR_ID, &vendor_id);
63 + if (vendor_id == 0x31041106) {
65 + printk(KERN_INFO "EHCI: Enabling VIA 6212 workarounds\n", misc_reg);
66 + pci_read_config_byte(ehci->hcd.pdev, 0x49, &misc_reg);
68 + pci_write_config_byte(ehci->hcd.pdev, 0x49, misc_reg);
69 + pci_read_config_byte(ehci->hcd.pdev, 0x49, &misc_reg);
71 + pci_read_config_byte(ehci->hcd.pdev, 0x4b, &misc_reg);
73 + pci_write_config_byte(ehci->hcd.pdev, 0x4b, misc_reg);
74 + pci_read_config_byte(ehci->hcd.pdev, 0x4b, &misc_reg);
78 writel (INTR_MASK, &ehci->regs->intr_enable);
79 writel (ehci->periodic_dma, &ehci->regs->frame_list);
81 diff -ur linux.old/drivers/usb/host/ehci-q.c linux.dev/drivers/usb/host/ehci-q.c
82 --- linux.old/drivers/usb/host/ehci-q.c 2006-07-30 11:31:57.000000000 +0200
83 +++ linux.dev/drivers/usb/host/ehci-q.c 2006-07-30 12:10:15.000000000 +0200
85 writel (cmd, &ehci->regs->command);
86 ehci->hcd.state = USB_STATE_RUNNING;
87 /* posted write need not be known to HC yet ... */
89 + timer_action (ehci, TIMER_IO_WATCHDOG);
93 diff -ur linux.old/drivers/usb/host/usb-uhci.c linux.dev/drivers/usb/host/usb-uhci.c
94 --- linux.old/drivers/usb/host/usb-uhci.c 2004-11-17 12:54:21.000000000 +0100
95 +++ linux.dev/drivers/usb/host/usb-uhci.c 2006-07-30 12:10:16.000000000 +0200
97 ((urb_priv_t*)urb->hcpriv)->flags=0;
100 - if ((urb->status != -ECONNABORTED) && (urb->status != ECONNRESET) &&
101 + if ((urb->status != -ECONNABORTED) && (urb->status != -ECONNRESET) &&
102 (urb->status != -ENOENT)) {
104 urb->status = -EINPROGRESS;
105 @@ -3034,6 +3034,21 @@
113 + pci_read_config_dword (dev, PCI_VENDOR_ID, &vendor_id);
114 + if (vendor_id == 0x30381106) {
116 + printk(KERN_INFO "UHCI: Enabling VIA 6212 workarounds\n");
117 + pci_read_config_byte(dev, 0x41, &misc_reg);
119 + pci_write_config_byte(dev, 0x41, misc_reg);
120 + pci_read_config_byte(dev, 0x41, &misc_reg);
124 /* Search for the IO base address.. */
125 for (i = 0; i < 6; i++) {
127 diff -ur linux.old/drivers/usb/storage/transport.c linux.dev/drivers/usb/storage/transport.c
128 --- linux.old/drivers/usb/storage/transport.c 2005-04-04 03:42:19.000000000 +0200
129 +++ linux.dev/drivers/usb/storage/transport.c 2006-07-30 12:22:56.000000000 +0200
131 #include <linux/sched.h>
132 #include <linux/errno.h>
133 #include <linux/slab.h>
134 +#include <linux/pci.h>
137 +/* These definitions mirror those in pci.h, so they can be used
138 + * interchangeably with their PCI_ counterparts */
139 +enum dma_data_direction {
140 + DMA_BIDIRECTIONAL = 0,
142 + DMA_FROM_DEVICE = 2,
146 +#define dma_map_sg(d,s,n,dir) pci_map_sg(d,s,n,dir)
147 +#define dma_unmap_sg(d,s,n,dir) pci_unmap_sg(d,s,n,dir)
151 /***********************************************************************
153 @@ -554,6 +570,543 @@
154 return US_BULK_TRANSFER_SHORT;
157 +/*-------------------------------------------------------------------*/
159 + * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist
160 + * @dev: device to which the scatterlist will be mapped
161 + * @pipe: endpoint defining the mapping direction
162 + * @sg: the scatterlist to unmap
163 + * @n_hw_ents: the positive return value from usb_buffer_map_sg
165 + * Reverses the effect of usb_buffer_map_sg().
167 +static void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
168 + struct scatterlist *sg, int n_hw_ents)
170 + struct usb_bus *bus;
171 + struct usb_hcd *hcd;
172 + struct pci_dev *pdev;
175 + || !(bus = dev->bus)
176 + || !(hcd = bus->hcpriv)
177 + || !(pdev = hcd->pdev)
178 + || !pdev->dma_mask)
181 + dma_unmap_sg (pdev, sg, n_hw_ents,
182 + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
186 + * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
187 + * @dev: device to which the scatterlist will be mapped
188 + * @pipe: endpoint defining the mapping direction
189 + * @sg: the scatterlist to map
190 + * @nents: the number of entries in the scatterlist
192 + * Return value is either < 0 (indicating no buffers could be mapped), or
193 + * the number of DMA mapping array entries in the scatterlist.
195 + * The caller is responsible for placing the resulting DMA addresses from
196 + * the scatterlist into URB transfer buffer pointers, and for setting the
197 + * URB_NO_TRANSFER_DMA_MAP transfer flag in each of those URBs.
199 + * Top I/O rates come from queuing URBs, instead of waiting for each one
200 + * to complete before starting the next I/O. This is particularly easy
201 + * to do with scatterlists. Just allocate and submit one URB for each DMA
202 + * mapping entry returned, stopping on the first error or when all succeed.
203 + * Better yet, use the usb_sg_*() calls, which do that (and more) for you.
205 + * This call would normally be used when translating scatterlist requests,
206 + * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it
207 + * may be able to coalesce mappings for improved I/O efficiency.
209 + * Reverse the effect of this call with usb_buffer_unmap_sg().
211 +static int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
212 + struct scatterlist *sg, int nents)
214 + struct usb_bus *bus;
215 + struct usb_hcd *hcd;
216 + struct pci_dev *pdev;
219 + || usb_pipecontrol (pipe)
220 + || !(bus = dev->bus)
221 + || !(hcd = bus->hcpriv)
222 + || !(pdev = hcd->pdev)
223 + || !pdev->dma_mask)
226 + // FIXME generic api broken like pci, can't report errors
227 + return dma_map_sg (pdev, sg, nents,
228 + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
231 +static void sg_clean (struct usb_sg_request *io)
233 + struct usb_hcd *hcd = io->dev->bus->hcpriv;
234 + struct pci_dev *pdev = hcd->pdev;
237 + while (io->entries--)
238 + usb_free_urb (io->urbs [io->entries]);
242 + if (pdev->dma_mask != 0)
243 + usb_buffer_unmap_sg (io->dev, io->pipe, io->sg, io->nents);
247 +static void sg_complete (struct urb *urb)
249 + struct usb_sg_request *io = (struct usb_sg_request *) urb->context;
251 + spin_lock (&io->lock);
253 + /* In 2.5 we require hcds' endpoint queues not to progress after fault
254 + * reports, until the completion callback (this!) returns. That lets
255 + * device driver code (like this routine) unlink queued urbs first,
256 + * if it needs to, since the HC won't work on them at all. So it's
257 + * not possible for page N+1 to overwrite page N, and so on.
259 + * That's only for "hard" faults; "soft" faults (unlinks) sometimes
260 + * complete before the HCD can get requests away from hardware,
261 + * though never during cleanup after a hard fault.
264 + && (io->status != -ECONNRESET
265 + || urb->status != -ECONNRESET)
266 + && urb->actual_length) {
267 + US_DEBUGP("Error: %s ep%d%s scatterlist error %d/%d\n",
269 + usb_pipeendpoint (urb->pipe),
270 + usb_pipein (urb->pipe) ? "in" : "out",
271 + urb->status, io->status);
275 + if (urb->status && urb->status != -ECONNRESET) {
276 + int i, found, status;
278 + io->status = urb->status;
280 + /* the previous urbs, and this one, completed already.
281 + * unlink pending urbs so they won't rx/tx bad data.
283 + for (i = 0, found = 0; i < io->entries; i++) {
287 + status = usb_unlink_urb (io->urbs [i]);
288 + if (status != -EINPROGRESS && status != -EBUSY)
289 + US_DEBUGP("Error: %s, unlink --> %d\n", __FUNCTION__, status);
290 + } else if (urb == io->urbs [i])
296 + /* on the last completion, signal usb_sg_wait() */
297 + io->bytes += urb->actual_length;
300 + complete (&io->complete);
302 + spin_unlock (&io->lock);
306 + * usb_sg_init - initializes scatterlist-based bulk/interrupt I/O request
307 + * @io: request block being initialized. until usb_sg_wait() returns,
308 + * treat this as a pointer to an opaque block of memory,
309 + * @dev: the usb device that will send or receive the data
310 + * @pipe: endpoint "pipe" used to transfer the data
311 + * @period: polling rate for interrupt endpoints, in frames or
312 + * (for high speed endpoints) microframes; ignored for bulk
313 + * @sg: scatterlist entries
314 + * @nents: how many entries in the scatterlist
315 + * @length: how many bytes to send from the scatterlist, or zero to
316 + * send every byte identified in the list.
317 + * @mem_flags: SLAB_* flags affecting memory allocations in this call
319 + * Returns zero for success, else a negative errno value. This initializes a
320 + * scatter/gather request, allocating resources such as I/O mappings and urb
321 + * memory (except maybe memory used by USB controller drivers).
323 + * The request must be issued using usb_sg_wait(), which waits for the I/O to
324 + * complete (or to be canceled) and then cleans up all resources allocated by
327 + * The request may be canceled with usb_sg_cancel(), either before or after
328 + * usb_sg_wait() is called.
331 + struct usb_sg_request *io,
332 + struct usb_device *dev,
335 + struct scatterlist *sg,
344 + struct usb_hcd *hcd;
346 + hcd = dev->bus->hcpriv;
348 + if (!io || !dev || !sg
349 + || usb_pipecontrol (pipe)
350 + || usb_pipeisoc (pipe)
354 + spin_lock_init (&io->lock);
360 + /* not all host controllers use DMA (like the mainstream pci ones);
361 + * they can use PIO (sl811) or be software over another transport.
363 + dma = (hcd->pdev->dma_mask != 0);
365 + io->entries = usb_buffer_map_sg (dev, pipe, sg, nents);
367 + io->entries = nents;
369 + /* initialize all the urbs we'll use */
370 + if (io->entries <= 0)
371 + return io->entries;
374 + io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags);
378 + urb_flags = USB_ASYNC_UNLINK | URB_NO_INTERRUPT | URB_NO_TRANSFER_DMA_MAP;
379 + if (usb_pipein (pipe))
380 + urb_flags |= URB_SHORT_NOT_OK;
382 + for (i = 0; i < io->entries; i++, io->count = i) {
385 + io->urbs [i] = usb_alloc_urb (0);
386 + if (!io->urbs [i]) {
391 + io->urbs [i]->dev = 0;
392 + io->urbs [i]->pipe = pipe;
393 + io->urbs [i]->interval = period;
394 + io->urbs [i]->transfer_flags = urb_flags;
396 + io->urbs [i]->complete = sg_complete;
397 + io->urbs [i]->context = io;
398 + io->urbs [i]->status = -EINPROGRESS;
399 + io->urbs [i]->actual_length = 0;
402 + /* hc may use _only_ transfer_dma */
403 + io->urbs [i]->transfer_dma = sg_dma_address (sg + i);
404 + len = sg_dma_len (sg + i);
406 + /* hc may use _only_ transfer_buffer */
407 + io->urbs [i]->transfer_buffer =
408 + page_address (sg [i].page) + sg [i].offset;
409 + len = sg [i].length;
413 + len = min_t (unsigned, len, length);
416 + io->entries = i + 1;
418 + io->urbs [i]->transfer_buffer_length = len;
420 + io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT;
422 + /* transaction state */
425 + init_completion (&io->complete);
434 + * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait()
435 + * @io: request block, initialized with usb_sg_init()
437 + * This stops a request after it has been started by usb_sg_wait().
438 + * It can also prevents one initialized by usb_sg_init() from starting,
439 + * so that call just frees resources allocated to the request.
441 +void usb_sg_cancel (struct usb_sg_request *io)
443 + unsigned long flags;
445 + spin_lock_irqsave (&io->lock, flags);
447 + /* shut everything down, if it didn't already */
451 + io->status = -ECONNRESET;
452 + for (i = 0; i < io->entries; i++) {
455 + if (!io->urbs [i]->dev)
457 + retval = usb_unlink_urb (io->urbs [i]);
458 + if (retval != -EINPROGRESS && retval != -EBUSY)
459 + US_DEBUGP("WARNING: %s, unlink --> %d\n", __FUNCTION__, retval);
462 + spin_unlock_irqrestore (&io->lock, flags);
466 + * usb_sg_wait - synchronously execute scatter/gather request
467 + * @io: request block handle, as initialized with usb_sg_init().
468 + * some fields become accessible when this call returns.
469 + * Context: !in_interrupt ()
471 + * This function blocks until the specified I/O operation completes. It
472 + * leverages the grouping of the related I/O requests to get good transfer
473 + * rates, by queueing the requests. At higher speeds, such queuing can
474 + * significantly improve USB throughput.
476 + * There are three kinds of completion for this function.
477 + * (1) success, where io->status is zero. The number of io->bytes
478 + * transferred is as requested.
479 + * (2) error, where io->status is a negative errno value. The number
480 + * of io->bytes transferred before the error is usually less
481 + * than requested, and can be nonzero.
482 + * (3) cancelation, a type of error with status -ECONNRESET that
483 + * is initiated by usb_sg_cancel().
485 + * When this function returns, all memory allocated through usb_sg_init() or
486 + * this call will have been freed. The request block parameter may still be
487 + * passed to usb_sg_cancel(), or it may be freed. It could also be
488 + * reinitialized and then reused.
490 + * Data Transfer Rates:
492 + * Bulk transfers are valid for full or high speed endpoints.
493 + * The best full speed data rate is 19 packets of 64 bytes each
494 + * per frame, or 1216 bytes per millisecond.
495 + * The best high speed data rate is 13 packets of 512 bytes each
496 + * per microframe, or 52 KBytes per millisecond.
498 + * The reason to use interrupt transfers through this API would most likely
499 + * be to reserve high speed bandwidth, where up to 24 KBytes per millisecond
500 + * could be transferred. That capability is less useful for low or full
501 + * speed interrupt endpoints, which allow at most one packet per millisecond,
502 + * of at most 8 or 64 bytes (respectively).
504 +void usb_sg_wait (struct usb_sg_request *io)
506 + int i, entries = io->entries;
508 + /* queue the urbs. */
509 + spin_lock_irq (&io->lock);
510 + for (i = 0; i < entries && !io->status; i++) {
513 + io->urbs [i]->dev = io->dev;
514 + retval = usb_submit_urb (io->urbs [i]);
516 + /* after we submit, let completions or cancelations fire;
517 + * we handshake using io->status.
519 + spin_unlock_irq (&io->lock);
521 + /* maybe we retrying will recover */
522 + case -ENXIO: // hc didn't queue this one
525 + io->urbs [i]->dev = 0;
531 + /* no error? continue immediately.
533 + * NOTE: to work better with UHCI (4K I/O buffer may
534 + * need 3K of TDs) it may be good to limit how many
535 + * URBs are queued at once; N milliseconds?
541 + /* fail any uncompleted urbs */
543 + spin_lock_irq (&io->lock);
544 + io->count -= entries - i;
545 + if (io->status == -EINPROGRESS)
546 + io->status = retval;
547 + if (io->count == 0)
548 + complete (&io->complete);
549 + spin_unlock_irq (&io->lock);
551 + io->urbs [i]->dev = 0;
552 + io->urbs [i]->status = retval;
554 + US_DEBUGP("%s, submit --> %d\n", __FUNCTION__, retval);
555 + usb_sg_cancel (io);
557 + spin_lock_irq (&io->lock);
558 + if (retval && io->status == -ECONNRESET)
559 + io->status = retval;
561 + spin_unlock_irq (&io->lock);
563 + /* OK, yes, this could be packaged as non-blocking.
564 + * So could the submit loop above ... but it's easier to
565 + * solve neither problem than to solve both!
567 + wait_for_completion (&io->complete);
573 + * Interpret the results of a URB transfer
575 + * This function prints appropriate debugging messages, clears halts on
576 + * non-control endpoints, and translates the status to the corresponding
577 + * USB_STOR_XFER_xxx return code.
579 +static int interpret_urb_result(struct us_data *us, unsigned int pipe,
580 + unsigned int length, int result, unsigned int partial)
582 + US_DEBUGP("Status code %d; transferred %u/%u\n",
583 + result, partial, length);
586 + /* no error code; did we send all the data? */
588 + if (partial != length) {
589 + US_DEBUGP("-- short transfer\n");
590 + return USB_STOR_XFER_SHORT;
593 + US_DEBUGP("-- transfer complete\n");
594 + return USB_STOR_XFER_GOOD;
598 + /* for control endpoints, (used by CB[I]) a stall indicates
599 + * a failed command */
600 + if (usb_pipecontrol(pipe)) {
601 + US_DEBUGP("-- stall on control pipe\n");
602 + return USB_STOR_XFER_STALLED;
605 + /* for other sorts of endpoint, clear the stall */
606 + US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
607 + if (usb_stor_clear_halt(us, pipe) < 0)
608 + return USB_STOR_XFER_ERROR;
609 + return USB_STOR_XFER_STALLED;
611 + /* timeout or excessively long NAK */
613 + US_DEBUGP("-- timeout or NAK\n");
614 + return USB_STOR_XFER_ERROR;
616 + /* babble - the device tried to send more than we wanted to read */
618 + US_DEBUGP("-- babble\n");
619 + return USB_STOR_XFER_LONG;
621 + /* the transfer was cancelled by abort, disconnect, or timeout */
623 + US_DEBUGP("-- transfer cancelled\n");
624 + return USB_STOR_XFER_ERROR;
626 + /* short scatter-gather read transfer */
628 + US_DEBUGP("-- short read transfer\n");
629 + return USB_STOR_XFER_SHORT;
631 + /* abort or disconnect in progress */
633 + US_DEBUGP("-- abort or disconnect in progress\n");
634 + return USB_STOR_XFER_ERROR;
636 + /* the catch-all error case */
638 + US_DEBUGP("-- unknown error\n");
639 + return USB_STOR_XFER_ERROR;
644 + * Transfer a scatter-gather list via bulk transfer
646 + * This function does basically the same thing as usb_stor_bulk_msg()
647 + * above, but it uses the usbcore scatter-gather library.
649 +int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
650 + struct scatterlist *sg, int num_sg, unsigned int length,
651 + unsigned int *act_len)
655 + /* don't submit s-g requests during abort/disconnect processing */
656 + if (us->flags & ABORTING_OR_DISCONNECTING)
657 + return USB_STOR_XFER_ERROR;
659 + /* initialize the scatter-gather request block */
660 + US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
662 + result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
663 + sg, num_sg, length, SLAB_NOIO);
665 + US_DEBUGP("usb_sg_init returned %d\n", result);
666 + return USB_STOR_XFER_ERROR;
669 + /* since the block has been initialized successfully, it's now
670 + * okay to cancel it */
671 + set_bit(US_FLIDX_SG_ACTIVE, &us->flags);
673 + /* did an abort/disconnect occur during the submission? */
674 + if (us->flags & ABORTING_OR_DISCONNECTING) {
676 + /* cancel the request, if it hasn't been cancelled already */
677 + if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->flags)) {
678 + US_DEBUGP("-- cancelling sg request\n");
679 + usb_sg_cancel(&us->current_sg);
683 + /* wait for the completion of the transfer */
684 + usb_sg_wait(&us->current_sg);
685 + clear_bit(US_FLIDX_SG_ACTIVE, &us->flags);
687 + result = us->current_sg.status;
689 + *act_len = us->current_sg.bytes;
690 + return interpret_urb_result(us, pipe, length, result,
691 + us->current_sg.bytes);
695 * Transfer an entire SCSI command's worth of data payload over the bulk
698 struct scatterlist *sg;
699 unsigned int total_transferred = 0;
700 unsigned int transfer_amount;
701 + unsigned int partial;
704 /* calculate how much we want to transfer */
705 transfer_amount = usb_stor_transfer_length(srb);
706 @@ -585,23 +1140,34 @@
707 * make the appropriate requests for each, until done
709 sg = (struct scatterlist *) srb->request_buffer;
710 - for (i = 0; i < srb->use_sg; i++) {
712 - /* transfer the lesser of the next buffer or the
713 - * remaining data */
714 - if (transfer_amount - total_transferred >=
716 - result = usb_stor_transfer_partial(us,
717 - sg[i].address, sg[i].length);
718 - total_transferred += sg[i].length;
720 - result = usb_stor_transfer_partial(us,
722 - transfer_amount - total_transferred);
724 - /* if we get an error, end the loop here */
727 + if (us->pusb_dev->speed == USB_SPEED_HIGH) {
728 + /* calculate the appropriate pipe information */
729 + if (us->srb->sc_data_direction == SCSI_DATA_READ)
730 + pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
732 + pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
733 + /* use the usb core scatter-gather primitives */
734 + result = usb_stor_bulk_transfer_sglist(us, pipe,
735 + sg, srb->use_sg, transfer_amount, &partial);
737 + for (i = 0; i < srb->use_sg; i++) {
739 + /* transfer the lesser of the next buffer or the
740 + * remaining data */
741 + if (transfer_amount - total_transferred >=
743 + result = usb_stor_transfer_partial(us,
744 + sg[i].address, sg[i].length);
745 + total_transferred += sg[i].length;
747 + result = usb_stor_transfer_partial(us,
749 + transfer_amount - total_transferred);
751 + /* if we get an error, end the loop here */
758 diff -ur linux.old/drivers/usb/storage/transport.h linux.dev/drivers/usb/storage/transport.h
759 --- linux.old/drivers/usb/storage/transport.h 2003-08-25 13:44:42.000000000 +0200
760 +++ linux.dev/drivers/usb/storage/transport.h 2006-07-30 12:10:16.000000000 +0200
762 #define US_BULK_TRANSFER_ABORTED 3 /* transfer canceled */
765 + * usb_stor_bulk_transfer_xxx() return codes, in order of severity
768 +#define USB_STOR_XFER_GOOD 0 /* good transfer */
769 +#define USB_STOR_XFER_SHORT 1 /* transferred less than expected */
770 +#define USB_STOR_XFER_STALLED 2 /* endpoint stalled */
771 +#define USB_STOR_XFER_LONG 3 /* device tried to send too much */
772 +#define USB_STOR_XFER_ERROR 4 /* transfer died in the middle */
775 * Transport return codes
778 diff -ur linux.old/drivers/usb/storage/usb.h linux.dev/drivers/usb/storage/usb.h
779 --- linux.old/drivers/usb/storage/usb.h 2005-04-04 03:42:20.000000000 +0200
780 +++ linux.dev/drivers/usb/storage/usb.h 2006-07-30 12:11:06.000000000 +0200
782 typedef void (*proto_cmnd)(Scsi_Cmnd*, struct us_data*);
783 typedef void (*extra_data_destructor)(void *); /* extra data destructor */
785 +/* Dynamic flag definitions: used in set_bit() etc. */
786 +#define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */
787 +#define US_FLIDX_SG_ACTIVE 19 /* 0x00080000 current_sg is in use */
788 +#define US_FLIDX_ABORTING 20 /* 0x00100000 abort is in progress */
789 +#define US_FLIDX_DISCONNECTING 21 /* 0x00200000 disconnect in progress */
790 +#define ABORTING_OR_DISCONNECTING ((1UL << US_FLIDX_ABORTING) | \
791 + (1UL << US_FLIDX_DISCONNECTING))
792 +#define US_FLIDX_RESETTING 22 /* 0x00400000 device reset in progress */
794 +/* processing state machine states */
795 +#define US_STATE_IDLE 1
796 +#define US_STATE_RUNNING 2
797 +#define US_STATE_RESETTING 3
798 +#define US_STATE_ABORTING 4
801 + * struct usb_sg_request - support for scatter/gather I/O
802 + * @status: zero indicates success, else negative errno
803 + * @bytes: counts bytes transferred.
805 + * These requests are initialized using usb_sg_init(), and then are used
806 + * as request handles passed to usb_sg_wait() or usb_sg_cancel(). Most
807 + * members of the request object aren't for driver access.
809 + * The status and bytecount values are valid only after usb_sg_wait()
810 + * returns. If the status is zero, then the bytecount matches the total
811 + * from the request.
813 + * After an error completion, drivers may need to clear a halt condition
816 +struct usb_sg_request {
821 + * members below are private to usbcore,
822 + * and are not provided for driver access!
826 + struct usb_device *dev;
828 + struct scatterlist *sg;
835 + struct completion complete;
839 /* we allocate one of these for every device that we remember */
841 struct us_data *next; /* next device */
843 struct urb *current_urb; /* non-int USB requests */
844 struct completion current_done; /* the done flag */
845 unsigned int tag; /* tag for bulk CBW/CSW */
846 + struct usb_sg_request current_sg; /* scatter-gather req. */
848 /* the semaphore for sleeping the control thread */
849 struct semaphore sema; /* to sleep thread on */
850 diff -ur linux.old/include/linux/usb.h linux.dev/include/linux/usb.h
851 --- linux.old/include/linux/usb.h 2004-11-17 12:54:22.000000000 +0100
852 +++ linux.dev/include/linux/usb.h 2006-07-30 12:19:19.000000000 +0200
854 #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */
855 /* ... less overhead for QUEUE_BULK */
856 #define USB_TIMEOUT_KILLED 0x1000 // only set by HCD!
857 +#define URB_NO_TRANSFER_DMA_MAP 0x0400 /* urb->transfer_dma valid on submit */
858 +#define URB_NO_SETUP_DMA_MAP 0x0800 /* urb->setup_dma valid on submit */
860 struct iso_packet_descriptor