I guess this diff would skip sending the early events.  You don't show how
it is used, in which drivers it is used, nor how they are modified to send
replacements for the skipped messages.

And then you would modify specific drivers to not send the early events,
and instead use an additional API for them to send a event when ready.

If that is the plan, some drivers would send early events which are
believed to be equivelant to ready events, and others would contain code
which only produces ready events.

I worry we'll end up in a hybrid model, and some drivers will forever
have early events which don't indicate readiness.

joshua stein <[email protected]> wrote:

> But either way, if a driver is causing a panic because it responds 
> before it is ready, the same thing would happen without hotplug if 
> it was communicated with at the wrong time (like some script running 
> in a loop).  Those drivers should just not respond to ioctls or 
> whatever they are doing before they are ready rather than just 
> hoping that no one sees their attachment too early.
> 
> 
> diff --git sys/dev/hotplug.c sys/dev/hotplug.c
> index e1e7bad95c9..434c43f4135 100644
> --- sys/dev/hotplug.c
> +++ sys/dev/hotplug.c
> @@ -73,6 +73,12 @@ hotplug_device_attach(enum devclass class, char *name)
>       hotplug_put_event(&he);
>  }
>  
> +void
> +hotplug_defer_attach(struct device *dev)
> +{
> +     dev->dv_flags |= DVF_HOTPLUG_DEFER;
> +}
> +
>  void
>  hotplug_device_detach(enum devclass class, char *name)
>  {
> diff --git sys/kern/subr_autoconf.c sys/kern/subr_autoconf.c
> index 13fafc6994e..e09f11486c0 100644
> --- sys/kern/subr_autoconf.c
> +++ sys/kern/subr_autoconf.c
> @@ -403,7 +403,7 @@ config_attach(struct device *parent, void *match, void 
> *aux, cfprint_t print)
>       (*ca->ca_attach)(parent, dev, aux);
>       config_process_deferred_children(dev);
>  #if NHOTPLUG > 0
> -     if (!cold)
> +     if (!cold && !(dev->dv_flags & DVF_HOTPLUG_DEFER))
>               hotplug_device_attach(cd->cd_class, dev->dv_xname);
>  #endif
>  
> diff --git sys/sys/device.h sys/sys/device.h
> index 90827f53503..b73b248d040 100644
> --- sys/sys/device.h
> +++ sys/sys/device.h
> @@ -81,7 +81,8 @@ struct device {
>  };
>  
>  /* dv_flags */
> -#define      DVF_ACTIVE      0x0001          /* device is activated */
> +#define      DVF_ACTIVE              0x0001          /* device is activated 
> */
> +#define      DVF_HOTPLUG_DEFER       0x0002          /* defer hotplug 
> announce */
>  
>  TAILQ_HEAD(devicelist, device);
>  
> diff --git sys/sys/hotplug.h sys/sys/hotplug.h
> index f2da3f6cfd8..7e68482a428 100644
> --- sys/sys/hotplug.h
> +++ sys/sys/hotplug.h
> @@ -35,6 +35,7 @@ struct hotplug_event {
>  #ifdef _KERNEL
>  void hotplug_device_attach(enum devclass, char *);
>  void hotplug_device_detach(enum devclass, char *);
> +void hotplug_defer_attach(struct device *);
>  #endif
>  
>  #endif       /* _SYS_HOTPLUG_H_ */
> 

Reply via email to