From owner-freebsd-arm@FreeBSD.ORG Sun Jun 28 10:55:16 2009 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1FDB106567F for ; Sun, 28 Jun 2009 10:55:16 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe05.swip.net [212.247.154.129]) by mx1.freebsd.org (Postfix) with ESMTP id 4D2998FC19 for ; Sun, 28 Jun 2009 10:55:16 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=Hrwt8fWgTlIA:10 a=hlIU1J3LQChSjWV/CGRL5g==:17 a=m4X4Y5dQOB2DOwTTiTYA:9 a=8ipVIBLg3e7VFiSgQXBdK4HAca8A:4 Received: from [193.217.167.6] (account mc467741@c2i.net HELO laptop.selasky.org) by mailfe05.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 1167912719; Sun, 28 Jun 2009 11:55:13 +0200 From: Hans Petter Selasky To: Alexandr Rybalko , freebsd-arm@freebsd.org Date: Sun, 28 Jun 2009 11:54:40 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-CURRENT; KDE/4.2.4; i386; ; ) References: <200906231035.43096.kosmo@semihalf.com> <20090623121129.d18492a3.ray@dlink.ua> <200906231912.20741.hselasky@c2i.net> In-Reply-To: <200906231912.20741.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200906281154.43392.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org, Piotr =?utf-8?q?Zi=C4=99cik?= , thompsa@freebsd.org Subject: Re: CPU Cache and busdma usage in USB X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2009 10:55:17 -0000 Hi Piotr and Rafal, Your patch is not fully correct. It will break support for x86 and more when bounce pages are uses. Let's get the definitions right: man busdma BUS_DMASYNC_PREREAD Perform any synchronization required prior to an update of host memory by the device. BUS_DMASYNC_PREWRITE Perform any synchronization required after an update of host memory by the CPU and prior to device access to host memory. BUS_DMASYNC_POSTREAD Perform any synchronization required after an update of host memory by the device and prior to CPU access to host memory. BUS_DMASYNC_POSTWRITE Perform any synchronization required after device access to host memory. My view: XXX_PREXXX functions should be used prior to read/write device access. In other words, PRE has to be a flush operation. XXX_POSTXXX functions should be used after read/write device access. In other words, POST has to be an invalidate operation. Reading: src/sys/arm/arm/busdma_machdep.c I find bus_dmamap_sync_buf() to be coherent with this view. Can you check if the COHERENT bit is set for your allocation? if (map->flags & DMAMAP_COHERENT) return; Summed up: The existing code is doing correct. What is known is a problem with the memory mapping, so that the same memory page can get mapped with different attributes, which makes the problem appear. --HPS