From owner-freebsd-current@FreeBSD.ORG Mon Mar 30 15:53:03 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 6CE4E1065670 for ; Mon, 30 Mar 2009 15:53:03 +0000 (UTC) (envelope-from barney_cordoba@yahoo.com) Received: from web63906.mail.re1.yahoo.com (web63906.mail.re1.yahoo.com [69.147.97.121]) by mx1.freebsd.org (Postfix) with SMTP id 27A718FC0C for ; Mon, 30 Mar 2009 15:53:02 +0000 (UTC) (envelope-from barney_cordoba@yahoo.com) Received: (qmail 10197 invoked by uid 60001); 30 Mar 2009 15:53:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1238428382; bh=skI2Fw1TQ8s9VczZInPPxvC6FjZj9y0aBBB6hxR5f8A=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=KCEK7EMEDpXCo9kvageNN+jP7FT742RaKMKhFUtMo1/XxVlnUNVcfg3bA9Jd11W1XsAbngiJZ0mDxVbF1lkz+BFMO/XDjcqPjZ0v81MYXK+q2/5X12Ofl+XSL2j9wYVoJN+xJzj17pOLNvijsdBVoMZAq2Y+Se8QxtdmTd453gk= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=kMsP0TDetVfjZ5J5VlB8gnYiqrNbPwDUw4K0R20/BWI6Dp5PlVrEVQIbD2e9dDnERyBNjr57Q4NKEKq/HPBMGOqNp8liyboSHkE/V2QYLkBy4pI+RmCmo267b0zUhuHPNWMfKO98q4wMPrc7eYTlB0PlDiQPCfmo2/PMcOix/qE=; Message-ID: <452083.9826.qm@web63906.mail.re1.yahoo.com> X-YMail-OSG: XcWJnLAVM1nPgikCDr6Qh5hNlVhF0m.YZUqGHyP47_YWkMzPq2aHnvXp4I92fZtee1Nam4Ox3v.BYpqXO4ZqQQm7KA0RXntk3ASZRL70LLcrCp7RdZSdkWDdcfrAtZxwLepwbOgIfH9qCrrqIfoj.mZ697ME_M93dl9vz6Dj7uTJTOGxGRhwhABVsmEPND9LVhddJ5MHaEijMScFmGk33Jmsnre36aMynuv0Xba.2CzFvlnkc.k6seRcOJcTGwV9hDJzeMYZXcJEM1eRDj6JcJ4- Received: from [98.242.222.229] by web63906.mail.re1.yahoo.com via HTTP; Mon, 30 Mar 2009 08:53:02 PDT X-Mailer: YahooMailWebService/0.7.289.1 Date: Mon, 30 Mar 2009 08:53:02 -0700 (PDT) From: Barney Cordoba To: freebsd-current@FreeBSD.org, John Baldwin In-Reply-To: <200903301059.13428.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Subject: Re: pci_alloc_resource is broken X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: barney_cordoba@yahoo.com 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:53:04 -0000 --- On Mon, 3/30/09, John Baldwin wrote: > From: John Baldwin > Subject: Re: pci_alloc_resource is broken > To: freebsd-current@FreeBSD.org, barney_cordoba@yahoo.com > Date: Monday, March 30, 2009, 10:59 AM > 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 We're remapping in another driver because in the commercial world, we don't always have access to kernel source, and there is a strong desire to separate the NIC driver from the secondary function so customers can get patches for the OS without having to worry about incompatibility with the secondary modules. I can add a function to the NIC driver also, but the goal is to be able to distribute a module that doesn't require modification to the stock driver for the system. Barney