Skip to content

Commit 95d23dc

Browse files
xairytorvalds
authored andcommitted
usb, kcov: collect coverage from hub_event
Add kcov_remote_start()/kcov_remote_stop() annotations to the hub_event() function, which is responsible for processing events on USB buses, in particular events that happen during USB device enumeration. Since hub_event() is run in a global background kernel thread (see Documentation/dev-tools/kcov.rst for details), each USB bus gets a unique global handle from the USB subsystem kcov handle range. As the result kcov can now be used to collect coverage from events that happen on a particular USB bus. [[email protected]: avoid patch conflicts to make life easier for Andrew] Link: http://lkml.kernel.org/r/de4fe1c219db2d002d905dc1736e2a3bfa1db997.1572366574.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Cc: Alan Stern <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Anders Roxell <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: David Windsor <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Elena Reshetova <[email protected]> Cc: Jason Wang <[email protected]> Cc: Marco Elver <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent eec028c commit 95d23dc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/usb/core/hub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/sched/mm.h>
1919
#include <linux/list.h>
2020
#include <linux/slab.h>
21+
#include <linux/kcov.h>
2122
#include <linux/ioctl.h>
2223
#include <linux/usb.h>
2324
#include <linux/usbdevice_fs.h>
@@ -5484,6 +5485,8 @@ static void hub_event(struct work_struct *work)
54845485
hub_dev = hub->intfdev;
54855486
intf = to_usb_interface(hub_dev);
54865487

5488+
kcov_remote_start_usb((u64)hdev->bus->busnum);
5489+
54875490
dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
54885491
hdev->state, hdev->maxchild,
54895492
/* NOTE: expects max 15 ports... */
@@ -5590,6 +5593,8 @@ static void hub_event(struct work_struct *work)
55905593
/* Balance the stuff in kick_hub_wq() and allow autosuspend */
55915594
usb_autopm_put_interface(intf);
55925595
kref_put(&hub->kref, hub_release);
5596+
5597+
kcov_remote_stop();
55935598
}
55945599

55955600
static const struct usb_device_id hub_id_table[] = {

0 commit comments

Comments
 (0)