Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5855664pxb; Tue, 16 Feb 2021 09:09:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQG7bDbmNDJvGaNq6CFc0/pWx0jtYQrEM20CL3zGylQgr1e1wWvOrqFcr8sv6jmXfgYvAd X-Received: by 2002:aa7:cb53:: with SMTP id w19mr17865372edt.324.1613495382789; Tue, 16 Feb 2021 09:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613495382; cv=none; d=google.com; s=arc-20160816; b=pMSVufuIodyqPy37btKN15gKtQM9cXcWNwtreFfR9YglTcdetYRn03UdgmDvFHa9X1 YbgnX1OsjZhJXLZ/HSJtTeJDKfSQmzUikakTzSEDdXSJafN4n29Y54ocOgJrkT3kllNJ nywL9d5TwIKlWPJgZNNbRamMjX89CUtPtXa9j68omnhbux2KiG2tBlxawXJBfxyaSM3J rFPhRv1AaSne3vp7TkF7RLYGXF0JLqZJDQJrPhuUsCUuxEWGH+sSt3AzPUWy7u50idyu Nz/dfFruKWGPwnpLIbtdKRImIpWfyWoL1e/8uXiG2vm0y3WiUprYyBBS5UAM71AaiD2C 8Wjg== 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=EOoT/2ZRzWvEXcLxuZ6fIHpjifNSP30Dl3Nv/8J4jR4=; b=y1wwD98cnDH4Fpok6DI/Tt/OdztKDwnHr8AdOEPZCcJKQiNzk5Lt1ABIiOYBGNY5Z/ 4zfH+D+ry04458JC1JS3q9X+T6hqhQ613ocBaCy9CxfndZPVl8e69lUSxnAwJdNqr8pw RcAokcaaDA89av06rBpHQfcDmKKya8ieji8Ibg7Rq5dkxLx9W+L2sp5ThbV8s8v1q26g IS/K0aHVjJaY/Ou3o0fSkTUZxXUOAb36mFUPHELrdGAA2raEGsBGLL74vm9pGubydzPn Lm4ZiDX7efKV9V/0M0n1xyfDHBJ3Pls+aOKVbLd8LA8oMm0q0qr4WF9KajVOs/mF6DD9 s2iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WdCXyIRk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si14754745ejy.191.2021.02.16.09.09.17; Tue, 16 Feb 2021 09:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WdCXyIRk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230248AbhBPRIp (ORCPT + 99 others); Tue, 16 Feb 2021 12:08:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229784AbhBPRIn (ORCPT ); Tue, 16 Feb 2021 12:08:43 -0500 Received: from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com [IPv6:2607:f8b0:4864:20::b2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B51A7C061756 for ; Tue, 16 Feb 2021 09:08:03 -0800 (PST) Received: by mail-yb1-xb2e.google.com with SMTP id y128so11094496ybf.10 for ; Tue, 16 Feb 2021 09:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EOoT/2ZRzWvEXcLxuZ6fIHpjifNSP30Dl3Nv/8J4jR4=; b=WdCXyIRke16cMJsDa3zli6lc0UjF1wpzWcCkHwpauoeANh/CWtv98wK+NlR53jpmEX fPUsPo82SM1O6aRxFbpsrJT1mwlDapMcy4Qaeqd7Mys422WEBikk+gmxH/XKf9inqEqi FZ0g+OW/dTEtg7kiq5XU6pPJjXsFWS196dc0wPOzE7MKFPuMZJy6dzzF7YtZJHmHZLaU go80z7YdKCWqvAK4Z+0DLZ40C/Oy1AFuRWSgcJadSe7GXBXTu3iXLx4MepBGcuunexFf NL1IghxDsoc71++IbB58tXt/KXrRsnLMW4NBtz4QTQ3eJPKAyPwzoWVj1kFdqZlCmMDP zVOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EOoT/2ZRzWvEXcLxuZ6fIHpjifNSP30Dl3Nv/8J4jR4=; b=akyCcUTZk/8CP2kc//TJ/KXS2YqbKLSAKQLyCndOUC9uTHeDxbJnMlYD7YceM3RKAz VzFe2RfiueM/uBJ43DmYy+8kbKaLCWCMtO0R4h5YA9Vtr3DFHPmsYzN2NcEmyGxsVuZb zdJJ5LKawdeuuDgJ/X8j0m9RVQYCwo4EyEtn6DNabGxWyjOghYqNlej5BgoXQyoE+Bmu Q+wY+znUIcKvOGhZPKLhul9CkndHpMOvTfYFgkUvvvKJDnsOAOu0NqHW8NjhjtrL8oWO 3O+78N5SzO9uiVlfhsLPSysrTg/6a0hTOz8kSe1Rf3DPTolV4MlL2w3PrWmGFDV+uZ9m TI+A== X-Gm-Message-State: AOAM5328aQQN/dpTabHwbmRJLkuQabGwxXobW9E9KpCx61QIhVzLmdhi 82LmimvF1QILoSSC+yT4bcJ9K2maL89IPytPFtUwEg== X-Received: by 2002:a25:3345:: with SMTP id z66mr31002234ybz.466.1613495282718; Tue, 16 Feb 2021 09:08:02 -0800 (PST) MIME-Version: 1.0 References: <20210215111619.2385030-1-geert+renesas@glider.be> In-Reply-To: From: Saravana Kannan Date: Tue, 16 Feb 2021 09:07:26 -0800 Message-ID: Subject: Re: [PATCH] driver core: Fix double failed probing with fw_devlink=on To: Geert Uytterhoeven Cc: "Rafael J. Wysocki" , Geert Uytterhoeven , Greg Kroah-Hartman , Linux-Renesas , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 15, 2021 at 12:59 PM Saravana Kannan wrote: > > On Mon, Feb 15, 2021 at 11:08 AM Geert Uytterhoeven > wrote: > > > > Hi Saravana, > > > > On Mon, Feb 15, 2021 at 7:27 PM Saravana Kannan wrote: > > > On Mon, Feb 15, 2021 at 6:59 AM Rafael J. Wysocki wrote: > > > > On Mon, Feb 15, 2021 at 12:16 PM Geert Uytterhoeven > > > > wrote: > > > > > With fw_devlink=permissive, devices are added to the deferred probe > > > > > pending list if their driver's .probe() method returns -EPROBE_DEFER. > > > > > > > > > > With fw_devlink=on, devices are added to the deferred probe pending list > > > > > if they are determined to be a consumer, > > > > > > If they are determined to be a consumer or if they are determined to > > > have a supplier that hasn't probed yet? > > > > When the supplier has probed: > > > > bus: 'platform': driver_probe_device: matched device > > e6150000.clock-controller with driver renesas-cpg-mssr > > bus: 'platform': really_probe: probing driver renesas-cpg-mssr > > with device e6150000.clock-controller > > PM: Added domain provider from /soc/clock-controller@e6150000 > > driver: 'renesas-cpg-mssr': driver_bound: bound to device > > 'e6150000.clock-controller' > > platform e6055800.gpio: Added to deferred list > > [...] > > platform e6020000.watchdog: Added to deferred list > > [...] > > platform fe000000.pcie: Added to deferred list > > > > > > > which happens before their > > > > > driver's .probe() method is called. If the actual probe fails later > > > > > (real failure, not -EPROBE_DEFER), the device will still be on the > > > > > deferred probe pending list, and it will be probed again when deferred > > > > > probing kicks in, which is futile. > > > > > > > > > > Fix this by explicitly removing the device from the deferred probe > > > > > pending list in case of probe failures. > > > > > > > > > > Fixes: e590474768f1cc04 ("driver core: Set fw_devlink=on by default") > > > > > Signed-off-by: Geert Uytterhoeven > > > > > > > > Good catch: > > > > > > > > Reviewed-by: Rafael J. Wysocki > > > > > > The issue is real and needs to be fixed. But I'm confused how this can > > > happen. We won't even enter really_probe() if the driver isn't ready. > > > We also won't get to run the driver's .probe() if the suppliers aren't > > > ready. So how does the device get added to the deferred probe list > > > before the driver is ready? Is this due to device_links_driver_bound() > > > on the supplier? > > > > > > Can you give a more detailed step by step on the case you are hitting? > > > > The device is added to the list due to device_links_driver_bound() > > calling driver_deferred_probe_add() on all consumer devices. > > Thanks for the explanation. Maybe add more details like this to the > commit text or in the code? > > For the code: > Reviewed-by: Saravana Kanna Ugh... I just realized that I might have to give this a Nak because of bad locking in deferred_probe_work_func(). The unlock/lock inside the loop is a terrible hack. If we add this patch, we can end up modifying a linked list while it's being traversed and cause a crash or busy loop (you'll accidentally end up on an "empty list"). I ran into a similar issue during one of my unrelated refactors. -Saravana