From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 15 18:03:56 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8C20CFB5 for ; Sat, 15 Nov 2014 18:03:56 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F3DBF364 for ; Sat, 15 Nov 2014 18:03:55 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id sAFI33sv045970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 15 Nov 2014 20:03:03 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua sAFI33sv045970 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id sAFI32FW045969; Sat, 15 Nov 2014 20:03:02 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 15 Nov 2014 20:03:02 +0200 From: Konstantin Belousov To: Alexander Kabaev Subject: Re: Newbus question Message-ID: <20141115180302.GL17068@kib.kiev.ua> References: <20141115121730.3a5bac94@kan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141115121730.3a5bac94@kan> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: FreeBSD Hackers , "O'Connor, Daniel" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Nov 2014 18:03:56 -0000 On Sat, Nov 15, 2014 at 12:17:30PM -0500, Alexander Kabaev wrote: > On Sat, 15 Nov 2014 17:32:39 +1030 > "O'Connor, Daniel" wrote: > > > Hi, > > I am trying to write a driver for the EHCI debug port [1]. I found > > some userland code which I got working (written by the person who did > > the Linux version) and now I am trying to get it running in the > > kernel. One problem I have is that it needs to run in parallel with > > the normal EHCI controller. It uses the same BAR as the EHCI > > controller but offset (the offset is found in a PCI capability). I > > think I can bus_alloc_resource() if I change EHCI to allocate with > > RF_SHAREABLE but my first problem is to add another device so my > > driver doesn't contest with the EHCI driver. > > > > Currently I have a module which loops over bus/slot/func using > > find_bsf (is there a way to enumerate all connected PCI devices?) and > > then check each for the debug capability (I plan on being a bit > > pickier later but it works so far) then creating a child device. The > > problem is that the probe routine > > > > Hi, > > I do not think this can be done without cooperation of the ECHI device. > You'd have to go the way of the full parent/child relationship between > ehci parent and debug port child devices. Fortunately, this is not that > hard to do and you can even define your own devmethod interfaces to make > communication between debug port decoupled, so that debug port can be > loaded and unloaded independently. The echi device already manages one > child usbus device, adding another should not be too hard. I think that debugging should be available much earlier than the device tree is explored and devices are attached. It probably makes sense to operate the debugging port outside the newbus at all, in particular, before the pci and acpi machinery is initialized. You might want a callback from ehci driver when it appropriated the resources, to handle the case of bar realocation.