Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp5137001rwb; Wed, 17 Aug 2022 11:45:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Xbr7XiUheldmRgZsQNOnvU9LF8PldD0JgjAy0LxNdgcQ04Pgf7TbQxf1PLx25Iv4XiJgG X-Received: by 2002:a17:907:284a:b0:730:a1f1:38b5 with SMTP id el10-20020a170907284a00b00730a1f138b5mr16876113ejc.732.1660761903220; Wed, 17 Aug 2022 11:45:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660761903; cv=none; d=google.com; s=arc-20160816; b=VkY4uif+4IYipVqgeYRKDdnOEFs5MK/jusqseQtda7Yp8T0FZn7KtJBJI1bpsxmnya N90132B9g8wpFu7VBbZkwGtUgEv1xCl1YrvGkArJNVQZ45lKR06e6uJlLz+s+kITDBPa 7FUafmhZ0jh+Kfo2x4WGFppo/++8ua7Vhze8FmomEbEd3cGYv3phLDFlE+zm8aiISM8v VB0SAbQohdIJDHi2q2Lcq3zi0day7DDs6g17GoEoTyLWLhUYnablPYN7nFhFTnbtxLw2 KblFC6S/6d8LdoXP0vGFYoZ1OYwc+A8OZ4Su/YiqIsYNYAAxSKXsJGZ/fZaWsQ8vgiJx 4g8w== 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:mime-version:message-id:date :dkim-signature; bh=ZYTlBBFnaZ0P/8h1RW7JgkzBP7Qz3/ENWA74waVFHsk=; b=eLzmRfrU/vm8uW+hkB4BVSTxaX4YBZgvLerBJuPwF9puGtqpasAY/2M7u83UEAonwp Q/RdB9HzSVvijOmGPskuqaIDuf/W16w7NvMnI4FDvj5UEONgsmQFh9ltR4/OCIrM74x9 4s4sa9h6ACNYwUGMnjpwAyfbj57O9LffKxN6DEuZ2qEpUmddJalkoqS0+lpwfpBWNSqI 7RtzYcbCkSj7spazNKUjoPdmI0mNxVZ3lptMHEafmSYwyvirjaK9S9ows7LHap5x1fpF yO9DZF75dwxf2TrAui2ycpdC1J8m4iJ9EO+zbUgS494E24r7mViPJT6Rgk+mpIZMpZ4s TQVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rEKzgG4k; 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 hq18-20020a1709073f1200b007394b02127bsi4122033ejc.1002.2022.08.17.11.44.36; Wed, 17 Aug 2022 11:45:03 -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=rEKzgG4k; 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 S241097AbiHQSkt (ORCPT + 99 others); Wed, 17 Aug 2022 14:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241006AbiHQSko (ORCPT ); Wed, 17 Aug 2022 14:40:44 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCBB5A00EE for ; Wed, 17 Aug 2022 11:40:40 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d3-20020a170902cec300b0016f04e2e730so8595349plg.1 for ; Wed, 17 Aug 2022 11:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc; bh=ZYTlBBFnaZ0P/8h1RW7JgkzBP7Qz3/ENWA74waVFHsk=; b=rEKzgG4kB4gJbvdPUY9H+lfnRgqahefKDR5Jl73nA4WKGW5kwuqnE88uTY3v00RzaR P1XqUhHs+w6cV8koRkvS9gXHlJMZFkJO0Bj5DiMro7jSn6MbktfS4XD+brKZjtIQlDvb oF6nNCpMSlQJz8fcZfBUd8ryCNywZ6t4+gIMJS/wasIo4COpmd00eLTiu9rkzKnLBiyj jZPGnBjgNjAqfK+18xRawhoR/RLoAcl5bAavj+iTn+QzSSJGMAzogpo0nyPY7URheaJZ MLzzf2V3uR8cfruliPSKCDP2Qt73gUn9gGO7Y8hp82RFjbgulhTxsLFZyJSWboAG7dMI 6FIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc; bh=ZYTlBBFnaZ0P/8h1RW7JgkzBP7Qz3/ENWA74waVFHsk=; b=4DEc/FPpEpJtBVm6bYszy1nwW9He2md+d2JrxIlg65btQrxiWs9fUVmfnVih/HnKDc F+xKbdyR/8T6EeXHni8lz2KUdpvnTBscttYJEMhNkTA4Zh/oi2Ty/t7MXhTyFnMd3IVt RMW22JSAuVCZJ+3BfSrHUoUAnNY/XPogLrmOj6o9nQCsyh4IJ9HyC4yiJwl3GDRRu7Mm 8bOWf3YvPQX1hhCQyat3ZzA7D4z+WasCraF6mRcoL1LJKzVef6k8cOnIhIcF/jkPWlES MMdGLSq86hgACcQVUIBSVFs7IAZFzvowVMUZ8ioxCLN8eI/n6z2DvOS+nVERuougrNLZ wD2A== X-Gm-Message-State: ACgBeo3QswZia55bcIDNiSg7s3J03Mj/m/jxkaBJ2c/5+QsCYWrUTTSr kp8DMuauavvVFvj9Emt46CJDsS/YaaXqhYFZhXGU2w== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:6c6d:d00:f0dd:6ddf]) (user=isaacmanjarres job=sendgmr) by 2002:a17:90a:bf0a:b0:1fa:b53c:3f3a with SMTP id c10-20020a17090abf0a00b001fab53c3f3amr4095338pjs.126.1660761640140; Wed, 17 Aug 2022 11:40:40 -0700 (PDT) Date: Wed, 17 Aug 2022 11:40:26 -0700 Message-Id: <20220817184026.3468620-1-isaacmanjarres@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral From: "Isaac J. Manjarres" To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Russell King , Ulf Hansson , Marek Szyprowski , Tomeu Vizoso Cc: "Isaac J. Manjarres" , stable@vger.kernel.org, Saravana Kannan , Guenter Roeck , 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 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. Cc: stable@vger.kernel.org Cc: Saravana Kannan Fixes: 656b8035b0ee ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()") Reported-by: Guenter Roeck Signed-off-by: Isaac J. Manjarres Tested-by: Guenter Roeck Reviewed-by: Saravana Kannan --- drivers/base/dd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) v1 -> v2: - Fixed the logic in __driver_attach() to allow a driver to continue attempting to match and bind with devices in case of any error, not just probe deferral. v2 -> v3: - Restored the patch back to v1. - Added Guenter's Tested-by tag. - Added Saravana's Reviewed-by tag. - Cc'd stable@vger.kernel.org Greg, This is the final version of this patch. Can you please pick this up? Thanks, Isaac diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 70f79fc71539..90b31fb141a5 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -881,6 +881,11 @@ static int __device_attach_driver(struct device_driver *drv, void *_data) dev_dbg(dev, "Device match requests probe deferral\n"); dev->can_match = true; 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\n", ret); return ret; @@ -1120,6 +1125,11 @@ static int __driver_attach(struct device *dev, void *data) dev_dbg(dev, "Device match requests probe deferral\n"); dev->can_match = true; 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\n", ret); return ret; -- 2.37.1.595.g718a3a8f04-goog