public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Alan Stern <stern@rowland.harvard.edu>
Subject: [patch 58/71] USB: fix the clear_tt_buffer interface
Date: Fri, 04 Sep 2009 17:14:33 -0700	[thread overview]
Message-ID: <20090905001456.303436301@mini.kroah.org> (raw)
In-Reply-To: <20090905001824.GA18171@kroah.com>

[-- Attachment #1: usb-fix-the-clear_tt_buffer-interface.patch --]
[-- Type: text/plain, Size: 6888 bytes --]

2.6.30-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Alan Stern <stern@rowland.harvard.edu>

commit cb88a1b887bb8908f6e00ce29e893ea52b074940 upstream.

This patch (as1255) updates the interface for calling
usb_hub_clear_tt_buffer().  Even the name of the function is changed!

When an async URB (i.e., Control or Bulk) going through a high-speed
hub to a non-high-speed device is cancelled or fails, the hub's
Transaction Translator buffer may be left busy still trying to
complete the transaction.  The buffer has to be cleared; that's what
usb_hub_clear_tt_buffer() does.

It isn't safe to send any more URBs to the same endpoint until the TT
buffer is fully clear.  Therefore the HCD needs to be told when the
Clear-TT-Buffer request has finished.  This patch adds a callback
method to struct hc_driver for that purpose, and makes the hub driver
invoke the callback at the proper time.

The patch also changes a couple of names; "hub_tt_kevent" and
"tt.kevent" now look rather antiquated.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/core/hcd.h    |    4 ++++
 drivers/usb/core/hub.c    |   40 ++++++++++++++++++++++++++--------------
 drivers/usb/core/hub.h    |    6 ++++--
 drivers/usb/host/ehci-q.c |    2 +-
 4 files changed, 35 insertions(+), 17 deletions(-)

--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -224,6 +224,10 @@ struct hc_driver {
 	void	(*relinquish_port)(struct usb_hcd *, int);
 		/* has a port been handed over to a companion? */
 	int	(*port_handed_over)(struct usb_hcd *, int);
+
+		/* CLEAR_TT_BUFFER completion callback */
+	void	(*clear_tt_buffer_complete)(struct usb_hcd *,
+				struct usb_host_endpoint *);
 };
 
 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -448,10 +448,10 @@ hub_clear_tt_buffer (struct usb_device *
  * talking to TTs must queue control transfers (not just bulk and iso), so
  * both can talk to the same hub concurrently.
  */
-static void hub_tt_kevent (struct work_struct *work)
+static void hub_tt_work(struct work_struct *work)
 {
 	struct usb_hub		*hub =
-		container_of(work, struct usb_hub, tt.kevent);
+		container_of(work, struct usb_hub, tt.clear_work);
 	unsigned long		flags;
 	int			limit = 100;
 
@@ -460,6 +460,7 @@ static void hub_tt_kevent (struct work_s
 		struct list_head	*temp;
 		struct usb_tt_clear	*clear;
 		struct usb_device	*hdev = hub->hdev;
+		const struct hc_driver	*drv;
 		int			status;
 
 		temp = hub->tt.clear_list.next;
@@ -469,21 +470,25 @@ static void hub_tt_kevent (struct work_s
 		/* drop lock so HCD can concurrently report other TT errors */
 		spin_unlock_irqrestore (&hub->tt.lock, flags);
 		status = hub_clear_tt_buffer (hdev, clear->devinfo, clear->tt);
-		spin_lock_irqsave (&hub->tt.lock, flags);
-
 		if (status)
 			dev_err (&hdev->dev,
 				"clear tt %d (%04x) error %d\n",
 				clear->tt, clear->devinfo, status);
+
+		/* Tell the HCD, even if the operation failed */
+		drv = clear->hcd->driver;
+		if (drv->clear_tt_buffer_complete)
+			(drv->clear_tt_buffer_complete)(clear->hcd, clear->ep);
+
 		kfree(clear);
+		spin_lock_irqsave(&hub->tt.lock, flags);
 	}
 	spin_unlock_irqrestore (&hub->tt.lock, flags);
 }
 
 /**
- * usb_hub_tt_clear_buffer - clear control/bulk TT state in high speed hub
- * @udev: the device whose split transaction failed
- * @pipe: identifies the endpoint of the failed transaction
+ * usb_hub_clear_tt_buffer - clear control/bulk TT state in high speed hub
+ * @urb: an URB associated with the failed or incomplete split transaction
  *
  * High speed HCDs use this to tell the hub driver that some split control or
  * bulk transaction failed in a way that requires clearing internal state of
@@ -493,8 +498,10 @@ static void hub_tt_kevent (struct work_s
  * It may not be possible for that hub to handle additional full (or low)
  * speed transactions until that state is fully cleared out.
  */
-void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
+int usb_hub_clear_tt_buffer(struct urb *urb)
 {
+	struct usb_device	*udev = urb->dev;
+	int			pipe = urb->pipe;
 	struct usb_tt		*tt = udev->tt;
 	unsigned long		flags;
 	struct usb_tt_clear	*clear;
@@ -506,7 +513,7 @@ void usb_hub_tt_clear_buffer (struct usb
 	if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
 		dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
 		/* FIXME recover somehow ... RESET_TT? */
-		return;
+		return -ENOMEM;
 	}
 
 	/* info that CLEAR_TT_BUFFER needs */
@@ -518,14 +525,19 @@ void usb_hub_tt_clear_buffer (struct usb
 			: (USB_ENDPOINT_XFER_BULK << 11);
 	if (usb_pipein (pipe))
 		clear->devinfo |= 1 << 15;
-	
+
+	/* info for completion callback */
+	clear->hcd = bus_to_hcd(udev->bus);
+	clear->ep = urb->ep;
+
 	/* tell keventd to clear state for this TT */
 	spin_lock_irqsave (&tt->lock, flags);
 	list_add_tail (&clear->clear_list, &tt->clear_list);
-	schedule_work (&tt->kevent);
+	schedule_work(&tt->clear_work);
 	spin_unlock_irqrestore (&tt->lock, flags);
+	return 0;
 }
-EXPORT_SYMBOL_GPL(usb_hub_tt_clear_buffer);
+EXPORT_SYMBOL_GPL(usb_hub_clear_tt_buffer);
 
 /* If do_delay is false, return the number of milliseconds the caller
  * needs to delay.
@@ -816,7 +828,7 @@ static void hub_quiesce(struct usb_hub *
 	if (hub->has_indicators)
 		cancel_delayed_work_sync(&hub->leds);
 	if (hub->tt.hub)
-		cancel_work_sync(&hub->tt.kevent);
+		cancel_work_sync(&hub->tt.clear_work);
 }
 
 /* caller has locked the hub device */
@@ -933,7 +945,7 @@ static int hub_configure(struct usb_hub 
 
 	spin_lock_init (&hub->tt.lock);
 	INIT_LIST_HEAD (&hub->tt.clear_list);
-	INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
+	INIT_WORK(&hub->tt.clear_work, hub_tt_work);
 	switch (hdev->descriptor.bDeviceProtocol) {
 		case 0:
 			break;
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -185,16 +185,18 @@ struct usb_tt {
 	/* for control/bulk error recovery (CLEAR_TT_BUFFER) */
 	spinlock_t		lock;
 	struct list_head	clear_list;	/* of usb_tt_clear */
-	struct work_struct			kevent;
+	struct work_struct	clear_work;
 };
 
 struct usb_tt_clear {
 	struct list_head	clear_list;
 	unsigned		tt;
 	u16			devinfo;
+	struct usb_hcd		*hcd;
+	struct usb_host_endpoint	*ep;
 };
 
-extern void usb_hub_tt_clear_buffer(struct usb_device *dev, int pipe);
+extern int usb_hub_clear_tt_buffer(struct urb *urb);
 extern void usb_ep0_reinit(struct usb_device *);
 
 #endif /* __LINUX_HUB_H */
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -215,7 +215,7 @@ static int qtd_copy_status (
 			/* REVISIT ARC-derived cores don't clear the root
 			 * hub TT buffer in this way...
 			 */
-			usb_hub_tt_clear_buffer (urb->dev, urb->pipe);
+			usb_hub_clear_tt_buffer(urb);
 		}
 	}
 



  parent reply	other threads:[~2009-09-05  0:25 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090905001335.106974681@mini.kroah.org>
2009-09-05  0:18 ` [patch 00/71] 2.6.30.6-stable review Greg KH
2009-09-05  0:13   ` [patch 01/71] ehea: Fix napi list corruption on ifconfig down Greg KH
2009-09-05  0:13   ` [patch 02/71] poll/select: initialize triggered field of struct poll_wqueues Greg KH
2009-09-05  0:13   ` [patch 03/71] Make bitmask and operators return a result code Greg KH
2009-09-05  0:13   ` [patch 04/71] x86: dont send an IPI to the empty set of CPUs Greg KH
2009-09-05  0:13   ` [patch 05/71] x86: dont call ->send_IPI_mask() with an empty mask Greg KH
2009-09-05  0:13   ` [patch 06/71] mm: build_zonelists(): move clear node_load[] to __build_all_zonelists() Greg KH
2009-09-05  0:13   ` [patch 07/71] rt2x00: fix memory corruption in rf cache, add a sanity check Greg KH
2009-09-05  0:13   ` [patch 08/71] mac80211: fix panic when splicing unprepared TIDs Greg KH
2009-09-05  0:13   ` [patch 09/71] Re-introduce page mapping check in mark_buffer_dirty() Greg KH
2009-09-05  0:13   ` [patch 10/71] mm: fix hugetlb bug due to user_shm_unlock call Greg KH
2009-09-05  0:13   ` [patch 11/71] ima: hashing large files bug fix Greg KH
2009-09-05  0:13   ` [patch 12/71] kernel_read: redefine offset type Greg KH
2009-09-05  0:13   ` [patch 13/71] tracing: Fix too large stack usage in do_one_initcall() Greg KH
2009-09-05  0:13   ` [patch 14/71] sound: pcm_lib: fix unsorted list constraint handling Greg KH
2009-09-05  0:13   ` [patch 15/71] clone(): fix race between copy_process() and de_thread() Greg KH
2009-09-05  0:13   ` [patch 16/71] wmi: fix kernel panic when stack protection enabled Greg KH
2009-09-05  0:13   ` [patch 17/71] SUNRPC: Fix rpc_task_force_reencode Greg KH
2009-09-05  0:13   ` [patch 18/71] ALSA: hda - Fix MacBookPro 3,1/4,1 quirk with ALC889A Greg KH
2009-09-05  0:13   ` [patch 19/71] KVM: take mmu_lock when updating a deleted slot Greg KH
2009-09-05  0:13   ` [patch 20/71] KVM: x86: check for cr3 validity in mmu_alloc_roots Greg KH
2009-09-05  0:13   ` [patch 21/71] KVM: MMU: protect kvm_mmu_change_mmu_pages with mmu_lock Greg KH
2009-09-05  0:13   ` [patch 22/71] KVM: MMU: do not free active mmu pages in free_mmu_pages() Greg KH
2009-09-05  0:13   ` [patch 23/71] KVM: Introduce {set/get}_interrupt_shadow() Greg KH
2009-09-05  0:13   ` [patch 24/71] KVM: Deal with interrupt shadow state for emulated instructions Greg KH
2009-09-05  0:14   ` [patch 25/71] KVM: MMU: Use different shadows when EFER.NXE changes Greg KH
2009-09-05  0:14   ` [patch 26/71] KVM: x86: Ignore reads to EVNTSEL MSRs Greg KH
2009-09-05  0:14   ` [patch 27/71] KVM: Ignore reads to K7 " Greg KH
2009-09-05  0:14   ` [patch 28/71] KVM: Fix cpuid feature misreporting Greg KH
2009-09-05  0:14   ` [patch 29/71] KVM: x86: verify MTRR/PAT validity Greg KH
2009-09-05  0:14   ` [patch 30/71] KVM: SVM: force new asid on vcpu migration Greg KH
2009-09-05  0:14   ` [patch 31/71] KVM: MMU: handle n_free_mmu_pages > n_alloc_mmu_pages in kvm_mmu_change_mmu_pages Greg KH
2009-09-05  0:14   ` [patch 32/71] [stable] [PATCH 14/16] KVM: MMU: limit rmap chain length Greg KH
2009-09-05  0:14   ` [patch 33/71] KVM: fix ack not being delivered when msi present Greg KH
2009-09-05  0:14   ` [patch 34/71] KVM: Fix KVM_GET_MSR_INDEX_LIST Greg KH
2009-09-05  0:14   ` [patch 35/71] iwl3945: fix rfkill switch Greg KH
2009-09-05  0:14   ` [patch 36/71] iwlagn: do not send key clear commands when rfkill enabled Greg KH
2009-09-05  0:14   ` [patch 37/71] libata: OCZ Vertex cant do HPA Greg KH
2009-09-05  0:14   ` [patch 38/71] SCSI: mpt2sas: Introduced check for enclosure_handle to avoid crash Greg KH
2009-09-05  0:14   ` [patch 39/71] SCSI: mpt2sas: Expander fix oops saying "Already part of another port" Greg KH
2009-09-05  0:14   ` [patch 40/71] SCSI: mpt2sas: Raid 10 Value is showing as Raid 1E in /va/log/messages Greg KH
2009-09-05  0:14   ` [patch 41/71] SCSI: mpt2sas: Excessive log info causes sas iounit page time out Greg KH
2009-09-05  0:14   ` [patch 42/71] SCSI: mpt2sas: fix infinite loop inside config request Greg KH
2009-09-05  0:14   ` [patch 43/71] SCSI: mpt2sas: fix crash due to Watchdog is active while OS in standby mode Greg KH
2009-09-05  0:14   ` [patch 44/71] SCSI: mpt2sas: fix oops because drv data points to NULL on resume from hibernate Greg KH
2009-09-05  0:14   ` [patch 45/71] [SCSI] mpt2sas: fix config request and diag reset deadlock Greg KH
2009-09-05  0:14   ` [patch 46/71] do_sigaltstack: avoid copying stack_t as a structure to user space Greg KH
2009-09-05  0:14   ` [patch 47/71] Bug Fix arch/ia64/kernel/pci-dma.c: fix recursive dma_supported() call in iommu_dma_supported() Greg KH
2009-09-05  0:14   ` [patch 48/71] x86, amd: Dont probe for extended APIC ID if APICs are disabled Greg KH
2009-09-05  0:14   ` [patch 49/71] ocfs2: Initialize the cluster were writing to in a non-sparse extend Greg KH
2009-09-05  0:14   ` [patch 50/71] ACPI processor: force throttling state when BIOS returns incorrect value Greg KH
2009-09-05  0:14   ` [patch 51/71] vfs: fix inode_init_always calling convention Greg KH
2009-09-05  0:14   ` [patch 52/71] vfs: add __destroy_inode Greg KH
2009-09-05  0:14   ` [patch 53/71] xfs: fix freeing of inodes not yet added to the inode cache Greg KH
2009-09-05  0:14   ` [patch 54/71] xfs: fix spin_is_locked assert on uni-processor builds Greg KH
2009-09-05  0:14   ` [patch 55/71] gspca - ov534: Fix ov772x Greg KH
2009-09-05  0:14   ` [patch 56/71] kthreads: fix kthread_create() vs kthread_stop() race Greg KH
2009-09-05  0:14   ` [patch 57/71] ipv6: Fix commit 63d9950b08184e6531adceb65f64b429909cc101 (ipv6: Make v4-mapped bindings consistent with IPv4) Greg KH
2009-09-05  0:14   ` Greg KH [this message]
2009-09-05  0:14   ` [patch 59/71] USB: EHCI: use the new clear_tt_buffer interface Greg KH
2009-09-05  0:14   ` [patch 60/71] USB: EHCI: fix two new bugs related to Clear-TT-Buffer Greg KH
2009-09-05  0:14   ` [patch 61/71] powerpc/ps3: Add missing check for PS3 to rtc-ps3 platform device registration Greg KH
2009-09-05  0:14   ` [patch 62/71] ipv4: make ip_append_data() handle NULL routing table Greg KH
2009-09-05  0:14   ` [patch 63/71] ar9170: fix read & write outside array bounds Greg KH
2009-09-05  0:14   ` [patch 64/71] xenfb: connect to backend before registering fb Greg KH
2009-09-05  0:14   ` [patch 65/71] can: Fix raw_getname() leak Greg KH
2009-09-05  0:14   ` [patch 66/71] irda: Fix irda_getname() leak Greg KH
2009-09-05  0:14   ` [patch 67/71] appletalk: fix atalk_getname() leak Greg KH
2009-09-05  0:14   ` [patch 68/71] netrom: Fix nr_getname() leak Greg KH
2009-09-05  0:14   ` [patch 69/71] econet: Fix econet_getname() leak Greg KH
2009-09-05  0:14   ` [patch 70/71] rose: Fix rose_getname() leak Greg KH
2009-09-05  0:14   ` [patch 71/71] NET: llc, zero sockaddr_llc struct Greg KH
2009-09-05  4:54   ` [patch 00/71] 2.6.30.6-stable review Grant Coady
2009-09-05 14:48     ` Greg KH
2009-09-08 19:23   ` [Stable-review] " Luis R. Rodriguez
2009-09-09 22:44     ` Greg KH
2009-09-10  0:21       ` Luis R. Rodriguez
2009-09-10  3:00         ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090905001456.303436301@mini.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox