Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1100979rwe; Thu, 25 Aug 2022 15:44:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR596vpYibKMajwVHDKU+JqOID8JToTOSq+PyPiHf8x4UDxThmjVF57kzga8sZfyYRI9BKCL X-Received: by 2002:a17:90b:4a88:b0:1fb:36b7:7f8e with SMTP id lp8-20020a17090b4a8800b001fb36b77f8emr1263510pjb.22.1661467452536; Thu, 25 Aug 2022 15:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661467452; cv=none; d=google.com; s=arc-20160816; b=NxCxKbBmYs5xXN5sKffrY8oRrbK7Tj+xjoqebt3qLgtF7P4VkzrVpXXQv0SwhDIrwn bJG+HStIYGq1rvKgiOUhg+EBT9QEP94OGRHK40X72zfRbWRW4WhuKgTqH6t1d4ljEvLU +aADz0BQziesIubP7h/b4Ai84cEk/xHeijoJD6c6ZrfhJzX2CweBvn2bD1wEdFxTWFcu Qm07YElonpOlQhNxwKpijR045H/+5UJKp7p1jh2ZPLuJfNrjykyw4bLpHe1kXp8Ilode lSFGISqzdsnT1pyrryzrtriC5AYlw+B6gPjpBA5Zs2WOlU1GQN3WseBworgJelxXvCCH P5Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YLpy2xCVK51CZcFB6zrbiai4Ndy7eOAyjwmsLFCvyjU=; b=Ta9dYw/ZYLRmrsdNjA+5KG39Q5oUlUvtFEJU8EfDYnTuNqNrjWs8j7JBJDth/pA/uY PuazJfCehPgajvFzFFctmVacRFhUyf6VNPy4g8vpLYlmSPKpJ2+cMQW8Hf7Slx+G/u+5 vA3vPU5ZZdTwQCoTG3WZC4auDrm5GFyDfA+r4Gnl87w1AS0H2Lid3vZT3de5Ip1wP8qi ZYDouxO6PmUy/CcqYXNXxUJHXphejRRarXS+HRYMvVxh0W5DIaKwf8u65/9boJb9zt88 tlGp13XeSwALBAx7qk+d6OTnKX89YMRmPSda0+Oue7NigRpeipk5pipp4EyiF1hVvBDN BQdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RuNF59Ut; 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 y7-20020a63de47000000b0042a59edc558si292833pgi.244.2022.08.25.15.44.01; Thu, 25 Aug 2022 15:44:12 -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=RuNF59Ut; 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 S244332AbiHYWVF (ORCPT + 99 others); Thu, 25 Aug 2022 18:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244357AbiHYWVC (ORCPT ); Thu, 25 Aug 2022 18:21:02 -0400 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701F5C578C for ; Thu, 25 Aug 2022 15:21:00 -0700 (PDT) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-324ec5a9e97so576565337b3.7 for ; Thu, 25 Aug 2022 15:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=YLpy2xCVK51CZcFB6zrbiai4Ndy7eOAyjwmsLFCvyjU=; b=RuNF59UtgFixO6ATvPnw/me6kowb8cK+ihIPiN9YGvyGWowPWv82QGFElwUvI5+DKh 4bM5mWzcBhtKOSRx+2dmqP7D/25ANqTEvkNgxLoZ03wM+hqSBilKjjVQnTGCMzQRJvrf 7OmD4R3ZcaS+JouPbNz1nqMeUivjrGYpAJO8ghMB+GXoorGZxcOVY6c5N0xxdBtmHwFb rHW5lKM/+QFvdViqOupzGWdox6T1quWhzvQDszZN+5ppKABtqYAVc6ogO2655g3uO5Un hCeyKkvFIbcG4AOPpY0aWraEDTbF1LJtJDlAcDlsGMIQ8GNjJyqD7u1NEhxtgTZWs3Mh zQWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=YLpy2xCVK51CZcFB6zrbiai4Ndy7eOAyjwmsLFCvyjU=; b=nTsz73hiJAdOyaf9rae2OnCujpgrIgab3p2McUzbglCMn5EgCscCCC7+97hB9mgTRH VtWO2/CFYDE9d4jZao9+LpLmuOIT86ydDuPsv1cyCtR1TzQMgIyS02m/gWekW/FjZvbr CG5a81qaDiPKNeRG1KGtMreBFLVgKOpCGFf1Uqmlu+OOWiLK70wVuFP4XueJ5l8443ja /rMvNQlwSJckd2W2rZSKA1YxBAHtRiGDAVcXxfRfLg6YIM/ar5poBZumG8vcO9hzAm9E YDeQzpRGfVVhZVflgMjDbv4D4M8rVqJxHLf7ARR9P0uojUd6MAVLAZjw1FaQBSvkoOkL FDWA== X-Gm-Message-State: ACgBeo3AUG59DxEzR5enV2O5uRhtCZELMHSuapdX2F7xRHFkztIchDTH 4HaCJBpQgogAgnKSDVors0RNyU0Rm7l/GoD8wPf3Og== X-Received: by 2002:a25:bd4d:0:b0:696:489a:3a86 with SMTP id p13-20020a25bd4d000000b00696489a3a86mr3142761ybm.447.1661466059351; Thu, 25 Aug 2022 15:20:59 -0700 (PDT) MIME-Version: 1.0 References: <20220817184026.3468620-1-isaacmanjarres@google.com> In-Reply-To: <20220817184026.3468620-1-isaacmanjarres@google.com> From: Saravana Kannan Date: Thu, 25 Aug 2022 15:20:23 -0700 Message-ID: Subject: Re: [PATCH v3] driver core: Don't probe devices after bus_type.match() probe deferral To: "Isaac J. Manjarres" Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Russell King , Ulf Hansson , Marek Szyprowski , Tomeu Vizoso , stable@vger.kernel.org, Guenter Roeck , kernel-team@android.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_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 On Wed, Aug 17, 2022 at 11:40 AM Isaac J. Manjarres wrote: > > 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 > Greg, Can you pull this in for 6.0-rcX please? This is fixing a long standing bug that was exposed by my amba code cleanup. -Saravana