From owner-freebsd-mips@FreeBSD.ORG  Wed Aug 29 02:22:58 2012
Return-Path: <owner-freebsd-mips@FreeBSD.ORG>
Delivered-To: freebsd-mips@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8762F106566B;
	Wed, 29 Aug 2012 02:22:58 +0000 (UTC)
	(envelope-from adrian.chadd@gmail.com)
Received: from mail-pz0-f54.google.com (mail-pz0-f54.google.com
	[209.85.210.54])
	by mx1.freebsd.org (Postfix) with ESMTP id 575D18FC15;
	Wed, 29 Aug 2012 02:22:58 +0000 (UTC)
Received: by dadr6 with SMTP id r6so45384dad.13
	for <multiple recipients>; Tue, 28 Aug 2012 19:22:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=mime-version:sender:date:x-google-sender-auth:message-id:subject
	:from:to:content-type;
	bh=jPaxisYnGaNzyL81BFW26rd2oRWNOqjntmaqtrIA9BM=;
	b=Y6yWxVnQW5rfu4H6GoNtOrjUwqX4T79x0DkWrQ5bM60eF29l7wdRswXtY6kA60kyk8
	DwtSR2Nh4SJgrC6iAW+Ro/U5nNw3Hi5qx2+0Heco/CuVUyweypK6J3b43VxnVViCpm/6
	pODAkBf+qAhJIt9WFEF3SOaJ+rCNH1FqN+dMkUYODeI8L4ZcMO3B7US8uc8/xIYOy6wq
	ykHPzF8Dm/GZcA4W30JpFHtjzuXk5S7gM3zUhUfSO6UTcz/CaraOSmKayH0oHP5GVhGg
	gBTKuXQmI18gqt6Dw+i25szZWV8UAn6yMF8g4HW5+3Rgze1O2hgOy9FsCbxBZwvfVEAd
	+fyA==
MIME-Version: 1.0
Received: by 10.66.74.196 with SMTP id w4mr133242pav.32.1346206977921; Tue, 28
	Aug 2012 19:22:57 -0700 (PDT)
Sender: adrian.chadd@gmail.com
Received: by 10.68.36.106 with HTTP; Tue, 28 Aug 2012 19:22:57 -0700 (PDT)
Date: Tue, 28 Aug 2012 19:22:57 -0700
X-Google-Sender-Auth: 1EKXm5nhF29ln4MNaNAWBW3n_r8
Message-ID: <CAJ-VmomuwKKaQ6AszeDo-iQwL+8DPJpBB9av0K+Vbaj2feHO7g@mail.gmail.com>
From: Adrian Chadd <adrian@freebsd.org>
To: scottl@freebsd.org, freebsd-mips@freebsd.org
Content-Type: text/plain; charset=ISO-8859-1
Cc: 
Subject: MIPS busdma map questions
X-BeenThere: freebsd-mips@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Porting FreeBSD to MIPS <freebsd-mips.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-mips>,
	<mailto:freebsd-mips-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-mips>
List-Post: <mailto:freebsd-mips@freebsd.org>
List-Help: <mailto:freebsd-mips-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-mips>,
	<mailto:freebsd-mips-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Aug 2012 02:22:58 -0000

Hi,

I have a couple of busdma map questions.

#1 - in mips/mips/busdma_machdep.c, bus_dmamap_destroy() calls
_busdma_free_dmamap() and -then- goes and walks the dma map list. Is
this a good idea or not? :)

#2 - the ath(4) code (in sys/dev/ath/if_ath.c:ath_descdma_alloc_desc()
on -HEAD) does the following:

* creates a tag
* allocates a dmamap (bus_dmamap_create) - storing it in dd->dd_dmamap;
* allocates memory via bus_dmamem_alloc - also storing it in dd->dd_dmamap.

Now, I saw some NULL pointer derefernce going on when thigns failed to
load - and what I found was bus_dmamem_alloc() overwrites the dmat
pointer passed in (dd_dmamap above). So the dmamap allocated via
bus_dmamap_create() is just plain overwritten.

I'm guessing that when allocating memory via bus_dmamem_alloc(), the
call to bus_dmamap_create() (and the bus_dmamap_destroy()) isn't
needed.

Scott/mips people - what do you think?



Adrian