Re: bus dma: a flag/quirk for page zero

From: John Baldwin <jhb_at_freebsd.org>
Date: Wed, 11 Jan 2012 10:01:04 -0500
On Tuesday, January 10, 2012 3:18:28 pm Andriy Gapon wrote:
> 
> Some hardware interfaces may reserve a special meaning for a (physical) memory
> address value of zero.  One example is the OHCI specification where a zero value
> in CurrentBufferPointer doesn't mean a physical address, but has a reserved
> meaning.  To be honest I don't have another example :) but don't preclude its
> existence.
> 
> To deal with this peculiarity we could use a special flag/quirk that would
> instruct the bus dma code to never use the page zero for communication with the
> hardware.
> Here's a proof of concept patch that implements the idea:
> http://people.freebsd.org/~avg/usb-dma-pagezero.diff
> 
> Some concerns:
> - not sure if BUS_DMA_NO_PAGEZERO is the best name for the flag
> - the patch implements the flag only for x86 at the moment
> - usb code uses the flag regardless of the actual controller type
> 
> What do you think?

I think this is fine, but you should just always exclude page zero when allocating
bounce pages.  Bounce pages are assigned to zones that can be shared by multiple
tags, so other tags that map to the same zone can alloc bounce pages that ohci
will use (add_bounce_page() should probably take the bounce zone as an arg instead
of a tag).  I think it's not worth creating a separate zone just for ohci, but
to forbid page zero from all zones instead.  Also, please change this:

-	if (newtag->lowaddr < ptoa((vm_paddr_t)Maxmem)
-	 || newtag->alignment > 1)
+	if (newtag->lowaddr < ptoa((vm_paddr_t)Maxmem) ||
+	    newtag->alignment > 1)
+		newtag->flags |= BUS_DMA_COULD_BOUNCE;
+
+	if ((newtag->flags & BUS_DMA_NO_PAGEZERO) != 0)
 		newtag->flags |= BUS_DMA_COULD_BOUNCE;

To just be one if.

-- 
John Baldwin
Received on Wed Jan 11 2012 - 14:14:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:23 UTC