Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jan 2012 10:01:04 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        Andriy Gapon <avg@freebsd.org>
Subject:   Re: bus dma: a flag/quirk for page zero
Message-ID:  <201201111001.04724.jhb@freebsd.org>
In-Reply-To: <4F0C9D14.60705@FreeBSD.org>
References:  <4F0C9D14.60705@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201111001.04724.jhb>