From owner-freebsd-current@FreeBSD.ORG Mon Mar 30 15:34:48 2009 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D00FC1065670 for ; Mon, 30 Mar 2009 15:34:48 +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 A0C918FC16 for ; Mon, 30 Mar 2009 15:34:48 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 3784046B0D; Mon, 30 Mar 2009 11:34:48 -0400 (EDT) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n2UFYVHs023015; Mon, 30 Mar 2009 11:34:42 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-current@FreeBSD.org, barney_cordoba@yahoo.com Date: Mon, 30 Mar 2009 10:59:13 -0400 User-Agent: KMail/1.9.7 References: <513261.38032.qm@web63907.mail.re1.yahoo.com> In-Reply-To: <513261.38032.qm@web63907.mail.re1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903301059.13428.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 30 Mar 2009 11:34:42 -0400 (EDT) X-Virus-Scanned: ClamAV 0.94.2/9180/Sun Mar 29 16:40:14 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Subject: Re: pci_alloc_resource is broken X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2009 15:34:49 -0000 On Sunday 29 March 2009 11:34:32 am Barney Cordoba wrote: > > --- On Sat, 3/28/09, Barney Cordoba wrote: > > > From: Barney Cordoba > > Subject: Re: Bus Resource busy panic > > To: current@freebsd.org > > Date: Saturday, March 28, 2009, 8:03 PM > > --- On Sat, 3/28/09, Barney Cordoba > > wrote: > > > > > From: Barney Cordoba > > > Subject: Bus Resource busy panic > > > To: current@freebsd.org > > > Date: Saturday, March 28, 2009, 6:35 PM > > > I have a situation that results in a panic in 8 that > > runs > > > happily in 7. > > > Its a bus_alloc_resource of type SYS_RES_MEMORY that > > is > > > used by 2 > > > separate devices. > > > > > > I see there is an RF_SHAREABLE flag. That flag > > hadn't > > > been set, but is there > > > something in 8 that now requires it? > > > > > > As a side question, should a bus_alloc_resource call > > panic > > > the system just > > > because the resource is busy? > > > > > > Barney > > > > Some more info on this. The panic is in > > resource_list_alloc() and > > setting SHAREABLE doesn't fix it. I see the same code > > in 7 so > > I'm not sure why it would work in 7 and not 8. > > > > Basically there are 2 devices that need to do IO on a > > board, and they > > are both doing > > > > bus_alloc_resource_any(dev, SYS_RES_MEMORY,&rid, > > RF_ACTIVE); > > > > > > Barney > > > > I'm not sure if anyone was reading the original thread, so I > created another with my results. > > Someone broke pci_alloc_resource. In the SYS_RES_MEMORY case, when > rman_get_device() != dev (but rle->res is set), it erroneously > falls to resource_list_alloc which will panic on device resource busy. > > It seems that this would preclude the sharing of a resource, as any > secondary request will not only fail, but panic the system This was actually on purpose to prevent multiple allocations of a resource. Multiple allocations actually leak kernel memory since the resource only keeps track of the current mapping. My question is why are you having one device allocate resources of another device? If you have two functions of a multi-function PCI adapter that you want one logical driver for, then have each function's driver allocate its own resources and store the 'struct resource *' in a "global" softc. You can then use whichever resource you need for bus_read/write when you do bit-banging. -- John Baldwin