Message ID | 569F8E38.5030101@semihalf.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
On Wed, Jan 20, 2016 at 02:40:08PM +0100, Tomasz Nowicki wrote: [...] > >>>>+ /* Root bridge device needs to be sure of parent ACPI type */ > >>>>+ ACPI_COMPANION_SET(&device->dev, device); > >>> > >>>I do not understand why the code above is needed, can you elaborate > >>>please ? > >>> > >> > >>This makes sure that device->dev can be identified as ACPI device, > >>so we can use to_acpi_device_node() and assign companion safely > >>below. > > > >I do not follow. If you refer to the fwnode handle type, that is > >already set by ACPI core code (before acpi_pci_root_add() is called, > >in acpi_init_device_object()). > > acpi_init_device_object() sets ACPI fwnode handle type only for > "device", but not for "device->dev" which is what is passed as an > argument to pci_create_root_bus(). > > Without ACPI_COMPANION_SET(&device->dev, device) here, no one can be > sure if we have ACPI device in pci_create_root_bus(). Ok, got it. The question is whether this should be done in ACPI core instead (is there a reason why it should *not* be done ?), but I now understand your point. Thanks, Lorenzo -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 20.01.2016 15:22, Lorenzo Pieralisi wrote: > On Wed, Jan 20, 2016 at 02:40:08PM +0100, Tomasz Nowicki wrote: > > [...] > >>>>>> + /* Root bridge device needs to be sure of parent ACPI type */ >>>>>> + ACPI_COMPANION_SET(&device->dev, device); >>>>> >>>>> I do not understand why the code above is needed, can you elaborate >>>>> please ? >>>>> >>>> >>>> This makes sure that device->dev can be identified as ACPI device, >>>> so we can use to_acpi_device_node() and assign companion safely >>>> below. >>> >>> I do not follow. If you refer to the fwnode handle type, that is >>> already set by ACPI core code (before acpi_pci_root_add() is called, >>> in acpi_init_device_object()). >> >> acpi_init_device_object() sets ACPI fwnode handle type only for >> "device", but not for "device->dev" which is what is passed as an >> argument to pci_create_root_bus(). >> >> Without ACPI_COMPANION_SET(&device->dev, device) here, no one can be >> sure if we have ACPI device in pci_create_root_bus(). > > Ok, got it. The question is whether this should be done in ACPI > core instead (is there a reason why it should *not* be done ?), but I > now understand your point. > I am not able to answer that question, but I see lots of changes in this area made by Rafael. Rafael, can you please shed some light on this? Thanks, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jan 20, 2016 at 03:41:56PM +0100, Tomasz Nowicki wrote: > On 20.01.2016 15:22, Lorenzo Pieralisi wrote: > >On Wed, Jan 20, 2016 at 02:40:08PM +0100, Tomasz Nowicki wrote: > > > >[...] > > > >>>>>>+ /* Root bridge device needs to be sure of parent ACPI type */ > >>>>>>+ ACPI_COMPANION_SET(&device->dev, device); > >>>>> > >>>>>I do not understand why the code above is needed, can you elaborate > >>>>>please ? > >>>>> > >>>> > >>>>This makes sure that device->dev can be identified as ACPI device, > >>>>so we can use to_acpi_device_node() and assign companion safely > >>>>below. > >>> > >>>I do not follow. If you refer to the fwnode handle type, that is > >>>already set by ACPI core code (before acpi_pci_root_add() is called, > >>>in acpi_init_device_object()). > >> > >>acpi_init_device_object() sets ACPI fwnode handle type only for > >>"device", but not for "device->dev" which is what is passed as an > >>argument to pci_create_root_bus(). > >> > >>Without ACPI_COMPANION_SET(&device->dev, device) here, no one can be > >>sure if we have ACPI device in pci_create_root_bus(). > > > >Ok, got it. The question is whether this should be done in ACPI > >core instead (is there a reason why it should *not* be done ?), but I > >now understand your point. > > > > I am not able to answer that question, but I see lots of changes in > this area made by Rafael. I had a further look and I am not sure why the fwnode_handle* in the dev member of the acpi_device is not made to point at the fwnode member of the acpi_device by *default* (acpi_init_device_object() ?), probably because it is never used as such but certainly Rafael knows, so I would ask him to clarify please it is unclear to me. I do not see anything wrong in what you are doing in this patch. Rafael, any comments ? Thanks, Lorenzo -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 88c9d20..1b74bf6 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -967,7 +967,11 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, pci_add_resource(&info->resources, &root->secondary); - /* Root bridge device needs to be sure of parent ACPI type */ - ACPI_COMPANION_SET(&device->dev, device); + if (to_acpi_device_node(device->dev.fwnode) == NULL) + pr_err("NON-ACPI TYPE\n"); + else + pr_err("ACPI TYPE\n"); + bus = pci_create_root_bus(&device->dev, busnum, ops->pci_ops, sysdata, &info->resources);