From patchwork Fri Jun 26 10:01:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 11627229 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC1091392 for ; Fri, 26 Jun 2020 11:24:08 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77688206C0 for ; Fri, 26 Jun 2020 11:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fYN8ECsO"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="DUbhxXWi"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="OnXwuQl/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77688206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=pLBayL2+CbpKfEFg6rvOvrMnLzcJ95XouWWti4VPbtU=; b=fYN8ECsOOCInhUBN7evvNZiusn ZuAh4JW/yC8RAiga2kclHXCPTChWHi4G9YoHUQyzw4SrFxkMQj7Km6r/pLm49QZYpXixQ8c9RhHis agFeW+w2cxZDM+w3b3AW/SmZjNjbxEVlilXOFtUR4L8UJEgay85i6WNwX2LSL+FrXkQpkbscGpzLY VA1Lb1WBtanhk0jRkEtwlLqMzgfiXq0logtNoHLSeSHB5+KZZziLSQSItaIIzIJN5k/UNc2uN6Poc zLEz5Nqsh2UyRGH75ONJB5tkkJaFxPllUCySSXO8GbXRFXzo7bDlsBi32iS29iBB9FbjHudbKeU75 eYyUuscA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jomRN-0000nO-SR; Fri, 26 Jun 2020 11:22:41 +0000 Received: from casper.infradead.org ([90.155.50.34]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jolDb-0000YK-D6 for linux-arm-kernel@merlin.infradead.org; Fri, 26 Jun 2020 10:04:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:Content-Type:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zzYpMezHcCPuAI9WGmae4c4hMI68Rcf9k4HVAnd3Gnw=; b=DUbhxXWi2PAoLoXe3kazR7hj4E Y7dMj2yHzaaf1yutdbREHHslnODxnKCxKwp/hMRZNwdhRHErItIu6EcDLzJINjU4Jg97I6/Pci+HY PYWQ2iMtFyuiZUV6YOwRaJBv4CMZX3or+g6PdVk9Dr2KddZrd8dYWUNjnVOFPhi5z3d2QHGnI65hZ ceYZeCeIn9XTU25z8Wv/Xirsn32ZRf11QBlbEwVFlfA5TOIKncgeME1B5XuLVzYtLDvj4FonVNsCB NH31jLKe3Cl8VsZxSaOxpbp4CpGJdaPGq2MMu+500zfnaSS+DFoEfJxhw0H1h0ICvHsRcrmZXzWv9 NXZ7I61Q==; Received: from mailout2.w1.samsung.com ([210.118.77.12]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jolAX-0003aY-Hz for linux-arm-kernel@lists.infradead.org; Fri, 26 Jun 2020 10:01:32 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200626100110euoutp02a6c961508f6ca3eeb3e7a8e8e5838701~cD7yWTE6X2540925409euoutp02G for ; Fri, 26 Jun 2020 10:01:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200626100110euoutp02a6c961508f6ca3eeb3e7a8e8e5838701~cD7yWTE6X2540925409euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593165670; bh=zzYpMezHcCPuAI9WGmae4c4hMI68Rcf9k4HVAnd3Gnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OnXwuQl/2zZZcghh0En8N22tVuv4q0gKbHR17QkgjhsUL5+z19i7D2wgk9XaaudXt GUEfWEWvEIKdVhc9nX9EkTDTpMNSL2/vT2RPRBVFrYZPj8wkbuNV94UTohdiRzalqw e0N5WSup0uUpl3rewfZBJq9evpLCU449zLLYloU8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200626100110eucas1p234cd1b600e94a718a94bef5fec6310f6~cD7x95GAB1856618566eucas1p25; Fri, 26 Jun 2020 10:01:10 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id AD.EC.06318.667C5FE5; Fri, 26 Jun 2020 11:01:10 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200626100110eucas1p2c5b91f2c98a5c6e5739f5af3207d192e~cD7xp296r1867018670eucas1p24; Fri, 26 Jun 2020 10:01:10 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200626100110eusmtrp2c937eca2603216d9e16861f32096763f~cD7xpJucK1306813068eusmtrp2D; Fri, 26 Jun 2020 10:01:10 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-62-5ef5c766c33b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C3.86.06017.567C5FE5; Fri, 26 Jun 2020 11:01:10 +0100 (BST) Received: from AMDC3748.digital.local (unknown [106.120.51.74]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200626100109eusmtip190f09b3306fb2cc99e90aff84181ad15~cD7w4Nr0M2485024850eusmtip1F; Fri, 26 Jun 2020 10:01:09 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v6 2/4] driver core: add deferring probe reason to devices_deferred property Date: Fri, 26 Jun 2020 12:01:01 +0200 Message-Id: <20200626100103.18879-3-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626100103.18879-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSfUyMcRz3u+e553muOR7npu+6MGdsMmElPzLDSs8/zB9kWMfRo5q6y10v Slu3RbrSGxJHqxFa5OhtQqpD52WXihpX7bIyotaoY7Xz0uPJ/Pf5fj8v398++zGEwiH1YWJ0 CbxBp41VU15kfevEqxWH7W7NqmwrYOftNikeKniM8N0LVikuej9I4d/1hQR+4x6lcMZVK4W7 fgwR+PlwF4nNheU0rh7oluLX9y9T2FbUiHDVkz4a2/L24ZLxImITy73u7iC40bcnaa7xexnJ NVj6aO5S1kUpV11pprhnBZ0SrqnkFs25cuwSrqY8ncurrURcc+5ZkhurXrBDvtdrQyQfG5PE G1ZuPOAVnd3dQ8b3Lz72JdeJTOjb/Gwk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5c62KDKPrEKPG2uwusiE1AU+Lv 5ptsILaIgLFE/9lZ7CBFzAJtrBJzzz9hB0kIC8RIvDvcA7SCg4NFQFVi52EtkDCvgIXE41tr GSEWyEus3nAAbBmngKXE9Fu9rCDlQkA1nUsiJzDyLWBkWMUoklpanJueW2ykV5yYW1yal66X nJ+7iREYWduO/dyyg7HrXfAhRgEORiUe3gMTv8QJsSaWFVfmHmKU4GBWEuF1Ons6Tog3JbGy KrUoP76oNCe1+BCjKdBJE5mlRJPzgVGfVxJvaGpobmFpaG5sbmxmoSTO2yFwMEZIID2xJDU7 NbUgtQimj4mDU6qBMeHQMhOjk2ES0hdvvFN64ZYnM1dN1feqWeyG3UXeImvdlI+4FJov107V fXiLy3jytpqfm/zeGLxOVfgZ9W5Z8IIfize9O23U+ueYknePfeZShlVLf3gt+yHGLf4uxDEx w3H/xJA7nx+tvLTgH2tEkOi1rze3CclFq7ikROZ+LVmQ+jJO58M3eSWW4oxEQy3mouJEABQO xHbCAgAA X-CMS-MailID: 20200626100110eucas1p2c5b91f2c98a5c6e5739f5af3207d192e X-Msg-Generator: CA X-RootMTR: 20200626100110eucas1p2c5b91f2c98a5c6e5739f5af3207d192e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200626100110eucas1p2c5b91f2c98a5c6e5739f5af3207d192e References: <20200626100103.18879-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200626_110114_209984_20BD6298 X-CRM114-Status: GOOD ( 22.59 ) X-Spam-Score: -7.1 (-------) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-7.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , "Rafael J. Wysocki" , Jonas Karlman , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, "open list:DRM DRIVERS" , Russell King - ARM Linux , Neil Armstrong , Andrzej Hajda , andy.shevchenko@gmail.com, Mark Brown , Laurent Pinchart , Daniel Vetter , 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 /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 Reviewed-by: Rafael J. Wysocki --- drivers/base/base.h | 3 +++ drivers/base/core.c | 8 ++++++-- drivers/base/dd.c | 23 ++++++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 95c22c0f9036..6954fccab3d7 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -93,6 +93,7 @@ struct device_private { struct klist_node knode_class; struct list_head deferred_probe; struct device_driver *async_driver; + char *deferred_probe_reason; struct device *device; u8 dead:1; }; @@ -134,6 +135,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 device_set_deferred_probe_reson(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 3a827c82933f..fee047f03681 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3963,6 +3963,8 @@ define_dev_printk_level(_dev_info, KERN_INFO); * This helper implements common pattern present in probe functions for error * checking: print debug or error message depending if the error value is * -EPROBE_DEFER and propagate error upwards. + * In case of -EPROBE_DEFER it sets also defer probe reason, which can be + * checked later by reading devices_deferred debugfs attribute. * It replaces code sequence: * if (err != -EPROBE_DEFER) * dev_err(dev, ...); @@ -3984,10 +3986,12 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - if (err != -EPROBE_DEFER) + if (err != -EPROBE_DEFER) { dev_err(dev, "error %d: %pV", err, &vaf); - else + } else { + device_set_deferred_probe_reson(dev, &vaf); dev_dbg(dev, "error %d: %pV", err, &vaf); + } va_end(args); diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9a1d940342ac..dd5683b61f74 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" @@ -136,6 +137,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_reason); + dev->p->deferred_probe_reason = NULL; } mutex_unlock(&deferred_probe_mutex); } @@ -211,6 +214,23 @@ void device_unblock_probing(void) driver_deferred_probe_trigger(); } +/** + * device_set_deferred_probe_reson() - Set defer probe reason message for device + * @dev: the pointer to the struct device + * @vaf: the pointer to va_format structure with message + */ +void device_set_deferred_probe_reson(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_reason); + dev->p->deferred_probe_reason = kasprintf(GFP_KERNEL, "%s: %pV", drv, vaf); + + mutex_unlock(&deferred_probe_mutex); +} + /* * deferred_devs_show() - Show the devices in the deferred probe pending list. */ @@ -221,7 +241,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_reason ?: "\n"); mutex_unlock(&deferred_probe_mutex);