Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: make urb scatter-gather support more generic

The WHCI HCD will also support urbs with scatter-gather lists. Add a
usb_bus field to indicated how many sg list elements are supported by
the HCD. Use this to decide whether to pass the scatter-list to the HCD
or not.

Make the usb-storage driver use this new field.

Signed-off-by: David Vrabel <david.vrabel@csr.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

David Vrabel and committed by
Greg Kroah-Hartman
4c1bd3d7 09ce497e

+14 -7
+1 -7
drivers/usb/core/message.c
··· 393 393 if (io->entries <= 0) 394 394 return io->entries; 395 395 396 - /* If we're running on an xHCI host controller, queue the whole scatter 397 - * gather list with one call to urb_enqueue(). This is only for bulk, 398 - * as that endpoint type does not care how the data gets broken up 399 - * across frames. 400 - */ 401 - if (usb_pipebulk(pipe) && 402 - bus_to_hcd(dev->bus)->driver->flags & HCD_USB3) { 396 + if (dev->bus->sg_tablesize > 0) { 403 397 io->urbs = kmalloc(sizeof *io->urbs, mem_flags); 404 398 use_sg = true; 405 399 } else {
+2
drivers/usb/host/xhci-pci.c
··· 54 54 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 55 55 int retval; 56 56 57 + hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 1; 58 + 57 59 xhci->cap_regs = hcd->regs; 58 60 xhci->op_regs = hcd->regs + 59 61 HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase));
+10
drivers/usb/storage/usb.c
··· 843 843 complete_and_exit(&us->scanning_done, 0); 844 844 } 845 845 846 + static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf) 847 + { 848 + struct usb_device *usb_dev = interface_to_usbdev(intf); 849 + 850 + if (usb_dev->bus->sg_tablesize) { 851 + return usb_dev->bus->sg_tablesize; 852 + } 853 + return SG_ALL; 854 + } 846 855 847 856 /* First part of general USB mass-storage probing */ 848 857 int usb_stor_probe1(struct us_data **pus, ··· 880 871 * Allow 16-byte CDBs and thus > 2TB 881 872 */ 882 873 host->max_cmd_len = 16; 874 + host->sg_tablesize = usb_stor_sg_tablesize(intf); 883 875 *pus = us = host_to_us(host); 884 876 memset(us, 0, sizeof(struct us_data)); 885 877 mutex_init(&(us->dev_mutex));
+1
include/linux/usb.h
··· 331 331 u8 otg_port; /* 0, or number of OTG/HNP port */ 332 332 unsigned is_b_host:1; /* true during some HNP roleswitches */ 333 333 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ 334 + unsigned sg_tablesize; /* 0 or largest number of sg list entries */ 334 335 335 336 int devnum_next; /* Next open device number in 336 337 * round-robin allocation */