public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* ACPI hot-plug notification help needed
@ 2005-07-25 23:35 Bjorn Helgaas
       [not found] ` <200507251735.23394.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
       [not found] ` <200508011620.02609.bjorn.helgaas@hp.com>
  0 siblings, 2 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2005-07-25 23:35 UTC (permalink / raw)
  To: naveen.b.s-ral2JQCrhuEAvxtiuMwx3w,
	anil.s.keshavamurthy-ral2JQCrhuEAvxtiuMwx3w
  Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Can somebody explain how the notification stuff in the ACPI
memory and container drivers works?

The usual ACPI driver registers its IDs and add() and remove()
functions with acpi_bus_register_driver(), and the ACPI core
calls the add() function when it finds a device that is present
(based on _STA) and whose _HID or _CID matches.

The memory and container drivers (acpi_memhotplug.c[1] and container.c)
also do this.  But in addition, they traverse the entire ACPI namespace
and attach notify handlers to any devices that match the IDs[2], even
if the _STA indicates "not present".

It seems strange to attach notify handlers to devices that are
not present.  Maybe ACPI allows events to be sent to devices that
don't exist, but it just seems weird.  I'd expect a hotplug add to
cause events to some previously-present *parent* of the new device.
The parent's driver could then re-scan its children and add any
that are newly-added or newly-marked "present".

But these drivers seem to expect hot-add events on the new device
itself, and then they go through the motions of acpi_bus_add()
directly.  This seems like it belongs somewhere in the ACPI core.

I just noticed that the processor_core and acpiphp_glue drivers
do the same thing.  Does this mean that other ACPI drivers that
want to handle hot-plug will also have to go through this dance
of attaching notify handlers to non-present devices?  Does ACPI
have to supply nodes for every possible hot-pluggable device in
the namespace at boot-time, just to provide places to hang these
handlers?

Please enlighten me.

[1] "acpi_memhotplug.c" seems redundant.  Wouldn't "memory.c"
     be just as descriptive?  It's in the ACPI directory, so
     we don't need "acpi_", and ACPI drivers in general can
     support hotplug, so it doesn't seem like we need that either.

[2] This match is not as completely implemented as that in the
    ACPI core, so it doesn't check _CID.  So this seems like a
    case where duplication of functionality leads to maintenance
    problems.  Compare is_root_bridge(), is_memory_device(), and
    container_walk_namespace_cb().


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: ACPI hot-plug notification help needed
@ 2005-07-26  4:28 S, Naveen B
  0 siblings, 0 replies; 13+ messages in thread
From: S, Naveen B @ 2005-07-26  4:28 UTC (permalink / raw)
  To: Keshavamurthy, Anil S, Bjorn Helgaas, Tolentino, Matthew E
  Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

I agree with Anil's comments. 
See my comments below. 

>>> Can somebody explain how the notification stuff in the ACPI
>>> memory and container drivers works?
>>Sure.
>>>
>>> The usual ACPI driver registers its IDs and add() and remove()
>>> functions with acpi_bus_register_driver(), and the ACPI core
>>> calls the add() function when it finds a device that is present
>>> (based on _STA) and whose _HID or _CID matches.
>>
>>Humm.. I would say that ACPI core calls the add() functions
>>for all the devices which it has seen during its boot( of course
>>based on _STA) and whose _HID or _CID matches.
>>
>>Here is how the current core works.
>>During system boot the ACPI core scans for all the devices
>>in its root namespace scope i.e by calling acpi_bus_scan()
>>and for each device whose _STA is present calls acpi_bus_add()
>>which stores the device in linked list. Later when ACPI driver
>>registers its IDs the ACPI core just looks in this device list.
>>The core does not keep track of devices whose _STA became present
>>after boot.
>>
>>>
>>> The memory and container drivers (acpi_memhotplug.c[1] and
container.c)
>>> also do this.  But in addition, they traverse the entire ACPI
namespace
>>> and attach notify handlers to any devices that match the IDs[2],
even
>>> if the _STA indicates "not present".
>>
>>This is how the ACPI core expects us to register for all the devices
>>for which we care notifications. We want to register for all the
devices
>>i.e for the devices which are present and for devices which are not
>>present.
>>To do this we walk the entire namespace scope and check for _HID or
_CID
>>match and register a notify handler for this device.
>>
>>>
>>> It seems strange to attach notify handlers to devices that are
>>> not present.  Maybe ACPI allows events to be sent to devices that
>>> don't exist, but it just seems weird.  I'd expect a hotplug add to
>>
>>When we were implementing this even for us it looked strange that
>>we have to attach a notify handlers for each and every device. Believe
>>me this is how we had to do.
>>
>>> cause events to some previously-present *parent* of the new device.
>>> The parent's driver could then re-scan its children and add any
>>> that are newly-added or newly-marked "present".
>>
>>This might not alway be true. Some f/w might not want to send
>>notification on the parent as the re-scan might be a costly operation
>>as the parent might contain a large number of children. Imaging a case
>>where we want to attach a device under _SB scope, in case if the
>>notification went to _SB and we have rescan the whole namespace here.
>>
>>>
>>> But these drivers seem to expect hot-add events on the new device
>>> itself, and then they go through the motions of acpi_bus_add()
>>> directly.  This seems like it belongs somewhere in the ACPI core.
>>
>>The core functionality still recides inside ACPI core, it just that
>>these drivers which support hotplug are responsible for registering
>>for a notification and based on the notification they have to call
>>acpi_bus_add() to add the device and from then on the acpi_bus_add()
>>function takes care of doing rest of the stuff including calling
>>add() function of the driver.
>>
>>>
>>> I just noticed that the processor_core and acpiphp_glue drivers
>>> do the same thing.  Does this mean that other ACPI drivers that
>>> want to handle hot-plug will also have to go through this dance
>>> of attaching notify handlers to non-present devices?  Does ACPI
>>Don't you think even acpiphp drivers which support slot hotplug
>>also does the same thing?
>>> have to supply nodes for every possible hot-pluggable device in
>>> the namespace at boot-time, just to provide places to hang these
>>> handlers?
>>Yes, the ACPI namespace has to list its max possible configuration
>>in its namespace.
>>
>>>
>>> Please enlighten me.
>>>
>>> [1] "acpi_memhotplug.c" seems redundant.  Wouldn't "memory.c"
>>>      be just as descriptive?  It's in the ACPI directory, so
>>>      we don't need "acpi_", and ACPI drivers in general can
>>>      support hotplug, so it doesn't seem like we need that either.
>>Naveen, any thoughts on this one?
This was renamed to acpi_memhotplug.c, which is more descriptive, based
on the feedback. We might not need "acpi_" though. This driver is very
much required mainly to field hot plug notifications on memory devices
and to interface with Kernel VM subsystem, which ACPI drivers in general
cannot support.
>>>
>>> [2] This match is not as completely implemented as that in the
>>>     ACPI core, so it doesn't check _CID.  So this seems like a
>>>     case where duplication of functionality leads to maintenance
>>>     problems.  Compare is_root_bridge(), is_memory_device(), and
>>>     container_walk_namespace_cb().
>>Patch welcome:-)
>>
>>-Anil


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-08-03 21:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-25 23:35 ACPI hot-plug notification help needed Bjorn Helgaas
     [not found] ` <200507251735.23394.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2005-07-26  0:39   ` Keshavamurthy Anil S
     [not found]     ` <20050725173911.A24040-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2005-07-26 19:56       ` Bjorn Helgaas
     [not found]         ` <200507261356.08152.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2005-07-27  0:05           ` Keshavamurthy Anil S
     [not found]             ` <20050726170459.A5591-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2005-07-27 23:06               ` Bjorn Helgaas
     [not found] ` <200508011620.02609.bjorn.helgaas@hp.com>
     [not found]   ` <20050801170345.A16268@unix-os.sc.intel.com>
     [not found]     ` <20050801170345.A16268-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2005-08-02 22:41       ` Bjorn Helgaas
     [not found]         ` <200508021641.26007.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2005-08-03  4:37           ` Kenji Kaneshige
2005-08-03 19:36           ` Keshavamurthy Anil S
     [not found]             ` <20050803123627.A4443-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2005-08-03 20:27               ` Bjorn Helgaas
     [not found]                 ` <200508031427.11057.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2005-08-03 20:55                   ` Keshavamurthy Anil S
     [not found]                     ` <20050803135511.B5010-39QZ/XbsZ5/mO6KZMuUCQVaTQe2KTcn/@public.gmane.org>
2005-08-03 21:13                       ` Bjorn Helgaas
     [not found]                         ` <200508031513.30570.bjorn.helgaas-VXdhtT5mjnY@public.gmane.org>
2005-08-03 21:41                           ` Keshavamurthy Anil S
  -- strict thread matches above, loose matches on Subject: below --
2005-07-26  4:28 S, Naveen B

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox