From patchwork Thu Dec 20 10:22:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10738747 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 A19DD161F for ; Thu, 20 Dec 2018 10:23:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B03528734 for ; Thu, 20 Dec 2018 10:23:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AA3C28749; Thu, 20 Dec 2018 10:23:58 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 1644F28734 for ; Thu, 20 Dec 2018 10:23:58 +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=XV7QCVo2/MdX8guutdr8nEZQjquoB9dYyvU+A5OPSLA=; b=J7rJ4rVD3HFzDMcbUuizIzAItx jRK5jwaLNQFAat6bqO+KdUmax7+guZVASAPyJeje9vyFeWd8hjyx2SQIdzkxVmAitBegLBszmcDe5 P38i5zuyXkQ19h8q2xVrYS2JNRhPzeWsK/7NB5Qsu4On4L4Ay5cU8xkZOtu1hkXUUA3xQ6cjrw6mW F6k/F40EdV9bWWYAR+Wx05XxLCQpfawDSrqguK0apZ6fOZWfKYG4v42RlypzoO6TUBOwV3+Tx2PpZ DeYJl7Lm+xAgI36EhPU+nWbK1OPuqvfFD79O7nGunz6hu8aJ9RUX1wAFDPXOtvaE0BXnoFziepocI 6XvA4oXQ==; 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 1gZvUj-0000zw-0H; Thu, 20 Dec 2018 10:23:57 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZvU3-0000Ne-Ua for linux-arm-kernel@lists.infradead.org; Thu, 20 Dec 2018 10:23:18 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181220102301euoutp011d2f8fa81597595e91faf4c075aef9fd~yA2s7z1h71726317263euoutp01C; Thu, 20 Dec 2018 10:23:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181220102301euoutp011d2f8fa81597595e91faf4c075aef9fd~yA2s7z1h71726317263euoutp01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1545301381; bh=xiRdmEIjOQ4EiEDf+t5yeCMyixU5eUBvPbNazTa7hqM=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=pWzG0FXzJIQVwYsxGZlr6+9ofFku2EJ6LpGNB7Futel5If04FYse9mPCihyH4tvLo HWBxYbT/kM2VyB/jKCcSL+h7MsEpHrgF8DNXBPSm0z1gKJRdLzrA/gelE51mQ+Xj1b jm+yctrVbetmtcPOR97M9zJ8o8dConj1wJb5jyY4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181220102300eucas1p2be6910aca112870eb95bf44d54f87d75~yA2sdmyvI0424004240eucas1p2B; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id B1.78.04806.48D6B1C5; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181220102259eucas1p1884a0b68ce342239c2a43a74cc50725a~yA2rdSQbY1464414644eucas1p1Q; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-b5-5c1b6d84646f Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 78.6E.04128.38D6B1C5; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PK100480669SP10@eusync3.samsung.com>; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v4 2/3] driver core: add deferring probe reason to devices_deferred property Date: Thu, 20 Dec 2018 11:22:46 +0100 Message-id: <20181220102247.4911-3-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181220102247.4911-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsWy7djP87otudIxBtNWCFvcWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6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O1oDY bAKaEn8332QDsUUEjCX6z85iB2lgFljELLF33T5WkISwQJzEuZvzWEGGsgioSjy9VwIS5hUw l2g4dgusREJAXmL1hgPMICWcAhYSP1eyQ6wyl/hzZzrbBEaeBYwMqxhFUkuLc9Nzi430ihNz i0vz0vWS83M3MQJDb9uxn1t2MHa9Cz7EKMDBqMTDOyNKKkaINbGsuDL3EKMEB7OSCO/jLOkY Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rznDSqjhATSE0tSs1NTC1KLYLJMHJxSDYyipatk5P42 eTDn91kwLj5Qu2lVO6Mz+xmWsArPtXbifn11WyY7yKac/5C49u6E9hRZz6vNPapHEy5/l3+6 kzfz0NIUb/ZN08yym1zOa7lrvHTbGnNB3tZq25ObcSIx3/9y9Nff4lGOT/8+rTF9H/9k0yt3 JBrVM9dac2pl/qxpVmP2Tpm+UYmlOCPRUIu5qDgRACwsLNo5AgAA X-CMS-MailID: 20181220102259eucas1p1884a0b68ce342239c2a43a74cc50725a X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181220102259eucas1p1884a0b68ce342239c2a43a74cc50725a References: <20181220102247.4911-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181220_022316_127003_1E639442 X-CRM114-Status: GOOD ( 21.34 ) 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 7f644f3c41d3..d3eb5aeeaa28 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3108,6 +3108,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, ...); @@ -3123,14 +3124,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 88713f182086..857aa4d1d45d 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);