From patchwork Thu Jul 2 13:44:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 11638911 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 3BC4B13B4 for ; Thu, 2 Jul 2020 13:46:22 +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 06BA5207D4 for ; Thu, 2 Jul 2020 13:46:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pCZGkA6d"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="coTUImIX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06BA5207D4 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=0WIWAtFK8nGYdOdPS+//VAlarDi3L3fLyG03Z7GGe1Q=; b=pCZGkA6d7agn4jtX2H61d7HkVa 7lX7UymFbYdnEAg+0CV1Vc7ObXVTsjZ0C+igDSNlGplkUzsWqSOLJ1F/haoGA7nRwZGlrCKhhcIV+ 3SAVrMkG8VGy35mMsjALTgc9P2ZwKsOk0n+YfTtlbfGVEwk7mKer1JObqnyibf0ZpKd1cqajVo4YE 4OMNrEu+cJpqRiicgH1hSwzYo2v+2/0/ip2NbNPXaeCGvOSUYHcvJpv0weA+12/r8x3RfsZrNYkai jUtu8FBu6vFBA1Vbn9CZf0dDDkjETabL8qLy+Jl1tcVY7MgHzJ3kOx8HaxknisiLDMxi0PA9ewyqt iqbJVzgw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqzW5-0007mE-BH; Thu, 02 Jul 2020 13:44:41 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqzW1-0007lJ-TV for linux-arm-kernel@lists.infradead.org; Thu, 02 Jul 2020 13:44:39 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200702134435euoutp0126889854b5049e3cab5c54aa3218a25e~d82kIwysB0745907459euoutp01V for ; Thu, 2 Jul 2020 13:44:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200702134435euoutp0126889854b5049e3cab5c54aa3218a25e~d82kIwysB0745907459euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593697475; bh=Wcn/fZwn0l0I3UrXznsXGlfRgX1zzz/eHT6cU1JUJ98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=coTUImIXandF5sPwA8906cKi/QS9cqx/iqXawoGD7LBBvkCASPVFfheEvILlvt4J8 Y0IHpte5+lkdtPjPpDN9luu9X5+Fq4h9flkYlViCWI1JYmezY1ZHYmowZqLBlLmp+r aUimFdb7LptZhIDZQFTsESvS/hzZgIQxD6/78Pto= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200702134435eucas1p277a21a6696e124b42c102540c6665951~d82j2tuHL1813018130eucas1p2-; Thu, 2 Jul 2020 13:44:35 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 92.F2.05997.3C4EDFE5; Thu, 2 Jul 2020 14:44:35 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200702134434eucas1p233a3f66f5bdb4b97f4f49d2d43d45297~d82je7wnZ3023830238eucas1p2_; Thu, 2 Jul 2020 13:44:34 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200702134434eusmtrp21c06ae96bce6fb9cbe4c5cc8fdfb920f~d82jeDPk60528405284eusmtrp2c; Thu, 2 Jul 2020 13:44:34 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-fd-5efde4c3265d Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D4.94.06017.2C4EDFE5; Thu, 2 Jul 2020 14:44:34 +0100 (BST) Received: from AMDC3748.digital.local (unknown [106.120.51.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200702134434eusmtip2c307019c112809392842a9a51d543146~d82ivfvFs2865128651eusmtip2L; Thu, 2 Jul 2020 13:44:34 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v8 2/5] driver core: add deferring probe reason to devices_deferred property Date: Thu, 2 Jul 2020 15:44:21 +0200 Message-Id: <20200702134421.6412-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA0WSbUhTYRTHeXbv7r2OFtcZ+KCRtNKySCsDHyrMIuRSB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xm tNg4Yz2rxdSHT9gs/m+byGxx5et7NovmxevZLK5+f8lscfLNVRaLzolL2C02Pb7GanF51xw2 i0NT9zJarD1yl93iUF+0xdwvU5kdBDwuX7vI7PH+Riu7x95vC1g8ds66y+4xu2Mmq8emVZ1s HicmXGLy2D93DbvH/e7jTB6bl9R79G1ZxehxoHcyi8fnTXIBvFF6NkX5pSWpChn5xSW2StGG FkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6GWt/tTMXHFGp2Hv2KmMD4zG5LkZO DgkBE4l/L2azgNhCAksZJZ7sNoGIi0vsnv+WGcIWlvhzrYsNouYTo8TEpWBxNgFNib+bb4LF RQSMJfrPzmLvYuTiYBZoY5WYe/4JO0hCWCBG4u+Nd4wgNouAqkTL96tgNq+AucS9WR1sEAvk JVZvOAA2lFMgUGLv+iVQBwVInLjZxzaBkW8BI8MqRpHU0uLc9NxiI73ixNzi0rx0veT83E2M wMjaduznlh2MXe+CDzEKcDAq8fBOOP43Tog1say4MvcQowQHs5IIr9PZ03FCvCmJlVWpRfnx RaU5qcWHGE2BjprILCWanA+M+rySeENTQ3MLS0NzY3NjMwslcd4OgYMxQgLpiSWp2ampBalF MH1MHJxSDYyTjA/6fM878yhdRnDj1unBz/knyIXxLsoMf9wm+alsW2Hbv+hL56JtncV9A5MN Jzfqdi9zXNyj+aqoZdd2N67giQGu2Svfp/7KYNl7amWmbbFd8qedM5QzVVRsVG3VQp+t5nTa ftDZrfvXvugrYhb8H07nT7krcb17r8v6gvWhKrtsrKp/r1FiKc5INNRiLipOBABK6oWQwgIA AA== X-CMS-MailID: 20200702134434eucas1p233a3f66f5bdb4b97f4f49d2d43d45297 X-Msg-Generator: CA X-RootMTR: 20200702134434eucas1p233a3f66f5bdb4b97f4f49d2d43d45297 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200702134434eucas1p233a3f66f5bdb4b97f4f49d2d43d45297 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200702_094438_263285_5A8F862A X-CRM114-Status: GOOD ( 22.25 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.11 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.11 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 dev_err_probe function introduced recently, ie. if dev_err_probe will be called with -EPROBE_DEFER instead of printk the message will be attached to a deferred device and printed when user reads 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 --- v8: - improved commit message --- 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);