Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp720974imm; Wed, 17 Oct 2018 07:19:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV63f8kyzqi6MhYamCDKHPH147YuO5rsvMuk6IN42aLw9H/y1DHRb1HgpGBXkRDPqt+fIUytP X-Received: by 2002:a63:9612:: with SMTP id c18-v6mr23850617pge.21.1539785961163; Wed, 17 Oct 2018 07:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539785961; cv=none; d=google.com; s=arc-20160816; b=gF3TKQbCf8V2bPhsFGPsD0qGS++jaV8FGvI/6TiOFqlY8RMrVvDK37dpIJIsJFanOW 7GoaPTSsOEaZAUEZbkj6xPL9+ofR+3b4B1RJggEkbLfxX7LPs1NxT88WzakycGEQV4nf lhl8ftMpfYVE3cIUq1EbTA03QiBUXy4P/3/NQyPGoNg/bB/k2AiMmyZJsHWP2XIPGrkD YWR7bURvdOIHVreL42d84vGGqTItVsroPyxqS18h8vY2Yoo4I1E0Ig3YoNiDITWBTVka chE56X4OWZlJZnQGjYbOciMp6YWsYh4XlnqJlh3ZN2h9gAVA27JAknyvLk2zfM/cWpwz WcRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Auy6A7nZyjkaINCspo+YaVJkei55i/ixp+Oe//zMYAI=; b=kaMqiYYq6JIFb8T7EXMLsP3ppIHifRe2Y6M/7FaePfon9GE0cYZMe0Fj3zx2foT0yl lpKJz4C8vmnO0c/zguwO9QuCYg39V1yAIYlyc7XY1GyaqaW+y/6FC0i87D1LHXEKUUNg OJ9OTmPogdGKo5fXmb/JoX30+vq9KKe07e2XD+OIwNCSq2J8QCrNy+NaT8bS+G7puFaF ziShB8zDbXyeJP/XL8OkdQqGFwWzD9TiPfilljDcMcHtWdYUHuQjCRhsCVxhefMT9k9Z UYrpC1kN+87QzlazFS+Hqc11cP2coYWc5SsoVkHbVXH9aDX+0TlgBehPSogI53Ma92Q2 dewQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtNsF1Xd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23-v6si17791363plr.83.2018.10.17.07.19.00; Wed, 17 Oct 2018 07:19:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtNsF1Xd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbeJQWNq (ORCPT + 99 others); Wed, 17 Oct 2018 18:13:46 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:35950 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727568AbeJQWNq (ORCPT ); Wed, 17 Oct 2018 18:13:46 -0400 Received: by mail-qk1-f194.google.com with SMTP id a85-v6so16548345qkg.3 for ; Wed, 17 Oct 2018 07:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Auy6A7nZyjkaINCspo+YaVJkei55i/ixp+Oe//zMYAI=; b=qtNsF1XdZO76bEEXRMIOlycYeCY60Pl5udpkdW6m6XbQLjrdcCc3mtvU8DnNr74nWG DtMWrvmnbSLh+K5sFKvI0+VyErGgZzGGLvfpoCIybfpJXvcZk1CDXC9MTF4zw9i6z1BK /EfILSGDbcVMIZNH5oSrbm/rRYUNLanEDrhfoMxxJ+fy6yqCXcGktTItZXbWw7SME6Dl egMcE+hcguYOOeg7XPnr7Ri+jtLWKryZ95uAhYQKSqPSMt8oRqiU+DcxcM1NMu/Xiy3Q DsUgFK9lc/5KkIF8a2eOB7E6616n501NRAX4e/hlwEQ/ZsWVVmT2YnLHkYCX1m33EhUI fZjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Auy6A7nZyjkaINCspo+YaVJkei55i/ixp+Oe//zMYAI=; b=ipmQPjziu9cA84utUY/Hc6nejKHPRYZz0HtcJE9fti9Fsv3MwOLmFxuEyRdFFtcXIu 6rOJmuZb7gTa0UHqMx/Jh4uZqj4kwXPO08JkaIrj3J6LIo/K4lpXnMpz/diGOpm9ddHw aUfziZqOLygm8HHjBHco8HzJYTFov3Gtyz/NiD5AU+yJb9xwUwWoLJqA8aTSp/4wa7jr nBz5rGZdc0EEWoppXkEJ7EUr+Q4by2sUja/+Qm/03CTo7jlTYuX+FmKM+r8giWjlUqWb ECtPUNjcT6BoynfsGGVU5uAaQXPy4JpZNg+0RervbFneBB0gzuxYsFzuTBart92R7ncF pn4Q== X-Gm-Message-State: ABuFfoiCN6So34PhLb0cnjwPS25K7NTWIBohTNpEkLt355jVGiDkGJ8R BK7uD0X35HndhXlE03X+CBk7vfir/GNuiZ4TkPU= X-Received: by 2002:ae9:c307:: with SMTP id n7-v6mr24669009qkg.70.1539785871263; Wed, 17 Oct 2018 07:17:51 -0700 (PDT) MIME-Version: 1.0 References: <20181017132400.5300-1-a.hajda@samsung.com> In-Reply-To: <20181017132400.5300-1-a.hajda@samsung.com> From: Andy Shevchenko Date: Wed, 17 Oct 2018 17:17:39 +0300 Message-ID: Subject: Re: [PATCH v3 2/4] driver core: add deferring probe reason to devices_deferred property To: Andrzej Hajda Cc: Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , Marek Szyprowski , "Rafael J. Wysocki" , Linux Kernel Mailing List , Javier Martinez Canillas , linux-arm Mailing List , Mark Brown , Russell King - ARM Linux Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 17, 2018 at 4:24 PM Andrzej Hajda wrote: > > /sys/kernel/debug/devices_deferred property contains list of deferred devices. > This list does not contain reason why the driver deferred probe, the patch > improves it. > The natural place to set the reason is probe_err function introduced recently, > ie. if probe_err will be called with -EPROBE_DEFER instead of printk the message > will be attached to deferred device and printed when user read devices_deferred > property. > > Signed-off-by: Andrzej Hajda > Reviewed-by: Mark Brown > Reviewed-by: Javier Martinez Canillas > Reviewed-by: Andy Shevchenko > --- > v3: > - adjusted deferred_devs_show, to accept newline ended messages, > - changed conditonal check to positive, > - added R-b by Andy. > v2: > - changed __deferred_probe_set_msg args - like in __dev_printk, fits better, > - use kasprintf instead of bunch of code, > - keep consistent format of devices_deferred lines, > - added R-Bs (again I hope changes above are not against it). > --- > drivers/base/base.h | 3 +++ > drivers/base/core.c | 9 +++++---- > drivers/base/dd.c | 21 ++++++++++++++++++++- > 3 files changed, 28 insertions(+), 5 deletions(-) > > diff --git a/drivers/base/base.h b/drivers/base/base.h > index 7a419a7a6235..effbd5e7f9f1 100644 > --- a/drivers/base/base.h > +++ b/drivers/base/base.h > @@ -75,6 +75,7 @@ struct device_private { > struct klist_node knode_driver; > struct klist_node knode_bus; > struct list_head deferred_probe; > + char *deferred_probe_msg; > struct device *device; > }; > #define to_device_private_parent(obj) \ > @@ -113,6 +114,8 @@ extern void device_release_driver_internal(struct device *dev, > extern void driver_detach(struct device_driver *drv); > extern int driver_probe_device(struct device_driver *drv, struct device *dev); > extern void driver_deferred_probe_del(struct device *dev); > +extern void __deferred_probe_set_msg(const struct device *dev, > + struct va_format *vaf); > static inline int driver_match_device(struct device_driver *drv, > struct device *dev) > { > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 1f3e99c2ef03..27990110fb24 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -3076,6 +3076,7 @@ define_dev_printk_level(_dev_info, KERN_INFO); > * > * This helper implements common pattern present in probe functions for error > * checking: print message if the error is not -EPROBE_DEFER and propagate it. > + * In case of -EPROBE_DEFER it sets defer probe reason. > * It replaces code sequence: > * if (err != -EPROBE_DEFER) > * dev_err(dev, ...); > @@ -3091,14 +3092,14 @@ int probe_err(const struct device *dev, int err, const char *fmt, ...) > struct va_format vaf; > va_list args; > > - if (err == -EPROBE_DEFER) > - return err; > - > va_start(args, fmt); > vaf.fmt = fmt; > vaf.va = &args; > > - dev_err(dev, "error %d: %pV", err, &vaf); > + if (err == -EPROBE_DEFER) > + __deferred_probe_set_msg(dev, &vaf); > + else > + dev_err(dev, "error %d: %pV", err, &vaf); > > va_end(args); > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > index 169412ee4ae8..6e488146b328 100644 > --- a/drivers/base/dd.c > +++ b/drivers/base/dd.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > #include "base.h" > #include "power/power.h" > @@ -132,6 +133,8 @@ void driver_deferred_probe_del(struct device *dev) > if (!list_empty(&dev->p->deferred_probe)) { > dev_dbg(dev, "Removed from deferred list\n"); > list_del_init(&dev->p->deferred_probe); > + kfree(dev->p->deferred_probe_msg); > + dev->p->deferred_probe_msg = NULL; > } > mutex_unlock(&deferred_probe_mutex); > } > @@ -202,6 +205,21 @@ void device_unblock_probing(void) > driver_deferred_probe_trigger(); > } > > +/* > + * __deferred_probe_set_msg() - Set defer probe reason message for device > + */ > +void __deferred_probe_set_msg(const struct device *dev, struct va_format *vaf) > +{ > + mutex_lock(&deferred_probe_mutex); > + > + if (dev->p->deferred_probe_msg) Sorry, I have noticed this a bit late, this check is not needed, since kfree() is NULL-aware. > + kfree(dev->p->deferred_probe_msg); > + dev->p->deferred_probe_msg = kasprintf(GFP_KERNEL, "%s: %pV", > + dev_driver_string(dev), vaf); ...and perhaps slightly better looking (up to you): const char *drv = dev_driver_string(dev); ... ... = kasprintf(..., drv, ...); // it would be exactly oneline > + > + mutex_unlock(&deferred_probe_mutex); > +} > + > /* > * deferred_devs_show() - Show the devices in the deferred probe pending list. > */ > @@ -212,7 +230,8 @@ static int deferred_devs_show(struct seq_file *s, void *data) > mutex_lock(&deferred_probe_mutex); > > list_for_each_entry(curr, &deferred_probe_pending_list, deferred_probe) > - seq_printf(s, "%s\n", dev_name(curr->device)); > + seq_printf(s, "%s\t%s", dev_name(curr->device), > + curr->device->p->deferred_probe_msg ?: "\n"); > > mutex_unlock(&deferred_probe_mutex); > > -- > 2.18.0 > -- With Best Regards, Andy Shevchenko