From: Greg KH <gregKH@linuxfoundation.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: linux-usb@vger.kernel.org, stern@rowland.harvard.edu
Subject: Re: [PATCHv2] base: force NOIO allocations during unplug
Date: Thu, 17 Sep 2020 08:41:45 +0200 [thread overview]
Message-ID: <20200917064145.GA3194762@kroah.com> (raw)
In-Reply-To: <20200916191544.5104-1-oneukum@suse.com>
On Wed, Sep 16, 2020 at 09:15:44PM +0200, Oliver Neukum wrote:
> 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 <oneukum@suse.com>
> ---
> drivers/base/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index bb5806a2bd4c..b79783454293 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -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);
> --
> 2.16.4
>
Thanks, now queued up.
greg k-h
prev parent reply other threads:[~2020-09-17 6:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 19:15 [PATCHv2] base: force NOIO allocations during unplug Oliver Neukum
2020-09-17 6:41 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200917064145.GA3194762@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).