Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6831331rwn; Tue, 13 Sep 2022 09:32:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR5emFdHXc2bkDD7kqrAt1JSslvmYavKGA9gCkyX8fsEiHGLw2Y5OujXmERchzm3DO/18Q4z X-Received: by 2002:a17:90a:203:b0:200:8df6:84c with SMTP id c3-20020a17090a020300b002008df6084cmr154614pjc.24.1663086770671; Tue, 13 Sep 2022 09:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086770; cv=none; d=google.com; s=arc-20160816; b=HcN4/vKVkL53aafd4GLSZYRjYaZjcLsMgzkjdvD7WlgEmcXcai+y2zmOOlSx/DqewF tDKhXFYABf7w4CeqLjuE2rH49nGsuVr57N/SjAJ4wiLF12lIxJdDqT+TzdRdh6DD8PEY +2F2VmJIXoTRAVCYv6R+KyhK87ruU5QfsrtOMyBecDre20Fnpmr8nH/KDeHu/tpJc1Tk l+e+emibFf7vjEUW++6QpWniHl6AKJ0l+A/xkI8e5HlKqhN1J6VZAFEGhXh0v8IPtpdo cUmpBGiD40uImP6dLHf0BzGeDjwHrP/WRSa4eT/9nXOWVJvIJFtRSQTbpax7Fiq/YIi4 ok8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oHi699vX0VIwrZ8ZTWYUUHOP7MwqNUQjFlyLBVLvZcE=; b=DL+2uiKPunUxKwlDvv8X0J4NYCg43jgsHoWh/7PLZcbWYYP+PdxsrY/vsz8LJ1Yuvh HEVSzHIjQtstomol6SVeZz+ysZEStPOwcA+njnF9SKgmEqY3IT0z2n5I7GGxiH85XzVN M9KgyiG6dPmBICG35V9A1rC0vzcCzzYqsFLdoqGz6RIDFuSVbTIPsgpRw9cKBRDk+h5P mHbos91B9a6uTVSWWVIQPa9woR5WBccQFeHzLQIyS8TWVILFfdMply38PNauVgoykAdl Zm9YOqV2PCvYYlqJd5Q7oeRz7TlQmB9Yc87VupFx18yoGCqKuzIKEnDG1SVUCEXoGV1i u+pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fUMFYhyn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a6566d3000000b0043855015f38si12680157pgw.165.2022.09.13.09.32.34; Tue, 13 Sep 2022 09:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fUMFYhyn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236260AbiIMPZl (ORCPT + 99 others); Tue, 13 Sep 2022 11:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235906AbiIMPXP (ORCPT ); Tue, 13 Sep 2022 11:23:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E483A7C76C; Tue, 13 Sep 2022 07:37:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 75C4461497; Tue, 13 Sep 2022 14:37:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 800E7C433D6; Tue, 13 Sep 2022 14:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079837; bh=UdEWgUayR1c1F44NFCT/U/oo6sgvgxYMIIsL8AFPoV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fUMFYhyn4iwqshgYfmcVFa9/urkQoHIGPnvV+je3OPXQGm4HEMUos+QEc88HW+iew RdN8KpBE3wUhAiqBWYZW/bIR9tz0z9TFLmfRfuUpaA4HUIKjvua8yNfna02KEqrouG J+vboYAA3sb+A+O+mc0fJJH462HyuGvfYU8zqoSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Saravana Kannan , Guenter Roeck , Linus Walleij , "Isaac J. Manjarres" Subject: [PATCH 4.9 33/42] driver core: Dont probe devices after bus_type.match() probe deferral Date: Tue, 13 Sep 2022 16:08:04 +0200 Message-Id: <20220913140344.041278326@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140342.228397194@linuxfoundation.org> References: <20220913140342.228397194@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Isaac J. Manjarres commit 25e9fbf0fd38868a429feabc38abebfc6dbf6542 upstream. Both __device_attach_driver() and __driver_attach() check the return code of the bus_type.match() function to see if the device needs to be added to the deferred probe list. After adding the device to the list, the logic attempts to bind the device to the driver anyway, as if the device had matched with the driver, which is not correct. If __device_attach_driver() detects that the device in question is not ready to match with a driver on the bus, then it doesn't make sense for the device to attempt to bind with the current driver or continue attempting to match with any of the other drivers on the bus. So, update the logic in __device_attach_driver() to reflect this. If __driver_attach() detects that a driver tried to match with a device that is not ready to match yet, then the driver should not attempt to bind with the device. However, the driver can still attempt to match and bind with other devices on the bus, as drivers can be bound to multiple devices. So, update the logic in __driver_attach() to reflect this. Fixes: 656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()") Cc: stable@vger.kernel.org Cc: Saravana Kannan Reported-by: Guenter Roeck Tested-by: Guenter Roeck Tested-by: Linus Walleij Reviewed-by: Saravana Kannan Signed-off-by: Isaac J. Manjarres Link: https://lore.kernel.org/r/20220817184026.3468620-1-isaacmanjarres@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/base/dd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -590,6 +590,11 @@ static int __device_attach_driver(struct } else if (ret == -EPROBE_DEFER) { dev_dbg(dev, "Device match requests probe deferral\n"); driver_deferred_probe_add(dev); + /* + * Device can't match with a driver right now, so don't attempt + * to match or bind with other drivers on the bus. + */ + return ret; } else if (ret < 0) { dev_dbg(dev, "Bus failed to match device: %d", ret); return ret; @@ -732,6 +737,11 @@ static int __driver_attach(struct device } else if (ret == -EPROBE_DEFER) { dev_dbg(dev, "Device match requests probe deferral\n"); driver_deferred_probe_add(dev); + /* + * Driver could not match with device, but may match with + * another device on the bus. + */ + return 0; } else if (ret < 0) { dev_dbg(dev, "Bus failed to match device: %d", ret); return ret;