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
96 @@ -3034,6 +3034,21 @@
104 + pci_read_config_dword (dev, PCI_VENDOR_ID, &vendor_id);
105 + if (vendor_id == 0x30381106) {
107 + printk(KERN_INFO "UHCI: Enabling VIA 6212 workarounds\n");
108 + pci_read_config_byte(dev, 0x41, &misc_reg);
110 + pci_write_config_byte(dev, 0x41, misc_reg);
111 + pci_read_config_byte(dev, 0x41, &misc_reg);
115 /* Search for the IO base address.. */
116 for (i = 0; i < 6; i++) {
118 diff -ur linux.old/drivers/usb/storage/transport.c linux.dev/drivers/usb/storage/transport.c
119 --- linux.old/drivers/usb/storage/transport.c 2005-04-04 03:42:19.000000000 +0200
120 +++ linux.dev/drivers/usb/storage/transport.c 2006-07-30 12:22:56.000000000 +0200
122 #include <linux/sched.h>
123 #include <linux/errno.h>
124 #include <linux/slab.h>
125 +#include <linux/pci.h>
128 +/* These definitions mirror those in pci.h, so they can be used
129 + * interchangeably with their PCI_ counterparts */
130 +enum dma_data_direction {
131 + DMA_BIDIRECTIONAL = 0,
133 + DMA_FROM_DEVICE = 2,
137 +#define dma_map_sg(d,s,n,dir) pci_map_sg(d,s,n,dir)
138 +#define dma_unmap_sg(d,s,n,dir) pci_unmap_sg(d,s,n,dir)
142 /***********************************************************************
144 @@ -554,6 +570,543 @@
145 return US_BULK_TRANSFER_SHORT;
148 +/*-------------------------------------------------------------------*/
150 + * usb_buffer_unmap_sg - free DMA mapping(s) for a scatterlist
151 + * @dev: device to which the scatterlist will be mapped
152 + * @pipe: endpoint defining the mapping direction
153 + * @sg: the scatterlist to unmap
154 + * @n_hw_ents: the positive return value from usb_buffer_map_sg
156 + * Reverses the effect of usb_buffer_map_sg().
158 +static void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
159 + struct scatterlist *sg, int n_hw_ents)
161 + struct usb_bus *bus;
162 + struct usb_hcd *hcd;
163 + struct pci_dev *pdev;
166 + || !(bus = dev->bus)
167 + || !(hcd = bus->hcpriv)
168 + || !(pdev = hcd->pdev)
169 + || !pdev->dma_mask)
172 + dma_unmap_sg (pdev, sg, n_hw_ents,
173 + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
177 + * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint
178 + * @dev: device to which the scatterlist will be mapped
179 + * @pipe: endpoint defining the mapping direction
180 + * @sg: the scatterlist to map
181 + * @nents: the number of entries in the scatterlist
183 + * Return value is either < 0 (indicating no buffers could be mapped), or
184 + * the number of DMA mapping array entries in the scatterlist.
186 + * The caller is responsible for placing the resulting DMA addresses from
187 + * the scatterlist into URB transfer buffer pointers, and for setting the
188 + * URB_NO_TRANSFER_DMA_MAP transfer flag in each of those URBs.
190 + * Top I/O rates come from queuing URBs, instead of waiting for each one
191 + * to complete before starting the next I/O. This is particularly easy
192 + * to do with scatterlists. Just allocate and submit one URB for each DMA
193 + * mapping entry returned, stopping on the first error or when all succeed.
194 + * Better yet, use the usb_sg_*() calls, which do that (and more) for you.
196 + * This call would normally be used when translating scatterlist requests,
197 + * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it
198 + * may be able to coalesce mappings for improved I/O efficiency.
200 + * Reverse the effect of this call with usb_buffer_unmap_sg().
202 +static int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
203 + struct scatterlist *sg, int nents)
205 + struct usb_bus *bus;
206 + struct usb_hcd *hcd;
207 + struct pci_dev *pdev;
210 + || usb_pipecontrol (pipe)
211 + || !(bus = dev->bus)
212 + || !(hcd = bus->hcpriv)
213 + || !(pdev = hcd->pdev)
214 + || !pdev->dma_mask)
217 + // FIXME generic api broken like pci, can't report errors
218 + return dma_map_sg (pdev, sg, nents,
219 + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
222 +static void sg_clean (struct usb_sg_request *io)
224 + struct usb_hcd *hcd = io->dev->bus->hcpriv;
225 + struct pci_dev *pdev = hcd->pdev;
228 + while (io->entries--)
229 + usb_free_urb (io->urbs [io->entries]);
233 + if (pdev->dma_mask != 0)
234 + usb_buffer_unmap_sg (io->dev, io->pipe, io->sg, io->nents);
238 +static void sg_complete (struct urb *urb)
240 + struct usb_sg_request *io = (struct usb_sg_request *) urb->context;
242 + spin_lock (&io->lock);
244 + /* In 2.5 we require hcds' endpoint queues not to progress after fault
245 + * reports, until the completion callback (this!) returns. That lets
246 + * device driver code (like this routine) unlink queued urbs first,
247 + * if it needs to, since the HC won't work on them at all. So it's
248 + * not possible for page N+1 to overwrite page N, and so on.
250 + * That's only for "hard" faults; "soft" faults (unlinks) sometimes
251 + * complete before the HCD can get requests away from hardware,
252 + * though never during cleanup after a hard fault.
255 + && (io->status != -ECONNRESET
256 + || urb->status != -ECONNRESET)
257 + && urb->actual_length) {
258 + US_DEBUGP("Error: %s ep%d%s scatterlist error %d/%d\n",
260 + usb_pipeendpoint (urb->pipe),
261 + usb_pipein (urb->pipe) ? "in" : "out",
262 + urb->status, io->status);
266 + if (urb->status && urb->status != -ECONNRESET) {
267 + int i, found, status;
269 + io->status = urb->status;
271 + /* the previous urbs, and this one, completed already.
272 + * unlink pending urbs so they won't rx/tx bad data.
274 + for (i = 0, found = 0; i < io->entries; i++) {
278 + status = usb_unlink_urb (io->urbs [i]);
279 + if (status != -EINPROGRESS && status != -EBUSY)
280 + US_DEBUGP("Error: %s, unlink --> %d\n", __FUNCTION__, status);
281 + } else if (urb == io->urbs [i])
287 + /* on the last completion, signal usb_sg_wait() */
288 + io->bytes += urb->actual_length;
291 + complete (&io->complete);
293 + spin_unlock (&io->lock);
297 + * usb_sg_init - initializes scatterlist-based bulk/interrupt I/O request
298 + * @io: request block being initialized. until usb_sg_wait() returns,
299 + * treat this as a pointer to an opaque block of memory,
300 + * @dev: the usb device that will send or receive the data
301 + * @pipe: endpoint "pipe" used to transfer the data
302 + * @period: polling rate for interrupt endpoints, in frames or
303 + * (for high speed endpoints) microframes; ignored for bulk
304 + * @sg: scatterlist entries
305 + * @nents: how many entries in the scatterlist
306 + * @length: how many bytes to send from the scatterlist, or zero to
307 + * send every byte identified in the list.
308 + * @mem_flags: SLAB_* flags affecting memory allocations in this call
310 + * Returns zero for success, else a negative errno value. This initializes a
311 + * scatter/gather request, allocating resources such as I/O mappings and urb
312 + * memory (except maybe memory used by USB controller drivers).
314 + * The request must be issued using usb_sg_wait(), which waits for the I/O to
315 + * complete (or to be canceled) and then cleans up all resources allocated by
318 + * The request may be canceled with usb_sg_cancel(), either before or after
319 + * usb_sg_wait() is called.
322 + struct usb_sg_request *io,
323 + struct usb_device *dev,
326 + struct scatterlist *sg,
335 + struct usb_hcd *hcd;
337 + hcd = dev->bus->hcpriv;
339 + if (!io || !dev || !sg
340 + || usb_pipecontrol (pipe)
341 + || usb_pipeisoc (pipe)
345 + spin_lock_init (&io->lock);
351 + /* not all host controllers use DMA (like the mainstream pci ones);
352 + * they can use PIO (sl811) or be software over another transport.
354 + dma = (hcd->pdev->dma_mask != 0);
356 + io->entries = usb_buffer_map_sg (dev, pipe, sg, nents);
358 + io->entries = nents;
360 + /* initialize all the urbs we'll use */
361 + if (io->entries <= 0)
362 + return io->entries;
365 + io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags);
369 + urb_flags = USB_ASYNC_UNLINK | URB_NO_INTERRUPT | URB_NO_TRANSFER_DMA_MAP;
370 + if (usb_pipein (pipe))
371 + urb_flags |= URB_SHORT_NOT_OK;
373 + for (i = 0; i < io->entries; i++, io->count = i) {
376 + io->urbs [i] = usb_alloc_urb (0);
377 + if (!io->urbs [i]) {
382 + io->urbs [i]->dev = 0;
383 + io->urbs [i]->pipe = pipe;
384 + io->urbs [i]->interval = period;
385 + io->urbs [i]->transfer_flags = urb_flags;
387 + io->urbs [i]->complete = sg_complete;
388 + io->urbs [i]->context = io;
389 + io->urbs [i]->status = -EINPROGRESS;
390 + io->urbs [i]->actual_length = 0;
393 + /* hc may use _only_ transfer_dma */
394 + io->urbs [i]->transfer_dma = sg_dma_address (sg + i);
395 + len = sg_dma_len (sg + i);
397 + /* hc may use _only_ transfer_buffer */
398 + io->urbs [i]->transfer_buffer =
399 + page_address (sg [i].page) + sg [i].offset;
400 + len = sg [i].length;
404 + len = min_t (unsigned, len, length);
407 + io->entries = i + 1;
409 + io->urbs [i]->transfer_buffer_length = len;
411 + io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT;
413 + /* transaction state */
416 + init_completion (&io->complete);
425 + * usb_sg_cancel - stop scatter/gather i/o issued by usb_sg_wait()
426 + * @io: request block, initialized with usb_sg_init()
428 + * This stops a request after it has been started by usb_sg_wait().
429 + * It can also prevents one initialized by usb_sg_init() from starting,
430 + * so that call just frees resources allocated to the request.
432 +void usb_sg_cancel (struct usb_sg_request *io)
434 + unsigned long flags;
436 + spin_lock_irqsave (&io->lock, flags);
438 + /* shut everything down, if it didn't already */
442 + io->status = -ECONNRESET;
443 + for (i = 0; i < io->entries; i++) {
446 + if (!io->urbs [i]->dev)
448 + retval = usb_unlink_urb (io->urbs [i]);
449 + if (retval != -EINPROGRESS && retval != -EBUSY)
450 + US_DEBUGP("WARNING: %s, unlink --> %d\n", __FUNCTION__, retval);
453 + spin_unlock_irqrestore (&io->lock, flags);
457 + * usb_sg_wait - synchronously execute scatter/gather request
458 + * @io: request block handle, as initialized with usb_sg_init().
459 + * some fields become accessible when this call returns.
460 + * Context: !in_interrupt ()
462 + * This function blocks until the specified I/O operation completes. It
463 + * leverages the grouping of the related I/O requests to get good transfer
464 + * rates, by queueing the requests. At higher speeds, such queuing can
465 + * significantly improve USB throughput.
467 + * There are three kinds of completion for this function.
468 + * (1) success, where io->status is zero. The number of io->bytes
469 + * transferred is as requested.
470 + * (2) error, where io->status is a negative errno value. The number
471 + * of io->bytes transferred before the error is usually less
472 + * than requested, and can be nonzero.
473 + * (3) cancelation, a type of error with status -ECONNRESET that
474 + * is initiated by usb_sg_cancel().
476 + * When this function returns, all memory allocated through usb_sg_init() or
477 + * this call will have been freed. The request block parameter may still be
478 + * passed to usb_sg_cancel(), or it may be freed. It could also be
479 + * reinitialized and then reused.
481 + * Data Transfer Rates:
483 + * Bulk transfers are valid for full or high speed endpoints.
484 + * The best full speed data rate is 19 packets of 64 bytes each
485 + * per frame, or 1216 bytes per millisecond.
486 + * The best high speed data rate is 13 packets of 512 bytes each
487 + * per microframe, or 52 KBytes per millisecond.
489 + * The reason to use interrupt transfers through this API would most likely
490 + * be to reserve high speed bandwidth, where up to 24 KBytes per millisecond
491 + * could be transferred. That capability is less useful for low or full
492 + * speed interrupt endpoints, which allow at most one packet per millisecond,
493 + * of at most 8 or 64 bytes (respectively).
495 +void usb_sg_wait (struct usb_sg_request *io)
497 + int i, entries = io->entries;
499 + /* queue the urbs. */
500 + spin_lock_irq (&io->lock);
501 + for (i = 0; i < entries && !io->status; i++) {
504 + io->urbs [i]->dev = io->dev;
505 + retval = usb_submit_urb (io->urbs [i]);
507 + /* after we submit, let completions or cancelations fire;
508 + * we handshake using io->status.
510 + spin_unlock_irq (&io->lock);
512 + /* maybe we retrying will recover */
513 + case -ENXIO: // hc didn't queue this one
516 + io->urbs [i]->dev = 0;
522 + /* no error? continue immediately.
524 + * NOTE: to work better with UHCI (4K I/O buffer may
525 + * need 3K of TDs) it may be good to limit how many
526 + * URBs are queued at once; N milliseconds?
532 + /* fail any uncompleted urbs */
534 + spin_lock_irq (&io->lock);
535 + io->count -= entries - i;
536 + if (io->status == -EINPROGRESS)
537 + io->status = retval;
538 + if (io->count == 0)
539 + complete (&io->complete);
540 + spin_unlock_irq (&io->lock);
542 + io->urbs [i]->dev = 0;
543 + io->urbs [i]->status = retval;
545 + US_DEBUGP("%s, submit --> %d\n", __FUNCTION__, retval);
546 + usb_sg_cancel (io);
548 + spin_lock_irq (&io->lock);
549 + if (retval && io->status == -ECONNRESET)
550 + io->status = retval;
552 + spin_unlock_irq (&io->lock);
554 + /* OK, yes, this could be packaged as non-blocking.
555 + * So could the submit loop above ... but it's easier to
556 + * solve neither problem than to solve both!
558 + wait_for_completion (&io->complete);
564 + * Interpret the results of a URB transfer
566 + * This function prints appropriate debugging messages, clears halts on
567 + * non-control endpoints, and translates the status to the corresponding
568 + * USB_STOR_XFER_xxx return code.
570 +static int interpret_urb_result(struct us_data *us, unsigned int pipe,
571 + unsigned int length, int result, unsigned int partial)
573 + US_DEBUGP("Status code %d; transferred %u/%u\n",
574 + result, partial, length);
577 + /* no error code; did we send all the data? */
579 + if (partial != length) {
580 + US_DEBUGP("-- short transfer\n");
581 + return USB_STOR_XFER_SHORT;
584 + US_DEBUGP("-- transfer complete\n");
585 + return USB_STOR_XFER_GOOD;
589 + /* for control endpoints, (used by CB[I]) a stall indicates
590 + * a failed command */
591 + if (usb_pipecontrol(pipe)) {
592 + US_DEBUGP("-- stall on control pipe\n");
593 + return USB_STOR_XFER_STALLED;
596 + /* for other sorts of endpoint, clear the stall */
597 + US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
598 + if (usb_stor_clear_halt(us, pipe) < 0)
599 + return USB_STOR_XFER_ERROR;
600 + return USB_STOR_XFER_STALLED;
602 + /* timeout or excessively long NAK */
604 + US_DEBUGP("-- timeout or NAK\n");
605 + return USB_STOR_XFER_ERROR;
607 + /* babble - the device tried to send more than we wanted to read */
609 + US_DEBUGP("-- babble\n");
610 + return USB_STOR_XFER_LONG;
612 + /* the transfer was cancelled by abort, disconnect, or timeout */
614 + US_DEBUGP("-- transfer cancelled\n");
615 + return USB_STOR_XFER_ERROR;
617 + /* short scatter-gather read transfer */
619 + US_DEBUGP("-- short read transfer\n");
620 + return USB_STOR_XFER_SHORT;
622 + /* abort or disconnect in progress */
624 + US_DEBUGP("-- abort or disconnect in progress\n");
625 + return USB_STOR_XFER_ERROR;
627 + /* the catch-all error case */
629 + US_DEBUGP("-- unknown error\n");
630 + return USB_STOR_XFER_ERROR;
635 + * Transfer a scatter-gather list via bulk transfer
637 + * This function does basically the same thing as usb_stor_bulk_msg()
638 + * above, but it uses the usbcore scatter-gather library.
640 +int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
641 + struct scatterlist *sg, int num_sg, unsigned int length,
642 + unsigned int *act_len)
646 + /* don't submit s-g requests during abort/disconnect processing */
647 + if (us->flags & ABORTING_OR_DISCONNECTING)
648 + return USB_STOR_XFER_ERROR;
650 + /* initialize the scatter-gather request block */
651 + US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
653 + result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
654 + sg, num_sg, length, SLAB_NOIO);
656 + US_DEBUGP("usb_sg_init returned %d\n", result);
657 + return USB_STOR_XFER_ERROR;
660 + /* since the block has been initialized successfully, it's now
661 + * okay to cancel it */
662 + set_bit(US_FLIDX_SG_ACTIVE, &us->flags);
664 + /* did an abort/disconnect occur during the submission? */
665 + if (us->flags & ABORTING_OR_DISCONNECTING) {
667 + /* cancel the request, if it hasn't been cancelled already */
668 + if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->flags)) {
669 + US_DEBUGP("-- cancelling sg request\n");
670 + usb_sg_cancel(&us->current_sg);
674 + /* wait for the completion of the transfer */
675 + usb_sg_wait(&us->current_sg);
676 + clear_bit(US_FLIDX_SG_ACTIVE, &us->flags);
678 + result = us->current_sg.status;
680 + *act_len = us->current_sg.bytes;
681 + return interpret_urb_result(us, pipe, length, result,
682 + us->current_sg.bytes);
686 * Transfer an entire SCSI command's worth of data payload over the bulk
689 struct scatterlist *sg;
690 unsigned int total_transferred = 0;
691 unsigned int transfer_amount;
692 + unsigned int partial;
695 /* calculate how much we want to transfer */
696 transfer_amount = usb_stor_transfer_length(srb);
697 @@ -585,23 +1140,34 @@
698 * make the appropriate requests for each, until done
700 sg = (struct scatterlist *) srb->request_buffer;
701 - for (i = 0; i < srb->use_sg; i++) {
703 - /* transfer the lesser of the next buffer or the
704 - * remaining data */
705 - if (transfer_amount - total_transferred >=
707 - result = usb_stor_transfer_partial(us,
708 - sg[i].address, sg[i].length);
709 - total_transferred += sg[i].length;
711 - result = usb_stor_transfer_partial(us,
713 - transfer_amount - total_transferred);
715 - /* if we get an error, end the loop here */
718 + if (us->pusb_dev->speed == USB_SPEED_HIGH) {
719 + /* calculate the appropriate pipe information */
720 + if (us->srb->sc_data_direction == SCSI_DATA_READ)
721 + pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
723 + pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
724 + /* use the usb core scatter-gather primitives */
725 + result = usb_stor_bulk_transfer_sglist(us, pipe,
726 + sg, srb->use_sg, transfer_amount, &partial);
728 + for (i = 0; i < srb->use_sg; i++) {
730 + /* transfer the lesser of the next buffer or the
731 + * remaining data */
732 + if (transfer_amount - total_transferred >=
734 + result = usb_stor_transfer_partial(us,
735 + sg[i].address, sg[i].length);
736 + total_transferred += sg[i].length;
738 + result = usb_stor_transfer_partial(us,
740 + transfer_amount - total_transferred);
742 + /* if we get an error, end the loop here */
749 diff -ur linux.old/drivers/usb/storage/transport.h linux.dev/drivers/usb/storage/transport.h
750 --- linux.old/drivers/usb/storage/transport.h 2003-08-25 13:44:42.000000000 +0200
751 +++ linux.dev/drivers/usb/storage/transport.h 2006-07-30 12:10:16.000000000 +0200
753 #define US_BULK_TRANSFER_ABORTED 3 /* transfer canceled */
756 + * usb_stor_bulk_transfer_xxx() return codes, in order of severity
759 +#define USB_STOR_XFER_GOOD 0 /* good transfer */
760 +#define USB_STOR_XFER_SHORT 1 /* transferred less than expected */
761 +#define USB_STOR_XFER_STALLED 2 /* endpoint stalled */
762 +#define USB_STOR_XFER_LONG 3 /* device tried to send too much */
763 +#define USB_STOR_XFER_ERROR 4 /* transfer died in the middle */
766 * Transport return codes
769 diff -ur linux.old/drivers/usb/storage/usb.h linux.dev/drivers/usb/storage/usb.h
770 --- linux.old/drivers/usb/storage/usb.h 2005-04-04 03:42:20.000000000 +0200
771 +++ linux.dev/drivers/usb/storage/usb.h 2006-07-30 12:11:06.000000000 +0200
773 typedef void (*proto_cmnd)(Scsi_Cmnd*, struct us_data*);
774 typedef void (*extra_data_destructor)(void *); /* extra data destructor */
776 +/* Dynamic flag definitions: used in set_bit() etc. */
777 +#define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */
778 +#define US_FLIDX_SG_ACTIVE 19 /* 0x00080000 current_sg is in use */
779 +#define US_FLIDX_ABORTING 20 /* 0x00100000 abort is in progress */
780 +#define US_FLIDX_DISCONNECTING 21 /* 0x00200000 disconnect in progress */
781 +#define ABORTING_OR_DISCONNECTING ((1UL << US_FLIDX_ABORTING) | \
782 + (1UL << US_FLIDX_DISCONNECTING))
783 +#define US_FLIDX_RESETTING 22 /* 0x00400000 device reset in progress */
785 +/* processing state machine states */
786 +#define US_STATE_IDLE 1
787 +#define US_STATE_RUNNING 2
788 +#define US_STATE_RESETTING 3
789 +#define US_STATE_ABORTING 4
792 + * struct usb_sg_request - support for scatter/gather I/O
793 + * @status: zero indicates success, else negative errno
794 + * @bytes: counts bytes transferred.
796 + * These requests are initialized using usb_sg_init(), and then are used
797 + * as request handles passed to usb_sg_wait() or usb_sg_cancel(). Most
798 + * members of the request object aren't for driver access.
800 + * The status and bytecount values are valid only after usb_sg_wait()
801 + * returns. If the status is zero, then the bytecount matches the total
802 + * from the request.
804 + * After an error completion, drivers may need to clear a halt condition
807 +struct usb_sg_request {
812 + * members below are private to usbcore,
813 + * and are not provided for driver access!
817 + struct usb_device *dev;
819 + struct scatterlist *sg;
826 + struct completion complete;
830 /* we allocate one of these for every device that we remember */
832 struct us_data *next; /* next device */
834 struct urb *current_urb; /* non-int USB requests */
835 struct completion current_done; /* the done flag */
836 unsigned int tag; /* tag for bulk CBW/CSW */
837 + struct usb_sg_request current_sg; /* scatter-gather req. */
839 /* the semaphore for sleeping the control thread */
840 struct semaphore sema; /* to sleep thread on */
841 diff -ur linux.old/include/linux/usb.h linux.dev/include/linux/usb.h
842 --- linux.old/include/linux/usb.h 2004-11-17 12:54:22.000000000 +0100
843 +++ linux.dev/include/linux/usb.h 2006-07-30 12:19:19.000000000 +0200
845 #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */
846 /* ... less overhead for QUEUE_BULK */
847 #define USB_TIMEOUT_KILLED 0x1000 // only set by HCD!
848 +#define URB_NO_TRANSFER_DMA_MAP 0x0400 /* urb->transfer_dma valid on submit */
849 +#define URB_NO_SETUP_DMA_MAP 0x0800 /* urb->setup_dma valid on submit */
851 struct iso_packet_descriptor