Pete Zaitcev wrote:
On Fri, 28 Jan 2005 10:52:49 -0800, David Daney <[EMAIL PROTECTED]> wrote:

A short summary is that memory barriers are needed in several places for correct operation on my MIPS based platform.


The real URL to the patch is here:

http://sourceforge.net/mailarchive/forum.php?thread_id=6446190&forum_id=5398


I can imagine, but actual patch seems to be too crude.


I have attached a patch against usb-ohci.c from the 2.4.29 sources I obtained from linux-mips.org. These should be the same as the "master" 2.4.29 sources WRT USB.

It is possible that some of the wmb() that I added are not necessary, but which ones they are is unclear to me.


So, why don't you figure out which are necessary?

A lack of time and expertise with OHCI...

A memory barrier is only
needed in case of concurrent accesses, either by other CPU, or by DMA.
For other CPUs, we have barriers built into spinlocks. If those are not
sufficient, we should strive to place spinlocks right. If DMA is a problem,
the large majority of the patched places simply make no sense.

I suspect the problem is with DMA for the simple reason that the system in question has only one CPU. I am not an OHCI expert, I could not tell from a very casual and uninformed perusal of the code which make sense and which do not, so I put them before any OHCI register write where I could not quickly prove to myself that they were not needed.



Look at the very first segment, for example:


ed->ed_prev = ohci->ed_controltail;
if (!ohci->ed_controltail && !ohci->ed_rm_list[0] &&
!ohci->ed_rm_list[1] && !ohci->sleeping) {
ohci->hc_control |= OHCI_CTRL_CLE;
+ wmb();
writel (ohci->hc_control, &ohci->regs->control);
}
ohci->ed_controltail = edi;


What are we protecting here? ed_prev? But why under if()? The hc_control
is not a subject of a concurrent access, is it?


As I said, I just slapped some wmb() in several (but not all) places where a hacked up earlier version of the driver had them. In this case an argument could be made that because wmb() could take a long time we only want to do it in the cases where we are writing to a register (i.e. it is needed).


In a perfect world, I would get the OHCI spec and spend several days reading it and fixing the driver the proper way. My main motivation for sending the patch was to make the OHCI experts aware of the problems I had, and show my imperfect solution. I don't have time to do anything else right now.

David Daney.


------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to