From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 9 03:59:13 2012 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 F311F1065670; Mon, 9 Jul 2012 03:59:12 +0000 (UTC) (envelope-from lacombar@gmail.com) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx1.freebsd.org (Postfix) with ESMTP id 616F68FC12; Mon, 9 Jul 2012 03:59:12 +0000 (UTC) Received: by wibhq12 with SMTP id hq12so2289693wib.1 for ; Sun, 08 Jul 2012 20:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=vuTa1iouTc9jB8ljAgnrc1sQ5y9CsDgdP2qoGAZPbw4=; b=vYSVByUD6emmo1ZGwNsWVHmynuv08ZoMhTIIrWBpgnXe5MN/VbCc5hXgCTMhfVdfqX pgUrv+lF5UU/pvBeftfsKtFkvx3+jTZHMzvnnnZDb8B77S12FPWZVKgOoOKkwLra160F Dqg1woO2HQiOmc+b8gkLckR2qYveagtcxlpIdNL32DKxrL7jhK2kehxvZAr87+xPa4Nn dCcmr5pzEu1YBANokMCT81+QD3FUF8txTmOdpXVAXtvdu4A7e5RFamlLXdu8cEl9jRG/ QWQskxgwGccVsu4wXHNpNLFlLyMgV85eF5gJmyYfYdXebRsBnxX74xpkHuSyIes/B22W YzXg== MIME-Version: 1.0 Received: by 10.180.14.34 with SMTP id m2mr26009127wic.22.1341806345314; Sun, 08 Jul 2012 20:59:05 -0700 (PDT) Received: by 10.216.23.200 with HTTP; Sun, 8 Jul 2012 20:59:05 -0700 (PDT) In-Reply-To: <31A0DCE7-3B93-41BC-805A-E0B163892112@bsdimp.com> References: <31A0DCE7-3B93-41BC-805A-E0B163892112@bsdimp.com> Date: Sun, 8 Jul 2012 23:59:05 -0400 Message-ID: From: Arnaud Lacombe To: Warner Losh Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Hackers , FreeBSD Current Subject: Re: newbus' ivar's limitation.. 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: Mon, 09 Jul 2012 03:59:13 -0000 Hi, On Sun, Jul 8, 2012 at 10:07 PM, Warner Losh wrote: > > On Jul 8, 2012, at 7:22 PM, Arnaud Lacombe wrote: >> Ok, yet another Newbus' limitation. Assuming a device exports more >> than one interface, and one of its child has need to use more than one >> interface, each interfaces cannot register, concurrently, its own >> ivar. While I try to always have a single child per >> interface/resource, I need to keep some compatibility with the old way >> of doing thing (POLA wrt. drivers I cannot/will not convert and >> userland). So, it would have been nice if ivar had been per-interface, >> not global and unique to one device. > > There's one pointer for the ivars. The bus code gets to determine what t= he ivar looks like, because the interface is totally private to the bus. S= o long as it returns the right thing for any key that's presented, it doesn= 't matter quite how things are done. > > So I'm not sure I understand what you are saying here. > > The problem, more basically, is that the ivar keys are not unique. Curre= ntly, there's no bits used in the key to define the values to be non-overla= pping. For example: > enum pci_device_ivars { > PCI_IVAR_SUBVENDOR, > PCI_IVAR_SUBDEVICE, > PCI_IVAR_VENDOR, > .... > }; > > We could easily reserve the upper 16-bits of this field to be that key. = This value could then be used to differentiate them. But this wouldn't sca= le too well. Given that there's only about a dozen or two in the tree, tha= t's right at the moment, it wouldn't be hard to do something like: > > enum ivar_namespace { > IVAR_PCI =3D 1, > IVAR_PCCARD, > IVAR_USB, > etc > }; > #define IVAR_SHIFT 16 > > and the above could be changed to: > > enum pci_device_ivars { > PCI_IVAR_SUBVENDOR =3D IVAR_PCI << IVAR_SHIFT, > PCI_IVAR_SUBDEVICE, > PCI_IVAR_VENDOR, > .... > }; > > and then we'd have an unambiguous key, and the bus could easily implement= multiple interfaces. > > but then again, most of the existing interfaces in the kernel are mutuall= y exclusive, so you could implement this just for your new interfaces. > ok, I think I got it now. You and I are exactly saying the same thing, just in different terms; there is no way to currently specify multiple independent (/overlapping) ivars in a child... - Arnaud