From patchwork Thu Dec 3 08:51:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 7757391 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E36BBEEE1 for ; Thu, 3 Dec 2015 08:52:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FF852041C for ; Thu, 3 Dec 2015 08:52:05 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 69AE62051D for ; Thu, 3 Dec 2015 08:52:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1a4PcQ-0000aM-QG; Thu, 03 Dec 2015 08:52:02 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1a4PcP-0000aC-CX for tpmdd-devel@lists.sourceforge.net; Thu, 03 Dec 2015 08:52:01 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of ts.fujitsu.com designates 80.70.172.51 as permitted sender) client-ip=80.70.172.51; envelope-from=martin.wilck@ts.fujitsu.com; helo=dgate20.ts.fujitsu.com; Received: from dgate20.ts.fujitsu.com ([80.70.172.51]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1a4PcN-0004kP-Bg for tpmdd-devel@lists.sourceforge.net; Thu, 03 Dec 2015 08:52:01 +0000 X-SBRSScore: None Received: from unknown (HELO abgdgate60u.abg.fsc.net) ([172.25.138.90]) by dgate20u.abg.fsc.net with ESMTP; 03 Dec 2015 09:51:52 +0100 Received: from unknown (HELO pdbcooper.pdb.fsc.net) ([172.25.111.126]) by abgdgate60u.abg.fsc.net with ESMTP; 03 Dec 2015 09:51:53 +0100 Received: from pdbcooper.pdb.fsc.net (localhost [127.0.0.1]) by pdbcooper.pdb.fsc.net (8.14.9/8.14.8) with ESMTP id tB38pjBS009991; Thu, 3 Dec 2015 09:51:46 +0100 From: martin.wilck@ts.fujitsu.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, u.kleine-koenig@pengutronix.de Date: Thu, 3 Dec 2015 09:51:44 +0100 Message-Id: <1449132704-9952-1-git-send-email-martin.wilck@ts.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <20151202165338.GA18274@kroah.com> References: <20151202165338.GA18274@kroah.com> X-Spam-Score: -1.1 (-) X-Headers-End: 1a4PcN-0004kP-Bg Cc: Martin Wilck , tpmdd-devel@lists.sourceforge.net Subject: [tpmdd-devel] [PATCH v3] base/platform: fix binding for drivers without probe callback X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, HK_RANDOM_ENVFROM, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Wilck Since b8b2c7d845d5, platform_drv_probe() is called for all platform devices. If drv->probe is NULL, and dev_pm_domain_attach() fails, platform_drv_probe() will return the error code from dev_pm_domain_attach(). This causes real_probe() to enter the "probe_failed" path and set dev->driver to NULL. Before b8b2c7d845d5, real_probe() would assume success if both dev->bus->probe and drv->probe were missing. As a result, a device and driver could be "bound" together just by matching their names; this doesn't work any more after b8b2c7d845d5. This change broke the assumptions of certain drivers; for example, the TPM code has long assumed that platform driver and device with matching name could be bound in this way. That assumption may cause such drivers to fail with Oops during initialization after applying this change. Failure in suspend/resume tests under qemu has also been reported. This patch restores the previous (4.3.0 and earlier) behavior of platform_drv_probe() in the case when the associated platform driver has no "probe" function. Fixes: b8b2c7d845d5 ("base/platform: assert that dev_pm_domain callbacks are called unconditionally") Signed-off-by: Martin Wilck Acked-by: Uwe Kleine-König Acked-by: Jarkko Sakkinen --- v2: fixed style issues, rephrased commit message. v3: rephrased commit message and subject again. drivers/base/platform.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1dd6d3b..176b59f 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -513,10 +513,15 @@ static int platform_drv_probe(struct device *_dev) return ret; ret = dev_pm_domain_attach(_dev, true); - if (ret != -EPROBE_DEFER && drv->probe) { - ret = drv->probe(dev); - if (ret) - dev_pm_domain_detach(_dev, true); + if (ret != -EPROBE_DEFER) { + if (drv->probe) { + ret = drv->probe(dev); + if (ret) + dev_pm_domain_detach(_dev, true); + } else { + /* don't fail if just dev_pm_domain_attach failed */ + ret = 0; + } } if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {