Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1054305rwn; Thu, 8 Sep 2022 12:38:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4QK7QBEuCPxEesAphx47xDws8La8hFM45AvoPCypXvW3//L0NIp9NDTSVyq/4euhXrUSz6 X-Received: by 2002:a17:902:f604:b0:172:75a4:33ea with SMTP id n4-20020a170902f60400b0017275a433eamr10167066plg.7.1662665898703; Thu, 08 Sep 2022 12:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662665898; cv=none; d=google.com; s=arc-20160816; b=wZldXtuyHiJxGdyDrhHuDmbz5+/gR2w0WKNcLWd17CcxyunzFmxZ4DffuX3vhYuWHM wu4Ze8GzW4ZS6QOn54CJkjGPO4yP+jfeMPjVWHQI7Vy9ABfqJz3Fx6ym9Fpqo3ogYRNY OF3ypy6nLIP/w5DAzTuDvVAaulN6wABZz16GrGfqMTuBlEVt4nwlrlTdbZDjjyArynfb yK6LAvOb/80ziuLWmzQWQDGPvTkisYX08Akg3d4RN0Syp5hUNUfFUG57mJP9BawEXwCE 9UNsIKeVUj9yP8CeThMsvqZarfPAtMvzaTZhVLWWXEY8Peihb8awUoSDE2XFluljv9Qh smgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=O4urUyfiGdJyv28nhxclK5Fziywl5uchRNtfEllatqY=; b=afapUSCH6fTytvHjXUvDc5D9ed+WYXd1jZ0RatdLk/j6p4F31kFVEud9ud1Ik1XYOB ktLnjH8NkUd1vS3ouPTuiSSirvAwBq2W6wdnsXxcXHA+FCpJE4xG/5wgMXl5XdDP8nKk nKt+qPUoWKVlEorG9FyYJZfhLfpiaKG5rEJpff7bYRGbSvNIr+7e76XWCNlMqKOPWNfp ijasMASJ2L8MSC1qMsRDaXAVRY2D6daADME2PJL12mz5pZCqnzI5Ft0y+fHWZHzkCHBi zKJwSuJ1Z5h6UcwjjRhLvX/0AvG4OaZo9AaE8nh0NGKJcJWeNIqXtIcFDSG8NM8GMVix USKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=nSFkuydp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gm9-20020a17090b100900b0020043c89f31si3152385pjb.107.2022.09.08.12.38.06; Thu, 08 Sep 2022 12:38:18 -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=@google.com header.s=20210112 header.b=nSFkuydp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbiIHTBw (ORCPT + 99 others); Thu, 8 Sep 2022 15:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbiIHTBt (ORCPT ); Thu, 8 Sep 2022 15:01:49 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791E358B66 for ; Thu, 8 Sep 2022 12:01:48 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 66-20020a251145000000b006a7b4a27d04so12140451ybr.20 for ; Thu, 08 Sep 2022 12:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=O4urUyfiGdJyv28nhxclK5Fziywl5uchRNtfEllatqY=; b=nSFkuydpP6YjOzhEIc52xjkDtVbdI4kmXCtAq7yCXZcp2do/KumEGdDZoKPE05z/2v u2JGZXLhy9MP6gJaMfq37X/cpicPVL108yZsw/2OQimSjod/5s90g6SGxsQXNzaMpDsM XZXQwTZGSZ9ap2lVOT9shKtEm9K3z+roK/T7gS3mgdV+tUkx7vHn3u2UQK7LD58dcasi fQmNob4SRoltwHmggg/TYlGLnGLYyQJIZv40AoY1E1qcmQlEvvfyWt0OJcLWQlA7jyvn XuDA2zH5naXk9ff1EqXLin3O5w0WOEB9KW2kAvefe+5yKU9ilBRYWzQdpZ0h/R1/zI8G F7pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=O4urUyfiGdJyv28nhxclK5Fziywl5uchRNtfEllatqY=; b=oCLlDrWMODgSxnYRiDeb0dpEK1gsbirXh2DX0giDtHHrIvnorEv9GlP0RCbuD/iYNM yUTZyViipE8DBoML+TgfGhuD17RCBxt7un26ZcE4mtKBngKZ3QNY/KK2OxXTYMq2i2Mh ijyqOed//M9EcW2NZSaTkqxzNb3dqSPe0k1DKsEc62BzA5G31vTmp+lmFMyl8EgOwN5S 5UgjNMnhxA/Zmgaqjgni0VQtLVjJVCZKi4Z/SjDiFSn6A3Xx7JvE18YwaRb/8nGpN8N/ 4rwLa0HP+LbTtqm+t0hrcBvLLZ5iaTzPqkK2FFhgHfabNqTlpowXIXmSlRQdMp2WbSkp v3xg== X-Gm-Message-State: ACgBeo2lCHm5Ad/8EamRLC2rN67UCKUqvYprQtzoWQ/V7FQQ4mvb1XZd PTLfoj1Vv6EbkRQuoxkQ1Mxg11CVscsFgM6cFmHDDQ== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:66bd:4175:b3a6:1479]) (user=isaacmanjarres job=sendgmr) by 2002:a5b:9c4:0:b0:691:7745:afb5 with SMTP id y4-20020a5b09c4000000b006917745afb5mr8412716ybq.57.1662663707790; Thu, 08 Sep 2022 12:01:47 -0700 (PDT) Date: Thu, 8 Sep 2022 12:01:43 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220908190144.3731136-1-isaacmanjarres@google.com> Subject: [PATCH stable-4.14] driver core: Don't probe devices after bus_type.match() probe deferral From: "Isaac J. Manjarres" To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Marek Szyprowski , Russell King , Tomeu Vizoso , Ulf Hansson Cc: "Isaac J. Manjarres" , stable@vger.kernel.org, Saravana Kannan , Guenter Roeck , Linus Walleij , kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 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 --- drivers/base/dd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index fc27fab62f50..a7bcbb99e820 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -632,6 +632,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data) } 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; @@ -774,6 +779,11 @@ static int __driver_attach(struct device *dev, void *data) } 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; -- 2.37.2.789.g6183377224-goog