From patchwork Thu Oct 18 06:49:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10646765 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 A2E1514E2 for ; Thu, 18 Oct 2018 06:49:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92A1F287AA for ; Thu, 18 Oct 2018 06:49:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85A1F287B1; Thu, 18 Oct 2018 06:49:44 +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 6E270287AA for ; Thu, 18 Oct 2018 06:49:43 +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=bC9seXBissPrrPHEcrwYx75DYGD2iRQVmWshnuSusQ8=; b=tCAyVo8FV/eXG0SLpbxGtdhmuS g/7oriLMxxj6dGwIObxruGDzZZbk7vSZizdkTKrygQMt5JNW3NmRB/MQp7zQ+KaqxINH64snTkj74 7Qp9dfqQL1v/47+KUCtmpJzcJRA3iUNtKURCR3SGQ6xTee91ggYQT+fqX/+4ZsSR7qyz5Kw2uEG/q ZvYwgxvawan++Fbs/1rnyxixL76qipuugZ0Y1q7+n+kt+VCcJuDzQCkvu+hIE3eU24+zoTjWOn9dz kummOXmkLJAmPLw0BmBDIC9Tvqd6o/MSpr3rCKyQ/X0+01lTUAxMMgukFMElC1HG1Dushnyo8sNQ+ Yl1lb3Wg==; 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 1gD27l-0007xN-4k; Thu, 18 Oct 2018 06:49:37 +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 1gD27f-0007vh-U3 for linux-arm-kernel@lists.infradead.org; Thu, 18 Oct 2018 06:49:34 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181018064918euoutp02e6da4cc0d674b0ee810eaa2a0500f47f~eoTHV1xuw2667226672euoutp02u; Thu, 18 Oct 2018 06:49:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181018064918euoutp02e6da4cc0d674b0ee810eaa2a0500f47f~eoTHV1xuw2667226672euoutp02u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539845358; bh=qAREvdHcFvOM48/FqFxff/A8CbHIHJf1GkZzLV/P1Nk=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=L1TFiD5W0D8tLBuSXpPpPc6nKfiopJbnRo6/CuJ7pElLNcKKfmxPklWYjAFHLA+dk 71pw1yno2UlfHWLoJp1JfiOJCkJX6U9cREcsBTGeGPlm53pVFi3p9vtvtDq1AhahYr QM3htuAeSYe6W8GFakX8lj4hXmUETo3+DTLn3lgM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181018064917eucas1p10bd9cf1a4de80027a3328554210d3274~eoTGvukGN1478014780eucas1p1K; Thu, 18 Oct 2018 06:49:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 1D.D3.04294.DEC28CB5; Thu, 18 Oct 2018 07:49:17 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181018064916eucas1p22f03a19eb09cecdb0061dc5a4bf99ce6~eoTFkltpY2757327573eucas1p2O; Thu, 18 Oct 2018 06:49:16 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-f8-5bc82ced14ff Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 5E.96.04128.CEC28CB5; Thu, 18 Oct 2018 07:49:16 +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 <0PGS004LF8A3IH30@eusync1.samsung.com>; Thu, 18 Oct 2018 07:49:16 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v4 2/3] driver core: add deferring probe reason to devices_deferred property Date: Thu, 18 Oct 2018 08:49:06 +0200 Message-id: <20181018064906.23116-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLIsWRmVeSWpSXmKPExsWy7djP87pvdU5EG8zbzWJxa905VouXEw4z WmycsZ7VYurDJ2wWzYvXs1ksnLac0WLT42usFpd3zWGzODR1L6PF2iN32S3mfpnK7MDtcfna RWaPn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xhL9Z2exgxQxCyxilti7bh8rSEJYIE7i3M15YDaLgKrEvBmHwWxeAQuJ B5N/MkGsk5d4eLydEcTmFAiWeNK6GqxGSCBAYtKGd8wTGHkWMDKsYhRJLS3OTc8tNtIrTswt Ls1L10vOz93ECAzBbcd+btnB2PUu+BCjAAejEg/vg9Tj0UKsiWXFlbmHGCU4mJVEeFlmA4V4 UxIrq1KL8uOLSnNSiw8xSnOwKInznjeojBISSE8sSc1OTS1ILYLJMnFwSjUwhu43+LXs80Ub ne0Sm98yTV6lJLODeduvWhOJyM4fXF0Cpq84HzIJ2L+xEHlh5hp7NPdrQEH/rtMLbmXZ5anf 3X/K4eatkGrZSTcYbC7eSHr8J+HrKYULX+9nhsYxVO/gePlu65uGl1x+HteN/059cf7OVk0n 3XtSf+Kt9DJ/OnJUCB3K/bv5mhJLcUaioRZzUXEiALVaPKc9AgAA X-CMS-MailID: 20181018064916eucas1p22f03a19eb09cecdb0061dc5a4bf99ce6 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181018064916eucas1p22f03a19eb09cecdb0061dc5a4bf99ce6 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181017_234932_110422_0F1236FD X-CRM114-Status: GOOD ( 22.65 ) 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 --- v4: - removed NULL check before kfree, - coding style tweaking. 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..e7986a307420 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) +{ + const char *drv = dev_driver_string(dev); + + mutex_lock(&deferred_probe_mutex); + + kfree(dev->p->deferred_probe_msg); + dev->p->deferred_probe_msg = kasprintf(GFP_KERNEL, "%s: %pV", drv, 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);