From patchwork Wed Oct 17 13:24:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10645617 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 2F19A13B0 for ; Wed, 17 Oct 2018 13:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2752AF89 for ; Wed, 17 Oct 2018 13:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08F322B01D; Wed, 17 Oct 2018 13:24:52 +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 738362AF89 for ; Wed, 17 Oct 2018 13:24:51 +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=q0Smm1wOQ/3OYG/OyGq6v+uQtiLJ4ZfNcgxQDBBuoc0=; b=LFs0ocOsP6dltho3OG82yiVIN+ aABBy9Q9J3HR8pfDG6814ZL/zY7/SX0Se6ld1LvRaquRH/XyT792u60x7nS+rzAEs2Qn69EoJD652 rCj2hV2oBNqHoZXX7WyMMsZghxVaRmlchFYEV4eSNfrwBWuZ5fgRJwULh7hmh66QHNjLDVPoqw7Bn RIvrWgpa3VY4lptDob9tNhfQFQxZyKEb0q5rdelkj92n4wgtd1ZXuVzBBPKgpKqvsgaYVhoxC3n3M aCltWANbOVaOia5d9A/aJR8Gm6od2jKM4nHAbERIWM1cl1u7hgh3qgs2bdSY3jyG6gIX4CKAve7+V qcqoG9tw==; 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 1gCloX-0005nJ-SW; Wed, 17 Oct 2018 13:24:41 +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 1gClo9-0005kP-0I for linux-arm-kernel@lists.infradead.org; Wed, 17 Oct 2018 13:24:39 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181017132405euoutp02005d68ab1e0ef2ca264267500000b78c~eaCh62nEj0173801738euoutp02n; Wed, 17 Oct 2018 13:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181017132405euoutp02005d68ab1e0ef2ca264267500000b78c~eaCh62nEj0173801738euoutp02n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539782645; bh=GjM3hXLpGpu2oLx0y/QxqDKTrt2I5BaXddjRV+9RukY=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=pPA9OO6W0HBaEG5kfKHSoOYGCm/rdxkGWb70B2J715tBhcm11QSV44Ibm93n7Cj7Z SQVS1i9A7E4BMxJY/N/D0W5njoJ8UBFS2z05LYK05IlfDyIUI+jTepJA7ijkuOKKWM 9nInjC6SMODKKBQg+xSSs8a69KiHvLJmbd9F0uIA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181017132405eucas1p2aad685ce534a2bf2915e154781498620~eaChUXMkH2955629556eucas1p20; Wed, 17 Oct 2018 13:24:05 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 3D.0A.04294.4F737CB5; Wed, 17 Oct 2018 14:24:04 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181017132404eucas1p2a413f6853af8f11a874650b6289d56cf~eaCgnAlOV1251312513eucas1p2D; Wed, 17 Oct 2018 13:24:04 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-c1-5bc737f41b86 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 15.4F.04284.4F737CB5; Wed, 17 Oct 2018 14:24:04 +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 <0PGQ00EGYVW3RX40@eusync1.samsung.com>; Wed, 17 Oct 2018 14:24:04 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v3 2/4] driver core: add deferring probe reason to devices_deferred property Date: Wed, 17 Oct 2018 15:24:00 +0200 Message-id: <20181017132400.5300-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDIsWRmVeSWpSXmKPExsWy7djP87pfzI9HG9zq0ra4te4cq8XLCYcZ LTbOWM9qMfXhEzaL5sXr2SwWTlvOaLHp8TVWi8u75rBZHJq6l9Fi7ZG77BZzv0xlduD2uHzt IrPHzll32T02repk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JqAp8XfzTTYQW0TAWKL/7Cx2kCJmgUXMEnvX7WMFSQgLxEmcO7kerIhFQFWi49NmsGZeAXOJ CbNPsEOsk5d4eLydEcTmFAiWOPxmCguILSQQIHFrbhPzBEaeBYwMqxhFUkuLc9Nziw31ihNz i0vz0vWS83M3MQJDcNuxn5t3MF7aGHyIUYCDUYmHd4fYsWgh1sSy4srcQ4wSHMxKIrxVisej hXhTEiurUovy44tKc1KLDzFKc7AoifOeN6iMEhJITyxJzU5NLUgtgskycXBKNTCWR3muPvRt 75aln+Y9O+N1+Kbmj9Jvq/eZXIv60X843M4poX5th+acv+5f9uUf+m/weOeUhX5+6fnT1PUe GW3d3h2/QWynQ+KzYKXGkqVM83jKbt2KV1Jwrhb4cWvyoz+bwm9Ib5z+O81n29RKR5mqt1ve aG50Zmk8GGa7/MCtLx+un2i7/dC4TYmlOCPRUIu5qDgRAOvtZiQ9AgAA X-CMS-MailID: 20181017132404eucas1p2a413f6853af8f11a874650b6289d56cf X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181017132404eucas1p2a413f6853af8f11a874650b6289d56cf References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181017_062417_219839_409EBC08 X-CRM114-Status: GOOD ( 22.39 ) 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 , Russell King - ARM Linux , 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: 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) + 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", dev_name(curr->device), + curr->device->p->deferred_probe_msg ?: "\n"); mutex_unlock(&deferred_probe_mutex);