From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 15 20:05:27 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2890C16A4CE for ; Tue, 15 Feb 2005 20:05:27 +0000 (GMT) Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id A3BD443D41 for ; Tue, 15 Feb 2005 20:05:26 +0000 (GMT) (envelope-from gallatin@cs.duke.edu) Received: from grasshopper.cs.duke.edu (grasshopper.cs.duke.edu [152.3.145.30]) by duke.cs.duke.edu (8.13.1/8.13.1) with ESMTP id j1FK5P1h022824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 Feb 2005 15:05:25 -0500 (EST) Received: (from gallatin@localhost) by grasshopper.cs.duke.edu (8.12.9p2/8.12.9/Submit) id j1FK5Kd2081778; Tue, 15 Feb 2005 15:05:20 -0500 (EST) (envelope-from gallatin) From: Andrew Gallatin MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16914.22016.593790.719399@grasshopper.cs.duke.edu> Date: Tue, 15 Feb 2005 15:05:20 -0500 (EST) To: freebsd-hackers@freebsd.org X-Mailer: VM 6.75 under 21.1 (patch 12) "Channel Islands" XEmacs Lucid Subject: mapping small parts of a pci card to conserve KVA X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2005 20:05:27 -0000 I maintain drivers for a PCI card which presents itself as having 16MB of address space. Eg: mx0: mem 0xf9000000-0xf9ffffff irq 20 at device 3.0 on pci1 However, most of that address space does not need to be mapped into the host. Really, only a little over 2MB needs to be mapped (3 regions with length 1024 bytes, 256 bytes, and 2MB). I've tried to re-write things so that I make multiple calls to bus_alloc_resource() with the (hopefully) appropriate offset and lengths. Eg: rid = PCIR_MAPS; *res = bus_alloc_resource(is->arch.dev, SYS_RES_MEMORY, &rid, (u_long)offset, (u_long)(offset + len - 1), len, RF_ACTIVE|PCI_RF_DENSE); At least on 5.3R, I seem to get back the same struct resource * from each call. rman_get_virtual() returns a different kva for each mapping, yet they all seem to map to the same physical address. Eg, I call vtophys() on the results of rman_get_virtual(), for each segment, and they all map to 0xf9000000. Is there a way to just map what I need? Thanks, Drew