Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6823004rwn; Tue, 13 Sep 2022 09:26:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fbzMye/bjTjHjYzrL0wC0AMbSmtZh6D23tqPWKlj+gp55zG8yq9LUkO94x/eprvXAbIkn X-Received: by 2002:a17:907:762b:b0:771:5755:82b7 with SMTP id jy11-20020a170907762b00b00771575582b7mr19950309ejc.684.1663086380046; Tue, 13 Sep 2022 09:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086380; cv=none; d=google.com; s=arc-20160816; b=bcTOIrryYCpAD1ETRKdhAps49+YyXGKgP2DWZBWaimqoYfpfzkYeoNIFQ384KS2TV9 KiWdRVSoweyPfChWZrumAc25GLFZFHa0wbjFgMrvfzzcCRr2pxXS1EitgXCf8dGo7OZO WGo3ydJJ9nbCWKGzrrlUtUpHcKP2xWlTQeWvorSZk8DEOReevzotqeAiPCcUhCbgbv8h qsWw1jPokAsQk2V8plp9CFRY+wK1SprmfO9p0D1cdn8v2lrvXdwMdkkW4iLSMLfeJEuB S6NFTcQeU1je5W4Sje98neLULK6OBq2bUt0SEoYLmaZfIodqUS+0bPReLZlYPJ2ipifn sGmQ== 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=SjbjnVBZUPxgYCWnacPguKzT03yvAsjSNO2AJg7UHQo=; b=hl0dzzgh0uVNrYGMVFY9Z65TMqW2YBGFRJhLwZs5vNxFcAWmialTVemfuPQDOK1hvf MxG7AjpuBOpUH6zvBh9YlBkyzoopNTfR8KKVrYuH15l9yYM2E3Wfzyfvqz3P/cN6vvoV NnUyTH9dzQTGsHRIZaQcWVZvRdo8xgvZhP6/7LN0HmGOwXJ2UIj6eeLXXsvx1fwtwpBg Vilo3FLrTY84hAXmoMLtYJY4wCf4hglsWvQ8aXEdkqUwiVl2CF4vpnppLQE0kxK6LDvd Tsnxnr46iE/OZhVuCa7N7aVwsfYhp0gxj89wnGNHdzp+6g4uTZ4/5YS3RC0OtZDhP0Y8 n6Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IFiLjXcY; 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 bb8-20020a1709070a0800b007413d43db0fsi3013775ejc.732.2022.09.13.09.25.51; Tue, 13 Sep 2022 09:26:20 -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=IFiLjXcY; 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 S234820AbiIMPBV (ORCPT + 99 others); Tue, 13 Sep 2022 11:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235184AbiIMO7Z (ORCPT ); Tue, 13 Sep 2022 10:59:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6245162AA1; Tue, 13 Sep 2022 07:28:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id 59C8EB80F9B; Tue, 13 Sep 2022 14:28:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0E06C433D6; Tue, 13 Sep 2022 14:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079280; bh=wTT+y7OxndejrNZVsBuIMLnHzd38Ef9JL6Sq4tH05kc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IFiLjXcYLS+OmNLqHyMhrcuXSIC9OPTCbmrhl8XILEdLKHpDUBEcltjxrYUvBCdbt 4853RsTG3zpjO8629gpR/MDmUKS0ukktDKfjqFn0JIvL5AHNvszFvexybf1q38ZJ95 hFYu3MhH3gTbUdYAaCxs9UvZryeXHSfiQYO1NPK8= 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 5.4 055/108] driver core: Dont probe devices after bus_type.match() probe deferral Date: Tue, 13 Sep 2022 16:06:26 +0200 Message-Id: <20220913140355.994585527@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140353.549108748@linuxfoundation.org> References: <20220913140353.549108748@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 @@ -818,6 +818,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; @@ -1057,6 +1062,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;