From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 23 20:06:12 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9FD891065670 for ; Thu, 23 Jul 2009 20:06:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 78FB98FC1F for ; Thu, 23 Jul 2009 20:06:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by cyrus.watson.org (Postfix) with ESMTPSA id 299D346B58; Thu, 23 Jul 2009 16:06:12 -0400 (EDT) From: John Baldwin To: Andre Albsmeier Date: Thu, 23 Jul 2009 16:06:11 -0400 User-Agent: KMail/1.9.7 References: <200907230835.50814.jhb@freebsd.org> <200907231425.n6NEPeRH026492@ambrisko.com> <20090723175351.GA70584@curry.mchp.siemens.de> In-Reply-To: <20090723175351.GA70584@curry.mchp.siemens.de> MIME-Version: 1.0 Content-Disposition: inline X-Length: 2632 X-UID: 20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200907231606.11904.jhb@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: Re: Reading acpi memory from a driver attached to hostb X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2009 20:06:12 -0000 On Thursday 23 July 2009 1:53:51 pm Andre Albsmeier wrote: > John, apparently you sent me an email (thanks a lot) which I never > received (we have to blame our company's spam filters which I do > not control). I'll comment on it here in my reply to Doug... Yes, I saw the bounces. Hopefully you see the list version of this. > > | Did you try > > | doing 'bus_alloc_resource(device_get_parent(device_get_parent(dev))' in your > > | driver that is a child of hostb0? > > I tried this, well, something similar: I had to do 4 times > device_get_parent() to end up at acpi0: > > mydriver -> hostb0 -> pci0 -> pcib0 -> acpi0 You don't actually need to do that. pci0 will pass the request up to acpi0 eventually. You just need to ask pci0 to allocate it for you and it will see you are not a direct child and take the 'passthrough' case here: struct resource * pci_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { ... if (device_get_parent(child) != dev) return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child, type, rid, start, end, count, flags)); ... } Rather than trying to allocate the whole chunk of the ACPI resource, I would just do a specific allocation like so: rid = 0; res = BUS_ALLOC_RESOURCE(device_get_parent(device_get_parent(dev)), dev, SYS_RES_MEMORY, &rid, , , , RF_ACTIVE); -- John Baldwin