public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: davidm@hpl.hp.com
Cc: Grant Grundler <iod00d@hp.com>, Greg KH <greg@kroah.com>,
	vojtech@suse.cz, linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org,
	pochini@shiny.it
Subject: Re: [linux-usb-devel] Re: serious 2.6 bug in USB subsystem?
Date: Mon, 08 Mar 2004 13:48:38 -0800	[thread overview]
Message-ID: <404CEA36.2000903@pacbell.net> (raw)
In-Reply-To: <16460.49761.482020.911821@napali.hpl.hp.com>

[-- Attachment #1: Type: text/plain, Size: 647 bytes --]

David Mosberger wrote:

>  consistency = coherency + ordering

That's one of the things I meant when I said the docs weren't
quite there yet ... the dma_*() API docs don't address how
to achieve the ordering, or even mention that it's an issue.

Plus, there are definitions of coherency that include event
ordering; it's not clear which definition is intended.


Anyway, see the attached patch.  It goes on top of 2.6.4-bk2
and passes my unlink tests (the ones that haven't been run
much on recent kernels!) on several different OHCI hosts.

Other issues may be lurking, but this seems to fix a handful
of nasties that I could reproduce.

- Dave


[-- Attachment #2: ohci-0308.patch --]
[-- Type: text/plain, Size: 3017 bytes --]

Fixes for some recent OHCI instability.

    - Never munge ed->hwTailP once it's set up, except when appending
      to the queue.

    - Don't clear control/bulk "current ED" registers when taking
      entries off the queue.  The chip may still be using the value.

    - Revert part of previous bk1 patch, which removed a fast path
      that makes a visible difference in some common operations.
      Removing it just slowed timings, and didn't fix anything.

    - Make the "unlink during submit" path behave better (SMP).


--- 1.50/drivers/usb/host/ohci-q.c	Tue Mar  2 22:48:07 2004
+++ edited/drivers/usb/host/ohci-q.c	Mon Mar  8 13:15:08 2004
@@ -282,7 +282,6 @@
 			if (!ed->hwNextED) {
 				ohci->hc_control &= ~OHCI_CTRL_CLE;
 				writel (ohci->hc_control, &ohci->regs->control);
-				writel (0, &ohci->regs->ed_controlcurrent);
 				// post those pci writes
 				(void) readl (&ohci->regs->control);
 			}
@@ -306,7 +305,6 @@
 			if (!ed->hwNextED) {
 				ohci->hc_control &= ~OHCI_CTRL_BLE;
 				writel (ohci->hc_control, &ohci->regs->control);
-				writel (0, &ohci->regs->ed_bulkcurrent);
 				// post those pci writes
 				(void) readl (&ohci->regs->control);
 			}
@@ -331,6 +329,19 @@
 		periodic_unlink (ohci, ed);
 		break;
 	}
+
+	/* NOTE: Except for a couple of exceptionally clean unlink cases
+	 * (like unlinking the only c/b ED, with no TDs) HCs may still be
+	 * caching this operational ED (or its address).  Safe unlinking
+	 * involves not marking it ED_IDLE till INTR_SF; we always do that
+	 * if td_list isn't empty.  Otherwise the race is small; but ...
+	 */
+	if (ed->state == ED_OPER) {
+		ed->state = ED_IDLE;
+		ed->hwINFO &= ~(ED_SKIP | ED_DEQUEUE);
+		ed->hwHeadP &= ~ED_H;
+		wmb ();
+	}
 }
 
 
@@ -794,8 +805,6 @@
 		next->next_dl_td = rev;	
 		rev = next;
 
-		if (ed->hwTailP == cpu_to_le32 (next->td_dma))
-			ed->hwTailP = next->hwNextTD;
 		ed->hwHeadP = next->hwNextTD | toggle;
 	}
 
@@ -941,12 +950,7 @@
 				continue;
 			}
 
-			/* patch pointers hc uses ... tail, if we're removing
-			 * an otherwise active td, and whatever td pointer
-			 * points to this td
-			 */
-			if (ed->hwTailP == cpu_to_le32 (td->td_dma))
-				ed->hwTailP = td->hwNextTD;
+			/* patch pointer hc uses */
 			savebits = *prev & ~cpu_to_le32 (TD_MASK);
 			*prev = td->hwNextTD | savebits;
 
@@ -1041,7 +1045,7 @@
 
 		/* clean schedule:  unlink EDs that are no longer busy */
 		if (list_empty (&ed->td_list))
-			start_ed_unlink (ohci, ed);
+			ed_deschedule (ohci, ed);
 		/* ... reenabling halted EDs only after fault cleanup */
 		else if ((ed->hwINFO & (ED_SKIP | ED_DEQUEUE)) == ED_SKIP) {
 			td = list_entry (ed->td_list.next, struct td, td_list);
--- 1.57/drivers/usb/host/ohci-hcd.c	Tue Mar  2 22:48:07 2004
+++ edited/drivers/usb/host/ohci-hcd.c	Mon Mar  8 12:39:24 2004
@@ -233,7 +233,7 @@
 	spin_lock (&urb->lock);
 	if (urb->status != -EINPROGRESS) {
 		spin_unlock (&urb->lock);
-
+		urb->hcpriv = urb_priv;
 		finish_urb (ohci, urb, 0);
 		retval = 0;
 		goto fail;

  reply	other threads:[~2004-03-08 21:59 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-27 22:35 serious 2.6 bug in USB subsystem? David Mosberger
2003-10-28  1:30 ` Greg KH
2003-10-28  3:00   ` David Mosberger
2003-10-30 15:11     ` [linux-usb-devel] " David Brownell
2003-10-30 20:15       ` David Mosberger
     [not found]         ` <16289.55171.278494.17172@napali.hpl.hp.com>
2003-10-31 16:23           ` David Brownell
2003-10-31 18:34             ` David Mosberger
2003-10-31 18:50               ` Valdis.Kletnieks
2003-10-31 19:28               ` David Brownell
2003-10-31 19:50                 ` David Mosberger
2003-10-31 20:06                   ` David S. Miller
2004-03-06  2:08             ` David Mosberger
2004-03-06  2:13               ` David Mosberger
2004-03-06  4:55               ` David Brownell
2004-03-06  5:49                 ` David Mosberger
2004-03-06  7:21                   ` David Mosberger
2004-03-06  8:39                     ` David Mosberger
2004-03-06 16:37                   ` David Brownell
2004-03-08  6:18                     ` Grant Grundler
2004-03-08 18:58                       ` David Mosberger
2004-03-08 21:48                         ` David Brownell [this message]
2004-03-09  9:15                           ` David Mosberger
2004-03-09 17:36                             ` David Brownell
2004-03-09 17:58                               ` David Mosberger
2004-03-09 20:39                                 ` David Brownell
2004-03-09 23:32                                   ` David Mosberger
2004-03-10  2:53                                     ` David Brownell
2004-03-10  6:11                                       ` David Mosberger
2004-03-10  6:59                                   ` David Mosberger
2004-03-10  7:52                                     ` Wouter Lueks
2004-03-10 16:49                                       ` David Mosberger
2004-03-10 19:49                                         ` Wouter Lueks
2004-03-10 16:22                                     ` David Brownell
2004-03-10 18:04                                       ` David Mosberger
2004-03-11  2:43                                         ` David Brownell
2004-03-11  5:35                                           ` David Mosberger
2004-03-10 19:29                                     ` Colin Leroy
2004-03-06  9:17                 ` [linux-usb-devel] " David Mosberger
2004-03-06 17:30                   ` David Brownell
2004-03-07 13:48                     ` Matthias Andree
2004-03-08 18:49                     ` David Mosberger
2003-11-03  3:46         ` David Brownell
2003-11-03 21:25           ` David Mosberger
2004-03-03 12:33 ` Wouter Lueks
2004-03-03 15:30   ` Wouter Lueks

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=404CEA36.2000903@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=davidm@hpl.hp.com \
    --cc=greg@kroah.com \
    --cc=iod00d@hp.com \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=pochini@shiny.it \
    --cc=vojtech@suse.cz \
    /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