Skip to content

Commit 0a50f61

Browse files
toddpoynorgregkh
authored andcommitted
drivers: base: initcall_debug logs for driver probe times
Add initcall_debug logs for each driver device probe call, for example: probe of a3800000.ramoops returned 1 after 3007 usecs This replaces the previous code added to report times for deferred probes. It also reports OF platform bus device creates that were formerly lumped together in a single entry for function of_platform_default_populate_init, as well as helping to annotate other initcalls that involve device probing. Remove restriction on printing probe times only during initcalls, since initcall_debug now continues to show driver timing info past the boot phase. Signed-off-by: Todd Poynor <toddpoynor@google.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7daf201 commit 0a50f61

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

drivers/base/dd.c

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static DEFINE_MUTEX(deferred_probe_mutex);
5353
static LIST_HEAD(deferred_probe_pending_list);
5454
static LIST_HEAD(deferred_probe_active_list);
5555
static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
56-
static bool initcalls_done;
5756

5857
/*
5958
* In some cases, like suspend to RAM or hibernation, It might be reasonable
@@ -62,26 +61,6 @@ static bool initcalls_done;
6261
*/
6362
static bool defer_all_probes;
6463

65-
/*
66-
* For initcall_debug, show the deferred probes executed in late_initcall
67-
* processing.
68-
*/
69-
static void deferred_probe_debug(struct device *dev)
70-
{
71-
ktime_t calltime, delta, rettime;
72-
unsigned long long duration;
73-
74-
printk(KERN_DEBUG "deferred probe %s @ %i\n", dev_name(dev),
75-
task_pid_nr(current));
76-
calltime = ktime_get();
77-
bus_probe_device(dev);
78-
rettime = ktime_get();
79-
delta = ktime_sub(rettime, calltime);
80-
duration = (unsigned long long) ktime_to_ns(delta) >> 10;
81-
printk(KERN_DEBUG "deferred probe %s returned after %lld usecs\n",
82-
dev_name(dev), duration);
83-
}
84-
8564
/*
8665
* deferred_probe_work_func() - Retry probing devices in the active list.
8766
*/
@@ -125,11 +104,7 @@ static void deferred_probe_work_func(struct work_struct *work)
125104
device_pm_move_to_tail(dev);
126105

127106
dev_dbg(dev, "Retrying from deferred list\n");
128-
if (initcall_debug && !initcalls_done)
129-
deferred_probe_debug(dev);
130-
else
131-
bus_probe_device(dev);
132-
107+
bus_probe_device(dev);
133108
mutex_lock(&deferred_probe_mutex);
134109

135110
put_device(dev);
@@ -237,7 +212,6 @@ static int deferred_probe_initcall(void)
237212
driver_deferred_probe_trigger();
238213
/* Sort as many dependencies as possible before exiting initcalls */
239214
flush_work(&deferred_probe_work);
240-
initcalls_done = true;
241215
return 0;
242216
}
243217
late_initcall(deferred_probe_initcall);
@@ -527,6 +501,23 @@ static int really_probe(struct device *dev, struct device_driver *drv)
527501
return ret;
528502
}
529503

504+
/*
505+
* For initcall_debug, show the driver probe time.
506+
*/
507+
static int really_probe_debug(struct device *dev, struct device_driver *drv)
508+
{
509+
ktime_t calltime, delta, rettime;
510+
int ret;
511+
512+
calltime = ktime_get();
513+
ret = really_probe(dev, drv);
514+
rettime = ktime_get();
515+
delta = ktime_sub(rettime, calltime);
516+
printk(KERN_DEBUG "probe of %s returned %d after %lld usecs\n",
517+
dev_name(dev), ret, (s64) ktime_to_us(delta));
518+
return ret;
519+
}
520+
530521
/**
531522
* driver_probe_done
532523
* Determine if the probe sequence is finished or not.
@@ -585,7 +576,10 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
585576
pm_runtime_get_sync(dev->parent);
586577

587578
pm_runtime_barrier(dev);
588-
ret = really_probe(dev, drv);
579+
if (initcall_debug)
580+
ret = really_probe_debug(dev, drv);
581+
else
582+
ret = really_probe(dev, drv);
589583
pm_request_idle(dev);
590584

591585
if (dev->parent)

0 commit comments

Comments
 (0)