Skip to content

Commit 599bad3

Browse files
committed
driver core: Add BUS_NOTIFY_REMOVED_DEVICE event
This event closes an important gap in the bus notifiers. There is already the BUS_NOTIFY_DEL_DEVICE event, but that is sent when the device is still bound to its device driver. This is too early for the IOMMU code to destroy any mappings for the device, as they might still be in use by the driver. The new BUS_NOTIFY_REMOVED_DEVICE event introduced with this patch closes this gap as it is sent when the device is already unbound from its device driver and almost completly removed from the driver core. With this event the IOMMU code can safely destroy any mappings and other data structures when a device is removed. Signed-off-by: Joerg Roedel <jroedel@suse.de> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Tested-by: Jerry Hoemann <jerry.hoemann@hp.com>
1 parent eecbad7 commit 599bad3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

drivers/base/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,9 @@ void device_del(struct device *dev)
12111211
*/
12121212
if (platform_notify_remove)
12131213
platform_notify_remove(dev);
1214+
if (dev->bus)
1215+
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
1216+
BUS_NOTIFY_REMOVED_DEVICE, dev);
12141217
kobject_uevent(&dev->kobj, KOBJ_REMOVE);
12151218
cleanup_device_parent(dev);
12161219
kobject_del(&dev->kobj);

include/linux/device.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,14 @@ extern int bus_unregister_notifier(struct bus_type *bus,
181181
* with the device lock held in the core, so be careful.
182182
*/
183183
#define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */
184-
#define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */
185-
#define BUS_NOTIFY_BIND_DRIVER 0x00000003 /* driver about to be
184+
#define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device to be removed */
185+
#define BUS_NOTIFY_REMOVED_DEVICE 0x00000003 /* device removed */
186+
#define BUS_NOTIFY_BIND_DRIVER 0x00000004 /* driver about to be
186187
bound */
187-
#define BUS_NOTIFY_BOUND_DRIVER 0x00000004 /* driver bound to device */
188-
#define BUS_NOTIFY_UNBIND_DRIVER 0x00000005 /* driver about to be
188+
#define BUS_NOTIFY_BOUND_DRIVER 0x00000005 /* driver bound to device */
189+
#define BUS_NOTIFY_UNBIND_DRIVER 0x00000006 /* driver about to be
189190
unbound */
190-
#define BUS_NOTIFY_UNBOUND_DRIVER 0x00000006 /* driver is unbound
191+
#define BUS_NOTIFY_UNBOUND_DRIVER 0x00000007 /* driver is unbound
191192
from the device */
192193

193194
extern struct kset *bus_get_kset(struct bus_type *bus);

0 commit comments

Comments
 (0)