Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2020 16:01:52 -0700
From:      Mark Millard <marklmi@yahoo.com>
To:        John-Mark Gurney <jmg@funkthat.com>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, freebsd-drivers@freebsd.org
Subject:   Re: Can we hook a device as device to two different parent devices?
Message-ID:  <C0CDA802-8990-41AF-91B2-C371593E6D19@yahoo.com>
In-Reply-To: <20200604215300.GH4213@funkthat.com>
References:  <CAAO%2BANOB8m6OjRY-FOVVHQi3vdcCEnHdjE2s3xoHdh0rjaTruQ@mail.gmail.com> <c1b611bc-4fa7-7975-da3f-e7c68a26e92b@FreeBSD.org> <CANCZdfpF%2BaiZYLRHo-NOizZcAuBz%2BXhsqYvXTazHrMVz_%2Bh=3w@mail.gmail.com> <CAAO%2BANOQfY3AUy5o9BP22O5Uxp83crAXNhFrOeMcmsStkk4Y-w@mail.gmail.com> <20200604215300.GH4213@funkthat.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[I'm only trying to follow along for my own edification
in an area I'm not familiar with.]

On 2020-Jun-4, at 14:53, John-Mark Gurney <jmg at funkthat.com> wrote:

> Rajesh Kumar wrote this message on Fri, Jun 05, 2020 at 00:01 +0530:
>> Thanks Warner and Andriy for your answers.
>> 
>> Having said they are two separate instances, if the child driver calls the
>> interface of two parents as below
>> device1_interface(child_dev), then  device_get_parent(child_dev) in the
>> device1 interface will return device1 reference
>> device2_interface(child_dev), then  device_get_parent(child_dev) in the
>> device2 interface will return device2 reference
>> 
>> Is that right?
> 
> I think you're confused.  The device tree is a strict tree.  This
> means that a device can have ONLY one parent.  The multiple parents
> is simply saying that a device can attach at different points in the
> tree...
> 
> example, you have a device dev that is declared as possibly having both
> pci and simplebus:
> 
> nexus0
>  acpi0
>    pcib0
>      pci0
>        hostb0
>        pcib1
>          pci1
>            dev0
>  ofwbus0
>    simplebus1 pnpinfo compat=simple-bus
>      dev1
> 
> This example (and entirely made up, I've merged the tree from two
> different machines, running devinfo -v, only merged to make a point),
> dev0, when calling device_get_parent, will get the pci1 device, and
> dev1 when calling device_get_parent will get simplebus1...
> 
> I think this might be what you said above, but couldn't follow the
> device1_interface(child_dev) part, as that didn't make sense to me...

You have 3 "dev" names mentioned above: dev, dev0, dev1
You mention "dev" as the "device".

So am I to infer that for "dev" only one of dev0 vs. dev1
can be attached at a time (to its parent)? Code can still
find out what the alternative would be for the other one
of the two, but having both dev0 and dev1 based attachments
at the same time can not be done?

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C0CDA802-8990-41AF-91B2-C371593E6D19>