Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5361320pxv; Wed, 7 Jul 2021 01:45:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4En5lSIUJFkYz/a8Ylexcord/x8m8ivqQMjiun+mcLPSFL64yhxRIFSgqGXtOI7c2z56f X-Received: by 2002:a50:cdcb:: with SMTP id h11mr28897755edj.366.1625647551681; Wed, 07 Jul 2021 01:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625647551; cv=none; d=google.com; s=arc-20160816; b=Y14JGvbTFOn20iWfhOsmR11CBsXGKmDjX2O/5XPLCS40xqsYBQw7CtEWiQP/GCjZ3n 7HlEutWIHfWc/W4DS3LgLijIPz+AkjykIm8eApe8wuXQPZmJAfi1k+IushzZ2ndicSj1 0b5d9D503vuMd307PAB5EHdyh39EIwAJ/ywyr7MVRMQ6R5Vys+iixIyQDzycXIrYMOna wM7Nm0LgPgYOqmvLO8Yr9lJZJmKxM9nA0E3QiNvPwH9YQF8oLYoadYy8MM084CyhfGRt LSLPxNvRtn+QOlCXFEczpQcj5EjsoQPtJjCAdeds4Ty6XjnuehsCw5h9MzvN7IHOBdJB yCzg== 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; bh=g/NUV0k0sKL15rnH03t063q9JhylHeH6MXLj7AK83z8=; b=CUfRjW6kJ5sl0x439wc1rx4UH0OffJ47ds+50jfm2c1ubBGMwzMbtC0b47SHOByB21 y7rZ1B1JAZ914v7ISeR67Um3UjR5eOwO2hikM6mZ4PaBZX/Zf0FZ3PeXnJ+Nokhdf0Jf q52zMNuxY8q2eC0YoC23yeWI/PRdxN3sVVrVIbPegvKqFUNlMrZuC+cVBXwEk7yZD9kH Cl+arsQx2L7oODnt27iqWaB8ef/VtVdz3Mmtcn1Qqul9W8X+TQDXWhEU0gwGFk64WUOm Xyhs0bvHhZw8xZvixnYtL4sQoSdd/0/SxBsAYG7iSFmpV6RTOy0uMiWCly7vP+o6YOsK zmXQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id er20si17789873ejc.491.2021.07.07.01.45.28; Wed, 07 Jul 2021 01:45:51 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbhGGIqE (ORCPT + 99 others); Wed, 7 Jul 2021 04:46:04 -0400 Received: from mail-vk1-f182.google.com ([209.85.221.182]:46011 "EHLO mail-vk1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhGGIqD (ORCPT ); Wed, 7 Jul 2021 04:46:03 -0400 Received: by mail-vk1-f182.google.com with SMTP id j190so416563vkg.12; Wed, 07 Jul 2021 01:43:23 -0700 (PDT) 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=g/NUV0k0sKL15rnH03t063q9JhylHeH6MXLj7AK83z8=; b=hGRzyERd1Ifu5U2xCx+uvaOeg+Gs4rSORmty/w3GQgjVSi+RVWdU9G9dyYQYAb+zyR JpwBfSl9ZzYEBqOzRhYELZUCcXGxln4QU9gv7ShLkTfCSywDByg18ltgjwcq551unoiK JuBxP3+aZArVDKvK1TUwHSF2xFIo86W2wmnE+cpcM4Z7R4hY1YT+So4aDqtvkLNHu58W sM0D/cpcRpiokO8V36rn2Mld1lvubjvEbTfIL2dfXTYB90vowqcjC7DfV2rYKO91dGKc Xd31hcB3N7LQD7kjUUlykRt3Pc2q4PkhtkMV3xm0YAOWwVJhBa/3D9t6K3YF+TjKqWlj zHNg== X-Gm-Message-State: AOAM533dxEZxOBLC4/IfpEPiqxI8p6cl8xafjIB3Mmld2xXg85Tp+Ojt BKfcMa9AEXC6XU+yr8TrfVib7UD5sfw9gNSI0Ss= X-Received: by 2002:a1f:1207:: with SMTP id 7mr520916vks.1.1625647403340; Wed, 07 Jul 2021 01:43:23 -0700 (PDT) MIME-Version: 1.0 References: <20210215111619.2385030-1-geert+renesas@glider.be> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 7 Jul 2021 10:43:12 +0200 Message-ID: Subject: Re: [PATCH] driver core: Fix double failed probing with fw_devlink=on To: Saravana Kannan Cc: "Rafael J. Wysocki" , 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 Hi Saravana, (going over old patch I still have in my local tree) On Tue, Feb 16, 2021 at 6:08 PM Saravana Kannan wrote: > On Mon, Feb 15, 2021 at 12:59 PM Saravana Kannan wrote: > > On Mon, Feb 15, 2021 at 11:08 AM Geert Uytterhoeven > > wrote: > > > 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. Turns out the issue I was seeing went away due to commit f2db85b64f0af141 ("driver core: Avoid pointless deferred probe attempts"), so there is no need to apply this patch. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds