Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp543133imm; Wed, 17 Oct 2018 04:36:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV62EMz4w/yOuutLgQG1jw39FW8RVmpvkHW5Cru6kPgxuqUeWxJX6mndqWQJbzBMx0hWV/Rif X-Received: by 2002:a62:e80c:: with SMTP id c12-v6mr26375692pfi.124.1539776161555; Wed, 17 Oct 2018 04:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539776161; cv=none; d=google.com; s=arc-20160816; b=blercPwMQrhMWFS9rBzAuL3TNY91cQCDuWtc5KHQ0WWq0Mu0vLQzCFhXZvdf3y6ALE soOG+/XIzPfQzQRpD4o+N91fgPdKi6WhN7m1thPEoD9O6vJevbq1+frSxuSX+dVpAmJm dpxlcPQNy7aU9+yT12n1Bd8Lzb+BeRRV0wuA7w3+iTfGUsqoqIW7VYztubNku8sxxQ3j UJ6GbTxdGHdmIkh5zP3h46PE/rrAQlSwXnM6U/XqsU+PrlwIYhtBIsa7SvjDqEgKuDW7 NKYV2yy302pux1e/cBI8DBWGGJu03uIpjKAlxpyYvwkmETLTDMf6rkER75EvEn9VTef9 ZkQg== 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=04QSD0e3zhfJhEu92WOWMQ/lx1OgM8EE3aevV5ZUBes=; b=y6s9fVx630wDRt6DSbU3UdBkM3kmRJEwqx+T4UQ578FqP+SwNHEtWNHPMcP/1t4VM9 z7GRoIrQYtyDUYuGZNNn/HUkOchydE8tWWyCRjM+FsxC1sbSmD+Y2FfG9EnhWxBnEA2I XUpEOjrgtTyP2YCza8WUB7UKVNMhFmu+1hytU82X3Ok3NAwyg9P8Wp0uppOq5sXCVPW9 J0NnhvytlWz5IXWuHXodOZ69+FQf+wYDzqCOEmRlObGZnX3Imic9tDkun42gKXFju9yL VbsyzXLsNk/Tka6tb0dGP7QN/RyX1LZx4mnjFJxEADre+Q6S7u6OVz3e0BPs8F224mSj YPkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lRADcSez; 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 x6-v6si17263252pgf.303.2018.10.17.04.35.44; Wed, 17 Oct 2018 04:36:01 -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=lRADcSez; 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 S1727139AbeJQTaa (ORCPT + 99 others); Wed, 17 Oct 2018 15:30:30 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:37605 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeJQTaa (ORCPT ); Wed, 17 Oct 2018 15:30:30 -0400 Received: by mail-qt1-f195.google.com with SMTP id d14-v6so29498398qto.4 for ; Wed, 17 Oct 2018 04:35:12 -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=04QSD0e3zhfJhEu92WOWMQ/lx1OgM8EE3aevV5ZUBes=; b=lRADcSezK8m3JIyvqHqisMjLFm2Fh9HqPaXDLRA++jwUS6l7hcvA6ao5k+kXSiyEe+ 9dDijdHWnB0mIlj5+y1PE8UB//x4e3t7Wif7u1Vk8AGSSdZhzCsk+rc6aLY08ysJc1/W ldLJQA6Awn3EOiLkljdrysAZDoqA09x7CJralRk+4JD7KmOJNAVahhT9sI1yoPPTgWA3 6lTNhtlMLvSo8vPkdeNYqQk1OJpLpNv3vKMhopmOHKy9s8VE7QyoMBVTmwwFzy+uBv0A 3bBCIleThfBWXyj/1blBKd1tsut9ExLb7Kx9SPSAdSX/iCbO8G45/bk5t7iaP4FHVPel EJAw== 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=04QSD0e3zhfJhEu92WOWMQ/lx1OgM8EE3aevV5ZUBes=; b=AordX27KF2OnEqWR/1ymg59xCWB5PJ0bgFqmA1aniYiedhPTmTDbzs610JB4+Ihmpm XAgJ70Olz9PPSwMx4Am94CWZgZ/ABa1PE5tbguEtme+Ef6YOydupzZCpJNExV1J7d3AJ rR4ydL3eh6L9Sj+53VlDYEcd4shjDlr8PtyyyS461b4MNI8zaCckUuar0f9F/K8SHpSo 6JSqL2d5JAmJvsPe9xMEv6UDgsmGvQh98zxDqZK+q1Ol5disQWlmXt4jMnAZRKoLS1mr NHLOn6Vo7qSj2w0HXOZlwCZ2TV8gofLsXmZA4BdWC1R2HtHMrwVUlGw6ncLaK2p0Ua0l ZyDA== X-Gm-Message-State: ABuFfogUhn/+ydUnj68dyKx50EP0cYct3TOqzJig249jK636g0GeDNjZ +0FdOV3fZeUdLHdHamSCRGuBIbyP9Xqztpjj25Y= X-Received: by 2002:aed:2de3:: with SMTP id i90-v6mr5625705qtd.229.1539776111662; Wed, 17 Oct 2018 04:35:11 -0700 (PDT) MIME-Version: 1.0 References: <20181017085936.30886-1-a.hajda@samsung.com> In-Reply-To: <20181017085936.30886-1-a.hajda@samsung.com> From: Andy Shevchenko Date: Wed, 17 Oct 2018 14:35:00 +0300 Message-ID: Subject: Re: [PATCH v2 2/3] 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 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 11:59 AM 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. > Looks good to me (with one comment below since patch 1 will be changed anyway), Reviewed-by: Andy Shevchenko > Signed-off-by: Andrzej Hajda > Reviewed-by: Mark Brown > Reviewed-by: Javier Martinez Canillas > --- > 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 | 11 +++++++---- > drivers/base/dd.c | 21 ++++++++++++++++++++- > 3 files changed, 30 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 aa6f3229d066..560758b2ae79 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,13 +3092,15 @@ 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, "%pV, %d\n", &vaf, err); > + This new line can be part of patch 1. > + if (err != -EPROBE_DEFER) > + dev_err(dev, "%pV, %d\n", &vaf, err); > + else > + __deferred_probe_set_msg(dev, &vaf); > + Here you may still keep the same, i.e. positive, conditional. > va_end(args); > > return err; > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > index 169412ee4ae8..345fbfe335d1 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) > + kfree(dev->p->deferred_probe_msg); > + dev->p->deferred_probe_msg = kasprintf(GFP_KERNEL, "%s: %pV", > + dev_driver_string(dev), vaf); > + > + 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\n", dev_name(curr->device), > + curr->device->p->deferred_probe_msg ?: ""); > > mutex_unlock(&deferred_probe_mutex); > > -- > 2.18.0 > -- With Best Regards, Andy Shevchenko