base: force NOIO allocations during unplug
Subsystems (2)
PATCH v2 1/1 base: force NOIO allocations during unplug
There is one overlooked situation under which a driver must not do IO to allocate memory. You cannot do that while disconnecting a device. A device being disconnected is no longer functional in most cases, yet IO may fail only when the handler runs.
v2: extended section for NOIO until after second notifier chain
Signed-off-by Oliver Neukum <[email protected]>
--- drivers/base/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/base/core.c +4 -0
@@ -26,6 +26,7 @@#include <linux/pm_runtime.h> #include <linux/netdevice.h> #include <linux/sched/signal.h> +#include <linux/sched/mm.h> #include <linux/sysfs.h> #include "base.h"
@@ -3062,6 +3063,7 @@ void device_del(struct device *dev)struct device *parent = dev->parent;struct kobject *glue_dir =NULL ;struct class_interface *class_intf; +unsigned int noio_flag;device_lock (dev);kill_device (dev);
@@ -3073,6 +3075,7 @@ void device_del(struct device *dev)/* Notify clients of device removal. This call must come * before dpm_sysfs_remove(). */ + noio_flag =memalloc_noio_save ();if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DEL_DEVICE , dev);
@@ -3114,6 +3117,7 @@ void device_del(struct device *dev) glue_dir =get_glue_dir (dev);kobject_del (&dev->kobj);cleanup_glue_dir (dev, glue_dir); +memalloc_noio_restore (noio_flag);put_device (parent); }EXPORT_SYMBOL_GPL (device_del);
Signature · 1 line
2.16.4
Greg KH
maintainerQuoted 52 lines · Oliver Neukum
There is one overlooked situation under which a driver must not do IO to allocate memory. You cannot do that while disconnecting a device. A device being disconnected is no longer functional in most cases, yet IO may fail only when the handler runs.
v2: extended section for NOIO until after second notifier chain
Signed-off-by Oliver Neukum <[email protected]>--- drivers/base/core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/base/core.c +4
-0@@ -26,6 +26,7 @@#include <linux/pm_runtime.h> #include <linux/netdevice.h> #include <linux/sched/signal.h> +#include <linux/sched/mm.h> #include <linux/sysfs.h> #include "base.h" @@ -3062,6 +3063,7 @@ void device_del(struct device *dev)struct device *parent = dev->parent;struct kobject *glue_dir =NULL ;struct class_interface *class_intf; +unsigned int noio_flag;device_lock (dev);kill_device (dev);@@ -3073,6 +3075,7 @@ void device_del(struct device *dev)/* Notify clients of device removal. This call must come * before dpm_sysfs_remove(). */ + noio_flag =memalloc_noio_save ();if (dev->bus)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DEL_DEVICE , dev);@@ -3114,6 +3117,7 @@ void device_del(struct device *dev) glue_dir =get_glue_dir (dev);kobject_del (&dev->kobj);cleanup_glue_dir (dev, glue_dir); +memalloc_noio_restore (noio_flag);put_device (parent); }EXPORT_SYMBOL_GPL (device_del);Signature · 1 line
2.16.4
Thanks, now queued up.
greg k-h