From patchwork Tue Oct 16 07:22:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10643171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D8EE109C for ; Tue, 16 Oct 2018 07:23:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70281283BF for ; Tue, 16 Oct 2018 07:23:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 642BF286B0; Tue, 16 Oct 2018 07:23:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3933028435 for ; Tue, 16 Oct 2018 07:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-reply-to:Message-id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HJKObpdgn6EzgyE5Ac/ZH0Lx8od984lkYAH7qVev1r0=; b=uSIGDKTOwvevZgOzChpfQTd6x6 BeusmA6blTJbNuZJxlCOnTQDLNMACTKnHJBc5EpR3x1Ur2/H4h1MkSgXbc7NxE1RHAg9sXTlqZRby piPvzJMQej2skPn/nEXmCidIbsOLccl0R41fghQ6ve9i7uqZuDGWXIqcvGfHaVgbRRz2SN+JYiyuu TtCkxKfL56vYNd/RDqV1T9p+1NKGeoLFNzcLGEYqiIbOMo5bfnZeeizXQDRkAHErFWro8Xv5DwfCR xNHYDXuKhMIm+8qDDofI4WY2bd1CRNCCd2xrvZoQGE5ynRjo+NDBmvKdHbXDSxmKM3UfE42pYfJyi l97wtcdw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCJh9-00009J-Qx; Tue, 16 Oct 2018 07:23:11 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCJh3-00006s-AO for linux-arm-kernel@lists.infradead.org; Tue, 16 Oct 2018 07:23:07 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181016072251euoutp028054f81d8b6633c73bbb805aedf07bdb~eBd1qSgM81635816358euoutp02G; Tue, 16 Oct 2018 07:22:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181016072251euoutp028054f81d8b6633c73bbb805aedf07bdb~eBd1qSgM81635816358euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539674571; bh=n6s8ODfGLPqt06r2NaOTqEiqXV/ukN9zx/7Pm9IszQY=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=NWypIqF+yyM+Kpywi/RAx1LjeWf2aVwz6I3NDhDZkPp7w8l+It6nVY9Czk192+Um4 NfI8AEbk8RIjTPtUTwx2BBviorGR8XJ9OoVknibXevcfsnfn18LahvMzKXVj2FHh6l QTeF4NmfP36cuemuyV+XHvH1YYymjhhhP4xJKpMo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181016072250eucas1p1ebd0f93494648a7b2177c051a3e9124b~eBd1FnnA01687516875eucas1p1q; Tue, 16 Oct 2018 07:22:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 58.F8.04294.AC195CB5; Tue, 16 Oct 2018 08:22:50 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181016072249eucas1p28855602564eb74a771fe521712962680~eBd0UM8Ui2131721317eucas1p2q; Tue, 16 Oct 2018 07:22:49 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-c0-5bc591cabcce Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DD.F5.04284.9C195CB5; Tue, 16 Oct 2018 08:22:49 +0100 (BST) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PGO0048DKHZVR70@eusync1.samsung.com>; Tue, 16 Oct 2018 08:22:49 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH 2/3] driver core: add deferring probe reason to devices_deferred property Date: Tue, 16 Oct 2018 09:22:43 +0200 Message-id: <20181016072244.1216-3-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: <20181016072244.1216-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsWy7djPc7qnJh6NNmjs5Le4te4cq8XLCYcZ LTbOWM9qMfXhEzaL5sXr2SwWTlvOaLHp8TVWi8u75rBZrD1yl91i7pepzA5cHjtn3WX32LSq k81j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BAtcfrtTzCbRUBVYlr7BXYQm1fAXOLSzMNgcQkBeYmH x9vBbE4BC4nrGzYzg9hCQDW3L7SxT2DkWcDIsIpRJLW0ODc9t9hQrzgxt7g0L10vOT93EyMw 2LYd+7l5B+OljcGHGAU4GJV4eH9cPxItxJpYVlyZe4hRgoNZSYRXtvJotBBvSmJlVWpRfnxR aU5q8SFGaQ4WJXHe8waVUUIC6YklqdmpqQWpRTBZJg5OqQZGbZ1rk2v8+Z1Ytz1OWL7zqP2O 1B/+CTwZ+76f+WWfuWn3c53uXYtbZtzgvJ+gFLuJ3/FFq0b+ySe3H64L+NNbXRXbyXrDfY1B g/v+2r0RNXreDGwi+00OlrLPqPrAZr40plrgn2u+1cslsWWbAh+e7VMsP5LAsH/elTn3LDI4 SyVm+TXXGd9UYinOSDTUYi4qTgQAdw6ryjICAAA= X-CMS-MailID: 20181016072249eucas1p28855602564eb74a771fe521712962680 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181016072249eucas1p28855602564eb74a771fe521712962680 References: <20181016072244.1216-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181016_002305_498326_2588D0E9 X-CRM114-Status: GOOD ( 21.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Javier Martinez Canillas , Andrzej Hajda , andy.shevchenko@gmail.com, Mark Brown , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP /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: Javier Martinez Canillas --- drivers/base/base.h | 3 +++ drivers/base/core.c | 15 +++++++++------ drivers/base/dd.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 7a419a7a6235..6f9371bfe40b 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, const char *fmt, + va_list args); 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 23fabefb217a..df9895adf11b 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,15 +3092,17 @@ int probe_err(const struct device *dev, int err, const char *fmt, ...) struct va_format vaf; va_list args; - if (err != -EPROBE_DEFER) { - va_start(args, fmt); + va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; + vaf.fmt = fmt; + vaf.va = &args; + if (err != -EPROBE_DEFER) __dev_printk(KERN_ERR, dev, &vaf); - va_end(args); - } + else + __deferred_probe_set_msg(dev, fmt, args); + + va_end(args); return err; } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 169412ee4ae8..e2f81e538d4b 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,32 @@ 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, const char *fmt, + va_list args) +{ + const int size = 128; + char **p; + int n; + + mutex_lock(&deferred_probe_mutex); + + p = &dev->p->deferred_probe_msg; + if (!*p) { + *p = kmalloc(size, GFP_KERNEL); + if (!*p) + goto end; + } + n = snprintf(*p, size, "%s %s: ", dev_driver_string(dev), dev_name(dev)); + if (n < size) + vsnprintf(*p + n, size - n, fmt, args); + +end: + mutex_unlock(&deferred_probe_mutex); +} + /* * deferred_devs_show() - Show the devices in the deferred probe pending list. */ @@ -212,7 +241,10 @@ 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)); + if (curr->device->p->deferred_probe_msg) + seq_puts(s, curr->device->p->deferred_probe_msg); + else + seq_printf(s, "%s\n", dev_name(curr->device)); mutex_unlock(&deferred_probe_mutex);